From 969bb9a59da62884853003bb6e8828465af0b688 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 8 Aug 2024 10:04:39 +0100 Subject: [PATCH 1/5] Fix issue with undefined `wpParselySmartLinkingAllowedBlocks` (#2685) --- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.js | 26 +++++++++---------- .../smart-linking/smart-linking.tsx | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index fe760624f..5019e6f73 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-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '69283974093cc5f88771'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-dom-ready', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '3f0bf999b9f142454ec8'); diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index 36067d09d..87a914b9f 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,28 +1,28 @@ -!function(){"use strict";var e={20:function(e,t,n){var r=n(609),i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,s={},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)&&!l.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===s[r]&&(s[r]=t[r]);return{$$typeof:i,type:e,key:c,ref:u,props:s,_owner:o.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},848:function(e,t,n){e.exports=n(20)},609:function(e){e.exports=window.React}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){n.d({},{_:function(){return Xn}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.domReady,l=n.n(o),c=window.wp.editPost,u=window.wp.element,p=window.wp.i18n,d=window.wp.primitives,f=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})}),h=window.wp.plugins,v=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,s=function(t,n){var r;return void 0===n&&(n={}),function(e,t){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(o){return function(l){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,o[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=1e4&&(clearInterval(s),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}(),g=(v.trackEvent,function(){return(0,i.jsx)(s.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,i.jsx)(s.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,i.jsxs)(s.SVG,{className:a,height:n,viewBox:"0 0 60 65",width:n,xmlns:"http://www.w3.org/2000/svg",children:[(0,i.jsx)(s.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,i.jsx)(s.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,i.jsx)(s.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,i.jsx)(s.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"})]})},m=function(){return m=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===M.ParselySuggestionsApiOpenAiError||s.code===M.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,p.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===M.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===M.ParselySuggestionsApiSchemaError?s.message=(0,p.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===M.ParselySuggestionsApiNoData?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===M.ParselySuggestionsApiOpenAiSchema?s.message=(0,p.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===M.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,p.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return $(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[M.PluginCredentialsNotSetMessageDetected,M.PluginSettingsSiteIdNotSet,M.PluginSettingsApiSecretNotSet].includes(this.code)?F(e):(this.code===M.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!==M.ParselyApiForbidden&&this.code!==M.ParselySuggestionsApiNoAuthentication||(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===M.HttpRequestFailed&&(this.hint=this.Hint((0,p.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(D,{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.prototype.createErrorSnackbar=function(){//.test(this.message)||(0,a.dispatch)("core/notices").createNotice("error",this.message,{type:"snackbar"})},t}(Error),K=function(e){var t=e.isDetectingEnabled,n=e.onLinkChange,r=e.onLinkRemove,i=e.onLinkAdd,s=e.debounceValue,o=void 0===s?500:s,l=(0,a.useSelect)((function(e){return{blocks:(0,e("core/block-editor").getBlocks)()}}),[]).blocks,c=(0,u.useRef)(l),p=(0,u.useRef)(t);return(0,u.useEffect)((function(){var e=(0,O.debounce)((function(){for(var t=[],s=0;s0)return r(e.innerBlocks,t[s].innerBlocks);if(JSON.stringify(e)!==JSON.stringify(t[s])){var a=t[s],o=i.parseFromString(e.attributes.content||"","text/html"),l=i.parseFromString((null==a?void 0:a.attributes.content)||"","text/html"),c=Array.from(o.querySelectorAll("a[data-smartlink]")),u=Array.from(l.querySelectorAll("a[data-smartlink]")),p=c.filter((function(e){return!u.some((function(t){return t.dataset.smartlink===e.dataset.smartlink}))})),d=u.filter((function(e){return!c.some((function(t){return t.dataset.smartlink===e.dataset.smartlink}))})),f=c.filter((function(e){var t=u.find((function(t){return t.dataset.smartlink===e.dataset.smartlink}));return t&&t.outerHTML!==e.outerHTML}));(p.length>0||d.length>0||f.length>0)&&n.push({block:e,prevBlock:a,addedLinks:p,removedLinks:d,changedLinks:f})}}}))};return r(e,t),n}(l,c.current);a.length>0&&(a.forEach((function(e){e.changedLinks.length>0&&n&&n(e),e.addedLinks.length>0&&i&&i(e),e.removedLinks.length>0&&r&&r(e)})),c.current=l)}),o);return e(t),function(){e.cancel()}}),[l,o,t,i,n,r]),null},Y=function(e){var t=e.value,n=e.onChange,r=e.max,a=e.min,o=e.suffix,l=e.size,c=e.label,u=e.initialPosition,p=e.disabled,d=e.className;return(0,i.jsxs)("div",{className:"parsely-inputrange-control ".concat(d||""),children:[(0,i.jsx)(s.__experimentalHeading,{className:"parsely-inputrange-control__label",level:3,children:c}),(0,i.jsxs)("div",{className:"parsely-inputrange-control__controls",children:[(0,i.jsx)(s.__experimentalNumberControl,{disabled:p,value:t,suffix:(0,i.jsx)(s.__experimentalInputControlSuffixWrapper,{children:o}),size:null!=l?l:"__unstable-large",min:a,max:r,onChange:function(e){var t=parseInt(e,10);isNaN(t)||n(t)}}),(0,i.jsx)(s.RangeControl,{disabled:p,value:t,showTooltip:!1,initialPosition:u,onChange:function(e){n(e)},withInputField:!1,min:a,max:r})]})]})},J=function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function a(e){try{l(r.next(e))}catch(e){s(e)}}function o(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,o)}l((r=r.apply(e,t||[])).next())}))},Q=function(e,t){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(o){return function(l){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,o[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]

","\n\x3c!-- /wp:paragraph --\x3e");t&&y((0,H.parse)(n))}),[o]),(0,i.jsxs)("div",{className:"smart-linking-review-suggestion",children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:l,right:c,up:l,down:c}}),(0,i.jsx)("div",{className:"review-suggestion-post-title",children:null===(t=o.post_data)||void 0===t?void 0:t.title}),(0,i.jsxs)("div",{className:"review-suggestion-preview",children:[!(null===(n=o.post_data)||void 0===n?void 0:n.is_first_paragraph)&&(0,i.jsx)(Me,{topOrBottom:"top"}),(0,i.jsx)(Be,{block:g[0],link:o,useOriginalBlock:!0}),!(null===(r=o.post_data)||void 0===r?void 0:r.is_last_paragraph)&&(0,i.jsx)(Me,{topOrBottom:"bottom"})]}),(0,i.jsx)(s.__experimentalDivider,{}),(0,i.jsx)(De,{link:o}),(0,i.jsxs)("div",{className:"review-controls",children:[(0,i.jsx)(s.Tooltip,{shortcut:"←",text:(0,p.__)("Previous","wp-parsely"),children:(0,i.jsx)(s.Button,{disabled:!d,className:"wp-parsely-review-suggestion-previous",onClick:l,icon:Ae,children:(0,p.__)("Previous","wp-parsely")})}),(0,i.jsx)("div",{className:"reviews-controls-middle",children:(0,i.jsx)(s.Button,{target:"_blank",href:(null===(a=o.post_data)||void 0===a?void 0:a.edit_link)+"&smart-link="+o.uid,variant:"secondary",onClick:function(){v.trackEvent("smart_linking_open_in_editor_pressed",{type:"inbound",uid:o.uid})},children:(0,p.__)("Open in the Editor","wp-parsely")})}),(0,i.jsx)(s.Tooltip,{shortcut:"→",text:(0,p.__)("Next","wp-parsely"),children:(0,i.jsxs)(s.Button,{disabled:!f,onClick:c,className:"wp-parsely-review-suggestion-next",children:[(0,p.__)("Next","wp-parsely"),(0,i.jsx)(z,{icon:Oe})]})})]})]})},Ve=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,i.jsxs)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",className:a,width:n,height:n,viewBox:"0 0 24 24",fill:"none",children:[(0,i.jsx)(s.Path,{d:"M8.18983 5.90381L8.83642 7.54325L10.4758 8.18983L8.83642 8.8364L8.18983 10.4759L7.54324 8.8364L5.90381 8.18983L7.54324 7.54325L8.18983 5.90381Z"}),(0,i.jsx)(s.Path,{d:"M15.048 5.90381L15.9101 8.08972L18.0961 8.95186L15.9101 9.81397L15.048 11.9999L14.1859 9.81397L12 8.95186L14.1859 8.08972L15.048 5.90381Z"}),(0,i.jsx)(s.Path,{d:"M11.238 10.4761L12.3157 13.2085L15.048 14.2861L12.3157 15.3638L11.238 18.0962L10.1603 15.3638L7.42798 14.2861L10.1603 13.2085L11.238 10.4761Z"})]})},Ge=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;ii.bottom)&&(n.scrollTop=r.offsetTop-n.offsetTop)}}}}),[t,d]);var h=function(){var e=document.querySelector(".smart-linking-review-sidebar-tabs [data-active-item]"),t=null==e?void 0:e.nextElementSibling;t||(t=document.querySelector('.smart-linking-review-sidebar-tabs [role="tab"]')),t&&t.click()},g=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,p.__)("NEW","wp-parsely"),(0,i.jsx)(Ve,{})]}),y=[];n&&n.length>0&&y.push({name:"outbound",title:(0,p.__)("Outbound","wp-parsely")}),r&&r.length>0&&y.push({name:"inbound",title:(0,p.__)("Inbound","wp-parsely")});var m="outbound";return y=y.filter((function(e){return"outbound"===e.name&&r&&0===r.length&&(e.title=(0,p.__)("Outbound Smart Links","wp-parsely"),m="outbound"),"inbound"===e.name&&n&&0===n.length&&(e.title=(0,p.__)("Inbound Smart Links","wp-parsely"),m="inbound"),e})),(0,i.jsxs)("div",{className:"smart-linking-review-sidebar",ref:o,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{tab:function(){return h()},"shift+tab":function(){return h()}}}),(0,i.jsx)(s.TabPanel,{className:"smart-linking-review-sidebar-tabs",initialTabName:m,tabs:y,onSelect:function(e){var t,i;"outbound"===e&&n&&n.length>0&&a(n[0]),"inbound"===e&&r&&r.length>0&&a(r[0]),v.trackEvent("smart_linking_modal_tab_selected",{tab:e,total_inbound:null!==(t=null==r?void 0:r.length)&&void 0!==t?t:0,total_outbound:null!==(i=null==n?void 0:n.length)&&void 0!==i?i:0})},children:function(e){return(0,i.jsxs)(i.Fragment,{children:["outbound"===e.name&&(0,i.jsx)(i.Fragment,{children:n&&0!==n.length?n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){l.current[n]=e},className:(null==t?void 0:t.uid)===e.uid?"is-selected":"",role:"menuitemradio",isSelected:(null==t?void 0:t.uid)===e.uid,onClick:function(){return a(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&g]},e.uid)})):(0,i.jsxs)(i.Fragment,{children:[" ",(0,p.__)("No outbound links found.","wp-parsely")]})}),"inbound"===e.name&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"review-sidebar-tip",children:(0,p.__)("This section shows external posts that link back to the current post.","wp-parsely")}),r&&0!==r.length?r.map((function(e,r){var o;return(0,i.jsx)(s.MenuItem,{ref:function(e){l.current[(n?n.length:0)+r]=e},className:(null==t?void 0:t.uid)===e.uid?"is-selected":"",role:"menuitemradio",isSelected:(null==t?void 0:t.uid)===e.uid,onClick:function(){return a(e)},children:(0,i.jsx)("span",{className:"smart-linking-menu-item",children:null===(o=e.post_data)||void 0===o?void 0:o.title})},e.uid)})):(0,i.jsxs)(i.Fragment,{children:[" ",(0,p.__)("No inbound links found.","wp-parsely")]})]})]})}})]})},ze=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})}),Ue=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})}),qe=function(e){var t,n,r,s,o=null===(t=e.link.match)||void 0===t?void 0:t.blockId,l=(0,a.useSelect)((function(e){var t=e("core/block-editor"),n=t.getBlock,r=t.getBlockParents;return o?{block:n(o),parents:r(o).map((function(e){return n(e)})).filter((function(e){return void 0!==e}))}:{block:void 0,parents:[]}}),[o]),c=l.block,u=l.parents;return c?(0,i.jsxs)("div",{className:"review-suggestions-breadcrumbs",children:[u.map((function(e,t){var n;return(0,i.jsxs)("span",{children:[(0,i.jsx)("span",{className:"breadcrumbs-parent-block",children:null===(n=(0,H.getBlockType)(e.name))||void 0===n?void 0:n.title}),(0,i.jsx)("span",{className:"breadcrumbs-parent-separator",children:" / "})]},t)})),(0,i.jsxs)("span",{className:"breadcrumbs-current-block",children:[(0,i.jsx)("span",{className:"breadcrumbs-current-block-type",children:null===(n=(0,H.getBlockType)(c.name))||void 0===n?void 0:n.title}),(null===(s=null===(r=c.attributes)||void 0===r?void 0:r.metadata)||void 0===s?void 0:s.name)&&(0,i.jsx)("span",{className:"breadcrumbs-current-block-name",children:c.attributes.metadata.name})]})]}):(0,i.jsx)(i.Fragment,{})},Ze=function(e){var t,n=e.link,r=(0,u.useState)(n.href),o=r[0],l=r[1],c=(0,u.useState)(null===(t=n.destination)||void 0===t?void 0:t.post_type),d=c[0],f=c[1],h=(0,u.useRef)(null),v=(0,a.useDispatch)(ye).updateSmartLink;return(0,u.useEffect)((function(){n.destination?f(n.destination.post_type):(f((0,p.__)("External","wp-parsely")),Le.getInstance().getPostTypeByURL(n.href).then((function(e){e&&f(e.post_type),n.destination=e,v(n)})))}),[n,v]),(0,u.useEffect)((function(){var e=function(){if(h.current){var e=h.current.offsetWidth,t=Math.floor(e/8);l(function(e,t){var n=e.replace(/(^\w+:|^)\/\//,"").replace(/^www\./,"");if(!t||n.length<=t)return n;var r=n.split("/")[0],i=n.substring(r.length);t-=r.length;var s=Math.floor((t-3)/2),a=i.substring(0,s),o=i.substring(i.length-s);return"".concat(r).concat(a,"...").concat(o)}(n.href,t))}};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[n]),(0,i.jsx)(s.MenuItem,{ref:h,info:o,iconPosition:"left",icon:Ce,shortcut:d,className:"block-editor-link-control__search-item wp-parsely-link-suggestion-link-details",children:n.title})},$e=function(e){var t=e.link,n=e.onNext,r=e.onPrevious,o=e.onAccept,l=e.onReject,c=e.onRemove,u=e.onSelectInEditor,d=e.hasPrevious,f=e.hasNext;if(t&&void 0!==t.post_data)return(0,i.jsx)(Fe,{link:t,onNext:n,onPrevious:r,onAccept:o,onReject:l,onRemove:c,onSelectInEditor:u,hasPrevious:d,hasNext:f});if(!(null==t?void 0:t.match))return(0,i.jsx)(i.Fragment,{children:(0,p.__)("This Smart Link does not have any matches in the current content.","wp-parsely")});var h=t.match.blockId,v=(0,a.select)("core/block-editor").getBlock(h),g=t.applied;return v?(0,i.jsxs)("div",{className:"smart-linking-review-suggestion",children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:r,right:n,up:r,down:n,a:function(){t&&!t.applied&&o()},r:function(){t&&(t.applied?c():l())}}}),(0,i.jsx)(qe,{link:t}),(0,i.jsx)("div",{className:"review-suggestion-preview",children:(0,i.jsx)(Be,{block:v,link:t})}),(0,i.jsx)(s.__experimentalDivider,{}),(0,i.jsx)(Ze,{link:t}),(0,i.jsxs)("div",{className:"review-controls",children:[(0,i.jsx)(s.Tooltip,{shortcut:"←",text:(0,p.__)("Previous","wp-parsely"),children:(0,i.jsx)(s.Button,{disabled:!d,className:"wp-parsely-review-suggestion-previous",onClick:r,icon:Ae,children:(0,p.__)("Previous","wp-parsely")})}),(0,i.jsxs)("div",{className:"reviews-controls-middle",children:[!g&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.Tooltip,{shortcut:"R",text:(0,p.__)("Reject","wp-parsely"),children:(0,i.jsx)(s.Button,{className:"wp-parsely-review-suggestion-reject",icon:ze,onClick:l,variant:"secondary",children:(0,p.__)("Reject","wp-parsely")})}),(0,i.jsx)(s.Tooltip,{shortcut:"A",text:(0,p.__)("Accept","wp-parsely"),children:(0,i.jsx)(s.Button,{className:"wp-parsely-review-suggestion-accept",icon:Ue,onClick:o,variant:"secondary",children:(0,p.__)("Accept","wp-parsely")})})]}),g&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.Tooltip,{shortcut:"R",text:(0,p.__)("Remove","wp-parsely"),children:(0,i.jsx)(s.Button,{className:"wp-parsely-review-suggestion-reject",icon:ze,onClick:c,variant:"secondary",children:(0,p.__)("Remove","wp-parsely")})}),(0,i.jsx)(s.Button,{className:"wp-parsely-review-suggestion-accept",onClick:u,variant:"secondary",children:(0,p.__)("Select in Editor","wp-parsely")})]})]}),(0,i.jsx)(s.Tooltip,{shortcut:"→",text:(0,p.__)("Next","wp-parsely"),children:(0,i.jsxs)(s.Button,{disabled:!f,onClick:n,className:"wp-parsely-review-suggestion-next",children:[(0,p.__)("Next","wp-parsely"),(0,i.jsx)(z,{icon:Oe})]})})]})]}):(0,i.jsx)(i.Fragment,{children:(0,p.__)("No block is selected.","wp-parsely")})},We=function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function a(e){try{l(r.next(e))}catch(e){s(e)}}function o(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,o)}l((r=r.apply(e,t||[])).next())}))},Ke=function(e,t){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(o){return function(l){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,o[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&(o=a[0],(l=o.parentNode)&&(c=document.createTextNode(null!==(u=o.textContent)&&void 0!==u?u:""),l.replaceChild(c,o),q.updateBlockAttributes(n,{content:s.innerHTML}))),[4,E(t.uid)]):[2]):[2];case 1:return p.sent(),[2]}}))}))},C=(0,u.useCallback)((function(){h(!1),x().filter((function(e){return!e.applied})).length>0?c(!0):(Z.unlockPostAutosaving("smart-linking-review-modal"),t())}),[x,t]),A=function(e){c(!1),e?(h(!1),T().then((function(){C()}))):h(!0)},O=function(){if(ee(S)){var e=w.indexOf(S);if(!w[t=e+1])return;P(w[t])}else{var t;if(e=m.indexOf(S),!m[t=e+1])return;P(m[t])}},R=function(){if(ee(S)){var e=w.indexOf(S);if(!w[t=e-1])return;P(w[t])}else{var t;if(e=m.indexOf(S),!m[t=e-1])return;P(m[t])}};return(0,u.useEffect)((function(){f?Z.lockPostAutosaving("smart-linking-review-modal"):f&&0===y.length&&C()}),[f,t,y,C]),(0,u.useEffect)((function(){h(n)}),[n]),(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsx)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:C,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(He,{outboundLinks:m,inboundLinks:w,activeLink:S,setSelectedLink:P}),S&&(ee(S)?(0,i.jsx)(Fe,{link:S,onNext:O,onPrevious:R,hasNext:w.indexOf(S)0}):(0,i.jsx)($e,{link:S,hasNext:_().indexOf(S)<_().length-1,hasPrevious:_().indexOf(S)>0,onNext:O,onPrevious:R,onAccept:function(){return We(void 0,void 0,void 0,(function(){var e,t;return Ke(this,(function(n){switch(n.label){case 0:return S.match?(r(S),[4,(i=S.match.blockId,s=S,We(void 0,void 0,void 0,(function(){var e,t;return Ke(this,(function(n){switch(n.label){case 0:return(e=document.createElement("a")).href=s.href,e.title=s.title,e.setAttribute("data-smartlink",s.uid),(t=(0,a.select)("core/block-editor").getBlock(i))?(re(t,s,e),s.applied=!0,[4,L(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),v.trackEvent("smart_linking_link_accepted",{link:S.href,title:S.title,text:S.text,uid:S.uid}),0===b().length?(C(),[2]):(e=m.indexOf(S),m[t=e+1]?P(m[t]):P(m[0]),[2])}var i,s}))}))},onReject:function(){return We(void 0,void 0,void 0,(function(){var e,t;return Ke(this,(function(n){switch(n.label){case 0:return e=m.indexOf(S),m[t=e+1]?P(m[t]):m[0]?P(m[0]):C(),[4,E(S.uid)];case 1:return n.sent(),v.trackEvent("smart_linking_link_rejected",{link:S.href,title:S.title,text:S.text,uid:S.uid}),[2]}}))}))},onRemove:function(){return We(void 0,void 0,void 0,(function(){var e,t,n,r;return Ke(this,(function(i){switch(i.label){case 0:return S.match?(e=(0,a.select)("core/block-editor").getBlock(S.match.blockId))?(t=_(),n=t.indexOf(S),r=n-1,[4,N(e,S)]):[3,2]:[2];case 1:if(i.sent(),v.trackEvent("smart_linking_link_removed",{link:S.href,title:S.title,text:S.text,uid:S.uid}),0===(t=_()).length&&w.length>0)return P(w[0]),[2];if(0===t.length&&0===w.length)return C(),[2];if(t[r])return P(t[r]),[2];P(t[0]),i.label=2;case 2:return[2]}}))}))},onSelectInEditor:function(){if(S.match){var e=(0,a.select)("core/block-editor").getBlock(S.match.blockId);if(e){q.selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));t&&fe(t,S.uid),v.trackEvent("smart_linking_select_in_editor_pressed",{type:"outbound",uid:S.uid}),C()}}}}))]})}),l&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return A(!1)},className:"wp-parsely-smart-linking-close-dialog",children:[(0,p.__)("Are you sure you want to close? All un-accepted smart links will not be added.","wp-parsely"),(0,i.jsxs)("div",{className:"smart-linking-close-dialog-actions",children:[(0,i.jsx)(s.Button,{variant:"secondary",onClick:function(){return A(!1)},children:(0,p.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return A(!0)},children:(0,p.__)("Close","wp-parsely")})]})]})]})})),Je=function(){return Je=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&S("success",/* translators: %d: number of smart links applied */ /* translators: %d: number of smart links applied */ +!function(){"use strict";var e={20:function(e,t,n){var r=n(609),i=Symbol.for("react.element"),s=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,o=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,n){var r,s={},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)&&!l.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps)void 0===s[r]&&(s[r]=t[r]);return{$$typeof:i,type:e,key:c,ref:u,props:s,_owner:o.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},848:function(e,t,n){e.exports=n(20)},609:function(e){e.exports=window.React}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){n.d({},{_:function(){return er}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.domReady,l=n.n(o),c=window.wp.editPost,u=window.wp.element,p=window.wp.i18n,d=window.wp.primitives,f=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})}),h=window.wp.plugins,v=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,s=function(t,n){var r;return void 0===n&&(n={}),function(e,t){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(o){return function(l){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,o[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=1e4&&(clearInterval(s),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}(),g=(v.trackEvent,function(){return(0,i.jsx)(s.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,i.jsx)(s.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,i.jsxs)(s.SVG,{className:a,height:n,viewBox:"0 0 60 65",width:n,xmlns:"http://www.w3.org/2000/svg",children:[(0,i.jsx)(s.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,i.jsx)(s.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,i.jsx)(s.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,i.jsx)(s.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"})]})},m=function(){return m=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===M.ParselySuggestionsApiOpenAiError||s.code===M.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,p.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===M.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===M.ParselySuggestionsApiSchemaError?s.message=(0,p.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===M.ParselySuggestionsApiNoData?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===M.ParselySuggestionsApiOpenAiSchema?s.message=(0,p.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===M.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,p.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return $(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[M.PluginCredentialsNotSetMessageDetected,M.PluginSettingsSiteIdNotSet,M.PluginSettingsApiSecretNotSet].includes(this.code)?F(e):(this.code===M.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!==M.ParselyApiForbidden&&this.code!==M.ParselySuggestionsApiNoAuthentication||(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===M.HttpRequestFailed&&(this.hint=this.Hint((0,p.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(D,{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.prototype.createErrorSnackbar=function(){//.test(this.message)||(0,a.dispatch)("core/notices").createNotice("error",this.message,{type:"snackbar"})},t}(Error),K=function(e){var t=e.isDetectingEnabled,n=e.onLinkChange,r=e.onLinkRemove,i=e.onLinkAdd,s=e.debounceValue,o=void 0===s?500:s,l=(0,a.useSelect)((function(e){return{blocks:(0,e("core/block-editor").getBlocks)()}}),[]).blocks,c=(0,u.useRef)(l),p=(0,u.useRef)(t);return(0,u.useEffect)((function(){var e=(0,O.debounce)((function(){for(var t=[],s=0;s0)return r(e.innerBlocks,t[s].innerBlocks);if(JSON.stringify(e)!==JSON.stringify(t[s])){var a=t[s],o=i.parseFromString(e.attributes.content||"","text/html"),l=i.parseFromString((null==a?void 0:a.attributes.content)||"","text/html"),c=Array.from(o.querySelectorAll("a[data-smartlink]")),u=Array.from(l.querySelectorAll("a[data-smartlink]")),p=c.filter((function(e){return!u.some((function(t){return t.dataset.smartlink===e.dataset.smartlink}))})),d=u.filter((function(e){return!c.some((function(t){return t.dataset.smartlink===e.dataset.smartlink}))})),f=c.filter((function(e){var t=u.find((function(t){return t.dataset.smartlink===e.dataset.smartlink}));return t&&t.outerHTML!==e.outerHTML}));(p.length>0||d.length>0||f.length>0)&&n.push({block:e,prevBlock:a,addedLinks:p,removedLinks:d,changedLinks:f})}}}))};return r(e,t),n}(l,c.current);a.length>0&&(a.forEach((function(e){e.changedLinks.length>0&&n&&n(e),e.addedLinks.length>0&&i&&i(e),e.removedLinks.length>0&&r&&r(e)})),c.current=l)}),o);return e(t),function(){e.cancel()}}),[l,o,t,i,n,r]),null},Y=function(e){var t=e.value,n=e.onChange,r=e.max,a=e.min,o=e.suffix,l=e.size,c=e.label,u=e.initialPosition,p=e.disabled,d=e.className;return(0,i.jsxs)("div",{className:"parsely-inputrange-control ".concat(d||""),children:[(0,i.jsx)(s.__experimentalHeading,{className:"parsely-inputrange-control__label",level:3,children:c}),(0,i.jsxs)("div",{className:"parsely-inputrange-control__controls",children:[(0,i.jsx)(s.__experimentalNumberControl,{disabled:p,value:t,suffix:(0,i.jsx)(s.__experimentalInputControlSuffixWrapper,{children:o}),size:null!=l?l:"__unstable-large",min:a,max:r,onChange:function(e){var t=parseInt(e,10);isNaN(t)||n(t)}}),(0,i.jsx)(s.RangeControl,{disabled:p,value:t,showTooltip:!1,initialPosition:u,onChange:function(e){n(e)},withInputField:!1,min:a,max:r})]})]})},J=function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function a(e){try{l(r.next(e))}catch(e){s(e)}}function o(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,o)}l((r=r.apply(e,t||[])).next())}))},Q=function(e,t){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(o){return function(l){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,o[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]

","\n\x3c!-- /wp:paragraph --\x3e");t&&y((0,H.parse)(n))}),[o]),(0,i.jsxs)("div",{className:"smart-linking-review-suggestion",children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:l,right:c,up:l,down:c}}),(0,i.jsx)("div",{className:"review-suggestion-post-title",children:null===(t=o.post_data)||void 0===t?void 0:t.title}),(0,i.jsxs)("div",{className:"review-suggestion-preview",children:[!(null===(n=o.post_data)||void 0===n?void 0:n.is_first_paragraph)&&(0,i.jsx)(Me,{topOrBottom:"top"}),(0,i.jsx)(Be,{block:g[0],link:o,useOriginalBlock:!0}),!(null===(r=o.post_data)||void 0===r?void 0:r.is_last_paragraph)&&(0,i.jsx)(Me,{topOrBottom:"bottom"})]}),(0,i.jsx)(s.__experimentalDivider,{}),(0,i.jsx)(De,{link:o}),(0,i.jsxs)("div",{className:"review-controls",children:[(0,i.jsx)(s.Tooltip,{shortcut:"←",text:(0,p.__)("Previous","wp-parsely"),children:(0,i.jsx)(s.Button,{disabled:!d,className:"wp-parsely-review-suggestion-previous",onClick:l,icon:Ae,children:(0,p.__)("Previous","wp-parsely")})}),(0,i.jsx)("div",{className:"reviews-controls-middle",children:(0,i.jsx)(s.Button,{target:"_blank",href:(null===(a=o.post_data)||void 0===a?void 0:a.edit_link)+"&smart-link="+o.uid,variant:"secondary",onClick:function(){v.trackEvent("smart_linking_open_in_editor_pressed",{type:"inbound",uid:o.uid})},children:(0,p.__)("Open in the Editor","wp-parsely")})}),(0,i.jsx)(s.Tooltip,{shortcut:"→",text:(0,p.__)("Next","wp-parsely"),children:(0,i.jsxs)(s.Button,{disabled:!f,onClick:c,className:"wp-parsely-review-suggestion-next",children:[(0,p.__)("Next","wp-parsely"),(0,i.jsx)(z,{icon:Oe})]})})]})]})},Ve=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,i.jsxs)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",className:a,width:n,height:n,viewBox:"0 0 24 24",fill:"none",children:[(0,i.jsx)(s.Path,{d:"M8.18983 5.90381L8.83642 7.54325L10.4758 8.18983L8.83642 8.8364L8.18983 10.4759L7.54324 8.8364L5.90381 8.18983L7.54324 7.54325L8.18983 5.90381Z"}),(0,i.jsx)(s.Path,{d:"M15.048 5.90381L15.9101 8.08972L18.0961 8.95186L15.9101 9.81397L15.048 11.9999L14.1859 9.81397L12 8.95186L14.1859 8.08972L15.048 5.90381Z"}),(0,i.jsx)(s.Path,{d:"M11.238 10.4761L12.3157 13.2085L15.048 14.2861L12.3157 15.3638L11.238 18.0962L10.1603 15.3638L7.42798 14.2861L10.1603 13.2085L11.238 10.4761Z"})]})},Ge=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;ii.bottom)&&(n.scrollTop=r.offsetTop-n.offsetTop)}}}}),[t,d]);var h=function(){var e=document.querySelector(".smart-linking-review-sidebar-tabs [data-active-item]"),t=null==e?void 0:e.nextElementSibling;t||(t=document.querySelector('.smart-linking-review-sidebar-tabs [role="tab"]')),t&&t.click()},g=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,p.__)("NEW","wp-parsely"),(0,i.jsx)(Ve,{})]}),y=[];n&&n.length>0&&y.push({name:"outbound",title:(0,p.__)("Outbound","wp-parsely")}),r&&r.length>0&&y.push({name:"inbound",title:(0,p.__)("Inbound","wp-parsely")});var m="outbound";return y=y.filter((function(e){return"outbound"===e.name&&r&&0===r.length&&(e.title=(0,p.__)("Outbound Smart Links","wp-parsely"),m="outbound"),"inbound"===e.name&&n&&0===n.length&&(e.title=(0,p.__)("Inbound Smart Links","wp-parsely"),m="inbound"),e})),(0,i.jsxs)("div",{className:"smart-linking-review-sidebar",ref:o,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{tab:function(){return h()},"shift+tab":function(){return h()}}}),(0,i.jsx)(s.TabPanel,{className:"smart-linking-review-sidebar-tabs",initialTabName:m,tabs:y,onSelect:function(e){var t,i;"outbound"===e&&n&&n.length>0&&a(n[0]),"inbound"===e&&r&&r.length>0&&a(r[0]),v.trackEvent("smart_linking_modal_tab_selected",{tab:e,total_inbound:null!==(t=null==r?void 0:r.length)&&void 0!==t?t:0,total_outbound:null!==(i=null==n?void 0:n.length)&&void 0!==i?i:0})},children:function(e){return(0,i.jsxs)(i.Fragment,{children:["outbound"===e.name&&(0,i.jsx)(i.Fragment,{children:n&&0!==n.length?n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){l.current[n]=e},className:(null==t?void 0:t.uid)===e.uid?"is-selected":"",role:"menuitemradio",isSelected:(null==t?void 0:t.uid)===e.uid,onClick:function(){return a(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&g]},e.uid)})):(0,i.jsxs)(i.Fragment,{children:[" ",(0,p.__)("No outbound links found.","wp-parsely")]})}),"inbound"===e.name&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"review-sidebar-tip",children:(0,p.__)("This section shows external posts that link back to the current post.","wp-parsely")}),r&&0!==r.length?r.map((function(e,r){var o;return(0,i.jsx)(s.MenuItem,{ref:function(e){l.current[(n?n.length:0)+r]=e},className:(null==t?void 0:t.uid)===e.uid?"is-selected":"",role:"menuitemradio",isSelected:(null==t?void 0:t.uid)===e.uid,onClick:function(){return a(e)},children:(0,i.jsx)("span",{className:"smart-linking-menu-item",children:null===(o=e.post_data)||void 0===o?void 0:o.title})},e.uid)})):(0,i.jsxs)(i.Fragment,{children:[" ",(0,p.__)("No inbound links found.","wp-parsely")]})]})]})}})]})},ze=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"})}),Ue=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})}),qe=function(e){var t,n,r,s,o=null===(t=e.link.match)||void 0===t?void 0:t.blockId,l=(0,a.useSelect)((function(e){var t=e("core/block-editor"),n=t.getBlock,r=t.getBlockParents;return o?{block:n(o),parents:r(o).map((function(e){return n(e)})).filter((function(e){return void 0!==e}))}:{block:void 0,parents:[]}}),[o]),c=l.block,u=l.parents;return c?(0,i.jsxs)("div",{className:"review-suggestions-breadcrumbs",children:[u.map((function(e,t){var n;return(0,i.jsxs)("span",{children:[(0,i.jsx)("span",{className:"breadcrumbs-parent-block",children:null===(n=(0,H.getBlockType)(e.name))||void 0===n?void 0:n.title}),(0,i.jsx)("span",{className:"breadcrumbs-parent-separator",children:" / "})]},t)})),(0,i.jsxs)("span",{className:"breadcrumbs-current-block",children:[(0,i.jsx)("span",{className:"breadcrumbs-current-block-type",children:null===(n=(0,H.getBlockType)(c.name))||void 0===n?void 0:n.title}),(null===(s=null===(r=c.attributes)||void 0===r?void 0:r.metadata)||void 0===s?void 0:s.name)&&(0,i.jsx)("span",{className:"breadcrumbs-current-block-name",children:c.attributes.metadata.name})]})]}):(0,i.jsx)(i.Fragment,{})},Ze=function(e){var t,n=e.link,r=(0,u.useState)(n.href),o=r[0],l=r[1],c=(0,u.useState)(null===(t=n.destination)||void 0===t?void 0:t.post_type),d=c[0],f=c[1],h=(0,u.useRef)(null),v=(0,a.useDispatch)(ye).updateSmartLink;return(0,u.useEffect)((function(){n.destination?f(n.destination.post_type):(f((0,p.__)("External","wp-parsely")),Le.getInstance().getPostTypeByURL(n.href).then((function(e){e&&f(e.post_type),n.destination=e,v(n)})))}),[n,v]),(0,u.useEffect)((function(){var e=function(){if(h.current){var e=h.current.offsetWidth,t=Math.floor(e/8);l(function(e,t){var n=e.replace(/(^\w+:|^)\/\//,"").replace(/^www\./,"");if(!t||n.length<=t)return n;var r=n.split("/")[0],i=n.substring(r.length);t-=r.length;var s=Math.floor((t-3)/2),a=i.substring(0,s),o=i.substring(i.length-s);return"".concat(r).concat(a,"...").concat(o)}(n.href,t))}};return e(),window.addEventListener("resize",e),function(){window.removeEventListener("resize",e)}}),[n]),(0,i.jsx)(s.MenuItem,{ref:h,info:o,iconPosition:"left",icon:Ce,shortcut:d,className:"block-editor-link-control__search-item wp-parsely-link-suggestion-link-details",children:n.title})},$e=function(e){var t=e.link,n=e.onNext,r=e.onPrevious,o=e.onAccept,l=e.onReject,c=e.onRemove,u=e.onSelectInEditor,d=e.hasPrevious,f=e.hasNext;if(t&&void 0!==t.post_data)return(0,i.jsx)(Fe,{link:t,onNext:n,onPrevious:r,onAccept:o,onReject:l,onRemove:c,onSelectInEditor:u,hasPrevious:d,hasNext:f});if(!(null==t?void 0:t.match))return(0,i.jsx)(i.Fragment,{children:(0,p.__)("This Smart Link does not have any matches in the current content.","wp-parsely")});var h=t.match.blockId,v=(0,a.select)("core/block-editor").getBlock(h),g=t.applied;return v?(0,i.jsxs)("div",{className:"smart-linking-review-suggestion",children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:r,right:n,up:r,down:n,a:function(){t&&!t.applied&&o()},r:function(){t&&(t.applied?c():l())}}}),(0,i.jsx)(qe,{link:t}),(0,i.jsx)("div",{className:"review-suggestion-preview",children:(0,i.jsx)(Be,{block:v,link:t})}),(0,i.jsx)(s.__experimentalDivider,{}),(0,i.jsx)(Ze,{link:t}),(0,i.jsxs)("div",{className:"review-controls",children:[(0,i.jsx)(s.Tooltip,{shortcut:"←",text:(0,p.__)("Previous","wp-parsely"),children:(0,i.jsx)(s.Button,{disabled:!d,className:"wp-parsely-review-suggestion-previous",onClick:r,icon:Ae,children:(0,p.__)("Previous","wp-parsely")})}),(0,i.jsxs)("div",{className:"reviews-controls-middle",children:[!g&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.Tooltip,{shortcut:"R",text:(0,p.__)("Reject","wp-parsely"),children:(0,i.jsx)(s.Button,{className:"wp-parsely-review-suggestion-reject",icon:ze,onClick:l,variant:"secondary",children:(0,p.__)("Reject","wp-parsely")})}),(0,i.jsx)(s.Tooltip,{shortcut:"A",text:(0,p.__)("Accept","wp-parsely"),children:(0,i.jsx)(s.Button,{className:"wp-parsely-review-suggestion-accept",icon:Ue,onClick:o,variant:"secondary",children:(0,p.__)("Accept","wp-parsely")})})]}),g&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)(s.Tooltip,{shortcut:"R",text:(0,p.__)("Remove","wp-parsely"),children:(0,i.jsx)(s.Button,{className:"wp-parsely-review-suggestion-reject",icon:ze,onClick:c,variant:"secondary",children:(0,p.__)("Remove","wp-parsely")})}),(0,i.jsx)(s.Button,{className:"wp-parsely-review-suggestion-accept",onClick:u,variant:"secondary",children:(0,p.__)("Select in Editor","wp-parsely")})]})]}),(0,i.jsx)(s.Tooltip,{shortcut:"→",text:(0,p.__)("Next","wp-parsely"),children:(0,i.jsxs)(s.Button,{disabled:!f,onClick:n,className:"wp-parsely-review-suggestion-next",children:[(0,p.__)("Next","wp-parsely"),(0,i.jsx)(z,{icon:Oe})]})})]})]}):(0,i.jsx)(i.Fragment,{children:(0,p.__)("No block is selected.","wp-parsely")})},We=function(e,t,n,r){return new(n||(n=Promise))((function(i,s){function a(e){try{l(r.next(e))}catch(e){s(e)}}function o(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,o)}l((r=r.apply(e,t||[])).next())}))},Ke=function(e,t){var n,r,i,s,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:o(0),throw:o(1),return:o(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function o(o){return function(l){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;s&&(s=0,o[0]&&(a=0)),a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!((i=(i=a.trys).length>0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&(o=a[0],(l=o.parentNode)&&(c=document.createTextNode(null!==(u=o.textContent)&&void 0!==u?u:""),l.replaceChild(c,o),q.updateBlockAttributes(n,{content:s.innerHTML}))),[4,E(t.uid)]):[2]):[2];case 1:return p.sent(),[2]}}))}))},C=(0,u.useCallback)((function(){h(!1),x().filter((function(e){return!e.applied})).length>0?c(!0):(Z.unlockPostAutosaving("smart-linking-review-modal"),t())}),[x,t]),A=function(e){c(!1),e?(h(!1),T().then((function(){C()}))):h(!0)},O=function(){if(ee(S)){var e=w.indexOf(S);if(!w[t=e+1])return;P(w[t])}else{var t;if(e=m.indexOf(S),!m[t=e+1])return;P(m[t])}},R=function(){if(ee(S)){var e=w.indexOf(S);if(!w[t=e-1])return;P(w[t])}else{var t;if(e=m.indexOf(S),!m[t=e-1])return;P(m[t])}};return(0,u.useEffect)((function(){f?Z.lockPostAutosaving("smart-linking-review-modal"):f&&0===y.length&&C()}),[f,t,y,C]),(0,u.useEffect)((function(){h(n)}),[n]),(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsx)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:C,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(He,{outboundLinks:m,inboundLinks:w,activeLink:S,setSelectedLink:P}),S&&(ee(S)?(0,i.jsx)(Fe,{link:S,onNext:O,onPrevious:R,hasNext:w.indexOf(S)0}):(0,i.jsx)($e,{link:S,hasNext:_().indexOf(S)<_().length-1,hasPrevious:_().indexOf(S)>0,onNext:O,onPrevious:R,onAccept:function(){return We(void 0,void 0,void 0,(function(){var e,t;return Ke(this,(function(n){switch(n.label){case 0:return S.match?(r(S),[4,(i=S.match.blockId,s=S,We(void 0,void 0,void 0,(function(){var e,t;return Ke(this,(function(n){switch(n.label){case 0:return(e=document.createElement("a")).href=s.href,e.title=s.title,e.setAttribute("data-smartlink",s.uid),(t=(0,a.select)("core/block-editor").getBlock(i))?(re(t,s,e),s.applied=!0,[4,L(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),v.trackEvent("smart_linking_link_accepted",{link:S.href,title:S.title,text:S.text,uid:S.uid}),0===b().length?(C(),[2]):(e=m.indexOf(S),m[t=e+1]?P(m[t]):P(m[0]),[2])}var i,s}))}))},onReject:function(){return We(void 0,void 0,void 0,(function(){var e,t;return Ke(this,(function(n){switch(n.label){case 0:return e=m.indexOf(S),m[t=e+1]?P(m[t]):m[0]?P(m[0]):C(),[4,E(S.uid)];case 1:return n.sent(),v.trackEvent("smart_linking_link_rejected",{link:S.href,title:S.title,text:S.text,uid:S.uid}),[2]}}))}))},onRemove:function(){return We(void 0,void 0,void 0,(function(){var e,t,n,r;return Ke(this,(function(i){switch(i.label){case 0:return S.match?(e=(0,a.select)("core/block-editor").getBlock(S.match.blockId))?(t=_(),n=t.indexOf(S),r=n-1,[4,N(e,S)]):[3,2]:[2];case 1:if(i.sent(),v.trackEvent("smart_linking_link_removed",{link:S.href,title:S.title,text:S.text,uid:S.uid}),0===(t=_()).length&&w.length>0)return P(w[0]),[2];if(0===t.length&&0===w.length)return C(),[2];if(t[r])return P(t[r]),[2];P(t[0]),i.label=2;case 2:return[2]}}))}))},onSelectInEditor:function(){if(S.match){var e=(0,a.select)("core/block-editor").getBlock(S.match.blockId);if(e){q.selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));t&&fe(t,S.uid),v.trackEvent("smart_linking_select_in_editor_pressed",{type:"outbound",uid:S.uid}),C()}}}}))]})}),l&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return A(!1)},className:"wp-parsely-smart-linking-close-dialog",children:[(0,p.__)("Are you sure you want to close? All un-accepted smart links will not be added.","wp-parsely"),(0,i.jsxs)("div",{className:"smart-linking-close-dialog-actions",children:[(0,i.jsx)(s.Button,{variant:"secondary",onClick:function(){return A(!1)},children:(0,p.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return A(!0)},children:(0,p.__)("Close","wp-parsely")})]})]})]})})),Je=function(){return Je=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&S("success",/* translators: %d: number of smart links applied */ /* translators: %d: number of smart links applied */ (0,p.sprintf)((0,p.__)("%s smart links successfully applied.","wp-parsely"),w),{type:"snackbar"}):b(0)}),[x]),(0,u.useEffect)((function(){if(!(Object.keys(B).length>0)){var e={maxLinksPerPost:d.SmartLinking.MaxLinks};le(e)}}),[le,d]);var ke=(0,a.useSelect)((function(e){var t=e("core/block-editor"),r=t.getSelectedBlock,i=t.getBlock,s=t.getBlocks,a=e("core/editor"),o=a.getEditedPostContent,l=a.getCurrentPostAttribute;return{allBlocks:s(),selectedBlock:n?i(n):r(),postContent:o(),postPermalink:l("link")}}),[n]),Se=ke.allBlocks,Pe=ke.selectedBlock,je=ke.postContent,Te=ke.postPermalink,Ce=function(e){return Qe(void 0,void 0,void 0,(function(){var t,n,r,i,s;return Xe(this,(function(a){switch(a.label){case 0:t=[],a.label=1;case 1:return a.trys.push([1,4,,9]),[4,de((n=N||!Pe)?pe.All:pe.Selected)];case 2:return a.sent(),o=Te.replace(/^https?:\/\//i,""),r=["http://"+o,"https://"+o],i=function(e){return e.map((function(e){return e.href}))}(G),r.push.apply(r,i),[4,Le.getInstance().generateSmartLinks(Pe&&!n?(0,H.getBlockContent)(Pe):je,I,r)];case 3:return t=a.sent(),[3,9];case 4:if((s=a.sent()).code&&s.code===M.ParselyAborted)throw s.numRetries=3-e,s;return e>0&&s.retryFetch?(console.error(s),[4,he(!0)]):[3,8];case 5:return a.sent(),[4,ve()];case 6:return a.sent(),[4,Ce(e-1)];case 7:return[2,a.sent()];case 8:throw s;case 9:return[2,t]}var o}))}))},Ae=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Ie=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),Z.unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)(K,{isDetectingEnabled:!E,onLinkRemove:function(e){!function(e){J(this,void 0,void 0,(function(){var t,n,r;return Q(this,(function(i){switch(i.label){case 0:return[4,ce((0,H.getBlockContent)(e),e.clientId)];case 1:return t=i.sent(),n=t.missingSmartLinks,r=t.didAnyFixes,n.forEach((function(e){(0,a.dispatch)(ye).removeSmartLink(e.uid)})),[2,r]}}))}))}(e.block)}}),(0,i.jsxs)(s.PanelRow,{className:t,children:[(0,i.jsxs)("div",{className:"smart-linking-text",children:[(0,p.__)("Automatically insert links to your most relevant, top performing content.","wp-parsely"),(0,i.jsxs)(s.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-smart-linking-beta",target:"_blank",variant:"link",children:[(0,p.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(z,{icon:U,size:18,className:"parsely-external-link-icon"})]})]}),A&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return te(null)},className:"wp-parsely-content-helper-error",children:A.Message()}),x&&w>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return k(!1)},className:"wp-parsely-smart-linking-suggested-links",children:(0,p.sprintf)(/* translators: 1 - number of smart links generated */ /* translators: 1 - number of smart links generated */ (0,p.__)("Successfully added %s smart links.","wp-parsely"),w>0?w:R.length)}),(0,i.jsx)(_e,{disabled:L,selectedBlock:Pe,onSettingChange:function(e,t){var n;y({SmartLinking:Je(Je({},d.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e&&fe(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return Qe(void 0,void 0,void 0,(function(){var e,t,n,r,i,s,a,l;return Xe(this,(function(c){switch(c.label){case 0:return[4,ee(!0)];case 1:return c.sent(),[4,ge()];case 2:return c.sent(),[4,te(null)];case 3:return c.sent(),k(!1),v.trackEvent("smart_linking_generate_pressed",{is_full_content:N,selected_block:null!==(s=null==Pe?void 0:Pe.name)&&void 0!==s?s:"none",context:o}),[4,Ae(N?"all":null==Pe?void 0:Pe.clientId)];case 4:c.sent(),e=setTimeout((function(){var e;ee(!1),v.trackEvent("smart_linking_generate_timeout",{is_full_content:N,selected_block:null!==(e=null==Pe?void 0:Pe.name)&&void 0!==e?e:"none",context:o}),Oe(N?"all":null==Pe?void 0:Pe.clientId)}),18e4),t=D,c.label=5;case 5:return c.trys.push([5,8,10,15]),[4,Ce(3)];case 6:return n=c.sent(),[4,(u=n,Qe(void 0,void 0,void 0,(function(){var e;return Xe(this,(function(t){switch(t.label){case 0:return u=u.filter((function(e){return!G.some((function(t){return t.uid===e.uid&&t.applied}))})),e=Te.replace(/^https?:\/\//,"").replace(/\/+$/,""),u=(u=u.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)}))).filter((function(e){return!G.some((function(t){return t.href===e.href?(console.warn("PCH Smart Linking: Skipping duplicate link: ".concat(e.href)),!0):t.text===e.text&&t.offset!==e.offset&&(console.warn("PCH Smart Linking: Skipping duplicate link text: ".concat(e.text)),!0)}))})),u=(u=ae(N?Se:[Pe],u,{}).filter((function(e){return e.match}))).filter((function(e){if(!e.match)return!1;var t=e.match.blockLinkPosition,n=t+e.text.length;return!G.some((function(r){if(!r.match)return!1;if(e.match.blockId!==r.match.blockId)return!1;var i=r.match.blockLinkPosition,s=i+r.text.length;return t>=i&&n<=s}))})),[4,ne(u)];case 1:return t.sent(),[2,u]}}))})))];case 7:if(0===c.sent().length)throw new W((0,p.__)("No smart links were generated.","wp-parsely"),M.ParselySuggestionsApiNoData,"");return we(!0),[3,15];case 8:return r=c.sent(),i=new W(null!==(a=r.message)&&void 0!==a?a:"An unknown error has occurred.",null!==(l=r.code)&&void 0!==l?l:M.UnknownError),r.code&&r.code===M.ParselyAborted&&(i.message=(0,p.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ /* translators: %d: number of retry attempts, %s: attempt plural */ (0,p.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),r.numRetries,(0,p._n)("attempt","attempts",r.numRetries,"wp-parsely"))),console.error(r),[4,te(i)];case 9:return c.sent(),i.createErrorSnackbar(),[3,15];case 10:return[4,ee(!1)];case 11:return c.sent(),[4,de(t)];case 12:return c.sent(),[4,he(!1)];case 13:return c.sent(),[4,Oe(N?"all":null==Pe?void 0:Pe.clientId)];case 14:return c.sent(),clearTimeout(e),[7];case 15:return[2]}var u}))}))},variant:"primary",isBusy:L,disabled:L,children:F?(0,p.sprintf)(/* translators: %1$d: number of retry attempts, %2$d: maximum number of retries */ /* translators: %1$d: number of retry attempts, %2$d: maximum number of retries */ -(0,p.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),V,3):L?(0,p.__)("Generating Smart Links…","wp-parsely"):(0,p.__)("Add Smart Links","wp-parsely")})}),($.length>0||q.length>0)&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return Qe(void 0,void 0,void 0,(function(){var e,t;return Xe(this,(function(n){switch(n.label){case 0:return[4,ue()];case 1:return e=n.sent(),t=oe(),[4,ne(t)];case 2:return n.sent(),we(!0),v.trackEvent("smart_linking_review_pressed",{num_smart_links:G.length,has_fixed_links:e,context:o}),[2]}}))}))},variant:"secondary",disabled:L,children:(0,p.__)("Review Smart Links","wp-parsely")})})]}),E&&(0,i.jsx)(Ye,{isOpen:E,onAppliedLink:function(){b((function(e){return e+1}))},onClose:function(){k(!0),we(!1)}})]})},nt=function(){return nt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0)&&(t(),e())}))}))]}))},new((n=void 0)||(n=Promise))((function(i,s){function a(e){try{l(r.next(e))}catch(e){s(e)}}function o(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,o)}l((r=r.apply(e,t||[])).next())}));var e,t,n,r}().then((function(){var t=document.querySelector(".wp-block-post-content");fe(t,e)}))})))},ht=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M7 11.5h10V13H7z"})}),vt=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})}),gt=function(e){var t=e.title,n=e.icon,r=e.subtitle,a=e.level,o=void 0===a?2:a,l=e.children,c=e.controls,u=e.onClick,d=e.isOpen,f=e.isLoading,h=e.dropdownChildren;return(0,i.jsxs)("div",{className:"performance-stat-panel",children:[(0,i.jsxs)(s.__experimentalHStack,{className:"panel-header level-"+o,children:[(0,i.jsx)(s.__experimentalHeading,{level:o,children:t}),r&&!d&&(0,i.jsx)("span",{className:"panel-subtitle",children:r}),c&&!h&&(0,i.jsx)(s.DropdownMenu,{icon:n,label:(0,p.__)("Settings","wp-parsely"),className:"panel-settings-button",controls:c}),h&&(0,i.jsx)(s.DropdownMenu,{icon:n,label:(0,p.__)("Settings","wp-parsely"),className:"panel-settings-button",children:h}),n&&!h&&!c&&(0,i.jsx)(s.Button,{icon:n,className:"panel-settings-button",isPressed:d,onClick:u})]}),(0,i.jsx)("div",{className:"panel-body",children:f?(0,i.jsx)("div",{className:"parsely-spinner-wrapper","data-testid":"parsely-spinner-wrapper",children:(0,i.jsx)(s.Spinner,{})}):l})]})};function yt(e,t,n){void 0===t&&(t=1),void 0===n&&(n="");var r=parseInt(e.replace(/\D/g,""),10);if(r<1e3)return e;r<1e4&&(t=1);var i=r,s=r.toString(),a="",o=0;return Object.entries({1e3:"k","1,000,000":"M","1,000,000,000":"B","1,000,000,000,000":"T","1,000,000,000,000,000":"Q"}).forEach((function(e){var n=e[0],l=e[1],c=parseInt(n.replace(/\D/g,""),10);if(r>=c){var u=t;(i=r/c)%1>1/o&&(u=i>10?1:2),u=parseFloat(i.toFixed(2))===parseFloat(i.toFixed(0))?0:u,s=i.toFixed(u),a=l}o=c})),s+n+a}var mt=function(e){var n=e.data,r=e.isLoading,a=(0,u.useState)(t.Views),o=a[0],l=a[1],c=(0,u.useState)(!1),d=c[0],f=c[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,p.__)("Social","wp-parsely");case"search":return(0,p.__)("Search","wp-parsely");case"other":return(0,p.__)("Other","wp-parsely");case"internal":return(0,p.__)("Internal","wp-parsely");case"direct":return(0,p.__)("Direct","wp-parsely")}return e},v=(0,p.sprintf)((0,p.__)("By %s","wp-parsely"),N(o)); -/* translators: %s: metric description */return(0,i.jsxs)(gt,{title:(0,p.__)("Categories","wp-parsely"),level:3,subtitle:v,isOpen:d,onClick:function(){return f(!d)},children:[d&&(0,i.jsx)("div",{className:"panel-settings",children:(0,i.jsx)(s.SelectControl,{value:o,prefix:(0,p.__)("By: ","wp-parsely"),onChange:function(e){L(e,t)&&l(e)},children:Object.values(t).map((function(e){return(0,i.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[N(e),"avg_engaged"===e&&(0,p.__)(" (coming soon)","wp-parsely")]},e)}))})}),r?(0,i.jsx)("div",{className:"parsely-spinner-wrapper","data-testid":"parsely-spinner-wrapper",children:(0,i.jsx)(s.Spinner,{})}):(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"multi-percentage-bar",children:Object.entries(n.referrers.types).map((function(e){var t=e[0],n=e[1],r=(0,p.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ /* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ +(0,p.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),V,3):L?(0,p.__)("Generating Smart Links…","wp-parsely"):(0,p.__)("Add Smart Links","wp-parsely")})}),($.length>0||q.length>0)&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return Qe(void 0,void 0,void 0,(function(){var e,t;return Xe(this,(function(n){switch(n.label){case 0:return[4,ue()];case 1:return e=n.sent(),t=oe(),[4,ne(t)];case 2:return n.sent(),we(!0),v.trackEvent("smart_linking_review_pressed",{num_smart_links:G.length,has_fixed_links:e,context:o}),[2]}}))}))},variant:"secondary",disabled:L,children:(0,p.__)("Review Smart Links","wp-parsely")})})]}),E&&(0,i.jsx)(Ye,{isOpen:E,onAppliedLink:function(){b((function(e){return e+1}))},onClose:function(){k(!0),we(!1)}})]})},rt=function(){return rt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0)&&(t(),e())}))}))]}))},new((n=void 0)||(n=Promise))((function(i,s){function a(e){try{l(r.next(e))}catch(e){s(e)}}function o(e){try{l(r.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,o)}l((r=r.apply(e,t||[])).next())}));var e,t,n,r}().then((function(){var t=document.querySelector(".wp-block-post-content");fe(t,e)}))})))},vt=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M7 11.5h10V13H7z"})}),gt=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"})}),yt=function(e){var t=e.title,n=e.icon,r=e.subtitle,a=e.level,o=void 0===a?2:a,l=e.children,c=e.controls,u=e.onClick,d=e.isOpen,f=e.isLoading,h=e.dropdownChildren;return(0,i.jsxs)("div",{className:"performance-stat-panel",children:[(0,i.jsxs)(s.__experimentalHStack,{className:"panel-header level-"+o,children:[(0,i.jsx)(s.__experimentalHeading,{level:o,children:t}),r&&!d&&(0,i.jsx)("span",{className:"panel-subtitle",children:r}),c&&!h&&(0,i.jsx)(s.DropdownMenu,{icon:n,label:(0,p.__)("Settings","wp-parsely"),className:"panel-settings-button",controls:c}),h&&(0,i.jsx)(s.DropdownMenu,{icon:n,label:(0,p.__)("Settings","wp-parsely"),className:"panel-settings-button",children:h}),n&&!h&&!c&&(0,i.jsx)(s.Button,{icon:n,className:"panel-settings-button",isPressed:d,onClick:u})]}),(0,i.jsx)("div",{className:"panel-body",children:f?(0,i.jsx)("div",{className:"parsely-spinner-wrapper","data-testid":"parsely-spinner-wrapper",children:(0,i.jsx)(s.Spinner,{})}):l})]})};function mt(e,t,n){void 0===t&&(t=1),void 0===n&&(n="");var r=parseInt(e.replace(/\D/g,""),10);if(r<1e3)return e;r<1e4&&(t=1);var i=r,s=r.toString(),a="",o=0;return Object.entries({1e3:"k","1,000,000":"M","1,000,000,000":"B","1,000,000,000,000":"T","1,000,000,000,000,000":"Q"}).forEach((function(e){var n=e[0],l=e[1],c=parseInt(n.replace(/\D/g,""),10);if(r>=c){var u=t;(i=r/c)%1>1/o&&(u=i>10?1:2),u=parseFloat(i.toFixed(2))===parseFloat(i.toFixed(0))?0:u,s=i.toFixed(u),a=l}o=c})),s+n+a}var wt=function(e){var n=e.data,r=e.isLoading,a=(0,u.useState)(t.Views),o=a[0],l=a[1],c=(0,u.useState)(!1),d=c[0],f=c[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,p.__)("Social","wp-parsely");case"search":return(0,p.__)("Search","wp-parsely");case"other":return(0,p.__)("Other","wp-parsely");case"internal":return(0,p.__)("Internal","wp-parsely");case"direct":return(0,p.__)("Direct","wp-parsely")}return e},v=(0,p.sprintf)((0,p.__)("By %s","wp-parsely"),N(o)); +/* translators: %s: metric description */return(0,i.jsxs)(yt,{title:(0,p.__)("Categories","wp-parsely"),level:3,subtitle:v,isOpen:d,onClick:function(){return f(!d)},children:[d&&(0,i.jsx)("div",{className:"panel-settings",children:(0,i.jsx)(s.SelectControl,{value:o,prefix:(0,p.__)("By: ","wp-parsely"),onChange:function(e){L(e,t)&&l(e)},children:Object.values(t).map((function(e){return(0,i.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[N(e),"avg_engaged"===e&&(0,p.__)(" (coming soon)","wp-parsely")]},e)}))})}),r?(0,i.jsx)("div",{className:"parsely-spinner-wrapper","data-testid":"parsely-spinner-wrapper",children:(0,i.jsx)(s.Spinner,{})}):(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"multi-percentage-bar",children:Object.entries(n.referrers.types).map((function(e){var t=e[0],n=e[1],r=(0,p.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ /* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ (0,p.__)("%1$s: %2$s%%","wp-parsely"),h(t),n.viewsPercentage);return(0,i.jsx)(s.Tooltip /* translators: %s: percentage value */,{ /* translators: %s: percentage value */ -text:"".concat(h(t)," - ").concat((0,p.sprintf)((0,p.__)("%s%%","wp-parsely"),n.viewsPercentage)),delay:150,children:(0,i.jsx)("div",{"aria-label":r,className:"bar-fill "+t,style:{width:n.viewsPercentage+"%"}})},t)}))}),(0,i.jsx)("div",{className:"percentage-bar-labels",children:Object.entries(n.referrers.types).map((function(e){var t=e[0],n=e[1];return(0,i.jsxs)("div",{className:"single-label "+t,children:[(0,i.jsx)("div",{className:"label-color "+t}),(0,i.jsx)("div",{className:"label-text",children:h(t)}),(0,i.jsx)("div",{className:"label-value",children:yt(n.views)})]},t)}))})]})]})},wt=(0,i.jsx)(d.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(d.Path,{d:"M3.99961 13C4.67043 13.3354 4.6703 13.3357 4.67017 13.3359L4.67298 13.3305C4.67621 13.3242 4.68184 13.3135 4.68988 13.2985C4.70595 13.2686 4.7316 13.2218 4.76695 13.1608C4.8377 13.0385 4.94692 12.8592 5.09541 12.6419C5.39312 12.2062 5.84436 11.624 6.45435 11.0431C7.67308 9.88241 9.49719 8.75 11.9996 8.75C14.502 8.75 16.3261 9.88241 17.5449 11.0431C18.1549 11.624 18.6061 12.2062 18.9038 12.6419C19.0523 12.8592 19.1615 13.0385 19.2323 13.1608C19.2676 13.2218 19.2933 13.2686 19.3093 13.2985C19.3174 13.3135 19.323 13.3242 19.3262 13.3305L19.3291 13.3359C19.3289 13.3357 19.3288 13.3354 19.9996 13C20.6704 12.6646 20.6703 12.6643 20.6701 12.664L20.6697 12.6632L20.6688 12.6614L20.6662 12.6563L20.6583 12.6408C20.6517 12.6282 20.6427 12.6108 20.631 12.5892C20.6078 12.5459 20.5744 12.4852 20.5306 12.4096C20.4432 12.2584 20.3141 12.0471 20.1423 11.7956C19.7994 11.2938 19.2819 10.626 18.5794 9.9569C17.1731 8.61759 14.9972 7.25 11.9996 7.25C9.00203 7.25 6.82614 8.61759 5.41987 9.9569C4.71736 10.626 4.19984 11.2938 3.85694 11.7956C3.68511 12.0471 3.55605 12.2584 3.4686 12.4096C3.42484 12.4852 3.39142 12.5459 3.36818 12.5892C3.35656 12.6108 3.34748 12.6282 3.34092 12.6408L3.33297 12.6563L3.33041 12.6614L3.32948 12.6632L3.32911 12.664C3.32894 12.6643 3.32879 12.6646 3.99961 13ZM11.9996 16C13.9326 16 15.4996 14.433 15.4996 12.5C15.4996 10.567 13.9326 9 11.9996 9C10.0666 9 8.49961 10.567 8.49961 12.5C8.49961 14.433 10.0666 16 11.9996 16Z"})}),bt=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M15.5 9.5a1 1 0 100-2 1 1 0 000 2zm0 1.5a2.5 2.5 0 100-5 2.5 2.5 0 000 5zm-2.25 6v-2a2.75 2.75 0 00-2.75-2.75h-4A2.75 2.75 0 003.75 15v2h1.5v-2c0-.69.56-1.25 1.25-1.25h4c.69 0 1.25.56 1.25 1.25v2h1.5zm7-2v2h-1.5v-2c0-.69-.56-1.25-1.25-1.25H15v-1.5h2.5A2.75 2.75 0 0120.25 15zM9.5 8.5a1 1 0 11-2 0 1 1 0 012 0zm1.5 0a2.5 2.5 0 11-5 0 2.5 2.5 0 015 0z",fillRule:"evenodd"})}),_t=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M12 4V2.2L9 4.8l3 2.5V5.5c3.6 0 6.5 2.9 6.5 6.5 0 2.9-1.9 5.3-4.5 6.2v.2l-.1-.2c-.4.1-.7.2-1.1.2l.2 1.5c.3 0 .6-.1 1-.2 3.5-.9 6-4 6-7.7 0-4.4-3.6-8-8-8zm-7.9 7l1.5.2c.1-1.2.5-2.3 1.2-3.2l-1.1-.9C4.8 8.2 4.3 9.6 4.1 11zm1.5 1.8l-1.5.2c.1.7.3 1.4.5 2 .3.7.6 1.3 1 1.8l1.2-.8c-.3-.5-.6-1-.8-1.5s-.4-1.1-.4-1.7zm1.5 5.5c1.1.9 2.4 1.4 3.8 1.6l.2-1.5c-1.1-.1-2.2-.5-3.1-1.2l-.9 1.1z"})}),xt=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"})}),kt=function(){return kt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]1?[2,Promise.reject(new W((0,p.sprintf)(/* translators: URL of the published post */ /* translators: URL of the published post */ -(0,p.__)("Multiple results were returned for the post %s by the Parse.ly API.","wp-parsely"),t),M.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return It(this,void 0,void 0,(function(){return Bt(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,ke.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",Rt(Rt({},At(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(Se),Dt=function(){return Dt=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&e.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return n.sent(),[4,t(r-1)];case 2:return n.sent(),[3,4];case 3:d(e),o(!1),n.label=4;case 4:return[2]}}))}))})),[2]}))}))};return o(!0),t(1),function(){d(void 0)}}),[n]),(0,i.jsxs)("div",{className:"wp-parsely-performance-panel",children:[(0,i.jsx)(gt,{title:(0,p.__)("Performance Stats","wp-parsely"),icon:vt,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(Ut,{onClose:t})},children:(0,i.jsx)("div",{className:"panel-settings",children:(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:m.PerformanceStats.Period,prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,p.__)("Period: ","wp-parsely")}),onChange:function(t){L(t,e)&&(w({PerformanceStats:Dt(Dt({},m.PerformanceStats),{Period:t})}),v.trackEvent("editor_sidebar_performance_period_changed",{period:t}))},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:E(e)},e)}))})})}),c?c.Message():(0,i.jsxs)(i.Fragment,{children:[zt(m,"overview")&&(0,i.jsx)(Nt,{data:h,isLoading:a}),zt(m,"categories")&&(0,i.jsx)(mt,{data:h,isLoading:a}),zt(m,"referrers")&&(0,i.jsx)(Ct,{data:h,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){v.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,p.__)("View this in Parse.ly","wp-parsely")})]})},Zt=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(G,{children:(0,i.jsx)(qt,{period:t})})})},$t=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Tag,label:(0,p.__)("Tag","wp-parsely")}),a.categories.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Section,label:(0,p.__)("Section","wp-parsely")}),a.authors.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Author,label:(0,p.__)("Author","wp-parsely")})]})})},Kt=function(e){var t=e.filter,n=e.label,a=e.postData,o=$t(e,["filter","label","postData"]);return(0,i.jsx)("div",{className:"related-posts-filter-values",children:(0,i.jsx)(s.ComboboxControl,{__next40pxDefaultSize:!0,allowReset:!0,label:n,onChange:function(e){return o.onFilterValueChange(e)},options:r.Tag===t.type?a.tags.map((function(e){return{value:e,label:e}})):r.Section===t.type?a.categories.map((function(e){return{value:e,label:e}})):r.Author===t.type?a.authors.map((function(e){return{value:e,label:e}})):[],value:t.value})})},Yt=function(e){var t=e.filter,n=e.postData,s=e.label,a=$t(e,["filter","postData","label"]),o=function(){return n.authors.length>0&&n.categories.length>0||n.authors.length>0&&n.tags.length>0||n.tags.length>0&&n.categories.length>0},l=function(){return r.Tag===t.type&&n.tags.length>1||r.Section===t.type&&n.categories.length>1||r.Author===t.type&&n.authors.length>1};return o()||l()?(0,i.jsxs)("div",{className:"related-posts-filter-settings",children:[o()&&(0,i.jsx)(Wt,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(Kt,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},Jt=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z"})}),Qt=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5.625 5.5h9.75c.069 0 .125.056.125.125v9.75a.125.125 0 0 1-.125.125h-9.75a.125.125 0 0 1-.125-.125v-9.75c0-.069.056-.125.125-.125ZM4 5.625C4 4.728 4.728 4 5.625 4h9.75C16.273 4 17 4.728 17 5.625v9.75c0 .898-.727 1.625-1.625 1.625h-9.75A1.625 1.625 0 0 1 4 15.375v-9.75Zm14.5 11.656v-9H20v9C20 18.8 18.77 20 17.251 20H6.25v-1.5h11.001c.69 0 1.249-.528 1.249-1.219Z"})}),Xt=function(){return(0,i.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"1",height:"40",viewBox:"0 0 1 40",fill:"none",children:(0,i.jsx)(s.Rect,{width:"1",height:"40",fill:"#cccccc"})})};function en(e){var t=e.metric,n=e.post,r=e.avgEngagedIcon,s=e.viewsIcon;return"views"===t?(0,i.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,i.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Number of Views","wp-parsely")}),s,yt(n.views.toString())]}):"avg_engaged"===t?(0,i.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,i.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Average Time","wp-parsely")}),r,n.avgEngaged]}):(0,i.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}var tn,nn=function(e){var t,n,r=e.metric,o=e.post,l=e.postContent,c=(0,a.useDispatch)("core/notices").createNotice,u=l&&(t=l,n=I(o.rawUrl),new RegExp("]*href=[\"'](http://|https://)?.*".concat(n,".*[\"'][^>]*>"),"i").test(t));return(0,i.jsxs)("div",{className:"related-post-single","data-testid":"related-post-single",children:[(0,i.jsx)("div",{className:"related-post-title",children:(0,i.jsxs)("a",{href:o.url,target:"_blank",rel:"noreferrer",children:[(0,i.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("View on website (opens new tab)","wp-parsely")}),o.title]})}),(0,i.jsx)("div",{className:"related-post-actions",children:(0,i.jsxs)("div",{className:"related-post-info",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"related-post-metric",children:(0,i.jsx)(en,{metric:r,post:o,viewsIcon:(0,i.jsx)(z,{icon:wt}),avgEngagedIcon:(0,i.jsx)(s.Dashicon,{icon:"clock",size:24})})}),u&&(0,i.jsx)("div",{className:"related-post-linked",children:(0,i.jsx)(s.Tooltip,{text:(0,p.__)("This post is linked in the content","wp-parsely"),children:(0,i.jsx)(z,{icon:Jt,size:24})})})]}),(0,i.jsx)(Xt,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:Qt,iconSize:24,onClick:function(){navigator.clipboard.writeText(o.rawUrl).then((function(){c("success",(0,p.__)("URL copied to clipboard","wp-parsely"),{type:"snackbar"})}))},label:(0,p.__)("Copy URL to clipboard","wp-parsely")}),(0,i.jsx)(s.Button,{icon:(0,i.jsx)(y,{}),iconSize:18,href:o.dashUrl,target:"_blank",label:(0,p.__)("View in Parse.ly","wp-parsely")})]})]})})]})},rn=window.wp.coreData,sn=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function __(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(__.prototype=n.prototype,new __)}}(),an=function(){return an=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&e.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return n.sent(),[4,t(r-1)];case 2:return n.sent(),[3,4];case 3:d(e),o(!1),n.label=4;case 4:return[2]}}))}))})),[2]}))}))};return o(!0),t(1),function(){d(void 0)}}),[n]),(0,i.jsxs)("div",{className:"wp-parsely-performance-panel",children:[(0,i.jsx)(yt,{title:(0,p.__)("Performance Stats","wp-parsely"),icon:gt,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(qt,{onClose:t})},children:(0,i.jsx)("div",{className:"panel-settings",children:(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:m.PerformanceStats.Period,prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,p.__)("Period: ","wp-parsely")}),onChange:function(t){L(t,e)&&(w({PerformanceStats:Ft(Ft({},m.PerformanceStats),{Period:t})}),v.trackEvent("editor_sidebar_performance_period_changed",{period:t}))},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:E(e)},e)}))})})}),c?c.Message():(0,i.jsxs)(i.Fragment,{children:[Ut(m,"overview")&&(0,i.jsx)(Ct,{data:h,isLoading:a}),Ut(m,"categories")&&(0,i.jsx)(wt,{data:h,isLoading:a}),Ut(m,"referrers")&&(0,i.jsx)(At,{data:h,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){v.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,p.__)("View this in Parse.ly","wp-parsely")})]})},$t=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(G,{children:(0,i.jsx)(Zt,{period:t})})})},Wt=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Tag,label:(0,p.__)("Tag","wp-parsely")}),a.categories.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Section,label:(0,p.__)("Section","wp-parsely")}),a.authors.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Author,label:(0,p.__)("Author","wp-parsely")})]})})},Yt=function(e){var t=e.filter,n=e.label,a=e.postData,o=Wt(e,["filter","label","postData"]);return(0,i.jsx)("div",{className:"related-posts-filter-values",children:(0,i.jsx)(s.ComboboxControl,{__next40pxDefaultSize:!0,allowReset:!0,label:n,onChange:function(e){return o.onFilterValueChange(e)},options:r.Tag===t.type?a.tags.map((function(e){return{value:e,label:e}})):r.Section===t.type?a.categories.map((function(e){return{value:e,label:e}})):r.Author===t.type?a.authors.map((function(e){return{value:e,label:e}})):[],value:t.value})})},Jt=function(e){var t=e.filter,n=e.postData,s=e.label,a=Wt(e,["filter","postData","label"]),o=function(){return n.authors.length>0&&n.categories.length>0||n.authors.length>0&&n.tags.length>0||n.tags.length>0&&n.categories.length>0},l=function(){return r.Tag===t.type&&n.tags.length>1||r.Section===t.type&&n.categories.length>1||r.Author===t.type&&n.authors.length>1};return o()||l()?(0,i.jsxs)("div",{className:"related-posts-filter-settings",children:[o()&&(0,i.jsx)(Kt,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(Yt,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},Qt=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M10 17.389H8.444A5.194 5.194 0 1 1 8.444 7H10v1.5H8.444a3.694 3.694 0 0 0 0 7.389H10v1.5ZM14 7h1.556a5.194 5.194 0 0 1 0 10.39H14v-1.5h1.556a3.694 3.694 0 0 0 0-7.39H14V7Zm-4.5 6h5v-1.5h-5V13Z"})}),Xt=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M5.625 5.5h9.75c.069 0 .125.056.125.125v9.75a.125.125 0 0 1-.125.125h-9.75a.125.125 0 0 1-.125-.125v-9.75c0-.069.056-.125.125-.125ZM4 5.625C4 4.728 4.728 4 5.625 4h9.75C16.273 4 17 4.728 17 5.625v9.75c0 .898-.727 1.625-1.625 1.625h-9.75A1.625 1.625 0 0 1 4 15.375v-9.75Zm14.5 11.656v-9H20v9C20 18.8 18.77 20 17.251 20H6.25v-1.5h11.001c.69 0 1.249-.528 1.249-1.219Z"})}),en=function(){return(0,i.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"1",height:"40",viewBox:"0 0 1 40",fill:"none",children:(0,i.jsx)(s.Rect,{width:"1",height:"40",fill:"#cccccc"})})};function tn(e){var t=e.metric,n=e.post,r=e.avgEngagedIcon,s=e.viewsIcon;return"views"===t?(0,i.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,i.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Number of Views","wp-parsely")}),s,mt(n.views.toString())]}):"avg_engaged"===t?(0,i.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,i.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("Average Time","wp-parsely")}),r,n.avgEngaged]}):(0,i.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}var nn,rn=function(e){var t,n,r=e.metric,o=e.post,l=e.postContent,c=(0,a.useDispatch)("core/notices").createNotice,u=l&&(t=l,n=I(o.rawUrl),new RegExp("]*href=[\"'](http://|https://)?.*".concat(n,".*[\"'][^>]*>"),"i").test(t));return(0,i.jsxs)("div",{className:"related-post-single","data-testid":"related-post-single",children:[(0,i.jsx)("div",{className:"related-post-title",children:(0,i.jsxs)("a",{href:o.url,target:"_blank",rel:"noreferrer",children:[(0,i.jsx)("span",{className:"screen-reader-text",children:(0,p.__)("View on website (opens new tab)","wp-parsely")}),o.title]})}),(0,i.jsx)("div",{className:"related-post-actions",children:(0,i.jsxs)("div",{className:"related-post-info",children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:"related-post-metric",children:(0,i.jsx)(tn,{metric:r,post:o,viewsIcon:(0,i.jsx)(z,{icon:bt}),avgEngagedIcon:(0,i.jsx)(s.Dashicon,{icon:"clock",size:24})})}),u&&(0,i.jsx)("div",{className:"related-post-linked",children:(0,i.jsx)(s.Tooltip,{text:(0,p.__)("This post is linked in the content","wp-parsely"),children:(0,i.jsx)(z,{icon:Qt,size:24})})})]}),(0,i.jsx)(en,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:Xt,iconSize:24,onClick:function(){navigator.clipboard.writeText(o.rawUrl).then((function(){c("success",(0,p.__)("URL copied to clipboard","wp-parsely"),{type:"snackbar"})}))},label:(0,p.__)("Copy URL to clipboard","wp-parsely")}),(0,i.jsx)(s.Button,{icon:(0,i.jsx)(y,{}),iconSize:18,href:o.dashUrl,target:"_blank",label:(0,p.__)("View in Parse.ly","wp-parsely")})]})]})})]})},sn=window.wp.coreData,an=function(){var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)};return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function __(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(__.prototype=n.prototype,new __)}}(),on=function(){return on=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&f.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:f,context:"view"}))&&void 0!==n?n:void 0:null,tagRecords:a=Array.isArray(h)&&h.length>0&&h.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:h,context:"view"}))&&void 0!==r?r:void 0:null,isLoading:u("getEntityRecords",["root","user",{include:[d],context:"view"}])||u("getEntityRecords",["taxonomy","category",{include:f,context:"view"}])||u("getEntityRecords",["taxonomy","post_tag",{include:h,context:"view"}]),hasResolved:(c("getEntityRecords",["root","user",{include:[d],context:"view"}])||null===i)&&(c("getEntityRecords",["taxonomy","category",{include:f,context:"view"}])||null===s)&&(c("getEntityRecords",["taxonomy","post_tag",{include:h,context:"view"}])||null===a)}}),[]);return(0,u.useEffect)((function(){var e=r.authorRecords,t=r.categoryRecords,i=r.tagRecords,s=r.isLoading;r.hasResolved&&!s&&n({authors:e,categories:t,tags:i,isReady:!0})}),[r]),t}(),m=y.authors,w=y.categories,b=y.tags,_=y.isReady;(0,u.useEffect)((function(){if(_){var e=function(e){return function(e){return!(!Array.isArray(e)||0===e.length)&&e.every((function(e){return"name"in e&&"id"in e&&"slug"in e&&"description"in e&&"link"in e}))}(e)?e.map((function(e){return e.name})):[]};g({authors:e(m),categories:e(w),tags:e(b)})}}),[m,w,b,_]);var x=(0,u.useState)(!0),k=x[0],S=x[1],P=(0,u.useState)(),T=P[0],C=P[1],A=(0,u.useState)(),R=A[0],I=A[1],B=(0,u.useState)([]),M=B[0],D=B[1],F=(0,u.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),V=F[0],G=F[1],H=(0,u.useState)(void 0),z=H[0],U=H[1],q=(0,O.useDebounce)(U,1e3);(0,a.useSelect)((function(e){if("undefined"==typeof jest){var t=e("core/editor").getEditedPostContent;q(t())}else q("Jest test is running")}),[q]);var Z=function(e,t){l({RelatedPosts:un(un({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,u.useEffect)((function(){var e,t,n=function(e){return pn(void 0,void 0,void 0,(function(){return dn(this,(function(t){return cn.getInstance().getRelatedPosts(c,d,V).then((function(e){D(e.posts),I(e.message),S(!1)})).catch((function(t){return pn(void 0,void 0,void 0,(function(){return dn(this,(function(r){switch(r.label){case 0:return e>0&&t.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return r.sent(),[4,n(e-1)];case 2:return r.sent(),[3,4];case 3:S(!1),C(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===V.type,s=r.Tag===V.type,a=r.Section===V.type,o=r.Unavailable===V.type,l=0===h.authors.length,u=0===h.tags.length,p=0===h.categories.length,f=i&&!h.authors.includes(V.value),v=s&&!h.tags.includes(V.value),g=a&&!h.categories.includes(V.value);return S(!0),o||s&&u||a&&p||i&&l?Object.values(h).every((function(e){return 0===e.length}))||G((e="",t=r.Unavailable,h.tags.length>=1?(t=r.Tag,e=h.tags[0]):h.categories.length>=1?(t=r.Section,e=h.categories[0]):h.authors.length>=1&&(t=r.Author,e=h.authors[0]),{type:t,value:e})):v?G({type:r.Tag,value:h.tags[0]}):g?G({type:r.Section,value:h.categories[0]}):f?G({type:r.Author,value:h.authors[0]}):n(1),function(){S(!1),D([]),I(""),C(void 0)}}),[c,d,V,h]),0===h.authors.length&&0===h.categories.length&&0===h.tags.length&&_?(0,i.jsx)("div",{className:"wp-parsely-related-posts",children:(0,i.jsx)("div",{className:"related-posts-body",children:(0,p.__)("Error: No author, section, or tags could be found for this post.","wp-parsely")})}):(0,i.jsxs)("div",{className:"wp-parsely-related-posts",children:[(0,i.jsx)("div",{className:"related-posts-description",children:(0,p.__)("Find top-performing related posts based on a key metric.","wp-parsely")}),(0,i.jsxs)("div",{className:"related-posts-body",children:[(0,i.jsxs)("div",{className:"related-posts-settings",children:[(0,i.jsx)(s.SelectControl,{size:"__unstable-large",onChange:function(e){var n;L(n=e,t)&&(l({RelatedPosts:un(un({},o.RelatedPosts),{Metric:n})}),v.trackEvent("related_posts_metric_changed",{metric:n}))},prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,p.__)("Metric: ","wp-parsely")}),value:d,children:Object.values(t).map((function(e){return(0,i.jsx)("option",{value:e,children:N(e)},e)}))}),(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:c,prefix:(0,i.jsxs)(s.__experimentalInputControlPrefixWrapper,{children:[(0,p.__)("Period: ","wp-parsely")," "]}),onChange:function(t){return function(t){L(t,e)&&(l({RelatedPosts:un(un({},o.RelatedPosts),{Period:t})}),v.trackEvent("related_posts_period_changed",{period:t}))}(t)},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:E(e)},e)}))})]}),(0,i.jsx)(Yt,{label:(0,p.__)("Filter by","wp-parsely"),filter:V,onFilterTypeChange:function(e){if(L(e,r)){var t="",n=e;r.Tag===n&&(t=h.tags[0]),r.Section===n&&(t=h.categories[0]),r.Author===n&&(t=h.authors[0]),""!==t&&(Z(n,t),G({type:n,value:t}),v.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(V.type,e),G(un(un({},V),{value:e})))},postData:h}),(0,i.jsxs)("div",{className:"related-posts-wrapper",children:[(0,i.jsx)("div",{children:(0,i.jsx)("p",{className:"related-posts-descr","data-testid":"parsely-related-posts-descr",children:r.Tag===V.type?(0,p.sprintf)(/* translators: 1: tag name, 2: period */ /* translators: 1: tag name, 2: period */ +message:(0,p.sprintf)((0,p.__)('by author "%1$s"',"wp-parsely"),n.value)};throw new W((0,p.__)("No valid filter type has been specified.","wp-parsely"),M.CannotFormulateApiQuery)},t}(Se),pn=function(){return pn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&f.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:f,context:"view"}))&&void 0!==n?n:void 0:null,tagRecords:a=Array.isArray(h)&&h.length>0&&h.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:h,context:"view"}))&&void 0!==r?r:void 0:null,isLoading:u("getEntityRecords",["root","user",{include:[d],context:"view"}])||u("getEntityRecords",["taxonomy","category",{include:f,context:"view"}])||u("getEntityRecords",["taxonomy","post_tag",{include:h,context:"view"}]),hasResolved:(c("getEntityRecords",["root","user",{include:[d],context:"view"}])||null===i)&&(c("getEntityRecords",["taxonomy","category",{include:f,context:"view"}])||null===s)&&(c("getEntityRecords",["taxonomy","post_tag",{include:h,context:"view"}])||null===a)}}),[]);return(0,u.useEffect)((function(){var e=r.authorRecords,t=r.categoryRecords,i=r.tagRecords,s=r.isLoading;r.hasResolved&&!s&&n({authors:e,categories:t,tags:i,isReady:!0})}),[r]),t}(),m=y.authors,w=y.categories,b=y.tags,_=y.isReady;(0,u.useEffect)((function(){if(_){var e=function(e){return function(e){return!(!Array.isArray(e)||0===e.length)&&e.every((function(e){return"name"in e&&"id"in e&&"slug"in e&&"description"in e&&"link"in e}))}(e)?e.map((function(e){return e.name})):[]};g({authors:e(m),categories:e(w),tags:e(b)})}}),[m,w,b,_]);var x=(0,u.useState)(!0),k=x[0],S=x[1],P=(0,u.useState)(),T=P[0],C=P[1],A=(0,u.useState)(),R=A[0],I=A[1],B=(0,u.useState)([]),M=B[0],D=B[1],F=(0,u.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),V=F[0],G=F[1],H=(0,u.useState)(void 0),z=H[0],U=H[1],q=(0,O.useDebounce)(U,1e3);(0,a.useSelect)((function(e){if("undefined"==typeof jest){var t=e("core/editor").getEditedPostContent;q(t())}else q("Jest test is running")}),[q]);var Z=function(e,t){l({RelatedPosts:pn(pn({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,u.useEffect)((function(){var e,t,n=function(e){return dn(void 0,void 0,void 0,(function(){return fn(this,(function(t){return un.getInstance().getRelatedPosts(c,d,V).then((function(e){D(e.posts),I(e.message),S(!1)})).catch((function(t){return dn(void 0,void 0,void 0,(function(){return fn(this,(function(r){switch(r.label){case 0:return e>0&&t.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return r.sent(),[4,n(e-1)];case 2:return r.sent(),[3,4];case 3:S(!1),C(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===V.type,s=r.Tag===V.type,a=r.Section===V.type,o=r.Unavailable===V.type,l=0===h.authors.length,u=0===h.tags.length,p=0===h.categories.length,f=i&&!h.authors.includes(V.value),v=s&&!h.tags.includes(V.value),g=a&&!h.categories.includes(V.value);return S(!0),o||s&&u||a&&p||i&&l?Object.values(h).every((function(e){return 0===e.length}))||G((e="",t=r.Unavailable,h.tags.length>=1?(t=r.Tag,e=h.tags[0]):h.categories.length>=1?(t=r.Section,e=h.categories[0]):h.authors.length>=1&&(t=r.Author,e=h.authors[0]),{type:t,value:e})):v?G({type:r.Tag,value:h.tags[0]}):g?G({type:r.Section,value:h.categories[0]}):f?G({type:r.Author,value:h.authors[0]}):n(1),function(){S(!1),D([]),I(""),C(void 0)}}),[c,d,V,h]),0===h.authors.length&&0===h.categories.length&&0===h.tags.length&&_?(0,i.jsx)("div",{className:"wp-parsely-related-posts",children:(0,i.jsx)("div",{className:"related-posts-body",children:(0,p.__)("Error: No author, section, or tags could be found for this post.","wp-parsely")})}):(0,i.jsxs)("div",{className:"wp-parsely-related-posts",children:[(0,i.jsx)("div",{className:"related-posts-description",children:(0,p.__)("Find top-performing related posts based on a key metric.","wp-parsely")}),(0,i.jsxs)("div",{className:"related-posts-body",children:[(0,i.jsxs)("div",{className:"related-posts-settings",children:[(0,i.jsx)(s.SelectControl,{size:"__unstable-large",onChange:function(e){var n;L(n=e,t)&&(l({RelatedPosts:pn(pn({},o.RelatedPosts),{Metric:n})}),v.trackEvent("related_posts_metric_changed",{metric:n}))},prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,p.__)("Metric: ","wp-parsely")}),value:d,children:Object.values(t).map((function(e){return(0,i.jsx)("option",{value:e,children:N(e)},e)}))}),(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:c,prefix:(0,i.jsxs)(s.__experimentalInputControlPrefixWrapper,{children:[(0,p.__)("Period: ","wp-parsely")," "]}),onChange:function(t){return function(t){L(t,e)&&(l({RelatedPosts:pn(pn({},o.RelatedPosts),{Period:t})}),v.trackEvent("related_posts_period_changed",{period:t}))}(t)},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:E(e)},e)}))})]}),(0,i.jsx)(Jt,{label:(0,p.__)("Filter by","wp-parsely"),filter:V,onFilterTypeChange:function(e){if(L(e,r)){var t="",n=e;r.Tag===n&&(t=h.tags[0]),r.Section===n&&(t=h.categories[0]),r.Author===n&&(t=h.authors[0]),""!==t&&(Z(n,t),G({type:n,value:t}),v.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(V.type,e),G(pn(pn({},V),{value:e})))},postData:h}),(0,i.jsxs)("div",{className:"related-posts-wrapper",children:[(0,i.jsx)("div",{children:(0,i.jsx)("p",{className:"related-posts-descr","data-testid":"parsely-related-posts-descr",children:r.Tag===V.type?(0,p.sprintf)(/* translators: 1: tag name, 2: period */ /* translators: 1: tag name, 2: period */ (0,p.__)("Top related posts with the “%1$s” tag in the %2$s.","wp-parsely"),V.value,E(c,!0)):r.Section===V.type?(0,p.sprintf)(/* translators: 1: section name, 2: period */ /* translators: 1: section name, 2: period */ (0,p.__)("Top related posts in the “%1$s” section in the %2$s.","wp-parsely"),V.value,E(c,!0)):r.Author===V.type?(0,p.sprintf)(/* translators: 1: author name, 2: period */ /* translators: 1: author name, 2: period */ -(0,p.__)("Top related posts by %1$s in the %2$s.","wp-parsely"),V.value,E(c,!0)):null!=R?R:""})}),T&&T.Message(),k&&(0,i.jsx)("div",{className:"related-posts-loading-message","data-testid":"parsely-related-posts-loading-message",children:(0,p.__)("Loading…","wp-parsely")}),!k&&!T&&0===M.length&&(0,i.jsx)("div",{className:"related-posts-empty","data-testid":"parsely-related-posts-empty",children:(0,p.__)("No related posts found.","wp-parsely")}),!k&&M.length>0&&(0,i.jsx)("div",{className:"related-posts-list",children:M.map((function(e){return(0,i.jsx)(nn,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},hn=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})}),vn=function(){return(0,i.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:(0,i.jsx)(s.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"})})},gn={journalist:{label:(0,p.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,p.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,p.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,p.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,p.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,p.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,p.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,p.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,p.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,p.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,p.__)("Custom Persona","wp-parsely"),icon:hn}},yn=Object.keys(gn),mn=function(e){return"custom"===e||""===e?gn.custom.label:wn(e)?e:gn[e].label},wn=function(e){return!yn.includes(e)||"custom"===e},bn=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,O.useDebounce)(n,500);return(0,i.jsx)("div",{className:"parsely-persona-selector-custom",children:(0,i.jsx)(s.TextControl,{value:a||t,placeholder:(0,p.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),l(e),o(e)}})})},xn=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,p.__)("Select a persona…","wp-parsely"):n,a=e.label,o=void 0===a?(0,p.__)("Persona","wp-parsely"):a,l=e.onChange,c=e.onDropdownChange,u=e.disabled,d=void 0!==u&&u,f=e.allowCustom,h=void 0!==f&&f;return(0,i.jsxs)(s.Disabled,{isDisabled:d,children:[o&&(0,i.jsx)("div",{className:"wp-parsely-dropdown-label",children:o}),(0,i.jsx)(s.DropdownMenu,{label:(0,p.__)("Persona","wp-parsely"),className:"parsely-persona-selector-dropdown"+(d?" is-disabled":""),popoverProps:{className:"wp-parsely-popover"},toggleProps:{children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"parsely-persona-selector-label",children:wn(t)?gn.custom.label:r}),(0,i.jsx)(vn,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,p.__)("Persona","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:yn.map((function(e){if(!h&&"custom"===e)return null;var r=gn[e],a=e===t||wn(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==c||c(e),l(e),n(),"custom"===e&&setTimeout((function(){var e=document.querySelector(".parsely-persona-selector-custom input");e&&e.focus()}),0)},children:[r.icon&&(0,i.jsx)(z,{icon:r.icon}),r.label]},e)}))})})}}),h&&wn(t)&&(0,i.jsx)(bn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},kn={neutral:{label:(0,p.__)("Neutral","wp-parsely")},formal:{label:(0,p.__)("Formal","wp-parsely")},humorous:{label:(0,p.__)("Humorous","wp-parsely")},confident:{label:(0,p.__)("Confident","wp-parsely")},provocative:{label:(0,p.__)("Provocative","wp-parsely")},serious:{label:(0,p.__)("Serious","wp-parsely")},inspirational:{label:(0,p.__)("Inspirational","wp-parsely")},skeptical:{label:(0,p.__)("Skeptical","wp-parsely")},conversational:{label:(0,p.__)("Conversational","wp-parsely")},analytical:{label:(0,p.__)("Analytical","wp-parsely")},custom:{label:(0,p.__)("Custom Tone","wp-parsely"),icon:hn}},Sn=Object.keys(kn),Pn=function(e){return"custom"===e||""===e?kn.custom.label:jn(e)?e:kn[e].label},jn=function(e){return!Sn.includes(e)||"custom"===e},Tn=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,O.useDebounce)(n,500);return(0,i.jsx)("div",{className:"parsely-tone-selector-custom",children:(0,i.jsx)(s.TextControl,{value:a||t,placeholder:(0,p.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),l(e),o(e)}})})},Ln=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,p.__)("Select a tone","wp-parsely"):n,a=e.label,o=void 0===a?(0,p.__)("Tone","wp-parsely"):a,l=e.onChange,c=e.onDropdownChange,u=e.disabled,d=void 0!==u&&u,f=e.allowCustom,h=void 0!==f&&f;return(0,i.jsxs)(s.Disabled,{isDisabled:d,children:[(0,i.jsx)("div",{className:"wp-parsely-dropdown-label",children:o}),(0,i.jsx)(s.DropdownMenu,{label:(0,p.__)("Tone","wp-parsely"),className:"parsely-tone-selector-dropdown"+(d?" is-disabled":""),popoverProps:{className:"wp-parsely-popover"},toggleProps:{children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"parsely-tone-selector-label",children:jn(t)?kn.custom.label:r}),(0,i.jsx)(vn,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,p.__)("Select a tone","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Sn.map((function(e){if(!h&&"custom"===e)return null;var r=kn[e],a=e===t||jn(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==c||c(e),l(e),n(),"custom"===e&&setTimeout((function(){var e=document.querySelector(".parsely-tone-selector-custom input");e&&e.focus()}),0)},children:[r.icon&&(0,i.jsx)(z,{icon:r.icon}),r.label]},e)}))})})}}),h&&jn(t)&&(0,i.jsx)(Tn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},En=(0,i.jsx)(d.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(d.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"})}),Nn=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.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"})}),Cn=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.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"})}),An=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.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"})}),On=function(){return On=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0?(0,i.jsx)("span",{className:"parsely-write-titles-text",children:(0,u.createInterpolateElement)( +(0,p.__)("Top related posts by %1$s in the %2$s.","wp-parsely"),V.value,E(c,!0)):null!=R?R:""})}),T&&T.Message(),k&&(0,i.jsx)("div",{className:"related-posts-loading-message","data-testid":"parsely-related-posts-loading-message",children:(0,p.__)("Loading…","wp-parsely")}),!k&&!T&&0===M.length&&(0,i.jsx)("div",{className:"related-posts-empty","data-testid":"parsely-related-posts-empty",children:(0,p.__)("No related posts found.","wp-parsely")}),!k&&M.length>0&&(0,i.jsx)("div",{className:"related-posts-list",children:M.map((function(e){return(0,i.jsx)(rn,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},vn=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})}),gn=function(){return(0,i.jsx)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",width:"18",height:"18",viewBox:"0 0 18 18",fill:"none",children:(0,i.jsx)(s.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"})})},yn={journalist:{label:(0,p.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,p.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,p.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,p.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,p.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,p.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,p.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,p.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,p.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,p.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,p.__)("Custom Persona","wp-parsely"),icon:vn}},mn=Object.keys(yn),wn=function(e){return"custom"===e||""===e?yn.custom.label:bn(e)?e:yn[e].label},bn=function(e){return!mn.includes(e)||"custom"===e},xn=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,O.useDebounce)(n,500);return(0,i.jsx)("div",{className:"parsely-persona-selector-custom",children:(0,i.jsx)(s.TextControl,{value:a||t,placeholder:(0,p.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),l(e),o(e)}})})},kn=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,p.__)("Select a persona…","wp-parsely"):n,a=e.label,o=void 0===a?(0,p.__)("Persona","wp-parsely"):a,l=e.onChange,c=e.onDropdownChange,u=e.disabled,d=void 0!==u&&u,f=e.allowCustom,h=void 0!==f&&f;return(0,i.jsxs)(s.Disabled,{isDisabled:d,children:[o&&(0,i.jsx)("div",{className:"wp-parsely-dropdown-label",children:o}),(0,i.jsx)(s.DropdownMenu,{label:(0,p.__)("Persona","wp-parsely"),className:"parsely-persona-selector-dropdown"+(d?" is-disabled":""),popoverProps:{className:"wp-parsely-popover"},toggleProps:{children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"parsely-persona-selector-label",children:bn(t)?yn.custom.label:r}),(0,i.jsx)(gn,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,p.__)("Persona","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:mn.map((function(e){if(!h&&"custom"===e)return null;var r=yn[e],a=e===t||bn(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==c||c(e),l(e),n(),"custom"===e&&setTimeout((function(){var e=document.querySelector(".parsely-persona-selector-custom input");e&&e.focus()}),0)},children:[r.icon&&(0,i.jsx)(z,{icon:r.icon}),r.label]},e)}))})})}}),h&&bn(t)&&(0,i.jsx)(xn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},Sn={neutral:{label:(0,p.__)("Neutral","wp-parsely")},formal:{label:(0,p.__)("Formal","wp-parsely")},humorous:{label:(0,p.__)("Humorous","wp-parsely")},confident:{label:(0,p.__)("Confident","wp-parsely")},provocative:{label:(0,p.__)("Provocative","wp-parsely")},serious:{label:(0,p.__)("Serious","wp-parsely")},inspirational:{label:(0,p.__)("Inspirational","wp-parsely")},skeptical:{label:(0,p.__)("Skeptical","wp-parsely")},conversational:{label:(0,p.__)("Conversational","wp-parsely")},analytical:{label:(0,p.__)("Analytical","wp-parsely")},custom:{label:(0,p.__)("Custom Tone","wp-parsely"),icon:vn}},Pn=Object.keys(Sn),jn=function(e){return"custom"===e||""===e?Sn.custom.label:Tn(e)?e:Sn[e].label},Tn=function(e){return!Pn.includes(e)||"custom"===e},Ln=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,O.useDebounce)(n,500);return(0,i.jsx)("div",{className:"parsely-tone-selector-custom",children:(0,i.jsx)(s.TextControl,{value:a||t,placeholder:(0,p.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),l(e),o(e)}})})},En=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,p.__)("Select a tone","wp-parsely"):n,a=e.label,o=void 0===a?(0,p.__)("Tone","wp-parsely"):a,l=e.onChange,c=e.onDropdownChange,u=e.disabled,d=void 0!==u&&u,f=e.allowCustom,h=void 0!==f&&f;return(0,i.jsxs)(s.Disabled,{isDisabled:d,children:[(0,i.jsx)("div",{className:"wp-parsely-dropdown-label",children:o}),(0,i.jsx)(s.DropdownMenu,{label:(0,p.__)("Tone","wp-parsely"),className:"parsely-tone-selector-dropdown"+(d?" is-disabled":""),popoverProps:{className:"wp-parsely-popover"},toggleProps:{children:(0,i.jsxs)(i.Fragment,{children:[(0,i.jsx)("div",{className:"parsely-tone-selector-label",children:Tn(t)?Sn.custom.label:r}),(0,i.jsx)(gn,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,p.__)("Select a tone","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Pn.map((function(e){if(!h&&"custom"===e)return null;var r=Sn[e],a=e===t||Tn(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==c||c(e),l(e),n(),"custom"===e&&setTimeout((function(){var e=document.querySelector(".parsely-tone-selector-custom input");e&&e.focus()}),0)},children:[r.icon&&(0,i.jsx)(z,{icon:r.icon}),r.label]},e)}))})})}}),h&&Tn(t)&&(0,i.jsx)(Ln,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},Nn=(0,i.jsx)(d.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(d.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"})}),Cn=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.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"})}),An=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.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"})}),On=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.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"})}),Rn=function(){return Rn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0?(0,i.jsx)("span",{className:"parsely-write-titles-text",children:(0,u.createInterpolateElement)( // translators: %1$s is the tone, %2$s is the persona. // translators: %1$s is the tone, %2$s is the persona. -(0,p.__)("We've generated a few titles based on the content of your post, written as a .","wp-parsely"),{tone:(0,i.jsx)("strong",{children:Pn(d)}),persona:(0,i.jsx)("strong",{children:mn(g)})})}):(0,p.__)("Use Parse.ly AI to generate a title for your post.","wp-parsely"),(0,i.jsxs)(s.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-title-suggestions-beta",target:"_blank",variant:"link",children:[(0,p.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(z,{icon:U,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{className:"wp-parsely-content-helper-error",onRemove:function(){return l(void 0)},status:"info",children:o.Message()}),void 0!==S&&(0,i.jsx)(Vn,{title:S,type:tn.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(Gn,{pinnedTitles:_,isOpen:!0}),b.length>0&&(0,i.jsx)(zn,{suggestions:b,isOpen:!0,isLoading:w})]}),(0,i.jsx)(Hn,{isLoading:w,onPersonaChange:function(e){A("Persona",e),y(e)},onSettingChange:A,onToneChange:function(e){A("Tone",e),f(e)},persona:t.TitleSuggestions.Persona,tone:t.TitleSuggestions.Tone}),(0,i.jsx)("div",{className:"title-suggestions-generate",children:(0,i.jsxs)(s.Button,{variant:"primary",isBusy:w,disabled:w||"custom"===d||"custom"===g,onClick:function(){return $n(void 0,void 0,void 0,(function(){return Wn(this,(function(e){switch(e.label){case 0:return l(void 0),!1!==w?[3,2]:(v.trackEvent("title_suggestions_generate_pressed",{request_more:b.length>0,total_titles:b.length,total_pinned:b.filter((function(e){return e.isPinned})).length,tone:d,persona:g}),[4,(t=tn.PostTitle,n=O,r=d,i=g,$n(void 0,void 0,void 0,(function(){var e,s,a;return Wn(this,(function(o){switch(o.label){case 0:return[4,L(!0)];case 1:o.sent(),e=qn.getInstance(),o.label=2;case 2:return o.trys.push([2,5,,6]),[4,e.generateTitles(n,3,r,i)];case 3:return s=o.sent(),[4,T(t,s)];case 4:return o.sent(),[3,6];case 5:return a=o.sent(),l(a),T(t,[]),[3,6];case 6:return[4,L(!1)];case 7:return o.sent(),[2]}}))})))]);case 1:e.sent(),e.label=2;case 2:return[2]}var t,n,r,i}))}))},children:[w&&(0,p.__)("Generating Titles…","wp-parsely"),!w&&x.length>0&&(0,p.__)("Generate More","wp-parsely"),!w&&0===x.length&&(0,p.__)("Generate Titles","wp-parsely")]})})]})})},Yn=function(){return Yn=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,i.jsx)("strong",{children:jn(d)}),persona:(0,i.jsx)("strong",{children:wn(g)})})}):(0,p.__)("Use Parse.ly AI to generate a title for your post.","wp-parsely"),(0,i.jsxs)(s.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-title-suggestions-beta",target:"_blank",variant:"link",children:[(0,p.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(z,{icon:U,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{className:"wp-parsely-content-helper-error",onRemove:function(){return l(void 0)},status:"info",children:o.Message()}),void 0!==S&&(0,i.jsx)(Gn,{title:S,type:nn.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(Hn,{pinnedTitles:_,isOpen:!0}),b.length>0&&(0,i.jsx)(Un,{suggestions:b,isOpen:!0,isLoading:w})]}),(0,i.jsx)(zn,{isLoading:w,onPersonaChange:function(e){A("Persona",e),y(e)},onSettingChange:A,onToneChange:function(e){A("Tone",e),f(e)},persona:t.TitleSuggestions.Persona,tone:t.TitleSuggestions.Tone}),(0,i.jsx)("div",{className:"title-suggestions-generate",children:(0,i.jsxs)(s.Button,{variant:"primary",isBusy:w,disabled:w||"custom"===d||"custom"===g,onClick:function(){return Wn(void 0,void 0,void 0,(function(){return Kn(this,(function(e){switch(e.label){case 0:return l(void 0),!1!==w?[3,2]:(v.trackEvent("title_suggestions_generate_pressed",{request_more:b.length>0,total_titles:b.length,total_pinned:b.filter((function(e){return e.isPinned})).length,tone:d,persona:g}),[4,(t=nn.PostTitle,n=O,r=d,i=g,Wn(void 0,void 0,void 0,(function(){var e,s,a;return Kn(this,(function(o){switch(o.label){case 0:return[4,L(!0)];case 1:o.sent(),e=Zn.getInstance(),o.label=2;case 2:return o.trys.push([2,5,,6]),[4,e.generateTitles(n,3,r,i)];case 3:return s=o.sent(),[4,T(t,s)];case 4:return o.sent(),[3,6];case 5:return a=o.sent(),l(a),T(t,[]),[3,6];case 6:return[4,L(!1)];case 7:return o.sent(),[2]}}))})))]);case 1:e.sent(),e.label=2;case 2:return[2]}var t,n,r,i}))}))},children:[w&&(0,p.__)("Generating Titles…","wp-parsely"),!w&&x.length>0&&(0,p.__)("Generate More","wp-parsely"),!w&&0===x.length&&(0,p.__)("Generate Titles","wp-parsely")]})})]})})},Jn=function(){return Jn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n Date: Thu, 8 Aug 2024 10:12:45 +0100 Subject: [PATCH 2/5] Fix PHPStan warning --- src/Endpoints/class-base-api-proxy.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Endpoints/class-base-api-proxy.php b/src/Endpoints/class-base-api-proxy.php index 7faaac4f3..1c144010f 100644 --- a/src/Endpoints/class-base-api-proxy.php +++ b/src/Endpoints/class-base-api-proxy.php @@ -155,7 +155,7 @@ protected function get_data( WP_REST_Request $request, bool $require_api_secret } // A proxy with caching behavior is used here. - $response = $this->api->get_items( $params ); // @phpstan-ignore-line. + $response = $this->api->get_items( $params ); if ( is_wp_error( $response ) ) { return $response; From b28da7a022b97e09e33231ac3868331cc9996075 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 8 Aug 2024 10:16:29 +0100 Subject: [PATCH 3/5] Update wp-parsely version number to 3.16.3 --- README.md | 2 +- package-lock.json | 4 ++-- package.json | 2 +- tests/e2e/utils.ts | 2 +- wp-parsely.php | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 714d890ec..5b99ddf9d 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Parse.ly -Stable tag: 3.16.2 +Stable tag: 3.16.3 Requires at least: 5.2 Tested up to: 6.5 Requires PHP: 7.2 diff --git a/package-lock.json b/package-lock.json index 466a57c3d..d3a0e26be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "wp-parsely", - "version": "3.16.2", + "version": "3.16.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "wp-parsely", - "version": "3.16.2", + "version": "3.16.3", "license": "GPL-2.0-or-later", "dependencies": { "@types/js-cookie": "^3.0.6", diff --git a/package.json b/package.json index 7feb6b9e5..3b2d5af7c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wp-parsely", - "version": "3.16.2", + "version": "3.16.3", "private": true, "description": "The Parse.ly plugin facilitates real-time and historical analytics to your content through a platform designed and built for digital publishing.", "author": "parsely, hbbtstar, jblz, mikeyarce, GaryJ, parsely_mike, acicovic, mehmoodak, vaurdan", diff --git a/tests/e2e/utils.ts b/tests/e2e/utils.ts index 90f54ead5..fbe7549a7 100644 --- a/tests/e2e/utils.ts +++ b/tests/e2e/utils.ts @@ -8,7 +8,7 @@ import { visitAdminPage, } from '@wordpress/e2e-test-utils'; -export const PLUGIN_VERSION = '3.16.2'; +export const PLUGIN_VERSION = '3.16.3'; export const VALID_SITE_ID = 'demoaccount.parsely.com'; export const INVALID_SITE_ID = 'invalid.parsely.com'; export const VALID_API_SECRET = 'valid_api_secret'; diff --git a/wp-parsely.php b/wp-parsely.php index 728ce0c0e..f89339570 100644 --- a/wp-parsely.php +++ b/wp-parsely.php @@ -11,7 +11,7 @@ * Plugin Name: Parse.ly * Plugin URI: https://docs.parse.ly/wordpress * Description: This plugin makes it a snap to add Parse.ly tracking code and metadata to your WordPress blog. - * Version: 3.16.2 + * Version: 3.16.3 * Author: Parse.ly * Author URI: https://www.parse.ly * Text Domain: wp-parsely @@ -70,7 +70,7 @@ return; } -const PARSELY_VERSION = '3.16.2'; +const PARSELY_VERSION = '3.16.3'; const PARSELY_FILE = __FILE__; require_once __DIR__ . '/src/Models/class-base-model.php'; From b37eef28e5a58c5692f5382f691a5b799710b2b7 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 8 Aug 2024 10:16:52 +0100 Subject: [PATCH 4/5] Update CHANGELOG.md for version 3.16.3 --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dc4388fe..5346ab5c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.16.3](https://github.com/Parsely/wp-parsely/compare/3.16.2...3.16.3) - 2024-08-08 + +### Fixed + +- PCH Smart Linking: Fix issue with undefined 'wpParselySmartLinkingAllowedBlocks' ([#2685](https://github.com/Parsely/wp-parsely/pull/2685)) + + ## [3.16.2](https://github.com/Parsely/wp-parsely/compare/3.16.1...3.16.2) - 2024-07-30 ### Fixed From 7d5ecec49306df6db21bc98a48eb8f70d9b6524f Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 8 Aug 2024 10:18:22 +0100 Subject: [PATCH 5/5] Remove empty line from CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5346ab5c1..64a704534 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - PCH Smart Linking: Fix issue with undefined 'wpParselySmartLinkingAllowedBlocks' ([#2685](https://github.com/Parsely/wp-parsely/pull/2685)) - ## [3.16.2](https://github.com/Parsely/wp-parsely/compare/3.16.1...3.16.2) - 2024-07-30 ### Fixed