PluginProbe
Parse.ly / 3.23.5
Parse.ly v3.23.5
3.24.1 3.24.0 3.23.7 3.23.6 3.23.5 3.23.4 3.23.3 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.17.0 3.18.0 3.18.1 3.19.0 3.19.1 3.19.2 3.19.3 3.2.0 3.2.1 3.20.0 3.20.1 3.20.2 3.20.3 All 105 releases
wp-parsely / build / admin-settings.js

admin-settings.js in Parse.ly 3.23.5, at build/admin-settings.js

1 lines 18.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 !function(){"use strict";var e={20:function(e,t,n){var r=n(609),o=Symbol.for("react.element"),s=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),a=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,n){var r,l={},c=null,u=null;for(r in void 0!==n&&(c=""+n),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)s.call(t,r)&&!i.hasOwnProperty(r)&&(l[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===l[r]&&(l[r]=t[r]);return{$$typeof:o,type:e,key:c,ref:u,props:l,_owner:a.current}}},848:function(e,t,n){e.exports=n(20)},609:function(e){e.exports=window.React}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,r=window.wp.escapeHtml,o=window.wp.i18n,s=n(848),a=window.wp.data,i=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var n="content-helper-error-message";return(null==e?void 0:e.className)&&(n+=" "+e.className),(0,s.jsx)("div",{className:n,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},l=(e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)},function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function __(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(__.prototype=n.prototype,new __)});!function(e){e.AccessToFeatureDisabled="ch_access_to_feature_disabled",e.FetchError="fetch_error",e.HttpRequestFailed="http_request_failed",e.ParselyAborted="ch_parsely_aborted",e.ParselyApiForbidden="403",e.ParselyApiResponseContainsError="ch_response_contains_error",e.ParselyApiReturnedNoData="ch_parsely_api_returned_no_data",e.ParselyApiReturnedTooManyResults="ch_parsely_api_returned_too_many_results",e.PluginCredentialsNotSetMessageDetected="parsely_credentials_not_set_message_detected",e.PluginSettingsApiSecretNotSet="parsely_api_secret_not_set",e.PluginSettingsSiteIdNotSet="parsely_site_id_not_set",e.PostIsNotPublished="ch_post_not_published",e.UnknownError="ch_unknown_error",e.ParselySuggestionsApiAuthUnavailable="AUTH_UNAVAILABLE",e.ParselySuggestionsApiNoAuthentication="NO_AUTHENTICATION",e.ParselySuggestionsApiNoAuthorization="NO_AUTHORIZATION",e.ParselySuggestionsApiNoData="NO_DATA",e.ParselySuggestionsApiNoDataManualLinking="NO_DATA_MANUAL_LINKING",e.ParselySuggestionsApiOpenAiError="OPENAI_ERROR",e.ParselySuggestionsApiOpenAiSchema="OPENAI_SCHEMA",e.ParselySuggestionsApiOpenAiUnavailable="OPENAI_UNAVAILABLE",e.ParselySuggestionsApiResponseValidationError="RESPONSE_VALIDATION_ERROR",e.ParselySuggestionsApiSchemaError="SCHEMA_ERROR",e.ParselySuggestionsInvalidRequest="INVALID_REQUEST"}(t||(t={}));var c=function(e){function n(r,s,a){void 0===a&&(a=(0,o.__)("Error:","wp-parsely"));var i=this;r.startsWith(a)&&(a=""),"string"!=typeof s&&(s=String(s)),(i=e.call(this,a.length>0?"".concat(a," ").concat(r):r)||this).hint=null,i.name=i.constructor.name,i.code=s;var l=[t.FetchError,t.HttpRequestFailed,t.ParselySuggestionsApiAuthUnavailable,t.ParselySuggestionsApiOpenAiError,t.ParselySuggestionsApiOpenAiSchema,t.ParselySuggestionsApiOpenAiUnavailable,t.ParselySuggestionsApiSchemaError];return i.retryFetch=l.includes(i.code),Object.setPrototypeOf(i,n.prototype),i.CustomizeErrorMessaging(),i}return l(n,e),n.prototype.CustomizeErrorMessaging=function(){this.code===t.AccessToFeatureDisabled?this.message=(0,o.__)("Access to this feature is disabled by the site's administration.","wp-parsely"):this.code===t.ParselySuggestionsApiNoAuthorization?this.message=(0,o.__)('This AI-powered feature is opt-in. To gain access, please submit a request <a href="https://wpvip.com/content-helper/#content-helper-form" target="_blank" rel="noopener">here</a>.',"wp-parsely"):this.code===t.ParselySuggestionsApiOpenAiError||this.code===t.ParselySuggestionsApiOpenAiUnavailable?this.message=(0,o.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):this.code===t.HttpRequestFailed&&this.message.includes("cURL error 28")?this.message=(0,o.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):this.code===t.ParselySuggestionsApiSchemaError||this.code===t.ParselySuggestionsInvalidRequest?this.message=(0,o.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):this.code===t.ParselySuggestionsApiNoData||this.code===t.ParselySuggestionsApiNoDataManualLinking?this.message=(0,o.__)("The Parse.ly API couldn't find any relevant data to fulfill the request.","wp-parsely"):this.code===t.ParselySuggestionsApiOpenAiSchema||this.code===t.ParselySuggestionsApiResponseValidationError?this.message=(0,o.__)("The Parse.ly API returned an incorrect response.","wp-parsely"):this.code===t.ParselySuggestionsApiAuthUnavailable&&(this.message=(0,o.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),this.code===t.FetchError&&(this.hint=this.Hint((0,o.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==t.ParselyApiForbidden&&this.code!==t.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===t.HttpRequestFailed&&(this.hint=this.Hint((0,o.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely")))},n.prototype.Hint=function(e){return'<p className="content-helper-error-message-hint" data-testid="content-helper-error-message-hint"><strong>'.concat((0,o.__)("Hint:","wp-parsely"),"</strong> ").concat(e,"</p>")},n.prototype.Message=function(e){return void 0===e&&(e=null),[t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsSiteIdNotSet,t.PluginSettingsApiSecretNotSet].includes(this.code)?function(e){var t;return void 0===e&&(e=null),(0,s.jsx)(i,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:null!==(t=window.wpParselyEmptyCredentialsMessage)&&void 0!==t?t:(0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely")})}(e):(0,s.jsx)(i,{className:null==e?void 0:e.className,testId:"error",children:"<p>".concat(this.message,"</p>").concat(this.hint?this.hint:"")})},n.prototype.createErrorSnackbar=function(){/<a.*?>/.test(this.message)||(0,a.dispatch)("core/notices").createNotice("error",this.message,{type:"snackbar"})},n}(Error),u=window.wp.url,p=window.wp.apiFetch,d=n.n(p),f=function(){return f=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},f.apply(this,arguments)},h=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,n){return r=this,s=void 0,i=function(){var r,s,a,i,l,u;return function(e,t){var n,r,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=i(0),a.throw=i(1),a.return=i(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,(function(p){switch(p.label){case 0:r=this.getOrCreateController(n),s=r.abortController,a=r.abortId,e.signal=s.signal,p.label=1;case 1:return p.trys.push([1,3,4,5]),[4,d()(f(f({},e),{parse:!0}))];case 2:return(i=p.sent()).error?[2,Promise.reject(new c(i.error.message,t.ParselyApiResponseContainsError))]:[2,i.data];case 3:return"AbortError"===(l=p.sent()).name?[2,Promise.reject(new c((0,o.__)("The operation was aborted.","wp-parsely"),t.ParselyAborted))]:(u=l.message,"object"==typeof l.message&&l.message[0].msg&&(u=l.message[0].msg),[2,Promise.reject(new c(u,l.code))]);case 4:return this.abortControllers.delete(a),[7];case 5:return[2]}}))},new((a=void 0)||(a=Promise))((function(e,t){function n(e){try{l(i.next(e))}catch(e){t(e)}}function o(e){try{l(i.throw(e))}catch(e){t(e)}}function l(t){var r;t.done?e(t.value):(r=t.value,r instanceof a?r:new a((function(e){e(r)}))).then(n,o)}l((i=i.apply(r,s||[])).next())}));var r,s,a,i},e}(),y=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function __(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(__.prototype=n.prototype,new __)}}(),g=function(){return g=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},g.apply(this,arguments)},b=function(e){function n(){return null!==e&&e.apply(this,arguments)||this}return y(n,e),n.getInstance=function(){return this.instance||(this.instance=new n),this.instance},n.prototype.getAuthorizationResponse=function(e){return n=this,r=void 0,s=function(){var n,r;return function(e,t){var n,r,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=i(0),a.throw=i(1),a.return=i(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,(function(o){switch(o.label){case 0:n={code:0,message:""},o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.fetch({method:"POST",path:(0,u.addQueryArgs)("/wp-parsely/v2/content-helper/check-auth",g({},e))})];case 2:return n=o.sent(),[3,4];case 3:if((r=o.sent())instanceof c)throw r;if(r instanceof Error)throw new c(r.message,t.UnknownError);return[3,4];case 4:return[2,n]}}))},new((o=void 0)||(o=Promise))((function(e,t){function a(e){try{l(s.next(e))}catch(e){t(e)}}function i(e){try{l(s.throw(e))}catch(e){t(e)}}function l(t){var n;t.done?e(t.value):(n=t.value,n instanceof o?n:new o((function(e){e(n)}))).then(a,i)}l((s=s.apply(n,r||[])).next())}));var n,r,o,s},n}(h);function _(){var e,t,n=""!==location.hash?location.hash.substring(1):"basic-section";null===(e=document.querySelectorAll(".nav-tab"))||void 0===e||e.forEach((function(e){e.classList.contains(n+"-tab")?e.classList.add("nav-tab-active"):e.classList.remove("nav-tab-active")})),null===(t=document.querySelectorAll(".tab-content"))||void 0===t||t.forEach((function(e){e.classList.contains(n)?e.setAttribute("style","display: initial"):e.setAttribute("style","display: none")}));var r=document.querySelector('form[name="parsely"]');r&&(r.removeAttribute("hidden"),r.setAttribute("action","options.php#".concat(n)))}function v(e){var t=e.target.dataset.option,n=window.wp.media({multiple:!1,library:{type:"image"}});n.on("select",(function(){var e=n.state().get("selection").first().toJSON().url,r="#media-single-image-"+t+" input.file-path",o=document.querySelector(r);o&&(o.value=e)})),n.open()}document.addEventListener("DOMContentLoaded",(function(){var e;!function(){var e,n,s,a;e=this,n=void 0,a=function(){var e,n,s,a,i,l,u,p,d,f,h;return function(e,t){var n,r,o,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=i(0),a.throw=i(1),a.return=i(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function i(i){return function(l){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,i[0]&&(s=0)),s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!((o=(o=s.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=t.call(e,s)}catch(e){i=[6,e],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,l])}}}(this,(function(y){switch(y.label){case 0:e=null,n=null,y.label=1;case 1:return y.trys.push([1,3,4,5]),[4,Promise.all([b.getInstance().getAuthorizationResponse({auth_scope:"suggestions_api"}),b.getInstance().getAuthorizationResponse({auth_scope:"traffic_boost"})])];case 2:return s=y.sent(),a=s[0],i=s[1],n={api:a,traffic_boost:i},[3,5];case 3:return l=y.sent(),console.error(l),l instanceof c&&t.PluginSettingsApiSecretNotSet===l.code&&(e=(0,o.sprintf)("<p><strong>%s</strong></p>",(0,r.escapeHTML)((0,o.__)("All Content Intelligence AI functionality is disabled because an API Secret has not been set.","wp-parsely")))),[3,5];case 4:return n&&(200!==n.api.code?(u=(0,o.sprintf)('<a href="%1$s" target="_blank" rel="noopener">%2$s</a>',"https://wpvip.com/content-helper/#content-helper-form",(0,o.__)("Request access here","wp-parsely")),d=(0,o.sprintf)((0,r.escapeHTML)((0,o.__)("All Content Intelligence AI functionality is disabled for this website. %s.","wp-parsely")),u),e=(0,o.sprintf)("<p><strong>%s</strong></p>",d)):200===n.api.code&&200!==n.traffic_boost.code&&(p=(0,o.sprintf)('<a href="%1$s">%2$s</a>',"mailto:support@parsely.com","support@parsely.com"),d=(0,o.sprintf)((0,r.escapeHTML)((0,o.__)("Engagement Boost functionality is disabled for this website. To enable it, contact %s.","wp-parsely")),p),e=(0,o.sprintf)("<p><strong>%s</strong></p>",d))),e&&((f=document.createElement("div")).className="content-helper-message notice notice-error",f.innerHTML=e,(h=document.querySelector(".content-intelligence-section"))&&h.insertBefore(f,h.firstChild)),[7];case 5:return[2]}}))},new((s=void 0)||(s=Promise))((function(t,r){function o(e){try{l(a.next(e))}catch(e){r(e)}}function i(e){try{l(a.throw(e))}catch(e){r(e)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof s?n:new s((function(e){e(n)}))).then(o,i)}l((a=a.apply(e,n||[])).next())}))}(),function(){var e=document.querySelector("input#content_helper_ai_features_enabled"),t=document.querySelectorAll("input#content_helper_smart_linking_enabled, input#content_helper_title_suggestions_enabled, input#content_helper_excerpt_suggestions_enabled, input#content_helper_traffic_boost_enabled"),n=document.querySelectorAll("div.content-intelligence-section fieldset");function r(){e&&(e.checked?n.forEach((function(e){a(e,!1),t.forEach((function(e){o(e)}))})):(n.forEach((function(t){t.querySelector("#".concat(e.id))||a(t)})),document.querySelectorAll("label.prevent-disable").forEach((function(e){s(e,!1)}))))}function o(e){var t,n,r=null===(n=null===(t=e.closest("fieldset"))||void 0===t?void 0:t.nextSibling)||void 0===n?void 0:n.nextSibling;e.checked?a([e,r],!1):(a(r),s(e.parentElement))}function s(e,t){void 0===t&&(t=!0),t?e.classList.add("prevent-disable"):e.classList.remove("prevent-disable")}function a(e,t){void 0===t&&(t=!0),Array.isArray(e)||(e=[e]),e.forEach((function(e){t?e.setAttribute("disabled","disabled"):e.removeAttribute("disabled")}))}(function(){var e;null===(e=document.querySelector('.wp-admin form[name="parsely"]'))||void 0===e||e.addEventListener("submit",(function(){var e=".wp-admin .content-intelligence-section fieldset";document.querySelectorAll("".concat(e,"[disabled]")).forEach((function(t){var n,r;null===(r=null===(n=t.parentElement)||void 0===n?void 0:n.parentElement)||void 0===r||r.classList.add("disabled-before-posting"),t.querySelectorAll("".concat(e,' label input[type="checkbox"]')).forEach((function(e){e.classList.add("disabled")})),t.removeAttribute("disabled")}))}))})(),r(),null==e||e.addEventListener("change",(function(){r()})),t.forEach((function(e){e.addEventListener("change",(function(){o(e)}))}))}(),_(),window.addEventListener("hashchange",_),null===(e=document.querySelector(".media-single-image button.browse"))||void 0===e||e.addEventListener("click",v)}))}()}();