芝麻web文件管理V1.00
编辑当前文件:/home/pulsehostuk9/www/misfits2/wp-content/plugins/uicore-framework/assets/js/ai.min.js
(()=>{"use strict";var t,e={8883:(t,e,r)=>{var n=r(2893),o=function(){var t=this,e=t._self._c;return e("div",{staticClass:"ui-ai-writer"},[e("a",{directives:[{name:"show",rawName:"v-show",value:t.writing,expression:"writing"}],staticClass:"button button-primary button-large uicore-ai-assistant-working",attrs:{type:"button",href:"#none"},on:{click:function(e){return t.stop(!0)}}},[t._v("Stop")]),e("uibase",{directives:[{name:"show",rawName:"v-show",value:!t.writing,expression:"!writing"}],style:t.getMainColor,attrs:{title:"AI Writing Assistant
BETA
",scroll:!1}},[""==t.mode?e("div",{staticClass:"uianim-content"},[e("p",{staticStyle:{padding:"0 20px","font-size":"14px",margin:"0"}},[t._v("\r\n We need to connect to your OpenAl account so you have full control and ownership of your data. You\r\n can find your Secret API key in your\r\n "),e("a",{attrs:{href:"https://beta.openai.com/account/api-keys",target:"_blank"}},[t._v("User settings")]),t._v("\r\n (inside your OpenAI Account).\r\n ")]),e("div",{staticClass:"uicore-core-setting"},[e("label",{staticClass:"uicore_h2",attrs:{for:"openaiApiKey"}},[t._v("OpenAI Key")]),e("input",{directives:[{name:"model",rawName:"v-model",value:t.openaiApiKey,expression:"openaiApiKey"}],staticStyle:{width:"100%","max-width":"100%"},attrs:{id:"openaiApiKey",type:"text",placeholder:"sk-
"},domProps:{value:t.openaiApiKey},on:{input:function(e){e.target.composing||(t.openaiApiKey=e.target.value)}}})]),e("div",{staticClass:"uicore-btn",on:{click:t.saveKey}},[t._v("Save OpenAI Key")])]):t._e(),"done"==t.mode?e("div",{staticClass:"uianim-content"},[e("p",{staticStyle:{margin:"0 20px 15px","font-size":"16px"}},[t._v("\r\n Your article has been generated successfully. Please note that this is a "),e("b",[t._v("beta")]),t._v(" feature and we\r\n are constantly working on improving it. "),e("br"),e("i",{staticStyle:{"font-size":"13px",opacity:"0.7","line-height":"19px","margin-top":"14px",display:"block"}},[t._v("Your feedback is important to us, so if you have any suggestions please don’t hesitate to let\r\n us know.")])]),e("div",{staticClass:"ui-ai-feedback"},[e("a",{staticClass:"uicore-btn",staticStyle:{background:"#f1f5f9",color:"#0f172a"},attrs:{href:"https://feedback.uicore.co/",target:"_blank"},on:{click:t.close}},[t._v("Suggest an idea")]),e("div",{staticClass:"uicore-btn",on:{click:t.close}},[t._v("Dismiss")])])]):t._e(),"write"==t.mode?e("div",{staticClass:"uianim-content"},[e("div",{staticClass:"uicore-core-setting"},[e("label",{staticClass:"uicore_h2",attrs:{for:"ui-ai-topic"}},[t._v("Topic")]),e("textarea",{directives:[{name:"model",rawName:"v-model",value:t.topic,expression:"topic"}],attrs:{id:"ui-ai-topic",type:"text",placeholder:"Write 1-2 sentences about what your article is about."},domProps:{value:t.topic},on:{input:function(e){e.target.composing||(t.topic=e.target.value)}}})]),e("div",{staticClass:"uicore-core-setting"},[e("label",{staticClass:"uicore_h2",attrs:{for:"ui-ai-keywords"}},[t._v("Keywords to include")]),e("textarea",{directives:[{name:"model",rawName:"v-model",value:t.keywords,expression:"keywords"}],attrs:{id:"ui-ai-keywords",type:"text",placeholder:"List of keywords separated by coma."},domProps:{value:t.keywords},on:{input:function(e){e.target.composing||(t.keywords=e.target.value)}}})]),e("div",{staticClass:"uicore-core-setting"},[e("label",{staticClass:"uicore_h2"},[t._v("Tone Of Voice")]),e("multiselect",{attrs:{options:t.toneList,"allow-empty":!1,"show-labels":!1,searchable:!0,"clear-on-select":!1,"preserve-search":!0,multiple:!0,placeholder:"Select One or More"},model:{value:t.tone,callback:function(e){t.tone=e},expression:"tone"}})],1),e("div",{staticClass:"uicore-core-setting"},[e("label",{staticClass:"uicore_h2"},[t._v("Length")]),e("input",{directives:[{name:"model",rawName:"v-model",value:t.length,expression:"length"}],attrs:{type:"range",min:"200",max:"1500"},domProps:{value:t.length},on:{__r:function(e){t.length=e.target.value}}}),e("div",{staticClass:"data"},[t._v(t._s(t.length)+" Words")])]),e("div",{staticClass:"uicore-btn",on:{click:t.generateResponse}},[t._v("Write Article")])]):t._e()])],1)};o._withStripped=!0;var i=function(){var t=this,e=t._self._c;return e("div",{staticClass:"uicore-base"},[e("div",{staticClass:"uicore-base_header"},[e("div",{staticClass:"uicore-base_title",domProps:{innerHTML:t._s(t.title)}}),e("div",{staticClass:"uicore-base_close",on:{click:t.close}},[e("svg",{attrs:{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",fill:"none"}},[e("path",{attrs:{d:"M18 6L6 18",stroke:"#0F172A","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}}),e("path",{attrs:{d:"M6 6L18 18",stroke:"#0F172A","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"}})])])]),e("div",{staticClass:"uicore-base_content"},[t.scroll?e("perfect-scrollbar",[t._t("default")],2):t._t("default")],2)])};i._withStripped=!0;const a={name:"uibase",props:["title","scroll"],methods:{close:function(){this.$emit("close")}}};var s=r(4486);const c=(0,s.A)(a,i,[],!1,null,null,null).exports;var l=r(5262),u=r.n(l);function p(t){return p="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p(t)}function d(){d=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",c=i.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var i=e&&e.prototype instanceof w?e:w,a=Object.create(i.prototype),s=new j(n||[]);return o(a,"_invoke",{value:O(t,r,s)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=u;var f="suspendedStart",v="suspendedYield",y="executing",m="completed",g={};function w(){}function b(){}function k(){}var x={};l(x,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(P([])));E&&E!==r&&n.call(E,a)&&(x=E);var C=k.prototype=w.prototype=Object.create(x);function A(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(o,i,a,s){var c=h(t[o],t,i);if("throw"!==c.type){var l=c.arg,u=l.value;return u&&"object"==p(u)&&n.call(u,"__await")?e.resolve(u.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(u).then((function(t){l.value=t,a(l)}),(function(t){return r("throw",t,a,s)}))}s(c.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return i=i?i.then(o,o):o()}})}function O(e,r,n){var o=f;return function(i,a){if(o===y)throw Error("Generator is already running");if(o===m){if("throw"===i)throw a;return{value:t,done:!0}}for(n.method=i,n.arg=a;;){var s=n.delegate;if(s){var c=S(s,n);if(c){if(c===g)continue;return c}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===f)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var l=h(e,r,n);if("normal"===l.type){if(o=n.done?m:v,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=m,n.method="throw",n.arg=l.arg)}}}function S(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,S(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=h(o,e.iterator,r.arg);if("throw"===i.type)return r.method="throw",r.arg=i.arg,r.delegate=null,g;var a=i.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function I(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function P(e){if(e||""===e){var r=e[a];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var o=-1,i=function r(){for(;++o
=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(c&&l){if(this.prev
=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev
=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),I(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;I(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:P(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function h(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function f(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function a(t){h(i,n,o,a,s,"next",t)}function s(t){h(i,n,o,a,s,"throw",t)}a(void 0)}))}}var v=r(2505);const y={components:{uibase:c,multiselect:u()},data:function(){return{mode:"",abortController:null,writing:!1,tone:[],keywords:"",topic:"",length:500,active:!0,openaiApiKey:"",toneList:["Informative","Conversational","Persuasive","Educational","Humorous","Authoritative","Instructional","Personal","Thoughtful","Inspirational","Analytical","Entertaining","Professional","Narrative","Motivational","Controversial","Chatty","Casual","Opinionated","Helpful","Friendly","Sarcastic","Sincere","Relatable","Candid","Analytic","Emotional","Serious","Explanatory","Instructional","Encouraging","Critical","Honest","Engaging","Descriptive","Inspiring","Witty","Unbiased","Expository","Inquisitive","Factual","Informal","Analyzing","Comparative","Reflective","Argumentative","Compelling","Insightful","Practical","Inspired","Clear","Expressive"]}},beforeMount:function(){""==window.uicore_ai.key||null==window.uicore_ai.key?this.mode="":(this.openaiApiKey=window.uicore_ai.key,this.mode="write")},methods:{close:function(){document.querySelector(".ui-ai-writer .uicore-base_close").click()},start:function(){this.writing=!0,this.abortController=new AbortController,jQuery("#uicore-writing-assistant-trigger").hide()},stop:function(t){this.mode=t?"write":"done",this.writing=!1,this.abortController.abort(),this.convertToBlocks(),jQuery("#uicore-writing-assistant-trigger").show()},saveKey:function(){var t=this;return f(d().mark((function e(){var r;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.storeValidKey(t.openaiApiKey);case 2:if(!e.sent){e.next=9;break}window.uicore_ai.key=t.openaiApiKey,t.mode="write",r=uicore_ai.api,v.post(r,{aiKey:t.openaiApiKey}),e.next=10;break;case 9:alert("Invalid Api Key");case 10:case"end":return e.stop()}}),e)})))()},storeValidKey:function(t){return f(d().mark((function e(){var r,n,o;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r={method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t)},body:JSON.stringify({model:"gpt-3.5-turbo",temperature:.02,max_tokens:1,messages:[{role:"user",content:"?"}]})},e.prev=2,e.next=5,fetch("https://api.openai.com/v1/chat/completions",r);case 5:return n=e.sent,e.next=8,n.json();case 8:if(o=e.sent,!n.ok){e.next=13;break}return e.abrupt("return",!0);case 13:throw new Error("API key error: ".concat(o.error));case 14:e.next=20;break;case 16:return e.prev=16,e.t0=e.catch(2),console.error(e.t0.message),e.abrupt("return",!1);case 20:case"end":return e.stop()}}),e,null,[[2,16]])})))()},generateResponse:function(){var t=this;return f(d().mark((function e(){var r,n,o,i,a,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,r=!1,n=function(t,e){wp.data.dispatch("core/block-editor").updateBlockAttributes(e,{content:t})},o=function(t){r||(wp.data.dispatch("core/block-editor").insertBlock(wp.blocks.createBlock("core/freeform",{content:""})),r=!0);var e=wp.data.select("core/block-editor").getSelectedBlockClientId(),o=wp.data.select("core/block-editor").getBlock(e),i=o&&o.attributes?o.attributes.content:"";n(i+t,e)},t.start(),e.next=7,fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{"Content-Type":"application/json",Authorization:"Bearer ".concat(t.openaiApiKey)},body:JSON.stringify({model:"gpt-3.5-turbo",temperature:.03,stream:!0,stop:["[STOP]"],messages:[{role:"system",content:"You are a profesional blog content writer. You write the article in a gutenberg html format."},{role:"user",content:t.prompt()}]}),signal:t.abortController.signal});case 7:if(i=e.sent,a=function(){var e=f(d().mark((function e(r){var n,i,a,s;return d().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=3,r.read();case 3:if(n=e.sent,i=n.done,a=n.value,!i){e.next=11;break}return document.querySelector(".interface-interface-skeleton__content").scrollTop=0,t.stop(),e.abrupt("break",15);case 11:(s=t.getStreamText(new TextDecoder("utf-8").decode(a)))&&o(s),e.next=0;break;case 15:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),i.ok){e.next=22;break}if(401!==i.status){e.next=19;break}t.openaiApiKey="",t.mode="",t.writing=!1,t.abortController.abort(),jQuery("#uicore-writing-assistant-trigger").show(),alert("Invalid Api Key"),e.next=20;break;case 19:throw new Error("HTTP error! status: ".concat(i.status));case 20:e.next=24;break;case 22:s=i.body.getReader(),a(s);case 24:e.next=31;break;case 26:e.prev=26,e.t0=e.catch(0),console.error(e.t0),console.log("Error: ",e.t0.message),"Unauthorized"===e.t0.message&&alert("Invalid Api Key");case 31:case"end":return e.stop()}}),e,null,[[0,26]])})))()},getStreamText:function(t){var e=this,r=t.split("\n\n");if(r.length>1){var n="";return r.forEach((function(t){t.startsWith("data: ")&&(n+=e.getStreamText(t))})),n}var o=r[0].substring(6),i=null;try{i=JSON.parse(o)}catch(t){return""}return"stop"===i.choices[0].finish_reason?"":i.choices[0]&&void 0!==i.choices[0].delta.content?i.choices[0].delta.content:""},prompt:function(){return"Create a blog post about “"+this.topic+"”. Write it in a “"+this.tone.join(", ")+"” tone. \n Use transition words. Use active voice. Write aproximative "+this.length+" words. \n Include the following keywords: “"+this.keywords+"”.\n Start with a compelling headline and introduction.\n Use subheadings to break up the content and make it easy to scan.\n Use short paragraphs and sentences to improve readability.\n Use bullet points and numbered lists to highlight important information (using ul and li).\n Use a conversational tone and avoid jargon.\n End with a clear call-to-action or conclusion.\n\n When it comes to structure, a good format to follow is:\n Grab the reader's attention and introduce the topic.\n Develop your ideas and provide supporting evidence.\n Summarize your main points and provide a call-to-action or conclusion.\n\n Format the response as wysiwyg html.\n !!DO NOT INCLUDE OTHER HTML TAGS THAN THE ONES USED FOR TEXT FORMATING eg:
,
etc!!\n !!WRITE THE TEXT IN THE LANGUAGE OF THE TOPIC: \""+this.topic+'"!!\n '},convertToBlocks:function(){var t=wp.blocks.createBlock,e=wp.data.dispatch,r=wp.data.select("core/block-editor").getSelectedBlock(),n=r.attributes.content,o=wp.blocks.rawHandler({HTML:n,mode:"BLOCKS"});o.reverse(),o.forEach((function(n){var o=n.name,i=n.attributes,a=n.innerBlocks,s=t(o,i,a);e("core/block-editor").insertBlock(s,r.clientId)})),e("core/block-editor").removeBlock(r.clientId)}},computed:{getMainColor:function(){return"--uicore-primary:#532df5"}}};const m=(0,s.A)(y,o,[],!1,null,null,null).exports;!function(t,e){var r="uicore-writing-assistant-trigger",o='
AI Writing Assistant
',i=document.getElementById("editor");if(i)e.data.subscribe((function(){setTimeout((function(){if(null==document.getElementsByClassName("uicore-ai-assistant-btn")[0]){var t=i.querySelector(".edit-post-header-toolbar");t instanceof HTMLElement&&(t.insertAdjacentHTML("beforeend",o),t.insertAdjacentHTML("beforeend",'
'),document.getElementById(r).addEventListener("click",(function(t){var e=new n.Ay({el:"#ui-ai-app",destroyed:function(){},render:function(t){return t(m)}});setTimeout((function(){jQuery(".ui-ai-writer .uicore-base_close").on("click",(function(){e.$destroy(),document.getElementById("uicore-assistant-wrapper").innerHTML='
'}))}),400),t.preventDefault()})))}}),1)}))}(window,wp)}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var i=r[t]={id:t,loaded:!1,exports:{}};return e[t].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.m=e,t=[],n.O=(e,r,o,i)=>{if(!r){var a=1/0;for(u=0;u
=i)&&Object.keys(n.O).every((t=>n.O[t](r[c])))?r.splice(c--,1):(s=!1,i
0&&t[u-1][2]>i;u--)t[u]=t[u-1];t[u]=[r,o,i]},n.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),n.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),n.j=53,(()=>{var t={53:0};n.O.j=e=>0===t[e];var e=(e,r)=>{var o,i,[a,s,c]=r,l=0;if(a.some((e=>0!==t[e]))){for(o in s)n.o(s,o)&&(n.m[o]=s[o]);if(c)var u=c(n)}for(e&&e(r);l
n(8883)));o=n.O(o)})();