From 0df67871a4954e5b1192b58e4e6fad8d81ef76be Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Fri, 8 Mar 2024 16:22:45 +0200 Subject: [PATCH 1/2] Update Content Suggestions API Beta message --- build/content-helper/dashboard-widget.asset.php | 2 +- build/content-helper/dashboard-widget.js | 2 +- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.js | 2 +- build/content-helper/excerpt-generator.asset.php | 2 +- build/content-helper/excerpt-generator.js | 2 +- src/content-helper/common/content-helper-error.tsx | 3 ++- 7 files changed, 8 insertions(+), 7 deletions(-) diff --git a/build/content-helper/dashboard-widget.asset.php b/build/content-helper/dashboard-widget.asset.php index b3b61fd40..f762c97b3 100644 --- a/build/content-helper/dashboard-widget.asset.php +++ b/build/content-helper/dashboard-widget.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '136ae706ae2ab6e091ad'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '68d9813064fecfe775a1'); diff --git a/build/content-helper/dashboard-widget.js b/build/content-helper/dashboard-widget.js index 7ea1dd723..209dc848a 100644 --- a/build/content-helper/dashboard-widget.js +++ b/build/content-helper/dashboard-widget.js @@ -1 +1 @@ -!function(){"use strict";var e={251:function(e,t,r){var n=r(196),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,u=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)i.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:u,props:s,_owner:o.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},893:function(e,t,r){e.exports=r(251)},196:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n,a=r(893),s=window.wp.element,i=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,a.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},o=function(e){return void 0===e&&(e=null),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:window.wpParselyEmptyCredentialsMessage})},l=function(){return l=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),f=(d.trackEvent,function(e){var t=e.defaultValue,r=e.items,n=e.onChange;return(0,a.jsx)("select",{onChange:n,value:t,children:r.map((function(e){return(0,a.jsx)("option",{value:e[0],children:e[1]},e[0])}))})}),h=window.wp.data,y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r".concat(this.message,"

").concat(this.hint?this.hint:"")}))},t.prototype.Hint=function(e){return'

'.concat((0,p.__)("Hint:","wp-parsely")," ").concat(e,"

")},t}(Error),C={month:"short",day:"numeric",year:"numeric"},R={month:"short",day:"numeric"},O=(0,p.__)("Date N/A","wp-parsely");function L(e){if(!1===function(e){return!isNaN(+e)&&0!==e.getTime()}(e))return O;var t=C;return e.getUTCFullYear()===(new Date).getUTCFullYear()&&(t=R),Intl.DateTimeFormat(document.documentElement.lang||"en",t).format(e)}var M=function(){return M=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]=c){var u=t;(a=n/c)%1>1/o&&(u=a>10?1:2),u=parseFloat(a.toFixed(2))===parseFloat(a.toFixed(0))?0:u,s=a.toFixed(u),i=l}o=c})),s+r+i}function q(e){var t=e.metric,r=e.post,n=e.avgEngagedIcon,s=e.viewsIcon;return"views"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Number of Views","wp-parsely")}),s,G(r.views.toString())]}):"avg_engaged"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Average Time","wp-parsely")}),n,r.avgEngaged]}):(0,a.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}function z(e){var t,r=e.metric,n=e.post;return(0,a.jsx)("li",{className:"parsely-top-post",children:(0,a.jsxs)("div",{className:"parsely-top-post-content",children:[(0,a.jsx)($,{post:n}),(0,a.jsxs)("div",{className:"parsely-top-post-data",children:[(0,a.jsx)(q,{metric:r,post:n}),(0,a.jsx)(X,{post:n}),(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:n.url,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("View Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(D,{})]}),0!==n.postId&&(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:(t=n.postId,"/wp-admin/post.php?post=".concat(t,"&action=edit")),target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Edit Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(H,{})]}),(0,a.jsxs)("div",{className:"parsely-top-post-metadata",children:[(0,a.jsxs)("span",{className:"parsely-top-post-date",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Date","wp-parsely")}),L(new Date(n.date))]}),(0,a.jsxs)("span",{className:"parsely-top-post-author",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Author","wp-parsely")}),n.author]})]})]})]})},n.id)}function $(e){var t=e.post;return t.thumbnailUrl?(0,a.jsxs)("div",{className:"parsely-top-post-thumbnail",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Thumbnail","wp-parsely")}),(0,a.jsx)("img",{src:t.thumbnailUrl,alt:(0,p.__)("Post thumbnail","wp-parsely")})]}):(0,a.jsx)("div",{className:"parsely-top-post-thumbnail",children:(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Post thumbnail not available","wp-parsely")})})}function X(e){var t=e.post;return(0,a.jsxs)("a",{className:"parsely-top-post-title",href:t.dashUrl,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("View in Parse.ly (opens in new tab)","wp-parsely")}),t.title]})}var Y=function(){return Y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]0&&e.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return r.sent(),[4,t(n-1)];case 2:return r.sent(),[3,4];case 3:h(!1),w(e),r.label=4;case 4:return[2]}}))}))})),[2]}))}))};return h(!0),t(1),function(){h(!1),_([]),w(void 0)}}),[i,x]);var N=function(e,t){d.trackEvent("dash_widget_filter_changed",Y({filter:e},t))},k=(0,a.jsxs)("div",{className:"parsely-top-posts-filters",children:[(0,a.jsx)(f,{defaultValue:i.Period,items:Object.values(e).map((function(e){return[e,j(e)]})),onChange:function(t){S(t.target.value,e)&&(o({Period:t.target.value}),N("period",{period:t.target.value}),T(1))}}),(0,a.jsx)(f,{defaultValue:i.Metric,items:Object.values(t).map((function(e){return[e,E(e)]})),onChange:function(e){S(e.target.value,t)&&(o({Metric:e.target.value}),N("metric",{metric:e.target.value}),T(1))}})]}),I=(0,a.jsxs)("div",{className:"parsely-top-posts-navigation",children:[(0,a.jsx)("button",{className:"parsely-top-posts-navigation-prev",disabled:x<=1,"aria-label":(0,p.__)("Previous page","wp-parsely"),onClick:function(){T(x-1),d.trackEvent("dash_widget_navigation",{navigation:"previous",to_page:x-1})},children:(0,p.__)("<< Previous","wp-parsely")}),(0,p.sprintf)(/* translators: 1: Current page */(0,p.__)("Page %1$d","wp-parsely"),x),(0,a.jsx)("button",{className:"parsely-top-posts-navigation-next",disabled:!c&&m.length<5,"aria-label":(0,p.__)("Next page","wp-parsely"),onClick:function(){T(x+1),d.trackEvent("dash_widget_navigation",{navigation:"next",to_page:x+1})},children:(0,p.__)("Next >>","wp-parsely")})]});if(v)return(0,a.jsxs)(a.Fragment,{children:[k,v.Message(),x>1&&I]});var A=(0,a.jsx)("div",{className:"parsely-spinner-wrapper",children:(0,a.jsx)(u.Spinner,{})});return(0,a.jsxs)(a.Fragment,{children:[k,c?A:(0,a.jsx)("ol",{className:"parsely-top-posts",style:{counterReset:"item "+5*(x-1)},children:m.map((function(e){return(0,a.jsx)(z,{metric:i.Metric,post:e},e.id)}))}),(m.length>=5||x>1)&&I]})}var K=function(r){var n;try{n=JSON.parse(r)}catch(r){return{Metric:t.Views,Period:e.Days7}}return S(null==n?void 0:n.Metric,t)||(n.Metric=t.Views),S(null==n?void 0:n.Period,e)||(n.Period=e.Days7),n};window.addEventListener("load",(function(){var e=document.querySelector("#wp-parsely-dashboard-widget > .inside");if(null!==e){var t=(0,a.jsx)(x,{endpoint:"dashboard-widget-settings",defaultSettings:K(window.wpParselyContentHelperSettings),children:(0,a.jsx)(c,{children:(0,a.jsx)(W,{})})});s.createRoot?(0,s.createRoot)(e).render(t):(0,s.render)(t,e)}}),!1)}()}(); \ No newline at end of file +!function(){"use strict";var e={251:function(e,t,r){var n=r(196),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,o=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,u=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)i.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:u,props:s,_owner:o.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},893:function(e,t,r){e.exports=r(251)},196:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n,a=r(893),s=window.wp.element,i=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,a.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},o=function(e){return void 0===e&&(e=null),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:window.wpParselyEmptyCredentialsMessage})},l=function(){return l=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),f=(d.trackEvent,function(e){var t=e.defaultValue,r=e.items,n=e.onChange;return(0,a.jsx)("select",{onChange:n,value:t,children:r.map((function(e){return(0,a.jsx)("option",{value:e[0],children:e[1]},e[0])}))})}),h=window.wp.data,y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;rhere.',"wp-parsely"):s.code===N.ParselyInternalServerError?s.message=(0,p.__)("The Parse.ly API returned an internal server error. Please try again later.","wp-parsely"):s.code===N.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,p.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===N.ParselySchemaValidationFailed?s.message=(0,p.__)("The Parse.ly API returned a validation error. Please try again later.","wp-parsely"):s.code===N.ParselyUpstreamMalformedResponse&&s.message.includes("Insufficient Storage")?s.message=(0,p.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===N.ParselyUpstreamMalformedResponse?s.message=(0,p.__)("The Parse.ly API returned a malformed response. Please try again later.","wp-parsely"):s.code===N.ParselyUpstreamNotAvailable&&(s.message=(0,p.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return I(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[N.PluginCredentialsNotSetMessageDetected,N.PluginSettingsSiteIdNotSet,N.PluginSettingsApiSecretNotSet].includes(this.code)?o(e):(this.code===N.FetchError&&(this.hint=this.Hint((0,p.__)("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===N.ParselyApiForbidden&&(this.hint=this.Hint((0,p.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===N.HttpRequestFailed&&(this.hint=this.Hint((0,p.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},t.prototype.Hint=function(e){return'

'.concat((0,p.__)("Hint:","wp-parsely")," ").concat(e,"

")},t}(Error),C={month:"short",day:"numeric",year:"numeric"},R={month:"short",day:"numeric"},O=(0,p.__)("Date N/A","wp-parsely");function L(e){if(!1===function(e){return!isNaN(+e)&&0!==e.getTime()}(e))return O;var t=C;return e.getUTCFullYear()===(new Date).getUTCFullYear()&&(t=R),Intl.DateTimeFormat(document.documentElement.lang||"en",t).format(e)}var M=function(){return M=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]=c){var u=t;(a=n/c)%1>1/o&&(u=a>10?1:2),u=parseFloat(a.toFixed(2))===parseFloat(a.toFixed(0))?0:u,s=a.toFixed(u),i=l}o=c})),s+r+i}function q(e){var t=e.metric,r=e.post,n=e.avgEngagedIcon,s=e.viewsIcon;return"views"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Number of Views","wp-parsely")}),s,G(r.views.toString())]}):"avg_engaged"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Average Time","wp-parsely")}),n,r.avgEngaged]}):(0,a.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}function z(e){var t,r=e.metric,n=e.post;return(0,a.jsx)("li",{className:"parsely-top-post",children:(0,a.jsxs)("div",{className:"parsely-top-post-content",children:[(0,a.jsx)($,{post:n}),(0,a.jsxs)("div",{className:"parsely-top-post-data",children:[(0,a.jsx)(q,{metric:r,post:n}),(0,a.jsx)(X,{post:n}),(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:n.url,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("View Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(D,{})]}),0!==n.postId&&(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:(t=n.postId,"/wp-admin/post.php?post=".concat(t,"&action=edit")),target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Edit Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(H,{})]}),(0,a.jsxs)("div",{className:"parsely-top-post-metadata",children:[(0,a.jsxs)("span",{className:"parsely-top-post-date",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Date","wp-parsely")}),L(new Date(n.date))]}),(0,a.jsxs)("span",{className:"parsely-top-post-author",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Author","wp-parsely")}),n.author]})]})]})]})},n.id)}function $(e){var t=e.post;return t.thumbnailUrl?(0,a.jsxs)("div",{className:"parsely-top-post-thumbnail",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Thumbnail","wp-parsely")}),(0,a.jsx)("img",{src:t.thumbnailUrl,alt:(0,p.__)("Post thumbnail","wp-parsely")})]}):(0,a.jsx)("div",{className:"parsely-top-post-thumbnail",children:(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Post thumbnail not available","wp-parsely")})})}function X(e){var t=e.post;return(0,a.jsxs)("a",{className:"parsely-top-post-title",href:t.dashUrl,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("View in Parse.ly (opens in new tab)","wp-parsely")}),t.title]})}var Y=function(){return Y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==o[0]&&2!==o[0])){i=0;continue}if(3===o[0]&&(!a||o[1]>a[0]&&o[1]0&&e.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return r.sent(),[4,t(n-1)];case 2:return r.sent(),[3,4];case 3:h(!1),w(e),r.label=4;case 4:return[2]}}))}))})),[2]}))}))};return h(!0),t(1),function(){h(!1),_([]),w(void 0)}}),[i,x]);var N=function(e,t){d.trackEvent("dash_widget_filter_changed",Y({filter:e},t))},k=(0,a.jsxs)("div",{className:"parsely-top-posts-filters",children:[(0,a.jsx)(f,{defaultValue:i.Period,items:Object.values(e).map((function(e){return[e,j(e)]})),onChange:function(t){S(t.target.value,e)&&(o({Period:t.target.value}),N("period",{period:t.target.value}),T(1))}}),(0,a.jsx)(f,{defaultValue:i.Metric,items:Object.values(t).map((function(e){return[e,E(e)]})),onChange:function(e){S(e.target.value,t)&&(o({Metric:e.target.value}),N("metric",{metric:e.target.value}),T(1))}})]}),I=(0,a.jsxs)("div",{className:"parsely-top-posts-navigation",children:[(0,a.jsx)("button",{className:"parsely-top-posts-navigation-prev",disabled:x<=1,"aria-label":(0,p.__)("Previous page","wp-parsely"),onClick:function(){T(x-1),d.trackEvent("dash_widget_navigation",{navigation:"previous",to_page:x-1})},children:(0,p.__)("<< Previous","wp-parsely")}),(0,p.sprintf)(/* translators: 1: Current page */(0,p.__)("Page %1$d","wp-parsely"),x),(0,a.jsx)("button",{className:"parsely-top-posts-navigation-next",disabled:!c&&m.length<5,"aria-label":(0,p.__)("Next page","wp-parsely"),onClick:function(){T(x+1),d.trackEvent("dash_widget_navigation",{navigation:"next",to_page:x+1})},children:(0,p.__)("Next >>","wp-parsely")})]});if(v)return(0,a.jsxs)(a.Fragment,{children:[k,v.Message(),x>1&&I]});var A=(0,a.jsx)("div",{className:"parsely-spinner-wrapper",children:(0,a.jsx)(u.Spinner,{})});return(0,a.jsxs)(a.Fragment,{children:[k,c?A:(0,a.jsx)("ol",{className:"parsely-top-posts",style:{counterReset:"item "+5*(x-1)},children:m.map((function(e){return(0,a.jsx)(z,{metric:i.Metric,post:e},e.id)}))}),(m.length>=5||x>1)&&I]})}var K=function(r){var n;try{n=JSON.parse(r)}catch(r){return{Metric:t.Views,Period:e.Days7}}return S(null==n?void 0:n.Metric,t)||(n.Metric=t.Views),S(null==n?void 0:n.Period,e)||(n.Period=e.Days7),n};window.addEventListener("load",(function(){var e=document.querySelector("#wp-parsely-dashboard-widget > .inside");if(null!==e){var t=(0,a.jsx)(x,{endpoint:"dashboard-widget-settings",defaultSettings:K(window.wpParselyContentHelperSettings),children:(0,a.jsx)(c,{children:(0,a.jsx)(W,{})})});s.createRoot?(0,s.createRoot)(e).render(t):(0,s.render)(t,e)}}),!1)}()}(); \ No newline at end of file diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index 7bb62bf1a..4ee1aadb1 100644 --- a/build/content-helper/editor-sidebar.asset.php +++ b/build/content-helper/editor-sidebar.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'ea850f58cd95403acde8'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '7c3234595c458b46b56e'); diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index 3d1c17be0..74be1d1d1 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,4 +1,4 @@ -!function(){"use strict";var e={251:function(e,t,n){var r=n(196),s=Symbol.for("react.element"),i=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,i={},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)a.call(t,r)&&!o.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===i[r]&&(i[r]=t[r]);return{$$typeof:s,type:e,key:c,ref:u,props:i,_owner:l.current}}t.Fragment=i,t.jsx=c,t.jsxs=c},893:function(e,t,n){e.exports=n(251)},196:function(e){e.exports=window.React}},t={};function n(r){var s=t[r];if(void 0!==s)return s.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.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(){n.d({},{W:function(){return Kt}});var e,t,r,s=n(893),i=window.wp.components,a=window.wp.data,l=window.wp.editPost,o=window.wp.element,c=window.wp.i18n,u=n(196),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,g=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,i=function(t,n){var r;return void 0===n&&(n={}),function(e,t){var n,r,s,i,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(o){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(s=2&l[0]?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[2&l[0],s.value]),l[0]){case 0:case 1:s=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!((s=(s=a.trys).length>0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]=1e4&&(clearInterval(i),n("Telemetry library not loaded"))}),100);else n("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,n){var r;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(n=this.prepareProperties(n),null===(r=this._tkq)||void 0===r||r.push(["recordEvent",t,n])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,n={};return Object.keys(e).forEach((function(r){t.isProprietyValid(r)&&(n[r]=e[r])})),n},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),h=(g.trackEvent,function(){return(0,s.jsx)(i.SVG,{"aria-hidden":"true",version:"1.1",viewBox:"0 0 15 15",width:"15",height:"15",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)(i.Path,{d:"M0 14.0025V11.0025L7.5 3.5025L10.5 6.5025L3 14.0025H0ZM12 5.0025L13.56 3.4425C14.15 2.8525 14.15 1.9025 13.56 1.3225L12.68 0.4425C12.09 -0.1475 11.14 -0.1475 10.56 0.4425L9 2.0025L12 5.0025Z"})})}),y=function(e){var t=e.size,n=void 0===t?24:t,r=e.className,a=void 0===r?"wp-parsely-icon":r;return(0,s.jsxs)(i.SVG,{className:a,height:n,viewBox:"0 0 60 65",width:n,xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M23.72,51.53c0-.18,0-.34-.06-.52a13.11,13.11,0,0,0-2.1-5.53A14.74,14.74,0,0,0,19.12,43c-.27-.21-.5-.11-.51.22l-.24,3.42c0,.33-.38.35-.49,0l-1.5-4.8a1.4,1.4,0,0,0-.77-.78,23.91,23.91,0,0,0-3.1-.84c-1.38-.24-3.39-.39-3.39-.39-.34,0-.45.21-.25.49l2.06,3.76c.2.27,0,.54-.29.33l-4.51-3.6a3.68,3.68,0,0,0-2.86-.48c-1,.16-2.44.46-2.44.46a.68.68,0,0,0-.39.25.73.73,0,0,0-.14.45S.41,43,.54,44a3.63,3.63,0,0,0,1.25,2.62L6.48,50c.28.2.09.49-.23.37l-4.18-.94c-.32-.12-.5,0-.4.37,0,0,.69,1.89,1.31,3.16a24,24,0,0,0,1.66,2.74,1.34,1.34,0,0,0,1,.52l5,.13c.33,0,.41.38.1.48L7.51,58c-.31.1-.34.35-.07.55a14.29,14.29,0,0,0,3.05,1.66,13.09,13.09,0,0,0,5.9.5,25.13,25.13,0,0,0,4.34-1,9.55,9.55,0,0,1-.08-1.2,9.32,9.32,0,0,1,3.07-6.91"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M59.7,41.53a.73.73,0,0,0-.14-.45.68.68,0,0,0-.39-.25s-1.43-.3-2.44-.46a3.64,3.64,0,0,0-2.86.48l-4.51,3.6c-.26.21-.49-.06-.29-.33l2.06-3.76c.2-.28.09-.49-.25-.49,0,0-2,.15-3.39.39a23.91,23.91,0,0,0-3.1.84,1.4,1.4,0,0,0-.77.78l-1.5,4.8c-.11.32-.48.3-.49,0l-.24-3.42c0-.33-.24-.43-.51-.22a14.74,14.74,0,0,0-2.44,2.47A13.11,13.11,0,0,0,36.34,51c0,.18,0,.34-.06.52a9.26,9.26,0,0,1,3,8.1,24.1,24.1,0,0,0,4.34,1,13.09,13.09,0,0,0,5.9-.5,14.29,14.29,0,0,0,3.05-1.66c.27-.2.24-.45-.07-.55l-3.22-1.17c-.31-.1-.23-.47.1-.48l5-.13a1.38,1.38,0,0,0,1-.52A24.6,24.6,0,0,0,57,52.92c.61-1.27,1.31-3.16,1.31-3.16.1-.33-.08-.49-.4-.37l-4.18.94c-.32.12-.51-.17-.23-.37l4.69-3.34A3.63,3.63,0,0,0,59.46,44c.13-1,.24-2.47.24-2.47"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M46.5,25.61c0-.53-.35-.72-.8-.43l-4.86,2.66c-.45.28-.56-.27-.23-.69l4.66-6.23a2,2,0,0,0,.28-1.68,36.51,36.51,0,0,0-2.19-4.89,34,34,0,0,0-2.81-3.94c-.33-.41-.74-.35-.91.16l-2.28,5.68c-.16.5-.6.48-.59-.05l.28-8.93a2.54,2.54,0,0,0-.66-1.64S35,4.27,33.88,3.27,30.78.69,30.78.69a1.29,1.29,0,0,0-1.54,0s-1.88,1.49-3.12,2.59-2.48,2.35-2.48,2.35A2.5,2.5,0,0,0,23,7.27l.27,8.93c0,.53-.41.55-.58.05l-2.29-5.69c-.17-.5-.57-.56-.91-.14a35.77,35.77,0,0,0-3,4.2,35.55,35.55,0,0,0-2,4.62,2,2,0,0,0,.27,1.67l4.67,6.24c.33.42.23,1-.22.69l-4.87-2.66c-.45-.29-.82-.1-.82.43a18.6,18.6,0,0,0,.83,5.07,20.16,20.16,0,0,0,5.37,7.77c3.19,3,5.93,7.8,7.45,11.08A9.6,9.6,0,0,1,30,49.09a9.31,9.31,0,0,1,2.86.45c1.52-3.28,4.26-8.11,7.44-11.09a20.46,20.46,0,0,0,5.09-7,19,19,0,0,0,1.11-5.82"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M36.12,58.44A6.12,6.12,0,1,1,30,52.32a6.11,6.11,0,0,1,6.12,6.12"})]})},v=function(){return v=Object.assign||function(e){for(var t,n=1,r=arguments.length;n".concat(this.message,"

").concat(this.hint?this.hint:"")}))},t.prototype.Hint=function(e){return'

'.concat((0,c.__)("Hint:","wp-parsely")," ").concat(e,"

")},t}(Error),Q=function(){function e(){}return e.generateSmartLinks=function(e){return t=this,n=arguments,s=function(e,t,n){var r,s,i;return void 0===t&&(t=ce),void 0===n&&(n=oe),function(e,t){var n,r,s,i,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(o){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(s=2&l[0]?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[2&l[0],s.value]),l[0]){case 0:case 1:s=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!((s=(s=a.trys).length>0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]0)){var e={maxLinksPerPost:p.SmartLinkingMaxLinks,maxLinkWords:p.SmartLinkingMaxLinkWords};R(e)}}),[R,p]);var I=(0,a.useSelect)((function(e){var t=e("core/block-editor"),r=t.getSelectedBlock,s=t.getBlock,i=e("core/editor").getEditedPostContent;return{selectedBlock:n?s(n):r(),postContent:i()}}),[n]),M=I.selectedBlock,B=I.postContent;(0,o.useEffect)((function(){y(null)}),[M]);var F=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},H=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,s.jsx)("div",{className:"wp-parsely-smart-linking",children:(0,s.jsxs)(i.PanelRow,{className:t,children:[(0,s.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("Automatically insert links to your most relevant, top performing content.","wp-parsely"),(0,s.jsxs)(i.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-smart-linking-beta",target:"_blank",variant:"link",children:[(0,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,s.jsx)(D,{icon:V,size:18,className:"parsely-external-link-icon"})]})]}),x&&(0,s.jsx)(i.Notice,{status:"info",isDismissible:!1,className:"wp-parsely-content-helper-error",children:x.message}),null!==S&&(0,s.jsx)(i.Notice,{status:"success",isDismissible:!1,className:"wp-parsely-smart-linking-suggested-links",children:/* translators: 1 - number of smart links generated */ +!function(){"use strict";var e={251:function(e,t,n){var r=n(196),s=Symbol.for("react.element"),i=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,i={},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)a.call(t,r)&&!o.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===i[r]&&(i[r]=t[r]);return{$$typeof:s,type:e,key:c,ref:u,props:i,_owner:l.current}}t.Fragment=i,t.jsx=c,t.jsxs=c},893:function(e,t,n){e.exports=n(251)},196:function(e){e.exports=window.React}},t={};function n(r){var s=t[r];if(void 0!==s)return s.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.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(){n.d({},{W:function(){return Kt}});var e,t,r,s=n(893),i=window.wp.components,a=window.wp.data,l=window.wp.editPost,o=window.wp.element,c=window.wp.i18n,u=n(196),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,g=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,i=function(t,n){var r;return void 0===n&&(n={}),function(e,t){var n,r,s,i,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(o){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(s=2&l[0]?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[2&l[0],s.value]),l[0]){case 0:case 1:s=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!((s=(s=a.trys).length>0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]=1e4&&(clearInterval(i),n("Telemetry library not loaded"))}),100);else n("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,n){var r;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(n=this.prepareProperties(n),null===(r=this._tkq)||void 0===r||r.push(["recordEvent",t,n])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,n={};return Object.keys(e).forEach((function(r){t.isProprietyValid(r)&&(n[r]=e[r])})),n},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),h=(g.trackEvent,function(){return(0,s.jsx)(i.SVG,{"aria-hidden":"true",version:"1.1",viewBox:"0 0 15 15",width:"15",height:"15",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)(i.Path,{d:"M0 14.0025V11.0025L7.5 3.5025L10.5 6.5025L3 14.0025H0ZM12 5.0025L13.56 3.4425C14.15 2.8525 14.15 1.9025 13.56 1.3225L12.68 0.4425C12.09 -0.1475 11.14 -0.1475 10.56 0.4425L9 2.0025L12 5.0025Z"})})}),y=function(e){var t=e.size,n=void 0===t?24:t,r=e.className,a=void 0===r?"wp-parsely-icon":r;return(0,s.jsxs)(i.SVG,{className:a,height:n,viewBox:"0 0 60 65",width:n,xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M23.72,51.53c0-.18,0-.34-.06-.52a13.11,13.11,0,0,0-2.1-5.53A14.74,14.74,0,0,0,19.12,43c-.27-.21-.5-.11-.51.22l-.24,3.42c0,.33-.38.35-.49,0l-1.5-4.8a1.4,1.4,0,0,0-.77-.78,23.91,23.91,0,0,0-3.1-.84c-1.38-.24-3.39-.39-3.39-.39-.34,0-.45.21-.25.49l2.06,3.76c.2.27,0,.54-.29.33l-4.51-3.6a3.68,3.68,0,0,0-2.86-.48c-1,.16-2.44.46-2.44.46a.68.68,0,0,0-.39.25.73.73,0,0,0-.14.45S.41,43,.54,44a3.63,3.63,0,0,0,1.25,2.62L6.48,50c.28.2.09.49-.23.37l-4.18-.94c-.32-.12-.5,0-.4.37,0,0,.69,1.89,1.31,3.16a24,24,0,0,0,1.66,2.74,1.34,1.34,0,0,0,1,.52l5,.13c.33,0,.41.38.1.48L7.51,58c-.31.1-.34.35-.07.55a14.29,14.29,0,0,0,3.05,1.66,13.09,13.09,0,0,0,5.9.5,25.13,25.13,0,0,0,4.34-1,9.55,9.55,0,0,1-.08-1.2,9.32,9.32,0,0,1,3.07-6.91"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M59.7,41.53a.73.73,0,0,0-.14-.45.68.68,0,0,0-.39-.25s-1.43-.3-2.44-.46a3.64,3.64,0,0,0-2.86.48l-4.51,3.6c-.26.21-.49-.06-.29-.33l2.06-3.76c.2-.28.09-.49-.25-.49,0,0-2,.15-3.39.39a23.91,23.91,0,0,0-3.1.84,1.4,1.4,0,0,0-.77.78l-1.5,4.8c-.11.32-.48.3-.49,0l-.24-3.42c0-.33-.24-.43-.51-.22a14.74,14.74,0,0,0-2.44,2.47A13.11,13.11,0,0,0,36.34,51c0,.18,0,.34-.06.52a9.26,9.26,0,0,1,3,8.1,24.1,24.1,0,0,0,4.34,1,13.09,13.09,0,0,0,5.9-.5,14.29,14.29,0,0,0,3.05-1.66c.27-.2.24-.45-.07-.55l-3.22-1.17c-.31-.1-.23-.47.1-.48l5-.13a1.38,1.38,0,0,0,1-.52A24.6,24.6,0,0,0,57,52.92c.61-1.27,1.31-3.16,1.31-3.16.1-.33-.08-.49-.4-.37l-4.18.94c-.32.12-.51-.17-.23-.37l4.69-3.34A3.63,3.63,0,0,0,59.46,44c.13-1,.24-2.47.24-2.47"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M46.5,25.61c0-.53-.35-.72-.8-.43l-4.86,2.66c-.45.28-.56-.27-.23-.69l4.66-6.23a2,2,0,0,0,.28-1.68,36.51,36.51,0,0,0-2.19-4.89,34,34,0,0,0-2.81-3.94c-.33-.41-.74-.35-.91.16l-2.28,5.68c-.16.5-.6.48-.59-.05l.28-8.93a2.54,2.54,0,0,0-.66-1.64S35,4.27,33.88,3.27,30.78.69,30.78.69a1.29,1.29,0,0,0-1.54,0s-1.88,1.49-3.12,2.59-2.48,2.35-2.48,2.35A2.5,2.5,0,0,0,23,7.27l.27,8.93c0,.53-.41.55-.58.05l-2.29-5.69c-.17-.5-.57-.56-.91-.14a35.77,35.77,0,0,0-3,4.2,35.55,35.55,0,0,0-2,4.62,2,2,0,0,0,.27,1.67l4.67,6.24c.33.42.23,1-.22.69l-4.87-2.66c-.45-.29-.82-.1-.82.43a18.6,18.6,0,0,0,.83,5.07,20.16,20.16,0,0,0,5.37,7.77c3.19,3,5.93,7.8,7.45,11.08A9.6,9.6,0,0,1,30,49.09a9.31,9.31,0,0,1,2.86.45c1.52-3.28,4.26-8.11,7.44-11.09a20.46,20.46,0,0,0,5.09-7,19,19,0,0,0,1.11-5.82"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M36.12,58.44A6.12,6.12,0,1,1,30,52.32a6.11,6.11,0,0,1,6.12,6.12"})]})},v=function(){return v=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):i.code===q.ParselyInternalServerError?i.message=(0,c.__)("The Parse.ly API returned an internal server error. Please try again later.","wp-parsely"):i.code===q.HttpRequestFailed&&i.message.includes("cURL error 28")?i.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):i.code===q.ParselySchemaValidationFailed?i.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again later.","wp-parsely"):i.code===q.ParselyUpstreamMalformedResponse&&i.message.includes("Insufficient Storage")?i.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):i.code===q.ParselyUpstreamMalformedResponse?i.message=(0,c.__)("The Parse.ly API returned a malformed response. Please try again later.","wp-parsely"):i.code===q.ParselyUpstreamNotAvailable&&(i.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),i}return K(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[q.PluginCredentialsNotSetMessageDetected,q.PluginSettingsSiteIdNotSet,q.PluginSettingsApiSecretNotSet].includes(this.code)?I(e):(this.code===q.FetchError&&(this.hint=this.Hint((0,c.__)("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===q.ParselyApiForbidden&&(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===q.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,s.jsx)(R,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},t.prototype.Hint=function(e){return'

'.concat((0,c.__)("Hint:","wp-parsely")," ").concat(e,"

")},t}(Error),Q=function(){function e(){}return e.generateSmartLinks=function(e){return t=this,n=arguments,s=function(e,t,n){var r,s,i;return void 0===t&&(t=ce),void 0===n&&(n=oe),function(e,t){var n,r,s,i,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(o){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(s=2&l[0]?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[2&l[0],s.value]),l[0]){case 0:case 1:s=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!((s=(s=a.trys).length>0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]0)){var e={maxLinksPerPost:p.SmartLinkingMaxLinks,maxLinkWords:p.SmartLinkingMaxLinkWords};R(e)}}),[R,p]);var I=(0,a.useSelect)((function(e){var t=e("core/block-editor"),r=t.getSelectedBlock,s=t.getBlock,i=e("core/editor").getEditedPostContent;return{selectedBlock:n?s(n):r(),postContent:i()}}),[n]),M=I.selectedBlock,B=I.postContent;(0,o.useEffect)((function(){y(null)}),[M]);var F=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},H=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,s.jsx)("div",{className:"wp-parsely-smart-linking",children:(0,s.jsxs)(i.PanelRow,{className:t,children:[(0,s.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("Automatically insert links to your most relevant, top performing content.","wp-parsely"),(0,s.jsxs)(i.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-smart-linking-beta",target:"_blank",variant:"link",children:[(0,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,s.jsx)(D,{icon:V,size:18,className:"parsely-external-link-icon"})]})]}),x&&(0,s.jsx)(i.Notice,{status:"info",isDismissible:!1,className:"wp-parsely-content-helper-error",children:x.message}),null!==S&&(0,s.jsx)(i.Notice,{status:"success",isDismissible:!1,className:"wp-parsely-smart-linking-suggested-links",children:/* translators: 1 - number of smart links generated */ (0,c.sprintf)((0,c.__)("Successfully added %s smart links.","wp-parsely"),S.length)}),(0,s.jsx)($,{disabled:w,selectedBlock:null==M?void 0:M.clientId,onSettingChange:function(e,t){var n,r;d(((n={})[e]=t,n)),R(((r={})[e]=t,r))}}),(0,s.jsxs)("div",{className:"smart-linking-generate",children:[(0,s.jsx)(i.Button,{onClick:function(){return ee(void 0,void 0,void 0,(function(){var e,t,n,r,s;return te(this,(function(i){switch(i.label){case 0:return[4,C(!0)];case 1:return i.sent(),[4,N(null)];case 2:return i.sent(),[4,L(null)];case 3:return i.sent(),g.trackEvent("smart_linking_generate_pressed",{is_full_content:_,selected_block:null!==(s=null==M?void 0:M.name)&&void 0!==s?s:"none",context:l}),[4,F(_?"all":null==M?void 0:M.clientId)];case 4:i.sent(),e=setTimeout((function(){var e;C(!1),g.trackEvent("smart_linking_generate_timeout",{is_full_content:_,selected_block:null!==(e=null==M?void 0:M.name)&&void 0!==e?e:"none",context:l}),G(_?"all":null==M?void 0:M.clientId)}),6e4),i.label=5;case 5:return i.trys.push([5,11,12,15]),t=_||!M,n=[],!(null==M?void 0:M.originalContent)||t?[3,7]:[4,Q.generateSmartLinks(null==M?void 0:M.originalContent,j,P)];case 6:return n=i.sent(),[3,9];case 7:return[4,Q.generateSmartLinks(B,j,P)];case 8:n=i.sent(),i.label=9;case 9:return[4,N(n)];case 10:return i.sent(),function(e){var t;g.trackEvent("smart_linking_applied",{is_full_content:_,selected_block:null!==(t=null==M?void 0:M.name)&&void 0!==t?t:"none",links_count:e.length,context:l});for(var n="",r=n=M&&!_?M.attributes.content:B,s=0,i=e;s(null==d?void 0:d.length)&&o.offset++;var f='').concat(o.text,"");r=X(r,new RegExp("(".concat(o.text,"|]*>").concat(o.text,")")),f,o.offset)}}M&&!_?(0,a.dispatch)("core/block-editor").updateBlockAttributes(M.clientId,{content:r}):(0,a.dispatch)("core/editor").editPost({content:r}),v("success",/* translators: 1 - number of smart links generated */ (0,c.sprintf)((0,c.__)("%s links applied.","wp-parsely"),e.length),{type:"snackbar",isDismissible:!0})}(n),[3,15];case 11:return r=i.sent(),L(r),v("error",(0,c.__)("There was a problem applying smart links.","wp-parsely"),{type:"snackbar",isDismissible:!0}),[3,15];case 12:return[4,C(!1)];case 13:return i.sent(),[4,G(_?"all":null==M?void 0:M.clientId)];case 14:return i.sent(),clearTimeout(e),[7];case 15:return[2]}}))}))},variant:"primary",isBusy:w,disabled:w,children:w?(0,c.__)("Adding Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")}),h&&(0,s.jsxs)(i.Notice,{status:"warning",isDismissible:!0,onRemove:function(){return y(null)},className:"wp-parsely-smart-linking-hint",children:[(0,s.jsx)("strong",{children:(0,c.__)("Hint:","wp-parsely")})," ",h]})]})]})})},se=function(){return se=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=c){var u=t;(s=r/c)%1>1/l&&(u=s>10?1:2),u=parseFloat(s.toFixed(2))===parseFloat(s.toFixed(0))?0:u,i=s.toFixed(u),a=o}l=c})),i+n+a}var me=function(e){var n=e.data,r=e.isLoading,a=(0,o.useState)(t.Views),l=a[0],u=a[1],p=(0,o.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var g=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},h=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),C(l)); /* translators: %s: metric description */return(0,s.jsxs)(ye,{title:(0,c.__)("Categories","wp-parsely"),level:3,subtitle:h,isOpen:d,onClick:function(){return f(!d)},children:[d&&(0,s.jsx)("div",{className:"panel-settings",children:(0,s.jsx)(i.SelectControl,{value:l,prefix:(0,c.__)("By: ","wp-parsely"),onChange:function(e){T(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,s.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[C(e),"avg_engaged"===e&&(0,c.__)(" (coming soon)","wp-parsely")]},e)}))})}),r?(0,s.jsx)("div",{className:"parsely-spinner-wrapper","data-testid":"parsely-spinner-wrapper",children:(0,s.jsx)(i.Spinner,{})}):(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"multi-percentage-bar",children:Object.entries(n.referrers.types).map((function(e){var t=e[0],n=e[1],r=(0,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ diff --git a/build/content-helper/excerpt-generator.asset.php b/build/content-helper/excerpt-generator.asset.php index 3a29ca6b7..909ef076c 100644 --- a/build/content-helper/excerpt-generator.asset.php +++ b/build/content-helper/excerpt-generator.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => '513a649a3d3c8d964b95'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => '2d0071eca570bd4ce8c0'); diff --git a/build/content-helper/excerpt-generator.js b/build/content-helper/excerpt-generator.js index 1a15f7c67..364b0f830 100644 --- a/build/content-helper/excerpt-generator.js +++ b/build/content-helper/excerpt-generator.js @@ -1,3 +1,3 @@ -!function(){"use strict";var e={251:function(e,t,r){var n=r(196),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,p=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(p=t.ref),t)o.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:p,props:s,_owner:i.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},893:function(e,t,r){e.exports=r(251)},196:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n=window.wp.hooks,a=window.wp.data,s=window.wp.plugins,o=r(893),i=window.wp.components,l=window.wp.editPost,c=window.wp.editor,p=window.wp.element,u=window.wp.i18n,d=window.wp.wordcount,y=r(196),h=window.wp.primitives,f=(0,y.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,y.createElement)(h.Path,{d:"M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"})),w=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return r=this,n=arguments,s=function(t,r){var n;return void 0===r&&(r={}),function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),v=(w.trackEvent,function(e){var t=e.size,r=void 0===t?24:t,n=e.className,a=void 0===n?"wp-parsely-icon":n;return(0,o.jsxs)(i.SVG,{className:a,height:r,viewBox:"0 0 60 65",width:r,xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M23.72,51.53c0-.18,0-.34-.06-.52a13.11,13.11,0,0,0-2.1-5.53A14.74,14.74,0,0,0,19.12,43c-.27-.21-.5-.11-.51.22l-.24,3.42c0,.33-.38.35-.49,0l-1.5-4.8a1.4,1.4,0,0,0-.77-.78,23.91,23.91,0,0,0-3.1-.84c-1.38-.24-3.39-.39-3.39-.39-.34,0-.45.21-.25.49l2.06,3.76c.2.27,0,.54-.29.33l-4.51-3.6a3.68,3.68,0,0,0-2.86-.48c-1,.16-2.44.46-2.44.46a.68.68,0,0,0-.39.25.73.73,0,0,0-.14.45S.41,43,.54,44a3.63,3.63,0,0,0,1.25,2.62L6.48,50c.28.2.09.49-.23.37l-4.18-.94c-.32-.12-.5,0-.4.37,0,0,.69,1.89,1.31,3.16a24,24,0,0,0,1.66,2.74,1.34,1.34,0,0,0,1,.52l5,.13c.33,0,.41.38.1.48L7.51,58c-.31.1-.34.35-.07.55a14.29,14.29,0,0,0,3.05,1.66,13.09,13.09,0,0,0,5.9.5,25.13,25.13,0,0,0,4.34-1,9.55,9.55,0,0,1-.08-1.2,9.32,9.32,0,0,1,3.07-6.91"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M59.7,41.53a.73.73,0,0,0-.14-.45.68.68,0,0,0-.39-.25s-1.43-.3-2.44-.46a3.64,3.64,0,0,0-2.86.48l-4.51,3.6c-.26.21-.49-.06-.29-.33l2.06-3.76c.2-.28.09-.49-.25-.49,0,0-2,.15-3.39.39a23.91,23.91,0,0,0-3.1.84,1.4,1.4,0,0,0-.77.78l-1.5,4.8c-.11.32-.48.3-.49,0l-.24-3.42c0-.33-.24-.43-.51-.22a14.74,14.74,0,0,0-2.44,2.47A13.11,13.11,0,0,0,36.34,51c0,.18,0,.34-.06.52a9.26,9.26,0,0,1,3,8.1,24.1,24.1,0,0,0,4.34,1,13.09,13.09,0,0,0,5.9-.5,14.29,14.29,0,0,0,3.05-1.66c.27-.2.24-.45-.07-.55l-3.22-1.17c-.31-.1-.23-.47.1-.48l5-.13a1.38,1.38,0,0,0,1-.52A24.6,24.6,0,0,0,57,52.92c.61-1.27,1.31-3.16,1.31-3.16.1-.33-.08-.49-.4-.37l-4.18.94c-.32.12-.51-.17-.23-.37l4.69-3.34A3.63,3.63,0,0,0,59.46,44c.13-1,.24-2.47.24-2.47"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M46.5,25.61c0-.53-.35-.72-.8-.43l-4.86,2.66c-.45.28-.56-.27-.23-.69l4.66-6.23a2,2,0,0,0,.28-1.68,36.51,36.51,0,0,0-2.19-4.89,34,34,0,0,0-2.81-3.94c-.33-.41-.74-.35-.91.16l-2.28,5.68c-.16.5-.6.48-.59-.05l.28-8.93a2.54,2.54,0,0,0-.66-1.64S35,4.27,33.88,3.27,30.78.69,30.78.69a1.29,1.29,0,0,0-1.54,0s-1.88,1.49-3.12,2.59-2.48,2.35-2.48,2.35A2.5,2.5,0,0,0,23,7.27l.27,8.93c0,.53-.41.55-.58.05l-2.29-5.69c-.17-.5-.57-.56-.91-.14a35.77,35.77,0,0,0-3,4.2,35.55,35.55,0,0,0-2,4.62,2,2,0,0,0,.27,1.67l4.67,6.24c.33.42.23,1-.22.69l-4.87-2.66c-.45-.29-.82-.1-.82.43a18.6,18.6,0,0,0,.83,5.07,20.16,20.16,0,0,0,5.37,7.77c3.19,3,5.93,7.8,7.45,11.08A9.6,9.6,0,0,1,30,49.09a9.31,9.31,0,0,1,2.86.45c1.52-3.28,4.26-8.11,7.44-11.09a20.46,20.46,0,0,0,5.09-7,19,19,0,0,0,1.11-5.82"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M36.12,58.44A6.12,6.12,0,1,1,30,52.32a6.11,6.11,0,0,1,6.12,6.12"})]})}),_=window.wp.apiFetch,m=r.n(_),g=window.wp.url,P=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,o.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},b=(e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)},function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function __(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(__.prototype=r.prototype,new __)});!function(e){e.CannotFormulateApiQuery="ch_cannot_formulate_api_query",e.FetchError="fetch_error",e.HttpRequestFailed="http_request_failed",e[e.ParselyApiForbidden=403]="ParselyApiForbidden",e.ParselyApiResponseContainsError="ch_response_contains_error",e.ParselyApiReturnedNoData="ch_parsely_api_returned_no_data",e.ParselyApiReturnedTooManyResults="ch_parsely_api_returned_too_many_results",e[e.ParselyApiUnauthorized=401]="ParselyApiUnauthorized",e[e.ParselyInternalServerError=500]="ParselyInternalServerError",e[e.ParselySchemaValidationFailed=422]="ParselySchemaValidationFailed",e[e.ParselyUpstreamMalformedResponse=507]="ParselyUpstreamMalformedResponse",e[e.ParselyUpstreamNotAvailable=503]="ParselyUpstreamNotAvailable",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"}(t||(t={}));var x=function(e){function r(n,a,s){void 0===s&&(s=(0,u.__)("Error: ","wp-parsely"));var o=e.call(this,s+n)||this;o.hint=null,o.name=o.constructor.name,o.code=a;var i=[t.ParselyApiForbidden,t.ParselyApiResponseContainsError,t.ParselyApiReturnedNoData,t.ParselyApiReturnedTooManyResults,t.ParselyApiUnauthorized,t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsApiSecretNotSet,t.PluginSettingsSiteIdNotSet,t.PostIsNotPublished];return o.retryFetch=!i.includes(o.code),Object.setPrototypeOf(o,r.prototype),o.code===t.ParselyApiUnauthorized?o.message=(0,u.__)("This feature is accessible to select customers participating in its beta testing.","wp-parsely"):o.code===t.ParselyInternalServerError?o.message=(0,u.__)("The Parse.ly API returned an internal server error. Please try again later.","wp-parsely"):o.code===t.HttpRequestFailed&&o.message.includes("cURL error 28")?o.message=(0,u.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):o.code===t.ParselySchemaValidationFailed?o.message=(0,u.__)("The Parse.ly API returned a validation error. Please try again later.","wp-parsely"):o.code===t.ParselyUpstreamMalformedResponse&&o.message.includes("Insufficient Storage")?o.message=(0,u.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):o.code===t.ParselyUpstreamMalformedResponse?o.message=(0,u.__)("The Parse.ly API returned a malformed response. Please try again later.","wp-parsely"):o.code===t.ParselyUpstreamNotAvailable&&(o.message=(0,u.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),o}return b(r,e),r.prototype.Message=function(e){return void 0===e&&(e=null),[t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsSiteIdNotSet,t.PluginSettingsApiSecretNotSet].includes(this.code)?function(e){return void 0===e&&(e=null),(0,o.jsx)(P,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:window.wpParselyEmptyCredentialsMessage})}(e):(this.code===t.FetchError&&(this.hint=this.Hint((0,u.__)("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.hint=this.Hint((0,u.__)("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,u.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,o.jsx)(P,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},r.prototype.Hint=function(e){return'

'.concat((0,u.__)("Hint:","wp-parsely")," ").concat(e,"

")},r}(Error),E=function(){function e(){}return e.prototype.generateExcerpt=function(e,r){return n=this,a=void 0,o=function(){var n,a,s;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0,O=(0,d.count)(s||N,"words",{}),C=(0,u.sprintf)( +!function(){"use strict";var e={251:function(e,t,r){var n=r(196),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,p=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(p=t.ref),t)o.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:p,props:s,_owner:i.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},893:function(e,t,r){e.exports=r(251)},196:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n=window.wp.hooks,a=window.wp.data,s=window.wp.plugins,o=r(893),i=window.wp.components,l=window.wp.editPost,c=window.wp.editor,p=window.wp.element,u=window.wp.i18n,d=window.wp.wordcount,y=r(196),h=window.wp.primitives,f=(0,y.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,y.createElement)(h.Path,{d:"M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"})),w=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return r=this,n=arguments,s=function(t,r){var n;return void 0===r&&(r={}),function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),v=(w.trackEvent,function(e){var t=e.size,r=void 0===t?24:t,n=e.className,a=void 0===n?"wp-parsely-icon":n;return(0,o.jsxs)(i.SVG,{className:a,height:r,viewBox:"0 0 60 65",width:r,xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M23.72,51.53c0-.18,0-.34-.06-.52a13.11,13.11,0,0,0-2.1-5.53A14.74,14.74,0,0,0,19.12,43c-.27-.21-.5-.11-.51.22l-.24,3.42c0,.33-.38.35-.49,0l-1.5-4.8a1.4,1.4,0,0,0-.77-.78,23.91,23.91,0,0,0-3.1-.84c-1.38-.24-3.39-.39-3.39-.39-.34,0-.45.21-.25.49l2.06,3.76c.2.27,0,.54-.29.33l-4.51-3.6a3.68,3.68,0,0,0-2.86-.48c-1,.16-2.44.46-2.44.46a.68.68,0,0,0-.39.25.73.73,0,0,0-.14.45S.41,43,.54,44a3.63,3.63,0,0,0,1.25,2.62L6.48,50c.28.2.09.49-.23.37l-4.18-.94c-.32-.12-.5,0-.4.37,0,0,.69,1.89,1.31,3.16a24,24,0,0,0,1.66,2.74,1.34,1.34,0,0,0,1,.52l5,.13c.33,0,.41.38.1.48L7.51,58c-.31.1-.34.35-.07.55a14.29,14.29,0,0,0,3.05,1.66,13.09,13.09,0,0,0,5.9.5,25.13,25.13,0,0,0,4.34-1,9.55,9.55,0,0,1-.08-1.2,9.32,9.32,0,0,1,3.07-6.91"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M59.7,41.53a.73.73,0,0,0-.14-.45.68.68,0,0,0-.39-.25s-1.43-.3-2.44-.46a3.64,3.64,0,0,0-2.86.48l-4.51,3.6c-.26.21-.49-.06-.29-.33l2.06-3.76c.2-.28.09-.49-.25-.49,0,0-2,.15-3.39.39a23.91,23.91,0,0,0-3.1.84,1.4,1.4,0,0,0-.77.78l-1.5,4.8c-.11.32-.48.3-.49,0l-.24-3.42c0-.33-.24-.43-.51-.22a14.74,14.74,0,0,0-2.44,2.47A13.11,13.11,0,0,0,36.34,51c0,.18,0,.34-.06.52a9.26,9.26,0,0,1,3,8.1,24.1,24.1,0,0,0,4.34,1,13.09,13.09,0,0,0,5.9-.5,14.29,14.29,0,0,0,3.05-1.66c.27-.2.24-.45-.07-.55l-3.22-1.17c-.31-.1-.23-.47.1-.48l5-.13a1.38,1.38,0,0,0,1-.52A24.6,24.6,0,0,0,57,52.92c.61-1.27,1.31-3.16,1.31-3.16.1-.33-.08-.49-.4-.37l-4.18.94c-.32.12-.51-.17-.23-.37l4.69-3.34A3.63,3.63,0,0,0,59.46,44c.13-1,.24-2.47.24-2.47"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M46.5,25.61c0-.53-.35-.72-.8-.43l-4.86,2.66c-.45.28-.56-.27-.23-.69l4.66-6.23a2,2,0,0,0,.28-1.68,36.51,36.51,0,0,0-2.19-4.89,34,34,0,0,0-2.81-3.94c-.33-.41-.74-.35-.91.16l-2.28,5.68c-.16.5-.6.48-.59-.05l.28-8.93a2.54,2.54,0,0,0-.66-1.64S35,4.27,33.88,3.27,30.78.69,30.78.69a1.29,1.29,0,0,0-1.54,0s-1.88,1.49-3.12,2.59-2.48,2.35-2.48,2.35A2.5,2.5,0,0,0,23,7.27l.27,8.93c0,.53-.41.55-.58.05l-2.29-5.69c-.17-.5-.57-.56-.91-.14a35.77,35.77,0,0,0-3,4.2,35.55,35.55,0,0,0-2,4.62,2,2,0,0,0,.27,1.67l4.67,6.24c.33.42.23,1-.22.69l-4.87-2.66c-.45-.29-.82-.1-.82.43a18.6,18.6,0,0,0,.83,5.07,20.16,20.16,0,0,0,5.37,7.77c3.19,3,5.93,7.8,7.45,11.08A9.6,9.6,0,0,1,30,49.09a9.31,9.31,0,0,1,2.86.45c1.52-3.28,4.26-8.11,7.44-11.09a20.46,20.46,0,0,0,5.09-7,19,19,0,0,0,1.11-5.82"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M36.12,58.44A6.12,6.12,0,1,1,30,52.32a6.11,6.11,0,0,1,6.12,6.12"})]})}),_=window.wp.apiFetch,m=r.n(_),g=window.wp.url,P=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,o.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},b=(e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)},function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function __(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(__.prototype=r.prototype,new __)});!function(e){e.CannotFormulateApiQuery="ch_cannot_formulate_api_query",e.FetchError="fetch_error",e.HttpRequestFailed="http_request_failed",e[e.ParselyApiForbidden=403]="ParselyApiForbidden",e.ParselyApiResponseContainsError="ch_response_contains_error",e.ParselyApiReturnedNoData="ch_parsely_api_returned_no_data",e.ParselyApiReturnedTooManyResults="ch_parsely_api_returned_too_many_results",e[e.ParselyApiUnauthorized=401]="ParselyApiUnauthorized",e[e.ParselyInternalServerError=500]="ParselyInternalServerError",e[e.ParselySchemaValidationFailed=422]="ParselySchemaValidationFailed",e[e.ParselyUpstreamMalformedResponse=507]="ParselyUpstreamMalformedResponse",e[e.ParselyUpstreamNotAvailable=503]="ParselyUpstreamNotAvailable",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"}(t||(t={}));var x=function(e){function r(n,a,s){void 0===s&&(s=(0,u.__)("Error: ","wp-parsely"));var o=e.call(this,s+n)||this;o.hint=null,o.name=o.constructor.name,o.code=a;var i=[t.ParselyApiForbidden,t.ParselyApiResponseContainsError,t.ParselyApiReturnedNoData,t.ParselyApiReturnedTooManyResults,t.ParselyApiUnauthorized,t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsApiSecretNotSet,t.PluginSettingsSiteIdNotSet,t.PostIsNotPublished];return o.retryFetch=!i.includes(o.code),Object.setPrototypeOf(o,r.prototype),o.code===t.ParselyApiUnauthorized?o.message=(0,u.__)('This AI-powered feature is opt-in. To gain access, please submit a request here.',"wp-parsely"):o.code===t.ParselyInternalServerError?o.message=(0,u.__)("The Parse.ly API returned an internal server error. Please try again later.","wp-parsely"):o.code===t.HttpRequestFailed&&o.message.includes("cURL error 28")?o.message=(0,u.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):o.code===t.ParselySchemaValidationFailed?o.message=(0,u.__)("The Parse.ly API returned a validation error. Please try again later.","wp-parsely"):o.code===t.ParselyUpstreamMalformedResponse&&o.message.includes("Insufficient Storage")?o.message=(0,u.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):o.code===t.ParselyUpstreamMalformedResponse?o.message=(0,u.__)("The Parse.ly API returned a malformed response. Please try again later.","wp-parsely"):o.code===t.ParselyUpstreamNotAvailable&&(o.message=(0,u.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),o}return b(r,e),r.prototype.Message=function(e){return void 0===e&&(e=null),[t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsSiteIdNotSet,t.PluginSettingsApiSecretNotSet].includes(this.code)?function(e){return void 0===e&&(e=null),(0,o.jsx)(P,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:window.wpParselyEmptyCredentialsMessage})}(e):(this.code===t.FetchError&&(this.hint=this.Hint((0,u.__)("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.hint=this.Hint((0,u.__)("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,u.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,o.jsx)(P,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},r.prototype.Hint=function(e){return'

'.concat((0,u.__)("Hint:","wp-parsely")," ").concat(e,"

")},r}(Error),E=function(){function e(){}return e.prototype.generateExcerpt=function(e,r){return n=this,a=void 0,o=function(){var n,a,s;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0,O=(0,d.count)(s||N,"words",{}),C=(0,u.sprintf)( // Translators: %1$s the number of words in the excerpt. (0,u._n)("%1$s word","%1$s words",O,"wp-parsely"),O);return(0,p.useEffect)((function(){var e=document.querySelector(".editor-post-excerpt textarea");e&&(e.scrollTop=0)}),[s]),(0,o.jsxs)("div",{className:"editor-post-excerpt",children:[(0,o.jsxs)("div",{style:{position:"relative"},children:[t&&(0,o.jsx)("div",{className:"editor-post-excerpt__loading_animation",children:(0,o.jsx)(A,{})}),(0,o.jsx)(i.TextareaControl,{__nextHasNoMarginBottom:!0,label:(0,u.__)("Write an excerpt (optional)","wp-parsely"),className:"editor-post-excerpt__textarea",onChange:function(e){return b({excerpt:e})},readOnly:t||R,value:t?"":R?s:N,help:O?C:null})]}),(0,o.jsxs)(i.Button,{href:(0,u.__)("https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt","wp-parsely"),target:"_blank",variant:"link",children:[(0,u.__)("Learn more about manual excerpts","wp-parsely"),(0,o.jsx)(i.Icon,{icon:f,size:18,className:"parsely-external-link-icon"})]}),(0,o.jsxs)("div",{className:"wp-parsely-excerpt-generator",children:[(0,o.jsxs)("div",{className:"wp-parsely-excerpt-generator-header",children:[(0,o.jsx)(v,{size:16}),(0,o.jsxs)("div",{className:"wp-parsely-excerpt-generator-header-label",children:[(0,u.__)("Generate With Parse.ly","wp-parsely"),(0,o.jsx)("span",{className:"beta-label",children:(0,u.__)("Beta","wp-parsely")})]})]}),g&&(0,o.jsx)(i.Notice,{status:"info",isDismissible:!1,className:"wp-parsely-excerpt-generator-error",children:g.Message()}),(0,o.jsx)("div",{className:"wp-parsely-excerpt-generator-controls",children:R?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.Button,{variant:"secondary",onClick:function(){return S(void 0,void 0,void 0,(function(){return k(this,(function(e){switch(e.label){case 0:return[4,b({excerpt:s})];case 1:return e.sent(),l(""),w.trackEvent("excerpt_generator_accepted"),[2]}}))}))},children:(0,u.__)("Accept","wp-parsely")}),(0,o.jsx)(i.Button,{isDestructive:!0,variant:"secondary",onClick:function(){return S(void 0,void 0,void 0,(function(){return k(this,(function(e){return l(""),w.trackEvent("excerpt_generator_discarded"),[2]}))}))},children:(0,u.__)("Discard","wp-parsely")})]}):(0,o.jsxs)(i.Button,{onClick:function(){return S(void 0,void 0,void 0,(function(){var e,t;return k(this,(function(n){switch(n.label){case 0:r(!0),P(void 0),_(h+1),n.label=1;case 1:return n.trys.push([1,3,4,5]),w.trackEvent("excerpt_generator_pressed"),[4,x.generateExcerpt(I,j)];case 2:return e=n.sent(),l(e),[3,5];case 3:return t=n.sent(),P(t),[3,5];case 4:return r(!1),[7];case 5:return[2]}}))}))},variant:"primary",isBusy:t,disabled:t,children:[t&&(0,u.__)("Generating Excerpt…","wp-parsely"),!t&&h>0&&(0,u.__)("Regenerate Excerpt","wp-parsely"),!t&&0===h&&(0,u.__)("Generate Excerpt","wp-parsely")]})}),(0,o.jsxs)(i.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-excerpt-generator-beta",target:"_blank",variant:"link",children:[(0,u.__)("Learn more about Parse.ly AI","wp-parsely"),(0,o.jsx)(i.Icon,{icon:f,size:18,className:"parsely-external-link-icon"})]})]})]})},A=function(){return(0,o.jsx)(i.Animate,{type:"loading",children:function(e){var t=e.className;return(0,o.jsx)("span",{className:t,children:(0,u.__)("Generating…","wp-parsely")})}})},N=function(){return(0,o.jsx)(c.PostTypeSupportCheck,{supportKeys:"excerpt",children:(0,o.jsx)(l.PluginDocumentSettingPanel,{name:"parsely-post-excerpt",title:"Excerpt",children:(0,o.jsx)(T,{})})})};(0,n.addFilter)("plugins.registerPlugin","wp-parsely-excerpt-generator",(function(e,t){var r,o;return"wp-parsely-block-editor-sidebar"!==t||((null===(r=null===window||void 0===window?void 0:window.Jetpack_Editor_Initial_State)||void 0===r?void 0:r.available_blocks["ai-content-lens"])&&(console.log("Parse.ly: Jetpack AI is enabled and will be disabled."),(0,n.removeFilter)("blocks.registerBlockType","jetpack/ai-content-lens-features")),(0,s.registerPlugin)("wp-parsely-excerpt-generator",{render:N}),null===(o=(0,a.dispatch)("core/edit-post"))||void 0===o||o.removeEditorPanel("post-excerpt")),e}),1e3)}()}(); \ No newline at end of file diff --git a/src/content-helper/common/content-helper-error.tsx b/src/content-helper/common/content-helper-error.tsx index 07fe3a33e..fc37235e1 100644 --- a/src/content-helper/common/content-helper-error.tsx +++ b/src/content-helper/common/content-helper-error.tsx @@ -72,7 +72,8 @@ export class ContentHelperError extends Error { // Errors that need rephrasing. if ( this.code === ContentHelperErrorCode.ParselyApiUnauthorized ) { this.message = __( - 'This feature is accessible to select customers participating in its beta testing.', + 'This AI-powered feature is opt-in. To gain access, please submit a request ' + + 'here.', 'wp-parsely' ); } else if ( this.code === ContentHelperErrorCode.ParselyInternalServerError ) { From cef6766eb7623297368808ec4fe37745c9b7675c Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Fri, 8 Mar 2024 18:03:39 +0200 Subject: [PATCH 2/2] Rebuild assets --- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index ef8de2b1a..216c6dc13 100644 --- a/build/content-helper/editor-sidebar.asset.php +++ b/build/content-helper/editor-sidebar.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'e97e1d62ec54740d74c8'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '1013e223b437772e186b'); diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index 63fada6d7..1dff62b64 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,7 +1,7 @@ -!function(){"use strict";var e={251:function(e,t,n){var r=n(196),s=Symbol.for("react.element"),i=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,i={},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)a.call(t,r)&&!o.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===i[r]&&(i[r]=t[r]);return{$$typeof:s,type:e,key:c,ref:u,props:i,_owner:l.current}}t.Fragment=i,t.jsx=c,t.jsxs=c},893:function(e,t,n){e.exports=n(251)},196:function(e){e.exports=window.React}},t={};function n(r){var s=t[r];if(void 0!==s)return s.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.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(){n.d({},{W:function(){return qt}});var e,t,r,s=n(893),i=window.wp.components,a=window.wp.data,l=window.wp.editPost,o=window.wp.element,c=window.wp.i18n,u=n(196),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,g=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,i=function(t,n){var r;return void 0===n&&(n={}),function(e,t){var n,r,s,i,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(o){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(s=2&l[0]?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[2&l[0],s.value]),l[0]){case 0:case 1:s=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!((s=(s=a.trys).length>0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]=1e4&&(clearInterval(i),n("Telemetry library not loaded"))}),100);else n("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,n){var r;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(n=this.prepareProperties(n),null===(r=this._tkq)||void 0===r||r.push(["recordEvent",t,n])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,n={};return Object.keys(e).forEach((function(r){t.isProprietyValid(r)&&(n[r]=e[r])})),n},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),h=(g.trackEvent,function(){return(0,s.jsx)(i.SVG,{"aria-hidden":"true",version:"1.1",viewBox:"0 0 15 15",width:"15",height:"15",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)(i.Path,{d:"M0 14.0025V11.0025L7.5 3.5025L10.5 6.5025L3 14.0025H0ZM12 5.0025L13.56 3.4425C14.15 2.8525 14.15 1.9025 13.56 1.3225L12.68 0.4425C12.09 -0.1475 11.14 -0.1475 10.56 0.4425L9 2.0025L12 5.0025Z"})})}),v=function(e){var t=e.size,n=void 0===t?24:t,r=e.className,a=void 0===r?"wp-parsely-icon":r;return(0,s.jsxs)(i.SVG,{className:a,height:n,viewBox:"0 0 60 65",width:n,xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M23.72,51.53c0-.18,0-.34-.06-.52a13.11,13.11,0,0,0-2.1-5.53A14.74,14.74,0,0,0,19.12,43c-.27-.21-.5-.11-.51.22l-.24,3.42c0,.33-.38.35-.49,0l-1.5-4.8a1.4,1.4,0,0,0-.77-.78,23.91,23.91,0,0,0-3.1-.84c-1.38-.24-3.39-.39-3.39-.39-.34,0-.45.21-.25.49l2.06,3.76c.2.27,0,.54-.29.33l-4.51-3.6a3.68,3.68,0,0,0-2.86-.48c-1,.16-2.44.46-2.44.46a.68.68,0,0,0-.39.25.73.73,0,0,0-.14.45S.41,43,.54,44a3.63,3.63,0,0,0,1.25,2.62L6.48,50c.28.2.09.49-.23.37l-4.18-.94c-.32-.12-.5,0-.4.37,0,0,.69,1.89,1.31,3.16a24,24,0,0,0,1.66,2.74,1.34,1.34,0,0,0,1,.52l5,.13c.33,0,.41.38.1.48L7.51,58c-.31.1-.34.35-.07.55a14.29,14.29,0,0,0,3.05,1.66,13.09,13.09,0,0,0,5.9.5,25.13,25.13,0,0,0,4.34-1,9.55,9.55,0,0,1-.08-1.2,9.32,9.32,0,0,1,3.07-6.91"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M59.7,41.53a.73.73,0,0,0-.14-.45.68.68,0,0,0-.39-.25s-1.43-.3-2.44-.46a3.64,3.64,0,0,0-2.86.48l-4.51,3.6c-.26.21-.49-.06-.29-.33l2.06-3.76c.2-.28.09-.49-.25-.49,0,0-2,.15-3.39.39a23.91,23.91,0,0,0-3.1.84,1.4,1.4,0,0,0-.77.78l-1.5,4.8c-.11.32-.48.3-.49,0l-.24-3.42c0-.33-.24-.43-.51-.22a14.74,14.74,0,0,0-2.44,2.47A13.11,13.11,0,0,0,36.34,51c0,.18,0,.34-.06.52a9.26,9.26,0,0,1,3,8.1,24.1,24.1,0,0,0,4.34,1,13.09,13.09,0,0,0,5.9-.5,14.29,14.29,0,0,0,3.05-1.66c.27-.2.24-.45-.07-.55l-3.22-1.17c-.31-.1-.23-.47.1-.48l5-.13a1.38,1.38,0,0,0,1-.52A24.6,24.6,0,0,0,57,52.92c.61-1.27,1.31-3.16,1.31-3.16.1-.33-.08-.49-.4-.37l-4.18.94c-.32.12-.51-.17-.23-.37l4.69-3.34A3.63,3.63,0,0,0,59.46,44c.13-1,.24-2.47.24-2.47"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M46.5,25.61c0-.53-.35-.72-.8-.43l-4.86,2.66c-.45.28-.56-.27-.23-.69l4.66-6.23a2,2,0,0,0,.28-1.68,36.51,36.51,0,0,0-2.19-4.89,34,34,0,0,0-2.81-3.94c-.33-.41-.74-.35-.91.16l-2.28,5.68c-.16.5-.6.48-.59-.05l.28-8.93a2.54,2.54,0,0,0-.66-1.64S35,4.27,33.88,3.27,30.78.69,30.78.69a1.29,1.29,0,0,0-1.54,0s-1.88,1.49-3.12,2.59-2.48,2.35-2.48,2.35A2.5,2.5,0,0,0,23,7.27l.27,8.93c0,.53-.41.55-.58.05l-2.29-5.69c-.17-.5-.57-.56-.91-.14a35.77,35.77,0,0,0-3,4.2,35.55,35.55,0,0,0-2,4.62,2,2,0,0,0,.27,1.67l4.67,6.24c.33.42.23,1-.22.69l-4.87-2.66c-.45-.29-.82-.1-.82.43a18.6,18.6,0,0,0,.83,5.07,20.16,20.16,0,0,0,5.37,7.77c3.19,3,5.93,7.8,7.45,11.08A9.6,9.6,0,0,1,30,49.09a9.31,9.31,0,0,1,2.86.45c1.52-3.28,4.26-8.11,7.44-11.09a20.46,20.46,0,0,0,5.09-7,19,19,0,0,0,1.11-5.82"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M36.12,58.44A6.12,6.12,0,1,1,30,52.32a6.11,6.11,0,0,1,6.12,6.12"})]})},y=function(){return y=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):i.code===$.ParselyInternalServerError?i.message=(0,c.__)("The Parse.ly API returned an internal server error. Please try again later.","wp-parsely"):i.code===$.HttpRequestFailed&&i.message.includes("cURL error 28")?i.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):i.code===$.ParselySchemaValidationFailed?i.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again later.","wp-parsely"):i.code===$.ParselyUpstreamMalformedResponse&&i.message.includes("Insufficient Storage")?i.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):i.code===$.ParselyUpstreamMalformedResponse?i.message=(0,c.__)("The Parse.ly API returned a malformed response. Please try again later.","wp-parsely"):i.code===$.ParselyUpstreamNotAvailable&&(i.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),i}return K(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[$.PluginCredentialsNotSetMessageDetected,$.PluginSettingsSiteIdNotSet,$.PluginSettingsApiSecretNotSet].includes(this.code)?I(e):(this.code===$.FetchError&&(this.hint=this.Hint((0,c.__)("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===$.ParselyApiForbidden&&(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===$.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,s.jsx)(R,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},t.prototype.Hint=function(e){return'

'.concat((0,c.__)("Hint:","wp-parsely")," ").concat(e,"

")},t}(Error),Q=function(){function e(){}return e.generateSmartLinks=function(e){return t=this,n=arguments,s=function(e,t,n){var r,s,i;return void 0===t&&(t=ce),void 0===n&&(n=oe),function(e,t){var n,r,s,i,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(o){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(s=2&l[0]?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[2&l[0],s.value]),l[0]){case 0:case 1:s=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!((s=(s=a.trys).length>0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]0)){var e={maxLinksPerPost:p.SmartLinkingMaxLinks,maxLinkWords:p.SmartLinkingMaxLinkWords};R(e)}}),[R,p]);var I=(0,a.useSelect)((function(e){var t=e("core/block-editor"),r=t.getSelectedBlock,s=t.getBlock,i=e("core/editor").getEditedPostContent;return{selectedBlock:n?s(n):r(),postContent:i()}}),[n]),B=I.selectedBlock,M=I.postContent;(0,o.useEffect)((function(){v(null)}),[B]);var F=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},H=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,s.jsx)("div",{className:"wp-parsely-smart-linking",children:(0,s.jsxs)(i.PanelRow,{className:t,children:[(0,s.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("Automatically insert links to your most relevant, top performing content.","wp-parsely"),(0,s.jsxs)(i.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-smart-linking-beta",target:"_blank",variant:"link",children:[(0,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,s.jsx)(D,{icon:V,size:18,className:"parsely-external-link-icon"})]})]}),x&&(0,s.jsx)(i.Notice,{status:"info",isDismissible:!1,className:"wp-parsely-content-helper-error",children:x.message}),null!==S&&(0,s.jsx)(i.Notice,{status:"success",isDismissible:!1,className:"wp-parsely-smart-linking-suggested-links",children:/* translators: 1 - number of smart links generated */ -(0,c.sprintf)((0,c.__)("Successfully added %s smart links.","wp-parsely"),S.length)}),(0,s.jsx)(q,{disabled:w,selectedBlock:null==B?void 0:B.clientId,onSettingChange:function(e,t){var n,r;d(((n={})[e]=t,n)),R(((r={})[e]=t,r))}}),(0,s.jsxs)("div",{className:"smart-linking-generate",children:[(0,s.jsx)(i.Button,{onClick:function(){return ee(void 0,void 0,void 0,(function(){var e,t,n,r,s;return te(this,(function(i){switch(i.label){case 0:return[4,C(!0)];case 1:return i.sent(),[4,N(null)];case 2:return i.sent(),[4,L(null)];case 3:return i.sent(),g.trackEvent("smart_linking_generate_pressed",{is_full_content:_,selected_block:null!==(s=null==B?void 0:B.name)&&void 0!==s?s:"none",context:l}),[4,F(_?"all":null==B?void 0:B.clientId)];case 4:i.sent(),e=setTimeout((function(){var e;C(!1),g.trackEvent("smart_linking_generate_timeout",{is_full_content:_,selected_block:null!==(e=null==B?void 0:B.name)&&void 0!==e?e:"none",context:l}),G(_?"all":null==B?void 0:B.clientId)}),6e4),i.label=5;case 5:return i.trys.push([5,11,12,15]),t=_||!B,n=[],!(null==B?void 0:B.originalContent)||t?[3,7]:[4,Q.generateSmartLinks(null==B?void 0:B.originalContent,j,P)];case 6:return n=i.sent(),[3,9];case 7:return[4,Q.generateSmartLinks(M,j,P)];case 8:n=i.sent(),i.label=9;case 9:return[4,N(n)];case 10:return i.sent(),function(e){var t;g.trackEvent("smart_linking_applied",{is_full_content:_,selected_block:null!==(t=null==B?void 0:B.name)&&void 0!==t?t:"none",links_count:e.length,context:l});for(var n="",r=n=B&&!_?B.attributes.content:M,s=0,i=e;s(null==d?void 0:d.length)&&o.offset++;var f='').concat(o.text,"");r=X(r,new RegExp("(".concat(o.text,"|]*>").concat(o.text,")")),f,o.offset)}}B&&!_?(0,a.dispatch)("core/block-editor").updateBlockAttributes(B.clientId,{content:r}):(0,a.dispatch)("core/editor").editPost({content:r}),y("success",/* translators: 1 - number of smart links generated */ -(0,c.sprintf)((0,c.__)("%s links applied.","wp-parsely"),e.length),{type:"snackbar",isDismissible:!0})}(n),[3,15];case 11:return r=i.sent(),L(r),y("error",(0,c.__)("There was a problem applying smart links.","wp-parsely"),{type:"snackbar",isDismissible:!0}),[3,15];case 12:return[4,C(!1)];case 13:return i.sent(),[4,G(_?"all":null==B?void 0:B.clientId)];case 14:return i.sent(),clearTimeout(e),[7];case 15:return[2]}}))}))},variant:"primary",isBusy:w,disabled:w,children:w?(0,c.__)("Adding Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")}),h&&(0,s.jsxs)(i.Notice,{status:"warning",isDismissible:!0,onRemove:function(){return v(null)},className:"wp-parsely-smart-linking-hint",children:[(0,s.jsx)("strong",{children:(0,c.__)("Hint:","wp-parsely")})," ",h]})]})]})})},se=function(){return se=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=c){var u=t;(s=r/c)%1>1/l&&(u=s>10?1:2),u=parseFloat(s.toFixed(2))===parseFloat(s.toFixed(0))?0:u,i=s.toFixed(u),a=o}l=c})),i+n+a}var me=function(e){var n=e.data,r=e.isLoading,a=(0,o.useState)(t.Views),l=a[0],u=a[1],p=(0,o.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var g=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},h=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),C(l)); -/* translators: %s: metric description */return(0,s.jsxs)(ve,{title:(0,c.__)("Categories","wp-parsely"),level:3,subtitle:h,isOpen:d,onClick:function(){return f(!d)},children:[d&&(0,s.jsx)("div",{className:"panel-settings",children:(0,s.jsx)(i.SelectControl,{value:l,prefix:(0,c.__)("By: ","wp-parsely"),onChange:function(e){T(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,s.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[C(e),"avg_engaged"===e&&(0,c.__)(" (coming soon)","wp-parsely")]},e)}))})}),r?(0,s.jsx)("div",{className:"parsely-spinner-wrapper","data-testid":"parsely-spinner-wrapper",children:(0,s.jsx)(i.Spinner,{})}):(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"multi-percentage-bar",children:Object.entries(n.referrers.types).map((function(e){var t=e[0],n=e[1],r=(0,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ +!function(){"use strict";var e={251:function(e,t,n){var r=n(196),s=Symbol.for("react.element"),i=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,l=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,i={},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)a.call(t,r)&&!o.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===i[r]&&(i[r]=t[r]);return{$$typeof:s,type:e,key:c,ref:u,props:i,_owner:l.current}}t.Fragment=i,t.jsx=c,t.jsxs=c},893:function(e,t,n){e.exports=n(251)},196:function(e){e.exports=window.React}},t={};function n(r){var s=t[r];if(void 0!==s)return s.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.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(){n.d({},{W:function(){return Qt}});var e,t,r,s=n(893),i=window.wp.components,a=window.wp.data,l=window.wp.editPost,o=window.wp.element,c=window.wp.i18n,u=n(196),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,g=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,i=function(t,n){var r;return void 0===n&&(n={}),function(e,t){var n,r,s,i,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(o){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(s=2&l[0]?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[2&l[0],s.value]),l[0]){case 0:case 1:s=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!((s=(s=a.trys).length>0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]=1e4&&(clearInterval(i),n("Telemetry library not loaded"))}),100);else n("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,n){var r;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(n=this.prepareProperties(n),null===(r=this._tkq)||void 0===r||r.push(["recordEvent",t,n])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,n={};return Object.keys(e).forEach((function(r){t.isProprietyValid(r)&&(n[r]=e[r])})),n},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),h=(g.trackEvent,function(){return(0,s.jsx)(i.SVG,{"aria-hidden":"true",version:"1.1",viewBox:"0 0 15 15",width:"15",height:"15",xmlns:"http://www.w3.org/2000/svg",children:(0,s.jsx)(i.Path,{d:"M0 14.0025V11.0025L7.5 3.5025L10.5 6.5025L3 14.0025H0ZM12 5.0025L13.56 3.4425C14.15 2.8525 14.15 1.9025 13.56 1.3225L12.68 0.4425C12.09 -0.1475 11.14 -0.1475 10.56 0.4425L9 2.0025L12 5.0025Z"})})}),v=function(e){var t=e.size,n=void 0===t?24:t,r=e.className,a=void 0===r?"wp-parsely-icon":r;return(0,s.jsxs)(i.SVG,{className:a,height:n,viewBox:"0 0 60 65",width:n,xmlns:"http://www.w3.org/2000/svg",children:[(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M23.72,51.53c0-.18,0-.34-.06-.52a13.11,13.11,0,0,0-2.1-5.53A14.74,14.74,0,0,0,19.12,43c-.27-.21-.5-.11-.51.22l-.24,3.42c0,.33-.38.35-.49,0l-1.5-4.8a1.4,1.4,0,0,0-.77-.78,23.91,23.91,0,0,0-3.1-.84c-1.38-.24-3.39-.39-3.39-.39-.34,0-.45.21-.25.49l2.06,3.76c.2.27,0,.54-.29.33l-4.51-3.6a3.68,3.68,0,0,0-2.86-.48c-1,.16-2.44.46-2.44.46a.68.68,0,0,0-.39.25.73.73,0,0,0-.14.45S.41,43,.54,44a3.63,3.63,0,0,0,1.25,2.62L6.48,50c.28.2.09.49-.23.37l-4.18-.94c-.32-.12-.5,0-.4.37,0,0,.69,1.89,1.31,3.16a24,24,0,0,0,1.66,2.74,1.34,1.34,0,0,0,1,.52l5,.13c.33,0,.41.38.1.48L7.51,58c-.31.1-.34.35-.07.55a14.29,14.29,0,0,0,3.05,1.66,13.09,13.09,0,0,0,5.9.5,25.13,25.13,0,0,0,4.34-1,9.55,9.55,0,0,1-.08-1.2,9.32,9.32,0,0,1,3.07-6.91"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M59.7,41.53a.73.73,0,0,0-.14-.45.68.68,0,0,0-.39-.25s-1.43-.3-2.44-.46a3.64,3.64,0,0,0-2.86.48l-4.51,3.6c-.26.21-.49-.06-.29-.33l2.06-3.76c.2-.28.09-.49-.25-.49,0,0-2,.15-3.39.39a23.91,23.91,0,0,0-3.1.84,1.4,1.4,0,0,0-.77.78l-1.5,4.8c-.11.32-.48.3-.49,0l-.24-3.42c0-.33-.24-.43-.51-.22a14.74,14.74,0,0,0-2.44,2.47A13.11,13.11,0,0,0,36.34,51c0,.18,0,.34-.06.52a9.26,9.26,0,0,1,3,8.1,24.1,24.1,0,0,0,4.34,1,13.09,13.09,0,0,0,5.9-.5,14.29,14.29,0,0,0,3.05-1.66c.27-.2.24-.45-.07-.55l-3.22-1.17c-.31-.1-.23-.47.1-.48l5-.13a1.38,1.38,0,0,0,1-.52A24.6,24.6,0,0,0,57,52.92c.61-1.27,1.31-3.16,1.31-3.16.1-.33-.08-.49-.4-.37l-4.18.94c-.32.12-.51-.17-.23-.37l4.69-3.34A3.63,3.63,0,0,0,59.46,44c.13-1,.24-2.47.24-2.47"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M46.5,25.61c0-.53-.35-.72-.8-.43l-4.86,2.66c-.45.28-.56-.27-.23-.69l4.66-6.23a2,2,0,0,0,.28-1.68,36.51,36.51,0,0,0-2.19-4.89,34,34,0,0,0-2.81-3.94c-.33-.41-.74-.35-.91.16l-2.28,5.68c-.16.5-.6.48-.59-.05l.28-8.93a2.54,2.54,0,0,0-.66-1.64S35,4.27,33.88,3.27,30.78.69,30.78.69a1.29,1.29,0,0,0-1.54,0s-1.88,1.49-3.12,2.59-2.48,2.35-2.48,2.35A2.5,2.5,0,0,0,23,7.27l.27,8.93c0,.53-.41.55-.58.05l-2.29-5.69c-.17-.5-.57-.56-.91-.14a35.77,35.77,0,0,0-3,4.2,35.55,35.55,0,0,0-2,4.62,2,2,0,0,0,.27,1.67l4.67,6.24c.33.42.23,1-.22.69l-4.87-2.66c-.45-.29-.82-.1-.82.43a18.6,18.6,0,0,0,.83,5.07,20.16,20.16,0,0,0,5.37,7.77c3.19,3,5.93,7.8,7.45,11.08A9.6,9.6,0,0,1,30,49.09a9.31,9.31,0,0,1,2.86.45c1.52-3.28,4.26-8.11,7.44-11.09a20.46,20.46,0,0,0,5.09-7,19,19,0,0,0,1.11-5.82"}),(0,s.jsx)(i.Path,{fill:"#5ba745",d:"M36.12,58.44A6.12,6.12,0,1,1,30,52.32a6.11,6.11,0,0,1,6.12,6.12"})]})},y=function(){return y=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):i.code===Z.ParselyInternalServerError?i.message=(0,c.__)("The Parse.ly API returned an internal server error. Please try again later.","wp-parsely"):i.code===Z.HttpRequestFailed&&i.message.includes("cURL error 28")?i.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):i.code===Z.ParselySchemaValidationFailed?i.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again later.","wp-parsely"):i.code===Z.ParselyUpstreamMalformedResponse&&i.message.includes("Insufficient Storage")?i.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):i.code===Z.ParselyUpstreamMalformedResponse?i.message=(0,c.__)("The Parse.ly API returned a malformed response. Please try again later.","wp-parsely"):i.code===Z.ParselyUpstreamNotAvailable&&(i.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),i}return K(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[Z.PluginCredentialsNotSetMessageDetected,Z.PluginSettingsSiteIdNotSet,Z.PluginSettingsApiSecretNotSet].includes(this.code)?I(e):(this.code===Z.FetchError&&(this.hint=this.Hint((0,c.__)("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===Z.ParselyApiForbidden&&(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===Z.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,s.jsx)(R,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

").concat(this.hint?this.hint:"")}))},t.prototype.Hint=function(e){return'

'.concat((0,c.__)("Hint:","wp-parsely")," ").concat(e,"

")},t}(Error),Q=function(){function e(){}return e.generateSmartLinks=function(e){return t=this,n=arguments,s=function(e,t,n){var r,s,i;return void 0===t&&(t=ce),void 0===n&&(n=oe),function(e,t){var n,r,s,i,a={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return i={next:l(0),throw:l(1),return:l(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function l(l){return function(o){return function(l){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,l[0]&&(a=0)),a;)try{if(n=1,r&&(s=2&l[0]?r.return:l[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,l[1])).done)return s;switch(r=0,s&&(l=[2&l[0],s.value]),l[0]){case 0:case 1:s=l;break;case 4:return a.label++,{value:l[1],done:!1};case 5:a.label++,r=l[1],l=[0];continue;case 7:l=a.ops.pop(),a.trys.pop();continue;default:if(!((s=(s=a.trys).length>0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]0)){var e={maxLinksPerPost:p.SmartLinkingMaxLinks,maxLinkWords:p.SmartLinkingMaxLinkWords};R(e)}}),[R,p]);var I=(0,a.useSelect)((function(e){var t=e("core/block-editor"),r=t.getSelectedBlock,s=t.getBlock,i=e("core/editor").getEditedPostContent;return{selectedBlock:n?s(n):r(),postContent:i()}}),[n]),B=I.selectedBlock,M=I.postContent;(0,o.useEffect)((function(){v(null)}),[B]);var F=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},z=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,s.jsx)("div",{className:"wp-parsely-smart-linking",children:(0,s.jsxs)(i.PanelRow,{className:t,children:[(0,s.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("Automatically insert links to your most relevant, top performing content.","wp-parsely"),(0,s.jsxs)(i.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-smart-linking-beta",target:"_blank",variant:"link",children:[(0,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,s.jsx)(V,{icon:D,size:18,className:"parsely-external-link-icon"})]})]}),x&&(0,s.jsx)(i.Notice,{status:"info",isDismissible:!1,className:"wp-parsely-content-helper-error",children:x.message}),null!==S&&(0,s.jsx)(i.Notice,{status:"success",isDismissible:!1,className:"wp-parsely-smart-linking-suggested-links",children:/* translators: 1 - number of smart links generated */ +(0,c.sprintf)((0,c.__)("Successfully added %s smart links.","wp-parsely"),S.length)}),(0,s.jsx)($,{disabled:w,selectedBlock:null==B?void 0:B.clientId,onSettingChange:function(e,t){var n,r;d(((n={})[e]=t,n)),R(((r={})[e]=t,r))}}),(0,s.jsxs)("div",{className:"smart-linking-generate",children:[(0,s.jsx)(i.Button,{onClick:function(){return ee(void 0,void 0,void 0,(function(){var e,t,n,r,s;return te(this,(function(i){switch(i.label){case 0:return[4,L(!0)];case 1:return i.sent(),[4,N(null)];case 2:return i.sent(),[4,C(null)];case 3:return i.sent(),g.trackEvent("smart_linking_generate_pressed",{is_full_content:_,selected_block:null!==(s=null==B?void 0:B.name)&&void 0!==s?s:"none",context:l}),[4,F(_?"all":null==B?void 0:B.clientId)];case 4:i.sent(),e=setTimeout((function(){var e;L(!1),g.trackEvent("smart_linking_generate_timeout",{is_full_content:_,selected_block:null!==(e=null==B?void 0:B.name)&&void 0!==e?e:"none",context:l}),G(_?"all":null==B?void 0:B.clientId)}),6e4),i.label=5;case 5:return i.trys.push([5,11,12,15]),t=_||!B,n=[],!(null==B?void 0:B.originalContent)||t?[3,7]:[4,Q.generateSmartLinks(null==B?void 0:B.originalContent,k,P)];case 6:return n=i.sent(),[3,9];case 7:return[4,Q.generateSmartLinks(M,k,P)];case 8:n=i.sent(),i.label=9;case 9:return[4,N(n)];case 10:return i.sent(),function(e){var t;g.trackEvent("smart_linking_applied",{is_full_content:_,selected_block:null!==(t=null==B?void 0:B.name)&&void 0!==t?t:"none",links_count:e.length,context:l});for(var n="",r=n=B&&!_?B.attributes.content:M,s=0,i=e;s(null==d?void 0:d.length)&&o.offset++;var f='').concat(o.text,"");r=X(r,new RegExp("(".concat(o.text,"|]*>").concat(o.text,")")),f,o.offset)}}B&&!_?(0,a.dispatch)("core/block-editor").updateBlockAttributes(B.clientId,{content:r}):(0,a.dispatch)("core/editor").editPost({content:r}),y("success",/* translators: 1 - number of smart links generated */ +(0,c.sprintf)((0,c.__)("%s links applied.","wp-parsely"),e.length),{type:"snackbar",isDismissible:!0})}(n),[3,15];case 11:return r=i.sent(),C(r),y("error",(0,c.__)("There was a problem applying smart links.","wp-parsely"),{type:"snackbar",isDismissible:!0}),[3,15];case 12:return[4,L(!1)];case 13:return i.sent(),[4,G(_?"all":null==B?void 0:B.clientId)];case 14:return i.sent(),clearTimeout(e),[7];case 15:return[2]}}))}))},variant:"primary",isBusy:w,disabled:w,children:w?(0,c.__)("Adding Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")}),h&&(0,s.jsxs)(i.Notice,{status:"warning",isDismissible:!0,onRemove:function(){return v(null)},className:"wp-parsely-smart-linking-hint",children:[(0,s.jsx)("strong",{children:(0,c.__)("Hint:","wp-parsely")})," ",h]})]})]})})},se=function(){return se=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=c){var u=t;(s=r/c)%1>1/l&&(u=s>10?1:2),u=parseFloat(s.toFixed(2))===parseFloat(s.toFixed(0))?0:u,i=s.toFixed(u),a=o}l=c})),i+n+a}var me=function(e){var n=e.data,r=e.isLoading,a=(0,o.useState)(t.Views),l=a[0],u=a[1],p=(0,o.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var g=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},h=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),L(l)); +/* translators: %s: metric description */return(0,s.jsxs)(ve,{title:(0,c.__)("Categories","wp-parsely"),level:3,subtitle:h,isOpen:d,onClick:function(){return f(!d)},children:[d&&(0,s.jsx)("div",{className:"panel-settings",children:(0,s.jsx)(i.SelectControl,{value:l,prefix:(0,c.__)("By: ","wp-parsely"),onChange:function(e){T(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,s.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[L(e),"avg_engaged"===e&&(0,c.__)(" (coming soon)","wp-parsely")]},e)}))})}),r?(0,s.jsx)("div",{className:"parsely-spinner-wrapper","data-testid":"parsely-spinner-wrapper",children:(0,s.jsx)(i.Spinner,{})}):(0,s.jsxs)("div",{children:[(0,s.jsx)("div",{className:"multi-percentage-bar",children:Object.entries(n.referrers.types).map((function(e){var t=e[0],n=e[1],r=(0,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ (0,c.__)("%1$s: %2$s%%","wp-parsely"),g(t),n.viewsPercentage);return(0,s.jsx)(i.Tooltip /* translators: %s: percentage value */,{ /* translators: %s: percentage value */ @@ -21,4 +21,4 @@ message:(0,c.sprintf)((0,c.__)('by author "%1$s"',"wp-parsely"),n.value)};throw (0,c.__)("Top related posts in the “%1$s” section in the %2$s.","wp-parsely"),D.value,E(p,!0)):r.Author===D.type?(0,c.sprintf)(/* translators: 1: author name, 2: period */ (0,c.__)("Top related posts by %1$s in the %2$s.","wp-parsely"),D.value,E(p,!0)):null!=A?A:""})}),k&&k.Message(),x&&(0,s.jsx)("div",{className:"related-posts-loading-message","data-testid":"parsely-related-posts-loading-message",children:(0,c.__)("Loading…","wp-parsely")}),!x&&!k&&0===B.length&&(0,s.jsx)("div",{className:"related-posts-empty",children:(0,c.__)("No related posts found.","wp-parsely")}),!x&&B.length>0&&(0,s.jsx)("div",{className:"related-posts-list",children:B.map((function(e){return(0,s.jsx)(rt,{metric:d,post:e,postContent:H},e.id)}))})]})]})]})},dt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),ft=function(){return(0,s.jsx)(i.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:(0,s.jsx)(i.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M13.5034 7.91642L9 12.0104L4.49662 7.91642L5.25337 7.08398L8.99999 10.49L12.7466 7.08398L13.5034 7.91642Z",fill:"#1E1E1E"})})},gt={journalist:{label:(0,c.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,c.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,c.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,c.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,c.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,c.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,c.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,c.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,c.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,c.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,c.__)("Custom Persona","wp-parsely"),icon:dt}},ht=Object.keys(gt),vt=function(e){return"custom"===e||""===e?gt.custom.label:yt(e)?e:gt[e].label},yt=function(e){return!ht.includes(e)||"custom"===e},mt=function(e){var t=e.value,n=e.onChange,r=(0,o.useState)(""),a=r[0],l=r[1],u=(0,N.useDebounce)(n,500);return(0,s.jsx)("div",{className:"parsely-persona-selector-custom",children:(0,s.jsx)(i.TextControl,{value:a||t,placeholder:(0,c.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void l("");e.length>32&&(e=e.slice(0,32)),u(e),l(e)}})})},wt=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,c.__)("Select a persona…","wp-parsely"):n,a=e.label,l=void 0===a?(0,c.__)("Persona","wp-parsely"):a,o=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,f=e.allowCustom,g=void 0!==f&&f;return(0,s.jsxs)(i.Disabled,{isDisabled:d,children:[l&&(0,s.jsx)("div",{className:"wp-parsely-dropdown-label",children:l}),(0,s.jsx)(i.DropdownMenu,{label:(0,c.__)("Persona","wp-parsely"),className:"parsely-persona-selector-dropdown"+(d?" is-disabled":""),popoverProps:{className:"wp-parsely-popover"},toggleProps:{children:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"parsely-persona-selector-label",children:yt(t)?gt.custom.label:r}),(0,s.jsx)(ft,{})]})},children:function(e){var n=e.onClose;return(0,s.jsx)(i.MenuGroup,{label:(0,c.__)("Persona","wp-parsely"),children:(0,s.jsx)(s.Fragment,{children:ht.map((function(e){if(!g&&"custom"===e)return null;var r=gt[e],a=e===t||yt(t)&&"custom"===e;return(0,s.jsxs)(i.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(e),o(e),n(),"custom"===e&&setTimeout((function(){var e=document.querySelector(".parsely-persona-selector-custom input");e&&e.focus()}),0)},children:[r.icon&&(0,s.jsx)(V,{icon:r.icon}),r.label]},e)}))})})}}),g&&yt(t)&&(0,s.jsx)(mt,{onChange:function(e){o(""!==e?e:"custom")},value:"custom"===t?"":t})]})},_t={neutral:{label:(0,c.__)("Neutral","wp-parsely")},formal:{label:(0,c.__)("Formal","wp-parsely")},humorous:{label:(0,c.__)("Humorous","wp-parsely")},confident:{label:(0,c.__)("Confident","wp-parsely")},provocative:{label:(0,c.__)("Provocative","wp-parsely")},serious:{label:(0,c.__)("Serious","wp-parsely")},inspirational:{label:(0,c.__)("Inspirational","wp-parsely")},skeptical:{label:(0,c.__)("Skeptical","wp-parsely")},conversational:{label:(0,c.__)("Conversational","wp-parsely")},analytical:{label:(0,c.__)("Analytical","wp-parsely")},custom:{label:(0,c.__)("Custom Tone","wp-parsely"),icon:dt}},bt=Object.keys(_t),xt=function(e){return"custom"===e||""===e?_t.custom.label:St(e)?e:_t[e].label},St=function(e){return!bt.includes(e)||"custom"===e},Pt=function(e){var t=e.value,n=e.onChange,r=(0,o.useState)(""),a=r[0],l=r[1],u=(0,N.useDebounce)(n,500);return(0,s.jsx)("div",{className:"parsely-tone-selector-custom",children:(0,s.jsx)(i.TextControl,{value:a||t,placeholder:(0,c.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void l("");e.length>32&&(e=e.slice(0,32)),u(e),l(e)}})})},jt=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,c.__)("Select a tone","wp-parsely"):n,a=e.label,l=void 0===a?(0,c.__)("Tone","wp-parsely"):a,o=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,f=e.allowCustom,g=void 0!==f&&f;return(0,s.jsxs)(i.Disabled,{isDisabled:d,children:[(0,s.jsx)("div",{className:"wp-parsely-dropdown-label",children:l}),(0,s.jsx)(i.DropdownMenu,{label:(0,c.__)("Tone","wp-parsely"),className:"parsely-tone-selector-dropdown"+(d?" is-disabled":""),popoverProps:{className:"wp-parsely-popover"},toggleProps:{children:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("div",{className:"parsely-tone-selector-label",children:St(t)?_t.custom.label:r}),(0,s.jsx)(ft,{})]})},children:function(e){var n=e.onClose;return(0,s.jsx)(i.MenuGroup,{label:(0,c.__)("Select a tone","wp-parsely"),children:(0,s.jsx)(s.Fragment,{children:bt.map((function(e){if(!g&&"custom"===e)return null;var r=_t[e],a=e===t||St(t)&&"custom"===e;return(0,s.jsxs)(i.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(e),o(e),n(),"custom"===e&&setTimeout((function(){var e=document.querySelector(".parsely-tone-selector-custom input");e&&e.focus()}),0)},children:[r.icon&&(0,s.jsx)(V,{icon:r.icon}),r.label]},e)}))})})}}),g&&St(t)&&(0,s.jsx)(Pt,{onChange:function(e){o(""!==e?e:"custom")},value:"custom"===t?"":t})]})},kt=(0,u.createElement)(p.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.Path,{d:"M10.97 10.159a3.382 3.382 0 0 0-2.857.955l1.724 1.723-2.836 2.913L7 17h1.25l2.913-2.837 1.723 1.723a3.38 3.38 0 0 0 .606-.825c.33-.63.446-1.343.35-2.032L17 10.695 13.305 7l-2.334 3.159Z"})),Tt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"})),Et=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})),Lt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z"})),Ct=function(){return Ct=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]0&&s[s.length-1])||6!==l[0]&&2!==l[0])){a=0;continue}if(3===l[0]&&(!s||l[1]>s[0]&&l[1]0?(0,s.jsx)("span",{className:"parsely-write-titles-text",children:(0,o.createInterpolateElement)( // translators: %1$s is the tone, %2$s is the persona. -(0,c.__)("We've generated a few titles based on the content of your post, written as a .","wp-parsely"),{tone:(0,s.jsx)("strong",{children:xt(d)}),persona:(0,s.jsx)("strong",{children:vt(v)})})}):(0,c.__)("Use Parse.ly AI to generate a title for your post.","wp-parsely"),(0,s.jsxs)(i.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-title-suggestions-beta",target:"_blank",variant:"link",children:[(0,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,s.jsx)(V,{icon:D,size:18,className:"parsely-external-link-icon"})]})]}),l&&(0,s.jsx)(i.Notice,{status:"info",isDismissible:!1,className:"wp-parsely-content-helper-error",children:l.message}),void 0!==P&&(0,s.jsx)(Vt,{title:P,type:tt.PostTitle,isOriginal:!0}),00&&(0,s.jsx)(Dt,{pinnedTitles:b,isOpen:!0}),_.length>0&&(0,s.jsx)(Ht,{suggestions:_,isOpen:!0,isLoading:w})]}),(0,s.jsx)(Ft,{isLoading:w,onPersonaChange:function(e){O("Persona",e),y(e)},onSettingChange:O,onToneChange:function(e){O("Tone",e),f(e)},persona:t.TitleSuggestionsSettings.Persona,tone:t.TitleSuggestionsSettings.Tone}),(0,s.jsx)("div",{className:"title-suggestions-generate",children:(0,s.jsxs)(i.Button,{variant:"primary",isBusy:w,disabled:w||"custom"===d||"custom"===v,onClick:function(){return Wt(void 0,void 0,void 0,(function(){return Zt(this,(function(e){switch(e.label){case 0:return u(void 0),!1!==w?[3,2]:(g.trackEvent("title_suggestions_generate_pressed",{request_more:_.length>0,total_titles:_.length,total_pinned:_.filter((function(e){return e.isPinned})).length,tone:d,persona:v}),[4,(t=tt.PostTitle,n=A,r=d,s=v,Wt(void 0,void 0,void 0,(function(){var e,i,a;return Zt(this,(function(l){switch(l.label){case 0:return[4,E(!0)];case 1:l.sent(),e=new zt,l.label=2;case 2:return l.trys.push([2,5,,6]),[4,e.generateTitles(n,3,r,s)];case 3:return i=l.sent(),[4,T(t,i)];case 4:return l.sent(),[3,6];case 5:return a=l.sent(),u(a),T(t,[]),[3,6];case 6:return[4,E(!1)];case 7:return l.sent(),[2]}}))})))]);case 1:e.sent(),e.label=2;case 2:return[2]}var t,n,r,s}))}))},children:[w&&(0,c.__)("Generating Titles…","wp-parsely"),!w&&x.length>0&&(0,c.__)("Generate More","wp-parsely"),!w&&0===x.length&&(0,c.__)("Generate Titles","wp-parsely")]})})]})})},qt=function(){return qt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n titles based on the content of your post, written as a .","wp-parsely"),{tone:(0,s.jsx)("strong",{children:xt(d)}),persona:(0,s.jsx)("strong",{children:vt(v)})})}):(0,c.__)("Use Parse.ly AI to generate a title for your post.","wp-parsely"),(0,s.jsxs)(i.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-title-suggestions-beta",target:"_blank",variant:"link",children:[(0,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,s.jsx)(V,{icon:D,size:18,className:"parsely-external-link-icon"})]})]}),l&&(0,s.jsx)(i.Notice,{status:"info",isDismissible:!1,className:"wp-parsely-content-helper-error",children:l.message}),void 0!==P&&(0,s.jsx)(Vt,{title:P,type:tt.PostTitle,isOriginal:!0}),00&&(0,s.jsx)(Dt,{pinnedTitles:b,isOpen:!0}),_.length>0&&(0,s.jsx)(Ht,{suggestions:_,isOpen:!0,isLoading:w})]}),(0,s.jsx)(Ft,{isLoading:w,onPersonaChange:function(e){O("Persona",e),y(e)},onSettingChange:O,onToneChange:function(e){O("Tone",e),f(e)},persona:t.TitleSuggestionsSettings.Persona,tone:t.TitleSuggestionsSettings.Tone}),(0,s.jsx)("div",{className:"title-suggestions-generate",children:(0,s.jsxs)(i.Button,{variant:"primary",isBusy:w,disabled:w||"custom"===d||"custom"===v,onClick:function(){return Wt(void 0,void 0,void 0,(function(){return Zt(this,(function(e){switch(e.label){case 0:return u(void 0),!1!==w?[3,2]:(g.trackEvent("title_suggestions_generate_pressed",{request_more:_.length>0,total_titles:_.length,total_pinned:_.filter((function(e){return e.isPinned})).length,tone:d,persona:v}),[4,(t=tt.PostTitle,n=A,r=d,s=v,Wt(void 0,void 0,void 0,(function(){var e,i,a;return Zt(this,(function(l){switch(l.label){case 0:return[4,E(!0)];case 1:l.sent(),e=new zt,l.label=2;case 2:return l.trys.push([2,5,,6]),[4,e.generateTitles(n,3,r,s)];case 3:return i=l.sent(),[4,T(t,i)];case 4:return l.sent(),[3,6];case 5:return a=l.sent(),u(a),T(t,[]),[3,6];case 6:return[4,E(!1)];case 7:return l.sent(),[2]}}))})))]);case 1:e.sent(),e.label=2;case 2:return[2]}var t,n,r,s}))}))},children:[w&&(0,c.__)("Generating Titles…","wp-parsely"),!w&&x.length>0&&(0,c.__)("Generate More","wp-parsely"),!w&&0===x.length&&(0,c.__)("Generate Titles","wp-parsely")]})})]})})},qt=function(){return qt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n