index.js
7 lines
| 1 | /*! For license information please see index.js.LICENSE.txt */ |
| 2 | (()=>{"use strict";var e,t={2203:(e,t,n)=>{var r,a,o,i,c,l=n(6488),u=n(5945),s=n(7098),f=n(8575),m=n(6160),d=n(2110),p=n(1630),h=n(4694),y=n(1497),v=n(8168),g=n(9317),E=n(1488),b=n(7818),w=n(146),R=n(8694),O=mwai.prefix,x=mwai.domain,T=mwai.rest_url.replace(/\/+$/,""),S=mwai.api_url.replace(/\/+$/,""),_=mwai.plugin_url.replace(/\/+$/,""),N="1"===mwai.is_pro,L=N&&"1"===mwai.is_registered,k=mwai.rest_nonce,C=mwai.options,P=mwai.session,A=(mwai.pricing,n(8406)),I=n(2788);function M(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var j=I.ZP.div(r||(r=M(["\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,I.ZP)(w.v)(a||(a=M(["\n\n .neko-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 .neko-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 margin-top: 5px;\n font-size: 13px;\n line-height: 1.2;\n }\n }\n"]))),F=I.ZP.img(o||(o=M(["\n width: 85px;\n height: 85px;\n padding-right: 10px;\n"]))),D=I.ZP.div(i||(i=M(["\n\n margin: 15px;\n\n .center {\n background: white;\n color: black;\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"]))),U=I.ZP.ul(c||(c=M(["\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 color: black;\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 B(e){return B="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},B(e)}function H(){H=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==B(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 z(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 Y(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){z(o,r,a,i,c,"next",e)}function c(e){z(o,r,a,i,c,"throw",e)}i(void 0)}))}}function W(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)||Z(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 Z(e,t){if(e){if("string"==typeof e)return q(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)?q(e,t):void 0}}function q(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,K=V.useState,J=V.useEffect,$="".concat(T,"/meow-common/v1"),X=function(e){var t=e.request,n=e.title,r=e.max,a=W(K(!1),2),o=a[0],i=a[1],c=W(K([]),2),l=c[0],u=c[1],s=l.length>0?l.reduce((function(e,t){return e+t})):0,f=l.length>0?Math.ceil(s/l.length):0,d=!l.length&&o;return J((function(){o&&setTimeout(Y(H().mark((function e(){var n,r,a;return H().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=(new Date).getTime(),e.next=3,(0,R.PV)("".concat($,"/").concat(t),{method:"POST",nonce:k});case 3:r=(new Date).getTime(),a=r-n,u((function(e){return[].concat(function(e){if(Array.isArray(e))return q(e)}(t=e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||Z(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(j,{style:{width:200,textAlign:"center"}},React.createElement(m.O,{h2:!0,style:{color:"white"}},n),React.createElement(A._,{size:200,value:d?r:f,max:r},React.createElement("span",{style:{fontSize:20}},d?"START":f+" ms"),React.createElement("span",{style:{fontSize:12}},d?"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 Q(e){return Q="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},Q(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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==Q(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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"!==Q(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==Q(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===Q(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;S&&T&&_||console.error("[@common/dashboard] apiUrl, restUrl and pluginUrl are mandatory.");var fe="".concat(T,"/meow-common/v1"),me=React.createElement(j,null,React.createElement(m.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://jordymeow.com"},"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"),".")),de=React.createElement(j,null,React.createElement(m.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(m.O,{p:!0},"⭐️ ",React.createElement("b",null,"File Operation Time")," creates a temporary size of 10MB every time."),React.createElement(m.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(j,null,React.createElement(m.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"))))),he=["".concat(fe,"/all_settings/"),{headers:{"X-WP-Nonce":k}}],ye=function(){var e=ie(ue(!1),2),t=e[0],n=e[1],r=(0,f.ZP)(he,R.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,s=ie(ue(!1),2),O=s[0],x=s[1],T=ie(ue([]),2),S=T[0],_=T[1],N=ie(ue(""),2),L=N[0],C=N[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 P=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,console.log({value:t,id:n,newSettingsData:r}),o(ne(ne({},a),{},{data:r}),!1),x(!0),e.next=7,(0,R.PV)("".concat(fe,"/update_option"),{method:"POST",nonce:k,json:{name:n,value:t}});case 7:i=e.sent,x(!1),i.success||alert(i.message),o();case 11: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 x(!0),e.next=3,(0,R.PV)("".concat(fe,"/error_logs"),{method:"POST",nonce:k});case 3:t=e.sent,n=t&&t.data?t.data:[],_(n.reverse()),x(!1);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),I=React.createElement(d.r,{title:"Main Menu"},React.createElement(p.l,{max:"1"},React.createElement(h.P,{name:"meowapps_hide_meowapps",label:"Hide (Not Recommended)",description:React.createElement(m.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:O,checked:l,onChange:P}))),M=React.createElement(d.r,{title:"SSL Verify"},React.createElement(p.l,{max:"1"},React.createElement(h.P,{name:"force_sslverify",label:"Force (Not Recommended)",description:React.createElement(m.O,{p:!0},"This will enforce the usage of SSL when checking the license or updating the plugin."),value:"1",disabled:O,checked:u,onChange:P})));return React.createElement(y.s,{showRestError:t},React.createElement(v.B,{title:"The Dashboard"}),React.createElement(g.o,null,React.createElement(g.z,{full:!0},React.createElement(E.c,null,React.createElement(E.P,{title:"Meow Apps"},me,React.createElement(g.o,null,React.createElement(g.z,{minimal:!0},React.createElement(G,{title:"AI Engine",className:"primary"},React.createElement(F,{src:"https://ps.w.org/ai-engine/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/ai-engine/"},"AI Engine")),React.createElement("p",null,"GPT for WordPress. ChatGPT chatbot, image & content generator, finetune/train models, etc. Ultra customizable, extensible, sleek UI. You will love it!"))),React.createElement(G,{title:"Media Cleaner",className:"primary"},React.createElement(F,{src:"https://ps.w.org/media-cleaner/assets/icon-256x256.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,"Clean your WordPress! Eliminate unused and broken media files. For a faster, and better website."))),React.createElement(G,{title:"Database Cleaner",className:"primary"},React.createElement(F,{src:"https://ps.w.org/database-cleaner/assets/icon-256x256.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,"Not only does Database Cleaner have a user-friendly UI, but it's also equipped to handle large DBs, giving it an edge over other plugins."))),React.createElement(G,{title:"Media File Renamer",className:"primary"},React.createElement(F,{src:"https://ps.w.org/media-file-renamer/assets/icon-256x256.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 and move files directly from the dashboard, manually, automatically or via AI, either individually or in bulk."))),React.createElement(G,{title:"Social Engine",className:"primary"},React.createElement(F,{src:"https://ps.w.org/social-engine/assets/icon-256x256.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,"Effortlessly schedule and automate the perfect posts for all your networks. Unlimited capabilities and infinite extensibility, for free!"))),React.createElement(G,{title:"Meow Analytics",className:"primary"},React.createElement(F,{src:"https://ps.w.org/meow-analytics/assets/icon-256x256.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(g.z,{minimal:!0},React.createElement(G,{title:"Photo Engine",className:"primary"},React.createElement(F,{src:"https://ps.w.org/wplr-sync/assets/icon-256x256.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(F,{src:"https://ps.w.org/meow-gallery/assets/icon-256x256.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(F,{src:"https://ps.w.org/meow-lightbox/assets/icon-256x256.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(F,{src:"https://ps.w.org/wp-retina-2x/assets/icon-256x256.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,"Manage, Optimize, Replace your images with Perfect Images."))),React.createElement(G,{title:"Contact Form Block",className:"primary"},React.createElement(F,{src:"https://ps.w.org/contact-form-block/assets/icon-256x256.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,{title:"Contact Form Block",className:"primary"},React.createElement(F,{src:"https://ps.w.org/seo-kiss/assets/icon-256x256.png"}),React.createElement("div",{className:"plugin-desc"},React.createElement("h2",null,React.createElement("a",{target:"_blank",href:"https://wordpress.org/plugins/seo-kiss/"},"SEO Kiss (Keep It Simple Stupid SEO)")),React.createElement("p",null,"Optimize your content for SEO. Keep everything simple and fast.")))))),React.createElement(E.P,{title:"Performance"},de,React.createElement("div",{style:{display:"flex",justifyContent:"space-around",marginBottom:25}},React.createElement(X,{title:"Empty Request Time",request:"empty_request",max:2500}),React.createElement(X,{title:"File Operation Time",request:"file_operation",max:2600}),React.createElement(X,{title:"SQL Request Time",request:"sql_request",max:2800})),pe),React.createElement(E.P,{title:"PHP Info"},React.createElement(D,{dangerouslySetInnerHTML:{__html:L}})),React.createElement(E.P,{title:"PHP Error Logs"},React.createElement(j,null,React.createElement(b._,{style:{marginBottom:10},color:"#ccb027",onClick:A},"Load PHP Error Logs"),React.createElement(U,null,S.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(m.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(E.P,{title:"Settings"},React.createElement(w.v,{title:"Settings",className:"primary"},I,M))))))},ve=n(3565),ge=n(1492),Ee=n(2719),be=n(2622),we=n(3895),Re=n(3506),Oe=n(3103),xe=n(8178),Te=n(477),Se=n(1203);function _e(e){return _e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_e(e)}function Ne(){Ne=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==_e(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 Le(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 ke(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Le(o,r,a,i,c,"next",e)}function c(e){Le(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Ce(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 Pe(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)?Pe(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 Pe(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 Ae=wp.element,Ie=Ae.useState,Me=Ae.useEffect,je="".concat(T,"/meow-licenser/").concat(O,"/v1"),Ge=function(){var e=Ce(Ie(!1),2),t=e[0],n=e[1],r=Ce(Ie(!1),2),a=r[0],o=r[1],i=Ce(Ie(null),2),c=i[0],l=i[1],u=Ce(Ie(null),2),s=u[0],f=u[1],d=Ce(Ie(""),2),p=d[0],h=d[1],y=L&&(!s||"valid"!==s.license),v=function(){var e=ke(Ne().mark((function e(){var t;return Ne().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(N){e.next=2;break}return e.abrupt("return");case 2:return n(!0),e.next=5,(0,R.PV)("".concat(je,"/get_license"),{method:"POST",nonce:k});case 5:t=e.sent,f(t.data),t.data.key&&h(t.data.key),n(!1);case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),g=function(){var e=ke(Ne().mark((function e(){return Ne().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n(!0),e.next=3,(0,R.PV)("".concat(je,"/set_license"),{method:"POST",nonce:k,json:{serialKey:null}});case 3:e.sent.success&&(h(""),f(null),l("licenseRemoved")),n(!1);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),E=function(){var e=ke(Ne().mark((function e(){var t;return Ne().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n(!0),e.next=3,(0,R.PV)("".concat(je,"/set_license"),{method:"POST",nonce:k,json:{serialKey:p,override:!0}});case 3:(t=e.sent).success&&(f(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)}}(),O=function(){var e=ke(Ne().mark((function e(){var t;return Ne().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("MEOW_OVERRIDE"!==p){e.next=5;break}return o(!0),f(null),h(""),e.abrupt("return");case 5:return n(!0),e.next=8,(0,R.PV)("".concat(je,"/set_license"),{method:"POST",nonce:k,json:{serialKey:p}});case 8:(t=e.sent).success&&(f(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)}}();Me((function(){v()}),[]);var x=y?"Forced License":L?"Enabled":"Disabled",T=y||s&&"valid"===s.license,S="Your license is active. Thanks a lot for your support :)";y&&(S="This license has been force-enabled for you.",s&&s.check_url&&(S=React.createElement(React.Fragment,null,React.createElement("span",null,S),React.createElement("br",null),React.createElement("small",null,"To check your license status, please click ",React.createElement("a",{target:"_blank",href:s.check_url+"&cache="+642e3*Math.random()},"here"),".")))),T||(s?"no_activations_left"===s.issue?S=React.createElement("span",null,"There are no activations left for this license. You can visit your account at ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com"},"Meow Apps"),", unregister a site, and click on ",React.createElement("i",null,"Retry to validate"),"."):"expired"===s.issue?S=React.createElement("span",null,"Your license has expired. You can get another license or renew the current one by visiting your account at ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com"},"Meow Apps"),"."):"missing"===s.issue?S="This license does not exist.":"disabled"===s.issue?S="This license has been disabled.":"item_name_mismatch"===s.issue?S="This license seems to be for a different plugin... isn't it? :)":"forced"===s.issue?S="ABC":(S=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})):S="Unknown error :(");var _=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 ",React.createElement("a",{target:"_blank",rel:"noreferrer",href:"https://meowapps.com/"},"Meow Apps"),"."),C=React.createElement(w.v,{title:"Pro Version (".concat(x,")"),busy:t,className:"primary"},!y&&!(s&&s.key===p)&&React.createElement(React.Fragment,null,React.createElement("div",{style:{marginBottom:10}},"License Key:"),React.createElement(ge.A,{id:"mfrh_pro_serial",name:"mfrh_pro_serial",disabled:t,value:p,onChange:function(e){return h(e)},placeholder:"Type your license key..."}),React.createElement(m.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.")),s&&!T&&React.createElement(Re.S,{variant:"danger"},S),(y||s)&&T&&React.createElement(Re.S,{variant:"success"},S),React.createElement("div",{style:{marginTop:15,display:"flex",justifyContent:"end"}},s&&!T&&React.createElement(b._,{className:"secondary",disabled:t||!p,onClick:O},"Retry to validate"),s&&s.key===p&&React.createElement(b._,{className:"secondary",disabled:t||!p,onClick:g},"Remove License"),React.createElement(b._,{disabled:t||!p||s&&s.key===p,onClick:O},"Validate License"),a&&!T&&React.createElement(b._,{disabled:t||!p||s&&s.key===p,onClick:E,className:"danger"},"Force License")),React.createElement(Se.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(Se.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 N?C:_};const{__:Fe}=wp.i18n,De={};De.COMMON={MODULES:Fe("Modules","ai-engine"),SETTINGS:Fe("Settings","ai-engine"),CHATBOT:Fe("Chatbot","ai-engine"),CHATBOT_HELP:Fe("Highly customizable chatbot.","ai-engine"),STATISTICS:Fe("Statistics","ai-engine"),STYLE:Fe("Style","ai-engine"),ENABLE:Fe("Enable","ai-engine"),NAME:Fe("Name","ai-engine"),SUBMIT:Fe("Submit","ai-engine"),MODEL:Fe("Model","ai-engine"),TEMPERATURE:Fe("Temperature","ai-engine"),MAX_TOKENS:Fe("Max Tokens","ai-engine"),STOP_SEQUENCE:Fe("Stop Sequence","ai-engine"),MODE:Fe("Mode","ai-engine"),CONTEXT:Fe("Context","ai-engine"),IMAGES_NUMBER:Fe("Number of Images","ai-engine"),AI_NAME:Fe("AI Name","ai-engine"),USER_NAME:Fe("User Name","ai-engine"),PLACEHOLDER:Fe("Placeholder","ai-engine"),START_SENTENCE:Fe("Start Sentence","ai-engine"),SEND:Fe("Send","ai-engine"),CLEAR:Fe("Clear","ai-engine"),SYSTEM_NAME:Fe("System Name","ai-engine"),ID:Fe("ID","ai-engine"),POPUP:Fe("Popup","ai-engine"),POSITION:Fe("Position","ai-engine"),ICON_TEXT:Fe("Icon Text","ai-engine"),FULL_SCREEN:Fe("Full Screen","ai-engine"),CASUALLY_FINE_TUNED:Fe("Casually Fine-Tuned","ai-engine"),CONTENT_AWARE:Fe("Content Aware","ai-engine"),SPACING:Fe("Spacing","ai-engine"),BORDER_RADIUS:Fe("Border Radius","ai-engine"),FONT_SIZE:Fe("Font Size","ai-engine"),FONT_COLOR:Fe("Font Color","ai-engine"),BACK_PRIMARY_COLOR:Fe("Back Primary Color","ai-engine"),BACK_SECONDARY_COLOR:Fe("Back Secondary Color","ai-engine"),HEADER_BUTTONS_COLOR:Fe("Header Buttons Color","ai-engine"),POPUP_ICON:Fe("Popup Icon","ai-engine"),CUSTOM_ICON_URL:Fe("Custom Icon URL","ai-engine"),FEATURES:Fe("Features","ai-engine"),TIMEFRAME:Fe("Timeframe","ai-engine"),ABSOLUTE:Fe("Absolute","ai-engine"),NONE:Fe("None","ai-engine"),EDITORS_ADMINS:Fe("Editors & Admins","ai-engine"),ADMINS_ONLY:Fe("Admins Only","ai-engine"),CREDITS:Fe("Credits","ai-engine"),TYPE:Fe("Type","ai-engine"),USERS:Fe("Users","ai-engine"),GUESTS:Fe("Guests","ai-engine"),OPENAI:Fe("Open AI","ai-engine"),LICENSE_TAB:Fe("License","ai-engine"),FINETUNES:Fe("Finetunes","ai-engine"),MODELS:Fe("Models","ai-engine"),DATASETS:Fe("Datasets","ai-engine"),ASSISTANTS:Fe("Assistants","ai-engine"),POSTS_SUGGESTIONS:Fe("Suggestions (Titles & Excerpts)","ai-engine"),POSTS_SUGGESTIONS_HELP:Fe("Generate suggestions based on the content.","ai-engine"),GENERATORS:Fe("Generators","ai-engine"),WOOCOMMERCE_PRODUCT_GENERATOR:Fe("WooCommerce Product Generator","ai-engine"),WOOCOMMERCE_PRODUCT_GENERATOR_HELP:Fe("Write all the WooCommerce fields for a given product.","ai-engine"),CONTENT_GENERATOR:Fe("Content Generator","ai-engine"),CONTENT_GENERATOR_HELP:Fe("Generate articles. Support templates.","ai-engine"),IMAGES_GENERATOR:Fe("Images Generator","ai-engine"),IMAGES_GENERATOR_HELP:Fe("Generate images. Support templates.","ai-engine"),PLAYGROUND:Fe("Playground","ai-engine"),PLAYGROUND_HELP:Fe("Play with AI or let it perform various tasks for you. Support templates.","ai-engine"),FORMS:Fe("Forms","ai-engine"),FORMS_HELP:Fe("Build AI forms. Based on fields, users will be given answers or suggestions.","ai-engine"),STATISTICS:Fe("Statistics","ai-engine"),STATISTICS_HELP:Fe("Track AI interactions, check statistics, set limits, and more!","ai-engine"),DEBUG_MODE:Fe("Debug Mode","ai-engine"),DEBUG_MODE_HELP:Fe("Debugging information will be displayed in the console.","ai-engine"),API_KEY:Fe("API Key","ai-engine"),API_KEY_HELP:Fe('You can get your API Keys in your <a href="https://beta.openai.com/account/api-keys" target="_blank">OpenAI Account</a>.',"ai-engine"),USAGE_COSTS_HELP:Fe('For the exact amounts, please check your <a href="https://beta.openai.com/account/usage" target="_blank">OpenAI account</a>.',"ai-engine"),USAGE_COSTS_PRO_HELP:Fe('If you would like to have better control on the amounts, add conditions or set limits to the usage of the AI, consider <a href="https://meowapps.com/ai-engine/" target="_blank">AI Engine Pro</a>.',"ai-engine"),LANGUAGE:Fe("Language","ai-engine"),HIDE:Fe("Hide","ai-engine"),SHOW:Fe("Show","ai-engine"),CONTENT:Fe("Content","ai-engine"),EXCERPT:Fe("Excerpt","ai-engine"),GENERATE:Fe("Generate","ai-engine"),MODEL_PARAMS:Fe("Model Params","ai-engine"),PROMPT:Fe("Prompt","ai-engine"),PROMPTS:Fe("Prompts","ai-engine"),LABEL:Fe("Label","ai-engine"),SYSTEM:Fe("System","ai-engine"),SHORTCODE:Fe("Shortcode","ai-engine"),SHORTCODES:Fe("Shortcodes","ai-engine"),RESOLVE:Fe("Resolve","ai-engine"),SENTENCES_BUFFER:Fe("Sentences Buffer","ai-engine"),INPUT_MAXLENGTH:Fe("Input Max Length","ai-engine"),COMPLIANCE_TEXT:Fe("Compliance Text","ai-engine"),MODERATION:Fe("Moderation","ai-engine"),MODERATION_HELP:Fe("Moderation features with AI.","ai-engine"),FORMATTING:Fe("Formatting","ai-engine"),FORMATTING_HELP:Fe("Convert the reply from the AI into HTML. <b>Markdown is supported, so it is highly recommended to add 'Use Markdown.' in your context.</b>","ai-engine"),LOGS:Fe("Logs","ai-engine"),CODE:Fe("Code","ai-engine"),EMBEDDINGS:Fe("Embeddings","ai-engine"),EMBEDDINGS_HELP:Fe("Create searchable data that can be reused to feed the chatbot and other AI or UI elements.","ai-engine"),EMBEDDINGS_APIKEY_HELP:Fe('You can get your API Keys in your <a href="https://app.pinecone.io/organizations/keys" target="_blank">Pinecone Account</a>.',"ai-engine"),SERVER:Fe("Server","ai-engine"),SERVER_HELP:Fe("The region which was set for your account.","ai-engine"),COST:Fe("Cost","ai-engine"),USAGE_COSTS:Fe("Usage Costs","ai-engine"),AUDIO_TRANSCRIPTION:Fe("Audio-to-Text","ai-engine"),AUDIO_TRANSCRIPTION_HELP:Fe("Transcribe audio files into texts.","ai-engine"),AUDIO_TAB:Fe("Audio","ai-engine"),EMBEDDINGS_INDEX:Fe("Embeddings Index","ai-engine"),NAMESPACE:Fe("Namespace","ai-engine"),NAMESPACE_HELP:Fe("The namespace is used to separate the data from other data. This allows you to use the same index on more than one website.","ai-engine"),ERROR:Fe("Error","ai-engine"),RETRY:Fe("Retry","ai-engine"),AUTO_RETRY:Fe("Auto Retry","ai-engine"),SKIP:Fe("Skip","ai-engine"),AUTO_SKIP:Fe("Auto Skip","ai-engine"),STOP:Fe("Stop","ai-engine"),AUTO_RETRY_DESCRIPTION:Fe("Auto Retry retries actions up to 10 times with increasing delay to avoid timeouts.","ai-engine"),WIDTH:Fe("Width","ai-engine"),MAX_HEIGHT:Fe("Max Height","ai-engine"),TECHNICAL_SETTINGS:Fe("Technical Settings","ai-engine"),MAIN_SETTINGS:Fe("Main Settings","ai-engine"),VISUAL_SETTINGS:Fe("Visual Settings","ai-engine"),DASHBOARD:Fe("Dashboard","ai-engine"),ADVANCED:Fe("Advanced","ai-engine"),DYNAMIC_MAX_TOKENS:Fe("Dynamic Max Tokens","ai-engine"),DISCUSSIONS:Fe("Discussions","ai-engine"),ROWS:Fe("Rows","ai-engine"),POST_TYPE:Fe("Post Type","ai-engine")},De.FORMS={PROMPT_INFO:Fe('The template of your prompt. To re-use the data entered by the user, use the name of that field between curly braces. Example: Recommend me {MUSIC_TYPE} artists. You can also use an ID as an input, like this: ${#myfield}. Finally, if you wish the output to be formatted, add: Use Markdown format."',"ai-engine"),OUTPUT:Fe("Output","ai-engine"),OUTPUT_ELEMENT:Fe("Output Element","ai-engine"),OUTPUT_ELEMENT_INFO:Fe("The result will be written to this element. If you wish to simply display the result in an Output Block, use its ID. For instance, if its ID is mwai-666, use '#mwai-666'.","ai-engine")},De.HELP={TEMPERATURE:Fe("Between 0 and 1. Higher values means the model will take more risks.","ai-engine"),MAX_TOKENS:Fe("The maximum number of tokens to generate. The model will stop generating once it hits this limit.","ai-engine"),STOP_SEQUENCE:Fe("The sequence of tokens that will cause the model to stop generating text. You absolutely need this with fine-tuned models.","ai-engine"),COST:Fe("Keeps track of the current costs.","ai-engine"),RESOLVE_SHORTCODE:Fe("Will resolve the shortcode in your content when needed (Content-Aware will use this, for instance).","ai-engine"),DYNAMIC_MAX_TOKENS:Fe("Max Tokens will be dynamically decreased based on the length of the prompt.","ai-engine"),FINETUNES:Fe("Train your own AI models.","ai-engine"),DISCUSSIONS:Fe("Keep the conversations and enable browsing them via the Conversations tab.","ai-engine")},De.SETTINGS={OPENAI_SETUP:Fe('To use the features of AI Engine, you need an OpenAI account and an API Key. Visit the <a href="https://beta.openai.com/account/api-keys" target="_blank">OpenAI</a> website to create an account, then insert your OpenAI API Key in the <b>Settings</b> tab.',"ai-engine"),PINECONE_SETUP:Fe('You choose to use Embeddings. To use them, you need to a Pinecone account. Visit the <a href="https://app.pinecone.io" target="_blank">Pinecone</a> website to create an account, then insert your Pinecone API Key in the <b>Settings</b> tab.',"ai-engine"),INTRO:Fe('Boost your WordPress with AI! Don\'t forget to visit the <a href="https://meowapps.com/ai-engine/" target="_blank">AI Engine website</a> for more information. Have fun! 🎵',"ai-engine"),MODULES_INTRO:Fe("To avoid cluttering the UI and your WP, only enable the features you need.","ai-engine"),ALERT_INJECT_BUT_NO_POPUP:Fe("You choose to inject the chatbot in your website. You probably also want to use the chatbot in a Popup.","ai-engine"),ALERT_FINETUNE_BUT_NO_CASUALLY:Fe("You choose a fine-tuned model. However, you didn't check the Casually Fine Tuned option. Make sure that's what you want.","ai-engine"),ALERT_CASUALLY_BUT_NO_FINETUNE:Fe("Normally, you should not check the Casually Fine Tuned option with a non-finetuned model. Make sure that's what you want.","ai-engine"),ALERT_CONTENTAWARE_BUT_NO_CONTENT:Fe('Content Aware requires your Context to use the {CONTENT} placeholder. It will be replaced by the content of page the chatbot is on. More info <a href="https://meowapps.com/ai-engine/tutorial/#contextualization" target="_blank">here</a>.',"ai-engine"),SET_AS_DEFAULT_PARAMETERS:Fe("Set as Default Parameters","ai-engine"),SET_AS_DEFAULT_PARAMETERS_HELP:Fe("Set the parameters above as the default parameters for the chatbot. You can then use the shortcode [mwai_chat] anywhere on your website.","ai-engine"),INJECT_DEFAULT_CHATBOT:Fe("Inject Default Chatbot in Entire Website","ai-engine"),INJECT_DEFAULT_CHATBOT_HELP:Fe("Inject the chatbot [mwai_chat] in the entire website.","ai-engine"),CHATGPT_STYLE_INTRO:Fe('Keep in mind that you can also style the chatbot (or a specific chatbot, if you use many) by injecting CSS. Have a look <a target="_blank" href="https://meowapps.com/ai-engine/tutorial/#apply-custom-style-to-the-chatbot">here</a>. More information in the <a target="_blank" href="https://meowapps.com/ai-engine/faq">FAQ</a>.',"ai-engine"),TYPEWRITER_EFFECT:Fe("Typewriter Effect","ai-engine"),TYPEWRITER_EFFECT_HELP:Fe("The reply from AI will be typewrited. I actually do not recommend this feature.","ai-engine"),CHATBOT_MODERATION_HELP:Fe("If the conversation seems offensive, the chatbot will reject it.","ai-engine")},De.CHATBOT={INTRO:Fe("If you only need one chatbot, set your parameters in the Chatbot Builder, and click on <b>Set as Default Parameters</b>. You can then use the shortcode <b>[mwai_chat]</b> anywhere on your website. You can also add the chatbot everywhere automatically by using <b>Inject Default Chatbot</b>.","ai-engine"),INTRO_2:Fe('You can have multiple chatbots on your website (or same page), each with different parameters. Setting an ID will memorize the conversation in the browser, Content Aware will make the content of your page available to the context (<a href="https://meowapps.com/ai-engine/tutorial/#content-aware-bot" target="_blank">read this</a>), and removing the AI Name and User Name will switch to avatars (similar to ChatGPT). Enjoy! 😎',"ai-engine"),CHATBOT_BUILDER:Fe("Chatbot Builder","ai-engine"),RESET_PARAMS:Fe("Reset Parameters","ai-engine")},De.STATISTICS={ABSOLUTE_HELP:Fe("Using Absolute, Day represents <i>today</i>. Otherwise, the <i>past 24 hours</i>. Same logic applies to the other timeframes.","ai-engine"),NO_CREDITS_MESSAGE:Fe("Message for No Credits","ai-engine"),FULL_ACCESS_USERS:Fe("Full-Access Users","ai-engine"),ENABLE_LIMITS:Fe("Enable Limits","ai-engine")},De.CONTENT_GENERATOR={INTRO:Fe("The Content Generator is a powerful tool that can generate content for you. It can be used to generate articles, emails, or even code. It can also be used to generate content for your chatbot. <b>Let me know if there are any new features you would like to see!</b> Have fun 🥳","ai-engine"),TITLE_MISSING:Fe("Title is missing!","ai-engine"),SECTIONS_MISSING:Fe("Sections are missing!","ai-engine"),SINGLE_GENERATE:Fe("Single Generate","ai-engine"),BULK_GENERATE:Fe("Bulk Generate","ai-engine"),CONTENT_PARAMS:Fe("Content Params","ai-engine"),POST_PARAMS:Fe("Post Params","ai-engine"),CONTENT_PARAMS_INTRO:Fe("Input fields are displayed for certain placeholders used in prompts, such as {LANGUAGE} or {WRITING_TONE}","ai-engine"),CUSTOM_LANGUAGE:Fe("Custom Language","ai-engine"),WRITING_STYLE:Fe("Writing Style","ai-engine"),WRITING_TONE:Fe("Writing Tone","ai-engine"),CUSTOM_LANGUAGE_HELP:Fe('All the languages are <i>somehow</i> supported by AI. <a href="https://meowapps.com/ai-engine/faq/#languages" target="_blank">Learn more</a>.',"ai-engine"),MODEL_HELP:Fe("The gpt-3.5-turbo and davinci models are currently the only acceptable ones for writing texts.","ai-engine"),PROMPTS_INTRO:Fe("Prompts represent the exact request sent to the AI. The variables between curly braces will be replaced by the content of the corresponding field. Prompts are saved in your templates.","ai-engine"),PROMPT_TITLE:Fe("Prompt for <b>Title</b>","ai-engine"),PROMPT_SECTIONS:Fe("Prompt for <b>Sections</b>","ai-engine"),PROMPT_CONTENT:Fe("Prompt for <b>Content</b>","ai-engine"),PROMPT_EXCERPT:Fe("Prompt for <b>Excerpt</b>","ai-engine"),POST_CREATED:Fe("Post Created!","ai-engine"),POST_CREATED_AS_DRAFT:Fe("Post Created as Draft!","ai-engine"),CONTENT_HELP:Fe('You can modify the content before using "Create Post". Markdown is supported, and will be converted to HTML when the post is created.',"ai-engine"),SECTIONS_HELP:Fe('Add, rewrite, remove, or reorganize those sections as you wish before (re)clicking on "Generate Content". Markdown format is recommended.',"ai-engine"),GENERATE_EXCERPT:Fe("Generate Excerpt","ai-engine"),GENERATE_CONTENT:Fe("Generate Content","ai-engine"),GENERATE_SECTIONS:Fe("Generate Sections","ai-engine"),PARAGRAPHS_PER_SECTION:Fe("# of Paragraphs per Section","ai-engine"),SECTIONS:Fe("Sections","ai-engine"),TOPICS_HELP:Fe("Write or paste your topics below. Each line will be used as a topic. The same <b>Params</b> and <b>Prompts</b> will be used as with the <b>Single Generate</b>, so make sure you get satisfying results with it first. This <b>takes time</b>, so relax and enjoy some coffee ☕️ and tea 🍵 :)","ai-engine"),GENERATED_POSTS:Fe("Generated Posts","ai-engine"),GENERATE_ALL:Fe("Generate All","ai-engine"),EDIT_POST:Fe("Edit Post","ai-engine"),CREATE_POST:Fe("Create Post","ai-engine"),TITLE_TOO_SHORT:Fe("The title is too short. It should be at least 3 words.","ai-engine"),TITLE_TOO_SHORT_2:Fe("The title is too short. It should be at least 40 characters.","ai-engine"),TITLE_TOO_LONG:Fe("The title is too long. It should be less than 8 words.","ai-engine"),TITLE_TOO_LONG_2:Fe("The title is too long. It should be less than 70 characters.","ai-engine")},De.TEMPLATES={TEMPLATES:Fe("Templates","ai-engine"),DELETE_CONFIRM:Fe("Are you sure you want to delete this template?","ai-engine"),NEW_TEMPLATE_NAME:Fe("New Template","ai-engine"),EDIT:Fe("EDIT","ai-engine"),JOIN_US:Fe('Interested in sharing and/or looking for more templates? Join us on the <a target="_blank" href="https://wordpress.org/support/topic/common-use-cases-for-templates">Templates Threads</a> in the forums.',"ai-engine")},De.PLAYGROUND={INTRO:Fe("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. <b>Let me know if there are any new features you would like to see!</b> Have fun 🥳","ai-engine"),PROMPT:Fe("Query / Prompt","ai-engine"),ANSWER:Fe("Answer","ai-engine")},De.ALERTS={FINETUNING_STARTED:Fe("Fine-tuning started! Check its progress in the <b>Models</b> section. Depending on your dataset size, it may take a while (from a few minutes to days).","ai-engine"),RESET_BUILDER:Fe("This will delete all the rows in the builder. Are you sure?","ai-engine"),DELETE_FINETUNE:Fe("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.","ai-engine"),FINETUNE_ALREADY_DELETED:Fe("This fine-tune was already deleted. It will be removed from the list.","ai-engine"),CHECK_CONSOLE:Fe("Error! Check your console for more details.","ai-engine"),DATASET_UPLOADED:Fe("Uploaded successfully! You can now train a model based on this dataset.","ai-engine"),ONLY_SUPPORTS_FILES:Fe("This only supports JSON, JSONL, and CSV files.","ai-engine"),EMPTY_LINES:Fe("Some lines 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.","ai-engine")},De.FINETUNING={MODELS_INTRO:Fe("The AI models you have fine-tuned. To create more, visit <b>Datasets</b>.","ai-engine"),DATASETS_INTRO:Fe("The datasets you have uploaded to OpenAI. To create a new dataset, switch from <b>Model Finetuner</b> to <b>Dataset Builder</b>. To train a new model, click on the <i>magic wand</i>.","ai-engine"),MODEL_FINETUNE:Fe("Model Finetune","ai-engine"),DATASET_BUILDER:Fe("Dataset Builder","ai-engine"),ENTRIES_EDITOR:Fe("Entries Editor","ai-engine"),ENTRIES_GENERATOR:Fe("Entries Generator","ai-engine"),HUGE_DATASET_WARNING:Fe("Caution: The data is too large to be saved in your browser's local storage.","ai-engine"),NO_FINETUNES_YET:Fe("No fine-tunes found. Refresh the list, or create a new one (via a dataset).","ai-engine"),CLEAN_MODELS_LIST:Fe("Clean Models List","ai-engine"),DELETED_FINETUNE_ISSUE:Fe("For some reason, OpenAI still return the models even after you deleted them. Don't worry, AI Engine will do the cleanup for you! You can force the cleanup by using this button. It takes a bit of time depending on the total of models you have.","ai-engine")},De.EMBEDDINGS={EDIT:Fe("EDIT","ai-engine"),AI_SEARCH:Fe("AI SEARCH","ai-engine")};const Ue=De;function Be(e){return Be="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},Be(e)}function He(){He=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==Be(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 ze(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 Ye(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){ze(o,r,a,i,c,"next",e)}function c(e){ze(o,r,a,i,c,"throw",e)}i(void 0)}))}}function We(e){return function(e){if(Array.isArray(e))return Ve(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||qe(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 Ze(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)||qe(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 qe(e,t){if(e){if("string"==typeof e)return Ve(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)?Ve(e,t):void 0}}function Ve(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 Ke=wp.element,Je=Ke.useMemo,$e=Ke.useState,Xe=Ke.useEffect,Qe={title:"",content:"",refId:null,type:"manual",behavior:"context"},et={name:"",podType:"p2"},tt=function(e){var t=e.options,n=t.openai_apikey,r=t.pinecone,a=n&&n.length>0,o=!(null!=t&&t.module_embeddings)||r.apikey&&r.apikey.length>0;return React.createElement(React.Fragment,null,!a&&React.createElement(Re.S,{variant:"danger",style:{marginTop:0,marginBottom:25}},(0,R.io)(Ue.SETTINGS.OPENAI_SETUP)),!o&&React.createElement(Re.S,{variant:"danger",style:{marginTop:0,marginBottom:25}},(0,R.io)(Ue.SETTINGS.PINECONE_SETUP)))};function nt(e){return e?e.split("\n").map((function(e){return(e=e.replace(/^\d+\.\s/,"")).startsWith('"')&&(e=e.slice(1)).endsWith('"')&&(e=e.slice(0,-1)),e})).filter((function(e){return e})).join("\n"):e}var rt,at,ot,it,ct=function(e){var t=e.disabled,n=e.options,r=e.language,a=e.customLanguage,o=Ze($e(null!=r?r:"en"),2),i=o[0],c=o[1],l=Ze($e(!1),2),u=l[0],s=l[1],f=Ze($e(""),2),m=f[0],d=f[1],p=(null==n?void 0:n.languages)||[],h=Je((function(){return Object.keys(p).map((function(e){return{value:e,label:p[e]}}))}),[p]);Xe((function(){var e=(document.querySelector("html").lang||navigator.language||navigator.userLanguage).substr(0,2);h.find((function(t){return t.value===e}))&&c(e)}),[]),Xe((function(){c(r)}),[r]),Xe((function(){a?(s(!0),d(a)):(s(!1),d(""),c(null!=r?r:"en"))}),[a]);var y=Je((function(){if(u)return m;var e=h.find((function(e){return e.value===i}));return e?e.label:(console.warn("A system language or a custom language should be set."),"English")}),[i,m]),v=function(e,t){"custom"!==e?c(e,t):s(!0)};return{jsxLanguageSelector:Je((function(){return React.createElement(React.Fragment,null,u&&React.createElement(ge.A,{name:"customLanguage",disabled:t,onReset:function(){s(!1)},description:(0,R.io)(Ue.CONTENT_GENERATOR.CUSTOM_LANGUAGE_HELP),value:m,onChange:d}),!u&&React.createElement(ve.N,{scrolldown:!0,name:"language",disabled:t,description:(0,R.io)(Ue.CONTENT_GENERATOR.CUSTOM_LANGUAGE_HELP),value:i,onChange:v},h.map((function(e){return React.createElement(ve.Z,{key:e.value,value:e.value,label:e.label})})),React.createElement(ve.Z,{key:"custom",value:"custom",label:"Other"})))}),[i,y,h,u]),currentLanguage:u?"custom":i,currentHumanLanguage:y,isCustom:u}},lt=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"gpt-3.5-turbo",n=$e(t),r=Ze(n,2),a=r[0],o=r[1],i=(null==e?void 0:e.openai_finetunes_deleted)||[],c=Je((function(){var t,n=e.openai_models,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.model})):[];return a.length&&(n=[].concat(We(n),We(a.map((function(e){var t=e.model.split(":")[0];return{model:e.model,name:"fn: ".concat(e.suffix,"/").concat(t),suffix:e.suffix,mode:"completion",family:t,description:"finetuned",finetuned:!0,tags:["finetune"]}}))))),(r=null===(t=r)||void 0===t?void 0:t.split(",").filter((function(e){return e}))).length&&(n=[].concat(We(n),We(r.map((function(e){return{id:e,model:e,description:"Extra"}}))))),n}),[e]),l=Je((function(){return c.filter((function(e){return!i.includes(e.model)}))}),[c,i]),u=Je((function(){return l.filter((function(e){return"completion"===(null==e?void 0:e.mode)||"chat"===(null==e?void 0:e.mode)}))}),[l]),s=function(e){return"gpt-3.5-turbo-0301"===e?e="gpt-3.5-turbo":"gpt-4-0314"===e&&(e="gpt-4"),c.find((function(t){return t.model===e}))},f=function(e){var t=s(e);return(null==t?void 0:t.finetuned)||!1},m=function(e){var t=s(e);return(null==t?void 0:t.name)||(null==t?void 0:t.model)||e},d=function(e){var t=s(e);return(null==t?void 0:t.family)||null},p=function(e){var t=s(e);return c.filter((function(e){var t;return null===(t=e.tags)||void 0===t?void 0:t.includes("core")})).find((function(e){return e.family===t.family}))||null},h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"1024x1024",n=p(e);if("image"===(null==n?void 0:n.type)&&null!=n&&n.options){var r=n.options.find((function(e){return e.option===t}));return(null==r?void 0:r.price)||null}return(null==n?void 0:n.price)||null},y=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"1024x1024",r=p(e),a=h(e,n);return a?a*t*r.unit:0};return{allModels:c,model:a,models:l,completionModels:u,setModel:o,isFineTunedModel:f,getModelName:m,getFamilyName:d,getPrice:h,getModel:s,calculatePrice:y}},ut=function(){var e=Ye(He().mark((function e(t){var n,r;return He().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(""!==(null==t||null===(n=t.filters)||void 0===n?void 0:n.aiSearch)){e.next=2;break}return e.abrupt("return",[]);case 2:return t.offset=(t.page-1)*t.limit,e.next=5,(0,R.PV)("".concat(S,"/vectors"),{nonce:k,method:"POST",json:t});case 5:return r=e.sent,e.abrupt("return",r?{total:r.total,vectors:r.vectors}:{total:0,vectors:[]});case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),st=function(){var e=Ye(He().mark((function e(t){var n;return He().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.offset=(t.page-1)*t.limit,e.next=3,(0,R.PV)("".concat(S,"/vectors"),{nonce:k,method:"POST",json:t});case 3:return n=e.sent,e.abrupt("return",n?{total:n.total,vectors:n.vectors}:{total:0,vectors:[]});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ft=function(){var e=Ye(He().mark((function e(t){var n,r,a;return He().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,R.PV)("".concat(S,"/count_posts?postType=").concat(t),{nonce:k});case 2:return a=e.sent,e.abrupt("return",null!=a&&null!==(n=a.count)&&void 0!==n&&n.publish?parseInt(null==a||null===(r=a.count)||void 0===r?void 0:r.publish):null);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),mt=function(){var e=Ye(He().mark((function e(t){var n,r,a,o=arguments;return He().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=o.length>1&&void 0!==o[1]?o[1]:0,r=o.length>2&&void 0!==o[2]?o[2]:0,e.next=4,(0,R.PV)("".concat(S,"/post_content?postType=").concat(t,"&offset=").concat(n,"&postId=").concat(r),{nonce:k});case 4:return a=e.sent,e.abrupt("return",a);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();function dt(e){for(var t=0,n=0,r=0;r<e.length;r++)e[r].charCodeAt(0)<128?t++:n++;return t/3.5+2.5*n}function pt(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2048,n=e,r=dt(n);r>t;)r=dt(n=n.slice(0,-32));return n}function ht(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var yt=function(e){var t=e.title,n=void 0===t?"Settings":t,r=e.options,a=void 0===r?C:r,o=null==a?void 0:a.module_playground,i=null==a?void 0:a.module_generator_content,c=null==a?void 0:a.module_generator_images;return React.createElement(v.B,{title:"AI Engine | ".concat(n),subtitle:"By Jordy Meow"},React.createElement("div",{style:{display:"flex",justifyContent:"flex-end"}},i&&React.createElement(b._,{className:"header",icon:"",onClick:function(){return location.href="edit.php?page=mwai_content_generator"}},"Build Content"),c&&React.createElement(b._,{className:"header",icon:"",onClick:function(){return location.href="edit.php?page=mwai_image_generator"}},"Build Images"),o&&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")))},vt=((0,I.ZP)(b._)(rt||(rt=ht(["\n"]))),I.ZP.div(at||(at=ht(["\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"])))),gt=I.ZP.div(ot||(ot=ht(["\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"]))),Et=I.ZP.div(it||(it=ht(["\n\n label {\n margin-bottom: 5px;\n display: block;\n }\n\n .nui-button {\n margin-bottom: 5px;\n }\n\n .neko-textarea {\n margin-bottom: 5px;\n }\n\n .neko-input {\n margin-bottom: 5px;\n }\n\n .form-row {\n display: flex;\n .nui-button, .neko-textarea, .neko-input {\n margin: 0;\n }\n }\n\n .form-row-label {\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n"]))),bt=n(7460),wt=n.n(bt),Rt=n(9378),Ot=n(3704),xt=n(9995),Tt=n(2625),St=n(776),_t=n(8281),Nt=n(4291);function Lt(e){return Lt="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},Lt(e)}function kt(){kt=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==Lt(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 Ct(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 Pt(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Ct(o,r,a,i,c,"next",e)}function c(e){Ct(o,r,a,i,c,"throw",e)}i(void 0)}))}}var At=function(){var e=Pt(kt().mark((function e(){var t;return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,R.PV)("".concat(S,"/post_types"),{nonce:k});case 2:if((t=e.sent).success){e.next=5;break}throw new Error(t.message);case 5:return e.abrupt("return",t.postTypes);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),It=function(){var e=Pt(kt().mark((function e(t){var n,r,a;return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,R.PV)("".concat(S,"/count_posts?postType=").concat(t),{nonce:k});case 2:return a=e.sent,e.abrupt("return",null!=a&&null!==(n=a.count)&&void 0!==n&&n.publish?parseInt(null==a||null===(r=a.count)||void 0===r?void 0:r.publish):null);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Mt=function(){var e=Pt(kt().mark((function e(t){var n,r,a,o=arguments;return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=o.length>1&&void 0!==o[1]?o[1]:0,r=o.length>2&&void 0!==o[2]?o[2]:0,e.next=4,(0,R.PV)("".concat(S,"/post_content?postType=").concat(t,"&offset=").concat(n,"&postId=").concat(r),{nonce:k});case 4:return a=e.sent,e.abrupt("return",a);case 6:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),jt=function(){var e=Pt(kt().mark((function e(){var t,n;return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,R.PV)("".concat(S,"/openai_files"),{nonce:k});case 2:if((n=e.sent).success){e.next=5;break}throw new Error(n.message);case 5:return e.abrupt("return",null==n||null===(t=n.files)||void 0===t?void 0:t.data);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Gt=function(){var e=Pt(kt().mark((function e(){var t;return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,R.PV)("".concat(S,"/openai_deleted_finetunes"),{nonce:k});case 2:if((t=e.sent).success){e.next=5;break}throw new Error(t.message);case 5:return e.abrupt("return",null==t?void 0:t.finetunes);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Ft=function(){var e=Pt(kt().mark((function e(){var t,n;return kt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,R.PV)("".concat(S,"/openai_finetunes"),{nonce:k});case 2:if((n=e.sent).success){e.next=5;break}throw new Error(n.message);case 5:return e.abrupt("return",null==n||null===(t=n.finetunes)||void 0===t?void 0:t.data);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();function Dt(e){return Dt="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},Dt(e)}function Ut(e){return function(e){if(Array.isArray(e))return Zt(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 Bt(){Bt=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==Dt(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 Ht(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 zt(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Ht(o,r,a,i,c,"next",e)}function c(e){Ht(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Yt(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 Zt(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)?Zt(e,t):void 0}}function Zt(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 qt=wp.element,Vt=qt.useState;qt.useEffect;const Kt=function(e){var t=e.setBuilderData,n=Yt(Vt("post"),2),r=n[0],a=n[1],o=Yt(Vt(0),2),i=o[0],c=o[1],l=Yt(Vt(!1),2),u=l[0],s=l[1],f=Yt(Vt("Generate 30 questions and answers from this text. Question use a neutral tone. Answers use the same tone as the text."),2),m=f[0],d=f[1],p=Yt(Vt("\n\nUse this format:\n\nQ: \nA: \n\nArticle:\n\n{CONTENT}"),2),h=p[0],y=(p[1],(0,Te.a)({queryKey:["postTypes"],queryFn:At})),v=y.isLoading,g=y.data,E=(0,Te.a)({queryKey:["postsCount-"+r],queryFn:function(){return It(r)}}),w=E.isLoading,O=E.data,x=(0,Nt.qj)({i18n:Ue,onStop:function(){s(),x.reset()}}),T=u||x.busy||w||v,_=function(e){if(!e)return[];for(var t=e.split("\n").filter((function(e){return""!==e.trim()})),n=[],r=0;r<t.length;r++)t[r].startsWith("Q:")?n.push({prompt:t[r].slice(2).trim()}):t[r].startsWith("A:")&&(n[n.length-1].completion=t[r].slice(2).trim());return n},N=function(){var e=zt(Bt().mark((function e(){var t,n,a,o,i,l,u,s,f,d,p,y,v,g,E,b,w,O,x=arguments;return Bt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=x.length>0&&void 0!==x[0]?x[0]:0,n=x.length>1&&void 0!==x[1]?x[1]:void 0,a=x.length>2&&void 0!==x[2]?x[2]:void 0,o=m+h,e.next=6,Mt(r,t,n||void 0);case 6:if(i=e.sent,l=null,u=null,s=null==i?void 0:i.content,f=null==i?void 0:i.url,d=null==i?void 0:i.title,p=0,i.success){e.next=18;break}alert(i.message),l=i.message,e.next=35;break;case 18:if(!(s.length<64)){e.next=22;break}console.log("Issue: Content is too short! Skipped.",{content:s}),e.next=35;break;case 22:return o=(o=(o=o.replace("{CONTENT}",s)).replace("{URL}",f)).replace("{TITLE}",d),e.next=27,(0,R.PV)("".concat(S,"/make_completions"),{method:"POST",json:{env:"admin-tools",session:P,prompt:o,temperature:.8,model:"gpt-3.5-turbo",maxTokens:2048,stop:""},signal:a,nonce:k});case 27:if((v=e.sent).success){e.next=33;break}if(null===(g=v.error)||void 0===g||!g.cancelledByUser){e.next=31;break}return e.abrupt("return",null);case 31:throw console.error(null!==(E=v.message)&&void 0!==E?E:"Unknown error, check your console logs."),new Error(null!==(b=v.message)&&void 0!==b?b:"Unknown error, check your console logs.");case 33:u=null==v?void 0:v.data,null!=v&&null!==(y=v.usage)&&void 0!==y&&y.total_tokens&&(p=v.usage.total_tokens,c((function(e){return e+v.usage.total_tokens})));case 35:return null!=a&&a.aborted&&L(),w=_(u),O={content:s,prompt:o,rawData:u,entries:w,error:l,tokens:p},console.log("Result:",O),e.abrupt("return",O);case 40:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),L=function(){console.log("User aborted."),setBusy(!1),x.reset()},C=function(){var e=zt(Bt().mark((function e(){var n,r,a;return Bt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return c(0),n=Array.from(Array(O).keys()),r=prompt("There are "+n.length+" entries. If you want to start from a certain entry offset, type it here. Otherwise, just press OK, and everything will be processed."),a=n.map((function(e){return function(){var n=zt(Bt().mark((function n(a){var o,i;return Bt().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:if(console.log("Task "+e),!(r&&e<r)){n.next=3;break}return n.abrupt("return",{success:!0});case 3:return n.next=5,N(e,null,a);case 5:return(null==(i=n.sent)||null===(o=i.entries)||void 0===o?void 0:o.length)>0&&t((function(e){return[].concat(Ut(e),Ut(i.entries))})),n.abrupt("return",{success:!0});case 8:case"end":return n.stop()}}),n)})));return function(e){return n.apply(this,arguments)}}()})),e.next=6,x.start(a);case 6:s(!1),alert("All done!"),x.reset();case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),A=function(){var e=zt(Bt().mark((function e(){var n,r;return Bt().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(c(0),null!==(n=prompt("Enter the ID of a post (leave blank to use the very first one)."))){e.next=4;break}return e.abrupt("return");case 4:return s(!0),e.next=7,N(0,n);case 7:r=e.sent,s(!1),r.entries.length?confirm("Got ".concat(r.entries.length," entries! Do you want to add them to your data? If not, they will be displayed in your console."))&&t((function(e){return[].concat(Ut(e),Ut(r.entries))})):alert("No entries were generated. Check the console for more information.");case 10:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return React.createElement(React.Fragment,null,React.createElement("div",{style:{display:"flex"}},React.createElement(b._,{disabled:T,onClick:A},"Single Generate (Test)"),React.createElement(b._,{disabled:T,onClick:function(){return C()}},"Run Bulk Generate"),React.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",paddingLeft:10}},"Based on ",w&&"...",!w&&O),React.createElement(ve.N,{id:"postType",scrolldown:!0,disabled:T,name:"postType",style:{width:100,marginLeft:10},onChange:a,value:r},null==g?void 0:g.map((function(e){return React.createElement(ve.Z,{key:e.type,value:e.type,label:e.name})}))),React.createElement(_t.U,{busy:x.busy,style:{marginLeft:10,flex:"auto"},value:x.value,max:x.max,onStopClick:x.stop}),React.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",paddingLeft:10}},"Tokens: ",i)),React.createElement(we.l,{id:"generatePrompt",name:"generatePrompt",rows:2,style:{marginTop:15},value:m,onBlur:d,disabled:T}),x.TasksErrorModal)};function Jt(e){return Jt="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},Jt(e)}function $t(e){return function(e){if(Array.isArray(e))return cn(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||on(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 Xt(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 Qt(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Xt(Object(n),!0).forEach((function(t){en(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xt(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function en(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==Jt(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==Jt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===Jt(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tn(){tn=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==Jt(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 nn(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 rn(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){nn(o,r,a,i,c,"next",e)}function c(e){nn(o,r,a,i,c,"throw",e)}i(void 0)}))}}function an(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)||on(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 on(e,t){if(e){if("string"==typeof e)return cn(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)?cn(e,t):void 0}}function cn(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 ln=wp.element,un=ln.useState,sn=ln.useMemo,fn=ln.useRef,mn=ln.useEffect,dn=[{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"}],pn=[{accessor:"status",title:"Status",sortable:!0,width:"100px"},{accessor:"id",title:"ID",width:"120px"},{accessor:"filename",title:"File"},{accessor:"purpose",title:"Purpose"},{accessor:"filesize",title:"Size",sortable:!0},{accessor:"createdOn",title:"Date",sortable:!0,width:"80px"},{accessor:"actions",title:"",width:"190px"}],hn=[{accessor:"status",title:"Status",sortable:!0,width:"100px"},{accessor:"id",title:"ID",width:"120px"},{accessor:"suffix",title:"Suffix"},{accessor:"model",title:"Model"},{accessor:"base_model",title:"Based On",width:"200px"},{accessor:"createdOn",title:"Date",sortable:!0,width:"80px"},{accessor:"actions",title:""}],yn="\n\n###\n\n",vn="\n\n",gn=function(e){var t=e.status,n=e.includeText,r=void 0!==n&&n,a=(0,s.r)().colors,o=a.orange,i=a.green,c=a.red,l=null;switch(t){case"pending":case"running":l=React.createElement(xe.J,{title:t,icon:"replay",spinning:!0,width:24,color:o});break;case"succeeded":case"processed":l=React.createElement(xe.J,{title:t,icon:"check-circle",width:24,color:i});break;case"failed":l=React.createElement(xe.J,{title:t,icon:"close",width:24,color:c});break;case"cancelled":l=React.createElement(xe.J,{title:t,icon:"close",width:24,color:o});break;default:l=React.createElement(xe.J,{title:t,icon:"alert",width:24,color:o})}return r?React.createElement("div",{style:{display:"flex",alignItems:"center"}},l,React.createElement("span",{style:{textTransform:"uppercase",fontSize:10,marginLeft:5}},t)):l},En=function(e){var t=e.children,n=e.data,r=e.onChange,a=void 0===r?function(){}:r,o=an(un(!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(we.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 bn=function(e){var t,n,r,a=e.options,o=e.updateOption,i=(0,s.r)().colors,c=(0,u.NL)(),l=an(un(),2),f=l[0],m=l[1],d=an(un(!1),2),p=d[0],y=d[1],v=an(un("finetunes"),2),g=v[0],E=v[1],w=an(un("editor"),2),O=w[0],x=w[1],T=an(un(!0),2),_=T[0],N=T[1],L=lt(a),C=L.models,P=L.model,A=L.setModel,I=L.getModel,M=L.isFineTunedModel,j=an(un("meow"),2),G=j[0],F=j[1],D=an(un(!1),2),U=D[0],B=D[1],H=an(un(4),2),z=H[0],Y=H[1],W=an(un(null),2),Z=W[0],q=W[1],V=an(un(!1),2),K=V[0],J=V[1],$=(0,Te.a)({queryKey:["datasets"],enabled:K,queryFn:jt}),X=$.isFetching,Q=$.error,ee=$.data,te=(null==a?void 0:a.openai_finetunes_deleted)||[],ne=an(un(!1),2),re=ne[0],ae=ne[1],oe=(null==a?void 0:a.openai_finetunes_all)||[];mn((function(){"files"!==g||K||J(!0)}),[g]),mn((function(){Q&&!re&&ae(Q)}),[Q]);var ie=10,ce=an(un(!0),2),le=ce[0],ue=ce[1],se=an(un(1),2),fe=se[0],me=se[1],de=an(un([]),2),pe=de[0],he=de[1],ye=an(un(""),2),we=ye[0],xe=ye[1],_e=sn((function(){return pe.length}),[pe]),Ne=function(){var e=rn(tn().mark((function e(){return tn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,c.invalidateQueries("datasets");case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Le=function(){var e=rn(tn().mark((function e(){return tn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y(!0),e.next=3,Ne();case 3:y(!1);case 4:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ke=function(){var e=rn(tn().mark((function e(){var t,n,r,a,o;return tn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=f,n=G,r=I(P),y(!0),a=M(P),e.next=7,(0,R.PV)("".concat(S,"/openai_files_finetune"),{method:"POST",nonce:k,json:{fileId:t,model:a?r.model:r.family,suffix:n,nEpochs:z,batchSize:Z}});case 7:if(!(o=e.sent).success){e.next=16;break}return e.next=11,Ce();case 11:alert(Ue.ALERTS.FINETUNING_STARTED),E("finetunes"),m(),e.next=17;break;case 16:alert(o.message);case 17:y(!1);case 18:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Ce=function(){var e=rn(tn().mark((function e(){return tn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:ze();case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Pe=function(){var e=rn(tn().mark((function e(){var t;return tn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y("clean"),e.next=3,Gt();case 3:return t=e.sent,e.next=6,o(t,"openai_finetunes_deleted");case 6:y(!1);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Ae=function(){var e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];e&&!confirm(Ue.ALERTS.RESET_BUILDER)||(he([]),Me([]))},Ie=function(e,t){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],r=pe.map((function(r,a){return a===e-1?Qt(Qt({},r),{},n?{completion:t}:{prompt:t}):r}));he(r)};mn((function(){if(!pe||0===pe.length){var e=localStorage.getItem("mwai_builder_data");e&&he(JSON.parse(e))}}),[]);var Me=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"),xe("MEOW-".concat(t,".jsonl"))}();try{e?localStorage.setItem("mwai_builder_data",JSON.stringify(e)):localStorage.removeItem("mwai_builder_data"),ue(!0)}catch(e){localStorage.removeItem("mwai_builder_data"),ue(!1)}};mn((function(){pe&&pe.length>0&&Me(pe)}),[pe]);var je=sn((function(){var e=(fe-1)*ie,t=null==pe?void 0:pe.slice((fe-1)*ie,(fe-1)*ie+ie);return null==t?void 0:t.map((function(t){var n,r,a=++e,o=null==t||null===(n=t.prompt)||void 0===n?void 0:n.toString().endsWith(yn),i=null==t||null===(r=t.completion)||void 0===r?void 0:r.toString().endsWith(vn);return{row:a,validPrompt:o?"� |
| 3 | ":"❌",prompt:React.createElement(En,{data:t.prompt,onChange:function(e){return Ie(a,e)}},o?t.prompt.substring(0,t.prompt.length-yn.length):t.prompt),validCompletion:i?"� |
| 4 | ":"❌",completion:React.createElement(En,{data:t.completion,onChange:function(e){return Ie(a,e,!0)}},i?t.completion.substring(0,t.completion.length-vn.length):t.completion),actions:React.createElement(b._,{rounded:!0,icon:"trash",onClick:function(){return function(e){var t=pe.filter((function(t,n){return n!==e-1}));he(t),0===t.length&&Me([])}(a)}})}}))}),[pe,fe,ie]),Ge=function(){var e=rn(tn().mark((function e(t){var n;return tn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y(!0),e.prev=1,e.next=4,(0,R.PV)("".concat(S,"/openai_files"),{method:"DELETE",nonce:k,json:{fileId:t}});case 4:if(!(n=e.sent).success){e.next=10;break}return e.next=8,Ne();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(Ue.ALERTS.CHECK_CONSOLE);case 17:y(!1);case 18:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(t){return e.apply(this,arguments)}}(),Fe=function(){var e=rn(tn().mark((function e(t){var n;return tn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y(!0),e.prev=1,e.next=4,(0,R.PV)("".concat(S,"/openai_finetunes_cancel"),{method:"POST",nonce:k,json:{finetuneId:t}});case 4:(n=e.sent).success?Ce():alert(n.message),e.next=12;break;case 8:e.prev=8,e.t0=e.catch(1),console.log(e.t0),alert(Ue.ALERTS.CHECK_CONSOLE);case 12:y(!1);case 13:case"end":return e.stop()}}),e,null,[[1,8]])})));return function(t){return e.apply(this,arguments)}}(),De=function(){var e=rn(tn().mark((function e(t){var n;return tn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(confirm(Ue.ALERTS.DELETE_FINETUNE)){e.next=2;break}return e.abrupt("return");case 2:return y(!0),e.prev=3,e.next=6,(0,R.PV)("".concat(S,"/openai_finetunes"),{method:"DELETE",nonce:k,json:{modelId:t}});case 6:if(!(n=e.sent).success){e.next=12;break}return e.next=10,o([].concat($t(te),[t]),"openai_finetunes_deleted");case 10:e.next=19;break;case 12:if(!(n.message.indexOf("does not exist")>-1)){e.next=18;break}return alert(Ue.ALERTS.FINETUNE_ALREADY_DELETED),e.next=16,o([].concat($t(te),[t]),"openai_finetunes_deleted");case 16:e.next=19;break;case 18:alert(n.message);case 19:e.next=25;break;case 21:e.prev=21,e.t0=e.catch(3),console.log(e.t0),alert(Ue.ALERTS.CHECK_CONSOLE);case 25:y(!1);case 26:case"end":return e.stop()}}),e,null,[[3,21]])})));return function(t){return e.apply(this,arguments)}}(),Be=function(){var e=rn(tn().mark((function e(t,n){var r,a,o,i;return tn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y(!0),e.prev=1,console.log({fileId:t,filename:n}),e.next=5,(0,R.PV)("".concat(S,"/openai_files_download"),{method:"POST",nonce:k,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(Ue.ALERTS.CHECK_CONSOLE);case 13:y(!1);case 14:case"end":return e.stop()}}),e,null,[[1,9]])})));return function(t,n){return e.apply(this,arguments)}}(),He=sn((function(){return null==ee?void 0:ee.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(gn,{status:e.status,includeText:!0}),id:t,filename:n,purpose:e.purpose,filesize:(0,R.td)(e.bytes),createdOn:React.createElement(React.Fragment,null,r.toLocaleDateString(),React.createElement("br",null),r.toLocaleTimeString()),actions:React.createElement(React.Fragment,null,React.createElement(b._,{disabled:!a,icon:"wand",onClick:function(){return m(t)}},"Train Model"),React.createElement(b._,{rounded:!0,icon:"arrow-down",onClick:function(){return Be(t,n)}}),React.createElement(b._,{className:"danger",rounded:!0,icon:"trash",onClick:function(){return Ge(t)}}))}}))}),[ee]),ze=function(){var e=rn(tn().mark((function e(){var t;return tn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y("finetunes"),e.next=3,Ft();case 3:t=(t=e.sent).sort((function(e,t){return t.created_at-e.created_at})).map((function(e){var t=new Date(1e3*e.created_at);return{id:e.id,status:e.status,suffix:e.suffix,model:e.fine_tuned_model,base_model:e.model,createdOn:t}})),o(t,"openai_finetunes_all"),y(!1);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Ye=sn((function(){return oe?oe.filter((function(e){return!te.includes(e.model)})).map((function(e){var t=new Date(e.createdOn);return Qt(Qt({},e),{},{status:React.createElement(gn,{status:e.status,includeText:!0}),createdOn:React.createElement(React.Fragment,null,t.toLocaleDateString(),React.createElement("br",null),t.toLocaleTimeString()),actions:React.createElement(React.Fragment,null,"succeeded"===e.status&&React.createElement(b._,{className:"danger",rounded:!0,icon:"trash",onClick:function(){return De(e.model)}}),"pending"===e.status&&React.createElement(b._,{className:"danger",rounded:!0,icon:"close",onClick:function(){return Fe(e.id)}}))})})):[]}),[te,oe]),We=X||p,Ze=function(){var e=rn(tn().mark((function e(){var t,n;return tn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y(!0),e.prev=1,t=pe.map((function(e){return JSON.stringify(e)})).join("\n"),console.log(t),e.next=6,(0,R.PV)("".concat(S,"/openai_files"),{method:"POST",nonce:k,json:{filename:we,data:t}});case 6:return n=e.sent,e.next=9,Ne();case 9:n.success?(Ae(!1),alert(Ue.ALERTS.DATASET_UPLOADED),E("files"),N(!0)):alert(n.message),e.next=16;break;case 12:e.prev=12,e.t0=e.catch(1),console.log(e.t0),alert(Ue.ALERTS.CHECK_CONSOLE);case 16:y(!1);case 17:case"end":return e.stop()}}),e,null,[[1,12]])})));return function(){return e.apply(this,arguments)}}(),qe=sn((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=I(P);return"".concat(null==c?void 0:c.family,":ft-your-org:").concat(G,"-").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)}),[G,P]),Ve=function(){var e=rn(tn().mark((function e(t){var n,r;return tn().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:n=tn().mark((function e(){var n,a,o,i,c;return tn().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(Ue.ALERTS.ONLY_SUPPORTS_FILES),console.log(n),e.abrupt("return","continue");case 9:a.onload=function(){var e=rn(tn().mark((function e(t){var n,r,a,l,u,s,f;return tn().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=wt().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(Ue.ALERTS.EMPTY_LINES),f=u.find((function(e){return!e.prompt||!e.completion})),console.log("Empty line: ",f)),he(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)}}(),Ke=fn(null);return React.createElement(React.Fragment,null,React.createElement(Ee.H,{style:{margin:"10px 10px 25px 10px"},contentStyle:{padding:10}},React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement(Rt.Q,{style:{marginRight:10},onLabel:Ue.FINETUNING.MODEL_FINETUNE,offLabel:Ue.FINETUNING.DATASET_BUILDER,width:165,onBackgroundColor:i.purple,offBackgroundColor:i.green,onChange:N,checked:_}),_&&React.createElement(Oe.h,{value:g,busy:We,onChange:function(e){E(e)}},React.createElement(Oe.S,{title:Ue.COMMON.MODELS,value:"finetunes",count:null!==(t=null==Ye?void 0:Ye.length)&&void 0!==t?t:"-"}),React.createElement(Oe.S,{title:Ue.COMMON.DATASETS,value:"files",count:null!==(n=null==He?void 0:He.length)&&void 0!==n?n:"-"})),_&&"finetunes"===g&&React.createElement(React.Fragment,null,React.createElement("div",{style:{flex:"auto"}}),React.createElement(b._,{disabled:p,busy:"finetunes"===p,onClick:Ce,className:"primary"},"Refresh Models")),_&&"files"===g&&React.createElement(React.Fragment,null,React.createElement("div",{style:{flex:"auto"}}),React.createElement(b._,{disabled:p,onClick:Le,className:"primary"},"Refresh Datasets")),!_&&React.createElement("div",{style:{display:"flex",alignItems:"center",width:"100%"}},React.createElement(Oe.h,{value:O,onChange:function(e){x(e)}},React.createElement(Oe.S,{title:Ue.FINETUNING.ENTRIES_EDITOR,value:"editor",count:null!==(r=null==pe?void 0:pe.length)&&void 0!==r?r:null}),React.createElement(Oe.S,{title:Ue.FINETUNING.ENTRIES_GENERATOR,value:"generator"})),React.createElement("div",{style:{flex:"auto"}}),React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement("label",{style:{marginRight:10}},"Filename:"),React.createElement(ge.A,{disabled:!_e||p,value:_e?we:"",onChange:xe,style:{width:210,marginRight:5}}),React.createElement(b._,{disabled:!_e||p,icon:"upload",onClick:Ze,className:"primary"},"Upload to OpenAI"))))),React.createElement(Ee.H,{style:{margin:10}},_&&"finetunes"===g&&React.createElement(React.Fragment,null,React.createElement("p",null,(0,R.io)(Ue.FINETUNING.MODELS_INTRO)),React.createElement(Ot.a,{busy:We,data:Ye,columns:hn,emptyMessage:Ue.FINETUNING.NO_FINETUNES_YET}),React.createElement("div",{style:{marginTop:5,display:"flex",justifyContent:"end",lineHeight:"12px",alignItems:"center"}},React.createElement(b._,{small:!0,disabled:p,busy:"clean"===p,onClick:Pe,className:"primary"},Ue.FINETUNING.CLEAN_MODELS_LIST),React.createElement("small",{style:{marginLeft:5}},Ue.FINETUNING.DELETED_FINETUNE_ISSUE))),_&&"files"===g&&React.createElement(React.Fragment,null,React.createElement("p",null,(0,R.io)(Ue.FINETUNING.DATASETS_INTRO)),React.createElement(Ot.a,{busy:We,data:He,columns:pn,emptyMessage:React.createElement(React.Fragment,null,"You do not have any dataset files yet.")})),!_&&"generator"===O&&React.createElement(React.Fragment,null,React.createElement(Kt,{setBuilderData:he})),!_&&"editor"===O&&React.createElement(React.Fragment,null,!le&&React.createElement("p",{style:{color:xt.ZP.red}},Ue.FINETUNING.HUGE_DATASET_WARNING),React.createElement("div",{style:{display:"flex"}},React.createElement(b._,{icon:"plus",onClick:function(){return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Text...\n\n###\n\n",t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"Text...\n\n";console.log(e,t),he([].concat($t(pe),[{prompt:e,completion:t}]))}()}},"Add Entry"),React.createElement(b._,{disabled:!_e,className:"secondary",onClick:function(){var e=pe.map((function(e){var t=e.prompt,n=e.completion;return t.endsWith(yn)||(t=t.trim(),t+=yn),n.endsWith(vn)||(n=n.trim(),n+=vn),{prompt:t,completion:n}}));he(e)}},"Format with Defaults"),React.createElement(Tt.b,{ref:Ke,onSelectFiles:Ve,accept:"",style:{paddingLeft:5}},React.createElement(b._,{className:"secondary",onClick:function(){return Ke.current.click()}},"Import File")),React.createElement(b._,{disabled:!_e,className:"secondary",style:{marginLeft:5},onClick:function(){var e=wt().unparse(pe),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:!_e,onClick:Ae,className:"danger"},"Reset Entries"),React.createElement("div",{style:{flex:"auto"}}),React.createElement(St.Q,{currentPage:fe,limit:ie,total:_e,onCurrentPageChanged:me,onClick:me}))),!_&&React.createElement(React.Fragment,null,React.createElement(be.i,{height:20}),React.createElement(Ot.a,{busy:p,data:je,columns:dn,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(be.i,{height:20}),React.createElement("div",{style:{display:"flex",justifyContent:"end"}},React.createElement(St.Q,{currentPage:fe,limit:ie,total:_e,onCurrentPageChanged:me,onClick:me})),React.createElement(be.i,{height:40,line:!0,style:{marginBottom:0}}),"generator"===O&&React.createElement(Re.S,{variant:"danger",style:{marginTop:0,marginBottom:25}},"Use this feature with caution. The AI will generate questions and answers for each of your post based on the given prompt, and they will be added to your dataset. Keep in mind that this process may be ",React.createElement("u",null,"extremely slow")," and require a ",React.createElement("u",null,"significant number of API calls"),", resulting in a costs (the tokens count is displayed next to the progress bar). Also, please note that for now, for some reason, the model doesn't seem to provide as many questions as we ask (contrary to ChatGPT)."),"editor"===O&&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"),". Please also check my ",React.createElement("a",{href:"https://meowapps.com/wordpress-chatbot-finetuned-model-ai/",target:"_blank"},"simplified tutorial"),".")," Is your dataset ready? Modify the filename to your liking and click ",React.createElement("b",null,"Upload to OpenAI")," 😎 Some extra notes for you:"),React.createElement("ul",null,React.createElement("li",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("li",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("li",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("li",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,'casually_fine_tuned="true"')," in the shortcode.")))),React.createElement(Se.L,{isOpen:re,title:"Error",onOkClick:function(){return ae()},onRequestClose:function(){return ae()},ok:"Ok",content:React.createElement(React.Fragment,null,React.createElement("p",null,null==re?void 0:re.message))}),React.createElement(Se.L,{isOpen:f,title:"Train a new model",onOkClick:ke,onRequestClose:function(){return m()},onCancelClick:function(){return m()},ok:"Start",disabled:p,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(be.i,{height:5}),React.createElement(ve.N,{id:"models",value:P,scrolldown:!0,onChange:A},C.filter((function(e){var t;return null===(t=e.tags)||void 0===t?void 0:t.includes("finetune")})).map((function(e){return React.createElement(ve.Z,{value:e.model,label:e.name})}))),React.createElement(be.i,{height:5}),React.createElement("small",null,"For now, the hyperparameters can't be modified - they are set automatically by OpenAI."),React.createElement(be.i,{height:10}),React.createElement("label",null,"Suffix (for new model name):"),React.createElement(be.i,{height:5}),React.createElement(ge.A,{value:G,onChange:F}),React.createElement(be.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,qe),"."),React.createElement(be.i,{line:!0,height:20}),React.createElement(h.P,{label:"Enable HyperParams",checked:U,onChange:B}),U&&React.createElement(React.Fragment,null,React.createElement("div",{style:{display:"flex",flexDirection:"row",alignItems:"center"}},React.createElement("label",{style:{marginRight:5}},"Number of Epochs:"),React.createElement(ge.A,{style:{marginRight:5},value:z,onChange:Y,type:"number"}),React.createElement("label",{style:{marginRight:5}},"Batch Size:"),React.createElement(ge.A,{value:Z,onChange:q,type:"number"}))))})))};var wn,Rn,On,xn=wp.element,Tn=(xn.useState,xn.useEffect,xn.useMemo,I.ZP.div(wn||(Rn=["\n display: flex;\n flex-direction: column;\n color: white;\n width: 100%;\n margin-top: -20px;\n\n h3 {\n font-size: 15px;\n color: white;\n padding-bottom: 10px;\n border-bottom: 1px solid white;\n }\n\n .description {\n color: white;\n border-radius: 5px;\n\n p {\n small {\n color: ",";\n font-size: 12px;\n }\n }\n\n p:first-child {\n margin-top: 0;\n }\n\n p:last-child {\n margin-bottom: 0;\n }\n }\n"],On||(On=Rn.slice(0)),wn=Object.freeze(Object.defineProperties(Rn,{raw:{value:Object.freeze(On)}}))),xt.ZP.yellow));const Sn=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("h2",{style:{color:"white",fontFamily:'-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif',fontSize:18,fontWeight:"normal"}},"Incidents (Open AI)"),React.createElement(m.O,{p:!0,style:{color:"white"}},"Only the incidents which occured ",React.createElement("b",null,"less than a week ago")," are displayed. The time difference between the PST time used by OpenAI and your local time is ",o," hours."),React.createElement(Tn,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 _n,Nn,Ln;function kn(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var Cn,Pn=I.ZP.div(_n||(_n=kn(["\n background: white;\n padding: 15px;\n border-radius: 5px;\n\n h2 {\n margin-bottom: 8px;\n }\n \n h2:first-child, 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 ul {\n margin: 20px 0 0 0;\n }\n\n li {\n margin-bottom: 5px;\n border: 1px solid #e5e5e5;\n padding: 8px;\n background: #f5f5f5;\n border-radius: 5px;\n cursor: pointer;\n position: relative;\n\n &:last-child {\n margin-bottom: 0;\n }\n\n &:hover {\n background: #e5e5e5;\n }\n\n &.active {\n background: #007cba;\n color: white;\n border-color: #007cba;\n\n &.modified {\n background: #ff8c00;\n border-color: #ff8c00;\n }\n }\n }\n\n .information {\n color: #a3a3a3;\n margin-top: 5px;\n font-size: 12px;\n line-height: 100%;\n }\n"]))),An=(0,I.ZP)(ge.A)(Nn||(Nn=kn(["\n flex: auto !important;\n\n input {\n height: 50px !important;\n font-size: 13px !important;\n font-family: monospace !important;\n padding: 20px !important;\n border-color: #333d4e !important;\n background: #333d4e !important;\n color: white !important;\n }\n"]))),In=I.ZP.div(Ln||(Ln=kn(["\n display: flex;\n flex-direction: column;\n\n .mwai-category {\n text-transform: uppercase;\n margin-bottom: 0;\n padding-bottom: 2px;\n border-bottom: 2px solid #d1e3f2;\n color: #007cb9;\n }\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\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: 10px 0 10px 0;\n }\n\n .neko-spacer {\n margin-bottom: 0 !important;\n }\n\n .neko-input {\n }\n\n .nui-select-option {\n }\n\n\n"]))),Mn=n(5651);function jn(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 Gn(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)?Gn(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 Gn(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 Fn=wp.element,Dn=Fn.useState,Un=Fn.useEffect,Bn=Fn.useRef,Hn=Fn.useCallback,zn=I.ZP.div(Cn||(Cn=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"]))),Yn=function(e){var t=e.name,n=e.value,r=e.onChange,a=Bn(),o=jn(Dn(!1),2),i=o[0],c=o[1],l=jn(Dn(n),2),u=l[0],s=l[1];Un((function(){s(n)}),[n]);var f,m,d=Hn((function(){u!==n&&r(u,t),c(!1)}),[u,n]);return Un((function(){var e=!1,t=!1,n=function(n){!e&&t&&f.current&&!f.current.contains(n.target)&&m(n)},r=function(n){t=f.current,e=f.current&&f.current.contains(n.target)};return document.addEventListener("mousedown",r),document.addEventListener("touchstart",r),document.addEventListener("click",n),function(){document.removeEventListener("mousedown",r),document.removeEventListener("touchstart",r),document.removeEventListener("click",n)}}),[f=a,m=d]),React.createElement(zn,{className:"neko-color-picker"},React.createElement("div",{className:"swatch",style:{backgroundColor:u},onClick:function(){return c(!0)}}),i&&React.createElement("div",{className:"popover",ref:a},React.createElement(Mn.gW,{color:u,onChange:s})))};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(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 qn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Zn(Object(n),!0).forEach((function(t){Vn(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zn(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"!==Wn(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==Wn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===Wn(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Kn(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}function $n(){$n=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 Xn(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)}var Qn=wp.element,er=Qn.useMemo,tr=Qn.useState,nr=Qn.useEffect,rr=[{accessor:"id",title:"ID",width:"50px"},{accessor:"env",title:"Env",width:"80px"},{accessor:"ip",title:"IP",width:"85px"},{accessor:"userId",title:"User",width:"45px"},{accessor:"model",title:"Model"},{accessor:"units",title:"Units",width:"65px",align:"right",sortable:!0},{accessor:"type",title:"Type",width:"50px"},{accessor:"price",title:"Price",width:"85px",align:"right",sortable:!0},{accessor:"time",title:"Time",width:"140px",sortable:!0}],ar=function(){var e,t=(e=$n().mark((function e(t){var n;return $n().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.offset=(t.page-1)*t.limit,e.next=3,(0,R.PV)("".concat(S,"/logs"),{nonce:k,method:"POST",json:t});case 3:return n=e.sent,e.abrupt("return",n?{total:n.total,logs:n.logs}:{total:0,logs:[]});case 5: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){Xn(o,r,a,i,c,"next",e)}function c(e){Xn(o,r,a,i,c,"throw",e)}i(void 0)}))});return function(e){return t.apply(this,arguments)}}();const or=function(){var e=(0,u.NL)(),t=Kn(tr({filters:null,sort:{accessor:"time",by:"desc"},page:1,limit:20}),2),n=t[0],r=t[1],a=(0,Te.a)({queryKey:["logs",n],queryFn:function(){return ar(n)},keepPreviousData:!0}),o=a.isFetching,i=a.data,c=Kn(tr("all"),2),l=c[0],s=c[1],f=lt(C).getModelName;nr((function(){r(qn(qn({},n),{},"all"===l?{filters:null}:{filters:{env:l}}))}),[l]);var m=er((function(){return(null==i?void 0:i.total)||0}),[i]),d=er((function(){return null!=i&&i.logs?null==i?void 0:i.logs.sort((function(e,t){return t.created_at-e.created_at})).map((function(e){var t=new Date(e.time),n=(t=new Date(t.getTime()-60*t.getTimezoneOffset()*1e3)).toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"});return{id:e.id,env:e.env,ip:e.ip,userId:e.userId?React.createElement("a",{target:"_blank",href:"/wp-admin/user-edit.php?user_id=".concat(e.userId)},e.userId):"-",model:React.createElement("span",{title:e.model},f(e.model)),units:e.units,type:e.type,price:React.createElement(React.Fragment,null,"$",e.price),time:n}})):[]}),[i]);return React.createElement(React.Fragment,null,React.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:10}},React.createElement(Oe.h,{value:l,onChange:function(e){s(e),r(qn(qn({},n),{},{page:1}))}},React.createElement(Oe.S,{title:"All",value:"all"}),React.createElement(Oe.S,{title:"Chatbot",value:"chatbot"}),React.createElement(Oe.S,{title:"Form",value:"form"}),React.createElement(Oe.S,{title:"Playground",value:"playground"})),React.createElement("div",null,React.createElement("div",{style:{display:"flex",flexDirection:"row"}},React.createElement(St.Q,{currentPage:n.page,limit:n.limit,total:m,onClick:function(e){r(qn(qn({},n),{},{page:e}))}}),React.createElement(b._,{className:"primary",style:{marginLeft:5},disabled:o,onClick:function(){e.invalidateQueries({queryKey:["logs"]})}},"Refresh")))),React.createElement(Ot.a,{alternateRowColor:!0,busy:o,sort:n.sort,onSortChange:function(e,t){r(qn(qn({},n),{},{sort:{accessor:e,by:t}}))},data:d,columns:rr}))};function ir(e){return ir="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},ir(e)}function cr(){cr=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==ir(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 lr(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 ur(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 sr(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)?sr(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 sr(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 fr=wp.element,mr=fr.useState;fr.useEffect,fr.useMemo;const dr=function(e){var t=e.options,n=e.updateOption,r=e.busy,a=ur(mr("I would love to live on a tropical island with beautiful and sexy felines, where we could bask in the sun on the sandy beaches, sip on refreshing coconut milk, and enjoy each other's company. While we might occasionally fight in the trees, our days would mostly be spent in peaceful slumber. However, I am not sure of how we would handle any potential disruptions to our idyllic existence if human were to come..."),2),o=a[0],i=a[1],c=ur(mr([]),2),l=c[0],u=c[1],s=ur(mr(""),2),f=(s[0],s[1]),m=ur(mr(!1),2),p=m[0],y=m[1],v=null==t?void 0:t.shortcode_chat_moderation,E=p||r,O=function(){var e,t=(e=cr().mark((function e(){var t,n;return cr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y(!0),e.next=3,(0,R.PV)("".concat(S,"/moderate"),{method:"POST",nonce:k,json:{text:o}});case 3:(t=e.sent).success?(n=t.results,u(null==n?void 0:n.results)):f(t.message),y(!1);case 6: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){lr(o,r,a,i,c,"next",e)}function c(e){lr(o,r,a,i,c,"throw",e)}i(void 0)}))});return function(){return t.apply(this,arguments)}}(),x=React.createElement(d.r,{title:Ue.COMMON.CHATBOT},React.createElement(h.P,{name:"shortcode_chat_moderation",label:Ue.COMMON.ENABLE,value:"1",checked:v,description:Ue.SETTINGS.CHATBOT_MODERATION_HELP,onChange:n}));return React.createElement(React.Fragment,null,React.createElement(g.o,null,React.createElement(g.z,{minimal:!0},React.createElement(w.v,{busy:E,title:Ue.COMMON.SETTINGS,className:"primary"},React.createElement("p",null,"You can enable moderation various parts of WordPress. It will slow down the processing a little."),x)),React.createElement(g.z,{minimal:!0},React.createElement(w.v,{busy:E,title:"AI Moderation Tester",className:"primary"},React.createElement("p",null,"Paste a text below, and check if it is safe for your website. ",React.createElement("b",null,"OpenAI Moderation Model is free!")," Learn more about it ",React.createElement("a",{href:"https://platform.openai.com/docs/guides/moderation/overview",target:"_blank"},"here"),"."),React.createElement(we.l,{name:"context",rows:8,value:o,onChange:i}),React.createElement(be.i,null),React.createElement(b._,{fullWidth:!0,onClick:O},"Moderation Check"),React.createElement(be.i,null),React.createElement("label",null,"Results:"),React.createElement("pre",null,JSON.stringify(l,null,2))))))};function pr(e){return pr="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},pr(e)}function hr(e){return function(e){if(Array.isArray(e))return xr(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Or(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 yr(){yr=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==pr(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 vr(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 gr(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){vr(o,r,a,i,c,"next",e)}function c(e){vr(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Er(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 br(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Er(Object(n),!0).forEach((function(t){wr(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Er(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function wr(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==pr(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==pr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===pr(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Rr(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)||Or(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 Or(e,t){if(e){if("string"==typeof e)return xr(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)?xr(e,t):void 0}}function xr(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 Tr=wp.element,Sr=Tr.useState,_r=Tr.useMemo,Nr=Tr.useEffect,Lr=[{accessor:"status",title:"Status",width:"80px"},{accessor:"title",title:"Title",sortable:!0},{accessor:"type",title:"Type",sortable:!0,width:"60px"},{accessor:"refId",title:"Ref",sortable:!0,width:"60px"},{accessor:"score",title:"Score",sortable:!0,width:"65px"},{accessor:"updated",title:"Updated",sortable:!0,width:"80px"},{accessor:"created",title:"Created",sortable:!0,width:"80px"},{accessor:"actions",title:"",width:"65px"}],kr=[{accessor:"status",title:"Status",sortable:!0,width:"80px"},{accessor:"title",title:"Title",sortable:!1},{accessor:"type",title:"Type",sortable:!0,width:"60px"},{accessor:"refId",title:"Ref",sortable:!1,width:"60px"},{accessor:"updated",title:"Updated",sortable:!0,width:"80px"},{accessor:"created",title:"Created",sortable:!0,width:"80px"},{accessor:"actions",title:"",width:"65px"}];const Cr=function(e){var t=e.options,n=e.updateOption,r=(0,u.NL)(),a=(0,s.r)().colors,o=Rr(Sr("post"),2),i=o[0],c=o[1],l=Rr(Sr(!1),2),f=l[0],m=l[1],d=Rr(Sr("edit"),2),p=d[0],y=d[1],v=Rr(Sr(""),2),E=v[0],O=v[1],x=Rr(Sr(!1),2),T=x[0],_=x[1],N=Rr(Sr(!1),2),L=N[0],C=N[1],A=Rr(Sr([]),2),I=A[0],M=A[1],j=Rr(Sr({rewriteContent:!0,prompt:"Rewrite the following content in a concise way, in {LANGUAGE}, with the same style and information. The new content should be less than 800 words and divided into paragraphs of 160-280 words each. Exclude any non-textual elements and eliminate any unnecessary repetition. If you are unable to meet these requirements, please respond with an empty message.\n\n{CONTENT}",createEmbeddingEachParagraph:!1,forceRecreate:!1}),2),G=j[0],F=j[1],D=t.pinecone||{},U=D.indexes||[],B=_r((function(){var e,t=U.find((function(e){return(null==e?void 0:e.name)===(null==D?void 0:D.index)}))||null;return{index:null!==(e=null==t?void 0:t.name)&&void 0!==e?e:"",indexIsReady:!(null==t||!t.ready)}}),[D,U]),H=B.index,z=B.indexIsReady,Y=(0,Te.a)({queryKey:["postTypes"],queryFn:At}),W=Y.isLoading,Z=Y.data,q=(0,Te.a)({queryKey:["postsCount-"+i],queryFn:function(){return ft(i)}}),V=q.isLoading,K=q.data,J=Rr(Sr({filters:{index:H},sort:{accessor:"created",by:"desc"},page:1,limit:20}),2),$=J[0],X=J[1],Q=(0,Te.a)({queryKey:["vectors",$],queryFn:function(){return st($)},keepPreviousData:!0}),ee=Q.isFetching,te=Q.data,ne=Rr(Sr({accessor:"score",by:"desc"}),2),re=ne[0],ae=ne[1],oe=Rr(Sr({total:0,vectors:[]}),2),ie=oe[0],ce=oe[1],le=ee||"searchVectors"===f,ue="search"===p?Lr:kr,se=(0,Nt.qj)({i18n:Ue,onStop:function(){m(),se.reset()}}),fe=f||le||se.isBusy||W;Nr((function(){X(br(br({},$),{},{filters:{index:null!=H?H:""}}))}),[H]),Nr((function(){U.length?H||de(U[0].name):de("")}),[U]),Nr((function(){"edit"===p&&(O(""),ce({total:0,vectors:[]}))}),[p]);var me=function(){var e=gr(yr().mark((function e(){var t,r;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return m("addIndex"),e.next=3,(0,R.PV)("".concat(S,"/pinecone/add_index"),{nonce:k,method:"POST",json:{name:L.name,podType:L.podType}});case 3:if(!(t=e.sent).success){e.next=11;break}return r=br(br({},D),{},{indexes:t.indexes}),e.next=8,n(r,"pinecone");case 8:C(!1),e.next=13;break;case 11:console.error(t.message),alert(t.message);case 13:m(!1);case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),de=function(){var e=gr(yr().mark((function e(t){var r;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=br(br({},D),{},{index:t}),n(r,"pinecone");case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),pe=function(){var e=gr(yr().mark((function e(){var t,r;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(confirm('Are you sure you want to delete the index "'.concat(H,'"? All the related embeddings will be deleted as well.'))){e.next=2;break}return e.abrupt("return");case 2:return m("deleteIndex"),e.next=5,(0,R.PV)("".concat(S,"/pinecone/delete_index"),{nonce:k,method:"DELETE",json:{name:H}});case 5:if(!(t=e.sent).success){e.next=12;break}return r=br(br({},D),{},{indexes:t.indexes}),e.next=10,n(r,"pinecone");case 10:e.next=14;break;case 12:console.error(t.message),alert(t.message);case 14:m(!1);case 15:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),he=function(){var e=gr(yr().mark((function e(){var t,r;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return m("refreshIndexes"),e.next=3,(0,R.PV)("".concat(S,"/pinecone/list_indexes"),{nonce:k,method:"GET"});case 3:if(!(t=e.sent).success){e.next=10;break}return r=br(br({},D),{},{indexes:t.indexes}),e.next=8,n(r,"pinecone");case 8:e.next=12;break;case 10:console.error(t.message),alert(t.message);case 12:m(!1);case 13:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ye=function(){var e=gr(yr().mark((function e(){var t;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return m("searchVectors"),e.next=3,ut(br(br({},$),{},{filters:{env:null!=H?H:"",aiSearch:E}}));case 3:t=e.sent,ce(t),m(!1);case 6:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Oe=function(){var e=gr(yr().mark((function e(){var t,n,a,o,i=arguments;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:T,n=i.length>1&&void 0!==i[1]&&i[1],i.length>2&&void 0!==i[2]&&i[2],n||m("addEmbedding"),e.next=6,(0,R.PV)("".concat(S,"/vector"),{nonce:k,method:"POST",json:{vector:br(br({},t),{},{dbIndex:H})}});case 6:if((a=e.sent).success){e.next=10;break}throw console.error(a.message),new Error(null!==(o=a.message)&&void 0!==o?o:"Unknown error, check your console logs.");case 10:return _(!1),console.log("Embedding Added",t),r.invalidateQueries({queryKey:["vectors"]}),n||m(!1),e.abrupt("return",!0);case 15:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),xe=function(){var e=gr(yr().mark((function e(){var t,n,a,o,i,c,l=arguments;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=l.length>0&&void 0!==l[0]?l[0]:T,(n=l.length>1?l[1]:void 0)||m("addEmbedding"),e.next=5,(0,R.PV)("".concat(S,"/vector"),{nonce:k,method:"PUT",json:{vector:br(br({},t),{},{dbIndex:H})}});case 5:if((a=e.sent).success){e.next=9;break}throw console.error(a.message),new Error(null!==(o=a.message)&&void 0!==o?o:"Unknown error, check your console logs.");case 9:return i=br({},t),_(!1),console.log("Embeddings updated.",t),r.invalidateQueries({queryKey:["vectors"]}),"search"===p&&((c=br({},ie)).vectors=[].concat(hr(c.vectors.filter((function(e){return t.id!==e.id}))),[i]),ce(c)),n||m(!1),e.abrupt("return",!0);case 16:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),_e=function(){var e=gr(yr().mark((function e(t){var n,r,a,o=arguments;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=o.length>1&&void 0!==o[1]&&o[1],o.length>2&&void 0!==o[2]&&o[2],n||m("getEmbedding"),e.next=5,(0,R.PV)("".concat(S,"/vectors_ref"),{nonce:k,method:"POST",json:{refId:t}});case 5:if((r=e.sent).success){e.next=9;break}throw console.error(r.message),new Error(null!==(a=r.message)&&void 0!==a?a:"Unknown error, check your console logs.");case 9:return n||m(!1),e.abrupt("return",r.vectors);case 11:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ne=function(){var e=gr(yr().mark((function e(t,n){var a,o,i;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n||m("deleteEmbedding"),e.next=3,(0,R.PV)("".concat(S,"/vectors"),{nonce:k,method:"DELETE",json:{ids:t}});case 3:if((a=e.sent).success){e.next=7;break}throw console.error(a.message),new Error(null!==(o=a.message)&&void 0!==o?o:"Unknown error, check your console logs.");case 7:console.log("Embeddings deleted.",{ids:t}),r.invalidateQueries({queryKey:["vectors"]}),"search"===p&&((i=br({},ie)).vectors=i.vectors.filter((function(e){return!t.includes(e.id)})),ce(i)),n||m(!1);case 11:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),Le=function(){var e=gr(yr().mark((function e(){return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(confirm("Are you sure you want to delete the selected embeddings?")){e.next=2;break}return e.abrupt("return");case 2:return m("deleteEmbeddings"),e.next=5,Ne(I);case 5:M([]),m(!1);case 7:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ke=function(){var e=gr(yr().mark((function e(t){var n,r,a,o,i,c,l=arguments;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=l.length>1&&void 0!==l[1]?l[1]:"english",r=l.length>2?l[2]:void 0,G.rewriteContent){e.next=4;break}return e.abrupt("return",t);case 4:return a=(a=G.prompt.replace("{CONTENT}",t)).replace("{LANGUAGE}",n),e.next=8,(0,R.PV)("".concat(S,"/make_completions"),{method:"POST",json:{env:"admin-tools",session:P,prompt:a,temperature:.4,model:"gpt-3.5-turbo",maxTokens:4096,stop:""},signal:r,nonce:k});case 8:if((o=e.sent).success){e.next=12;break}throw console.error(o.message),new Error(null!==(i=o.message)&&void 0!==i?i:"Unknown error, check your console logs.");case 12:return c=null==o?void 0:o.data,console.log("Content rewritten.",{from:t,to:c}),e.abrupt("return",c);case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),Ce=_r((function(){return(null==te?void 0:te.total)||0}),[te]),Pe=_r((function(){var e="edit"===p?te:ie;return null!=e&&e.vectors?("search"===p&&(e.vectors=e.vectors.sort((function(e,t){return"asc"===re.by?e[re.accessor]>t[re.accessor]?1:-1:e[re.accessor]<t[re.accessor]?1:-1}))),null==e?void 0:e.vectors.map((function(e){var t=new Date(e.updated),n=(t=new Date(t.getTime()-60*t.getTimezoneOffset()*1e3)).toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),r=new Date(e.created),a=(r=new Date(r.getTime()-60*r.getTimezoneOffset()*1e3)).toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"});return{id:e.id,type:e.type,refId:e.refId?e.refId:"-",score:e.score?(100*e.score.toFixed(4)).toFixed(2):"-",title:e.title,status:e.status,updated:n,created:a,actions:React.createElement(React.Fragment,null,React.createElement(b._,{className:"primary",rounded:!0,icon:"pencil",disabled:fe,onClick:function(){return _(e)}}),React.createElement(b._,{className:"danger",rounded:!0,icon:"trash",disabled:fe,onClick:function(){return Ne([e.id])}}))}}))):[]}),[p,te,ie,re,fe]),Ae=function(){console.log("User aborted."),m(!1),se.reset()},Ie=function(){var e=gr(yr().mark((function e(){var t,n,r,a,o,c,l,u,s,f,m,d,p,h,y,v,g,E=arguments;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return o=E.length>0&&void 0!==E[0]?E[0]:0,c=E.length>1&&void 0!==E[1]?E[1]:void 0,l=E.length>2&&void 0!==E[2]?E[2]:void 0,e.next=5,mt(i,o,c||void 0);case 5:if(u=e.sent,s=null!==(t=null==u?void 0:u.content)&&void 0!==t?t:null,f=null!==(n=null==u?void 0:u.title)&&void 0!==n?n:null,m=null!==(r=null==u?void 0:u.checksum)&&void 0!==r?r:null,d=null!==(a=null==u?void 0:u.language)&&void 0!==a?a:"english",c=null!=u&&u.postId?parseInt(null==u?void 0:u.postId):null,u.success){e.next=13;break}throw new Error(u.message);case 13:return console.log("* Post ID "+c),dt(s)>2048&&(s=pt(s,2048),console.log("Too much content. Reduced it to approximatively 2048 tokens.",{before:u.content,beforeLength:u.content.length,after:s,afterLength:s.length})),e.next=17,_e(c,!0,l);case 17:if(p=e.sent,!(s.length<64)){e.next=29;break}if(!(p.length>0)){e.next=25;break}return e.next=22,Ne(p.map((function(e){return e.id})),!0,l);case 22:console.warn("Content is too short. Embeddings deleted.",{content:s}),e.next=26;break;case 25:console.log("Content is too short. Skipped.",{content:s});case 26:return e.abrupt("return",!1);case 29:if(!(p.length>1)){e.next=34;break}return alert("Multiple embeddings for one single post are not handled yet. Please delete the embeddings related to ".concat(c," manually.")),e.abrupt("return",!1);case 34:if(1!==p.length){e.next=55;break}if((h=p[0]).refChecksum!==m||G.forceRecreate){e.next=40;break}console.log("Embedding exists with same content.",{embedding:h}),e.next=53;break;case 40:return h.refChecksum===m?console.log("Embedding exists with same content (but force re-create)."):console.log("Embedding exists with different content.",{current:h.content,new:s}),e.next=43,ke(s,d,l);case 43:if((y=e.sent)&&!(y.length<64)){e.next=49;break}return e.next=47,Ne(p.map((function(e){return e.id})),!0,l);case 47:return console.warn("Embeddings are too short. Embeddings deleted.",{content:s}),e.abrupt("return",!1);case 49:return e.next=51,xe(br(br({},h),{},{content:y,refChecksum:m}),!0,l);case 51:if(e.sent){e.next=53;break}return e.abrupt("return",!1);case 53:e.next=69;break;case 55:return e.next=57,ke(s,d,l);case 57:if((v=e.sent)&&!(v.length<64)){e.next=63;break}return e.next=61,Ne(p.map((function(e){return e.id})),!0,l);case 61:return console.log("Embeddings are too short. Skipped.",{content:s}),e.abrupt("return",!1);case 63:return g=br(br({},Qe),{},{title:f,content:v,type:"postId",refId:c,refChecksum:m,behavior:"context"}),e.next=66,Oe(g,!0,l);case 66:if(e.sent){e.next=68;break}return e.abrupt("return",!1);case 68:console.log("Embeddings added!",{embedding:g});case 69:return null!=l&&l.aborted&&Ae(),e.abrupt("return",!0);case 71:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Me=function(){var e=gr(yr().mark((function e(){var t,n;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return m("bulkRun"),t=Array.from(Array(K).keys()),n=t.map((function(e){return function(){var t=gr(yr().mark((function t(n){return yr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:t.next=2;break;case 2:return t.next=4,Ie(e,null,n);case 4:return t.abrupt("return",{success:!0});case 5:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}()})),e.next=6,se.start(n);case 6:m(!1),alert("All done!"),se.reset();case 9:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),je=function(){var e=gr(yr().mark((function e(){var t;return yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=prompt("Enter the Post ID to synchronize with:")){e.next=3;break}return e.abrupt("return");case 3:return m("singleRun"),e.prev=4,e.next=7,Ie(0,t);case 7:e.next=12;break;case 9:e.prev=9,e.t0=e.catch(4),alert(e.t0);case 12:m(!1);case 13:case"end":return e.stop()}}),e,null,[[4,9]])})));return function(){return e.apply(this,arguments)}}();return React.createElement(React.Fragment,null,React.createElement(g.o,null,React.createElement(g.z,{fullWidth:!0,minimal:!0,style:{marginBottom:-10}},React.createElement(Ee.H,{style:{margin:10},contentStyle:{padding:10}},React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement(Rt.Q,{style:{marginRight:10},disabled:fe||!H||!z,onLabel:Ue.EMBEDDINGS.AI_SEARCH,offLabel:Ue.EMBEDDINGS.EDIT,width:110,onValue:"search",offValue:"edit",checked:"search"===p,onChange:y,onBackgroundColor:a.purple,offBackgroundColor:a.green}),"search"===p&&React.createElement("div",{style:{flex:"auto",display:"flex"}},React.createElement(ge.A,{style:{flex:"auto",marginRight:5},placeholder:"Search",disabled:fe||!H||!z,value:E,onChange:O,onEnter:ye,onReset:function(){O(),ce({total:0,vectors:[]})}}),React.createElement(b._,{className:"primary",onClick:ye,disabled:fe||!H||!z,isBusy:"searchVectors"===f},"Search")),"edit"===p&&React.createElement(React.Fragment,null,React.createElement(b._,{className:"primary",disabled:fe||!H||!z,onClick:function(){return _(Qe)}},"Add"),I.length>0&&React.createElement(React.Fragment,null,React.createElement(b._,{className:"danger",disabled:fe||!H||!z,onClick:Le},"Delete")),React.createElement("div",{style:{marginRight:10,width:2,background:"#bedceb",marginLeft:10,height:30,borderRadius:10}}),React.createElement(b._,{className:"primary",disabled:fe||!H,isBusy:"singleRun"===f,onClick:function(){return je()}},"Sync One"),React.createElement(b._,{className:"primary",disabled:fe||!H,isBusy:"bulkRun"===f,onClick:function(){return Me()}},"Sync All"),React.createElement("div",{style:{display:"flex",justifyContent:"center",alignItems:"center",paddingLeft:10}},"Based on ",V&&"...",!V&&K),React.createElement(ve.N,{id:"postType",scrolldown:!0,disabled:fe,name:"postType",style:{width:100,marginLeft:10},onChange:c,value:i},null==Z?void 0:Z.map((function(e){return React.createElement(ve.Z,{key:e.type,value:e.type,label:e.name})}))),React.createElement(_t.U,{busy:se.busy,style:{marginLeft:10,flex:"auto"},value:se.value,max:se.max,onStopClick:se.stop}))))),React.createElement(g.z,{minimal:!0,style:{flex:3}},React.createElement(w.v,{className:"primary"},React.createElement(Ot.a,{busy:fe,sort:"edit"===p?$.sort:re,onSortChange:function(e,t){"edit"===p?X(br(br({},$),{},{sort:{accessor:e,by:t}})):ae({accessor:e,by:t})},data:Pe,columns:ue,onSelect:function(e){M([].concat(hr(I),hr(e)))},onUnselect:function(e){M(hr(I.filter((function(t){return!e.includes(t)}))))},selectedItems:I}),React.createElement(be.i,null),React.createElement("div",{style:{display:"flex",justifyContent:"end"}},React.createElement(St.Q,{currentPage:$.page,limit:$.limit,total:Ce,onClick:function(e){X(br(br({},$),{},{page:e}))}}),React.createElement(b._,{className:"primary",style:{marginLeft:5},disabled:le||!H,onClick:function(){r.invalidateQueries({queryKey:["vectors"]})}},"Refresh")))),React.createElement(g.z,{minimal:!0},React.createElement(w.v,{className:"primary"},React.createElement("label",null,"Index:"),React.createElement(ve.N,{fullWidth:!0,scrolldown:!0,name:"server",style:{marginRight:5},disabled:fe,value:D.index,onChange:function(e){return de(e)}},U.map((function(e){return React.createElement(ve.Z,{value:e.name,label:e.name})})),!(null!=U&&U.length)&&React.createElement(ve.Z,{value:"",label:"None"})),React.createElement(be.i,null),React.createElement("div",{style:{display:"flex"}},React.createElement(b._,{className:"primary",onClick:function(){return C(et)},style:{flex:1},isBusy:"addIndex"===f,disabled:fe},"Add Index"),React.createElement(b._,{className:"secondary",onClick:he,style:{flex:1},isBusy:"refreshIndexes"===f,disabled:fe},"Refresh"),React.createElement(b._,{className:"danger",onClick:pe,style:{flex:1},isBusy:"deleteEmbeddings"===f,disabled:fe||!H||!z},"Delete")),React.createElement(be.i,null),React.createElement("label",null,"Namespace:"),React.createElement(ge.A,{fullWidth:!0,disabled:!0,value:D.namespace}),H&&!z&&React.createElement(Re.S,{variant:"danger",style:{marginTop:15,padding:"8px 12px"}},"This index is currently being build by Pinecone. Wait a few minutes, then use the ",React.createElement("b",null,"Refresh")," button."),React.createElement("p",null,"The embeddings of this index will be used by the chatbot to build an answer if ",React.createElement("b",null,"the score for the query is above 75"),". More control over this will be available soon.")),React.createElement(w.v,{className:"primary",title:"Sync Settings"},React.createElement(h.P,{label:"Rewrite content (using GPT Turbo)",checked:G.rewriteContent,onChange:function(e){F(br(br({},G),{},{rewriteContent:e}))},description:"Your content might contain badly formatted text, be too long, repetitive, etc. By enabling this option, the content will be rewritten using GPT Turbo."}),React.createElement(be.i,null),G.rewriteContent&&React.createElement(we.l,{value:G.prompt,rows:10,onChange:function(e){F(br(br({},G),{},{prompt:e}))},description:"This is the prompt that will be used to rewrite the content. Use {CONTENT} to insert the original content."}),React.createElement(h.P,{label:"Force re-create",checked:G.forceRecreate,onChange:function(e){F(br(br({},G),{},{forceRecreate:e}))},description:"Re-create all the embeddings, even if they already exist with the same content."}))),React.createElement(g.z,{fullWidth:!0,minimal:!0},React.createElement(w.v,{title:"Quick Tutorial",className:"primary"},React.createElement("p",null,React.createElement("b",null,"This is beta! It works but it will need to be perfected. If you have any feedback, or want to discuss this, visit ",React.createElement("a",{href:"https://discord.gg/bHDGh38",target:"_blank"},"my discord server"),".")),React.createElement("p",null,"An embedding is a textual piece of data (sentence, paragraph, a whole article) that has been converted by OpenAI into a vector. Vectors can then be used to find the most relevant data for a given query. In this dashboard, you can create embeddings, and they will be synchronized with ",React.createElement("a",{target:"_blank",href:"https://www.pinecone.io/"},"Pinecone"),", a very fast and affordable vector database."),React.createElement("p",null,"You can switch from EDIT to AI SEARCH and you will be able to query the database, and get your content, with a score. You can edit the content and it will be synchronized with Pinecone. Then make your content perfect so that the results are satisfying! You can use Sync and Sync One, it will go through your posts and create the embeddings if they don't exist yet, or update them if they do."),React.createElement("p",null,"The chatbot can use the embeddings to answer questions. To activate this feature, you will need to add ",React.createElement("i",null,"embeddings_index")," to the chatbot. Check the builder! 😌"),React.createElement("p",null,React.createElement("i",null,"If you are able to make a simpler, quicker and better explanation than me, please let me know! Thank you!"))))),React.createElement(Se.L,{isOpen:T,title:null!=T&&T.id?"Modify Embedding":"Add Embedding",onOkClick:function(){null!=T&&T.id?xe():Oe()},onRequestClose:function(){return _(null)},onCancelClick:function(){return _(null)},ok:null!=T&&T.id?"Modify":"Add",disabled:"addEmbedding"===f,content:React.createElement(React.Fragment,null,React.createElement("p",null,"A custom embedding can be a sentence, a paragraph or a whole article. When an user input is made, the AI will search for the best embedding that matches the user input and will be able to answer with more accuracy."),React.createElement(be.i,{height:30}),React.createElement("label",null,"Title:"),React.createElement(be.i,null),React.createElement(ge.A,{value:null==T?void 0:T.title,placeholder:'Title, like "My Website Information"',description:"This is for your convenience only, it's not used anywhere.",onChange:function(e){return _(br(br({},T),{},{title:e}))}}),React.createElement(be.i,null),React.createElement("label",null,"Content:"),React.createElement(be.i,null),React.createElement(we.l,{value:null==T?void 0:T.content,onChange:function(e){return _(br(br({},T),{},{content:e}))}}),React.createElement(be.i,null),React.createElement("label",null,"Behavior:"),React.createElement(be.i,null),React.createElement(ve.N,{scrolldown:!0,name:"behavior",disabled:fe||!0,value:null==T?void 0:T.behavior,onChange:function(e){_(br(br({},T),{},{behavior:e}))}},React.createElement(ve.Z,{value:"context",label:"Context"}),React.createElement(ve.Z,{value:"answer",label:"Answer"})),React.createElement(be.i,null),React.createElement("label",null,"Type:"),React.createElement(be.i,null),React.createElement(ve.N,{scrolldown:!0,name:"type",disabled:fe||!0,value:null==T?void 0:T.type,onChange:function(e){_(br(br({},T),{},{type:e}))}},React.createElement(ve.Z,{value:"manual",label:"Manual"}),React.createElement(ve.Z,{value:"post",label:"Post (Whole)"}),React.createElement(ve.Z,{value:"post-fragment",label:"Post (Fragment)"})),("post"===(null==T?void 0:T.type)||"post-fragment"===(null==T?void 0:T.type))&&React.createElement(React.Fragment,null,React.createElement(be.i,null),React.createElement("label",null,"Post ID:"),React.createElement(be.i,null),React.createElement(ge.A,{value:null==T?void 0:T.refId,onChange:function(e){return _(br(br({},T),{},{refId:e}))}})))}),React.createElement(Se.L,{isOpen:L,title:"Add Index",onOkClick:me,onRequestClose:function(){return C(null)},onCancelClick:function(){return C(null)},ok:"Add Index",disabled:"addIndex"===f,content:React.createElement(React.Fragment,null,React.createElement("p",null,"An index is like a database, and contains embeddings. You can have many indexes and switch between them. The indexes are hosted on Pinecone."),React.createElement(be.i,{height:30}),React.createElement("label",null,"Name:"),React.createElement(be.i,null),React.createElement(ge.A,{value:null==L?void 0:L.name,placeholder:"Name for your index",onChange:function(e){return C(br(br({},L),{},{name:e}))}}),React.createElement(be.i,null),React.createElement("label",null,"Type:"),React.createElement(be.i,null),React.createElement(ve.N,{scrolldown:!0,name:"podType",disabled:fe,value:null==L?void 0:L.podType,onChange:function(e){C(br(br({},L),{},{podType:e}))},description:React.createElement(React.Fragment,null,"Pick S1 only if you will have more than 1 million of embeddings. P2 is faster for querying, slower for adding, and more expensive if you are not using the ",React.createElement("a",{href:"https://www.pinecone.io/pricing/",target:"_blank"},"Starter Plan")," (free) of Pinecone. P2 is recommended.")},React.createElement(ve.Z,{value:"s1",label:"S1 (5M Embeddings)"}),React.createElement(ve.Z,{value:"p1",label:"P1 (1M Embeddings & High Perf)"}),React.createElement(ve.Z,{value:"p2",label:"P2 (1M Embeddings & Max Perf)"})))}),se.TasksErrorModal)};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}wp.i18n.__;var Ar=wp.element,Ir=Ar.useMemo,Mr=Ar.useState,jr=function(e){var t,n,r=e.month,a=e.usageData,o=(new Date).toISOString().slice(0,7),i=(t=Mr(o==r),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)||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}}(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.")}()),c=i[0],l=i[1];return React.createElement("li",null,React.createElement("strong",{style:{marginLeft:5,cursor:"pointer"},onClick:function(){return l(!c)}},"🗓️ ",r," (",a[r].totalPrice.toFixed(2),"$)",React.createElement("span",{style:{marginLeft:5}},c?"🔽":"🔼")),React.createElement("ul",null,c&&a[r].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(4),"$)"))}))))};const Gr=function(e){var t=e.options,n=lt(t),r=n.models,a=n.getModelName,o=n.getModel,i=n.calculatePrice,c=null==t?void 0:t.openai_usage,l=Ir((function(){var e={};try{var t=(new Date).toISOString().slice(0,7);Object.keys(c).forEach((function(n){var r=c[n];e[n]||(e[n]={totalPrice:0,data:[]}),Object.keys(r).forEach((function(c){var l=r[c],u=o(c);if(u){var s=i(c,(null==l?void 0:l.total_tokens)||(null==l?void 0:l.images)||0);e[n].totalPrice+=s,e[n].data.push({name:a(c),isImage:"image"===u.type,usage:"image"===u.type?l.images:l.total_tokens,price:s})}else n===t&&console.warn("Cannot find price for model ".concat(c,"."))}))})),Object.keys(e).forEach((function(t){e[t].data.sort((function(e,t){return t.price-e.price}))}))}catch(e){console.error(e)}return React.createElement("ul",{style:{marginLeft:-7,marginTop:10,marginBottom:0,paddingBottom:0}},Object.keys(e).reverse().map((function(t,n){return React.createElement(jr,{key:n,month:t,usageData:e})})))}),[c,r]);return React.createElement(React.Fragment,null,!!c&&!!Object.keys(c).length&&l)};function Fr(e){return Fr="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},Fr(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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==Fr(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 Ur(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 Br(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 Hr(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)?Hr(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 Hr(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 zr=wp.element.useState;const Yr=function(){var e=Br(zr(""),2),t=e[0],n=e[1],r=Br(zr("transcription"),2),a=r[0],o=r[1],i=Br(zr(""),2),c=i[0],l=i[1],u=Br(zr(""),2),s=u[0],f=u[1],m=Br(zr(""),2),d=(m[0],m[1]),p=Br(zr(!1),2),h=p[0],y=p[1],v=function(){var e,n=(e=Dr().mark((function e(){var n,r;return Dr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y(!0),e.next=3,(0,R.PV)("".concat(S,"/transcribe"),{method:"POST",nonce:k,json:{url:t,prompt:s,mode:a}});case 3:(n=e.sent).success?(r=n.data,console.log(r),l(r)):d(n.message),y(!1);case 6: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){Ur(o,r,a,i,c,"next",e)}function c(e){Ur(o,r,a,i,c,"throw",e)}i(void 0)}))});return function(){return n.apply(this,arguments)}}();return React.createElement(React.Fragment,null,React.createElement(g.o,null,React.createElement(g.z,{minimal:!0},React.createElement(w.v,{busy:h,title:"Params",className:"primary"},React.createElement("p",null,"I have added this for you to play with. Let's see if we move into other parts of the WordPress UI or not! 😬 Don't hesitate to share your ideas. Costs are not added in AI Engine, as the requires usage data is not returned by OpenAI for this model."),React.createElement("label",null,"Audio URL:"),React.createElement(be.i,null),React.createElement(we.l,{name:"url",rows:1,value:t,onChange:n}),React.createElement(be.i,null),React.createElement("label",null,"Prompt:"),React.createElement(be.i,null),React.createElement(we.l,{rows:2,value:s,onChange:f,description:React.createElement(React.Fragment,null,"This optional prompt allows you to give more information about the audio transcript. More information ",React.createElement("a",{href:"https://platform.openai.com/docs/guides/speech-to-text/prompting",target:"_blank"},"here"),".")}),React.createElement(be.i,null),React.createElement("label",null,"Mode:"),React.createElement(be.i,null),React.createElement(ve.N,{fullWidth:!0,scrolldown:!0,value:a,onChange:o,description:React.createElement(React.Fragment,null,"For more information about languages support, have a look ",React.createElement("a",{href:"https://platform.openai.com/docs/guides/speech-to-text/translations",target:"_blank"},"here"),".")},React.createElement(ve.Z,{value:"transcription",label:"Transcription (Any Language)"}),React.createElement(ve.Z,{value:"translation",label:"Transcription (Any Language) + Translation into English"})),React.createElement(be.i,{height:65}),React.createElement(b._,{fullWidth:!0,style:{height:40},onClick:v},"Transcribe"))),React.createElement(g.z,{minimal:!0},React.createElement(w.v,{title:"Transcription",className:"primary"},React.createElement(be.i,null),React.createElement(we.l,{name:"context",rows:21,value:c,disabled:!c})))))};function Wr(e){return Wr="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},Wr(e)}var Zr,qr,Vr,Kr;function Jr(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 $r(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Jr(Object(n),!0).forEach((function(t){Xr(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Jr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Xr(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==Wr(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==Wr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===Wr(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qr(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 ea(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)?ea(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 ea(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 ta(){ta=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==Wr(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 na(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 ra(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){na(o,r,a,i,c,"next",e)}function c(e){na(o,r,a,i,c,"throw",e)}i(void 0)}))}}function aa(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var oa=wp.element,ia=oa.useMemo,ca=oa.useState,la=oa.useEffect,ua=I.ZP.div(Zr||(Zr=aa(["\n font-size: 12px;\n border-bottom: 1px solid black;\n"]))),sa=I.ZP.span(qr||(qr=aa(["\n font-weight: bold;\n text-transform: uppercase;\n"]))),fa=I.ZP.div(Vr||(Vr=aa(["\n font-size: 12px;\n color: #bdb8b8;\n background: #eeeeee;\n padding: 2px 8px;\n"]))),ma=I.ZP.div(Kr||(Kr=aa(["\n"]))),da=function(e){var t,n=e.message,r=null==n||null===(t=n.extra)||void 0===t?void 0:t.embedding;return React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement(ua,null,React.createElement(sa,null,n.type)),r&&React.createElement(fa,null,"Embedding: ",r.title," (",r.score.toFixed(2),")"),React.createElement(ma,null,n.text))},pa=[{accessor:"id",title:"ID",width:"50px"},{accessor:"lastMessage",title:"Last User Message"},{accessor:"messages",title:"#",width:"45px"},{accessor:"updated",title:"Last Update",width:"140px",sortable:!0}],ha=function(){var e=ra(ta().mark((function e(t){var n;return ta().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t.offset=(t.page-1)*t.limit,e.next=3,(0,R.PV)("".concat(S,"/chats"),{nonce:k,method:"POST",json:t});case 3:return n=e.sent,e.abrupt("return",n?{total:n.total,chats:n.chats}:{total:0,chats:[]});case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ya=function(){var e=ra(ta().mark((function e(t){var n;return ta().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,R.PV)("".concat(S,"/chats_delete"),{nonce:k,method:"POST",json:{chatId:t}});case 2:return n=e.sent,e.abrupt("return",n);case 4:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();const va=function(){var e,t,n,r,a=(0,u.NL)(),o=Qr(ca({filters:null,sort:{accessor:"created",by:"desc"},page:1,limit:10}),2),i=o[0],c=o[1],l=Qr(ca(!1),2),s=l[0],f=l[1],m=(0,Te.a)({queryKey:["chats",i],queryFn:function(){return ha(i)},keepPreviousData:!0,refetchInterval:s?5e3:null}),d=m.isFetching,p=m.data,y=Qr(ca("all"),2),v=y[0],E=(y[1],Qr(ca(null),2)),R=E[0],O=E[1];la((function(){c($r($r({},i),{},"all"===v?{filters:null}:{filters:{env:v}}))}),[v]);var x=ia((function(){return(null==p?void 0:p.total)||0}),[p]),T=ia((function(){return null!=p&&p.chats?null==p?void 0:p.chats.sort((function(e,t){return t.created_at-e.created_at})).map((function(e){var t,n=new Date(e.created),r=(n=new Date(n.getTime()-60*n.getTimezoneOffset()*1e3)).toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),a=new Date(e.updated),o=(a=new Date(a.getTime()-60*a.getTimezoneOffset()*1e3)).toLocaleDateString("ja-JP",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}),i=JSON.parse(e.messages),c=JSON.parse(e.extra),l=null==i?void 0:i.filter((function(e){return"user"===e.type})),u=null!=l&&l.length?l[l.length-1].text:"";return{id:e.id,chatId:e.chatId,messages:null!==(t=null==i?void 0:i.length)&&void 0!==t?t:0,lastMessage:u,extra:c.model,created:r,updated:o}})):[]}),[p]),S=ia((function(){if(!R)return null;var e=null==p?void 0:p.chats.find((function(e){return e.id===R}));if(!e)return null;var t=[],n={};try{t=JSON.parse(e.messages),n=JSON.parse(e.extra)}catch(e){console.log(e)}return{id:e.id,chatId:e.chatId,messages:t,extra:n,created:e.created,updated:e.updated}}),[R,p]),_=function(){var e=ra(ta().mark((function e(){return ta().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ya(S.chatId);case 2:a.invalidateQueries("chats");case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return React.createElement(React.Fragment,null,React.createElement(g.o,null,React.createElement(g.z,{minimal:!0,fullWidth:!0},React.createElement(Re.S,{variant:"success",style:{padding:"5px 10px"}},React.createElement("b",null,"This is extremely beta!")," I need your feedback. I am looking for ways to make this useful for you. The idea is that you can improve your chatbot by analyzing the conversations (then delete them when done). Another idea is to interact in a way or another with those conversations.")),React.createElement(g.z,{minimal:!0},React.createElement(w.v,{className:"primary",title:Ue.COMMON.DISCUSSIONS,action:React.createElement(React.Fragment,null,!s&&React.createElement(b._,{className:"primary",style:{marginLeft:5},disabled:d,onClick:function(){a.invalidateQueries({queryKey:["chats"]})}},"Refresh"))},React.createElement(Ot.a,{busy:!s&&d,selectedRow:R||[],sort:i.sort,onSortChange:function(e,t){c($r($r({},i),{},{sort:{accessor:e,by:t}}))},data:T,columns:pa,onSelectRow:function(e){O(e[0])}}),React.createElement("div",{style:{display:"flex",justifyContent:"space-between",marginTop:10}},React.createElement(h.P,{name:"auto-refresh",label:"Auto Refresh",value:"1",checked:s,onChange:function(){return f(!s)}}),React.createElement("div",null,React.createElement("div",{style:{display:"flex",flexDirection:"row"}},React.createElement(St.Q,{currentPage:i.page,limit:i.limit,total:x,onClick:function(e){c($r($r({},i),{},{page:e}))}})))))),React.createElement(g.z,{minimal:!0},React.createElement(w.v,{className:"primary",title:"Selected Discussion",action:React.createElement(React.Fragment,null,S&&React.createElement(b._,{className:"danger",onClick:_},"Delete"))},!S&&React.createElement("div",{style:{textAlign:"center",padding:10}},"No discussion selected."),null==S||null===(e=S.messages)||void 0===e?void 0:e.map((function(e,t){return React.createElement(da,{key:t,message:e})}))),!!S&&React.createElement(w.v,{className:"primary",title:"Information",action:React.createElement(React.Fragment,null)},React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{width:100,fontWeight:"bold"}},"Model"),React.createElement("div",null,null==S||null===(t=S.extra)||void 0===t?void 0:t.model)),React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{width:100,fontWeight:"bold"}},"Created"),React.createElement("div",null,null==S?void 0:S.created)),React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{width:100,fontWeight:"bold"}},"Updated"),React.createElement("div",null,null==S?void 0:S.updated)),React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{width:100,fontWeight:"bold"}},"IP"),React.createElement("div",null,null==S||null===(n=S.extra)||void 0===n?void 0:n.ip)),React.createElement("div",{style:{display:"flex",flexDirection:"column",marginBottom:5}},React.createElement("div",{style:{width:100,fontWeight:"bold"}},"UserID"),React.createElement("div",null,null==S||null===(r=S.extra)||void 0===r?void 0:r.userId))))))};function ga(e){return ga="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},ga(e)}function Ea(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 ba(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)?ba(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 ba(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 wa(){wa=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==ga(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 Ra(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 Oa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ra(Object(n),!0).forEach((function(t){xa(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ra(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function xa(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==ga(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==ga(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===ga(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ta(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 Sa(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Ta(o,r,a,i,c,"next",e)}function c(e){Ta(o,r,a,i,c,"throw",e)}i(void 0)}))}}var _a=wp.element,Na=_a.useMemo,La=_a.useState,ka=_a.useEffect,Ca=["chat-robot-1.svg","chat-robot-2.svg","chat-robot-3.svg","chat-robot-4.svg","chat-robot-5.svg","chat-robot-6.svg","chat-color-blue.svg","chat-color-green.svg","chat-color-red.svg","chat-traditional-1.svg","chat-traditional-2.svg","chat-traditional-3.svg"],Pa=function(){var e=Sa(wa().mark((function e(){var t,n;return wa().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,R.PV)("".concat(S,"/openai_incidents"),{nonce:k});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 Oa(Oa({},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 Aa=function(){var e,t,n,r,a,o,i,c,l,u,s,f,v,T,P,A,I,M,j,G,F,D,U,B,H,z,Y=Ea(La(C),2),W=Y[0],Z=Y[1],q=Ea(La(!1),2),V=q[0],K=q[1],J=Ea(La("users"),2),$=J[0],X=J[1],Q=lt(W),ee=Q.completionModels,te=Q.isFineTunedModel,ne=Q.getModel,re=null==W?void 0:W.shortcode_chat_default_params,ae=null==W?void 0:W.shortcode_chat_params,oe=null==W?void 0:W.shortcode_chat_styles,ie=null==W?void 0:W.shortcode_chat_params_override,ce=null==W?void 0:W.shortcode_chat_inject,le=null==W?void 0:W.module_suggestions,ue=null==W?void 0:W.module_woocommerce,se=null==W?void 0:W.module_forms,fe=null==W?void 0:W.module_finetunes,me=null==W?void 0:W.module_statistics,de=null==W?void 0:W.module_playground,pe=null==W?void 0:W.module_generator_content,he=null==W?void 0:W.module_generator_images,ye=null==W?void 0:W.module_moderation,Se=null==W?void 0:W.module_embeddings,_e=null==W?void 0:W.module_audio,Ne=null==W?void 0:W.limits,Le=null==W?void 0:W.default_limits,ke=null==W?void 0:W.shortcode_chat,Ce=null==W?void 0:W.shortcode_chat_formatting,Pe=null==W?void 0:W.shortcode_chat_logs,Ae=null!=W&&W.openai_apikey?null==W?void 0:W.openai_apikey:"",Ie=null==W?void 0:W.pinecone,Me=null==W?void 0:W.shortcode_chat_syntax_highlighting,je=null==W?void 0:W.shortcode_chat_typewriter,Fe=null==W?void 0:W.shortcode_chat_discussions,De=null==W?void 0:W.debug_mode,Be=null==W?void 0:W.dynamic_max_tokens,He=null==W?void 0:W.resolve_shortcodes,ze=null!==(e="chat"===(null==ae?void 0:ae.mode))&&void 0!==e?e:"chat",Ye=null!==(t="images"===(null==ae?void 0:ae.mode))&&void 0!==t&&t,We=null!=oe&&oe.icon?null==oe?void 0:oe.icon:"chat-color-green.svg",Ze=(null==We?void 0:We.startsWith("https://"))||(null==We?void 0:We.startsWith("http://")),qe=Ze?We:"".concat(_,"/images/").concat(We),Ve=(0,Te.a)({queryKey:["openAI_status"],queryFn:Pa}),Ke=Ve.isLoading,Je=Ve.data,$e=Ie.indexes||[],Xe=te(ae.model),Qe=ne(ae.model),et=ae.content_aware,nt=ae.context&&ae.context.includes("{CONTENT}"),rt=null==Je?void 0:Je.filter((function(e){return new Date(e.date)>new Date(Date.now()-864e5)})).length,at=V,ot=Na((function(){var e={};if(ie)return e;for(var t in re)re[t]!==ae[t]&&(e[t]=ae[t]);return ze&&(delete e.mode,delete e.max_results),Ye&&(delete e.context,delete e.content_aware,delete e.casually_fine_tuned,delete e.model,delete e.max_tokens,delete e.temperature),e}),[ie,re,ae]),it=Na((function(){var e=[];for(var t in ot)if(void 0!==ae[t]){var n=ae[t];n&&"string"==typeof n&&n.includes('"')&&(n=n.replace(/"/g,"'")),n&&"string"==typeof n&&n.includes("\n")&&(n=n.replace(/\n/g,"\\n")),n&&"string"==typeof n&&n.includes("[")&&(n=n.replace(/\[/g,"[")),n&&"string"==typeof n&&n.includes("]")&&(n=n.replace(/\]/g,"]")),e.push("".concat(t,'="').concat(n,'"'))}var r=e.join(" ");return"[mwai_chat"+(r?" ".concat(r):"")+"]"}),[ot]),ct=function(){var e=Sa(wa().mark((function e(t,n){var r,a;return wa().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=Oa(Oa({},W),{},xa({},n,t)),JSON.stringify(r)!==JSON.stringify(W)){e.next=4;break}return console.log("Options are already up to date."),e.abrupt("return");case 4:return K(!0),e.prev=5,e.next=8,(0,R.PV)("".concat(S,"/update_option"),{method:"POST",nonce:k,json:{options:r}});case 8:(a=e.sent).success&&Z(a.options),e.next=15;break;case 12:e.prev=12,e.t0=e.catch(5),e.t0.message&&alert(e.t0.message);case 15:return e.prev=15,K(!1),e.finish(15);case 18:case"end":return e.stop()}}),e,null,[[5,12,15,18]])})));return function(t,n){return e.apply(this,arguments)}}();ka((function(){"chat"!==(null==Qe?void 0:Qe.mode)&&ae.embeddings_index&&ut("","embeddings_index")}),[ae]);var ut=function(){var e=Sa(wa().mark((function e(t,n){var r;return wa().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Oa(Oa({},ae),{},xa({},n,t)),e.next=3,ct(r,"shortcode_chat_params");case 3:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),st=function(){var e=Sa(wa().mark((function e(t,n){var r;return wa().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=Oa(Oa({},Ne),{},xa({},n,t)),e.next=3,ct(r,"limits");case 3:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),ft=function(){var e=Sa(wa().mark((function e(t,n){var r,a;return wa().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"credits"===n&&(t=Math.max(0,t)),r=Oa(Oa({},Ne.users),{},xa({},n,t)),a=Oa(Oa({},Ne),{},{users:r}),e.next=5,ct(a,"limits");case 5:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),mt=function(){var e=Sa(wa().mark((function e(t,n){var r,a;return wa().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return"credits"===n&&(t=Math.max(0,t)),r=Oa(Oa({},Ne.guests),{},xa({},n,t)),a=Oa(Oa({},Ne),{},{guests:r}),e.next=5,ct(a,"limits");case 5:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),dt=function(){var e=Sa(wa().mark((function e(t,n){var r;return wa().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t){e.next=4;break}return r=Oa(Oa({},oe),{},xa({},n,t)),e.next=4,ct(r,"shortcode_chat_styles");case 4:case"end":return e.stop()}}),e)})));return function(t,n){return e.apply(this,arguments)}}(),pt=function(){var e=Sa(wa().mark((function e(t){var n;return wa().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.startsWith("http://")&&!t.startsWith("https://")){e.next=6;break}return n=Oa(Oa({},oe),{},{icon:t}),e.next=4,ct(n,"shortcode_chat_styles");case 4:e.next=7;break;case 6:alert("Please enter a valid URL.");case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),ht=function(){var e=Sa(wa().mark((function e(){return wa().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ct(re,"shortcode_chat_params");case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),vt=function(){var e=Sa(wa().mark((function e(){return wa().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ct({},"shortcode_chat_styles");case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),gt=function(){var e=Sa(wa().mark((function e(){return wa().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,ct(Le,"limits");case 2:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),Et=React.createElement(d.r,{title:Ue.COMMON.ASSISTANTS},React.createElement(p.l,{max:"1"},React.createElement(h.P,{name:"module_suggestions",label:Ue.COMMON.POSTS_SUGGESTIONS,value:"1",checked:le,description:Ue.COMMON.POSTS_SUGGESTIONS_HELP,onChange:ct}),React.createElement(h.P,{name:"module_woocommerce",label:Ue.COMMON.WOOCOMMERCE_PRODUCT_GENERATOR,value:"1",checked:ue,description:Ue.COMMON.WOOCOMMERCE_PRODUCT_GENERATOR_HELP,onChange:ct}))),bt=React.createElement(d.r,{title:Ue.COMMON.GENERATORS},React.createElement(p.l,{max:"1"},React.createElement(h.P,{name:"module_generator_content",label:Ue.COMMON.CONTENT_GENERATOR,value:"1",checked:pe,description:Ue.COMMON.CONTENT_GENERATOR_HELP,onChange:ct}),React.createElement(h.P,{name:"module_generator_images",label:Ue.COMMON.IMAGES_GENERATOR,value:"1",checked:he,description:Ue.COMMON.IMAGES_GENERATOR_HELP,onChange:ct}))),wt=React.createElement(d.r,{title:Ue.COMMON.PLAYGROUND},React.createElement(h.P,{name:"module_playground",label:Ue.COMMON.ENABLE,value:"1",checked:de,description:Ue.COMMON.PLAYGROUND_HELP,onChange:ct})),Rt=React.createElement(d.r,{title:React.createElement(React.Fragment,null,Ue.COMMON.FORMS,React.createElement("small",{style:{position:"relative",top:-3,fontSize:8}}," BETA"))},React.createElement(h.P,{name:"module_forms",label:Ue.COMMON.ENABLE,value:"1",checked:se,requirePro:!0,isPro:L,description:Ue.COMMON.FORMS_HELP,onChange:ct})),Ot=React.createElement(d.r,{title:Ue.COMMON.FINETUNES},React.createElement(h.P,{name:"module_finetunes",label:Ue.COMMON.ENABLE,value:"1",checked:fe,description:Ue.HELP.FINETUNES,onChange:ct})),xt=React.createElement(d.r,{title:React.createElement(React.Fragment,null,Ue.COMMON.STATISTICS,React.createElement("small",{style:{position:"relative",top:-3,fontSize:8}}," BETA"))},React.createElement(h.P,{name:"module_statistics",label:Ue.COMMON.ENABLE,value:"1",checked:me,requirePro:!0,isPro:L,description:Ue.COMMON.STATISTICS_HELP,onChange:ct})),Tt=React.createElement(d.r,{title:React.createElement(React.Fragment,null,Ue.COMMON.MODERATION,React.createElement("small",{style:{position:"relative",top:-3,fontSize:8}}," BETA"))},React.createElement(h.P,{name:"module_moderation",label:Ue.COMMON.ENABLE,value:"1",checked:ye,description:Ue.COMMON.MODERATION_HELP,onChange:ct})),St=React.createElement(d.r,{title:React.createElement(React.Fragment,null,Ue.COMMON.AUDIO_TRANSCRIPTION,React.createElement("small",{style:{position:"relative",top:-3,fontSize:8}}," BETA"))},React.createElement(h.P,{name:"module_audio",label:Ue.COMMON.ENABLE,value:"1",checked:_e,description:Ue.COMMON.AUDIO_TRANSCRIPTION_HELP,onChange:ct})),_t=React.createElement(d.r,{title:React.createElement(React.Fragment,null,Ue.COMMON.EMBEDDINGS,React.createElement("small",{style:{position:"relative",top:-3,fontSize:8}}," BETA"))},React.createElement(h.P,{name:"module_embeddings",label:Ue.COMMON.ENABLE,value:"1",checked:Se,requirePro:!0,isPro:L,description:Ue.COMMON.EMBEDDINGS_HELP,onChange:ct})),Nt=React.createElement(d.r,{title:Ue.COMMON.CHATBOT},React.createElement(p.l,{max:"1"},React.createElement(h.P,{name:"shortcode_chat",label:Ue.COMMON.ENABLE,value:"1",checked:ke,description:Ue.COMMON.CHATBOT_HELP,onChange:ct}))),Lt=React.createElement(d.r,{title:Ue.COMMON.FORMATTING},React.createElement(p.l,{max:"1"},React.createElement(h.P,{name:"shortcode_chat_formatting",label:Ue.COMMON.ENABLE,value:"1",checked:Ce,description:(0,R.io)(Ue.COMMON.FORMATTING_HELP),onChange:ct}))),kt=React.createElement(d.r,{title:Ue.SETTINGS.TYPEWRITER_EFFECT},React.createElement(p.l,{max:"1"},React.createElement(h.P,{name:"shortcode_chat_typewriter",label:Ue.COMMON.ENABLE,value:"1",checked:je,description:Ue.SETTINGS.TYPEWRITER_EFFECT_HELP,onChange:ct}))),Ct=React.createElement(d.r,{title:Ue.COMMON.DISCUSSIONS},React.createElement(p.l,{max:"1"},React.createElement(h.P,{name:"shortcode_chat_discussions",label:Ue.COMMON.ENABLE,value:"1",checked:Fe,description:Ue.HELP.DISCUSSIONS,onChange:ct}))),Pt=React.createElement(d.r,{title:Ue.COMMON.CODE},React.createElement(p.l,{max:"1"},React.createElement(h.P,{name:"shortcode_chat_syntax_highlighting",label:"Use Syntax Highlighting",value:"1",checked:Me,description:React.createElement(React.Fragment,null,"Add syntax coloring to the code written by the chatbot."),onChange:ct}))),At=React.createElement(d.r,{title:Ue.COMMON.LOGS},React.createElement(p.l,{max:"1"},React.createElement(ve.N,{scrolldown:!0,id:"shortcode_chat_logs",name:"shortcode_chat_logs",value:Pe,description:"",onChange:ct},React.createElement(ve.Z,{value:"",label:"None"}),React.createElement(ve.Z,{value:"file",label:"Files (/uploads/chatbot folder)"})))),It=React.createElement(d.r,{title:Ue.COMMON.DEBUG_MODE},React.createElement(h.P,{name:"debug_mode",label:Ue.COMMON.ENABLE,value:"1",checked:De,description:Ue.COMMON.DEBUG_MODE_HELP,onChange:ct})),Mt=React.createElement(d.r,{title:Ue.COMMON.SHORTCODES},React.createElement(h.P,{name:"resolve_shortcodes",label:Ue.COMMON.RESOLVE,value:"1",checked:He,description:Ue.HELP.RESOLVE_SHORTCODE,onChange:ct})),jt=React.createElement(d.r,{title:Ue.COMMON.DYNAMIC_MAX_TOKENS},React.createElement(h.P,{name:"dynamic_max_tokens",label:Ue.COMMON.ENABLE,value:"1",checked:Be,description:Ue.HELP.DYNAMIC_MAX_TOKENS,onChange:ct})),Gt=React.createElement(d.r,{title:Ue.COMMON.API_KEY},React.createElement(ge.A,{name:"openai_apikey",value:Ae,description:(0,R.io)(Ue.COMMON.API_KEY_HELP),onBlur:ct})),Ft=React.createElement(d.r,{title:Ue.COMMON.API_KEY},React.createElement(ge.A,{name:"apikey",value:Ie.apikey||"",description:(0,R.io)(Ue.COMMON.EMBEDDINGS_APIKEY_HELP),onBlur:function(e){var t=Oa(Oa({},Ie),{},{apikey:e});ct(t,"pinecone")}})),Dt=React.createElement(d.r,{title:Ue.COMMON.SERVER},React.createElement(ve.N,{scrolldown:!0,name:"server",value:Ie.server,description:(0,R.io)(Ue.COMMON.SERVER_HELP),onChange:function(e){var t=Oa(Oa({},Ie),{},{server:e});ct(t,"pinecone")}},React.createElement(ve.Z,{value:"us-east1-gcp",label:"us-east1-gcp"}),React.createElement(ve.Z,{value:"us-west1-gcp",label:"us-west1-gcp"}),React.createElement(ve.Z,{value:"us-west4-gcp",label:"us-west4-gcp"}),React.createElement(ve.Z,{value:"us-east-1-aws",label:"us-east-1-aws"}),React.createElement(ve.Z,{value:"us-west-1-aws",label:"us-west-1-aws"}),React.createElement(ve.Z,{value:"us-central1-gcp",label:"us-central1-gcp"}))),Ut=React.createElement(d.r,{title:Ue.COMMON.NAMESPACE},React.createElement(ge.A,{name:"namespace",value:Ie.namespace||"mwai",description:(0,R.io)(Ue.COMMON.NAMESPACE_HELP),onBlur:function(e){var t=Oa(Oa({},Ie),{},{namespace:e});ct(t,"pinecone")}})),Bt=React.createElement("div",null,React.createElement("div",{style:{fontSize:12,marginTop:-5}},(0,R.io)(Ue.COMMON.USAGE_COSTS_HELP)),React.createElement(Gr,{options:W}));return React.createElement(y.s,null,React.createElement(yt,{options:W}),React.createElement(g.o,null,React.createElement(g.z,{fullWidth:!0},React.createElement(tt,{options:W}),React.createElement(Ee.H,null,React.createElement(m.O,{p:!0},(0,R.io)(Ue.SETTINGS.INTRO))),React.createElement(E.c,{keepTabOnReload:!0},React.createElement(E.P,{title:Ue.COMMON.DASHBOARD},React.createElement(g.o,null,React.createElement(g.z,{minimal:!0},React.createElement(w.v,{busy:at,title:Ue.COMMON.MODULES,className:"primary"},React.createElement("p",null,Ue.SETTINGS.MODULES_INTRO),React.createElement(be.i,{height:50}),Nt,bt,wt,Et,Ot,xt,_t,Rt,Tt,St)),React.createElement(g.z,{minimal:!0},React.createElement(w.v,{busy:at,title:Ue.COMMON.USAGE_COSTS,className:"primary"},Bt)))),ke&&React.createElement(E.P,{title:Ue.COMMON.CHATBOT},React.createElement(g.o,null,React.createElement(g.z,{minimal:!0,fullWidth:!0},React.createElement(w.v,{className:"primary"},React.createElement(m.O,{p:!0},React.createElement("p",null,(0,R.io)(Ue.CHATBOT.INTRO)),React.createElement("p",null,(0,R.io)(Ue.CHATBOT.INTRO_2))))),React.createElement(g.z,{minimal:!0},React.createElement(w.v,{busy:at,title:Ue.CHATBOT.CHATBOT_BUILDER,className:"primary",action:React.createElement(b._,{className:"danger",onClick:ht},Ue.CHATBOT.RESET_PARAMS)},React.createElement(In,null,React.createElement("h4",{className:"mwai-category",style:{marginTop:0}},Ue.COMMON.MAIN_SETTINGS),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{height:"chat"===ae.mode?76:"inherit"}},React.createElement("label",null,Ue.COMMON.MODE,":"),React.createElement(ve.N,{scrolldown:!0,id:"mode",name:"mode",value:ae.mode,onChange:ut},React.createElement(ve.Z,{value:"chat",label:"Chat"}),React.createElement(ve.Z,{value:"images",label:"Images"}))),ze&&React.createElement("div",{className:"mwai-builder-col",style:{flex:5}},React.createElement("label",null,Ue.COMMON.CONTEXT,":"),React.createElement(we.l,{id:"context",name:"context",rows:4,value:ae.context,onBlur:ut})),Ye&&React.createElement("div",{className:"mwai-builder-col",style:{flex:5}},React.createElement("label",null,Ue.COMMON.IMAGES_NUMBER,":"),React.createElement(ge.A,{id:"max_results",name:"max_results",type:"number",value:ae.max_results,onBlur:ut}))),React.createElement("h4",{className:"mwai-category"},Ue.COMMON.VISUAL_SETTINGS),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.AI_NAME,":"),React.createElement(ge.A,{id:"ai_name",name:"ai_name","data-form-type":"other",value:ae.ai_name,onBlur:ut})),React.createElement("div",{className:"mwai-builder-col",style:{flex:4}},React.createElement("label",null,Ue.COMMON.START_SENTENCE,":"),React.createElement(ge.A,{id:"start_sentence",name:"start_sentence",value:ae.start_sentence,onBlur:ut}))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.USER_NAME,":"),React.createElement(ge.A,{id:"user_name",name:"user_name","data-form-type":"other",value:ae.user_name,onBlur:ut})),React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,Ue.COMMON.PLACEHOLDER,":"),React.createElement(ge.A,{id:"text_input_placeholder",name:"text_input_placeholder",value:ae.text_input_placeholder,onBlur:ut})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.SEND,":"),React.createElement(ge.A,{id:"text_send",name:"text_send",value:ae.text_send,onBlur:ut})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.CLEAR,":"),React.createElement(ge.A,{id:"text_clear",name:"text_clear",value:ae.text_clear,disabled:!ae.id,onBlur:ut}))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:3}},React.createElement("label",null,Ue.COMMON.COMPLIANCE_TEXT,":"),React.createElement(ge.A,{id:"text_compliance",name:"text_compliance",value:ae.text_compliance,onBlur:ut}))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.SYSTEM_NAME,":"),React.createElement(ge.A,{id:"sys_name",name:"sys_name","data-form-type":"other",value:ae.sys_name,onBlur:ut})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("div",null,React.createElement("label",{style:{display:"block"}},Ue.COMMON.ID,":"),React.createElement(ge.A,{id:"id",name:"id",type:"text",placeholder:"Optional",value:ae.id,onBlur:ut}))),React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,Ue.COMMON.STYLE,":"),React.createElement(ve.N,{scrolldown:!0,id:"style",name:"style",value:ae.style,description:"",onChange:ut},React.createElement(ve.Z,{value:"none",label:"None"}),React.createElement(ve.Z,{value:"chatgpt",label:"ChatGPT"}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.POPUP,":"),React.createElement(h.P,{name:"window",label:"Yes",checked:ae.window,value:"1",onChange:ut}))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,Ue.COMMON.POSITION,":"),React.createElement(ve.N,{scrolldown:!0,id:"icon_position",name:"icon_position",disabled:!ae.window,value:ae.icon_position,onChange:ut},React.createElement(ve.Z,{value:"bottom-right",label:"Bottom Right"}),React.createElement(ve.Z,{value:"bottom-left",label:"Bottom Left"}),React.createElement(ve.Z,{value:"top-right",label:"Top Right"}),React.createElement(ve.Z,{value:"top-left",label:"Top Left"}))),React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,Ue.COMMON.ICON_TEXT,":"),React.createElement(ge.A,{id:"icon_text",name:"icon_text",disabled:!ae.window,placeholder:"If set, appears next to icon",value:null!==(n=ae.icon_text)&&void 0!==n?n:"Chat",onBlur:ut})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ue.COMMON.FULL_SCREEN,":"),React.createElement(h.P,{name:"fullscreen",label:"Yes",checked:ae.fullscreen,value:"1",onChange:ut}))),React.createElement("h4",{className:"mwai-category"},Ue.COMMON.TECHNICAL_SETTINGS),ze&&React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:3}},React.createElement("label",null,Ue.COMMON.MODEL,":"),React.createElement(ve.N,{scrolldown:!0,id:"model",name:"model",value:ae.model,description:"",onChange:ut},ee.map((function(e){return React.createElement(ve.Z,{value:e.model,label:e.name})})))),React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,Ue.COMMON.CASUALLY_FINE_TUNED,":"),React.createElement(h.P,{name:"casually_fine_tuned",label:"Yes",disabled:!Xe&&!ae.casually_fine_tuned,checked:ae.casually_fine_tuned,value:"1",onChange:ut})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ue.COMMON.TEMPERATURE,":"),React.createElement(ge.A,{id:"temperature",name:"temperature",type:"number",step:"0.1",min:"0",max:"1",value:ae.temperature,onBlur:ut}))),ze&&React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ue.COMMON.MAX_TOKENS,":"),React.createElement(ge.A,{id:"max_tokens",name:"max_tokens",type:"number",min:"10",max:"2048",value:ae.max_tokens,onBlur:ut})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ue.COMMON.SENTENCES_BUFFER,":"),React.createElement(ge.A,{id:"max_sentences",name:"max_sentences",step:"1",min:"1",max:"512",value:ae.max_sentences,onBlur:ut})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ue.COMMON.INPUT_MAXLENGTH,":"),React.createElement(ge.A,{id:"text_input_maxlength",name:"text_input_maxlength",step:"1",min:"1",max:"512",value:ae.text_input_maxlength,onBlur:ut}))),ze&&React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.EMBEDDINGS_INDEX,":"),React.createElement(ve.N,{scrolldown:!0,id:"embeddings_index",name:"embeddings_index",requirePro:!0,isPro:L,disabled:!(null!=$e&&$e.length)||"chat"!==(null==Qe?void 0:Qe.mode),value:ae.embeddings_index,onChange:ut},$e.map((function(e){return React.createElement(ve.Z,{value:e.name,label:e.name})})),React.createElement(ve.Z,{value:"",label:"Disabled"}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.CONTENT_AWARE,":"),React.createElement(h.P,{name:"content_aware",label:"Yes",requirePro:!0,isPro:L,checked:ae.content_aware,value:"1",onChange:ut}))),ce&&!ae.window&&React.createElement(Re.S,{variant:"danger",style:{marginTop:15,padding:"10px 15px"}},React.createElement("p",null,Ue.SETTINGS.ALERT_INJECT_BUT_NO_POPUP)),Xe&&!ae.casually_fine_tuned&&React.createElement(Re.S,{variant:"danger",style:{marginTop:15,padding:"10px 15px"}},React.createElement("p",null,Ue.SETTINGS.ALERT_FINETUNE_BUT_NO_CASUALLY)),!Xe&&ae.casually_fine_tuned&&React.createElement(Re.S,{variant:"danger",style:{marginTop:15,padding:"10px 15px"}},React.createElement("p",null,Ue.SETTINGS.ALERT_CASUALLY_BUT_NO_FINETUNE)),et&&!nt&&React.createElement(Re.S,{variant:"danger",style:{marginTop:15,padding:"10px 15px"}},React.createElement("p",null,(0,R.io)(Ue.SETTINGS.ALERT_CONTENTAWARE_BUT_NO_CONTENT))),React.createElement("h4",{className:"mwai-category"},Ue.COMMON.SHORTCODE),React.createElement("pre",null,it)),React.createElement(h.P,{name:"shortcode_chat_params_override",label:Ue.SETTINGS.SET_AS_DEFAULT_PARAMETERS,disabled:Object.keys(ot).length<1&&!ie,value:"1",checked:ie,description:Ue.SETTINGS.SET_AS_DEFAULT_PARAMETERS_HELP,onChange:ct}),React.createElement(h.P,{name:"shortcode_chat_inject",label:Ue.SETTINGS.INJECT_DEFAULT_CHATBOT,value:"1",checked:ce,description:Ue.SETTINGS.INJECT_DEFAULT_CHATBOT_HELP,onChange:ct}))),React.createElement(g.z,{minimal:!0},React.createElement(w.v,{busy:at,title:"ChatGPT Style",className:"primary",action:React.createElement(b._,{className:"danger",onClick:vt},"Reset Styles")},React.createElement(In,null,React.createElement("p",null,(0,R.io)(Ue.SETTINGS.CHATGPT_STYLE_INTRO)),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:.66}},React.createElement("label",null,Ue.COMMON.SPACING,":"),React.createElement(ge.A,{id:"spacing",name:"spacing",value:null!==(r=null==oe?void 0:oe.spacing)&&void 0!==r?r:"15px",onBlur:dt})),React.createElement("div",{className:"mwai-builder-col",style:{flex:.66}},React.createElement("label",null,Ue.COMMON.BORDER_RADIUS,":"),React.createElement(ge.A,{id:"borderRadius",name:"borderRadius",value:null!==(a=null==oe?void 0:oe.borderRadius)&&void 0!==a?a:"10px",onBlur:dt})),React.createElement("div",{className:"mwai-builder-col",style:{flex:.66}},React.createElement("label",null,Ue.COMMON.FONT_SIZE,":"),React.createElement(ge.A,{id:"fontSize",name:"fontSize",value:null!==(o=null==oe?void 0:oe.fontSize)&&void 0!==o?o:"15px",onBlur:dt})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ue.COMMON.FONT_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(ge.A,{id:"fontColor",name:"fontColor",value:null!==(i=null==oe?void 0:oe.fontColor)&&void 0!==i?i:"#FFFFFF",onBlur:dt}),React.createElement(Yn,{id:"fontColor",name:"fontColor",value:null!==(c=null==oe?void 0:oe.fontColor)&&void 0!==c?c:"#FFFFFF",onChange:dt})))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.BACK_PRIMARY_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(ge.A,{id:"backgroundPrimaryColor",name:"backgroundPrimaryColor",value:null!==(l=null==oe?void 0:oe.backgroundPrimaryColor)&&void 0!==l?l:"#454654",onBlur:dt}),React.createElement(Yn,{id:"backgroundPrimaryColor",name:"backgroundPrimaryColor",value:null!==(u=null==oe?void 0:oe.backgroundPrimaryColor)&&void 0!==u?u:"#454654",onChange:dt}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.BACK_SECONDARY_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(ge.A,{id:"backgroundSecondaryColor",name:"backgroundSecondaryColor",value:null!==(s=null==oe?void 0:oe.backgroundSecondaryColor)&&void 0!==s?s:"#343541",onBlur:dt}),React.createElement(Yn,{id:"backgroundSecondaryColor",name:"backgroundSecondaryColor",value:null!==(f=null==oe?void 0:oe.backgroundSecondaryColor)&&void 0!==f?f:"#343541",onChange:dt}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.HEADER_BUTTONS_COLOR,":"),React.createElement("div",{style:{display:"flex"}},React.createElement(ge.A,{id:"headerButtonsColor",name:"headerButtonsColor",value:null!==(v=null==oe?void 0:oe.headerButtonsColor)&&void 0!==v?v:"#FFFFFF",onBlur:dt}),React.createElement(Yn,{id:"headerButtonsColor",name:"headerButtonsColor",value:null!==(T=null==oe?void 0:oe.headerButtonsColor)&&void 0!==T?T:"#FFFFFF",onChange:dt})))),React.createElement("h4",{className:"mwai-category"},Ue.COMMON.POPUP),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col",style:{flex:2}},React.createElement("label",null,Ue.COMMON.POPUP_ICON,":"),React.createElement("div",{style:{display:"flex"}},Ca.map((function(e){return React.createElement(React.Fragment,null,React.createElement("img",{style:{marginRight:2,cursor:"pointer"},width:24,height:24,src:"".concat(_,"/images/").concat(e),onClick:function(){dt(e,"icon")}}))})),React.createElement(b._,{small:!0,className:"primary",style:{marginLeft:5},onClick:function(){dt("".concat(_,"/images/chat-color-green.svg"),"icon")}},"Custom URL"))),React.createElement("div",{className:"mwai-builder-col",style:{width:48,display:"flex",alignItems:"end"}},React.createElement("img",{style:{marginRight:0,paddingTop:10},width:48,height:48,src:"".concat(qe)}))),Ze&&React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.CUSTOM_ICON_URL,":"),React.createElement(ge.A,{id:"icon",name:"icon",value:We,onBlur:pt}))),React.createElement("div",{className:"mwai-builder-row",style:{marginTop:0}},React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ue.COMMON.WIDTH,":"),React.createElement(ge.A,{id:"width",name:"width",value:null!==(P=null==oe?void 0:oe.width)&&void 0!==P?P:"460px",onBlur:dt})),React.createElement("div",{className:"mwai-builder-col",style:{flex:1}},React.createElement("label",null,Ue.COMMON.MAX_HEIGHT,":"),React.createElement(ge.A,{id:"maxHeight",name:"maxHeight",value:null!==(A=null==oe?void 0:oe.maxHeight)&&void 0!==A?A:"40vh",onBlur:dt}))))),React.createElement(w.v,{busy:at,title:Ue.COMMON.FEATURES,className:"primary"},Ct,Lt,Pt,kt,At)))),ke&&Fe&&React.createElement(E.P,{title:Ue.COMMON.DISCUSSIONS},React.createElement(va,null)),Se&&React.createElement(E.P,{title:Ue.COMMON.EMBEDDINGS},React.createElement(Cr,{options:W,updateOption:ct})),fe&&React.createElement(E.P,{title:Ue.COMMON.FINETUNES},React.createElement(bn,{options:W,updateOption:ct})),ye&&React.createElement(E.P,{title:Ue.COMMON.MODERATION},React.createElement(dr,{options:W,updateOption:ct,busy:at})),_e&&React.createElement(E.P,{title:Ue.COMMON.AUDIO_TAB},React.createElement(Yr,{options:W,updateOption:ct})),me&&React.createElement(E.P,{title:Ue.COMMON.STATISTICS},React.createElement(g.o,null,React.createElement(g.z,{minimal:!0,style:{flex:2.5}},React.createElement(w.v,{className:"primary",title:"Queries"},React.createElement(or,null))),React.createElement(g.z,{minimal:!0},React.createElement(In,null,React.createElement(w.v,{className:"primary",busy:at,title:"Limits",style:{flex:1},action:React.createElement(b._,{className:"danger",onClick:gt},"Reset Limits")},React.createElement(h.P,{name:"enabled",label:Ue.STATISTICS.ENABLE_LIMITS,checked:null==Ne?void 0:Ne.enabled,value:"1",onChange:st}),React.createElement(be.i,null),React.createElement(Oe.h,{value:$,busy:at,onChange:function(e){X(e)}},React.createElement(Oe.S,{title:Ue.COMMON.USERS,value:"users",disabled:!(null!=Ne&&Ne.enabled)}),React.createElement(Oe.S,{title:Ue.COMMON.GUESTS,value:"guests"})),"userId"===(null==Ne?void 0:Ne.target)&&React.createElement(React.Fragment,null,React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,"Message for Guests:"),React.createElement(ge.A,{id:"guestMessage",name:"guestMessage",disabled:!(null!=Ne&&Ne.enabled),value:null==Ne?void 0:Ne.guestMessage,onBlur:st})))),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.CREDITS,":"),React.createElement(ge.A,{id:"credits",name:"credits",type:"number",min:"0",max:"1000000",disabled:!(null!=Ne&&Ne.enabled),value:null==Ne||null===(I=Ne[$])||void 0===I?void 0:I.credits,onBlur:"users"===$?ft:mt})),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.TYPE,":"),React.createElement(ve.N,{scrolldown:!0,id:"creditType",name:"creditType",disabled:!(null!=Ne&&Ne.enabled),value:null==Ne||null===(M=Ne[$])||void 0===M?void 0:M.creditType,onChange:"users"===$?ft:mt},React.createElement(ve.Z,{key:"queries",id:"queries",value:"queries",label:"Queries"}),React.createElement(ve.Z,{key:"units",id:"units",value:"units",label:"Tokens"}),React.createElement(ve.Z,{key:"price",id:"price",value:"price",label:"Dollars"})))),0!==(null==Ne||null===(j=Ne[$])||void 0===j?void 0:j.credits)&&React.createElement("p",null,"If you want to apply variable amount of credits, ",React.createElement("a",{href:"https://meowapps.com/ai-engine/faq/#limits",target:"_blank"},"click here"),"."),0!==(null==Ne||null===(G=Ne[$])||void 0===G?void 0:G.credits)&&"price"===(null==Ne?void 0:Ne[$].creditType)&&React.createElement("p",null,"The dollars represent the budget you spent through OpenAI."),0===(null==Ne||null===(F=Ne[$])||void 0===F?void 0:F.credits)&&React.createElement("p",null,"Since there are no credits, the Message for No Credits Message with be displayed."),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.TIMEFRAME,":"),React.createElement(ve.N,{scrolldown:!0,id:"timeFrame",name:"timeFrame",disabled:!(null!=Ne&&Ne.enabled),value:null==Ne||null===(D=Ne[$])||void 0===D?void 0:D.timeFrame,onChange:"users"===$?ft:mt},React.createElement(ve.Z,{key:"hour",id:"hour",value:"hour",label:"Hour"}),React.createElement(ve.Z,{key:"day",id:"day",value:"day",label:"Day"}),React.createElement(ve.Z,{key:"week",id:"week",value:"week",label:"Week"}),React.createElement(ve.Z,{key:"month",id:"month",value:"month",label:"Month"}),React.createElement(ve.Z,{key:"year",id:"year",value:"year",label:"Year"}))),React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.COMMON.ABSOLUTE,":"),React.createElement(h.P,{name:"isAbsolute",label:"Yes",disabled:!(null!=Ne&&Ne.enabled),checked:null==Ne||null===(U=Ne[$])||void 0===U?void 0:U.isAbsolute,value:"1",onChange:"users"===$?ft:mt}))),(null==Ne||null===(B=Ne[$])||void 0===B?void 0:B.isAbsolute)&&React.createElement("p",null,(0,R.io)(Ue.STATISTICS.ABSOLUTE_HELP)),React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.STATISTICS.NO_CREDITS_MESSAGE,":"),React.createElement(ge.A,{id:"overLimitMessage",name:"overLimitMessage",disabled:!(null!=Ne&&Ne.enabled),value:null==Ne||null===(H=Ne[$])||void 0===H?void 0:H.overLimitMessage,onBlur:"users"===$?ft:mt}))),"users"===$&&React.createElement("div",{className:"mwai-builder-row"},React.createElement("div",{className:"mwai-builder-col"},React.createElement("label",null,Ue.STATISTICS.FULL_ACCESS_USERS,":"),React.createElement(ve.N,{scrolldown:!0,id:"ignoredUsers",name:"ignoredUsers",disabled:!(null!=Ne&&Ne.enabled),value:null==Ne||null===(z=Ne.users)||void 0===z?void 0:z.ignoredUsers,description:"",onChange:ft},React.createElement(ve.Z,{key:"none",id:"none",value:"",label:Ue.COMMON.NONE}),React.createElement(ve.Z,{key:"editor",id:"editor",value:"administrator,editor",label:Ue.COMMON.EDITORS_ADMINS}),React.createElement(ve.Z,{key:"admin",id:"admin",value:"administrator",label:Ue.COMMON.ADMINS_ONLY}))))))))),React.createElement(E.P,{key:"advanced",title:rt>0?React.createElement(React.Fragment,null,Ue.COMMON.SETTINGS," ",React.createElement(xe.J,{style:{marginLeft:2,marginRight:-5},width:"16",icon:"info-outline",color:"orange"})):React.createElement(React.Fragment,null,Ue.COMMON.SETTINGS)},React.createElement(g.o,null,React.createElement(g.z,{minimal:!0},React.createElement(w.v,{busy:at,title:Ue.COMMON.OPENAI,className:"primary"},Gt),Se&&React.createElement(w.v,{busy:at,title:"Pinecone",className:"primary"},Ft,Dt,Ut),React.createElement(w.v,{busy:at,title:Ue.COMMON.ADVANCED,className:"primary"},It,Mt,jt)),React.createElement(g.z,{minimal:!0},React.createElement(Sn,{incidents:Je,isLoading:Ke})))),React.createElement(E.P,{title:Ue.COMMON.LICENSE_TAB},React.createElement(Ge,{domain:x,prefix:O,isPro:N,isRegistered:L}))))))};var Ia=n(5307),Ma=[{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"}],ja=[{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"}],Ga="gpt-3.5-turbo",Fa=[{id:"default",name:"Default",mode:"query",model:Ga,temperature:.8,stopSequence:"",maxTokens:2048,prompt:""},{id:"article_translator",name:"Text Translator",mode:"query",model:Ga,temperature:.3,stopSequence:"",maxTokens:2048,prompt:"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"},{id:"restaurant_review",name:"Restaurant Review Writer",mode:"query",model:Ga,temperature:.8,stopSequence:"",maxTokens:2048,prompt:"Write a review for a French restaurant located in Kagurazaka, Tokyo. Looks like an old restaurant, food is traditional, chef is talkative, it is always full. Not expensive, but not fancy.\n"},{id:"article_corrector",name:"Text Corrector",mode:"query",model:Ga,temperature:.2,stopSequence:"",maxTokens:2048,prompt:"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 Optimizer",mode:"query",model:Ga,temperature:.6,stopSequence:"",maxTokens:1024,prompt:"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\nTitle: \nKeywords: \nExcerpt:\n\nArticle:\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."},{id:"wp_assistant",name:"WordPress Assistant",mode:"continuous",model:Ga,temperature:.8,stopSequence:"",maxTokens:150,prompt:"Converse as a WordPress expert. Be helpful, friendly, concise, avoid external URLs and commercial solutions.\n\nAI: Hi! How can I help you with WP today?\n"},{id:"casually_fine_tuned",name:"Casually Fined Tuned Tester",mode:"query",model:"text-davinci-003",temperature:.4,stopSequence:"\\n\\n",maxTokens:1024,prompt:"Hello! What's your name?\n\n###\n\n"}],Da=[{id:"default",name:"Default",model:"dall-e",maxResults:3,prompt:""},{id:"japan",name:"Ghibli Inspired",model:"dall-e",maxResults:3,prompt:"japan, tokyo, trees, izakaya, anime oil painting, high resolution, ghibli inspired, 4k"},{id:"steampunk",name:"Steampunk Architecture",model:"dall-e",maxResults:3,prompt:"steampunk architecture, exterior view, award-winning architectural photography from magazine, trees, theater"},{id:"modern-illustration",name:"Modern Illustration",model:"dall-e",maxResults:3,prompt:"illustration of a cat, modern design, for the web, cute, happy, 4k, high resolution, trending in artstation"}],Ua=[{id:"default",name:"Default",mode:"single",topic:"",topics:"",topicsAreTitles:!1,title:"",sections:"",model:Ga,temperature:.8,maxTokens:2048,sectionsCount:2,paragraphsCount:3,language:"en",customLanguage:"",writingStyle:"creative",writingTone:"cheerful",titlePromptFormat:'Write a title for an article about "{TOPIC}" in {LANGUAGE}. Style: {WRITING_STYLE}. Tone: {WRITING_TONE}. Must be between 40 and 60 characters.',sectionsPromptFormat:'Write {SECTIONS_COUNT} consecutive headings for an article about "{TITLE}", in {LANGUAGE}. Style: {WRITING_STYLE}. Tone: {WRITING_TONE}. Each heading is between 40 and 60 characters. Use Markdown for the headings (## ).',contentPromptFormat:'Write an article about "{TITLE}" in {LANGUAGE}. The article is organized by the following headings:\n\n{SECTIONS}\n\nWrite {PARAGRAPHS_PER_SECTION} paragraphs per heading. Use Markdown for formatting. Add an introduction prefixed by "===INTRO: ", and a conclusion prefixed by "===OUTRO: ". Style: {WRITING_STYLE}. Tone: {WRITING_TONE}.',excerptPromptFormat:'Write an excerpt for an article about "{TITLE}" in {LANGUAGE}. Style: {WRITING_STYLE}. Tone: {WRITING_TONE}. Must be between 40 and 60 characters.'}];function Ba(e){return Ba="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},Ba(e)}function Ha(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 za(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ha(Object(n),!0).forEach((function(t){Ya(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ha(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Ya(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==Ba(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==Ba(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===Ba(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Wa(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)||Ja(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 Za(){Za=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==Ba(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 qa(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 Va(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){qa(o,r,a,i,c,"next",e)}function c(e){qa(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Ka(e){return function(e){if(Array.isArray(e))return $a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Ja(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 Ja(e,t){if(e){if("string"==typeof e)return $a(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)?$a(e,t):void 0}}function $a(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 Xa=wp.element,Qa=Xa.useState,eo=Xa.useEffect,to=Xa.useMemo;function no(){return(new Date).getTime().toString(36)+Math.random().toString(36).substr(2,9)}var ro=function(e){var t=Ka(e);return t.sort((function(e,t){return"default"===e.id?-1:"default"===t.id?1:e.name.localeCompare(t.name)})),t},ao=function(){var e=Va(Za().mark((function e(t){var n,r,a;return Za().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,R.PV)("".concat(S,"/templates?category=").concat(t),{nonce:k});case 2:return n=e.sent,r=[],"imagesGenerator"===t?r=Da:"playground"===t?r=Fa:"contentGenerator"===t&&(r=Ua),a=r.find((function(e){return"default"===e.id})),null!=n&&n.templates&&n.templates.length>0&&(r=ro(n.templates)),a?r.forEach((function(e){Object.keys(a).forEach((function(t){void 0===e[t]&&(e[t]=a[t])}))})):console.warn("Default template not found for category: "+t),e.abrupt("return",r);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}();const oo=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"playground",t=Qa(),n=Wa(t,2),r=n[0],a=n[1],o=Qa(!1),i=Wa(o,2),c=i[0],l=i[1],u=Qa([]),s=Wa(u,2),f=s[0],m=s[1],d=(0,Te.a)({queryKey:["templates-".concat(e)],queryFn:function(){return ao(e)}}),p=d.isLoading,h=d.data;eo((function(){h&&(m(h),a(h[0]))}),[h]);var y=function(){var t=Va(Za().mark((function t(n){var r;return Za().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=ro(n),m(n),t.next=4,(0,R.PV)("".concat(S,"/templates"),{method:"POST",nonce:k,json:{category:e,templates:n}});case 4:return r=t.sent,t.abrupt("return",r);case 6:case"end":return t.stop()}}),t)})));return function(e){return t.apply(this,arguments)}}(),v=to((function(){if(!r||0===f.length)return!1;var e=f.find((function(e){return e.id===r.id}));return Object.keys(e).some((function(t){return e[t]!==r[t]}))}),[r,f]),g=function(e){a(e)},E=function(){var e=f.find((function(e){return e.id===r.id}));e&&a(za({},e))},w=function(){var e=prompt(Ue.COMMON.NAME,Ue.TEMPLATES.NEW_TEMPLATE_NAME);if(!e)return!1;var t=za(za({},r),{},{id:no(),name:e});y([].concat(Ka(f),[t])),a(za({},t))},O=function(){var e=f.map((function(e){return e.id===r.id?r:e}));y(e),a(za({},r))},x=function(){var e=prompt("New name",r.name);if(e){var t=f.map((function(t){return t.id===r.id?za(za({},t),{},{name:e}):t}));y(Ka(t)),a(za({},t.find((function(e){return e.id===r.id}))))}},T=function(){if(confirm(Ue.TEMPLATES.DELETE_CONFIRM)){var e=f.filter((function(e){return e.id!==r.id}));y(Ka(e)),a(za({},e[0]))}},_=to((function(){return v&&"default"!==r.id}),[r]),N=to((function(){return React.createElement("div",{style:{margin:"0"}},React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},React.createElement("h3",{style:{margin:0}},Ue.TEMPLATES.TEMPLATES),React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"}},React.createElement(Rt.Q,{small:!0,onLabel:Ue.TEMPLATES.EDIT,offLabel:Ue.TEMPLATES.EDIT,width:60,onChange:l,checked:c}))),p&&React.createElement("div",{style:{display:"flex",marginTop:30,justifyContent:"center"}},React.createElement("div",{style:{width:60}},React.createElement(Ia.S,{width:20}))),React.createElement("ul",null,f.map((function(e){return React.createElement("li",{className:r.id===e.id?"active"+(v&&c?" modified":""):"",onClick:function(){a(za({},e))}},e.name)}))),v&&React.createElement("div",{style:{display:"flex",marginTop:15}},React.createElement(b._,{fullWidth:!0,className:"secondary",icon:"undo",onClick:E},"Reset")),c&&React.createElement("div",{style:{display:"flex",flexDirection:"column"}},React.createElement(be.i,{line:!0,height:30}),React.createElement("div",{style:{display:"flex",marginBottom:5}},React.createElement(b._,{disabled:"default"===r.id,className:"danger",icon:"trash",onClick:T}),React.createElement(b._,{disabled:"default"===r.id,className:"secondary",icon:"pencil",onClick:x}),React.createElement(b._,{disabled:!_,className:"secondary",style:{flex:6},onClick:O},"Save")),React.createElement("div",{style:{display:"flex"}},React.createElement(b._,{onClick:w,style:{flex:6}},"Save as New"))),!c&&React.createElement("div",{style:{display:"flex",marginTop:15,lineHeight:"14px"}},React.createElement("small",null,(0,R.io)(Ue.TEMPLATES.JOIN_US))))}));return{template:r,resetTemplate:E,setTemplate:g,jsxTemplates:N,isEdit:c}};function io(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 co(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)?co(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 co(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 lo=wp.element,uo=lo.useState,so=lo.useMemo;const fo=function(e){var t=lt(e).calculatePrice,n=io(uo(0),2),r=n[0],a=n[1],o=io(uo(0),2),i=o[0],c=o[1],l=function(){a(0),c(0)};return{addUsage:function(e,n){var o=t(e,n);c(o),a(r+o)},jsxUsageCosts:so((function(){var e=(0,R.io)(Ue.COMMON.USAGE_COSTS_HELP);return L||(e=React.createElement(React.Fragment,null,e," ",(0,R.io)(Ue.COMMON.USAGE_COSTS_PRO_HELP))),React.createElement(Pn,null,React.createElement("h3",null,Ue.COMMON.USAGE_COSTS),React.createElement("div",null,"Session: ",React.createElement("span",{style:{float:"right"}},"$",r.toFixed(4))),React.createElement("div",null,"Last Request: ",React.createElement("span",{style:{float:"right"}},"$",i.toFixed(4))),React.createElement(be.i,{height:30}),React.createElement("p",{style:{fontSize:12,lineHeight:1.2,color:"var(--neko-dark-gray)"}},e),React.createElement(b._,{fullWidth:!0,onClick:l},"Reset Usage"))}),[r,i])}};function mo(e){return mo="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},mo(e)}var po;function ho(){ho=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==mo(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 yo(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 vo(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 go(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vo(Object(n),!0).forEach((function(t){Eo(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Eo(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==mo(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==mo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===mo(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bo(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 wo(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)?wo(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 wo(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 Ro=wp.element,Oo=Ro.useState,xo=Ro.useEffect,To=(Ro.useMemo,(0,I.ZP)(we.l)(po||(po=function(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(["\n .neko-textarea-container {\n \n textarea {\n color: white;\n font-size: 13px;\n padding: 10px;\n font-family: monospace;\n background: #333d4e;\n border: none;\n\n &:focus {\n background-color: #333d4e;\n }\n }\n }\n"]))));const So=function(){var e,t,n,r,a,o,i=oo("playground"),c=i.template,l=i.setTemplate,u=i.jsxTemplates,s=bo(Oo(""),2),f=s[0],d=s[1],p=lt(C).completionModels,h=fo(C),v=h.addUsage,E=h.jsxUsageCosts,w=bo(Oo(!1),2),O=w[0],x=w[1],T=bo(Oo(""),2),_=T[0],N=T[1],L=bo(Oo(),2),A=L[0],I=L[1],M=bo(Oo(),2),j=M[0],G=M[1],F=null!==(e=null==c?void 0:c.prompt)&&void 0!==e?e:"",D=null!==(t=null==c?void 0:c.model)&&void 0!==t?t:"gpt-3.5-turbo",U=null!==(n=null==c?void 0:c.mode)&&void 0!==n?n:"query",B=null!==(r=null==c?void 0:c.temperature)&&void 0!==r?r:1,H=null!==(a=null==c?void 0:c.stopSequence)&&void 0!==a?a:"",z=null!==(o=null==c?void 0:c.maxTokens)&&void 0!==o?o:2048,Y=function(e,t){l(go(go({},c),{},Eo({},t,e)))},W=function(e){l(go(go({},c),{},{prompt:e}))};xo((function(){c&&d("")}),[c]);var Z=function(){var e,t=(e=ho().mark((function e(){var t,n,r,a,o=arguments;return ho().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=o.length>0&&void 0!==o[0]?o[0]:F,x(!0),I(new Date),n=H.replace(/\\n/g,"\n"),e.next=6,(0,R.PV)("".concat(S,"/make_completions"),{method:"POST",nonce:k,json:{env:"playground",session:P,prompt:t,temperature:B,model:D,maxTokens:z,stop:n}});case 6:r=e.sent,console.log("Completions",{prompt:t,result:r}),r.success?("continuous"===U?W(t+"\n"+r.data+"\n"):d(r.data),v(D,(null==r||null===(a=r.usage)||void 0===a?void 0:a.total_tokens)||0)):G(r.message),I(),x(!1);case 11: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){yo(o,r,a,i,c,"next",e)}function c(e){yo(o,r,a,i,c,"throw",e)}i(void 0)}))});return function(){return t.apply(this,arguments)}}();return React.createElement(y.s,{nekoErrors:[]},React.createElement(yt,{title:"Playground"}),React.createElement(g.o,null,React.createElement(g.z,{fullWidth:!0},React.createElement(tt,{options:C}),React.createElement(Ee.H,{style:{marginBottom:0}},React.createElement(m.O,{p:!0},(0,R.io)(Ue.PLAYGROUND.INTRO)))),React.createElement(g.z,null,React.createElement(Pn,null,u),React.createElement(Pn,{style:{marginTop:20}},React.createElement("h3",{style:{marginTop:0}},"Mode"),React.createElement(ve.N,{scrolldown:!0,name:"mode",disabled:!0,value:U,description:"",onChange:Y},React.createElement(ve.Z,{key:"query",value:"query",label:"Query"}),React.createElement(ve.Z,{key:"continuous",value:"continuous",label:"Continuous"})))),React.createElement(g.z,{style:{flex:3}},React.createElement(Pn,null,"continuous"!==U&&React.createElement(React.Fragment,null,React.createElement("label",{style:{marginTop:0,marginBottom:10}},Ue.PLAYGROUND.PROMPT,":"),React.createElement(To,{style:{marginBottom:5},rows:12,onChange:W,value:F}),React.createElement("label",{style:{marginTop:0,marginBottom:10}},Ue.PLAYGROUND.ANSWER,":"),React.createElement(To,{countable:"words",rows:14,onChange:d,value:f})),"continuous"===U&&React.createElement(React.Fragment,null,React.createElement(To,{rows:18,onChange:W,value:F}),React.createElement("div",{style:{display:"flex"}},React.createElement("span",{class:"dashicons dashicons-format-continuous",style:{position:"absolute",color:"white",zIndex:200,fontSize:28,marginTop:12,marginLeft:10}}),React.createElement(An,{name:"continuousEntry",value:_,onChange:N,onEnter:function(){var e=F+"Human: "+_;W(e),N(""),Z(e)},disabled:O}))))),React.createElement(g.z,null,"query"===U&&React.createElement(React.Fragment,null,React.createElement(Pn,null,React.createElement(b._,{fullWidth:!0,onClick:function(){Z()},isBusy:O,startTime:A,style:{height:50,fontSize:14,flex:4}},Ue.COMMON.SUBMIT)),React.createElement(be.i,{height:30})),React.createElement(Pn,null,React.createElement("h3",null,Ue.COMMON.SETTINGS),React.createElement("label",null,Ue.COMMON.MODEL,":"),React.createElement(ve.N,{name:"model",value:D,scrolldown:!0,onChange:Y},p.map((function(e){return React.createElement(ve.Z,{value:e.model,label:e.name})}))),React.createElement("label",null,Ue.COMMON.TEMPERATURE,":"),React.createElement(ge.A,{name:"temperature",value:B,type:"number",onChange:function(e){return Y(parseFloat(e),"temperature")},description:React.createElement(React.Fragment,null,React.createElement("span",{style:{color:B>=0&&B<=1?"inherit":"red"}},Ue.HELP.TEMPERATURE))}),React.createElement("label",null,Ue.COMMON.MAX_TOKENS,":"),React.createElement(ge.A,{name:"maxTokens",value:z,type:"number",onChange:function(e){return Y(parseInt(e),"maxTokens")},description:React.createElement(React.Fragment,null,React.createElement("span",null,Ue.HELP.MAX_TOKENS))}),React.createElement("label",null,Ue.COMMON.STOP_SEQUENCE,":"),React.createElement(ge.A,{name:"stopSequence",value:H,type:"text",onChange:Y,description:React.createElement(React.Fragment,null,React.createElement("span",null,Ue.HELP.STOP_SEQUENCE))})),React.createElement(be.i,{height:30}),E)),React.createElement(Se.L,{isOpen:j,onRequestClose:function(){G()},onOkClick:function(){G()},title:"Error",content:React.createElement("p",null,j)}))};var _o,No;function Lo(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var ko=I.ZP.div(_o||(_o=Lo(["\n margin-bottom: 5px;\n"]))),Co=I.ZP.div(No||(No=Lo(["\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 Po(e){return Po="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},Po(e)}function Ao(){Ao=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==Po(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 Io(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 Mo(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Io(o,r,a,i,c,"next",e)}function c(e){Io(o,r,a,i,c,"throw",e)}i(void 0)}))}}function jo(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 Go(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)?Go(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 Go(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 Fo=wp.element,Do=Fo.useState,Uo=Fo.useEffect,Bo=Fo.useMemo;const Ho=function(e){var t=e.post,n=e.onTitleClick,r=void 0===n?{}:n,a=e.onClose,o=void 0===a?{}:a,i=jo(Do([]),2),c=i[0],l=i[1],u=jo(Do(!1),2),s=u[0],f=u[1],m=jo(Do(!1),2),d=m[0],p=m[1];Uo((function(){t&&h(t)}),[t]);var h=function(){var e=Mo(Ao().mark((function e(t){var n,r;return Ao().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.postId,t.postTitle,f(!0),e.next=4,(0,R.PV)("".concat(S,"/make_titles"),{method:"POST",nonce:k,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=Mo(Ao().mark((function e(t){return Ao().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),e.prev=1,e.next=4,r(t);case 4:v(),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)}}(),v=function(){var e=Mo(Ao().mark((function e(){return Ao().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)}}(),E=Bo((function(){return s?React.createElement(Ia.S,{type:"circle",size:"10%"}):d?React.createElement(React.Fragment,null,"Error: ",d):(null==c?void 0:c.length)>0?React.createElement(React.Fragment,null,"Pick a new title by clicking on it.",React.createElement(ko,null,c.map((function(e){return React.createElement(Co,{key:e,onClick:function(){y(e)}},e)})))):React.createElement(React.Fragment,null,"Nothing to display.")}),[s,c,d]);return React.createElement(g.o,null,React.createElement(Se.L,{isOpen:t,onRequestClose:v,title:'New title for "'.concat(null==t?void 0:t.postTitle,'"'),content:E,ok:"Close",onOkClick:v}))};function zo(e){return zo="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},zo(e)}function Yo(){Yo=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==zo(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 Wo(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 Zo(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 qo=wp.element,Vo=qo.useState,Ko=qo.useEffect;qo.useMemo;const Jo=function(){var e,t,n=(e=Vo(),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 Zo(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)?Zo(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];Ko((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=Yo().mark((function e(t){var n,o,i,c;return Yo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,R.PV)("".concat(S,"/update_post_title"),{method:"POST",nonce:k,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){Wo(o,r,a,i,c,"next",e)}function c(e){Wo(o,r,a,i,c,"throw",e)}i(void 0)}))});return function(e){return t.apply(this,arguments)}}();return React.createElement(s.Z,null,React.createElement(g.o,null,React.createElement(Ho,{post:r,onTitleClick:o,onClose:function(){a()}})))};function $o(e){return $o="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},$o(e)}function Xo(){Xo=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==$o(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 Qo(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 ei(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Qo(o,r,a,i,c,"next",e)}function c(e){Qo(o,r,a,i,c,"throw",e)}i(void 0)}))}}function ti(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 ni(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ti(Object(n),!0).forEach((function(t){ri(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ti(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ri(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==$o(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==$o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===$o(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ai(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)||oi(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 oi(e,t){if(e){if("string"==typeof e)return ii(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)?ii(e,t):void 0}}function ii(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 ci=wp.element,li=ci.useState,ui=ci.useEffect,si=ci.useMemo;const fi=function(){var e,t,n,r,a,o,i,c,l,u,s,f,d,p,v,E,w,O=ai(li(""),2),x=O[0],T=O[1],_=ai(li(""),2),N=_[0],L=_[1],A=oo("contentGenerator"),I=A.template,M=A.setTemplate,j=A.resetTemplate,G=A.jsxTemplates,F=lt(C).completionModels,D=(0,Nt.qj)(),U=ai(li(!1),2),B=U[0],H=U[1],z=ai(li(),2),Y=z[0],W=z[1],Z=ai(li(!1),2),q=Z[0],V=Z[1],K=ai(li(!1),2),J=K[0],$=K[1],X=ai(li(!1),2),Q=X[0],ee=X[1],te=ai(li(),2),ne=te[0],re=te[1],ae=ai(li("post"),2),oe=ae[0],ie=ae[1],ce=ai(li([]),2),le=ce[0],ue=ce[1],se=ai(li([]),2),fe=se[0],me=se[1],de=ai(li({}),2),pe=de[0],he=de[1],ye=si((function(){return function(e){if(!e)return null;var t=e.split(" ").length,n=e.length,r=[];return n?(t<3?r.push(Ue.CONTENT_GENERATOR.TITLE_TOO_SHORT):t>8?r.push(Ue.CONTENT_GENERATOR.TITLE_TOO_LONG):n<40?r.push(Ue.CONTENT_GENERATOR.TITLE_TOO_SHORT):n>70&&r.push(Ue.CONTENT_GENERATOR.TITLE_TOO_LONG_2),r.join(" ")):void 0}(Ce)}),[Ce]),Ee=fo(C),Re=Ee.addUsage,xe=Ee.jsxUsageCosts,_e=(0,Te.a)({queryKey:["postTypes"],queryFn:At}),Ne=_e.isLoading,Le=_e.data,ke=D.busy||B||Ne,Ce=null!==(e=null==I?void 0:I.title)&&void 0!==e?e:"",Pe=null!==(t=null==I?void 0:I.sections)&&void 0!==t?t:"",Ae=null!==(n=null==I?void 0:I.mode)&&void 0!==n?n:"single",Ie=null!==(r=null==I?void 0:I.topic)&&void 0!==r?r:"",Me=null!==(a=null==I?void 0:I.topics)&&void 0!==a?a:"",je=null!==(o=null==I?void 0:I.model)&&void 0!==o?o:"gpt-3.5-turbo",Ge=null!==(i=null==I?void 0:I.sectionsCount)&&void 0!==i?i:2,Fe=null!==(c=null==I?void 0:I.paragraphsCount)&&void 0!==c?c:3,De=null!==(l=null==I?void 0:I.writingStyle)&&void 0!==l?l:"creative",Be=null!==(u=null==I?void 0:I.writingTone)&&void 0!==u?u:"cheerful",He=null!==(s=null==I?void 0:I.titlePromptFormat)&&void 0!==s?s:"",ze=null!==(f=null==I?void 0:I.sectionsPromptFormat)&&void 0!==f?f:"",Ye=null!==(d=null==I?void 0:I.contentPromptFormat)&&void 0!==d?d:"",We=null!==(p=null==I?void 0:I.excerptPromptFormat)&&void 0!==p?p:"",Ze=null!==(v=null==I?void 0:I.temperature)&&void 0!==v?v:.6,qe=null!==(E=null==I?void 0:I.maxTokens)&&void 0!==E?E:2048,Ve=null!==(w=null==I?void 0:I.topicsAreTitles)&&void 0!==w&&w,Ke=!ze||!Ge,Je=ct({options:C,language:null==I?void 0:I.language,customLanguage:null==I?void 0:I.customLanguage}),$e=Je.jsxLanguageSelector,Xe=Je.currentLanguage,Qe=Je.isCustom,et=Je.currentHumanLanguage,rt=function(e,t){M((function(n){return ni(ni({},n),{},ri({},t,e))}))};ui((function(){var e=Me.split("\n").map((function(e){return e.trim()})).filter((function(e){return!!e}));ue(e)}),[Me]),ui((function(){I&&rt("","sections")}),[Ce,Ge]),ui((function(){T(""),L(""),re()}),[Pe,Fe]),ui((function(){I&&(!Qe&&I.customLanguage&&rt(null,"customLanguage"),Qe&&I.customLanguage!==et&&rt(et,"customLanguage"),I.language!==Xe&&rt(Xe,"language"))}),[Qe,Xe,et]);var at=function(e){return e.replace("{LANGUAGE}",et).replace("{WRITING_STYLE}",De).replace("{WRITING_TONE}",Be).replace("{PARAGRAPHS_PER_SECTION}",Fe).replace("{SECTIONS_COUNT}",Ge)},ot=si((function(){var e=function(e,t){return!!t.find((function(t){return t.includes(e)}))},t=[He,ze,Ye,We];return{language:e("{LANGUAGE}",t),writingStyle:e("{WRITING_STYLE}",t),writingTone:e("{WRITING_TONE}",t),sectionsCount:e("{SECTIONS_COUNT}",t),paragraphsCount:e("{PARAGRAPHS_PER_SECTION}",t)}}),[He,ze,Ye,We,Ge,Fe]),it=function(){var e=ei(Xo().mark((function e(){var t,n,r,a,o,i,c=arguments;return Xo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=c.length>0&&void 0!==c[0]?c[0]:prompt,r=c.length>1&&void 0!==c[1]?c[1]:2048,a=c.length>2&&void 0!==c[2]&&c[2],e.next=5,(0,R.PV)("".concat(S,"/make_completions"),{method:"POST",nonce:k,json:{env:"admin-tools",session:P,prompt:n,temperature:Ze,maxTokens:r,model:je}});case 5:if((o=e.sent).success){e.next=11;break}if(!a){e.next=9;break}throw new Error(o.message);case 9:return W(o.message),e.abrupt("return",null);case 11:return Re(je,(null==o||null===(t=o.usage)||void 0===t?void 0:t.total_tokens)||0),(i=o.data.trim()).startsWith('"')&&i.endsWith('"')&&(i=i.substring(1,i.length-1)),e.abrupt("return",i);case 15:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ut=function(){var e=ei(Xo().mark((function e(){var t,n,r,a,o,i=arguments;return Xo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:Ie,n=i.length>1&&void 0!==i[1]?i[1]:Ce,r=i.length>2&&void 0!==i[2]&&i[2],n){e.next=6;break}return alert(Ue.CONTENT_GENERATOR.TITLE_MISSING),e.abrupt("return");case 6:return H(!0),rt("","sections"),console.log("Sections Prompt:",{inTopic:t,inTitle:n,sectionsPromptFormat:ze}),a=(a=ze.replace("{TITLE}",n)).replace("{TOPIC}",t),a=at(a),e.next=14,it(a,512,r);case 14:return o=nt(o=e.sent),console.log("Sections:",{prompt:a,sections:o}),o&&rt(o,"sections"),H(!1),e.abrupt("return",o);case 20:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),st=function(){var e=ei(Xo().mark((function e(){var t,n,r,a,o,i,c=arguments;return Xo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=c.length>0&&void 0!==c[0]?c[0]:Ie,n=c.length>1&&void 0!==c[1]?c[1]:Ce,r=c.length>2&&void 0!==c[2]?c[2]:Pe,a=c.length>3&&void 0!==c[3]&&c[3],n){e.next=7;break}return alert(Ue.CONTENT_GENERATOR.TITLE_MISSING),e.abrupt("return");case 7:if(Ke||r){e.next=10;break}return alert(Ue.CONTENT_GENERATOR.SECTIONS_MISSING),e.abrupt("return");case 10:return H(!0),T((function(e){return""})),o=(o=(o=Ye.replace("{TITLE}",n)).replace("{SECTIONS}",r)).replace("{TOPIC}",t),o=at(o),e.next=18,it(o,qe,a);case 18:return(i=e.sent)&&(i=(i=(i=(i=(i=(i=i.replace(/^===INTRO:\n/,"")).replace(/^===INTRO: \n/,"")).replace(/===INTRO: /,"")).replace(/===OUTRO:\n/,"")).replace(/===OUTRO: \n/,"")).replace(/===OUTRO: /,""),T((function(e){return i}))),console.log("Content:",{prompt:o,content:i}),H(!1),e.abrupt("return",i);case 23:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),ft=function(){var e=ei(Xo().mark((function e(){var t,n,r,a,o,i=arguments;return Xo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=i.length>0&&void 0!==i[0]?i[0]:Ie,n=i.length>1&&void 0!==i[1]?i[1]:Ce,r=i.length>2&&void 0!==i[2]&&i[2],n){e.next=6;break}return alert(Ue.CONTENT_GENERATOR.TITLE_MISSING),e.abrupt("return");case 6:return H(!0),L((function(e){return""})),a=(a=We.replace("{TITLE}",n)).replace("{TOPIC}",t),a=at(a),e.next=13,it(a,256,r);case 13:return(o=e.sent)&&L((function(e){return o})),console.log("Excerpt:",{prompt:a,excerpt:o}),H(!1),e.abrupt("return",o);case 18:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),mt=function(){var e=ei(Xo().mark((function e(){var t,n,r,a,o,i,c,l=arguments;return Xo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=l.length>0&&void 0!==l[0]?l[0]:Ie,n=l.length>1&&void 0!==l[1]&&l[1],H(!0),he((function(){return ni(ni({},pe),{},{all:new Date})})),e.prev=4,r=t,Ve&&n){e.next=12;break}return a=at(He.replace("{TOPIC}",t)),e.next=10,it(a,64,n);case 10:r=e.sent,console.log("Title:",{prompt:a,title:r});case 12:if(o=null,i=null,c=null,H(!1),!r){e.next=41;break}if(rt(r,"title"),Ke){e.next=25;break}return he((function(e){return ni(ni({},e),{},{sections:new Date})})),e.next=22,ut(t,r,n);case 22:return o=e.sent,e.next=25,he((function(e){return ni(ni({},e),{},{sections:null})}));case 25:if(!o&&!Ke){e.next=41;break}return e.next=28,he((function(e){return ni(ni({},e),{},{content:new Date})}));case 28:return e.next=30,st(t,r,o,n);case 30:return i=e.sent,e.next=33,he((function(e){return ni(ni({},e),{},{content:null})}));case 33:if(!i){e.next=41;break}return e.next=36,he((function(e){return ni(ni({},e),{},{excerpt:new Date})}));case 36:return e.next=38,ft(t,r,n);case 38:return c=e.sent,e.next=41,he((function(e){return ni(ni({},e),{},{excerpt:null})}));case 41:return e.abrupt("return",{title:r,heads:o,content:i,excerpt:c});case 44:throw e.prev=44,e.t0=e.catch(4),H(!1),he({}),e.t0;case 49:case"end":return e.stop()}}),e,null,[[4,44]])})));return function(){return e.apply(this,arguments)}}(),dt=function(){var e=ei(Xo().mark((function e(){var t,n,r,a,o,i=arguments;return Xo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=i.length>0&&void 0!==i[0]?i[0]:Ce,n=i.length>1&&void 0!==i[1]?i[1]:x,r=i.length>2&&void 0!==i[2]?i[2]:N,a=i.length>3&&void 0!==i[3]&&i[3],H(!0),e.next=7,(0,R.PV)("".concat(S,"/create_post"),{method:"POST",nonce:k,json:{title:t,content:n,excerpt:r,postType:oe}});case 7:if(o=e.sent,H(!1),o.success){e.next=12;break}return W(o.message),e.abrupt("return",null);case 12:return a||re(o.postId),e.abrupt("return",o.postId);case 14:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),pt=function(){var e=ei(Xo().mark((function e(){var t;return Xo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return me([]),t=le.map((function(e,t){return ei(Xo().mark((function n(){var r,a,o,i,c;return Xo().wrap((function(n){for(;;)switch(n.prev=n.next){case 0:return console.log("Topic "+t),n.prev=1,n.next=4,mt(e,!0);case 4:if(r=n.sent,a=r.title,o=r.content,i=r.excerpt,!(a&&o&&i)){n.next=15;break}return n.next=11,dt(a,o,i,!0);case 11:c=n.sent,me((function(t){return[].concat(function(e){if(Array.isArray(e))return ii(e)}(n=t)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||oi(n)||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.")}(),[{postId:c,topic:e,title:a,content:o,excerpt:i}]);var n})),n.next=16;break;case 15:console.warn("Could not generate the post for: "+e);case 16:n.next=21;break;case 18:n.prev=18,n.t0=n.catch(1),confirm("An error was caught ("+n.t0.message+"). Should we continue?")||(D.stop(),D.reset(),H(!1));case 21:return n.abrupt("return",{success:!0});case 22:case"end":return n.stop()}}),n,null,[[1,18]])})))})),e.next=4,D.start(t);case 4:D.reset();case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return React.createElement(y.s,{nekoErrors:[]},React.createElement(yt,{title:Ue.COMMON.CONTENT_GENERATOR}),React.createElement(g.o,null,React.createElement(g.z,{fullWidth:!0},React.createElement(tt,{options:C}),React.createElement(m.O,{p:!0,style:{marginTop:0,marginBottom:0}},(0,R.io)(Ue.CONTENT_GENERATOR.INTRO))),React.createElement(g.z,{style:{flex:1}},React.createElement(Pn,{style:{marginBottom:25}},React.createElement("h2",{style:{marginTop:0}},"Topic"),React.createElement(we.l,{name:"topic",disabled:ke||"bulk"===Ae,rows:5,value:Ie,onChange:rt}),React.createElement(be.i,null),React.createElement(b._,{fullWidth:!0,disabled:!Ie||"bulk"===Ae,isBusy:ke,startTime:null==pe?void 0:pe.all,onClick:function(){return mt()}},Ue.COMMON.GENERATE)),React.createElement(be.i,{height:50}),React.createElement(Pn,{style:{marginBottom:25}},G)),React.createElement(g.z,{style:{flex:3}},React.createElement(Oe.h,{name:"mode",value:Ae,disabled:ke,onChange:rt},React.createElement(Oe.S,{title:Ue.CONTENT_GENERATOR.SINGLE_GENERATE,value:"single"}),React.createElement(Oe.S,{title:Ue.CONTENT_GENERATOR.BULK_GENERATE,value:"bulk",count:le.length})),React.createElement(be.i,{height:40}),"bulk"===Ae&&React.createElement(Pn,null,React.createElement("p",{style:{marginTop:0,marginBottom:20}},(0,R.io)(Ue.CONTENT_GENERATOR.TOPICS_HELP)),React.createElement("div",{style:{display:"flex"}},React.createElement(b._,{disabled:ke||!le.length,onClick:pt},Ue.COMMON.GENERATE),React.createElement(_t.U,{busy:D.busy,style:{marginLeft:10,flex:"auto"},value:D.value,max:D.max,onStopClick:D.stop})),React.createElement(be.i,{height:40}),React.createElement("h3",null,"Topics"),React.createElement(we.l,{name:"topics",rows:10,value:Me,onChange:rt}),React.createElement(h.P,{name:"topicsAreTitles",label:"Use Topics as Titles",value:"1",checked:Ve,onChange:rt}),React.createElement("h3",null,Ue.CONTENT_GENERATOR.GENERATED_POSTS),!fe.length&&React.createElement("i",null,"Nothing yet."),fe.length>0&&React.createElement("ul",null,fe.map((function(e){return React.createElement("li",null,e.title," ",React.createElement("a",{target:"_blank",href:"/?p=".concat(e.postId)},"View")," or ",React.createElement("a",{target:"_blank",href:"/wp-admin/post.php?post=".concat(e.postId,"&action=edit")},"Edit"))})))),"single"===Ae&&React.createElement(Pn,null,React.createElement("h2",{style:{marginTop:0}},"Title"),React.createElement(ge.A,{name:"title",disabled:ke,value:Ce,onChange:rt}),ye&&React.createElement("div",{className:"information"},"Advice: ",ye),ze&&React.createElement(React.Fragment,null,React.createElement(be.i,{height:20}),React.createElement(vt,null,React.createElement("h2",null,Ue.CONTENT_GENERATOR.SECTIONS),React.createElement("div",{style:{display:"flex",alignItems:"center"}},ot.sectionsCount&&React.createElement(React.Fragment,null,React.createElement("label",{style:{margin:"0 5px 0 0"}},"# of Sections: "),React.createElement(ve.N,{scrolldown:!0,name:"sectionsCount",disabled:ke,style:{marginRight:10},value:Ge,description:"",onChange:rt},React.createElement(ve.Z,{key:2,value:2,label:2}),React.createElement(ve.Z,{key:3,value:3,label:3}),React.createElement(ve.Z,{key:4,value:4,label:4}),React.createElement(ve.Z,{key:6,value:6,label:6}),React.createElement(ve.Z,{key:8,value:8,label:8}),React.createElement(ve.Z,{key:10,value:10,label:10}),React.createElement(ve.Z,{key:12,value:12,label:12}))),Ge>0&&React.createElement(b._,{disabled:!Ce,isBusy:ke,startTime:null==pe?void 0:pe.sections,onClick:function(){return ut()}},Ue.CONTENT_GENERATOR.GENERATE_SECTIONS))),Ge>0&&React.createElement(React.Fragment,null,React.createElement(be.i,{height:20}),React.createElement(we.l,{name:"sections",disabled:ke,rows:4,value:Pe,description:Ue.CONTENT_GENERATOR.SECTIONS_HELP,onChange:rt}))),React.createElement(be.i,{height:20}),React.createElement(vt,null,React.createElement("h2",null,Ue.COMMON.CONTENT),React.createElement("div",{style:{display:"flex",alignItems:"center"}},ot.paragraphsCount&&React.createElement(React.Fragment,null,React.createElement("label",{style:{margin:"0 5px 0 0"}},Ue.CONTENT_GENERATOR.PARAGRAPHS_PER_SECTION,": "),React.createElement(ve.N,{scrolldown:!0,name:"paragraphsCount",disabled:ke,style:{marginRight:10},value:Fe,description:"",onChange:rt},React.createElement(ve.Z,{key:1,value:1,label:1}),React.createElement(ve.Z,{key:2,value:2,label:2}),React.createElement(ve.Z,{key:3,value:3,label:3}),React.createElement(ve.Z,{key:4,value:4,label:4}),React.createElement(ve.Z,{key:6,value:6,label:6}),React.createElement(ve.Z,{key:8,value:8,label:8}),React.createElement(ve.Z,{key:10,value:10,label:10}))),React.createElement(b._,{disabled:!Ce,isBusy:ke,startTime:null==pe?void 0:pe.content,onClick:function(){return st()}},Ue.CONTENT_GENERATOR.GENERATE_CONTENT))),React.createElement(be.i,{height:20}),React.createElement(we.l,{countable:"words",disabled:ke,rows:12,value:x,description:Ue.CONTENT_GENERATOR.CONTENT_HELP,onChange:T}),React.createElement(be.i,{height:20}),React.createElement(vt,null,React.createElement("h2",null,Ue.COMMON.EXCERPT),React.createElement(b._,{disabled:!Ce,isBusy:ke,startTime:null==pe?void 0:pe.excerpt,onClick:function(){return ft()}},Ue.CONTENT_GENERATOR.GENERATE_EXCERPT)),React.createElement(be.i,{height:20}),React.createElement(we.l,{disabled:ke,value:N,onBlur:L,rows:3}),React.createElement(be.i,{line:!0,height:40}),React.createElement(ve.N,{fullWidth:!0,scrolldown:!0,disabled:ke,name:"postType",onChange:ie,value:oe},null==Le?void 0:Le.map((function(e){return React.createElement(ve.Z,{key:e.type,value:e.type,label:e.name})}))),React.createElement(be.i,{height:20}),React.createElement(b._,{fullWidth:!0,style:{height:60},onClick:function(){return dt()},isBusy:ke,disabled:!Ce||!x},Ue.CONTENT_GENERATOR.CREATE_POST))),React.createElement(g.z,null,React.createElement(Pn,null,React.createElement("h2",{style:{marginTop:0}},Ue.CONTENT_GENERATOR.CONTENT_PARAMS),!ot.language&&!ot.writingStyle&&!ot.writingTone&&React.createElement("div",{style:{fontSize:11,lineHeight:"14px"}},Ue.CONTENT_GENERATOR.CONTENT_PARAMS_INTRO),ot.language&&React.createElement(React.Fragment,null,React.createElement("label",null,Ue.COMMON.LANGUAGE,":"),$e),ot.writingStyle&&React.createElement(React.Fragment,null,React.createElement("label",null,Ue.CONTENT_GENERATOR.WRITING_STYLE,":"),React.createElement(ve.N,{scrolldown:!0,name:"writingStyle",disabled:ke,value:De,description:"",onChange:rt},Ma.map((function(e){return React.createElement(ve.Z,{key:e.value,value:e.value,label:e.label})})))),ot.writingTone&&React.createElement(React.Fragment,null,React.createElement("label",null,Ue.CONTENT_GENERATOR.WRITING_TONE,":"),React.createElement(ve.N,{scrolldown:!0,name:"writingTone",disabled:ke,value:Be,description:"",onChange:rt},ja.map((function(e){return React.createElement(ve.Z,{key:e.value,value:e.value,label:e.label})}))))),React.createElement(be.i,{height:30}),React.createElement(Pn,null,React.createElement(vt,null,React.createElement("h2",null,Ue.CONTENT_GENERATOR.POST_PARAMS),React.createElement(b._,{onClick:function(){return $(!J)}},J?Ue.COMMON.HIDE:Ue.COMMON.SHOW)),J&&React.createElement(React.Fragment,null,React.createElement("label",null,Ue.COMMON.POST_TYPE,":"),React.createElement(ve.N,{scrolldown:!0,disabled:ke,name:"postType",onChange:ie,value:oe},null==Le?void 0:Le.map((function(e){return React.createElement(ve.Z,{key:e.type,value:e.type,label:e.name})}))))),React.createElement(be.i,{height:30}),React.createElement(Pn,null,React.createElement(vt,null,React.createElement("h2",null,Ue.COMMON.MODEL_PARAMS),React.createElement(b._,{onClick:function(){return V(!q)}},q?Ue.COMMON.HIDE:Ue.COMMON.SHOW)),q&&React.createElement(React.Fragment,null,React.createElement("label",null,Ue.COMMON.TEMPERATURE,":"),React.createElement(ge.A,{name:"temperature",value:Ze,type:"number",onChange:rt,onBlur:rt,description:Ue.HELP.TEMPERATURE}),React.createElement("label",null,Ue.COMMON.MAX_TOKENS,":"),React.createElement(ge.A,{name:"maxTokens",value:qe,type:"number",onChange:rt,onBlur:rt,description:Ue.HELP.MAX_TOKENS}),React.createElement("label",null,Ue.COMMON.MODEL,":"),React.createElement(ve.N,{name:"model",value:je,description:Ue.CONTENT_GENERATOR.MODEL_HELP,scrolldown:!0,onChange:rt},F.map((function(e){return React.createElement(ve.Z,{value:e.model,label:e.name})}))))),React.createElement(be.i,{height:30}),React.createElement(Pn,null,React.createElement(vt,null,React.createElement("h2",null,(0,R.io)(Ue.COMMON.PROMPTS)),React.createElement(b._,{onClick:function(){return ee(!Q)}},Q?"Hide":"Show")),Q&&React.createElement(React.Fragment,null,React.createElement("p",{style:{fontSize:11,lineHeight:"14px"}},Ue.CONTENT_GENERATOR.PROMPTS_INTRO),React.createElement("label",null,(0,R.io)(Ue.CONTENT_GENERATOR.PROMPT_TITLE)),React.createElement(we.l,{disabled:ke,name:"titlePromptFormat",value:He,onChange:rt}),React.createElement("label",null,(0,R.io)(Ue.CONTENT_GENERATOR.PROMPT_SECTIONS)),React.createElement(we.l,{disabled:ke,name:"sectionsPromptFormat",value:ze,onChange:rt}),React.createElement("label",null,(0,R.io)(Ue.CONTENT_GENERATOR.PROMPT_CONTENT)),React.createElement(we.l,{disabled:ke,name:"contentPromptFormat",value:Ye,onChange:rt}),React.createElement("label",null,(0,R.io)(Ue.CONTENT_GENERATOR.PROMPT_EXCERPT)),React.createElement(we.l,{disabled:ke,name:"excerptPromptFormat",value:We,onChange:rt}))),React.createElement(be.i,{height:30}),xe)),React.createElement(Se.L,{isOpen:ne,onRequestClose:function(){return re()},onOkClick:function(){window.open("/wp-admin/post.php?post=".concat(ne,"&action=edit"),"_blank"),j()},ok:Ue.CONTENT_GENERATOR.EDIT_POST,cancel:"Close",onCancelClick:function(){return j()},title:Ue.CONTENT_GENERATOR.POST_CREATED,content:React.createElement("p",null,Ue.CONTENT_GENERATOR.POST_CREATED_AS_DRAFT)}),React.createElement(Se.L,{isOpen:Y,onRequestClose:function(){W()},onOkClick:function(){W()},title:"Error",content:React.createElement("p",null,Y)}))};function mi(e){return mi="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},mi(e)}var di;function pi(){pi=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==mi(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 hi(e){return function(e){if(Array.isArray(e))return Oi(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||Ri(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 yi(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 vi(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){yi(o,r,a,i,c,"next",e)}function c(e){yi(o,r,a,i,c,"throw",e)}i(void 0)}))}}function gi(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 Ei(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gi(Object(n),!0).forEach((function(t){bi(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gi(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function bi(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==mi(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==mi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===mi(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function wi(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)||Ri(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 Ri(e,t){if(e){if("string"==typeof e)return Oi(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)?Oi(e,t):void 0}}function Oi(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 xi=wp.element,Ti=xi.useState,Si=xi.useEffect,_i=xi.useMemo,Ni=[1,2,3,6,9],Li=I.ZP.div(di||(di=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 ki=function(){var e=oo("imagesGenerator"),t=e.template,n=e.setTemplate,r=e.jsxTemplates,a=wi(Ti(),2),o=a[0],i=a[1],c=wi(Ti(!0),2),l=c[0],u=c[1],s=wi(Ti(!1),2),f=s[0],d=s[1],p=wi(Ti([]),2),v=p[0],E=p[1],w=wi(Ti(),2),O=w[0],x=w[1],T=wi(Ti(""),2),_=T[0],N=T[1],L=wi(Ti(""),2),A=L[0],I=L[1],M=wi(Ti(""),2),j=M[0],G=M[1],F=wi(Ti(""),2),D=F[0],U=F[1],B=wi(Ti(""),2),H=B[0],z=B[1],Y=wi(Ti([]),2),W=Y[0],Z=Y[1],q=_i((function(){return v.indexOf(O)}),[O,v]),V=null==t?void 0:t.prompt,K=null==t?void 0:t.maxResults;Si((function(){if(O){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;o<r.length&&r[o]&&a.length+r[o].length<t;)a+="-"+r[o],o++;return a.length>t+1&&(a=a.slice(0,t+2)),a}(V)+".png";z(e),N(V),I(V),G(V),U(V)}}),[O]);var J=function(){var e=vi(pi().mark((function e(){var t;return pi().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d(!0),e.next=3,(0,R.PV)("".concat(S,"/make_images"),{method:"POST",nonce:k,json:{env:"admin-tools",session:P,prompt:V,maxResults:K}});case 3:return t=e.sent,d(!1),t.success&&E(l?[].concat(hi(v),hi(t.data)):t.data),i(t.message),e.abrupt("return",null);case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),$=function(){var e=vi(pi().mark((function e(){var t;return pi().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return d(!0),e.next=3,(0,R.PV)("".concat(S,"/create_image"),{method:"POST",nonce:k,json:{url:O,title:_,description:A,caption:j,alt:D,filename:H}});case 3:return t=e.sent,d(!1),t.success&&Z([].concat(hi(W),[{id:t.attachmentId,url:O}])),i(t.message),e.abrupt("return",null);case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),X=_i((function(){var e=W.find((function(e){return e.url===O}));return e?e.id:null}),[O,W]);return React.createElement(y.s,{nekoErrors:[]},React.createElement(yt,{title:"Image Generator"}),React.createElement(g.o,null,React.createElement(g.z,{fullWidth:!0},React.createElement(tt,{options:C}),React.createElement(m.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(g.z,null,React.createElement(Pn,{style:{marginBottom:25}},r)),React.createElement(g.z,{style:{flex:3}},O&&React.createElement(React.Fragment,null,React.createElement(Ee.H,null,React.createElement(vt,{style:{paddingBottom:10}},React.createElement("h2",null,"Images Generator"),React.createElement("div",{style:{display:"flex",alignItems:"center"}},React.createElement(b._,{disabled:q<1||f,onClick:function(){q>0&&x(v[q-1])}},"<"),React.createElement(b._,{disabled:f,onClick:function(){return x()}},"Back to results"),React.createElement(b._,{disabled:q>=v.length-1||f,onClick:function(){q<v.length-1&&x(v[q+1])}},">"))),React.createElement("div",{style:{display:"flex"}},React.createElement("div",{style:{flex:2}},React.createElement("img",{src:O,style:{width:"100%"}})),React.createElement("div",{style:{flex:1,marginLeft:10,display:"flex",flexDirection:"column"}},React.createElement(Li,null,React.createElement("label",null,"Title:"),React.createElement(we.l,{value:_,onBlur:N,rows:2})),React.createElement(Li,null,React.createElement("label",null,"Caption:"),React.createElement(we.l,{value:j,onBlur:G,rows:2})),React.createElement(Li,null,React.createElement("label",null,"Description:"),React.createElement(we.l,{value:A,onBlur:I,rows:2})),React.createElement(Li,null,React.createElement("label",null,"Alternative Text:"),React.createElement(we.l,{value:D,onBlur:U,rows:2})),React.createElement(Li,null,React.createElement("label",null,"Filename:"),React.createElement(ge.A,{value:H,onChange:z})),React.createElement(b._,{fullWidth:!0,style:{marginTop:7},isBusy:f,onClick:function(){return $()}},"Add to Media Library"),React.createElement(b._,{fullWidth:!0,style:{marginLeft:0,marginTop:7},isBusy:f,onClick:function(){return(e=document.createElement("a")).href=O,e.target="_blank",e.download=H,void e.click();var e}},"Download"),React.createElement(be.i,null),X&&React.createElement(Re.S,{variant:"success"},"The media has been created! You can edit it here: ",React.createElement("a",{href:"/wp-admin/post.php?post=".concat(X,"&action=edit"),target:"_blank"},"Edit Media #",X),"."))))),!O&&React.createElement(React.Fragment,null,React.createElement(Ee.H,null,React.createElement(vt,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(ve.N,{scrolldown:!0,id:"maxResults",name:"maxResults",disabled:f,style:{marginRight:10},value:K,description:"",onChange:function(e){n(Ei(Ei({},t),{},{maxResults:e}))}},Ni.map((function(e){return React.createElement(ve.Z,{key:e,id:e,value:e,label:e})}))),React.createElement(b._,{disabled:!V,isBusy:f,onClick:J},"Generate Images"))),React.createElement(we.l,{value:V,onChange:function(e){n(Ei(Ei({},t),{},{prompt:e}))},style:{marginTop:20}}),React.createElement(gt,null,v.map((function(e){return React.createElement("img",{src:e,onClick:function(){return x(e)}})})),hi(Array(Math.max(3-v.length,0)).keys()).map((function(e){return React.createElement("div",{class:"empty-image"})})))))),React.createElement(g.z,null,React.createElement(Ee.H,{style:{marginBottom:25}},React.createElement("h2",{style:{marginTop:0}},"Settings"),React.createElement(h.P,{id:"continuous_mode ",label:"Continuous",value:"1",checked:l,description:"New images will be added to the already generated images.",onChange:u})))),React.createElement(Se.L,{isOpen:o,onRequestClose:function(){i()},onOkClick:function(){i()},title:"Error",content:React.createElement("p",null,o)}))};function Ci(e){return Ci="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},Ci(e)}function Pi(){Pi=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==Ci(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 Ai(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 Ii(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Ai(o,r,a,i,c,"next",e)}function c(e){Ai(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Mi(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 ji(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)?ji(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 ji(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 Gi=wp.element,Fi=Gi.useState,Di=Gi.useEffect,Ui=Gi.useMemo;const Bi=function(e){var t=e.post,n=e.onExcerptClick,r=void 0===n?{}:n,a=e.onClose,o=void 0===a?{}:a,i=Mi(Fi([]),2),c=i[0],l=i[1],u=Mi(Fi(!1),2),s=u[0],f=u[1],m=Mi(Fi(!1),2),d=m[0],p=m[1];Di((function(){t&&h(t)}),[t]);var h=function(){var e=Ii(Pi().mark((function e(t){var n,r;return Pi().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=t.postId,f(!0),e.next=4,(0,R.PV)("".concat(S,"/make_excerpts"),{method:"POST",nonce:k,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=Ii(Pi().mark((function e(t){return Pi().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return f(!0),e.prev=1,e.next=4,r(t);case 4:v(),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)}}(),v=function(){var e=Ii(Pi().mark((function e(){return Pi().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)}}(),E=Ui((function(){return s?React.createElement(Ia.S,{type:"circle",size:"10%"}):d?React.createElement(React.Fragment,null,"Error: ",d):(null==c?void 0:c.length)>0?React.createElement(React.Fragment,null,"Pick a new excerpt by clicking on it.",React.createElement(ko,null,c.map((function(e){return React.createElement(Co,{key:e,onClick:function(){y(e)}},e)})))):React.createElement(React.Fragment,null,"Nothing to display.")}),[s,c,d]);return React.createElement(g.o,null,React.createElement(Se.L,{isOpen:t,onRequestClose:v,title:'New excerpt for "'.concat(null==t?void 0:t.postTitle,'"'),content:E,ok:"Close",onOkClick:v}))};function Hi(e){return Hi="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},Hi(e)}function zi(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 Yi(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?zi(Object(n),!0).forEach((function(t){Wi(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):zi(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Wi(e,t,n){return(t=function(e){var t=function(e,t){if("object"!==Hi(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,"string");if("object"!==Hi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===Hi(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var Zi=wp.element,qi=(Zi.useState,Zi.useEffect,Zi.useMemo),Vi=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"})))),Ki=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 Ji=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=qi((function(){switch(n){case"ai":default:return Vi;case"wand":return Ki}}),[n]);return React.createElement("svg",{style:Yi({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 $i(e){return $i="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},$i(e)}function Xi(){Xi=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==$i(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 Qi(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 ec(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){Qi(o,r,a,i,c,"next",e)}function c(e){Qi(o,r,a,i,c,"throw",e)}i(void 0)}))}}function tc(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 nc(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)?nc(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 nc(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 rc=wp.element,ac=rc.useState,oc=(rc.useEffect,rc.useMemo,wp.i18n.__),ic=wp.plugins.registerPlugin,cc=wp.components.Button,lc=wp.editPost,uc=lc.PluginDocumentSettingPanel,sc=lc.PluginBlockSettingsMenuItem,fc=function(){alert("Coming soon! Let me know your feedback and ideas, I will make this awesome for you.")};ic("ai-engine-menu-paragraph-generate",{render:function(){return React.createElement(React.Fragment,null,React.createElement(sc,{allowedBlocks:["core/paragraph"],icon:React.createElement(Ji,{icon:"wand",style:{marginRight:0}}),label:React.createElement(React.Fragment,null," ",oc("Enhance text")),onClick:fc}),React.createElement(sc,{allowedBlocks:["core/paragraph"],icon:React.createElement(Ji,{icon:"wand",style:{marginRight:0}}),label:React.createElement(React.Fragment,null," ",oc("Translate text")),onClick:fc}))}});var mc=function(){var e=null==C?void 0:C.module_suggestions,t=tc(ac(),2),n=t[0],r=t[1],a=tc(ac(),2),o=a[0],i=a[1],c=function(){var e=ec(Xi().mark((function e(t){return Xi().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)}}(),l=function(){var e=ec(Xi().mark((function e(t){return Xi().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 e?React.createElement(s.Z,null,React.createElement(uc,{name:"mwai-document-settings",title:React.createElement(React.Fragment,null,React.createElement(Ji,null)," AI Engine"),className:"mwai-document-settings"},React.createElement("p",null,"Suggest:"),React.createElement("div",{style:{display:"flex"}},React.createElement(cc,{variant:"primary",onClick:function(){var e=(0,wp.data.select("core/editor").getCurrentPost)(),t=e.id,n=e.title;e.excerpt,r({postId:t,postTitle:n})},style:{flex:1,marginRight:10}},React.createElement(Ji,{icon:"wand",style:{marginRight:8}})," Titles"),React.createElement(cc,{variant:"primary",onClick:function(){var e=(0,wp.data.select("core/editor").getCurrentPost)(),t=e.id,n=e.title;e.excerpt,i({postId:t,postTitle:n})},style:{flex:1}},React.createElement(Ji,{icon:"wand",style:{marginRight:8}})," Excerpts")),React.createElement(s.Z,null,React.createElement(g.o,null,React.createElement(Ho,{post:n,onTitleClick:c,onClose:r}),React.createElement(Bi,{post:o,onExcerptClick:l,onClose:i}))))):null};var dc,pc=["children","type","title","hint"];function hc(){return hc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},hc.apply(this,arguments)}var yc=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"})),vc=I.ZP.div(dc||(dc=function(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}(["\n\tcolor: black;\n\tdisplay: flex;\n\tflex-direction: column;\n\tborder: 1px solid black;\n\tfont-size: 15px;\n\tbox-sizing: content-box;\n\tfont-weight: 400;\n font-size: 13px;\n\tpadding: 10px;\n\tbackground: white;\n\n\t.mwai-title-container {\n\t\tflex: inherit;\n\t\tpadding: 5px 0px 5px 10px;\n\t\tdisplay: flex;\n\t\talign-items: center;\n\t\tcolor: black;\n\t\tfont-weight: 600;\n\t\tcursor: pointer;\n\n\t\t.mwai-hint {\n\t\t\tfont-size: 10px;\n\t\t\tfont-weight: 400;\n\t\t\ttext-align: right;\n\t\t\tflex: auto;\n\n\t\t\t.mwai-pill {\n\t\t\t\tbackground: ",";\n\t\t\t\tpadding: 5px 10px;\n\t\t\t\tborder-radius: 8px;\n\t\t\t\tcolor: white;\n\t\t\t}\n\n\t\t\t.mwai-pill-purple {\n\t\t\t\tbackground: ",";\n\t\t\t}\n\t\t}\n\t}\n\n\t.mwai-block-container-content {\n\t\tdisplay: none;\n\t\tflex: auto;\n\t\tpadding: 0px 10px;\n\n\t\t.mwai-block-container {\n\t\t\tborder: 1px solid black;\n\t\t\tmargin: 10px 0;\n\n\t\t\t.mwai-title-container {\n\t\t\t\tbackground: white;\n\t\t\t}\n\n\t\t\t.mwai-block-container-content {\n\t\t\t\tbackground: white;\n\t\t\t}\n\t\t}\n\t}\n\n\t&.mwai-container > .mwai-block-container-content {\n\t\tdisplay: block;\n\t}\n\n\t.is-selected {\n\n\t\t&:after {\n\t\t\tborder: 1px solid ",";\n\t\t}\n\n\t\t& > .mwai-block-container:not(.mwai-container) {\n\n\t\t\t.mwai-block-container-content {\n\t\t\t padding: 10px;\n\t\t\t display: flex;\n\t\t\t}\n\t\t}\n\t}\n\t\n"])),xt.ZP.blue,xt.ZP.purple,xt.ZP.blue),gc=function(e){var t=e.children,n=e.type,r=void 0===n?"":n,a=e.title,o=void 0===a?"":a,i=e.hint,c=void 0===i?"":i,l=function(e,t){if(null==e)return{};var n,r,a=function(e,t){if(null==e)return{};var n,r,a={},o=Object.keys(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||(a[n]=e[n]);return a}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(r=0;r<o.length;r++)n=o[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(a[n]=e[n])}return a}(e,pc),u=(0,Nt.F0)("mwai-block-container","mwai-"+r);return React.createElement(vc,hc({className:u},l),React.createElement("div",{className:"mwai-title-container"},React.createElement(Ji,{icon:"ai",style:{width:20,height:20}}),React.createElement("div",null,o),React.createElement("div",{className:"mwai-hint"},c)),React.createElement("div",{className:"mwai-block-container-content"},t))},Ec=(wp.i18n.__,wp.blocks),bc=Ec.registerBlockType,wc=(Ec.createBlock,wp.element),Rc=wc.useMemo,Oc=(wc.useEffect,wc.useState,wp.components),xc=(Oc.Button,Oc.DropZone,Oc.PanelBody),Tc=(Oc.RangeControl,Oc.CheckboxControl,Oc.TextControl,Oc.SelectControl,Oc.Toolbar,Oc.withNotices,wp.blockEditor),Sc=(Tc.BlockControls,Tc.InspectorControls),_c=function(e){var t=e.attributes;return t.id,t.fieldName,t.labelText,console.log(e),React.createElement(React.Fragment,null,"[mwai_chatbot]")},Nc=function(e){var t=e.attributes,n=(t.id,t.fieldName,t.labelText,e.setAttributes,Rc((function(){return _c(e)}),[e]));return React.createElement(React.Fragment,null,n,React.createElement(Sc,null,React.createElement(xc,{title:Ue.COMMON.CHATBOT}),React.createElement(xc,{title:Ue.COMMON.SETTINGS})))};function Lc(){return Lc=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Lc.apply(this,arguments)}var kc=wp.i18n.__,Cc=wp.blocks.registerBlockType,Pc=wp.element,Ac=(Pc.useMemo,Pc.useEffect),Ic=wp.components,Mc=(Ic.Button,Ic.PanelBody),jc=(Ic.TextControl,Ic.SelectControl),Gc=wp.blockEditor,Fc=Gc.InspectorControls,Dc=Gc.InnerBlocks,Uc=Gc.useBlockProps,Bc=function(e){var t=Uc.save(),n=e.attributes,r=n.id,a=n.theme,o='[mwai-form-container id="'.concat(r,'" theme="').concat(a,'"]');return React.createElement("div",Lc({},t,{id:"mwai-form-container-".concat(r),className:"mwai-form-container"}),o,React.createElement(Dc.Content,null))},Hc=function(e){var t=e.attributes,n=t.id,r=t.theme,a=e.setAttributes,o=Uc();return Ac((function(){if(!n){var e=Math.random().toString(36).substr(2,9);a({id:e})}}),[n]),React.createElement(React.Fragment,null,React.createElement(gc,{title:"Container",type:"container"},React.createElement("div",o,React.createElement(Dc,null))),React.createElement(Fc,null,React.createElement(Mc,{title:Ue.COMMON.STYLE},React.createElement("p",null,"The theme will be applied to all the AI elements in this container."),React.createElement(jc,{label:"Theme",value:r,onChange:function(e){return a({theme:e})},options:[{label:"None",value:"none"},{label:"ChatGPT",value:"ChatGPT"}]}))))};function zc(e){return function(e){if(Array.isArray(e))return Yc(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(e){if("string"==typeof e)return Yc(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)?Yc(e,t):void 0}}(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 Yc(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 Wc=wp.i18n.__,Zc=wp.blocks.registerBlockType,qc=wp.element.useEffect,Vc=wp.components,Kc=Vc.Button,Jc=Vc.PanelBody,$c=Vc.TextControl,Xc=Vc.SelectControl,Qc=(Vc.Icon,wp.blockEditor.InspectorControls),el=function(e){var t=e.attributes,n=t.id,r=t.label,a=t.type,o=t.name,i=t.options,c=void 0===i?[]:i,l=t.placeholder,u=t.rows,s=t.defaultValue,f=t.maxlength,m=encodeURIComponent(JSON.stringify(c)),d="[mwai-form-field";return n&&(d+=' id="'.concat(n,'"')),r&&(d+=' label="'.concat(r,'"')),a&&(d+=' type="'.concat(a,'"')),o&&(d+=' name="'.concat(o,'"')),m&&(d+=' options="'.concat(m,'"')),l&&(d+=' placeholder="'.concat(l,'"')),"textarea"===a&&u&&(d+=' rows="'.concat(u,'"')),s&&(d+=' default="'.concat(s,'"')),f&&(d+=' maxlength="'.concat(f,'"')),d+"]"},tl=function(e){var t,n=e.attributes,r=n.id,a=n.type,o=n.name,i=n.options,c=void 0===i?[]:i,l=n.label,u=n.placeholder,s=n.rows,f=n.defaultValue,m=n.maxlength,d=e.setAttributes;return qc((function(){if(!r){var e=Math.random().toString(36).substr(2,9);d({id:"mwai-"+e})}}),[r]),React.createElement(React.Fragment,null,React.createElement(gc,{title:"".concat((t=a,t.charAt(0).toUpperCase()+t.slice(1))),type:"field",hint:React.createElement("span",{className:"mwai-pill"},o)},React.createElement("div",null,l),React.createElement("div",{style:{flex:"auto"}}),React.createElement("div",null,o)),React.createElement(Qc,null,React.createElement(Jc,{title:Wc("Field")},React.createElement($c,{label:"Label Text",value:l,onChange:function(e){d({label:e});var t=e.trim().replace(/ /g,"_").replace(/[^\w-]+/g,"").toUpperCase();t&&d({name:t})}}),React.createElement($c,{label:"Field Name",value:o,onChange:function(e){return d({name:e})}}),React.createElement(Xc,{label:"Field Type",value:a,onChange:function(e){return d({type:e})},options:[{label:"Input",value:"input"},{label:"Select",value:"select"},{label:"Checkbox",value:"checkbox"},{label:"Radio",value:"radio"},{label:"Text Area",value:"textarea"}]}),("input"===a||"textarea"===a)&&React.createElement($c,{label:"Placeholder",value:u,onChange:function(e){return d({placeholder:e})}}),("input"===a||"textarea"===a)&&React.createElement($c,{label:"Default Value",value:f,onChange:function(e){return d({defaultValue:e})}}),("input"===a||"textarea"===a)&&React.createElement($c,{label:"Max Length",value:m,onChange:function(e){return d({maxlength:e})}}),"textarea"===a&&React.createElement($c,{label:Ue.COMMON.ROWS,value:s,onChange:function(e){return d({rows:e})},type:"number",step:"1",min:"1",max:"100"})),("select"===a||"radio"===a||"checkbox"===a)&&React.createElement(Jc,{title:React.createElement("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",width:"100%"}},React.createElement("div",null,Wc("Options")))},c.map((function(e,t){return React.createElement("div",{key:t,style:{display:"flex",marginBottom:-25}},React.createElement("div",{style:{marginRight:5}},React.createElement($c,{style:{marginRight:10},label:"Label",isInline:!0,value:e.label,onChange:function(e){var n=zc(c);n[t].label=e,d({options:n})}})),React.createElement($c,{style:{},label:"Value",isSubtle:!0,value:e.value,onChange:function(e){var n=zc(c);n[t].value=e,d({options:n})}}),React.createElement("div",{style:{marginLeft:5,position:"relative",top:23}},React.createElement(Kc,{style:{height:30},isDestructive:!0,icon:"trash",isSmall:!0,onClick:function(){var e=zc(c);e.splice(t,1),d({options:e})}})))})),React.createElement(Kc,{isPrimary:!0,style:{width:"100%",marginTop:10},onClick:function(e){var t=zc(c);t.push({label:"",value:""}),d({options:t})}},"Add Option")),React.createElement(Jc,{title:Ue.COMMON.SYSTEM},React.createElement($c,{label:"ID",value:r,onChange:function(e){return d({id:e})}}))))};var nl=wp.i18n.__,rl=wp.blocks.registerBlockType,al=wp.element,ol=(al.useMemo,al.useEffect),il=wp.components,cl=il.PanelBody,ll=il.TextControl,ul=wp.blockEditor.InspectorControls,sl=function(e){var t=e.attributes.id;return'[mwai-form-output id="'.concat(t,'"]')},fl=function(e){var t=e.attributes.id,n=e.setAttributes;return ol((function(){if(!t){var e=Math.random().toString(36).substr(2,9);n({id:"mwai-"+e})}}),[t]),React.createElement(React.Fragment,null,React.createElement(gc,{title:"Output",type:"output",hint:React.createElement("span",{className:"mwai-pill mwai-pill-purple"},"#",t)},React.createElement("div",null),React.createElement("div",{style:{flex:"auto"}}),React.createElement("div",null,"#",t)),React.createElement(ul,null,React.createElement(cl,{title:Ue.FORMS.OUTPUT},React.createElement(ll,{label:"ID",value:t,onChange:function(e){return n({id:e})}}))))};var ml=wp.i18n.__,dl=wp.blocks.registerBlockType,pl=wp.element,hl=pl.useMemo,yl=pl.useEffect,vl=wp.components,gl=vl.PanelBody,El=vl.TextControl,bl=vl.TextareaControl,wl=vl.SelectControl,Rl=(vl.UnitControl,wp.blockEditor.InspectorControls),Ol=function(e){var t=e.attributes,n=t.id,r=t.label,a=t.prompt,o=t.outputElement,i=t.model,c=t.temperature,l=t.maxTokens,u=encodeURIComponent(a);return'[mwai-form-submit id="'.concat(n,'" label="').concat(r,'" prompt="').concat(u,'" output_element="').concat(o,'" model="').concat(i,'" temperature="').concat(c,' max_tokens="').concat(l,'"]')},xl=function(e){var t=lt(C).models,n=e.attributes,r=n.id,a=n.label,o=n.prompt,i=n.model,c=n.temperature,l=n.maxTokens,u=n.outputElement,s=n.placeholders,f=void 0===s?[]:s,m=e.setAttributes;yl((function(){if(!r){var e=Math.random().toString(36).substr(2,9);m({id:"mwai-"+e})}}),[r]),yl((function(){var e=o.match(/{([^}]+)}/g);if(e){var t=e.map((function(e){return e.replace("{","").replace("}","")}));t.join(",")!==f.join(",")&&m({placeholders:t})}}),[o]);var d=hl((function(){return f?f.length:0}),[f]),p=hl((function(){var e=t.map((function(e){return{label:e.name,value:e.model}}));return e.push({label:"dall-e",value:"dall-e"}),e}),[t]);return React.createElement(React.Fragment,null,React.createElement(gc,{title:"Submit",type:"submit",hint:React.createElement(React.Fragment,null,React.createElement("span",{className:"mwai-pill"},d," field",d>1?"s":"")," to"," ",React.createElement("span",{className:"mwai-pill mwai-pill-purple"},u))},"Input Fields: ",f.join(", "),React.createElement("br",null),"Prompt: ",o,React.createElement("br",null),"Output Element: ",u),React.createElement(Rl,null,React.createElement(gl,{title:Ue.COMMON.OUTPUT},React.createElement(El,{label:Ue.COMMON.LABEL,value:a,onChange:function(e){return m({label:e})}}),React.createElement(bl,{label:Ue.COMMON.PROMPT,value:o,onChange:function(e){return m({prompt:e})},help:Ue.FORMS.PROMPT_INFO}),React.createElement(El,{label:Ue.FORMS.OUTPUT_ELEMENT,value:u,onChange:function(e){return m({outputElement:e})},help:Ue.FORMS.OUTPUT_ELEMENT_INFO})),React.createElement(gl,{title:Ue.COMMON.MODEL_PARAMS},t&&t.length>0&&React.createElement(wl,{label:Ue.COMMON.MODEL,value:i,options:p,onChange:function(e){return m({model:e})}}),React.createElement(El,{label:Ue.COMMON.TEMPERATURE,value:c,onChange:function(e){return m({temperature:e})},type:"number",step:"0.1",min:"0",max:"1",help:Ue.HELP.TEMPERATURE}),React.createElement(El,{label:Ue.COMMON.MAX_TOKENS,value:l,onChange:function(e){return m({maxTokens:e})},type:"number",step:"16",min:"32",max:"4096",help:Ue.HELP.MAX_TOKENS})),React.createElement(gl,{title:Ue.COMMON.SYSTEM},React.createElement(El,{label:"ID",value:r,onChange:function(e){return m({id:e})}}))))};function Tl(e){return Tl="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},Tl(e)}function Sl(){Sl=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 T(a||[]);return r(i,"_invoke",{value:w(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 d(){}function p(){}var h={};l(h,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(S([])));v&&v!==t&&n.call(v,o)&&(h=v);var g=p.prototype=m.prototype=Object.create(h);function E(e){["next","throw","return"].forEach((function(t){l(e,t,(function(e){return this._invoke(t,e)}))}))}function b(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"==Tl(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 w(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 O(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function x(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function T(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(O,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:_}}function _(){return{value:void 0,done:!0}}return d.prototype=p,r(g,"constructor",{value:p,configurable:!0}),r(p,"constructor",{value:d,configurable:!0}),d.displayName=l(p,c,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===d||"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}},E(b.prototype),l(b.prototype,i,(function(){return this})),e.AsyncIterator=b,e.async=function(t,n,r,a,o){void 0===o&&(o=Promise);var i=new b(u(t,n,r,a),o);return e.isGeneratorFunction(n)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},E(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,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(x),!e)for(var t in this)"t"===t.charAt(0)&&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),x(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;x(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 _l(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 Nl(e){return function(){var t=this,n=arguments;return new Promise((function(r,a){var o=e.apply(t,n);function i(e){_l(o,r,a,i,c,"next",e)}function c(e){_l(o,r,a,i,c,"throw",e)}i(void 0)}))}}function Ll(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 kl(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)?kl(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 kl(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 Cl=wp.element,Pl=Cl.useState,Al=Cl.useEffect;Cl.useMemo;const Il=function(e){var t=e.isOpen,n=void 0!==t&&t,r=(e.title,e.onClose),a=void 0===r?{}:r,o=Ll(Pl(""),2),i=o[0],c=o[1],l=Ll(Pl("Logitech MK270 Wireless Keyboard"),2),u=l[0],s=l[1],f=ct({options:C}),m=f.currentHumanLanguage,d=f.jsxLanguageSelector,p=Ll(Pl(""),2),h=p[0],y=p[1],v=Ll(Pl(""),2),E=v[0],w=v[1],O=Ll(Pl(""),2),x=O[0],T=O[1],_=Ll(Pl(!1),2),N=_[0],L=_[1],A=Ll(Pl(!1),2),I=(A[0],A[1]);function M(e){var t=e.split("\n"),n={};return t.forEach((function(e){e.startsWith("DESCRIPTION:")?n.description=e.replace("DESCRIPTION:","").trim():e.startsWith("SHORT_DESCRIPTION:")?n.shortDescription=e.replace("SHORT_DESCRIPTION:","").trim():e.startsWith("SEO_TITLE:")?n.seoTitle=e.replace("SEO_TITLE:","").trim():e.startsWith("TAGS:")&&(n.keywords=e.replace("TAGS:","").trim().split(", "))})),n}Al((function(){var e=document.getElementById("title");e&&s(e.value)}),[n]);var j=function(){var e=Nl(Sl().mark((function e(){var t,n,r;return Sl().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return L(!0),t=(t="Here is the product: {USER_ENTRY}\n\nBased on the product, write a description of this product (between 120 and 240 words), a short description (between 20-49 words), a SEO-friendly title, and tags, separated by commas. Write it in {LANGUAGE}. Use this format:\nDESCRIPTION: \nSHORT_DESCRIPTION: \nSEO_TITLE: \nTAGS: \n\n".replace("{USER_ENTRY}",u)).replace("{LANGUAGE}",m),e.next=5,(0,R.PV)("".concat(S,"/make_completions"),{method:"POST",nonce:k,json:{maxTokens:512,temperature:.8,env:"admin-tools",session:P,prompt:t}});case 5:n=e.sent,L(!1),n.success&&(r=M(n.data),console.log({raw:n.data,info:r}),c(r.description),y(r.shortDescription),w(r.seoTitle),T(r.keywords.join(", ")));case 8:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),G=function(){var e=document.getElementById("title");e?e.value=E:alert("The title cannot be written (the field could not be found).")},F=function(){var e=tinyMCE.get("content");e?e.setContent(i):alert("The content cannot be written (the field could not be found).")},D=function(){var e=tinyMCE.get("excerpt");e?e.setContent(h):alert("The content cannot be written (the field could not be found).")},U=function(){var e=document.getElementById("new-tag-product_tag");e?e.value=x:alert("The tags cannot be written (the field could not be found).")},B=function(){var e=Nl(Sl().mark((function e(){return Sl().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:G(),F(),D(),U(),a();case 5:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),H=function(){var e=Nl(Sl().mark((function e(){return Sl().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:a(),I(),L(!1);case 3:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}();return React.createElement(g.o,null,React.createElement(Se.L,{isOpen:n,onRequestClose:H,title:Ue.COMMON.WOOCOMMERCE_PRODUCT_GENERATOR,content:React.createElement(Et,null,React.createElement("label",null,"Define your product:"),React.createElement(we.l,{disabled:N,name:"userEntry",value:u,rows:3,onChange:s,style:{flex:"auto"},placeholder:"What's your product?"}),React.createElement("div",{className:"form-row"},React.createElement("div",{style:{flex:"auto"}},d),React.createElement(b._,{isBusy:N,onClick:j,style:{marginLeft:5}},"Generate Fields")),React.createElement(be.i,{height:30,line:!0}),React.createElement("div",{className:"form-row-label"},React.createElement("label",null,"Title"),React.createElement(b._,{small:!0,disabled:!E,onClick:G,style:{marginBottom:5,marginTop:-2,height:20,minHeight:20}},"Write")),React.createElement(ge.A,{disabled:N,value:E,onChange:w}),React.createElement("div",{className:"form-row-label"},React.createElement("label",null,"Description"),React.createElement(b._,{small:!0,disabled:!i,onClick:F,style:{marginBottom:5,marginTop:-2,height:20,minHeight:20}},"Write")),React.createElement(we.l,{disabled:N,rows:4,value:i,onChange:c}),React.createElement("div",{className:"form-row-label"},React.createElement("label",null,"Short Description"),React.createElement(b._,{small:!0,disabled:!h,onClick:D,style:{marginBottom:5,marginTop:-2,height:20,minHeight:20}},"Write")),React.createElement(we.l,{disabled:N,rows:4,value:h,onChange:y}),React.createElement("div",{className:"form-row-label"},React.createElement("label",null,"Product Tags"),React.createElement(b._,{small:!0,disabled:!x,onClick:U,style:{marginBottom:5,marginTop:-2,height:20,minHeight:20}},"Write")),React.createElement(ge.A,{small:!0,disabled:N,value:x,onChange:T})),ok:"Write all fields",onOkClick:B}))};function Ml(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 jl=wp.element,Gl=jl.useState,Fl=(jl.useEffect,jl.useMemo,wp.i18n.__,wp.components.Button);const Dl=function(){var e,t,n=(e=Gl(),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 Ml(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)?Ml(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];return React.createElement(React.Fragment,null,React.createElement("p",null,"Generate the WooCommerce fields."),React.createElement("div",{style:{display:"flex"}},React.createElement(Fl,{variant:"primary",onClick:function(){a(!0)},style:{flex:1,marginRight:10}},React.createElement(Ji,{icon:"wand",style:{marginRight:8}})," Generate Fields")),React.createElement(g.o,null,React.createElement(Il,{isOpen:r,onClose:function(){a(!1)}})))};var Ul=wp.element.render,Bl=new l.S({defaultOptions:{queries:{refetchOnWindowFocus:!1,refetchOnMount:!1,retry:!1}}});Zc("ai-engine/form-field",{title:"AI Form Field",description:React.createElement(React.Fragment,null,"This feature is ",React.createElement("b",null,"extremely beta"),". I am enhancing it based on your feedback."),icon:yc,category:"layout",keywords:[Wc("ai"),Wc("openai"),Wc("form")],attributes:{id:{type:"string",default:""},name:{type:"string",default:"LABEL"},type:{type:"string",default:"input"},options:{type:"array",default:[]},label:{type:"string",default:"Label: "},placeholder:{type:"string",default:""},defaultValue:{type:"string",default:""},maxlength:{type:"string",default:""},rows:{type:"rows",default:4}},edit:tl,save:el}),rl("ai-engine/form-output",{title:"AI Form Output",description:React.createElement(React.Fragment,null,"This feature is ",React.createElement("b",null,"extremely beta"),". I am enhancing it based on your feedback."),icon:yc,category:"layout",keywords:[nl("ai"),nl("openai"),nl("form")],attributes:{id:{type:"string",default:""}},edit:fl,save:sl}),bc("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:yc,category:"layout",keywords:["ai","openai","chatbot"],attributes:{id:{type:"string",default:""}},edit:Nc,save:_c}),dl("ai-engine/form-submit",{title:"AI Form Submit",description:React.createElement(React.Fragment,null,"This feature is ",React.createElement("b",null,"extremely beta"),". I am enhancing it based on your feedback."),icon:yc,category:"layout",keywords:[ml("ai"),ml("openai"),ml("form")],attributes:{id:{type:"string",default:""},label:{type:"string",default:"Submit"},prompt:{type:"string",default:""},outputElement:{type:"string",default:""},model:{type:"string",default:""},temperature:{type:"number",default:.8},maxTokens:{type:"number",default:4096},placeholders:{type:"array",default:[]}},edit:xl,save:Ol}),Cc("ai-engine/form-container",{title:"AI Form Container",description:React.createElement(React.Fragment,null,"This feature is ",React.createElement("b",null,"extremely beta"),". I am enhancing it based on your feedback."),icon:yc,category:"layout",keywords:[kc("ai"),kc("openai"),kc("form")],attributes:{id:{type:"string",default:""},theme:{type:"string",default:"ChatGPT"}},edit:Hc,save:Bc}),document.addEventListener("DOMContentLoaded",(function(){ic("ai-engine-document-settings",{render:mc});var e=document.getElementById("mwai-admin-settings");e&&Ul(React.createElement(u.aH,{client:Bl},React.createElement(s.Z,null,React.createElement(Aa,null))),e);var t=document.getElementById("mwai-content-generator");t&&Ul(React.createElement(u.aH,{client:Bl},React.createElement(s.Z,null,React.createElement(fi,null))),t);var n=document.getElementById("mwai-image-generator");n&&Ul(React.createElement(u.aH,{client:Bl},React.createElement(s.Z,null,React.createElement(ki,null))),n);var r=document.getElementById("mwai-playground");r&&Ul(React.createElement(u.aH,{client:Bl},React.createElement(s.Z,null,React.createElement(So,null))),r);var a=document.getElementById("mwai-admin-postsList");a&&Ul(React.createElement(s.Z,null,React.createElement(Jo,null)),a);var o=document.getElementById("mwai-admin-wcAssistant");o&&Ul(React.createElement(s.Z,null,React.createElement(Dl,null)),o);var i=document.getElementById("meow-common-dashboard");i&&Ul(React.createElement(s.Z,null,React.createElement(ye,null)),i)}))},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(2203)));a=r.O(a)})(); |