From 82f7209b3d967629b66a293dbe61093a4827d999 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 4 Apr 2024 13:03:49 +0100 Subject: [PATCH 01/44] Add optional `$request` parameter to `is_available_to_current_user` --- src/Endpoints/class-base-endpoint.php | 5 ++++- src/Endpoints/user-meta/class-base-endpoint-user-meta.php | 4 +++- src/RemoteAPI/class-analytics-post-detail-api.php | 5 ++++- src/RemoteAPI/class-analytics-posts-api.php | 5 ++++- src/RemoteAPI/class-referrers-post-detail-api.php | 5 ++++- src/RemoteAPI/class-related-api.php | 5 ++++- src/RemoteAPI/class-remote-api-cache.php | 7 +++++-- src/RemoteAPI/class-validate-api.php | 5 ++++- .../class-content-suggestions-base-api.php | 6 +++++- src/RemoteAPI/interface-remote-api.php | 6 ++++-- 10 files changed, 41 insertions(+), 12 deletions(-) diff --git a/src/Endpoints/class-base-endpoint.php b/src/Endpoints/class-base-endpoint.php index 9fd161686..692abf17c 100644 --- a/src/Endpoints/class-base-endpoint.php +++ b/src/Endpoints/class-base-endpoint.php @@ -11,6 +11,7 @@ namespace Parsely\Endpoints; use Parsely\Parsely; +use WP_REST_Request; use function Parsely\Utils\convert_endpoint_to_filter_key; @@ -57,10 +58,12 @@ abstract class Base_Endpoint { * user. * * @since 3.14.0 Replaced `is_public_endpoint`, `user_capability` and `permission_callback()`. + * @since 3.15.0 Added the `$request` parameter. * + * @param WP_REST_Request|null $request The request object. * @return bool */ - abstract public function is_available_to_current_user(): bool; + abstract public function is_available_to_current_user( $request = null ): bool; /** * Constructor. diff --git a/src/Endpoints/user-meta/class-base-endpoint-user-meta.php b/src/Endpoints/user-meta/class-base-endpoint-user-meta.php index 119ba3341..246a4b4ba 100644 --- a/src/Endpoints/user-meta/class-base-endpoint-user-meta.php +++ b/src/Endpoints/user-meta/class-base-endpoint-user-meta.php @@ -141,10 +141,12 @@ public function process_request( WP_REST_Request $request ): string { * user. * * @since 3.14.0 + * @since 3.15.0 Added the `$request` parameter. * + * @param WP_REST_Request|null $request The request object. * @return bool */ - public function is_available_to_current_user(): bool { + public function is_available_to_current_user( $request = null ): bool { return current_user_can( 'edit_user', $this->current_user_id ); } diff --git a/src/RemoteAPI/class-analytics-post-detail-api.php b/src/RemoteAPI/class-analytics-post-detail-api.php index a61049920..06dbbd231 100644 --- a/src/RemoteAPI/class-analytics-post-detail-api.php +++ b/src/RemoteAPI/class-analytics-post-detail-api.php @@ -12,6 +12,7 @@ use Parsely\Endpoints\Base_Endpoint; use Parsely\Parsely; +use WP_REST_Request; /** * Class for Analytics Post Detail API (`/analytics/post/detail`). @@ -28,10 +29,12 @@ class Analytics_Post_Detail_API extends Base_Endpoint_Remote { * user. * * @since 3.14.0 + * @since 3.15.0 Added the `$request` parameter. * + * @param WP_REST_Request|null $request The request object. * @return bool */ - public function is_available_to_current_user(): bool { + public function is_available_to_current_user( $request = null ): bool { return current_user_can( // phpcs:ignore WordPress.WP.Capabilities.Undetermined $this->apply_capability_filters( diff --git a/src/RemoteAPI/class-analytics-posts-api.php b/src/RemoteAPI/class-analytics-posts-api.php index 12d62d587..0e1c002c0 100644 --- a/src/RemoteAPI/class-analytics-posts-api.php +++ b/src/RemoteAPI/class-analytics-posts-api.php @@ -13,6 +13,7 @@ use Parsely\Endpoints\Base_Endpoint; use Parsely\Parsely; use WP_Error; +use WP_REST_Request; /** * Class for Analytics Posts API (`/analytics/posts`). @@ -65,10 +66,12 @@ class Analytics_Posts_API extends Base_Endpoint_Remote { * user. * * @since 3.14.0 + * @since 3.15.0 Added the `$request` parameter. * + * @param WP_REST_Request|null $request The request object. * @return bool */ - public function is_available_to_current_user(): bool { + public function is_available_to_current_user( $request = null ): bool { return current_user_can( // phpcs:ignore WordPress.WP.Capabilities.Undetermined $this->apply_capability_filters( diff --git a/src/RemoteAPI/class-referrers-post-detail-api.php b/src/RemoteAPI/class-referrers-post-detail-api.php index 51e91c9ec..16867834e 100644 --- a/src/RemoteAPI/class-referrers-post-detail-api.php +++ b/src/RemoteAPI/class-referrers-post-detail-api.php @@ -12,6 +12,7 @@ use Parsely\Endpoints\Base_Endpoint; use Parsely\Parsely; +use WP_REST_Request; /** * Class for Referrers Post Detail API (`/referrers/post/detail`). @@ -28,10 +29,12 @@ class Referrers_Post_Detail_API extends Base_Endpoint_Remote { * user. * * @since 3.14.0 + * @since 3.15.0 Added the `$request` parameter. * + * @param WP_REST_Request|null $request The request object. * @return bool */ - public function is_available_to_current_user(): bool { + public function is_available_to_current_user( $request = null ): bool { return current_user_can( // phpcs:ignore WordPress.WP.Capabilities.Undetermined $this->apply_capability_filters( diff --git a/src/RemoteAPI/class-related-api.php b/src/RemoteAPI/class-related-api.php index 93b47bba2..f12fcbfd2 100644 --- a/src/RemoteAPI/class-related-api.php +++ b/src/RemoteAPI/class-related-api.php @@ -11,6 +11,7 @@ namespace Parsely\RemoteAPI; use Parsely\Parsely; +use WP_REST_Request; /** * Class for Related API (`/related`). @@ -27,10 +28,12 @@ class Related_API extends Base_Endpoint_Remote { * user. * * @since 3.14.0 + * @since 3.15.0 Added the `$request` parameter. * + * @param WP_REST_Request|null $request The request object. * @return bool */ - public function is_available_to_current_user(): bool { + public function is_available_to_current_user( $request = null ): bool { return true; } } diff --git a/src/RemoteAPI/class-remote-api-cache.php b/src/RemoteAPI/class-remote-api-cache.php index a37e67006..13e653e33 100644 --- a/src/RemoteAPI/class-remote-api-cache.php +++ b/src/RemoteAPI/class-remote-api-cache.php @@ -11,6 +11,7 @@ namespace Parsely\RemoteAPI; use WP_Error; +use WP_REST_Request; /** * Caching Decorator for remote API endpoints. @@ -79,10 +80,12 @@ public function get_items( array $query, bool $associative = false ) { * * @since 3.7.0 * @since 3.14.0 Renamed from `is_user_allowed_to_make_api_call()`. + * @since 3.15.0 Added the `$request` parameter. * + * @param WP_REST_Request|null $request The request object. * @return bool */ - public function is_available_to_current_user(): bool { - return $this->remote_api->is_available_to_current_user(); + public function is_available_to_current_user( $request = null ): bool { + return $this->remote_api->is_available_to_current_user( $request ); } } diff --git a/src/RemoteAPI/class-validate-api.php b/src/RemoteAPI/class-validate-api.php index e7941cff3..c8810ca31 100644 --- a/src/RemoteAPI/class-validate-api.php +++ b/src/RemoteAPI/class-validate-api.php @@ -13,6 +13,7 @@ use Parsely\Endpoints\Base_Endpoint; use Parsely\Parsely; use WP_Error; +use WP_REST_Request; use function Parsely\Utils\convert_to_associative_array; @@ -33,10 +34,12 @@ class Validate_API extends Base_Endpoint_Remote { * user. * * @since 3.14.0 + * @since 3.15.0 Added the `$request` parameter. * + * @param WP_REST_Request|null $request The request object. * @return bool */ - public function is_available_to_current_user(): bool { + public function is_available_to_current_user( $request = null ): bool { return current_user_can( // phpcs:ignore WordPress.WP.Capabilities.Undetermined $this->apply_capability_filters( diff --git a/src/RemoteAPI/content-suggestions/class-content-suggestions-base-api.php b/src/RemoteAPI/content-suggestions/class-content-suggestions-base-api.php index 42f4d492a..294d7e57a 100644 --- a/src/RemoteAPI/content-suggestions/class-content-suggestions-base-api.php +++ b/src/RemoteAPI/content-suggestions/class-content-suggestions-base-api.php @@ -15,6 +15,8 @@ use Parsely\RemoteAPI\Base_Endpoint_Remote; use UnexpectedValueException; use WP_Error; +use WP_REST_Request; + /** * Base API for all Parse.ly Content Suggestion API endpoints. @@ -50,10 +52,12 @@ abstract class Content_Suggestions_Base_API extends Base_Endpoint_Remote { * user. * * @since 3.14.0 + * @since 3.15.0 Added the `$request` parameter. * + * @param WP_REST_Request|null $request The request object. * @return bool */ - public function is_available_to_current_user(): bool { + public function is_available_to_current_user( $request = null ): bool { return current_user_can( // phpcs:ignore WordPress.WP.Capabilities.Undetermined $this->apply_capability_filters( diff --git a/src/RemoteAPI/interface-remote-api.php b/src/RemoteAPI/interface-remote-api.php index 45d42c4e6..fc18e5ac8 100644 --- a/src/RemoteAPI/interface-remote-api.php +++ b/src/RemoteAPI/interface-remote-api.php @@ -11,7 +11,7 @@ namespace Parsely\RemoteAPI; use WP_Error; - +use WP_REST_Request; /** * Remote API Interface. */ @@ -31,8 +31,10 @@ public function get_items( array $query, bool $associative = false ); * user. * * @since 3.14.0 Renamed from `is_user_allowed_to_make_api_call()`. + * @since 3.15.0 Added the `$request` parameter. * + * @param WP_REST_Request|null $request The request object. * @return bool */ - public function is_available_to_current_user(): bool; + public function is_available_to_current_user( $request = null ): bool; } From a8dc5a830e8a7c48c6afbd789f7943338a9e78ec Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 4 Apr 2024 13:08:28 +0100 Subject: [PATCH 02/44] Lower phpstan type coverage param_type to 79.7 --- phpstan.neon | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/phpstan.neon b/phpstan.neon index fa904e4f5..fc103e8c3 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -14,7 +14,7 @@ parameters: - vendor/php-stubs/wordpress-tests-stubs/wordpress-tests-stubs.php type_coverage: return_type: 91 - param_type: 80 + param_type: 79.7 property_type: 0 # We can't use property types until PHP 7.4 becomes the plugin's minimum version. print_suggestions: false typeAliases: From 3751f4deb96d1f049f24e1caee218dd357de6432 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Fri, 5 Apr 2024 10:13:42 +0100 Subject: [PATCH 03/44] Add Smart Linking models and bare endpoint --- .../class-smart-linking-endpoint.php | 105 ++++++++++++++ src/Models/class-base-model.php | 73 ++++++++++ src/Models/class-smart-link.php | 132 ++++++++++++++++++ .../class-link-suggestion.php | 48 ------- .../class-suggest-linked-reference-api.php | 18 +-- wp-parsely.php | 6 + 6 files changed, 325 insertions(+), 57 deletions(-) create mode 100644 src/Endpoints/content-helper/class-smart-linking-endpoint.php create mode 100644 src/Models/class-base-model.php create mode 100644 src/Models/class-smart-link.php delete mode 100644 src/RemoteAPI/content-suggestions/class-link-suggestion.php diff --git a/src/Endpoints/content-helper/class-smart-linking-endpoint.php b/src/Endpoints/content-helper/class-smart-linking-endpoint.php new file mode 100644 index 000000000..6404f6979 --- /dev/null +++ b/src/Endpoints/content-helper/class-smart-linking-endpoint.php @@ -0,0 +1,105 @@ +get_param( 'post_id' ); + + // Check if the current user has edit capabilities for the post. + $can_edit = current_user_can( 'edit_post', $post_id ); + + // Check if the current user has the smart linking capability. + $has_capability = current_user_can( + $this->apply_capability_filters( + Base_Endpoint::DEFAULT_ACCESS_CAPABILITY + ) + ); + + return $can_edit && $has_capability; + } + + public function run(): void { + // Endpoint "[post-id]/set" + $this->register_endpoint( + static::ENDPOINT . + 'set_smart_links', + array( 'POST' ) + ); + + $this->register_endpoint( + static::ENDPOINT . '/add-smart-link', + 'add_smart_link', + array( 'POST' ) + ); + + $this->register_endpoint( + static::ENDPOINT . '/delete-smart-link', + 'delete_smart_link', + array( 'POST' ) + ); + + $this->register_endpoint( + static::ENDPOINT . '/get-smart-links', + 'get_smart_links', + array( 'GET' ) + ); + } + + public function set_smart_links( WP_REST_Request $request ): string { + return 'set_smart_links'; + } + + public function add_smart_link( WP_REST_Request $request ): string { + return 'add_smart_link'; + } + + public function delete_smart_link( WP_REST_Request $request ): string { + return 'add_smart_link'; + } + + public function get_smart_links( WP_REST_Request $request ): string { + return 'add_smart_link'; + } + + public function delete_all_smart_links( WP_REST_Request $request ): string { + return 'add_smart_link'; + } +} diff --git a/src/Models/class-base-model.php b/src/Models/class-base-model.php new file mode 100644 index 000000000..40b66a914 --- /dev/null +++ b/src/Models/class-base-model.php @@ -0,0 +1,73 @@ +uid = $this->generate_uid(); + } + + /** + * Returns the unique ID of the model. + * + * @since 3.15.0 + * + * @return string The unique ID of the model. + */ + public function get_uid(): string { + return $this->uid; + } + + /** + * Generates a unique ID for the model. + * + * @since 3.15.0 + * + * @return string The generated unique ID. + */ + abstract protected function generate_uid(): string; + + /** + * Serializes the model to a JSON string. + * + * @since 3.15.0 + * + * @return string The serialized model. + */ + abstract public function serialize(): string; + + /** + * Deserializes a JSON string to a model. + * + * @since 3.15.0 + * + * @param string $json The JSON string to deserialize. + * @return Base_Model The deserialized model. + */ + abstract static public function deserialize( string $json ): Base_Model; +} diff --git a/src/Models/class-smart-link.php b/src/Models/class-smart-link.php new file mode 100644 index 000000000..183607a7b --- /dev/null +++ b/src/Models/class-smart-link.php @@ -0,0 +1,132 @@ +href = $href; + $this->title = $title; + $this->text = $text; + $this->offset = $offset; + + parent::__construct(); + } + + /** + * Generates a unique ID for the suggested link. + * + * It takes the href, title, text, and offset properties and concatenates them + * to create a unique ID. This ID is hashed to ensure it is unique. + * + * @since 3.15.0 + * + * @return string The unique ID. + */ + protected function generate_uid(): string { + $unique_string = md5($this->href . $this->title . $this->text . $this->offset); + return $unique_string; + } + + /** + * Serializes the model to a JSON string. + * + * @since 3.15.0 + * + * @return string The serialized model. + */ + public function serialize(): string { + $json = wp_json_encode( array ( + 'uid' => $this->uid, + 'href' => $this->href, + 'title' => $this->title, + 'text' => $this->text, + 'offset' => $this->offset, + ) ); + + if ( false === $json ) { + $json = '{}'; + } + + return $json; + } + + /** + * Deserializes a JSON string to a model. + * + * @since 3.15.0 + * + * @param string $json The JSON string to deserialize. + * @return Base_Model The deserialized model. + */ + static public function deserialize( string $json ): Base_Model { + $data = json_decode( $json, true ); + + // Validate the JSON data. + if ( ! is_array( $data ) ) { + throw new \InvalidArgumentException( 'Invalid JSON data' ); + } + + return new Smart_Link( $data['href'], $data['title'], $data['text'], $data['offset'] ); + } + +} diff --git a/src/RemoteAPI/content-suggestions/class-link-suggestion.php b/src/RemoteAPI/content-suggestions/class-link-suggestion.php deleted file mode 100644 index 1caa97d5a..000000000 --- a/src/RemoteAPI/content-suggestions/class-link-suggestion.php +++ /dev/null @@ -1,48 +0,0 @@ -result as $link ) { - $link_obj = new Link_Suggestion(); - $link_obj->href = esc_url( $link->canonical_url ); - $link_obj->title = esc_attr( $link->title ); - $link_obj->text = wp_kses_post( $link->text ); - $link_obj->offset = $link->offset; + $link_obj = new Smart_Link( + esc_url( $link->canonical_url ), + esc_attr( $link->title ), + wp_kses_post( $link->text ), + $link->offset + ); $links[] = $link_obj; } diff --git a/wp-parsely.php b/wp-parsely.php index 2dba46cfe..7eccb4f88 100644 --- a/wp-parsely.php +++ b/wp-parsely.php @@ -72,6 +72,9 @@ const PARSELY_VERSION = '3.14.2'; const PARSELY_FILE = __FILE__; +require_once __DIR__ . '/src/Models/class-base-model.php'; +require_once __DIR__ . '/src/Models/class-smart-link.php'; + require_once __DIR__ . '/src/class-parsely.php'; require_once __DIR__ . '/src/class-scripts.php'; require_once __DIR__ . '/src/class-dashboard-link.php'; @@ -207,6 +210,9 @@ function parsely_rest_api_init(): void { ( new Dashboard_Widget_Settings_Endpoint( $GLOBALS['parsely'] ) )->run(); ( new Editor_Sidebar_Settings_Endpoint( $GLOBALS['parsely'] ) )->run(); + // Internal Content Helper endpoints. + + parsely_run_rest_api_endpoint( Related_API::class, Related_API_Proxy::class, From 3f8cd9bd9c7c92c010134adc3793f9883f16cc86 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 30 Apr 2024 10:12:57 +0100 Subject: [PATCH 04/44] Start implementing Modal UI --- src/content-helper/common/css/variables.scss | 5 + .../smart-linking/component-block-overlay.tsx | 2 +- .../smart-linking/component.tsx | 27 +++-- .../editor-sidebar/smart-linking/provider.ts | 25 +++++ .../review-modal/component-modal.tsx | 102 ++++++++++++++++++ .../review-modal/component-sidebar.tsx | 29 +++++ .../review-modal/component-suggestion.tsx | 79 ++++++++++++++ .../smart-linking/smart-linking.scss | 77 +++++++++++++ 8 files changed, 337 insertions(+), 9 deletions(-) create mode 100644 src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx create mode 100644 src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx create mode 100644 src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx diff --git a/src/content-helper/common/css/variables.scss b/src/content-helper/common/css/variables.scss index a23d973c7..ed6d306e7 100644 --- a/src/content-helper/common/css/variables.scss +++ b/src/content-helper/common/css/variables.scss @@ -8,6 +8,9 @@ $base-unit-5: 0.25rem; // 4px. $base-unit-10: 0.5rem; // 8px. $base-unit-15: 0.75rem; // 12px. $base-unit-20: 1rem; // 16px. +$base-unit-25: 1.25rem; // 20px. +$base-unit-30: 1.5rem; // 24px. +$base-unit-40: 2rem; // 32px. /** * This is a subset of the CSS variables defined in the Parse.ly dashboard. It @@ -21,6 +24,7 @@ $base-unit-20: 1rem; // 16px. .editor-post-excerpt, .wp-parsely-popover, .wp-parsely-suggested-title-modal, +.wp-parsely-smart-linking-review-modal, .wp-parsely-block-overlay, .components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"], // Sidebar icon. #wp-parsely-dashboard-widget { @@ -64,6 +68,7 @@ $base-unit-20: 1rem; // 16px. --grid-unit-10: #{$base-unit-10}; // 8px. --grid-unit-15: #{$base-unit-15}; // 12px. --grid-unit-20: #{$base-unit-20}; // 16px. + --grid-unit-30: #{$base-unit-30}; // 24px. /** Additional variables. **/ --font-size--smaller: 0.688rem; // 11px. diff --git a/src/content-helper/editor-sidebar/smart-linking/component-block-overlay.tsx b/src/content-helper/editor-sidebar/smart-linking/component-block-overlay.tsx index f8a532382..bad912be8 100644 --- a/src/content-helper/editor-sidebar/smart-linking/component-block-overlay.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/component-block-overlay.tsx @@ -203,11 +203,11 @@ export const withBlockOverlay = createHigherOrderComponent( ( BlockEdit ) => { return ( <> + - ); }; diff --git a/src/content-helper/editor-sidebar/smart-linking/component.tsx b/src/content-helper/editor-sidebar/smart-linking/component.tsx index 6eed9600b..f7ee90956 100644 --- a/src/content-helper/editor-sidebar/smart-linking/component.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/component.tsx @@ -6,7 +6,7 @@ import { BlockInstance } from '@wordpress/blocks'; import { Button, Notice, PanelRow } from '@wordpress/components'; import { useDebounce } from '@wordpress/compose'; import { dispatch, select, useDispatch, useSelect } from '@wordpress/data'; -import { useEffect, useState } from '@wordpress/element'; +import { useCallback, useEffect, useState } from '@wordpress/element'; import { __, _n, sprintf } from '@wordpress/i18n'; import { Icon, external } from '@wordpress/icons'; @@ -18,6 +18,7 @@ import { Telemetry } from '../../../js/telemetry/telemetry'; import { ContentHelperErrorCode } from '../../common/content-helper-error'; import { SidebarSettings, SmartLinkingSettings, useSettings } from '../../common/settings'; import { generateProtocolVariants } from '../../common/utils/functions'; +import { SmartLinkingReviewModal } from './review-modal/component-modal'; import { SmartLinkingSettings as SmartLinkingSettingsComponent } from './component-settings'; import { LinkSuggestion, SmartLinkingProvider } from './provider'; import { ApplyToOptions, SmartLinkingSettingsProps, SmartLinkingStore } from './store'; @@ -95,6 +96,7 @@ export const SmartLinkingPanel = ( { const setSettingsDebounced = useDebounce( setSettings, 500 ); const [ numAddedLinks, setNumAddedLinks ] = useState( 0 ); + const [ isReviewModalOpen, setIsReviewModalOpen ] = useState( false ); const { createNotice } = useDispatch( 'core/notices' ); @@ -244,12 +246,13 @@ export const SmartLinkingPanel = ( { * Generates smart links for the selected block or the entire post content. * * @since 3.14.0 - * @since 3.15.0 Renamed from `generateSmartLinks` to `generateAndApplySmartLinks`. + * @since 3.15.0 Renamed from `generateSmartLinks` to `generateSmartLinks`. */ - const generateAndApplySmartLinks = () => async (): Promise => { + const generateSmartLinks = async () => { await setLoading( true ); await setSuggestedLinks( null ); await setError( null ); + Telemetry.trackEvent( 'smart_linking_generate_pressed', { is_full_content: isFullContent, selected_block: selectedBlock?.name ?? 'none', @@ -275,9 +278,11 @@ export const SmartLinkingPanel = ( { const previousApplyTo = applyTo; try { const generatedLinks = await generateSmartLinksWithRetry( MAX_NUMBER_OF_RETRIES ); - applySmartLinks( generatedLinks ); + await setSuggestedLinks( generatedLinks ); + setIsReviewModalOpen( true ); + //applySmartLinks( generatedLinks ); } catch ( e: any ) { // eslint-disable-line @typescript-eslint/no-explicit-any - let snackBarMessage = __( 'There was a problem applying smart links.', 'wp-parsely' ); + let snackBarMessage = __( 'There was a problem generating smart links.', 'wp-parsely' ); // Handle the case where the operation was aborted by the user. if ( e.code && e.code === ContentHelperErrorCode.ParselyAborted ) { @@ -347,7 +352,6 @@ export const SmartLinkingPanel = ( { throw err; } - await setSuggestedLinks( generatedLinks ); return generatedLinks; }; @@ -649,7 +653,7 @@ export const SmartLinkingPanel = ( { ); } if ( loading ) { - return __( 'Adding Smart Links…', 'wp-parsely' ); + return __( 'Generating Smart Links…', 'wp-parsely' ); } return __( 'Add Smart Links', 'wp-parsely' ); }; @@ -702,7 +706,7 @@ export const SmartLinkingPanel = ( { />
+ + setIsReviewModalOpen( false ) } + links={ suggestedLinks } + /> ); }; diff --git a/src/content-helper/editor-sidebar/smart-linking/provider.ts b/src/content-helper/editor-sidebar/smart-linking/provider.ts index 72cc4938a..6c5aae352 100644 --- a/src/content-helper/editor-sidebar/smart-linking/provider.ts +++ b/src/content-helper/editor-sidebar/smart-linking/provider.ts @@ -16,6 +16,7 @@ import { DEFAULT_MAX_LINK_WORDS, DEFAULT_MAX_LINKS } from './smart-linking'; * @since 3.14.0 */ export type LinkSuggestion = { + uid?: string; href: string; text: string; title: string; @@ -66,6 +67,30 @@ export class SmartLinkingProvider extends BaseProvider { maxLinksPerPost: number = DEFAULT_MAX_LINKS, urlExclusionList: string[] = [], ): Promise { + return [ + { + uid: '9befadbab33de885cf9a739ab0b50f0d', + href: 'http:\/\/wpvip.com\/2022\/06\/08\/wordpress-myths\/', + title: 'busting 10 myths about wordpress and wordpress vip', + text: 'WordPress VIP is the gold standard', + offset: 0, + }, + { + uid: '74217439c37f4659e1e7ae8fb328e11d', + href: 'http:\/\/wpvip.com\/2022\/11\/02\/avoiding-cms-disaster-raising-your-wordpress-security-to-the-next-level\/', + title: 'avoiding cms disaster: raising your wordpress security to the next level', + text: 'Its core strengths lie in', + offset: 0, + }, + { + uid: '9b4b3a564dcce2235a30907b9e2a9c98', + href: 'http:\/\/wpvip.com\/2021\/04\/09\/how-the-wordpress-gutenberg-block-editor-empowers-enterprise-content-creators\/', + title: 'how the wordpress gutenberg block editor empowers enterprise content creators', + text: 'a robust suite of digital publishing tools', + offset: 0, + }, + ]; + const response = await this.fetch( { method: 'POST', path: addQueryArgs( '/wp-parsely/v1/content-suggestions/suggest-linked-reference', { diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx new file mode 100644 index 000000000..0b906e3b5 --- /dev/null +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx @@ -0,0 +1,102 @@ +import { BlockInstance } from '@wordpress/blocks'; +import { Button, Modal } from '@wordpress/components'; +import { useEffect, useState } from '@wordpress/element'; +import { __ } from '@wordpress/i18n'; + +import { LinkSuggestion } from '../provider'; +import { ReviewModalSidebar } from './component-sidebar'; +import { ReviewSuggestion } from './component-suggestion'; + +export type SmartLinkingReviewModalProps = { + links: LinkSuggestion[] | null, + onClose: () => void, + isOpen: boolean, + selectedBlock?: BlockInstance, +}; + +export const SmartLinkingReviewModal = ( { + links, + onClose, + isOpen, + selectedBlock, +}: SmartLinkingReviewModalProps ): JSX.Element => { + const [ showCloseDialog, setShowCloseDialog ] = useState( false ); + const [ isModalOpen, setIsModalOpen ] = useState( isOpen ); + + const showConfirmCloseDialog = () => setShowCloseDialog( true ); + const hideConfirmCloseDialog = () => setShowCloseDialog( false ); + + /** + * Update the modal state when the `isOpen` prop changes. + */ + useEffect( () => { + setIsModalOpen( isOpen ); + }, [ isOpen ] ); + + const onCloseHandler = () => { + console.log( 'onCloseHandler' ); + // Hide the modal. + setIsModalOpen( false ); + + if ( links ) { + showConfirmCloseDialog(); + console.log( showCloseDialog ); + return; + } + + onClose(); + }; + + const onCloseConfirmCloseDialog = ( shouldClose: boolean ) => { + console.log( 'onCloseConfirmCloseDialog' ); + hideConfirmCloseDialog(); + if ( shouldClose ) { + setIsModalOpen( false ); + onClose(); + } else { + setIsModalOpen( true ); + } + }; + + return ( + <> + { isModalOpen && ( + +
+ + +
+
+ ) } + + { showCloseDialog && ( + onCloseConfirmCloseDialog( false ) } + className="wp-parsely-smart-linking-close-dialog" + > + { __( 'Are you sure you want to close? All un-accepted smart links will not be added.', 'wp-parsely' ) } + + + + ) } + + + ); +}; diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx new file mode 100644 index 000000000..8db8dc38a --- /dev/null +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx @@ -0,0 +1,29 @@ +import { MenuItem } from '@wordpress/components'; +import { LinkSuggestion } from '../provider'; + +type ReviewModalSidebarProps = { + links: LinkSuggestion[] | null, +}; + +export const ReviewModalSidebar = ( { + links, +}: ReviewModalSidebarProps ): JSX.Element => { + return ( +
+
+
+ Outbound Smart Links + { links?.length } +
+ { links?.map( ( link ) => ( + + { link.text } + + ) ) } +
+
+ ); +}; diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx new file mode 100644 index 000000000..0bce95679 --- /dev/null +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx @@ -0,0 +1,79 @@ +import { selectBlock } from '@wordpress/block-editor/store/actions'; +import { BlockInstance, createBlock, serialize } from '@wordpress/blocks'; +import { Button, __experimentalDivider as Divider } from '@wordpress/components'; +import { useState } from '@wordpress/element'; +import { arrowLeft, arrowRight, check, close } from '@wordpress/icons'; +import { LinkSuggestion } from '../provider'; +import { + // @ts-ignore + BlockEditorProvider, WritingFlow, ObserveTyping, BlockList, BlockPreview as BlockPreviewComponent, +} from '@wordpress/block-editor'; + +type ReviewSuggestionProps = { + link: LinkSuggestion | null, + block?: BlockInstance, +}; + +const SuggestionBreadcrumb = ( { link, block }: ReviewSuggestionProps ): JSX.Element => { + return ( +
+ [Parent] / [Parent] / + + [Block Name] [Attribute] + +
+ ); +}; + +const BlockPreview = ( { block }: { block?: BlockInstance } ) => { + if ( ! block ) { + return <>; + } + + return ( +
+ + + +
+ ); +}; + +export const ReviewSuggestion = ( { + link, + block, +}: ReviewSuggestionProps ): JSX.Element => { + if ( ! link ) { + return <>; + } + + return ( +
+ +
+ +
+ +
{ link.href }
+
+ + + + +
+
+ ); +}; diff --git a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss index da495fe6f..0accc8d2c 100644 --- a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss +++ b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss @@ -185,3 +185,80 @@ margin-top: calc(var(--grid-unit-10) * -1); } } + +.wp-parsely-smart-linking-review-modal { + display: flex; + width: to_rem(766px); + flex-direction: column; + align-items: flex-start; + + .smart-linking-modal-body { + display: flex; + flex-direction: row; + gap: var(--grid-unit-30); + align-self: stretch; + } + + .smart-linking-review-sidebar { + display: flex; + width: to_rem(220px); + flex-direction: column; + align-items: flex-start; + gap: var(--grid-unit-20); + align-self: stretch; + + .review-sidebar-header { + margin-bottom: var(--grid-unit-15); + display: flex; + align-items: center; + gap: 6px; + align-self: stretch; + color: var(--sidebar-black); + font-size: 11px; + font-style: normal; + font-weight: 600; + line-height: var(--grid-unit-20); + text-transform: uppercase; + + > span { + color: var(--Gutenberg-Gray-700, #757575); + } + } + + .components-button.components-menu-item__button { + width: to_rem(220px); + + .components-menu-item__item { + overflow: hidden; + white-space: nowrap; + text-overflow: ellipsis; + display: inline; + text-align: left; + } + + .components-menu-item__shortcut { + padding-left: var(--grid-unit-10); + color: var(--Gutenberg-Blueberry, #3858E9); + } + } + } + + .smart-linking-review-suggestion { + display: flex; + flex-direction: column; + align-items: flex-start; + gap: 16px; + flex: 1 0 0; + align-self: stretch; + } +} + +.wp-parsely-preview-editor { + .block-editor-block-list__block { + pointer-events: none; /* Disables clicking and typing */ + } + + &.editor-styles-wrapper { + padding-bottom: 0; + } +} From 47a1dafe048128c0c07e389204fb0a24aa1cae26 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 2 May 2024 15:08:52 +0100 Subject: [PATCH 05/44] Implement preview and UI elements --- src/@types/gutenberg/types.ts | 1 + src/content-helper/common/css/variables.scss | 4 +- .../smart-linking/component.tsx | 105 ++++--- .../editor-sidebar/smart-linking/provider.ts | 71 ++++- .../review-modal/component-modal.tsx | 43 ++- .../review-modal/component-sidebar.tsx | 10 +- .../review-modal/component-suggestion.tsx | 288 +++++++++++++++--- .../smart-linking/smart-linking.scss | 86 +++++- .../editor-sidebar/smart-linking/utils.ts | 116 +++++++ 9 files changed, 623 insertions(+), 101 deletions(-) diff --git a/src/@types/gutenberg/types.ts b/src/@types/gutenberg/types.ts index 51b1ae1f7..c058f0c16 100644 --- a/src/@types/gutenberg/types.ts +++ b/src/@types/gutenberg/types.ts @@ -16,6 +16,7 @@ export interface GutenbergFunction { getSelectedBlock(): BlockInstance | null; getBlock( clientId: string ): BlockInstance | null; getBlocks(): BlockInstance[]; + getBlockParents( clientId: string ): string[]; getPermalink(): string | null; } diff --git a/src/content-helper/common/css/variables.scss b/src/content-helper/common/css/variables.scss index ed6d306e7..dee8ad58e 100644 --- a/src/content-helper/common/css/variables.scss +++ b/src/content-helper/common/css/variables.scss @@ -26,6 +26,7 @@ $base-unit-40: 2rem; // 32px. .wp-parsely-suggested-title-modal, .wp-parsely-smart-linking-review-modal, .wp-parsely-block-overlay, +.wp-parsely-preview-editor, .components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"], // Sidebar icon. #wp-parsely-dashboard-widget { @@ -34,7 +35,8 @@ $base-unit-40: 2rem; // 32px. --numeric-font: "ff-din-round-web", sans-serif; /** Category colors section - base scss. **/ - --parsely-green: hsl(107, 42%, 46%); + --parsely-green-components: 107, 42%, 46%; + --parsely-green: hsl( var(--parsely-green-components) ); --parsely-green-10: hsla(98, 61%, 81%, 1); --parsely-green-65: hsla(109, 59%, 26%, 1); --gray-200: #f7f8f9; diff --git a/src/content-helper/editor-sidebar/smart-linking/component.tsx b/src/content-helper/editor-sidebar/smart-linking/component.tsx index f7ee90956..1e60855d9 100644 --- a/src/content-helper/editor-sidebar/smart-linking/component.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/component.tsx @@ -242,6 +242,33 @@ export const SmartLinkingPanel = ( { [ selectedBlockClientId ], ); + const processSmartLinks = async ( links: LinkSuggestion[] ) => { + // An object to keep track of the number of times each link text has been found across all blocks. + const occurrenceCounts: LinkOccurrenceCounts = {}; + + // Apply the smart links to the content. + + /** + * Given a list of blocks, find the links in the blocks HTML content, and update the links with the matches. + * The position of the link must take into consideration the HTML structure of the block. + * + * @param blocks + * @param links + * @param occurrenceCounts + */ + const findLinksInBlocks = ( blocks: Readonly[], links: LinkSuggestion[], occurrenceCounts: LinkOccurrenceCounts ) => { + // Loop all the blocks + blocks.forEach( ( block ) => { + + } ); + }; + + applyLinksToBlocks( allBlocks, links, occurrenceCounts ); + + // Update the link suggestions with the new matches + await setSuggestedLinks( links ); + }; + /** * Generates smart links for the selected block or the entire post content. * @@ -253,6 +280,8 @@ export const SmartLinkingPanel = ( { await setSuggestedLinks( null ); await setError( null ); + console.log( 'generateSmartLinks' ); + Telemetry.trackEvent( 'smart_linking_generate_pressed', { is_full_content: isFullContent, selected_block: selectedBlock?.name ?? 'none', @@ -278,9 +307,8 @@ export const SmartLinkingPanel = ( { const previousApplyTo = applyTo; try { const generatedLinks = await generateSmartLinksWithRetry( MAX_NUMBER_OF_RETRIES ); - await setSuggestedLinks( generatedLinks ); + await processSmartLinks( generatedLinks ); setIsReviewModalOpen( true ); - //applySmartLinks( generatedLinks ); } catch ( e: any ) { // eslint-disable-line @typescript-eslint/no-explicit-any let snackBarMessage = __( 'There was a problem generating smart links.', 'wp-parsely' ); @@ -383,7 +411,7 @@ export const SmartLinkingPanel = ( { const updatedBlocks: BlockUpdate[] = []; // Apply the smart links to the content. - applyLinksToBlocks( blocks, links, occurrenceCounts, updatedBlocks ); + applyLinksToBlocks( blocks, links, occurrenceCounts ); // Update the content of each block. updateBlocksContent( updatedBlocks ); @@ -418,15 +446,11 @@ export const SmartLinkingPanel = ( { * @param {LinkSuggestion[]} links An array of link suggestions to apply to the content. * @param {LinkOccurrenceCounts} occurrenceCounts An object to keep track of the number of times each link text has * been applied across all blocks. - * @param {BlockUpdate[]} updatedBlocks An array of updated blocks with the new content. - * This array is modified in place and will contain the updated blocks - * after the function has been called. */ const applyLinksToBlocks = ( blocks: Readonly[], links: LinkSuggestion[], occurrenceCounts: LinkOccurrenceCounts, - updatedBlocks: BlockUpdate[], ): void => { // Check if any of the links being applied is a self-reference, and remove it if it is. const strippedPermalink = postPermalink @@ -442,10 +466,9 @@ export const SmartLinkingPanel = ( { } ); blocks.forEach( ( block ) => { - let blockUpdated = false; // Recursively apply links to any inner blocks. if ( block.innerBlocks && block.innerBlocks.length ) { - applyLinksToBlocks( block.innerBlocks, links, occurrenceCounts, updatedBlocks ); + applyLinksToBlocks( block.innerBlocks, links, occurrenceCounts ); return; } @@ -480,13 +503,23 @@ export const SmartLinkingPanel = ( { // Check if the link is in the correct position (offset) to be applied. if ( occurrenceCount.encountered === link.offset + 1 ) { // Create a new anchor element for the link. - const anchor = document.createElement( 'a' ); + /*const anchor = document.createElement( 'a' ); anchor.href = link.href; anchor.title = link.title; - anchor.textContent = match[ 0 ]; + anchor.textContent = match[ 0 ];*/ + + // Increment the linked count only when a link is applied. + occurrenceCount.linked++; + + // Update the LinkSuggestion to include the match + link.match = { + blockId: block.clientId, + startAt: getNodeOffset( contentElement, node ) + match.index, + endAt: getNodeOffset( contentElement, node ) + match.index + match[ 0 ].length, + }; // Replace the matched text with the new anchor element. - const range = document.createRange(); + /*const range = document.createRange(); range.setStart( node, match.index ); range.setEnd( node, match.index + match[ 0 ].length ); range.deleteContents(); @@ -501,31 +534,35 @@ export const SmartLinkingPanel = ( { node.textContent.slice( match.index + match[ 0 ].length ) ); node.parentNode?.insertBefore( remainingText, anchor.nextSibling ); - } - - // Increment the linked count only when a link is applied. - occurrenceCount.linked++; - - // Flag the block as updated. - blockUpdated = true; + }*/ } } } } ); } ); - - // Save the updated content if the block was updated. - if ( blockUpdated ) { - updatedBlocks.push( { - clientId: block.clientId, - newContent: contentElement.innerHTML, - } ); - } } } } ); }; + const getNodeOffset = ( parent: HTMLElement, node: Node ): number => { + let offset = 0; + let currentNode: Node | null = parent.firstChild; + + while ( currentNode !== node && currentNode !== null ) { + if ( currentNode.nodeType === Node.TEXT_NODE ) { + offset += ( currentNode.textContent || '' ).length; + } else if ( currentNode.nodeType === Node.ELEMENT_NODE ) { + // Using outerHTML property for HTMLElement nodes + const html = ( currentNode as HTMLElement ).outerHTML || ''; + offset += html.length; + } + currentNode = currentNode.nextSibling; + } + + return offset; + }; + /** * Updates the content of a block with the modified HTML. * @@ -587,17 +624,6 @@ export const SmartLinkingPanel = ( { const removeOverlay = async ( clientId: string = 'all' ): Promise => { await removeOverlayBlock( clientId ); - // Select a block after removing the overlay, only if we're using the block inspector. - if ( context === SmartLinkingPanelContext.BlockInspector ) { - if ( 'all' !== clientId && ! isFullContent ) { - dispatch( 'core/block-editor' ).selectBlock( clientId ); - } else { - const firstBlock = select( 'core/block-editor' ).getBlockOrder()[ 0 ]; - // Select the first block in the post. - dispatch( 'core/block-editor' ).selectBlock( firstBlock ); - } - } - // If there are no more overlay blocks, enable save. if ( overlayBlocks.length === 0 ) { enableSave(); @@ -717,10 +743,9 @@ export const SmartLinkingPanel = ( { setIsReviewModalOpen( false ) } - links={ suggestedLinks } + links={ suggestedLinks ?? [] } /> ); diff --git a/src/content-helper/editor-sidebar/smart-linking/provider.ts b/src/content-helper/editor-sidebar/smart-linking/provider.ts index 6c5aae352..d1cf4f620 100644 --- a/src/content-helper/editor-sidebar/smart-linking/provider.ts +++ b/src/content-helper/editor-sidebar/smart-linking/provider.ts @@ -21,8 +21,19 @@ export type LinkSuggestion = { text: string; title: string; offset: number; + match?: LinkSuggestionMatch; }; +/** + * Structure of a link suggestion match, that is filled in by the + * processing of the smart links. + */ +export type LinkSuggestionMatch = { + blockId: string; + startAt: number; + endAt: number; +} + /** * Returns data from the `content-suggestions/suggest-linked-reference` WordPress REST API * endpoint. @@ -67,30 +78,66 @@ export class SmartLinkingProvider extends BaseProvider { maxLinksPerPost: number = DEFAULT_MAX_LINKS, urlExclusionList: string[] = [], ): Promise { - return [ + /*return [ + { + uid: '3ba4e35e2eca3002207b63fac3c0911b', + href: 'http:\/\/wpvip.com\/2021\/12\/23\/secure-wordpress-hosting\/', + title: 'a guide to choosing the most secure wordpress hosting', + text: 'WordPress Enterprise', + offset: 0, + }, + { + uid: '883f036bec79f24dc79ca9c75d7bb2e9', + href: 'http:\/\/wpvip.com\/2023\/02\/16\/wordpress-org-vs-wordpress-com-vs-wordpress-vip-whats-the-difference\/', + title: 'wordpress.org vs wordpress.com vs wordpress vip: what\u2019s the difference?', + text: 'VIP Experience', + offset: 0, + }, { - uid: '9befadbab33de885cf9a739ab0b50f0d', + uid: '5a61bc47559692a0ec91a15447430568', href: 'http:\/\/wpvip.com\/2022\/06\/08\/wordpress-myths\/', title: 'busting 10 myths about wordpress and wordpress vip', - text: 'WordPress VIP is the gold standard', + text: 'Scalability', offset: 0, }, { - uid: '74217439c37f4659e1e7ae8fb328e11d', - href: 'http:\/\/wpvip.com\/2022\/11\/02\/avoiding-cms-disaster-raising-your-wordpress-security-to-the-next-level\/', - title: 'avoiding cms disaster: raising your wordpress security to the next level', - text: 'Its core strengths lie in', + uid: '83c8256011779fb29ea33b42251fb993', + href: 'http:\/\/wpvip.com\/2021\/05\/20\/wordpress-vip-is-fedramp-authorized\/', + title: 'wordpress vip is fedramp authorized', + text: 'Security', offset: 0, }, + ];*/ + return [ { - uid: '9b4b3a564dcce2235a30907b9e2a9c98', - href: 'http:\/\/wpvip.com\/2021\/04\/09\/how-the-wordpress-gutenberg-block-editor-empowers-enterprise-content-creators\/', - title: 'how the wordpress gutenberg block editor empowers enterprise content creators', - text: 'a robust suite of digital publishing tools', + uid: 'cf71c5c475bc7578013b7e6234832de4', + href: 'http:\/\/wpvip.com\/2023\/02\/16\/wordpress-org-vs-wordpress-com-vs-wordpress-vip-whats-the-difference\/', + title: 'wordpress.org vs wordpress.com vs wordpress vip: what\u2019s the difference?', + text: 'WordPress Enterprise', + offset: 0, + }, + { + uid: 'f16cb0363e8705c4d2e8f7c94412b192', + href: 'http:\/\/wpvip.com\/2023\/02\/16\/wordpress-org-vs-wordpress-com-vs-wordpress-vip-whats-the-difference\/', + title: 'wordpress.org vs wordpress.com vs wordpress vip: what\u2019s the difference?', + text: 'WordPress VIP', + offset: 1, + }, + { + uid: '8809b316cced142250c66d35d2681f1e', + href: 'http:\/\/wpvip.com\/2022\/06\/08\/wordpress-myths\/', + title: 'busting 10 myths about wordpress and wordpress vip', + text: 'scalability', + offset: 0, + }, + { + uid: '0ecd03591abebc70c1b9ee6a8110b9a3', + href: 'http:\/\/wpvip.com\/2021\/12\/23\/secure-wordpress-hosting\/', + title: 'a guide to choosing the most secure wordpress hosting', + text: 'custom development, security, scalability, and high performance', offset: 0, }, ]; - const response = await this.fetch( { method: 'POST', path: addQueryArgs( '/wp-parsely/v1/content-suggestions/suggest-linked-reference', { diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx index 0b906e3b5..878188f63 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx @@ -8,20 +8,29 @@ import { ReviewModalSidebar } from './component-sidebar'; import { ReviewSuggestion } from './component-suggestion'; export type SmartLinkingReviewModalProps = { - links: LinkSuggestion[] | null, + links: LinkSuggestion[], onClose: () => void, isOpen: boolean, - selectedBlock?: BlockInstance, }; export const SmartLinkingReviewModal = ( { links, onClose, isOpen, - selectedBlock, }: SmartLinkingReviewModalProps ): JSX.Element => { const [ showCloseDialog, setShowCloseDialog ] = useState( false ); const [ isModalOpen, setIsModalOpen ] = useState( isOpen ); + const [ selectedLink, setSelectedLink ] = useState( links[ 0 ] ); + const [ suggestedLinks, setSuggestedLinks ] = useState( links ); + //console.log( links, selectedLink ); + + // Set the first link as the selected link when the links are loaded. + useEffect( () => { + // Filter out any links without a match + const filteredLinks = links.filter( ( link ) => link.match ); + setSuggestedLinks( filteredLinks ); + setSelectedLink( filteredLinks[ 0 ] ); + }, [ links ] ); const showConfirmCloseDialog = () => setShowCloseDialog( true ); const hideConfirmCloseDialog = () => setShowCloseDialog( false ); @@ -69,8 +78,32 @@ export const SmartLinkingReviewModal = ( { shouldCloseOnEsc={ false } >
- - + + 0 } + onNext={ () => { + const currentIndex = suggestedLinks.indexOf( selectedLink ); + const nextIndex = currentIndex + 1; + setSelectedLink( suggestedLinks[ nextIndex ] ); + } } + onPrevious={ () => { + const currentIndex = suggestedLinks.indexOf( selectedLink ); + const previousIndex = currentIndex - 1; + setSelectedLink( suggestedLinks[ previousIndex ] ); + } } + onAccept={ () => { + console.log( 'onAccept' ); + } } + onReject={ () => { + console.log( 'onReject' ); + } } + />
) } diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx index 8db8dc38a..0edbcc11d 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx @@ -2,11 +2,15 @@ import { MenuItem } from '@wordpress/components'; import { LinkSuggestion } from '../provider'; type ReviewModalSidebarProps = { + activeLink: LinkSuggestion | null, links: LinkSuggestion[] | null, + setSelectedLink: ( link: LinkSuggestion ) => void, }; export const ReviewModalSidebar = ( { + activeLink, links, + setSelectedLink, }: ReviewModalSidebarProps ): JSX.Element => { return (
@@ -17,8 +21,12 @@ export const ReviewModalSidebar = ( {
{ links?.map( ( link ) => ( { + setSelectedLink( link ); + } } > { link.text } diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx index 0bce95679..48d196211 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx @@ -1,78 +1,288 @@ -import { selectBlock } from '@wordpress/block-editor/store/actions'; -import { BlockInstance, createBlock, serialize } from '@wordpress/blocks'; -import { Button, __experimentalDivider as Divider } from '@wordpress/components'; -import { useState } from '@wordpress/element'; -import { arrowLeft, arrowRight, check, close } from '@wordpress/icons'; +import { BlockInstance, cloneBlock, getBlockType } from '@wordpress/blocks'; +import { Button, __experimentalDivider as Divider, Disabled, ExternalLink, MenuItem } from '@wordpress/components'; +import { select as selectFn, useSelect } from '@wordpress/data'; +import { useEffect, useState } from '@wordpress/element'; +import { arrowLeft, arrowRight, check, closeSmall, Icon, page } from '@wordpress/icons'; +import { filterURLForDisplay } from '@wordpress/url'; +import { GutenbergFunction } from '../../../../@types/gutenberg/types'; import { LinkSuggestion } from '../provider'; -import { - // @ts-ignore - BlockEditorProvider, WritingFlow, ObserveTyping, BlockList, BlockPreview as BlockPreviewComponent, -} from '@wordpress/block-editor'; +import { BlockEditorProvider, BlockList, ObserveTyping, WritingFlow } from '@wordpress/block-editor'; +import { applyNodeToBlock } from '../utils'; -type ReviewSuggestionProps = { - link: LinkSuggestion | null, - block?: BlockInstance, +type SuggestionBreadcrumbProps = { + link: LinkSuggestion, }; +const SuggestionBreadcrumb = ( { link }: SuggestionBreadcrumbProps ): JSX.Element => { + const blockId = link.match?.blockId; + + // Fetch block details and parent IDs using the blockId + const { block, parents } = useSelect( + ( select ) => { + const { getBlock, getBlockParents } = select( 'core/block-editor' ) as GutenbergFunction; + + if ( ! blockId ) { + return { block: undefined, parents: [] }; + } + + return { + block: getBlock( blockId ), + parents: getBlockParents( blockId ) + .map( ( id ) => getBlock( id ) ) + .filter( ( currBlock ): currBlock is BlockInstance => currBlock !== undefined ), + }; + }, + [ blockId ], + ); + + if ( ! block ) { + return <>; + } -const SuggestionBreadcrumb = ( { link, block }: ReviewSuggestionProps ): JSX.Element => { return ( -
- [Parent] / [Parent] / - - [Block Name] [Attribute] +
+ { parents.map( ( parent: BlockInstance, index: number ) => ( + + + { getBlockType( parent.name )?.title } + +  /  + + ) ) } + + { getBlockType( block.name )?.title } + { block.attributes?.metadata?.name && ( + { block.attributes.metadata.name } + ) }
); }; -const BlockPreview = ( { block }: { block?: BlockInstance } ) => { +type StylesProps = { + styles: { + css?: string, + assets?: string, + __unstableType?: string, + }[], +}; +const Styles = ( { styles }: StylesProps ): JSX.Element => { + // CSS Only styles + const filteredStyles = styles + .filter( ( style ) => { + return ( + style.__unstableType === 'theme' || + style.__unstableType === 'user' + ) && style.css; + } ); + + return ( + <> + { filteredStyles.map( ( style, index ) => ( + + ) ) } + + ); +}; + +type BlockPreviewProps = { + block: BlockInstance, + link: LinkSuggestion, +} +const BlockPreview = ( { block, link }: BlockPreviewProps ) => { + const [ clonedBlock, setClonedBlock ] = useState( cloneBlock( block ) ); + + /** + * Runs when the block is updated. + * It will update the cloned block with the new block. + */ + useEffect( () => { + console.log( 'Updating cloned block' ); + setClonedBlock( cloneBlock( block ) ); + }, [ block, link ] ); + + /** + * Applies the link to the block. + * + * @param {BlockInstance} blockInstance The block instance to apply the link to. + * @param {LinkSuggestion} linkSuggestion The link suggestion to apply. + */ + const applyLinkToBlock = ( blockInstance: BlockInstance, linkSuggestion: LinkSuggestion ) => { + const anchor = document.createElement( 'a' ); + anchor.href = link.href; + anchor.title = link.title; + // Add data-smartlink attribute to the anchor tag + anchor.setAttribute( 'data-smartlink', 'true' ); + applyNodeToBlock( blockInstance, linkSuggestion, anchor ); + }; + + /** + * Highlights the link in the block. + * + * @param {BlockInstance} blockInstance The block instance to highlight the link in. + * @param {LinkSuggestion} linkSuggestion The link suggestion to highlight. + */ + const highlightLinkInBlock = ( blockInstance: BlockInstance, linkSuggestion: LinkSuggestion ) => { + const mark = document.createElement( 'mark' ); + mark.className = 'smart-linking-highlight'; + applyNodeToBlock( blockInstance, linkSuggestion, mark ); + }; + + /** + * Runs when the block is rendered in the DOM. + * It will set the block element to be non-editable. + */ + useEffect( () => { + const blockPreviewElement = document.querySelector( '.wp-parsely-preview-editor' ); + + if ( ! blockPreviewElement ) { + console.log( 'Block preview element not found' ); + return; + } + + highlightLinkInBlock( clonedBlock, link ); + + const observer = new MutationObserver( ( mutations: MutationRecord[] ) => { + mutations.forEach( ( mutation: MutationRecord ) => { + if ( mutation.type === 'childList' ) { + // Temporarily disconnect observer to prevent observing our own changes. + observer.disconnect(); + + mutation.addedNodes.forEach( ( node ) => { + if ( node instanceof HTMLElement ) { + const blockElement = document.querySelector( `.wp-parsely-preview-editor [data-block="${ clonedBlock.clientId }"]` ); + + if ( blockElement ) { + // Disable editing on the block element. + blockElement.setAttribute( 'contenteditable', 'false' ); + } + } + } ); + + // Reconnect observer after changes. + observer.observe( document.body, { childList: true, subtree: true } ); + } + } ); + } ); + + observer.observe( blockPreviewElement, { + childList: true, + subtree: true, + } ); + + return () => observer.disconnect(); + }, [ clonedBlock, link ] ); + if ( ! block ) { return <>; } + const settings = selectFn( 'core/block-editor' ).getSettings(); + return ( -
+ + -
+ + ); +}; + +const LinkDetails = ( { link }: { link: LinkSuggestion } ): JSX.Element => { + // Get the post type by the permalink + const displayUrl = filterURLForDisplay( link.href, 30 ); + + return ( + + { link.title } + ); }; +type ReviewSuggestionProps = { + link: LinkSuggestion, + onNext: () => void, + onPrevious: () => void, + onAccept: () => void, + onReject: () => void, + hasPrevious: boolean, + hasNext: boolean, +}; + export const ReviewSuggestion = ( { link, - block, + onNext, + onPrevious, + onAccept, + onReject, + hasPrevious, + hasNext, }: ReviewSuggestionProps ): JSX.Element => { - if ( ! link ) { - return <>; + if ( ! link?.match ) { + return <>No match!; + } + + const blockId = link.match.blockId; + // Get the block + const block = selectFn( 'core/block-editor' ).getBlock( blockId ); + + if ( ! block ) { + return <>No block!; } return (
- +
- +
-
{ link.href }
+
- - - +
+ + +
+ -
); diff --git a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss index 0accc8d2c..950ce4225 100644 --- a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss +++ b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss @@ -238,27 +238,107 @@ .components-menu-item__shortcut { padding-left: var(--grid-unit-10); - color: var(--Gutenberg-Blueberry, #3858E9); + color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)) } } } .smart-linking-review-suggestion { + max-width: to_rem(452px); display: flex; flex-direction: column; align-items: flex-start; gap: 16px; - flex: 1 0 0; + flex: 1; align-self: stretch; + + .review-suggestions-breadcrumbs { + font-size: to_rem(12px); + + .breadcrumbs-parent-separator { + margin: 0 var(--grid-unit-5); + } + + .breadcrumbs-parent-block { + color: var(--Gutenberg-Gray-700, #757575); + } + + .breadcrumbs-current-block { + color: var(--sidebar-black); + + .breadcrumbs-current-block-name { + margin-left: var(--grid-unit-10); + } + } + } + + .components-divider { + width: to_rem(452px); + height: 1px; + border-color: #CCC; + } + + .wp-parsely-link-suggestion-link-details { + text-align: left; + height: auto; + margin-bottom: var(--grid-unit-20); + + .components-menu-item__item { + word-wrap: break-word; + white-space: normal; + } + } + + .review-controls { + display: flex; + width: 452px; + justify-content: space-between; + align-items: center; + flex-shrink: 0; + align-self: stretch; + margin: 0 var(--grid-unit-20); + + .reviews-controls-middle { + display: flex; + justify-content: center; + align-items: center; + gap: var(--grid-unit-20, 16px); + flex: 1 0 0; + } + + .wp-parsely-review-suggestion-previous, + .wp-parsely-review-suggestion-next { + color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)); + } + + .wp-parsely-review-suggestion-reject { + border-radius: 2px; + box-shadow: inset 0 0 0 1px var(--Gutenberg-Alert-Red, #CC1818); + background: var(--Gutenberg-White, #FFF); + color: var(--Gutenberg-Alert-Red, #CC1818); + } + } } } .wp-parsely-preview-editor { .block-editor-block-list__block { - pointer-events: none; /* Disables clicking and typing */ + //pointer-events: none; /* Disables clicking and typing */ } &.editor-styles-wrapper { padding-bottom: 0; + font-size: var(--font-size--medium); + } + + p[role="document"] { + margin: 0; + } + + .smart-linking-highlight { + border-radius: 2px; + background: hsla( var(--parsely-green-components), 0.5); + mix-blend-mode: multiply; + text-decoration-line: underline; } } diff --git a/src/content-helper/editor-sidebar/smart-linking/utils.ts b/src/content-helper/editor-sidebar/smart-linking/utils.ts index 130249d19..08fb34fca 100644 --- a/src/content-helper/editor-sidebar/smart-linking/utils.ts +++ b/src/content-helper/editor-sidebar/smart-linking/utils.ts @@ -1,3 +1,8 @@ +// eslint-disable-next-line import/named +import { BlockInstance, getBlockContent } from '@wordpress/blocks'; +import { LinkSuggestion } from './provider'; +import { escapeRegExp } from '../../common/utils/functions'; + export { escapeRegExp } from '../../common/utils/functions'; /** @@ -35,3 +40,114 @@ export function findTextNodesNotInAnchor( element: HTMLElement, searchText: stri } return textNodes; } + +interface NodePosition { + node: Node; + offset: number; +} +export function findNodeAtPosition( root: Node, position: number ): NodePosition | null { + const nodeIterator = document.createNodeIterator( root, NodeFilter.SHOW_TEXT ); + let currentPos = 0; + let currentNode: Node | null; + + while ( ( currentNode = nodeIterator.nextNode() ) ) { + const textNode = currentNode as Text; // Cast to Text for better type safety + const length = textNode.length; // Use .length directly on Text node + + if ( currentPos + length > position ) { + return { node: textNode, offset: position - currentPos }; + } + currentPos += length; + } + return null; +} + +export function flattenHTML( root: HTMLElement ): { flattened: string, positions: Array<{ node: Node, start: number, end: number }> } { + let result = ''; + const positions: Array<{ node: Node, start: number, end: number }> = []; + let currentPos = 0; + + const nodeIterator = document.createNodeIterator( root, NodeFilter.SHOW_ALL, { + acceptNode: ( node ) => { + if ( node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.TEXT_NODE ) { + return NodeFilter.FILTER_ACCEPT; + } + return NodeFilter.FILTER_REJECT; + }, + } ); + + let currentNode: Node | null; + while ( ( currentNode = nodeIterator.nextNode() ) ) { + if ( currentNode.nodeType === Node.TEXT_NODE ) { + const length = ( currentNode as Text ).length; + positions.push( { node: currentNode, start: currentPos, end: currentPos + length } ); + result += currentNode.textContent; + currentPos += length; + } else if ( currentNode.nodeType === Node.ELEMENT_NODE ) { + const element = currentNode as HTMLElement; + const openTag = `<${ element.tagName.toLowerCase() }>`; + const closeTag = ``; + result += openTag; + currentPos += openTag.length; + positions.push( { node: element, start: currentPos, end: currentPos } ); // Placeholder for elements + result += closeTag; + currentPos += closeTag.length; + } + } + return { flattened: result, positions }; +} + +/** + * Applies a HTML node to a block's content, replacing the text of the link with the HTML node. + * This is useful for applying a link to a block's content. + * + * @since 3.15.0 + * + * @param block + * @param link + * @param htmlNode + */ +export function applyNodeToBlock( block: BlockInstance, link: LinkSuggestion, htmlNode: HTMLElement ) { + const blockContent: string = getBlockContent( block ); + + const doc = new DOMParser().parseFromString( blockContent, 'text/html' ); + const contentElement = doc.body.firstChild; + + if ( ! contentElement || ! ( contentElement instanceof HTMLElement ) ) { + return; + } + + const textNodes = findTextNodesNotInAnchor( contentElement, link.text ); + + textNodes.forEach( ( node ) => { + if ( ! node.textContent ) { + return; + } + + const regex = new RegExp( escapeRegExp( link.text ), 'g' ); + let match; + while ( ( match = regex.exec( node.textContent ) ) !== null ) { + const anchor: HTMLElement = htmlNode; + anchor.textContent = match[ 0 ]; + + const range = document.createRange(); + range.setStart( node, match.index ); + range.setEnd( node, match.index + match[ 0 ].length ); + range.deleteContents(); + range.insertNode( anchor ); + + if ( + node.textContent && + match.index + match[ 0 ].length < node.textContent.length + ) { + const remainingText = document.createTextNode( + node.textContent.slice( match.index + match[ 0 ].length ) + ); + node.parentNode?.insertBefore( remainingText, anchor.nextSibling ); + } + } + } ); + + // Update the block content with the new content + block.attributes.content = contentElement.innerHTML; +} From c8f2f55a53ce84e22b96fe056314976597889d39 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Mon, 6 May 2024 10:48:26 +0100 Subject: [PATCH 06/44] Finalize modal with apply and reject actions --- src/Models/class-smart-link.php | 9 ++ .../smart-linking/component.tsx | 1 - .../editor-sidebar/smart-linking/provider.ts | 33 +++- .../review-modal/component-modal.tsx | 114 ++++++++++++-- .../review-modal/component-sidebar.tsx | 2 +- .../review-modal/component-suggestion.tsx | 26 +--- .../smart-linking/smart-linking.scss | 7 +- .../editor-sidebar/smart-linking/store.ts | 8 +- .../editor-sidebar/smart-linking/utils.ts | 147 +++++++++--------- 9 files changed, 233 insertions(+), 114 deletions(-) diff --git a/src/Models/class-smart-link.php b/src/Models/class-smart-link.php index 183607a7b..1e380aeb6 100644 --- a/src/Models/class-smart-link.php +++ b/src/Models/class-smart-link.php @@ -53,6 +53,13 @@ class Smart_Link extends Base_Model { */ public $uid; + /** + * Whether the link has been applied. + * + * @var bool Whether the link has been applied. + */ + public $applied; + /** * Smart Link constructor. * @@ -68,6 +75,7 @@ public function __construct( string $href, string $title, string $text, int $off $this->title = $title; $this->text = $text; $this->offset = $offset; + $this->applied = false; parent::__construct(); } @@ -101,6 +109,7 @@ public function serialize(): string { 'title' => $this->title, 'text' => $this->text, 'offset' => $this->offset, + 'applied' => $this->applied ) ); if ( false === $json ) { diff --git a/src/content-helper/editor-sidebar/smart-linking/component.tsx b/src/content-helper/editor-sidebar/smart-linking/component.tsx index 1e60855d9..7504d60e2 100644 --- a/src/content-helper/editor-sidebar/smart-linking/component.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/component.tsx @@ -745,7 +745,6 @@ export const SmartLinkingPanel = ( { setIsReviewModalOpen( false ) } - links={ suggestedLinks ?? [] } />
); diff --git a/src/content-helper/editor-sidebar/smart-linking/provider.ts b/src/content-helper/editor-sidebar/smart-linking/provider.ts index d1cf4f620..aa0131888 100644 --- a/src/content-helper/editor-sidebar/smart-linking/provider.ts +++ b/src/content-helper/editor-sidebar/smart-linking/provider.ts @@ -21,6 +21,7 @@ export type LinkSuggestion = { text: string; title: string; offset: number; + applied: boolean; match?: LinkSuggestionMatch; }; @@ -108,13 +109,14 @@ export class SmartLinkingProvider extends BaseProvider { offset: 0, }, ];*/ - return [ + /*return [ { uid: 'cf71c5c475bc7578013b7e6234832de4', href: 'http:\/\/wpvip.com\/2023\/02\/16\/wordpress-org-vs-wordpress-com-vs-wordpress-vip-whats-the-difference\/', title: 'wordpress.org vs wordpress.com vs wordpress vip: what\u2019s the difference?', text: 'WordPress Enterprise', offset: 0, + applied: false, }, { uid: 'f16cb0363e8705c4d2e8f7c94412b192', @@ -122,6 +124,7 @@ export class SmartLinkingProvider extends BaseProvider { title: 'wordpress.org vs wordpress.com vs wordpress vip: what\u2019s the difference?', text: 'WordPress VIP', offset: 1, + applied: false, }, { uid: '8809b316cced142250c66d35d2681f1e', @@ -129,6 +132,7 @@ export class SmartLinkingProvider extends BaseProvider { title: 'busting 10 myths about wordpress and wordpress vip', text: 'scalability', offset: 0, + applied: false, }, { uid: '0ecd03591abebc70c1b9ee6a8110b9a3', @@ -136,6 +140,33 @@ export class SmartLinkingProvider extends BaseProvider { title: 'a guide to choosing the most secure wordpress hosting', text: 'custom development, security, scalability, and high performance', offset: 0, + applied: false, + }, + ];*/ + return [ + { + uid: '6e507388132fe7a97f2efac112ed2ebd', + href: 'http:\/\/wpvip.com\/2021\/12\/23\/secure-wordpress-hosting\/', + title: 'a guide to choosing the most secure wordpress hosting', + text: 'platform', + offset: 0, + applied: false, + }, + { + uid: 'db7a115cc2ef900f2c066a897db4cf28', + href: 'http:\/\/wpvip.com\/2021\/06\/14\/yet-another-top-tier-award-for-wordpress-vip-in-hosting-performance-review\/', + title: '\u201cyet another\u201d top tier award for wordpress vip in hosting performance review', + text: 'performance', + offset: 1, + applied: false, + }, + { + uid: '751b0938f1ecc0ae17f1bc196c42ba98', + href: 'http:\/\/wpvip.com\/2021\/09\/15\/six-questions-with-zephr-about-first-party-data-and-the-customer-journey\/', + title: 'six questions with zephr about first-party data and the customer journey', + text: 'performance', + offset: 0, + applied: false, }, ]; const response = await this.fetch( { diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx index 878188f63..ad60a7033 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx @@ -1,53 +1,107 @@ import { BlockInstance } from '@wordpress/blocks'; import { Button, Modal } from '@wordpress/components'; +import { dispatch, select, useDispatch, useSelect } from '@wordpress/data'; import { useEffect, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { LinkSuggestion } from '../provider'; +import { SmartLinkingStore } from '../store'; +import { applyNodeToBlock } from '../utils'; import { ReviewModalSidebar } from './component-sidebar'; import { ReviewSuggestion } from './component-suggestion'; export type SmartLinkingReviewModalProps = { - links: LinkSuggestion[], onClose: () => void, isOpen: boolean, }; export const SmartLinkingReviewModal = ( { - links, onClose, isOpen, }: SmartLinkingReviewModalProps ): JSX.Element => { const [ showCloseDialog, setShowCloseDialog ] = useState( false ); const [ isModalOpen, setIsModalOpen ] = useState( isOpen ); - const [ selectedLink, setSelectedLink ] = useState( links[ 0 ] ); - const [ suggestedLinks, setSuggestedLinks ] = useState( links ); - //console.log( links, selectedLink ); + + /** + * Loads the Smart Linking store selectors. + * + * @since 3.15.0 + */ + const { + suggestedLinks, + } = useSelect( ( selectFn ) => { + const { getSuggestedLinks } = selectFn( SmartLinkingStore ); + return { + suggestedLinks: getSuggestedLinks(), + }; + }, [] ); + + const [ selectedLink, setSelectedLink ] = useState( suggestedLinks[ 0 ] ); + + /** + * Loads the Smart Linking store actions. + * + * @since 3.15.0 + */ + const { + setSuggestedLinks, + } = useDispatch( SmartLinkingStore ); // Set the first link as the selected link when the links are loaded. useEffect( () => { + //console.log( suggestedLinks ); // Filter out any links without a match - const filteredLinks = links.filter( ( link ) => link.match ); - setSuggestedLinks( filteredLinks ); - setSelectedLink( filteredLinks[ 0 ] ); - }, [ links ] ); + //const filteredLinks = links.filter( ( link ) => link.match ); + //setSuggestedLinks( filteredLinks ); + setSelectedLink( suggestedLinks[ 0 ] ); + }, [ suggestedLinks ] ); const showConfirmCloseDialog = () => setShowCloseDialog( true ); const hideConfirmCloseDialog = () => setShowCloseDialog( false ); /** - * Update the modal state when the `isOpen` prop changes. + * Updates the modal state when the `isOpen` prop changes. */ useEffect( () => { setIsModalOpen( isOpen ); }, [ isOpen ] ); + /** + * Applies the link to the block. + * + * @param {string} blockId The block instance to apply the link to. + * @param {LinkSuggestion} linkSuggestion The link suggestion to apply. + */ + const applyLinkToBlock = async ( blockId: string, linkSuggestion: LinkSuggestion ) => { + const anchor = document.createElement( 'a' ); + anchor.href = linkSuggestion.href; + anchor.title = linkSuggestion.title; + // Add data-smartlink attribute to the anchor tag + anchor.setAttribute( 'data-smartlink', 'true' ); + + const block = select( 'core/block-editor' ).getBlock( blockId ); + if ( ! block ) { + return; + } + + applyNodeToBlock( block, linkSuggestion, anchor ); + + // Update the block + dispatch( 'core/block-editor' ).updateBlock( blockId, block ); + + linkSuggestion.applied = true; + + // Update the link suggestions. + await setSuggestedLinks( suggestedLinks ); + }; + const onCloseHandler = () => { - console.log( 'onCloseHandler' ); + const pendingLinks = suggestedLinks.filter( ( link ) => ! link.applied ); + // Hide the modal. setIsModalOpen( false ); - if ( links ) { + if ( suggestedLinks && pendingLinks.length > 0 ) { showConfirmCloseDialog(); console.log( showCloseDialog ); return; @@ -98,10 +152,42 @@ export const SmartLinkingReviewModal = ( { setSelectedLink( suggestedLinks[ previousIndex ] ); } } onAccept={ () => { - console.log( 'onAccept' ); + if ( ! selectedLink.match ) { + return; + } + applyLinkToBlock( selectedLink.match.blockId, selectedLink ) + .then( () => { + const currentIndex = suggestedLinks.indexOf( selectedLink ); + const nextIndex = currentIndex + 1; + + // If there is a next link, select it, otherwise close the modal. + if ( suggestedLinks[ nextIndex ] ) { + setSelectedLink( suggestedLinks[ nextIndex ] ); + } else { + onCloseHandler(); + } + } ); } } onReject={ () => { - console.log( 'onReject' ); + // Change to the next link. + const currentIndex = suggestedLinks.indexOf( selectedLink ); + const nextIndex = currentIndex + 1; + + // Check if it exists. If not, try to go for the first one on the array. + // If there isn't any, close the modal + if ( ! suggestedLinks[ nextIndex ] ) { + if ( suggestedLinks[ 0 ] ) { + setSelectedLink( suggestedLinks[ 0 ] ); + } else { + onCloseHandler(); + } + } else { + setSelectedLink( suggestedLinks[ nextIndex ] ); + } + + // Delete the rejected link from the list. + suggestedLinks.splice( currentIndex, 1 ); + setSuggestedLinks( suggestedLinks ); } } /> diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx index 0edbcc11d..c8b2eb2da 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx @@ -22,7 +22,7 @@ export const ReviewModalSidebar = ( { { links?.map( ( link ) => ( { setSelectedLink( link ); diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx index 48d196211..dd8a1bb16 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx @@ -66,7 +66,7 @@ type StylesProps = { }[], }; const Styles = ( { styles }: StylesProps ): JSX.Element => { - // CSS Only styles + // Get onlt the theme and user styles. const filteredStyles = styles .filter( ( style ) => { return ( @@ -75,6 +75,7 @@ const Styles = ( { styles }: StylesProps ): JSX.Element => { ) && style.css; } ); + // Returns the styles, but replaces the body selector with the block editor selector. return ( <> { filteredStyles.map( ( style, index ) => ( @@ -94,30 +95,18 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { /** * Runs when the block is updated. * It will update the cloned block with the new block. + * + * @since 3.15.0 */ useEffect( () => { - console.log( 'Updating cloned block' ); setClonedBlock( cloneBlock( block ) ); }, [ block, link ] ); - /** - * Applies the link to the block. - * - * @param {BlockInstance} blockInstance The block instance to apply the link to. - * @param {LinkSuggestion} linkSuggestion The link suggestion to apply. - */ - const applyLinkToBlock = ( blockInstance: BlockInstance, linkSuggestion: LinkSuggestion ) => { - const anchor = document.createElement( 'a' ); - anchor.href = link.href; - anchor.title = link.title; - // Add data-smartlink attribute to the anchor tag - anchor.setAttribute( 'data-smartlink', 'true' ); - applyNodeToBlock( blockInstance, linkSuggestion, anchor ); - }; - /** * Highlights the link in the block. * + * @since 3.15.0 + * * @param {BlockInstance} blockInstance The block instance to highlight the link in. * @param {LinkSuggestion} linkSuggestion The link suggestion to highlight. */ @@ -130,12 +119,13 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { /** * Runs when the block is rendered in the DOM. * It will set the block element to be non-editable. + * + * @since 3.15.0 */ useEffect( () => { const blockPreviewElement = document.querySelector( '.wp-parsely-preview-editor' ); if ( ! blockPreviewElement ) { - console.log( 'Block preview element not found' ); return; } diff --git a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss index 950ce4225..128fa1ddb 100644 --- a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss +++ b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss @@ -309,6 +309,10 @@ .wp-parsely-review-suggestion-previous, .wp-parsely-review-suggestion-next { color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)); + + &:disabled { + visibility: hidden; + } } .wp-parsely-review-suggestion-reject { @@ -322,9 +326,6 @@ } .wp-parsely-preview-editor { - .block-editor-block-list__block { - //pointer-events: none; /* Disables clicking and typing */ - } &.editor-styles-wrapper { padding-bottom: 0; diff --git a/src/content-helper/editor-sidebar/smart-linking/store.ts b/src/content-helper/editor-sidebar/smart-linking/store.ts index f89d729ea..fd64ed423 100644 --- a/src/content-helper/editor-sidebar/smart-linking/store.ts +++ b/src/content-helper/editor-sidebar/smart-linking/store.ts @@ -385,8 +385,8 @@ export const SmartLinkingStore = createReduxStore( 'wp-parsely/smart-linking', { getMaxLinks( state: SmartLinkingState ): number { return state.settings.maxLinksPerPost ?? DEFAULT_MAX_LINKS; }, - getSuggestedLinks( state: SmartLinkingState ): LinkSuggestion[] | null { - return state.suggestedLinks; + getSuggestedLinks( state: SmartLinkingState ): LinkSuggestion[] { + return state.suggestedLinks ?? []; }, wasAlreadyClicked( state: SmartLinkingState ): boolean { return state.wasAlreadyClicked; @@ -397,6 +397,10 @@ export const SmartLinkingStore = createReduxStore( 'wp-parsely/smart-linking', { getRetryAttempt( state: SmartLinkingState ): number { return state.retryAttempt; }, + hasUnappliedLinks( state: SmartLinkingState ): boolean { + console.log( 'hasUnappliedLinks', state.suggestedLinks?.filter( ( link ) => ! link.applied ) ); + return state.suggestedLinks?.some( ( link ) => ! link.applied ) ?? false; + }, }, } ); diff --git a/src/content-helper/editor-sidebar/smart-linking/utils.ts b/src/content-helper/editor-sidebar/smart-linking/utils.ts index 08fb34fca..384888cc8 100644 --- a/src/content-helper/editor-sidebar/smart-linking/utils.ts +++ b/src/content-helper/editor-sidebar/smart-linking/utils.ts @@ -11,6 +11,8 @@ export { escapeRegExp } from '../../common/utils/functions'; * * @since 3.14.1 * + * @TODO: REMOVE + * * @param {HTMLElement} element - The element to search within. * @param {string} searchText - The text to search for. * @@ -41,113 +43,110 @@ export function findTextNodesNotInAnchor( element: HTMLElement, searchText: stri return textNodes; } -interface NodePosition { - node: Node; - offset: number; -} -export function findNodeAtPosition( root: Node, position: number ): NodePosition | null { - const nodeIterator = document.createNodeIterator( root, NodeFilter.SHOW_TEXT ); - let currentPos = 0; - let currentNode: Node | null; - - while ( ( currentNode = nodeIterator.nextNode() ) ) { - const textNode = currentNode as Text; // Cast to Text for better type safety - const length = textNode.length; // Use .length directly on Text node - - if ( currentPos + length > position ) { - return { node: textNode, offset: position - currentPos }; +/** + * Checks if a node is inside a similar node to a reference node. + * + * @since 3.15.0 + * + * @param {Node} node The node to check. + * @param {HTMLElement} referenceNode The reference node to compare against. + * + * @return {boolean} Whether the node is inside a similar node to the reference node. + */ +function isInsideSimilarNode( node: Node, referenceNode: HTMLElement ): boolean { + let currentNode = node.parentNode; + while ( currentNode ) { + // Check by nodeName or any specific attribute + if ( currentNode.nodeName === referenceNode.nodeName ) { + return true; } - currentPos += length; + currentNode = currentNode.parentNode; } - return null; + return false; } -export function flattenHTML( root: HTMLElement ): { flattened: string, positions: Array<{ node: Node, start: number, end: number }> } { - let result = ''; - const positions: Array<{ node: Node, start: number, end: number }> = []; - let currentPos = 0; - - const nodeIterator = document.createNodeIterator( root, NodeFilter.SHOW_ALL, { - acceptNode: ( node ) => { - if ( node.nodeType === Node.ELEMENT_NODE || node.nodeType === Node.TEXT_NODE ) { - return NodeFilter.FILTER_ACCEPT; - } - return NodeFilter.FILTER_REJECT; - }, - } ); - - let currentNode: Node | null; - while ( ( currentNode = nodeIterator.nextNode() ) ) { - if ( currentNode.nodeType === Node.TEXT_NODE ) { - const length = ( currentNode as Text ).length; - positions.push( { node: currentNode, start: currentPos, end: currentPos + length } ); - result += currentNode.textContent; - currentPos += length; - } else if ( currentNode.nodeType === Node.ELEMENT_NODE ) { - const element = currentNode as HTMLElement; - const openTag = `<${ element.tagName.toLowerCase() }>`; - const closeTag = ``; - result += openTag; - currentPos += openTag.length; - positions.push( { node: element, start: currentPos, end: currentPos } ); // Placeholder for elements - result += closeTag; - currentPos += closeTag.length; +/** + * Finds all text nodes in an element that contain a given search text and are not within a similar node. + * + * @since 3.15.0 + * + * @param {Node} element The element to search within. + * @param {string} searchText The text to search for. + * @param {HTMLElement} referenceNode The reference node to compare against. + * + * @return {Node[]} The text nodes that match the search text and are not within a similar node. + */ +function findTextNodesNotInSimilarNode( element: Node, searchText: string, referenceNode: HTMLElement ): Node[] { + const textNodes: Node[] = []; + const walker = document.createTreeWalker( element, NodeFilter.SHOW_TEXT, null ); + + while ( walker.nextNode() ) { + const node = walker.currentNode; + if ( node.textContent && node.textContent.includes( searchText ) && ! isInsideSimilarNode( node, referenceNode ) ) { + textNodes.push( node ); } } - return { flattened: result, positions }; + + return textNodes; } /** - * Applies a HTML node to a block's content, replacing the text of the link with the HTML node. + * Applies an HTML node to a block's content, replacing the text of the link with the HTML node. * This is useful for applying a link to a block's content. * * @since 3.15.0 * - * @param block - * @param link - * @param htmlNode + * @param {BlockInstance} block The block instance to apply the link to. + * @param {LinkSuggestion} link The link suggestion to apply. + * @param {HTMLElement} htmlNode The HTML node to apply to the block. */ export function applyNodeToBlock( block: BlockInstance, link: LinkSuggestion, htmlNode: HTMLElement ) { const blockContent: string = getBlockContent( block ); const doc = new DOMParser().parseFromString( blockContent, 'text/html' ); - const contentElement = doc.body.firstChild; + const contentElement = doc.body.firstChild as HTMLElement; - if ( ! contentElement || ! ( contentElement instanceof HTMLElement ) ) { + if ( ! contentElement ) { return; } - const textNodes = findTextNodesNotInAnchor( contentElement, link.text ); + const textNodes = findTextNodesNotInSimilarNode( contentElement, link.text, htmlNode ); + let occurrenceCount = 0; + let hasAddedNode = false; textNodes.forEach( ( node ) => { - if ( ! node.textContent ) { + if ( ! node.textContent || isInsideSimilarNode( node, htmlNode ) || hasAddedNode ) { return; } const regex = new RegExp( escapeRegExp( link.text ), 'g' ); let match; while ( ( match = regex.exec( node.textContent ) ) !== null ) { - const anchor: HTMLElement = htmlNode; - anchor.textContent = match[ 0 ]; - - const range = document.createRange(); - range.setStart( node, match.index ); - range.setEnd( node, match.index + match[ 0 ].length ); - range.deleteContents(); - range.insertNode( anchor ); - - if ( - node.textContent && - match.index + match[ 0 ].length < node.textContent.length - ) { - const remainingText = document.createTextNode( - node.textContent.slice( match.index + match[ 0 ].length ) - ); - node.parentNode?.insertBefore( remainingText, anchor.nextSibling ); + if ( occurrenceCount === link.offset ) { + const anchor: HTMLElement = htmlNode.cloneNode( true ) as HTMLElement; + anchor.textContent = match[ 0 ]; + + const range = document.createRange(); + range.setStart( node, match.index ); + range.setEnd( node, match.index + match[ 0 ].length ); + range.deleteContents(); + range.insertNode( anchor ); + + if ( node.textContent && match.index + match[ 0 ].length < node.textContent.length ) { + const remainingText = document.createTextNode( + node.textContent.slice( match.index + match[ 0 ].length ) + ); + node.parentNode?.insertBefore( remainingText, anchor.nextSibling ); + } + + hasAddedNode = true; + + return; } + occurrenceCount++; } } ); - // Update the block content with the new content + // Update the block content with the new content. block.attributes.content = contentElement.innerHTML; } From ea5059f5e432a56d98960be9d79f4172c77f9a2b Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Mon, 6 May 2024 12:51:55 +0100 Subject: [PATCH 07/44] Add Remove Link and Select in Editor buttons --- .../smart-linking/component.tsx | 310 +++++------------- .../editor-sidebar/smart-linking/provider.ts | 16 +- .../review-modal/component-modal.tsx | 94 +++++- .../review-modal/component-sidebar.tsx | 8 +- .../review-modal/component-suggestion.tsx | 71 ++-- .../smart-linking/smart-linking.scss | 2 +- .../editor-sidebar/smart-linking/store.ts | 10 +- .../editor-sidebar/smart-linking/utils.ts | 8 +- 8 files changed, 236 insertions(+), 283 deletions(-) diff --git a/src/content-helper/editor-sidebar/smart-linking/component.tsx b/src/content-helper/editor-sidebar/smart-linking/component.tsx index 7504d60e2..c76915323 100644 --- a/src/content-helper/editor-sidebar/smart-linking/component.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/component.tsx @@ -2,11 +2,11 @@ * WordPress dependencies */ // eslint-disable-next-line import/named -import { BlockInstance } from '@wordpress/blocks'; +import { BlockInstance, getBlockContent } from '@wordpress/blocks'; import { Button, Notice, PanelRow } from '@wordpress/components'; import { useDebounce } from '@wordpress/compose'; -import { dispatch, select, useDispatch, useSelect } from '@wordpress/data'; -import { useCallback, useEffect, useState } from '@wordpress/element'; +import { dispatch, useDispatch, useSelect } from '@wordpress/data'; +import { useEffect, useState } from '@wordpress/element'; import { __, _n, sprintf } from '@wordpress/i18n'; import { Icon, external } from '@wordpress/icons'; @@ -20,7 +20,7 @@ import { SidebarSettings, SmartLinkingSettings, useSettings } from '../../common import { generateProtocolVariants } from '../../common/utils/functions'; import { SmartLinkingReviewModal } from './review-modal/component-modal'; import { SmartLinkingSettings as SmartLinkingSettingsComponent } from './component-settings'; -import { LinkSuggestion, SmartLinkingProvider } from './provider'; +import { SmartLink, SmartLinkingProvider } from './provider'; import { ApplyToOptions, SmartLinkingSettingsProps, SmartLinkingStore } from './store'; import { escapeRegExp, findTextNodesNotInAnchor } from './utils'; @@ -39,16 +39,6 @@ type LinkOccurrenceCounts = { }; }; -/** - * Represents an update to a block's content. - * - * @since 3.14.3 - */ -type BlockUpdate = { - clientId: string; - newContent: string; -}; - /** * Defines the props structure for SmartLinkingPanel. * @@ -96,10 +86,30 @@ export const SmartLinkingPanel = ( { const setSettingsDebounced = useDebounce( setSettings, 500 ); const [ numAddedLinks, setNumAddedLinks ] = useState( 0 ); + const [ isReviewDone, setIsReviewDone ] = useState( false ); const [ isReviewModalOpen, setIsReviewModalOpen ] = useState( false ); const { createNotice } = useDispatch( 'core/notices' ); + /** + * Handles the ending of the review process. + */ + useEffect( () => { + console.log( isReviewDone, numAddedLinks ); + if ( ! isReviewDone ) { + setNumAddedLinks( 0 ); + } else { + createNotice( + 'success', + /* translators: %d: number of smart links applied */ + sprintf( __( '%s smart links successfully applied.', 'wp-parsely' ), numAddedLinks ), + { + type: 'snackbar', + }, + ); + } + }, [ isReviewDone ] ); // eslint-disable-line react-hooks/exhaustive-deps + /** * Loads the Smart Linking store. * @@ -242,28 +252,12 @@ export const SmartLinkingPanel = ( { [ selectedBlockClientId ], ); - const processSmartLinks = async ( links: LinkSuggestion[] ) => { + const processSmartLinks = async ( links: SmartLink[] ) => { // An object to keep track of the number of times each link text has been found across all blocks. const occurrenceCounts: LinkOccurrenceCounts = {}; // Apply the smart links to the content. - - /** - * Given a list of blocks, find the links in the blocks HTML content, and update the links with the matches. - * The position of the link must take into consideration the HTML structure of the block. - * - * @param blocks - * @param links - * @param occurrenceCounts - */ - const findLinksInBlocks = ( blocks: Readonly[], links: LinkSuggestion[], occurrenceCounts: LinkOccurrenceCounts ) => { - // Loop all the blocks - blocks.forEach( ( block ) => { - - } ); - }; - - applyLinksToBlocks( allBlocks, links, occurrenceCounts ); + calculateSmartLinkingMatches( allBlocks, links, occurrenceCounts ); // Update the link suggestions with the new matches await setSuggestedLinks( links ); @@ -273,14 +267,12 @@ export const SmartLinkingPanel = ( { * Generates smart links for the selected block or the entire post content. * * @since 3.14.0 - * @since 3.15.0 Renamed from `generateSmartLinks` to `generateSmartLinks`. */ const generateSmartLinks = async () => { await setLoading( true ); await setSuggestedLinks( null ); await setError( null ); - - console.log( 'generateSmartLinks' ); + setIsReviewDone( false ); Telemetry.trackEvent( 'smart_linking_generate_pressed', { is_full_content: isFullContent, @@ -344,10 +336,10 @@ export const SmartLinkingPanel = ( { * * @param {number} retries The number of retries remaining. * - * @return {Promise} The generated smart links. + * @return {Promise} The generated smart links. */ - const generateSmartLinksWithRetry = async ( retries: number ): Promise => { - let generatedLinks: LinkSuggestion[] = []; + const generateSmartLinksWithRetry = async ( retries: number ): Promise => { + let generatedLinks: SmartLink[] = []; try { const generatingFullContent = isFullContent || ! selectedBlock; await setApplyTo( generatingFullContent ? ApplyToOptions.All : ApplyToOptions.Selected ); @@ -384,78 +376,31 @@ export const SmartLinkingPanel = ( { }; /** - * Applies the smart links to the selected block or the entire post content. + * Iterates through blocks of content to apply smart link suggestions based on their text content and specific offset. * - * @since 3.14.0 - * @since 3.14.1 Moved applyLinksToBlocks to a separate function. + * This function processes each block's content to identify and handle text nodes that match provided link suggestions. + * It filters out self-referencing links based on the given post permalink, avoids inserting links within existing anchor + * elements, and respects the specified offset for each link to determine the correct block. * - * @param {LinkSuggestion[]} links The smart links to apply. - */ - const applySmartLinks = ( links: LinkSuggestion[] ): void => { - Telemetry.trackEvent( 'smart_linking_applied', { - is_full_content: isFullContent || ! selectedBlock, - selected_block: selectedBlock?.name ?? 'none', - links_count: links.length, - context, - } ); - - let blocks; - if ( selectedBlock && ! isFullContent ) { - blocks = [ selectedBlock ]; - } else { - blocks = allBlocks; - } - - // An object to keep track of the number of times each link text has been found across all blocks. - const occurrenceCounts: LinkOccurrenceCounts = {}; - const updatedBlocks: BlockUpdate[] = []; - - // Apply the smart links to the content. - applyLinksToBlocks( blocks, links, occurrenceCounts ); - - // Update the content of each block. - updateBlocksContent( updatedBlocks ); - - const numberOfUpdatedLinks = Object.values( occurrenceCounts ).reduce( ( acc, occurrenceCount ) => { - return acc + occurrenceCount.linked; - }, 0 ); - - setNumAddedLinks( numberOfUpdatedLinks ); - - createNotice( - 'success', - /* translators: %d: number of smart links applied */ - sprintf( __( '%s smart links successfully applied.', 'wp-parsely' ), numberOfUpdatedLinks ), - { - type: 'snackbar', - }, - ); - }; - - /** - * Iterates through blocks of content to apply smart link suggestions. - * - * This function parses the content of each block, looking for text nodes that match the provided link suggestions. - * When a match is found, it creates an anchor element (``) around the matching text with the specified href and - * title from the link suggestion. - * It carefully avoids inserting links within existing anchor elements and handles various inline HTML elements gracefully. + * Note: The function is recursive for blocks containing inner blocks, ensuring all nested content is processed. * - * @since 3.14.1 + * @since 3.15.0 * - * @param {BlockInstance[]} blocks The blocks of content where links should be applied. - * @param {LinkSuggestion[]} links An array of link suggestions to apply to the content. - * @param {LinkOccurrenceCounts} occurrenceCounts An object to keep track of the number of times each link text has - * been applied across all blocks. + * @param {Readonly[]} blocks The blocks of content where links should be applied. + * @param {SmartLink[]} links An array of link suggestions to apply to the content. + * @param {LinkOccurrenceCounts} occurrenceCounts An object to keep track of the number of times each link text has + * been encountered and applied across all blocks. */ - const applyLinksToBlocks = ( + const calculateSmartLinkingMatches = ( blocks: Readonly[], - links: LinkSuggestion[], + links: SmartLink[], occurrenceCounts: LinkOccurrenceCounts, ): void => { - // Check if any of the links being applied is a self-reference, and remove it if it is. + // Simplify permalink stripping. const strippedPermalink = postPermalink - .replace( /^https?:\/\//, '' ) // Remove HTTP(S). - .replace( /\/+$/, '' ); // Remove trailing slash. + .replace( /^https?:\/\//, '' ).replace( /\/+$/, '' ); + + // Filter out self-referencing links. links = links.filter( ( link ) => { if ( link.href.includes( strippedPermalink ) ) { // eslint-disable-next-line no-console @@ -466,138 +411,44 @@ export const SmartLinkingPanel = ( { } ); blocks.forEach( ( block ) => { - // Recursively apply links to any inner blocks. - if ( block.innerBlocks && block.innerBlocks.length ) { - applyLinksToBlocks( block.innerBlocks, links, occurrenceCounts ); + // Handle inner blocks. + if ( block.innerBlocks?.length ) { + calculateSmartLinkingMatches( block.innerBlocks, links, occurrenceCounts ); return; } - if ( block.originalContent ) { - const blockContent: string = block.originalContent; - const doc = new DOMParser().parseFromString( blockContent, 'text/html' ); - - const contentElement = doc.body.firstChild; - if ( contentElement && contentElement instanceof HTMLElement ) { - links.forEach( ( link ) => { - const textNodes = findTextNodesNotInAnchor( contentElement, link.text ); - const occurrenceKey = `${ link.text }#${ link.offset }`; - - if ( ! occurrenceCounts[ occurrenceKey ] ) { - occurrenceCounts[ occurrenceKey ] = { encountered: 0, linked: 0 }; - } - - textNodes.forEach( ( node ) => { - if ( node.textContent ) { - const occurrenceCount = occurrenceCounts[ occurrenceKey ]; - if ( occurrenceCount.linked >= 1 ) { - // The link has already been applied, skip this occurrence. - return; - } - - const regex = new RegExp( escapeRegExp( link.text ), 'g' ); - let match; - while ( ( match = regex.exec( node.textContent ) ) !== null ) { - // Increment the encountered count every time the text is found. - occurrenceCount.encountered++; - - // Check if the link is in the correct position (offset) to be applied. - if ( occurrenceCount.encountered === link.offset + 1 ) { - // Create a new anchor element for the link. - /*const anchor = document.createElement( 'a' ); - anchor.href = link.href; - anchor.title = link.title; - anchor.textContent = match[ 0 ];*/ - - // Increment the linked count only when a link is applied. - occurrenceCount.linked++; - - // Update the LinkSuggestion to include the match - link.match = { - blockId: block.clientId, - startAt: getNodeOffset( contentElement, node ) + match.index, - endAt: getNodeOffset( contentElement, node ) + match.index + match[ 0 ].length, - }; - - // Replace the matched text with the new anchor element. - /*const range = document.createRange(); - range.setStart( node, match.index ); - range.setEnd( node, match.index + match[ 0 ].length ); - range.deleteContents(); - range.insertNode( anchor ); - - // Adjust the text node if there's text remaining after the link. - if ( - node.textContent && - match.index + match[ 0 ].length < node.textContent.length - ) { - const remainingText = document.createTextNode( - node.textContent.slice( match.index + match[ 0 ].length ) - ); - node.parentNode?.insertBefore( remainingText, anchor.nextSibling ); - }*/ - } - } - } - } ); - } ); - } - } - } ); - }; - - const getNodeOffset = ( parent: HTMLElement, node: Node ): number => { - let offset = 0; - let currentNode: Node | null = parent.firstChild; - - while ( currentNode !== node && currentNode !== null ) { - if ( currentNode.nodeType === Node.TEXT_NODE ) { - offset += ( currentNode.textContent || '' ).length; - } else if ( currentNode.nodeType === Node.ELEMENT_NODE ) { - // Using outerHTML property for HTMLElement nodes - const html = ( currentNode as HTMLElement ).outerHTML || ''; - offset += html.length; + // Skip blocks without original content. + if ( ! block.originalContent ) { + return; } - currentNode = currentNode.nextSibling; - } - - return offset; - }; - - /** - * Updates the content of a block with the modified HTML. - * - * This function updates the originalContent attribute of the block with the modified HTML. - * It also recursively updates the content of any inner blocks. - * - * @since 3.14.1 - * @since 3.14.3 Rename the function from updateBlockContent to updateBlocksContent. - * - * @param {BlockUpdate[]} blockUpdates An array of block updates. - */ - const updateBlocksContent = ( blockUpdates: BlockUpdate[] ) => { - const { getBlock } = select( 'core/block-editor' ); - const updatedBlocks: { [clientId: string]: object } = {}; - // Prepare the updated blocks object. - blockUpdates.forEach( ( blockUpdate ) => { - const block = getBlock( blockUpdate.clientId ); + const blockContent: string = getBlockContent( block ); + const doc = new DOMParser().parseFromString( blockContent, 'text/html' ); + const contentElement = doc.body.firstChild; - if ( ! block ) { + if ( ! ( contentElement instanceof HTMLElement ) ) { return; } - updatedBlocks[ block.clientId ] = { - content: blockUpdate.newContent, - }; - } ); + links.forEach( ( link ) => { + const textNodes = findTextNodesNotInAnchor( contentElement, link.text ); + const occurrenceKey = `${ link.text }#${ link.offset }`; + occurrenceCounts[ occurrenceKey ] = occurrenceCounts[ occurrenceKey ] || { encountered: 0, linked: 0 }; - // Update the blocks attributes. - dispatch( 'core/block-editor' ).updateBlockAttributes( - Object.keys( updatedBlocks ), - updatedBlocks, - // @ts-ignore - The uniqueByBlock parameter is not available in the type definition. - true, - ); + textNodes.forEach( ( node ) => { + const regex = new RegExp( escapeRegExp( link.text ), 'g' ); + while ( regex.exec( node.textContent ?? '' ) !== null ) { + const occurrenceCount = occurrenceCounts[ occurrenceKey ]; + occurrenceCount.encountered++; + + if ( occurrenceCount.encountered === link.offset + 1 && occurrenceCount.linked < 1 ) { + occurrenceCount.linked++; + link.match = { blockId: block.clientId }; + } + } + } ); + } ); + } ); }; /** @@ -710,10 +561,10 @@ export const SmartLinkingPanel = ( { { error.Message() } ) } - { suggestedLinks !== null && ( + { ( isReviewDone && numAddedLinks > 0 ) && ( setSuggestedLinks( null ) } + onRemove={ () => setIsReviewDone( false ) } className="wp-parsely-smart-linking-suggested-links" > { @@ -744,7 +595,14 @@ export const SmartLinkingPanel = ( { setIsReviewModalOpen( false ) } + onAppliedLink={ () => { + console.log( 'Link applied' ); + setNumAddedLinks( ( num ) => num + 1 ); + } } + onClose={ () => { + setIsReviewDone( true ); + setIsReviewModalOpen( false ); + } } /> ); diff --git a/src/content-helper/editor-sidebar/smart-linking/provider.ts b/src/content-helper/editor-sidebar/smart-linking/provider.ts index aa0131888..8a1b3e2f1 100644 --- a/src/content-helper/editor-sidebar/smart-linking/provider.ts +++ b/src/content-helper/editor-sidebar/smart-linking/provider.ts @@ -15,24 +15,22 @@ import { DEFAULT_MAX_LINK_WORDS, DEFAULT_MAX_LINKS } from './smart-linking'; * * @since 3.14.0 */ -export type LinkSuggestion = { - uid?: string; +export type SmartLink = { + uid: string; href: string; text: string; title: string; offset: number; applied: boolean; - match?: LinkSuggestionMatch; + match?: SmartLinkMatch; }; /** * Structure of a link suggestion match, that is filled in by the * processing of the smart links. */ -export type LinkSuggestionMatch = { +export type SmartLinkMatch = { blockId: string; - startAt: number; - endAt: number; } /** @@ -71,14 +69,14 @@ export class SmartLinkingProvider extends BaseProvider { * @param {number} maxLinksPerPost The maximum number of links to return. * @param {string[]} urlExclusionList A list of URLs to exclude from the suggestions. * - * @return {Promise} The resulting list of links. + * @return {Promise} The resulting list of links. */ public async generateSmartLinks( content: string, maxLinkWords: number = DEFAULT_MAX_LINK_WORDS, maxLinksPerPost: number = DEFAULT_MAX_LINKS, urlExclusionList: string[] = [], - ): Promise { + ): Promise { /*return [ { uid: '3ba4e35e2eca3002207b63fac3c0911b', @@ -169,7 +167,7 @@ export class SmartLinkingProvider extends BaseProvider { applied: false, }, ]; - const response = await this.fetch( { + const response = await this.fetch( { method: 'POST', path: addQueryArgs( '/wp-parsely/v1/content-suggestions/suggest-linked-reference', { max_link_words: maxLinkWords, diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx index ad60a7033..34e61245d 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx @@ -1,10 +1,10 @@ -import { BlockInstance } from '@wordpress/blocks'; +import { BlockInstance, getBlockContent } from '@wordpress/blocks'; import { Button, Modal } from '@wordpress/components'; import { dispatch, select, useDispatch, useSelect } from '@wordpress/data'; import { useEffect, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; -import { LinkSuggestion } from '../provider'; +import { SmartLink } from '../provider'; import { SmartLinkingStore } from '../store'; import { applyNodeToBlock } from '../utils'; import { ReviewModalSidebar } from './component-sidebar'; @@ -13,11 +13,13 @@ import { ReviewSuggestion } from './component-suggestion'; export type SmartLinkingReviewModalProps = { onClose: () => void, isOpen: boolean, + onAppliedLink: ( link: SmartLink ) => void, }; export const SmartLinkingReviewModal = ( { onClose, isOpen, + onAppliedLink, }: SmartLinkingReviewModalProps ): JSX.Element => { const [ showCloseDialog, setShowCloseDialog ] = useState( false ); const [ isModalOpen, setIsModalOpen ] = useState( isOpen ); @@ -36,7 +38,7 @@ export const SmartLinkingReviewModal = ( { }; }, [] ); - const [ selectedLink, setSelectedLink ] = useState( suggestedLinks[ 0 ] ); + const [ selectedLink, setSelectedLink ] = useState( suggestedLinks[ 0 ] ); /** * Loads the Smart Linking store actions. @@ -69,15 +71,15 @@ export const SmartLinkingReviewModal = ( { /** * Applies the link to the block. * - * @param {string} blockId The block instance to apply the link to. - * @param {LinkSuggestion} linkSuggestion The link suggestion to apply. + * @param {string} blockId The block instance to apply the link to. + * @param {SmartLink} linkSuggestion The link suggestion to apply. */ - const applyLinkToBlock = async ( blockId: string, linkSuggestion: LinkSuggestion ) => { + const applyLinkToBlock = async ( blockId: string, linkSuggestion: SmartLink ) => { const anchor = document.createElement( 'a' ); anchor.href = linkSuggestion.href; anchor.title = linkSuggestion.title; - // Add data-smartlink attribute to the anchor tag - anchor.setAttribute( 'data-smartlink', 'true' ); + // Add data-smartlink attribute to the anchor tag. + anchor.setAttribute( 'data-smartlink', linkSuggestion.uid ); const block = select( 'core/block-editor' ).getBlock( blockId ); if ( ! block ) { @@ -86,7 +88,7 @@ export const SmartLinkingReviewModal = ( { applyNodeToBlock( block, linkSuggestion, anchor ); - // Update the block + // Update the block. dispatch( 'core/block-editor' ).updateBlock( blockId, block ); linkSuggestion.applied = true; @@ -95,6 +97,48 @@ export const SmartLinkingReviewModal = ( { await setSuggestedLinks( suggestedLinks ); }; + /** + * Removes a Smart Link from a block. + * + * @since 3.15.0 + * + * @param {BlockInstance} block The block instance to remove the link from. + * @param {SmartLink} linkSuggestion The link suggestion to remove. + */ + const removeLinkFromBlock = ( block: BlockInstance, linkSuggestion: SmartLink ) => { + const blockId = block.clientId; + if ( ! block ) { + return; + } + + const blockContent: string = getBlockContent( block ); + const doc = new DOMParser().parseFromString( blockContent, 'text/html' ); + const contentElement = doc.body.firstChild as HTMLElement; + + if ( ! contentElement ) { + return; + } + + let anchors = Array.from( contentElement.querySelectorAll( 'a' ) ); + anchors = anchors.filter( ( anchor ) => anchor.href === linkSuggestion.href && anchor.textContent?.includes( linkSuggestion.text ) ); + + if ( anchors.length > linkSuggestion.offset ) { + const anchorToRemove = anchors[ linkSuggestion.offset ]; + if ( anchorToRemove ) { + const parentNode = anchorToRemove.parentNode; + if ( parentNode ) { + // Replace the anchor with its text content + const textNode = document.createTextNode( anchorToRemove.textContent || '' ); + parentNode.replaceChild( textNode, anchorToRemove ); + + // Update the block content + block.attributes.content = contentElement.innerHTML; + dispatch( 'core/block-editor' ).updateBlock( blockId, block ); + } + } + } + }; + const onCloseHandler = () => { const pendingLinks = suggestedLinks.filter( ( link ) => ! link.applied ); @@ -103,15 +147,14 @@ export const SmartLinkingReviewModal = ( { if ( suggestedLinks && pendingLinks.length > 0 ) { showConfirmCloseDialog(); - console.log( showCloseDialog ); return; } + // Close after 200ms. onClose(); }; const onCloseConfirmCloseDialog = ( shouldClose: boolean ) => { - console.log( 'onCloseConfirmCloseDialog' ); hideConfirmCloseDialog(); if ( shouldClose ) { setIsModalOpen( false ); @@ -155,6 +198,7 @@ export const SmartLinkingReviewModal = ( { if ( ! selectedLink.match ) { return; } + onAppliedLink( selectedLink ); applyLinkToBlock( selectedLink.match.blockId, selectedLink ) .then( () => { const currentIndex = suggestedLinks.indexOf( selectedLink ); @@ -189,6 +233,34 @@ export const SmartLinkingReviewModal = ( { suggestedLinks.splice( currentIndex, 1 ); setSuggestedLinks( suggestedLinks ); } } + onRemove={ () => { + if ( ! selectedLink.match ) { + return; + } + + const block = select( 'core/block-editor' ).getBlock( selectedLink.match.blockId ); + if ( block ) { + removeLinkFromBlock( block, selectedLink ); + + // Remove the link suggestion from the list + suggestedLinks.splice( suggestedLinks.indexOf( selectedLink ), 1 ); + setSuggestedLinks( suggestedLinks ); + } + } } + onSelectInEditor={ () => { + if ( ! selectedLink.match ) { + return; + } + + const block = select( 'core/block-editor' ).getBlock( selectedLink.match.blockId ); + if ( block ) { + // Select the block in the editor + dispatch( 'core/block-editor' ).selectBlock( block.clientId ); + + // Close the modal + onCloseHandler(); + } + } } /> diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx index c8b2eb2da..94464d246 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx @@ -1,10 +1,10 @@ import { MenuItem } from '@wordpress/components'; -import { LinkSuggestion } from '../provider'; +import { SmartLink } from '../provider'; type ReviewModalSidebarProps = { - activeLink: LinkSuggestion | null, - links: LinkSuggestion[] | null, - setSelectedLink: ( link: LinkSuggestion ) => void, + activeLink: SmartLink | null, + links: SmartLink[] | null, + setSelectedLink: ( link: SmartLink ) => void, }; export const ReviewModalSidebar = ( { diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx index dd8a1bb16..d3c91ea90 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx @@ -5,12 +5,12 @@ import { useEffect, useState } from '@wordpress/element'; import { arrowLeft, arrowRight, check, closeSmall, Icon, page } from '@wordpress/icons'; import { filterURLForDisplay } from '@wordpress/url'; import { GutenbergFunction } from '../../../../@types/gutenberg/types'; -import { LinkSuggestion } from '../provider'; +import { SmartLink } from '../provider'; import { BlockEditorProvider, BlockList, ObserveTyping, WritingFlow } from '@wordpress/block-editor'; import { applyNodeToBlock } from '../utils'; type SuggestionBreadcrumbProps = { - link: LinkSuggestion, + link: SmartLink, }; const SuggestionBreadcrumb = ( { link }: SuggestionBreadcrumbProps ): JSX.Element => { const blockId = link.match?.blockId; @@ -87,7 +87,7 @@ const Styles = ( { styles }: StylesProps ): JSX.Element => { type BlockPreviewProps = { block: BlockInstance, - link: LinkSuggestion, + link: SmartLink, } const BlockPreview = ( { block, link }: BlockPreviewProps ) => { const [ clonedBlock, setClonedBlock ] = useState( cloneBlock( block ) ); @@ -108,9 +108,9 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { * @since 3.15.0 * * @param {BlockInstance} blockInstance The block instance to highlight the link in. - * @param {LinkSuggestion} linkSuggestion The link suggestion to highlight. + * @param {SmartLink} linkSuggestion The link suggestion to highlight. */ - const highlightLinkInBlock = ( blockInstance: BlockInstance, linkSuggestion: LinkSuggestion ) => { + const highlightLinkInBlock = ( blockInstance: BlockInstance, linkSuggestion: SmartLink ) => { const mark = document.createElement( 'mark' ); mark.className = 'smart-linking-highlight'; applyNodeToBlock( blockInstance, linkSuggestion, mark ); @@ -186,7 +186,7 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { ); }; -const LinkDetails = ( { link }: { link: LinkSuggestion } ): JSX.Element => { +const LinkDetails = ( { link }: { link: SmartLink } ): JSX.Element => { // Get the post type by the permalink const displayUrl = filterURLForDisplay( link.href, 30 ); @@ -204,11 +204,13 @@ const LinkDetails = ( { link }: { link: LinkSuggestion } ): JSX.Element => { }; type ReviewSuggestionProps = { - link: LinkSuggestion, + link: SmartLink, onNext: () => void, onPrevious: () => void, onAccept: () => void, onReject: () => void, + onRemove: () => void, + onSelectInEditor: () => void, hasPrevious: boolean, hasNext: boolean, }; @@ -219,6 +221,8 @@ export const ReviewSuggestion = ( { onPrevious, onAccept, onReject, + onRemove, + onSelectInEditor, hasPrevious, hasNext, }: ReviewSuggestionProps ): JSX.Element => { @@ -229,6 +233,7 @@ export const ReviewSuggestion = ( { const blockId = link.match.blockId; // Get the block const block = selectFn( 'core/block-editor' ).getBlock( blockId ); + const isApplied = link.applied; if ( ! block ) { return <>No block!; @@ -249,21 +254,43 @@ export const ReviewSuggestion = ( { onClick={ onPrevious } icon={ arrowLeft }>Previous
- - + { ! isApplied && ( + <> + + + + ) } + { isApplied && ( + <> + + + + ) }
+ { isManageButtonVisible && ( +
+ +
+ ) } { - console.log( 'Link applied' ); setNumAddedLinks( ( num ) => num + 1 ); } } onClose={ () => { setIsReviewDone( true ); setIsReviewModalOpen( false ); + + if ( getSmartLinksFn().length > 0 ) { + setIsManageButtonVisible( true ); + } else { + setIsManageButtonVisible( false ); + } } } /> diff --git a/src/content-helper/editor-sidebar/smart-linking/provider.ts b/src/content-helper/editor-sidebar/smart-linking/provider.ts index fc127b911..a97ee0b79 100644 --- a/src/content-helper/editor-sidebar/smart-linking/provider.ts +++ b/src/content-helper/editor-sidebar/smart-linking/provider.ts @@ -31,6 +31,7 @@ export type SmartLink = { */ export type SmartLinkMatch = { blockId: string; + blockOffset: number; } /** @@ -141,6 +142,7 @@ export class SmartLinkingProvider extends BaseProvider { applied: false, }, ];*/ + /* return [ { uid: '6e507388132fe7a97f2efac112ed2ebd', @@ -166,6 +168,88 @@ export class SmartLinkingProvider extends BaseProvider { offset: 0, applied: false, }, + ];*/ + return [ + { + uid: '06187a56038c3aa8242b0fb98a1b5e5b', + href: 'http:\/\/wpvip.com\/2023\/02\/16\/wordpress-org-vs-wordpress-com-vs-wordpress-vip-whats-the-difference\/', + title: 'wordpress.org vs wordpress.com vs wordpress vip: what\u2019s the difference?', + text: 'scalability', + offset: 1, + applied: false, + }, + { + uid: '9d96d7a99cb750296acfabf242be9aa9', + href: 'http:\/\/wpvip.com\/2021\/08\/19\/pros-and-cons-of-a-headless-cms\/', + title: 'headless wordpress: pros and cons of a headless cms', + text: 'content management', + offset: 0, + applied: false, + }, + { + uid: '56998f94ba8960d8ab61bf4e4647f0ce', + href: 'http:\/\/wpvip.com\/2019\/06\/19\/wordpress-vip-agency-partners\/', + title: 'vip expands featured agency partner program to meet increasing client demand', + text: 'WordPress VIP', + offset: 1, + applied: false, + }, + { + uid: '26654b91191cc0c89a2120c092904e1e', + href: 'http:\/\/wpvip.com\/2021\/05\/20\/wordpress-vip-is-fedramp-authorized\/', + title: 'wordpress vip is fedramp authorized', + text: 'WordPress VIP', + offset: 3, + applied: false, + }, + { + uid: '6375ed150e43196210ee0c9efce57ec8', + href: 'http:\/\/wpvip.com\/2021\/12\/23\/secure-wordpress-hosting\/', + title: 'a guide to choosing the most secure wordpress hosting', + text: 'WordPress Enterprise', + offset: 7, + applied: false, + }, + { + uid: '0b1219ad6028972533cce67e651b8924', + href: 'http:\/\/wpvip.com\/2022\/05\/12\/how-open-source-software-benefits-businesses\/', + title: 'how open source software benefits businesses', + text: 'security', + offset: 1, + applied: false, + }, + { + uid: '1538c3bbbbd2ddd456e4900fba08fe75', + href: 'http:\/\/wpvip.com\/2021\/07\/21\/gutenberg-full-site-editing\/', + title: 'gutenberg full-site editing is here\u2014what it means for enterprises', + text: 'custom development', + offset: 1, + applied: false, + }, + { + uid: '4c9a2d36627ec108fea34f6c54460803', + href: 'http:\/\/wpvip.com\/2020\/07\/30\/its-official-the-future-is-vip-go\/', + title: 'it\u2019s official: the future is vip go!', + text: 'WordPress VIP', + offset: 4, + applied: false, + }, + { + uid: 'aa08a8f855c8bba2b0a4a7654806b973', + href: 'http:\/\/wpvip.com\/2018\/01\/30\/wordpress-hosting-2018-fastest\/', + title: 'independent speed and performance analysis finds wordpress vip fastest among top tier hosts', + text: 'performance optimization', + offset: 1, + applied: false, + }, + { + uid: '02a78ae49d95f17677ec189ff1c94dbc', + href: 'http:\/\/wpvip.com\/2023\/01\/26\/analytics-wordpress\/', + title: 'use the best wordpress analytics plugin: parse.ly', + text: 'WordPress Enterprise', + offset: 5, + applied: false, + }, ]; const response = await this.fetch( { method: 'POST', diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx index 2ee6a4d9f..9dafff959 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx @@ -1,11 +1,12 @@ +// eslint-disable-next-line import/named import { BlockInstance, getBlockContent } from '@wordpress/blocks'; -import { Button, Modal } from '@wordpress/components'; +import { Button, KeyboardShortcuts, Modal } from '@wordpress/components'; import { dispatch, select, useDispatch, useSelect } from '@wordpress/data'; -import { useEffect, useState } from '@wordpress/element'; +import { memo, useEffect, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { GutenbergFunction } from '../../../../@types/gutenberg/types'; -import { SmartLink, SmartLinkingProvider } from '../provider'; +import { SmartLink } from '../provider'; import { SmartLinkingStore } from '../store'; import { applyNodeToBlock } from '../utils'; import { ReviewModalSidebar } from './component-sidebar'; @@ -17,7 +18,7 @@ export type SmartLinkingReviewModalProps = { onAppliedLink: ( link: SmartLink ) => void, }; -export const SmartLinkingReviewModal = ( { +const SmartLinkingReviewModalComponent = ( { onClose, isOpen, onAppliedLink, @@ -38,15 +39,17 @@ export const SmartLinkingReviewModal = ( { * @since 3.15.0 */ const { + smartLinks, suggestedLinks, } = useSelect( ( selectFn ) => { - const { getSuggestedLinks } = selectFn( SmartLinkingStore ); + const { getSmartLinks, getSuggestedLinks } = selectFn( SmartLinkingStore ); return { - suggestedLinks: getSuggestedLinks(), + smartLinks: getSmartLinks(), + suggestedLinks: getSuggestedLinks, }; }, [] ); - const [ selectedLink, setSelectedLink ] = useState( suggestedLinks[ 0 ] ); + const [ selectedLink, setSelectedLink ] = useState( smartLinks[ 0 ] ); /** * Loads the Smart Linking store actions. @@ -54,23 +57,47 @@ export const SmartLinkingReviewModal = ( { * @since 3.15.0 */ const { - setSuggestedLinks, + purgeSmartLinksSuggestions, + updateSmartLink, + removeSmartLink, } = useDispatch( SmartLinkingStore ); - // Set the first link as the selected link when the links are loaded. + /** + * Sorts the smartLinks by the applied status. + */ useEffect( () => { - //console.log( suggestedLinks ); - // Filter out any links without a match - //const filteredLinks = links.filter( ( link ) => link.match ); - //setSuggestedLinks( filteredLinks ); - setSelectedLink( suggestedLinks[ 0 ] ); - }, [ suggestedLinks ] ); + smartLinks.sort( ( a, b ) => { + if ( a.applied && ! b.applied ) { + return 1; + } + if ( ! a.applied && b.applied ) { + return -1; + } + return 0; + } ); + }, [ smartLinks ] ); + + /** + * Sets the selected link when the suggested links change. + * + * @since 3.15.0 + */ + useEffect( () => { + if ( smartLinks.length === 0 ) { + onClose(); + return; + } + + setSelectedLink( smartLinks[ 0 ] ); + }, [ onClose, smartLinks ] ); const showConfirmCloseDialog = () => setShowCloseDialog( true ); const hideConfirmCloseDialog = () => setShowCloseDialog( false ); /** * Updates the modal state when the `isOpen` prop changes. + * + * @since 3.15.0 */ useEffect( () => { setIsModalOpen( isOpen ); @@ -79,6 +106,8 @@ export const SmartLinkingReviewModal = ( { /** * Applies the link to the block. * + * @since 3.15.0 + * * @param {string} blockId The block instance to apply the link to. * @param {SmartLink} linkSuggestion The link suggestion to apply. */ @@ -94,25 +123,24 @@ export const SmartLinkingReviewModal = ( { return; } + // Update the smart link in the store + linkSuggestion.applied = true; + await updateSmartLink( linkSuggestion ); + applyNodeToBlock( block, linkSuggestion, anchor ); // Update the block. dispatch( 'core/block-editor' ).updateBlock( blockId, block ); - linkSuggestion.applied = true; - - // Update the link suggestions. - await setSuggestedLinks( suggestedLinks ); - // Notify the API that the link was applied. - if ( postId ) { - const addedLink = await SmartLinkingProvider.getInstance().addSmartLink( postId, linkSuggestion ); - console.log( addedLink ); - } + //if ( postId ) { + // const addedLink = await SmartLinkingProvider.getInstance().addSmartLink( postId, linkSuggestion ); + // console.log( addedLink ); + //} }; /** - * Removes a Smart Link from a block. + * Removes a Smart Link from a block, using the unique identifier. * * @since 3.15.0 * @@ -133,51 +161,186 @@ export const SmartLinkingReviewModal = ( { return; } - let anchors = Array.from( contentElement.querySelectorAll( 'a' ) ); - anchors = anchors.filter( ( anchor ) => anchor.href === linkSuggestion.href && anchor.textContent?.includes( linkSuggestion.text ) ); - - if ( anchors.length > linkSuggestion.offset ) { - const anchorToRemove = anchors[ linkSuggestion.offset ]; - if ( anchorToRemove ) { - const parentNode = anchorToRemove.parentNode; - if ( parentNode ) { - // Replace the anchor with its text content - const textNode = document.createTextNode( anchorToRemove.textContent || '' ); - parentNode.replaceChild( textNode, anchorToRemove ); - - // Update the block content - block.attributes.content = contentElement.innerHTML; - dispatch( 'core/block-editor' ).updateBlock( blockId, block ); - } + // Select anchors by 'data-smartlink' attribute matching the UID. + const anchors = Array.from( contentElement.querySelectorAll( `a[data-smartlink="${ linkSuggestion.uid }"]` ) ); + + // Check if we found the anchor with the specified UID. + if ( anchors.length > 0 ) { + const anchorToRemove = anchors[ 0 ]; // Assuming UID is unique and there's only one match. + const parentNode = anchorToRemove.parentNode; + if ( parentNode ) { + // Replace the anchor with its text content + const textNode = document.createTextNode( anchorToRemove.textContent ?? '' ); + parentNode.replaceChild( textNode, anchorToRemove ); + + // Update the block content + block.attributes.content = contentElement.innerHTML; + dispatch( 'core/block-editor' ).updateBlock( blockId, block ); } } + + // Remove the link from the store. + removeSmartLink( linkSuggestion.uid ); }; + /** + * Handles the closing of the modal. + * + * If there are any pending links, a confirmation dialog is shown. + * When the modal is closed, any pending suggestions are purged. + * + * @since 3.15.0 + */ const onCloseHandler = () => { - const pendingLinks = suggestedLinks.filter( ( link ) => ! link.applied ); - // Hide the modal. setIsModalOpen( false ); - if ( suggestedLinks && pendingLinks.length > 0 ) { + const pendingLinks = smartLinks.filter( ( link ) => ! link.applied ); + if ( pendingLinks.length > 0 ) { showConfirmCloseDialog(); return; } - // Close after 200ms. - onClose(); + // Purge any remaining suggestions. + purgeSmartLinksSuggestions().then( () => onClose() ); }; + /** + * Handles the closing of the closing confirmation dialog. + * + * If the user confirms the closing, the modal is closed. + * + * @since 3.15.0 + * + * @param {boolean} shouldClose Whether the modal should be closed. + */ const onCloseConfirmCloseDialog = ( shouldClose: boolean ) => { hideConfirmCloseDialog(); if ( shouldClose ) { setIsModalOpen( false ); - onClose(); + purgeSmartLinksSuggestions().then( () => { + onClose(); + } ); } else { setIsModalOpen( true ); } }; + const handleNext = () => { + const currentIndex = smartLinks.indexOf( selectedLink ); + const nextIndex = currentIndex + 1; + + if ( ! smartLinks[ nextIndex ] ) { + return; + } + + setSelectedLink( smartLinks[ nextIndex ] ); + }; + + const handlePrevious = () => { + const currentIndex = smartLinks.indexOf( selectedLink ); + const previousIndex = currentIndex - 1; + + if ( ! smartLinks[ previousIndex ] ) { + return; + } + + setSelectedLink( smartLinks[ previousIndex ] ); + }; + + /** + * Handles the acceptance of a smart link. + * + * @since 3.15.0 + */ + const onAcceptHandler = () => { + if ( ! selectedLink.match ) { + return; + } + onAppliedLink( selectedLink ); + applyLinkToBlock( selectedLink.match.blockId, selectedLink ) + .then( () => { + // If there are no more suggested links, close the modal. + if ( suggestedLinks().length === 0 ) { + onCloseHandler(); + return; + } + + const currentIndex = smartLinks.indexOf( selectedLink ); + const nextIndex = currentIndex + 1; + + // If there is a next link, select it, otherwise select the first link + if ( smartLinks[ nextIndex ] ) { + setSelectedLink( smartLinks[ nextIndex ] ); + } else { + setSelectedLink( smartLinks[ 0 ] ); + } + } ); + }; + + /** + * Handles the rejection of a smart link. + * + * @since 3.15.0 + */ + const onRejectHandler = () => { + // Change to the next link. + const currentIndex = smartLinks.indexOf( selectedLink ); + const nextIndex = currentIndex + 1; + + // Check if it exists. If not, try to go for the first one on the array. + // If there isn't any, close the modal + if ( ! smartLinks[ nextIndex ] ) { + if ( smartLinks[ 0 ] ) { + setSelectedLink( smartLinks[ 0 ] ); + } else { + onCloseHandler(); + } + } else { + setSelectedLink( smartLinks[ nextIndex ] ); + } + + removeSmartLink( selectedLink.uid ); + }; + + /** + * Handles the removal of a smart link. + * + * @since 3.15.0 + */ + const onRemoveHandler = () => { + if ( ! selectedLink.match ) { + return; + } + + console.log( selectedLink ); + + const block = select( 'core/block-editor' ).getBlock( selectedLink.match.blockId ); + if ( block ) { + removeLinkFromBlock( block, selectedLink ); + } + }; + + /** + * Selects the link into the block editor. + * + * @since 3.15.0 + */ + const onSelectedInEditorHandler = () => { + if ( ! selectedLink.match ) { + return; + } + + const block = select( 'core/block-editor' ).getBlock( selectedLink.match.blockId ); + if ( block ) { + // Select the block in the editor + dispatch( 'core/block-editor' ).selectBlock( block.clientId ); + + // Close the modal + onCloseHandler(); + } + }; + return ( <> { isModalOpen && ( @@ -188,93 +351,43 @@ export const SmartLinkingReviewModal = ( { shouldCloseOnClickOutside={ false } shouldCloseOnEsc={ false } > + { + if ( selectedLink && ! selectedLink.applied ) { + onAcceptHandler(); + } + }, + r: () => { + if ( ! selectedLink ) { + return; + } + if ( selectedLink.applied ) { + onRemoveHandler(); + } else { + onRejectHandler(); + } + }, + } } />
0 } - onNext={ () => { - const currentIndex = suggestedLinks.indexOf( selectedLink ); - const nextIndex = currentIndex + 1; - setSelectedLink( suggestedLinks[ nextIndex ] ); - } } - onPrevious={ () => { - const currentIndex = suggestedLinks.indexOf( selectedLink ); - const previousIndex = currentIndex - 1; - setSelectedLink( suggestedLinks[ previousIndex ] ); - } } - onAccept={ () => { - if ( ! selectedLink.match ) { - return; - } - onAppliedLink( selectedLink ); - applyLinkToBlock( selectedLink.match.blockId, selectedLink ) - .then( () => { - const currentIndex = suggestedLinks.indexOf( selectedLink ); - const nextIndex = currentIndex + 1; - - // If there is a next link, select it, otherwise close the modal. - if ( suggestedLinks[ nextIndex ] ) { - setSelectedLink( suggestedLinks[ nextIndex ] ); - } else { - onCloseHandler(); - } - } ); - } } - onReject={ () => { - // Change to the next link. - const currentIndex = suggestedLinks.indexOf( selectedLink ); - const nextIndex = currentIndex + 1; - - // Check if it exists. If not, try to go for the first one on the array. - // If there isn't any, close the modal - if ( ! suggestedLinks[ nextIndex ] ) { - if ( suggestedLinks[ 0 ] ) { - setSelectedLink( suggestedLinks[ 0 ] ); - } else { - onCloseHandler(); - } - } else { - setSelectedLink( suggestedLinks[ nextIndex ] ); - } - - // Delete the rejected link from the list. - suggestedLinks.splice( currentIndex, 1 ); - setSuggestedLinks( suggestedLinks ); - } } - onRemove={ () => { - if ( ! selectedLink.match ) { - return; - } - - const block = select( 'core/block-editor' ).getBlock( selectedLink.match.blockId ); - if ( block ) { - removeLinkFromBlock( block, selectedLink ); - - // Remove the link suggestion from the list - suggestedLinks.splice( suggestedLinks.indexOf( selectedLink ), 1 ); - setSuggestedLinks( suggestedLinks ); - } - } } - onSelectInEditor={ () => { - if ( ! selectedLink.match ) { - return; - } - - const block = select( 'core/block-editor' ).getBlock( selectedLink.match.blockId ); - if ( block ) { - // Select the block in the editor - dispatch( 'core/block-editor' ).selectBlock( block.clientId ); - - // Close the modal - onCloseHandler(); - } - } } + hasNext={ smartLinks.indexOf( selectedLink ) < smartLinks.length - 1 } + hasPrevious={ smartLinks.indexOf( selectedLink ) > 0 } + onNext={ handleNext } + onPrevious={ handlePrevious } + onAccept={ onAcceptHandler } + onReject={ onRejectHandler } + onRemove={ onRemoveHandler } + onSelectInEditor={ onSelectedInEditorHandler } />
@@ -287,21 +400,26 @@ export const SmartLinkingReviewModal = ( { className="wp-parsely-smart-linking-close-dialog" > { __( 'Are you sure you want to close? All un-accepted smart links will not be added.', 'wp-parsely' ) } - - +
+ + +
) } ); }; + +export const SmartLinkingReviewModal = memo( SmartLinkingReviewModalComponent ); + diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx index 94464d246..574c3e6ef 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx @@ -22,6 +22,8 @@ export const ReviewModalSidebar = ( { { links?.map( ( link ) => ( { diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx index d3c91ea90..b8bbe5077 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx @@ -107,8 +107,8 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { * * @since 3.15.0 * - * @param {BlockInstance} blockInstance The block instance to highlight the link in. - * @param {SmartLink} linkSuggestion The link suggestion to highlight. + * @param {BlockInstance} blockInstance The block instance to highlight the link in. + * @param {SmartLink} linkSuggestion The link suggestion to highlight. */ const highlightLinkInBlock = ( blockInstance: BlockInstance, linkSuggestion: SmartLink ) => { const mark = document.createElement( 'mark' ); diff --git a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss index b06e9066e..70c94698d 100644 --- a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss +++ b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss @@ -161,7 +161,8 @@ } - .smart-linking-generate { + .smart-linking-generate, + .smart-linking-manage { display: flex; padding: to_rem(6px) 0 var(--grid-unit-20) 0; flex-direction: column; @@ -201,7 +202,9 @@ .smart-linking-review-sidebar { display: flex; - width: to_rem(220px); + min-width: to_rem(220px); + overflow-y: auto; + padding: 3px; flex-direction: column; align-items: flex-start; gap: var(--grid-unit-20); @@ -228,6 +231,10 @@ .components-button.components-menu-item__button { width: to_rem(220px); + &.is-selected { + border: 1px solid var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)); + } + .components-menu-item__item { overflow: hidden; white-space: nowrap; @@ -297,6 +304,7 @@ flex-shrink: 0; align-self: stretch; margin: 0 var(--grid-unit-20); + user-select: none; .reviews-controls-middle { display: flex; @@ -325,6 +333,22 @@ } } +.wp-parsely-smart-linking-close-dialog { + display: flex; + width: to_rem(384px); + flex-direction: column; + align-items: flex-start; + + .smart-linking-close-dialog-actions { + display: flex; + padding-top: var(--grid-unit-30); + justify-content: flex-end; + align-items: center; + gap: var(--grid-unit-15); + align-self: stretch; + } +} + .wp-parsely-preview-editor { &.editor-styles-wrapper { diff --git a/src/content-helper/editor-sidebar/smart-linking/store.ts b/src/content-helper/editor-sidebar/smart-linking/store.ts index 286b28e50..015b34f8c 100644 --- a/src/content-helper/editor-sidebar/smart-linking/store.ts +++ b/src/content-helper/editor-sidebar/smart-linking/store.ts @@ -41,7 +41,7 @@ type SmartLinkingState = { fullContent: boolean; error: ContentHelperError | null; settings: SmartLinkingSettingsProps; - suggestedLinks: SmartLink[] | null; + smartLinks: SmartLink[]; overlayBlocks: string[]; wasAlreadyClicked: boolean; isRetrying: boolean; @@ -120,16 +120,6 @@ interface SetSettingsAction { settings: SmartLinkingSettingsProps; } -/** - * Interface for the SetSuggestedLinksAction. - * - * @since 3.14.0 - */ -interface SetSuggestedLinksAction { - type: 'SET_SUGGESTED_LINKS'; - suggestedLinks: SmartLink[] | null; -} - /** * Interface for the SetWasAlreadyClickedAction. * @@ -160,6 +150,30 @@ interface SetIsRetryingAction { isRetrying: boolean; } +interface SetSmartLinksAction { + type: 'SET_SMART_LINKS'; + smartLinks: SmartLink[]; +} + +interface AddSmartLinkAction { + type: 'ADD_SMART_LINK'; + smartLink: SmartLink; +} + +interface AddSmartLinksAction { + type: 'ADD_SMART_LINKS'; + smartLinks: SmartLink[]; +} + +interface RemoveSmartLinkAction { + type: 'REMOVE_SMART_LINK'; + uid: string; +} + +interface PurgeSmartLinksSuggestionsAction { + type: 'PURGE_SMART_LINKS_SUGGESTIONS'; +} + /** * Interface for the IncrementRetryAttemptAction. * @@ -171,14 +185,15 @@ interface IncrementRetryAttemptAction { type ActionTypes = SetLoadingAction | SetOverlayBlocksAction | SetSettingsAction | AddOverlayBlockAction | RemoveOverlayBlockAction |SetFullContentAction | - SetSuggestedLinksAction | SetErrorAction| SetWasAlreadyClickedAction | SetApplyToAction | - IncrementRetryAttemptAction | SetIsRetryingAction; + SetErrorAction| SetWasAlreadyClickedAction | SetApplyToAction | IncrementRetryAttemptAction | + SetIsRetryingAction | SetSmartLinksAction | AddSmartLinkAction | AddSmartLinksAction | RemoveSmartLinkAction | + PurgeSmartLinksSuggestionsAction; const defaultState: SmartLinkingState = { isLoading: false, applyTo: null, fullContent: false, - suggestedLinks: null, + smartLinks: [], error: null, settings: { }, overlayBlocks: [], @@ -241,11 +256,6 @@ export const SmartLinkingStore = createReduxStore( 'wp-parsely/smart-linking', { ...action.settings, }, }; - case 'SET_SUGGESTED_LINKS': - return { - ...state, - suggestedLinks: action.suggestedLinks, - }; case 'SET_WAS_ALREADY_CLICKED': return { ...state, @@ -267,6 +277,52 @@ export const SmartLinkingStore = createReduxStore( 'wp-parsely/smart-linking', { ...state, retryAttempt: state.retryAttempt + 1, }; + case 'SET_SMART_LINKS': + return { + ...state, + smartLinks: action.smartLinks, + }; + case 'ADD_SMART_LINK': + // If the UID is already there, just update it, otherwise add it. + const existingIndex = state.smartLinks.findIndex( ( link ) => link.uid === action.smartLink.uid ); + if ( existingIndex !== -1 ) { + const newSmartLinks = [ ...state.smartLinks ]; + newSmartLinks[ existingIndex ] = action.smartLink; + return { + ...state, + smartLinks: newSmartLinks, + }; + } + return { + ...state, + smartLinks: [ ...state.smartLinks, action.smartLink ], + }; + case 'ADD_SMART_LINKS': + // If the UID is already there, just update it, otherwise add it. + const newSmartLinks = [ ...state.smartLinks ]; + action.smartLinks.forEach( ( link ) => { + // eslint-disable-next-line @typescript-eslint/no-shadow + const existingIndex = state.smartLinks.findIndex( ( l ) => l.uid === link.uid ); + if ( existingIndex !== -1 ) { + newSmartLinks[ existingIndex ] = link; + } else { + newSmartLinks.push( link ); + } + } ); + return { + ...state, + smartLinks: newSmartLinks, + }; + case 'REMOVE_SMART_LINK': + return { + ...state, + smartLinks: state.smartLinks.filter( ( link ) => link.uid !== action.uid ), + }; + case 'PURGE_SMART_LINKS_SUGGESTIONS': + return { + ...state, + smartLinks: state.smartLinks.filter( ( link ) => link.applied ), + }; default: return state; } @@ -330,12 +386,6 @@ export const SmartLinkingStore = createReduxStore( 'wp-parsely/smart-linking', { }, }; }, - setSuggestedLinks( suggestedLinks: SmartLink[] | null ): SetSuggestedLinksAction { - return { - type: 'SET_SUGGESTED_LINKS', - suggestedLinks, - }; - }, setAlreadyClicked( wasAlreadyClicked: boolean ): SetWasAlreadyClickedAction { return { type: 'SET_WAS_ALREADY_CLICKED', @@ -359,6 +409,42 @@ export const SmartLinkingStore = createReduxStore( 'wp-parsely/smart-linking', { type: 'INCREMENT_RETRY_ATTEMPT', }; }, + setSmartLinks( smartLinks: SmartLink[] ): SetSmartLinksAction { + return { + type: 'SET_SMART_LINKS', + smartLinks, + }; + }, + addSmartLink( smartLink: SmartLink ): AddSmartLinkAction { + return { + type: 'ADD_SMART_LINK', + smartLink, + }; + }, + updateSmartLink( smartLink: SmartLink ): AddSmartLinkAction { + // Alias of addSmartLink + return { + type: 'ADD_SMART_LINK', + smartLink, + }; + }, + addSmartLinks( smartLinks: SmartLink[] ): AddSmartLinksAction { + return { + type: 'ADD_SMART_LINKS', + smartLinks, + }; + }, + removeSmartLink( uid: string ): RemoveSmartLinkAction { + return { + type: 'REMOVE_SMART_LINK', + uid, + }; + }, + purgeSmartLinksSuggestions(): PurgeSmartLinksSuggestionsAction { + return { + type: 'PURGE_SMART_LINKS_SUGGESTIONS', + }; + }, }, selectors: { isLoading( state: SmartLinkingState ): boolean { @@ -386,7 +472,7 @@ export const SmartLinkingStore = createReduxStore( 'wp-parsely/smart-linking', { return state.settings.maxLinksPerPost ?? DEFAULT_MAX_LINKS; }, getSuggestedLinks( state: SmartLinkingState ): SmartLink[] { - return state.suggestedLinks ?? []; + return state.smartLinks.filter( ( link ) => ! link.applied ); }, wasAlreadyClicked( state: SmartLinkingState ): boolean { return state.wasAlreadyClicked; @@ -398,8 +484,10 @@ export const SmartLinkingStore = createReduxStore( 'wp-parsely/smart-linking', { return state.retryAttempt; }, hasUnappliedLinks( state: SmartLinkingState ): boolean { - console.log( 'hasUnappliedLinks', state.suggestedLinks?.filter( ( link ) => ! link.applied ) ); - return state.suggestedLinks?.some( ( link ) => ! link.applied ) ?? false; + return state.smartLinks.some( ( link ) => ! link.applied ); + }, + getSmartLinks( state: SmartLinkingState ): SmartLink[] { + return state.smartLinks; }, }, } ); diff --git a/src/content-helper/editor-sidebar/smart-linking/utils.ts b/src/content-helper/editor-sidebar/smart-linking/utils.ts index dc113574c..6c3be2266 100644 --- a/src/content-helper/editor-sidebar/smart-linking/utils.ts +++ b/src/content-helper/editor-sidebar/smart-linking/utils.ts @@ -94,9 +94,9 @@ function findTextNodesNotInSimilarNode( element: Node, searchText: string, refer * * @since 3.15.0 * - * @param {BlockInstance} block The block instance to apply the link to. - * @param {SmartLink} link The link suggestion to apply. - * @param {HTMLElement} htmlNode The HTML node to apply to the block. + * @param {BlockInstance} block The block instance to apply the link to. + * @param {SmartLink} link The link suggestion to apply. + * @param {HTMLElement} htmlNode The HTML node to apply to the block. */ export function applyNodeToBlock( block: BlockInstance, link: SmartLink, htmlNode: HTMLElement ) { const blockContent: string = getBlockContent( block ); @@ -114,13 +114,14 @@ export function applyNodeToBlock( block: BlockInstance, link: SmartLink, htmlNod textNodes.forEach( ( node ) => { if ( ! node.textContent || isInsideSimilarNode( node, htmlNode ) || hasAddedNode ) { + console.log( 'skip' ); return; } const regex = new RegExp( escapeRegExp( link.text ), 'g' ); let match; while ( ( match = regex.exec( node.textContent ) ) !== null ) { - if ( occurrenceCount === link.offset ) { + if ( occurrenceCount === link.match?.blockOffset ) { const anchor: HTMLElement = htmlNode.cloneNode( true ) as HTMLElement; anchor.textContent = match[ 0 ]; From c36f2c2e2e25e4067b7eae0bb844859529395bbe Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 7 May 2024 13:55:11 +0100 Subject: [PATCH 10/44] Add max-height to the sidebar --- .../editor-sidebar/smart-linking/smart-linking.scss | 1 + 1 file changed, 1 insertion(+) diff --git a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss index 70c94698d..f55dc30e6 100644 --- a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss +++ b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss @@ -203,6 +203,7 @@ .smart-linking-review-sidebar { display: flex; min-width: to_rem(220px); + max-height: to_rem(400px); overflow-y: auto; padding: 3px; flex-direction: column; From f89dedbb4e8b39bc50e784e3909123c5182ec56b Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 7 May 2024 13:55:47 +0100 Subject: [PATCH 11/44] Fix issue with the onClose callback of the modal --- .../smart-linking/review-modal/component-modal.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx index 9dafff959..5536a732d 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx @@ -83,13 +83,13 @@ const SmartLinkingReviewModalComponent = ( { * @since 3.15.0 */ useEffect( () => { - if ( smartLinks.length === 0 ) { + if ( isModalOpen && smartLinks.length === 0 ) { onClose(); return; } setSelectedLink( smartLinks[ 0 ] ); - }, [ onClose, smartLinks ] ); + }, [ isModalOpen, onClose, smartLinks ] ); const showConfirmCloseDialog = () => setShowCloseDialog( true ); const hideConfirmCloseDialog = () => setShowCloseDialog( false ); From dd15dfb13d0198f9fc094216a9819dde39cd6cec Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 7 May 2024 15:32:23 +0100 Subject: [PATCH 12/44] Sort smart links by block position and offset --- .../smart-linking/component.tsx | 22 ++++++++++++------- .../editor-sidebar/smart-linking/provider.ts | 5 +++-- .../review-modal/component-modal.tsx | 17 -------------- .../review-modal/component-sidebar.tsx | 1 + .../editor-sidebar/smart-linking/store.ts | 15 ++++++++----- .../editor-sidebar/smart-linking/utils.ts | 19 +++++++++++++++- 6 files changed, 45 insertions(+), 34 deletions(-) diff --git a/src/content-helper/editor-sidebar/smart-linking/component.tsx b/src/content-helper/editor-sidebar/smart-linking/component.tsx index 1c7f4daa0..e3c376486 100644 --- a/src/content-helper/editor-sidebar/smart-linking/component.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/component.tsx @@ -279,12 +279,11 @@ export const SmartLinkingPanel = ( { } ); // Calculate the smart links matches for each block. - links = calculateSmartLinkingMatches( allBlocks, links, {} ); + links = calculateSmartLinkingMatches( allBlocks, links, {} ) + // Filter out links without a match. + .filter( ( link ) => link.match ); - // Filter out links without a match. - links = links.filter( ( link ) => link.match ); - - // Update the link suggestions with the new matches + // Update the link suggestions with the new matches. await addSmartLinks( links ); }; @@ -415,6 +414,7 @@ export const SmartLinkingPanel = ( { * @param {SmartLink[]} links An array of link suggestions to apply to the content. * @param {LinkOccurrenceCounts} occurrenceCounts An object to keep track of the number of times each link text has * been encountered and applied across all blocks. + * @param {number} currentIndex The current index of the block being processed. * * @return {SmartLink[]} The filtered array of link suggestions that have been successfully applied to the content. */ @@ -422,11 +422,13 @@ export const SmartLinkingPanel = ( { blocks: Readonly[], links: SmartLink[], occurrenceCounts: LinkOccurrenceCounts, + currentIndex: number = 0 ): SmartLink[] => { - blocks.forEach( ( block ) => { + blocks.forEach( ( block, index ) => { + const currentBlockIndex = currentIndex + index; // Handle inner blocks. if ( block.innerBlocks?.length ) { - calculateSmartLinkingMatches( block.innerBlocks, links, occurrenceCounts ); + calculateSmartLinkingMatches( block.innerBlocks, links, occurrenceCounts, currentBlockIndex ); return; } @@ -458,7 +460,11 @@ export const SmartLinkingPanel = ( { if ( occurrenceCount.encountered === link.offset + 1 && occurrenceCount.linked < 1 ) { occurrenceCount.linked++; - link.match = { blockId: block.clientId, blockOffset: localCount - 1 }; + link.match = { + blockId: block.clientId, + blockOffset: localCount - 1, + blockPosition: currentBlockIndex, + }; } } } ); diff --git a/src/content-helper/editor-sidebar/smart-linking/provider.ts b/src/content-helper/editor-sidebar/smart-linking/provider.ts index a97ee0b79..9fa512b46 100644 --- a/src/content-helper/editor-sidebar/smart-linking/provider.ts +++ b/src/content-helper/editor-sidebar/smart-linking/provider.ts @@ -31,6 +31,7 @@ export type SmartLink = { */ export type SmartLinkMatch = { blockId: string; + blockPosition: number; blockOffset: number; } @@ -168,7 +169,7 @@ export class SmartLinkingProvider extends BaseProvider { offset: 0, applied: false, }, - ];*/ + ];*//* return [ { uid: '06187a56038c3aa8242b0fb98a1b5e5b', @@ -250,7 +251,7 @@ export class SmartLinkingProvider extends BaseProvider { offset: 5, applied: false, }, - ]; + ];*/ const response = await this.fetch( { method: 'POST', path: addQueryArgs( '/wp-parsely/v1/content-suggestions/suggest-linked-reference', { diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx index 5536a732d..9875f8dc3 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx @@ -62,21 +62,6 @@ const SmartLinkingReviewModalComponent = ( { removeSmartLink, } = useDispatch( SmartLinkingStore ); - /** - * Sorts the smartLinks by the applied status. - */ - useEffect( () => { - smartLinks.sort( ( a, b ) => { - if ( a.applied && ! b.applied ) { - return 1; - } - if ( ! a.applied && b.applied ) { - return -1; - } - return 0; - } ); - }, [ smartLinks ] ); - /** * Sets the selected link when the suggested links change. * @@ -313,8 +298,6 @@ const SmartLinkingReviewModalComponent = ( { return; } - console.log( selectedLink ); - const block = select( 'core/block-editor' ).getBlock( selectedLink.match.blockId ); if ( block ) { removeLinkFromBlock( block, selectedLink ); diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx index 574c3e6ef..dd9fbd0fe 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx @@ -1,4 +1,5 @@ import { MenuItem } from '@wordpress/components'; +import { useEffect, useState } from '@wordpress/element'; import { SmartLink } from '../provider'; type ReviewModalSidebarProps = { diff --git a/src/content-helper/editor-sidebar/smart-linking/store.ts b/src/content-helper/editor-sidebar/smart-linking/store.ts index 015b34f8c..0200af392 100644 --- a/src/content-helper/editor-sidebar/smart-linking/store.ts +++ b/src/content-helper/editor-sidebar/smart-linking/store.ts @@ -9,6 +9,7 @@ import { DEFAULT_MAX_LINKS, DEFAULT_MAX_LINK_WORDS } from './smart-linking'; * Internal dependencies */ import { SmartLink } from './provider'; +import { sortSmartLinks } from './utils'; /** * Defines the props structure for SmartLinkingSettings. @@ -280,7 +281,7 @@ export const SmartLinkingStore = createReduxStore( 'wp-parsely/smart-linking', { case 'SET_SMART_LINKS': return { ...state, - smartLinks: action.smartLinks, + smartLinks: sortSmartLinks( action.smartLinks ), }; case 'ADD_SMART_LINK': // If the UID is already there, just update it, otherwise add it. @@ -290,12 +291,12 @@ export const SmartLinkingStore = createReduxStore( 'wp-parsely/smart-linking', { newSmartLinks[ existingIndex ] = action.smartLink; return { ...state, - smartLinks: newSmartLinks, + smartLinks: sortSmartLinks( newSmartLinks ), }; } return { ...state, - smartLinks: [ ...state.smartLinks, action.smartLink ], + smartLinks: sortSmartLinks( [ ...state.smartLinks, action.smartLink ] ), }; case 'ADD_SMART_LINKS': // If the UID is already there, just update it, otherwise add it. @@ -311,17 +312,19 @@ export const SmartLinkingStore = createReduxStore( 'wp-parsely/smart-linking', { } ); return { ...state, - smartLinks: newSmartLinks, + smartLinks: sortSmartLinks( newSmartLinks ), }; case 'REMOVE_SMART_LINK': return { ...state, - smartLinks: state.smartLinks.filter( ( link ) => link.uid !== action.uid ), + smartLinks: + sortSmartLinks( state.smartLinks.filter( ( link ) => link.uid !== action.uid ) ), }; case 'PURGE_SMART_LINKS_SUGGESTIONS': return { ...state, - smartLinks: state.smartLinks.filter( ( link ) => link.applied ), + smartLinks: + sortSmartLinks( state.smartLinks.filter( ( link ) => link.applied ) ), }; default: return state; diff --git a/src/content-helper/editor-sidebar/smart-linking/utils.ts b/src/content-helper/editor-sidebar/smart-linking/utils.ts index 6c3be2266..8c3273fa4 100644 --- a/src/content-helper/editor-sidebar/smart-linking/utils.ts +++ b/src/content-helper/editor-sidebar/smart-linking/utils.ts @@ -114,7 +114,6 @@ export function applyNodeToBlock( block: BlockInstance, link: SmartLink, htmlNod textNodes.forEach( ( node ) => { if ( ! node.textContent || isInsideSimilarNode( node, htmlNode ) || hasAddedNode ) { - console.log( 'skip' ); return; } @@ -149,3 +148,21 @@ export function applyNodeToBlock( block: BlockInstance, link: SmartLink, htmlNod // Update the block content with the new content. block.attributes.content = contentElement.innerHTML; } + +export function sortSmartLinks( smartLinks: SmartLink[] ): SmartLink[] { + // Break-down in two buckets: applied and not applied + const appliedLinks = smartLinks.filter( ( link ) => link.applied ); + const notAppliedLinks = smartLinks.filter( ( link ) => ! link.applied ); + + const sortByBlockPosition = ( a: SmartLink, b:SmartLink ) => { + if ( a.match!.blockPosition === b.match!.blockPosition ) { + return a.match!.blockOffset - b.match!.blockOffset; + } + return a.match!.blockPosition - b.match!.blockPosition; + }; + + appliedLinks.sort( sortByBlockPosition ); + notAppliedLinks.sort( sortByBlockPosition ); + + return [ ...notAppliedLinks, ...appliedLinks ]; +} From adaa026a74aea4825a861e79125db86efdc8ee01 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Mon, 13 May 2024 10:42:12 +0100 Subject: [PATCH 13/44] Rebuild assets --- build/admin-settings.asset.php | 2 +- build/admin-settings.css | 2 +- build/blocks/recommendations/edit.asset.php | 2 +- build/blocks/recommendations/edit.js | 2 +- build/blocks/recommendations/view.asset.php | 2 +- build/blocks/recommendations/view.js | 2 +- .../content-helper/dashboard-widget.asset.php | 2 +- build/content-helper/dashboard-widget.css | 2 +- build/content-helper/dashboard-widget.js | 2 +- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.css | 10 ++--- build/content-helper/editor-sidebar.js | 39 +++++++++---------- .../excerpt-generator.asset.php | 2 +- build/content-helper/excerpt-generator.css | 2 +- build/content-helper/excerpt-generator.js | 3 +- build/recommended-widget.asset.php | 2 +- build/recommended-widget.css | 2 +- build/telemetry.asset.php | 2 +- build/telemetry.js | 2 +- 19 files changed, 41 insertions(+), 43 deletions(-) diff --git a/build/admin-settings.asset.php b/build/admin-settings.asset.php index 6e9a92c3e..83e176258 100644 --- a/build/admin-settings.asset.php +++ b/build/admin-settings.asset.php @@ -1 +1 @@ - array(), 'version' => '54de3040eda45ac58dbf'); + array(), 'version' => '05784a33626609c465f4'); diff --git a/build/admin-settings.css b/build/admin-settings.css index 2ce0634eb..0fd7159f3 100644 --- a/build/admin-settings.css +++ b/build/admin-settings.css @@ -1 +1 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.settings_page_parsely{--padding-default:15px}.settings_page_parsely #track-post-types{max-width:550px;width:100%}.settings_page_parsely #track-post-types td,.settings_page_parsely #track-post-types th{display:table-cell;padding:var(--padding-default);text-align:center;vertical-align:middle}.settings_page_parsely #track-post-types td{padding:0}.settings_page_parsely #track-post-types td label{display:inline-block;margin:0!important;padding-bottom:var(--padding-default);padding-top:var(--padding-default);width:100%}.settings_page_parsely #track-post-types thead th:nth-child(3){word-break:break-word}.settings_page_parsely fieldset:disabled *,.settings_page_parsely tr:has(fieldset:disabled) *{color:var(--gray-500);cursor:default}.settings_page_parsely .managed-option-badge{border:.0625rem solid var(--green-500);border-radius:.25rem;color:var(--green-500)!important;display:inline-block;font-size:.625rem;padding:.125rem .25rem;text-decoration:none}.settings_page_parsely a.managed-option-badge{cursor:pointer!important}.settings_page_parsely a.managed-option-badge:hover{background-color:var(--green-500);color:#fff!important}@media only screen and (max-width:380px){.settings_page_parsely #track-post-types td,.settings_page_parsely #track-post-types th{padding-left:10px;padding-right:10px}.settings_page_parsely #track-post-types th:first-child{max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.settings_page_parsely{--padding-default:15px}.settings_page_parsely #track-post-types{max-width:550px;width:100%}.settings_page_parsely #track-post-types td,.settings_page_parsely #track-post-types th{display:table-cell;padding:var(--padding-default);text-align:center;vertical-align:middle}.settings_page_parsely #track-post-types td{padding:0}.settings_page_parsely #track-post-types td label{display:inline-block;margin:0!important;padding-bottom:var(--padding-default);padding-top:var(--padding-default);width:100%}.settings_page_parsely #track-post-types thead th:nth-child(3){word-break:break-word}.settings_page_parsely fieldset:disabled *,.settings_page_parsely tr:has(fieldset:disabled) *{color:var(--gray-500);cursor:default}.settings_page_parsely .managed-option-badge{border:.0625rem solid var(--green-500);border-radius:.25rem;color:var(--green-500)!important;display:inline-block;font-size:.625rem;padding:.125rem .25rem;text-decoration:none}.settings_page_parsely a.managed-option-badge{cursor:pointer!important}.settings_page_parsely a.managed-option-badge:hover{background-color:var(--green-500);color:#fff!important}@media only screen and (max-width:380px){.settings_page_parsely #track-post-types td,.settings_page_parsely #track-post-types th{padding-left:10px;padding-right:10px}.settings_page_parsely #track-post-types th:first-child{max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}} diff --git a/build/blocks/recommendations/edit.asset.php b/build/blocks/recommendations/edit.asset.php index 3320beb03..d07e3e227 100644 --- a/build/blocks/recommendations/edit.asset.php +++ b/build/blocks/recommendations/edit.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '8daeb223e80bc2f56720'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'ada8db34ea07d80ab473'); diff --git a/build/blocks/recommendations/edit.js b/build/blocks/recommendations/edit.js index 5cf434a2c..ac88aae08 100644 --- a/build/blocks/recommendations/edit.js +++ b/build/blocks/recommendations/edit.js @@ -1 +1 @@ -!function(){"use strict";var e,n={271:function(e,n,r){var t,o,a=r(848),i=window.wp.blockEditor,l=window.wp.blocks,s=window.wp.i18n,c=window.wp.components,u=JSON.parse('{"UU":"wp-parsely/recommendations","uK":{"imagestyle":{"type":"string","default":"original"},"limit":{"type":"number","default":3},"openlinksinnewtab":{"type":"boolean","default":false},"showimages":{"type":"boolean","default":true},"sort":{"type":"string","default":"score"},"title":{"type":"string","default":"Related Content"}}}'),d=window.wp.element;(o=t||(t={}))[o.Error=0]="Error",o[o.Loaded=1]="Loaded",o[o.Recommendations=2]="Recommendations";var p=function(){return p=Object.assign||function(e){for(var n,r=1,t=arguments.length;r0&&o[o.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]=a)&&Object.keys(t.O).every((function(e){return t.O[e](r[s])}))?r.splice(s--,1):(l=!1,a0&&e[u-1][2]>a;u--)e[u]=e[u-1];e[u]=[r,o,a]},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},t.d=function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},function(){var e={335:0,203:0};t.O.j=function(n){return 0===e[n]};var n=function(n,r){var o,a,i=r[0],l=r[1],s=r[2],c=0;if(i.some((function(n){return 0!==e[n]}))){for(o in l)t.o(l,o)&&(t.m[o]=l[o]);if(s)var u=s(t)}for(n&&n(r);c0&&o[o.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]=a)&&Object.keys(t.O).every((function(e){return t.O[e](r[s])}))?r.splice(s--,1):(l=!1,a0&&e[u-1][2]>a;u--)e[u]=e[u-1];e[u]=[r,o,a]},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},t.d=function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},function(){var e={878:0,570:0};t.O.j=function(n){return 0===e[n]};var n=function(n,r){var o,a,i=r[0],l=r[1],s=r[2],c=0;if(i.some((function(n){return 0!==e[n]}))){for(o in l)t.o(l,o)&&(t.m[o]=l[o]);if(s)var u=s(t)}for(n&&n(r);c array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '827c1c0c5b711b046baf'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '767eb8d9a92dda7c7224'); diff --git a/build/blocks/recommendations/view.js b/build/blocks/recommendations/view.js index ac32818be..9ccc6203e 100644 --- a/build/blocks/recommendations/view.js +++ b/build/blocks/recommendations/view.js @@ -1 +1 @@ -!function(){"use strict";var e={20:function(e,r,n){var t=n(609),o=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(e,r,n){var t,a={},u=null,c=null;for(t in void 0!==n&&(u=""+n),void 0!==r.key&&(u=""+r.key),void 0!==r.ref&&(c=r.ref),r)i.call(r,t)&&!l.hasOwnProperty(t)&&(a[t]=r[t]);if(e&&e.defaultProps)for(t in r=e.defaultProps)void 0===a[t]&&(a[t]=r[t]);return{$$typeof:o,type:e,key:u,ref:c,props:a,_owner:s.current}}r.Fragment=a,r.jsx=u,r.jsxs=u},848:function(e,r,n){e.exports=n(20)},609:function(e){e.exports=window.React}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var a=r[t]={exports:{}};return e[t](a,a.exports,n),a.exports}n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,{a:r}),r},n.d=function(e,r){for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},function(){var e,r,t=n(848),o=n(609),a=window.wp.domReady,i=n.n(a),s=window.wp.element,l=window.wp.i18n;(r=e||(e={}))[r.Error=0]="Error",r[r.Loaded=1]="Loaded",r[r.Recommendations=2]="Recommendations";var u=function(){return u=Object.assign||function(e){for(var r,n=1,t=arguments.length;n0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1] array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '74d8c90239a5a2b71237'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '11c08dcb53396fc2cbca'); diff --git a/build/content-helper/dashboard-widget.css b/build/content-helper/dashboard-widget.css index 52838501e..d4ff79870 100644 --- a/build/content-helper/dashboard-widget.css +++ b/build/content-helper/dashboard-widget.css @@ -1 +1 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}#wp-parsely-dashboard-widget{color:var(--base-text);font-family:var(--base-font)}#wp-parsely-dashboard-widget .parsely-spinner-wrapper{display:flex;justify-content:center;margin:11.875rem 0}#wp-parsely-dashboard-widget .parsely-spinner-wrapper svg{height:22px;width:22px}#wp-parsely-dashboard-widget .content-helper-error-message{margin-top:1.125rem}#wp-parsely-dashboard-widget p.content-helper-error-message-hint{color:var(--gray-700)}#wp-parsely-dashboard-widget .parsely-top-posts-filters{display:flex;justify-content:space-between;margin-bottom:.625rem}#wp-parsely-dashboard-widget .parsely-top-posts-navigation{display:flex;justify-content:space-between;margin-top:.625rem}#wp-parsely-dashboard-widget .parsely-top-posts-navigation button{background:none;border:none;color:var(--blue-550);font-size:.75rem;font-weight:600;text-decoration:none}#wp-parsely-dashboard-widget .parsely-top-posts-navigation button:disabled{visibility:hidden}#wp-parsely-dashboard-widget .parsely-top-posts-navigation button:not([disabled]):hover{cursor:pointer}#wp-parsely-dashboard-widget .parsely-top-post-content{display:flex}#wp-parsely-dashboard-widget .parsely-top-post-content:before{content:counter(item) "";counter-increment:item;padding-right:.5rem}@media only screen and (max-width:380px){#wp-parsely-dashboard-widget .parsely-top-post-content:before{content:"";padding-right:0}}#wp-parsely-dashboard-widget .parsely-top-posts{list-style:none;margin:1rem 0 0}#wp-parsely-dashboard-widget .parsely-top-post{margin-bottom:1rem}#wp-parsely-dashboard-widget .parsely-top-post-thumbnail{height:46px;min-width:46px}#wp-parsely-dashboard-widget .parsely-top-post-thumbnail img{height:100%;width:100%}#wp-parsely-dashboard-widget .parsely-top-post-data{border-top:1px solid var(--gray-300);flex-grow:1;margin-left:.5rem;padding-top:.25rem}#wp-parsely-dashboard-widget .parsely-top-post-title{color:var(--base-text);font-size:.875rem;margin-right:.4375rem}#wp-parsely-dashboard-widget a.parsely-top-post-title:hover{color:var(--blue-550)}#wp-parsely-dashboard-widget .parsely-top-post-icon-link{position:relative;top:.25rem}#wp-parsely-dashboard-widget .parsely-top-post-icon-link svg{fill:#8d98a1;margin-right:.1875rem}#wp-parsely-dashboard-widget .parsely-top-post-icon-link svg:hover{fill:var(--blue-550)}#wp-parsely-dashboard-widget .parsely-top-post-metadata{margin:.25rem 0 0}#wp-parsely-dashboard-widget .parsely-top-post-metadata>span{color:var(--gray-500)}#wp-parsely-dashboard-widget .parsely-top-post-metadata>span:not(:first-child){margin-left:.75rem}#wp-parsely-dashboard-widget .parsely-post-metric-data{float:right;font-family:var(--numeric-font);font-size:1.125rem;padding-left:.625rem} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}#wp-parsely-dashboard-widget{color:var(--base-text);font-family:var(--base-font)}#wp-parsely-dashboard-widget .parsely-spinner-wrapper{display:flex;justify-content:center;margin:11.875rem 0}#wp-parsely-dashboard-widget .parsely-spinner-wrapper svg{height:22px;width:22px}#wp-parsely-dashboard-widget .content-helper-error-message{margin-top:1.125rem}#wp-parsely-dashboard-widget p.content-helper-error-message-hint{color:var(--gray-700)}#wp-parsely-dashboard-widget .parsely-top-posts-filters{display:flex;justify-content:space-between;margin-bottom:.625rem}#wp-parsely-dashboard-widget .parsely-top-posts-navigation{display:flex;justify-content:space-between;margin-top:.625rem}#wp-parsely-dashboard-widget .parsely-top-posts-navigation button{background:none;border:none;color:var(--blue-550);font-size:.75rem;font-weight:600;text-decoration:none}#wp-parsely-dashboard-widget .parsely-top-posts-navigation button:disabled{visibility:hidden}#wp-parsely-dashboard-widget .parsely-top-posts-navigation button:not([disabled]):hover{cursor:pointer}#wp-parsely-dashboard-widget .parsely-top-post-content{display:flex}#wp-parsely-dashboard-widget .parsely-top-post-content:before{content:counter(item) "";counter-increment:item;padding-right:.5rem}@media only screen and (max-width:380px){#wp-parsely-dashboard-widget .parsely-top-post-content:before{content:"";padding-right:0}}#wp-parsely-dashboard-widget .parsely-top-posts{list-style:none;margin:1rem 0 0}#wp-parsely-dashboard-widget .parsely-top-post{margin-bottom:1rem}#wp-parsely-dashboard-widget .parsely-top-post-thumbnail{height:46px;min-width:46px}#wp-parsely-dashboard-widget .parsely-top-post-thumbnail img{height:100%;width:100%}#wp-parsely-dashboard-widget .parsely-top-post-data{border-top:1px solid var(--gray-300);flex-grow:1;margin-left:.5rem;padding-top:.25rem}#wp-parsely-dashboard-widget .parsely-top-post-title{color:var(--base-text);font-size:.875rem;margin-right:.4375rem}#wp-parsely-dashboard-widget a.parsely-top-post-title:hover{color:var(--blue-550)}#wp-parsely-dashboard-widget .parsely-top-post-icon-link{position:relative;top:.25rem}#wp-parsely-dashboard-widget .parsely-top-post-icon-link svg{fill:#8d98a1;margin-right:.1875rem}#wp-parsely-dashboard-widget .parsely-top-post-icon-link svg:hover{fill:var(--blue-550)}#wp-parsely-dashboard-widget .parsely-top-post-metadata{margin:.25rem 0 0}#wp-parsely-dashboard-widget .parsely-top-post-metadata>span{color:var(--gray-500)}#wp-parsely-dashboard-widget .parsely-top-post-metadata>span:not(:first-child){margin-left:.75rem}#wp-parsely-dashboard-widget .parsely-post-metric-data{float:right;font-family:var(--numeric-font);font-size:1.125rem;padding-left:.625rem} diff --git a/build/content-helper/dashboard-widget.js b/build/content-helper/dashboard-widget.js index 92c40bb4d..e158345ad 100644 --- a/build/content-helper/dashboard-widget.js +++ b/build/content-helper/dashboard-widget.js @@ -1 +1 @@ -!function(){"use strict";var e={20:function(e,t,r){var n=r(609),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,u=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:u,props:s,_owner:i.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},848:function(e,t,r){e.exports=r(20)},609:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n,a=r(848),s=window.wp.element,o=window.wp.i18n,i=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,a.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},l=function(e){var t;return void 0===e&&(e=null),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:null!==(t=window.wpParselyEmptyCredentialsMessage)&&void 0!==t?t:(0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely")})},c=function(){return c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),h=(d.trackEvent,function(e){var t=e.defaultValue,r=e.items,n=e.onChange;return(0,a.jsx)("select",{onChange:n,value:t,children:r.map((function(e){return(0,a.jsx)("option",{value:e[0],children:e[1]},e[0])}))})}),f=window.wp.data,y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;rhere
.',"wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiError||s.code===N.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,o.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===N.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,o.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiSchemaError?s.message=(0,o.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===N.ParselySuggestionsApiNoData?s.message=(0,o.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiSchema?s.message=(0,o.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,o.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return C(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[N.PluginCredentialsNotSetMessageDetected,N.PluginSettingsSiteIdNotSet,N.PluginSettingsApiSecretNotSet].includes(this.code)?l(e):(this.code===N.FetchError&&(this.hint=this.Hint((0,o.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==N.ParselyApiForbidden&&this.code!==N.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===N.HttpRequestFailed&&(this.hint=this.Hint((0,o.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

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

".concat(this.message,"

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

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

")},t}(Error),I=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,r=Array.from(this.abortControllers.keys()).pop();r&&(t=this.abortControllers.get(r))&&(t.abort(),this.abortControllers.delete(r))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),r=new AbortController;return this.abortControllers.set(t,r),{abortController:r,abortId:t}},e.prototype.fetch=function(e,t){return r=this,n=void 0,s=function(){var r,n,a,s,i;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=c){var u=t;(a=n/c)%1>1/i&&(u=a>10?1:2),u=parseFloat(a.toFixed(2))===parseFloat(a.toFixed(0))?0:u,s=a.toFixed(u),o=l}i=c})),s+r+o}function z(e){var t=e.metric,r=e.post,n=e.avgEngagedIcon,s=e.viewsIcon;return"views"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Number of Views","wp-parsely")}),s,$(r.views.toString())]}):"avg_engaged"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Average Time","wp-parsely")}),n,r.avgEngaged]}):(0,a.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}function X(e){var t,r=e.metric,n=e.post;return(0,a.jsx)("li",{className:"parsely-top-post",children:(0,a.jsxs)("div",{className:"parsely-top-post-content",children:[(0,a.jsx)(B,{post:n}),(0,a.jsxs)("div",{className:"parsely-top-post-data",children:[(0,a.jsx)(z,{metric:r,post:n}),(0,a.jsx)(Z,{post:n}),(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:n.url,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(q,{})]}),0!==n.postId&&(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:(t=n.postId,"/wp-admin/post.php?post=".concat(t,"&action=edit")),target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Edit Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(G,{})]}),(0,a.jsxs)("div",{className:"parsely-top-post-metadata",children:[(0,a.jsxs)("span",{className:"parsely-top-post-date",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Date","wp-parsely")}),M(new Date(n.date))]}),(0,a.jsxs)("span",{className:"parsely-top-post-author",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Author","wp-parsely")}),n.author]})]})]})]})},n.id)}function B(e){var t=e.post;return t.thumbnailUrl?(0,a.jsxs)("div",{className:"parsely-top-post-thumbnail",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Thumbnail","wp-parsely")}),(0,a.jsx)("img",{src:t.thumbnailUrl,alt:(0,o.__)("Post thumbnail","wp-parsely")})]}):(0,a.jsx)("div",{className:"parsely-top-post-thumbnail",children:(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Post thumbnail not available","wp-parsely")})})}function Z(e){var t=e.post;return(0,a.jsxs)("a",{className:"parsely-top-post-title",href:t.dashUrl,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View in Parse.ly (opens in new tab)","wp-parsely")}),t.title]})}var Y=function(){return Y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&e.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return r.sent(),[4,t(n-1)];case 2:return r.sent(),[3,4];case 3:f(!1),v(e),r.label=4;case 4:return[2]}}))}))})),[2]}))}))};return f(!0),t(1),function(){f(!1),m([]),v(void 0)}}),[i,S]);var N=function(e,t){d.trackEvent("dash_widget_filter_changed",Y({filter:e},t))},T=(0,a.jsxs)("div",{className:"parsely-top-posts-filters",children:[(0,a.jsx)(h,{defaultValue:i.Period,items:Object.values(e).map((function(e){return[e,A(e)]})),onChange:function(t){x(t.target.value,e)&&(l({Period:t.target.value}),N("period",{period:t.target.value}),j(1))}}),(0,a.jsx)(h,{defaultValue:i.Metric,items:Object.values(t).map((function(e){return[e,E(e)]})),onChange:function(e){x(e.target.value,t)&&(l({Metric:e.target.value}),N("metric",{metric:e.target.value}),j(1))}})]}),C=(0,a.jsxs)("div",{className:"parsely-top-posts-navigation",children:[(0,a.jsx)("button",{className:"parsely-top-posts-navigation-prev",disabled:S<=1,"aria-label":(0,o.__)("Previous page","wp-parsely"),onClick:function(){j(S-1),d.trackEvent("dash_widget_navigation",{navigation:"previous",to_page:S-1})},children:(0,o.__)("<< Previous","wp-parsely")}),(0,o.sprintf)(/* translators: 1: Current page */(0,o.__)("Page %1$d","wp-parsely"),S),(0,a.jsx)("button",{className:"parsely-top-posts-navigation-next",disabled:!u&&_.length<5,"aria-label":(0,o.__)("Next page","wp-parsely"),onClick:function(){j(S+1),d.trackEvent("dash_widget_navigation",{navigation:"next",to_page:S+1})},children:(0,o.__)("Next >>","wp-parsely")})]});if(g)return(0,a.jsxs)(a.Fragment,{children:[T,g.Message(),S>1&&C]});var O=(0,a.jsx)("div",{className:"parsely-spinner-wrapper",children:(0,a.jsx)(p.Spinner,{})});return(0,a.jsxs)(a.Fragment,{children:[T,u?O:(0,a.jsx)("ol",{className:"parsely-top-posts",style:{counterReset:"item "+5*(S-1)},children:_.map((function(e){return(0,a.jsx)(X,{metric:i.Metric,post:e},e.id)}))}),(_.length>=5||S>1)&&C]})}var J=function(r){var n;try{n=JSON.parse(r)}catch(r){return{Metric:t.Views,Period:e.Days7}}return x(null==n?void 0:n.Metric,t)||(n.Metric=t.Views),x(null==n?void 0:n.Period,e)||(n.Period=e.Days7),n};window.addEventListener("load",(function(){var e=document.querySelector("#wp-parsely-dashboard-widget > .inside");if(null!==e){var t=(0,a.jsx)(S,{endpoint:"dashboard-widget-settings",defaultSettings:J(window.wpParselyContentHelperSettings),children:(0,a.jsx)(u,{children:(0,a.jsx)(Q,{})})});s.createRoot?(0,s.createRoot)(e).render(t):(0,s.render)(t,e)}}),!1)}()}(); \ No newline at end of file diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index 1891878a6..f819fa872 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-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '468ab0b5ad3986a2b08d'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'a87c7cfa869320fd4b29'); diff --git a/build/content-helper/editor-sidebar.css b/build/content-helper/editor-sidebar.css index d36bd5c93..e0da9c26d 100644 --- a/build/content-helper/editor-sidebar.css +++ b/build/content-helper/editor-sidebar.css @@ -1,5 +1,5 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 var(--grid-unit-15) 0 0;order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)} -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-performance-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}.wp-parsely-content-helper .wp-parsely-performance-panel .content-helper-error-message{margin:0!important}.wp-parsely-content-helper .wp-parsely-performance-panel .components-button.wp-parsely-view-post{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .panel-body{width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.5rem;padding:.375rem 0 1rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header{align-items:center;display:flex;gap:.375rem;height:1rem;margin-bottom:0;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2{margin-bottom:.9375rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2 h2{margin-bottom:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-3 h3{font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:1rem;margin-bottom:0;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-subtitle{align-items:center;align-self:stretch;color:var(--Gutenberg-Gray-700,#757575);display:flex;flex:1 0 0;font-size:var(--font-size--smaller);font-style:normal;font-weight:600;gap:.375rem;height:1rem;line-height:1rem;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .components-heading{display:block;font-weight:500;line-height:normal;margin:0}.wp-parsely-content-helper .wp-parsely-performance-panel .components-dropdown-menu{line-height:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points{align-content:flex-start;align-items:flex-start;align-self:stretch;display:flex;flex-wrap:wrap;gap:1rem var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point{align-items:center;background:var(--sidebar-white);border-radius:.25rem;display:flex;flex:1 0 0;flex-direction:column;gap:var(--grid-unit-5);justify-content:center;min-width:100px;padding:var(--grid-unit-20) var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point svg{align-items:flex-start;border-radius:.125rem;display:flex}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-title{align-self:stretch;color:var(--sidebar-black);font-size:.75rem;font-style:normal;font-weight:400;line-height:1rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value{align-self:stretch;color:var(--sidebar-black);font-size:1.25rem;font-style:normal;font-weight:590;line-height:1.75rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value.is-small{font-size:var(--font-size--medium)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar{align-items:flex-start;align-self:stretch;display:flex;height:1rem;margin:1rem 0;position:relative}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill{--radius:2px;align-self:stretch;position:relative;transition:filter .1s ease,transform .1s ease}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:hover{filter:opacity(1)!important;transform:scaleX(1) scaleY(1)!important}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:first-child{border-radius:var(--radius) 0 0 var(--radius)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:last-child{border-radius:0 var(--radius) var(--radius) 0}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar:hover .bar-fill{filter:opacity(.5);transform:scaleX(1) scaleY(.7)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label{align-items:center;align-self:stretch;display:flex;gap:.5rem;justify-content:center}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color{align-items:center;border-radius:.09375rem;display:flex;flex-direction:column;gap:.625rem;height:.625rem;justify-content:center;width:.1875rem}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1 0 0;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-value{color:var(--sidebar-black);font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;text-align:right}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:1rem 0}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-10);justify-content:space-between}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar{display:flex;flex:1;flex-direction:column;gap:.625rem;justify-content:center;max-width:6.25rem}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar{--radius:1.5px;background:var(--gray-400);border-radius:var(--radius);display:flex;height:.1875rem;margin:0;overflow:hidden}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar:after{background:var(--blueberry,#3858e9);border-radius:var(--radius);content:"";height:100%;width:var(--bar-fill)}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-value{color:var(--sidebar-black);flex-shrink:0;font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;min-width:3.125rem;text-align:right} -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-related-posts{align-items:flex-start;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-description{font-size:.8125rem;font-style:normal;font-weight:400;gap:.625rem;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body,.wp-parsely-related-posts .related-posts-description{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body{gap:1rem}.wp-parsely-related-posts .related-posts-body>div{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings{align-self:stretch;display:flex;flex-direction:column;gap:1rem;width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings{display:flex;flex-direction:column;gap:var(--grid-unit-20);width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control{height:2.5rem;overflow:hidden}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex{height:2.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex input{margin:0 var(--grid-unit-15)}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-descr{font-size:.8125rem;font-style:normal;font-weight:400;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-empty,.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-loading-message{color:var(--gray-900);font-size:.75rem;font-style:normal;font-weight:700;line-height:var(--grid-unit-20);overflow:hidden;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-title{align-items:center;align-self:stretch;display:flex;flex-direction:column;font-size:.875rem;font-style:normal;font-weight:600;gap:.5rem;justify-content:center;line-height:1.25rem;overflow:hidden;padding:var(--grid-unit-20);text-decoration-line:underline;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions{align-items:center;align-self:stretch;border-top:1px solid var(--gray-400);display:flex;flex-wrap:wrap;padding:0 var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:first-child,.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:last-child{display:flex;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric{align-items:center;display:flex}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric .parsely-post-metric-data{align-items:center;display:flex;gap:var(--grid-unit-5)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-linked{align-items:center;display:flex;margin-left:auto;fill:#008a20}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon path{fill:#1e1e1e}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon:hover path{fill:#0073aa} -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper{display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings>div{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding-bottom:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header .parsely-write-titles-text strong{text-transform:lowercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding-top:.375rem}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate .components-button{align-items:center;align-self:stretch;border-radius:2px;display:flex;height:2.5rem;justify-content:center;padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-dropdown-label{align-self:stretch;color:var(--sidebar-black);font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:var(--grid-unit-20);text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title{font-size:1rem;font-weight:600;line-height:1.25rem;margin:0 0 .9375rem;text-align:center}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title-actions{display:flex;gap:.625rem;justify-content:center;margin:.625rem 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion.pinned-title{background:var(--Gutenberg-Gray-100,#f0f0f0)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title{align-items:center;align-self:stretch;color:#1e1e1e;display:flex;flex-direction:column;font-size:.75rem;font-style:normal;font-weight:600;gap:var(--grid-unit-10);justify-content:center;line-height:1.25rem;padding:var(--grid-unit-15) var(--grid-unit-15) 0 var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title .suggested-title-original{align-self:flex-start;margin:0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions{align-items:center;align-self:stretch;border-top:1px solid var(--Gutenberg-Gray-400,#ccc);display:flex;flex-wrap:wrap;height:2.5rem;padding:0 var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-left,.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-right{display:flex;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin-bottom:var(--grid-unit-20);position:relative}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay{align-items:center;background-color:hsla(0,0%,100%,.9);bottom:0;display:flex;flex-direction:column;gap:var(--grid-unit-10);justify-content:center;left:0;position:absolute;right:0;top:0;z-index:1}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay .components-spinner{transform:scale(1.125)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-pinned-suggestions{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-content-helper-error.components-notice{margin-bottom:var(--grid-unit-10)}.wp-parsely-popover .components-popover__content{width:15.5rem}.wp-parsely-suggested-title-modal{align-items:flex-start;display:flex;flex-direction:column;width:20rem}.wp-parsely-suggested-title-modal h2{color:var(--sidebar-black);font-size:1rem;font-style:normal;font-weight:600;line-height:1.5rem}.wp-parsely-suggested-title-modal .suggested-title-modal-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;margin-top:1.5rem} -.parsely-tone-selector-dropdown{align-items:center;align-self:stretch;background:var(--Gutenberg-White,#fff);border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;height:2.25rem;overflow-wrap:break-word;width:100%;word-break:break-word}.parsely-tone-selector-dropdown button{height:2.0625rem}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle.has-icon svg:first-child{display:none}.parsely-tone-selector-dropdown.is-disabled{opacity:.5;pointer-events:none}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle{display:flex;gap:.625rem;width:100%}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle svg:first-of-type path{transform:scale(1.4);transform-origin:center}.parsely-tone-selector-dropdown .parsely-tone-selector-label{flex-grow:2;padding:0 var(--grid-unit-10);text-align:left}.parsely-tone-selector-dropdown .parsely-tone-selector-label:first-letter{text-transform:uppercase}.parsely-persona-selector-custom{width:100%}.parsely-persona-selector-custom .components-base-control__field input{display:flex;height:2.5rem;padding:var(--grid-unit-15) var(--grid-unit-20)}.parsely-persona-selector-custom .components-base-control__field input,.parsely-persona-selector-dropdown{align-items:center;align-self:stretch;border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px}.parsely-persona-selector-dropdown{background:var(--Gutenberg-White,#fff);height:2.25rem;overflow-wrap:break-word;width:100%;word-break:break-word}.parsely-persona-selector-dropdown .components-dropdown-menu__toggle.has-icon svg:first-child{display:none}.parsely-persona-selector-dropdown button{height:2.0625rem}.parsely-persona-selector-dropdown.is-disabled{opacity:.5;pointer-events:none}.parsely-persona-selector-dropdown .components-dropdown-menu__toggle{display:flex;gap:.625rem;width:100%}.parsely-persona-selector-dropdown .parsely-persona-selector-label{flex-grow:2;padding:0 var(--grid-unit-10);text-align:left}.parsely-persona-selector-dropdown .parsely-persona-selector-label:first-letter{text-transform:uppercase}.parsely-tone-selector-custom{width:100%}.parsely-tone-selector-custom .components-base-control__field input{align-items:center;align-self:stretch;border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;display:flex;height:2.5rem;padding:var(--grid-unit-15) var(--grid-unit-20)}#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.parsely-inputrange-control{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.parsely-inputrange-control .parsely-inputrange-control__label{margin:0}.parsely-inputrange-control .parsely-inputrange-control__controls{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-20);height:2.5rem}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control{display:flex;flex:1 0 0}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]::-webkit-inner-spin-button,.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]{-moz-appearance:textfield}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control .components-base-control__field{flex-grow:1}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control .components-input-control__suffix{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.parsely-inputrange-control .parsely-inputrange-control__controls .components-range-control{flex:1 0 0;height:36px}.parsely-inputrange-control .parsely-inputrange-control__controls .components-range-control .components-range-control__root{height:2.5rem}.parsely-panel-settings{width:100%}.parsely-panel-settings .parsely-panel-settings-header{display:flex;margin:.625rem 0;width:100%}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label{flex-grow:2;margin:0 0 0 .3125rem;text-align:left}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label .components-base-control__field{align-items:center;display:flex;justify-content:space-between}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label .components-base-control__field .components-base-control__label{margin-bottom:0}.parsely-panel-settings .parsely-panel-settings-body{align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper-error{align-self:flex-start;margin:0}.wp-parsely-content-helper-error p{margin:0}.wp-parsely-content-helper-error .content-helper-error-message{margin:0!important}.wp-parsely-collapsible-panel{align-items:flex-start;align-self:stretch;border-bottom:none;border-radius:2px;border-top:none;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:0 0 .5rem;padding:0}.wp-parsely-collapsible-panel .components-panel__body-title{align-items:center;align-self:stretch;display:flex;margin:0 -1rem .375rem;padding:0}.wp-parsely-collapsible-panel .components-panel__body-title .components-panel__icon,.wp-parsely-collapsible-panel .components-panel__body-title svg{margin-left:0;margin-right:var(--grid-unit-10);order:-1}.wp-parsely-collapsible-panel .components-panel__body-title:hover{background-color:transparent}.wp-parsely-collapsible-panel.is-opened{padding:0}.wp-parsely-collapsible-panel.is-opened>div:first-of-type{margin-top:calc(var(--grid-unit-20)*-1)}.wp-parsely-collapsible-panel.is-opened .components-panel__body-title{margin:0 calc(var(--grid-unit-20)*-1) .375rem;padding-bottom:0}.wp-parsely-collapsible-panel .components-panel__body-toggle.components-button{color:var(--Gutenberg-Gray-900,#1e1e1e);font-size:.6875rem;font-style:normal;font-weight:600;line-height:1rem;padding:var(--grid-unit-20) var(--grid-unit-20);text-transform:uppercase}.wp-parsely-collapsible-panel .components-panel__body-toggle.components-button .components-panel__arrow{margin-right:0}.wp-parsely-collapsible-panel .components-panel__body.is-opened{padding:0}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"]:focus,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"]:hover{background-color:#fff}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed:hover{background-color:var(--parsely-green-65)}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed .wp-parsely-sidebar-icon path,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed:hover .wp-parsely-sidebar-icon path{fill:var(--parsely-green-10)}.content-helper-error-message,.wp-parsely-content-helper-error .content-helper-error-message{margin-top:.9375rem!important}p.content-helper-error-message-hint{color:var(--gray-700)}.wp-parsely-content-helper-error.components-notice .components-notice__content{margin:0}.wp-parsely-content-helper-error.components-notice .components-notice__content .content-helper-error-message{margin-top:0!important}.wp-parsely-content-helper-error.components-notice .components-notice__content .content-helper-error-message p:last-child{margin-bottom:0!important}.wp-parsely-content-helper .wp-parsely-sidebar-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:1.5rem}.wp-parsely-content-helper .wp-parsely-sidebar-header .components-button{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .components-panel .panel-settings-button>button,.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .components-panel button.panel-settings-button{height:unset;min-width:unset;padding:0}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-panel>.content-helper-error-message{margin:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs button{align-items:center;display:flex;flex:1 0 0;flex-direction:column;height:3rem}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs .components-tab-panel__tabs-item:after{background:var(--gray-400);height:calc(var(--wp-admin-border-width-focus)*1);outline:2px solid transparent;outline-offset:-1px}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs .components-tab-panel__tabs-item.is-active:after{background:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-content-helper .parsely-spinner-wrapper{display:flex;justify-content:center;margin:2.5rem 0}.wp-parsely-content-helper .parsely-spinner-wrapper svg{height:22px;width:22px} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 var(--grid-unit-15) 0 0;order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate,.wp-parsely-smart-linking .smart-linking-manage{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button,.wp-parsely-smart-linking .smart-linking-manage button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)}.wp-parsely-smart-linking-review-modal{align-items:flex-start;display:flex;flex-direction:column;width:47.875rem}.wp-parsely-smart-linking-review-modal .smart-linking-modal-body{align-self:stretch;display:flex;flex-direction:row;gap:var(--grid-unit-30)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);max-height:25rem;min-width:13.75rem;overflow-y:auto;padding:3px}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header{align-items:center;align-self:stretch;color:var(--sidebar-black);display:flex;font-size:11px;font-style:normal;font-weight:600;gap:6px;line-height:var(--grid-unit-20);margin-bottom:var(--grid-unit-15);text-transform:uppercase}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header>span{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button{width:13.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected{border:1px solid var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__item{display:inline;overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__shortcut{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));padding-left:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion{align-items:flex-start;align-self:stretch;display:flex;flex:1;flex-direction:column;gap:16px;max-width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs{font-size:.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-separator{margin:0 var(--grid-unit-5)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-block{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block{color:var(--sidebar-black)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block .breadcrumbs-current-block-name{margin-left:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .components-divider{border-color:#ccc;height:1px;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .wp-parsely-link-suggestion-link-details{height:auto;margin-bottom:var(--grid-unit-20);text-align:left}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .wp-parsely-link-suggestion-link-details .components-menu-item__item{word-wrap:break-word;white-space:normal}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls{align-items:center;align-self:stretch;display:flex;flex-shrink:0;justify-content:space-between;margin:0 var(--grid-unit-20);-webkit-user-select:none;-moz-user-select:none;user-select:none;width:452px}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .reviews-controls-middle{align-items:center;display:flex;flex:1 0 0;gap:var(--grid-unit-20,16px);justify-content:center}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-next,.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-previous{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-reject{background:var(--Gutenberg-White,#fff);border-radius:2px;box-shadow:inset 0 0 0 1px var(--Gutenberg-Alert-Red,#cc1818);color:var(--Gutenberg-Alert-Red,#cc1818)}.wp-parsely-smart-linking-close-dialog{align-items:flex-start;display:flex;flex-direction:column;width:24rem}.wp-parsely-smart-linking-close-dialog .smart-linking-close-dialog-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;padding-top:var(--grid-unit-30)}.wp-parsely-preview-editor.editor-styles-wrapper{font-size:var(--font-size--medium);padding-bottom:0}.wp-parsely-preview-editor p[role=document]{margin:0}.wp-parsely-preview-editor .smart-linking-highlight{background:hsla(var(--parsely-green-components),.5);border-radius:2px;mix-blend-mode:multiply;text-decoration-line:underline} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-performance-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}.wp-parsely-content-helper .wp-parsely-performance-panel .content-helper-error-message{margin:0!important}.wp-parsely-content-helper .wp-parsely-performance-panel .components-button.wp-parsely-view-post{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .panel-body{width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.5rem;padding:.375rem 0 1rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header{align-items:center;display:flex;gap:.375rem;height:1rem;margin-bottom:0;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2{margin-bottom:.9375rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2 h2{margin-bottom:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-3 h3{font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:1rem;margin-bottom:0;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-subtitle{align-items:center;align-self:stretch;color:var(--Gutenberg-Gray-700,#757575);display:flex;flex:1 0 0;font-size:var(--font-size--smaller);font-style:normal;font-weight:600;gap:.375rem;height:1rem;line-height:1rem;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .components-heading{display:block;font-weight:500;line-height:normal;margin:0}.wp-parsely-content-helper .wp-parsely-performance-panel .components-dropdown-menu{line-height:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points{align-content:flex-start;align-items:flex-start;align-self:stretch;display:flex;flex-wrap:wrap;gap:1rem var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point{align-items:center;background:var(--sidebar-white);border-radius:.25rem;display:flex;flex:1 0 0;flex-direction:column;gap:var(--grid-unit-5);justify-content:center;min-width:100px;padding:var(--grid-unit-20) var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point svg{align-items:flex-start;border-radius:.125rem;display:flex}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-title{align-self:stretch;color:var(--sidebar-black);font-size:.75rem;font-style:normal;font-weight:400;line-height:1rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value{align-self:stretch;color:var(--sidebar-black);font-size:1.25rem;font-style:normal;font-weight:590;line-height:1.75rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value.is-small{font-size:var(--font-size--medium)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar{align-items:flex-start;align-self:stretch;display:flex;height:1rem;margin:1rem 0;position:relative}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill{--radius:2px;align-self:stretch;position:relative;transition:filter .1s ease,transform .1s ease}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:hover{filter:opacity(1)!important;transform:scaleX(1) scaleY(1)!important}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:first-child{border-radius:var(--radius) 0 0 var(--radius)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:last-child{border-radius:0 var(--radius) var(--radius) 0}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar:hover .bar-fill{filter:opacity(.5);transform:scaleX(1) scaleY(.7)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label{align-items:center;align-self:stretch;display:flex;gap:.5rem;justify-content:center}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color{align-items:center;border-radius:.09375rem;display:flex;flex-direction:column;gap:.625rem;height:.625rem;justify-content:center;width:.1875rem}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-text{-webkit-box-orient:vertical;-webkit-line-clamp:1;font-feature-settings:"ss06" on;color:var(--sidebar-black);display:-webkit-box;flex:1 0 0;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-value{color:var(--sidebar-black);font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;text-align:right}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:1rem 0}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-10);justify-content:space-between}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-title{-webkit-box-orient:vertical;-webkit-line-clamp:1;font-feature-settings:"ss06" on;color:var(--sidebar-black);display:-webkit-box;flex:1;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar{display:flex;flex:1;flex-direction:column;gap:.625rem;justify-content:center;max-width:6.25rem}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar{--radius:1.5px;background:var(--gray-400);border-radius:var(--radius);display:flex;height:.1875rem;margin:0;overflow:hidden}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar:after{background:var(--blueberry,#3858e9);border-radius:var(--radius);content:"";height:100%;width:var(--bar-fill)}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-value{color:var(--sidebar-black);flex-shrink:0;font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;min-width:3.125rem;text-align:right} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-related-posts{align-items:flex-start;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-description{font-size:.8125rem;font-style:normal;font-weight:400;gap:.625rem;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body,.wp-parsely-related-posts .related-posts-description{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body{gap:1rem}.wp-parsely-related-posts .related-posts-body>div{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings{align-self:stretch;display:flex;flex-direction:column;gap:1rem;width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings{display:flex;flex-direction:column;gap:var(--grid-unit-20);width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control{height:2.5rem;overflow:hidden}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex{height:2.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex input{margin:0 var(--grid-unit-15)}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-descr{font-size:.8125rem;font-style:normal;font-weight:400;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-empty,.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-loading-message{color:var(--gray-900);font-size:.75rem;font-style:normal;font-weight:700;line-height:var(--grid-unit-20);overflow:hidden;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-title{align-items:center;align-self:stretch;display:flex;flex-direction:column;font-size:.875rem;font-style:normal;font-weight:600;gap:.5rem;justify-content:center;line-height:1.25rem;overflow:hidden;padding:var(--grid-unit-20);text-decoration-line:underline;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions{align-items:center;align-self:stretch;border-top:1px solid var(--gray-400);display:flex;flex-wrap:wrap;padding:0 var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:first-child,.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:last-child{display:flex;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric{align-items:center;display:flex}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric .parsely-post-metric-data{align-items:center;display:flex;gap:var(--grid-unit-5)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-linked{fill:#008a20;align-items:center;display:flex;margin-left:auto}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon path{fill:#1e1e1e}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon:hover path{fill:#0073aa} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper{display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings>div{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding-bottom:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header .parsely-write-titles-text strong{text-transform:lowercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding-top:.375rem}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate .components-button{align-items:center;align-self:stretch;border-radius:2px;display:flex;height:2.5rem;justify-content:center;padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-dropdown-label{align-self:stretch;color:var(--sidebar-black);font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:var(--grid-unit-20);text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title{font-size:1rem;font-weight:600;line-height:1.25rem;margin:0 0 .9375rem;text-align:center}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title-actions{display:flex;gap:.625rem;justify-content:center;margin:.625rem 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion.pinned-title{background:var(--Gutenberg-Gray-100,#f0f0f0)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title{align-items:center;align-self:stretch;color:#1e1e1e;display:flex;flex-direction:column;font-size:.75rem;font-style:normal;font-weight:600;gap:var(--grid-unit-10);justify-content:center;line-height:1.25rem;padding:var(--grid-unit-15) var(--grid-unit-15) 0 var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title .suggested-title-original{align-self:flex-start;margin:0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions{align-items:center;align-self:stretch;border-top:1px solid var(--Gutenberg-Gray-400,#ccc);display:flex;flex-wrap:wrap;height:2.5rem;padding:0 var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-left,.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-right{display:flex;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin-bottom:var(--grid-unit-20);position:relative}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay{align-items:center;background-color:hsla(0,0%,100%,.9);bottom:0;display:flex;flex-direction:column;gap:var(--grid-unit-10);justify-content:center;left:0;position:absolute;right:0;top:0;z-index:1}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay .components-spinner{transform:scale(1.125)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-pinned-suggestions{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-content-helper-error.components-notice{margin-bottom:var(--grid-unit-10)}.wp-parsely-popover .components-popover__content{width:15.5rem}.wp-parsely-suggested-title-modal{align-items:flex-start;display:flex;flex-direction:column;width:20rem}.wp-parsely-suggested-title-modal h2{color:var(--sidebar-black);font-size:1rem;font-style:normal;font-weight:600;line-height:1.5rem}.wp-parsely-suggested-title-modal .suggested-title-modal-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;margin-top:1.5rem} +.parsely-tone-selector-dropdown{align-items:center;align-self:stretch;background:var(--Gutenberg-White,#fff);border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;height:2.25rem;overflow-wrap:break-word;width:100%;word-break:break-word}.parsely-tone-selector-dropdown button{height:2.0625rem}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle.has-icon svg:first-child{display:none}.parsely-tone-selector-dropdown.is-disabled{opacity:.5;pointer-events:none}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle{display:flex;gap:.625rem;width:100%}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle svg:first-of-type path{transform:scale(1.4);transform-origin:center}.parsely-tone-selector-dropdown .parsely-tone-selector-label{flex-grow:2;padding:0 var(--grid-unit-10);text-align:left}.parsely-tone-selector-dropdown .parsely-tone-selector-label:first-letter{text-transform:uppercase}.parsely-persona-selector-custom{width:100%}.parsely-persona-selector-custom .components-base-control__field input{display:flex;height:2.5rem;padding:var(--grid-unit-15) var(--grid-unit-20)}.parsely-persona-selector-custom .components-base-control__field input,.parsely-persona-selector-dropdown{align-items:center;align-self:stretch;border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px}.parsely-persona-selector-dropdown{background:var(--Gutenberg-White,#fff);height:2.25rem;overflow-wrap:break-word;width:100%;word-break:break-word}.parsely-persona-selector-dropdown .components-dropdown-menu__toggle.has-icon svg:first-child{display:none}.parsely-persona-selector-dropdown button{height:2.0625rem}.parsely-persona-selector-dropdown.is-disabled{opacity:.5;pointer-events:none}.parsely-persona-selector-dropdown .components-dropdown-menu__toggle{display:flex;gap:.625rem;width:100%}.parsely-persona-selector-dropdown .parsely-persona-selector-label{flex-grow:2;padding:0 var(--grid-unit-10);text-align:left}.parsely-persona-selector-dropdown .parsely-persona-selector-label:first-letter{text-transform:uppercase}.parsely-tone-selector-custom{width:100%}.parsely-tone-selector-custom .components-base-control__field input{align-items:center;align-self:stretch;border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;display:flex;height:2.5rem;padding:var(--grid-unit-15) var(--grid-unit-20)}#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.parsely-inputrange-control{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.parsely-inputrange-control .parsely-inputrange-control__label{margin:0}.parsely-inputrange-control .parsely-inputrange-control__controls{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-20);height:2.5rem}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control{display:flex;flex:1 0 0}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]::-webkit-inner-spin-button,.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]{-moz-appearance:textfield}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control .components-base-control__field{flex-grow:1}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control .components-input-control__suffix{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.parsely-inputrange-control .parsely-inputrange-control__controls .components-range-control{flex:1 0 0;height:36px}.parsely-inputrange-control .parsely-inputrange-control__controls .components-range-control .components-range-control__root{height:2.5rem}.parsely-panel-settings{width:100%}.parsely-panel-settings .parsely-panel-settings-header{display:flex;margin:.625rem 0;width:100%}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label{flex-grow:2;margin:0 0 0 .3125rem;text-align:left}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label .components-base-control__field{align-items:center;display:flex;justify-content:space-between}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label .components-base-control__field .components-base-control__label{margin-bottom:0}.parsely-panel-settings .parsely-panel-settings-body{align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper-error{align-self:flex-start;margin:0}.wp-parsely-content-helper-error p{margin:0}.wp-parsely-content-helper-error .content-helper-error-message{margin:0!important}.wp-parsely-collapsible-panel{align-items:flex-start;align-self:stretch;border-bottom:none;border-radius:2px;border-top:none;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:0 0 .5rem;padding:0}.wp-parsely-collapsible-panel .components-panel__body-title{align-items:center;align-self:stretch;display:flex;margin:0 -1rem .375rem;padding:0}.wp-parsely-collapsible-panel .components-panel__body-title .components-panel__icon,.wp-parsely-collapsible-panel .components-panel__body-title svg{margin-left:0;margin-right:var(--grid-unit-10);order:-1}.wp-parsely-collapsible-panel .components-panel__body-title:hover{background-color:transparent}.wp-parsely-collapsible-panel.is-opened{padding:0}.wp-parsely-collapsible-panel.is-opened>div:first-of-type{margin-top:calc(var(--grid-unit-20)*-1)}.wp-parsely-collapsible-panel.is-opened .components-panel__body-title{margin:0 calc(var(--grid-unit-20)*-1) .375rem;padding-bottom:0}.wp-parsely-collapsible-panel .components-panel__body-toggle.components-button{color:var(--Gutenberg-Gray-900,#1e1e1e);font-size:.6875rem;font-style:normal;font-weight:600;line-height:1rem;padding:var(--grid-unit-20) var(--grid-unit-20);text-transform:uppercase}.wp-parsely-collapsible-panel .components-panel__body-toggle.components-button .components-panel__arrow{margin-right:0}.wp-parsely-collapsible-panel .components-panel__body.is-opened{padding:0}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"]:focus,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"]:hover{background-color:#fff}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed:hover{background-color:var(--parsely-green-65)}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed .wp-parsely-sidebar-icon path,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed:hover .wp-parsely-sidebar-icon path{fill:var(--parsely-green-10)}.content-helper-error-message,.wp-parsely-content-helper-error .content-helper-error-message{margin-top:.9375rem!important}p.content-helper-error-message-hint{color:var(--gray-700)}.wp-parsely-content-helper-error.components-notice .components-notice__content{margin:0}.wp-parsely-content-helper-error.components-notice .components-notice__content .content-helper-error-message{margin-top:0!important}.wp-parsely-content-helper-error.components-notice .components-notice__content .content-helper-error-message p:last-child{margin-bottom:0!important}.wp-parsely-content-helper .wp-parsely-sidebar-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:1.5rem}.wp-parsely-content-helper .wp-parsely-sidebar-header .components-button{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .components-panel .panel-settings-button>button,.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .components-panel button.panel-settings-button{height:unset;min-width:unset;padding:0}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-panel>.content-helper-error-message{margin:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs button{align-items:center;display:flex;flex:1 0 0;flex-direction:column;height:3rem}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs .components-tab-panel__tabs-item:after{background:var(--gray-400);height:calc(var(--wp-admin-border-width-focus)*1);outline:2px solid transparent;outline-offset:-1px}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs .components-tab-panel__tabs-item.is-active:after{background:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-content-helper .parsely-spinner-wrapper{display:flex;justify-content:center;margin:2.5rem 0}.wp-parsely-content-helper .parsely-spinner-wrapper svg{height:22px;width:22px} diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index f7f336c8d..4f73fce87 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,27 +1,26 @@ -!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 sn}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=n(609),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,h=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=(h.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"})]})},v=function(){return v=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiError||s.code===A.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===A.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===A.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return H(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[A.PluginCredentialsNotSetMessageDetected,A.PluginSettingsSiteIdNotSet,A.PluginSettingsApiSecretNotSet].includes(this.code)?B(e):(this.code===A.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==A.ParselyApiForbidden&&this.code!==A.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===A.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(I,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function W(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var U,$=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})]})]})},Z=function(){return Z=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&&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)){var e={maxLinksPerPost:p.SmartLinking.MaxLinks,maxLinkWords:p.SmartLinking.MaxLinkWords};z(e)}}),[z,p]);var ee=(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]),te=ee.allBlocks,oe=ee.selectedBlock,le=ee.postContent,ce=ee.postPermalink,ue=function(e){return ie(void 0,void 0,void 0,(function(){var t,n,r,i;return se(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,$((n=b||!oe)?U.All:U.Selected)];case 2:return s.sent(),a=ce.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,ne.getInstance().generateSmartLinks(oe&&!n?(0,D.getBlockContent)(oe):le,T,j,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===A.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,Y(!0)]):[3,8];case 5:return s.sent(),[4,J()];case 6:return s.sent(),[4,ue(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[4,M(t)];case 10:return s.sent(),[2,t]}var a}))}))},pe=function(e,t,n,r){var i=ce.replace(/^https?:\/\//,"").replace(/\/+$/,"");t=t.filter((function(e){return!e.href.includes(i)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(e.href)),!1)})),e.forEach((function(e){var i=!1;if(e.innerBlocks&&e.innerBlocks.length)pe(e.innerBlocks,t,n,r);else if(e.originalContent){var s=(0,D.getBlockContent)(e),a=(new DOMParser).parseFromString(s,"text/html").body.firstChild;a&&a instanceof HTMLElement&&(t.forEach((function(e){var t=function(e,t){for(var n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:function(n){var r;if(!n.textContent||!n.textContent.includes(t))return NodeFilter.FILTER_REJECT;for(var i=n.parentNode;i&&i!==e;){if("A"===i.nodeName&&!(null===(r=i.textContent)||void 0===r?void 0:r.includes(t)))return NodeFilter.FILTER_REJECT;i=i.parentNode}return NodeFilter.FILTER_ACCEPT}}),i=[];n=r.nextNode();)i.push(n);return i}(a,e.text),r="".concat(e.text,"#").concat(e.offset);n[r]||(n[r]={encountered:0,linked:0}),t.forEach((function(t){var s;if(t.textContent){var a=n[r];if(a.linked>=1)return;for(var o=new RegExp(W(e.text),"g"),l=void 0;null!==(l=o.exec(t.textContent));)if(a.encountered++,a.encountered===e.offset+1){var c=document.createElement("a");c.href=e.href,c.title=e.title,c.textContent=l[0];var u=document.createRange();if(u.setStart(t,l.index),u.setEnd(t,l.index+l[0].length),u.deleteContents(),u.insertNode(c),t.textContent&&l.index+l[0].length[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},ye=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsx)("div",{className:"wp-parsely-smart-linking",children:(0,i.jsxs)(s.PanelRow,{className:t,children:[(0,i.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(F,{icon:G,size:18,className:"parsely-external-link-icon"})]})]}),P&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return B(null)},className:"wp-parsely-content-helper-error",children:P.Message()}),null!==S&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return M(null)},className:"wp-parsely-smart-linking-suggested-links",children:(0,c.sprintf)(/* translators: 1 - number of smart links generated */ /* translators: 1 - number of smart links generated */ -(0,c.__)("Successfully added %s smart links.","wp-parsely"),y>0?y:S.length)}),(0,i.jsx)(X,{disabled:_,selectedBlock:null==oe?void 0:oe.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:re(re({},p.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e?q(t):"MaxLinkWords"===e&&Z(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return ie(void 0,void 0,void 0,(function(){var e,t,n,r,i;return se(this,(function(s){switch(s.label){case 0:return[4,I(!0)];case 1:return s.sent(),[4,M(null)];case 2:return s.sent(),[4,B(null)];case 3:return s.sent(),h.trackEvent("smart_linking_generate_pressed",{is_full_content:b,selected_block:null!==(i=null==oe?void 0:oe.name)&&void 0!==i?i:"none",context:o}),[4,fe(b?"all":null==oe?void 0:oe.clientId)];case 4:s.sent(),e=setTimeout((function(){var e;I(!1),h.trackEvent("smart_linking_generate_timeout",{is_full_content:b,selected_block:null!==(e=null==oe?void 0:oe.name)&&void 0!==e?e:"none",context:o}),he(b?"all":null==oe?void 0:oe.clientId)}),18e4),t=C,s.label=5;case 5:return s.trys.push([5,7,9,14]),[4,ue(3)];case 6:return function(e){var t;h.trackEvent("smart_linking_applied",{is_full_content:b||!oe,selected_block:null!==(t=null==oe?void 0:oe.name)&&void 0!==t?t:"none",links_count:e.length,context:o});var n={},r=[];pe(oe&&!b?[oe]:te,e,n,r),de(r);var i=Object.values(n).reduce((function(e,t){return e+t.linked}),0);v(i),m("success",/* translators: %d: number of smart links applied */ /* translators: %d: number of smart links applied */ -(0,c.sprintf)((0,c.__)("%s smart links successfully applied.","wp-parsely"),i),{type:"snackbar"})}(s.sent()),[3,14];case 7:return n=s.sent(),r=(0,c.__)("There was a problem applying smart links.","wp-parsely"),n.code&&n.code===A.ParselyAborted&&(r=(0,c.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ /* translators: %d: number of retry attempts, %s: attempt plural */ -(0,c.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),n.numRetries,(0,c._n)("attempt","attempts",n.numRetries,"wp-parsely")),n.message=r),[4,B(n)];case 8:return s.sent(),m("error",r,{type:"snackbar"}),[3,14];case 9:return[4,I(!1)];case 10:return s.sent(),[4,$(t)];case 11:return s.sent(),[4,Y(!1)];case 12:return s.sent(),[4,he(b?"all":null==oe?void 0:oe.clientId)];case 13:return s.sent(),clearTimeout(e),[7];case 14:return[2]}}))}))},variant:"primary",isBusy:_,disabled:_,children:L?(0,c.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,c.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),N,3):_?(0,c.__)("Adding Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")})})]})})},le=function(){return le=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 xe=function(e){var n=e.data,r=e.isLoading,a=(0,l.useState)(t.Views),o=a[0],u=a[1],p=(0,l.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},g=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),C(o)); -/* translators: %s: metric description */return(0,i.jsxs)(_e,{title:(0,c.__)("Categories","wp-parsely"),level:3,subtitle:g,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,c.__)("By: ","wp-parsely"),onChange:function(e){T(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,i.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[C(e),"avg_engaged"===e&&(0,c.__)(" (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,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ /* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ +!function(){"use strict";var e={251:function(e,t,n){var r=n(196),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},893:function(e,t,n){e.exports=n(251)},196: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({},{W:function(){return Sn}});var e,t,r,i=n(893),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=n(196),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,h=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=(h.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"})]})},v=function(){return v=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiError||s.code===N.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===N.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===N.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return H(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[N.PluginCredentialsNotSetMessageDetected,N.PluginSettingsSiteIdNotSet,N.PluginSettingsApiSecretNotSet].includes(this.code)?B(e):(this.code===N.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==N.ParselyApiForbidden&&this.code!==N.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===N.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(I,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function W(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var U=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0?p(!0):x().then((function(){return t()}))},j=function(e){p(!1),e?(h(!1),x().then((function(){t()}))):h(!0)},T=function(){var e=y.indexOf(w)+1;y[e]&&_(y[e])},E=function(){var e=y.indexOf(w)-1;y[e]&&_(y[e])},L=function(){var e,t,n,i,s,o;w.match&&(r(w),(e=w.match.blockId,t=w,n=void 0,i=void 0,s=void 0,o=function(){var n,r;return 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){var l=o[0],c=l.parentNode;if(c){var u=document.createTextNode(null!==(n=l.textContent)&&void 0!==n?n:"");c.replaceChild(u,l),e.attributes.content=s.innerHTML,(0,a.dispatch)("core/block-editor").updateBlock(r,e)}}S(t.uid)}}}(e,w)}};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:P,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:E,right:T,up:E,down:T,a:function(){w&&!w.applied&&L()},r:function(){w&&(w.applied?N():C())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(te,{links:y,activeLink:w,setSelectedLink:_}),(0,i.jsx)(fe,{link:w,hasNext:y.indexOf(w)0,onNext:T,onPrevious:E,onAccept:L,onReject:C,onRemove:N,onSelectInEditor:function(){if(w.match){var e=(0,a.select)("core/block-editor").getBlock(w.match.blockId);e&&((0,a.dispatch)("core/block-editor").selectBlock(e.clientId),P())}}})]})]}),u&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return j(!1)},className:"wp-parsely-smart-linking-close-dialog",children:[(0,c.__)("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 j(!1)},children:(0,c.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return j(!0)},children:(0,c.__)("Close","wp-parsely")})]})]})]})})),ge=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})]})]})},ye=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,u=e.onSettingChange,p=(0,l.useRef)(),d=(0,l.useState)(""),f=d[0],h=d[1],g=(0,l.useState)(!1),y=g[0],v=g[1],m=(0,l.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(J),n=t.getMaxLinkWords,r=t.getMaxLinks,i=t.isFullContent,s=t.wasAlreadyClicked,a=t.getApplyTo;return{maxLinks:r(),maxLinkWords:n(),fullContent:i(),alreadyClicked:s(),applyTo:a()}}),[]),_=w.maxLinks,b=w.maxLinkWords,x=w.fullContent,k=w.alreadyClicked,S=w.applyTo,P=(0,a.useDispatch)(J),j=P.setMaxLinks,T=P.setMaxLinkWords,E=P.setFullContent,L=P.setAlreadyClicked,C=P.setApplyTo,N=null!==(t=S)&&void 0!==t?t:o?"selected":"all";return(0,l.useEffect)((function(){if(!r){var e=function(){r||(S===K.Selected&&setTimeout((function(){h((0,c.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),C(null),m((function(e){return!e})))};o||S===K.All||(y?setTimeout(e,500):e()),E(K.All===N)}}),[y,S,N,r,o,C,E,h]),(0,l.useEffect)((function(){if(!r&&p.current&&N&&!k&&o){var e=p.current.querySelector('button[data-value="'.concat(N,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(C(N),L(!0))}}),[o,x,r,S]),(0,l.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:N,label:(0,c.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&E("success",/* translators: %d: number of smart links applied */ +(0,c.sprintf)((0,c.__)("%s smart links successfully applied.","wp-parsely"),y),{type:"snackbar"}):v(0)}),[w]);var L=(0,a.useSelect)((function(e){var t=e(J),n=t.isLoading,r=t.getOverlayBlocks,i=t.getSuggestedLinks,s=t.getError,a=t.isFullContent,o=t.getMaxLinks,l=t.getMaxLinkWords,c=t.getSmartLinkingSettings,u=t.getApplyTo,p=t.isRetrying,d=t.getRetryAttempt,f=t.getSmartLinks;return{loading:n(),error:s(),maxLinks:o(),maxLinkWords:l(),isFullContent:a(),overlayBlocks:r(),suggestedLinks:i(),smartLinkingSettings:c(),applyTo:u(),retrying:p(),retryAttempt:d(),smartLinks:f(),getSmartLinksFn:f}}),[]),C=L.loading,A=L.isFullContent,R=L.overlayBlocks,I=L.error,B=L.suggestedLinks,M=L.maxLinks,D=L.maxLinkWords,H=L.smartLinkingSettings,z=L.applyTo,U=L.retrying,Z=L.retryAttempt,q=L.smartLinks,$=L.getSmartLinksFn,Y=(0,a.useDispatch)(J),Q=Y.setLoading,X=Y.setError,te=Y.addSmartLinks,ne=Y.addOverlayBlock,re=Y.removeOverlayBlock,ie=Y.setSmartLinkingSettings,se=Y.setApplyTo,ae=Y.setMaxLinkWords,oe=Y.setMaxLinks,le=Y.setIsRetrying,ce=Y.incrementRetryAttempt,ue=Y.purgeSmartLinksSuggestions;(0,l.useEffect)((function(){if(!(Object.keys(H).length>0)){var e={maxLinksPerPost:p.SmartLinking.MaxLinks,maxLinkWords:p.SmartLinking.MaxLinkWords};ie(e)}}),[ie,p]);var pe=(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]),de=pe.allBlocks,fe=pe.selectedBlock,ge=pe.postContent,ve=pe.postPermalink,me=function(e){return ke(void 0,void 0,void 0,(function(){var t,n,r,i;return Se(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,se((n=A||!fe)?K.All:K.Selected)];case 2:return s.sent(),a=ve.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,be.getInstance().generateSmartLinks((null==fe?void 0:fe.originalContent)&&!n?fe.originalContent:ge,D,M,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===N.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,le(!0)]):[3,8];case 5:return s.sent(),[4,ce()];case 6:return s.sent(),[4,me(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},we=function(e,t,n,r){return void 0===r&&(r=0),e.forEach((function(e,i){var s,a=r+i;if(null===(s=e.innerBlocks)||void 0===s?void 0:s.length)we(e.innerBlocks,t,n,a);else if(e.originalContent){var o=(0,V.getBlockContent)(e),l=(new DOMParser).parseFromString(o,"text/html").body.firstChild;l instanceof HTMLElement&&t.forEach((function(t){var r=function(e,t){for(var n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:function(n){var r;if(!n.textContent||!n.textContent.includes(t))return NodeFilter.FILTER_REJECT;for(var i=n.parentNode;i&&i!==e;){if("A"===i.nodeName&&!(null===(r=i.textContent)||void 0===r?void 0:r.includes(t)))return NodeFilter.FILTER_REJECT;i=i.parentNode}return NodeFilter.FILTER_ACCEPT}}),i=[];n=r.nextNode();)i.push(n);return i}(l,t.text),i="".concat(t.text,"#").concat(t.offset);n[i]=n[i]||{encountered:0,linked:0};var s=0;r.forEach((function(r){for(var o,l=new RegExp(W(t.text),"g");null!==l.exec(null!==(o=r.textContent)&&void 0!==o?o:"");){var c=n[i];c.encountered++,s++,c.encountered===t.offset+1&&c.linked<1&&(c.linked++,t.match={blockId:e.clientId,blockOffset:s-1,blockPosition:a})}}))}))}})),t},_e=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Ee=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsxs)(s.PanelRow,{className:t,children:[(0,i.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(F,{icon:G,size:18,className:"parsely-external-link-icon"})]})]}),I&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return X(null)},className:"wp-parsely-content-helper-error",children:I.Message()}),w&&y>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return _(!1)},className:"wp-parsely-smart-linking-suggested-links",children:(0,c.sprintf)(/* translators: 1 - number of smart links generated */ +(0,c.__)("Successfully added %s smart links.","wp-parsely"),y>0?y:B.length)}),(0,i.jsx)(ye,{disabled:C,selectedBlock:null==fe?void 0:fe.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:xe(xe({},p.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e?oe(t):"MaxLinkWords"===e&&ae(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return ke(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Se(this,(function(a){switch(a.label){case 0:return[4,Q(!0)];case 1:return a.sent(),[4,ue()];case 2:return a.sent(),[4,X(null)];case 3:return a.sent(),_(!1),h.trackEvent("smart_linking_generate_pressed",{is_full_content:A,selected_block:null!==(s=null==fe?void 0:fe.name)&&void 0!==s?s:"none",context:o}),[4,_e(A?"all":null==fe?void 0:fe.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;Q(!1),h.trackEvent("smart_linking_generate_timeout",{is_full_content:A,selected_block:null!==(e=null==fe?void 0:fe.name)&&void 0!==e?e:"none",context:o}),je(A?"all":null==fe?void 0:fe.clientId)}),18e4),t=z,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,me(3)];case 6:return n=a.sent(),[4,(l=n,ke(void 0,void 0,void 0,(function(){var e;return Se(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!q.find((function(t){return t.uid===e.uid&&t.applied}))})),e=ve.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=we(de,l,{}).filter((function(e){return e.match})),[4,te(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),k(!0),[3,15];case 8:return r=a.sent(),i=(0,c.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===N.ParselyAborted&&(i=(0,c.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ +(0,c.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),r.numRetries,(0,c._n)("attempt","attempts",r.numRetries,"wp-parsely")),r.message=i),[4,X(r)];case 9:return a.sent(),E("error",i,{type:"snackbar"}),[3,15];case 10:return[4,Q(!1)];case 11:return a.sent(),[4,se(t)];case 12:return a.sent(),[4,le(!1)];case 13:return a.sent(),[4,je(A?"all":null==fe?void 0:fe.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:C,disabled:C,children:U?(0,c.sprintf)(/* translators: %1$d: number of retry attempts, %2$d: maximum number of retries */ +(0,c.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),Z,3):C?(0,c.__)("Generating Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")})}),j&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return k(!0)},variant:"secondary",children:(0,c.__)("Review Smart Links","wp-parsely")})})]}),(0,i.jsx)(he,{isOpen:x,onAppliedLink:function(){v((function(e){return e+1}))},onClose:function(){_(!0),k(!1),$().length>0?T(!0):T(!1)}})]})},Te=function(){return Te=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 Fe=function(e){var n=e.data,r=e.isLoading,a=(0,l.useState)(t.Views),o=a[0],u=a[1],p=(0,l.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},g=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),L(o)); +/* translators: %s: metric description */return(0,i.jsxs)(De,{title:(0,c.__)("Categories","wp-parsely"),level:3,subtitle:g,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,c.__)("By: ","wp-parsely"),onChange:function(e){T(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,i.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[L(e),"avg_engaged"===e&&(0,c.__)(" (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,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ (0,c.__)("%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,c.sprintf)((0,c.__)("%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:be(n.views)})]},t)}))})]})]})},Pe=(0,u.createElement)(p.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.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"})),Se=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),ke=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),je=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"})),Te=function(){return Te=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]1?[2,Promise.reject(new z((0,c.sprintf)(/* translators: URL of the published post */ /* translators: URL of the published post */ -(0,c.__)("Multiple results were returned for the post %s by the Parse.ly API.","wp-parsely"),t),A.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return De(this,void 0,void 0,(function(){return Fe(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,J.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",Ve(Ve({},Be(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(ee),He=function(){return He=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)(_e,{title:(0,c.__)("Performance Stats","wp-parsely"),icon:we,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(qe,{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,c.__)("Period: ","wp-parsely")}),onChange:function(t){T(t,e)&&(w({PerformanceStats:He(He({},m.PerformanceStats),{Period:t})}),h.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)}))})})}),p?p.Message():(0,i.jsxs)(i.Fragment,{children:[Ze(m,"overview")&&(0,i.jsx)(Re,{data:g,isLoading:a}),Ze(m,"categories")&&(0,i.jsx)(xe,{data:g,isLoading:a}),Ze(m,"referrers")&&(0,i.jsx)(Ie,{data:g,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){h.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,c.__)("View this in Parse.ly","wp-parsely")})]})},Ke=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(V,{children:(0,i.jsx)(Ye,{period:t})})})},Qe=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,c.__)("Tag","wp-parsely")}),a.categories.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Section,label:(0,c.__)("Section","wp-parsely")}),a.authors.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Author,label:(0,c.__)("Author","wp-parsely")})]})})},Je=function(e){var t=e.filter,n=e.label,a=e.postData,o=Qe(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})})},et=function(e){var t=e.filter,n=e.postData,s=e.label,a=Qe(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)(Xe,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(Je,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},tt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),nt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"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"}));function rt(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,c.__)("Number of Views","wp-parsely")}),s,be(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,c.__)("Average Time","wp-parsely")}),r,n.avgEngaged]}):(0,i.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}var it,st=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"})})},at=function(e){var t,n,r=e.metric,o=e.post,l=e.postContent,u=(0,a.useDispatch)("core/notices").createNotice,p=l&&(t=l,n=W(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,c.__)("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)(rt,{metric:r,post:o,viewsIcon:(0,i.jsx)(F,{icon:Pe}),avgEngagedIcon:(0,i.jsx)(s.Dashicon,{icon:"clock",size:24})})}),p&&(0,i.jsx)("div",{className:"related-post-linked",children:(0,i.jsx)(s.Tooltip,{text:(0,c.__)("This post is linked in the content","wp-parsely"),children:(0,i.jsx)(F,{icon:tt,size:24})})})]}),(0,i.jsx)(st,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:nt,iconSize:24,onClick:function(){navigator.clipboard.writeText(o.rawUrl).then((function(){u("success",(0,c.__)("URL copied to clipboard","wp-parsely"),{type:"snackbar"})}))},label:(0,c.__)("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,c.__)("View in Parse.ly","wp-parsely")})]})]})})]})},ot=window.wp.coreData,lt=window.wp.editor,ct=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 __)}}(),ut=function(){return ut=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 z((0,c.sprintf)(/* translators: URL of the published post */ +(0,c.__)("Multiple results were returned for the post %s by the Parse.ly API.","wp-parsely"),t),N.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return rt(this,void 0,void 0,(function(){return it(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,oe.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",nt(nt({},et(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(ve),at=function(){return at=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)(De,{title:(0,c.__)("Performance Stats","wp-parsely"),icon:Me,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(dt,{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,c.__)("Period: ","wp-parsely")}),onChange:function(t){T(t,e)&&(w({PerformanceStats:at(at({},m.PerformanceStats),{Period:t})}),h.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)}))})})}),p?p.Message():(0,i.jsxs)(i.Fragment,{children:[pt(m,"overview")&&(0,i.jsx)(Xe,{data:g,isLoading:a}),pt(m,"categories")&&(0,i.jsx)(Fe,{data:g,isLoading:a}),pt(m,"referrers")&&(0,i.jsx)(Je,{data:g,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){h.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,c.__)("View this in Parse.ly","wp-parsely")})]})},ht=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(D,{children:(0,i.jsx)(ft,{period:t})})})},gt=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,c.__)("Tag","wp-parsely")}),a.categories.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Section,label:(0,c.__)("Section","wp-parsely")}),a.authors.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Author,label:(0,c.__)("Author","wp-parsely")})]})})},vt=function(e){var t=e.filter,n=e.label,a=e.postData,o=gt(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})})},mt=function(e){var t=e.filter,n=e.postData,s=e.label,a=gt(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)(yt,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(vt,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},wt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),_t=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"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"}));function bt(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,c.__)("Number of Views","wp-parsely")}),s,Ve(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,c.__)("Average Time","wp-parsely")}),r,n.avgEngaged]}):(0,i.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}var xt,kt=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"})})},St=function(e){var t,n,r=e.metric,o=e.post,l=e.postContent,u=(0,a.useDispatch)("core/notices").createNotice,p=l&&(t=l,n=W(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,c.__)("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)(bt,{metric:r,post:o,viewsIcon:(0,i.jsx)(F,{icon:Ge}),avgEngagedIcon:(0,i.jsx)(s.Dashicon,{icon:"clock",size:24})})}),p&&(0,i.jsx)("div",{className:"related-post-linked",children:(0,i.jsx)(s.Tooltip,{text:(0,c.__)("This post is linked in the content","wp-parsely"),children:(0,i.jsx)(F,{icon:wt,size:24})})})]}),(0,i.jsx)(kt,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:_t,iconSize:24,onClick:function(){navigator.clipboard.writeText(o.rawUrl).then((function(){u("success",(0,c.__)("URL copied to clipboard","wp-parsely"),{type:"snackbar"})}))},label:(0,c.__)("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,c.__)("View in Parse.ly","wp-parsely")})]})]})})]})},Pt=window.wp.coreData,jt=window.wp.editor,Tt=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 __)}}(),Et=function(){return Et=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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),m=v.authors,w=v.categories,_=v.tags,b=v.isReady;(0,l.useEffect)((function(){if(b){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})):[]};y({authors:e(m),categories:e(w),tags:e(_)})}}),[m,w,_,b]);var x=(0,l.useState)(!0),P=x[0],S=x[1],j=(0,l.useState)(),L=j[0],A=j[1],N=(0,l.useState)(),R=N[0],I=N[1],B=(0,l.useState)([]),M=B[0],V=B[1],D=(0,l.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=D[0],G=D[1],H=(0,l.useState)(void 0),z=H[0],W=H[1],U=(0,O.useDebounce)(W,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;U(t())}),[U]);var $=function(e,t){u({RelatedPosts:ht(ht({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,l.useEffect)((function(){var e,t,n=function(e){return gt(void 0,void 0,void 0,(function(){return yt(this,(function(t){return ft.getInstance().getRelatedPosts(p,d,F).then((function(e){V(e.posts),I(e.message),S(!1)})).catch((function(t){return gt(void 0,void 0,void 0,(function(){return yt(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),A(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===g.authors.length,c=0===g.tags.length,u=0===g.categories.length,f=i&&!g.authors.includes(F.value),h=s&&!g.tags.includes(F.value),y=a&&!g.categories.includes(F.value);return S(!0),o||s&&c||a&&u||i&&l?Object.values(g).every((function(e){return 0===e.length}))||G((e="",t=r.Unavailable,g.tags.length>=1?(t=r.Tag,e=g.tags[0]):g.categories.length>=1?(t=r.Section,e=g.categories[0]):g.authors.length>=1&&(t=r.Author,e=g.authors[0]),{type:t,value:e})):h?G({type:r.Tag,value:g.tags[0]}):y?G({type:r.Section,value:g.categories[0]}):f?G({type:r.Author,value:g.authors[0]}):n(1),function(){S(!1),V([]),I(""),A(void 0)}}),[p,d,F,g]),0===g.authors.length&&0===g.categories.length&&0===g.tags.length&&b?(0,i.jsx)("div",{className:"wp-parsely-related-posts",children:(0,i.jsx)("div",{className:"related-posts-body",children:(0,c.__)("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,c.__)("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;T(n=e,t)&&(u({RelatedPosts:ht(ht({},o.RelatedPosts),{Metric:n})}),h.trackEvent("related_posts_metric_changed",{metric:n}))},prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,c.__)("Metric: ","wp-parsely")}),value:d,children:Object.values(t).map((function(e){return(0,i.jsx)("option",{value:e,children:C(e)},e)}))}),(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:p,prefix:(0,i.jsxs)(s.__experimentalInputControlPrefixWrapper,{children:[(0,c.__)("Period: ","wp-parsely")," "]}),onChange:function(t){return function(t){T(t,e)&&(u({RelatedPosts:ht(ht({},o.RelatedPosts),{Period:t})}),h.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)(et,{label:(0,c.__)("Filter by","wp-parsely"),filter:F,onFilterTypeChange:function(e){if(T(e,r)){var t="",n=e;r.Tag===n&&(t=g.tags[0]),r.Section===n&&(t=g.categories[0]),r.Author===n&&(t=g.authors[0]),""!==t&&($(n,t),G({type:n,value:t}),h.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&($(F.type,e),G(ht(ht({},F),{value:e})))},postData:g}),(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===F.type?(0,c.sprintf)(/* translators: 1: tag name, 2: period */ /* translators: 1: tag name, 2: period */ -(0,c.__)("Top related posts with the “%1$s” tag in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Section===F.type?(0,c.sprintf)(/* translators: 1: section name, 2: period */ /* translators: 1: section name, 2: period */ -(0,c.__)("Top related posts in the “%1$s” section in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Author===F.type?(0,c.sprintf)(/* translators: 1: author name, 2: period */ /* translators: 1: author name, 2: period */ -(0,c.__)("Top related posts by %1$s in the %2$s.","wp-parsely"),F.value,E(p,!0)):null!=R?R:""})}),L&&L.Message(),P&&(0,i.jsx)("div",{className:"related-posts-loading-message","data-testid":"parsely-related-posts-loading-message",children:(0,c.__)("Loading…","wp-parsely")}),!P&&!L&&0===M.length&&(0,i.jsx)("div",{className:"related-posts-empty","data-testid":"parsely-related-posts-empty",children:(0,c.__)("No related posts found.","wp-parsely")}),!P&&M.length>0&&(0,i.jsx)("div",{className:"related-posts-list",children:M.map((function(e){return(0,i.jsx)(at,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},mt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),wt=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"})})},_t={journalist:{label:(0,c.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,c.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,c.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,c.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,c.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,c.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,c.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,c.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,c.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,c.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,c.__)("Custom Persona","wp-parsely"),icon:mt}},bt=Object.keys(_t),xt=function(e){return"custom"===e||""===e?_t.custom.label:Pt(e)?e:_t[e].label},Pt=function(e){return!bt.includes(e)||"custom"===e},St=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},kt=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,c.__)("Select a persona…","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Persona","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:Pt(t)?_t.custom.label:r}),(0,i.jsx)(wt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Persona","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:bt.map((function(e){if(!h&&"custom"===e)return null;var r=_t[e],a=e===t||Pt(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(F,{icon:r.icon}),r.label]},e)}))})})}}),h&&Pt(t)&&(0,i.jsx)(St,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},jt={neutral:{label:(0,c.__)("Neutral","wp-parsely")},formal:{label:(0,c.__)("Formal","wp-parsely")},humorous:{label:(0,c.__)("Humorous","wp-parsely")},confident:{label:(0,c.__)("Confident","wp-parsely")},provocative:{label:(0,c.__)("Provocative","wp-parsely")},serious:{label:(0,c.__)("Serious","wp-parsely")},inspirational:{label:(0,c.__)("Inspirational","wp-parsely")},skeptical:{label:(0,c.__)("Skeptical","wp-parsely")},conversational:{label:(0,c.__)("Conversational","wp-parsely")},analytical:{label:(0,c.__)("Analytical","wp-parsely")},custom:{label:(0,c.__)("Custom Tone","wp-parsely"),icon:mt}},Tt=Object.keys(jt),Et=function(e){return"custom"===e||""===e?jt.custom.label:Ct(e)?e:jt[e].label},Ct=function(e){return!Tt.includes(e)||"custom"===e},Lt=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},At=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,c.__)("Select a tone","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Tone","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:Ct(t)?jt.custom.label:r}),(0,i.jsx)(wt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Select a tone","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Tt.map((function(e){if(!h&&"custom"===e)return null;var r=jt[e],a=e===t||Ct(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(F,{icon:r.icon}),r.label]},e)}))})})}}),h&&Ct(t)&&(0,i.jsx)(Lt,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},Nt=(0,u.createElement)(p.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.Path,{d:"M10.97 10.159a3.382 3.382 0 0 0-2.857.955l1.724 1.723-2.836 2.913L7 17h1.25l2.913-2.837 1.723 1.723a3.38 3.38 0 0 0 .606-.825c.33-.63.446-1.343.35-2.032L17 10.695 13.305 7l-2.334 3.159Z"})),Ot=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"})),Rt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})),It=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z"})),Bt=function(){return Bt=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,l.createInterpolateElement)( +message:(0,c.sprintf)((0,c.__)('by author "%1$s"',"wp-parsely"),n.value)};throw new z((0,c.__)("No valid filter type has been specified.","wp-parsely"),N.CannotFormulateApiQuery)},t}(ve),At=function(){return At=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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),m=v.authors,w=v.categories,_=v.tags,b=v.isReady;(0,l.useEffect)((function(){if(b){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})):[]};y({authors:e(m),categories:e(w),tags:e(_)})}}),[m,w,_,b]);var x=(0,l.useState)(!0),k=x[0],S=x[1],j=(0,l.useState)(),C=j[0],N=j[1],A=(0,l.useState)(),R=A[0],I=A[1],B=(0,l.useState)([]),M=B[0],D=B[1],V=(0,l.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=V[0],G=V[1],H=(0,l.useState)(void 0),z=H[0],W=H[1],U=(0,O.useDebounce)(W,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;U(t())}),[U]);var Z=function(e,t){u({RelatedPosts:At(At({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,l.useEffect)((function(){var e,t,n=function(e){return Ot(void 0,void 0,void 0,(function(){return Rt(this,(function(t){return Nt.getInstance().getRelatedPosts(p,d,F).then((function(e){D(e.posts),I(e.message),S(!1)})).catch((function(t){return Ot(void 0,void 0,void 0,(function(){return Rt(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),N(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===g.authors.length,c=0===g.tags.length,u=0===g.categories.length,f=i&&!g.authors.includes(F.value),h=s&&!g.tags.includes(F.value),y=a&&!g.categories.includes(F.value);return S(!0),o||s&&c||a&&u||i&&l?Object.values(g).every((function(e){return 0===e.length}))||G((e="",t=r.Unavailable,g.tags.length>=1?(t=r.Tag,e=g.tags[0]):g.categories.length>=1?(t=r.Section,e=g.categories[0]):g.authors.length>=1&&(t=r.Author,e=g.authors[0]),{type:t,value:e})):h?G({type:r.Tag,value:g.tags[0]}):y?G({type:r.Section,value:g.categories[0]}):f?G({type:r.Author,value:g.authors[0]}):n(1),function(){S(!1),D([]),I(""),N(void 0)}}),[p,d,F,g]),0===g.authors.length&&0===g.categories.length&&0===g.tags.length&&b?(0,i.jsx)("div",{className:"wp-parsely-related-posts",children:(0,i.jsx)("div",{className:"related-posts-body",children:(0,c.__)("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,c.__)("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;T(n=e,t)&&(u({RelatedPosts:At(At({},o.RelatedPosts),{Metric:n})}),h.trackEvent("related_posts_metric_changed",{metric:n}))},prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,c.__)("Metric: ","wp-parsely")}),value:d,children:Object.values(t).map((function(e){return(0,i.jsx)("option",{value:e,children:L(e)},e)}))}),(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:p,prefix:(0,i.jsxs)(s.__experimentalInputControlPrefixWrapper,{children:[(0,c.__)("Period: ","wp-parsely")," "]}),onChange:function(t){return function(t){T(t,e)&&(u({RelatedPosts:At(At({},o.RelatedPosts),{Period:t})}),h.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)(mt,{label:(0,c.__)("Filter by","wp-parsely"),filter:F,onFilterTypeChange:function(e){if(T(e,r)){var t="",n=e;r.Tag===n&&(t=g.tags[0]),r.Section===n&&(t=g.categories[0]),r.Author===n&&(t=g.authors[0]),""!==t&&(Z(n,t),G({type:n,value:t}),h.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(F.type,e),G(At(At({},F),{value:e})))},postData:g}),(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===F.type?(0,c.sprintf)(/* translators: 1: tag name, 2: period */ +(0,c.__)("Top related posts with the “%1$s” tag in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Section===F.type?(0,c.sprintf)(/* translators: 1: section name, 2: period */ +(0,c.__)("Top related posts in the “%1$s” section in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Author===F.type?(0,c.sprintf)(/* translators: 1: author name, 2: period */ +(0,c.__)("Top related posts by %1$s in the %2$s.","wp-parsely"),F.value,E(p,!0)):null!=R?R:""})}),C&&C.Message(),k&&(0,i.jsx)("div",{className:"related-posts-loading-message","data-testid":"parsely-related-posts-loading-message",children:(0,c.__)("Loading…","wp-parsely")}),!k&&!C&&0===M.length&&(0,i.jsx)("div",{className:"related-posts-empty","data-testid":"parsely-related-posts-empty",children:(0,c.__)("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)(St,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},Bt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),Mt=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"})})},Dt={journalist:{label:(0,c.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,c.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,c.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,c.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,c.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,c.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,c.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,c.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,c.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,c.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,c.__)("Custom Persona","wp-parsely"),icon:Bt}},Vt=Object.keys(Dt),Ft=function(e){return"custom"===e||""===e?Dt.custom.label:Gt(e)?e:Dt[e].label},Gt=function(e){return!Vt.includes(e)||"custom"===e},Ht=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},zt=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,c.__)("Select a persona…","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Persona","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:Gt(t)?Dt.custom.label:r}),(0,i.jsx)(Mt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Persona","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Vt.map((function(e){if(!h&&"custom"===e)return null;var r=Dt[e],a=e===t||Gt(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(F,{icon:r.icon}),r.label]},e)}))})})}}),h&&Gt(t)&&(0,i.jsx)(Ht,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},Wt={neutral:{label:(0,c.__)("Neutral","wp-parsely")},formal:{label:(0,c.__)("Formal","wp-parsely")},humorous:{label:(0,c.__)("Humorous","wp-parsely")},confident:{label:(0,c.__)("Confident","wp-parsely")},provocative:{label:(0,c.__)("Provocative","wp-parsely")},serious:{label:(0,c.__)("Serious","wp-parsely")},inspirational:{label:(0,c.__)("Inspirational","wp-parsely")},skeptical:{label:(0,c.__)("Skeptical","wp-parsely")},conversational:{label:(0,c.__)("Conversational","wp-parsely")},analytical:{label:(0,c.__)("Analytical","wp-parsely")},custom:{label:(0,c.__)("Custom Tone","wp-parsely"),icon:Bt}},Ut=Object.keys(Wt),Zt=function(e){return"custom"===e||""===e?Wt.custom.label:qt(e)?e:Wt[e].label},qt=function(e){return!Ut.includes(e)||"custom"===e},$t=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},Kt=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,c.__)("Select a tone","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Tone","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:qt(t)?Wt.custom.label:r}),(0,i.jsx)(Mt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Select a tone","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Ut.map((function(e){if(!h&&"custom"===e)return null;var r=Wt[e],a=e===t||qt(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(F,{icon:r.icon}),r.label]},e)}))})})}}),h&&qt(t)&&(0,i.jsx)($t,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},Yt=(0,u.createElement)(p.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.Path,{d:"M10.97 10.159a3.382 3.382 0 0 0-2.857.955l1.724 1.723-2.836 2.913L7 17h1.25l2.913-2.837 1.723 1.723a3.38 3.38 0 0 0 .606-.825c.33-.63.446-1.343.35-2.032L17 10.695 13.305 7l-2.334 3.159Z"})),Qt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"})),Xt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})),Jt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z"})),en=function(){return en=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,l.createInterpolateElement)( // translators: %1$s is the tone, %2$s is the persona. -// translators: %1$s is the tone, %2$s is the persona. -(0,c.__)("We've generated a few titles based on the content of your post, written as a .","wp-parsely"),{tone:(0,i.jsx)("strong",{children:Et(d)}),persona:(0,i.jsx)("strong",{children:xt(y)})})}):(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(F,{icon:G,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==S&&(0,i.jsx)(Wt,{title:S,type:it.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(Ut,{pinnedTitles:b,isOpen:!0}),_.length>0&&(0,i.jsx)(qt,{suggestions:_,isOpen:!0,isLoading:w})]}),(0,i.jsx)($t,{isLoading:w,onPersonaChange:function(e){N("Persona",e),v(e)},onSettingChange:N,onToneChange:function(e){N("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"===y,onClick:function(){return Xt(void 0,void 0,void 0,(function(){return Jt(this,(function(e){switch(e.label){case 0:return u(void 0),!1!==w?[3,2]:(h.trackEvent("title_suggestions_generate_pressed",{request_more:_.length>0,total_titles:_.length,total_pinned:_.filter((function(e){return e.isPinned})).length,tone:d,persona:y}),[4,(t=it.PostTitle,n=O,r=d,i=y,Xt(void 0,void 0,void 0,(function(){var e,s,a;return Jt(this,(function(o){switch(o.label){case 0:return[4,E(!0)];case 1:o.sent(),e=Kt.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(),u(a),T(t,[]),[3,6];case 6:return[4,E(!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,c.__)("Generating Titles…","wp-parsely"),!w&&x.length>0&&(0,c.__)("Generate More","wp-parsely"),!w&&0===x.length&&(0,c.__)("Generate Titles","wp-parsely")]})})]})})},tn=function(){return tn=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:Zt(d)}),persona:(0,i.jsx)("strong",{children:Ft(y)})})}):(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(F,{icon:G,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==S&&(0,i.jsx)(cn,{title:S,type:xt.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(un,{pinnedTitles:b,isOpen:!0}),_.length>0&&(0,i.jsx)(fn,{suggestions:_,isOpen:!0,isLoading:w})]}),(0,i.jsx)(pn,{isLoading:w,onPersonaChange:function(e){A("Persona",e),v(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"===y,onClick:function(){return vn(void 0,void 0,void 0,(function(){return mn(this,(function(e){switch(e.label){case 0:return u(void 0),!1!==w?[3,2]:(h.trackEvent("title_suggestions_generate_pressed",{request_more:_.length>0,total_titles:_.length,total_pinned:_.filter((function(e){return e.isPinned})).length,tone:d,persona:y}),[4,(t=xt.PostTitle,n=O,r=d,i=y,vn(void 0,void 0,void 0,(function(){var e,s,a;return mn(this,(function(o){switch(o.label){case 0:return[4,E(!0)];case 1:o.sent(),e=gn.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(),u(a),T(t,[]),[3,6];case 6:return[4,E(!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,c.__)("Generating Titles…","wp-parsely"),!w&&x.length>0&&(0,c.__)("Generate More","wp-parsely"),!w&&0===x.length&&(0,c.__)("Generate Titles","wp-parsely")]})})]})})},bn=function(){return bn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => 'ea46a8c97ad927f52cbc'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => '0dbdd33d5ec4fabd7275'); diff --git a/build/content-helper/excerpt-generator.css b/build/content-helper/excerpt-generator.css index 50ef38a2e..c76c7b2eb 100644 --- a/build/content-helper/excerpt-generator.css +++ b/build/content-helper/excerpt-generator.css @@ -1 +1 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.editor-post-excerpt__loading_animation{left:.5625rem;position:absolute;top:1.8125rem}.editor-post-excerpt__textarea{margin-bottom:var(--grid-unit-10)}.editor-post-excerpt__textarea textarea:-moz-read-only{background-color:var(--Gutenberg-White,#fff)}.editor-post-excerpt__textarea textarea:read-only{background-color:var(--Gutenberg-White,#fff)}.wp-parsely-excerpt-generator{margin-top:1.25rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header{align-items:center;display:flex;justify-content:flex-start}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label{display:inline-block;font-size:.6875rem;font-weight:600;line-height:1.4;margin-left:.3125rem;padding:0;text-transform:uppercase}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label span.beta-label{color:var(--Gutenberg-Gray-700,#757575);padding-left:.375rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls{display:flex;gap:var(--grid-unit-10)}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls button{flex-grow:1;height:2.5rem;justify-content:center;margin-bottom:var(--grid-unit-10);margin-top:var(--grid-unit-10);padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-excerpt-generator .components-notice{margin:var(--grid-unit-20) 0 var(--grid-unit-15) 0}.wp-parsely-excerpt-generator .components-notice .components-notice__content{margin:0}.wp-parsely-excerpt-generator .components-notice .components-notice__content .content-helper-error-message{margin-top:0!important}.wp-parsely-excerpt-generator .components-notice .components-notice__content .content-helper-error-message p:last-child{margin-bottom:0!important} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.editor-post-excerpt__loading_animation{left:.5625rem;position:absolute;top:1.8125rem}.editor-post-excerpt__textarea{margin-bottom:var(--grid-unit-10)}.editor-post-excerpt__textarea textarea:-moz-read-only{background-color:var(--Gutenberg-White,#fff)}.editor-post-excerpt__textarea textarea:read-only{background-color:var(--Gutenberg-White,#fff)}.wp-parsely-excerpt-generator{margin-top:1.25rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header{align-items:center;display:flex;justify-content:flex-start}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label{display:inline-block;font-size:.6875rem;font-weight:600;line-height:1.4;margin-left:.3125rem;padding:0;text-transform:uppercase}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label span.beta-label{color:var(--Gutenberg-Gray-700,#757575);padding-left:.375rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls{display:flex;gap:var(--grid-unit-10)}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls button{flex-grow:1;height:2.5rem;justify-content:center;margin-bottom:var(--grid-unit-10);margin-top:var(--grid-unit-10);padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-excerpt-generator .components-notice{margin:var(--grid-unit-20) 0 var(--grid-unit-15) 0}.wp-parsely-excerpt-generator .components-notice .components-notice__content{margin:0}.wp-parsely-excerpt-generator .components-notice .components-notice__content .content-helper-error-message{margin-top:0!important}.wp-parsely-excerpt-generator .components-notice .components-notice__content .content-helper-error-message p:last-child{margin-bottom:0!important} diff --git a/build/content-helper/excerpt-generator.js b/build/content-helper/excerpt-generator.js index f32d0af5f..2378d0188 100644 --- a/build/content-helper/excerpt-generator.js +++ b/build/content-helper/excerpt-generator.js @@ -1,4 +1,3 @@ -!function(){"use strict";var e={20:function(e,t,r){var n=r(609),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,p=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(p=t.ref),t)o.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:p,props:s,_owner:i.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},848:function(e,t,r){e.exports=r(20)},609:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n=window.wp.data,a=window.wp.hooks,s=window.wp.plugins,o=r(848),i=window.wp.components,l=window.wp.editPost,c=window.wp.editor,p=window.wp.element,u=window.wp.i18n,d=window.wp.wordcount,y=r(609),h=window.wp.primitives,f=(0,y.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,y.createElement)(h.Path,{d:"M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"})),w=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return r=this,n=arguments,s=function(t,r){var n;return void 0===r&&(r={}),function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),v=(w.trackEvent,function(e){var t=e.size,r=void 0===t?24:t,n=e.className,a=void 0===n?"wp-parsely-icon":n;return(0,o.jsxs)(i.SVG,{className:a,height:r,viewBox:"0 0 60 65",width:r,xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M23.72,51.53c0-.18,0-.34-.06-.52a13.11,13.11,0,0,0-2.1-5.53A14.74,14.74,0,0,0,19.12,43c-.27-.21-.5-.11-.51.22l-.24,3.42c0,.33-.38.35-.49,0l-1.5-4.8a1.4,1.4,0,0,0-.77-.78,23.91,23.91,0,0,0-3.1-.84c-1.38-.24-3.39-.39-3.39-.39-.34,0-.45.21-.25.49l2.06,3.76c.2.27,0,.54-.29.33l-4.51-3.6a3.68,3.68,0,0,0-2.86-.48c-1,.16-2.44.46-2.44.46a.68.68,0,0,0-.39.25.73.73,0,0,0-.14.45S.41,43,.54,44a3.63,3.63,0,0,0,1.25,2.62L6.48,50c.28.2.09.49-.23.37l-4.18-.94c-.32-.12-.5,0-.4.37,0,0,.69,1.89,1.31,3.16a24,24,0,0,0,1.66,2.74,1.34,1.34,0,0,0,1,.52l5,.13c.33,0,.41.38.1.48L7.51,58c-.31.1-.34.35-.07.55a14.29,14.29,0,0,0,3.05,1.66,13.09,13.09,0,0,0,5.9.5,25.13,25.13,0,0,0,4.34-1,9.55,9.55,0,0,1-.08-1.2,9.32,9.32,0,0,1,3.07-6.91"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M59.7,41.53a.73.73,0,0,0-.14-.45.68.68,0,0,0-.39-.25s-1.43-.3-2.44-.46a3.64,3.64,0,0,0-2.86.48l-4.51,3.6c-.26.21-.49-.06-.29-.33l2.06-3.76c.2-.28.09-.49-.25-.49,0,0-2,.15-3.39.39a23.91,23.91,0,0,0-3.1.84,1.4,1.4,0,0,0-.77.78l-1.5,4.8c-.11.32-.48.3-.49,0l-.24-3.42c0-.33-.24-.43-.51-.22a14.74,14.74,0,0,0-2.44,2.47A13.11,13.11,0,0,0,36.34,51c0,.18,0,.34-.06.52a9.26,9.26,0,0,1,3,8.1,24.1,24.1,0,0,0,4.34,1,13.09,13.09,0,0,0,5.9-.5,14.29,14.29,0,0,0,3.05-1.66c.27-.2.24-.45-.07-.55l-3.22-1.17c-.31-.1-.23-.47.1-.48l5-.13a1.38,1.38,0,0,0,1-.52A24.6,24.6,0,0,0,57,52.92c.61-1.27,1.31-3.16,1.31-3.16.1-.33-.08-.49-.4-.37l-4.18.94c-.32.12-.51-.17-.23-.37l4.69-3.34A3.63,3.63,0,0,0,59.46,44c.13-1,.24-2.47.24-2.47"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M46.5,25.61c0-.53-.35-.72-.8-.43l-4.86,2.66c-.45.28-.56-.27-.23-.69l4.66-6.23a2,2,0,0,0,.28-1.68,36.51,36.51,0,0,0-2.19-4.89,34,34,0,0,0-2.81-3.94c-.33-.41-.74-.35-.91.16l-2.28,5.68c-.16.5-.6.48-.59-.05l.28-8.93a2.54,2.54,0,0,0-.66-1.64S35,4.27,33.88,3.27,30.78.69,30.78.69a1.29,1.29,0,0,0-1.54,0s-1.88,1.49-3.12,2.59-2.48,2.35-2.48,2.35A2.5,2.5,0,0,0,23,7.27l.27,8.93c0,.53-.41.55-.58.05l-2.29-5.69c-.17-.5-.57-.56-.91-.14a35.77,35.77,0,0,0-3,4.2,35.55,35.55,0,0,0-2,4.62,2,2,0,0,0,.27,1.67l4.67,6.24c.33.42.23,1-.22.69l-4.87-2.66c-.45-.29-.82-.1-.82.43a18.6,18.6,0,0,0,.83,5.07,20.16,20.16,0,0,0,5.37,7.77c3.19,3,5.93,7.8,7.45,11.08A9.6,9.6,0,0,1,30,49.09a9.31,9.31,0,0,1,2.86.45c1.52-3.28,4.26-8.11,7.44-11.09a20.46,20.46,0,0,0,5.09-7,19,19,0,0,0,1.11-5.82"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M36.12,58.44A6.12,6.12,0,1,1,30,52.32a6.11,6.11,0,0,1,6.12,6.12"})]})}),g=window.wp.apiFetch,_=r.n(g),P=window.wp.url,m=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,o.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},b=(e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)},function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function __(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(__.prototype=r.prototype,new __)});!function(e){e.CannotFormulateApiQuery="ch_cannot_formulate_api_query",e.FetchError="fetch_error",e.HttpRequestFailed="http_request_failed",e.ParselyAborted="ch_parsely_aborted",e[e.ParselyApiForbidden=403]="ParselyApiForbidden",e.ParselyApiResponseContainsError="ch_response_contains_error",e.ParselyApiReturnedNoData="ch_parsely_api_returned_no_data",e.ParselyApiReturnedTooManyResults="ch_parsely_api_returned_too_many_results",e.PluginCredentialsNotSetMessageDetected="parsely_credentials_not_set_message_detected",e.PluginSettingsApiSecretNotSet="parsely_api_secret_not_set",e.PluginSettingsSiteIdNotSet="parsely_site_id_not_set",e.PostIsNotPublished="ch_post_not_published",e.ParselySuggestionsApiAuthUnavailable="AUTH_UNAVAILABLE",e.ParselySuggestionsApiNoAuthentication="NO_AUTHENTICATION",e.ParselySuggestionsApiNoAuthorization="NO_AUTHORIZATION",e.ParselySuggestionsApiNoData="NO_DATA",e.ParselySuggestionsApiOpenAiError="OPENAI_ERROR",e.ParselySuggestionsApiOpenAiSchema="OPENAI_SCHEMA",e.ParselySuggestionsApiOpenAiUnavailable="OPENAI_UNAVAILABLE",e.ParselySuggestionsApiSchemaError="SCHEMA_ERROR"}(t||(t={}));var x=function(e){function r(n,a,s){void 0===s&&(s=(0,u.__)("Error: ","wp-parsely"));var o=e.call(this,s+n)||this;o.hint=null,o.name=o.constructor.name,o.code=a;var i=[t.ParselyApiForbidden,t.ParselyApiResponseContainsError,t.ParselyApiReturnedNoData,t.ParselyApiReturnedTooManyResults,t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsApiSecretNotSet,t.PluginSettingsSiteIdNotSet,t.PostIsNotPublished,t.ParselySuggestionsApiAuthUnavailable,t.ParselySuggestionsApiNoAuthentication,t.ParselySuggestionsApiNoAuthorization,t.ParselySuggestionsApiNoData,t.ParselySuggestionsApiSchemaError];return o.retryFetch=!i.includes(o.code),Object.setPrototypeOf(o,r.prototype),o.code===t.ParselySuggestionsApiNoAuthorization?o.message=(0,u.__)('This AI-powered feature is opt-in. To gain access, please submit a request here.',"wp-parsely"):o.code===t.ParselySuggestionsApiOpenAiError||o.code===t.ParselySuggestionsApiOpenAiUnavailable?o.message=(0,u.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):o.code===t.HttpRequestFailed&&o.message.includes("cURL error 28")?o.message=(0,u.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):o.code===t.ParselySuggestionsApiSchemaError?o.message=(0,u.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):o.code===t.ParselySuggestionsApiNoData?o.message=(0,u.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):o.code===t.ParselySuggestionsApiOpenAiSchema?o.message=(0,u.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):o.code===t.ParselySuggestionsApiAuthUnavailable&&(o.message=(0,u.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),o}return b(r,e),r.prototype.Message=function(e){return void 0===e&&(e=null),[t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsSiteIdNotSet,t.PluginSettingsApiSecretNotSet].includes(this.code)?function(e){var t;return void 0===e&&(e=null),(0,o.jsx)(m,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:null!==(t=window.wpParselyEmptyCredentialsMessage)&&void 0!==t?t:(0,u.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely")})}(e):(this.code===t.FetchError&&(this.hint=this.Hint((0,u.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==t.ParselyApiForbidden&&this.code!==t.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,u.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===t.HttpRequestFailed&&(this.hint=this.Hint((0,u.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,o.jsx)(m,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

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

".concat(this.message,"

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

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

")},r}(Error),A=function(){function e(){}return e.prototype.generateExcerpt=function(e,r){return n=this,a=void 0,o=function(){var n,a,s;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0,R=(0,d.count)(s||k,"words",{}),C=(0,u.sprintf)( // Translators: %1$s the number of words in the excerpt. (0,u._n)("%1$s word","%1$s words",R,"wp-parsely"),R);return(0,p.useEffect)((function(){var e=document.querySelector(".editor-post-excerpt textarea");e&&(e.scrollTop=0)}),[s]),(0,o.jsxs)("div",{className:"editor-post-excerpt",children:[(0,o.jsxs)("div",{style:{position:"relative"},children:[t&&(0,o.jsx)("div",{className:"editor-post-excerpt__loading_animation",children:(0,o.jsx)(T,{})}),(0,o.jsx)(i.TextareaControl,{__nextHasNoMarginBottom:!0,label:(0,u.__)("Write an excerpt (optional)","wp-parsely"),className:"editor-post-excerpt__textarea",onChange:function(e){return b({excerpt:e})},readOnly:t||O,value:t?"":O?s:k,help:R?C:null})]}),(0,o.jsxs)(i.Button,{href:(0,u.__)("https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt","wp-parsely"),target:"_blank",variant:"link",children:[(0,u.__)("Learn more about manual excerpts","wp-parsely"),(0,o.jsx)(i.Icon,{icon:f,size:18,className:"parsely-external-link-icon"})]}),(0,o.jsxs)("div",{className:"wp-parsely-excerpt-generator",children:[(0,o.jsxs)("div",{className:"wp-parsely-excerpt-generator-header",children:[(0,o.jsx)(v,{size:16}),(0,o.jsxs)("div",{className:"wp-parsely-excerpt-generator-header-label",children:[(0,u.__)("Generate With Parse.ly","wp-parsely"),(0,o.jsx)("span",{className:"beta-label",children:(0,u.__)("Beta","wp-parsely")})]})]}),P&&(0,o.jsx)(i.Notice,{status:"info",className:"wp-parsely-excerpt-generator-error",children:P.Message()}),(0,o.jsx)("div",{className:"wp-parsely-excerpt-generator-controls",children:O?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.Button,{variant:"secondary",onClick:function(){return E(void 0,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,b({excerpt:s})];case 1:return e.sent(),l(""),w.trackEvent("excerpt_generator_accepted"),[2]}}))}))},children:(0,u.__)("Accept","wp-parsely")}),(0,o.jsx)(i.Button,{isDestructive:!0,variant:"secondary",onClick:function(){return E(void 0,void 0,void 0,(function(){return S(this,(function(e){return l(""),w.trackEvent("excerpt_generator_discarded"),[2]}))}))},children:(0,u.__)("Discard","wp-parsely")})]}):(0,o.jsxs)(i.Button,{onClick:function(){return E(void 0,void 0,void 0,(function(){var e,t;return S(this,(function(n){switch(n.label){case 0:r(!0),m(void 0),n.label=1;case 1:return n.trys.push([1,3,4,5]),w.trackEvent("excerpt_generator_pressed"),[4,x.generateExcerpt(j,I)];case 2:return e=n.sent(),l(e),g(h+1),[3,5];case 3:return t=n.sent(),m(t),[3,5];case 4:return r(!1),[7];case 5:return[2]}}))}))},variant:"primary",isBusy:t,disabled:t,children:[t&&(0,u.__)("Generating Excerpt…","wp-parsely"),!t&&h>0&&(0,u.__)("Regenerate Excerpt","wp-parsely"),!t&&0===h&&(0,u.__)("Generate Excerpt","wp-parsely")]})}),(0,o.jsxs)(i.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-excerpt-generator-beta",target:"_blank",variant:"link",children:[(0,u.__)("Learn more about Parse.ly AI","wp-parsely"),(0,o.jsx)(i.Icon,{icon:f,size:18,className:"parsely-external-link-icon"})]})]})]})},T=function(){return(0,o.jsx)(i.Animate,{type:"loading",children:function(e){var t=e.className;return(0,o.jsx)("span",{className:t,children:(0,u.__)("Generating…","wp-parsely")})}})},k=function(){return(0,o.jsx)(c.PostTypeSupportCheck,{supportKeys:"excerpt",children:(0,o.jsx)(l.PluginDocumentSettingPanel,{name:"parsely-post-excerpt",title:"Excerpt",children:(0,o.jsx)(N,{})})})};(0,a.addFilter)("plugins.registerPlugin","wp-parsely-excerpt-generator",(function(e,t){var r,o,i,l;return"wp-parsely-block-editor-sidebar"!==t||((null===(r=null===window||void 0===window?void 0:window.Jetpack_Editor_Initial_State)||void 0===r?void 0:r.available_blocks["ai-content-lens"])&&(console.log("Parse.ly: Jetpack AI is enabled and will be disabled."),(0,a.removeFilter)("blocks.registerBlockType","jetpack/ai-content-lens-features")),(0,s.registerPlugin)("wp-parsely-excerpt-generator",{render:k}),(null===(o=(0,n.dispatch)("core/editor"))||void 0===o?void 0:o.removeEditorPanel)?null===(i=(0,n.dispatch)("core/editor"))||void 0===i||i.removeEditorPanel("post-excerpt"):null===(l=(0,n.dispatch)("core/edit-post"))||void 0===l||l.removeEditorPanel("post-excerpt")),e}),1e3)}()}(); \ No newline at end of file diff --git a/build/recommended-widget.asset.php b/build/recommended-widget.asset.php index b00da9edb..f998b6b9f 100644 --- a/build/recommended-widget.asset.php +++ b/build/recommended-widget.asset.php @@ -1 +1 @@ - array('wp-dom-ready'), 'version' => 'd31a14a294140e99fc99'); + array('wp-dom-ready'), 'version' => '57af74a55f7864233c8f'); diff --git a/build/recommended-widget.css b/build/recommended-widget.css index c656f7e04..42de09dcc 100644 --- a/build/recommended-widget.css +++ b/build/recommended-widget.css @@ -1 +1 @@ -.parsely-recommended-widget,.parsely-recommended-widget *{box-sizing:border-box}.parsely-recommended-widget{display:block;width:100%}.parsely-recommended-widget-hidden{display:none}.parsely-recommended-widget-entry a{padding:0}.parsely-recommended-widget-entry img{float:left;margin-right:15px}.parsely-recommended-widget-entry:after{clear:both;content:"";display:table}.parsely-author{display:block;margin-top:5px}.parsely-recommended-widget-title{font-size:1.1em;font-weight:700}.list-horizontal .parsely-recommended-widget-entry{border:none;display:inline-block;margin-bottom:15px;margin-right:15px;max-width:215px;min-width:142.5px;padding:0;vertical-align:text-top;width:45%}.list-horizontal .parsely-recommended-widget-entry img{float:none;margin-right:0;max-width:100%}@supports(display:grid){.parsely-recommended-widget-entry:after{clear:none;display:none}.display-thumbnail .parsely-recommended-widget{display:grid;grid-template-rows:auto;grid-gap:15px;grid-template-columns:minmax(85px,auto) minmax(50%,auto)}.list-horizontal .parsely-recommended-widget-entry{border:none;display:block;margin:0;max-width:none;min-width:auto;padding:0;vertical-align:initial;width:auto}.display-thumbnail:not(.list-horizontal) .parsely-recommended-widget-entry{display:contents}.parsely-recommendation-widget:not(.list-horizontal) .parsely-recommended-widget-entry img{float:none;margin-right:0;max-width:100%}.list-horizontal .parsely-recommended-widget{display:grid;grid-template-rows:auto;grid-gap:15px;grid-template-columns:repeat(auto-fill,minmax(150px,1fr))}} +.parsely-recommended-widget,.parsely-recommended-widget *{box-sizing:border-box}.parsely-recommended-widget{display:block;width:100%}.parsely-recommended-widget-hidden{display:none}.parsely-recommended-widget-entry a{padding:0}.parsely-recommended-widget-entry img{float:left;margin-right:15px}.parsely-recommended-widget-entry:after{clear:both;content:"";display:table}.parsely-author{display:block;margin-top:5px}.parsely-recommended-widget-title{font-size:1.1em;font-weight:700}.list-horizontal .parsely-recommended-widget-entry{border:none;display:inline-block;margin-bottom:15px;margin-right:15px;max-width:215px;min-width:142.5px;padding:0;vertical-align:text-top;width:45%}.list-horizontal .parsely-recommended-widget-entry img{float:none;margin-right:0;max-width:100%}@supports(display:grid){.parsely-recommended-widget-entry:after{clear:none;display:none}.display-thumbnail .parsely-recommended-widget{grid-gap:15px;display:grid;grid-template-columns:minmax(85px,auto) minmax(50%,auto);grid-template-rows:auto}.list-horizontal .parsely-recommended-widget-entry{border:none;display:block;margin:0;max-width:none;min-width:auto;padding:0;vertical-align:initial;width:auto}.display-thumbnail:not(.list-horizontal) .parsely-recommended-widget-entry{display:contents}.parsely-recommendation-widget:not(.list-horizontal) .parsely-recommended-widget-entry img{float:none;margin-right:0;max-width:100%}.list-horizontal .parsely-recommended-widget{grid-gap:15px;display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));grid-template-rows:auto}} diff --git a/build/telemetry.asset.php b/build/telemetry.asset.php index d56f85e35..2d23ff083 100644 --- a/build/telemetry.asset.php +++ b/build/telemetry.asset.php @@ -1 +1 @@ - array('wp-data', 'wp-element', 'wp-plugins'), 'version' => '86acff61b67acfaabbe2'); + array('wp-data', 'wp-element', 'wp-plugins'), 'version' => '8d53e0f5435bd20c6d07'); diff --git a/build/telemetry.js b/build/telemetry.js index a55a32e0a..bb526c368 100644 --- a/build/telemetry.js +++ b/build/telemetry.js @@ -1 +1 @@ -!function(){var e={873:function(e,t,n){var r=n(325).Symbol;e.exports=r},552:function(e,t,n){var r=n(873),o=n(659),i=n(350),a=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":a&&a in Object(e)?o(e):i(e)}},128:function(e,t,n){var r=n(800),o=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},840:function(e,t,n){var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},659:function(e,t,n){var r=n(873),o=Object.prototype,i=o.hasOwnProperty,a=o.toString,c=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,c),n=e[c];try{e[c]=void 0;var r=!0}catch(e){}var o=a.call(e);return r&&(t?e[c]=n:delete e[c]),o}},350:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},325:function(e,t,n){var r=n(840),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},800:function(e){var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},602:function(e,t,n){var r=n(805),o=n(124),i=n(374),a=Math.max,c=Math.min;e.exports=function(e,t,n){var u,l,s,f,p,d,v=0,y=!1,b=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function w(t){var n=u,r=l;return u=l=void 0,v=t,f=e.apply(r,n)}function m(e){var n=e-d;return void 0===d||n>=t||n<0||b&&e-v>=s}function E(){var e=o();if(m(e))return g(e);p=setTimeout(E,function(e){var n=t-(e-d);return b?c(n,s-(e-v)):n}(e))}function g(e){return p=void 0,h&&u?w(e):(u=l=void 0,f)}function T(){var e=o(),n=m(e);if(u=arguments,l=this,d=e,n){if(void 0===p)return function(e){return v=e,p=setTimeout(E,t),y?w(e):f}(d);if(b)return clearTimeout(p),p=setTimeout(E,t),w(d)}return void 0===p&&(p=setTimeout(E,t)),f}return t=i(t)||0,r(n)&&(y=!!n.leading,s=(b="maxWait"in n)?a(i(n.maxWait)||0,t):s,h="trailing"in n?!!n.trailing:h),T.cancel=function(){void 0!==p&&clearTimeout(p),v=0,u=d=l=p=void 0},T.flush=function(){return void 0===p?f:g(o())},T}},805:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},346:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},394:function(e,t,n){var r=n(552),o=n(346);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},124:function(e,t,n){var r=n(325);e.exports=function(){return r.Date.now()}},374:function(e,t,n){var r=n(128),o=n(805),i=n(394),a=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=c.test(e);return n||u.test(e)?l(e.slice(2),n?2:8):a.test(e)?NaN:+e}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.element,t=window.wp.plugins,r=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,i=function(t,n){var r;return void 0===n&&(n={}),function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]=1e4&&(clearInterval(i),n("Telemetry library not loaded"))}),100);else n("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,n){var r;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(n=this.prepareProperties(n),null===(r=this._tkq)||void 0===r||r.push(["recordEvent",t,n])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,n={};return Object.keys(e).forEach((function(r){t.isProprietyValid(r)&&(n[r]=e[r])})),n},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),o=(r.trackEvent,window.wp.data),i=n(602),a=n.n(i);if(r.getInstance().isTelemetryEnabled()){var c=[function(){var t="wp-parsely/";return(0,e.useEffect)((function(){var e,n,i,c,u;return(n=void 0,i=void 0,c=void 0,u=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]0)&&(t(),e())}))}))]}))},new(c||(c=Promise))((function(e,t){function r(e){try{a(u.next(e))}catch(e){t(e)}}function o(e){try{a(u.throw(e))}catch(e){t(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof c?n:new c((function(e){e(n)}))).then(r,o)}a((u=u.apply(n,i||[])).next())}))).then((function(){var n=(0,o.select)("core/block-editor").getBlocks(),i=a()((function(){var e=(0,o.select)("core/block-editor").getBlocks(),i=e.map((function(e){return e.clientId})),a=n.map((function(e){return e.clientId}));e.filter((function(e){return!a.includes(e.clientId)})).forEach((function(e){e.name.startsWith(t)&&r.trackEvent("block_added",{block:e.name})})),a.filter((function(e){return!i.includes(e)})).forEach((function(e){var o=n.find((function(t){return t.clientId===e}));o&&o.name.startsWith(t)&&r.trackEvent("block_removed",{block:o.name})})),n=e}),1e3);return e=(0,o.subscribe)(i,"core/block-editor")})),function(){e&&e()}}),[]),null}],u=e.createElement.apply(void 0,function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o=t||n<0||b&&e-v>=s}function E(){var e=o();if(m(e))return g(e);p=setTimeout(E,function(e){var n=t-(e-d);return b?c(n,s-(e-v)):n}(e))}function g(e){return p=void 0,h&&u?w(e):(u=l=void 0,f)}function T(){var e=o(),n=m(e);if(u=arguments,l=this,d=e,n){if(void 0===p)return function(e){return v=e,p=setTimeout(E,t),y?w(e):f}(d);if(b)return clearTimeout(p),p=setTimeout(E,t),w(d)}return void 0===p&&(p=setTimeout(E,t)),f}return t=i(t)||0,r(n)&&(y=!!n.leading,s=(b="maxWait"in n)?a(i(n.maxWait)||0,t):s,h="trailing"in n?!!n.trailing:h),T.cancel=function(){void 0!==p&&clearTimeout(p),v=0,u=d=l=p=void 0},T.flush=function(){return void 0===p?f:g(o())},T}},218:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},5:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},448:function(e,t,n){var r=n(239),o=n(5);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},771:function(e,t,n){var r=n(639);e.exports=function(){return r.Date.now()}},841:function(e,t,n){var r=n(561),o=n(218),i=n(448),a=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=c.test(e);return n||u.test(e)?l(e.slice(2),n?2:8):a.test(e)?NaN:+e}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.element,t=window.wp.plugins,r=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,i=function(t,n){var r;return void 0===n&&(n={}),function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]=1e4&&(clearInterval(i),n("Telemetry library not loaded"))}),100);else n("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,n){var r;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(n=this.prepareProperties(n),null===(r=this._tkq)||void 0===r||r.push(["recordEvent",t,n])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,n={};return Object.keys(e).forEach((function(r){t.isProprietyValid(r)&&(n[r]=e[r])})),n},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),o=(r.trackEvent,window.wp.data),i=n(279),a=n.n(i);if(r.getInstance().isTelemetryEnabled()){var c=[function(){var t="wp-parsely/";return(0,e.useEffect)((function(){var e,n,i,c,u;return(n=void 0,i=void 0,c=void 0,u=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]0)&&(t(),e())}))}))]}))},new(c||(c=Promise))((function(e,t){function r(e){try{a(u.next(e))}catch(e){t(e)}}function o(e){try{a(u.throw(e))}catch(e){t(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof c?n:new c((function(e){e(n)}))).then(r,o)}a((u=u.apply(n,i||[])).next())}))).then((function(){var n=(0,o.select)("core/block-editor").getBlocks(),i=a()((function(){var e=(0,o.select)("core/block-editor").getBlocks(),i=e.map((function(e){return e.clientId})),a=n.map((function(e){return e.clientId}));e.filter((function(e){return!a.includes(e.clientId)})).forEach((function(e){e.name.startsWith(t)&&r.trackEvent("block_added",{block:e.name})})),a.filter((function(e){return!i.includes(e)})).forEach((function(e){var o=n.find((function(t){return t.clientId===e}));o&&o.name.startsWith(t)&&r.trackEvent("block_removed",{block:o.name})})),n=e}),1e3);return e=(0,o.subscribe)(i,"core/block-editor")})),function(){e&&e()}}),[]),null}],u=e.createElement.apply(void 0,function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o Date: Mon, 13 May 2024 10:47:38 +0100 Subject: [PATCH 14/44] Rebuild assets --- build/blocks/recommendations/edit.asset.php | 2 +- build/blocks/recommendations/edit.js | 2 +- build/blocks/recommendations/view.asset.php | 2 +- build/blocks/recommendations/view.js | 2 +- .../content-helper/dashboard-widget.asset.php | 2 +- build/content-helper/dashboard-widget.js | 2 +- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.css | 4 +-- build/content-helper/editor-sidebar.js | 31 +++++++++-------- .../excerpt-generator.asset.php | 2 +- build/content-helper/excerpt-generator.js | 3 +- build/recommended-widget.asset.php | 2 +- build/recommended-widget.css | 2 +- build/telemetry.asset.php | 2 +- build/telemetry.js | 2 +- .../smart-linking/component.tsx | 34 ++++++++++--------- 16 files changed, 50 insertions(+), 46 deletions(-) diff --git a/build/blocks/recommendations/edit.asset.php b/build/blocks/recommendations/edit.asset.php index d07e3e227..3320beb03 100644 --- a/build/blocks/recommendations/edit.asset.php +++ b/build/blocks/recommendations/edit.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'ada8db34ea07d80ab473'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '8daeb223e80bc2f56720'); diff --git a/build/blocks/recommendations/edit.js b/build/blocks/recommendations/edit.js index ac88aae08..5cf434a2c 100644 --- a/build/blocks/recommendations/edit.js +++ b/build/blocks/recommendations/edit.js @@ -1 +1 @@ -!function(){"use strict";var e,n={204:function(e,n,r){var t,o,a=r(893),i=window.wp.blockEditor,l=window.wp.blocks,s=window.wp.i18n,c=window.wp.components,u=JSON.parse('{"u2":"wp-parsely/recommendations","Y4":{"imagestyle":{"type":"string","default":"original"},"limit":{"type":"number","default":3},"openlinksinnewtab":{"type":"boolean","default":false},"showimages":{"type":"boolean","default":true},"sort":{"type":"string","default":"score"},"title":{"type":"string","default":"Related Content"}}}'),d=window.wp.element;(o=t||(t={}))[o.Error=0]="Error",o[o.Loaded=1]="Loaded",o[o.Recommendations=2]="Recommendations";var p=function(){return p=Object.assign||function(e){for(var n,r=1,t=arguments.length;r0&&o[o.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]=a)&&Object.keys(t.O).every((function(e){return t.O[e](r[s])}))?r.splice(s--,1):(l=!1,a0&&e[u-1][2]>a;u--)e[u]=e[u-1];e[u]=[r,o,a]},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},t.d=function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},function(){var e={878:0,570:0};t.O.j=function(n){return 0===e[n]};var n=function(n,r){var o,a,i=r[0],l=r[1],s=r[2],c=0;if(i.some((function(n){return 0!==e[n]}))){for(o in l)t.o(l,o)&&(t.m[o]=l[o]);if(s)var u=s(t)}for(n&&n(r);c0&&o[o.length-1])||6!==l[0]&&2!==l[0])){i=0;continue}if(3===l[0]&&(!o||l[1]>o[0]&&l[1]=a)&&Object.keys(t.O).every((function(e){return t.O[e](r[s])}))?r.splice(s--,1):(l=!1,a0&&e[u-1][2]>a;u--)e[u]=e[u-1];e[u]=[r,o,a]},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,{a:n}),n},t.d=function(e,n){for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},function(){var e={335:0,203:0};t.O.j=function(n){return 0===e[n]};var n=function(n,r){var o,a,i=r[0],l=r[1],s=r[2],c=0;if(i.some((function(n){return 0!==e[n]}))){for(o in l)t.o(l,o)&&(t.m[o]=l[o]);if(s)var u=s(t)}for(n&&n(r);c array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '767eb8d9a92dda7c7224'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-compose', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '827c1c0c5b711b046baf'); diff --git a/build/blocks/recommendations/view.js b/build/blocks/recommendations/view.js index 9ccc6203e..ac32818be 100644 --- a/build/blocks/recommendations/view.js +++ b/build/blocks/recommendations/view.js @@ -1 +1 @@ -!function(){"use strict";var e={251:function(e,r,n){var t=n(196),o=Symbol.for("react.element"),a=Symbol.for("react.fragment"),i=Object.prototype.hasOwnProperty,s=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function u(e,r,n){var t,a={},u=null,c=null;for(t in void 0!==n&&(u=""+n),void 0!==r.key&&(u=""+r.key),void 0!==r.ref&&(c=r.ref),r)i.call(r,t)&&!l.hasOwnProperty(t)&&(a[t]=r[t]);if(e&&e.defaultProps)for(t in r=e.defaultProps)void 0===a[t]&&(a[t]=r[t]);return{$$typeof:o,type:e,key:u,ref:c,props:a,_owner:s.current}}r.Fragment=a,r.jsx=u,r.jsxs=u},893:function(e,r,n){e.exports=n(251)},196:function(e){e.exports=window.React}},r={};function n(t){var o=r[t];if(void 0!==o)return o.exports;var a=r[t]={exports:{}};return e[t](a,a.exports,n),a.exports}n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,{a:r}),r},n.d=function(e,r){for(var t in r)n.o(r,t)&&!n.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},function(){var e,r,t=n(893),o=n(196),a=window.wp.domReady,i=n.n(a),s=window.wp.element,l=window.wp.i18n;(r=e||(e={}))[r.Error=0]="Error",r[r.Loaded=1]="Loaded",r[r.Recommendations=2]="Recommendations";var u=function(){return u=Object.assign||function(e){for(var r,n=1,t=arguments.length;n0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]0&&o[o.length-1])||6!==s[0]&&2!==s[0])){i=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1] array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '11c08dcb53396fc2cbca'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => 'd7b943fdef5d5ebb0903'); diff --git a/build/content-helper/dashboard-widget.js b/build/content-helper/dashboard-widget.js index e158345ad..92c40bb4d 100644 --- a/build/content-helper/dashboard-widget.js +++ b/build/content-helper/dashboard-widget.js @@ -1 +1 @@ -!function(){"use strict";var e={251:function(e,t,r){var n=r(196),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,u=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:u,props:s,_owner:i.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},893:function(e,t,r){e.exports=r(251)},196:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n,a=r(893),s=window.wp.element,o=window.wp.i18n,i=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,a.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},l=function(e){var t;return void 0===e&&(e=null),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:null!==(t=window.wpParselyEmptyCredentialsMessage)&&void 0!==t?t:(0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely")})},c=function(){return c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),h=(d.trackEvent,function(e){var t=e.defaultValue,r=e.items,n=e.onChange;return(0,a.jsx)("select",{onChange:n,value:t,children:r.map((function(e){return(0,a.jsx)("option",{value:e[0],children:e[1]},e[0])}))})}),f=window.wp.data,y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;rhere.',"wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiError||s.code===N.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,o.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===N.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,o.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiSchemaError?s.message=(0,o.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===N.ParselySuggestionsApiNoData?s.message=(0,o.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiSchema?s.message=(0,o.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,o.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return C(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[N.PluginCredentialsNotSetMessageDetected,N.PluginSettingsSiteIdNotSet,N.PluginSettingsApiSecretNotSet].includes(this.code)?l(e):(this.code===N.FetchError&&(this.hint=this.Hint((0,o.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==N.ParselyApiForbidden&&this.code!==N.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===N.HttpRequestFailed&&(this.hint=this.Hint((0,o.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error),I=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,r=Array.from(this.abortControllers.keys()).pop();r&&(t=this.abortControllers.get(r))&&(t.abort(),this.abortControllers.delete(r))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),r=new AbortController;return this.abortControllers.set(t,r),{abortController:r,abortId:t}},e.prototype.fetch=function(e,t){return r=this,n=void 0,s=function(){var r,n,a,s,i;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=c){var u=t;(a=n/c)%1>1/i&&(u=a>10?1:2),u=parseFloat(a.toFixed(2))===parseFloat(a.toFixed(0))?0:u,s=a.toFixed(u),o=l}i=c})),s+r+o}function z(e){var t=e.metric,r=e.post,n=e.avgEngagedIcon,s=e.viewsIcon;return"views"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Number of Views","wp-parsely")}),s,$(r.views.toString())]}):"avg_engaged"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Average Time","wp-parsely")}),n,r.avgEngaged]}):(0,a.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}function X(e){var t,r=e.metric,n=e.post;return(0,a.jsx)("li",{className:"parsely-top-post",children:(0,a.jsxs)("div",{className:"parsely-top-post-content",children:[(0,a.jsx)(B,{post:n}),(0,a.jsxs)("div",{className:"parsely-top-post-data",children:[(0,a.jsx)(z,{metric:r,post:n}),(0,a.jsx)(Z,{post:n}),(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:n.url,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(q,{})]}),0!==n.postId&&(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:(t=n.postId,"/wp-admin/post.php?post=".concat(t,"&action=edit")),target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Edit Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(G,{})]}),(0,a.jsxs)("div",{className:"parsely-top-post-metadata",children:[(0,a.jsxs)("span",{className:"parsely-top-post-date",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Date","wp-parsely")}),M(new Date(n.date))]}),(0,a.jsxs)("span",{className:"parsely-top-post-author",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Author","wp-parsely")}),n.author]})]})]})]})},n.id)}function B(e){var t=e.post;return t.thumbnailUrl?(0,a.jsxs)("div",{className:"parsely-top-post-thumbnail",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Thumbnail","wp-parsely")}),(0,a.jsx)("img",{src:t.thumbnailUrl,alt:(0,o.__)("Post thumbnail","wp-parsely")})]}):(0,a.jsx)("div",{className:"parsely-top-post-thumbnail",children:(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Post thumbnail not available","wp-parsely")})})}function Z(e){var t=e.post;return(0,a.jsxs)("a",{className:"parsely-top-post-title",href:t.dashUrl,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View in Parse.ly (opens in new tab)","wp-parsely")}),t.title]})}var Y=function(){return Y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&e.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return r.sent(),[4,t(n-1)];case 2:return r.sent(),[3,4];case 3:f(!1),v(e),r.label=4;case 4:return[2]}}))}))})),[2]}))}))};return f(!0),t(1),function(){f(!1),m([]),v(void 0)}}),[i,S]);var N=function(e,t){d.trackEvent("dash_widget_filter_changed",Y({filter:e},t))},T=(0,a.jsxs)("div",{className:"parsely-top-posts-filters",children:[(0,a.jsx)(h,{defaultValue:i.Period,items:Object.values(e).map((function(e){return[e,A(e)]})),onChange:function(t){x(t.target.value,e)&&(l({Period:t.target.value}),N("period",{period:t.target.value}),j(1))}}),(0,a.jsx)(h,{defaultValue:i.Metric,items:Object.values(t).map((function(e){return[e,E(e)]})),onChange:function(e){x(e.target.value,t)&&(l({Metric:e.target.value}),N("metric",{metric:e.target.value}),j(1))}})]}),C=(0,a.jsxs)("div",{className:"parsely-top-posts-navigation",children:[(0,a.jsx)("button",{className:"parsely-top-posts-navigation-prev",disabled:S<=1,"aria-label":(0,o.__)("Previous page","wp-parsely"),onClick:function(){j(S-1),d.trackEvent("dash_widget_navigation",{navigation:"previous",to_page:S-1})},children:(0,o.__)("<< Previous","wp-parsely")}),(0,o.sprintf)(/* translators: 1: Current page */(0,o.__)("Page %1$d","wp-parsely"),S),(0,a.jsx)("button",{className:"parsely-top-posts-navigation-next",disabled:!u&&_.length<5,"aria-label":(0,o.__)("Next page","wp-parsely"),onClick:function(){j(S+1),d.trackEvent("dash_widget_navigation",{navigation:"next",to_page:S+1})},children:(0,o.__)("Next >>","wp-parsely")})]});if(g)return(0,a.jsxs)(a.Fragment,{children:[T,g.Message(),S>1&&C]});var O=(0,a.jsx)("div",{className:"parsely-spinner-wrapper",children:(0,a.jsx)(p.Spinner,{})});return(0,a.jsxs)(a.Fragment,{children:[T,u?O:(0,a.jsx)("ol",{className:"parsely-top-posts",style:{counterReset:"item "+5*(S-1)},children:_.map((function(e){return(0,a.jsx)(X,{metric:i.Metric,post:e},e.id)}))}),(_.length>=5||S>1)&&C]})}var J=function(r){var n;try{n=JSON.parse(r)}catch(r){return{Metric:t.Views,Period:e.Days7}}return x(null==n?void 0:n.Metric,t)||(n.Metric=t.Views),x(null==n?void 0:n.Period,e)||(n.Period=e.Days7),n};window.addEventListener("load",(function(){var e=document.querySelector("#wp-parsely-dashboard-widget > .inside");if(null!==e){var t=(0,a.jsx)(S,{endpoint:"dashboard-widget-settings",defaultSettings:J(window.wpParselyContentHelperSettings),children:(0,a.jsx)(u,{children:(0,a.jsx)(Q,{})})});s.createRoot?(0,s.createRoot)(e).render(t):(0,s.render)(t,e)}}),!1)}()}(); \ No newline at end of file +!function(){"use strict";var e={20:function(e,t,r){var n=r(609),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,u=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(u=t.ref),t)o.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:u,props:s,_owner:i.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},848:function(e,t,r){e.exports=r(20)},609:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n,a=r(848),s=window.wp.element,o=window.wp.i18n,i=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,a.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},l=function(e){var t;return void 0===e&&(e=null),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:null!==(t=window.wpParselyEmptyCredentialsMessage)&&void 0!==t?t:(0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely")})},c=function(){return c=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),h=(d.trackEvent,function(e){var t=e.defaultValue,r=e.items,n=e.onChange;return(0,a.jsx)("select",{onChange:n,value:t,children:r.map((function(e){return(0,a.jsx)("option",{value:e[0],children:e[1]},e[0])}))})}),f=window.wp.data,y=function(){return y=Object.assign||function(e){for(var t,r=1,n=arguments.length;rhere.',"wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiError||s.code===N.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,o.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===N.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,o.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiSchemaError?s.message=(0,o.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===N.ParselySuggestionsApiNoData?s.message=(0,o.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiSchema?s.message=(0,o.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,o.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return C(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[N.PluginCredentialsNotSetMessageDetected,N.PluginSettingsSiteIdNotSet,N.PluginSettingsApiSecretNotSet].includes(this.code)?l(e):(this.code===N.FetchError&&(this.hint=this.Hint((0,o.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==N.ParselyApiForbidden&&this.code!==N.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,o.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===N.HttpRequestFailed&&(this.hint=this.Hint((0,o.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,a.jsx)(i,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error),I=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,r=Array.from(this.abortControllers.keys()).pop();r&&(t=this.abortControllers.get(r))&&(t.abort(),this.abortControllers.delete(r))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),r=new AbortController;return this.abortControllers.set(t,r),{abortController:r,abortId:t}},e.prototype.fetch=function(e,t){return r=this,n=void 0,s=function(){var r,n,a,s,i;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=c){var u=t;(a=n/c)%1>1/i&&(u=a>10?1:2),u=parseFloat(a.toFixed(2))===parseFloat(a.toFixed(0))?0:u,s=a.toFixed(u),o=l}i=c})),s+r+o}function z(e){var t=e.metric,r=e.post,n=e.avgEngagedIcon,s=e.viewsIcon;return"views"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Number of Views","wp-parsely")}),s,$(r.views.toString())]}):"avg_engaged"===t?(0,a.jsxs)("span",{className:"parsely-post-metric-data",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Average Time","wp-parsely")}),n,r.avgEngaged]}):(0,a.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}function X(e){var t,r=e.metric,n=e.post;return(0,a.jsx)("li",{className:"parsely-top-post",children:(0,a.jsxs)("div",{className:"parsely-top-post-content",children:[(0,a.jsx)(B,{post:n}),(0,a.jsxs)("div",{className:"parsely-top-post-data",children:[(0,a.jsx)(z,{metric:r,post:n}),(0,a.jsx)(Z,{post:n}),(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:n.url,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(q,{})]}),0!==n.postId&&(0,a.jsxs)("a",{className:"parsely-top-post-icon-link",href:(t=n.postId,"/wp-admin/post.php?post=".concat(t,"&action=edit")),target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Edit Post (opens in new tab)","wp-parsely")}),(0,a.jsx)(G,{})]}),(0,a.jsxs)("div",{className:"parsely-top-post-metadata",children:[(0,a.jsxs)("span",{className:"parsely-top-post-date",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Date","wp-parsely")}),M(new Date(n.date))]}),(0,a.jsxs)("span",{className:"parsely-top-post-author",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Author","wp-parsely")}),n.author]})]})]})]})},n.id)}function B(e){var t=e.post;return t.thumbnailUrl?(0,a.jsxs)("div",{className:"parsely-top-post-thumbnail",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Thumbnail","wp-parsely")}),(0,a.jsx)("img",{src:t.thumbnailUrl,alt:(0,o.__)("Post thumbnail","wp-parsely")})]}):(0,a.jsx)("div",{className:"parsely-top-post-thumbnail",children:(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("Post thumbnail not available","wp-parsely")})})}function Z(e){var t=e.post;return(0,a.jsxs)("a",{className:"parsely-top-post-title",href:t.dashUrl,target:"_blank",rel:"noreferrer",children:[(0,a.jsx)("span",{className:"screen-reader-text",children:(0,o.__)("View in Parse.ly (opens in new tab)","wp-parsely")}),t.title]})}var Y=function(){return Y=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&e.retryFetch?[4,new Promise((function(e){return setTimeout(e,500)}))]:[3,3];case 1:return r.sent(),[4,t(n-1)];case 2:return r.sent(),[3,4];case 3:f(!1),v(e),r.label=4;case 4:return[2]}}))}))})),[2]}))}))};return f(!0),t(1),function(){f(!1),m([]),v(void 0)}}),[i,S]);var N=function(e,t){d.trackEvent("dash_widget_filter_changed",Y({filter:e},t))},T=(0,a.jsxs)("div",{className:"parsely-top-posts-filters",children:[(0,a.jsx)(h,{defaultValue:i.Period,items:Object.values(e).map((function(e){return[e,A(e)]})),onChange:function(t){x(t.target.value,e)&&(l({Period:t.target.value}),N("period",{period:t.target.value}),j(1))}}),(0,a.jsx)(h,{defaultValue:i.Metric,items:Object.values(t).map((function(e){return[e,E(e)]})),onChange:function(e){x(e.target.value,t)&&(l({Metric:e.target.value}),N("metric",{metric:e.target.value}),j(1))}})]}),C=(0,a.jsxs)("div",{className:"parsely-top-posts-navigation",children:[(0,a.jsx)("button",{className:"parsely-top-posts-navigation-prev",disabled:S<=1,"aria-label":(0,o.__)("Previous page","wp-parsely"),onClick:function(){j(S-1),d.trackEvent("dash_widget_navigation",{navigation:"previous",to_page:S-1})},children:(0,o.__)("<< Previous","wp-parsely")}),(0,o.sprintf)(/* translators: 1: Current page */ /* translators: 1: Current page */(0,o.__)("Page %1$d","wp-parsely"),S),(0,a.jsx)("button",{className:"parsely-top-posts-navigation-next",disabled:!u&&_.length<5,"aria-label":(0,o.__)("Next page","wp-parsely"),onClick:function(){j(S+1),d.trackEvent("dash_widget_navigation",{navigation:"next",to_page:S+1})},children:(0,o.__)("Next >>","wp-parsely")})]});if(g)return(0,a.jsxs)(a.Fragment,{children:[T,g.Message(),S>1&&C]});var O=(0,a.jsx)("div",{className:"parsely-spinner-wrapper",children:(0,a.jsx)(p.Spinner,{})});return(0,a.jsxs)(a.Fragment,{children:[T,u?O:(0,a.jsx)("ol",{className:"parsely-top-posts",style:{counterReset:"item "+5*(S-1)},children:_.map((function(e){return(0,a.jsx)(X,{metric:i.Metric,post:e},e.id)}))}),(_.length>=5||S>1)&&C]})}var J=function(r){var n;try{n=JSON.parse(r)}catch(r){return{Metric:t.Views,Period:e.Days7}}return x(null==n?void 0:n.Metric,t)||(n.Metric=t.Views),x(null==n?void 0:n.Period,e)||(n.Period=e.Days7),n};window.addEventListener("load",(function(){var e=document.querySelector("#wp-parsely-dashboard-widget > .inside");if(null!==e){var t=(0,a.jsx)(S,{endpoint:"dashboard-widget-settings",defaultSettings:J(window.wpParselyContentHelperSettings),children:(0,a.jsx)(u,{children:(0,a.jsx)(Q,{})})});s.createRoot?(0,s.createRoot)(e).render(t):(0,s.render)(t,e)}}),!1)}()}(); \ No newline at end of file diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index f819fa872..96effdff0 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-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'a87c7cfa869320fd4b29'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'b9972e12749bccd00878'); diff --git a/build/content-helper/editor-sidebar.css b/build/content-helper/editor-sidebar.css index e0da9c26d..cbe748d27 100644 --- a/build/content-helper/editor-sidebar.css +++ b/build/content-helper/editor-sidebar.css @@ -1,5 +1,5 @@ #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 var(--grid-unit-15) 0 0;order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate,.wp-parsely-smart-linking .smart-linking-manage{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button,.wp-parsely-smart-linking .smart-linking-manage button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)}.wp-parsely-smart-linking-review-modal{align-items:flex-start;display:flex;flex-direction:column;width:47.875rem}.wp-parsely-smart-linking-review-modal .smart-linking-modal-body{align-self:stretch;display:flex;flex-direction:row;gap:var(--grid-unit-30)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);max-height:25rem;min-width:13.75rem;overflow-y:auto;padding:3px}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header{align-items:center;align-self:stretch;color:var(--sidebar-black);display:flex;font-size:11px;font-style:normal;font-weight:600;gap:6px;line-height:var(--grid-unit-20);margin-bottom:var(--grid-unit-15);text-transform:uppercase}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header>span{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button{width:13.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected{border:1px solid var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__item{display:inline;overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__shortcut{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));padding-left:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion{align-items:flex-start;align-self:stretch;display:flex;flex:1;flex-direction:column;gap:16px;max-width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs{font-size:.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-separator{margin:0 var(--grid-unit-5)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-block{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block{color:var(--sidebar-black)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block .breadcrumbs-current-block-name{margin-left:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .components-divider{border-color:#ccc;height:1px;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .wp-parsely-link-suggestion-link-details{height:auto;margin-bottom:var(--grid-unit-20);text-align:left}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .wp-parsely-link-suggestion-link-details .components-menu-item__item{word-wrap:break-word;white-space:normal}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls{align-items:center;align-self:stretch;display:flex;flex-shrink:0;justify-content:space-between;margin:0 var(--grid-unit-20);-webkit-user-select:none;-moz-user-select:none;user-select:none;width:452px}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .reviews-controls-middle{align-items:center;display:flex;flex:1 0 0;gap:var(--grid-unit-20,16px);justify-content:center}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-next,.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-previous{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-reject{background:var(--Gutenberg-White,#fff);border-radius:2px;box-shadow:inset 0 0 0 1px var(--Gutenberg-Alert-Red,#cc1818);color:var(--Gutenberg-Alert-Red,#cc1818)}.wp-parsely-smart-linking-close-dialog{align-items:flex-start;display:flex;flex-direction:column;width:24rem}.wp-parsely-smart-linking-close-dialog .smart-linking-close-dialog-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;padding-top:var(--grid-unit-30)}.wp-parsely-preview-editor.editor-styles-wrapper{font-size:var(--font-size--medium);padding-bottom:0}.wp-parsely-preview-editor p[role=document]{margin:0}.wp-parsely-preview-editor .smart-linking-highlight{background:hsla(var(--parsely-green-components),.5);border-radius:2px;mix-blend-mode:multiply;text-decoration-line:underline} -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-performance-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}.wp-parsely-content-helper .wp-parsely-performance-panel .content-helper-error-message{margin:0!important}.wp-parsely-content-helper .wp-parsely-performance-panel .components-button.wp-parsely-view-post{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .panel-body{width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.5rem;padding:.375rem 0 1rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header{align-items:center;display:flex;gap:.375rem;height:1rem;margin-bottom:0;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2{margin-bottom:.9375rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2 h2{margin-bottom:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-3 h3{font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:1rem;margin-bottom:0;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-subtitle{align-items:center;align-self:stretch;color:var(--Gutenberg-Gray-700,#757575);display:flex;flex:1 0 0;font-size:var(--font-size--smaller);font-style:normal;font-weight:600;gap:.375rem;height:1rem;line-height:1rem;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .components-heading{display:block;font-weight:500;line-height:normal;margin:0}.wp-parsely-content-helper .wp-parsely-performance-panel .components-dropdown-menu{line-height:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points{align-content:flex-start;align-items:flex-start;align-self:stretch;display:flex;flex-wrap:wrap;gap:1rem var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point{align-items:center;background:var(--sidebar-white);border-radius:.25rem;display:flex;flex:1 0 0;flex-direction:column;gap:var(--grid-unit-5);justify-content:center;min-width:100px;padding:var(--grid-unit-20) var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point svg{align-items:flex-start;border-radius:.125rem;display:flex}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-title{align-self:stretch;color:var(--sidebar-black);font-size:.75rem;font-style:normal;font-weight:400;line-height:1rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value{align-self:stretch;color:var(--sidebar-black);font-size:1.25rem;font-style:normal;font-weight:590;line-height:1.75rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value.is-small{font-size:var(--font-size--medium)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar{align-items:flex-start;align-self:stretch;display:flex;height:1rem;margin:1rem 0;position:relative}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill{--radius:2px;align-self:stretch;position:relative;transition:filter .1s ease,transform .1s ease}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:hover{filter:opacity(1)!important;transform:scaleX(1) scaleY(1)!important}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:first-child{border-radius:var(--radius) 0 0 var(--radius)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:last-child{border-radius:0 var(--radius) var(--radius) 0}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar:hover .bar-fill{filter:opacity(.5);transform:scaleX(1) scaleY(.7)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label{align-items:center;align-self:stretch;display:flex;gap:.5rem;justify-content:center}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color{align-items:center;border-radius:.09375rem;display:flex;flex-direction:column;gap:.625rem;height:.625rem;justify-content:center;width:.1875rem}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-text{-webkit-box-orient:vertical;-webkit-line-clamp:1;font-feature-settings:"ss06" on;color:var(--sidebar-black);display:-webkit-box;flex:1 0 0;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-value{color:var(--sidebar-black);font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;text-align:right}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:1rem 0}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-10);justify-content:space-between}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-title{-webkit-box-orient:vertical;-webkit-line-clamp:1;font-feature-settings:"ss06" on;color:var(--sidebar-black);display:-webkit-box;flex:1;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar{display:flex;flex:1;flex-direction:column;gap:.625rem;justify-content:center;max-width:6.25rem}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar{--radius:1.5px;background:var(--gray-400);border-radius:var(--radius);display:flex;height:.1875rem;margin:0;overflow:hidden}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar:after{background:var(--blueberry,#3858e9);border-radius:var(--radius);content:"";height:100%;width:var(--bar-fill)}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-value{color:var(--sidebar-black);flex-shrink:0;font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;min-width:3.125rem;text-align:right} -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-related-posts{align-items:flex-start;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-description{font-size:.8125rem;font-style:normal;font-weight:400;gap:.625rem;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body,.wp-parsely-related-posts .related-posts-description{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body{gap:1rem}.wp-parsely-related-posts .related-posts-body>div{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings{align-self:stretch;display:flex;flex-direction:column;gap:1rem;width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings{display:flex;flex-direction:column;gap:var(--grid-unit-20);width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control{height:2.5rem;overflow:hidden}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex{height:2.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex input{margin:0 var(--grid-unit-15)}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-descr{font-size:.8125rem;font-style:normal;font-weight:400;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-empty,.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-loading-message{color:var(--gray-900);font-size:.75rem;font-style:normal;font-weight:700;line-height:var(--grid-unit-20);overflow:hidden;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-title{align-items:center;align-self:stretch;display:flex;flex-direction:column;font-size:.875rem;font-style:normal;font-weight:600;gap:.5rem;justify-content:center;line-height:1.25rem;overflow:hidden;padding:var(--grid-unit-20);text-decoration-line:underline;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions{align-items:center;align-self:stretch;border-top:1px solid var(--gray-400);display:flex;flex-wrap:wrap;padding:0 var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:first-child,.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:last-child{display:flex;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric{align-items:center;display:flex}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric .parsely-post-metric-data{align-items:center;display:flex;gap:var(--grid-unit-5)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-linked{fill:#008a20;align-items:center;display:flex;margin-left:auto}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon path{fill:#1e1e1e}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon:hover path{fill:#0073aa} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-performance-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}.wp-parsely-content-helper .wp-parsely-performance-panel .content-helper-error-message{margin:0!important}.wp-parsely-content-helper .wp-parsely-performance-panel .components-button.wp-parsely-view-post{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .panel-body{width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.5rem;padding:.375rem 0 1rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header{align-items:center;display:flex;gap:.375rem;height:1rem;margin-bottom:0;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2{margin-bottom:.9375rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2 h2{margin-bottom:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-3 h3{font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:1rem;margin-bottom:0;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-subtitle{align-items:center;align-self:stretch;color:var(--Gutenberg-Gray-700,#757575);display:flex;flex:1 0 0;font-size:var(--font-size--smaller);font-style:normal;font-weight:600;gap:.375rem;height:1rem;line-height:1rem;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .components-heading{display:block;font-weight:500;line-height:normal;margin:0}.wp-parsely-content-helper .wp-parsely-performance-panel .components-dropdown-menu{line-height:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points{align-content:flex-start;align-items:flex-start;align-self:stretch;display:flex;flex-wrap:wrap;gap:1rem var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point{align-items:center;background:var(--sidebar-white);border-radius:.25rem;display:flex;flex:1 0 0;flex-direction:column;gap:var(--grid-unit-5);justify-content:center;min-width:100px;padding:var(--grid-unit-20) var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point svg{align-items:flex-start;border-radius:.125rem;display:flex}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-title{align-self:stretch;color:var(--sidebar-black);font-size:.75rem;font-style:normal;font-weight:400;line-height:1rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value{align-self:stretch;color:var(--sidebar-black);font-size:1.25rem;font-style:normal;font-weight:590;line-height:1.75rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value.is-small{font-size:var(--font-size--medium)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar{align-items:flex-start;align-self:stretch;display:flex;height:1rem;margin:1rem 0;position:relative}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill{--radius:2px;align-self:stretch;position:relative;transition:filter .1s ease,transform .1s ease}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:hover{filter:opacity(1)!important;transform:scaleX(1) scaleY(1)!important}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:first-child{border-radius:var(--radius) 0 0 var(--radius)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:last-child{border-radius:0 var(--radius) var(--radius) 0}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar:hover .bar-fill{filter:opacity(.5);transform:scaleX(1) scaleY(.7)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label{align-items:center;align-self:stretch;display:flex;gap:.5rem;justify-content:center}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color{align-items:center;border-radius:.09375rem;display:flex;flex-direction:column;gap:.625rem;height:.625rem;justify-content:center;width:.1875rem}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1 0 0;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-value{color:var(--sidebar-black);font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;text-align:right}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:1rem 0}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-10);justify-content:space-between}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar{display:flex;flex:1;flex-direction:column;gap:.625rem;justify-content:center;max-width:6.25rem}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar{--radius:1.5px;background:var(--gray-400);border-radius:var(--radius);display:flex;height:.1875rem;margin:0;overflow:hidden}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar:after{background:var(--blueberry,#3858e9);border-radius:var(--radius);content:"";height:100%;width:var(--bar-fill)}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-value{color:var(--sidebar-black);flex-shrink:0;font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;min-width:3.125rem;text-align:right} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-related-posts{align-items:flex-start;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-description{font-size:.8125rem;font-style:normal;font-weight:400;gap:.625rem;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body,.wp-parsely-related-posts .related-posts-description{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body{gap:1rem}.wp-parsely-related-posts .related-posts-body>div{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings{align-self:stretch;display:flex;flex-direction:column;gap:1rem;width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings{display:flex;flex-direction:column;gap:var(--grid-unit-20);width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control{height:2.5rem;overflow:hidden}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex{height:2.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex input{margin:0 var(--grid-unit-15)}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-descr{font-size:.8125rem;font-style:normal;font-weight:400;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-empty,.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-loading-message{color:var(--gray-900);font-size:.75rem;font-style:normal;font-weight:700;line-height:var(--grid-unit-20);overflow:hidden;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-title{align-items:center;align-self:stretch;display:flex;flex-direction:column;font-size:.875rem;font-style:normal;font-weight:600;gap:.5rem;justify-content:center;line-height:1.25rem;overflow:hidden;padding:var(--grid-unit-20);text-decoration-line:underline;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions{align-items:center;align-self:stretch;border-top:1px solid var(--gray-400);display:flex;flex-wrap:wrap;padding:0 var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:first-child,.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:last-child{display:flex;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric{align-items:center;display:flex}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric .parsely-post-metric-data{align-items:center;display:flex;gap:var(--grid-unit-5)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-linked{align-items:center;display:flex;margin-left:auto;fill:#008a20}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon path{fill:#1e1e1e}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon:hover path{fill:#0073aa} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper{display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings>div{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding-bottom:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header .parsely-write-titles-text strong{text-transform:lowercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding-top:.375rem}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate .components-button{align-items:center;align-self:stretch;border-radius:2px;display:flex;height:2.5rem;justify-content:center;padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-dropdown-label{align-self:stretch;color:var(--sidebar-black);font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:var(--grid-unit-20);text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title{font-size:1rem;font-weight:600;line-height:1.25rem;margin:0 0 .9375rem;text-align:center}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title-actions{display:flex;gap:.625rem;justify-content:center;margin:.625rem 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion.pinned-title{background:var(--Gutenberg-Gray-100,#f0f0f0)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title{align-items:center;align-self:stretch;color:#1e1e1e;display:flex;flex-direction:column;font-size:.75rem;font-style:normal;font-weight:600;gap:var(--grid-unit-10);justify-content:center;line-height:1.25rem;padding:var(--grid-unit-15) var(--grid-unit-15) 0 var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title .suggested-title-original{align-self:flex-start;margin:0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions{align-items:center;align-self:stretch;border-top:1px solid var(--Gutenberg-Gray-400,#ccc);display:flex;flex-wrap:wrap;height:2.5rem;padding:0 var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-left,.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-right{display:flex;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin-bottom:var(--grid-unit-20);position:relative}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay{align-items:center;background-color:hsla(0,0%,100%,.9);bottom:0;display:flex;flex-direction:column;gap:var(--grid-unit-10);justify-content:center;left:0;position:absolute;right:0;top:0;z-index:1}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay .components-spinner{transform:scale(1.125)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-pinned-suggestions{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-content-helper-error.components-notice{margin-bottom:var(--grid-unit-10)}.wp-parsely-popover .components-popover__content{width:15.5rem}.wp-parsely-suggested-title-modal{align-items:flex-start;display:flex;flex-direction:column;width:20rem}.wp-parsely-suggested-title-modal h2{color:var(--sidebar-black);font-size:1rem;font-style:normal;font-weight:600;line-height:1.5rem}.wp-parsely-suggested-title-modal .suggested-title-modal-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;margin-top:1.5rem} .parsely-tone-selector-dropdown{align-items:center;align-self:stretch;background:var(--Gutenberg-White,#fff);border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;height:2.25rem;overflow-wrap:break-word;width:100%;word-break:break-word}.parsely-tone-selector-dropdown button{height:2.0625rem}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle.has-icon svg:first-child{display:none}.parsely-tone-selector-dropdown.is-disabled{opacity:.5;pointer-events:none}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle{display:flex;gap:.625rem;width:100%}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle svg:first-of-type path{transform:scale(1.4);transform-origin:center}.parsely-tone-selector-dropdown .parsely-tone-selector-label{flex-grow:2;padding:0 var(--grid-unit-10);text-align:left}.parsely-tone-selector-dropdown .parsely-tone-selector-label:first-letter{text-transform:uppercase}.parsely-persona-selector-custom{width:100%}.parsely-persona-selector-custom .components-base-control__field input{display:flex;height:2.5rem;padding:var(--grid-unit-15) var(--grid-unit-20)}.parsely-persona-selector-custom .components-base-control__field input,.parsely-persona-selector-dropdown{align-items:center;align-self:stretch;border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px}.parsely-persona-selector-dropdown{background:var(--Gutenberg-White,#fff);height:2.25rem;overflow-wrap:break-word;width:100%;word-break:break-word}.parsely-persona-selector-dropdown .components-dropdown-menu__toggle.has-icon svg:first-child{display:none}.parsely-persona-selector-dropdown button{height:2.0625rem}.parsely-persona-selector-dropdown.is-disabled{opacity:.5;pointer-events:none}.parsely-persona-selector-dropdown .components-dropdown-menu__toggle{display:flex;gap:.625rem;width:100%}.parsely-persona-selector-dropdown .parsely-persona-selector-label{flex-grow:2;padding:0 var(--grid-unit-10);text-align:left}.parsely-persona-selector-dropdown .parsely-persona-selector-label:first-letter{text-transform:uppercase}.parsely-tone-selector-custom{width:100%}.parsely-tone-selector-custom .components-base-control__field input{align-items:center;align-self:stretch;border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;display:flex;height:2.5rem;padding:var(--grid-unit-15) var(--grid-unit-20)}#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.parsely-inputrange-control{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.parsely-inputrange-control .parsely-inputrange-control__label{margin:0}.parsely-inputrange-control .parsely-inputrange-control__controls{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-20);height:2.5rem}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control{display:flex;flex:1 0 0}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]::-webkit-inner-spin-button,.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]{-moz-appearance:textfield}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control .components-base-control__field{flex-grow:1}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control .components-input-control__suffix{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.parsely-inputrange-control .parsely-inputrange-control__controls .components-range-control{flex:1 0 0;height:36px}.parsely-inputrange-control .parsely-inputrange-control__controls .components-range-control .components-range-control__root{height:2.5rem}.parsely-panel-settings{width:100%}.parsely-panel-settings .parsely-panel-settings-header{display:flex;margin:.625rem 0;width:100%}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label{flex-grow:2;margin:0 0 0 .3125rem;text-align:left}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label .components-base-control__field{align-items:center;display:flex;justify-content:space-between}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label .components-base-control__field .components-base-control__label{margin-bottom:0}.parsely-panel-settings .parsely-panel-settings-body{align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper-error{align-self:flex-start;margin:0}.wp-parsely-content-helper-error p{margin:0}.wp-parsely-content-helper-error .content-helper-error-message{margin:0!important}.wp-parsely-collapsible-panel{align-items:flex-start;align-self:stretch;border-bottom:none;border-radius:2px;border-top:none;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:0 0 .5rem;padding:0}.wp-parsely-collapsible-panel .components-panel__body-title{align-items:center;align-self:stretch;display:flex;margin:0 -1rem .375rem;padding:0}.wp-parsely-collapsible-panel .components-panel__body-title .components-panel__icon,.wp-parsely-collapsible-panel .components-panel__body-title svg{margin-left:0;margin-right:var(--grid-unit-10);order:-1}.wp-parsely-collapsible-panel .components-panel__body-title:hover{background-color:transparent}.wp-parsely-collapsible-panel.is-opened{padding:0}.wp-parsely-collapsible-panel.is-opened>div:first-of-type{margin-top:calc(var(--grid-unit-20)*-1)}.wp-parsely-collapsible-panel.is-opened .components-panel__body-title{margin:0 calc(var(--grid-unit-20)*-1) .375rem;padding-bottom:0}.wp-parsely-collapsible-panel .components-panel__body-toggle.components-button{color:var(--Gutenberg-Gray-900,#1e1e1e);font-size:.6875rem;font-style:normal;font-weight:600;line-height:1rem;padding:var(--grid-unit-20) var(--grid-unit-20);text-transform:uppercase}.wp-parsely-collapsible-panel .components-panel__body-toggle.components-button .components-panel__arrow{margin-right:0}.wp-parsely-collapsible-panel .components-panel__body.is-opened{padding:0}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"]:focus,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"]:hover{background-color:#fff}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed:hover{background-color:var(--parsely-green-65)}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed .wp-parsely-sidebar-icon path,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed:hover .wp-parsely-sidebar-icon path{fill:var(--parsely-green-10)}.content-helper-error-message,.wp-parsely-content-helper-error .content-helper-error-message{margin-top:.9375rem!important}p.content-helper-error-message-hint{color:var(--gray-700)}.wp-parsely-content-helper-error.components-notice .components-notice__content{margin:0}.wp-parsely-content-helper-error.components-notice .components-notice__content .content-helper-error-message{margin-top:0!important}.wp-parsely-content-helper-error.components-notice .components-notice__content .content-helper-error-message p:last-child{margin-bottom:0!important}.wp-parsely-content-helper .wp-parsely-sidebar-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:1.5rem}.wp-parsely-content-helper .wp-parsely-sidebar-header .components-button{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .components-panel .panel-settings-button>button,.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .components-panel button.panel-settings-button{height:unset;min-width:unset;padding:0}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-panel>.content-helper-error-message{margin:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs button{align-items:center;display:flex;flex:1 0 0;flex-direction:column;height:3rem}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs .components-tab-panel__tabs-item:after{background:var(--gray-400);height:calc(var(--wp-admin-border-width-focus)*1);outline:2px solid transparent;outline-offset:-1px}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs .components-tab-panel__tabs-item.is-active:after{background:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-content-helper .parsely-spinner-wrapper{display:flex;justify-content:center;margin:2.5rem 0}.wp-parsely-content-helper .parsely-spinner-wrapper svg{height:22px;width:22px} diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index 4f73fce87..39c521cc6 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,26 +1,27 @@ -!function(){"use strict";var e={251:function(e,t,n){var r=n(196),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},893:function(e,t,n){e.exports=n(251)},196: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({},{W:function(){return Sn}});var e,t,r,i=n(893),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=n(196),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,h=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=(h.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"})]})},v=function(){return v=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiError||s.code===N.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===N.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===N.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return H(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[N.PluginCredentialsNotSetMessageDetected,N.PluginSettingsSiteIdNotSet,N.PluginSettingsApiSecretNotSet].includes(this.code)?B(e):(this.code===N.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==N.ParselyApiForbidden&&this.code!==N.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===N.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(I,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function W(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var U=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0?p(!0):x().then((function(){return t()}))},j=function(e){p(!1),e?(h(!1),x().then((function(){t()}))):h(!0)},T=function(){var e=y.indexOf(w)+1;y[e]&&_(y[e])},E=function(){var e=y.indexOf(w)-1;y[e]&&_(y[e])},L=function(){var e,t,n,i,s,o;w.match&&(r(w),(e=w.match.blockId,t=w,n=void 0,i=void 0,s=void 0,o=function(){var n,r;return 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){var l=o[0],c=l.parentNode;if(c){var u=document.createTextNode(null!==(n=l.textContent)&&void 0!==n?n:"");c.replaceChild(u,l),e.attributes.content=s.innerHTML,(0,a.dispatch)("core/block-editor").updateBlock(r,e)}}S(t.uid)}}}(e,w)}};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:P,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:E,right:T,up:E,down:T,a:function(){w&&!w.applied&&L()},r:function(){w&&(w.applied?N():C())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(te,{links:y,activeLink:w,setSelectedLink:_}),(0,i.jsx)(fe,{link:w,hasNext:y.indexOf(w)0,onNext:T,onPrevious:E,onAccept:L,onReject:C,onRemove:N,onSelectInEditor:function(){if(w.match){var e=(0,a.select)("core/block-editor").getBlock(w.match.blockId);e&&((0,a.dispatch)("core/block-editor").selectBlock(e.clientId),P())}}})]})]}),u&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return j(!1)},className:"wp-parsely-smart-linking-close-dialog",children:[(0,c.__)("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 j(!1)},children:(0,c.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return j(!0)},children:(0,c.__)("Close","wp-parsely")})]})]})]})})),ge=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})]})]})},ye=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,u=e.onSettingChange,p=(0,l.useRef)(),d=(0,l.useState)(""),f=d[0],h=d[1],g=(0,l.useState)(!1),y=g[0],v=g[1],m=(0,l.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(J),n=t.getMaxLinkWords,r=t.getMaxLinks,i=t.isFullContent,s=t.wasAlreadyClicked,a=t.getApplyTo;return{maxLinks:r(),maxLinkWords:n(),fullContent:i(),alreadyClicked:s(),applyTo:a()}}),[]),_=w.maxLinks,b=w.maxLinkWords,x=w.fullContent,k=w.alreadyClicked,S=w.applyTo,P=(0,a.useDispatch)(J),j=P.setMaxLinks,T=P.setMaxLinkWords,E=P.setFullContent,L=P.setAlreadyClicked,C=P.setApplyTo,N=null!==(t=S)&&void 0!==t?t:o?"selected":"all";return(0,l.useEffect)((function(){if(!r){var e=function(){r||(S===K.Selected&&setTimeout((function(){h((0,c.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),C(null),m((function(e){return!e})))};o||S===K.All||(y?setTimeout(e,500):e()),E(K.All===N)}}),[y,S,N,r,o,C,E,h]),(0,l.useEffect)((function(){if(!r&&p.current&&N&&!k&&o){var e=p.current.querySelector('button[data-value="'.concat(N,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(C(N),L(!0))}}),[o,x,r,S]),(0,l.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:N,label:(0,c.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&E("success",/* translators: %d: number of smart links applied */ -(0,c.sprintf)((0,c.__)("%s smart links successfully applied.","wp-parsely"),y),{type:"snackbar"}):v(0)}),[w]);var L=(0,a.useSelect)((function(e){var t=e(J),n=t.isLoading,r=t.getOverlayBlocks,i=t.getSuggestedLinks,s=t.getError,a=t.isFullContent,o=t.getMaxLinks,l=t.getMaxLinkWords,c=t.getSmartLinkingSettings,u=t.getApplyTo,p=t.isRetrying,d=t.getRetryAttempt,f=t.getSmartLinks;return{loading:n(),error:s(),maxLinks:o(),maxLinkWords:l(),isFullContent:a(),overlayBlocks:r(),suggestedLinks:i(),smartLinkingSettings:c(),applyTo:u(),retrying:p(),retryAttempt:d(),smartLinks:f(),getSmartLinksFn:f}}),[]),C=L.loading,A=L.isFullContent,R=L.overlayBlocks,I=L.error,B=L.suggestedLinks,M=L.maxLinks,D=L.maxLinkWords,H=L.smartLinkingSettings,z=L.applyTo,U=L.retrying,Z=L.retryAttempt,q=L.smartLinks,$=L.getSmartLinksFn,Y=(0,a.useDispatch)(J),Q=Y.setLoading,X=Y.setError,te=Y.addSmartLinks,ne=Y.addOverlayBlock,re=Y.removeOverlayBlock,ie=Y.setSmartLinkingSettings,se=Y.setApplyTo,ae=Y.setMaxLinkWords,oe=Y.setMaxLinks,le=Y.setIsRetrying,ce=Y.incrementRetryAttempt,ue=Y.purgeSmartLinksSuggestions;(0,l.useEffect)((function(){if(!(Object.keys(H).length>0)){var e={maxLinksPerPost:p.SmartLinking.MaxLinks,maxLinkWords:p.SmartLinking.MaxLinkWords};ie(e)}}),[ie,p]);var pe=(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]),de=pe.allBlocks,fe=pe.selectedBlock,ge=pe.postContent,ve=pe.postPermalink,me=function(e){return ke(void 0,void 0,void 0,(function(){var t,n,r,i;return Se(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,se((n=A||!fe)?K.All:K.Selected)];case 2:return s.sent(),a=ve.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,be.getInstance().generateSmartLinks((null==fe?void 0:fe.originalContent)&&!n?fe.originalContent:ge,D,M,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===N.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,le(!0)]):[3,8];case 5:return s.sent(),[4,ce()];case 6:return s.sent(),[4,me(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},we=function(e,t,n,r){return void 0===r&&(r=0),e.forEach((function(e,i){var s,a=r+i;if(null===(s=e.innerBlocks)||void 0===s?void 0:s.length)we(e.innerBlocks,t,n,a);else if(e.originalContent){var o=(0,V.getBlockContent)(e),l=(new DOMParser).parseFromString(o,"text/html").body.firstChild;l instanceof HTMLElement&&t.forEach((function(t){var r=function(e,t){for(var n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:function(n){var r;if(!n.textContent||!n.textContent.includes(t))return NodeFilter.FILTER_REJECT;for(var i=n.parentNode;i&&i!==e;){if("A"===i.nodeName&&!(null===(r=i.textContent)||void 0===r?void 0:r.includes(t)))return NodeFilter.FILTER_REJECT;i=i.parentNode}return NodeFilter.FILTER_ACCEPT}}),i=[];n=r.nextNode();)i.push(n);return i}(l,t.text),i="".concat(t.text,"#").concat(t.offset);n[i]=n[i]||{encountered:0,linked:0};var s=0;r.forEach((function(r){for(var o,l=new RegExp(W(t.text),"g");null!==l.exec(null!==(o=r.textContent)&&void 0!==o?o:"");){var c=n[i];c.encountered++,s++,c.encountered===t.offset+1&&c.linked<1&&(c.linked++,t.match={blockId:e.clientId,blockOffset:s-1,blockPosition:a})}}))}))}})),t},_e=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Ee=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsxs)(s.PanelRow,{className:t,children:[(0,i.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(F,{icon:G,size:18,className:"parsely-external-link-icon"})]})]}),I&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return X(null)},className:"wp-parsely-content-helper-error",children:I.Message()}),w&&y>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return _(!1)},className:"wp-parsely-smart-linking-suggested-links",children:(0,c.sprintf)(/* translators: 1 - number of smart links generated */ -(0,c.__)("Successfully added %s smart links.","wp-parsely"),y>0?y:B.length)}),(0,i.jsx)(ye,{disabled:C,selectedBlock:null==fe?void 0:fe.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:xe(xe({},p.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e?oe(t):"MaxLinkWords"===e&&ae(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return ke(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Se(this,(function(a){switch(a.label){case 0:return[4,Q(!0)];case 1:return a.sent(),[4,ue()];case 2:return a.sent(),[4,X(null)];case 3:return a.sent(),_(!1),h.trackEvent("smart_linking_generate_pressed",{is_full_content:A,selected_block:null!==(s=null==fe?void 0:fe.name)&&void 0!==s?s:"none",context:o}),[4,_e(A?"all":null==fe?void 0:fe.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;Q(!1),h.trackEvent("smart_linking_generate_timeout",{is_full_content:A,selected_block:null!==(e=null==fe?void 0:fe.name)&&void 0!==e?e:"none",context:o}),je(A?"all":null==fe?void 0:fe.clientId)}),18e4),t=z,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,me(3)];case 6:return n=a.sent(),[4,(l=n,ke(void 0,void 0,void 0,(function(){var e;return Se(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!q.find((function(t){return t.uid===e.uid&&t.applied}))})),e=ve.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=we(de,l,{}).filter((function(e){return e.match})),[4,te(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),k(!0),[3,15];case 8:return r=a.sent(),i=(0,c.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===N.ParselyAborted&&(i=(0,c.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ -(0,c.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),r.numRetries,(0,c._n)("attempt","attempts",r.numRetries,"wp-parsely")),r.message=i),[4,X(r)];case 9:return a.sent(),E("error",i,{type:"snackbar"}),[3,15];case 10:return[4,Q(!1)];case 11:return a.sent(),[4,se(t)];case 12:return a.sent(),[4,le(!1)];case 13:return a.sent(),[4,je(A?"all":null==fe?void 0:fe.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:C,disabled:C,children:U?(0,c.sprintf)(/* translators: %1$d: number of retry attempts, %2$d: maximum number of retries */ -(0,c.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),Z,3):C?(0,c.__)("Generating Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")})}),j&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return k(!0)},variant:"secondary",children:(0,c.__)("Review Smart Links","wp-parsely")})})]}),(0,i.jsx)(he,{isOpen:x,onAppliedLink:function(){v((function(e){return e+1}))},onClose:function(){_(!0),k(!1),$().length>0?T(!0):T(!1)}})]})},Te=function(){return Te=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 Fe=function(e){var n=e.data,r=e.isLoading,a=(0,l.useState)(t.Views),o=a[0],u=a[1],p=(0,l.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},g=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),L(o)); -/* translators: %s: metric description */return(0,i.jsxs)(De,{title:(0,c.__)("Categories","wp-parsely"),level:3,subtitle:g,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,c.__)("By: ","wp-parsely"),onChange:function(e){T(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,i.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[L(e),"avg_engaged"===e&&(0,c.__)(" (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,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ +!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 Sn}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=n(609),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,h=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=(h.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"})]})},v=function(){return v=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiError||s.code===N.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===N.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===N.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return H(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[N.PluginCredentialsNotSetMessageDetected,N.PluginSettingsSiteIdNotSet,N.PluginSettingsApiSecretNotSet].includes(this.code)?B(e):(this.code===N.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==N.ParselyApiForbidden&&this.code!==N.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===N.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(I,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function U(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var W=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0?p(!0):x().then((function(){return t()}))},j=function(e){p(!1),e?(h(!1),x().then((function(){t()}))):h(!0)},T=function(){var e=y.indexOf(w)+1;y[e]&&_(y[e])},E=function(){var e=y.indexOf(w)-1;y[e]&&_(y[e])},L=function(){var e,t,n,i,s,o;w.match&&(r(w),(e=w.match.blockId,t=w,n=void 0,i=void 0,s=void 0,o=function(){var n,r;return 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){var l=o[0],c=l.parentNode;if(c){var u=document.createTextNode(null!==(n=l.textContent)&&void 0!==n?n:"");c.replaceChild(u,l),e.attributes.content=s.innerHTML,(0,a.dispatch)("core/block-editor").updateBlock(r,e)}}S(t.uid)}}}(e,w)}};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:P,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:E,right:T,up:E,down:T,a:function(){w&&!w.applied&&L()},r:function(){w&&(w.applied?N():C())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(te,{links:y,activeLink:w,setSelectedLink:_}),(0,i.jsx)(fe,{link:w,hasNext:y.indexOf(w)0,onNext:T,onPrevious:E,onAccept:L,onReject:C,onRemove:N,onSelectInEditor:function(){if(w.match){var e=(0,a.select)("core/block-editor").getBlock(w.match.blockId);e&&((0,a.dispatch)("core/block-editor").selectBlock(e.clientId),P())}}})]})]}),u&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return j(!1)},className:"wp-parsely-smart-linking-close-dialog",children:[(0,c.__)("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 j(!1)},children:(0,c.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return j(!0)},children:(0,c.__)("Close","wp-parsely")})]})]})]})})),ge=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})]})]})},ye=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,u=e.onSettingChange,p=(0,l.useRef)(),d=(0,l.useState)(""),f=d[0],h=d[1],g=(0,l.useState)(!1),y=g[0],v=g[1],m=(0,l.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(J),n=t.getMaxLinkWords,r=t.getMaxLinks,i=t.isFullContent,s=t.wasAlreadyClicked,a=t.getApplyTo;return{maxLinks:r(),maxLinkWords:n(),fullContent:i(),alreadyClicked:s(),applyTo:a()}}),[]),_=w.maxLinks,b=w.maxLinkWords,x=w.fullContent,k=w.alreadyClicked,S=w.applyTo,P=(0,a.useDispatch)(J),j=P.setMaxLinks,T=P.setMaxLinkWords,E=P.setFullContent,L=P.setAlreadyClicked,C=P.setApplyTo,N=null!==(t=S)&&void 0!==t?t:o?"selected":"all";return(0,l.useEffect)((function(){if(!r){var e=function(){r||(S===K.Selected&&setTimeout((function(){h((0,c.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),C(null),m((function(e){return!e})))};o||S===K.All||(y?setTimeout(e,500):e()),E(K.All===N)}}),[y,S,N,r,o,C,E,h]),(0,l.useEffect)((function(){if(!r&&p.current&&N&&!k&&o){var e=p.current.querySelector('button[data-value="'.concat(N,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(C(N),L(!0))}}),[o,x,r,S]),(0,l.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:N,label:(0,c.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&E("success",/* translators: %d: number of smart links applied */ /* translators: %d: number of smart links applied */ +(0,c.sprintf)((0,c.__)("%s smart links successfully applied.","wp-parsely"),y),{type:"snackbar"}):v(0)}),[w]);var L=(0,a.useSelect)((function(e){var t=e(J),n=t.isLoading,r=t.getOverlayBlocks,i=t.getSuggestedLinks,s=t.getError,a=t.isFullContent,o=t.getMaxLinks,l=t.getMaxLinkWords,c=t.getSmartLinkingSettings,u=t.getApplyTo,p=t.isRetrying,d=t.getRetryAttempt,f=t.getSmartLinks;return{loading:n(),error:s(),maxLinks:o(),maxLinkWords:l(),isFullContent:a(),overlayBlocks:r(),suggestedLinks:i(),smartLinkingSettings:c(),applyTo:u(),retrying:p(),retryAttempt:d(),smartLinks:f(),getSmartLinksFn:f}}),[]),C=L.loading,A=L.isFullContent,R=L.overlayBlocks,I=L.error,B=L.suggestedLinks,M=L.maxLinks,D=L.maxLinkWords,H=L.smartLinkingSettings,z=L.applyTo,W=L.retrying,Z=L.retryAttempt,q=L.smartLinks,$=L.getSmartLinksFn,Y=(0,a.useDispatch)(J),Q=Y.setLoading,X=Y.setError,te=Y.addSmartLinks,ne=Y.addOverlayBlock,re=Y.removeOverlayBlock,ie=Y.setSmartLinkingSettings,se=Y.setApplyTo,ae=Y.setMaxLinkWords,oe=Y.setMaxLinks,le=Y.setIsRetrying,ce=Y.incrementRetryAttempt,ue=Y.purgeSmartLinksSuggestions;(0,l.useEffect)((function(){if(!(Object.keys(H).length>0)){var e={maxLinksPerPost:p.SmartLinking.MaxLinks,maxLinkWords:p.SmartLinking.MaxLinkWords};ie(e)}}),[ie,p]);var pe=(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]),de=pe.allBlocks,fe=pe.selectedBlock,ge=pe.postContent,ve=pe.postPermalink,me=function(e){return ke(void 0,void 0,void 0,(function(){var t,n,r,i;return Se(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,se((n=A||!fe)?K.All:K.Selected)];case 2:return s.sent(),a=ve.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,be.getInstance().generateSmartLinks((null==fe?void 0:fe.originalContent)&&!n?fe.originalContent:ge,D,M,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===N.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,le(!0)]):[3,8];case 5:return s.sent(),[4,ce()];case 6:return s.sent(),[4,me(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},we=function(e,t,n,r){return void 0===r&&(r=0),e.forEach((function(e,i){var s,a=r+i;if(null===(s=e.innerBlocks)||void 0===s?void 0:s.length)we(e.innerBlocks,t,n,a);else if(e.originalContent){var o=(0,V.getBlockContent)(e),l=(new DOMParser).parseFromString(o,"text/html").body.firstChild;l instanceof HTMLElement&&t.forEach((function(t){var r=function(e,t){for(var n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:function(n){var r;if(!n.textContent||!n.textContent.includes(t))return NodeFilter.FILTER_REJECT;for(var i=n.parentNode;i&&i!==e;){if("A"===i.nodeName&&!(null===(r=i.textContent)||void 0===r?void 0:r.includes(t)))return NodeFilter.FILTER_REJECT;i=i.parentNode}return NodeFilter.FILTER_ACCEPT}}),i=[];n=r.nextNode();)i.push(n);return i}(l,t.text),i="".concat(t.text,"#").concat(t.offset);n[i]=n[i]||{encountered:0,linked:0};var s=0;r.forEach((function(r){for(var o,l=new RegExp(U(t.text),"g");null!==l.exec(null!==(o=r.textContent)&&void 0!==o?o:"");){var c=n[i];c.encountered++,s++,c.encountered===t.offset+1&&c.linked<1&&(c.linked++,t.match={blockId:e.clientId,blockOffset:s-1,blockPosition:a})}}))}))}})),t},_e=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Ee=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsxs)(s.PanelRow,{className:t,children:[(0,i.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(F,{icon:G,size:18,className:"parsely-external-link-icon"})]})]}),I&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return X(null)},className:"wp-parsely-content-helper-error",children:I.Message()}),w&&y>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return _(!1)},className:"wp-parsely-smart-linking-suggested-links",children:(0,c.sprintf)(/* translators: 1 - number of smart links generated */ /* translators: 1 - number of smart links generated */ +(0,c.__)("Successfully added %s smart links.","wp-parsely"),y>0?y:B.length)}),(0,i.jsx)(ye,{disabled:C,selectedBlock:null==fe?void 0:fe.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:xe(xe({},p.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e?oe(t):"MaxLinkWords"===e&&ae(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return ke(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Se(this,(function(a){switch(a.label){case 0:return[4,Q(!0)];case 1:return a.sent(),[4,ue()];case 2:return a.sent(),[4,X(null)];case 3:return a.sent(),_(!1),h.trackEvent("smart_linking_generate_pressed",{is_full_content:A,selected_block:null!==(s=null==fe?void 0:fe.name)&&void 0!==s?s:"none",context:o}),[4,_e(A?"all":null==fe?void 0:fe.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;Q(!1),h.trackEvent("smart_linking_generate_timeout",{is_full_content:A,selected_block:null!==(e=null==fe?void 0:fe.name)&&void 0!==e?e:"none",context:o}),je(A?"all":null==fe?void 0:fe.clientId)}),18e4),t=z,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,me(3)];case 6:return n=a.sent(),[4,(l=n,ke(void 0,void 0,void 0,(function(){var e;return Se(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!q.find((function(t){return t.uid===e.uid&&t.applied}))})),e=ve.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=we(de,l,{}).filter((function(e){return e.match})),[4,te(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),k(!0),[3,15];case 8:return r=a.sent(),i=(0,c.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===N.ParselyAborted&&(i=(0,c.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ /* translators: %d: number of retry attempts, %s: attempt plural */ +(0,c.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),r.numRetries,(0,c._n)("attempt","attempts",r.numRetries,"wp-parsely")),r.message=i),[4,X(r)];case 9:return a.sent(),E("error",i,{type:"snackbar"}),[3,15];case 10:return[4,Q(!1)];case 11:return a.sent(),[4,se(t)];case 12:return a.sent(),[4,le(!1)];case 13:return a.sent(),[4,je(A?"all":null==fe?void 0:fe.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:C,disabled:C,children:W?(0,c.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,c.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),Z,3):C?(0,c.__)("Generating Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")})}),j&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return k(!0)},variant:"secondary",children:(0,c.__)("Review Smart Links","wp-parsely")})})]}),x&&(0,i.jsx)(he,{isOpen:x,onAppliedLink:function(){v((function(e){return e+1}))},onClose:function(){_(!0),k(!1),$().length>0?T(!0):T(!1)}})]})},Te=function(){return Te=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 Fe=function(e){var n=e.data,r=e.isLoading,a=(0,l.useState)(t.Views),o=a[0],u=a[1],p=(0,l.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},g=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),L(o)); +/* translators: %s: metric description */return(0,i.jsxs)(De,{title:(0,c.__)("Categories","wp-parsely"),level:3,subtitle:g,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,c.__)("By: ","wp-parsely"),onChange:function(e){T(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,i.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[L(e),"avg_engaged"===e&&(0,c.__)(" (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,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ /* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ (0,c.__)("%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,c.sprintf)((0,c.__)("%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:Ve(n.views)})]},t)}))})]})]})},Ge=(0,u.createElement)(p.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.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"})),He=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),ze=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),We=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"})),Ue=function(){return Ue=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]1?[2,Promise.reject(new z((0,c.sprintf)(/* translators: URL of the published post */ -(0,c.__)("Multiple results were returned for the post %s by the Parse.ly API.","wp-parsely"),t),N.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return rt(this,void 0,void 0,(function(){return it(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,oe.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",nt(nt({},et(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(ve),at=function(){return at=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)(De,{title:(0,c.__)("Performance Stats","wp-parsely"),icon:Me,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(dt,{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,c.__)("Period: ","wp-parsely")}),onChange:function(t){T(t,e)&&(w({PerformanceStats:at(at({},m.PerformanceStats),{Period:t})}),h.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)}))})})}),p?p.Message():(0,i.jsxs)(i.Fragment,{children:[pt(m,"overview")&&(0,i.jsx)(Xe,{data:g,isLoading:a}),pt(m,"categories")&&(0,i.jsx)(Fe,{data:g,isLoading:a}),pt(m,"referrers")&&(0,i.jsx)(Je,{data:g,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){h.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,c.__)("View this in Parse.ly","wp-parsely")})]})},ht=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(D,{children:(0,i.jsx)(ft,{period:t})})})},gt=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,c.__)("Tag","wp-parsely")}),a.categories.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Section,label:(0,c.__)("Section","wp-parsely")}),a.authors.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Author,label:(0,c.__)("Author","wp-parsely")})]})})},vt=function(e){var t=e.filter,n=e.label,a=e.postData,o=gt(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})})},mt=function(e){var t=e.filter,n=e.postData,s=e.label,a=gt(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)(yt,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(vt,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},wt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),_t=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"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"}));function bt(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,c.__)("Number of Views","wp-parsely")}),s,Ve(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,c.__)("Average Time","wp-parsely")}),r,n.avgEngaged]}):(0,i.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}var xt,kt=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"})})},St=function(e){var t,n,r=e.metric,o=e.post,l=e.postContent,u=(0,a.useDispatch)("core/notices").createNotice,p=l&&(t=l,n=W(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,c.__)("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)(bt,{metric:r,post:o,viewsIcon:(0,i.jsx)(F,{icon:Ge}),avgEngagedIcon:(0,i.jsx)(s.Dashicon,{icon:"clock",size:24})})}),p&&(0,i.jsx)("div",{className:"related-post-linked",children:(0,i.jsx)(s.Tooltip,{text:(0,c.__)("This post is linked in the content","wp-parsely"),children:(0,i.jsx)(F,{icon:wt,size:24})})})]}),(0,i.jsx)(kt,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:_t,iconSize:24,onClick:function(){navigator.clipboard.writeText(o.rawUrl).then((function(){u("success",(0,c.__)("URL copied to clipboard","wp-parsely"),{type:"snackbar"})}))},label:(0,c.__)("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,c.__)("View in Parse.ly","wp-parsely")})]})]})})]})},Pt=window.wp.coreData,jt=window.wp.editor,Tt=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 __)}}(),Et=function(){return Et=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 z((0,c.sprintf)(/* translators: URL of the published post */ /* translators: URL of the published post */ +(0,c.__)("Multiple results were returned for the post %s by the Parse.ly API.","wp-parsely"),t),N.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return rt(this,void 0,void 0,(function(){return it(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,oe.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",nt(nt({},et(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(ve),at=function(){return at=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)(De,{title:(0,c.__)("Performance Stats","wp-parsely"),icon:Me,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(dt,{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,c.__)("Period: ","wp-parsely")}),onChange:function(t){T(t,e)&&(w({PerformanceStats:at(at({},m.PerformanceStats),{Period:t})}),h.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)}))})})}),p?p.Message():(0,i.jsxs)(i.Fragment,{children:[pt(m,"overview")&&(0,i.jsx)(Xe,{data:g,isLoading:a}),pt(m,"categories")&&(0,i.jsx)(Fe,{data:g,isLoading:a}),pt(m,"referrers")&&(0,i.jsx)(Je,{data:g,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){h.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,c.__)("View this in Parse.ly","wp-parsely")})]})},ht=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(D,{children:(0,i.jsx)(ft,{period:t})})})},gt=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,c.__)("Tag","wp-parsely")}),a.categories.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Section,label:(0,c.__)("Section","wp-parsely")}),a.authors.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Author,label:(0,c.__)("Author","wp-parsely")})]})})},vt=function(e){var t=e.filter,n=e.label,a=e.postData,o=gt(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})})},mt=function(e){var t=e.filter,n=e.postData,s=e.label,a=gt(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)(yt,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(vt,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},wt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),_t=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"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"}));function bt(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,c.__)("Number of Views","wp-parsely")}),s,Ve(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,c.__)("Average Time","wp-parsely")}),r,n.avgEngaged]}):(0,i.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}var xt,kt=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"})})},St=function(e){var t,n,r=e.metric,o=e.post,l=e.postContent,u=(0,a.useDispatch)("core/notices").createNotice,p=l&&(t=l,n=U(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,c.__)("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)(bt,{metric:r,post:o,viewsIcon:(0,i.jsx)(F,{icon:Ge}),avgEngagedIcon:(0,i.jsx)(s.Dashicon,{icon:"clock",size:24})})}),p&&(0,i.jsx)("div",{className:"related-post-linked",children:(0,i.jsx)(s.Tooltip,{text:(0,c.__)("This post is linked in the content","wp-parsely"),children:(0,i.jsx)(F,{icon:wt,size:24})})})]}),(0,i.jsx)(kt,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:_t,iconSize:24,onClick:function(){navigator.clipboard.writeText(o.rawUrl).then((function(){u("success",(0,c.__)("URL copied to clipboard","wp-parsely"),{type:"snackbar"})}))},label:(0,c.__)("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,c.__)("View in Parse.ly","wp-parsely")})]})]})})]})},Pt=window.wp.coreData,jt=window.wp.editor,Tt=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 __)}}(),Et=function(){return Et=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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),m=v.authors,w=v.categories,_=v.tags,b=v.isReady;(0,l.useEffect)((function(){if(b){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})):[]};y({authors:e(m),categories:e(w),tags:e(_)})}}),[m,w,_,b]);var x=(0,l.useState)(!0),k=x[0],S=x[1],j=(0,l.useState)(),C=j[0],N=j[1],A=(0,l.useState)(),R=A[0],I=A[1],B=(0,l.useState)([]),M=B[0],D=B[1],V=(0,l.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=V[0],G=V[1],H=(0,l.useState)(void 0),z=H[0],W=H[1],U=(0,O.useDebounce)(W,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;U(t())}),[U]);var Z=function(e,t){u({RelatedPosts:At(At({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,l.useEffect)((function(){var e,t,n=function(e){return Ot(void 0,void 0,void 0,(function(){return Rt(this,(function(t){return Nt.getInstance().getRelatedPosts(p,d,F).then((function(e){D(e.posts),I(e.message),S(!1)})).catch((function(t){return Ot(void 0,void 0,void 0,(function(){return Rt(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),N(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===g.authors.length,c=0===g.tags.length,u=0===g.categories.length,f=i&&!g.authors.includes(F.value),h=s&&!g.tags.includes(F.value),y=a&&!g.categories.includes(F.value);return S(!0),o||s&&c||a&&u||i&&l?Object.values(g).every((function(e){return 0===e.length}))||G((e="",t=r.Unavailable,g.tags.length>=1?(t=r.Tag,e=g.tags[0]):g.categories.length>=1?(t=r.Section,e=g.categories[0]):g.authors.length>=1&&(t=r.Author,e=g.authors[0]),{type:t,value:e})):h?G({type:r.Tag,value:g.tags[0]}):y?G({type:r.Section,value:g.categories[0]}):f?G({type:r.Author,value:g.authors[0]}):n(1),function(){S(!1),D([]),I(""),N(void 0)}}),[p,d,F,g]),0===g.authors.length&&0===g.categories.length&&0===g.tags.length&&b?(0,i.jsx)("div",{className:"wp-parsely-related-posts",children:(0,i.jsx)("div",{className:"related-posts-body",children:(0,c.__)("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,c.__)("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;T(n=e,t)&&(u({RelatedPosts:At(At({},o.RelatedPosts),{Metric:n})}),h.trackEvent("related_posts_metric_changed",{metric:n}))},prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,c.__)("Metric: ","wp-parsely")}),value:d,children:Object.values(t).map((function(e){return(0,i.jsx)("option",{value:e,children:L(e)},e)}))}),(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:p,prefix:(0,i.jsxs)(s.__experimentalInputControlPrefixWrapper,{children:[(0,c.__)("Period: ","wp-parsely")," "]}),onChange:function(t){return function(t){T(t,e)&&(u({RelatedPosts:At(At({},o.RelatedPosts),{Period:t})}),h.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)(mt,{label:(0,c.__)("Filter by","wp-parsely"),filter:F,onFilterTypeChange:function(e){if(T(e,r)){var t="",n=e;r.Tag===n&&(t=g.tags[0]),r.Section===n&&(t=g.categories[0]),r.Author===n&&(t=g.authors[0]),""!==t&&(Z(n,t),G({type:n,value:t}),h.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(F.type,e),G(At(At({},F),{value:e})))},postData:g}),(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===F.type?(0,c.sprintf)(/* translators: 1: tag name, 2: period */ -(0,c.__)("Top related posts with the “%1$s” tag in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Section===F.type?(0,c.sprintf)(/* translators: 1: section name, 2: period */ -(0,c.__)("Top related posts in the “%1$s” section in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Author===F.type?(0,c.sprintf)(/* translators: 1: author name, 2: period */ -(0,c.__)("Top related posts by %1$s in the %2$s.","wp-parsely"),F.value,E(p,!0)):null!=R?R:""})}),C&&C.Message(),k&&(0,i.jsx)("div",{className:"related-posts-loading-message","data-testid":"parsely-related-posts-loading-message",children:(0,c.__)("Loading…","wp-parsely")}),!k&&!C&&0===M.length&&(0,i.jsx)("div",{className:"related-posts-empty","data-testid":"parsely-related-posts-empty",children:(0,c.__)("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)(St,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},Bt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),Mt=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"})})},Dt={journalist:{label:(0,c.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,c.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,c.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,c.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,c.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,c.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,c.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,c.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,c.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,c.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,c.__)("Custom Persona","wp-parsely"),icon:Bt}},Vt=Object.keys(Dt),Ft=function(e){return"custom"===e||""===e?Dt.custom.label:Gt(e)?e:Dt[e].label},Gt=function(e){return!Vt.includes(e)||"custom"===e},Ht=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},zt=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,c.__)("Select a persona…","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Persona","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:Gt(t)?Dt.custom.label:r}),(0,i.jsx)(Mt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Persona","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Vt.map((function(e){if(!h&&"custom"===e)return null;var r=Dt[e],a=e===t||Gt(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(F,{icon:r.icon}),r.label]},e)}))})})}}),h&&Gt(t)&&(0,i.jsx)(Ht,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},Wt={neutral:{label:(0,c.__)("Neutral","wp-parsely")},formal:{label:(0,c.__)("Formal","wp-parsely")},humorous:{label:(0,c.__)("Humorous","wp-parsely")},confident:{label:(0,c.__)("Confident","wp-parsely")},provocative:{label:(0,c.__)("Provocative","wp-parsely")},serious:{label:(0,c.__)("Serious","wp-parsely")},inspirational:{label:(0,c.__)("Inspirational","wp-parsely")},skeptical:{label:(0,c.__)("Skeptical","wp-parsely")},conversational:{label:(0,c.__)("Conversational","wp-parsely")},analytical:{label:(0,c.__)("Analytical","wp-parsely")},custom:{label:(0,c.__)("Custom Tone","wp-parsely"),icon:Bt}},Ut=Object.keys(Wt),Zt=function(e){return"custom"===e||""===e?Wt.custom.label:qt(e)?e:Wt[e].label},qt=function(e){return!Ut.includes(e)||"custom"===e},$t=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},Kt=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,c.__)("Select a tone","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Tone","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:qt(t)?Wt.custom.label:r}),(0,i.jsx)(Mt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Select a tone","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Ut.map((function(e){if(!h&&"custom"===e)return null;var r=Wt[e],a=e===t||qt(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(F,{icon:r.icon}),r.label]},e)}))})})}}),h&&qt(t)&&(0,i.jsx)($t,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},Yt=(0,u.createElement)(p.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.Path,{d:"M10.97 10.159a3.382 3.382 0 0 0-2.857.955l1.724 1.723-2.836 2.913L7 17h1.25l2.913-2.837 1.723 1.723a3.38 3.38 0 0 0 .606-.825c.33-.63.446-1.343.35-2.032L17 10.695 13.305 7l-2.334 3.159Z"})),Qt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"})),Xt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})),Jt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z"})),en=function(){return en=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,l.createInterpolateElement)( +message:(0,c.sprintf)((0,c.__)('by author "%1$s"',"wp-parsely"),n.value)};throw new z((0,c.__)("No valid filter type has been specified.","wp-parsely"),N.CannotFormulateApiQuery)},t}(ve),At=function(){return At=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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),m=v.authors,w=v.categories,_=v.tags,b=v.isReady;(0,l.useEffect)((function(){if(b){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})):[]};y({authors:e(m),categories:e(w),tags:e(_)})}}),[m,w,_,b]);var x=(0,l.useState)(!0),k=x[0],S=x[1],j=(0,l.useState)(),C=j[0],N=j[1],A=(0,l.useState)(),R=A[0],I=A[1],B=(0,l.useState)([]),M=B[0],D=B[1],V=(0,l.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=V[0],G=V[1],H=(0,l.useState)(void 0),z=H[0],U=H[1],W=(0,O.useDebounce)(U,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;W(t())}),[W]);var Z=function(e,t){u({RelatedPosts:At(At({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,l.useEffect)((function(){var e,t,n=function(e){return Ot(void 0,void 0,void 0,(function(){return Rt(this,(function(t){return Nt.getInstance().getRelatedPosts(p,d,F).then((function(e){D(e.posts),I(e.message),S(!1)})).catch((function(t){return Ot(void 0,void 0,void 0,(function(){return Rt(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),N(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===g.authors.length,c=0===g.tags.length,u=0===g.categories.length,f=i&&!g.authors.includes(F.value),h=s&&!g.tags.includes(F.value),y=a&&!g.categories.includes(F.value);return S(!0),o||s&&c||a&&u||i&&l?Object.values(g).every((function(e){return 0===e.length}))||G((e="",t=r.Unavailable,g.tags.length>=1?(t=r.Tag,e=g.tags[0]):g.categories.length>=1?(t=r.Section,e=g.categories[0]):g.authors.length>=1&&(t=r.Author,e=g.authors[0]),{type:t,value:e})):h?G({type:r.Tag,value:g.tags[0]}):y?G({type:r.Section,value:g.categories[0]}):f?G({type:r.Author,value:g.authors[0]}):n(1),function(){S(!1),D([]),I(""),N(void 0)}}),[p,d,F,g]),0===g.authors.length&&0===g.categories.length&&0===g.tags.length&&b?(0,i.jsx)("div",{className:"wp-parsely-related-posts",children:(0,i.jsx)("div",{className:"related-posts-body",children:(0,c.__)("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,c.__)("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;T(n=e,t)&&(u({RelatedPosts:At(At({},o.RelatedPosts),{Metric:n})}),h.trackEvent("related_posts_metric_changed",{metric:n}))},prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,c.__)("Metric: ","wp-parsely")}),value:d,children:Object.values(t).map((function(e){return(0,i.jsx)("option",{value:e,children:L(e)},e)}))}),(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:p,prefix:(0,i.jsxs)(s.__experimentalInputControlPrefixWrapper,{children:[(0,c.__)("Period: ","wp-parsely")," "]}),onChange:function(t){return function(t){T(t,e)&&(u({RelatedPosts:At(At({},o.RelatedPosts),{Period:t})}),h.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)(mt,{label:(0,c.__)("Filter by","wp-parsely"),filter:F,onFilterTypeChange:function(e){if(T(e,r)){var t="",n=e;r.Tag===n&&(t=g.tags[0]),r.Section===n&&(t=g.categories[0]),r.Author===n&&(t=g.authors[0]),""!==t&&(Z(n,t),G({type:n,value:t}),h.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(F.type,e),G(At(At({},F),{value:e})))},postData:g}),(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===F.type?(0,c.sprintf)(/* translators: 1: tag name, 2: period */ /* translators: 1: tag name, 2: period */ +(0,c.__)("Top related posts with the “%1$s” tag in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Section===F.type?(0,c.sprintf)(/* translators: 1: section name, 2: period */ /* translators: 1: section name, 2: period */ +(0,c.__)("Top related posts in the “%1$s” section in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Author===F.type?(0,c.sprintf)(/* translators: 1: author name, 2: period */ /* translators: 1: author name, 2: period */ +(0,c.__)("Top related posts by %1$s in the %2$s.","wp-parsely"),F.value,E(p,!0)):null!=R?R:""})}),C&&C.Message(),k&&(0,i.jsx)("div",{className:"related-posts-loading-message","data-testid":"parsely-related-posts-loading-message",children:(0,c.__)("Loading…","wp-parsely")}),!k&&!C&&0===M.length&&(0,i.jsx)("div",{className:"related-posts-empty","data-testid":"parsely-related-posts-empty",children:(0,c.__)("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)(St,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},Bt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),Mt=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"})})},Dt={journalist:{label:(0,c.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,c.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,c.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,c.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,c.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,c.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,c.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,c.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,c.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,c.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,c.__)("Custom Persona","wp-parsely"),icon:Bt}},Vt=Object.keys(Dt),Ft=function(e){return"custom"===e||""===e?Dt.custom.label:Gt(e)?e:Dt[e].label},Gt=function(e){return!Vt.includes(e)||"custom"===e},Ht=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},zt=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,c.__)("Select a persona…","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Persona","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:Gt(t)?Dt.custom.label:r}),(0,i.jsx)(Mt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Persona","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Vt.map((function(e){if(!h&&"custom"===e)return null;var r=Dt[e],a=e===t||Gt(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(F,{icon:r.icon}),r.label]},e)}))})})}}),h&&Gt(t)&&(0,i.jsx)(Ht,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},Ut={neutral:{label:(0,c.__)("Neutral","wp-parsely")},formal:{label:(0,c.__)("Formal","wp-parsely")},humorous:{label:(0,c.__)("Humorous","wp-parsely")},confident:{label:(0,c.__)("Confident","wp-parsely")},provocative:{label:(0,c.__)("Provocative","wp-parsely")},serious:{label:(0,c.__)("Serious","wp-parsely")},inspirational:{label:(0,c.__)("Inspirational","wp-parsely")},skeptical:{label:(0,c.__)("Skeptical","wp-parsely")},conversational:{label:(0,c.__)("Conversational","wp-parsely")},analytical:{label:(0,c.__)("Analytical","wp-parsely")},custom:{label:(0,c.__)("Custom Tone","wp-parsely"),icon:Bt}},Wt=Object.keys(Ut),Zt=function(e){return"custom"===e||""===e?Ut.custom.label:qt(e)?e:Ut[e].label},qt=function(e){return!Wt.includes(e)||"custom"===e},$t=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},Kt=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,c.__)("Select a tone","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Tone","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:qt(t)?Ut.custom.label:r}),(0,i.jsx)(Mt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Select a tone","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Wt.map((function(e){if(!h&&"custom"===e)return null;var r=Ut[e],a=e===t||qt(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(F,{icon:r.icon}),r.label]},e)}))})})}}),h&&qt(t)&&(0,i.jsx)($t,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},Yt=(0,u.createElement)(p.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.Path,{d:"M10.97 10.159a3.382 3.382 0 0 0-2.857.955l1.724 1.723-2.836 2.913L7 17h1.25l2.913-2.837 1.723 1.723a3.38 3.38 0 0 0 .606-.825c.33-.63.446-1.343.35-2.032L17 10.695 13.305 7l-2.334 3.159Z"})),Qt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"})),Xt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})),Jt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z"})),en=function(){return en=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,l.createInterpolateElement)( +// translators: %1$s is the tone, %2$s is the persona. // translators: %1$s is the tone, %2$s is the persona. (0,c.__)("We've generated a few titles based on the content of your post, written as a .","wp-parsely"),{tone:(0,i.jsx)("strong",{children:Zt(d)}),persona:(0,i.jsx)("strong",{children:Ft(y)})})}):(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(F,{icon:G,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==S&&(0,i.jsx)(cn,{title:S,type:xt.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(un,{pinnedTitles:b,isOpen:!0}),_.length>0&&(0,i.jsx)(fn,{suggestions:_,isOpen:!0,isLoading:w})]}),(0,i.jsx)(pn,{isLoading:w,onPersonaChange:function(e){A("Persona",e),v(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"===y,onClick:function(){return vn(void 0,void 0,void 0,(function(){return mn(this,(function(e){switch(e.label){case 0:return u(void 0),!1!==w?[3,2]:(h.trackEvent("title_suggestions_generate_pressed",{request_more:_.length>0,total_titles:_.length,total_pinned:_.filter((function(e){return e.isPinned})).length,tone:d,persona:y}),[4,(t=xt.PostTitle,n=O,r=d,i=y,vn(void 0,void 0,void 0,(function(){var e,s,a;return mn(this,(function(o){switch(o.label){case 0:return[4,E(!0)];case 1:o.sent(),e=gn.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(),u(a),T(t,[]),[3,6];case 6:return[4,E(!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,c.__)("Generating Titles…","wp-parsely"),!w&&x.length>0&&(0,c.__)("Generate More","wp-parsely"),!w&&0===x.length&&(0,c.__)("Generate Titles","wp-parsely")]})})]})})},bn=function(){return bn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => '0dbdd33d5ec4fabd7275'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => '97d245b83425f790daa0'); diff --git a/build/content-helper/excerpt-generator.js b/build/content-helper/excerpt-generator.js index 2378d0188..f32d0af5f 100644 --- a/build/content-helper/excerpt-generator.js +++ b/build/content-helper/excerpt-generator.js @@ -1,3 +1,4 @@ -!function(){"use strict";var e={251:function(e,t,r){var n=r(196),a=Symbol.for("react.element"),s=Symbol.for("react.fragment"),o=Object.prototype.hasOwnProperty,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function c(e,t,r){var n,s={},c=null,p=null;for(n in void 0!==r&&(c=""+r),void 0!==t.key&&(c=""+t.key),void 0!==t.ref&&(p=t.ref),t)o.call(t,n)&&!l.hasOwnProperty(n)&&(s[n]=t[n]);if(e&&e.defaultProps)for(n in t=e.defaultProps)void 0===s[n]&&(s[n]=t[n]);return{$$typeof:a,type:e,key:c,ref:p,props:s,_owner:i.current}}t.Fragment=s,t.jsx=c,t.jsxs=c},893:function(e,t,r){e.exports=r(251)},196:function(e){e.exports=window.React}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var s=t[n]={exports:{}};return e[n](s,s.exports,r),s.exports}r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,{a:t}),t},r.d=function(e,t){for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){var e,t,n=window.wp.data,a=window.wp.hooks,s=window.wp.plugins,o=r(893),i=window.wp.components,l=window.wp.editPost,c=window.wp.editor,p=window.wp.element,u=window.wp.i18n,d=window.wp.wordcount,y=r(196),h=window.wp.primitives,f=(0,y.createElement)(h.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,y.createElement)(h.Path,{d:"M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"})),w=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return r=this,n=arguments,s=function(t,r){var n;return void 0===r&&(r={}),function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]=1e4&&(clearInterval(s),r("Telemetry library not loaded"))}),100);else r("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,r){var n;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(r=this.prepareProperties(r),null===(n=this._tkq)||void 0===n||n.push(["recordEvent",t,r])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,r={};return Object.keys(e).forEach((function(n){t.isProprietyValid(n)&&(r[n]=e[n])})),r},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),v=(w.trackEvent,function(e){var t=e.size,r=void 0===t?24:t,n=e.className,a=void 0===n?"wp-parsely-icon":n;return(0,o.jsxs)(i.SVG,{className:a,height:r,viewBox:"0 0 60 65",width:r,xmlns:"http://www.w3.org/2000/svg",children:[(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M23.72,51.53c0-.18,0-.34-.06-.52a13.11,13.11,0,0,0-2.1-5.53A14.74,14.74,0,0,0,19.12,43c-.27-.21-.5-.11-.51.22l-.24,3.42c0,.33-.38.35-.49,0l-1.5-4.8a1.4,1.4,0,0,0-.77-.78,23.91,23.91,0,0,0-3.1-.84c-1.38-.24-3.39-.39-3.39-.39-.34,0-.45.21-.25.49l2.06,3.76c.2.27,0,.54-.29.33l-4.51-3.6a3.68,3.68,0,0,0-2.86-.48c-1,.16-2.44.46-2.44.46a.68.68,0,0,0-.39.25.73.73,0,0,0-.14.45S.41,43,.54,44a3.63,3.63,0,0,0,1.25,2.62L6.48,50c.28.2.09.49-.23.37l-4.18-.94c-.32-.12-.5,0-.4.37,0,0,.69,1.89,1.31,3.16a24,24,0,0,0,1.66,2.74,1.34,1.34,0,0,0,1,.52l5,.13c.33,0,.41.38.1.48L7.51,58c-.31.1-.34.35-.07.55a14.29,14.29,0,0,0,3.05,1.66,13.09,13.09,0,0,0,5.9.5,25.13,25.13,0,0,0,4.34-1,9.55,9.55,0,0,1-.08-1.2,9.32,9.32,0,0,1,3.07-6.91"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M59.7,41.53a.73.73,0,0,0-.14-.45.68.68,0,0,0-.39-.25s-1.43-.3-2.44-.46a3.64,3.64,0,0,0-2.86.48l-4.51,3.6c-.26.21-.49-.06-.29-.33l2.06-3.76c.2-.28.09-.49-.25-.49,0,0-2,.15-3.39.39a23.91,23.91,0,0,0-3.1.84,1.4,1.4,0,0,0-.77.78l-1.5,4.8c-.11.32-.48.3-.49,0l-.24-3.42c0-.33-.24-.43-.51-.22a14.74,14.74,0,0,0-2.44,2.47A13.11,13.11,0,0,0,36.34,51c0,.18,0,.34-.06.52a9.26,9.26,0,0,1,3,8.1,24.1,24.1,0,0,0,4.34,1,13.09,13.09,0,0,0,5.9-.5,14.29,14.29,0,0,0,3.05-1.66c.27-.2.24-.45-.07-.55l-3.22-1.17c-.31-.1-.23-.47.1-.48l5-.13a1.38,1.38,0,0,0,1-.52A24.6,24.6,0,0,0,57,52.92c.61-1.27,1.31-3.16,1.31-3.16.1-.33-.08-.49-.4-.37l-4.18.94c-.32.12-.51-.17-.23-.37l4.69-3.34A3.63,3.63,0,0,0,59.46,44c.13-1,.24-2.47.24-2.47"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M46.5,25.61c0-.53-.35-.72-.8-.43l-4.86,2.66c-.45.28-.56-.27-.23-.69l4.66-6.23a2,2,0,0,0,.28-1.68,36.51,36.51,0,0,0-2.19-4.89,34,34,0,0,0-2.81-3.94c-.33-.41-.74-.35-.91.16l-2.28,5.68c-.16.5-.6.48-.59-.05l.28-8.93a2.54,2.54,0,0,0-.66-1.64S35,4.27,33.88,3.27,30.78.69,30.78.69a1.29,1.29,0,0,0-1.54,0s-1.88,1.49-3.12,2.59-2.48,2.35-2.48,2.35A2.5,2.5,0,0,0,23,7.27l.27,8.93c0,.53-.41.55-.58.05l-2.29-5.69c-.17-.5-.57-.56-.91-.14a35.77,35.77,0,0,0-3,4.2,35.55,35.55,0,0,0-2,4.62,2,2,0,0,0,.27,1.67l4.67,6.24c.33.42.23,1-.22.69l-4.87-2.66c-.45-.29-.82-.1-.82.43a18.6,18.6,0,0,0,.83,5.07,20.16,20.16,0,0,0,5.37,7.77c3.19,3,5.93,7.8,7.45,11.08A9.6,9.6,0,0,1,30,49.09a9.31,9.31,0,0,1,2.86.45c1.52-3.28,4.26-8.11,7.44-11.09a20.46,20.46,0,0,0,5.09-7,19,19,0,0,0,1.11-5.82"}),(0,o.jsx)(i.Path,{fill:"#5ba745",d:"M36.12,58.44A6.12,6.12,0,1,1,30,52.32a6.11,6.11,0,0,1,6.12,6.12"})]})}),g=window.wp.apiFetch,_=r.n(g),P=window.wp.url,m=function(e){void 0===e&&(e=null);var t="";(null==e?void 0:e.children)&&(t=e.children);var r="content-helper-error-message";return(null==e?void 0:e.className)&&(r+=" "+e.className),(0,o.jsx)("div",{className:r,"data-testid":null==e?void 0:e.testId,dangerouslySetInnerHTML:{__html:t}})},b=(e=function(t,r){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},e(t,r)},function(t,r){if("function"!=typeof r&&null!==r)throw new TypeError("Class extends value "+String(r)+" is not a constructor or null");function __(){this.constructor=t}e(t,r),t.prototype=null===r?Object.create(r):(__.prototype=r.prototype,new __)});!function(e){e.CannotFormulateApiQuery="ch_cannot_formulate_api_query",e.FetchError="fetch_error",e.HttpRequestFailed="http_request_failed",e.ParselyAborted="ch_parsely_aborted",e[e.ParselyApiForbidden=403]="ParselyApiForbidden",e.ParselyApiResponseContainsError="ch_response_contains_error",e.ParselyApiReturnedNoData="ch_parsely_api_returned_no_data",e.ParselyApiReturnedTooManyResults="ch_parsely_api_returned_too_many_results",e.PluginCredentialsNotSetMessageDetected="parsely_credentials_not_set_message_detected",e.PluginSettingsApiSecretNotSet="parsely_api_secret_not_set",e.PluginSettingsSiteIdNotSet="parsely_site_id_not_set",e.PostIsNotPublished="ch_post_not_published",e.ParselySuggestionsApiAuthUnavailable="AUTH_UNAVAILABLE",e.ParselySuggestionsApiNoAuthentication="NO_AUTHENTICATION",e.ParselySuggestionsApiNoAuthorization="NO_AUTHORIZATION",e.ParselySuggestionsApiNoData="NO_DATA",e.ParselySuggestionsApiOpenAiError="OPENAI_ERROR",e.ParselySuggestionsApiOpenAiSchema="OPENAI_SCHEMA",e.ParselySuggestionsApiOpenAiUnavailable="OPENAI_UNAVAILABLE",e.ParselySuggestionsApiSchemaError="SCHEMA_ERROR"}(t||(t={}));var x=function(e){function r(n,a,s){void 0===s&&(s=(0,u.__)("Error: ","wp-parsely"));var o=e.call(this,s+n)||this;o.hint=null,o.name=o.constructor.name,o.code=a;var i=[t.ParselyApiForbidden,t.ParselyApiResponseContainsError,t.ParselyApiReturnedNoData,t.ParselyApiReturnedTooManyResults,t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsApiSecretNotSet,t.PluginSettingsSiteIdNotSet,t.PostIsNotPublished,t.ParselySuggestionsApiAuthUnavailable,t.ParselySuggestionsApiNoAuthentication,t.ParselySuggestionsApiNoAuthorization,t.ParselySuggestionsApiNoData,t.ParselySuggestionsApiSchemaError];return o.retryFetch=!i.includes(o.code),Object.setPrototypeOf(o,r.prototype),o.code===t.ParselySuggestionsApiNoAuthorization?o.message=(0,u.__)('This AI-powered feature is opt-in. To gain access, please submit a request here.',"wp-parsely"):o.code===t.ParselySuggestionsApiOpenAiError||o.code===t.ParselySuggestionsApiOpenAiUnavailable?o.message=(0,u.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):o.code===t.HttpRequestFailed&&o.message.includes("cURL error 28")?o.message=(0,u.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):o.code===t.ParselySuggestionsApiSchemaError?o.message=(0,u.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):o.code===t.ParselySuggestionsApiNoData?o.message=(0,u.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):o.code===t.ParselySuggestionsApiOpenAiSchema?o.message=(0,u.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):o.code===t.ParselySuggestionsApiAuthUnavailable&&(o.message=(0,u.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),o}return b(r,e),r.prototype.Message=function(e){return void 0===e&&(e=null),[t.PluginCredentialsNotSetMessageDetected,t.PluginSettingsSiteIdNotSet,t.PluginSettingsApiSecretNotSet].includes(this.code)?function(e){var t;return void 0===e&&(e=null),(0,o.jsx)(m,{className:null==e?void 0:e.className,testId:"empty-credentials-message",children:null!==(t=window.wpParselyEmptyCredentialsMessage)&&void 0!==t?t:(0,u.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely")})}(e):(this.code===t.FetchError&&(this.hint=this.Hint((0,u.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==t.ParselyApiForbidden&&this.code!==t.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,u.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===t.HttpRequestFailed&&(this.hint=this.Hint((0,u.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,o.jsx)(m,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

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

".concat(this.message,"

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

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

")},r}(Error),A=function(){function e(){}return e.prototype.generateExcerpt=function(e,r){return n=this,a=void 0,o=function(){var n,a,s;return function(e,t){var r,n,a,s,o={label:0,sent:function(){if(1&a[0])throw a[1];return a[1]},trys:[],ops:[]};return s={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function i(i){return function(l){return function(i){if(r)throw new TypeError("Generator is already executing.");for(;s&&(s=0,i[0]&&(o=0)),o;)try{if(r=1,n&&(a=2&i[0]?n.return:i[0]?n.throw||((a=n.return)&&a.call(n),0):n.next)&&!(a=a.call(n,i[1])).done)return a;switch(n=0,a&&(i=[2&i[0],a.value]),i[0]){case 0:case 1:a=i;break;case 4:return o.label++,{value:i[1],done:!1};case 5:o.label++,n=i[1],i=[0];continue;case 7:i=o.ops.pop(),o.trys.pop();continue;default:if(!((a=(a=o.trys).length>0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0&&a[a.length-1])||6!==i[0]&&2!==i[0])){o=0;continue}if(3===i[0]&&(!a||i[1]>a[0]&&i[1]0,R=(0,d.count)(s||k,"words",{}),C=(0,u.sprintf)( +// Translators: %1$s the number of words in the excerpt. // Translators: %1$s the number of words in the excerpt. (0,u._n)("%1$s word","%1$s words",R,"wp-parsely"),R);return(0,p.useEffect)((function(){var e=document.querySelector(".editor-post-excerpt textarea");e&&(e.scrollTop=0)}),[s]),(0,o.jsxs)("div",{className:"editor-post-excerpt",children:[(0,o.jsxs)("div",{style:{position:"relative"},children:[t&&(0,o.jsx)("div",{className:"editor-post-excerpt__loading_animation",children:(0,o.jsx)(T,{})}),(0,o.jsx)(i.TextareaControl,{__nextHasNoMarginBottom:!0,label:(0,u.__)("Write an excerpt (optional)","wp-parsely"),className:"editor-post-excerpt__textarea",onChange:function(e){return b({excerpt:e})},readOnly:t||O,value:t?"":O?s:k,help:R?C:null})]}),(0,o.jsxs)(i.Button,{href:(0,u.__)("https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt","wp-parsely"),target:"_blank",variant:"link",children:[(0,u.__)("Learn more about manual excerpts","wp-parsely"),(0,o.jsx)(i.Icon,{icon:f,size:18,className:"parsely-external-link-icon"})]}),(0,o.jsxs)("div",{className:"wp-parsely-excerpt-generator",children:[(0,o.jsxs)("div",{className:"wp-parsely-excerpt-generator-header",children:[(0,o.jsx)(v,{size:16}),(0,o.jsxs)("div",{className:"wp-parsely-excerpt-generator-header-label",children:[(0,u.__)("Generate With Parse.ly","wp-parsely"),(0,o.jsx)("span",{className:"beta-label",children:(0,u.__)("Beta","wp-parsely")})]})]}),P&&(0,o.jsx)(i.Notice,{status:"info",className:"wp-parsely-excerpt-generator-error",children:P.Message()}),(0,o.jsx)("div",{className:"wp-parsely-excerpt-generator-controls",children:O?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(i.Button,{variant:"secondary",onClick:function(){return E(void 0,void 0,void 0,(function(){return S(this,(function(e){switch(e.label){case 0:return[4,b({excerpt:s})];case 1:return e.sent(),l(""),w.trackEvent("excerpt_generator_accepted"),[2]}}))}))},children:(0,u.__)("Accept","wp-parsely")}),(0,o.jsx)(i.Button,{isDestructive:!0,variant:"secondary",onClick:function(){return E(void 0,void 0,void 0,(function(){return S(this,(function(e){return l(""),w.trackEvent("excerpt_generator_discarded"),[2]}))}))},children:(0,u.__)("Discard","wp-parsely")})]}):(0,o.jsxs)(i.Button,{onClick:function(){return E(void 0,void 0,void 0,(function(){var e,t;return S(this,(function(n){switch(n.label){case 0:r(!0),m(void 0),n.label=1;case 1:return n.trys.push([1,3,4,5]),w.trackEvent("excerpt_generator_pressed"),[4,x.generateExcerpt(j,I)];case 2:return e=n.sent(),l(e),g(h+1),[3,5];case 3:return t=n.sent(),m(t),[3,5];case 4:return r(!1),[7];case 5:return[2]}}))}))},variant:"primary",isBusy:t,disabled:t,children:[t&&(0,u.__)("Generating Excerpt…","wp-parsely"),!t&&h>0&&(0,u.__)("Regenerate Excerpt","wp-parsely"),!t&&0===h&&(0,u.__)("Generate Excerpt","wp-parsely")]})}),(0,o.jsxs)(i.Button,{href:"https://docs.parse.ly/plugin-content-helper/#h-excerpt-generator-beta",target:"_blank",variant:"link",children:[(0,u.__)("Learn more about Parse.ly AI","wp-parsely"),(0,o.jsx)(i.Icon,{icon:f,size:18,className:"parsely-external-link-icon"})]})]})]})},T=function(){return(0,o.jsx)(i.Animate,{type:"loading",children:function(e){var t=e.className;return(0,o.jsx)("span",{className:t,children:(0,u.__)("Generating…","wp-parsely")})}})},k=function(){return(0,o.jsx)(c.PostTypeSupportCheck,{supportKeys:"excerpt",children:(0,o.jsx)(l.PluginDocumentSettingPanel,{name:"parsely-post-excerpt",title:"Excerpt",children:(0,o.jsx)(N,{})})})};(0,a.addFilter)("plugins.registerPlugin","wp-parsely-excerpt-generator",(function(e,t){var r,o,i,l;return"wp-parsely-block-editor-sidebar"!==t||((null===(r=null===window||void 0===window?void 0:window.Jetpack_Editor_Initial_State)||void 0===r?void 0:r.available_blocks["ai-content-lens"])&&(console.log("Parse.ly: Jetpack AI is enabled and will be disabled."),(0,a.removeFilter)("blocks.registerBlockType","jetpack/ai-content-lens-features")),(0,s.registerPlugin)("wp-parsely-excerpt-generator",{render:k}),(null===(o=(0,n.dispatch)("core/editor"))||void 0===o?void 0:o.removeEditorPanel)?null===(i=(0,n.dispatch)("core/editor"))||void 0===i||i.removeEditorPanel("post-excerpt"):null===(l=(0,n.dispatch)("core/edit-post"))||void 0===l||l.removeEditorPanel("post-excerpt")),e}),1e3)}()}(); \ No newline at end of file diff --git a/build/recommended-widget.asset.php b/build/recommended-widget.asset.php index f998b6b9f..b00da9edb 100644 --- a/build/recommended-widget.asset.php +++ b/build/recommended-widget.asset.php @@ -1 +1 @@ - array('wp-dom-ready'), 'version' => '57af74a55f7864233c8f'); + array('wp-dom-ready'), 'version' => 'd31a14a294140e99fc99'); diff --git a/build/recommended-widget.css b/build/recommended-widget.css index 42de09dcc..c656f7e04 100644 --- a/build/recommended-widget.css +++ b/build/recommended-widget.css @@ -1 +1 @@ -.parsely-recommended-widget,.parsely-recommended-widget *{box-sizing:border-box}.parsely-recommended-widget{display:block;width:100%}.parsely-recommended-widget-hidden{display:none}.parsely-recommended-widget-entry a{padding:0}.parsely-recommended-widget-entry img{float:left;margin-right:15px}.parsely-recommended-widget-entry:after{clear:both;content:"";display:table}.parsely-author{display:block;margin-top:5px}.parsely-recommended-widget-title{font-size:1.1em;font-weight:700}.list-horizontal .parsely-recommended-widget-entry{border:none;display:inline-block;margin-bottom:15px;margin-right:15px;max-width:215px;min-width:142.5px;padding:0;vertical-align:text-top;width:45%}.list-horizontal .parsely-recommended-widget-entry img{float:none;margin-right:0;max-width:100%}@supports(display:grid){.parsely-recommended-widget-entry:after{clear:none;display:none}.display-thumbnail .parsely-recommended-widget{grid-gap:15px;display:grid;grid-template-columns:minmax(85px,auto) minmax(50%,auto);grid-template-rows:auto}.list-horizontal .parsely-recommended-widget-entry{border:none;display:block;margin:0;max-width:none;min-width:auto;padding:0;vertical-align:initial;width:auto}.display-thumbnail:not(.list-horizontal) .parsely-recommended-widget-entry{display:contents}.parsely-recommendation-widget:not(.list-horizontal) .parsely-recommended-widget-entry img{float:none;margin-right:0;max-width:100%}.list-horizontal .parsely-recommended-widget{grid-gap:15px;display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));grid-template-rows:auto}} +.parsely-recommended-widget,.parsely-recommended-widget *{box-sizing:border-box}.parsely-recommended-widget{display:block;width:100%}.parsely-recommended-widget-hidden{display:none}.parsely-recommended-widget-entry a{padding:0}.parsely-recommended-widget-entry img{float:left;margin-right:15px}.parsely-recommended-widget-entry:after{clear:both;content:"";display:table}.parsely-author{display:block;margin-top:5px}.parsely-recommended-widget-title{font-size:1.1em;font-weight:700}.list-horizontal .parsely-recommended-widget-entry{border:none;display:inline-block;margin-bottom:15px;margin-right:15px;max-width:215px;min-width:142.5px;padding:0;vertical-align:text-top;width:45%}.list-horizontal .parsely-recommended-widget-entry img{float:none;margin-right:0;max-width:100%}@supports(display:grid){.parsely-recommended-widget-entry:after{clear:none;display:none}.display-thumbnail .parsely-recommended-widget{display:grid;grid-template-rows:auto;grid-gap:15px;grid-template-columns:minmax(85px,auto) minmax(50%,auto)}.list-horizontal .parsely-recommended-widget-entry{border:none;display:block;margin:0;max-width:none;min-width:auto;padding:0;vertical-align:initial;width:auto}.display-thumbnail:not(.list-horizontal) .parsely-recommended-widget-entry{display:contents}.parsely-recommendation-widget:not(.list-horizontal) .parsely-recommended-widget-entry img{float:none;margin-right:0;max-width:100%}.list-horizontal .parsely-recommended-widget{display:grid;grid-template-rows:auto;grid-gap:15px;grid-template-columns:repeat(auto-fill,minmax(150px,1fr))}} diff --git a/build/telemetry.asset.php b/build/telemetry.asset.php index 2d23ff083..d56f85e35 100644 --- a/build/telemetry.asset.php +++ b/build/telemetry.asset.php @@ -1 +1 @@ - array('wp-data', 'wp-element', 'wp-plugins'), 'version' => '8d53e0f5435bd20c6d07'); + array('wp-data', 'wp-element', 'wp-plugins'), 'version' => '86acff61b67acfaabbe2'); diff --git a/build/telemetry.js b/build/telemetry.js index bb526c368..a55a32e0a 100644 --- a/build/telemetry.js +++ b/build/telemetry.js @@ -1 +1 @@ -!function(){var e={705:function(e,t,n){var r=n(639).Symbol;e.exports=r},239:function(e,t,n){var r=n(705),o=n(607),i=n(436),a=r?r.toStringTag:void 0;e.exports=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":a&&a in Object(e)?o(e):i(e)}},561:function(e,t,n){var r=n(990),o=/^\s+/;e.exports=function(e){return e?e.slice(0,r(e)+1).replace(o,""):e}},957:function(e,t,n){var r="object"==typeof n.g&&n.g&&n.g.Object===Object&&n.g;e.exports=r},607:function(e,t,n){var r=n(705),o=Object.prototype,i=o.hasOwnProperty,a=o.toString,c=r?r.toStringTag:void 0;e.exports=function(e){var t=i.call(e,c),n=e[c];try{e[c]=void 0;var r=!0}catch(e){}var o=a.call(e);return r&&(t?e[c]=n:delete e[c]),o}},436:function(e){var t=Object.prototype.toString;e.exports=function(e){return t.call(e)}},639:function(e,t,n){var r=n(957),o="object"==typeof self&&self&&self.Object===Object&&self,i=r||o||Function("return this")();e.exports=i},990:function(e){var t=/\s/;e.exports=function(e){for(var n=e.length;n--&&t.test(e.charAt(n)););return n}},279:function(e,t,n){var r=n(218),o=n(771),i=n(841),a=Math.max,c=Math.min;e.exports=function(e,t,n){var u,l,s,f,p,d,v=0,y=!1,b=!1,h=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function w(t){var n=u,r=l;return u=l=void 0,v=t,f=e.apply(r,n)}function m(e){var n=e-d;return void 0===d||n>=t||n<0||b&&e-v>=s}function E(){var e=o();if(m(e))return g(e);p=setTimeout(E,function(e){var n=t-(e-d);return b?c(n,s-(e-v)):n}(e))}function g(e){return p=void 0,h&&u?w(e):(u=l=void 0,f)}function T(){var e=o(),n=m(e);if(u=arguments,l=this,d=e,n){if(void 0===p)return function(e){return v=e,p=setTimeout(E,t),y?w(e):f}(d);if(b)return clearTimeout(p),p=setTimeout(E,t),w(d)}return void 0===p&&(p=setTimeout(E,t)),f}return t=i(t)||0,r(n)&&(y=!!n.leading,s=(b="maxWait"in n)?a(i(n.maxWait)||0,t):s,h="trailing"in n?!!n.trailing:h),T.cancel=function(){void 0!==p&&clearTimeout(p),v=0,u=d=l=p=void 0},T.flush=function(){return void 0===p?f:g(o())},T}},218:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},5:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},448:function(e,t,n){var r=n(239),o=n(5);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},771:function(e,t,n){var r=n(639);e.exports=function(){return r.Date.now()}},841:function(e,t,n){var r=n(561),o=n(218),i=n(448),a=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=c.test(e);return n||u.test(e)?l(e.slice(2),n?2:8):a.test(e)?NaN:+e}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.element,t=window.wp.plugins,r=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,i=function(t,n){var r;return void 0===n&&(n={}),function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]=1e4&&(clearInterval(i),n("Telemetry library not loaded"))}),100);else n("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,n){var r;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(n=this.prepareProperties(n),null===(r=this._tkq)||void 0===r||r.push(["recordEvent",t,n])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,n={};return Object.keys(e).forEach((function(r){t.isProprietyValid(r)&&(n[r]=e[r])})),n},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),o=(r.trackEvent,window.wp.data),i=n(279),a=n.n(i);if(r.getInstance().isTelemetryEnabled()){var c=[function(){var t="wp-parsely/";return(0,e.useEffect)((function(){var e,n,i,c,u;return(n=void 0,i=void 0,c=void 0,u=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]0)&&(t(),e())}))}))]}))},new(c||(c=Promise))((function(e,t){function r(e){try{a(u.next(e))}catch(e){t(e)}}function o(e){try{a(u.throw(e))}catch(e){t(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof c?n:new c((function(e){e(n)}))).then(r,o)}a((u=u.apply(n,i||[])).next())}))).then((function(){var n=(0,o.select)("core/block-editor").getBlocks(),i=a()((function(){var e=(0,o.select)("core/block-editor").getBlocks(),i=e.map((function(e){return e.clientId})),a=n.map((function(e){return e.clientId}));e.filter((function(e){return!a.includes(e.clientId)})).forEach((function(e){e.name.startsWith(t)&&r.trackEvent("block_added",{block:e.name})})),a.filter((function(e){return!i.includes(e)})).forEach((function(e){var o=n.find((function(t){return t.clientId===e}));o&&o.name.startsWith(t)&&r.trackEvent("block_removed",{block:o.name})})),n=e}),1e3);return e=(0,o.subscribe)(i,"core/block-editor")})),function(){e&&e()}}),[]),null}],u=e.createElement.apply(void 0,function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o=t||n<0||b&&e-v>=s}function E(){var e=o();if(m(e))return g(e);p=setTimeout(E,function(e){var n=t-(e-d);return b?c(n,s-(e-v)):n}(e))}function g(e){return p=void 0,h&&u?w(e):(u=l=void 0,f)}function T(){var e=o(),n=m(e);if(u=arguments,l=this,d=e,n){if(void 0===p)return function(e){return v=e,p=setTimeout(E,t),y?w(e):f}(d);if(b)return clearTimeout(p),p=setTimeout(E,t),w(d)}return void 0===p&&(p=setTimeout(E,t)),f}return t=i(t)||0,r(n)&&(y=!!n.leading,s=(b="maxWait"in n)?a(i(n.maxWait)||0,t):s,h="trailing"in n?!!n.trailing:h),T.cancel=function(){void 0!==p&&clearTimeout(p),v=0,u=d=l=p=void 0},T.flush=function(){return void 0===p?f:g(o())},T}},805:function(e){e.exports=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}},346:function(e){e.exports=function(e){return null!=e&&"object"==typeof e}},394:function(e,t,n){var r=n(552),o=n(346);e.exports=function(e){return"symbol"==typeof e||o(e)&&"[object Symbol]"==r(e)}},124:function(e,t,n){var r=n(325);e.exports=function(){return r.Date.now()}},374:function(e,t,n){var r=n(128),o=n(805),i=n(394),a=/^[-+]0x[0-9a-f]+$/i,c=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt;e.exports=function(e){if("number"==typeof e)return e;if(i(e))return NaN;if(o(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=o(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=r(e);var n=c.test(e);return n||u.test(e)?l(e.slice(2),n?2:8):a.test(e)?NaN:+e}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},function(){"use strict";var e=window.wp.element,t=window.wp.plugins,r=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,i=function(t,n){var r;return void 0===n&&(n={}),function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]=1e4&&(clearInterval(i),n("Telemetry library not loaded"))}),100);else n("Telemetry not enabled")}))},e.prototype.trackEvent=function(t,n){var r;this.isLoaded?(0!==t.indexOf(e.TRACKS_PREFIX)&&(t=e.TRACKS_PREFIX+t),this.isEventNameValid(t)?(n=this.prepareProperties(n),null===(r=this._tkq)||void 0===r||r.push(["recordEvent",t,n])):console.error("Error tracking event: Invalid event name")):console.error("Error tracking event: Telemetry not loaded")},e.prototype.isTelemetryEnabled=function(){return this.isEnabled},e.prototype.isProprietyValid=function(t){return e.PROPERTY_REGEX.test(t)},e.prototype.isEventNameValid=function(t){return e.EVENT_NAME_REGEX.test(t)},e.prototype.prepareProperties=function(e){return(e=this.sanitizeProperties(e)).parsely_version=wpParselyTracksTelemetry.version,wpParselyTracksTelemetry.user&&(e._ut=wpParselyTracksTelemetry.user.type,e._ui=wpParselyTracksTelemetry.user.id),wpParselyTracksTelemetry.vipgo_env&&(e.vipgo_env=wpParselyTracksTelemetry.vipgo_env),this.sanitizeProperties(e)},e.prototype.sanitizeProperties=function(e){var t=this,n={};return Object.keys(e).forEach((function(r){t.isProprietyValid(r)&&(n[r]=e[r])})),n},e.TRACKS_PREFIX="wpparsely_",e.EVENT_NAME_REGEX=/^(([a-z0-9]+)_){2}([a-z0-9_]+)$/,e.PROPERTY_REGEX=/^[a-z_][a-z0-9_]*$/,e}(),o=(r.trackEvent,window.wp.data),i=n(602),a=n.n(i);if(r.getInstance().isTelemetryEnabled()){var c=[function(){var t="wp-parsely/";return(0,e.useEffect)((function(){var e,n,i,c,u;return(n=void 0,i=void 0,c=void 0,u=function(){return function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(u){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]0)&&(t(),e())}))}))]}))},new(c||(c=Promise))((function(e,t){function r(e){try{a(u.next(e))}catch(e){t(e)}}function o(e){try{a(u.throw(e))}catch(e){t(e)}}function a(t){var n;t.done?e(t.value):(n=t.value,n instanceof c?n:new c((function(e){e(n)}))).then(r,o)}a((u=u.apply(n,i||[])).next())}))).then((function(){var n=(0,o.select)("core/block-editor").getBlocks(),i=a()((function(){var e=(0,o.select)("core/block-editor").getBlocks(),i=e.map((function(e){return e.clientId})),a=n.map((function(e){return e.clientId}));e.filter((function(e){return!a.includes(e.clientId)})).forEach((function(e){e.name.startsWith(t)&&r.trackEvent("block_added",{block:e.name})})),a.filter((function(e){return!i.includes(e)})).forEach((function(e){var o=n.find((function(t){return t.clientId===e}));o&&o.name.startsWith(t)&&r.trackEvent("block_removed",{block:o.name})})),n=e}),1e3);return e=(0,o.subscribe)(i,"core/block-editor")})),function(){e&&e()}}),[]),null}],u=e.createElement.apply(void 0,function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o - { - setNumAddedLinks( ( num ) => num + 1 ); - } } - onClose={ () => { - setIsReviewDone( true ); - setIsReviewModalOpen( false ); - - if ( getSmartLinksFn().length > 0 ) { - setIsManageButtonVisible( true ); - } else { - setIsManageButtonVisible( false ); - } - } } - /> + { isReviewModalOpen && ( + { + setNumAddedLinks( ( num ) => num + 1 ); + } } + onClose={ () => { + setIsReviewDone( true ); + setIsReviewModalOpen( false ); + + if ( getSmartLinksFn().length > 0 ) { + setIsManageButtonVisible( true ); + } else { + setIsManageButtonVisible( false ); + } + } } + /> + ) } ); }; From a39561c13fc69705f32f53849bd5f276866b5955 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Mon, 13 May 2024 12:53:08 +0100 Subject: [PATCH 15/44] Implement getting existing smart links to populate the modal --- .../smart-linking/component.tsx | 68 ++++++---- .../review-modal/component-suggestion.tsx | 28 ++++- .../smart-linking/smart-linking.scss | 1 + .../smart-linking/smart-linking.tsx | 4 + .../editor-sidebar/smart-linking/store.ts | 29 ++++- .../editor-sidebar/smart-linking/utils.ts | 119 +++++++++++++++++- 6 files changed, 220 insertions(+), 29 deletions(-) diff --git a/src/content-helper/editor-sidebar/smart-linking/component.tsx b/src/content-helper/editor-sidebar/smart-linking/component.tsx index 9d5e84824..826628bba 100644 --- a/src/content-helper/editor-sidebar/smart-linking/component.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/component.tsx @@ -6,7 +6,7 @@ import { BlockInstance, getBlockContent } from '@wordpress/blocks'; import { Button, Notice, PanelRow } from '@wordpress/components'; import { useDebounce } from '@wordpress/compose'; import { dispatch, useDispatch, useSelect } from '@wordpress/data'; -import { useEffect, useState } from '@wordpress/element'; +import { useEffect, useMemo, useState } from '@wordpress/element'; import { __, _n, sprintf } from '@wordpress/i18n'; import { Icon, external } from '@wordpress/icons'; @@ -22,7 +22,7 @@ import { SmartLinkingReviewModal } from './review-modal/component-modal'; import { SmartLinkingSettings as SmartLinkingSettingsComponent } from './component-settings'; import { SmartLink, SmartLinkingProvider } from './provider'; import { ApplyToOptions, SmartLinkingSettingsProps, SmartLinkingStore } from './store'; -import { escapeRegExp, findTextNodesNotInAnchor } from './utils'; +import { escapeRegExp, findTextNodesNotInAnchor, getAllSmartLinksInPost } from './utils'; /** * Represents the counts of occurrences and applications of links within text content. @@ -92,30 +92,13 @@ export const SmartLinkingPanel = ( { const { createNotice } = useDispatch( 'core/notices' ); - /** - * Handles the ending of the review process. - */ - useEffect( () => { - if ( ! isReviewDone ) { - setNumAddedLinks( 0 ); - } else if ( numAddedLinks > 0 ) { - createNotice( - 'success', - /* translators: %d: number of smart links applied */ - sprintf( __( '%s smart links successfully applied.', 'wp-parsely' ), numAddedLinks ), - { - type: 'snackbar', - }, - ); - } - }, [ isReviewDone ] ); // eslint-disable-line react-hooks/exhaustive-deps - /** * Loads the Smart Linking store. * * @since 3.14.0 */ const { + ready, loading, isFullContent, overlayBlocks, @@ -131,6 +114,7 @@ export const SmartLinkingPanel = ( { getSmartLinksFn, } = useSelect( ( selectFn ) => { const { + isReady, isLoading, getOverlayBlocks, getSuggestedLinks, @@ -146,6 +130,7 @@ export const SmartLinkingPanel = ( { getSmartLinks, } = selectFn( SmartLinkingStore ); return { + ready: isReady(), loading: isLoading(), error: getError(), maxLinks: getMaxLinks(), @@ -162,12 +147,15 @@ export const SmartLinkingPanel = ( { }; }, [] ); + const appliedLinks = useMemo( () => smartLinks.filter( ( link ) => link.applied ), [ smartLinks ] ); + /** * Loads the Smart Linking store actions. * * @since 3.14.0 */ const { + setIsReady, setLoading, setError, addSmartLinks, @@ -182,6 +170,37 @@ export const SmartLinkingPanel = ( { purgeSmartLinksSuggestions, } = useDispatch( SmartLinkingStore ); + /** + * Handles the initialization of the Smart Linking existing links. + * + * @since 3.15.0 + */ + useEffect( () => { + if ( ! ready ) { + const existingSmartLinks = getAllSmartLinksInPost(); + addSmartLinks( existingSmartLinks ); + setIsReady( true ); + } + }, [ ready, setIsReady ] ); + + /** + * Handles the ending of the review process. + */ + useEffect( () => { + if ( ! isReviewDone ) { + setNumAddedLinks( 0 ); + } else if ( numAddedLinks > 0 ) { + createNotice( + 'success', + /* translators: %d: number of smart links applied */ + sprintf( __( '%s smart links successfully applied.', 'wp-parsely' ), numAddedLinks ), + { + type: 'snackbar', + }, + ); + } + }, [ isReviewDone ] ); // eslint-disable-line react-hooks/exhaustive-deps + /** * Handles the change of a setting. * @@ -614,10 +633,15 @@ export const SmartLinkingPanel = ( { { getGenerateButtonMessage() } - { isManageButtonVisible && ( + { appliedLinks.length > 0 && (
+ + +
{ ! isApplied && ( <> - - + + + + + + ) } { isApplied && ( <> - + + + ) }
- + + +
); From 0aeffc45d7a9b77f39d2e2229894331629650cc1 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Mon, 20 May 2024 10:26:12 +0100 Subject: [PATCH 22/44] Clean-up code and documentation --- .../smart-linking/component-link-monitor.tsx | 55 +++++- .../smart-linking/component.tsx | 31 ++- .../editor-sidebar/smart-linking/hooks.ts | 11 +- .../editor-sidebar/smart-linking/provider.ts | 180 +----------------- .../review-modal/component-modal.tsx | 82 +++++--- .../review-modal/component-sidebar.tsx | 17 ++ .../review-modal/component-suggestion.tsx | 152 +++++++++++---- .../editor-sidebar/smart-linking/store.ts | 40 +++- 8 files changed, 312 insertions(+), 256 deletions(-) diff --git a/src/content-helper/editor-sidebar/smart-linking/component-link-monitor.tsx b/src/content-helper/editor-sidebar/smart-linking/component-link-monitor.tsx index 4e881529f..e9d820e1e 100644 --- a/src/content-helper/editor-sidebar/smart-linking/component-link-monitor.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/component-link-monitor.tsx @@ -1,9 +1,22 @@ +/** + * WordPress dependencies + */ +// eslint-disable-next-line import/named import { BlockInstance } from '@wordpress/blocks'; import { useEffect, useRef } from '@wordpress/element'; import { useSelect } from '@wordpress/data'; -import { GutenbergFunction } from '../../../@types/gutenberg/types'; import { debounce } from '@wordpress/compose'; +/** + * Internal dependencies + */ +import { GutenbergFunction } from '../../../@types/gutenberg/types'; + +/** + * Defines the structure of a block change. + * + * @since 3.16.0 + */ type BlockChange = { block: BlockInstance; prevBlock: BlockInstance; @@ -12,7 +25,18 @@ type BlockChange = { changedLinks: HTMLAnchorElement[]; }; -// Function to check blocks and detect changes +/** + * Checks for changes in the blocks and calls the appropriate callback functions. + * + * The function compares the current blocks with the previous blocks and detects changes in the smart links. + * + * @since 3.16.0 + * + * @param {BlockInstance[]} currentBlocks The current blocks. + * @param {BlockInstance[]} previousBlocks The previous blocks. + * + * @return {BlockChange[]} The list of changes detected. + */ const checkBlocks = ( currentBlocks: BlockInstance[], previousBlocks: BlockInstance[] @@ -27,7 +51,7 @@ const checkBlocks = ( return; } - // Check inner blocks recursively + // Check inner blocks recursively. if ( block.innerBlocks.length > 0 ) { return traverseBlocks( block.innerBlocks, prevBlocks[ index ].innerBlocks ); } @@ -38,11 +62,11 @@ const checkBlocks = ( const blockDOM = domParser.parseFromString( block.attributes.content || '', 'text/html' ); const prevBlockDOM = domParser.parseFromString( prevBlock?.attributes.content || '', 'text/html' ); - // Get all smart links in the block and previous block + // Get all smart links in the block and previous block. const smartLinks = Array.from( blockDOM.querySelectorAll( 'a[data-smartlink]' ) ) as HTMLAnchorElement[]; const prevSmartLinks = Array.from( prevBlockDOM.querySelectorAll( 'a[data-smartlink]' ) ) as HTMLAnchorElement[]; - // Compare and make a list of added, removed, and changed smart links + // Compare and make a list of added, removed, and changed smart links. const addedLinks = smartLinks.filter( ( link ) => ! prevSmartLinks.some( ( prevLink ) => prevLink.dataset.smartlink === link.dataset.smartlink @@ -72,8 +96,18 @@ const checkBlocks = ( return changesDetected; }; +/** + * Defines the callback function for the block change. + * + * @since 3.16.0 + */ type onChangeCallback = ( change: BlockChange ) => void; +/** + * The LinkMonitor component props. + * + * @since 3.16.0 + */ type LinkMonitorProps = { isDetectingEnabled: boolean; onLinkChange?: onChangeCallback; @@ -82,6 +116,15 @@ type LinkMonitorProps = { debounceValue?: number; }; +/** + * The LinkMonitor component. + * + * This component monitors the changes in the blocks and detects the changes in the smart links. + * + * @since 3.16.0 + * + * @param {LinkMonitorProps} props The component props. + */ export const LinkMonitor = ( { isDetectingEnabled, onLinkChange, @@ -138,7 +181,7 @@ export const LinkMonitor = ( { return () => { debouncedCheckBlocks.cancel(); }; - }, [ blocks, isDetectingEnabled, onLinkAdd, onLinkChange, onLinkRemove ] ); + }, [ blocks, debounceValue, isDetectingEnabled, onLinkAdd, onLinkChange, onLinkRemove ] ); return null; }; diff --git a/src/content-helper/editor-sidebar/smart-linking/component.tsx b/src/content-helper/editor-sidebar/smart-linking/component.tsx index 1f672bcf5..a7c1437e7 100644 --- a/src/content-helper/editor-sidebar/smart-linking/component.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/component.tsx @@ -18,7 +18,7 @@ import { ContentHelperErrorCode } from '../../common/content-helper-error'; import { SidebarSettings, SmartLinkingSettings, useSettings } from '../../common/settings'; import { generateProtocolVariants } from '../../common/utils/functions'; import { LinkMonitor } from './component-link-monitor'; -import { useAfterSave, useValidateSmartLinksBeforeSave } from './hooks'; +import { useValidateSmartLinksBeforeSave } from './hooks'; import { SmartLinkingReviewModal } from './review-modal/component-modal'; import { SmartLinkingSettings as SmartLinkingSettingsComponent } from './component-settings'; import { SmartLink, SmartLinkingProvider } from './provider'; @@ -113,8 +113,7 @@ export const SmartLinkingPanel = ( { getOverlayBlocks, getSuggestedLinks, getError, - // eslint-disable-next-line @typescript-eslint/no-shadow - isFullContent, + isFullContent, // eslint-disable-line @typescript-eslint/no-shadow getMaxLinks, getMaxLinkWords, getSmartLinkingSettings, @@ -141,6 +140,13 @@ export const SmartLinkingPanel = ( { }; }, [] ); + /** + * The filtered list of smart links that have been applied. + * + * This list is memoized to prevent unnecessary re-renders. + * + * @since 3.16.0 + */ const appliedLinks = useMemo( () => smartLinks.filter( ( link ) => link.applied ), [ smartLinks ] ); /** @@ -168,7 +174,7 @@ export const SmartLinkingPanel = ( { /** * Handles the initialization of the Smart Linking existing links. * - * @since 3.15.0 + * @since 3.16.0 */ useEffect( () => { if ( ! ready ) { @@ -181,6 +187,9 @@ export const SmartLinkingPanel = ( { /** * Handles the ending of the review process. + * Shows a success notice if the review is done and there are added links. + * + * @since 3.16.0 */ useEffect( () => { if ( ! isReviewDone ) { @@ -273,6 +282,20 @@ export const SmartLinkingPanel = ( { [ selectedBlockClientId ], ); + /** + * Processes the smart links generated by the Smart Linking provider. + * + * The processing step are: + * - Exclude the links that have been applied already. + * - Strip the protocol and trailing slashes from the post permalink. + * - Filter out self-referencing links. + * - Calculate the smart links matches for each block. + * - Update the stored smart links with the new matches. + * + * @since 3.16.0 + * + * @param {SmartLink[]} links The smart links to process. + */ const processSmartLinks = async ( links: SmartLink[] ) => { // Exclude the links that have been applied already. links = links.filter( diff --git a/src/content-helper/editor-sidebar/smart-linking/hooks.ts b/src/content-helper/editor-sidebar/smart-linking/hooks.ts index 8faf2a77f..0b97819c5 100644 --- a/src/content-helper/editor-sidebar/smart-linking/hooks.ts +++ b/src/content-helper/editor-sidebar/smart-linking/hooks.ts @@ -1,8 +1,15 @@ +/** + * WordPress dependencies + */ import { useRef, useState, useEffect } from '@wordpress/element'; -import { dispatch, useDispatch, useSelect } from '@wordpress/data'; +import { dispatch, useSelect } from '@wordpress/data'; +import { store as editorStore } from '@wordpress/editor'; + +/** + * Internal dependencies + */ import { GutenbergFunction } from '../../../@types/gutenberg/types'; import { validateAndFixSmartLinksInPost } from './utils'; -import { store as editorStore } from '@wordpress/editor'; /** * Returns `true` if the post is done saving, `false` otherwise. diff --git a/src/content-helper/editor-sidebar/smart-linking/provider.ts b/src/content-helper/editor-sidebar/smart-linking/provider.ts index f66232837..9071bb11f 100644 --- a/src/content-helper/editor-sidebar/smart-linking/provider.ts +++ b/src/content-helper/editor-sidebar/smart-linking/provider.ts @@ -82,179 +82,6 @@ export class SmartLinkingProvider extends BaseProvider { maxLinksPerPost: number = DEFAULT_MAX_LINKS, urlExclusionList: string[] = [], ): Promise { - /*return [ - { - uid: '3ba4e35e2eca3002207b63fac3c0911b', - href: 'http:\/\/wpvip.com\/2021\/12\/23\/secure-wordpress-hosting\/', - title: 'a guide to choosing the most secure wordpress hosting', - text: 'WordPress Enterprise', - offset: 0, - }, - { - uid: '883f036bec79f24dc79ca9c75d7bb2e9', - href: 'http:\/\/wpvip.com\/2023\/02\/16\/wordpress-org-vs-wordpress-com-vs-wordpress-vip-whats-the-difference\/', - title: 'wordpress.org vs wordpress.com vs wordpress vip: what\u2019s the difference?', - text: 'VIP Experience', - offset: 0, - }, - { - uid: '5a61bc47559692a0ec91a15447430568', - href: 'http:\/\/wpvip.com\/2022\/06\/08\/wordpress-myths\/', - title: 'busting 10 myths about wordpress and wordpress vip', - text: 'Scalability', - offset: 0, - }, - { - uid: '83c8256011779fb29ea33b42251fb993', - href: 'http:\/\/wpvip.com\/2021\/05\/20\/wordpress-vip-is-fedramp-authorized\/', - title: 'wordpress vip is fedramp authorized', - text: 'Security', - offset: 0, - }, - ];*/ - /*return [ - { - uid: 'cf71c5c475bc7578013b7e6234832de4', - href: 'http:\/\/wpvip.com\/2023\/02\/16\/wordpress-org-vs-wordpress-com-vs-wordpress-vip-whats-the-difference\/', - title: 'wordpress.org vs wordpress.com vs wordpress vip: what\u2019s the difference?', - text: 'WordPress Enterprise', - offset: 0, - applied: false, - }, - { - uid: 'f16cb0363e8705c4d2e8f7c94412b192', - href: 'http:\/\/wpvip.com\/2023\/02\/16\/wordpress-org-vs-wordpress-com-vs-wordpress-vip-whats-the-difference\/', - title: 'wordpress.org vs wordpress.com vs wordpress vip: what\u2019s the difference?', - text: 'WordPress VIP', - offset: 1, - applied: false, - }, - { - uid: '8809b316cced142250c66d35d2681f1e', - href: 'http:\/\/wpvip.com\/2022\/06\/08\/wordpress-myths\/', - title: 'busting 10 myths about wordpress and wordpress vip', - text: 'scalability', - offset: 0, - applied: false, - }, - { - uid: '0ecd03591abebc70c1b9ee6a8110b9a3', - href: 'http:\/\/wpvip.com\/2021\/12\/23\/secure-wordpress-hosting\/', - title: 'a guide to choosing the most secure wordpress hosting', - text: 'custom development, security, scalability, and high performance', - offset: 0, - applied: false, - }, - ];*/ - /* - return [ - { - uid: '6e507388132fe7a97f2efac112ed2ebd', - href: 'http:\/\/wpvip.com\/2021\/12\/23\/secure-wordpress-hosting\/', - title: 'a guide to choosing the most secure wordpress hosting', - text: 'platform', - offset: 0, - applied: false, - }, - { - uid: 'db7a115cc2ef900f2c066a897db4cf28', - href: 'http:\/\/wpvip.com\/2021\/06\/14\/yet-another-top-tier-award-for-wordpress-vip-in-hosting-performance-review\/', - title: '\u201cyet another\u201d top tier award for wordpress vip in hosting performance review', - text: 'performance', - offset: 1, - applied: false, - }, - { - uid: '751b0938f1ecc0ae17f1bc196c42ba98', - href: 'http:\/\/wpvip.com\/2021\/09\/15\/six-questions-with-zephr-about-first-party-data-and-the-customer-journey\/', - title: 'six questions with zephr about first-party data and the customer journey', - text: 'performance', - offset: 0, - applied: false, - }, - ];*//* - return [ - { - uid: '06187a56038c3aa8242b0fb98a1b5e5b', - href: 'http:\/\/wpvip.com\/2023\/02\/16\/wordpress-org-vs-wordpress-com-vs-wordpress-vip-whats-the-difference\/', - title: 'wordpress.org vs wordpress.com vs wordpress vip: what\u2019s the difference?', - text: 'scalability', - offset: 1, - applied: false, - }, - { - uid: '9d96d7a99cb750296acfabf242be9aa9', - href: 'http:\/\/wpvip.com\/2021\/08\/19\/pros-and-cons-of-a-headless-cms\/', - title: 'headless wordpress: pros and cons of a headless cms', - text: 'content management', - offset: 0, - applied: false, - }, - { - uid: '56998f94ba8960d8ab61bf4e4647f0ce', - href: 'http:\/\/wpvip.com\/2019\/06\/19\/wordpress-vip-agency-partners\/', - title: 'vip expands featured agency partner program to meet increasing client demand', - text: 'WordPress VIP', - offset: 1, - applied: false, - }, - { - uid: '26654b91191cc0c89a2120c092904e1e', - href: 'http:\/\/wpvip.com\/2021\/05\/20\/wordpress-vip-is-fedramp-authorized\/', - title: 'wordpress vip is fedramp authorized', - text: 'WordPress VIP', - offset: 3, - applied: false, - }, - { - uid: '6375ed150e43196210ee0c9efce57ec8', - href: 'http:\/\/wpvip.com\/2021\/12\/23\/secure-wordpress-hosting\/', - title: 'a guide to choosing the most secure wordpress hosting', - text: 'WordPress Enterprise', - offset: 7, - applied: false, - }, - { - uid: '0b1219ad6028972533cce67e651b8924', - href: 'http:\/\/wpvip.com\/2022\/05\/12\/how-open-source-software-benefits-businesses\/', - title: 'how open source software benefits businesses', - text: 'security', - offset: 1, - applied: false, - }, - { - uid: '1538c3bbbbd2ddd456e4900fba08fe75', - href: 'http:\/\/wpvip.com\/2021\/07\/21\/gutenberg-full-site-editing\/', - title: 'gutenberg full-site editing is here\u2014what it means for enterprises', - text: 'custom development', - offset: 1, - applied: false, - }, - { - uid: '4c9a2d36627ec108fea34f6c54460803', - href: 'http:\/\/wpvip.com\/2020\/07\/30\/its-official-the-future-is-vip-go\/', - title: 'it\u2019s official: the future is vip go!', - text: 'WordPress VIP', - offset: 4, - applied: false, - }, - { - uid: 'aa08a8f855c8bba2b0a4a7654806b973', - href: 'http:\/\/wpvip.com\/2018\/01\/30\/wordpress-hosting-2018-fastest\/', - title: 'independent speed and performance analysis finds wordpress vip fastest among top tier hosts', - text: 'performance optimization', - offset: 1, - applied: false, - }, - { - uid: '02a78ae49d95f17677ec189ff1c94dbc', - href: 'http:\/\/wpvip.com\/2023\/01\/26\/analytics-wordpress\/', - title: 'use the best wordpress analytics plugin: parse.ly', - text: 'WordPress Enterprise', - offset: 5, - applied: false, - }, - ];*/ const response = await this.fetch( { method: 'POST', path: addQueryArgs( '/wp-parsely/v1/content-suggestions/suggest-linked-reference', { @@ -283,6 +110,13 @@ export class SmartLinkingProvider extends BaseProvider { return response; } + /** + * Get the post type of post by its URL. + * + * @param {string} url The URL of the post. + * + * @return {Promise} The post type of the post. + */ public async getPostTypeByURL( url: string ): Promise { const response = await this.fetch<{ post_type: string }>( { method: 'POST', diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx index df342fd52..547378575 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx @@ -1,23 +1,40 @@ +/** + * WordPress dependencies + */ // eslint-disable-next-line import/named import { BlockInstance, getBlockContent } from '@wordpress/blocks'; import { Button, KeyboardShortcuts, Modal } from '@wordpress/components'; import { dispatch, select, useDispatch, useSelect } from '@wordpress/data'; import { memo, useEffect, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; -import { GutenbergFunction } from '../../../../@types/gutenberg/types'; +/** + * Internal dependencies + */ import { SmartLink } from '../provider'; import { SmartLinkingStore } from '../store'; import { applyNodeToBlock } from '../utils'; import { ReviewModalSidebar } from './component-sidebar'; import { ReviewSuggestion } from './component-suggestion'; +/** + * The props for the SmartLinkingReviewModal component. + * + * @since 3.16.0 + */ export type SmartLinkingReviewModalProps = { onClose: () => void, isOpen: boolean, onAppliedLink: ( link: SmartLink ) => void, }; +/** + * The SmartLinkingReviewModal component displays a modal to review and apply smart links. + * + * @since 3.16.0 + * + * @param {SmartLinkingReviewModalProps} props The component props. + */ const SmartLinkingReviewModalComponent = ( { onClose, isOpen, @@ -26,17 +43,10 @@ const SmartLinkingReviewModalComponent = ( { const [ showCloseDialog, setShowCloseDialog ] = useState( false ); const [ isModalOpen, setIsModalOpen ] = useState( isOpen ); - const { postId } = useSelect( ( selectFn ) => { - const { getCurrentPostId } = selectFn( 'core/editor' ) as GutenbergFunction; - return { - postId: getCurrentPostId(), - }; - }, [] ); - /** * Loads the Smart Linking store selectors. * - * @since 3.15.0 + * @since 3.16.0 */ const { smartLinks, @@ -57,7 +67,7 @@ const SmartLinkingReviewModalComponent = ( { /** * Loads the Smart Linking store actions. * - * @since 3.15.0 + * @since 3.16.0 */ const { purgeSmartLinksSuggestions, @@ -68,7 +78,7 @@ const SmartLinkingReviewModalComponent = ( { /** * Sets the selected link when the suggested links change. * - * @since 3.15.0 + * @since 3.16.0 */ useEffect( () => { if ( isModalOpen && smartLinks.length === 0 ) { @@ -82,7 +92,7 @@ const SmartLinkingReviewModalComponent = ( { /** * Updates the modal state when the `isOpen` prop changes. * - * @since 3.15.0 + * @since 3.16.0 */ useEffect( () => { setIsModalOpen( isOpen ); @@ -91,7 +101,7 @@ const SmartLinkingReviewModalComponent = ( { /** * Applies the link to the block. * - * @since 3.15.0 + * @since 3.16.0 * * @param {string} blockId The block instance to apply the link to. * @param {SmartLink} linkSuggestion The link suggestion to apply. @@ -111,7 +121,7 @@ const SmartLinkingReviewModalComponent = ( { // Apply and updates the block content. applyNodeToBlock( block, linkSuggestion, anchor ); - // Update the smart link in the store + // Update the smart link in the store. linkSuggestion.applied = true; await updateSmartLink( linkSuggestion ); }; @@ -119,7 +129,7 @@ const SmartLinkingReviewModalComponent = ( { /** * Removes a Smart Link from a block, using the unique identifier. * - * @since 3.15.0 + * @since 3.16.0 * * @param {BlockInstance} block The block instance to remove the link from. * @param {SmartLink} linkSuggestion The link suggestion to remove. @@ -145,14 +155,14 @@ const SmartLinkingReviewModalComponent = ( { // Check if we found the anchor with the specified UID. if ( anchors.length > 0 ) { - const anchorToRemove = anchors[ 0 ]; // Assuming UID is unique and there's only one match. + const anchorToRemove = anchors[ 0 ]; const parentNode = anchorToRemove.parentNode; if ( parentNode ) { - // Replace the anchor with its text content + // Replace the anchor with its text content. const textNode = document.createTextNode( anchorToRemove.textContent ?? '' ); parentNode.replaceChild( textNode, anchorToRemove ); - // Update the block content + // Update the block content. dispatch( 'core/block-editor' ).updateBlockAttributes( blockId, { content: contentElement.innerHTML } ); } } @@ -167,7 +177,7 @@ const SmartLinkingReviewModalComponent = ( { * If there are any pending links, a confirmation dialog is shown. * When the modal is closed, any pending suggestions are purged. * - * @since 3.15.0 + * @since 3.16.0 */ const onCloseHandler = () => { // Hide the modal. @@ -188,7 +198,7 @@ const SmartLinkingReviewModalComponent = ( { * * If the user confirms the closing, the modal is closed. * - * @since 3.15.0 + * @since 3.16.0 * * @param {boolean} shouldClose Whether the modal should be closed. */ @@ -204,6 +214,11 @@ const SmartLinkingReviewModalComponent = ( { } }; + /** + * Handles the selection of the next smart link. + * + * @since 3.16.0 + */ const handleNext = () => { const currentIndex = smartLinks.indexOf( selectedLink ); const nextIndex = currentIndex + 1; @@ -215,6 +230,11 @@ const SmartLinkingReviewModalComponent = ( { setSelectedLink( smartLinks[ nextIndex ] ); }; + /** + * Handles the selection of the previous smart link. + * + * @since 3.16.0 + */ const handlePrevious = () => { const currentIndex = getSmartLinks().indexOf( selectedLink ); const previousIndex = currentIndex - 1; @@ -229,7 +249,7 @@ const SmartLinkingReviewModalComponent = ( { /** * Handles the acceptance of a smart link. * - * @since 3.15.0 + * @since 3.16.0 */ const onAcceptHandler = async () => { if ( ! selectedLink.match ) { @@ -248,7 +268,7 @@ const SmartLinkingReviewModalComponent = ( { const currentIndex = smartLinks.indexOf( selectedLink ); const nextIndex = currentIndex + 1; - // If there is a next link, select it, otherwise select the first link + // If there is a next link, select it, otherwise select the first link. if ( smartLinks[ nextIndex ] ) { setSelectedLink( smartLinks[ nextIndex ] ); } else { @@ -259,7 +279,7 @@ const SmartLinkingReviewModalComponent = ( { /** * Handles the rejection of a smart link. * - * @since 3.15.0 + * @since 3.16.0 */ const onRejectHandler = async () => { // Change to the next link. @@ -267,7 +287,7 @@ const SmartLinkingReviewModalComponent = ( { const nextIndex = currentIndex + 1; // Check if it exists. If not, try to go for the first one on the array. - // If there isn't any, close the modal + // If there isn't any, close the modal. if ( ! smartLinks[ nextIndex ] ) { if ( smartLinks[ 0 ] ) { setSelectedLink( smartLinks[ 0 ] ); @@ -284,7 +304,7 @@ const SmartLinkingReviewModalComponent = ( { /** * Handles the removal of a smart link. * - * @since 3.15.0 + * @since 3.16.0 */ const onRemoveHandler = async () => { if ( ! selectedLink.match ) { @@ -313,19 +333,20 @@ const SmartLinkingReviewModalComponent = ( { /** * Selects the link into the block editor. * - * @since 3.15.0 + * @since 3.16.0 */ const onSelectedInEditorHandler = () => { if ( ! selectedLink.match ) { return; } + // TODO const block = select( 'core/block-editor' ).getBlock( selectedLink.match.blockId ); if ( block ) { - // Select the block in the editor + // Select the block in the editor. dispatch( 'core/block-editor' ).selectBlock( block.clientId ); - // Close the modal + // Close the modal. onCloseHandler(); } }; @@ -410,4 +431,9 @@ const SmartLinkingReviewModalComponent = ( { ); }; +/** + * The SmartLinkingReviewModal component, memoized for performance. + * + * @since 3.16.0 + */ export const SmartLinkingReviewModal = memo( SmartLinkingReviewModalComponent ); diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx index 8fc056385..d38e53dcc 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-sidebar.tsx @@ -1,6 +1,13 @@ +/** + * WordPress dependencies + */ import { MenuItem } from '@wordpress/components'; import { useEffect, useRef } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; + +/** + * Internal dependencies + */ import { AiIcon } from '../../../common/icons/ai-icon'; import { SmartLink } from '../provider'; @@ -10,6 +17,13 @@ type ReviewModalSidebarProps = { setSelectedLink: ( link: SmartLink ) => void, }; +/** + * Sidebar component for the review modal. + * + * @since 3.16.0 + * + * @param {ReviewModalSidebarProps} props The component props. + */ export const ReviewModalSidebar = ( { activeLink, links, @@ -20,6 +34,8 @@ export const ReviewModalSidebar = ( { /** * Handles the scroll of the sidebar to the active link. + * + * @since 3.16.0 */ useEffect( () => { if ( activeLink ) { @@ -45,6 +61,7 @@ export const ReviewModalSidebar = ( { } } }, [ activeLink, links ] ); + const label = ( { __( 'NEW', 'wp-parsely' ) } diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx index e85145460..70f32b22b 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx @@ -1,3 +1,7 @@ +/** + * WordPress dependencies + */ +// eslint-disable-next-line import/named import { BlockInstance, cloneBlock, getBlockContent, getBlockType } from '@wordpress/blocks'; import { Button, @@ -11,15 +15,34 @@ import { useEffect, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { arrowLeft, arrowRight, check, closeSmall, Icon, page } from '@wordpress/icons'; import { filterURLForDisplay } from '@wordpress/url'; + +/** + * Internal dependencies + */ import { GutenbergFunction } from '../../../../@types/gutenberg/types'; import { SmartLink, SmartLinkingProvider } from '../provider'; import { BlockEditorProvider, BlockList } from '@wordpress/block-editor'; import { SmartLinkingStore } from '../store'; import { applyNodeToBlock } from '../utils'; +/** + * The props for the SuggestionBreadcrumb component. + * + * @since 3.16.0 + */ type SuggestionBreadcrumbProps = { link: SmartLink, }; + +/** + * Displays the breadcrumb for the suggestion. + * + * It shows the parent blocks of the block where the link is found. + * + * @since 3.16.0 + * + * @param {SuggestionBreadcrumbProps} props The component props. + */ const SuggestionBreadcrumb = ( { link }: SuggestionBreadcrumbProps ): JSX.Element => { const blockId = link.match?.blockId; @@ -66,6 +89,11 @@ const SuggestionBreadcrumb = ( { link }: SuggestionBreadcrumbProps ): JSX.Elemen ); }; +/** + * The props for the Styles component. + * + * @since 3.16.0 + */ type StylesProps = { styles: { css?: string, @@ -73,6 +101,16 @@ type StylesProps = { __unstableType?: string, }[], }; + +/** + * The Styles component, which renders the editor styles for the block preview. + * + * This component replaces the body selector with the block editor selector. + * + * @since 3.16.0 + * + * @param {StylesProps} props The component props. + */ const Styles = ( { styles }: StylesProps ): JSX.Element => { // Get onlt the theme and user styles. const filteredStyles = styles @@ -93,10 +131,23 @@ const Styles = ( { styles }: StylesProps ): JSX.Element => { ); }; +/** + * The props for the BlockPreview component. + * + * @since 3.16.0 + */ type BlockPreviewProps = { block: BlockInstance, link: SmartLink, } + +/** + * The BlockPreview component, which renders the block preview for the suggestion. + * + * @since 3.16.0 + * + * @param {BlockPreviewProps} props The component props. + */ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { const [ clonedBlock, setClonedBlock ] = useState( cloneBlock( block ) ); @@ -104,51 +155,17 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { * Runs when the block is updated. * It will update the cloned block with the new block. * - * @since 3.15.0 + * @since 3.16.0 */ useEffect( () => { setClonedBlock( cloneBlock( block ) ); }, [ block, link ] ); - /** - * Highlights the link in the block. - * - * @since 3.15.0 - * - * @param {BlockInstance} blockInstance The block instance to highlight the link in. - * @param {SmartLink} linkSuggestion The link suggestion to highlight. - */ - const highlightLinkInBlock = ( blockInstance: BlockInstance, linkSuggestion: SmartLink ) => { - // If the link is not applied, add a highlight with a new mark element. - if ( ! link.applied ) { - const mark = document.createElement( 'mark' ); - mark.className = 'smart-linking-highlight'; - blockInstance.attributes.content = applyNodeToBlock( blockInstance, linkSuggestion, mark ); - return; - } - - // Otherwise, if the link is applied, add a highlight class to the link element with the link uid - const blockContent: string = getBlockContent( blockInstance ); - - const doc = new DOMParser().parseFromString( blockContent, 'text/html' ); - const contentElement = doc.body.firstChild as HTMLElement; - if ( ! contentElement ) { - return; - } - - const anchor = contentElement.querySelector( `a[data-smartlink="${ linkSuggestion.uid }"]` ); - if ( anchor ) { - anchor.classList.add( 'smart-linking-highlight' ); - } - - blockInstance.attributes.content = contentElement.innerHTML; - }; - /** * Runs when the block is rendered in the DOM. - * It will set the block element to be non-editable. + * It will set the block element to be non-editable and highlight the link in the block. * - * @since 3.15.0 + * @since 3.16.0 */ useEffect( () => { const blockPreviewElement = document.querySelector( '.wp-parsely-preview-editor' ); @@ -157,6 +174,40 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { return; } + /** + * Highlights the link in the block. + * + * @since 3.16.0 + * + * @param {BlockInstance} blockInstance The block instance to highlight the link in. + * @param {SmartLink} linkSuggestion The link suggestion to highlight. + */ + const highlightLinkInBlock = ( blockInstance: BlockInstance, linkSuggestion: SmartLink ) => { + // If the link is not applied, add a highlight with a new mark element. + if ( ! link.applied ) { + const mark = document.createElement( 'mark' ); + mark.className = 'smart-linking-highlight'; + blockInstance.attributes.content = applyNodeToBlock( blockInstance, linkSuggestion, mark ); + return; + } + + // Otherwise, if the link is applied, add a highlight class to the link element with the link uid + const blockContent: string = getBlockContent( blockInstance ); + + const doc = new DOMParser().parseFromString( blockContent, 'text/html' ); + const contentElement = doc.body.firstChild as HTMLElement; + if ( ! contentElement ) { + return; + } + + const anchor = contentElement.querySelector( `a[data-smartlink="${ linkSuggestion.uid }"]` ); + if ( anchor ) { + anchor.classList.add( 'smart-linking-highlight' ); + } + + blockInstance.attributes.content = contentElement.innerHTML; + }; + highlightLinkInBlock( clonedBlock, link ); const observer = new MutationObserver( ( mutations: MutationRecord[] ) => { @@ -188,7 +239,7 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { } ); return () => observer.disconnect(); - }, [ clonedBlock, highlightLinkInBlock, link ] ); + }, [ clonedBlock, link ] ); if ( ! block ) { return <>; @@ -214,6 +265,13 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { ); }; +/** + * The LinkDetails component, which renders the details of the link suggestion. + * + * @since 3.16.0 + * + * @param {{link: SmartLink}} props The component props. + */ const LinkDetails = ( { link }: { link: SmartLink } ): JSX.Element => { // Get the post type by the permalink const displayUrl = filterURLForDisplay( link.href, 30 ); @@ -224,6 +282,12 @@ const LinkDetails = ( { link }: { link: SmartLink } ): JSX.Element => { updateSmartLink, } = useDispatch( SmartLinkingStore ); + /** + * Fetches the post type by the permalink using the SmartLinkingProvider. + * If the post type is not found, it will default to 'External'. + * + * @since 3.16.0 + */ useEffect( () => { if ( ! link.post_type ) { SmartLinkingProvider.getInstance().getPostTypeByURL( link.href ).then( ( type ) => { @@ -251,6 +315,11 @@ const LinkDetails = ( { link }: { link: SmartLink } ): JSX.Element => { ); }; +/** + * The props for the ReviewSuggestion component. + * + * @since 3.16.0 + */ type ReviewSuggestionProps = { link: SmartLink, onNext: () => void, @@ -263,6 +332,13 @@ type ReviewSuggestionProps = { hasNext: boolean, }; +/** + * The ReviewSuggestion component, which renders the review suggestion UI. + * + * @since 3.16.0 + * + * @param {ReviewSuggestionProps} props The component props. + */ export const ReviewSuggestion = ( { link, onNext, diff --git a/src/content-helper/editor-sidebar/smart-linking/store.ts b/src/content-helper/editor-sidebar/smart-linking/store.ts index 7899d2000..a0ad0da84 100644 --- a/src/content-helper/editor-sidebar/smart-linking/store.ts +++ b/src/content-helper/editor-sidebar/smart-linking/store.ts @@ -2,14 +2,14 @@ * WordPress dependencies */ import { createReduxStore, register } from '@wordpress/data'; -import { ContentHelperError } from '../../common/content-helper-error'; -import { DEFAULT_MAX_LINKS, DEFAULT_MAX_LINK_WORDS } from './smart-linking'; /** * Internal dependencies */ +import { ContentHelperError } from '../../common/content-helper-error'; import { SmartLink } from './provider'; import { sortSmartLinks } from './utils'; +import { DEFAULT_MAX_LINKS, DEFAULT_MAX_LINK_WORDS } from './smart-linking'; /** * Defines the props structure for SmartLinkingSettings. @@ -56,7 +56,7 @@ type SmartLinkingState = { /** * Interface for the SetIsReadyAction. * - * @since 3.15.0 + * @since 3.16.0 */ interface SetIsReadyAction { type: 'SET_IS_READY'; @@ -155,33 +155,58 @@ interface SetApplyToAction { /** * Interface for the SetIsRetryingAction. * - * @since 3.15.0 + * @since 3.16.0 */ interface SetIsRetryingAction { type: 'SET_IS_RETRYING'; isRetrying: boolean; } +/** + * Interface for the SetSmartLinksAction. + * + * @since 3.16.0 + */ interface SetSmartLinksAction { type: 'SET_SMART_LINKS'; smartLinks: SmartLink[]; } +/** + * Interface for the AddSmartLinkAction. + * + * @since 3.16.0 + */ interface AddSmartLinkAction { type: 'ADD_SMART_LINK'; smartLink: SmartLink; } +/** + * Interface for the AddSmartLinksAction. + * + * @since 3.16.0 + */ interface AddSmartLinksAction { type: 'ADD_SMART_LINKS'; smartLinks: SmartLink[]; } +/** + * Interface for the RemoveSmartLinkAction. + * + * @since 3.16.0 + */ interface RemoveSmartLinkAction { type: 'REMOVE_SMART_LINK'; uid: string; } +/** + * Interface for the PurgeSmartLinksSuggestionsAction. + * + * @since 3.16.0 + */ interface PurgeSmartLinksSuggestionsAction { type: 'PURGE_SMART_LINKS_SUGGESTIONS'; } @@ -195,6 +220,11 @@ interface IncrementRetryAttemptAction { type: 'INCREMENT_RETRY_ATTEMPT'; } +/** + * Interface for the SetIsReviewModalOpenAction. + * + * @since 3.16.0 + */ interface SetIsReviewModalOpenAction { type: 'SET_IS_REVIEW_MODAL_OPEN'; isReviewModalOpen: boolean; @@ -459,7 +489,7 @@ export const SmartLinkingStore = createReduxStore( 'wp-parsely/smart-linking', { }; }, updateSmartLink( smartLink: SmartLink ): AddSmartLinkAction { - // Alias of addSmartLink + // Alias of addSmartLink. return { type: 'ADD_SMART_LINK', smartLink, From 0aaab8930130ce3024fd2a52288382e657a15913 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Mon, 20 May 2024 11:09:25 +0100 Subject: [PATCH 23/44] Implement the link selection functionality --- .../review-modal/component-modal.tsx | 24 ++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx index 547378575..ea7c45a5a 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-modal.tsx @@ -339,13 +339,35 @@ const SmartLinkingReviewModalComponent = ( { if ( ! selectedLink.match ) { return; } - // TODO const block = select( 'core/block-editor' ).getBlock( selectedLink.match.blockId ); if ( block ) { // Select the block in the editor. dispatch( 'core/block-editor' ).selectBlock( block.clientId ); + // Find the link element within the block. + const blockContent = document.querySelector( `[data-block="${ block.clientId }"]` ); + if ( blockContent ) { + const ownerDocument = blockContent.ownerDocument; + const linkElement = blockContent.querySelector( `a[data-smartlink="${ selectedLink.uid }"]` ) as HTMLElement; + if ( linkElement ) { + // Set focus to the link element. + linkElement.focus(); + + // Select the link. + const range = ownerDocument.createRange(); + if ( linkElement.firstChild ) { + range.setStart( linkElement.firstChild, 0 ); // Start at the beginning of the link text + range.setEndAfter( linkElement.firstChild ); + const sel = ownerDocument.getSelection(); + if ( sel ) { + sel.removeAllRanges(); + sel.addRange( range ); + } + } + } + } + // Close the modal. onCloseHandler(); } From 5ca91ecb1e52b3579746435a41ea4d8295764b8c Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Mon, 20 May 2024 11:51:28 +0100 Subject: [PATCH 24/44] UI & functionality tweaks to the Link Details component --- .../class-smart-linking-endpoint.php | 27 ++++++------ .../review-modal/component-suggestion.tsx | 41 +++++++++++++++---- .../smart-linking/smart-linking.scss | 7 +++- .../editor-sidebar/smart-linking/utils.ts | 17 ++++++++ 4 files changed, 68 insertions(+), 24 deletions(-) diff --git a/src/Endpoints/content-helper/class-smart-linking-endpoint.php b/src/Endpoints/content-helper/class-smart-linking-endpoint.php index 125ef3dda..a0d88d99d 100644 --- a/src/Endpoints/content-helper/class-smart-linking-endpoint.php +++ b/src/Endpoints/content-helper/class-smart-linking-endpoint.php @@ -129,29 +129,28 @@ public function url_to_post_type( WP_REST_Request $request ): WP_REST_Response { $post_id = 0; - if ( ( $cache = wp_cache_get( $url, 'wp_parsely_smart_link_url_to_postid' ) ) === false ) { + if ( ( $cache = wp_cache_get( $url, 'wp_parsely_smart_link_url_to_postid' ) ) !== false ) { $post_id = $cache; } else if ( function_exists( 'wpcom_vip_url_to_postid' ) ) { $post_id = wpcom_vip_url_to_postid( $url ); } else { $post_id = url_to_postid( $url ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.url_to_postid_url_to_postid + wp_cache_set( $url, $post_id, 'wp_parsely_smart_link_url_to_postid' ); } - if ( 0 === $post_id ) { - return new WP_REST_Response( array( - 'error' => array( - 'name' => 'invalid_url', - 'message' => 'Invalid URL', - ), - ), 400 ); - } - - return new WP_REST_Response( array( + $response = array( 'data' => array( - 'post_id' => $post_id, - 'post_type' => get_post_type( $post_id ), + 'post_id' => false, + 'post_type' => false, ), - ), 200 ); + ); + + if ( 0 !== $post_id ) { + $response['data']['post_id'] = $post_id; + $response['data']['post_type'] = get_post_type( $post_id ); + } + + return new WP_REST_Response( $response, 200 ); } public function set_smart_links( WP_REST_Request $request ): string { diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx index 70f32b22b..747cf9daa 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx @@ -11,7 +11,7 @@ import { Tooltip, } from '@wordpress/components'; import { select as selectFn, useDispatch, useSelect } from '@wordpress/data'; -import { useEffect, useState } from '@wordpress/element'; +import { useEffect, useRef, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { arrowLeft, arrowRight, check, closeSmall, Icon, page } from '@wordpress/icons'; import { filterURLForDisplay } from '@wordpress/url'; @@ -23,7 +23,7 @@ import { GutenbergFunction } from '../../../../@types/gutenberg/types'; import { SmartLink, SmartLinkingProvider } from '../provider'; import { BlockEditorProvider, BlockList } from '@wordpress/block-editor'; import { SmartLinkingStore } from '../store'; -import { applyNodeToBlock } from '../utils'; +import { applyNodeToBlock, trimURLForDisplay } from '../utils'; /** * The props for the SuggestionBreadcrumb component. @@ -274,9 +274,9 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { */ const LinkDetails = ( { link }: { link: SmartLink } ): JSX.Element => { // Get the post type by the permalink - const displayUrl = filterURLForDisplay( link.href, 30 ); - + const [ displayUrl, setDisplayUrl ] = useState( link.href ); const [ postType, setPostType ] = useState( link.post_type ); + const linkRef = useRef( null ); const { updateSmartLink, @@ -290,20 +290,45 @@ const LinkDetails = ( { link }: { link: SmartLink } ): JSX.Element => { */ useEffect( () => { if ( ! link.post_type ) { + setPostType( __( 'External', 'wp-parsely' ) ); SmartLinkingProvider.getInstance().getPostTypeByURL( link.href ).then( ( type ) => { - if ( ! type ) { - type = __( 'External', 'wp-parsely' ); + if ( type ) { + setPostType( type ); } - - setPostType( type ); link.post_type = type ?? 'external'; updateSmartLink( link ); } ); + } else { + setPostType( link.post_type ); } + }, [ link, updateSmartLink ] ); + + /** + * Trims the URL for display based on the container width. + * + * @since 3.16.0 + */ + useEffect( () => { + const calculateTrimSize = () => { + if ( linkRef.current ) { + const containerWidth = linkRef.current.offsetWidth; + const averageCharWidth = 8; // Estimate or adjust based on actual character width + const maxLength = Math.floor( containerWidth / averageCharWidth ); + setDisplayUrl( trimURLForDisplay( link.href, maxLength ) ); + } + }; + + calculateTrimSize(); + + window.addEventListener( 'resize', calculateTrimSize ); + return () => { + window.removeEventListener( 'resize', calculateTrimSize ); + }; }, [ link ] ); return ( Date: Mon, 20 May 2024 14:40:32 +0100 Subject: [PATCH 25/44] Rebuild assets with the "finalized" UI & fix linting --- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.css | 2 +- build/content-helper/editor-sidebar.js | 32 +-- src/Endpoints/class-base-endpoint.php | 33 ++++ .../class-smart-linking-endpoint.php | 183 ++++++++++-------- src/Models/class-base-model.php | 24 +-- src/Models/class-smart-link.php | 66 ++++--- .../class-suggest-linked-reference-api.php | 4 +- src/content-helper/common/css/variables.scss | 2 +- .../review-modal/component-suggestion.tsx | 1 - .../smart-linking/smart-linking.scss | 69 +++---- .../editor-sidebar/smart-linking/utils.ts | 107 +++++++--- 12 files changed, 306 insertions(+), 219 deletions(-) diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index 96effdff0..95dafac80 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-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'b9972e12749bccd00878'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'fd925047e100cf5191e8'); diff --git a/build/content-helper/editor-sidebar.css b/build/content-helper/editor-sidebar.css index cbe748d27..d1f7b690a 100644 --- a/build/content-helper/editor-sidebar.css +++ b/build/content-helper/editor-sidebar.css @@ -1,4 +1,4 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 var(--grid-unit-15) 0 0;order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate,.wp-parsely-smart-linking .smart-linking-manage{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button,.wp-parsely-smart-linking .smart-linking-manage button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)}.wp-parsely-smart-linking-review-modal{align-items:flex-start;display:flex;flex-direction:column;width:47.875rem}.wp-parsely-smart-linking-review-modal .smart-linking-modal-body{align-self:stretch;display:flex;flex-direction:row;gap:var(--grid-unit-30)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);max-height:25rem;min-width:13.75rem;overflow-y:auto;padding:3px}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header{align-items:center;align-self:stretch;color:var(--sidebar-black);display:flex;font-size:11px;font-style:normal;font-weight:600;gap:6px;line-height:var(--grid-unit-20);margin-bottom:var(--grid-unit-15);text-transform:uppercase}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header>span{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button{width:13.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected{border:1px solid var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__item{display:inline;overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__shortcut{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));padding-left:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion{align-items:flex-start;align-self:stretch;display:flex;flex:1;flex-direction:column;gap:16px;max-width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs{font-size:.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-separator{margin:0 var(--grid-unit-5)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-block{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block{color:var(--sidebar-black)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block .breadcrumbs-current-block-name{margin-left:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .components-divider{border-color:#ccc;height:1px;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .wp-parsely-link-suggestion-link-details{height:auto;margin-bottom:var(--grid-unit-20);text-align:left}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .wp-parsely-link-suggestion-link-details .components-menu-item__item{word-wrap:break-word;white-space:normal}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls{align-items:center;align-self:stretch;display:flex;flex-shrink:0;justify-content:space-between;margin:0 var(--grid-unit-20);-webkit-user-select:none;-moz-user-select:none;user-select:none;width:452px}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .reviews-controls-middle{align-items:center;display:flex;flex:1 0 0;gap:var(--grid-unit-20,16px);justify-content:center}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-next,.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-previous{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-reject{background:var(--Gutenberg-White,#fff);border-radius:2px;box-shadow:inset 0 0 0 1px var(--Gutenberg-Alert-Red,#cc1818);color:var(--Gutenberg-Alert-Red,#cc1818)}.wp-parsely-smart-linking-close-dialog{align-items:flex-start;display:flex;flex-direction:column;width:24rem}.wp-parsely-smart-linking-close-dialog .smart-linking-close-dialog-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;padding-top:var(--grid-unit-30)}.wp-parsely-preview-editor.editor-styles-wrapper{font-size:var(--font-size--medium);padding-bottom:0}.wp-parsely-preview-editor p[role=document]{margin:0}.wp-parsely-preview-editor .smart-linking-highlight{background:hsla(var(--parsely-green-components),.5);border-radius:2px;mix-blend-mode:multiply;text-decoration-line:underline} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 var(--grid-unit-15) 0 0;order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate,.wp-parsely-smart-linking .smart-linking-manage{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button,.wp-parsely-smart-linking .smart-linking-manage button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)}.wp-parsely-smart-linking-review-modal{align-items:flex-start;display:flex;flex-direction:column;width:47.875rem}.wp-parsely-smart-linking-review-modal .smart-linking-modal-body{align-self:stretch;display:flex;flex-direction:row;gap:var(--grid-unit-30)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);max-height:25rem;min-width:13.75rem;overflow-y:auto;padding:3px}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header{align-items:center;align-self:stretch;color:var(--sidebar-black);display:flex;font-size:11px;font-style:normal;font-weight:600;gap:6px;line-height:var(--grid-unit-20);margin-bottom:var(--grid-unit-15);text-transform:uppercase}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header>span{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button{align-items:center;display:flex;justify-content:space-between;width:13.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button:focus{box-shadow:none;outline:none}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected{background-color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected .smart-linking-menu-label{color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__item{padding-right:0;width:100%}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-item{display:inline;flex-grow:1;overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-label{align-items:center;color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));display:flex;padding-left:var(--grid-unit-10);white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion{align-items:flex-start;align-self:stretch;display:flex;flex:1;flex-direction:column;gap:16px;max-width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs{font-size:.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-separator{margin:0 var(--grid-unit-5)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-block{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block{color:var(--sidebar-black)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block .breadcrumbs-current-block-name{margin-left:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .components-divider{border-color:#ccc;height:1px;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .wp-parsely-link-suggestion-link-details{height:auto;margin-bottom:var(--grid-unit-20);text-align:left}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .wp-parsely-link-suggestion-link-details .components-menu-item__item{display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls{align-items:center;align-self:stretch;display:flex;flex-shrink:0;justify-content:space-between;margin:0 var(--grid-unit-20);-webkit-user-select:none;-moz-user-select:none;user-select:none;width:452px}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .reviews-controls-middle{align-items:center;display:flex;flex:1 0 0;gap:var(--grid-unit-20,16px);justify-content:center}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-next,.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-previous{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-reject{background:var(--Gutenberg-White,#fff);border-radius:2px;box-shadow:inset 0 0 0 1px var(--Gutenberg-Alert-Red,#cc1818);color:var(--Gutenberg-Alert-Red,#cc1818)}.wp-parsely-smart-linking-close-dialog{align-items:flex-start;display:flex;flex-direction:column;width:24rem}.wp-parsely-smart-linking-close-dialog .smart-linking-close-dialog-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;padding-top:var(--grid-unit-30)}.wp-parsely-preview-editor.editor-styles-wrapper{font-size:var(--font-size--medium);padding-bottom:0}.wp-parsely-preview-editor p[role=document]{margin:0}.wp-parsely-preview-editor .smart-linking-highlight{background:hsla(var(--parsely-green-components),.5);border-radius:2px;color:var(--sidebar-black);mix-blend-mode:multiply;text-decoration-line:underline} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-performance-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}.wp-parsely-content-helper .wp-parsely-performance-panel .content-helper-error-message{margin:0!important}.wp-parsely-content-helper .wp-parsely-performance-panel .components-button.wp-parsely-view-post{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .panel-body{width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.5rem;padding:.375rem 0 1rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header{align-items:center;display:flex;gap:.375rem;height:1rem;margin-bottom:0;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2{margin-bottom:.9375rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2 h2{margin-bottom:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-3 h3{font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:1rem;margin-bottom:0;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-subtitle{align-items:center;align-self:stretch;color:var(--Gutenberg-Gray-700,#757575);display:flex;flex:1 0 0;font-size:var(--font-size--smaller);font-style:normal;font-weight:600;gap:.375rem;height:1rem;line-height:1rem;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .components-heading{display:block;font-weight:500;line-height:normal;margin:0}.wp-parsely-content-helper .wp-parsely-performance-panel .components-dropdown-menu{line-height:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points{align-content:flex-start;align-items:flex-start;align-self:stretch;display:flex;flex-wrap:wrap;gap:1rem var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point{align-items:center;background:var(--sidebar-white);border-radius:.25rem;display:flex;flex:1 0 0;flex-direction:column;gap:var(--grid-unit-5);justify-content:center;min-width:100px;padding:var(--grid-unit-20) var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point svg{align-items:flex-start;border-radius:.125rem;display:flex}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-title{align-self:stretch;color:var(--sidebar-black);font-size:.75rem;font-style:normal;font-weight:400;line-height:1rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value{align-self:stretch;color:var(--sidebar-black);font-size:1.25rem;font-style:normal;font-weight:590;line-height:1.75rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value.is-small{font-size:var(--font-size--medium)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar{align-items:flex-start;align-self:stretch;display:flex;height:1rem;margin:1rem 0;position:relative}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill{--radius:2px;align-self:stretch;position:relative;transition:filter .1s ease,transform .1s ease}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:hover{filter:opacity(1)!important;transform:scaleX(1) scaleY(1)!important}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:first-child{border-radius:var(--radius) 0 0 var(--radius)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:last-child{border-radius:0 var(--radius) var(--radius) 0}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar:hover .bar-fill{filter:opacity(.5);transform:scaleX(1) scaleY(.7)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label{align-items:center;align-self:stretch;display:flex;gap:.5rem;justify-content:center}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color{align-items:center;border-radius:.09375rem;display:flex;flex-direction:column;gap:.625rem;height:.625rem;justify-content:center;width:.1875rem}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1 0 0;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-value{color:var(--sidebar-black);font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;text-align:right}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:1rem 0}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-10);justify-content:space-between}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar{display:flex;flex:1;flex-direction:column;gap:.625rem;justify-content:center;max-width:6.25rem}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar{--radius:1.5px;background:var(--gray-400);border-radius:var(--radius);display:flex;height:.1875rem;margin:0;overflow:hidden}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar:after{background:var(--blueberry,#3858e9);border-radius:var(--radius);content:"";height:100%;width:var(--bar-fill)}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-value{color:var(--sidebar-black);flex-shrink:0;font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;min-width:3.125rem;text-align:right} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-related-posts{align-items:flex-start;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-description{font-size:.8125rem;font-style:normal;font-weight:400;gap:.625rem;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body,.wp-parsely-related-posts .related-posts-description{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body{gap:1rem}.wp-parsely-related-posts .related-posts-body>div{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings{align-self:stretch;display:flex;flex-direction:column;gap:1rem;width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings{display:flex;flex-direction:column;gap:var(--grid-unit-20);width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control{height:2.5rem;overflow:hidden}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex{height:2.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex input{margin:0 var(--grid-unit-15)}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-descr{font-size:.8125rem;font-style:normal;font-weight:400;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-empty,.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-loading-message{color:var(--gray-900);font-size:.75rem;font-style:normal;font-weight:700;line-height:var(--grid-unit-20);overflow:hidden;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-title{align-items:center;align-self:stretch;display:flex;flex-direction:column;font-size:.875rem;font-style:normal;font-weight:600;gap:.5rem;justify-content:center;line-height:1.25rem;overflow:hidden;padding:var(--grid-unit-20);text-decoration-line:underline;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions{align-items:center;align-self:stretch;border-top:1px solid var(--gray-400);display:flex;flex-wrap:wrap;padding:0 var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:first-child,.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:last-child{display:flex;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric{align-items:center;display:flex}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric .parsely-post-metric-data{align-items:center;display:flex;gap:var(--grid-unit-5)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-linked{align-items:center;display:flex;margin-left:auto;fill:#008a20}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon path{fill:#1e1e1e}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon:hover path{fill:#0073aa} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper{display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings>div{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding-bottom:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header .parsely-write-titles-text strong{text-transform:lowercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding-top:.375rem}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate .components-button{align-items:center;align-self:stretch;border-radius:2px;display:flex;height:2.5rem;justify-content:center;padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-dropdown-label{align-self:stretch;color:var(--sidebar-black);font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:var(--grid-unit-20);text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title{font-size:1rem;font-weight:600;line-height:1.25rem;margin:0 0 .9375rem;text-align:center}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title-actions{display:flex;gap:.625rem;justify-content:center;margin:.625rem 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion.pinned-title{background:var(--Gutenberg-Gray-100,#f0f0f0)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title{align-items:center;align-self:stretch;color:#1e1e1e;display:flex;flex-direction:column;font-size:.75rem;font-style:normal;font-weight:600;gap:var(--grid-unit-10);justify-content:center;line-height:1.25rem;padding:var(--grid-unit-15) var(--grid-unit-15) 0 var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title .suggested-title-original{align-self:flex-start;margin:0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions{align-items:center;align-self:stretch;border-top:1px solid var(--Gutenberg-Gray-400,#ccc);display:flex;flex-wrap:wrap;height:2.5rem;padding:0 var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-left,.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-right{display:flex;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin-bottom:var(--grid-unit-20);position:relative}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay{align-items:center;background-color:hsla(0,0%,100%,.9);bottom:0;display:flex;flex-direction:column;gap:var(--grid-unit-10);justify-content:center;left:0;position:absolute;right:0;top:0;z-index:1}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay .components-spinner{transform:scale(1.125)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-pinned-suggestions{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-content-helper-error.components-notice{margin-bottom:var(--grid-unit-10)}.wp-parsely-popover .components-popover__content{width:15.5rem}.wp-parsely-suggested-title-modal{align-items:flex-start;display:flex;flex-direction:column;width:20rem}.wp-parsely-suggested-title-modal h2{color:var(--sidebar-black);font-size:1rem;font-style:normal;font-weight:600;line-height:1.5rem}.wp-parsely-suggested-title-modal .suggested-title-modal-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;margin-top:1.5rem} diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index 39c521cc6..cb9fef3ee 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,27 +1,27 @@ -!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 Sn}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=n(609),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,h=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=(h.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"})]})},v=function(){return v=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiError||s.code===N.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===N.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===N.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return H(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[N.PluginCredentialsNotSetMessageDetected,N.PluginSettingsSiteIdNotSet,N.PluginSettingsApiSecretNotSet].includes(this.code)?B(e):(this.code===N.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==N.ParselyApiForbidden&&this.code!==N.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===N.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(I,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function U(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var W=function(e,t,n){if(n||2===arguments.length)for(var r,i=0,s=t.length;i0?p(!0):x().then((function(){return t()}))},j=function(e){p(!1),e?(h(!1),x().then((function(){t()}))):h(!0)},T=function(){var e=y.indexOf(w)+1;y[e]&&_(y[e])},E=function(){var e=y.indexOf(w)-1;y[e]&&_(y[e])},L=function(){var e,t,n,i,s,o;w.match&&(r(w),(e=w.match.blockId,t=w,n=void 0,i=void 0,s=void 0,o=function(){var n,r;return 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){var l=o[0],c=l.parentNode;if(c){var u=document.createTextNode(null!==(n=l.textContent)&&void 0!==n?n:"");c.replaceChild(u,l),e.attributes.content=s.innerHTML,(0,a.dispatch)("core/block-editor").updateBlock(r,e)}}S(t.uid)}}}(e,w)}};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:P,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:E,right:T,up:E,down:T,a:function(){w&&!w.applied&&L()},r:function(){w&&(w.applied?N():C())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(te,{links:y,activeLink:w,setSelectedLink:_}),(0,i.jsx)(fe,{link:w,hasNext:y.indexOf(w)0,onNext:T,onPrevious:E,onAccept:L,onReject:C,onRemove:N,onSelectInEditor:function(){if(w.match){var e=(0,a.select)("core/block-editor").getBlock(w.match.blockId);e&&((0,a.dispatch)("core/block-editor").selectBlock(e.clientId),P())}}})]})]}),u&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return j(!1)},className:"wp-parsely-smart-linking-close-dialog",children:[(0,c.__)("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 j(!1)},children:(0,c.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return j(!0)},children:(0,c.__)("Close","wp-parsely")})]})]})]})})),ge=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})]})]})},ye=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,u=e.onSettingChange,p=(0,l.useRef)(),d=(0,l.useState)(""),f=d[0],h=d[1],g=(0,l.useState)(!1),y=g[0],v=g[1],m=(0,l.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(J),n=t.getMaxLinkWords,r=t.getMaxLinks,i=t.isFullContent,s=t.wasAlreadyClicked,a=t.getApplyTo;return{maxLinks:r(),maxLinkWords:n(),fullContent:i(),alreadyClicked:s(),applyTo:a()}}),[]),_=w.maxLinks,b=w.maxLinkWords,x=w.fullContent,k=w.alreadyClicked,S=w.applyTo,P=(0,a.useDispatch)(J),j=P.setMaxLinks,T=P.setMaxLinkWords,E=P.setFullContent,L=P.setAlreadyClicked,C=P.setApplyTo,N=null!==(t=S)&&void 0!==t?t:o?"selected":"all";return(0,l.useEffect)((function(){if(!r){var e=function(){r||(S===K.Selected&&setTimeout((function(){h((0,c.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),C(null),m((function(e){return!e})))};o||S===K.All||(y?setTimeout(e,500):e()),E(K.All===N)}}),[y,S,N,r,o,C,E,h]),(0,l.useEffect)((function(){if(!r&&p.current&&N&&!k&&o){var e=p.current.querySelector('button[data-value="'.concat(N,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(C(N),L(!0))}}),[o,x,r,S]),(0,l.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:N,label:(0,c.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&E("success",/* translators: %d: number of smart links applied */ /* translators: %d: number of smart links applied */ -(0,c.sprintf)((0,c.__)("%s smart links successfully applied.","wp-parsely"),y),{type:"snackbar"}):v(0)}),[w]);var L=(0,a.useSelect)((function(e){var t=e(J),n=t.isLoading,r=t.getOverlayBlocks,i=t.getSuggestedLinks,s=t.getError,a=t.isFullContent,o=t.getMaxLinks,l=t.getMaxLinkWords,c=t.getSmartLinkingSettings,u=t.getApplyTo,p=t.isRetrying,d=t.getRetryAttempt,f=t.getSmartLinks;return{loading:n(),error:s(),maxLinks:o(),maxLinkWords:l(),isFullContent:a(),overlayBlocks:r(),suggestedLinks:i(),smartLinkingSettings:c(),applyTo:u(),retrying:p(),retryAttempt:d(),smartLinks:f(),getSmartLinksFn:f}}),[]),C=L.loading,A=L.isFullContent,R=L.overlayBlocks,I=L.error,B=L.suggestedLinks,M=L.maxLinks,D=L.maxLinkWords,H=L.smartLinkingSettings,z=L.applyTo,W=L.retrying,Z=L.retryAttempt,q=L.smartLinks,$=L.getSmartLinksFn,Y=(0,a.useDispatch)(J),Q=Y.setLoading,X=Y.setError,te=Y.addSmartLinks,ne=Y.addOverlayBlock,re=Y.removeOverlayBlock,ie=Y.setSmartLinkingSettings,se=Y.setApplyTo,ae=Y.setMaxLinkWords,oe=Y.setMaxLinks,le=Y.setIsRetrying,ce=Y.incrementRetryAttempt,ue=Y.purgeSmartLinksSuggestions;(0,l.useEffect)((function(){if(!(Object.keys(H).length>0)){var e={maxLinksPerPost:p.SmartLinking.MaxLinks,maxLinkWords:p.SmartLinking.MaxLinkWords};ie(e)}}),[ie,p]);var pe=(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]),de=pe.allBlocks,fe=pe.selectedBlock,ge=pe.postContent,ve=pe.postPermalink,me=function(e){return ke(void 0,void 0,void 0,(function(){var t,n,r,i;return Se(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,se((n=A||!fe)?K.All:K.Selected)];case 2:return s.sent(),a=ve.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,be.getInstance().generateSmartLinks((null==fe?void 0:fe.originalContent)&&!n?fe.originalContent:ge,D,M,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===N.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,le(!0)]):[3,8];case 5:return s.sent(),[4,ce()];case 6:return s.sent(),[4,me(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},we=function(e,t,n,r){return void 0===r&&(r=0),e.forEach((function(e,i){var s,a=r+i;if(null===(s=e.innerBlocks)||void 0===s?void 0:s.length)we(e.innerBlocks,t,n,a);else if(e.originalContent){var o=(0,V.getBlockContent)(e),l=(new DOMParser).parseFromString(o,"text/html").body.firstChild;l instanceof HTMLElement&&t.forEach((function(t){var r=function(e,t){for(var n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:function(n){var r;if(!n.textContent||!n.textContent.includes(t))return NodeFilter.FILTER_REJECT;for(var i=n.parentNode;i&&i!==e;){if("A"===i.nodeName&&!(null===(r=i.textContent)||void 0===r?void 0:r.includes(t)))return NodeFilter.FILTER_REJECT;i=i.parentNode}return NodeFilter.FILTER_ACCEPT}}),i=[];n=r.nextNode();)i.push(n);return i}(l,t.text),i="".concat(t.text,"#").concat(t.offset);n[i]=n[i]||{encountered:0,linked:0};var s=0;r.forEach((function(r){for(var o,l=new RegExp(U(t.text),"g");null!==l.exec(null!==(o=r.textContent)&&void 0!==o?o:"");){var c=n[i];c.encountered++,s++,c.encountered===t.offset+1&&c.linked<1&&(c.linked++,t.match={blockId:e.clientId,blockOffset:s-1,blockPosition:a})}}))}))}})),t},_e=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Ee=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsxs)(s.PanelRow,{className:t,children:[(0,i.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(F,{icon:G,size:18,className:"parsely-external-link-icon"})]})]}),I&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return X(null)},className:"wp-parsely-content-helper-error",children:I.Message()}),w&&y>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return _(!1)},className:"wp-parsely-smart-linking-suggested-links",children:(0,c.sprintf)(/* translators: 1 - number of smart links generated */ /* translators: 1 - number of smart links generated */ -(0,c.__)("Successfully added %s smart links.","wp-parsely"),y>0?y:B.length)}),(0,i.jsx)(ye,{disabled:C,selectedBlock:null==fe?void 0:fe.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:xe(xe({},p.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e?oe(t):"MaxLinkWords"===e&&ae(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return ke(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Se(this,(function(a){switch(a.label){case 0:return[4,Q(!0)];case 1:return a.sent(),[4,ue()];case 2:return a.sent(),[4,X(null)];case 3:return a.sent(),_(!1),h.trackEvent("smart_linking_generate_pressed",{is_full_content:A,selected_block:null!==(s=null==fe?void 0:fe.name)&&void 0!==s?s:"none",context:o}),[4,_e(A?"all":null==fe?void 0:fe.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;Q(!1),h.trackEvent("smart_linking_generate_timeout",{is_full_content:A,selected_block:null!==(e=null==fe?void 0:fe.name)&&void 0!==e?e:"none",context:o}),je(A?"all":null==fe?void 0:fe.clientId)}),18e4),t=z,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,me(3)];case 6:return n=a.sent(),[4,(l=n,ke(void 0,void 0,void 0,(function(){var e;return Se(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!q.find((function(t){return t.uid===e.uid&&t.applied}))})),e=ve.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=we(de,l,{}).filter((function(e){return e.match})),[4,te(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),k(!0),[3,15];case 8:return r=a.sent(),i=(0,c.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===N.ParselyAborted&&(i=(0,c.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ /* translators: %d: number of retry attempts, %s: attempt plural */ -(0,c.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),r.numRetries,(0,c._n)("attempt","attempts",r.numRetries,"wp-parsely")),r.message=i),[4,X(r)];case 9:return a.sent(),E("error",i,{type:"snackbar"}),[3,15];case 10:return[4,Q(!1)];case 11:return a.sent(),[4,se(t)];case 12:return a.sent(),[4,le(!1)];case 13:return a.sent(),[4,je(A?"all":null==fe?void 0:fe.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:C,disabled:C,children:W?(0,c.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,c.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),Z,3):C?(0,c.__)("Generating Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")})}),j&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return k(!0)},variant:"secondary",children:(0,c.__)("Review Smart Links","wp-parsely")})})]}),x&&(0,i.jsx)(he,{isOpen:x,onAppliedLink:function(){v((function(e){return e+1}))},onClose:function(){_(!0),k(!1),$().length>0?T(!0):T(!1)}})]})},Te=function(){return Te=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 Fe=function(e){var n=e.data,r=e.isLoading,a=(0,l.useState)(t.Views),o=a[0],u=a[1],p=(0,l.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},g=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),L(o)); -/* translators: %s: metric description */return(0,i.jsxs)(De,{title:(0,c.__)("Categories","wp-parsely"),level:3,subtitle:g,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,c.__)("By: ","wp-parsely"),onChange:function(e){T(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,i.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[L(e),"avg_engaged"===e&&(0,c.__)(" (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,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ /* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ +!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 Bn}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=n(609),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,h=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}(),v=(h.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"})})}),g=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"})]})},y=function(){return y=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiError||s.code===A.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===A.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===A.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return G(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[A.PluginCredentialsNotSetMessageDetected,A.PluginSettingsSiteIdNotSet,A.PluginSettingsApiSecretNotSet].includes(this.code)?M(e):(this.code===A.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==A.ParselyApiForbidden&&this.code!==A.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===A.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(I,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var W,U=function(e){var t=e.isDetectingEnabled,n=e.onLinkChange,r=e.onLinkRemove,i=e.onLinkAdd,s=e.debounceValue,o=void 0===s?500:s,c=(0,a.useSelect)((function(e){return{blocks:(0,e("core/block-editor").getBlocks)()}}),[]).blocks,u=(0,l.useRef)(c),p=(0,l.useRef)(t);return(0,l.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}(c,u.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)})),u.current=c)}),o);return e(t),function(){e.cancel()}}),[c,o,t,i,n,r]),null},q=window.wp.editor,Z=window.wp.blocks,$=function(){return $=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var u=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,c.__)("NEW","wp-parsely"),(0,i.jsx)(fe,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,c.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&u]},e.uid)}))]})})},ve=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,u.createElement)(p.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})),ge=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),ye=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),me=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),we=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})),_e=window.wp.url,be=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?p(!0):k().then((function(){return t()}))},E=function(e){p(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},L=function(){var e=g.indexOf(_)+1;g[e]&&b(g[e])},C=function(){var e=m().indexOf(_)-1;m()[e]&&b(m()[e])},A=function(){return Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(this,(function(n){switch(n.label){case 0:return _.match?(r(_),[4,(i=_.match.blockId,s=_,Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(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))?(ne(t,s,e),s.applied=!0,[4,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(_),g[t=e+1]?b(g[t]):b(g[0]),[2])}var i,s}))}))},N=function(){return Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(this,(function(n){switch(n.label){case 0:return e=g.indexOf(_),g[t=e+1]?b(g[t]):g[0]?b(g[0]):T(),[4,P(_.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Ne(void 0,void 0,void 0,(function(){var e,t,n,r;return Oe(this,(function(i){switch(i.label){case 0:return _.match?(e=(0,a.select)("core/block-editor").getBlock(_.match.blockId))?(t=m(),n=t.indexOf(_),r=n-1,[4,j(e,_)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?b(t[r]):b(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:L,up:C,down:L,a:function(){_&&!_.applied&&A()},r:function(){_&&(_.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(he,{links:g,activeLink:_,setSelectedLink:b}),(0,i.jsx)(Ae,{link:_,hasNext:m().indexOf(_)0,onNext:L,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(_.match){var e=(0,a.select)("core/block-editor").getBlock(_.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(_.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),u&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return E(!1)},className:"wp-parsely-smart-linking-close-dialog",children:[(0,c.__)("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 E(!1)},children:(0,c.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return E(!0)},children:(0,c.__)("Close","wp-parsely")})]})]})]})})),Ie=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})]})]})},Me=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,u=e.onSettingChange,p=(0,l.useRef)(),d=(0,l.useState)(""),f=d[0],h=d[1],v=(0,l.useState)(!1),g=v[0],y=v[1],m=(0,l.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(Q),n=t.getMaxLinkWords,r=t.getMaxLinks,i=t.isFullContent,s=t.wasAlreadyClicked,a=t.getApplyTo;return{maxLinks:r(),maxLinkWords:n(),fullContent:i(),alreadyClicked:s(),applyTo:a()}}),[]),_=w.maxLinks,b=w.maxLinkWords,x=w.fullContent,k=w.alreadyClicked,S=w.applyTo,P=(0,a.useDispatch)(Q),j=P.setMaxLinks,T=P.setMaxLinkWords,E=P.setFullContent,L=P.setAlreadyClicked,C=P.setApplyTo,A=null!==(t=S)&&void 0!==t?t:o?"selected":"all";return(0,l.useEffect)((function(){if(!r){var e=function(){r||(S===W.Selected&&setTimeout((function(){h((0,c.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),C(null),m((function(e){return!e})))};o||S===W.All||(g?setTimeout(e,500):e()),E(W.All===A)}}),[g,S,A,r,o,C,E,h]),(0,l.useEffect)((function(){if(!r&&p.current&&A&&!k&&o){var e=p.current.querySelector('button[data-value="'.concat(A,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(C(A),L(!0))}}),[o,x,r,S]),(0,l.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:A,label:(0,c.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&S("success",/* translators: %d: number of smart links applied */ /* translators: %d: number of smart links applied */ +(0,c.sprintf)((0,c.__)("%s smart links successfully applied.","wp-parsely"),w),{type:"snackbar"}):_(0)}),[x]),(0,l.useEffect)((function(){if(!(Object.keys(D).length>0)){var e={maxLinksPerPost:v.SmartLinking.MaxLinks,maxLinkWords:v.SmartLinking.MaxLinkWords};fe(e)}}),[fe,v]);var be=(0,a.useSelect)((function(e){var t=e("core/block-editor"),n=t.getSelectedBlock,r=t.getBlock,i=t.getBlocks,s=e("core/editor"),a=s.getEditedPostContent,o=s.getCurrentPostAttribute;return{allBlocks:i(),selectedBlock:u?r(u):n(),postContent:a(),postPermalink:o("link")}}),[u]),xe=be.allBlocks,ke=be.selectedBlock,Se=be.postContent,je=be.postPermalink,Te=function(e){return De(void 0,void 0,void 0,(function(){var t,n,r,i;return Ve(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,he((n=C||!ke)?W.All:W.Selected)];case 2:return s.sent(),a=je.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,Pe.getInstance().generateSmartLinks((null==ke?void 0:ke.originalContent)&&!n?ke.originalContent:Se,B,M,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===A.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,ye(!0)]):[3,8];case 5:return s.sent(),[4,me()];case 6:return s.sent(),[4,Te(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},Ee=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Ae=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)(U,{isDetectingEnabled:!1,onLinkRemove:function(e){!function(e){X(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,le((0,Z.getBlockContent)(e),e.clientId)];case 1:return t.sent().forEach((function(e){(0,a.dispatch)(Q).removeSmartLink(e.uid)})),[2]}}))}))}(e.block)}}),(0,i.jsxs)(s.PanelRow,{className:o,children:[(0,i.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(V,{icon:F,size:18,className:"parsely-external-link-icon"})]})]}),R&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return ne(null)},className:"wp-parsely-content-helper-error",children:R.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,c.sprintf)(/* translators: 1 - number of smart links generated */ /* translators: 1 - number of smart links generated */ +(0,c.__)("Successfully added %s smart links.","wp-parsely"),w>0?w:I.length)}),(0,i.jsx)(Me,{disabled:E,selectedBlock:null==ke?void 0:ke.clientId,onSettingChange:function(e,t){var n;y({SmartLinking:Be(Be({},v.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e?ge(t):"MaxLinkWords"===e&&ve(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return De(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Ve(this,(function(a){switch(a.label){case 0:return[4,te(!0)];case 1:return a.sent(),[4,we()];case 2:return a.sent(),[4,ne(null)];case 3:return a.sent(),k(!1),h.trackEvent("smart_linking_generate_pressed",{is_full_content:C,selected_block:null!==(s=null==ke?void 0:ke.name)&&void 0!==s?s:"none",context:d}),[4,Ee(C?"all":null==ke?void 0:ke.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;te(!1),h.trackEvent("smart_linking_generate_timeout",{is_full_content:C,selected_block:null!==(e=null==ke?void 0:ke.name)&&void 0!==e?e:"none",context:d}),Le(C?"all":null==ke?void 0:ke.clientId)}),18e4),t=G,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,Te(3)];case 6:return n=a.sent(),[4,(o=n,De(void 0,void 0,void 0,(function(){var e;return Ve(this,(function(t){switch(t.label){case 0:return o=o.filter((function(e){return!$.find((function(t){return t.uid===e.uid&&t.applied}))})),e=je.replace(/^https?:\/\//,"").replace(/\/+$/,""),o=o.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),o=se(xe,o,{}).filter((function(e){return e.match})),[4,re(o)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),_e(!0),[3,15];case 8:return r=a.sent(),i=(0,c.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===A.ParselyAborted&&(i=(0,c.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ /* translators: %d: number of retry attempts, %s: attempt plural */ +(0,c.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),r.numRetries,(0,c._n)("attempt","attempts",r.numRetries,"wp-parsely")),r.message=i),[4,ne(r)];case 9:return a.sent(),S("error",i,{type:"snackbar"}),[3,15];case 10:return[4,te(!1)];case 11:return a.sent(),[4,he(t)];case 12:return a.sent(),[4,ye(!1)];case 13:return a.sent(),[4,Le(C?"all":null==ke?void 0:ke.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var o}))}))},variant:"primary",isBusy:E,disabled:E,children:H?(0,c.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,c.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),z,3):E?(0,c.__)("Generating Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")})}),K.length>0&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return De(void 0,void 0,void 0,(function(){var e;return Ve(this,(function(t){switch(t.label){case 0:return[4,ce()];case 1:return t.sent(),e=ae(),[4,re(e)];case 2:return t.sent(),_e(!0),[2]}}))}))},variant:"secondary",children:(0,c.__)("Review Smart Links","wp-parsely")})})]}),L&&(0,i.jsx)(Re,{isOpen:L,onAppliedLink:function(){_((function(e){return e+1}))},onClose:function(){k(!0),_e(!1)}})]})},He=function(){return He=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 tt=function(e){var n=e.data,r=e.isLoading,a=(0,l.useState)(t.Views),o=a[0],u=a[1],p=(0,l.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},v=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),L(o)); +/* translators: %s: metric description */return(0,i.jsxs)(Je,{title:(0,c.__)("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,c.__)("By: ","wp-parsely"),onChange:function(e){T(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,i.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[L(e),"avg_engaged"===e&&(0,c.__)(" (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,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ /* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ (0,c.__)("%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,c.sprintf)((0,c.__)("%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:Ve(n.views)})]},t)}))})]})]})},Ge=(0,u.createElement)(p.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.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"})),He=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),ze=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),Ue=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"})),We=function(){return We=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]1?[2,Promise.reject(new z((0,c.sprintf)(/* translators: URL of the published post */ /* translators: URL of the published post */ -(0,c.__)("Multiple results were returned for the post %s by the Parse.ly API.","wp-parsely"),t),N.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return rt(this,void 0,void 0,(function(){return it(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,oe.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",nt(nt({},et(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(ve),at=function(){return at=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)(De,{title:(0,c.__)("Performance Stats","wp-parsely"),icon:Me,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(dt,{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,c.__)("Period: ","wp-parsely")}),onChange:function(t){T(t,e)&&(w({PerformanceStats:at(at({},m.PerformanceStats),{Period:t})}),h.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)}))})})}),p?p.Message():(0,i.jsxs)(i.Fragment,{children:[pt(m,"overview")&&(0,i.jsx)(Xe,{data:g,isLoading:a}),pt(m,"categories")&&(0,i.jsx)(Fe,{data:g,isLoading:a}),pt(m,"referrers")&&(0,i.jsx)(Je,{data:g,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){h.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,c.__)("View this in Parse.ly","wp-parsely")})]})},ht=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(D,{children:(0,i.jsx)(ft,{period:t})})})},gt=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,c.__)("Tag","wp-parsely")}),a.categories.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Section,label:(0,c.__)("Section","wp-parsely")}),a.authors.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Author,label:(0,c.__)("Author","wp-parsely")})]})})},vt=function(e){var t=e.filter,n=e.label,a=e.postData,o=gt(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})})},mt=function(e){var t=e.filter,n=e.postData,s=e.label,a=gt(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)(yt,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(vt,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},wt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),_t=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"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"}));function bt(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,c.__)("Number of Views","wp-parsely")}),s,Ve(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,c.__)("Average Time","wp-parsely")}),r,n.avgEngaged]}):(0,i.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}var xt,kt=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"})})},St=function(e){var t,n,r=e.metric,o=e.post,l=e.postContent,u=(0,a.useDispatch)("core/notices").createNotice,p=l&&(t=l,n=U(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,c.__)("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)(bt,{metric:r,post:o,viewsIcon:(0,i.jsx)(F,{icon:Ge}),avgEngagedIcon:(0,i.jsx)(s.Dashicon,{icon:"clock",size:24})})}),p&&(0,i.jsx)("div",{className:"related-post-linked",children:(0,i.jsx)(s.Tooltip,{text:(0,c.__)("This post is linked in the content","wp-parsely"),children:(0,i.jsx)(F,{icon:wt,size:24})})})]}),(0,i.jsx)(kt,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:_t,iconSize:24,onClick:function(){navigator.clipboard.writeText(o.rawUrl).then((function(){u("success",(0,c.__)("URL copied to clipboard","wp-parsely"),{type:"snackbar"})}))},label:(0,c.__)("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,c.__)("View in Parse.ly","wp-parsely")})]})]})})]})},Pt=window.wp.coreData,jt=window.wp.editor,Tt=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 __)}}(),Et=function(){return Et=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 H((0,c.sprintf)(/* translators: URL of the published post */ /* translators: URL of the published post */ +(0,c.__)("Multiple results were returned for the post %s by the Parse.ly API.","wp-parsely"),t),A.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return mt(this,void 0,void 0,(function(){return wt(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,_e.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",yt(yt({},vt(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(be),bt=function(){return bt=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)(Je,{title:(0,c.__)("Performance Stats","wp-parsely"),icon:Xe,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(Tt,{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,c.__)("Period: ","wp-parsely")}),onChange:function(t){T(t,e)&&(w({PerformanceStats:bt(bt({},m.PerformanceStats),{Period:t})}),h.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)}))})})}),p?p.Message():(0,i.jsxs)(i.Fragment,{children:[jt(m,"overview")&&(0,i.jsx)(ft,{data:v,isLoading:a}),jt(m,"categories")&&(0,i.jsx)(tt,{data:v,isLoading:a}),jt(m,"referrers")&&(0,i.jsx)(ht,{data:v,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){h.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,c.__)("View this in Parse.ly","wp-parsely")})]})},Lt=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(D,{children:(0,i.jsx)(Et,{period:t})})})},Ct=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,c.__)("Tag","wp-parsely")}),a.categories.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Section,label:(0,c.__)("Section","wp-parsely")}),a.authors.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Author,label:(0,c.__)("Author","wp-parsely")})]})})},Nt=function(e){var t=e.filter,n=e.label,a=e.postData,o=Ct(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})})},Ot=function(e){var t=e.filter,n=e.postData,s=e.label,a=Ct(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)(At,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(Nt,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},Rt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),It=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"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"}));function Mt(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,c.__)("Number of Views","wp-parsely")}),s,et(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,c.__)("Average Time","wp-parsely")}),r,n.avgEngaged]}):(0,i.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}var Bt,Dt=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"})})},Vt=function(e){var t,n,r=e.metric,o=e.post,l=e.postContent,u=(0,a.useDispatch)("core/notices").createNotice,p=l&&(t=l,n=z(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,c.__)("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)(Mt,{metric:r,post:o,viewsIcon:(0,i.jsx)(V,{icon:nt}),avgEngagedIcon:(0,i.jsx)(s.Dashicon,{icon:"clock",size:24})})}),p&&(0,i.jsx)("div",{className:"related-post-linked",children:(0,i.jsx)(s.Tooltip,{text:(0,c.__)("This post is linked in the content","wp-parsely"),children:(0,i.jsx)(V,{icon:Rt,size:24})})})]}),(0,i.jsx)(Dt,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:It,iconSize:24,onClick:function(){navigator.clipboard.writeText(o.rawUrl).then((function(){u("success",(0,c.__)("URL copied to clipboard","wp-parsely"),{type:"snackbar"})}))},label:(0,c.__)("Copy URL to clipboard","wp-parsely")}),(0,i.jsx)(s.Button,{icon:(0,i.jsx)(g,{}),iconSize:18,href:o.dashUrl,target:"_blank",label:(0,c.__)("View in Parse.ly","wp-parsely")})]})]})})]})},Ft=window.wp.coreData,Gt=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 __)}}(),Ht=function(){return Ht=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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),m=v.authors,w=v.categories,_=v.tags,b=v.isReady;(0,l.useEffect)((function(){if(b){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})):[]};y({authors:e(m),categories:e(w),tags:e(_)})}}),[m,w,_,b]);var x=(0,l.useState)(!0),k=x[0],S=x[1],j=(0,l.useState)(),C=j[0],N=j[1],A=(0,l.useState)(),R=A[0],I=A[1],B=(0,l.useState)([]),M=B[0],D=B[1],V=(0,l.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=V[0],G=V[1],H=(0,l.useState)(void 0),z=H[0],U=H[1],W=(0,O.useDebounce)(U,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;W(t())}),[W]);var Z=function(e,t){u({RelatedPosts:At(At({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,l.useEffect)((function(){var e,t,n=function(e){return Ot(void 0,void 0,void 0,(function(){return Rt(this,(function(t){return Nt.getInstance().getRelatedPosts(p,d,F).then((function(e){D(e.posts),I(e.message),S(!1)})).catch((function(t){return Ot(void 0,void 0,void 0,(function(){return Rt(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),N(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===g.authors.length,c=0===g.tags.length,u=0===g.categories.length,f=i&&!g.authors.includes(F.value),h=s&&!g.tags.includes(F.value),y=a&&!g.categories.includes(F.value);return S(!0),o||s&&c||a&&u||i&&l?Object.values(g).every((function(e){return 0===e.length}))||G((e="",t=r.Unavailable,g.tags.length>=1?(t=r.Tag,e=g.tags[0]):g.categories.length>=1?(t=r.Section,e=g.categories[0]):g.authors.length>=1&&(t=r.Author,e=g.authors[0]),{type:t,value:e})):h?G({type:r.Tag,value:g.tags[0]}):y?G({type:r.Section,value:g.categories[0]}):f?G({type:r.Author,value:g.authors[0]}):n(1),function(){S(!1),D([]),I(""),N(void 0)}}),[p,d,F,g]),0===g.authors.length&&0===g.categories.length&&0===g.tags.length&&b?(0,i.jsx)("div",{className:"wp-parsely-related-posts",children:(0,i.jsx)("div",{className:"related-posts-body",children:(0,c.__)("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,c.__)("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;T(n=e,t)&&(u({RelatedPosts:At(At({},o.RelatedPosts),{Metric:n})}),h.trackEvent("related_posts_metric_changed",{metric:n}))},prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,c.__)("Metric: ","wp-parsely")}),value:d,children:Object.values(t).map((function(e){return(0,i.jsx)("option",{value:e,children:L(e)},e)}))}),(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:p,prefix:(0,i.jsxs)(s.__experimentalInputControlPrefixWrapper,{children:[(0,c.__)("Period: ","wp-parsely")," "]}),onChange:function(t){return function(t){T(t,e)&&(u({RelatedPosts:At(At({},o.RelatedPosts),{Period:t})}),h.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)(mt,{label:(0,c.__)("Filter by","wp-parsely"),filter:F,onFilterTypeChange:function(e){if(T(e,r)){var t="",n=e;r.Tag===n&&(t=g.tags[0]),r.Section===n&&(t=g.categories[0]),r.Author===n&&(t=g.authors[0]),""!==t&&(Z(n,t),G({type:n,value:t}),h.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(F.type,e),G(At(At({},F),{value:e})))},postData:g}),(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===F.type?(0,c.sprintf)(/* translators: 1: tag name, 2: period */ /* translators: 1: tag name, 2: period */ +message:(0,c.sprintf)((0,c.__)('by author "%1$s"',"wp-parsely"),n.value)};throw new H((0,c.__)("No valid filter type has been specified.","wp-parsely"),A.CannotFormulateApiQuery)},t}(be),qt=function(){return qt=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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),m=y.authors,w=y.categories,_=y.tags,b=y.isReady;(0,l.useEffect)((function(){if(b){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(_)})}}),[m,w,_,b]);var x=(0,l.useState)(!0),k=x[0],S=x[1],j=(0,l.useState)(),C=j[0],A=j[1],N=(0,l.useState)(),R=N[0],I=N[1],M=(0,l.useState)([]),B=M[0],D=M[1],V=(0,l.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=V[0],G=V[1],H=(0,l.useState)(void 0),z=H[0],W=H[1],U=(0,O.useDebounce)(W,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;U(t())}),[U]);var Z=function(e,t){u({RelatedPosts:qt(qt({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,l.useEffect)((function(){var e,t,n=function(e){return Zt(void 0,void 0,void 0,(function(){return $t(this,(function(t){return Ut.getInstance().getRelatedPosts(p,d,F).then((function(e){D(e.posts),I(e.message),S(!1)})).catch((function(t){return Zt(void 0,void 0,void 0,(function(){return $t(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),A(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===v.authors.length,c=0===v.tags.length,u=0===v.categories.length,f=i&&!v.authors.includes(F.value),h=s&&!v.tags.includes(F.value),g=a&&!v.categories.includes(F.value);return S(!0),o||s&&c||a&&u||i&&l?Object.values(v).every((function(e){return 0===e.length}))||G((e="",t=r.Unavailable,v.tags.length>=1?(t=r.Tag,e=v.tags[0]):v.categories.length>=1?(t=r.Section,e=v.categories[0]):v.authors.length>=1&&(t=r.Author,e=v.authors[0]),{type:t,value:e})):h?G({type:r.Tag,value:v.tags[0]}):g?G({type:r.Section,value:v.categories[0]}):f?G({type:r.Author,value:v.authors[0]}):n(1),function(){S(!1),D([]),I(""),A(void 0)}}),[p,d,F,v]),0===v.authors.length&&0===v.categories.length&&0===v.tags.length&&b?(0,i.jsx)("div",{className:"wp-parsely-related-posts",children:(0,i.jsx)("div",{className:"related-posts-body",children:(0,c.__)("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,c.__)("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;T(n=e,t)&&(u({RelatedPosts:qt(qt({},o.RelatedPosts),{Metric:n})}),h.trackEvent("related_posts_metric_changed",{metric:n}))},prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,c.__)("Metric: ","wp-parsely")}),value:d,children:Object.values(t).map((function(e){return(0,i.jsx)("option",{value:e,children:L(e)},e)}))}),(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:p,prefix:(0,i.jsxs)(s.__experimentalInputControlPrefixWrapper,{children:[(0,c.__)("Period: ","wp-parsely")," "]}),onChange:function(t){return function(t){T(t,e)&&(u({RelatedPosts:qt(qt({},o.RelatedPosts),{Period:t})}),h.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)(Ot,{label:(0,c.__)("Filter by","wp-parsely"),filter:F,onFilterTypeChange:function(e){if(T(e,r)){var t="",n=e;r.Tag===n&&(t=v.tags[0]),r.Section===n&&(t=v.categories[0]),r.Author===n&&(t=v.authors[0]),""!==t&&(Z(n,t),G({type:n,value:t}),h.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(F.type,e),G(qt(qt({},F),{value:e})))},postData:v}),(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===F.type?(0,c.sprintf)(/* translators: 1: tag name, 2: period */ /* translators: 1: tag name, 2: period */ (0,c.__)("Top related posts with the “%1$s” tag in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Section===F.type?(0,c.sprintf)(/* translators: 1: section name, 2: period */ /* translators: 1: section name, 2: period */ (0,c.__)("Top related posts in the “%1$s” section in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Author===F.type?(0,c.sprintf)(/* translators: 1: author name, 2: period */ /* translators: 1: author name, 2: period */ -(0,c.__)("Top related posts by %1$s in the %2$s.","wp-parsely"),F.value,E(p,!0)):null!=R?R:""})}),C&&C.Message(),k&&(0,i.jsx)("div",{className:"related-posts-loading-message","data-testid":"parsely-related-posts-loading-message",children:(0,c.__)("Loading…","wp-parsely")}),!k&&!C&&0===M.length&&(0,i.jsx)("div",{className:"related-posts-empty","data-testid":"parsely-related-posts-empty",children:(0,c.__)("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)(St,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},Bt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),Mt=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"})})},Dt={journalist:{label:(0,c.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,c.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,c.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,c.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,c.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,c.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,c.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,c.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,c.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,c.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,c.__)("Custom Persona","wp-parsely"),icon:Bt}},Vt=Object.keys(Dt),Ft=function(e){return"custom"===e||""===e?Dt.custom.label:Gt(e)?e:Dt[e].label},Gt=function(e){return!Vt.includes(e)||"custom"===e},Ht=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},zt=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,c.__)("Select a persona…","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Persona","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:Gt(t)?Dt.custom.label:r}),(0,i.jsx)(Mt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Persona","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Vt.map((function(e){if(!h&&"custom"===e)return null;var r=Dt[e],a=e===t||Gt(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(F,{icon:r.icon}),r.label]},e)}))})})}}),h&&Gt(t)&&(0,i.jsx)(Ht,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},Ut={neutral:{label:(0,c.__)("Neutral","wp-parsely")},formal:{label:(0,c.__)("Formal","wp-parsely")},humorous:{label:(0,c.__)("Humorous","wp-parsely")},confident:{label:(0,c.__)("Confident","wp-parsely")},provocative:{label:(0,c.__)("Provocative","wp-parsely")},serious:{label:(0,c.__)("Serious","wp-parsely")},inspirational:{label:(0,c.__)("Inspirational","wp-parsely")},skeptical:{label:(0,c.__)("Skeptical","wp-parsely")},conversational:{label:(0,c.__)("Conversational","wp-parsely")},analytical:{label:(0,c.__)("Analytical","wp-parsely")},custom:{label:(0,c.__)("Custom Tone","wp-parsely"),icon:Bt}},Wt=Object.keys(Ut),Zt=function(e){return"custom"===e||""===e?Ut.custom.label:qt(e)?e:Ut[e].label},qt=function(e){return!Wt.includes(e)||"custom"===e},$t=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},Kt=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,c.__)("Select a tone","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Tone","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:qt(t)?Ut.custom.label:r}),(0,i.jsx)(Mt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Select a tone","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Wt.map((function(e){if(!h&&"custom"===e)return null;var r=Ut[e],a=e===t||qt(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(F,{icon:r.icon}),r.label]},e)}))})})}}),h&&qt(t)&&(0,i.jsx)($t,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},Yt=(0,u.createElement)(p.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.Path,{d:"M10.97 10.159a3.382 3.382 0 0 0-2.857.955l1.724 1.723-2.836 2.913L7 17h1.25l2.913-2.837 1.723 1.723a3.38 3.38 0 0 0 .606-.825c.33-.63.446-1.343.35-2.032L17 10.695 13.305 7l-2.334 3.159Z"})),Qt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"})),Xt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})),Jt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z"})),en=function(){return en=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,l.createInterpolateElement)( +(0,c.__)("Top related posts by %1$s in the %2$s.","wp-parsely"),F.value,E(p,!0)):null!=R?R:""})}),C&&C.Message(),k&&(0,i.jsx)("div",{className:"related-posts-loading-message","data-testid":"parsely-related-posts-loading-message",children:(0,c.__)("Loading…","wp-parsely")}),!k&&!C&&0===B.length&&(0,i.jsx)("div",{className:"related-posts-empty","data-testid":"parsely-related-posts-empty",children:(0,c.__)("No related posts found.","wp-parsely")}),!k&&B.length>0&&(0,i.jsx)("div",{className:"related-posts-list",children:B.map((function(e){return(0,i.jsx)(Vt,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},Yt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),Qt=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"})})},Xt={journalist:{label:(0,c.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,c.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,c.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,c.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,c.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,c.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,c.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,c.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,c.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,c.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,c.__)("Custom Persona","wp-parsely"),icon:Yt}},Jt=Object.keys(Xt),en=function(e){return"custom"===e||""===e?Xt.custom.label:tn(e)?e:Xt[e].label},tn=function(e){return!Jt.includes(e)||"custom"===e},nn=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},rn=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,c.__)("Select a persona…","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Persona","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:tn(t)?Xt.custom.label:r}),(0,i.jsx)(Qt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Persona","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Jt.map((function(e){if(!h&&"custom"===e)return null;var r=Xt[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==u||u(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)(V,{icon:r.icon}),r.label]},e)}))})})}}),h&&tn(t)&&(0,i.jsx)(nn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},sn={neutral:{label:(0,c.__)("Neutral","wp-parsely")},formal:{label:(0,c.__)("Formal","wp-parsely")},humorous:{label:(0,c.__)("Humorous","wp-parsely")},confident:{label:(0,c.__)("Confident","wp-parsely")},provocative:{label:(0,c.__)("Provocative","wp-parsely")},serious:{label:(0,c.__)("Serious","wp-parsely")},inspirational:{label:(0,c.__)("Inspirational","wp-parsely")},skeptical:{label:(0,c.__)("Skeptical","wp-parsely")},conversational:{label:(0,c.__)("Conversational","wp-parsely")},analytical:{label:(0,c.__)("Analytical","wp-parsely")},custom:{label:(0,c.__)("Custom Tone","wp-parsely"),icon:Yt}},an=Object.keys(sn),on=function(e){return"custom"===e||""===e?sn.custom.label:ln(e)?e:sn[e].label},ln=function(e){return!an.includes(e)||"custom"===e},cn=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},un=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,c.__)("Select a tone","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Tone","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:ln(t)?sn.custom.label:r}),(0,i.jsx)(Qt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Select a tone","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:an.map((function(e){if(!h&&"custom"===e)return null;var r=sn[e],a=e===t||ln(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(V,{icon:r.icon}),r.label]},e)}))})})}}),h&&ln(t)&&(0,i.jsx)(cn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},pn=(0,u.createElement)(p.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.Path,{d:"M10.97 10.159a3.382 3.382 0 0 0-2.857.955l1.724 1.723-2.836 2.913L7 17h1.25l2.913-2.837 1.723 1.723a3.38 3.38 0 0 0 .606-.825c.33-.63.446-1.343.35-2.032L17 10.695 13.305 7l-2.334 3.159Z"})),dn=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"})),fn=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})),hn=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z"})),vn=function(){return vn=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,l.createInterpolateElement)( // translators: %1$s is the tone, %2$s is the persona. // translators: %1$s is the tone, %2$s is the persona. -(0,c.__)("We've generated a few titles based on the content of your post, written as a .","wp-parsely"),{tone:(0,i.jsx)("strong",{children:Zt(d)}),persona:(0,i.jsx)("strong",{children:Ft(y)})})}):(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(F,{icon:G,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==S&&(0,i.jsx)(cn,{title:S,type:xt.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(un,{pinnedTitles:b,isOpen:!0}),_.length>0&&(0,i.jsx)(fn,{suggestions:_,isOpen:!0,isLoading:w})]}),(0,i.jsx)(pn,{isLoading:w,onPersonaChange:function(e){A("Persona",e),v(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"===y,onClick:function(){return vn(void 0,void 0,void 0,(function(){return mn(this,(function(e){switch(e.label){case 0:return u(void 0),!1!==w?[3,2]:(h.trackEvent("title_suggestions_generate_pressed",{request_more:_.length>0,total_titles:_.length,total_pinned:_.filter((function(e){return e.isPinned})).length,tone:d,persona:y}),[4,(t=xt.PostTitle,n=O,r=d,i=y,vn(void 0,void 0,void 0,(function(){var e,s,a;return mn(this,(function(o){switch(o.label){case 0:return[4,E(!0)];case 1:o.sent(),e=gn.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(),u(a),T(t,[]),[3,6];case 6:return[4,E(!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,c.__)("Generating Titles…","wp-parsely"),!w&&x.length>0&&(0,c.__)("Generate More","wp-parsely"),!w&&0===x.length&&(0,c.__)("Generate Titles","wp-parsely")]})})]})})},bn=function(){return bn=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:on(d)}),persona:(0,i.jsx)("strong",{children:en(g)})})}):(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(V,{icon:F,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==S&&(0,i.jsx)(Sn,{title:S,type:Bt.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(Pn,{pinnedTitles:b,isOpen:!0}),_.length>0&&(0,i.jsx)(Tn,{suggestions:_,isOpen:!0,isLoading:w})]}),(0,i.jsx)(jn,{isLoading:w,onPersonaChange:function(e){N("Persona",e),y(e)},onSettingChange:N,onToneChange:function(e){N("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 An(void 0,void 0,void 0,(function(){return Nn(this,(function(e){switch(e.label){case 0:return u(void 0),!1!==w?[3,2]:(h.trackEvent("title_suggestions_generate_pressed",{request_more:_.length>0,total_titles:_.length,total_pinned:_.filter((function(e){return e.isPinned})).length,tone:d,persona:g}),[4,(t=Bt.PostTitle,n=O,r=d,i=g,An(void 0,void 0,void 0,(function(){var e,s,a;return Nn(this,(function(o){switch(o.label){case 0:return[4,E(!0)];case 1:o.sent(),e=Ln.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(),u(a),T(t,[]),[3,6];case 6:return[4,E(!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,c.__)("Generating Titles…","wp-parsely"),!w&&x.length>0&&(0,c.__)("Generate More","wp-parsely"),!w&&0===x.length&&(0,c.__)("Generate Titles","wp-parsely")]})})]})})},Rn=function(){return Rn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n $methods The HTTP methods to allow for the endpoint. + * @param array $args The arguments for the endpoint. + */ + public function register_endpoint_with_args( + string $endpoint, + string $callback, + array $methods = array( 'GET' ), + array $args = array() + ): void { + if ( ! apply_filters( 'wp_parsely_enable_' . convert_endpoint_to_filter_key( $endpoint ) . '_endpoint', true ) ) { + return; + } + + $rest_route_args = array( + array( + 'methods' => $methods, + 'callback' => array( $this, $callback ), + 'permission_callback' => array( $this, 'is_available_to_current_user' ), + 'args' => $args, + 'show_in_index' => static::is_available_to_current_user(), + ), + ); + + register_rest_route( 'wp-parsely/v1', $endpoint, $rest_route_args ); + } } diff --git a/src/Endpoints/content-helper/class-smart-linking-endpoint.php b/src/Endpoints/content-helper/class-smart-linking-endpoint.php index a0d88d99d..a682878f7 100644 --- a/src/Endpoints/content-helper/class-smart-linking-endpoint.php +++ b/src/Endpoints/content-helper/class-smart-linking-endpoint.php @@ -1,4 +1,10 @@ get_param( 'post_id' ); - if ( $post_id ) { + if ( null === $post_id ) { // Check if the current user has edit capabilities for the post. $can_edit = current_user_can( 'edit_post', $post_id ); } else { @@ -69,6 +78,7 @@ public function is_available_to_current_user( $request = null ): bool { // Check if the current user has the smart linking capability. $has_capability = current_user_can( + // phpcs:ignore WordPress.WP.Capabilities.Undetermined $this->apply_capability_filters( Base_Endpoint::DEFAULT_ACCESS_CAPABILITY ) @@ -77,89 +87,79 @@ public function is_available_to_current_user( $request = null ): bool { return $can_edit && $has_capability; } + /** + * Registers the endpoints. + * + * @since 3.16.0 + */ public function run(): void { $this->register_endpoint( static::ENDPOINT . '/url-to-post-type', 'url_to_post_type', array( 'POST' ) ); - // Endpoint "[post-id]/set" - /*$this->register_endpoint( - static::ENDPOINT . '/(?P\d+)/set', - 'set_smart_links', - array( 'POST' ) - ); - $this->register_endpoint( - static::ENDPOINT . '/add', + $this->register_endpoint_with_args( + static::ENDPOINT . '/(?P\d+)/add', 'add_smart_link', array( 'POST' ) ); - - $this->register_endpoint( - static::ENDPOINT . '/delete-smart-link', - 'delete_smart_link', - array( 'POST' ) - ); - - $this->register_endpoint( - static::ENDPOINT . '/get-smart-links', - 'get_smart_links', - array( 'GET' ) - );*/ - register_rest_route('wp-parsely/v1', '/smart-linking/(?P\d+)/add', array( - 'methods' => 'POST', - 'callback' => array( $this, 'add_smart_link' ), - 'permission_callback' => array( $this, 'is_available_to_current_user' ), - )); - } + /** + * Converts a URL to a post type. + * + * @param WP_REST_Request $request The request object. + * @return WP_REST_Response The response object. + */ public function url_to_post_type( WP_REST_Request $request ): WP_REST_Response { $url = $request->get_param( 'url' ); if ( ! is_string( $url ) ) { - return new WP_REST_Response( array( - 'error' => array( - 'name' => 'invalid_request', - 'message' => 'Invalid request body.', + return new WP_REST_Response( + array( + 'error' => array( + 'name' => 'invalid_request', + 'message' => 'Invalid request body.', + ), ), - ), 400 ); + 400 + ); } $post_id = 0; + $cache = wp_cache_get( $url, 'wp_parsely_smart_link_url_to_postid' ); - if ( ( $cache = wp_cache_get( $url, 'wp_parsely_smart_link_url_to_postid' ) ) !== false ) { + if ( is_integer( $cache ) ) { $post_id = $cache; - } else if ( function_exists( 'wpcom_vip_url_to_postid' ) ) { - $post_id = wpcom_vip_url_to_postid( $url ); + } elseif ( function_exists( 'wpcom_vip_url_to_postid' ) ) { + $post_id = wpcom_vip_url_to_postid( $url ); } else { - $post_id = url_to_postid( $url ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.url_to_postid_url_to_postid + // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.url_to_postid_url_to_postid + $post_id = url_to_postid( $url ); wp_cache_set( $url, $post_id, 'wp_parsely_smart_link_url_to_postid' ); } $response = array( 'data' => array( - 'post_id' => false, + 'post_id' => false, 'post_type' => false, ), ); if ( 0 !== $post_id ) { - $response['data']['post_id'] = $post_id; + $response['data']['post_id'] = $post_id; $response['data']['post_type'] = get_post_type( $post_id ); } return new WP_REST_Response( $response, 200 ); } - public function set_smart_links( WP_REST_Request $request ): string { - return 'set_smart_links'; - } - /** * Validates the request parameters. * + * @throws InvalidArgumentException If the request is invalid. + * * @param WP_REST_Request $request The request object. * @return bool True if the request is valid, false otherwise. */ @@ -179,6 +179,12 @@ private function validate_request( WP_REST_Request $request ): bool { return true; } + /** + * Adds a smart link to a post. + * + * @param WP_REST_Request $request The request object. + * @return WP_REST_Response The response object. + */ public function add_smart_link( WP_REST_Request $request ): WP_REST_Response { try { $this->validate_request( $request ); @@ -194,26 +200,34 @@ public function add_smart_link( WP_REST_Request $request ): WP_REST_Response { $json_body = $request->get_body(); $body_data = json_decode( $json_body, true ); - if ( !is_array( $body_data ) || ! isset( $body_data['link'] ) ) { - return new WP_REST_Response( array( - 'error' => array( - 'name' => 'invalid_request', - 'message' => 'Invalid request body.', + if ( ! is_array( $body_data ) || ! isset( $body_data['link'] ) ) { + return new WP_REST_Response( + array( + 'error' => array( + 'name' => 'invalid_request', + 'message' => 'Invalid request body.', + ), ), - ), 400 ); + 400 + ); } $encoded_data = wp_json_encode( $body_data['link'] ); if ( false === $encoded_data ) { - return new WP_REST_Response( array( - 'error' => array( - 'name' => 'invalid_request', - 'message' => 'Invalid request body.', + return new WP_REST_Response( + array( + 'error' => array( + 'name' => 'invalid_request', + 'message' => 'Invalid request body.', + ), ), - ), 400 ); + 400 + ); } /** + * Smart link object. + * * @var Smart_Link $smart_link The smart link object. */ $smart_link = Smart_Link::deserialize( $encoded_data ); @@ -221,36 +235,33 @@ public function add_smart_link( WP_REST_Request $request ): WP_REST_Response { // Save the smart link to the post meta. if ( ! $smart_link->save() ) { - return new WP_REST_Response( array( - 'error' => array( - 'name' => 'add_smart_link_failed', - 'message' => 'Failed to add smart link.', + return new WP_REST_Response( + array( + 'error' => array( + 'name' => 'add_smart_link_failed', + 'message' => 'Failed to add smart link.', + ), ), - ), 500 ); + 500 + ); } - return new WP_REST_Response( array( - 'data' => json_decode( $smart_link->serialize() ), - ), 200 ); + return new WP_REST_Response( + array( + 'data' => json_decode( $smart_link->serialize() ), + ), + 200 + ); } catch ( \InvalidArgumentException $e ) { - return new WP_REST_Response( array( - 'error' => array( - 'name' => 'invalid_request', - 'message' => $e->getMessage(), + return new WP_REST_Response( + array( + 'error' => array( + 'name' => 'invalid_request', + 'message' => $e->getMessage(), + ), ), - ), 400 ); + 400 + ); } } - - public function delete_smart_link( WP_REST_Request $request ): string { - return 'add_smart_link'; - } - - public function get_smart_links( WP_REST_Request $request ): string { - return 'add_smart_link'; - } - - public function delete_all_smart_links( WP_REST_Request $request ): string { - return 'add_smart_link'; - } } diff --git a/src/Models/class-base-model.php b/src/Models/class-base-model.php index 334134321..c2f4afee8 100644 --- a/src/Models/class-base-model.php +++ b/src/Models/class-base-model.php @@ -1,9 +1,9 @@ uid = $this->generate_uid(); @@ -35,7 +35,7 @@ public function __construct() { /** * Returns the unique ID of the model. * - * @since 3.15.0 + * @since 3.16.0 * * @return string The unique ID of the model. */ @@ -46,7 +46,7 @@ public function get_uid(): string { /** * Generates a unique ID for the model. * - * @since 3.15.0 + * @since 3.16.0 * * @return string The generated unique ID. */ @@ -55,7 +55,7 @@ abstract protected function generate_uid(): string; /** * Serializes the model to a JSON string. * - * @since 3.15.0 + * @since 3.16.0 * * @return string The serialized model. */ @@ -72,7 +72,7 @@ public function serialize(): string { /** * Converts the model to an array. * - * @since 3.15.0 + * @since 3.16.0 * * @return array The model as an array. */ @@ -81,17 +81,17 @@ abstract public function to_array(): array; /** * Deserializes a JSON string to a model. * - * @since 3.15.0 + * @since 3.16.0 * * @param string $json The JSON string to deserialize. * @return Base_Model The deserialized model. */ - abstract static public function deserialize( string $json ): Base_Model; + abstract public static function deserialize( string $json ): Base_Model; /** * Saves the model to the database. * - * @since 3.15.0 + * @since 3.16.0 * * @return bool True if the model was saved successfully, false otherwise. */ diff --git a/src/Models/class-smart-link.php b/src/Models/class-smart-link.php index 247e0c892..b60fec45c 100644 --- a/src/Models/class-smart-link.php +++ b/src/Models/class-smart-link.php @@ -3,19 +3,21 @@ * Smart Link model: Represents a smart link suggestion returned by the Smart Linking API. * * @package Parsely - * @since 3.15.0 + * @since 3.16.0 */ declare(strict_types=1); namespace Parsely\Models; +use InvalidArgumentException; + /** * Smart Link class * * Represents a smart link suggestion returned by the Smart Linking API. * - * @since 3.15.0 + * @since 3.16.0 */ class Smart_Link extends Base_Model { /** @@ -77,18 +79,18 @@ class Smart_Link extends Base_Model { /** * Smart Link constructor. * - * @since 3.15.0 + * @since 3.16.0 * * @param string $href The URL of the suggested link. * @param string $title The title of the suggested link. * @param string $text The text of the suggested link. - * @param int $offset The offset/position for the suggested link. + * @param int $offset The offset/position for the suggested link. */ public function __construct( string $href, string $title, string $text, int $offset ) { - $this->href = $href; - $this->title = $title; - $this->text = $text; - $this->offset = $offset; + $this->href = $href; + $this->title = $title; + $this->text = $text; + $this->offset = $offset; $this->applied = false; $this->post_id = $this->get_post_id_by_url( $href ); @@ -110,27 +112,29 @@ public function __construct( string $href, string $title, string $text, int $off /** * Gets the post ID by URL. * - * @since 3.15.0 + * @since 3.16.0 * * @param string $url The URL to get the post ID for. * @return int|false The post ID of the URL, false if not found. */ private function get_post_id_by_url( string $url ) { - if ( ( $cache = wp_cache_get( $url, 'wp_parsely_smart_link_url_to_postid' ) ) === false ) { + $cache = wp_cache_get( $url, 'wp_parsely_smart_link_url_to_postid' ); + if ( is_integer( $cache ) ) { return $cache; } if ( function_exists( 'wpcom_vip_url_to_postid' ) ) { - $post_id = wpcom_vip_url_to_postid( $url ); + $post_id = wpcom_vip_url_to_postid( $url ); } else { - $post_id = url_to_postid( $url ); // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.url_to_postid_url_to_postid + // phpcs:ignore WordPressVIPMinimum.Functions.RestrictedFunctions.url_to_postid_url_to_postid + $post_id = url_to_postid( $url ); + wp_cache_set( $url, $post_id, 'wp_parsely_smart_link_url_to_postid' ); } if ( 0 === $post_id ) { return false; } - wp_cache_set( $url, $post_id, 'wp_parsely_smart_link_url_to_postid' ); return $post_id; } @@ -140,39 +144,38 @@ private function get_post_id_by_url( string $url ) { * It takes the href, title, text, and offset properties and concatenates them * to create a unique ID. This ID is hashed to ensure it is unique. * - * @since 3.15.0 + * @since 3.16.0 * * @return string The unique ID. */ protected function generate_uid(): string { - $unique_string = md5($this->href . $this->title . $this->text . $this->offset); - return $unique_string; + return md5( $this->href . $this->title . $this->text . $this->offset ); } /** * Serializes the model to a JSON string. * - * @since 3.15.0 + * @since 3.16.0 * * @return array The serialized model. */ public function to_array(): array { - return array ( - 'uid' => $this->uid, - 'href' => $this->href, - 'title' => $this->title, - 'text' => $this->text, - 'offset' => $this->offset, - 'applied' => $this->applied, + return array( + 'uid' => $this->uid, + 'href' => $this->href, + 'title' => $this->title, + 'text' => $this->text, + 'offset' => $this->offset, + 'applied' => $this->applied, 'post_type' => $this->post_type, - 'post_id' => $this->post_id, + 'post_id' => $this->post_id, ); } /** * Sets the post ID of the suggested link. * - * @since 3.15.0 + * @since 3.16.0 * * @param int $post_id The post ID of the suggested link. */ @@ -183,17 +186,19 @@ public function set_post_id( int $post_id ): void { /** * Deserializes a JSON string to a model. * - * @since 3.15.0 + * @since 3.16.0 + * + * @throws InvalidArgumentException If the JSON data is invalid. * * @param string $json The JSON string to deserialize. * @return Base_Model The deserialized model. */ - static public function deserialize( string $json ): Base_Model { + public static function deserialize( string $json ): Base_Model { $data = json_decode( $json, true ); // Validate the JSON data. if ( ! is_array( $data ) ) { - throw new \InvalidArgumentException( 'Invalid JSON data' ); + throw new InvalidArgumentException( 'Invalid JSON data' ); } return new Smart_Link( $data['href'], $data['title'], $data['text'], $data['offset'] ); @@ -205,7 +210,7 @@ static public function deserialize( string $json ): Base_Model { * @return bool True if the smart link was saved successfully, false otherwise. */ public function save(): bool { - if ( false === $this->post_id) { + if ( false === $this->post_id ) { return false; } @@ -219,5 +224,4 @@ public function save(): bool { return add_post_meta( $this->post_id, $post_meta_key, $this->serialize(), true ) !== false; } - } diff --git a/src/RemoteAPI/content-suggestions/class-suggest-linked-reference-api.php b/src/RemoteAPI/content-suggestions/class-suggest-linked-reference-api.php index 8bcc33ee3..2e5127d5c 100644 --- a/src/RemoteAPI/content-suggestions/class-suggest-linked-reference-api.php +++ b/src/RemoteAPI/content-suggestions/class-suggest-linked-reference-api.php @@ -73,13 +73,13 @@ public function get_links( // Convert the links to Smart_Link objects. $links = array(); foreach ( $decoded->result as $link ) { - $link_obj = new Smart_Link( + $link_obj = new Smart_Link( esc_url( $link->canonical_url ), esc_attr( $link->title ), wp_kses_post( $link->text ), $link->offset ); - $links[] = $link_obj; + $links[] = $link_obj; } return $links; diff --git a/src/content-helper/common/css/variables.scss b/src/content-helper/common/css/variables.scss index e77c310a8..b9845252f 100644 --- a/src/content-helper/common/css/variables.scss +++ b/src/content-helper/common/css/variables.scss @@ -37,7 +37,7 @@ $base-unit-40: 2rem; // 32px. /** Category colors section - base scss. **/ --parsely-green-components: 107, 42%, 46%; - --parsely-green: hsl( var(--parsely-green-components) ); + --parsely-green: hsl(var(--parsely-green-components)); --parsely-green-10: hsla(98, 61%, 81%, 1); --parsely-green-65: hsla(109, 59%, 26%, 1); --gray-200: #f7f8f9; diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx index 747cf9daa..0f0db861a 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx @@ -14,7 +14,6 @@ import { select as selectFn, useDispatch, useSelect } from '@wordpress/data'; import { useEffect, useRef, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { arrowLeft, arrowRight, check, closeSmall, Icon, page } from '@wordpress/icons'; -import { filterURLForDisplay } from '@wordpress/url'; /** * Internal dependencies diff --git a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss index 4edd8caed..ebfdb71fa 100644 --- a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss +++ b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss @@ -200,6 +200,20 @@ align-self: stretch; } + .wp-parsely-link-suggestion-link-details { + text-align: left; + height: auto; + margin-bottom: var(--grid-unit-20); + + .components-menu-item__item { + display: inline-block; + max-width: 100%; /* Adjust based on the container size */ + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + } + } + .smart-linking-review-sidebar { display: flex; min-width: to_rem(220px); @@ -240,11 +254,19 @@ box-shadow: none; } + .smart-linking-menu-label { + display: flex; + align-items: center; + white-space: nowrap; + padding-left: var(--grid-unit-10); + color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)); + } + &.is-selected { background-color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)); color: #fff; - .smart-linking-menu-label{ + .smart-linking-menu-label { color: #fff; } } @@ -263,27 +285,6 @@ flex-grow: 1; //margin-right: 10px; } - - .smart-linking-menu-label { - display: flex; - align-items: center; - white-space: nowrap; - padding-left: var(--grid-unit-10); - color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)) - } - - /*.components-menu-item__item { - overflow: hidden; - white-space: nowrap; - text-overflow: ellipsis; - display: inline; - text-align: left; - }*/ - - /*.components-menu-item__shortcut { - padding-left: var(--grid-unit-10); - color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)) - }*/ } } @@ -319,21 +320,7 @@ .components-divider { width: to_rem(452px); height: 1px; - border-color: #CCC; - } - - .wp-parsely-link-suggestion-link-details { - text-align: left; - height: auto; - margin-bottom: var(--grid-unit-20); - - .components-menu-item__item { - display: inline-block; - max-width: 100%; /* Adjust based on the container size */ - overflow: hidden; - text-overflow: ellipsis; - white-space: nowrap; - } + border-color: #ccc; } .review-controls { @@ -365,9 +352,9 @@ .wp-parsely-review-suggestion-reject { border-radius: 2px; - box-shadow: inset 0 0 0 1px var(--Gutenberg-Alert-Red, #CC1818); - background: var(--Gutenberg-White, #FFF); - color: var(--Gutenberg-Alert-Red, #CC1818); + box-shadow: inset 0 0 0 1px var(--Gutenberg-Alert-Red, #cc1818); + background: var(--Gutenberg-White, #fff); + color: var(--Gutenberg-Alert-Red, #cc1818); } } } @@ -402,7 +389,7 @@ .smart-linking-highlight { border-radius: 2px; - background: hsla( var(--parsely-green-components), 0.5); + background: hsla(var(--parsely-green-components), 0.5); mix-blend-mode: multiply; text-decoration-line: underline; color: var(--sidebar-black); diff --git a/src/content-helper/editor-sidebar/smart-linking/utils.ts b/src/content-helper/editor-sidebar/smart-linking/utils.ts index 9d1a16991..234d67a6b 100644 --- a/src/content-helper/editor-sidebar/smart-linking/utils.ts +++ b/src/content-helper/editor-sidebar/smart-linking/utils.ts @@ -1,10 +1,16 @@ +/** + * WordPress dependencies + */ // eslint-disable-next-line import/named import { BlockInstance, getBlockContent } from '@wordpress/blocks'; import { dispatch, select } from '@wordpress/data'; -import { SmartLink, SmartLinkingProvider } from './provider'; + +/** + * Internal dependencies + */ +import { SmartLink } from './provider'; import { escapeRegExp } from '../../common/utils/functions'; import { SmartLinkingStore } from './store'; - export { escapeRegExp } from '../../common/utils/functions'; /** @@ -74,7 +80,7 @@ function isLinkAtNode( textNode: Text, smartLinkUID: string ): boolean { function isInsideSimilarNode( node: Node, referenceNode: HTMLElement ): boolean { let currentNode = node.parentNode; while ( currentNode ) { - // Check by nodeName or any specific attribute + // Check by nodeName or any specific attribute. if ( currentNode.nodeName === referenceNode.nodeName ) { return true; } @@ -178,8 +184,19 @@ export function applyNodeToBlock( block: BlockInstance, link: SmartLink, htmlNod return contentElement.innerHTML; } +/** + * Sorts smart links based on their block position and link position within the block. + * + * The applied links are sorted after the not applied links. + * + * @since 3.16.0 + * + * @param {SmartLink[]} smartLinks The smart links to sort. + * + * @return {SmartLink[]} The sorted smart links. + */ export function sortSmartLinks( smartLinks: SmartLink[] ): SmartLink[] { - // Break-down in two buckets: applied and not applied + // Break-down in two buckets: applied and not applied. const appliedLinks = smartLinks.filter( ( link ) => link.applied ); const notAppliedLinks = smartLinks.filter( ( link ) => ! link.applied ); @@ -223,6 +240,7 @@ function flattenBlocks( blocks: BlockInstance[], flatList: BlockInstance[] = [] * - `linked`: The number of times a link has been successfully applied for a specific link text. * * @since 3.14.1 + * @since 3.16.0 Moved from `content-helper/editor-sidebar/smart-linking/component.tsx`. */ type LinkOccurrenceCounts = { [key: string]: { @@ -232,15 +250,15 @@ type LinkOccurrenceCounts = { }; /** - * Iterates through blocks of content to apply smart link suggestions based on their text content and specific offset. + * Iterates through blocks of content to calculate the correct block and offset for each link suggestion. * * This function processes each block's content to identify and handle text nodes that match provided link suggestions. - * It filters out self-referencing links based on the given post permalink, avoids inserting links within existing anchor - * elements, and respects the specified offset for each link to determine the correct block. + * It avoids inserting links within existing anchor and respects the specified offset for each link to determine the + * correct block. * * Note: The function is recursive for blocks containing inner blocks, ensuring all nested content is processed. * - * @since 3.15.0 + * @since 3.16.0 * * @param {Readonly[]} blocks The blocks of content where links should be applied. * @param {SmartLink[]} links An array of link suggestions to apply to the content. @@ -248,7 +266,7 @@ type LinkOccurrenceCounts = { * been encountered and applied across all blocks. * @param {number} currentIndex The current index of the block being processed. * - * @return {SmartLink[]} The filtered array of link suggestions that have been successfully applied to the content. + * @return {SmartLink[]} The array of link suggestions that have been successfully applied to the content. */ export function calculateSmartLinkingMatches( blocks: Readonly[], @@ -316,6 +334,18 @@ export function calculateSmartLinkingMatches( return links; } +/** + * Gets all smart links in the post content. + * + * This function parses the post content to find all the smart links in the post content. Each smart link is + * identified by the `data-smartlink` attribute in the anchor tag. + * + * After finding all the smart links, it calculates the correct block and offset for each link suggestion. + * + * @since 3.16.0 + * + * @return {SmartLink[]} The smart links in the post content. + */ export function getAllSmartLinksInPost(): SmartLink[] { const blocks = flattenBlocks( select( 'core/block-editor' ).getBlocks() ); const postContent = select( 'core/editor' ).getEditedPostContent(); @@ -351,8 +381,8 @@ export function getAllSmartLinksInPost(): SmartLink[] { match: { blockId: block?.clientId ?? '', blockPosition: blockIndex, - blockOffset: -1, - blockLinkPosition: -1, + blockOffset: -1, // Will be calculated later. + blockLinkPosition: -1, // Will be calculated later. }, }; @@ -362,6 +392,19 @@ export function getAllSmartLinksInPost(): SmartLink[] { return calculateSmartLinkingMatches( blocks, smartLinks ); } +/** + * Gets the offset of a link in the post content. + * + * This function calculates the offset of a link in the post content by counting the number of times the link text + * is encountered before the link in the post content. + * + * @since 3.16.0 + * + * @param {HTMLAnchorElement} link The link to calculate the offset for. + * @param {Document} document The document to search the link in. + * + * @return {number} The offset of the link in the post content. + */ function getLinkOffset( link: HTMLAnchorElement, document: Document ): number { const smartLinkUID = link.dataset.smartlink; const linkText = link.textContent?.trim(); @@ -386,7 +429,7 @@ function getLinkOffset( link: HTMLAnchorElement, document: Document ): number { return occurrence; } - // Move to next occurrence of linkText in the current text node + // Move to next occurrence of linkText in the current text node. pos = nodeValue.indexOf( linkText, pos + linkText.length ); occurrence++; } @@ -411,38 +454,38 @@ function getLinkOffset( link: HTMLAnchorElement, document: Document ): number { * @return {Promise} The missing smart links that were not found in the post content. */ export async function validateAndFixSmartLinks( content: string, blockId: string|false = false ): Promise { - // Get the post content and all the smart links from the store + // Get the post content and all the smart links from the store. let smartLinks = select( SmartLinkingStore ).getSmartLinks(); - // If a blockId is provided, filter out all the smart links that don't belong to the block + // If a blockId is provided, filter out all the smart links that don't belong to the block. if ( blockId ) { smartLinks = smartLinks.filter( ( smartLink ) => smartLink.match?.blockId === blockId ); } - // Create a DOM from the post content + // Create a DOM from the post content. const parser = new DOMParser(); const doc = parser.parseFromString( content, 'text/html' ); const missingSmartLinks: SmartLink[] = []; - // Check for each smart link UID in the post content + // Check for each smart link UID in the post content. smartLinks.forEach( ( smartLink ) => { - // Search for the link with the UID in the post content + // Search for the link with the UID in the post content. const link = doc.querySelector( `a[data-smartlink="${ smartLink.uid }"]` ); - // If the link is not found, add it to the missing smart links array + // If the link is not found, add it to the missing smart links array. if ( ! link ) { missingSmartLinks.push( smartLink ); } } ); - // For each missing smart link, try to find a link that matches the text, title and href + // For each missing smart link, try to find a link that matches the text, title and href. missingSmartLinks.forEach( ( missingSmartLink ) => { if ( ! missingSmartLink.match?.blockId ) { return; } - // Get the block that contains the smart link + // Get the block that contains the smart link. const block = select( 'core/block-editor' ).getBlock( missingSmartLink.match?.blockId ); if ( ! block ) { @@ -462,14 +505,14 @@ export async function validateAndFixSmartLinks( content: string, blockId: string return; } - // If the link is found, remove it from the missing smart links array + // If the link is found, remove it from the missing smart links array. missingSmartLinks.splice( missingSmartLinks.indexOf( missingSmartLink ), 1 ); // Restore the missing fields from the link (data-smartlink and title). link.setAttribute( 'data-smartlink', missingSmartLink.uid ); link.title = missingSmartLink.title; - // Update the block content with the new content + // Update the block content with the new content. const paragraph = blockDoc.body.firstChild as HTMLElement; dispatch( 'core/block-editor' ).updateBlockAttributes( block.clientId, { content: paragraph.innerHTML } ); } ); @@ -486,7 +529,7 @@ export async function validateAndFixSmartLinksInPost(): Promise { const postContent = select( 'core/editor' ).getEditedPostContent(); const missingLinks = await validateAndFixSmartLinks( postContent ); - // Remove any missing smart-links that are not in the store + // Remove any missing smart-links that are not in the store. missingLinks.forEach( ( missingLink ) => { dispatch( SmartLinkingStore ).removeSmartLink( missingLink.uid ); } ); @@ -503,22 +546,32 @@ export async function validateAndFixSmartLinksInBlock( block: BlockInstance ): P const blockContent: string = getBlockContent( block ); const missingLinks = await validateAndFixSmartLinks( blockContent, block.clientId ); - // Remove any missing smart-links that are not in the store + // Remove any missing smart-links that are not in the store. missingLinks.forEach( ( missingLink ) => { dispatch( SmartLinkingStore ).removeSmartLink( missingLink.uid ); } ); } +/** + * Trims a URL for display, ensuring it fits within the specified maximum length. + * + * @since 3.16.0 + * + * @param {string} url The URL to trim. + * @param {number} maxLength The maximum length of the URL. + * + * @return {string} The trimmed URL. + */ export function trimURLForDisplay( url: string, maxLength: number ): string { - // Remove protocol (http, https) and www + // Remove protocol (http, https) and www. const strippedUrl = url.replace( /(^\w+:|^)\/\//, '' ).replace( /^www\./, '' ); - // If no maxLength is specified or the URL length is already less than maxLength, return the stripped URL + // If no maxLength is specified or the URL length is already less than maxLength, return the stripped URL. if ( ! maxLength || strippedUrl.length <= maxLength ) { return strippedUrl; } - // Calculate part lengths for trimming + // Calculate part lengths for trimming. const partLength = Math.floor( ( maxLength - 3 ) / 2 ); const start = strippedUrl.substring( 0, partLength ); const end = strippedUrl.substring( strippedUrl.length - partLength ); From 76ad8778dc3e843121ba8f1c87a860c7023d93ee Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Mon, 20 May 2024 14:57:09 +0100 Subject: [PATCH 26/44] Rebuild assets & fix tests --- build/admin-settings-rtl.css | 2 +- build/admin-settings.asset.php | 2 +- build/content-helper/dashboard-widget-rtl.css | 2 +- .../content-helper/dashboard-widget.asset.php | 2 +- build/content-helper/editor-sidebar-rtl.css | 10 +++++----- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.css | 2 +- build/content-helper/excerpt-generator-rtl.css | 2 +- .../content-helper/excerpt-generator.asset.php | 2 +- tests/Integration/BaseUserMetaEndpointTest.php | 18 ++++++++++++++++++ tests/Integration/ProxyEndpointTest.php | 2 +- .../SuggestLinkedReferenceAPITest.php | 3 ++- 12 files changed, 34 insertions(+), 15 deletions(-) diff --git a/build/admin-settings-rtl.css b/build/admin-settings-rtl.css index 8a59b2979..21a2880dd 100644 --- a/build/admin-settings-rtl.css +++ b/build/admin-settings-rtl.css @@ -1 +1 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.settings_page_parsely{--padding-default:15px}.settings_page_parsely #track-post-types{max-width:550px;width:100%}.settings_page_parsely #track-post-types td,.settings_page_parsely #track-post-types th{display:table-cell;padding:var(--padding-default);text-align:center;vertical-align:middle}.settings_page_parsely #track-post-types td{padding:0}.settings_page_parsely #track-post-types td label{display:inline-block;margin:0!important;padding-bottom:var(--padding-default);padding-top:var(--padding-default);width:100%}.settings_page_parsely #track-post-types thead th:nth-child(3){word-break:break-word}.settings_page_parsely fieldset:disabled *,.settings_page_parsely tr:has(fieldset:disabled) *{color:var(--gray-500);cursor:default}.settings_page_parsely .managed-option-badge{border:.0625rem solid var(--green-500);border-radius:.25rem;color:var(--green-500)!important;display:inline-block;font-size:.625rem;padding:.125rem .25rem;text-decoration:none}.settings_page_parsely a.managed-option-badge{cursor:pointer!important}.settings_page_parsely a.managed-option-badge:hover{background-color:var(--green-500);color:#fff!important}@media only screen and (max-width:380px){.settings_page_parsely #track-post-types td,.settings_page_parsely #track-post-types th{padding-right:10px;padding-left:10px}.settings_page_parsely #track-post-types th:first-child{max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.settings_page_parsely{--padding-default:15px}.settings_page_parsely #track-post-types{max-width:550px;width:100%}.settings_page_parsely #track-post-types td,.settings_page_parsely #track-post-types th{display:table-cell;padding:var(--padding-default);text-align:center;vertical-align:middle}.settings_page_parsely #track-post-types td{padding:0}.settings_page_parsely #track-post-types td label{display:inline-block;margin:0!important;padding-bottom:var(--padding-default);padding-top:var(--padding-default);width:100%}.settings_page_parsely #track-post-types thead th:nth-child(3){word-break:break-word}.settings_page_parsely fieldset:disabled *,.settings_page_parsely tr:has(fieldset:disabled) *{color:var(--gray-500);cursor:default}.settings_page_parsely .managed-option-badge{border:.0625rem solid var(--green-500);border-radius:.25rem;color:var(--green-500)!important;display:inline-block;font-size:.625rem;padding:.125rem .25rem;text-decoration:none}.settings_page_parsely a.managed-option-badge{cursor:pointer!important}.settings_page_parsely a.managed-option-badge:hover{background-color:var(--green-500);color:#fff!important}@media only screen and (max-width:380px){.settings_page_parsely #track-post-types td,.settings_page_parsely #track-post-types th{padding-right:10px;padding-left:10px}.settings_page_parsely #track-post-types th:first-child{max-width:120px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}} diff --git a/build/admin-settings.asset.php b/build/admin-settings.asset.php index 3e4513aea..91d66c680 100644 --- a/build/admin-settings.asset.php +++ b/build/admin-settings.asset.php @@ -1 +1 @@ - array(), 'version' => 'e15999c17e352b22474b'); + array(), 'version' => '20eafa29410328a029a2'); diff --git a/build/content-helper/dashboard-widget-rtl.css b/build/content-helper/dashboard-widget-rtl.css index 1054e63a2..447c1c3cf 100644 --- a/build/content-helper/dashboard-widget-rtl.css +++ b/build/content-helper/dashboard-widget-rtl.css @@ -1 +1 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}#wp-parsely-dashboard-widget{color:var(--base-text);font-family:var(--base-font)}#wp-parsely-dashboard-widget .parsely-spinner-wrapper{display:flex;justify-content:center;margin:11.875rem 0}#wp-parsely-dashboard-widget .parsely-spinner-wrapper svg{height:22px;width:22px}#wp-parsely-dashboard-widget .content-helper-error-message{margin-top:1.125rem}#wp-parsely-dashboard-widget p.content-helper-error-message-hint{color:var(--gray-700)}#wp-parsely-dashboard-widget .parsely-top-posts-filters{display:flex;justify-content:space-between;margin-bottom:.625rem}#wp-parsely-dashboard-widget .parsely-top-posts-navigation{display:flex;justify-content:space-between;margin-top:.625rem}#wp-parsely-dashboard-widget .parsely-top-posts-navigation button{background:none;border:none;color:var(--blue-550);font-size:.75rem;font-weight:600;text-decoration:none}#wp-parsely-dashboard-widget .parsely-top-posts-navigation button:disabled{visibility:hidden}#wp-parsely-dashboard-widget .parsely-top-posts-navigation button:not([disabled]):hover{cursor:pointer}#wp-parsely-dashboard-widget .parsely-top-post-content{display:flex}#wp-parsely-dashboard-widget .parsely-top-post-content:before{content:counter(item) "";counter-increment:item;padding-left:.5rem}@media only screen and (max-width:380px){#wp-parsely-dashboard-widget .parsely-top-post-content:before{content:"";padding-left:0}}#wp-parsely-dashboard-widget .parsely-top-posts{list-style:none;margin:1rem 0 0}#wp-parsely-dashboard-widget .parsely-top-post{margin-bottom:1rem}#wp-parsely-dashboard-widget .parsely-top-post-thumbnail{height:46px;min-width:46px}#wp-parsely-dashboard-widget .parsely-top-post-thumbnail img{height:100%;width:100%}#wp-parsely-dashboard-widget .parsely-top-post-data{border-top:1px solid var(--gray-300);flex-grow:1;margin-right:.5rem;padding-top:.25rem}#wp-parsely-dashboard-widget .parsely-top-post-title{color:var(--base-text);font-size:.875rem;margin-left:.4375rem}#wp-parsely-dashboard-widget a.parsely-top-post-title:hover{color:var(--blue-550)}#wp-parsely-dashboard-widget .parsely-top-post-icon-link{position:relative;top:.25rem}#wp-parsely-dashboard-widget .parsely-top-post-icon-link svg{fill:#8d98a1;margin-left:.1875rem}#wp-parsely-dashboard-widget .parsely-top-post-icon-link svg:hover{fill:var(--blue-550)}#wp-parsely-dashboard-widget .parsely-top-post-metadata{margin:.25rem 0 0}#wp-parsely-dashboard-widget .parsely-top-post-metadata>span{color:var(--gray-500)}#wp-parsely-dashboard-widget .parsely-top-post-metadata>span:not(:first-child){margin-right:.75rem}#wp-parsely-dashboard-widget .parsely-post-metric-data{float:left;font-family:var(--numeric-font);font-size:1.125rem;padding-right:.625rem} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}#wp-parsely-dashboard-widget{color:var(--base-text);font-family:var(--base-font)}#wp-parsely-dashboard-widget .parsely-spinner-wrapper{display:flex;justify-content:center;margin:11.875rem 0}#wp-parsely-dashboard-widget .parsely-spinner-wrapper svg{height:22px;width:22px}#wp-parsely-dashboard-widget .content-helper-error-message{margin-top:1.125rem}#wp-parsely-dashboard-widget p.content-helper-error-message-hint{color:var(--gray-700)}#wp-parsely-dashboard-widget .parsely-top-posts-filters{display:flex;justify-content:space-between;margin-bottom:.625rem}#wp-parsely-dashboard-widget .parsely-top-posts-navigation{display:flex;justify-content:space-between;margin-top:.625rem}#wp-parsely-dashboard-widget .parsely-top-posts-navigation button{background:none;border:none;color:var(--blue-550);font-size:.75rem;font-weight:600;text-decoration:none}#wp-parsely-dashboard-widget .parsely-top-posts-navigation button:disabled{visibility:hidden}#wp-parsely-dashboard-widget .parsely-top-posts-navigation button:not([disabled]):hover{cursor:pointer}#wp-parsely-dashboard-widget .parsely-top-post-content{display:flex}#wp-parsely-dashboard-widget .parsely-top-post-content:before{content:counter(item) "";counter-increment:item;padding-left:.5rem}@media only screen and (max-width:380px){#wp-parsely-dashboard-widget .parsely-top-post-content:before{content:"";padding-left:0}}#wp-parsely-dashboard-widget .parsely-top-posts{list-style:none;margin:1rem 0 0}#wp-parsely-dashboard-widget .parsely-top-post{margin-bottom:1rem}#wp-parsely-dashboard-widget .parsely-top-post-thumbnail{height:46px;min-width:46px}#wp-parsely-dashboard-widget .parsely-top-post-thumbnail img{height:100%;width:100%}#wp-parsely-dashboard-widget .parsely-top-post-data{border-top:1px solid var(--gray-300);flex-grow:1;margin-right:.5rem;padding-top:.25rem}#wp-parsely-dashboard-widget .parsely-top-post-title{color:var(--base-text);font-size:.875rem;margin-left:.4375rem}#wp-parsely-dashboard-widget a.parsely-top-post-title:hover{color:var(--blue-550)}#wp-parsely-dashboard-widget .parsely-top-post-icon-link{position:relative;top:.25rem}#wp-parsely-dashboard-widget .parsely-top-post-icon-link svg{fill:#8d98a1;margin-left:.1875rem}#wp-parsely-dashboard-widget .parsely-top-post-icon-link svg:hover{fill:var(--blue-550)}#wp-parsely-dashboard-widget .parsely-top-post-metadata{margin:.25rem 0 0}#wp-parsely-dashboard-widget .parsely-top-post-metadata>span{color:var(--gray-500)}#wp-parsely-dashboard-widget .parsely-top-post-metadata>span:not(:first-child){margin-right:.75rem}#wp-parsely-dashboard-widget .parsely-post-metric-data{float:left;font-family:var(--numeric-font);font-size:1.125rem;padding-right:.625rem} diff --git a/build/content-helper/dashboard-widget.asset.php b/build/content-helper/dashboard-widget.asset.php index 65368a141..670d941c1 100644 --- a/build/content-helper/dashboard-widget.asset.php +++ b/build/content-helper/dashboard-widget.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '930369a3015a8fbd0eee'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-element', 'wp-i18n', 'wp-url'), 'version' => '2a085e2f1803cbb45764'); diff --git a/build/content-helper/editor-sidebar-rtl.css b/build/content-helper/editor-sidebar-rtl.css index d0c845940..d04059502 100644 --- a/build/content-helper/editor-sidebar-rtl.css +++ b/build/content-helper/editor-sidebar-rtl.css @@ -1,5 +1,5 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;right:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 0 0 var(--grid-unit-15);order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)} -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-performance-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}.wp-parsely-content-helper .wp-parsely-performance-panel .content-helper-error-message{margin:0!important}.wp-parsely-content-helper .wp-parsely-performance-panel .components-button.wp-parsely-view-post{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .panel-body{width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.5rem;padding:.375rem 0 1rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header{align-items:center;display:flex;gap:.375rem;height:1rem;margin-bottom:0;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2{margin-bottom:.9375rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2 h2{margin-bottom:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-3 h3{font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:1rem;margin-bottom:0;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-subtitle{align-items:center;align-self:stretch;color:var(--Gutenberg-Gray-700,#757575);display:flex;flex:1 0 0;font-size:var(--font-size--smaller);font-style:normal;font-weight:600;gap:.375rem;height:1rem;line-height:1rem;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .components-heading{display:block;font-weight:500;line-height:normal;margin:0}.wp-parsely-content-helper .wp-parsely-performance-panel .components-dropdown-menu{line-height:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points{align-content:flex-start;align-items:flex-start;align-self:stretch;display:flex;flex-wrap:wrap;gap:1rem var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point{align-items:center;background:var(--sidebar-white);border-radius:.25rem;display:flex;flex:1 0 0;flex-direction:column;gap:var(--grid-unit-5);justify-content:center;min-width:100px;padding:var(--grid-unit-20) var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point svg{align-items:flex-start;border-radius:.125rem;display:flex}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-title{align-self:stretch;color:var(--sidebar-black);font-size:.75rem;font-style:normal;font-weight:400;line-height:1rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value{align-self:stretch;color:var(--sidebar-black);font-size:1.25rem;font-style:normal;font-weight:590;line-height:1.75rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value.is-small{font-size:var(--font-size--medium)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar{align-items:flex-start;align-self:stretch;display:flex;height:1rem;margin:1rem 0;position:relative}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill{--radius:2px;align-self:stretch;position:relative;transition:filter .1s ease,transform .1s ease}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:hover{filter:opacity(1)!important;transform:scaleX(1) scaleY(1)!important}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:first-child{border-radius:0 var(--radius) var(--radius) 0}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:last-child{border-radius:var(--radius) 0 0 var(--radius)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar:hover .bar-fill{filter:opacity(.5);transform:scaleX(1) scaleY(.7)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label{align-items:center;align-self:stretch;display:flex;gap:.5rem;justify-content:center}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color{align-items:center;border-radius:.09375rem;display:flex;flex-direction:column;gap:.625rem;height:.625rem;justify-content:center;width:.1875rem}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1 0 0;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-value{color:var(--sidebar-black);font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;text-align:left}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:1rem 0}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-10);justify-content:space-between}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar{display:flex;flex:1;flex-direction:column;gap:.625rem;justify-content:center;max-width:6.25rem}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar{--radius:1.5px;background:var(--gray-400);border-radius:var(--radius);display:flex;height:.1875rem;margin:0;overflow:hidden}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar:after{background:var(--blueberry,#3858e9);border-radius:var(--radius);content:"";height:100%;width:var(--bar-fill)}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-value{color:var(--sidebar-black);flex-shrink:0;font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;min-width:3.125rem;text-align:left} -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-related-posts{align-items:flex-start;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-description{font-size:.8125rem;font-style:normal;font-weight:400;gap:.625rem;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body,.wp-parsely-related-posts .related-posts-description{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body{gap:1rem}.wp-parsely-related-posts .related-posts-body>div{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings{align-self:stretch;display:flex;flex-direction:column;gap:1rem;width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings{display:flex;flex-direction:column;gap:var(--grid-unit-20);width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control{height:2.5rem;overflow:hidden}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex{height:2.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex input{margin:0 var(--grid-unit-15)}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-descr{font-size:.8125rem;font-style:normal;font-weight:400;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-empty,.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-loading-message{color:var(--gray-900);font-size:.75rem;font-style:normal;font-weight:700;line-height:var(--grid-unit-20);overflow:hidden;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-title{align-items:center;align-self:stretch;display:flex;flex-direction:column;font-size:.875rem;font-style:normal;font-weight:600;gap:.5rem;justify-content:center;line-height:1.25rem;overflow:hidden;padding:var(--grid-unit-20);text-decoration-line:underline;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions{align-items:center;align-self:stretch;border-top:1px solid var(--gray-400);display:flex;flex-wrap:wrap;padding:0 var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:first-child,.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:last-child{display:flex;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric{align-items:center;display:flex}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric .parsely-post-metric-data{align-items:center;display:flex;gap:var(--grid-unit-5)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-linked{align-items:center;display:flex;margin-right:auto;fill:#008a20}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon path{fill:#1e1e1e}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon:hover path{fill:#0073aa} -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper{display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings>div{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding-bottom:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header .parsely-write-titles-text strong{text-transform:lowercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding-top:.375rem}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate .components-button{align-items:center;align-self:stretch;border-radius:2px;display:flex;height:2.5rem;justify-content:center;padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-dropdown-label{align-self:stretch;color:var(--sidebar-black);font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:var(--grid-unit-20);text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title{font-size:1rem;font-weight:600;line-height:1.25rem;margin:0 0 .9375rem;text-align:center}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title-actions{display:flex;gap:.625rem;justify-content:center;margin:.625rem 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion.pinned-title{background:var(--Gutenberg-Gray-100,#f0f0f0)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title{align-items:center;align-self:stretch;color:#1e1e1e;display:flex;flex-direction:column;font-size:.75rem;font-style:normal;font-weight:600;gap:var(--grid-unit-10);justify-content:center;line-height:1.25rem;padding:var(--grid-unit-15) var(--grid-unit-15) 0 var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title .suggested-title-original{align-self:flex-start;margin:0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions{align-items:center;align-self:stretch;border-top:1px solid var(--Gutenberg-Gray-400,#ccc);display:flex;flex-wrap:wrap;height:2.5rem;padding:0 var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-left,.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-right{display:flex;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin-bottom:var(--grid-unit-20);position:relative}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay{align-items:center;background-color:hsla(0,0%,100%,.9);bottom:0;display:flex;flex-direction:column;gap:var(--grid-unit-10);justify-content:center;right:0;position:absolute;left:0;top:0;z-index:1}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay .components-spinner{transform:scale(1.125)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-pinned-suggestions{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-content-helper-error.components-notice{margin-bottom:var(--grid-unit-10)}.wp-parsely-popover .components-popover__content{width:15.5rem}.wp-parsely-suggested-title-modal{align-items:flex-start;display:flex;flex-direction:column;width:20rem}.wp-parsely-suggested-title-modal h2{color:var(--sidebar-black);font-size:1rem;font-style:normal;font-weight:600;line-height:1.5rem}.wp-parsely-suggested-title-modal .suggested-title-modal-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;margin-top:1.5rem} -.parsely-tone-selector-dropdown{align-items:center;align-self:stretch;background:var(--Gutenberg-White,#fff);border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;height:2.25rem;overflow-wrap:break-word;width:100%;word-break:break-word}.parsely-tone-selector-dropdown button{height:2.0625rem}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle.has-icon svg:first-child{display:none}.parsely-tone-selector-dropdown.is-disabled{opacity:.5;pointer-events:none}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle{display:flex;gap:.625rem;width:100%}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle svg:first-of-type path{transform:scale(1.4);transform-origin:center}.parsely-tone-selector-dropdown .parsely-tone-selector-label{flex-grow:2;padding:0 var(--grid-unit-10);text-align:right}.parsely-tone-selector-dropdown .parsely-tone-selector-label:first-letter{text-transform:uppercase}.parsely-persona-selector-custom{width:100%}.parsely-persona-selector-custom .components-base-control__field input{display:flex;height:2.5rem;padding:var(--grid-unit-15) var(--grid-unit-20)}.parsely-persona-selector-custom .components-base-control__field input,.parsely-persona-selector-dropdown{align-items:center;align-self:stretch;border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px}.parsely-persona-selector-dropdown{background:var(--Gutenberg-White,#fff);height:2.25rem;overflow-wrap:break-word;width:100%;word-break:break-word}.parsely-persona-selector-dropdown .components-dropdown-menu__toggle.has-icon svg:first-child{display:none}.parsely-persona-selector-dropdown button{height:2.0625rem}.parsely-persona-selector-dropdown.is-disabled{opacity:.5;pointer-events:none}.parsely-persona-selector-dropdown .components-dropdown-menu__toggle{display:flex;gap:.625rem;width:100%}.parsely-persona-selector-dropdown .parsely-persona-selector-label{flex-grow:2;padding:0 var(--grid-unit-10);text-align:right}.parsely-persona-selector-dropdown .parsely-persona-selector-label:first-letter{text-transform:uppercase}.parsely-tone-selector-custom{width:100%}.parsely-tone-selector-custom .components-base-control__field input{align-items:center;align-self:stretch;border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;display:flex;height:2.5rem;padding:var(--grid-unit-15) var(--grid-unit-20)}#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.parsely-inputrange-control{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.parsely-inputrange-control .parsely-inputrange-control__label{margin:0}.parsely-inputrange-control .parsely-inputrange-control__controls{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-20);height:2.5rem}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control{display:flex;flex:1 0 0}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]::-webkit-inner-spin-button,.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]{-moz-appearance:textfield}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control .components-base-control__field{flex-grow:1}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control .components-input-control__suffix{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.parsely-inputrange-control .parsely-inputrange-control__controls .components-range-control{flex:1 0 0;height:36px}.parsely-inputrange-control .parsely-inputrange-control__controls .components-range-control .components-range-control__root{height:2.5rem}.parsely-panel-settings{width:100%}.parsely-panel-settings .parsely-panel-settings-header{display:flex;margin:.625rem 0;width:100%}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label{flex-grow:2;margin:0 .3125rem 0 0;text-align:right}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label .components-base-control__field{align-items:center;display:flex;justify-content:space-between}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label .components-base-control__field .components-base-control__label{margin-bottom:0}.parsely-panel-settings .parsely-panel-settings-body{align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper-error{align-self:flex-start;margin:0}.wp-parsely-content-helper-error p{margin:0}.wp-parsely-content-helper-error .content-helper-error-message{margin:0!important}.wp-parsely-collapsible-panel{align-items:flex-start;align-self:stretch;border-bottom:none;border-radius:2px;border-top:none;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:0 0 .5rem;padding:0}.wp-parsely-collapsible-panel .components-panel__body-title{align-items:center;align-self:stretch;display:flex;margin:0 -1rem .375rem;padding:0}.wp-parsely-collapsible-panel .components-panel__body-title .components-panel__icon,.wp-parsely-collapsible-panel .components-panel__body-title svg{margin-right:0;margin-left:var(--grid-unit-10);order:-1}.wp-parsely-collapsible-panel .components-panel__body-title:hover{background-color:transparent}.wp-parsely-collapsible-panel.is-opened{padding:0}.wp-parsely-collapsible-panel.is-opened>div:first-of-type{margin-top:calc(var(--grid-unit-20)*-1)}.wp-parsely-collapsible-panel.is-opened .components-panel__body-title{margin:0 calc(var(--grid-unit-20)*-1) .375rem;padding-bottom:0}.wp-parsely-collapsible-panel .components-panel__body-toggle.components-button{color:var(--Gutenberg-Gray-900,#1e1e1e);font-size:.6875rem;font-style:normal;font-weight:600;line-height:1rem;padding:var(--grid-unit-20) var(--grid-unit-20);text-transform:uppercase}.wp-parsely-collapsible-panel .components-panel__body-toggle.components-button .components-panel__arrow{margin-left:0}.wp-parsely-collapsible-panel .components-panel__body.is-opened{padding:0}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"]:focus,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"]:hover{background-color:#fff}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed:hover{background-color:var(--parsely-green-65)}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed .wp-parsely-sidebar-icon path,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed:hover .wp-parsely-sidebar-icon path{fill:var(--parsely-green-10)}.content-helper-error-message,.wp-parsely-content-helper-error .content-helper-error-message{margin-top:.9375rem!important}p.content-helper-error-message-hint{color:var(--gray-700)}.wp-parsely-content-helper-error.components-notice .components-notice__content{margin:0}.wp-parsely-content-helper-error.components-notice .components-notice__content .content-helper-error-message{margin-top:0!important}.wp-parsely-content-helper-error.components-notice .components-notice__content .content-helper-error-message p:last-child{margin-bottom:0!important}.wp-parsely-content-helper .wp-parsely-sidebar-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:1.5rem}.wp-parsely-content-helper .wp-parsely-sidebar-header .components-button{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .components-panel .panel-settings-button>button,.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .components-panel button.panel-settings-button{height:unset;min-width:unset;padding:0}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-panel>.content-helper-error-message{margin:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs button{align-items:center;display:flex;flex:1 0 0;flex-direction:column;height:3rem}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs .components-tab-panel__tabs-item:after{background:var(--gray-400);height:calc(var(--wp-admin-border-width-focus)*1);outline:2px solid transparent;outline-offset:-1px}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs .components-tab-panel__tabs-item.is-active:after{background:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-content-helper .parsely-spinner-wrapper{display:flex;justify-content:center;margin:2.5rem 0}.wp-parsely-content-helper .parsely-spinner-wrapper svg{height:22px;width:22px} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;right:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 0 0 var(--grid-unit-15);order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate,.wp-parsely-smart-linking .smart-linking-manage{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button,.wp-parsely-smart-linking .smart-linking-manage button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)}.wp-parsely-smart-linking-review-modal{align-items:flex-start;display:flex;flex-direction:column;width:47.875rem}.wp-parsely-smart-linking-review-modal .smart-linking-modal-body{align-self:stretch;display:flex;flex-direction:row;gap:var(--grid-unit-30)}.wp-parsely-smart-linking-review-modal .wp-parsely-link-suggestion-link-details{height:auto;margin-bottom:var(--grid-unit-20);text-align:right}.wp-parsely-smart-linking-review-modal .wp-parsely-link-suggestion-link-details .components-menu-item__item{display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);max-height:25rem;min-width:13.75rem;overflow-y:auto;padding:3px}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header{align-items:center;align-self:stretch;color:var(--sidebar-black);display:flex;font-size:11px;font-style:normal;font-weight:600;gap:6px;line-height:var(--grid-unit-20);margin-bottom:var(--grid-unit-15);text-transform:uppercase}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header>span{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button{align-items:center;display:flex;justify-content:space-between;width:13.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button:focus{box-shadow:none;outline:none}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-label{align-items:center;color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));display:flex;padding-right:var(--grid-unit-10);white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected{background-color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected .smart-linking-menu-label{color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__item{padding-left:0;width:100%}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-item{display:inline;flex-grow:1;overflow:hidden;text-align:right;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion{align-items:flex-start;align-self:stretch;display:flex;flex:1;flex-direction:column;gap:16px;max-width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs{font-size:.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-separator{margin:0 var(--grid-unit-5)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-block{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block{color:var(--sidebar-black)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block .breadcrumbs-current-block-name{margin-right:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .components-divider{border-color:#ccc;height:1px;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls{align-items:center;align-self:stretch;display:flex;flex-shrink:0;justify-content:space-between;margin:0 var(--grid-unit-20);-webkit-user-select:none;-moz-user-select:none;user-select:none;width:452px}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .reviews-controls-middle{align-items:center;display:flex;flex:1 0 0;gap:var(--grid-unit-20,16px);justify-content:center}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-next,.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-previous{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-reject{background:var(--Gutenberg-White,#fff);border-radius:2px;box-shadow:inset 0 0 0 1px var(--Gutenberg-Alert-Red,#cc1818);color:var(--Gutenberg-Alert-Red,#cc1818)}.wp-parsely-smart-linking-close-dialog{align-items:flex-start;display:flex;flex-direction:column;width:24rem}.wp-parsely-smart-linking-close-dialog .smart-linking-close-dialog-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;padding-top:var(--grid-unit-30)}.wp-parsely-preview-editor.editor-styles-wrapper{font-size:var(--font-size--medium);padding-bottom:0}.wp-parsely-preview-editor p[role=document]{margin:0}.wp-parsely-preview-editor .smart-linking-highlight{background:hsla(var(--parsely-green-components),.5);border-radius:2px;color:var(--sidebar-black);mix-blend-mode:multiply;text-decoration-line:underline} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-performance-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}.wp-parsely-content-helper .wp-parsely-performance-panel .content-helper-error-message{margin:0!important}.wp-parsely-content-helper .wp-parsely-performance-panel .components-button.wp-parsely-view-post{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .panel-body{width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.5rem;padding:.375rem 0 1rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header{align-items:center;display:flex;gap:.375rem;height:1rem;margin-bottom:0;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2{margin-bottom:.9375rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2 h2{margin-bottom:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-3 h3{font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:1rem;margin-bottom:0;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-subtitle{align-items:center;align-self:stretch;color:var(--Gutenberg-Gray-700,#757575);display:flex;flex:1 0 0;font-size:var(--font-size--smaller);font-style:normal;font-weight:600;gap:.375rem;height:1rem;line-height:1rem;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .components-heading{display:block;font-weight:500;line-height:normal;margin:0}.wp-parsely-content-helper .wp-parsely-performance-panel .components-dropdown-menu{line-height:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points{align-content:flex-start;align-items:flex-start;align-self:stretch;display:flex;flex-wrap:wrap;gap:1rem var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point{align-items:center;background:var(--sidebar-white);border-radius:.25rem;display:flex;flex:1 0 0;flex-direction:column;gap:var(--grid-unit-5);justify-content:center;min-width:100px;padding:var(--grid-unit-20) var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point svg{align-items:flex-start;border-radius:.125rem;display:flex}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-title{align-self:stretch;color:var(--sidebar-black);font-size:.75rem;font-style:normal;font-weight:400;line-height:1rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value{align-self:stretch;color:var(--sidebar-black);font-size:1.25rem;font-style:normal;font-weight:590;line-height:1.75rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value.is-small{font-size:var(--font-size--medium)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar{align-items:flex-start;align-self:stretch;display:flex;height:1rem;margin:1rem 0;position:relative}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill{--radius:2px;align-self:stretch;position:relative;transition:filter .1s ease,transform .1s ease}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:hover{filter:opacity(1)!important;transform:scaleX(1) scaleY(1)!important}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:first-child{border-radius:0 var(--radius) var(--radius) 0}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:last-child{border-radius:var(--radius) 0 0 var(--radius)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar:hover .bar-fill{filter:opacity(.5);transform:scaleX(1) scaleY(.7)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label{align-items:center;align-self:stretch;display:flex;gap:.5rem;justify-content:center}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color{align-items:center;border-radius:.09375rem;display:flex;flex-direction:column;gap:.625rem;height:.625rem;justify-content:center;width:.1875rem}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1 0 0;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-value{color:var(--sidebar-black);font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;text-align:left}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:1rem 0}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-10);justify-content:space-between}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar{display:flex;flex:1;flex-direction:column;gap:.625rem;justify-content:center;max-width:6.25rem}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar{--radius:1.5px;background:var(--gray-400);border-radius:var(--radius);display:flex;height:.1875rem;margin:0;overflow:hidden}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar:after{background:var(--blueberry,#3858e9);border-radius:var(--radius);content:"";height:100%;width:var(--bar-fill)}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-value{color:var(--sidebar-black);flex-shrink:0;font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;min-width:3.125rem;text-align:left} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-related-posts{align-items:flex-start;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-description{font-size:.8125rem;font-style:normal;font-weight:400;gap:.625rem;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body,.wp-parsely-related-posts .related-posts-description{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body{gap:1rem}.wp-parsely-related-posts .related-posts-body>div{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings{align-self:stretch;display:flex;flex-direction:column;gap:1rem;width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings{display:flex;flex-direction:column;gap:var(--grid-unit-20);width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control{height:2.5rem;overflow:hidden}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex{height:2.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex input{margin:0 var(--grid-unit-15)}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-descr{font-size:.8125rem;font-style:normal;font-weight:400;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-empty,.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-loading-message{color:var(--gray-900);font-size:.75rem;font-style:normal;font-weight:700;line-height:var(--grid-unit-20);overflow:hidden;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-title{align-items:center;align-self:stretch;display:flex;flex-direction:column;font-size:.875rem;font-style:normal;font-weight:600;gap:.5rem;justify-content:center;line-height:1.25rem;overflow:hidden;padding:var(--grid-unit-20);text-decoration-line:underline;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions{align-items:center;align-self:stretch;border-top:1px solid var(--gray-400);display:flex;flex-wrap:wrap;padding:0 var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:first-child,.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:last-child{display:flex;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric{align-items:center;display:flex}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric .parsely-post-metric-data{align-items:center;display:flex;gap:var(--grid-unit-5)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-linked{align-items:center;display:flex;margin-right:auto;fill:#008a20}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon path{fill:#1e1e1e}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon:hover path{fill:#0073aa} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper{display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings>div{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding-bottom:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header .parsely-write-titles-text strong{text-transform:lowercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding-top:.375rem}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate .components-button{align-items:center;align-self:stretch;border-radius:2px;display:flex;height:2.5rem;justify-content:center;padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-dropdown-label{align-self:stretch;color:var(--sidebar-black);font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:var(--grid-unit-20);text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title{font-size:1rem;font-weight:600;line-height:1.25rem;margin:0 0 .9375rem;text-align:center}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title-actions{display:flex;gap:.625rem;justify-content:center;margin:.625rem 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion.pinned-title{background:var(--Gutenberg-Gray-100,#f0f0f0)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title{align-items:center;align-self:stretch;color:#1e1e1e;display:flex;flex-direction:column;font-size:.75rem;font-style:normal;font-weight:600;gap:var(--grid-unit-10);justify-content:center;line-height:1.25rem;padding:var(--grid-unit-15) var(--grid-unit-15) 0 var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title .suggested-title-original{align-self:flex-start;margin:0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions{align-items:center;align-self:stretch;border-top:1px solid var(--Gutenberg-Gray-400,#ccc);display:flex;flex-wrap:wrap;height:2.5rem;padding:0 var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-left,.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-right{display:flex;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin-bottom:var(--grid-unit-20);position:relative}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay{align-items:center;background-color:hsla(0,0%,100%,.9);bottom:0;display:flex;flex-direction:column;gap:var(--grid-unit-10);justify-content:center;right:0;position:absolute;left:0;top:0;z-index:1}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay .components-spinner{transform:scale(1.125)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-pinned-suggestions{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-content-helper-error.components-notice{margin-bottom:var(--grid-unit-10)}.wp-parsely-popover .components-popover__content{width:15.5rem}.wp-parsely-suggested-title-modal{align-items:flex-start;display:flex;flex-direction:column;width:20rem}.wp-parsely-suggested-title-modal h2{color:var(--sidebar-black);font-size:1rem;font-style:normal;font-weight:600;line-height:1.5rem}.wp-parsely-suggested-title-modal .suggested-title-modal-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;margin-top:1.5rem} +.parsely-tone-selector-dropdown{align-items:center;align-self:stretch;background:var(--Gutenberg-White,#fff);border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;height:2.25rem;overflow-wrap:break-word;width:100%;word-break:break-word}.parsely-tone-selector-dropdown button{height:2.0625rem}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle.has-icon svg:first-child{display:none}.parsely-tone-selector-dropdown.is-disabled{opacity:.5;pointer-events:none}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle{display:flex;gap:.625rem;width:100%}.parsely-tone-selector-dropdown .components-dropdown-menu__toggle svg:first-of-type path{transform:scale(1.4);transform-origin:center}.parsely-tone-selector-dropdown .parsely-tone-selector-label{flex-grow:2;padding:0 var(--grid-unit-10);text-align:right}.parsely-tone-selector-dropdown .parsely-tone-selector-label:first-letter{text-transform:uppercase}.parsely-persona-selector-custom{width:100%}.parsely-persona-selector-custom .components-base-control__field input{display:flex;height:2.5rem;padding:var(--grid-unit-15) var(--grid-unit-20)}.parsely-persona-selector-custom .components-base-control__field input,.parsely-persona-selector-dropdown{align-items:center;align-self:stretch;border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px}.parsely-persona-selector-dropdown{background:var(--Gutenberg-White,#fff);height:2.25rem;overflow-wrap:break-word;width:100%;word-break:break-word}.parsely-persona-selector-dropdown .components-dropdown-menu__toggle.has-icon svg:first-child{display:none}.parsely-persona-selector-dropdown button{height:2.0625rem}.parsely-persona-selector-dropdown.is-disabled{opacity:.5;pointer-events:none}.parsely-persona-selector-dropdown .components-dropdown-menu__toggle{display:flex;gap:.625rem;width:100%}.parsely-persona-selector-dropdown .parsely-persona-selector-label{flex-grow:2;padding:0 var(--grid-unit-10);text-align:right}.parsely-persona-selector-dropdown .parsely-persona-selector-label:first-letter{text-transform:uppercase}.parsely-tone-selector-custom{width:100%}.parsely-tone-selector-custom .components-base-control__field input{align-items:center;align-self:stretch;border:1px solid var(--Gutenberg-Gray-600,#949494);border-radius:2px;display:flex;height:2.5rem;padding:var(--grid-unit-15) var(--grid-unit-20)}#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.parsely-inputrange-control{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.parsely-inputrange-control .parsely-inputrange-control__label{margin:0}.parsely-inputrange-control .parsely-inputrange-control__controls{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-20);height:2.5rem}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control{display:flex;flex:1 0 0}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]::-webkit-inner-spin-button,.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none;margin:0}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control input[type=number]{-moz-appearance:textfield}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control .components-base-control__field{flex-grow:1}.parsely-inputrange-control .parsely-inputrange-control__controls .components-input-control .components-input-control__suffix{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.parsely-inputrange-control .parsely-inputrange-control__controls .components-range-control{flex:1 0 0;height:36px}.parsely-inputrange-control .parsely-inputrange-control__controls .components-range-control .components-range-control__root{height:2.5rem}.parsely-panel-settings{width:100%}.parsely-panel-settings .parsely-panel-settings-header{display:flex;margin:.625rem 0;width:100%}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label{flex-grow:2;margin:0 .3125rem 0 0;text-align:right}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label .components-base-control__field{align-items:center;display:flex;justify-content:space-between}.parsely-panel-settings .parsely-panel-settings-header .parsely-panel-settings-header-label .components-base-control__field .components-base-control__label{margin-bottom:0}.parsely-panel-settings .parsely-panel-settings-body{align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper-error{align-self:flex-start;margin:0}.wp-parsely-content-helper-error p{margin:0}.wp-parsely-content-helper-error .content-helper-error-message{margin:0!important}.wp-parsely-collapsible-panel{align-items:flex-start;align-self:stretch;border-bottom:none;border-radius:2px;border-top:none;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:0 0 .5rem;padding:0}.wp-parsely-collapsible-panel .components-panel__body-title{align-items:center;align-self:stretch;display:flex;margin:0 -1rem .375rem;padding:0}.wp-parsely-collapsible-panel .components-panel__body-title .components-panel__icon,.wp-parsely-collapsible-panel .components-panel__body-title svg{margin-right:0;margin-left:var(--grid-unit-10);order:-1}.wp-parsely-collapsible-panel .components-panel__body-title:hover{background-color:transparent}.wp-parsely-collapsible-panel.is-opened{padding:0}.wp-parsely-collapsible-panel.is-opened>div:first-of-type{margin-top:calc(var(--grid-unit-20)*-1)}.wp-parsely-collapsible-panel.is-opened .components-panel__body-title{margin:0 calc(var(--grid-unit-20)*-1) .375rem;padding-bottom:0}.wp-parsely-collapsible-panel .components-panel__body-toggle.components-button{color:var(--Gutenberg-Gray-900,#1e1e1e);font-size:.6875rem;font-style:normal;font-weight:600;line-height:1rem;padding:var(--grid-unit-20) var(--grid-unit-20);text-transform:uppercase}.wp-parsely-collapsible-panel .components-panel__body-toggle.components-button .components-panel__arrow{margin-left:0}.wp-parsely-collapsible-panel .components-panel__body.is-opened{padding:0}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"]:focus,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"]:hover{background-color:#fff}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed:hover{background-color:var(--parsely-green-65)}.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed .wp-parsely-sidebar-icon path,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"].is-pressed:hover .wp-parsely-sidebar-icon path{fill:var(--parsely-green-10)}.content-helper-error-message,.wp-parsely-content-helper-error .content-helper-error-message{margin-top:.9375rem!important}p.content-helper-error-message-hint{color:var(--gray-700)}.wp-parsely-content-helper-error.components-notice .components-notice__content{margin:0}.wp-parsely-content-helper-error.components-notice .components-notice__content .content-helper-error-message{margin-top:0!important}.wp-parsely-content-helper-error.components-notice .components-notice__content .content-helper-error-message p:last-child{margin-bottom:0!important}.wp-parsely-content-helper .wp-parsely-sidebar-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:1.5rem}.wp-parsely-content-helper .wp-parsely-sidebar-header .components-button{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .components-panel .panel-settings-button>button,.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .components-panel button.panel-settings-button{height:unset;min-width:unset;padding:0}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-panel>.content-helper-error-message{margin:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs button{align-items:center;display:flex;flex:1 0 0;flex-direction:column;height:3rem}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs .components-tab-panel__tabs-item:after{background:var(--gray-400);height:calc(var(--wp-admin-border-width-focus)*1);outline:2px solid transparent;outline-offset:-1px}.wp-parsely-content-helper .wp-parsely-sidebar-main-panel .wp-parsely-sidebar-tabs .components-tab-panel__tabs .components-tab-panel__tabs-item.is-active:after{background:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-content-helper .parsely-spinner-wrapper{display:flex;justify-content:center;margin:2.5rem 0}.wp-parsely-content-helper .parsely-spinner-wrapper svg{height:22px;width:22px} diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index d588bfba8..58f027f93 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-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'e0a20bf11ee7b3eefcd6'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '62c2ec3cdd2ec3a477be'); diff --git a/build/content-helper/editor-sidebar.css b/build/content-helper/editor-sidebar.css index d1f7b690a..45a1d47d4 100644 --- a/build/content-helper/editor-sidebar.css +++ b/build/content-helper/editor-sidebar.css @@ -1,4 +1,4 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 var(--grid-unit-15) 0 0;order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate,.wp-parsely-smart-linking .smart-linking-manage{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button,.wp-parsely-smart-linking .smart-linking-manage button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)}.wp-parsely-smart-linking-review-modal{align-items:flex-start;display:flex;flex-direction:column;width:47.875rem}.wp-parsely-smart-linking-review-modal .smart-linking-modal-body{align-self:stretch;display:flex;flex-direction:row;gap:var(--grid-unit-30)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);max-height:25rem;min-width:13.75rem;overflow-y:auto;padding:3px}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header{align-items:center;align-self:stretch;color:var(--sidebar-black);display:flex;font-size:11px;font-style:normal;font-weight:600;gap:6px;line-height:var(--grid-unit-20);margin-bottom:var(--grid-unit-15);text-transform:uppercase}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header>span{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button{align-items:center;display:flex;justify-content:space-between;width:13.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button:focus{box-shadow:none;outline:none}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected{background-color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected .smart-linking-menu-label{color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__item{padding-right:0;width:100%}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-item{display:inline;flex-grow:1;overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-label{align-items:center;color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));display:flex;padding-left:var(--grid-unit-10);white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion{align-items:flex-start;align-self:stretch;display:flex;flex:1;flex-direction:column;gap:16px;max-width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs{font-size:.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-separator{margin:0 var(--grid-unit-5)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-block{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block{color:var(--sidebar-black)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block .breadcrumbs-current-block-name{margin-left:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .components-divider{border-color:#ccc;height:1px;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .wp-parsely-link-suggestion-link-details{height:auto;margin-bottom:var(--grid-unit-20);text-align:left}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .wp-parsely-link-suggestion-link-details .components-menu-item__item{display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls{align-items:center;align-self:stretch;display:flex;flex-shrink:0;justify-content:space-between;margin:0 var(--grid-unit-20);-webkit-user-select:none;-moz-user-select:none;user-select:none;width:452px}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .reviews-controls-middle{align-items:center;display:flex;flex:1 0 0;gap:var(--grid-unit-20,16px);justify-content:center}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-next,.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-previous{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-reject{background:var(--Gutenberg-White,#fff);border-radius:2px;box-shadow:inset 0 0 0 1px var(--Gutenberg-Alert-Red,#cc1818);color:var(--Gutenberg-Alert-Red,#cc1818)}.wp-parsely-smart-linking-close-dialog{align-items:flex-start;display:flex;flex-direction:column;width:24rem}.wp-parsely-smart-linking-close-dialog .smart-linking-close-dialog-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;padding-top:var(--grid-unit-30)}.wp-parsely-preview-editor.editor-styles-wrapper{font-size:var(--font-size--medium);padding-bottom:0}.wp-parsely-preview-editor p[role=document]{margin:0}.wp-parsely-preview-editor .smart-linking-highlight{background:hsla(var(--parsely-green-components),.5);border-radius:2px;color:var(--sidebar-black);mix-blend-mode:multiply;text-decoration-line:underline} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 var(--grid-unit-15) 0 0;order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate,.wp-parsely-smart-linking .smart-linking-manage{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button,.wp-parsely-smart-linking .smart-linking-manage button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)}.wp-parsely-smart-linking-review-modal{align-items:flex-start;display:flex;flex-direction:column;width:47.875rem}.wp-parsely-smart-linking-review-modal .smart-linking-modal-body{align-self:stretch;display:flex;flex-direction:row;gap:var(--grid-unit-30)}.wp-parsely-smart-linking-review-modal .wp-parsely-link-suggestion-link-details{height:auto;margin-bottom:var(--grid-unit-20);text-align:left}.wp-parsely-smart-linking-review-modal .wp-parsely-link-suggestion-link-details .components-menu-item__item{display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);max-height:25rem;min-width:13.75rem;overflow-y:auto;padding:3px}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header{align-items:center;align-self:stretch;color:var(--sidebar-black);display:flex;font-size:11px;font-style:normal;font-weight:600;gap:6px;line-height:var(--grid-unit-20);margin-bottom:var(--grid-unit-15);text-transform:uppercase}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header>span{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button{align-items:center;display:flex;justify-content:space-between;width:13.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button:focus{box-shadow:none;outline:none}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-label{align-items:center;color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));display:flex;padding-left:var(--grid-unit-10);white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected{background-color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected .smart-linking-menu-label{color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__item{padding-right:0;width:100%}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-item{display:inline;flex-grow:1;overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion{align-items:flex-start;align-self:stretch;display:flex;flex:1;flex-direction:column;gap:16px;max-width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs{font-size:.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-separator{margin:0 var(--grid-unit-5)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-block{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block{color:var(--sidebar-black)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block .breadcrumbs-current-block-name{margin-left:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .components-divider{border-color:#ccc;height:1px;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls{align-items:center;align-self:stretch;display:flex;flex-shrink:0;justify-content:space-between;margin:0 var(--grid-unit-20);-webkit-user-select:none;-moz-user-select:none;user-select:none;width:452px}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .reviews-controls-middle{align-items:center;display:flex;flex:1 0 0;gap:var(--grid-unit-20,16px);justify-content:center}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-next,.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-previous{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-reject{background:var(--Gutenberg-White,#fff);border-radius:2px;box-shadow:inset 0 0 0 1px var(--Gutenberg-Alert-Red,#cc1818);color:var(--Gutenberg-Alert-Red,#cc1818)}.wp-parsely-smart-linking-close-dialog{align-items:flex-start;display:flex;flex-direction:column;width:24rem}.wp-parsely-smart-linking-close-dialog .smart-linking-close-dialog-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;padding-top:var(--grid-unit-30)}.wp-parsely-preview-editor.editor-styles-wrapper{font-size:var(--font-size--medium);padding-bottom:0}.wp-parsely-preview-editor p[role=document]{margin:0}.wp-parsely-preview-editor .smart-linking-highlight{background:hsla(var(--parsely-green-components),.5);border-radius:2px;color:var(--sidebar-black);mix-blend-mode:multiply;text-decoration-line:underline} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-performance-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}.wp-parsely-content-helper .wp-parsely-performance-panel .content-helper-error-message{margin:0!important}.wp-parsely-content-helper .wp-parsely-performance-panel .components-button.wp-parsely-view-post{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .panel-body{width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.5rem;padding:.375rem 0 1rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header{align-items:center;display:flex;gap:.375rem;height:1rem;margin-bottom:0;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2{margin-bottom:.9375rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2 h2{margin-bottom:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-3 h3{font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:1rem;margin-bottom:0;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-subtitle{align-items:center;align-self:stretch;color:var(--Gutenberg-Gray-700,#757575);display:flex;flex:1 0 0;font-size:var(--font-size--smaller);font-style:normal;font-weight:600;gap:.375rem;height:1rem;line-height:1rem;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .components-heading{display:block;font-weight:500;line-height:normal;margin:0}.wp-parsely-content-helper .wp-parsely-performance-panel .components-dropdown-menu{line-height:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points{align-content:flex-start;align-items:flex-start;align-self:stretch;display:flex;flex-wrap:wrap;gap:1rem var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point{align-items:center;background:var(--sidebar-white);border-radius:.25rem;display:flex;flex:1 0 0;flex-direction:column;gap:var(--grid-unit-5);justify-content:center;min-width:100px;padding:var(--grid-unit-20) var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point svg{align-items:flex-start;border-radius:.125rem;display:flex}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-title{align-self:stretch;color:var(--sidebar-black);font-size:.75rem;font-style:normal;font-weight:400;line-height:1rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value{align-self:stretch;color:var(--sidebar-black);font-size:1.25rem;font-style:normal;font-weight:590;line-height:1.75rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value.is-small{font-size:var(--font-size--medium)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar{align-items:flex-start;align-self:stretch;display:flex;height:1rem;margin:1rem 0;position:relative}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill{--radius:2px;align-self:stretch;position:relative;transition:filter .1s ease,transform .1s ease}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:hover{filter:opacity(1)!important;transform:scaleX(1) scaleY(1)!important}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:first-child{border-radius:var(--radius) 0 0 var(--radius)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:last-child{border-radius:0 var(--radius) var(--radius) 0}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar:hover .bar-fill{filter:opacity(.5);transform:scaleX(1) scaleY(.7)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label{align-items:center;align-self:stretch;display:flex;gap:.5rem;justify-content:center}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color{align-items:center;border-radius:.09375rem;display:flex;flex-direction:column;gap:.625rem;height:.625rem;justify-content:center;width:.1875rem}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1 0 0;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-value{color:var(--sidebar-black);font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;text-align:right}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:1rem 0}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-10);justify-content:space-between}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar{display:flex;flex:1;flex-direction:column;gap:.625rem;justify-content:center;max-width:6.25rem}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar{--radius:1.5px;background:var(--gray-400);border-radius:var(--radius);display:flex;height:.1875rem;margin:0;overflow:hidden}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar:after{background:var(--blueberry,#3858e9);border-radius:var(--radius);content:"";height:100%;width:var(--bar-fill)}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-value{color:var(--sidebar-black);flex-shrink:0;font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;min-width:3.125rem;text-align:right} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-related-posts{align-items:flex-start;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-description{font-size:.8125rem;font-style:normal;font-weight:400;gap:.625rem;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body,.wp-parsely-related-posts .related-posts-description{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body{gap:1rem}.wp-parsely-related-posts .related-posts-body>div{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings{align-self:stretch;display:flex;flex-direction:column;gap:1rem;width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings{display:flex;flex-direction:column;gap:var(--grid-unit-20);width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control{height:2.5rem;overflow:hidden}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex{height:2.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex input{margin:0 var(--grid-unit-15)}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-descr{font-size:.8125rem;font-style:normal;font-weight:400;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-empty,.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-loading-message{color:var(--gray-900);font-size:.75rem;font-style:normal;font-weight:700;line-height:var(--grid-unit-20);overflow:hidden;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-title{align-items:center;align-self:stretch;display:flex;flex-direction:column;font-size:.875rem;font-style:normal;font-weight:600;gap:.5rem;justify-content:center;line-height:1.25rem;overflow:hidden;padding:var(--grid-unit-20);text-decoration-line:underline;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions{align-items:center;align-self:stretch;border-top:1px solid var(--gray-400);display:flex;flex-wrap:wrap;padding:0 var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:first-child,.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:last-child{display:flex;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric{align-items:center;display:flex}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric .parsely-post-metric-data{align-items:center;display:flex;gap:var(--grid-unit-5)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-linked{align-items:center;display:flex;margin-left:auto;fill:#008a20}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon path{fill:#1e1e1e}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon:hover path{fill:#0073aa} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper{display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings>div{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding-bottom:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header .parsely-write-titles-text strong{text-transform:lowercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding-top:.375rem}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate .components-button{align-items:center;align-self:stretch;border-radius:2px;display:flex;height:2.5rem;justify-content:center;padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-dropdown-label{align-self:stretch;color:var(--sidebar-black);font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:var(--grid-unit-20);text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title{font-size:1rem;font-weight:600;line-height:1.25rem;margin:0 0 .9375rem;text-align:center}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title-actions{display:flex;gap:.625rem;justify-content:center;margin:.625rem 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion.pinned-title{background:var(--Gutenberg-Gray-100,#f0f0f0)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title{align-items:center;align-self:stretch;color:#1e1e1e;display:flex;flex-direction:column;font-size:.75rem;font-style:normal;font-weight:600;gap:var(--grid-unit-10);justify-content:center;line-height:1.25rem;padding:var(--grid-unit-15) var(--grid-unit-15) 0 var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title .suggested-title-original{align-self:flex-start;margin:0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions{align-items:center;align-self:stretch;border-top:1px solid var(--Gutenberg-Gray-400,#ccc);display:flex;flex-wrap:wrap;height:2.5rem;padding:0 var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-left,.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-right{display:flex;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin-bottom:var(--grid-unit-20);position:relative}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay{align-items:center;background-color:hsla(0,0%,100%,.9);bottom:0;display:flex;flex-direction:column;gap:var(--grid-unit-10);justify-content:center;left:0;position:absolute;right:0;top:0;z-index:1}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay .components-spinner{transform:scale(1.125)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-pinned-suggestions{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-content-helper-error.components-notice{margin-bottom:var(--grid-unit-10)}.wp-parsely-popover .components-popover__content{width:15.5rem}.wp-parsely-suggested-title-modal{align-items:flex-start;display:flex;flex-direction:column;width:20rem}.wp-parsely-suggested-title-modal h2{color:var(--sidebar-black);font-size:1rem;font-style:normal;font-weight:600;line-height:1.5rem}.wp-parsely-suggested-title-modal .suggested-title-modal-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;margin-top:1.5rem} diff --git a/build/content-helper/excerpt-generator-rtl.css b/build/content-helper/excerpt-generator-rtl.css index 84a9c9ac6..6f3cc48f5 100644 --- a/build/content-helper/excerpt-generator-rtl.css +++ b/build/content-helper/excerpt-generator-rtl.css @@ -1 +1 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green:#59a744;--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.editor-post-excerpt__loading_animation{right:.5625rem;position:absolute;top:1.8125rem}.editor-post-excerpt__textarea{margin-bottom:var(--grid-unit-10)}.editor-post-excerpt__textarea textarea:-moz-read-only{background-color:var(--Gutenberg-White,#fff)}.editor-post-excerpt__textarea textarea:read-only{background-color:var(--Gutenberg-White,#fff)}.wp-parsely-excerpt-generator{margin-top:1.25rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header{align-items:center;display:flex;justify-content:flex-start}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label{display:inline-block;font-size:.6875rem;font-weight:600;line-height:1.4;margin-right:.3125rem;padding:0;text-transform:uppercase}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label span.beta-label{color:var(--Gutenberg-Gray-700,#757575);padding-right:.375rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls{display:flex;gap:var(--grid-unit-10)}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls button{flex-grow:1;height:2.5rem;justify-content:center;margin-bottom:var(--grid-unit-10);margin-top:var(--grid-unit-10);padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-excerpt-generator .components-notice{margin:var(--grid-unit-20) 0 var(--grid-unit-15) 0}.wp-parsely-excerpt-generator .components-notice .components-notice__content{margin:0}.wp-parsely-excerpt-generator .components-notice .components-notice__content .content-helper-error-message{margin-top:0!important}.wp-parsely-excerpt-generator .components-notice .components-notice__content .content-helper-error-message p:last-child{margin-bottom:0!important} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.editor-post-excerpt__loading_animation{right:.5625rem;position:absolute;top:1.8125rem}.editor-post-excerpt__textarea{margin-bottom:var(--grid-unit-10)}.editor-post-excerpt__textarea textarea:-moz-read-only{background-color:var(--Gutenberg-White,#fff)}.editor-post-excerpt__textarea textarea:read-only{background-color:var(--Gutenberg-White,#fff)}.wp-parsely-excerpt-generator{margin-top:1.25rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header{align-items:center;display:flex;justify-content:flex-start}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label{display:inline-block;font-size:.6875rem;font-weight:600;line-height:1.4;margin-right:.3125rem;padding:0;text-transform:uppercase}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-header .wp-parsely-excerpt-generator-header-label span.beta-label{color:var(--Gutenberg-Gray-700,#757575);padding-right:.375rem}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls{display:flex;gap:var(--grid-unit-10)}.wp-parsely-excerpt-generator .wp-parsely-excerpt-generator-controls button{flex-grow:1;height:2.5rem;justify-content:center;margin-bottom:var(--grid-unit-10);margin-top:var(--grid-unit-10);padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-excerpt-generator .components-notice{margin:var(--grid-unit-20) 0 var(--grid-unit-15) 0}.wp-parsely-excerpt-generator .components-notice .components-notice__content{margin:0}.wp-parsely-excerpt-generator .components-notice .components-notice__content .content-helper-error-message{margin-top:0!important}.wp-parsely-excerpt-generator .components-notice .components-notice__content .content-helper-error-message p:last-child{margin-bottom:0!important} diff --git a/build/content-helper/excerpt-generator.asset.php b/build/content-helper/excerpt-generator.asset.php index 88df71c3e..47a04e61d 100644 --- a/build/content-helper/excerpt-generator.asset.php +++ b/build/content-helper/excerpt-generator.asset.php @@ -1 +1 @@ - array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => '210e32429864dc3da802'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => '6babbaf67143852ea4d1'); diff --git a/tests/Integration/BaseUserMetaEndpointTest.php b/tests/Integration/BaseUserMetaEndpointTest.php index befd671e8..a7ef35ef9 100644 --- a/tests/Integration/BaseUserMetaEndpointTest.php +++ b/tests/Integration/BaseUserMetaEndpointTest.php @@ -145,4 +145,22 @@ protected function send_put_request( string $data ): string { return $result; } + + /** + * Verifies that the route is not registered when the respective filter is + * set to false. + */ + public function run_test_do_not_register_route_when_proxy_is_disabled(): void { + // Override some setup steps in order to set the filter to false. + remove_action( 'rest_api_init', $this->rest_api_init_proxy ); + $endpoint = $this->get_endpoint(); + $this->rest_api_init_proxy = static function () use ( $endpoint ) { + add_filter( 'wp_parsely_enable_' . self::$filter_key . '_endpoint', '__return_false' ); + $endpoint->run(); + }; + add_action( 'rest_api_init', $this->rest_api_init_proxy ); + + $routes = rest_get_server()->get_routes(); + self::assertFalse( array_key_exists( self::$route, $routes ) ); + } } diff --git a/tests/Integration/ProxyEndpointTest.php b/tests/Integration/ProxyEndpointTest.php index 81a923b67..030871970 100644 --- a/tests/Integration/ProxyEndpointTest.php +++ b/tests/Integration/ProxyEndpointTest.php @@ -38,7 +38,7 @@ abstract class ProxyEndpointTest extends TestCase { * * @var callable $rest_api_init_proxy */ - private $rest_api_init_proxy; + protected $rest_api_init_proxy; /** * Route of the WP REST endpoint. diff --git a/tests/Integration/RemoteAPI/content-suggestions/SuggestLinkedReferenceAPITest.php b/tests/Integration/RemoteAPI/content-suggestions/SuggestLinkedReferenceAPITest.php index 49d3b4c84..21d2d3c8d 100644 --- a/tests/Integration/RemoteAPI/content-suggestions/SuggestLinkedReferenceAPITest.php +++ b/tests/Integration/RemoteAPI/content-suggestions/SuggestLinkedReferenceAPITest.php @@ -10,6 +10,7 @@ namespace Parsely\Tests\Integration\RemoteAPI\ContentSuggestions; +use Parsely\Models\Smart_Link; use Parsely\Parsely; use Parsely\RemoteAPI\ContentSuggestions\Suggest_Linked_Reference_API; @@ -153,7 +154,7 @@ public function test_get_links(): void { // instance. foreach ( $suggested_links as $suggested_link ) { self::assertIsObject( $suggested_link ); - self::assertInstanceOf( 'Parsely\RemoteAPI\ContentSuggestions\Link_Suggestion', $suggested_link ); + self::assertInstanceOf( Smart_Link::class, $suggested_link ); } // Remove mock. From 7b882f9e5eef50680f4e37e9d45be3af1643cbc1 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 21 May 2024 15:28:20 +0100 Subject: [PATCH 27/44] Fix some issues with link validation and saving --- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.js | 10 +-- .../class-smart-linking-endpoint.php | 2 +- .../smart-linking/component.tsx | 6 +- .../editor-sidebar/smart-linking/hooks.ts | 88 +++++++++---------- .../editor-sidebar/smart-linking/utils.ts | 47 ++++++---- 6 files changed, 82 insertions(+), 73 deletions(-) diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index 58f027f93..2f2f72f35 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-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '62c2ec3cdd2ec3a477be'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'f3a73bf70642da809d4a'); diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index cb9fef3ee..0dd1d25e8 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,8 +1,8 @@ -!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 Bn}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=n(609),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,h=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}(),v=(h.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"})})}),g=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"})]})},y=function(){return y=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiError||s.code===A.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===A.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===A.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return G(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[A.PluginCredentialsNotSetMessageDetected,A.PluginSettingsSiteIdNotSet,A.PluginSettingsApiSecretNotSet].includes(this.code)?M(e):(this.code===A.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==A.ParselyApiForbidden&&this.code!==A.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===A.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(I,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var W,U=function(e){var t=e.isDetectingEnabled,n=e.onLinkChange,r=e.onLinkRemove,i=e.onLinkAdd,s=e.debounceValue,o=void 0===s?500:s,c=(0,a.useSelect)((function(e){return{blocks:(0,e("core/block-editor").getBlocks)()}}),[]).blocks,u=(0,l.useRef)(c),p=(0,l.useRef)(t);return(0,l.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}(c,u.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)})),u.current=c)}),o);return e(t),function(){e.cancel()}}),[c,o,t,i,n,r]),null},q=window.wp.editor,Z=window.wp.blocks,$=function(){return $=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var u=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,c.__)("NEW","wp-parsely"),(0,i.jsx)(fe,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,c.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&u]},e.uid)}))]})})},ve=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,u.createElement)(p.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})),ge=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),ye=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),me=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),we=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})),_e=window.wp.url,be=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?p(!0):k().then((function(){return t()}))},E=function(e){p(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},L=function(){var e=g.indexOf(_)+1;g[e]&&b(g[e])},C=function(){var e=m().indexOf(_)-1;m()[e]&&b(m()[e])},A=function(){return Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(this,(function(n){switch(n.label){case 0:return _.match?(r(_),[4,(i=_.match.blockId,s=_,Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(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))?(ne(t,s,e),s.applied=!0,[4,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(_),g[t=e+1]?b(g[t]):b(g[0]),[2])}var i,s}))}))},N=function(){return Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(this,(function(n){switch(n.label){case 0:return e=g.indexOf(_),g[t=e+1]?b(g[t]):g[0]?b(g[0]):T(),[4,P(_.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Ne(void 0,void 0,void 0,(function(){var e,t,n,r;return Oe(this,(function(i){switch(i.label){case 0:return _.match?(e=(0,a.select)("core/block-editor").getBlock(_.match.blockId))?(t=m(),n=t.indexOf(_),r=n-1,[4,j(e,_)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?b(t[r]):b(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:L,up:C,down:L,a:function(){_&&!_.applied&&A()},r:function(){_&&(_.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(he,{links:g,activeLink:_,setSelectedLink:b}),(0,i.jsx)(Ae,{link:_,hasNext:m().indexOf(_)0,onNext:L,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(_.match){var e=(0,a.select)("core/block-editor").getBlock(_.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(_.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),u&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return E(!1)},className:"wp-parsely-smart-linking-close-dialog",children:[(0,c.__)("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 E(!1)},children:(0,c.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return E(!0)},children:(0,c.__)("Close","wp-parsely")})]})]})]})})),Ie=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})]})]})},Me=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,u=e.onSettingChange,p=(0,l.useRef)(),d=(0,l.useState)(""),f=d[0],h=d[1],v=(0,l.useState)(!1),g=v[0],y=v[1],m=(0,l.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(Q),n=t.getMaxLinkWords,r=t.getMaxLinks,i=t.isFullContent,s=t.wasAlreadyClicked,a=t.getApplyTo;return{maxLinks:r(),maxLinkWords:n(),fullContent:i(),alreadyClicked:s(),applyTo:a()}}),[]),_=w.maxLinks,b=w.maxLinkWords,x=w.fullContent,k=w.alreadyClicked,S=w.applyTo,P=(0,a.useDispatch)(Q),j=P.setMaxLinks,T=P.setMaxLinkWords,E=P.setFullContent,L=P.setAlreadyClicked,C=P.setApplyTo,A=null!==(t=S)&&void 0!==t?t:o?"selected":"all";return(0,l.useEffect)((function(){if(!r){var e=function(){r||(S===W.Selected&&setTimeout((function(){h((0,c.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),C(null),m((function(e){return!e})))};o||S===W.All||(g?setTimeout(e,500):e()),E(W.All===A)}}),[g,S,A,r,o,C,E,h]),(0,l.useEffect)((function(){if(!r&&p.current&&A&&!k&&o){var e=p.current.querySelector('button[data-value="'.concat(A,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(C(A),L(!0))}}),[o,x,r,S]),(0,l.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:A,label:(0,c.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&S("success",/* translators: %d: number of smart links applied */ /* translators: %d: number of smart links applied */ -(0,c.sprintf)((0,c.__)("%s smart links successfully applied.","wp-parsely"),w),{type:"snackbar"}):_(0)}),[x]),(0,l.useEffect)((function(){if(!(Object.keys(D).length>0)){var e={maxLinksPerPost:v.SmartLinking.MaxLinks,maxLinkWords:v.SmartLinking.MaxLinkWords};fe(e)}}),[fe,v]);var be=(0,a.useSelect)((function(e){var t=e("core/block-editor"),n=t.getSelectedBlock,r=t.getBlock,i=t.getBlocks,s=e("core/editor"),a=s.getEditedPostContent,o=s.getCurrentPostAttribute;return{allBlocks:i(),selectedBlock:u?r(u):n(),postContent:a(),postPermalink:o("link")}}),[u]),xe=be.allBlocks,ke=be.selectedBlock,Se=be.postContent,je=be.postPermalink,Te=function(e){return De(void 0,void 0,void 0,(function(){var t,n,r,i;return Ve(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,he((n=C||!ke)?W.All:W.Selected)];case 2:return s.sent(),a=je.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,Pe.getInstance().generateSmartLinks((null==ke?void 0:ke.originalContent)&&!n?ke.originalContent:Se,B,M,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===A.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,ye(!0)]):[3,8];case 5:return s.sent(),[4,me()];case 6:return s.sent(),[4,Te(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},Ee=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Ae=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)(U,{isDetectingEnabled:!1,onLinkRemove:function(e){!function(e){X(this,void 0,void 0,(function(){return J(this,(function(t){switch(t.label){case 0:return[4,le((0,Z.getBlockContent)(e),e.clientId)];case 1:return t.sent().forEach((function(e){(0,a.dispatch)(Q).removeSmartLink(e.uid)})),[2]}}))}))}(e.block)}}),(0,i.jsxs)(s.PanelRow,{className:o,children:[(0,i.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(V,{icon:F,size:18,className:"parsely-external-link-icon"})]})]}),R&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return ne(null)},className:"wp-parsely-content-helper-error",children:R.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,c.sprintf)(/* translators: 1 - number of smart links generated */ /* translators: 1 - number of smart links generated */ -(0,c.__)("Successfully added %s smart links.","wp-parsely"),w>0?w:I.length)}),(0,i.jsx)(Me,{disabled:E,selectedBlock:null==ke?void 0:ke.clientId,onSettingChange:function(e,t){var n;y({SmartLinking:Be(Be({},v.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e?ge(t):"MaxLinkWords"===e&&ve(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return De(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Ve(this,(function(a){switch(a.label){case 0:return[4,te(!0)];case 1:return a.sent(),[4,we()];case 2:return a.sent(),[4,ne(null)];case 3:return a.sent(),k(!1),h.trackEvent("smart_linking_generate_pressed",{is_full_content:C,selected_block:null!==(s=null==ke?void 0:ke.name)&&void 0!==s?s:"none",context:d}),[4,Ee(C?"all":null==ke?void 0:ke.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;te(!1),h.trackEvent("smart_linking_generate_timeout",{is_full_content:C,selected_block:null!==(e=null==ke?void 0:ke.name)&&void 0!==e?e:"none",context:d}),Le(C?"all":null==ke?void 0:ke.clientId)}),18e4),t=G,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,Te(3)];case 6:return n=a.sent(),[4,(o=n,De(void 0,void 0,void 0,(function(){var e;return Ve(this,(function(t){switch(t.label){case 0:return o=o.filter((function(e){return!$.find((function(t){return t.uid===e.uid&&t.applied}))})),e=je.replace(/^https?:\/\//,"").replace(/\/+$/,""),o=o.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),o=se(xe,o,{}).filter((function(e){return e.match})),[4,re(o)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),_e(!0),[3,15];case 8:return r=a.sent(),i=(0,c.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===A.ParselyAborted&&(i=(0,c.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ /* translators: %d: number of retry attempts, %s: attempt plural */ -(0,c.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),r.numRetries,(0,c._n)("attempt","attempts",r.numRetries,"wp-parsely")),r.message=i),[4,ne(r)];case 9:return a.sent(),S("error",i,{type:"snackbar"}),[3,15];case 10:return[4,te(!1)];case 11:return a.sent(),[4,he(t)];case 12:return a.sent(),[4,ye(!1)];case 13:return a.sent(),[4,Le(C?"all":null==ke?void 0:ke.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var o}))}))},variant:"primary",isBusy:E,disabled:E,children:H?(0,c.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,c.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),z,3):E?(0,c.__)("Generating Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")})}),K.length>0&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return De(void 0,void 0,void 0,(function(){var e;return Ve(this,(function(t){switch(t.label){case 0:return[4,ce()];case 1:return t.sent(),e=ae(),[4,re(e)];case 2:return t.sent(),_e(!0),[2]}}))}))},variant:"secondary",children:(0,c.__)("Review Smart Links","wp-parsely")})})]}),L&&(0,i.jsx)(Re,{isOpen:L,onAppliedLink:function(){_((function(e){return e+1}))},onClose:function(){k(!0),_e(!1)}})]})},He=function(){return He=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 tt=function(e){var n=e.data,r=e.isLoading,a=(0,l.useState)(t.Views),o=a[0],u=a[1],p=(0,l.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},v=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),L(o)); +!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 Bn}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=n(609),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,h=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}(),v=(h.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"})})}),g=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"})]})},y=function(){return y=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiError||s.code===A.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===A.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===A.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return G(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[A.PluginCredentialsNotSetMessageDetected,A.PluginSettingsSiteIdNotSet,A.PluginSettingsApiSecretNotSet].includes(this.code)?M(e):(this.code===A.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==A.ParselyApiForbidden&&this.code!==A.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===A.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(I,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var W,U=function(e){var t=e.isDetectingEnabled,n=e.onLinkChange,r=e.onLinkRemove,i=e.onLinkAdd,s=e.debounceValue,o=void 0===s?500:s,c=(0,a.useSelect)((function(e){return{blocks:(0,e("core/block-editor").getBlocks)()}}),[]).blocks,u=(0,l.useRef)(c),p=(0,l.useRef)(t);return(0,l.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}(c,u.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)})),u.current=c)}),o);return e(t),function(){e.cancel()}}),[c,o,t,i,n,r]),null},q=window.wp.editor,Z=window.wp.blocks,$=function(){return $=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var u=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,c.__)("NEW","wp-parsely"),(0,i.jsx)(fe,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,c.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&u]},e.uid)}))]})})},ve=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,u.createElement)(p.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})),ge=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),ye=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),me=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),we=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})),_e=window.wp.url,be=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?p(!0):k().then((function(){return t()}))},E=function(e){p(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},L=function(){var e=g.indexOf(_)+1;g[e]&&b(g[e])},C=function(){var e=m().indexOf(_)-1;m()[e]&&b(m()[e])},A=function(){return Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(this,(function(n){switch(n.label){case 0:return _.match?(r(_),[4,(i=_.match.blockId,s=_,Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(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))?(ne(t,s,e),s.applied=!0,[4,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(_),g[t=e+1]?b(g[t]):b(g[0]),[2])}var i,s}))}))},N=function(){return Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(this,(function(n){switch(n.label){case 0:return e=g.indexOf(_),g[t=e+1]?b(g[t]):g[0]?b(g[0]):T(),[4,P(_.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Ne(void 0,void 0,void 0,(function(){var e,t,n,r;return Oe(this,(function(i){switch(i.label){case 0:return _.match?(e=(0,a.select)("core/block-editor").getBlock(_.match.blockId))?(t=m(),n=t.indexOf(_),r=n-1,[4,j(e,_)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?b(t[r]):b(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:L,up:C,down:L,a:function(){_&&!_.applied&&A()},r:function(){_&&(_.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(he,{links:g,activeLink:_,setSelectedLink:b}),(0,i.jsx)(Ae,{link:_,hasNext:m().indexOf(_)0,onNext:L,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(_.match){var e=(0,a.select)("core/block-editor").getBlock(_.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(_.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),u&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return E(!1)},className:"wp-parsely-smart-linking-close-dialog",children:[(0,c.__)("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 E(!1)},children:(0,c.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return E(!0)},children:(0,c.__)("Close","wp-parsely")})]})]})]})})),Ie=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})]})]})},Me=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,u=e.onSettingChange,p=(0,l.useRef)(),d=(0,l.useState)(""),f=d[0],h=d[1],v=(0,l.useState)(!1),g=v[0],y=v[1],m=(0,l.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(Q),n=t.getMaxLinkWords,r=t.getMaxLinks,i=t.isFullContent,s=t.wasAlreadyClicked,a=t.getApplyTo;return{maxLinks:r(),maxLinkWords:n(),fullContent:i(),alreadyClicked:s(),applyTo:a()}}),[]),_=w.maxLinks,b=w.maxLinkWords,x=w.fullContent,k=w.alreadyClicked,S=w.applyTo,P=(0,a.useDispatch)(Q),j=P.setMaxLinks,T=P.setMaxLinkWords,E=P.setFullContent,L=P.setAlreadyClicked,C=P.setApplyTo,A=null!==(t=S)&&void 0!==t?t:o?"selected":"all";return(0,l.useEffect)((function(){if(!r){var e=function(){r||(S===W.Selected&&setTimeout((function(){h((0,c.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),C(null),m((function(e){return!e})))};o||S===W.All||(g?setTimeout(e,500):e()),E(W.All===A)}}),[g,S,A,r,o,C,E,h]),(0,l.useEffect)((function(){if(!r&&p.current&&A&&!k&&o){var e=p.current.querySelector('button[data-value="'.concat(A,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(C(A),L(!0))}}),[o,x,r,S]),(0,l.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:A,label:(0,c.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&b("success",/* translators: %d: number of smart links applied */ /* translators: %d: number of smart links applied */ +(0,c.sprintf)((0,c.__)("%s smart links successfully applied.","wp-parsely"),g),{type:"snackbar"}):y(0)}),[w]),(0,l.useEffect)((function(){if(!(Object.keys(I).length>0)){var e={maxLinksPerPost:p.SmartLinking.MaxLinks,maxLinkWords:p.SmartLinking.MaxLinkWords};re(e)}}),[re,p]);var me=(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]),we=me.allBlocks,_e=me.selectedBlock,be=me.postContent,xe=me.postPermalink,ke=function(e){return De(void 0,void 0,void 0,(function(){var t,n,r,i;return Ve(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,ie((n=T||!_e)?W.All:W.Selected)];case 2:return s.sent(),a=xe.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,Pe.getInstance().generateSmartLinks((null==_e?void 0:_e.originalContent)&&!n?_e.originalContent:be,R,N,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===A.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,he(!0)]):[3,8];case 5:return s.sent(),[4,ve()];case 6:return s.sent(),[4,ke(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},Se=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Ee=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)(U,{isDetectingEnabled:!j,onLinkRemove:function(e){!function(e){X(this,void 0,void 0,(function(){var t,n,r;return J(this,(function(i){switch(i.label){case 0:return[4,le((0,Z.getBlockContent)(e),e.clientId)];case 1:return t=i.sent(),n=t.missingSmartLinks,r=t.didAnyFixes,n.forEach((function(e){(0,a.dispatch)(Q).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,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(V,{icon:F,size:18,className:"parsely-external-link-icon"})]})]}),L&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return Y(null)},className:"wp-parsely-content-helper-error",children:L.Message()}),w&&g>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return _(!1)},className:"wp-parsely-smart-linking-suggested-links",children:(0,c.sprintf)(/* translators: 1 - number of smart links generated */ /* translators: 1 - number of smart links generated */ +(0,c.__)("Successfully added %s smart links.","wp-parsely"),g>0?g:C.length)}),(0,i.jsx)(Me,{disabled:S,selectedBlock:null==_e?void 0:_e.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:Be(Be({},p.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e?fe(t):"MaxLinkWords"===e&&oe(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return De(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Ve(this,(function(a){switch(a.label){case 0:return[4,K(!0)];case 1:return a.sent(),[4,ge()];case 2:return a.sent(),[4,Y(null)];case 3:return a.sent(),_(!1),h.trackEvent("smart_linking_generate_pressed",{is_full_content:T,selected_block:null!==(s=null==_e?void 0:_e.name)&&void 0!==s?s:"none",context:o}),[4,Se(T?"all":null==_e?void 0:_e.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;K(!1),h.trackEvent("smart_linking_generate_timeout",{is_full_content:T,selected_block:null!==(e=null==_e?void 0:_e.name)&&void 0!==e?e:"none",context:o}),je(T?"all":null==_e?void 0:_e.clientId)}),18e4),t=M,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,ke(3)];case 6:return n=a.sent(),[4,(l=n,De(void 0,void 0,void 0,(function(){var e;return Ve(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!G.find((function(t){return t.uid===e.uid&&t.applied}))})),e=xe.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=se(we,l,{}).filter((function(e){return e.match})),[4,ee(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),ye(!0),[3,15];case 8:return r=a.sent(),i=(0,c.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===A.ParselyAborted&&(i=(0,c.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ /* translators: %d: number of retry attempts, %s: attempt plural */ +(0,c.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),r.numRetries,(0,c._n)("attempt","attempts",r.numRetries,"wp-parsely")),r.message=i),[4,Y(r)];case 9:return a.sent(),b("error",i,{type:"snackbar"}),[3,15];case 10:return[4,K(!1)];case 11:return a.sent(),[4,ie(t)];case 12:return a.sent(),[4,he(!1)];case 13:return a.sent(),[4,je(T?"all":null==_e?void 0:_e.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:S,disabled:S,children:B?(0,c.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,c.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),D,3):S?(0,c.__)("Generating Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")})}),H.length>0&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return De(void 0,void 0,void 0,(function(){var e;return Ve(this,(function(t){switch(t.label){case 0:return[4,ce()];case 1:return t.sent(),e=ae(),[4,ee(e)];case 2:return t.sent(),ye(!0),[2]}}))}))},variant:"secondary",children:(0,c.__)("Review Smart Links","wp-parsely")})})]}),j&&(0,i.jsx)(Re,{isOpen:j,onAppliedLink:function(){y((function(e){return e+1}))},onClose:function(){_(!0),ye(!1)}})]})},He=function(){return He=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 tt=function(e){var n=e.data,r=e.isLoading,a=(0,l.useState)(t.Views),o=a[0],u=a[1],p=(0,l.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},v=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),L(o)); /* translators: %s: metric description */return(0,i.jsxs)(Je,{title:(0,c.__)("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,c.__)("By: ","wp-parsely"),onChange:function(e){T(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,i.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[L(e),"avg_engaged"===e&&(0,c.__)(" (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,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ /* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ (0,c.__)("%1$s: %2$s%%","wp-parsely"),h(t),n.viewsPercentage);return(0,i.jsx)(s.Tooltip /* translators: %s: percentage value */,{ diff --git a/src/Endpoints/content-helper/class-smart-linking-endpoint.php b/src/Endpoints/content-helper/class-smart-linking-endpoint.php index a682878f7..ab0bd507e 100644 --- a/src/Endpoints/content-helper/class-smart-linking-endpoint.php +++ b/src/Endpoints/content-helper/class-smart-linking-endpoint.php @@ -69,7 +69,7 @@ public function is_available_to_current_user( $request = null ): bool { $post_id = $request->get_param( 'post_id' ); - if ( null === $post_id ) { + if ( null !== $post_id ) { // Check if the current user has edit capabilities for the post. $can_edit = current_user_can( 'edit_post', $post_id ); } else { diff --git a/src/content-helper/editor-sidebar/smart-linking/component.tsx b/src/content-helper/editor-sidebar/smart-linking/component.tsx index a7c1437e7..9f8e5889a 100644 --- a/src/content-helper/editor-sidebar/smart-linking/component.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/component.tsx @@ -18,7 +18,7 @@ import { ContentHelperErrorCode } from '../../common/content-helper-error'; import { SidebarSettings, SmartLinkingSettings, useSettings } from '../../common/settings'; import { generateProtocolVariants } from '../../common/utils/functions'; import { LinkMonitor } from './component-link-monitor'; -import { useValidateSmartLinksBeforeSave } from './hooks'; +import { useSmartLinksValidation } from './hooks'; import { SmartLinkingReviewModal } from './review-modal/component-modal'; import { SmartLinkingSettings as SmartLinkingSettingsComponent } from './component-settings'; import { SmartLink, SmartLinkingProvider } from './provider'; @@ -76,7 +76,7 @@ export const SmartLinkingPanel = ( { const { settings, setSettings } = useSettings(); // Saving hooks. - useValidateSmartLinksBeforeSave(); + useSmartLinksValidation(); const setSettingsDebounced = useDebounce( setSettings, 500 ); @@ -524,7 +524,7 @@ export const SmartLinkingPanel = ( { return (
{ // When a link is removed, validate and fix any smart-link that got the data-smartlink attribute removed. validateAndFixSmartLinksInBlock( changes.block ); diff --git a/src/content-helper/editor-sidebar/smart-linking/hooks.ts b/src/content-helper/editor-sidebar/smart-linking/hooks.ts index 0b97819c5..9bb1c6b09 100644 --- a/src/content-helper/editor-sidebar/smart-linking/hooks.ts +++ b/src/content-helper/editor-sidebar/smart-linking/hooks.ts @@ -12,86 +12,78 @@ import { GutenbergFunction } from '../../../@types/gutenberg/types'; import { validateAndFixSmartLinksInPost } from './utils'; /** - * Returns `true` if the post is done saving, `false` otherwise. + * Handles the smart links validation process, which will validate the smart links before saving the post. + * + * This hook is used to validate the smart links before saving the post. It will validate the smart links before + * saving the post, and then save the post after the smart links have been validated. This is necessary because + * the validation process may change the post content, and those changes are not reflected in the post saving process. + * + * This is a fallback for the validation step in the LinkMonitor component. If for some reason the validation step + * is not triggered, this hook will fix the smart links before saving the post. * * @since 3.16.0 * - * @return {boolean} Whether the post is done saving. + * @return {boolean} Whether the post is saved. */ -export const useAfterSave = (): boolean => { +export const useSmartLinksValidation = (): boolean => { const [ isPostSaved, setIsPostSaved ] = useState( false ); + const [ didAnyFixes, setDidAnyFixes ] = useState( false ); const isPostSavingInProgress = useRef( false ); + const hasValidatedLinks = useRef( false ); + const { isSavingPost, isAutosavingPost } = useSelect( ( selectFn ) => { const coreEditorSelect = selectFn( 'core/editor' ) as GutenbergFunction; - return { isSavingPost: coreEditorSelect.isSavingPost(), isAutosavingPost: coreEditorSelect.isAutosavingPost(), }; }, [] ); - useEffect( () => { - if ( ( isSavingPost || isAutosavingPost ) && ! isPostSavingInProgress.current ) { - setIsPostSaved( false ); - isPostSavingInProgress.current = true; - } - if ( ! ( isSavingPost || isAutosavingPost ) && isPostSavingInProgress.current ) { - // Code to run after post is done saving. - setIsPostSaved( true ); - isPostSavingInProgress.current = false; - } - }, [ isSavingPost, isAutosavingPost ] ); - - return isPostSaved; -}; - -/** - * Validates and fixes smart links before saving the post, and saves the smart links to the database. - * - * @since 3.16.0 - */ -export const useValidateSmartLinksBeforeSave = () => { - const { isSavingPost } = useSelect( ( selectFn ) => { - const coreEditorSelect = selectFn( 'core/editor' ) as GutenbergFunction; - return { - isSavingPost: coreEditorSelect.isSavingPost(), - postContent: coreEditorSelect.getEditedPostContent(), - }; - }, [] ); - - const isAfterSave = useAfterSave(); - const hasSavedRef = useRef( false ); - /** - * Handles the before save action. + * Handles the before save action, which will validate the smart links before saving the post. * * @since 3.16.0 */ useEffect( () => { - if ( isSavingPost ) { + if ( isSavingPost && ! hasValidatedLinks.current ) { ( async () => { - // Validate and fix smart links that might have had the data-smartlink attribute removed. - await validateAndFixSmartLinksInPost(); - hasSavedRef.current = true; + const validationFixed = await validateAndFixSmartLinksInPost(); + setDidAnyFixes( validationFixed ); + hasValidatedLinks.current = true; } )(); } }, [ isSavingPost ] ); /** - * Handles the after save action, which will save the post after the smart links have been validated. + * Handles the post saving state tracking. * * @since 3.16.0 */ useEffect( () => { - if ( isAfterSave && hasSavedRef.current ) { + if ( ( isSavingPost || isAutosavingPost ) && ! isPostSavingInProgress.current ) { + setIsPostSaved( false ); + isPostSavingInProgress.current = true; + } else if ( ! ( isSavingPost || isAutosavingPost ) && isPostSavingInProgress.current ) { + setIsPostSaved( true ); + isPostSavingInProgress.current = false; + } + }, [ isSavingPost, isAutosavingPost ] ); + + /** + * Handles the post saving action, which will save the post after the smart links have been validated. + * This is necessary because the validation process may change the post content, and those changes are not + * reflected in the post saving process. + * + * @since 3.16.0 + */ + useEffect( () => { + if ( isPostSaved && hasValidatedLinks.current && didAnyFixes ) { ( async () => { - // Trigger the save action await dispatch( editorStore ).savePost(); - - // TODO: Save the smart links to the database. + hasValidatedLinks.current = false; } )(); } + }, [ didAnyFixes, isPostSaved ] ); - hasSavedRef.current = false; - }, [ isAfterSave ] ); + return isPostSaved; }; diff --git a/src/content-helper/editor-sidebar/smart-linking/utils.ts b/src/content-helper/editor-sidebar/smart-linking/utils.ts index 234d67a6b..cc424c455 100644 --- a/src/content-helper/editor-sidebar/smart-linking/utils.ts +++ b/src/content-helper/editor-sidebar/smart-linking/utils.ts @@ -438,6 +438,10 @@ function getLinkOffset( link: HTMLAnchorElement, document: Document ): number { return -1; } +type ValidateAndFixSmartLinksReturnType = { + missingSmartLinks: SmartLink[], + didAnyFixes: boolean +}; /** * Validates and fixes smart links in a specific content. * @@ -451,9 +455,9 @@ function getLinkOffset( link: HTMLAnchorElement, document: Document ): number { * @param {string} content The post content to validate and fix smart links. * @param {string|false} blockId The block ID to filter the smart links by. * - * @return {Promise} The missing smart links that were not found in the post content. + * @return {ValidateAndFixSmartLinksReturnType} The missing smart links and whether any fixes were made. */ -export async function validateAndFixSmartLinks( content: string, blockId: string|false = false ): Promise { +export async function validateAndFixSmartLinks( content: string, blockId: string|false = false ): Promise { // Get the post content and all the smart links from the store. let smartLinks = select( SmartLinkingStore ).getSmartLinks(); @@ -479,17 +483,21 @@ export async function validateAndFixSmartLinks( content: string, blockId: string } } ); + // Flag to check if any fixes were made. + let didAnyFixes = false; + // For each missing smart link, try to find a link that matches the text, title and href. - missingSmartLinks.forEach( ( missingSmartLink ) => { + for ( let i = 0; i < missingSmartLinks.length; i++ ) { + const missingSmartLink = missingSmartLinks[ i ]; if ( ! missingSmartLink.match?.blockId ) { - return; + continue; } // Get the block that contains the smart link. const block = select( 'core/block-editor' ).getBlock( missingSmartLink.match?.blockId ); if ( ! block ) { - return; + continue; } const blockContent: string = getBlockContent( block ); @@ -502,11 +510,11 @@ export async function validateAndFixSmartLinks( content: string, blockId: string } ); if ( ! link ) { - return; + continue; } // If the link is found, remove it from the missing smart links array. - missingSmartLinks.splice( missingSmartLinks.indexOf( missingSmartLink ), 1 ); + missingSmartLinks.splice( i--, 1 ); // Restore the missing fields from the link (data-smartlink and title). link.setAttribute( 'data-smartlink', missingSmartLink.uid ); @@ -515,24 +523,29 @@ export async function validateAndFixSmartLinks( content: string, blockId: string // Update the block content with the new content. const paragraph = blockDoc.body.firstChild as HTMLElement; dispatch( 'core/block-editor' ).updateBlockAttributes( block.clientId, { content: paragraph.innerHTML } ); - } ); + didAnyFixes = true; + } - return missingSmartLinks; + return { missingSmartLinks, didAnyFixes }; } /** * Validates and fixes smart links in the post content. * * @since 3.16.0 + * + * @return {boolean} Whether any fixes were made. */ -export async function validateAndFixSmartLinksInPost(): Promise { +export async function validateAndFixSmartLinksInPost(): Promise { const postContent = select( 'core/editor' ).getEditedPostContent(); - const missingLinks = await validateAndFixSmartLinks( postContent ); + const { missingSmartLinks, didAnyFixes } = await validateAndFixSmartLinks( postContent ); // Remove any missing smart-links that are not in the store. - missingLinks.forEach( ( missingLink ) => { + missingSmartLinks.forEach( ( missingLink ) => { dispatch( SmartLinkingStore ).removeSmartLink( missingLink.uid ); } ); + + return didAnyFixes; } /** @@ -541,15 +554,19 @@ export async function validateAndFixSmartLinksInPost(): Promise { * @since 3.16.0 * * @param {BlockInstance} block The block instance to validate and fix smart links. + * + * @return {boolean} Whether any fixes were made. */ -export async function validateAndFixSmartLinksInBlock( block: BlockInstance ): Promise { +export async function validateAndFixSmartLinksInBlock( block: BlockInstance ): Promise { const blockContent: string = getBlockContent( block ); - const missingLinks = await validateAndFixSmartLinks( blockContent, block.clientId ); + const { missingSmartLinks, didAnyFixes } = await validateAndFixSmartLinks( blockContent, block.clientId ); // Remove any missing smart-links that are not in the store. - missingLinks.forEach( ( missingLink ) => { + missingSmartLinks.forEach( ( missingLink ) => { dispatch( SmartLinkingStore ).removeSmartLink( missingLink.uid ); } ); + + return didAnyFixes; } /** From 6d9606cc2baefcdedbce43659d76f6d4a91ad775 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 22 May 2024 11:01:47 +0100 Subject: [PATCH 28/44] Address issue with sorting in some edge cases --- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.js | 2 +- .../editor-sidebar/smart-linking/provider.ts | 3 +++ .../review-modal/component-suggestion.tsx | 15 +++++++-------- .../editor-sidebar/smart-linking/utils.ts | 5 +++-- 5 files changed, 15 insertions(+), 12 deletions(-) diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index 2f2f72f35..e8d7acf74 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-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => 'f3a73bf70642da809d4a'); + array('react', 'wp-api-fetch', 'wp-block-editor', 'wp-blocks', 'wp-components', 'wp-compose', 'wp-core-data', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '8689d9ef12bf6681a56b'); diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index 0dd1d25e8..d52248307 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,4 +1,4 @@ -!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 Bn}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=n(609),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,h=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}(),v=(h.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"})})}),g=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"})]})},y=function(){return y=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiError||s.code===A.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===A.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===A.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return G(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[A.PluginCredentialsNotSetMessageDetected,A.PluginSettingsSiteIdNotSet,A.PluginSettingsApiSecretNotSet].includes(this.code)?M(e):(this.code===A.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==A.ParselyApiForbidden&&this.code!==A.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===A.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(I,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var W,U=function(e){var t=e.isDetectingEnabled,n=e.onLinkChange,r=e.onLinkRemove,i=e.onLinkAdd,s=e.debounceValue,o=void 0===s?500:s,c=(0,a.useSelect)((function(e){return{blocks:(0,e("core/block-editor").getBlocks)()}}),[]).blocks,u=(0,l.useRef)(c),p=(0,l.useRef)(t);return(0,l.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}(c,u.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)})),u.current=c)}),o);return e(t),function(){e.cancel()}}),[c,o,t,i,n,r]),null},q=window.wp.editor,Z=window.wp.blocks,$=function(){return $=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var u=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,c.__)("NEW","wp-parsely"),(0,i.jsx)(fe,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,c.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&u]},e.uid)}))]})})},ve=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,u.createElement)(p.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})),ge=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),ye=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),me=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),we=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})),_e=window.wp.url,be=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?p(!0):k().then((function(){return t()}))},E=function(e){p(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},L=function(){var e=g.indexOf(_)+1;g[e]&&b(g[e])},C=function(){var e=m().indexOf(_)-1;m()[e]&&b(m()[e])},A=function(){return Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(this,(function(n){switch(n.label){case 0:return _.match?(r(_),[4,(i=_.match.blockId,s=_,Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(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))?(ne(t,s,e),s.applied=!0,[4,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(_),g[t=e+1]?b(g[t]):b(g[0]),[2])}var i,s}))}))},N=function(){return Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(this,(function(n){switch(n.label){case 0:return e=g.indexOf(_),g[t=e+1]?b(g[t]):g[0]?b(g[0]):T(),[4,P(_.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Ne(void 0,void 0,void 0,(function(){var e,t,n,r;return Oe(this,(function(i){switch(i.label){case 0:return _.match?(e=(0,a.select)("core/block-editor").getBlock(_.match.blockId))?(t=m(),n=t.indexOf(_),r=n-1,[4,j(e,_)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?b(t[r]):b(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:L,up:C,down:L,a:function(){_&&!_.applied&&A()},r:function(){_&&(_.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(he,{links:g,activeLink:_,setSelectedLink:b}),(0,i.jsx)(Ae,{link:_,hasNext:m().indexOf(_)0,onNext:L,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(_.match){var e=(0,a.select)("core/block-editor").getBlock(_.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(_.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),u&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return E(!1)},className:"wp-parsely-smart-linking-close-dialog",children:[(0,c.__)("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 E(!1)},children:(0,c.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return E(!0)},children:(0,c.__)("Close","wp-parsely")})]})]})]})})),Ie=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})]})]})},Me=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,u=e.onSettingChange,p=(0,l.useRef)(),d=(0,l.useState)(""),f=d[0],h=d[1],v=(0,l.useState)(!1),g=v[0],y=v[1],m=(0,l.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(Q),n=t.getMaxLinkWords,r=t.getMaxLinks,i=t.isFullContent,s=t.wasAlreadyClicked,a=t.getApplyTo;return{maxLinks:r(),maxLinkWords:n(),fullContent:i(),alreadyClicked:s(),applyTo:a()}}),[]),_=w.maxLinks,b=w.maxLinkWords,x=w.fullContent,k=w.alreadyClicked,S=w.applyTo,P=(0,a.useDispatch)(Q),j=P.setMaxLinks,T=P.setMaxLinkWords,E=P.setFullContent,L=P.setAlreadyClicked,C=P.setApplyTo,A=null!==(t=S)&&void 0!==t?t:o?"selected":"all";return(0,l.useEffect)((function(){if(!r){var e=function(){r||(S===W.Selected&&setTimeout((function(){h((0,c.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),C(null),m((function(e){return!e})))};o||S===W.All||(g?setTimeout(e,500):e()),E(W.All===A)}}),[g,S,A,r,o,C,E,h]),(0,l.useEffect)((function(){if(!r&&p.current&&A&&!k&&o){var e=p.current.querySelector('button[data-value="'.concat(A,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(C(A),L(!0))}}),[o,x,r,S]),(0,l.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:A,label:(0,c.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&b("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 Bn}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=n(609),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,h=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}(),v=(h.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"})})}),g=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"})]})},y=function(){return y=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiError||s.code===A.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===A.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===A.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return G(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[A.PluginCredentialsNotSetMessageDetected,A.PluginSettingsSiteIdNotSet,A.PluginSettingsApiSecretNotSet].includes(this.code)?M(e):(this.code===A.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==A.ParselyApiForbidden&&this.code!==A.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===A.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(I,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var W,U=function(e){var t=e.isDetectingEnabled,n=e.onLinkChange,r=e.onLinkRemove,i=e.onLinkAdd,s=e.debounceValue,o=void 0===s?500:s,c=(0,a.useSelect)((function(e){return{blocks:(0,e("core/block-editor").getBlocks)()}}),[]).blocks,u=(0,l.useRef)(c),p=(0,l.useRef)(t);return(0,l.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}(c,u.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)})),u.current=c)}),o);return e(t),function(){e.cancel()}}),[c,o,t,i,n,r]),null},q=window.wp.editor,Z=window.wp.blocks,$=function(){return $=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var u=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,c.__)("NEW","wp-parsely"),(0,i.jsx)(fe,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,c.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&u]},e.uid)}))]})})},ve=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,u.createElement)(p.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})),ge=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),ye=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),me=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),we=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})),_e=window.wp.url,be=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?p(!0):k().then((function(){return t()}))},E=function(e){p(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},L=function(){var e=g.indexOf(_)+1;g[e]&&b(g[e])},C=function(){var e=m().indexOf(_)-1;m()[e]&&b(m()[e])},A=function(){return Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(this,(function(n){switch(n.label){case 0:return _.match?(r(_),[4,(i=_.match.blockId,s=_,Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(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))?(ne(t,s,e),s.applied=!0,[4,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(_),g[t=e+1]?b(g[t]):b(g[0]),[2])}var i,s}))}))},N=function(){return Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(this,(function(n){switch(n.label){case 0:return e=g.indexOf(_),g[t=e+1]?b(g[t]):g[0]?b(g[0]):T(),[4,P(_.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Ne(void 0,void 0,void 0,(function(){var e,t,n,r;return Oe(this,(function(i){switch(i.label){case 0:return _.match?(e=(0,a.select)("core/block-editor").getBlock(_.match.blockId))?(t=m(),n=t.indexOf(_),r=n-1,[4,j(e,_)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?b(t[r]):b(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:L,up:C,down:L,a:function(){_&&!_.applied&&A()},r:function(){_&&(_.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(he,{links:g,activeLink:_,setSelectedLink:b}),(0,i.jsx)(Ae,{link:_,hasNext:m().indexOf(_)0,onNext:L,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(_.match){var e=(0,a.select)("core/block-editor").getBlock(_.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(_.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),u&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return E(!1)},className:"wp-parsely-smart-linking-close-dialog",children:[(0,c.__)("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 E(!1)},children:(0,c.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return E(!0)},children:(0,c.__)("Close","wp-parsely")})]})]})]})})),Ie=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})]})]})},Me=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,u=e.onSettingChange,p=(0,l.useRef)(),d=(0,l.useState)(""),f=d[0],h=d[1],v=(0,l.useState)(!1),g=v[0],y=v[1],m=(0,l.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(Q),n=t.getMaxLinkWords,r=t.getMaxLinks,i=t.isFullContent,s=t.wasAlreadyClicked,a=t.getApplyTo;return{maxLinks:r(),maxLinkWords:n(),fullContent:i(),alreadyClicked:s(),applyTo:a()}}),[]),_=w.maxLinks,b=w.maxLinkWords,x=w.fullContent,k=w.alreadyClicked,S=w.applyTo,P=(0,a.useDispatch)(Q),j=P.setMaxLinks,T=P.setMaxLinkWords,E=P.setFullContent,L=P.setAlreadyClicked,C=P.setApplyTo,A=null!==(t=S)&&void 0!==t?t:o?"selected":"all";return(0,l.useEffect)((function(){if(!r){var e=function(){r||(S===W.Selected&&setTimeout((function(){h((0,c.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),C(null),m((function(e){return!e})))};o||S===W.All||(g?setTimeout(e,500):e()),E(W.All===A)}}),[g,S,A,r,o,C,E,h]),(0,l.useEffect)((function(){if(!r&&p.current&&A&&!k&&o){var e=p.current.querySelector('button[data-value="'.concat(A,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(C(A),L(!0))}}),[o,x,r,S]),(0,l.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:A,label:(0,c.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&b("success",/* translators: %d: number of smart links applied */ /* translators: %d: number of smart links applied */ (0,c.sprintf)((0,c.__)("%s smart links successfully applied.","wp-parsely"),g),{type:"snackbar"}):y(0)}),[w]),(0,l.useEffect)((function(){if(!(Object.keys(I).length>0)){var e={maxLinksPerPost:p.SmartLinking.MaxLinks,maxLinkWords:p.SmartLinking.MaxLinkWords};re(e)}}),[re,p]);var me=(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]),we=me.allBlocks,_e=me.selectedBlock,be=me.postContent,xe=me.postPermalink,ke=function(e){return De(void 0,void 0,void 0,(function(){var t,n,r,i;return Ve(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,ie((n=T||!_e)?W.All:W.Selected)];case 2:return s.sent(),a=xe.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,Pe.getInstance().generateSmartLinks((null==_e?void 0:_e.originalContent)&&!n?_e.originalContent:be,R,N,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===A.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,he(!0)]):[3,8];case 5:return s.sent(),[4,ve()];case 6:return s.sent(),[4,ke(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},Se=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Ee=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)(U,{isDetectingEnabled:!j,onLinkRemove:function(e){!function(e){X(this,void 0,void 0,(function(){var t,n,r;return J(this,(function(i){switch(i.label){case 0:return[4,le((0,Z.getBlockContent)(e),e.clientId)];case 1:return t=i.sent(),n=t.missingSmartLinks,r=t.didAnyFixes,n.forEach((function(e){(0,a.dispatch)(Q).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,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(V,{icon:F,size:18,className:"parsely-external-link-icon"})]})]}),L&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return Y(null)},className:"wp-parsely-content-helper-error",children:L.Message()}),w&&g>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return _(!1)},className:"wp-parsely-smart-linking-suggested-links",children:(0,c.sprintf)(/* translators: 1 - number of smart links generated */ /* translators: 1 - number of smart links generated */ (0,c.__)("Successfully added %s smart links.","wp-parsely"),g>0?g:C.length)}),(0,i.jsx)(Me,{disabled:S,selectedBlock:null==_e?void 0:_e.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:Be(Be({},p.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e?fe(t):"MaxLinkWords"===e&&oe(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return De(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Ve(this,(function(a){switch(a.label){case 0:return[4,K(!0)];case 1:return a.sent(),[4,ge()];case 2:return a.sent(),[4,Y(null)];case 3:return a.sent(),_(!1),h.trackEvent("smart_linking_generate_pressed",{is_full_content:T,selected_block:null!==(s=null==_e?void 0:_e.name)&&void 0!==s?s:"none",context:o}),[4,Se(T?"all":null==_e?void 0:_e.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;K(!1),h.trackEvent("smart_linking_generate_timeout",{is_full_content:T,selected_block:null!==(e=null==_e?void 0:_e.name)&&void 0!==e?e:"none",context:o}),je(T?"all":null==_e?void 0:_e.clientId)}),18e4),t=M,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,ke(3)];case 6:return n=a.sent(),[4,(l=n,De(void 0,void 0,void 0,(function(){var e;return Ve(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!G.find((function(t){return t.uid===e.uid&&t.applied}))})),e=xe.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=se(we,l,{}).filter((function(e){return e.match})),[4,ee(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),ye(!0),[3,15];case 8:return r=a.sent(),i=(0,c.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===A.ParselyAborted&&(i=(0,c.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ /* translators: %d: number of retry attempts, %s: attempt plural */ (0,c.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),r.numRetries,(0,c._n)("attempt","attempts",r.numRetries,"wp-parsely")),r.message=i),[4,Y(r)];case 9:return a.sent(),b("error",i,{type:"snackbar"}),[3,15];case 10:return[4,K(!1)];case 11:return a.sent(),[4,ie(t)];case 12:return a.sent(),[4,he(!1)];case 13:return a.sent(),[4,je(T?"all":null==_e?void 0:_e.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:S,disabled:S,children:B?(0,c.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 */ diff --git a/src/content-helper/editor-sidebar/smart-linking/provider.ts b/src/content-helper/editor-sidebar/smart-linking/provider.ts index 9071bb11f..d853feced 100644 --- a/src/content-helper/editor-sidebar/smart-linking/provider.ts +++ b/src/content-helper/editor-sidebar/smart-linking/provider.ts @@ -14,6 +14,7 @@ import { DEFAULT_MAX_LINK_WORDS, DEFAULT_MAX_LINKS } from './smart-linking'; * `content-suggestions/suggest-linked-reference` endpoint. * * @since 3.14.0 + * @since 3.16.0 Added the `applied`, `match`, `post_id`, and `post_type` properties. */ export type SmartLink = { uid: string; @@ -30,6 +31,8 @@ export type SmartLink = { /** * Structure of a link suggestion match, that is filled in by the * processing of the smart links. + * + * @since 3.16.0 */ export type SmartLinkMatch = { blockId: string; diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx index 0f0db861a..e1abc447b 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx @@ -11,7 +11,7 @@ import { Tooltip, } from '@wordpress/components'; import { select as selectFn, useDispatch, useSelect } from '@wordpress/data'; -import { useEffect, useRef, useState } from '@wordpress/element'; +import { useEffect, useMemo, useRef, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; import { arrowLeft, arrowRight, check, closeSmall, Icon, page } from '@wordpress/icons'; @@ -148,17 +148,16 @@ type BlockPreviewProps = { * @param {BlockPreviewProps} props The component props. */ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { - const [ clonedBlock, setClonedBlock ] = useState( cloneBlock( block ) ); - /** - * Runs when the block is updated. - * It will update the cloned block with the new block. + * Clones the block to prevent editing the original block. + * The memoized block is used to prevent unnecessary re-renders. + * + * It updates when the block or link changes. * * @since 3.16.0 */ - useEffect( () => { - setClonedBlock( cloneBlock( block ) ); - }, [ block, link ] ); + // eslint-disable-next-line react-hooks/exhaustive-deps + const clonedBlock = useMemo( () => cloneBlock( block ), [ block, link ] ); /** * Runs when the block is rendered in the DOM. diff --git a/src/content-helper/editor-sidebar/smart-linking/utils.ts b/src/content-helper/editor-sidebar/smart-linking/utils.ts index cc424c455..03bf96d89 100644 --- a/src/content-helper/editor-sidebar/smart-linking/utils.ts +++ b/src/content-helper/editor-sidebar/smart-linking/utils.ts @@ -294,7 +294,7 @@ export function calculateSmartLinkingMatches( return; } - const fullContent = contentElement.innerHTML; + const fullContentPlain = contentElement.textContent; links.forEach( ( link ) => { const textNodes = findTextNodesNotInAnchor( contentElement, link.text ); @@ -308,7 +308,7 @@ export function calculateSmartLinkingMatches( const regex = new RegExp( escapeRegExp( link.text ), 'g' ); let match; const nodeText = node.textContent ?? ''; - const startPosition = fullContent.indexOf( nodeText, cumulativeTextLength ); + const startPosition = fullContentPlain?.indexOf( nodeText, cumulativeTextLength ) ?? 0; while ( ( match = regex.exec( nodeText ) ) !== null ) { const occurrenceCount = occurrenceCounts[ occurrenceKey ]; @@ -442,6 +442,7 @@ type ValidateAndFixSmartLinksReturnType = { missingSmartLinks: SmartLink[], didAnyFixes: boolean }; + /** * Validates and fixes smart links in a specific content. * From 72d9292a7a1759c677fc600c5df0081f38153f76 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 22 May 2024 15:00:30 +0100 Subject: [PATCH 29/44] Apply code review suggestions --- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.js | 40 +++++++++---------- src/Endpoints/class-base-endpoint.php | 2 +- .../class-base-endpoint-user-meta.php | 2 +- .../class-analytics-post-detail-api.php | 2 +- .../editor-sidebar/editor-sidebar.tsx | 7 +++- .../smart-linking/smart-linking.scss | 5 --- .../editor-sidebar/smart-linking/utils.ts | 13 ++++-- .../js/content-helper/smart-linking.test.tsx | 23 +++++++++++ 9 files changed, 63 insertions(+), 33 deletions(-) create mode 100644 tests/js/content-helper/smart-linking.test.tsx diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index e8d7acf74..c51ed8905 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-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '8689d9ef12bf6681a56b'); + 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' => '60c5e3eff2a39794cf2d'); diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index d52248307..349630f4a 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,27 +1,27 @@ -!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 Bn}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=n(609),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,h=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}(),v=(h.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"})})}),g=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"})]})},y=function(){return y=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiError||s.code===A.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===A.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===A.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return G(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[A.PluginCredentialsNotSetMessageDetected,A.PluginSettingsSiteIdNotSet,A.PluginSettingsApiSecretNotSet].includes(this.code)?M(e):(this.code===A.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==A.ParselyApiForbidden&&this.code!==A.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===A.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(I,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var W,U=function(e){var t=e.isDetectingEnabled,n=e.onLinkChange,r=e.onLinkRemove,i=e.onLinkAdd,s=e.debounceValue,o=void 0===s?500:s,c=(0,a.useSelect)((function(e){return{blocks:(0,e("core/block-editor").getBlocks)()}}),[]).blocks,u=(0,l.useRef)(c),p=(0,l.useRef)(t);return(0,l.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}(c,u.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)})),u.current=c)}),o);return e(t),function(){e.cancel()}}),[c,o,t,i,n,r]),null},q=window.wp.editor,Z=window.wp.blocks,$=function(){return $=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var u=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,c.__)("NEW","wp-parsely"),(0,i.jsx)(fe,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,c.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&u]},e.uid)}))]})})},ve=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,u.createElement)(p.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})),ge=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),ye=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),me=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),we=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})),_e=window.wp.url,be=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?p(!0):k().then((function(){return t()}))},E=function(e){p(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},L=function(){var e=g.indexOf(_)+1;g[e]&&b(g[e])},C=function(){var e=m().indexOf(_)-1;m()[e]&&b(m()[e])},A=function(){return Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(this,(function(n){switch(n.label){case 0:return _.match?(r(_),[4,(i=_.match.blockId,s=_,Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(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))?(ne(t,s,e),s.applied=!0,[4,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(_),g[t=e+1]?b(g[t]):b(g[0]),[2])}var i,s}))}))},N=function(){return Ne(void 0,void 0,void 0,(function(){var e,t;return Oe(this,(function(n){switch(n.label){case 0:return e=g.indexOf(_),g[t=e+1]?b(g[t]):g[0]?b(g[0]):T(),[4,P(_.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Ne(void 0,void 0,void 0,(function(){var e,t,n,r;return Oe(this,(function(i){switch(i.label){case 0:return _.match?(e=(0,a.select)("core/block-editor").getBlock(_.match.blockId))?(t=m(),n=t.indexOf(_),r=n-1,[4,j(e,_)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?b(t[r]):b(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:L,up:C,down:L,a:function(){_&&!_.applied&&A()},r:function(){_&&(_.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(he,{links:g,activeLink:_,setSelectedLink:b}),(0,i.jsx)(Ae,{link:_,hasNext:m().indexOf(_)0,onNext:L,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(_.match){var e=(0,a.select)("core/block-editor").getBlock(_.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(_.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),u&&(0,i.jsxs)(s.Modal,{title:(0,c.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return E(!1)},className:"wp-parsely-smart-linking-close-dialog",children:[(0,c.__)("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 E(!1)},children:(0,c.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return E(!0)},children:(0,c.__)("Close","wp-parsely")})]})]})]})})),Ie=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})]})]})},Me=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,u=e.onSettingChange,p=(0,l.useRef)(),d=(0,l.useState)(""),f=d[0],h=d[1],v=(0,l.useState)(!1),g=v[0],y=v[1],m=(0,l.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(Q),n=t.getMaxLinkWords,r=t.getMaxLinks,i=t.isFullContent,s=t.wasAlreadyClicked,a=t.getApplyTo;return{maxLinks:r(),maxLinkWords:n(),fullContent:i(),alreadyClicked:s(),applyTo:a()}}),[]),_=w.maxLinks,b=w.maxLinkWords,x=w.fullContent,k=w.alreadyClicked,S=w.applyTo,P=(0,a.useDispatch)(Q),j=P.setMaxLinks,T=P.setMaxLinkWords,E=P.setFullContent,L=P.setAlreadyClicked,C=P.setApplyTo,A=null!==(t=S)&&void 0!==t?t:o?"selected":"all";return(0,l.useEffect)((function(){if(!r){var e=function(){r||(S===W.Selected&&setTimeout((function(){h((0,c.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),C(null),m((function(e){return!e})))};o||S===W.All||(g?setTimeout(e,500):e()),E(W.All===A)}}),[g,S,A,r,o,C,E,h]),(0,l.useEffect)((function(){if(!r&&p.current&&A&&!k&&o){var e=p.current.querySelector('button[data-value="'.concat(A,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(C(A),L(!0))}}),[o,x,r,S]),(0,l.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:p,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:A,label:(0,c.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&b("success",/* translators: %d: number of smart links applied */ /* translators: %d: number of smart links applied */ -(0,c.sprintf)((0,c.__)("%s smart links successfully applied.","wp-parsely"),g),{type:"snackbar"}):y(0)}),[w]),(0,l.useEffect)((function(){if(!(Object.keys(I).length>0)){var e={maxLinksPerPost:p.SmartLinking.MaxLinks,maxLinkWords:p.SmartLinking.MaxLinkWords};re(e)}}),[re,p]);var me=(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]),we=me.allBlocks,_e=me.selectedBlock,be=me.postContent,xe=me.postPermalink,ke=function(e){return De(void 0,void 0,void 0,(function(){var t,n,r,i;return Ve(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,ie((n=T||!_e)?W.All:W.Selected)];case 2:return s.sent(),a=xe.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,Pe.getInstance().generateSmartLinks((null==_e?void 0:_e.originalContent)&&!n?_e.originalContent:be,R,N,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===A.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,he(!0)]):[3,8];case 5:return s.sent(),[4,ve()];case 6:return s.sent(),[4,ke(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},Se=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Ee=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)(U,{isDetectingEnabled:!j,onLinkRemove:function(e){!function(e){X(this,void 0,void 0,(function(){var t,n,r;return J(this,(function(i){switch(i.label){case 0:return[4,le((0,Z.getBlockContent)(e),e.clientId)];case 1:return t=i.sent(),n=t.missingSmartLinks,r=t.didAnyFixes,n.forEach((function(e){(0,a.dispatch)(Q).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,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(V,{icon:F,size:18,className:"parsely-external-link-icon"})]})]}),L&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return Y(null)},className:"wp-parsely-content-helper-error",children:L.Message()}),w&&g>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return _(!1)},className:"wp-parsely-smart-linking-suggested-links",children:(0,c.sprintf)(/* translators: 1 - number of smart links generated */ /* translators: 1 - number of smart links generated */ -(0,c.__)("Successfully added %s smart links.","wp-parsely"),g>0?g:C.length)}),(0,i.jsx)(Me,{disabled:S,selectedBlock:null==_e?void 0:_e.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:Be(Be({},p.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e?fe(t):"MaxLinkWords"===e&&oe(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return De(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Ve(this,(function(a){switch(a.label){case 0:return[4,K(!0)];case 1:return a.sent(),[4,ge()];case 2:return a.sent(),[4,Y(null)];case 3:return a.sent(),_(!1),h.trackEvent("smart_linking_generate_pressed",{is_full_content:T,selected_block:null!==(s=null==_e?void 0:_e.name)&&void 0!==s?s:"none",context:o}),[4,Se(T?"all":null==_e?void 0:_e.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;K(!1),h.trackEvent("smart_linking_generate_timeout",{is_full_content:T,selected_block:null!==(e=null==_e?void 0:_e.name)&&void 0!==e?e:"none",context:o}),je(T?"all":null==_e?void 0:_e.clientId)}),18e4),t=M,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,ke(3)];case 6:return n=a.sent(),[4,(l=n,De(void 0,void 0,void 0,(function(){var e;return Ve(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!G.find((function(t){return t.uid===e.uid&&t.applied}))})),e=xe.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=se(we,l,{}).filter((function(e){return e.match})),[4,ee(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),ye(!0),[3,15];case 8:return r=a.sent(),i=(0,c.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===A.ParselyAborted&&(i=(0,c.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ /* translators: %d: number of retry attempts, %s: attempt plural */ -(0,c.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),r.numRetries,(0,c._n)("attempt","attempts",r.numRetries,"wp-parsely")),r.message=i),[4,Y(r)];case 9:return a.sent(),b("error",i,{type:"snackbar"}),[3,15];case 10:return[4,K(!1)];case 11:return a.sent(),[4,ie(t)];case 12:return a.sent(),[4,he(!1)];case 13:return a.sent(),[4,je(T?"all":null==_e?void 0:_e.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:S,disabled:S,children:B?(0,c.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,c.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),D,3):S?(0,c.__)("Generating Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")})}),H.length>0&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return De(void 0,void 0,void 0,(function(){var e;return Ve(this,(function(t){switch(t.label){case 0:return[4,ce()];case 1:return t.sent(),e=ae(),[4,ee(e)];case 2:return t.sent(),ye(!0),[2]}}))}))},variant:"secondary",children:(0,c.__)("Review Smart Links","wp-parsely")})})]}),j&&(0,i.jsx)(Re,{isOpen:j,onAppliedLink:function(){y((function(e){return e+1}))},onClose:function(){_(!0),ye(!1)}})]})},He=function(){return He=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 tt=function(e){var n=e.data,r=e.isLoading,a=(0,l.useState)(t.Views),o=a[0],u=a[1],p=(0,l.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},v=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),L(o)); -/* translators: %s: metric description */return(0,i.jsxs)(Je,{title:(0,c.__)("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,c.__)("By: ","wp-parsely"),onChange:function(e){T(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,i.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[L(e),"avg_engaged"===e&&(0,c.__)(" (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,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ /* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ -(0,c.__)("%1$s: %2$s%%","wp-parsely"),h(t),n.viewsPercentage);return(0,i.jsx)(s.Tooltip +!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 Gn}});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=n(609),f=window.wp.primitives,h=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),v=window.wp.plugins,g=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,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}(),y=(g.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"})})}),m=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"})]})},w=function(){return w=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===O.ParselySuggestionsApiOpenAiError||s.code===O.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===O.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===O.ParselySuggestionsApiSchemaError?s.message=(0,p.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===O.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===O.ParselySuggestionsApiOpenAiSchema?s.message=(0,p.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===O.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,p.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return z(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[O.PluginCredentialsNotSetMessageDetected,O.PluginSettingsSiteIdNotSet,O.PluginSettingsApiSecretNotSet].includes(this.code)?D(e):(this.code===O.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!==O.ParselyApiForbidden&&this.code!==O.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===O.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)(B,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function U(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var q,Z=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,I.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},$=window.wp.editor,K=window.wp.blocks,Y=function(){return Y=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var l=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,p.__)("NEW","wp-parsely"),(0,i.jsx)(ve,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,p.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&l]},e.uid)}))]})})},ye=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,d.createElement)(f.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})),me=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),we=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),_e=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),be=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})),xe=window.wp.url,ke=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?c(!0):k().then((function(){return t()}))},E=function(e){c(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},L=function(){var e=g.indexOf(_)+1;g[e]&&b(g[e])},C=function(){var e=m().indexOf(_)-1;m()[e]&&b(m()[e])},A=function(){return Re(void 0,void 0,void 0,(function(){var e,t;return Ie(this,(function(n){switch(n.label){case 0:return _.match?(r(_),[4,(i=_.match.blockId,s=_,Re(void 0,void 0,void 0,(function(){var e,t;return Ie(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))?(ie(t,s,e),s.applied=!0,[4,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(_),g[t=e+1]?b(g[t]):b(g[0]),[2])}var i,s}))}))},N=function(){return Re(void 0,void 0,void 0,(function(){var e,t;return Ie(this,(function(n){switch(n.label){case 0:return e=g.indexOf(_),g[t=e+1]?b(g[t]):g[0]?b(g[0]):T(),[4,P(_.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Re(void 0,void 0,void 0,(function(){var e,t,n,r;return Ie(this,(function(i){switch(i.label){case 0:return _.match?(e=(0,a.select)("core/block-editor").getBlock(_.match.blockId))?(t=m(),n=t.indexOf(_),r=n-1,[4,j(e,_)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?b(t[r]):b(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:L,up:C,down:L,a:function(){_&&!_.applied&&A()},r:function(){_&&(_.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(ge,{links:g,activeLink:_,setSelectedLink:b}),(0,i.jsx)(Oe,{link:_,hasNext:m().indexOf(_)0,onNext:L,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(_.match){var e=(0,a.select)("core/block-editor").getBlock(_.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(_.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),l&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return E(!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 E(!1)},children:(0,p.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return E(!0)},children:(0,p.__)("Close","wp-parsely")})]})]})]})})),Be=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})]})]})},De=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,l=e.onSettingChange,c=(0,u.useRef)(),d=(0,u.useState)(""),f=d[0],h=d[1],v=(0,u.useState)(!1),g=v[0],y=v[1],m=(0,u.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(J),n=t.getMaxLinkWords,r=t.getMaxLinks,i=t.isFullContent,s=t.wasAlreadyClicked,a=t.getApplyTo;return{maxLinks:r(),maxLinkWords:n(),fullContent:i(),alreadyClicked:s(),applyTo:a()}}),[]),_=w.maxLinks,b=w.maxLinkWords,x=w.fullContent,k=w.alreadyClicked,S=w.applyTo,P=(0,a.useDispatch)(J),j=P.setMaxLinks,T=P.setMaxLinkWords,E=P.setFullContent,L=P.setAlreadyClicked,C=P.setApplyTo,A=null!==(t=S)&&void 0!==t?t:o?"selected":"all";return(0,u.useEffect)((function(){if(!r){var e=function(){r||(S===q.Selected&&setTimeout((function(){h((0,p.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),C(null),m((function(e){return!e})))};o||S===q.All||(g?setTimeout(e,500):e()),E(q.All===A)}}),[g,S,A,r,o,C,E,h]),(0,u.useEffect)((function(){if(!r&&c.current&&A&&!k&&o){var e=c.current.querySelector('button[data-value="'.concat(A,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(C(A),L(!0))}}),[o,x,r,S]),(0,u.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:c,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:A,label:(0,p.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&b("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"),v),{type:"snackbar"}):y(0)}),[w]),(0,u.useEffect)((function(){if(!(Object.keys(R).length>0)){var e={maxLinksPerPost:c.SmartLinking.MaxLinks,maxLinkWords:c.SmartLinking.MaxLinkWords};re(e)}}),[re,c]);var me=(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]),we=me.allBlocks,_e=me.selectedBlock,be=me.postContent,xe=me.postPermalink,ke=function(e){return Fe(void 0,void 0,void 0,(function(){var t,n,r,i;return Ge(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,ie((n=j||!_e)?q.All:q.Selected)];case 2:return s.sent(),a=xe.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,Te.getInstance().generateSmartLinks((null==_e?void 0:_e.originalContent)&&!n?_e.originalContent:be,N,A,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===O.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,ce(!0)]):[3,8];case 5:return s.sent(),[4,ve()];case 6:return s.sent(),[4,ke(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},Se=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Ee=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)(Z,{isDetectingEnabled:!P,onLinkRemove:function(e){!function(e){ee(this,void 0,void 0,(function(){var t,n,r;return te(this,(function(i){switch(i.label){case 0:return[4,ue((0,K.getBlockContent)(e),e.clientId)];case 1:return t=i.sent(),n=t.missingSmartLinks,r=t.didAnyFixes,n.forEach((function(e){(0,a.dispatch)(J).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)(G,{icon:H,size:18,className:"parsely-external-link-icon"})]})]}),L&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return Y(null)},className:"wp-parsely-content-helper-error",children:L.Message()}),w&&v>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return _(!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"),v>0?v:C.length)}),(0,i.jsx)(De,{disabled:S,selectedBlock:null==_e?void 0:_e.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:Ve(Ve({},c.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e?ae(t):"MaxLinkWords"===e&&se(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return Fe(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Ge(this,(function(a){switch(a.label){case 0:return[4,U(!0)];case 1:return a.sent(),[4,ge()];case 2:return a.sent(),[4,Y(null)];case 3:return a.sent(),_(!1),g.trackEvent("smart_linking_generate_pressed",{is_full_content:j,selected_block:null!==(s=null==_e?void 0:_e.name)&&void 0!==s?s:"none",context:o}),[4,Se(j?"all":null==_e?void 0:_e.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;U(!1),g.trackEvent("smart_linking_generate_timeout",{is_full_content:j,selected_block:null!==(e=null==_e?void 0:_e.name)&&void 0!==e?e:"none",context:o}),Pe(j?"all":null==_e?void 0:_e.clientId)}),18e4),t=M,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,ke(3)];case 6:return n=a.sent(),[4,(l=n,Fe(void 0,void 0,void 0,(function(){var e;return Ge(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!V.find((function(t){return t.uid===e.uid&&t.applied}))})),e=xe.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=oe(we,l,{}).filter((function(e){return e.match})),[4,Q(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),ye(!0),[3,15];case 8:return r=a.sent(),i=(0,p.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===O.ParselyAborted&&(i=(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")),r.message=i),[4,Y(r)];case 9:return a.sent(),b("error",i,{type:"snackbar"}),[3,15];case 10:return[4,U(!1)];case 11:return a.sent(),[4,ie(t)];case 12:return a.sent(),[4,ce(!1)];case 13:return a.sent(),[4,Pe(j?"all":null==_e?void 0:_e.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:S,disabled:S,children:B?(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"),D,3):S?(0,p.__)("Generating Smart Links…","wp-parsely"):(0,p.__)("Add Smart Links","wp-parsely")})}),F.length>0&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return Fe(void 0,void 0,void 0,(function(){var e;return Ge(this,(function(t){switch(t.label){case 0:return[4,pe()];case 1:return t.sent(),e=le(),[4,Q(e)];case 2:return t.sent(),ye(!0),[2]}}))}))},variant:"secondary",children:(0,p.__)("Review Smart Links","wp-parsely")})})]}),P&&(0,i.jsx)(Me,{isOpen:P,onAppliedLink:function(){y((function(e){return e+1}))},onClose:function(){_(!0),ye(!1)}})]})},We=function(){return We=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 st=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"),A(o)); +/* translators: %s: metric description */return(0,i.jsxs)(rt,{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:[A(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,c.sprintf)((0,c.__)("%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:et(n.views)})]},t)}))})]})]})},nt=(0,u.createElement)(p.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.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"})),rt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),it=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),st=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"})),at=function(){return at=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]1?[2,Promise.reject(new H((0,c.sprintf)(/* translators: URL of the published post */ /* translators: URL of the published post */ -(0,c.__)("Multiple results were returned for the post %s by the Parse.ly API.","wp-parsely"),t),A.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return mt(this,void 0,void 0,(function(){return wt(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,_e.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",yt(yt({},vt(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(be),bt=function(){return bt=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)(Je,{title:(0,c.__)("Performance Stats","wp-parsely"),icon:Xe,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(Tt,{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,c.__)("Period: ","wp-parsely")}),onChange:function(t){T(t,e)&&(w({PerformanceStats:bt(bt({},m.PerformanceStats),{Period:t})}),h.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)}))})})}),p?p.Message():(0,i.jsxs)(i.Fragment,{children:[jt(m,"overview")&&(0,i.jsx)(ft,{data:v,isLoading:a}),jt(m,"categories")&&(0,i.jsx)(tt,{data:v,isLoading:a}),jt(m,"referrers")&&(0,i.jsx)(ht,{data:v,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){h.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,c.__)("View this in Parse.ly","wp-parsely")})]})},Lt=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(D,{children:(0,i.jsx)(Et,{period:t})})})},Ct=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,c.__)("Tag","wp-parsely")}),a.categories.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Section,label:(0,c.__)("Section","wp-parsely")}),a.authors.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Author,label:(0,c.__)("Author","wp-parsely")})]})})},Nt=function(e){var t=e.filter,n=e.label,a=e.postData,o=Ct(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})})},Ot=function(e){var t=e.filter,n=e.postData,s=e.label,a=Ct(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)(At,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(Nt,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},Rt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),It=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"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"}));function Mt(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,c.__)("Number of Views","wp-parsely")}),s,et(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,c.__)("Average Time","wp-parsely")}),r,n.avgEngaged]}):(0,i.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}var Bt,Dt=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"})})},Vt=function(e){var t,n,r=e.metric,o=e.post,l=e.postContent,u=(0,a.useDispatch)("core/notices").createNotice,p=l&&(t=l,n=z(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,c.__)("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)(Mt,{metric:r,post:o,viewsIcon:(0,i.jsx)(V,{icon:nt}),avgEngagedIcon:(0,i.jsx)(s.Dashicon,{icon:"clock",size:24})})}),p&&(0,i.jsx)("div",{className:"related-post-linked",children:(0,i.jsx)(s.Tooltip,{text:(0,c.__)("This post is linked in the content","wp-parsely"),children:(0,i.jsx)(V,{icon:Rt,size:24})})})]}),(0,i.jsx)(Dt,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:It,iconSize:24,onClick:function(){navigator.clipboard.writeText(o.rawUrl).then((function(){u("success",(0,c.__)("URL copied to clipboard","wp-parsely"),{type:"snackbar"})}))},label:(0,c.__)("Copy URL to clipboard","wp-parsely")}),(0,i.jsx)(s.Button,{icon:(0,i.jsx)(g,{}),iconSize:18,href:o.dashUrl,target:"_blank",label:(0,c.__)("View in Parse.ly","wp-parsely")})]})]})})]})},Ft=window.wp.coreData,Gt=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 __)}}(),Ht=function(){return Ht=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),O.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return xt(this,void 0,void 0,(function(){return kt(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,xe.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",bt(bt({},wt(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(ke),Pt=function(){return Pt=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)(rt,{title:(0,p.__)("Performance Stats","wp-parsely"),icon:nt,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(At,{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:Pt(Pt({},m.PerformanceStats),{Period:t})}),g.trackEvent("editor_sidebar_performance_period_changed",{period:t}))},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:C(e)},e)}))})})}),c?c.Message():(0,i.jsxs)(i.Fragment,{children:[Ct(m,"overview")&&(0,i.jsx)(yt,{data:h,isLoading:a}),Ct(m,"categories")&&(0,i.jsx)(st,{data:h,isLoading:a}),Ct(m,"referrers")&&(0,i.jsx)(mt,{data:h,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){g.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,p.__)("View this in Parse.ly","wp-parsely")})]})},Ot=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(F,{children:(0,i.jsx)(Nt,{period:t})})})},Rt=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")})]})})},Mt=function(e){var t=e.filter,n=e.label,a=e.postData,o=Rt(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})})},Bt=function(e){var t=e.filter,n=e.postData,s=e.label,a=Rt(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)(It,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(Mt,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},Dt=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),Vt=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"}));function Ft(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,it(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 Gt,Ht=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"})})},zt=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=U(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)(Ft,{metric:r,post:o,viewsIcon:(0,i.jsx)(G,{icon:at}),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)(G,{icon:Dt,size:24})})})]}),(0,i.jsx)(Ht,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:Vt,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)(m,{}),iconSize:18,href:o.dashUrl,target:"_blank",label:(0,p.__)("View in Parse.ly","wp-parsely")})]})]})})]})},Wt=window.wp.coreData,Ut=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 __)}}(),qt=function(){return qt=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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),m=y.authors,w=y.categories,_=y.tags,b=y.isReady;(0,l.useEffect)((function(){if(b){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(_)})}}),[m,w,_,b]);var x=(0,l.useState)(!0),k=x[0],S=x[1],j=(0,l.useState)(),C=j[0],A=j[1],N=(0,l.useState)(),R=N[0],I=N[1],M=(0,l.useState)([]),B=M[0],D=M[1],V=(0,l.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=V[0],G=V[1],H=(0,l.useState)(void 0),z=H[0],W=H[1],U=(0,O.useDebounce)(W,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;U(t())}),[U]);var Z=function(e,t){u({RelatedPosts:qt(qt({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,l.useEffect)((function(){var e,t,n=function(e){return Zt(void 0,void 0,void 0,(function(){return $t(this,(function(t){return Ut.getInstance().getRelatedPosts(p,d,F).then((function(e){D(e.posts),I(e.message),S(!1)})).catch((function(t){return Zt(void 0,void 0,void 0,(function(){return $t(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),A(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===v.authors.length,c=0===v.tags.length,u=0===v.categories.length,f=i&&!v.authors.includes(F.value),h=s&&!v.tags.includes(F.value),g=a&&!v.categories.includes(F.value);return S(!0),o||s&&c||a&&u||i&&l?Object.values(v).every((function(e){return 0===e.length}))||G((e="",t=r.Unavailable,v.tags.length>=1?(t=r.Tag,e=v.tags[0]):v.categories.length>=1?(t=r.Section,e=v.categories[0]):v.authors.length>=1&&(t=r.Author,e=v.authors[0]),{type:t,value:e})):h?G({type:r.Tag,value:v.tags[0]}):g?G({type:r.Section,value:v.categories[0]}):f?G({type:r.Author,value:v.authors[0]}):n(1),function(){S(!1),D([]),I(""),A(void 0)}}),[p,d,F,v]),0===v.authors.length&&0===v.categories.length&&0===v.tags.length&&b?(0,i.jsx)("div",{className:"wp-parsely-related-posts",children:(0,i.jsx)("div",{className:"related-posts-body",children:(0,c.__)("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,c.__)("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;T(n=e,t)&&(u({RelatedPosts:qt(qt({},o.RelatedPosts),{Metric:n})}),h.trackEvent("related_posts_metric_changed",{metric:n}))},prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,c.__)("Metric: ","wp-parsely")}),value:d,children:Object.values(t).map((function(e){return(0,i.jsx)("option",{value:e,children:L(e)},e)}))}),(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:p,prefix:(0,i.jsxs)(s.__experimentalInputControlPrefixWrapper,{children:[(0,c.__)("Period: ","wp-parsely")," "]}),onChange:function(t){return function(t){T(t,e)&&(u({RelatedPosts:qt(qt({},o.RelatedPosts),{Period:t})}),h.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)(Ot,{label:(0,c.__)("Filter by","wp-parsely"),filter:F,onFilterTypeChange:function(e){if(T(e,r)){var t="",n=e;r.Tag===n&&(t=v.tags[0]),r.Section===n&&(t=v.categories[0]),r.Author===n&&(t=v.authors[0]),""!==t&&(Z(n,t),G({type:n,value:t}),h.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(F.type,e),G(qt(qt({},F),{value:e})))},postData:v}),(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===F.type?(0,c.sprintf)(/* translators: 1: tag name, 2: period */ /* translators: 1: tag name, 2: period */ -(0,c.__)("Top related posts with the “%1$s” tag in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Section===F.type?(0,c.sprintf)(/* translators: 1: section name, 2: period */ /* translators: 1: section name, 2: period */ -(0,c.__)("Top related posts in the “%1$s” section in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Author===F.type?(0,c.sprintf)(/* translators: 1: author name, 2: period */ /* translators: 1: author name, 2: period */ -(0,c.__)("Top related posts by %1$s in the %2$s.","wp-parsely"),F.value,E(p,!0)):null!=R?R:""})}),C&&C.Message(),k&&(0,i.jsx)("div",{className:"related-posts-loading-message","data-testid":"parsely-related-posts-loading-message",children:(0,c.__)("Loading…","wp-parsely")}),!k&&!C&&0===B.length&&(0,i.jsx)("div",{className:"related-posts-empty","data-testid":"parsely-related-posts-empty",children:(0,c.__)("No related posts found.","wp-parsely")}),!k&&B.length>0&&(0,i.jsx)("div",{className:"related-posts-list",children:B.map((function(e){return(0,i.jsx)(Vt,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},Yt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),Qt=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"})})},Xt={journalist:{label:(0,c.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,c.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,c.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,c.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,c.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,c.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,c.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,c.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,c.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,c.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,c.__)("Custom Persona","wp-parsely"),icon:Yt}},Jt=Object.keys(Xt),en=function(e){return"custom"===e||""===e?Xt.custom.label:tn(e)?e:Xt[e].label},tn=function(e){return!Jt.includes(e)||"custom"===e},nn=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},rn=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,c.__)("Select a persona…","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Persona","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:tn(t)?Xt.custom.label:r}),(0,i.jsx)(Qt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Persona","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:Jt.map((function(e){if(!h&&"custom"===e)return null;var r=Xt[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==u||u(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)(V,{icon:r.icon}),r.label]},e)}))})})}}),h&&tn(t)&&(0,i.jsx)(nn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},sn={neutral:{label:(0,c.__)("Neutral","wp-parsely")},formal:{label:(0,c.__)("Formal","wp-parsely")},humorous:{label:(0,c.__)("Humorous","wp-parsely")},confident:{label:(0,c.__)("Confident","wp-parsely")},provocative:{label:(0,c.__)("Provocative","wp-parsely")},serious:{label:(0,c.__)("Serious","wp-parsely")},inspirational:{label:(0,c.__)("Inspirational","wp-parsely")},skeptical:{label:(0,c.__)("Skeptical","wp-parsely")},conversational:{label:(0,c.__)("Conversational","wp-parsely")},analytical:{label:(0,c.__)("Analytical","wp-parsely")},custom:{label:(0,c.__)("Custom Tone","wp-parsely"),icon:Yt}},an=Object.keys(sn),on=function(e){return"custom"===e||""===e?sn.custom.label:ln(e)?e:sn[e].label},ln=function(e){return!an.includes(e)||"custom"===e},cn=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},un=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,c.__)("Select a tone","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Tone","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:ln(t)?sn.custom.label:r}),(0,i.jsx)(Qt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Select a tone","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:an.map((function(e){if(!h&&"custom"===e)return null;var r=sn[e],a=e===t||ln(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(V,{icon:r.icon}),r.label]},e)}))})})}}),h&&ln(t)&&(0,i.jsx)(cn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},pn=(0,u.createElement)(p.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.Path,{d:"M10.97 10.159a3.382 3.382 0 0 0-2.857.955l1.724 1.723-2.836 2.913L7 17h1.25l2.913-2.837 1.723 1.723a3.38 3.38 0 0 0 .606-.825c.33-.63.446-1.343.35-2.032L17 10.695 13.305 7l-2.334 3.159Z"})),dn=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"})),fn=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})),hn=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z"})),vn=function(){return vn=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,l.createInterpolateElement)( +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"),O.CannotFormulateApiQuery)},t}(ke),Yt=function(){return Yt=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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),m=y.authors,w=y.categories,_=y.tags,b=y.isReady;(0,u.useEffect)((function(){if(b){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})):[]};v({authors:e(m),categories:e(w),tags:e(_)})}}),[m,w,_,b]);var x=(0,u.useState)(!0),k=x[0],S=x[1],P=(0,u.useState)(),j=P[0],E=P[1],N=(0,u.useState)(),O=N[0],R=N[1],M=(0,u.useState)([]),B=M[0],D=M[1],V=(0,u.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=V[0],G=V[1],H=(0,u.useState)(void 0),z=H[0],W=H[1],U=(0,I.useDebounce)(W,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;U(t())}),[U]);var q=function(e,t){l({RelatedPosts:Yt(Yt({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,u.useEffect)((function(){var e,t,n=function(e){return Qt(void 0,void 0,void 0,(function(){return Xt(this,(function(t){return Kt.getInstance().getRelatedPosts(c,d,F).then((function(e){D(e.posts),R(e.message),S(!1)})).catch((function(t){return Qt(void 0,void 0,void 0,(function(){return Xt(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),E(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===h.authors.length,u=0===h.tags.length,p=0===h.categories.length,f=i&&!h.authors.includes(F.value),v=s&&!h.tags.includes(F.value),g=a&&!h.categories.includes(F.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([]),R(""),E(void 0)}}),[c,d,F,h]),0===h.authors.length&&0===h.categories.length&&0===h.tags.length&&b?(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:Yt(Yt({},o.RelatedPosts),{Metric:n})}),g.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:A(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:Yt(Yt({},o.RelatedPosts),{Period:t})}),g.trackEvent("related_posts_period_changed",{period:t}))}(t)},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:C(e)},e)}))})]}),(0,i.jsx)(Bt,{label:(0,p.__)("Filter by","wp-parsely"),filter:F,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&&(q(n,t),G({type:n,value:t}),g.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(q(F.type,e),G(Yt(Yt({},F),{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===F.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"),F.value,C(c,!0)):r.Section===F.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"),F.value,C(c,!0)):r.Author===F.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"),F.value,C(c,!0)):null!=O?O:""})}),j&&j.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&&!j&&0===B.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&&B.length>0&&(0,i.jsx)("div",{className:"related-posts-list",children:B.map((function(e){return(0,i.jsx)(zt,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},en=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),tn=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"})})},nn={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:en}},rn=Object.keys(nn),sn=function(e){return"custom"===e||""===e?nn.custom.label:an(e)?e:nn[e].label},an=function(e){return!rn.includes(e)||"custom"===e},on=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,I.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)}})})},ln=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:an(t)?nn.custom.label:r}),(0,i.jsx)(tn,{})]})},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:rn.map((function(e){if(!h&&"custom"===e)return null;var r=nn[e],a=e===t||an(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)(G,{icon:r.icon}),r.label]},e)}))})})}}),h&&an(t)&&(0,i.jsx)(on,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},cn={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:en}},un=Object.keys(cn),pn=function(e){return"custom"===e||""===e?cn.custom.label:dn(e)?e:cn[e].label},dn=function(e){return!un.includes(e)||"custom"===e},fn=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,I.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)}})})},hn=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:dn(t)?cn.custom.label:r}),(0,i.jsx)(tn,{})]})},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:un.map((function(e){if(!h&&"custom"===e)return null;var r=cn[e],a=e===t||dn(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)(G,{icon:r.icon}),r.label]},e)}))})})}}),h&&dn(t)&&(0,i.jsx)(fn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},vn=(0,d.createElement)(f.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(f.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"})),gn=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),yn=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),mn=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),wn=function(){return wn=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,c.__)("We've generated a few titles based on the content of your post, written as a .","wp-parsely"),{tone:(0,i.jsx)("strong",{children:on(d)}),persona:(0,i.jsx)("strong",{children:en(g)})})}):(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(V,{icon:F,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==S&&(0,i.jsx)(Sn,{title:S,type:Bt.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(Pn,{pinnedTitles:b,isOpen:!0}),_.length>0&&(0,i.jsx)(Tn,{suggestions:_,isOpen:!0,isLoading:w})]}),(0,i.jsx)(jn,{isLoading:w,onPersonaChange:function(e){N("Persona",e),y(e)},onSettingChange:N,onToneChange:function(e){N("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 An(void 0,void 0,void 0,(function(){return Nn(this,(function(e){switch(e.label){case 0:return u(void 0),!1!==w?[3,2]:(h.trackEvent("title_suggestions_generate_pressed",{request_more:_.length>0,total_titles:_.length,total_pinned:_.filter((function(e){return e.isPinned})).length,tone:d,persona:g}),[4,(t=Bt.PostTitle,n=O,r=d,i=g,An(void 0,void 0,void 0,(function(){var e,s,a;return Nn(this,(function(o){switch(o.label){case 0:return[4,E(!0)];case 1:o.sent(),e=Ln.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(),u(a),T(t,[]),[3,6];case 6:return[4,E(!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,c.__)("Generating Titles…","wp-parsely"),!w&&x.length>0&&(0,c.__)("Generate More","wp-parsely"),!w&&0===x.length&&(0,c.__)("Generate Titles","wp-parsely")]})})]})})},Rn=function(){return Rn=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:pn(d)}),persona:(0,i.jsx)("strong",{children:sn(v)})})}):(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)(G,{icon:H,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==S&&(0,i.jsx)(En,{title:S,type:Gt.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(Ln,{pinnedTitles:b,isOpen:!0}),_.length>0&&(0,i.jsx)(An,{suggestions:_,isOpen:!0,isLoading:w})]}),(0,i.jsx)(Cn,{isLoading:w,onPersonaChange:function(e){N("Persona",e),y(e)},onSettingChange:N,onToneChange:function(e){N("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"===v,onClick:function(){return In(void 0,void 0,void 0,(function(){return Mn(this,(function(e){switch(e.label){case 0:return l(void 0),!1!==w?[3,2]:(g.trackEvent("title_suggestions_generate_pressed",{request_more:_.length>0,total_titles:_.length,total_pinned:_.filter((function(e){return e.isPinned})).length,tone:d,persona:v}),[4,(t=Gt.PostTitle,n=O,r=d,i=v,In(void 0,void 0,void 0,(function(){var e,s,a;return Mn(this,(function(o){switch(o.label){case 0:return[4,E(!0)];case 1:o.sent(),e=On.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,j(t,s)];case 4:return o.sent(),[3,6];case 5:return a=o.sent(),l(a),j(t,[]),[3,6];case 6:return[4,E(!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")]})})]})})},Dn=function(){return Dn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n { + if ( initSmartLinking ) { + initSmartLinking(); + } +} ); diff --git a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss index ebfdb71fa..3dc6b2265 100644 --- a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss +++ b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss @@ -283,7 +283,6 @@ display: inline; text-align: left; flex-grow: 1; - //margin-right: 10px; } } } @@ -344,10 +343,6 @@ .wp-parsely-review-suggestion-previous, .wp-parsely-review-suggestion-next { color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)); - - &:disabled { - //visibility: hidden; - } } .wp-parsely-review-suggestion-reject { diff --git a/src/content-helper/editor-sidebar/smart-linking/utils.ts b/src/content-helper/editor-sidebar/smart-linking/utils.ts index 03bf96d89..a1b95cd31 100644 --- a/src/content-helper/editor-sidebar/smart-linking/utils.ts +++ b/src/content-helper/editor-sidebar/smart-linking/utils.ts @@ -589,10 +589,17 @@ export function trimURLForDisplay( url: string, maxLength: number ): string { return strippedUrl; } + // Get the domain name and path from the URL + const domain = strippedUrl.split( '/' )[ 0 ]; + const path = strippedUrl.substring( domain.length ); + + // Update the maxLength to account for the domain name, plus a slash. + maxLength -= domain.length; + // Calculate part lengths for trimming. const partLength = Math.floor( ( maxLength - 3 ) / 2 ); - const start = strippedUrl.substring( 0, partLength ); - const end = strippedUrl.substring( strippedUrl.length - partLength ); + const start = path.substring( 0, partLength ); + const end = path.substring( path.length - partLength ); - return `${ start }...${ end }`; + return `${ domain }${ start }...${ end }`; } diff --git a/tests/js/content-helper/smart-linking.test.tsx b/tests/js/content-helper/smart-linking.test.tsx new file mode 100644 index 000000000..664892a77 --- /dev/null +++ b/tests/js/content-helper/smart-linking.test.tsx @@ -0,0 +1,23 @@ +import { trimURLForDisplay } from '../../../src/content-helper/editor-sidebar/smart-linking/utils'; + +describe( 'trimURLForDisplay', () => { + it( 'should remove protocol and www', () => { + expect( trimURLForDisplay( 'https://www.example.com', 20 ) ).toBe( 'example.com' ); + } ); + + it( 'should keep the domain in long URLs correctly', () => { + expect( trimURLForDisplay( 'https://www.example.com/long-url-path', 20 ) ).toBe( 'example.com/lo...ath' ); + expect( trimURLForDisplay( 'https://www.example.com/long-url-path', 20 ) ).toContain( 'example.com' ); + } ); + it( 'should trim long URLs correctly', () => { + expect( trimURLForDisplay( 'https://www.example.com/it-a-very-long-url-path', 30 ) ).toBe( 'example.com/it-a-ve...url-path' ); + } ); + it( 'should return the full URL if it is shorter than maxLength', () => { + expect( trimURLForDisplay( 'https://example.com', 50 ) ).toBe( 'example.com' ); + } ); + + it( 'should handle edge cases gracefully', () => { + expect( trimURLForDisplay( 'https://a.com', 5 ) ).toBe( 'a.com' ); + expect( trimURLForDisplay( 'https://example.com', 0 ) ).toBe( 'example.com' ); + } ); +} ); From 470e5cbe9073ea2740f0fe8346af9ca4ec3d2894 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 22 May 2024 15:04:44 +0100 Subject: [PATCH 30/44] Apply suggestions from code review Co-authored-by: Alex Cicovic <23142906+acicovic@users.noreply.github.com> --- src/RemoteAPI/class-analytics-posts-api.php | 2 +- src/RemoteAPI/class-referrers-post-detail-api.php | 2 +- src/RemoteAPI/class-related-api.php | 2 +- src/RemoteAPI/class-remote-api-cache.php | 2 +- src/RemoteAPI/class-validate-api.php | 2 +- .../content-suggestions/class-content-suggestions-base-api.php | 2 +- src/RemoteAPI/interface-remote-api.php | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/RemoteAPI/class-analytics-posts-api.php b/src/RemoteAPI/class-analytics-posts-api.php index 0e1c002c0..9b70421cc 100644 --- a/src/RemoteAPI/class-analytics-posts-api.php +++ b/src/RemoteAPI/class-analytics-posts-api.php @@ -66,7 +66,7 @@ class Analytics_Posts_API extends Base_Endpoint_Remote { * user. * * @since 3.14.0 - * @since 3.15.0 Added the `$request` parameter. + * @since 3.16.0 Added the `$request` parameter. * * @param WP_REST_Request|null $request The request object. * @return bool diff --git a/src/RemoteAPI/class-referrers-post-detail-api.php b/src/RemoteAPI/class-referrers-post-detail-api.php index 16867834e..45233630e 100644 --- a/src/RemoteAPI/class-referrers-post-detail-api.php +++ b/src/RemoteAPI/class-referrers-post-detail-api.php @@ -29,7 +29,7 @@ class Referrers_Post_Detail_API extends Base_Endpoint_Remote { * user. * * @since 3.14.0 - * @since 3.15.0 Added the `$request` parameter. + * @since 3.16.0 Added the `$request` parameter. * * @param WP_REST_Request|null $request The request object. * @return bool diff --git a/src/RemoteAPI/class-related-api.php b/src/RemoteAPI/class-related-api.php index f12fcbfd2..ea130bf02 100644 --- a/src/RemoteAPI/class-related-api.php +++ b/src/RemoteAPI/class-related-api.php @@ -28,7 +28,7 @@ class Related_API extends Base_Endpoint_Remote { * user. * * @since 3.14.0 - * @since 3.15.0 Added the `$request` parameter. + * @since 3.16.0 Added the `$request` parameter. * * @param WP_REST_Request|null $request The request object. * @return bool diff --git a/src/RemoteAPI/class-remote-api-cache.php b/src/RemoteAPI/class-remote-api-cache.php index 13e653e33..9b60c8a46 100644 --- a/src/RemoteAPI/class-remote-api-cache.php +++ b/src/RemoteAPI/class-remote-api-cache.php @@ -80,7 +80,7 @@ public function get_items( array $query, bool $associative = false ) { * * @since 3.7.0 * @since 3.14.0 Renamed from `is_user_allowed_to_make_api_call()`. - * @since 3.15.0 Added the `$request` parameter. + * @since 3.16.0 Added the `$request` parameter. * * @param WP_REST_Request|null $request The request object. * @return bool diff --git a/src/RemoteAPI/class-validate-api.php b/src/RemoteAPI/class-validate-api.php index c8810ca31..9f5b6b3be 100644 --- a/src/RemoteAPI/class-validate-api.php +++ b/src/RemoteAPI/class-validate-api.php @@ -34,7 +34,7 @@ class Validate_API extends Base_Endpoint_Remote { * user. * * @since 3.14.0 - * @since 3.15.0 Added the `$request` parameter. + * @since 3.16.0 Added the `$request` parameter. * * @param WP_REST_Request|null $request The request object. * @return bool diff --git a/src/RemoteAPI/content-suggestions/class-content-suggestions-base-api.php b/src/RemoteAPI/content-suggestions/class-content-suggestions-base-api.php index 294d7e57a..3d2a1b050 100644 --- a/src/RemoteAPI/content-suggestions/class-content-suggestions-base-api.php +++ b/src/RemoteAPI/content-suggestions/class-content-suggestions-base-api.php @@ -52,7 +52,7 @@ abstract class Content_Suggestions_Base_API extends Base_Endpoint_Remote { * user. * * @since 3.14.0 - * @since 3.15.0 Added the `$request` parameter. + * @since 3.16.0 Added the `$request` parameter. * * @param WP_REST_Request|null $request The request object. * @return bool diff --git a/src/RemoteAPI/interface-remote-api.php b/src/RemoteAPI/interface-remote-api.php index fc18e5ac8..644fb74d9 100644 --- a/src/RemoteAPI/interface-remote-api.php +++ b/src/RemoteAPI/interface-remote-api.php @@ -31,7 +31,7 @@ public function get_items( array $query, bool $associative = false ); * user. * * @since 3.14.0 Renamed from `is_user_allowed_to_make_api_call()`. - * @since 3.15.0 Added the `$request` parameter. + * @since 3.16.0 Added the `$request` parameter. * * @param WP_REST_Request|null $request The request object. * @return bool From e2d1b00333afea1de7b47a537897df7ea2239cfc Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Wed, 22 May 2024 15:53:02 +0100 Subject: [PATCH 31/44] Rebuild assets --- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.js | 40 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index 91504ead6..e8819af9a 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-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '42f891ce2c2ff964b1d2'); + 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' => '5af92f58bd834c9d4521'); diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index c80e33116..9240efb5b 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,27 +1,27 @@ -!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 rn}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=n(609),p=window.wp.primitives,d=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),f=window.wp.plugins,h=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=(h.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"})]})},v=function(){return v=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiError||s.code===N.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===N.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===N.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===N.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return H(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[N.PluginCredentialsNotSetMessageDetected,N.PluginSettingsSiteIdNotSet,N.PluginSettingsApiSecretNotSet].includes(this.code)?B(e):(this.code===N.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==N.ParselyApiForbidden&&this.code!==N.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===N.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(I,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function U(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var $,Z=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})]})]})},q=function(){return q=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&&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)){var e={maxLinksPerPost:p.SmartLinking.MaxLinks};H(e)}}),[H,p]);var Y=(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]),J=Y.allBlocks,ee=Y.selectedBlock,te=Y.postContent,oe=Y.postPermalink,le=function(e){return ie(void 0,void 0,void 0,(function(){var t,n,r,i;return se(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,z((n=b||!ee)?$.All:$.Selected)];case 2:return s.sent(),a=oe.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,ne.getInstance().generateSmartLinks(ee&&!n?(0,D.getBlockContent)(ee):te,k,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===N.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,q(!0)]):[3,8];case 5:return s.sent(),[4,W()];case 6:return s.sent(),[4,le(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[4,B(t)];case 10:return s.sent(),[2,t]}var a}))}))},ce=function(e,t,n,r){var i=oe.replace(/^https?:\/\//,"").replace(/\/+$/,"");t=t.filter((function(e){return!e.href.includes(i)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(e.href)),!1)})),e.forEach((function(e){var i=!1;if(e.innerBlocks&&e.innerBlocks.length)ce(e.innerBlocks,t,n,r);else if(e.originalContent){var s=(0,D.getBlockContent)(e),a=(new DOMParser).parseFromString(s,"text/html").body.firstChild;a&&a instanceof HTMLElement&&(t.forEach((function(e){var t=function(e,t){for(var n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:function(n){var r;if(!n.textContent||!n.textContent.includes(t))return NodeFilter.FILTER_REJECT;for(var i=n.parentNode;i&&i!==e;){if("A"===i.nodeName&&!(null===(r=i.textContent)||void 0===r?void 0:r.includes(t)))return NodeFilter.FILTER_REJECT;i=i.parentNode}return NodeFilter.FILTER_ACCEPT}}),i=[];n=r.nextNode();)i.push(n);return i}(a,e.text),r="".concat(e.text,"#").concat(e.offset);n[r]||(n[r]={encountered:0,linked:0}),t.forEach((function(t){var s;if(t.textContent){var a=n[r];if(a.linked>=1)return;for(var o=new RegExp(U(e.text),"g"),l=void 0;null!==(l=o.exec(t.textContent));)if(a.encountered++,a.encountered===e.offset+1){var c=document.createElement("a");c.href=e.href,c.title=e.title,c.textContent=l[0];var u=document.createRange();if(u.setStart(t,l.index),u.setEnd(t,l.index+l[0].length),u.deleteContents(),u.insertNode(c),t.textContent&&l.index+l[0].length[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},he=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsx)("div",{className:"wp-parsely-smart-linking",children:(0,i.jsxs)(s.PanelRow,{className:t,children:[(0,i.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(F,{icon:G,size:18,className:"parsely-external-link-icon"})]})]}),P&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return I(null)},className:"wp-parsely-content-helper-error",children:P.Message()}),null!==S&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return B(null)},className:"wp-parsely-smart-linking-suggested-links",children:(0,c.sprintf)(/* translators: 1 - number of smart links generated */ /* translators: 1 - number of smart links generated */ -(0,c.__)("Successfully added %s smart links.","wp-parsely"),y>0?y:S.length)}),(0,i.jsx)(X,{disabled:_,selectedBlock:null==ee?void 0:ee.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:re(re({},p.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e&&Z(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return ie(void 0,void 0,void 0,(function(){var e,t,n,r,i;return se(this,(function(s){switch(s.label){case 0:return[4,R(!0)];case 1:return s.sent(),[4,B(null)];case 2:return s.sent(),[4,I(null)];case 3:return s.sent(),h.trackEvent("smart_linking_generate_pressed",{is_full_content:b,selected_block:null!==(i=null==ee?void 0:ee.name)&&void 0!==i?i:"none",context:o}),[4,pe(b?"all":null==ee?void 0:ee.clientId)];case 4:s.sent(),e=setTimeout((function(){var e;R(!1),h.trackEvent("smart_linking_generate_timeout",{is_full_content:b,selected_block:null!==(e=null==ee?void 0:ee.name)&&void 0!==e?e:"none",context:o}),de(b?"all":null==ee?void 0:ee.clientId)}),18e4),t=E,s.label=5;case 5:return s.trys.push([5,7,9,14]),[4,le(3)];case 6:return function(e){var t;h.trackEvent("smart_linking_applied",{is_full_content:b||!ee,selected_block:null!==(t=null==ee?void 0:ee.name)&&void 0!==t?t:"none",links_count:e.length,context:o});var n={},r=[];ce(ee&&!b?[ee]:J,e,n,r),ue(r);var i=Object.values(n).reduce((function(e,t){return e+t.linked}),0);v(i),w("success",/* translators: %d: number of smart links applied */ /* translators: %d: number of smart links applied */ -(0,c.sprintf)((0,c.__)("%s smart links successfully applied.","wp-parsely"),i),{type:"snackbar"})}(s.sent()),[3,14];case 7:return n=s.sent(),r=(0,c.__)("There was a problem applying smart links.","wp-parsely"),n.code&&n.code===N.ParselyAborted&&(r=(0,c.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ /* translators: %d: number of retry attempts, %s: attempt plural */ -(0,c.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),n.numRetries,(0,c._n)("attempt","attempts",n.numRetries,"wp-parsely")),n.message=r),[4,I(n)];case 8:return s.sent(),w("error",r,{type:"snackbar"}),[3,14];case 9:return[4,R(!1)];case 10:return s.sent(),[4,z(t)];case 11:return s.sent(),[4,q(!1)];case 12:return s.sent(),[4,de(b?"all":null==ee?void 0:ee.clientId)];case 13:return s.sent(),clearTimeout(e),[7];case 14:return[2]}}))}))},variant:"primary",isBusy:_,disabled:_,children:C?(0,c.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,c.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),A,3):_?(0,c.__)("Adding Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")})})]})})},le=function(){return le=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 be=function(e){var n=e.data,r=e.isLoading,a=(0,l.useState)(t.Views),o=a[0],u=a[1],p=(0,l.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},g=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),C(o)); -/* translators: %s: metric description */return(0,i.jsxs)(me,{title:(0,c.__)("Categories","wp-parsely"),level:3,subtitle:g,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,c.__)("By: ","wp-parsely"),onChange:function(e){T(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,i.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[C(e),"avg_engaged"===e&&(0,c.__)(" (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,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ /* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ -(0,c.__)("%1$s: %2$s%%","wp-parsely"),h(t),n.viewsPercentage);return(0,i.jsx)(s.Tooltip +!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 Fn}});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=n(609),f=window.wp.primitives,h=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),v=window.wp.plugins,g=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,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}(),y=(g.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"})})}),m=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"})]})},w=function(){return w=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===O.ParselySuggestionsApiOpenAiError||s.code===O.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===O.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===O.ParselySuggestionsApiSchemaError?s.message=(0,p.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===O.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===O.ParselySuggestionsApiOpenAiSchema?s.message=(0,p.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===O.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,p.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return z(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[O.PluginCredentialsNotSetMessageDetected,O.PluginSettingsSiteIdNotSet,O.PluginSettingsApiSecretNotSet].includes(this.code)?D(e):(this.code===O.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!==O.ParselyApiForbidden&&this.code!==O.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===O.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)(M,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z,$=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,I.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},W=window.wp.editor,K=window.wp.blocks,Y=function(){return Y=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var l=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,p.__)("NEW","wp-parsely"),(0,i.jsx)(ve,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,p.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&l]},e.uid)}))]})})},ye=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,d.createElement)(f.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})),me=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),we=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),be=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),_e=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})),xe=window.wp.url,ke=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?c(!0):k().then((function(){return t()}))},E=function(e){c(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},L=function(){var e=g.indexOf(b)+1;g[e]&&_(g[e])},C=function(){var e=m().indexOf(b)-1;m()[e]&&_(m()[e])},A=function(){return Re(void 0,void 0,void 0,(function(){var e,t;return Ie(this,(function(n){switch(n.label){case 0:return b.match?(r(b),[4,(i=b.match.blockId,s=b,Re(void 0,void 0,void 0,(function(){var e,t;return Ie(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))?(ie(t,s,e),s.applied=!0,[4,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(b),g[t=e+1]?_(g[t]):_(g[0]),[2])}var i,s}))}))},N=function(){return Re(void 0,void 0,void 0,(function(){var e,t;return Ie(this,(function(n){switch(n.label){case 0:return e=g.indexOf(b),g[t=e+1]?_(g[t]):g[0]?_(g[0]):T(),[4,P(b.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Re(void 0,void 0,void 0,(function(){var e,t,n,r;return Ie(this,(function(i){switch(i.label){case 0:return b.match?(e=(0,a.select)("core/block-editor").getBlock(b.match.blockId))?(t=m(),n=t.indexOf(b),r=n-1,[4,j(e,b)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?_(t[r]):_(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:L,up:C,down:L,a:function(){b&&!b.applied&&A()},r:function(){b&&(b.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(ge,{links:g,activeLink:b,setSelectedLink:_}),(0,i.jsx)(Oe,{link:b,hasNext:m().indexOf(b)0,onNext:L,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(b.match){var e=(0,a.select)("core/block-editor").getBlock(b.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(b.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),l&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return E(!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 E(!1)},children:(0,p.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return E(!0)},children:(0,p.__)("Close","wp-parsely")})]})]})]})})),Me=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})]})]})},De=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,l=e.onSettingChange,c=(0,u.useRef)(),d=(0,u.useState)(""),f=d[0],h=d[1],v=(0,u.useState)(!1),g=v[0],y=v[1],m=(0,u.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(J),n=t.getMaxLinks,r=t.isFullContent,i=t.wasAlreadyClicked,s=t.getApplyTo;return{maxLinks:n(),fullContent:r(),alreadyClicked:i(),applyTo:s()}}),[]),b=w.maxLinks,_=w.fullContent,x=w.alreadyClicked,k=w.applyTo,S=(0,a.useDispatch)(J),P=S.setMaxLinks,j=S.setFullContent,T=S.setAlreadyClicked,E=S.setApplyTo,L=null!==(t=k)&&void 0!==t?t:o?"selected":"all";return(0,u.useEffect)((function(){if(!r){var e=function(){r||(k===Z.Selected&&setTimeout((function(){h((0,p.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),E(null),m((function(e){return!e})))};o||k===Z.All||(g?setTimeout(e,500):e()),j(Z.All===L)}}),[g,k,L,r,o,E,j,h]),(0,u.useEffect)((function(){if(!r&&c.current&&L&&!x&&o){var e=c.current.querySelector('button[data-value="'.concat(L,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(E(L),T(!0))}}),[o,_,r,k]),(0,u.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:c,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:L,label:(0,p.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&_("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"),v),{type:"snackbar"}):y(0)}),[w]),(0,u.useEffect)((function(){if(!(Object.keys(N).length>0)){var e={maxLinksPerPost:c.SmartLinking.MaxLinks};ne(e)}}),[ne,c]);var ge=(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]),ye=ge.allBlocks,me=ge.selectedBlock,we=ge.postContent,be=ge.postPermalink,_e=function(e){return Fe(void 0,void 0,void 0,(function(){var t,n,r,i;return Ge(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,re((n=j||!me)?Z.All:Z.Selected)];case 2:return s.sent(),a=be.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,Te.getInstance().generateSmartLinks((null==me?void 0:me.originalContent)&&!n?me.originalContent:we,A,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===O.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,se(!0)]):[3,8];case 5:return s.sent(),[4,ae()];case 6:return s.sent(),[4,_e(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},xe=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Pe=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)($,{isDetectingEnabled:!P,onLinkRemove:function(e){!function(e){ee(this,void 0,void 0,(function(){var t,n,r;return te(this,(function(i){switch(i.label){case 0:return[4,ue((0,K.getBlockContent)(e),e.clientId)];case 1:return t=i.sent(),n=t.missingSmartLinks,r=t.didAnyFixes,n.forEach((function(e){(0,a.dispatch)(J).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)(G,{icon:H,size:18,className:"parsely-external-link-icon"})]})]}),L&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return q(null)},className:"wp-parsely-content-helper-error",children:L.Message()}),w&&v>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return b(!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"),v>0?v:C.length)}),(0,i.jsx)(De,{disabled:S,selectedBlock:null==me?void 0:me.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:Ve(Ve({},c.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e&&ie(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return Fe(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Ge(this,(function(a){switch(a.label){case 0:return[4,U(!0)];case 1:return a.sent(),[4,ce()];case 2:return a.sent(),[4,q(null)];case 3:return a.sent(),b(!1),g.trackEvent("smart_linking_generate_pressed",{is_full_content:j,selected_block:null!==(s=null==me?void 0:me.name)&&void 0!==s?s:"none",context:o}),[4,xe(j?"all":null==me?void 0:me.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;U(!1),g.trackEvent("smart_linking_generate_timeout",{is_full_content:j,selected_block:null!==(e=null==me?void 0:me.name)&&void 0!==e?e:"none",context:o}),ke(j?"all":null==me?void 0:me.clientId)}),18e4),t=R,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,_e(3)];case 6:return n=a.sent(),[4,(l=n,Fe(void 0,void 0,void 0,(function(){var e;return Ge(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!D.find((function(t){return t.uid===e.uid&&t.applied}))})),e=be.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=oe(ye,l,{}).filter((function(e){return e.match})),[4,Y(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),ve(!0),[3,15];case 8:return r=a.sent(),i=(0,p.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===O.ParselyAborted&&(i=(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")),r.message=i),[4,q(r)];case 9:return a.sent(),_("error",i,{type:"snackbar"}),[3,15];case 10:return[4,U(!1)];case 11:return a.sent(),[4,re(t)];case 12:return a.sent(),[4,se(!1)];case 13:return a.sent(),[4,ke(j?"all":null==me?void 0:me.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:S,disabled:S,children:B?(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"),M,3):S?(0,p.__)("Generating Smart Links…","wp-parsely"):(0,p.__)("Add Smart Links","wp-parsely")})}),V.length>0&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return Fe(void 0,void 0,void 0,(function(){var e;return Ge(this,(function(t){switch(t.label){case 0:return[4,pe()];case 1:return t.sent(),e=le(),[4,Y(e)];case 2:return t.sent(),ve(!0),[2]}}))}))},variant:"secondary",children:(0,p.__)("Review Smart Links","wp-parsely")})})]}),P&&(0,i.jsx)(Be,{isOpen:P,onAppliedLink:function(){y((function(e){return e+1}))},onClose:function(){b(!0),ve(!1)}})]})},Ue=function(){return Ue=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 it=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"),A(o)); +/* translators: %s: metric description */return(0,i.jsxs)(nt,{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:[A(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,c.sprintf)((0,c.__)("%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:_e(n.views)})]},t)}))})]})]})},xe=(0,u.createElement)(p.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.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"})),Pe=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),Se=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),je=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"})),ke=function(){return ke=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]1?[2,Promise.reject(new z((0,c.sprintf)(/* translators: URL of the published post */ /* translators: URL of the published post */ -(0,c.__)("Multiple results were returned for the post %s by the Parse.ly API.","wp-parsely"),t),N.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return Ve(this,void 0,void 0,(function(){return De(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,J.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",Me(Me({},Ie(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(ee),Ge=function(){return Ge=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)(me,{title:(0,c.__)("Performance Stats","wp-parsely"),icon:we,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(qe,{onClose:t})},children:(0,i.jsx)("div",{className:"panel-settings",children:(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:w.PerformanceStats.Period,prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,c.__)("Period: ","wp-parsely")}),onChange:function(t){T(t,e)&&(m({PerformanceStats:Ge(Ge({},w.PerformanceStats),{Period:t})}),h.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)}))})})}),p?p.Message():(0,i.jsxs)(i.Fragment,{children:[Ze(w,"overview")&&(0,i.jsx)(Oe,{data:g,isLoading:a}),Ze(w,"categories")&&(0,i.jsx)(be,{data:g,isLoading:a}),Ze(w,"referrers")&&(0,i.jsx)(Re,{data:g,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){h.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,c.__)("View this in Parse.ly","wp-parsely")})]})},Ye=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(V,{children:(0,i.jsx)(We,{period:t})})})},Ke=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,c.__)("Tag","wp-parsely")}),a.categories.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Section,label:(0,c.__)("Section","wp-parsely")}),a.authors.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Author,label:(0,c.__)("Author","wp-parsely")})]})})},Xe=function(e){var t=e.filter,n=e.label,a=e.postData,o=Ke(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})})},Je=function(e){var t=e.filter,n=e.postData,s=e.label,a=Ke(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)(Qe,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(Xe,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},et=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.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"})),tt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"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"}));function nt(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,c.__)("Number of Views","wp-parsely")}),s,_e(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,c.__)("Average Time","wp-parsely")}),r,n.avgEngaged]}):(0,i.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}var rt,it=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"})})},st=function(e){var t,n,r=e.metric,o=e.post,l=e.postContent,u=(0,a.useDispatch)("core/notices").createNotice,p=l&&(t=l,n=U(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,c.__)("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)(nt,{metric:r,post:o,viewsIcon:(0,i.jsx)(F,{icon:xe}),avgEngagedIcon:(0,i.jsx)(s.Dashicon,{icon:"clock",size:24})})}),p&&(0,i.jsx)("div",{className:"related-post-linked",children:(0,i.jsx)(s.Tooltip,{text:(0,c.__)("This post is linked in the content","wp-parsely"),children:(0,i.jsx)(F,{icon:et,size:24})})})]}),(0,i.jsx)(it,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:tt,iconSize:24,onClick:function(){navigator.clipboard.writeText(o.rawUrl).then((function(){u("success",(0,c.__)("URL copied to clipboard","wp-parsely"),{type:"snackbar"})}))},label:(0,c.__)("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,c.__)("View in Parse.ly","wp-parsely")})]})]})})]})},at=window.wp.coreData,ot=window.wp.editor,lt=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 __)}}(),ct=function(){return ct=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 U((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),O.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return _t(this,void 0,void 0,(function(){return xt(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,xe.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",bt(bt({},mt(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(ke),St=function(){return St=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)(nt,{title:(0,p.__)("Performance Stats","wp-parsely"),icon:tt,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(Ct,{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:St(St({},m.PerformanceStats),{Period:t})}),g.trackEvent("editor_sidebar_performance_period_changed",{period:t}))},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:C(e)},e)}))})})}),c?c.Message():(0,i.jsxs)(i.Fragment,{children:[Lt(m,"overview")&&(0,i.jsx)(gt,{data:h,isLoading:a}),Lt(m,"categories")&&(0,i.jsx)(it,{data:h,isLoading:a}),Lt(m,"referrers")&&(0,i.jsx)(yt,{data:h,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){g.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,p.__)("View this in Parse.ly","wp-parsely")})]})},Nt=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(F,{children:(0,i.jsx)(At,{period:t})})})},Ot=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")})]})})},It=function(e){var t=e.filter,n=e.label,a=e.postData,o=Ot(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})})},Bt=function(e){var t=e.filter,n=e.postData,s=e.label,a=Ot(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)(Rt,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(It,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},Mt=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),Dt=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"}));function Vt(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,rt(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 Ft,Gt=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"})})},Ht=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=q(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)(Vt,{metric:r,post:o,viewsIcon:(0,i.jsx)(G,{icon:st}),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)(G,{icon:Mt,size:24})})})]}),(0,i.jsx)(Gt,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:Dt,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)(m,{}),iconSize:18,href:o.dashUrl,target:"_blank",label:(0,p.__)("View in Parse.ly","wp-parsely")})]})]})})]})},zt=window.wp.coreData,Ut=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 __)}}(),qt=function(){return qt=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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),w=v.authors,m=v.categories,_=v.tags,b=v.isReady;(0,l.useEffect)((function(){if(b){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})):[]};y({authors:e(w),categories:e(m),tags:e(_)})}}),[w,m,_,b]);var x=(0,l.useState)(!0),P=x[0],S=x[1],k=(0,l.useState)(),A=k[0],N=k[1],L=(0,l.useState)(),R=L[0],I=L[1],B=(0,l.useState)([]),M=B[0],V=B[1],D=(0,l.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=D[0],G=D[1],H=(0,l.useState)(void 0),z=H[0],U=H[1],$=(0,O.useDebounce)(U,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;$(t())}),[$]);var Z=function(e,t){u({RelatedPosts:ft(ft({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,l.useEffect)((function(){var e,t,n=function(e){return ht(void 0,void 0,void 0,(function(){return gt(this,(function(t){return dt.getInstance().getRelatedPosts(p,d,F).then((function(e){V(e.posts),I(e.message),S(!1)})).catch((function(t){return ht(void 0,void 0,void 0,(function(){return gt(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),N(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===g.authors.length,c=0===g.tags.length,u=0===g.categories.length,f=i&&!g.authors.includes(F.value),h=s&&!g.tags.includes(F.value),y=a&&!g.categories.includes(F.value);return S(!0),o||s&&c||a&&u||i&&l?Object.values(g).every((function(e){return 0===e.length}))||G((e="",t=r.Unavailable,g.tags.length>=1?(t=r.Tag,e=g.tags[0]):g.categories.length>=1?(t=r.Section,e=g.categories[0]):g.authors.length>=1&&(t=r.Author,e=g.authors[0]),{type:t,value:e})):h?G({type:r.Tag,value:g.tags[0]}):y?G({type:r.Section,value:g.categories[0]}):f?G({type:r.Author,value:g.authors[0]}):n(1),function(){S(!1),V([]),I(""),N(void 0)}}),[p,d,F,g]),0===g.authors.length&&0===g.categories.length&&0===g.tags.length&&b?(0,i.jsx)("div",{className:"wp-parsely-related-posts",children:(0,i.jsx)("div",{className:"related-posts-body",children:(0,c.__)("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,c.__)("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;T(n=e,t)&&(u({RelatedPosts:ft(ft({},o.RelatedPosts),{Metric:n})}),h.trackEvent("related_posts_metric_changed",{metric:n}))},prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,c.__)("Metric: ","wp-parsely")}),value:d,children:Object.values(t).map((function(e){return(0,i.jsx)("option",{value:e,children:C(e)},e)}))}),(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:p,prefix:(0,i.jsxs)(s.__experimentalInputControlPrefixWrapper,{children:[(0,c.__)("Period: ","wp-parsely")," "]}),onChange:function(t){return function(t){T(t,e)&&(u({RelatedPosts:ft(ft({},o.RelatedPosts),{Period:t})}),h.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)(Je,{label:(0,c.__)("Filter by","wp-parsely"),filter:F,onFilterTypeChange:function(e){if(T(e,r)){var t="",n=e;r.Tag===n&&(t=g.tags[0]),r.Section===n&&(t=g.categories[0]),r.Author===n&&(t=g.authors[0]),""!==t&&(Z(n,t),G({type:n,value:t}),h.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(F.type,e),G(ft(ft({},F),{value:e})))},postData:g}),(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===F.type?(0,c.sprintf)(/* translators: 1: tag name, 2: period */ /* translators: 1: tag name, 2: period */ -(0,c.__)("Top related posts with the “%1$s” tag in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Section===F.type?(0,c.sprintf)(/* translators: 1: section name, 2: period */ /* translators: 1: section name, 2: period */ -(0,c.__)("Top related posts in the “%1$s” section in the %2$s.","wp-parsely"),F.value,E(p,!0)):r.Author===F.type?(0,c.sprintf)(/* translators: 1: author name, 2: period */ /* translators: 1: author name, 2: period */ -(0,c.__)("Top related posts by %1$s in the %2$s.","wp-parsely"),F.value,E(p,!0)):null!=R?R:""})}),A&&A.Message(),P&&(0,i.jsx)("div",{className:"related-posts-loading-message","data-testid":"parsely-related-posts-loading-message",children:(0,c.__)("Loading…","wp-parsely")}),!P&&!A&&0===M.length&&(0,i.jsx)("div",{className:"related-posts-empty","data-testid":"parsely-related-posts-empty",children:(0,c.__)("No related posts found.","wp-parsely")}),!P&&M.length>0&&(0,i.jsx)("div",{className:"related-posts-list",children:M.map((function(e){return(0,i.jsx)(st,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},vt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),wt=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"})})},mt={journalist:{label:(0,c.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,c.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,c.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,c.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,c.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,c.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,c.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,c.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,c.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,c.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,c.__)("Custom Persona","wp-parsely"),icon:vt}},_t=Object.keys(mt),bt=function(e){return"custom"===e||""===e?mt.custom.label:xt(e)?e:mt[e].label},xt=function(e){return!_t.includes(e)||"custom"===e},Pt=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},St=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,c.__)("Select a persona…","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Persona","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:xt(t)?mt.custom.label:r}),(0,i.jsx)(wt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Persona","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:_t.map((function(e){if(!h&&"custom"===e)return null;var r=mt[e],a=e===t||xt(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(F,{icon:r.icon}),r.label]},e)}))})})}}),h&&xt(t)&&(0,i.jsx)(Pt,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},jt={neutral:{label:(0,c.__)("Neutral","wp-parsely")},formal:{label:(0,c.__)("Formal","wp-parsely")},humorous:{label:(0,c.__)("Humorous","wp-parsely")},confident:{label:(0,c.__)("Confident","wp-parsely")},provocative:{label:(0,c.__)("Provocative","wp-parsely")},serious:{label:(0,c.__)("Serious","wp-parsely")},inspirational:{label:(0,c.__)("Inspirational","wp-parsely")},skeptical:{label:(0,c.__)("Skeptical","wp-parsely")},conversational:{label:(0,c.__)("Conversational","wp-parsely")},analytical:{label:(0,c.__)("Analytical","wp-parsely")},custom:{label:(0,c.__)("Custom Tone","wp-parsely"),icon:vt}},kt=Object.keys(jt),Tt=function(e){return"custom"===e||""===e?jt.custom.label:Et(e)?e:jt[e].label},Et=function(e){return!kt.includes(e)||"custom"===e},Ct=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(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,c.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},At=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,c.__)("Select a tone","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Tone","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:Et(t)?jt.custom.label:r}),(0,i.jsx)(wt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Select a tone","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:kt.map((function(e){if(!h&&"custom"===e)return null;var r=jt[e],a=e===t||Et(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(F,{icon:r.icon}),r.label]},e)}))})})}}),h&&Et(t)&&(0,i.jsx)(Ct,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},Nt=(0,u.createElement)(p.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,u.createElement)(p.Path,{d:"M10.97 10.159a3.382 3.382 0 0 0-2.857.955l1.724 1.723-2.836 2.913L7 17h1.25l2.913-2.837 1.723 1.723a3.38 3.38 0 0 0 .606-.825c.33-.63.446-1.343.35-2.032L17 10.695 13.305 7l-2.334 3.159Z"})),Lt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"})),Ot=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"})),Rt=(0,u.createElement)(p.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,u.createElement)(p.Path,{d:"m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z"})),It=function(){return It=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,l.createInterpolateElement)( +message:(0,p.sprintf)((0,p.__)('by author "%1$s"',"wp-parsely"),n.value)};throw new U((0,p.__)("No valid filter type has been specified.","wp-parsely"),O.CannotFormulateApiQuery)},t}(ke),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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),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})):[]};v({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)(),j=P[0],E=P[1],N=(0,u.useState)(),O=N[0],R=N[1],B=(0,u.useState)([]),M=B[0],D=B[1],V=(0,u.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=V[0],G=V[1],H=(0,u.useState)(void 0),z=H[0],U=H[1],q=(0,I.useDebounce)(U,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;q(t())}),[q]);var Z=function(e,t){l({RelatedPosts:Kt(Kt({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,u.useEffect)((function(){var e,t,n=function(e){return Yt(void 0,void 0,void 0,(function(){return Qt(this,(function(t){return Wt.getInstance().getRelatedPosts(c,d,F).then((function(e){D(e.posts),R(e.message),S(!1)})).catch((function(t){return Yt(void 0,void 0,void 0,(function(){return Qt(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),E(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===h.authors.length,u=0===h.tags.length,p=0===h.categories.length,f=i&&!h.authors.includes(F.value),v=s&&!h.tags.includes(F.value),g=a&&!h.categories.includes(F.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([]),R(""),E(void 0)}}),[c,d,F,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:Kt(Kt({},o.RelatedPosts),{Metric:n})}),g.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:A(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:Kt(Kt({},o.RelatedPosts),{Period:t})}),g.trackEvent("related_posts_period_changed",{period:t}))}(t)},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:C(e)},e)}))})]}),(0,i.jsx)(Bt,{label:(0,p.__)("Filter by","wp-parsely"),filter:F,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}),g.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(F.type,e),G(Kt(Kt({},F),{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===F.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"),F.value,C(c,!0)):r.Section===F.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"),F.value,C(c,!0)):r.Author===F.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"),F.value,C(c,!0)):null!=O?O:""})}),j&&j.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&&!j&&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)(Ht,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},Jt=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),en=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"})})},tn={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:Jt}},nn=Object.keys(tn),rn=function(e){return"custom"===e||""===e?tn.custom.label:sn(e)?e:tn[e].label},sn=function(e){return!nn.includes(e)||"custom"===e},an=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,I.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)}})})},on=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:sn(t)?tn.custom.label:r}),(0,i.jsx)(en,{})]})},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:nn.map((function(e){if(!h&&"custom"===e)return null;var r=tn[e],a=e===t||sn(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)(G,{icon:r.icon}),r.label]},e)}))})})}}),h&&sn(t)&&(0,i.jsx)(an,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},ln={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:Jt}},cn=Object.keys(ln),un=function(e){return"custom"===e||""===e?ln.custom.label:pn(e)?e:ln[e].label},pn=function(e){return!cn.includes(e)||"custom"===e},dn=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,I.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)}})})},fn=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:pn(t)?ln.custom.label:r}),(0,i.jsx)(en,{})]})},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:cn.map((function(e){if(!h&&"custom"===e)return null;var r=ln[e],a=e===t||pn(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)(G,{icon:r.icon}),r.label]},e)}))})})}}),h&&pn(t)&&(0,i.jsx)(dn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},hn=(0,d.createElement)(f.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(f.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"})),vn=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),gn=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),yn=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),mn=function(){return mn=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,c.__)("We've generated a few titles based on the content of your post, written as a .","wp-parsely"),{tone:(0,i.jsx)("strong",{children:Tt(d)}),persona:(0,i.jsx)("strong",{children:bt(y)})})}):(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(F,{icon:G,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==S&&(0,i.jsx)(zt,{title:S,type:rt.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(Ut,{pinnedTitles:b,isOpen:!0}),_.length>0&&(0,i.jsx)(qt,{suggestions:_,isOpen:!0,isLoading:m})]}),(0,i.jsx)($t,{isLoading:m,onPersonaChange:function(e){L("Persona",e),v(e)},onSettingChange:L,onToneChange:function(e){L("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:m,disabled:m||"custom"===d||"custom"===y,onClick:function(){return Qt(void 0,void 0,void 0,(function(){return Xt(this,(function(e){switch(e.label){case 0:return u(void 0),!1!==m?[3,2]:(h.trackEvent("title_suggestions_generate_pressed",{request_more:_.length>0,total_titles:_.length,total_pinned:_.filter((function(e){return e.isPinned})).length,tone:d,persona:y}),[4,(t=rt.PostTitle,n=O,r=d,i=y,Qt(void 0,void 0,void 0,(function(){var e,s,a;return Xt(this,(function(o){switch(o.label){case 0:return[4,E(!0)];case 1:o.sent(),e=Yt.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(),u(a),T(t,[]),[3,6];case 6:return[4,E(!1)];case 7:return o.sent(),[2]}}))})))]);case 1:e.sent(),e.label=2;case 2:return[2]}var t,n,r,i}))}))},children:[m&&(0,c.__)("Generating Titles…","wp-parsely"),!m&&x.length>0&&(0,c.__)("Generate More","wp-parsely"),!m&&0===x.length&&(0,c.__)("Generate Titles","wp-parsely")]})})]})})},en=function(){return en=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:un(d)}),persona:(0,i.jsx)("strong",{children:rn(v)})})}):(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)(G,{icon:H,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==S&&(0,i.jsx)(Tn,{title:S,type:Ft.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(En,{pinnedTitles:_,isOpen:!0}),b.length>0&&(0,i.jsx)(Cn,{suggestions:b,isOpen:!0,isLoading:w})]}),(0,i.jsx)(Ln,{isLoading:w,onPersonaChange:function(e){N("Persona",e),y(e)},onSettingChange:N,onToneChange:function(e){N("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"===v,onClick:function(){return Rn(void 0,void 0,void 0,(function(){return In(this,(function(e){switch(e.label){case 0:return l(void 0),!1!==w?[3,2]:(g.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:v}),[4,(t=Ft.PostTitle,n=O,r=d,i=v,Rn(void 0,void 0,void 0,(function(){var e,s,a;return In(this,(function(o){switch(o.label){case 0:return[4,E(!0)];case 1:o.sent(),e=Nn.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,j(t,s)];case 4:return o.sent(),[3,6];case 5:return a=o.sent(),l(a),j(t,[]),[3,6];case 6:return[4,E(!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")]})})]})})},Mn=function(){return Mn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n Date: Thu, 23 May 2024 12:36:12 +0300 Subject: [PATCH 32/44] class-smart-linking-endpoint.php: Improve comments --- .../class-smart-linking-endpoint.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Endpoints/content-helper/class-smart-linking-endpoint.php b/src/Endpoints/content-helper/class-smart-linking-endpoint.php index ab0bd507e..952e4badd 100644 --- a/src/Endpoints/content-helper/class-smart-linking-endpoint.php +++ b/src/Endpoints/content-helper/class-smart-linking-endpoint.php @@ -1,6 +1,6 @@ Date: Thu, 23 May 2024 11:08:47 +0100 Subject: [PATCH 33/44] Fix regression with getBlockContent --- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.js | 22 +++++++------- .../smart-linking/component.tsx | 30 +++++++++++++++++-- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index e8819af9a..8d16f2af2 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' => '5af92f58bd834c9d4521'); + 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' => 'efb3ad19c380adbeebbb'); diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index 9240efb5b..ef4e08f47 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,16 +1,16 @@ -!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 Fn}});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=n(609),f=window.wp.primitives,h=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),v=window.wp.plugins,g=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,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}(),y=(g.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"})})}),m=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"})]})},w=function(){return w=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===O.ParselySuggestionsApiOpenAiError||s.code===O.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===O.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===O.ParselySuggestionsApiSchemaError?s.message=(0,p.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===O.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===O.ParselySuggestionsApiOpenAiSchema?s.message=(0,p.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===O.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,p.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return z(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[O.PluginCredentialsNotSetMessageDetected,O.PluginSettingsSiteIdNotSet,O.PluginSettingsApiSecretNotSet].includes(this.code)?D(e):(this.code===O.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!==O.ParselyApiForbidden&&this.code!==O.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===O.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)(M,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z,$=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,I.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},W=window.wp.editor,K=window.wp.blocks,Y=function(){return Y=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var l=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,p.__)("NEW","wp-parsely"),(0,i.jsx)(ve,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,p.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&l]},e.uid)}))]})})},ye=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,d.createElement)(f.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})),me=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),we=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),be=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),_e=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})),xe=window.wp.url,ke=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?c(!0):k().then((function(){return t()}))},E=function(e){c(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},L=function(){var e=g.indexOf(b)+1;g[e]&&_(g[e])},C=function(){var e=m().indexOf(b)-1;m()[e]&&_(m()[e])},A=function(){return Re(void 0,void 0,void 0,(function(){var e,t;return Ie(this,(function(n){switch(n.label){case 0:return b.match?(r(b),[4,(i=b.match.blockId,s=b,Re(void 0,void 0,void 0,(function(){var e,t;return Ie(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))?(ie(t,s,e),s.applied=!0,[4,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(b),g[t=e+1]?_(g[t]):_(g[0]),[2])}var i,s}))}))},N=function(){return Re(void 0,void 0,void 0,(function(){var e,t;return Ie(this,(function(n){switch(n.label){case 0:return e=g.indexOf(b),g[t=e+1]?_(g[t]):g[0]?_(g[0]):T(),[4,P(b.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Re(void 0,void 0,void 0,(function(){var e,t,n,r;return Ie(this,(function(i){switch(i.label){case 0:return b.match?(e=(0,a.select)("core/block-editor").getBlock(b.match.blockId))?(t=m(),n=t.indexOf(b),r=n-1,[4,j(e,b)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?_(t[r]):_(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:L,up:C,down:L,a:function(){b&&!b.applied&&A()},r:function(){b&&(b.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(ge,{links:g,activeLink:b,setSelectedLink:_}),(0,i.jsx)(Oe,{link:b,hasNext:m().indexOf(b)0,onNext:L,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(b.match){var e=(0,a.select)("core/block-editor").getBlock(b.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(b.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),l&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return E(!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 E(!1)},children:(0,p.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return E(!0)},children:(0,p.__)("Close","wp-parsely")})]})]})]})})),Me=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})]})]})},De=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,l=e.onSettingChange,c=(0,u.useRef)(),d=(0,u.useState)(""),f=d[0],h=d[1],v=(0,u.useState)(!1),g=v[0],y=v[1],m=(0,u.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(J),n=t.getMaxLinks,r=t.isFullContent,i=t.wasAlreadyClicked,s=t.getApplyTo;return{maxLinks:n(),fullContent:r(),alreadyClicked:i(),applyTo:s()}}),[]),b=w.maxLinks,_=w.fullContent,x=w.alreadyClicked,k=w.applyTo,S=(0,a.useDispatch)(J),P=S.setMaxLinks,j=S.setFullContent,T=S.setAlreadyClicked,E=S.setApplyTo,L=null!==(t=k)&&void 0!==t?t:o?"selected":"all";return(0,u.useEffect)((function(){if(!r){var e=function(){r||(k===Z.Selected&&setTimeout((function(){h((0,p.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),E(null),m((function(e){return!e})))};o||k===Z.All||(g?setTimeout(e,500):e()),j(Z.All===L)}}),[g,k,L,r,o,E,j,h]),(0,u.useEffect)((function(){if(!r&&c.current&&L&&!x&&o){var e=c.current.querySelector('button[data-value="'.concat(L,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(E(L),T(!0))}}),[o,_,r,k]),(0,u.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:c,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:L,label:(0,p.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&_("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"),v),{type:"snackbar"}):y(0)}),[w]),(0,u.useEffect)((function(){if(!(Object.keys(N).length>0)){var e={maxLinksPerPost:c.SmartLinking.MaxLinks};ne(e)}}),[ne,c]);var ge=(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]),ye=ge.allBlocks,me=ge.selectedBlock,we=ge.postContent,be=ge.postPermalink,_e=function(e){return Fe(void 0,void 0,void 0,(function(){var t,n,r,i;return Ge(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,re((n=j||!me)?Z.All:Z.Selected)];case 2:return s.sent(),a=be.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,Te.getInstance().generateSmartLinks((null==me?void 0:me.originalContent)&&!n?me.originalContent:we,A,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===O.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,se(!0)]):[3,8];case 5:return s.sent(),[4,ae()];case 6:return s.sent(),[4,_e(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},xe=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Pe=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)($,{isDetectingEnabled:!P,onLinkRemove:function(e){!function(e){ee(this,void 0,void 0,(function(){var t,n,r;return te(this,(function(i){switch(i.label){case 0:return[4,ue((0,K.getBlockContent)(e),e.clientId)];case 1:return t=i.sent(),n=t.missingSmartLinks,r=t.didAnyFixes,n.forEach((function(e){(0,a.dispatch)(J).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)(G,{icon:H,size:18,className:"parsely-external-link-icon"})]})]}),L&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return q(null)},className:"wp-parsely-content-helper-error",children:L.Message()}),w&&v>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return b(!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"),v>0?v:C.length)}),(0,i.jsx)(De,{disabled:S,selectedBlock:null==me?void 0:me.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:Ve(Ve({},c.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e&&ie(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return Fe(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Ge(this,(function(a){switch(a.label){case 0:return[4,U(!0)];case 1:return a.sent(),[4,ce()];case 2:return a.sent(),[4,q(null)];case 3:return a.sent(),b(!1),g.trackEvent("smart_linking_generate_pressed",{is_full_content:j,selected_block:null!==(s=null==me?void 0:me.name)&&void 0!==s?s:"none",context:o}),[4,xe(j?"all":null==me?void 0:me.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;U(!1),g.trackEvent("smart_linking_generate_timeout",{is_full_content:j,selected_block:null!==(e=null==me?void 0:me.name)&&void 0!==e?e:"none",context:o}),ke(j?"all":null==me?void 0:me.clientId)}),18e4),t=R,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,_e(3)];case 6:return n=a.sent(),[4,(l=n,Fe(void 0,void 0,void 0,(function(){var e;return Ge(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!D.find((function(t){return t.uid===e.uid&&t.applied}))})),e=be.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=oe(ye,l,{}).filter((function(e){return e.match})),[4,Y(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),ve(!0),[3,15];case 8:return r=a.sent(),i=(0,p.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===O.ParselyAborted&&(i=(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")),r.message=i),[4,q(r)];case 9:return a.sent(),_("error",i,{type:"snackbar"}),[3,15];case 10:return[4,U(!1)];case 11:return a.sent(),[4,re(t)];case 12:return a.sent(),[4,se(!1)];case 13:return a.sent(),[4,ke(j?"all":null==me?void 0:me.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:S,disabled:S,children:B?(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 */ +!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 Fn}});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=n(609),f=window.wp.primitives,h=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),v=window.wp.plugins,g=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,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}(),y=(g.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"})})}),m=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"})]})},w=function(){return w=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===O.ParselySuggestionsApiOpenAiError||s.code===O.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===O.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===O.ParselySuggestionsApiSchemaError?s.message=(0,p.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===O.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===O.ParselySuggestionsApiOpenAiSchema?s.message=(0,p.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===O.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,p.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return U(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[O.PluginCredentialsNotSetMessageDetected,O.PluginSettingsSiteIdNotSet,O.PluginSettingsApiSecretNotSet].includes(this.code)?D(e):(this.code===O.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!==O.ParselyApiForbidden&&this.code!==O.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===O.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)(M,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function Z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var $,W=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,I.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},K=window.wp.editor,Y=function(){return Y=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var l=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,p.__)("NEW","wp-parsely"),(0,i.jsx)(ve,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,p.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&l]},e.uid)}))]})})},ye=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,d.createElement)(f.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})),me=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),we=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),be=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),_e=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})),xe=window.wp.url,ke=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?c(!0):k().then((function(){return t()}))},E=function(e){c(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},L=function(){var e=g.indexOf(b)+1;g[e]&&_(g[e])},C=function(){var e=m().indexOf(b)-1;m()[e]&&_(m()[e])},A=function(){return Re(void 0,void 0,void 0,(function(){var e,t;return Ie(this,(function(n){switch(n.label){case 0:return b.match?(r(b),[4,(i=b.match.blockId,s=b,Re(void 0,void 0,void 0,(function(){var e,t;return Ie(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))?(ie(t,s,e),s.applied=!0,[4,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(b),g[t=e+1]?_(g[t]):_(g[0]),[2])}var i,s}))}))},N=function(){return Re(void 0,void 0,void 0,(function(){var e,t;return Ie(this,(function(n){switch(n.label){case 0:return e=g.indexOf(b),g[t=e+1]?_(g[t]):g[0]?_(g[0]):T(),[4,P(b.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Re(void 0,void 0,void 0,(function(){var e,t,n,r;return Ie(this,(function(i){switch(i.label){case 0:return b.match?(e=(0,a.select)("core/block-editor").getBlock(b.match.blockId))?(t=m(),n=t.indexOf(b),r=n-1,[4,j(e,b)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?_(t[r]):_(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:L,up:C,down:L,a:function(){b&&!b.applied&&A()},r:function(){b&&(b.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(ge,{links:g,activeLink:b,setSelectedLink:_}),(0,i.jsx)(Oe,{link:b,hasNext:m().indexOf(b)0,onNext:L,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(b.match){var e=(0,a.select)("core/block-editor").getBlock(b.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(b.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),l&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return E(!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 E(!1)},children:(0,p.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return E(!0)},children:(0,p.__)("Close","wp-parsely")})]})]})]})})),Me=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})]})]})},De=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,l=e.onSettingChange,c=(0,u.useRef)(),d=(0,u.useState)(""),f=d[0],h=d[1],v=(0,u.useState)(!1),g=v[0],y=v[1],m=(0,u.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(J),n=t.getMaxLinks,r=t.isFullContent,i=t.wasAlreadyClicked,s=t.getApplyTo;return{maxLinks:n(),fullContent:r(),alreadyClicked:i(),applyTo:s()}}),[]),b=w.maxLinks,_=w.fullContent,x=w.alreadyClicked,k=w.applyTo,S=(0,a.useDispatch)(J),P=S.setMaxLinks,j=S.setFullContent,T=S.setAlreadyClicked,E=S.setApplyTo,L=null!==(t=k)&&void 0!==t?t:o?"selected":"all";return(0,u.useEffect)((function(){if(!r){var e=function(){r||(k===$.Selected&&setTimeout((function(){h((0,p.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),E(null),m((function(e){return!e})))};o||k===$.All||(g?setTimeout(e,500):e()),j($.All===L)}}),[g,k,L,r,o,E,j,h]),(0,u.useEffect)((function(){if(!r&&c.current&&L&&!x&&o){var e=c.current.querySelector('button[data-value="'.concat(L,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(E(L),T(!0))}}),[o,_,r,k]),(0,u.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:c,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:L,label:(0,p.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&_("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"),v),{type:"snackbar"}):y(0)}),[w]),(0,u.useEffect)((function(){if(!(Object.keys(N).length>0)){var e={maxLinksPerPost:c.SmartLinking.MaxLinks};ne(e)}}),[ne,c]);var ge=(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]),ye=ge.allBlocks,me=ge.selectedBlock,we=ge.postContent,be=ge.postPermalink,_e=function(e){return Fe(void 0,void 0,void 0,(function(){var t,n,r,i;return Ge(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,re((n=j||!me)?$.All:$.Selected)];case 2:return s.sent(),a=be.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,Te.getInstance().generateSmartLinks(me&&!n?(0,G.getBlockContent)(me):we,A,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===O.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,se(!0)]):[3,8];case 5:return s.sent(),[4,ae()];case 6:return s.sent(),[4,_e(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},xe=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Pe=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)(W,{isDetectingEnabled:!P,onLinkRemove:function(e){!function(e){ee(this,void 0,void 0,(function(){var t,n,r;return te(this,(function(i){switch(i.label){case 0:return[4,ue((0,G.getBlockContent)(e),e.clientId)];case 1:return t=i.sent(),n=t.missingSmartLinks,r=t.didAnyFixes,n.forEach((function(e){(0,a.dispatch)(J).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)(H,{icon:z,size:18,className:"parsely-external-link-icon"})]})]}),L&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return Z(null)},className:"wp-parsely-content-helper-error",children:L.Message()}),w&&v>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return b(!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"),v>0?v:C.length)}),(0,i.jsx)(De,{disabled:S,selectedBlock:null==me?void 0:me.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:Ve(Ve({},c.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e&&ie(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return Fe(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Ge(this,(function(a){switch(a.label){case 0:return[4,q(!0)];case 1:return a.sent(),[4,ce()];case 2:return a.sent(),[4,Z(null)];case 3:return a.sent(),b(!1),g.trackEvent("smart_linking_generate_pressed",{is_full_content:j,selected_block:null!==(s=null==me?void 0:me.name)&&void 0!==s?s:"none",context:o}),[4,xe(j?"all":null==me?void 0:me.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;q(!1),g.trackEvent("smart_linking_generate_timeout",{is_full_content:j,selected_block:null!==(e=null==me?void 0:me.name)&&void 0!==e?e:"none",context:o}),ke(j?"all":null==me?void 0:me.clientId)}),18e4),t=R,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,_e(3)];case 6:return n=a.sent(),[4,(l=n,Fe(void 0,void 0,void 0,(function(){var e;return Ge(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!D.find((function(t){return t.uid===e.uid&&t.applied}))})),e=be.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=(l=oe(ye,l,{}).filter((function(e){return e.match}))).filter((function(e){if(D.some((function(t){return t.text===e.text&&t.offset===e.offset})))return!1;if(!e.match)return!1;var t=e.match.blockLinkPosition,n=t+e.text.length;return!D.some((function(r){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,Y(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),ve(!0),[3,15];case 8:return r=a.sent(),i=(0,p.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===O.ParselyAborted&&(i=(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")),r.message=i),[4,Z(r)];case 9:return a.sent(),_("error",i,{type:"snackbar"}),[3,15];case 10:return[4,q(!1)];case 11:return a.sent(),[4,re(t)];case 12:return a.sent(),[4,se(!1)];case 13:return a.sent(),[4,ke(j?"all":null==me?void 0:me.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:S,disabled:S,children:B?(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"),M,3):S?(0,p.__)("Generating Smart Links…","wp-parsely"):(0,p.__)("Add Smart Links","wp-parsely")})}),V.length>0&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return Fe(void 0,void 0,void 0,(function(){var e;return Ge(this,(function(t){switch(t.label){case 0:return[4,pe()];case 1:return t.sent(),e=le(),[4,Y(e)];case 2:return t.sent(),ve(!0),[2]}}))}))},variant:"secondary",children:(0,p.__)("Review Smart Links","wp-parsely")})})]}),P&&(0,i.jsx)(Be,{isOpen:P,onAppliedLink:function(){y((function(e){return e+1}))},onClose:function(){b(!0),ve(!1)}})]})},Ue=function(){return Ue=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 it=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"),A(o)); /* translators: %s: metric description */return(0,i.jsxs)(nt,{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:[A(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:rt(n.views)})]},t)}))})]})]})},st=(0,d.createElement)(f.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(f.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"})),at=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),ot=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),lt=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"})),ct=function(){return ct=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]1?[2,Promise.reject(new U((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),O.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return _t(this,void 0,void 0,(function(){return xt(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,xe.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",bt(bt({},mt(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(ke),St=function(){return St=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)(nt,{title:(0,p.__)("Performance Stats","wp-parsely"),icon:tt,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(Ct,{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:St(St({},m.PerformanceStats),{Period:t})}),g.trackEvent("editor_sidebar_performance_period_changed",{period:t}))},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:C(e)},e)}))})})}),c?c.Message():(0,i.jsxs)(i.Fragment,{children:[Lt(m,"overview")&&(0,i.jsx)(gt,{data:h,isLoading:a}),Lt(m,"categories")&&(0,i.jsx)(it,{data:h,isLoading:a}),Lt(m,"referrers")&&(0,i.jsx)(yt,{data:h,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){g.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,p.__)("View this in Parse.ly","wp-parsely")})]})},Nt=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(F,{children:(0,i.jsx)(At,{period:t})})})},Ot=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")})]})})},It=function(e){var t=e.filter,n=e.label,a=e.postData,o=Ot(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})})},Bt=function(e){var t=e.filter,n=e.postData,s=e.label,a=Ot(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)(Rt,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(It,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},Mt=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),Dt=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"}));function Vt(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,rt(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 Ft,Gt=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"})})},Ht=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=q(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)(Vt,{metric:r,post:o,viewsIcon:(0,i.jsx)(G,{icon:st}),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)(G,{icon:Mt,size:24})})})]}),(0,i.jsx)(Gt,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:Dt,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)(m,{}),iconSize:18,href:o.dashUrl,target:"_blank",label:(0,p.__)("View in Parse.ly","wp-parsely")})]})]})})]})},zt=window.wp.coreData,Ut=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 __)}}(),qt=function(){return qt=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 q((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),O.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return _t(this,void 0,void 0,(function(){return xt(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,xe.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",bt(bt({},mt(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(ke),St=function(){return St=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)(nt,{title:(0,p.__)("Performance Stats","wp-parsely"),icon:tt,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(Ct,{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:St(St({},m.PerformanceStats),{Period:t})}),g.trackEvent("editor_sidebar_performance_period_changed",{period:t}))},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:C(e)},e)}))})})}),c?c.Message():(0,i.jsxs)(i.Fragment,{children:[Lt(m,"overview")&&(0,i.jsx)(gt,{data:h,isLoading:a}),Lt(m,"categories")&&(0,i.jsx)(it,{data:h,isLoading:a}),Lt(m,"referrers")&&(0,i.jsx)(yt,{data:h,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){g.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,p.__)("View this in Parse.ly","wp-parsely")})]})},Nt=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(F,{children:(0,i.jsx)(At,{period:t})})})},Ot=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")})]})})},It=function(e){var t=e.filter,n=e.label,a=e.postData,o=Ot(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})})},Bt=function(e){var t=e.filter,n=e.postData,s=e.label,a=Ot(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)(Rt,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(It,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},Mt=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),Dt=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"}));function Vt(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,rt(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 Ft,Gt=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"})})},Ht=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=Z(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)(Vt,{metric:r,post:o,viewsIcon:(0,i.jsx)(H,{icon:st}),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)(H,{icon:Mt,size:24})})})]}),(0,i.jsx)(Gt,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:Dt,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)(m,{}),iconSize:18,href:o.dashUrl,target:"_blank",label:(0,p.__)("View in Parse.ly","wp-parsely")})]})]})})]})},zt=window.wp.coreData,Ut=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 __)}}(),qt=function(){return qt=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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),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})):[]};v({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)(),j=P[0],E=P[1],N=(0,u.useState)(),O=N[0],R=N[1],B=(0,u.useState)([]),M=B[0],D=B[1],V=(0,u.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=V[0],G=V[1],H=(0,u.useState)(void 0),z=H[0],U=H[1],q=(0,I.useDebounce)(U,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;q(t())}),[q]);var Z=function(e,t){l({RelatedPosts:Kt(Kt({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,u.useEffect)((function(){var e,t,n=function(e){return Yt(void 0,void 0,void 0,(function(){return Qt(this,(function(t){return Wt.getInstance().getRelatedPosts(c,d,F).then((function(e){D(e.posts),R(e.message),S(!1)})).catch((function(t){return Yt(void 0,void 0,void 0,(function(){return Qt(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),E(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===h.authors.length,u=0===h.tags.length,p=0===h.categories.length,f=i&&!h.authors.includes(F.value),v=s&&!h.tags.includes(F.value),g=a&&!h.categories.includes(F.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([]),R(""),E(void 0)}}),[c,d,F,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:Kt(Kt({},o.RelatedPosts),{Metric:n})}),g.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:A(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:Kt(Kt({},o.RelatedPosts),{Period:t})}),g.trackEvent("related_posts_period_changed",{period:t}))}(t)},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:C(e)},e)}))})]}),(0,i.jsx)(Bt,{label:(0,p.__)("Filter by","wp-parsely"),filter:F,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}),g.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(F.type,e),G(Kt(Kt({},F),{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===F.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 q((0,p.__)("No valid filter type has been specified.","wp-parsely"),O.CannotFormulateApiQuery)},t}(ke),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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),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})):[]};v({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)(),j=P[0],E=P[1],N=(0,u.useState)(),O=N[0],R=N[1],B=(0,u.useState)([]),M=B[0],D=B[1],V=(0,u.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=V[0],G=V[1],H=(0,u.useState)(void 0),z=H[0],U=H[1],q=(0,I.useDebounce)(U,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;q(t())}),[q]);var Z=function(e,t){l({RelatedPosts:Kt(Kt({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,u.useEffect)((function(){var e,t,n=function(e){return Yt(void 0,void 0,void 0,(function(){return Qt(this,(function(t){return Wt.getInstance().getRelatedPosts(c,d,F).then((function(e){D(e.posts),R(e.message),S(!1)})).catch((function(t){return Yt(void 0,void 0,void 0,(function(){return Qt(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),E(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===h.authors.length,u=0===h.tags.length,p=0===h.categories.length,f=i&&!h.authors.includes(F.value),v=s&&!h.tags.includes(F.value),g=a&&!h.categories.includes(F.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([]),R(""),E(void 0)}}),[c,d,F,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:Kt(Kt({},o.RelatedPosts),{Metric:n})}),g.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:A(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:Kt(Kt({},o.RelatedPosts),{Period:t})}),g.trackEvent("related_posts_period_changed",{period:t}))}(t)},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:C(e)},e)}))})]}),(0,i.jsx)(Bt,{label:(0,p.__)("Filter by","wp-parsely"),filter:F,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}),g.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(F.type,e),G(Kt(Kt({},F),{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===F.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"),F.value,C(c,!0)):r.Section===F.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"),F.value,C(c,!0)):r.Author===F.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"),F.value,C(c,!0)):null!=O?O:""})}),j&&j.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&&!j&&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)(Ht,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},Jt=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),en=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"})})},tn={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:Jt}},nn=Object.keys(tn),rn=function(e){return"custom"===e||""===e?tn.custom.label:sn(e)?e:tn[e].label},sn=function(e){return!nn.includes(e)||"custom"===e},an=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,I.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)}})})},on=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:sn(t)?tn.custom.label:r}),(0,i.jsx)(en,{})]})},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:nn.map((function(e){if(!h&&"custom"===e)return null;var r=tn[e],a=e===t||sn(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)(G,{icon:r.icon}),r.label]},e)}))})})}}),h&&sn(t)&&(0,i.jsx)(an,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},ln={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:Jt}},cn=Object.keys(ln),un=function(e){return"custom"===e||""===e?ln.custom.label:pn(e)?e:ln[e].label},pn=function(e){return!cn.includes(e)||"custom"===e},dn=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,I.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)}})})},fn=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:pn(t)?ln.custom.label:r}),(0,i.jsx)(en,{})]})},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:cn.map((function(e){if(!h&&"custom"===e)return null;var r=ln[e],a=e===t||pn(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)(G,{icon:r.icon}),r.label]},e)}))})})}}),h&&pn(t)&&(0,i.jsx)(dn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},hn=(0,d.createElement)(f.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(f.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"})),vn=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),gn=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),yn=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),mn=function(){return mn=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"),F.value,C(c,!0)):null!=O?O:""})}),j&&j.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&&!j&&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)(Ht,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},Jt=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})),en=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"})})},tn={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:Jt}},nn=Object.keys(tn),rn=function(e){return"custom"===e||""===e?tn.custom.label:sn(e)?e:tn[e].label},sn=function(e){return!nn.includes(e)||"custom"===e},an=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,I.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)}})})},on=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:sn(t)?tn.custom.label:r}),(0,i.jsx)(en,{})]})},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:nn.map((function(e){if(!h&&"custom"===e)return null;var r=tn[e],a=e===t||sn(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)(H,{icon:r.icon}),r.label]},e)}))})})}}),h&&sn(t)&&(0,i.jsx)(an,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},ln={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:Jt}},cn=Object.keys(ln),un=function(e){return"custom"===e||""===e?ln.custom.label:pn(e)?e:ln[e].label},pn=function(e){return!cn.includes(e)||"custom"===e},dn=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,I.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)}})})},fn=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:pn(t)?ln.custom.label:r}),(0,i.jsx)(en,{})]})},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:cn.map((function(e){if(!h&&"custom"===e)return null;var r=ln[e],a=e===t||pn(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)(H,{icon:r.icon}),r.label]},e)}))})})}}),h&&pn(t)&&(0,i.jsx)(dn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},hn=(0,d.createElement)(f.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg"},(0,d.createElement)(f.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"})),vn=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),gn=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),yn=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),mn=function(){return mn=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:un(d)}),persona:(0,i.jsx)("strong",{children:rn(v)})})}):(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)(G,{icon:H,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==S&&(0,i.jsx)(Tn,{title:S,type:Ft.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(En,{pinnedTitles:_,isOpen:!0}),b.length>0&&(0,i.jsx)(Cn,{suggestions:b,isOpen:!0,isLoading:w})]}),(0,i.jsx)(Ln,{isLoading:w,onPersonaChange:function(e){N("Persona",e),y(e)},onSettingChange:N,onToneChange:function(e){N("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"===v,onClick:function(){return Rn(void 0,void 0,void 0,(function(){return In(this,(function(e){switch(e.label){case 0:return l(void 0),!1!==w?[3,2]:(g.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:v}),[4,(t=Ft.PostTitle,n=O,r=d,i=v,Rn(void 0,void 0,void 0,(function(){var e,s,a;return In(this,(function(o){switch(o.label){case 0:return[4,E(!0)];case 1:o.sent(),e=Nn.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,j(t,s)];case 4:return o.sent(),[3,6];case 5:return a=o.sent(),l(a),j(t,[]),[3,6];case 6:return[4,E(!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")]})})]})})},Mn=function(){return Mn=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:un(d)}),persona:(0,i.jsx)("strong",{children:rn(v)})})}):(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)(H,{icon:z,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==S&&(0,i.jsx)(Tn,{title:S,type:Ft.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(En,{pinnedTitles:_,isOpen:!0}),b.length>0&&(0,i.jsx)(Cn,{suggestions:b,isOpen:!0,isLoading:w})]}),(0,i.jsx)(Ln,{isLoading:w,onPersonaChange:function(e){N("Persona",e),y(e)},onSettingChange:N,onToneChange:function(e){N("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"===v,onClick:function(){return Rn(void 0,void 0,void 0,(function(){return In(this,(function(e){switch(e.label){case 0:return l(void 0),!1!==w?[3,2]:(g.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:v}),[4,(t=Ft.PostTitle,n=O,r=d,i=v,Rn(void 0,void 0,void 0,(function(){var e,s,a;return In(this,(function(o){switch(o.label){case 0:return[4,E(!0)];case 1:o.sent(),e=Nn.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,j(t,s)];case 4:return o.sent(),[3,6];case 5:return a=o.sent(),l(a),j(t,[]),[3,6];case 6:return[4,E(!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")]})})]})})},Mn=function(){return Mn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n link.match ); + // Filter out links without match and smart links being inserted inside another smart link. + links = links.filter( ( link ) => { + // If the link text and offset are the same, we want to keep the link, so it can replace the old smart link. + if ( smartLinks.some( ( sl ) => sl.text === link.text && sl.offset === link.offset ) ) { + // TODO: Flag smart link as updated, for now we just remove the old one. + return false; + } + + if ( ! link.match ) { + return false; + } + const linkStart = link.match.blockLinkPosition; + const linkEnd = linkStart + link.text.length; + + return ! smartLinks.some( ( sl ) => { + if ( link.match!.blockId !== sl.match!.blockId ) { + return false; + } + const slStart = sl.match!.blockLinkPosition; + const slEnd = slStart + sl.text.length; + + return ( linkStart >= slStart && linkEnd <= slEnd ); + } ); + } ); + // Update the link suggestions with the new matches. await addSmartLinks( links ); }; @@ -402,8 +428,8 @@ export const SmartLinkingPanel = ( { const urlExclusionList = generateProtocolVariants( postPermalink ); generatedLinks = await SmartLinkingProvider.getInstance().generateSmartLinks( - ( selectedBlock?.originalContent && ! generatingFullContent ) - ? selectedBlock.originalContent + ( selectedBlock && ! generatingFullContent ) + ? getBlockContent( selectedBlock ) : postContent, maxLinks, urlExclusionList From 45f1d91487e1130cea220edce2bd217905870cdd Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 23 May 2024 12:03:05 +0100 Subject: [PATCH 34/44] Apply suggestions from code review Co-authored-by: Alex Cicovic <23142906+acicovic@users.noreply.github.com> --- src/Endpoints/class-base-endpoint.php | 2 +- src/RemoteAPI/interface-remote-api.php | 1 + tests/Integration/BaseUserMetaEndpointTest.php | 4 +++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Endpoints/class-base-endpoint.php b/src/Endpoints/class-base-endpoint.php index 2797dfcc7..2d2f206ee 100644 --- a/src/Endpoints/class-base-endpoint.php +++ b/src/Endpoints/class-base-endpoint.php @@ -176,7 +176,7 @@ public function register_endpoint_with_args( array $methods = array( 'GET' ), array $args = array() ): void { - if ( ! apply_filters( 'wp_parsely_enable_' . convert_endpoint_to_filter_key( $endpoint ) . '_endpoint', true ) ) { + if ( ! apply_filters( 'wp_parsely_enable_' . convert_endpoint_to_filter_key( $endpoint ) . '_api_proxy', true ) ) { return; } diff --git a/src/RemoteAPI/interface-remote-api.php b/src/RemoteAPI/interface-remote-api.php index 644fb74d9..88c4cf6a9 100644 --- a/src/RemoteAPI/interface-remote-api.php +++ b/src/RemoteAPI/interface-remote-api.php @@ -12,6 +12,7 @@ use WP_Error; use WP_REST_Request; + /** * Remote API Interface. */ diff --git a/tests/Integration/BaseUserMetaEndpointTest.php b/tests/Integration/BaseUserMetaEndpointTest.php index a7ef35ef9..a32e32cc3 100644 --- a/tests/Integration/BaseUserMetaEndpointTest.php +++ b/tests/Integration/BaseUserMetaEndpointTest.php @@ -149,13 +149,15 @@ protected function send_put_request( string $data ): string { /** * Verifies that the route is not registered when the respective filter is * set to false. + * + * @since 3.16.0 */ public function run_test_do_not_register_route_when_proxy_is_disabled(): void { // Override some setup steps in order to set the filter to false. remove_action( 'rest_api_init', $this->rest_api_init_proxy ); $endpoint = $this->get_endpoint(); $this->rest_api_init_proxy = static function () use ( $endpoint ) { - add_filter( 'wp_parsely_enable_' . self::$filter_key . '_endpoint', '__return_false' ); + add_filter( 'wp_parsely_enable_' . self::$filter_key . '_api_proxy', '__return_false' ); $endpoint->run(); }; add_action( 'rest_api_init', $this->rest_api_init_proxy ); From 9de4b08af4cb0cdf6bb4db183eb95d969dc32751 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 23 May 2024 12:04:45 +0100 Subject: [PATCH 35/44] Update src/Endpoints/class-base-endpoint.php Co-authored-by: Alex Cicovic <23142906+acicovic@users.noreply.github.com> --- src/Endpoints/class-base-endpoint.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Endpoints/class-base-endpoint.php b/src/Endpoints/class-base-endpoint.php index 2d2f206ee..3e3c272e8 100644 --- a/src/Endpoints/class-base-endpoint.php +++ b/src/Endpoints/class-base-endpoint.php @@ -129,7 +129,7 @@ public function register_endpoint( string $callback, array $methods = array( 'GET' ) ): void { - if ( ! apply_filters( 'wp_parsely_enable_' . convert_endpoint_to_filter_key( $endpoint ) . '_endpoint', true ) ) { + if ( ! apply_filters( 'wp_parsely_enable_' . convert_endpoint_to_filter_key( $endpoint ) . '_api_proxy', true ) ) { return; } From ca7d0949075ddcdf6e6056381059409cd3abdac4 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 23 May 2024 12:11:07 +0100 Subject: [PATCH 36/44] Performance improvement per code review suggestion. --- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.js | 2 +- src/content-helper/editor-sidebar/smart-linking/component.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index 8d16f2af2..df2ed7b3b 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' => 'efb3ad19c380adbeebbb'); + 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' => '5c7aa2fd7c4edadc201a'); diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index ef4e08f47..f5fb9578d 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,6 +1,6 @@ !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 Fn}});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=n(609),f=window.wp.primitives,h=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})),v=window.wp.plugins,g=function(){function e(){this._tkq=[],this.isLoaded=!1,this.isEnabled=!1,"undefined"!=typeof wpParselyTracksTelemetry&&(this.isEnabled=!0,this.loadTrackingLibrary())}return e.getInstance=function(){return window.wpParselyTelemetryInstance||Object.defineProperty(window,"wpParselyTelemetryInstance",{value:new e,writable:!1,configurable:!1,enumerable:!1}),window.wpParselyTelemetryInstance},e.prototype.loadTrackingLibrary=function(){var e=this,t=document.createElement("script");t.async=!0,t.src="//stats.wp.com/w.js",t.onload=function(){e.isLoaded=!0,e._tkq=window._tkq||[]},document.head.appendChild(t)},e.trackEvent=function(t){return n=this,r=arguments,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}(),y=(g.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"})})}),m=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"})]})},w=function(){return w=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===O.ParselySuggestionsApiOpenAiError||s.code===O.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===O.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===O.ParselySuggestionsApiSchemaError?s.message=(0,p.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===O.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===O.ParselySuggestionsApiOpenAiSchema?s.message=(0,p.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===O.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,p.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return U(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[O.PluginCredentialsNotSetMessageDetected,O.PluginSettingsSiteIdNotSet,O.PluginSettingsApiSecretNotSet].includes(this.code)?D(e):(this.code===O.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!==O.ParselyApiForbidden&&this.code!==O.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===O.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)(M,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function Z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var $,W=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,I.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},K=window.wp.editor,Y=function(){return Y=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var l=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,p.__)("NEW","wp-parsely"),(0,i.jsx)(ve,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,p.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&l]},e.uid)}))]})})},ye=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,d.createElement)(f.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})),me=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})),we=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.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"})),be=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"})),_e=(0,d.createElement)(f.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,d.createElement)(f.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})),xe=window.wp.url,ke=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?c(!0):k().then((function(){return t()}))},E=function(e){c(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},L=function(){var e=g.indexOf(b)+1;g[e]&&_(g[e])},C=function(){var e=m().indexOf(b)-1;m()[e]&&_(m()[e])},A=function(){return Re(void 0,void 0,void 0,(function(){var e,t;return Ie(this,(function(n){switch(n.label){case 0:return b.match?(r(b),[4,(i=b.match.blockId,s=b,Re(void 0,void 0,void 0,(function(){var e,t;return Ie(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))?(ie(t,s,e),s.applied=!0,[4,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(b),g[t=e+1]?_(g[t]):_(g[0]),[2])}var i,s}))}))},N=function(){return Re(void 0,void 0,void 0,(function(){var e,t;return Ie(this,(function(n){switch(n.label){case 0:return e=g.indexOf(b),g[t=e+1]?_(g[t]):g[0]?_(g[0]):T(),[4,P(b.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Re(void 0,void 0,void 0,(function(){var e,t,n,r;return Ie(this,(function(i){switch(i.label){case 0:return b.match?(e=(0,a.select)("core/block-editor").getBlock(b.match.blockId))?(t=m(),n=t.indexOf(b),r=n-1,[4,j(e,b)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?_(t[r]):_(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:L,up:C,down:L,a:function(){b&&!b.applied&&A()},r:function(){b&&(b.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(ge,{links:g,activeLink:b,setSelectedLink:_}),(0,i.jsx)(Oe,{link:b,hasNext:m().indexOf(b)0,onNext:L,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(b.match){var e=(0,a.select)("core/block-editor").getBlock(b.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(b.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),l&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return E(!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 E(!1)},children:(0,p.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return E(!0)},children:(0,p.__)("Close","wp-parsely")})]})]})]})})),Me=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})]})]})},De=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,l=e.onSettingChange,c=(0,u.useRef)(),d=(0,u.useState)(""),f=d[0],h=d[1],v=(0,u.useState)(!1),g=v[0],y=v[1],m=(0,u.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(J),n=t.getMaxLinks,r=t.isFullContent,i=t.wasAlreadyClicked,s=t.getApplyTo;return{maxLinks:n(),fullContent:r(),alreadyClicked:i(),applyTo:s()}}),[]),b=w.maxLinks,_=w.fullContent,x=w.alreadyClicked,k=w.applyTo,S=(0,a.useDispatch)(J),P=S.setMaxLinks,j=S.setFullContent,T=S.setAlreadyClicked,E=S.setApplyTo,L=null!==(t=k)&&void 0!==t?t:o?"selected":"all";return(0,u.useEffect)((function(){if(!r){var e=function(){r||(k===$.Selected&&setTimeout((function(){h((0,p.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),E(null),m((function(e){return!e})))};o||k===$.All||(g?setTimeout(e,500):e()),j($.All===L)}}),[g,k,L,r,o,E,j,h]),(0,u.useEffect)((function(){if(!r&&c.current&&L&&!x&&o){var e=c.current.querySelector('button[data-value="'.concat(L,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(E(L),T(!0))}}),[o,_,r,k]),(0,u.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:c,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:L,label:(0,p.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&_("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"),v),{type:"snackbar"}):y(0)}),[w]),(0,u.useEffect)((function(){if(!(Object.keys(N).length>0)){var e={maxLinksPerPost:c.SmartLinking.MaxLinks};ne(e)}}),[ne,c]);var ge=(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]),ye=ge.allBlocks,me=ge.selectedBlock,we=ge.postContent,be=ge.postPermalink,_e=function(e){return Fe(void 0,void 0,void 0,(function(){var t,n,r,i;return Ge(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,re((n=j||!me)?$.All:$.Selected)];case 2:return s.sent(),a=be.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,Te.getInstance().generateSmartLinks(me&&!n?(0,G.getBlockContent)(me):we,A,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===O.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,se(!0)]):[3,8];case 5:return s.sent(),[4,ae()];case 6:return s.sent(),[4,_e(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},xe=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Pe=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)(W,{isDetectingEnabled:!P,onLinkRemove:function(e){!function(e){ee(this,void 0,void 0,(function(){var t,n,r;return te(this,(function(i){switch(i.label){case 0:return[4,ue((0,G.getBlockContent)(e),e.clientId)];case 1:return t=i.sent(),n=t.missingSmartLinks,r=t.didAnyFixes,n.forEach((function(e){(0,a.dispatch)(J).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)(H,{icon:z,size:18,className:"parsely-external-link-icon"})]})]}),L&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return Z(null)},className:"wp-parsely-content-helper-error",children:L.Message()}),w&&v>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return b(!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"),v>0?v:C.length)}),(0,i.jsx)(De,{disabled:S,selectedBlock:null==me?void 0:me.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:Ve(Ve({},c.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e&&ie(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return Fe(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Ge(this,(function(a){switch(a.label){case 0:return[4,q(!0)];case 1:return a.sent(),[4,ce()];case 2:return a.sent(),[4,Z(null)];case 3:return a.sent(),b(!1),g.trackEvent("smart_linking_generate_pressed",{is_full_content:j,selected_block:null!==(s=null==me?void 0:me.name)&&void 0!==s?s:"none",context:o}),[4,xe(j?"all":null==me?void 0:me.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;q(!1),g.trackEvent("smart_linking_generate_timeout",{is_full_content:j,selected_block:null!==(e=null==me?void 0:me.name)&&void 0!==e?e:"none",context:o}),ke(j?"all":null==me?void 0:me.clientId)}),18e4),t=R,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,_e(3)];case 6:return n=a.sent(),[4,(l=n,Fe(void 0,void 0,void 0,(function(){var e;return Ge(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!D.find((function(t){return t.uid===e.uid&&t.applied}))})),e=be.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=(l=oe(ye,l,{}).filter((function(e){return e.match}))).filter((function(e){if(D.some((function(t){return t.text===e.text&&t.offset===e.offset})))return!1;if(!e.match)return!1;var t=e.match.blockLinkPosition,n=t+e.text.length;return!D.some((function(r){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,Y(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),ve(!0),[3,15];case 8:return r=a.sent(),i=(0,p.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===O.ParselyAborted&&(i=(0,p.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ /* translators: %d: number of retry attempts, %s: attempt plural */ +(0,p.__)("Successfully added %s smart links.","wp-parsely"),v>0?v:C.length)}),(0,i.jsx)(De,{disabled:S,selectedBlock:null==me?void 0:me.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:Ve(Ve({},c.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e&&ie(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return Fe(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Ge(this,(function(a){switch(a.label){case 0:return[4,q(!0)];case 1:return a.sent(),[4,ce()];case 2:return a.sent(),[4,Z(null)];case 3:return a.sent(),b(!1),g.trackEvent("smart_linking_generate_pressed",{is_full_content:j,selected_block:null!==(s=null==me?void 0:me.name)&&void 0!==s?s:"none",context:o}),[4,xe(j?"all":null==me?void 0:me.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;q(!1),g.trackEvent("smart_linking_generate_timeout",{is_full_content:j,selected_block:null!==(e=null==me?void 0:me.name)&&void 0!==e?e:"none",context:o}),ke(j?"all":null==me?void 0:me.clientId)}),18e4),t=R,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,_e(3)];case 6:return n=a.sent(),[4,(l=n,Fe(void 0,void 0,void 0,(function(){var e;return Ge(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!D.some((function(t){return t.uid===e.uid&&t.applied}))})),e=be.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=(l=oe(ye,l,{}).filter((function(e){return e.match}))).filter((function(e){if(D.some((function(t){return t.text===e.text&&t.offset===e.offset})))return!1;if(!e.match)return!1;var t=e.match.blockLinkPosition,n=t+e.text.length;return!D.some((function(r){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,Y(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),ve(!0),[3,15];case 8:return r=a.sent(),i=(0,p.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===O.ParselyAborted&&(i=(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")),r.message=i),[4,Z(r)];case 9:return a.sent(),_("error",i,{type:"snackbar"}),[3,15];case 10:return[4,q(!1)];case 11:return a.sent(),[4,re(t)];case 12:return a.sent(),[4,se(!1)];case 13:return a.sent(),[4,ke(j?"all":null==me?void 0:me.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:S,disabled:S,children:B?(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"),M,3):S?(0,p.__)("Generating Smart Links…","wp-parsely"):(0,p.__)("Add Smart Links","wp-parsely")})}),V.length>0&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return Fe(void 0,void 0,void 0,(function(){var e;return Ge(this,(function(t){switch(t.label){case 0:return[4,pe()];case 1:return t.sent(),e=le(),[4,Y(e)];case 2:return t.sent(),ve(!0),[2]}}))}))},variant:"secondary",children:(0,p.__)("Review Smart Links","wp-parsely")})})]}),P&&(0,i.jsx)(Be,{isOpen:P,onAppliedLink:function(){y((function(e){return e+1}))},onClose:function(){b(!0),ve(!1)}})]})},Ue=function(){return Ue=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 it=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"),A(o)); /* translators: %s: metric description */return(0,i.jsxs)(nt,{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:[A(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 */ diff --git a/src/content-helper/editor-sidebar/smart-linking/component.tsx b/src/content-helper/editor-sidebar/smart-linking/component.tsx index 48fdb2743..2ec48d65f 100644 --- a/src/content-helper/editor-sidebar/smart-linking/component.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/component.tsx @@ -293,7 +293,7 @@ export const SmartLinkingPanel = ( { const processSmartLinks = async ( links: SmartLink[] ) => { // Exclude the links that have been applied already. links = links.filter( - ( link ) => ! smartLinks.find( ( sl ) => sl.uid === link.uid && sl.applied ) + ( link ) => ! smartLinks.some( ( sl ) => sl.uid === link.uid && sl.applied ) ); // Strip the protocol and trailing slashes from the post permalink. From c2a173d1f7b4b1aae76bf834b02f44c6344f2ddb Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Thu, 23 May 2024 14:18:38 +0300 Subject: [PATCH 37/44] Improve comments in some PHP files --- .../class-smart-linking-endpoint.php | 3 --- src/Models/class-base-model.php | 3 ++- src/Models/class-smart-link.php | 19 +++++++++++++++---- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/Endpoints/content-helper/class-smart-linking-endpoint.php b/src/Endpoints/content-helper/class-smart-linking-endpoint.php index 952e4badd..89ec10e21 100644 --- a/src/Endpoints/content-helper/class-smart-linking-endpoint.php +++ b/src/Endpoints/content-helper/class-smart-linking-endpoint.php @@ -31,7 +31,6 @@ class Smart_Linking_Endpoint extends Base_Endpoint { * The endpoint base path. * * @since 3.16.0 - * * @var string */ protected const ENDPOINT = '/smart-linking'; @@ -40,7 +39,6 @@ class Smart_Linking_Endpoint extends Base_Endpoint { * The post meta key for storing smart links. * * @since 3.16.0 - * * @var string */ protected const POST_META_KEY = '_parsely_smart_links'; @@ -49,7 +47,6 @@ class Smart_Linking_Endpoint extends Base_Endpoint { * The current post. * * @since 3.16.0 - * * @var WP_Post|null */ protected $current_post; diff --git a/src/Models/class-base-model.php b/src/Models/class-base-model.php index c2f4afee8..4b8301b92 100644 --- a/src/Models/class-base-model.php +++ b/src/Models/class-base-model.php @@ -11,7 +11,7 @@ namespace Parsely\Models; /** - * Base model class for all Parse.ly models + * Base model class for all Parse.ly models. * * @since 3.16.0 */ @@ -19,6 +19,7 @@ abstract class Base_Model { /** * The unique ID of the model. * + * @since 3.16.0 * @var string The unique ID of the model. */ public $uid; diff --git a/src/Models/class-smart-link.php b/src/Models/class-smart-link.php index b60fec45c..d55bf750f 100644 --- a/src/Models/class-smart-link.php +++ b/src/Models/class-smart-link.php @@ -1,6 +1,7 @@ Date: Thu, 23 May 2024 14:55:00 +0300 Subject: [PATCH 38/44] Smart Linking Provider: Improve comments --- src/content-helper/editor-sidebar/smart-linking/provider.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/content-helper/editor-sidebar/smart-linking/provider.ts b/src/content-helper/editor-sidebar/smart-linking/provider.ts index d8d64093f..e1e7faf81 100644 --- a/src/content-helper/editor-sidebar/smart-linking/provider.ts +++ b/src/content-helper/editor-sidebar/smart-linking/provider.ts @@ -42,8 +42,8 @@ export type SmartLinkMatch = { } /** - * Returns data from the `content-suggestions/suggest-linked-reference` WordPress REST API - * endpoint. + * Returns data from the `content-suggestions/suggest-linked-reference` + * WordPress REST API endpoint. * * @since 3.14.0 */ @@ -113,6 +113,8 @@ export class SmartLinkingProvider extends BaseProvider { /** * Get the post type of post by its URL. * + * @since 3.16.0 + * * @param {string} url The URL of the post. * * @return {Promise} The post type of the post. From 2e870bb5e29cacd4febef29f2dbb04e00bcbff4a Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Fri, 24 May 2024 09:14:30 +0300 Subject: [PATCH 39/44] Apply whitespace and comment improvements --- .../review-modal/component-suggestion.tsx | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx index e1abc447b..c405050c0 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx @@ -5,22 +5,22 @@ import { BlockInstance, cloneBlock, getBlockContent, getBlockType } from '@wordpress/blocks'; import { Button, - __experimentalDivider as Divider, Disabled, + __experimentalDivider as Divider, MenuItem, Tooltip, } from '@wordpress/components'; import { select as selectFn, useDispatch, useSelect } from '@wordpress/data'; import { useEffect, useMemo, useRef, useState } from '@wordpress/element'; import { __ } from '@wordpress/i18n'; -import { arrowLeft, arrowRight, check, closeSmall, Icon, page } from '@wordpress/icons'; +import { Icon, arrowLeft, arrowRight, check, closeSmall, page } from '@wordpress/icons'; /** * Internal dependencies */ +import { BlockEditorProvider, BlockList } from '@wordpress/block-editor'; import { GutenbergFunction } from '../../../../@types/gutenberg/types'; import { SmartLink, SmartLinkingProvider } from '../provider'; -import { BlockEditorProvider, BlockList } from '@wordpress/block-editor'; import { SmartLinkingStore } from '../store'; import { applyNodeToBlock, trimURLForDisplay } from '../utils'; @@ -45,7 +45,7 @@ type SuggestionBreadcrumbProps = { const SuggestionBreadcrumb = ( { link }: SuggestionBreadcrumbProps ): JSX.Element => { const blockId = link.match?.blockId; - // Fetch block details and parent IDs using the blockId + // Fetch block details and parent IDs using the blockId. const { block, parents } = useSelect( ( select ) => { const { getBlock, getBlockParents } = select( 'core/block-editor' ) as GutenbergFunction; @@ -111,7 +111,7 @@ type StylesProps = { * @param {StylesProps} props The component props. */ const Styles = ( { styles }: StylesProps ): JSX.Element => { - // Get onlt the theme and user styles. + // Get only the theme and user styles. const filteredStyles = styles .filter( ( style ) => { return ( @@ -141,7 +141,8 @@ type BlockPreviewProps = { } /** - * The BlockPreview component, which renders the block preview for the suggestion. + * The BlockPreview component, which renders the block preview for the + * suggestion. * * @since 3.16.0 * @@ -161,7 +162,9 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { /** * Runs when the block is rendered in the DOM. - * It will set the block element to be non-editable and highlight the link in the block. + * + * It will set the block element to be non-editable and highlight the link + * in the block. * * @since 3.16.0 */ @@ -189,7 +192,8 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { return; } - // Otherwise, if the link is applied, add a highlight class to the link element with the link uid + // Otherwise, if the link is applied, add a highlight class to the + // link element with the link UID. const blockContent: string = getBlockContent( blockInstance ); const doc = new DOMParser().parseFromString( blockContent, 'text/html' ); @@ -198,7 +202,9 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { return; } - const anchor = contentElement.querySelector( `a[data-smartlink="${ linkSuggestion.uid }"]` ); + const anchor = contentElement.querySelector( + `a[data-smartlink="${ linkSuggestion.uid }"]` + ); if ( anchor ) { anchor.classList.add( 'smart-linking-highlight' ); } @@ -216,7 +222,9 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { mutation.addedNodes.forEach( ( node ) => { if ( node instanceof HTMLElement ) { - const blockElement = document.querySelector( `.wp-parsely-preview-editor [data-block="${ clonedBlock.clientId }"]` ); + const blockElement = document.querySelector( + `.wp-parsely-preview-editor [data-block="${ clonedBlock.clientId }"]` + ); if ( blockElement ) { // Disable editing on the block element. @@ -271,7 +279,7 @@ const BlockPreview = ( { block, link }: BlockPreviewProps ) => { * @param {{link: SmartLink}} props The component props. */ const LinkDetails = ( { link }: { link: SmartLink } ): JSX.Element => { - // Get the post type by the permalink + // Get the post type by the permalink. const [ displayUrl, setDisplayUrl ] = useState( link.href ); const [ postType, setPostType ] = useState( link.post_type ); const linkRef = useRef( null ); @@ -282,6 +290,7 @@ const LinkDetails = ( { link }: { link: SmartLink } ): JSX.Element => { /** * Fetches the post type by the permalink using the SmartLinkingProvider. + * * If the post type is not found, it will default to 'External'. * * @since 3.16.0 @@ -310,7 +319,7 @@ const LinkDetails = ( { link }: { link: SmartLink } ): JSX.Element => { const calculateTrimSize = () => { if ( linkRef.current ) { const containerWidth = linkRef.current.offsetWidth; - const averageCharWidth = 8; // Estimate or adjust based on actual character width + const averageCharWidth = 8; // Estimate or adjust based on actual character width. const maxLength = Math.floor( containerWidth / averageCharWidth ); setDisplayUrl( trimURLForDisplay( link.href, maxLength ) ); } @@ -378,7 +387,7 @@ export const ReviewSuggestion = ( { } const blockId = link.match.blockId; - // Get the block + // Get the block. const block = selectFn( 'core/block-editor' ).getBlock( blockId ); const isApplied = link.applied; From 0df289938d81f75508b1e2c9c093ce901a04f9a9 Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Fri, 24 May 2024 09:36:40 +0300 Subject: [PATCH 40/44] Apply whitespace and comment improvements --- .../editor-sidebar/smart-linking/utils.ts | 90 ++++++++++++------- 1 file changed, 56 insertions(+), 34 deletions(-) diff --git a/src/content-helper/editor-sidebar/smart-linking/utils.ts b/src/content-helper/editor-sidebar/smart-linking/utils.ts index a1b95cd31..b8e84a2de 100644 --- a/src/content-helper/editor-sidebar/smart-linking/utils.ts +++ b/src/content-helper/editor-sidebar/smart-linking/utils.ts @@ -8,19 +8,21 @@ import { dispatch, select } from '@wordpress/data'; /** * Internal dependencies */ -import { SmartLink } from './provider'; import { escapeRegExp } from '../../common/utils/functions'; +import { SmartLink } from './provider'; import { SmartLinkingStore } from './store'; export { escapeRegExp } from '../../common/utils/functions'; /** - * Finds all text nodes in an element that contain a given search text and are not within an anchor tag. + * Finds all text nodes in an element that contain a given search text and are + * not within an anchor tag. + * * This is useful for finding text nodes that should be linked. * * @since 3.14.1 * - * @param {HTMLElement} element - The element to search within. - * @param {string} searchText - The text to search for. + * @param {HTMLElement} element The element to search within. + * @param {string} searchText The text to search for. * * @return {Node[]} The text nodes that match the search text and are not within an anchor tag. */ @@ -55,7 +57,7 @@ export function findTextNodesNotInAnchor( element: HTMLElement, searchText: stri * @since 3.16.0 * * @param {Text} textNode The text node to check. - * @param {string} smartLinkUID The smart link uid to check for. + * @param {string} smartLinkUID The smart link UID to check for. * * @return {boolean} Whether the smart link is present in the text node. */ @@ -70,7 +72,7 @@ function isLinkAtNode( textNode: Text, smartLinkUID: string ): boolean { /** * Checks if a node is inside a similar node to a reference node. * - * @since 3.15.0 + * @since 3.16.0 * * @param {Node} node The node to check. * @param {HTMLElement} referenceNode The reference node to compare against. @@ -92,7 +94,7 @@ function isInsideSimilarNode( node: Node, referenceNode: HTMLElement ): boolean /** * Finds all text nodes in an element that contain a given search text. * - * @since 3.15.0 + * @since 3.16.0 * * @param {Node} element The element to search within. * @param {string} searchText The text to search for. @@ -114,10 +116,12 @@ function findTextNodes( element: Node, searchText: string ): Node[] { } /** - * Applies an HTML node to a block's content, replacing the text of the link with the HTML node. + * Applies an HTML node to a block's content, replacing the text of the link + * with the HTML node. + * * This is useful for applying a link to a block's content. * - * @since 3.15.0 + * @since 3.16.0 * * @param {BlockInstance} block The block instance to apply the link to. * @param {SmartLink} link The link suggestion to apply. @@ -144,7 +148,8 @@ export function applyNodeToBlock( block: BlockInstance, link: SmartLink, htmlNod } if ( isInsideSimilarNode( node, htmlNode ) ) { - // Check if the node content contains the link text, and if so increase the occurrence count. + // Check if the node content contains the link text, and if so + // increase the occurrence count. if ( node.textContent?.includes( link.text ) ) { occurrenceCount++; } @@ -179,13 +184,14 @@ export function applyNodeToBlock( block: BlockInstance, link: SmartLink, htmlNod } } ); - // Update the block content with the new content + // Update the block content with the new content. dispatch( 'core/block-editor' ).updateBlockAttributes( block.clientId, { content: contentElement.innerHTML } ); return contentElement.innerHTML; } /** - * Sorts smart links based on their block position and link position within the block. + * Sorts smart links based on their block position and link position within the + * block. * * The applied links are sorted after the not applied links. * @@ -234,10 +240,13 @@ function flattenBlocks( blocks: BlockInstance[], flatList: BlockInstance[] = [] } /** - * Represents the counts of occurrences and applications of links within text content. + * Represents the counts of occurrences and applications of links within text + * content. * - * - `encountered`: The number of times a specific link text is encountered in the content. - * - `linked`: The number of times a link has been successfully applied for a specific link text. + * - `encountered`: The number of times a specific link text is encountered in + * the content. + * - `linked`: The number of times a link has been successfully applied for a + * specific link text. * * @since 3.14.1 * @since 3.16.0 Moved from `content-helper/editor-sidebar/smart-linking/component.tsx`. @@ -250,20 +259,23 @@ type LinkOccurrenceCounts = { }; /** - * Iterates through blocks of content to calculate the correct block and offset for each link suggestion. + * Iterates through blocks of content to calculate the correct block and offset + * for each link suggestion. * - * This function processes each block's content to identify and handle text nodes that match provided link suggestions. - * It avoids inserting links within existing anchor and respects the specified offset for each link to determine the - * correct block. + * This function processes each block's content to identify and handle text + * nodes that match provided link suggestions. It avoids inserting links within + * existing anchor and respects the specified offset for each link to determine + * the correct block. * - * Note: The function is recursive for blocks containing inner blocks, ensuring all nested content is processed. + * Note: The function is recursive for blocks containing inner blocks, ensuring + * all nested content is processed. * * @since 3.16.0 * * @param {Readonly[]} blocks The blocks of content where links should be applied. * @param {SmartLink[]} links An array of link suggestions to apply to the content. - * @param {LinkOccurrenceCounts} occurrenceCounts An object to keep track of the number of times each link text has - * been encountered and applied across all blocks. + * @param {LinkOccurrenceCounts} occurrenceCounts An object to keep track of the number of times each link + * text has been encountered and applied across all blocks. * @param {number} currentIndex The current index of the block being processed. * * @return {SmartLink[]} The array of link suggestions that have been successfully applied to the content. @@ -337,10 +349,12 @@ export function calculateSmartLinkingMatches( /** * Gets all smart links in the post content. * - * This function parses the post content to find all the smart links in the post content. Each smart link is - * identified by the `data-smartlink` attribute in the anchor tag. + * This function parses the post content to find all the smart links in the post + * content. Each smart link is identified by the `data-smartlink` attribute in + * the anchor tag. * - * After finding all the smart links, it calculates the correct block and offset for each link suggestion. + * After finding all the smart links, it calculates the correct block and offset + * for each link suggestion. * * @since 3.16.0 * @@ -395,8 +409,9 @@ export function getAllSmartLinksInPost(): SmartLink[] { /** * Gets the offset of a link in the post content. * - * This function calculates the offset of a link in the post content by counting the number of times the link text - * is encountered before the link in the post content. + * This function calculates the offset of a link in the post content by counting + * the number of times the link text is encountered before the link in the post + * content. * * @since 3.16.0 * @@ -446,10 +461,11 @@ type ValidateAndFixSmartLinksReturnType = { /** * Validates and fixes smart links in a specific content. * - * This function checks if the smart links in the store are still present in the post content. - * If a smart link is not found in the post content, it tries to find a link that matches the text, - * title and href of the smart link. - * And if the link is found, it restores the missing fields from the link (data-smartlink and title). + * This function checks if the smart links in the store are still present in the + * post content. If a smart link is not found in the post content, it tries to + * find a link that matches the text, title and href of the smart link. And if + * the link is found, it restores the missing fields from the link + * (data-smartlink and title). * * @since 3.16.0 * @@ -458,7 +474,10 @@ type ValidateAndFixSmartLinksReturnType = { * * @return {ValidateAndFixSmartLinksReturnType} The missing smart links and whether any fixes were made. */ -export async function validateAndFixSmartLinks( content: string, blockId: string|false = false ): Promise { +export async function validateAndFixSmartLinks( + content: string, + blockId: string|false = false +): Promise { // Get the post content and all the smart links from the store. let smartLinks = select( SmartLinkingStore ).getSmartLinks(); @@ -523,7 +542,9 @@ export async function validateAndFixSmartLinks( content: string, blockId: string // Update the block content with the new content. const paragraph = blockDoc.body.firstChild as HTMLElement; - dispatch( 'core/block-editor' ).updateBlockAttributes( block.clientId, { content: paragraph.innerHTML } ); + dispatch( 'core/block-editor' ).updateBlockAttributes( + block.clientId, { content: paragraph.innerHTML } + ); didAnyFixes = true; } @@ -584,7 +605,8 @@ export function trimURLForDisplay( url: string, maxLength: number ): string { // Remove protocol (http, https) and www. const strippedUrl = url.replace( /(^\w+:|^)\/\//, '' ).replace( /^www\./, '' ); - // If no maxLength is specified or the URL length is already less than maxLength, return the stripped URL. + // If no maxLength is specified or the URL length is already less than + // maxLength, return the stripped URL. if ( ! maxLength || strippedUrl.length <= maxLength ) { return strippedUrl; } From bfa96fb13a91356a5368b4d5325640a0190bf622 Mon Sep 17 00:00:00 2001 From: Alex Cicovic <23142906+acicovic@users.noreply.github.com> Date: Fri, 24 May 2024 10:19:39 +0300 Subject: [PATCH 41/44] Apply comment improvements --- src/content-helper/editor-sidebar/smart-linking/utils.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content-helper/editor-sidebar/smart-linking/utils.ts b/src/content-helper/editor-sidebar/smart-linking/utils.ts index b8e84a2de..1ee3ee8cd 100644 --- a/src/content-helper/editor-sidebar/smart-linking/utils.ts +++ b/src/content-helper/editor-sidebar/smart-linking/utils.ts @@ -562,7 +562,7 @@ export async function validateAndFixSmartLinksInPost(): Promise { const postContent = select( 'core/editor' ).getEditedPostContent(); const { missingSmartLinks, didAnyFixes } = await validateAndFixSmartLinks( postContent ); - // Remove any missing smart-links that are not in the store. + // Remove any missing smart links that are not in the store. missingSmartLinks.forEach( ( missingLink ) => { dispatch( SmartLinkingStore ).removeSmartLink( missingLink.uid ); } ); @@ -583,7 +583,7 @@ export async function validateAndFixSmartLinksInBlock( block: BlockInstance ): P const blockContent: string = getBlockContent( block ); const { missingSmartLinks, didAnyFixes } = await validateAndFixSmartLinks( blockContent, block.clientId ); - // Remove any missing smart-links that are not in the store. + // Remove any missing smart links that are not in the store. missingSmartLinks.forEach( ( missingLink ) => { dispatch( SmartLinkingStore ).removeSmartLink( missingLink.uid ); } ); From 017e1770ce2953288cf0cb7508d325508ed6290e Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 4 Jun 2024 10:15:21 +0100 Subject: [PATCH 42/44] Rebuild assets --- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.js | 40 +++++++++---------- .../excerpt-generator.asset.php | 2 +- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index b07d9d709..6b985e7ba 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-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url'), 'version' => '1fe19247ad31344aad81'); + 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' => 'c78390535175d02a3a1e'); diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index acd63a5e3..b41f29427 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,27 +1,27 @@ -!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 nn}});var e,t,r,i=n(848),s=window.wp.components,a=window.wp.data,o=window.wp.editPost,l=window.wp.element,c=window.wp.i18n,u=window.wp.primitives,p=(0,i.jsx)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(u.Path,{fillRule:"evenodd",d:"M11.25 5h1.5v15h-1.5V5zM6 10h1.5v10H6V10zm12 4h-1.5v6H18v-6z",clipRule:"evenodd"})}),d=window.wp.plugins,f=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}(),h=(f.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"})})}),g=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"})]})},y=function(){return y=Object.assign||function(e){for(var t,n=1,r=arguments.length;nhere.',"wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiError||s.code===A.ParselySuggestionsApiOpenAiUnavailable?s.message=(0,c.__)("The Parse.ly API returned an internal server error. Please retry with a different input, or try again later.","wp-parsely"):s.code===A.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,c.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiSchemaError?s.message=(0,c.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===A.ParselySuggestionsApiNoData?s.message=(0,c.__)("The Parse.ly API couldn't find any relevant data to fulfill the request. Please retry with a different input.","wp-parsely"):s.code===A.ParselySuggestionsApiOpenAiSchema?s.message=(0,c.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===A.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,c.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return G(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[A.PluginCredentialsNotSetMessageDetected,A.PluginSettingsSiteIdNotSet,A.PluginSettingsApiSecretNotSet].includes(this.code)?I(e):(this.code===A.FetchError&&(this.hint=this.Hint((0,c.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==A.ParselyApiForbidden&&this.code!==A.ParselySuggestionsApiNoAuthentication||(this.hint=this.Hint((0,c.__)("Please ensure that the Site ID and API Secret given in the plugin's settings are correct.","wp-parsely"))),this.code===A.HttpRequestFailed&&(this.hint=this.Hint((0,c.__)("The Parse.ly API cannot be reached. Please verify that you are online.","wp-parsely"))),(0,i.jsx)(R,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function z(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var U,$=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})]})]})},Z=function(){return Z=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&&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)){var e={maxLinksPerPost:p.SmartLinking.MaxLinks};H(e)}}),[H,p]);var X=(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]),J=X.allBlocks,ee=X.selectedBlock,ae=X.postContent,oe=X.postPermalink,le=function(e){return re(void 0,void 0,void 0,(function(){var t,n,r,i;return ie(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,$((n=b||!ee)?U.All:U.Selected)];case 2:return s.sent(),a=oe.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,te.getInstance().generateSmartLinks(ee&&!n?(0,V.getBlockContent)(ee):ae,k,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===A.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,q(!0)]):[3,8];case 5:return s.sent(),[4,W()];case 6:return s.sent(),[4,le(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[4,B(t)];case 10:return s.sent(),[2,t]}var a}))}))},ce=function(e,t,n,r){var i=oe.replace(/^https?:\/\//,"").replace(/\/+$/,"");t=t.filter((function(e){return!e.href.includes(i)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(e.href)),!1)})),e.forEach((function(e){var i=!1;if(e.innerBlocks&&e.innerBlocks.length)ce(e.innerBlocks,t,n,r);else if(e.originalContent){var s=(0,V.getBlockContent)(e),a=(new DOMParser).parseFromString(s,"text/html").body.firstChild;a&&a instanceof HTMLElement&&(t.forEach((function(e){var t=function(e,t){for(var n,r=document.createTreeWalker(e,NodeFilter.SHOW_TEXT,{acceptNode:function(n){var r;if(!n.textContent||!n.textContent.includes(t))return NodeFilter.FILTER_REJECT;for(var i=n.parentNode;i&&i!==e;){if("A"===i.nodeName&&!(null===(r=i.textContent)||void 0===r?void 0:r.includes(t)))return NodeFilter.FILTER_REJECT;i=i.parentNode}return NodeFilter.FILTER_ACCEPT}}),i=[];n=r.nextNode();)i.push(n);return i}(a,e.text),r="".concat(e.text,"#").concat(e.offset);n[r]||(n[r]={encountered:0,linked:0}),t.forEach((function(t){var s;if(t.textContent){var a=n[r];if(a.linked>=1)return;for(var o=new RegExp(z(e.text),"g"),l=void 0;null!==(l=o.exec(t.textContent));)if(a.encountered++,a.encountered===e.offset+1){var c=document.createElement("a");c.href=e.href,c.title=e.title,c.textContent=l[0];var u=document.createRange();if(u.setStart(t,l.index),u.setEnd(t,l.index+l[0].length),u.deleteContents(),u.insertNode(c),t.textContent&&l.index+l[0].length[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},he=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsx)("div",{className:"wp-parsely-smart-linking",children:(0,i.jsxs)(s.PanelRow,{className:t,children:[(0,i.jsxs)("div",{className:"smart-linking-text",children:[(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(D,{icon:F,size:18,className:"parsely-external-link-icon"})]})]}),P&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return I(null)},className:"wp-parsely-content-helper-error",children:P.Message()}),null!==j&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return B(null)},className:"wp-parsely-smart-linking-suggested-links",children:(0,c.sprintf)(/* translators: 1 - number of smart links generated */ /* translators: 1 - number of smart links generated */ -(0,c.__)("Successfully added %s smart links.","wp-parsely"),y>0?y:j.length)}),(0,i.jsx)(Q,{disabled:m,selectedBlock:null==ee?void 0:ee.clientId,onSettingChange:function(e,t){var n;h({SmartLinking:ne(ne({},p.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e&&Z(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return re(void 0,void 0,void 0,(function(){var e,t,n,r,i;return ie(this,(function(s){switch(s.label){case 0:return[4,R(!0)];case 1:return s.sent(),[4,B(null)];case 2:return s.sent(),[4,I(null)];case 3:return s.sent(),f.trackEvent("smart_linking_generate_pressed",{is_full_content:b,selected_block:null!==(i=null==ee?void 0:ee.name)&&void 0!==i?i:"none",context:o}),[4,pe(b?"all":null==ee?void 0:ee.clientId)];case 4:s.sent(),e=setTimeout((function(){var e;R(!1),f.trackEvent("smart_linking_generate_timeout",{is_full_content:b,selected_block:null!==(e=null==ee?void 0:ee.name)&&void 0!==e?e:"none",context:o}),de(b?"all":null==ee?void 0:ee.clientId)}),18e4),t=C,s.label=5;case 5:return s.trys.push([5,7,9,14]),[4,le(3)];case 6:return function(e){var t;f.trackEvent("smart_linking_applied",{is_full_content:b||!ee,selected_block:null!==(t=null==ee?void 0:ee.name)&&void 0!==t?t:"none",links_count:e.length,context:o});var n={},r=[];ce(ee&&!b?[ee]:J,e,n,r),ue(r);var i=Object.values(n).reduce((function(e,t){return e+t.linked}),0);v(i),w("success",/* translators: %d: number of smart links applied */ /* translators: %d: number of smart links applied */ -(0,c.sprintf)((0,c.__)("%s smart links successfully applied.","wp-parsely"),i),{type:"snackbar"})}(s.sent()),[3,14];case 7:return n=s.sent(),r=(0,c.__)("There was a problem applying smart links.","wp-parsely"),n.code&&n.code===A.ParselyAborted&&(r=(0,c.sprintf)(/* translators: %d: number of retry attempts, %s: attempt plural */ /* translators: %d: number of retry attempts, %s: attempt plural */ -(0,c.__)("The Smart Linking process was cancelled after %1$d %2$s.","wp-parsely"),n.numRetries,(0,c._n)("attempt","attempts",n.numRetries,"wp-parsely")),n.message=r),[4,I(n)];case 8:return s.sent(),w("error",r,{type:"snackbar"}),[3,14];case 9:return[4,R(!1)];case 10:return s.sent(),[4,$(t)];case 11:return s.sent(),[4,q(!1)];case 12:return s.sent(),[4,de(b?"all":null==ee?void 0:ee.clientId)];case 13:return s.sent(),clearTimeout(e),[7];case 14:return[2]}}))}))},variant:"primary",isBusy:m,disabled:m,children:E?(0,c.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,c.__)("Retrying… Attempt %1$d of %2$d","wp-parsely"),N,3):m?(0,c.__)("Adding Smart Links…","wp-parsely"):(0,c.__)("Add Smart Links","wp-parsely")})})]})})},oe=function(){return oe=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 me=function(e){var n=e.data,r=e.isLoading,a=(0,l.useState)(t.Views),o=a[0],u=a[1],p=(0,l.useState)(!1),d=p[0],f=p[1];r||delete n.referrers.types.totals;var h=function(e){switch(e){case"social":return(0,c.__)("Social","wp-parsely");case"search":return(0,c.__)("Search","wp-parsely");case"other":return(0,c.__)("Other","wp-parsely");case"internal":return(0,c.__)("Internal","wp-parsely");case"direct":return(0,c.__)("Direct","wp-parsely")}return e},g=(0,c.sprintf)((0,c.__)("By %s","wp-parsely"),C(o)); -/* translators: %s: metric description */return(0,i.jsxs)(we,{title:(0,c.__)("Categories","wp-parsely"),level:3,subtitle:g,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,c.__)("By: ","wp-parsely"),onChange:function(e){k(e,t)&&u(e)},children:Object.values(t).map((function(e){return(0,i.jsxs)("option",{value:e,disabled:"avg_engaged"===e,children:[C(e),"avg_engaged"===e&&(0,c.__)(" (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,c.sprintf)(/* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ /* translators: 1: Referrer type, 2: Percentage value, %%: Escaped percent sign */ -(0,c.__)("%1$s: %2$s%%","wp-parsely"),h(t),n.viewsPercentage);return(0,i.jsx)(s.Tooltip +!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 Vn}});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===N.ParselySuggestionsApiOpenAiError||s.code===N.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===N.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,p.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiSchemaError?s.message=(0,p.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===N.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===N.ParselySuggestionsApiOpenAiSchema?s.message=(0,p.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,p.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return z(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[N.PluginCredentialsNotSetMessageDetected,N.PluginSettingsSiteIdNotSet,N.PluginSettingsApiSecretNotSet].includes(this.code)?M(e):(this.code===N.FetchError&&(this.hint=this.Hint((0,p.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==N.ParselyApiForbidden&&this.code!==N.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===N.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)(B,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z,$=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,R.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},W=window.wp.editor,K=function(){return K=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var l=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,p.__)("NEW","wp-parsely"),(0,i.jsx)(he,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,p.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&l]},e.uid)}))]})})},ge=(0,i.jsxs)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,i.jsx)(d.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,i.jsx)(d.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})]}),ye=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})}),me=(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"})}),we=(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"})}),be=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})}),_e=window.wp.url,xe=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?c(!0):k().then((function(){return t()}))},L=function(e){c(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},E=function(){var e=g.indexOf(b)+1;g[e]&&_(g[e])},C=function(){var e=m().indexOf(b)-1;m()[e]&&_(m()[e])},A=function(){return Oe(void 0,void 0,void 0,(function(){var e,t;return Re(this,(function(n){switch(n.label){case 0:return b.match?(r(b),[4,(i=b.match.blockId,s=b,Oe(void 0,void 0,void 0,(function(){var e,t;return Re(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,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(b),g[t=e+1]?_(g[t]):_(g[0]),[2])}var i,s}))}))},N=function(){return Oe(void 0,void 0,void 0,(function(){var e,t;return Re(this,(function(n){switch(n.label){case 0:return e=g.indexOf(b),g[t=e+1]?_(g[t]):g[0]?_(g[0]):T(),[4,P(b.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Oe(void 0,void 0,void 0,(function(){var e,t,n,r;return Re(this,(function(i){switch(i.label){case 0:return b.match?(e=(0,a.select)("core/block-editor").getBlock(b.match.blockId))?(t=m(),n=t.indexOf(b),r=n-1,[4,j(e,b)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?_(t[r]):_(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:E,up:C,down:E,a:function(){b&&!b.applied&&A()},r:function(){b&&(b.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(ve,{links:g,activeLink:b,setSelectedLink:_}),(0,i.jsx)(Ne,{link:b,hasNext:m().indexOf(b)0,onNext:E,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(b.match){var e=(0,a.select)("core/block-editor").getBlock(b.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(b.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),l&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return L(!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 L(!1)},children:(0,p.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return L(!0)},children:(0,p.__)("Close","wp-parsely")})]})]})]})})),Be=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})]})]})},Me=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,l=e.onSettingChange,c=(0,u.useRef)(),d=(0,u.useState)(""),f=d[0],h=d[1],v=(0,u.useState)(!1),g=v[0],y=v[1],m=(0,u.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(X),n=t.getMaxLinks,r=t.isFullContent,i=t.wasAlreadyClicked,s=t.getApplyTo;return{maxLinks:n(),fullContent:r(),alreadyClicked:i(),applyTo:s()}}),[]),b=w.maxLinks,_=w.fullContent,x=w.alreadyClicked,k=w.applyTo,S=(0,a.useDispatch)(X),P=S.setMaxLinks,j=S.setFullContent,T=S.setAlreadyClicked,L=S.setApplyTo,E=null!==(t=k)&&void 0!==t?t:o?"selected":"all";return(0,u.useEffect)((function(){if(!r){var e=function(){r||(k===Z.Selected&&setTimeout((function(){h((0,p.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),L(null),m((function(e){return!e})))};o||k===Z.All||(g?setTimeout(e,500):e()),j(Z.All===E)}}),[g,k,E,r,o,L,j,h]),(0,u.useEffect)((function(){if(!r&&c.current&&E&&!x&&o){var e=c.current.querySelector('button[data-value="'.concat(E,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(L(E),T(!0))}}),[o,_,r,k]),(0,u.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:c,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:E,label:(0,p.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&_("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"),g),{type:"snackbar"}):y(0)}),[w]),(0,u.useEffect)((function(){if(!(Object.keys(O).length>0)){var e={maxLinksPerPost:c.SmartLinking.MaxLinks};ne(e)}}),[ne,c]);var ge=(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]),ye=ge.allBlocks,me=ge.selectedBlock,we=ge.postContent,be=ge.postPermalink,_e=function(e){return Ve(void 0,void 0,void 0,(function(){var t,n,r,i;return Fe(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,re((n=T||!me)?Z.All:Z.Selected)];case 2:return s.sent(),a=be.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,je.getInstance().generateSmartLinks(me&&!n?(0,F.getBlockContent)(me):we,A,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===N.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,se(!0)]):[3,8];case 5:return s.sent(),[4,le()];case 6:return s.sent(),[4,_e(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},xe=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Pe=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)($,{isDetectingEnabled:!P,onLinkRemove:function(e){!function(e){J(this,void 0,void 0,(function(){var t,n,r;return ee(this,(function(i){switch(i.label){case 0:return[4,ce((0,F.getBlockContent)(e),e.clientId)];case 1:return t=i.sent(),n=t.missingSmartLinks,r=t.didAnyFixes,n.forEach((function(e){(0,a.dispatch)(X).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)(G,{icon:H,size:18,className:"parsely-external-link-icon"})]})]}),E&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return K(null)},className:"wp-parsely-content-helper-error",children:E.Message()}),w&&g>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return b(!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"),g>0?g:C.length)}),(0,i.jsx)(Me,{disabled:S,selectedBlock:null==me?void 0:me.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:De(De({},c.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e&&ie(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return Ve(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Fe(this,(function(a){switch(a.label){case 0:return[4,q(!0)];case 1:return a.sent(),[4,he()];case 2:return a.sent(),[4,K(null)];case 3:return a.sent(),b(!1),v.trackEvent("smart_linking_generate_pressed",{is_full_content:T,selected_block:null!==(s=null==me?void 0:me.name)&&void 0!==s?s:"none",context:o}),[4,xe(T?"all":null==me?void 0:me.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;q(!1),v.trackEvent("smart_linking_generate_timeout",{is_full_content:T,selected_block:null!==(e=null==me?void 0:me.name)&&void 0!==e?e:"none",context:o}),ke(T?"all":null==me?void 0:me.clientId)}),18e4),t=I,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,_e(3)];case 6:return n=a.sent(),[4,(l=n,Ve(void 0,void 0,void 0,(function(){var e;return Fe(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!D.some((function(t){return t.uid===e.uid&&t.applied}))})),e=be.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=(l=ae(ye,l,{}).filter((function(e){return e.match}))).filter((function(e){if(D.some((function(t){return t.text===e.text&&t.offset===e.offset})))return!1;if(!e.match)return!1;var t=e.match.blockLinkPosition,n=t+e.text.length;return!D.some((function(r){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,Y(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),ve(!0),[3,15];case 8:return r=a.sent(),i=(0,p.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===N.ParselyAborted&&(i=(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")),r.message=i),[4,K(r)];case 9:return a.sent(),_("error",i,{type:"snackbar"}),[3,15];case 10:return[4,q(!1)];case 11:return a.sent(),[4,re(t)];case 12:return a.sent(),[4,se(!1)];case 13:return a.sent(),[4,ke(T?"all":null==me?void 0:me.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:S,disabled:S,children:B?(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"),M,3):S?(0,p.__)("Generating Smart Links…","wp-parsely"):(0,p.__)("Add Smart Links","wp-parsely")})}),V.length>0&&(0,i.jsx)("div",{className:"smart-linking-manage",children:(0,i.jsx)(s.Button,{onClick:function(){return Ve(void 0,void 0,void 0,(function(){var e;return Fe(this,(function(t){switch(t.label){case 0:return[4,ue()];case 1:return t.sent(),e=oe(),[4,Y(e)];case 2:return t.sent(),ve(!0),[2]}}))}))},variant:"secondary",children:(0,p.__)("Review Smart Links","wp-parsely")})})]}),P&&(0,i.jsx)(Ie,{isOpen:P,onAppliedLink:function(){y((function(e){return e+1}))},onClose:function(){b(!0),ve(!1)}})]})},ze=function(){return ze=Object.assign||function(e){for(var t,n=1,r=arguments.length;n=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 rt=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"),C(o)); +/* translators: %s: metric description */return(0,i.jsxs)(tt,{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:[C(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,c.sprintf)((0,c.__)("%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:_e(n.views)})]},t)}))})]})]})},be=(0,i.jsx)(u.SVG,{viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(u.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"})}),xe=(0,i.jsx)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(u.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"})}),Pe=(0,i.jsx)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(u.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"})}),Se=(0,i.jsx)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(u.Path,{d:"M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z"})}),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]1?[2,Promise.reject(new H((0,c.sprintf)(/* translators: URL of the published post */ /* translators: URL of the published post */ -(0,c.__)("Multiple results were returned for the post %s by the Parse.ly API.","wp-parsely"),t),A.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return Me(this,void 0,void 0,(function(){return Ve(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,X.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",Be(Be({},Re(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(J),Fe=function(){return Fe=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)(we,{title:(0,c.__)("Performance Stats","wp-parsely"),icon:ve,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(Ze,{onClose:t})},children:(0,i.jsx)("div",{className:"panel-settings",children:(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:w.PerformanceStats.Period,prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,c.__)("Period: ","wp-parsely")}),onChange:function(t){k(t,e)&&(_({PerformanceStats:Fe(Fe({},w.PerformanceStats),{Period:t})}),f.trackEvent("editor_sidebar_performance_period_changed",{period:t}))},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:T(e)},e)}))})})}),p?p.Message():(0,i.jsxs)(i.Fragment,{children:[$e(w,"overview")&&(0,i.jsx)(Le,{data:g,isLoading:a}),$e(w,"categories")&&(0,i.jsx)(me,{data:g,isLoading:a}),$e(w,"referrers")&&(0,i.jsx)(Oe,{data:g,isLoading:a})]}),window.wpParselyPostUrl&&(0,i.jsx)(s.Button,{className:"wp-parsely-view-post",variant:"primary",onClick:function(){f.trackEvent("editor_sidebar_view_post_pressed")},href:window.wpParselyPostUrl,rel:"noopener",target:"_blank",children:(0,c.__)("View this in Parse.ly","wp-parsely")})]})},We=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(M,{children:(0,i.jsx)(qe,{period:t})})})},Ye=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,c.__)("Tag","wp-parsely")}),a.categories.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Section,label:(0,c.__)("Section","wp-parsely")}),a.authors.length>=1&&(0,i.jsx)(s.__experimentalToggleGroupControlOption,{value:r.Author,label:(0,c.__)("Author","wp-parsely")})]})})},Qe=function(e){var t=e.filter,n=e.label,a=e.postData,o=Ye(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})})},Xe=function(e){var t=e.filter,n=e.postData,s=e.label,a=Ye(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)(Ke,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(Qe,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},Je=(0,i.jsx)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(u.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"})}),et=(0,i.jsx)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(u.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"})});function tt(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,c.__)("Number of Views","wp-parsely")}),s,_e(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,c.__)("Average Time","wp-parsely")}),r,n.avgEngaged]}):(0,i.jsx)("span",{className:"parsely-post-metric-data",children:"-"})}var nt,rt=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"})})},it=function(e){var t,n,r=e.metric,o=e.post,l=e.postContent,u=(0,a.useDispatch)("core/notices").createNotice,p=l&&(t=l,n=z(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,c.__)("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)(tt,{metric:r,post:o,viewsIcon:(0,i.jsx)(D,{icon:be}),avgEngagedIcon:(0,i.jsx)(s.Dashicon,{icon:"clock",size:24})})}),p&&(0,i.jsx)("div",{className:"related-post-linked",children:(0,i.jsx)(s.Tooltip,{text:(0,c.__)("This post is linked in the content","wp-parsely"),children:(0,i.jsx)(D,{icon:Je,size:24})})})]}),(0,i.jsx)(rt,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:et,iconSize:24,onClick:function(){navigator.clipboard.writeText(o.rawUrl).then((function(){u("success",(0,c.__)("URL copied to clipboard","wp-parsely"),{type:"snackbar"})}))},label:(0,c.__)("Copy URL to clipboard","wp-parsely")}),(0,i.jsx)(s.Button,{icon:(0,i.jsx)(g,{}),iconSize:18,href:o.dashUrl,target:"_blank",label:(0,c.__)("View in Parse.ly","wp-parsely")})]})]})})]})},st=window.wp.coreData,at=window.wp.editor,ot=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 __)}}(),lt=function(){return lt=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 U((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),N.ParselyApiReturnedTooManyResults))]:[2,n[0]]}}))}))},t.prototype.fetchReferrerDataFromWpEndpoint=function(e,t,n){return bt(this,void 0,void 0,(function(){return _t(this,(function(r){switch(r.label){case 0:return[4,this.fetch({path:(0,_e.addQueryArgs)("/wp-parsely/v1/referrers/post/detail",wt(wt({},yt(e)),{itm_source:this.itmSource,total_views:n,url:t}))})];case 1:return[2,r.sent()]}}))}))},t}(xe),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&&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)(tt,{title:(0,p.__)("Performance Stats","wp-parsely"),icon:et,dropdownChildren:function(e){var t=e.onClose;return(0,i.jsx)(Et,{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:kt(kt({},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:[Lt(m,"overview")&&(0,i.jsx)(vt,{data:h,isLoading:a}),Lt(m,"categories")&&(0,i.jsx)(rt,{data:h,isLoading:a}),Lt(m,"referrers")&&(0,i.jsx)(gt,{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")})]})},At=function(e){var t=e.period;return(0,i.jsx)(s.Panel,{children:(0,i.jsx)(V,{children:(0,i.jsx)(Ct,{period:t})})})},Nt=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")})]})})},Rt=function(e){var t=e.filter,n=e.label,a=e.postData,o=Nt(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})})},It=function(e){var t=e.filter,n=e.postData,s=e.label,a=Nt(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)(Ot,{filter:t,label:s,onFilterTypeChange:a.onFilterTypeChange,postData:n}),l()&&(0,i.jsx)(Rt,{filter:t,label:o()?void 0:s,onFilterValueChange:a.onFilterValueChange,postData:n})]}):null},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:"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"})}),Mt=(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"})});function Dt(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,nt(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 Vt,Ft=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"})})},Gt=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=q(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)(Dt,{metric:r,post:o,viewsIcon:(0,i.jsx)(G,{icon:it}),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)(G,{icon:Bt,size:24})})})]}),(0,i.jsx)(Ft,{}),(0,i.jsxs)("div",{children:[(0,i.jsx)(s.Button,{icon:Mt,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")})]})]})})]})},Ht=window.wp.coreData,zt=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 __)}}(),Ut=function(){return Ut=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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),w=v.authors,_=v.categories,m=v.tags,b=v.isReady;(0,l.useEffect)((function(){if(b){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})):[]};y({authors:e(w),categories:e(_),tags:e(m)})}}),[w,_,m,b]);var x=(0,l.useState)(!0),P=x[0],j=x[1],E=(0,l.useState)(),A=E[0],N=E[1],O=(0,l.useState)(),R=O[0],I=O[1],B=(0,l.useState)([]),M=B[0],V=B[1],D=(0,l.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=D[0],G=D[1],H=(0,l.useState)(void 0),z=H[0],U=H[1],$=(0,L.useDebounce)(U,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;$(t())}),[$]);var Z=function(e,t){u({RelatedPosts:dt(dt({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,l.useEffect)((function(){var e,t,n=function(e){return ft(void 0,void 0,void 0,(function(){return ht(this,(function(t){return pt.getInstance().getRelatedPosts(p,d,F).then((function(e){V(e.posts),I(e.message),j(!1)})).catch((function(t){return ft(void 0,void 0,void 0,(function(){return ht(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:j(!1),N(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===g.authors.length,c=0===g.tags.length,u=0===g.categories.length,f=i&&!g.authors.includes(F.value),h=s&&!g.tags.includes(F.value),y=a&&!g.categories.includes(F.value);return j(!0),o||s&&c||a&&u||i&&l?Object.values(g).every((function(e){return 0===e.length}))||G((e="",t=r.Unavailable,g.tags.length>=1?(t=r.Tag,e=g.tags[0]):g.categories.length>=1?(t=r.Section,e=g.categories[0]):g.authors.length>=1&&(t=r.Author,e=g.authors[0]),{type:t,value:e})):h?G({type:r.Tag,value:g.tags[0]}):y?G({type:r.Section,value:g.categories[0]}):f?G({type:r.Author,value:g.authors[0]}):n(1),function(){j(!1),V([]),I(""),N(void 0)}}),[p,d,F,g]),0===g.authors.length&&0===g.categories.length&&0===g.tags.length&&b?(0,i.jsx)("div",{className:"wp-parsely-related-posts",children:(0,i.jsx)("div",{className:"related-posts-body",children:(0,c.__)("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,c.__)("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;k(n=e,t)&&(u({RelatedPosts:dt(dt({},o.RelatedPosts),{Metric:n})}),f.trackEvent("related_posts_metric_changed",{metric:n}))},prefix:(0,i.jsx)(s.__experimentalInputControlPrefixWrapper,{children:(0,c.__)("Metric: ","wp-parsely")}),value:d,children:Object.values(t).map((function(e){return(0,i.jsx)("option",{value:e,children:C(e)},e)}))}),(0,i.jsx)(s.SelectControl,{size:"__unstable-large",value:p,prefix:(0,i.jsxs)(s.__experimentalInputControlPrefixWrapper,{children:[(0,c.__)("Period: ","wp-parsely")," "]}),onChange:function(t){return function(t){k(t,e)&&(u({RelatedPosts:dt(dt({},o.RelatedPosts),{Period:t})}),f.trackEvent("related_posts_period_changed",{period:t}))}(t)},children:Object.values(e).map((function(e){return(0,i.jsx)("option",{value:e,children:T(e)},e)}))})]}),(0,i.jsx)(Xe,{label:(0,c.__)("Filter by","wp-parsely"),filter:F,onFilterTypeChange:function(e){if(k(e,r)){var t="",n=e;r.Tag===n&&(t=g.tags[0]),r.Section===n&&(t=g.categories[0]),r.Author===n&&(t=g.authors[0]),""!==t&&(Z(n,t),G({type:n,value:t}),f.trackEvent("related_posts_filter_type_changed",{filter_type:n}))}},onFilterValueChange:function(e){"string"==typeof e&&(Z(F.type,e),G(dt(dt({},F),{value:e})))},postData:g}),(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===F.type?(0,c.sprintf)(/* translators: 1: tag name, 2: period */ /* translators: 1: tag name, 2: period */ -(0,c.__)("Top related posts with the “%1$s” tag in the %2$s.","wp-parsely"),F.value,T(p,!0)):r.Section===F.type?(0,c.sprintf)(/* translators: 1: section name, 2: period */ /* translators: 1: section name, 2: period */ -(0,c.__)("Top related posts in the “%1$s” section in the %2$s.","wp-parsely"),F.value,T(p,!0)):r.Author===F.type?(0,c.sprintf)(/* translators: 1: author name, 2: period */ /* translators: 1: author name, 2: period */ -(0,c.__)("Top related posts by %1$s in the %2$s.","wp-parsely"),F.value,T(p,!0)):null!=R?R:""})}),A&&A.Message(),P&&(0,i.jsx)("div",{className:"related-posts-loading-message","data-testid":"parsely-related-posts-loading-message",children:(0,c.__)("Loading…","wp-parsely")}),!P&&!A&&0===M.length&&(0,i.jsx)("div",{className:"related-posts-empty","data-testid":"parsely-related-posts-empty",children:(0,c.__)("No related posts found.","wp-parsely")}),!P&&M.length>0&&(0,i.jsx)("div",{className:"related-posts-list",children:M.map((function(e){return(0,i.jsx)(it,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},yt=(0,i.jsx)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(u.Path,{d:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})}),vt=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"})})},wt={journalist:{label:(0,c.__)("Journalist","wp-parsely")},editorialWriter:{label:(0,c.__)("Editorial Writer","wp-parsely")},investigativeReporter:{label:(0,c.__)("Investigative Reporter","wp-parsely")},techAnalyst:{label:(0,c.__)("Tech Analyst","wp-parsely")},businessAnalyst:{label:(0,c.__)("Business Analyst","wp-parsely")},culturalCommentator:{label:(0,c.__)("Cultural Commentator","wp-parsely")},scienceCorrespondent:{label:(0,c.__)("Science Correspondent","wp-parsely")},politicalAnalyst:{label:(0,c.__)("Political Analyst","wp-parsely")},healthWellnessAdvocate:{label:(0,c.__)("Health and Wellness Advocate","wp-parsely")},environmentalJournalist:{label:(0,c.__)("Environmental Journalist","wp-parsely")},custom:{label:(0,c.__)("Custom Persona","wp-parsely"),icon:yt}},_t=Object.keys(wt),mt=function(e){return"custom"===e||""===e?wt.custom.label:bt(e)?e:wt[e].label},bt=function(e){return!_t.includes(e)||"custom"===e},xt=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(0,L.useDebounce)(n,500);return(0,i.jsx)("div",{className:"parsely-persona-selector-custom",children:(0,i.jsx)(s.TextControl,{value:a||t,placeholder:(0,c.__)("Enter a custom persona…","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},Pt=function(e){var t=e.persona,n=e.value,r=void 0===n?(0,c.__)("Select a persona…","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Persona","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:bt(t)?wt.custom.label:r}),(0,i.jsx)(vt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Persona","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:_t.map((function(e){if(!h&&"custom"===e)return null;var r=wt[e],a=e===t||bt(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(D,{icon:r.icon}),r.label]},e)}))})})}}),h&&bt(t)&&(0,i.jsx)(xt,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},St={neutral:{label:(0,c.__)("Neutral","wp-parsely")},formal:{label:(0,c.__)("Formal","wp-parsely")},humorous:{label:(0,c.__)("Humorous","wp-parsely")},confident:{label:(0,c.__)("Confident","wp-parsely")},provocative:{label:(0,c.__)("Provocative","wp-parsely")},serious:{label:(0,c.__)("Serious","wp-parsely")},inspirational:{label:(0,c.__)("Inspirational","wp-parsely")},skeptical:{label:(0,c.__)("Skeptical","wp-parsely")},conversational:{label:(0,c.__)("Conversational","wp-parsely")},analytical:{label:(0,c.__)("Analytical","wp-parsely")},custom:{label:(0,c.__)("Custom Tone","wp-parsely"),icon:yt}},jt=Object.keys(St),kt=function(e){return"custom"===e||""===e?St.custom.label:Tt(e)?e:St[e].label},Tt=function(e){return!jt.includes(e)||"custom"===e},Ct=function(e){var t=e.value,n=e.onChange,r=(0,l.useState)(""),a=r[0],o=r[1],u=(0,L.useDebounce)(n,500);return(0,i.jsx)("div",{className:"parsely-tone-selector-custom",children:(0,i.jsx)(s.TextControl,{value:a||t,placeholder:(0,c.__)("Enter a custom tone","wp-parsely"),onChange:function(e){if(""===e)return n(""),void o("");e.length>32&&(e=e.slice(0,32)),u(e),o(e)}})})},Et=function(e){var t=e.tone,n=e.value,r=void 0===n?(0,c.__)("Select a tone","wp-parsely"):n,a=e.label,o=void 0===a?(0,c.__)("Tone","wp-parsely"):a,l=e.onChange,u=e.onDropdownChange,p=e.disabled,d=void 0!==p&&p,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,c.__)("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:Tt(t)?St.custom.label:r}),(0,i.jsx)(vt,{})]})},children:function(e){var n=e.onClose;return(0,i.jsx)(s.MenuGroup,{label:(0,c.__)("Select a tone","wp-parsely"),children:(0,i.jsx)(i.Fragment,{children:jt.map((function(e){if(!h&&"custom"===e)return null;var r=St[e],a=e===t||Tt(t)&&"custom"===e;return(0,i.jsxs)(s.MenuItem,{isSelected:a,className:a?"is-selected":"",role:"menuitemradio",onClick:function(){null==u||u(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)(D,{icon:r.icon}),r.label]},e)}))})})}}),h&&Tt(t)&&(0,i.jsx)(Ct,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},At=(0,i.jsx)(u.SVG,{width:"24",height:"24",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:(0,i.jsx)(u.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"})}),Nt=(0,i.jsx)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(u.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"})}),Lt=(0,i.jsx)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(u.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"})}),Ot=(0,i.jsx)(u.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(u.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"})}),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&&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,l.createInterpolateElement)( +message:(0,p.sprintf)((0,p.__)('by author "%1$s"',"wp-parsely"),n.value)};throw new U((0,p.__)("No valid filter type has been specified.","wp-parsely"),N.CannotFormulateApiQuery)},t}(xe),Wt=function(){return Wt=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&&u.every(Number.isInteger)?null!==(n=l("taxonomy","category",{include:u,context:"view"}))&&void 0!==n?n:void 0:null,tags:a=Array.isArray(p)&&p.length>0&&p.every(Number.isInteger)?null!==(r=l("taxonomy","post_tag",{include:p,context:"view"}))&&void 0!==r?r:void 0:null,isReady:void 0!==i&&void 0!==s&&void 0!==a}}),[]);return{authors:e.authors,categories:e.categories,tags:e.tags,isReady:e.isReady}}(),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],A=P[1],N=(0,u.useState)(),O=N[0],I=N[1],B=(0,u.useState)([]),M=B[0],D=B[1],V=(0,u.useState)({type:o.RelatedPosts.FilterBy,value:o.RelatedPosts.FilterValue}),F=V[0],G=V[1],H=(0,u.useState)(void 0),z=H[0],U=H[1],q=(0,R.useDebounce)(U,1e3);(0,a.useSelect)((function(e){var t=e("core/editor").getEditedPostContent;q(t())}),[q]);var Z=function(e,t){l({RelatedPosts:Wt(Wt({},o.RelatedPosts),{FilterBy:e,FilterValue:t})})};return(0,u.useEffect)((function(){var e,t,n=function(e){return Kt(void 0,void 0,void 0,(function(){return Yt(this,(function(t){return $t.getInstance().getRelatedPosts(c,d,F).then((function(e){D(e.posts),I(e.message),S(!1)})).catch((function(t){return Kt(void 0,void 0,void 0,(function(){return Yt(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),A(t),r.label=4;case 4:return[2]}}))}))})),[2]}))}))},i=r.Author===F.type,s=r.Tag===F.type,a=r.Section===F.type,o=r.Unavailable===F.type,l=0===h.authors.length,u=0===h.tags.length,p=0===h.categories.length,f=i&&!h.authors.includes(F.value),v=s&&!h.tags.includes(F.value),g=a&&!h.categories.includes(F.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(""),A(void 0)}}),[c,d,F,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:Wt(Wt({},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:C(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:Wt(Wt({},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)(It,{label:(0,p.__)("Filter by","wp-parsely"),filter:F,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(F.type,e),G(Wt(Wt({},F),{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===F.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"),F.value,E(c,!0)):r.Section===F.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"),F.value,E(c,!0)):r.Author===F.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"),F.value,E(c,!0)):null!=O?O:""})}),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)(Gt,{metric:d,post:e,postContent:z},e.id)}))})]})]})]})},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:"m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"})}),Jt=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"})})},en={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:Xt}},tn=Object.keys(en),nn=function(e){return"custom"===e||""===e?en.custom.label:rn(e)?e:en[e].label},rn=function(e){return!tn.includes(e)||"custom"===e},sn=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,R.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)}})})},an=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:rn(t)?en.custom.label:r}),(0,i.jsx)(Jt,{})]})},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:tn.map((function(e){if(!h&&"custom"===e)return null;var r=en[e],a=e===t||rn(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)(G,{icon:r.icon}),r.label]},e)}))})})}}),h&&rn(t)&&(0,i.jsx)(sn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},on={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:Xt}},ln=Object.keys(on),cn=function(e){return"custom"===e||""===e?on.custom.label:un(e)?e:on[e].label},un=function(e){return!ln.includes(e)||"custom"===e},pn=function(e){var t=e.value,n=e.onChange,r=(0,u.useState)(""),a=r[0],o=r[1],l=(0,R.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)}})})},dn=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:un(t)?on.custom.label:r}),(0,i.jsx)(Jt,{})]})},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:ln.map((function(e){if(!h&&"custom"===e)return null;var r=on[e],a=e===t||un(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)(G,{icon:r.icon}),r.label]},e)}))})})}}),h&&un(t)&&(0,i.jsx)(pn,{onChange:function(e){l(""!==e?e:"custom")},value:"custom"===t?"":t})]})},fn=(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"})}),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:"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"})}),vn=(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"})}),gn=(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"})}),yn=function(){return yn=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,c.__)("We've generated a few titles based on the content of your post, written as a .","wp-parsely"),{tone:(0,i.jsx)("strong",{children:kt(d)}),persona:(0,i.jsx)("strong",{children:mt(y)})})}):(0,c.__)("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,c.__)("Learn more about Parse.ly AI","wp-parsely"),(0,i.jsx)(D,{icon:F,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==j&&(0,i.jsx)(Ht,{title:j,type:nt.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(zt,{pinnedTitles:b,isOpen:!0}),m.length>0&&(0,i.jsx)(Zt,{suggestions:m,isOpen:!0,isLoading:_})]}),(0,i.jsx)(Ut,{isLoading:_,onPersonaChange:function(e){L("Persona",e),v(e)},onSettingChange:L,onToneChange:function(e){L("Tone",e),h(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:_,disabled:_||"custom"===d||"custom"===y,onClick:function(){return Kt(void 0,void 0,void 0,(function(){return Qt(this,(function(e){switch(e.label){case 0:return u(void 0),!1!==_?[3,2]:(f.trackEvent("title_suggestions_generate_pressed",{request_more:m.length>0,total_titles:m.length,total_pinned:m.filter((function(e){return e.isPinned})).length,tone:d,persona:y}),[4,(t=nt.PostTitle,n=O,r=d,i=y,Kt(void 0,void 0,void 0,(function(){var e,s,a;return Qt(this,(function(o){switch(o.label){case 0:return[4,C(!0)];case 1:o.sent(),e=Wt.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(),u(a),T(t,[]),[3,6];case 6:return[4,C(!1)];case 7:return o.sent(),[2]}}))})))]);case 1:e.sent(),e.label=2;case 2:return[2]}var t,n,r,i}))}))},children:[_&&(0,c.__)("Generating Titles…","wp-parsely"),!_&&x.length>0&&(0,c.__)("Generate More","wp-parsely"),!_&&0===x.length&&(0,c.__)("Generate Titles","wp-parsely")]})})]})})},Jt=function(){return Jt=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:cn(d)}),persona:(0,i.jsx)("strong",{children:nn(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)(G,{icon:H,size:18,className:"parsely-external-link-icon"})]})]}),o&&(0,i.jsx)(s.Notice,{status:"info",className:"wp-parsely-content-helper-error",children:o.Message()}),void 0!==S&&(0,i.jsx)(jn,{title:S,type:Vt.PostTitle,isOriginal:!0}),00&&(0,i.jsx)(Tn,{pinnedTitles:_,isOpen:!0}),b.length>0&&(0,i.jsx)(En,{suggestions:b,isOpen:!0,isLoading:w})]}),(0,i.jsx)(Ln,{isLoading:w,onPersonaChange:function(e){N("Persona",e),y(e)},onSettingChange:N,onToneChange:function(e){N("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 On(void 0,void 0,void 0,(function(){return Rn(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=Vt.PostTitle,n=O,r=d,i=g,On(void 0,void 0,void 0,(function(){var e,s,a;return Rn(this,(function(o){switch(o.label){case 0:return[4,L(!0)];case 1:o.sent(),e=An.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")]})})]})})},Bn=function(){return Bn=Object.assign||function(e){for(var t,n=1,r=arguments.length;n array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => 'a7b252bfafae3617d0bb'); + array('react', 'wp-api-fetch', 'wp-components', 'wp-data', 'wp-edit-post', 'wp-editor', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-plugins', 'wp-primitives', 'wp-url', 'wp-wordcount'), 'version' => '9c0c7a418d3626c4c8a7'); From 2a9f29ec9a1b5c982875ae8cfabc27bbe626db2e Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Tue, 4 Jun 2024 10:47:38 +0100 Subject: [PATCH 43/44] Apply code review suggestions from @acicovic --- build/content-helper/editor-sidebar-rtl.css | 2 +- build/content-helper/editor-sidebar.asset.php | 2 +- build/content-helper/editor-sidebar.css | 2 +- build/content-helper/editor-sidebar.js | 2 +- .../smart-linking/component-link-monitor.tsx | 1 - .../review-modal/component-suggestion.tsx | 4 ++-- .../smart-linking/smart-linking.scss | 14 +++++++------- .../editor-sidebar/smart-linking/store.ts | 2 +- .../editor-sidebar/smart-linking/utils.ts | 13 ++++++++++++- 9 files changed, 26 insertions(+), 16 deletions(-) diff --git a/build/content-helper/editor-sidebar-rtl.css b/build/content-helper/editor-sidebar-rtl.css index d04059502..ef0fb5afd 100644 --- a/build/content-helper/editor-sidebar-rtl.css +++ b/build/content-helper/editor-sidebar-rtl.css @@ -1,4 +1,4 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;right:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 0 0 var(--grid-unit-15);order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate,.wp-parsely-smart-linking .smart-linking-manage{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button,.wp-parsely-smart-linking .smart-linking-manage button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)}.wp-parsely-smart-linking-review-modal{align-items:flex-start;display:flex;flex-direction:column;width:47.875rem}.wp-parsely-smart-linking-review-modal .smart-linking-modal-body{align-self:stretch;display:flex;flex-direction:row;gap:var(--grid-unit-30)}.wp-parsely-smart-linking-review-modal .wp-parsely-link-suggestion-link-details{height:auto;margin-bottom:var(--grid-unit-20);text-align:right}.wp-parsely-smart-linking-review-modal .wp-parsely-link-suggestion-link-details .components-menu-item__item{display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);max-height:25rem;min-width:13.75rem;overflow-y:auto;padding:3px}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header{align-items:center;align-self:stretch;color:var(--sidebar-black);display:flex;font-size:11px;font-style:normal;font-weight:600;gap:6px;line-height:var(--grid-unit-20);margin-bottom:var(--grid-unit-15);text-transform:uppercase}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header>span{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button{align-items:center;display:flex;justify-content:space-between;width:13.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button:focus{box-shadow:none;outline:none}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-label{align-items:center;color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));display:flex;padding-right:var(--grid-unit-10);white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected{background-color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected .smart-linking-menu-label{color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__item{padding-left:0;width:100%}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-item{display:inline;flex-grow:1;overflow:hidden;text-align:right;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion{align-items:flex-start;align-self:stretch;display:flex;flex:1;flex-direction:column;gap:16px;max-width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs{font-size:.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-separator{margin:0 var(--grid-unit-5)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-block{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block{color:var(--sidebar-black)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block .breadcrumbs-current-block-name{margin-right:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .components-divider{border-color:#ccc;height:1px;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls{align-items:center;align-self:stretch;display:flex;flex-shrink:0;justify-content:space-between;margin:0 var(--grid-unit-20);-webkit-user-select:none;-moz-user-select:none;user-select:none;width:452px}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .reviews-controls-middle{align-items:center;display:flex;flex:1 0 0;gap:var(--grid-unit-20,16px);justify-content:center}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-next,.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-previous{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-reject{background:var(--Gutenberg-White,#fff);border-radius:2px;box-shadow:inset 0 0 0 1px var(--Gutenberg-Alert-Red,#cc1818);color:var(--Gutenberg-Alert-Red,#cc1818)}.wp-parsely-smart-linking-close-dialog{align-items:flex-start;display:flex;flex-direction:column;width:24rem}.wp-parsely-smart-linking-close-dialog .smart-linking-close-dialog-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;padding-top:var(--grid-unit-30)}.wp-parsely-preview-editor.editor-styles-wrapper{font-size:var(--font-size--medium);padding-bottom:0}.wp-parsely-preview-editor p[role=document]{margin:0}.wp-parsely-preview-editor .smart-linking-highlight{background:hsla(var(--parsely-green-components),.5);border-radius:2px;color:var(--sidebar-black);mix-blend-mode:multiply;text-decoration-line:underline} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;right:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 0 0 var(--grid-unit-15);order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate,.wp-parsely-smart-linking .smart-linking-manage{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button,.wp-parsely-smart-linking .smart-linking-manage button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)}.wp-parsely-smart-linking-review-modal{align-items:flex-start;display:flex;flex-direction:column;width:47.875rem}.wp-parsely-smart-linking-review-modal .smart-linking-modal-body{align-self:stretch;display:flex;flex-direction:row;gap:var(--grid-unit-30)}.wp-parsely-smart-linking-review-modal .wp-parsely-link-suggestion-link-details{height:auto;margin-bottom:var(--grid-unit-20);text-align:right}.wp-parsely-smart-linking-review-modal .wp-parsely-link-suggestion-link-details .components-menu-item__item{display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);max-height:25rem;min-width:13.75rem;overflow-y:auto;padding:.1875rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header{align-items:center;align-self:stretch;color:var(--sidebar-black);display:flex;font-size:.6875rem;font-style:normal;font-weight:600;gap:.375rem;line-height:var(--grid-unit-20);margin-bottom:var(--grid-unit-15);text-transform:uppercase}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header>span{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button{align-items:center;display:flex;justify-content:space-between;width:13.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button:focus{box-shadow:none;outline:none}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-label{align-items:center;color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));display:flex;padding-right:var(--grid-unit-10);white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected{background-color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected .smart-linking-menu-label{color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__item{padding-left:0;width:100%}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-item{display:inline;flex-grow:1;overflow:hidden;text-align:right;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion{align-items:flex-start;align-self:stretch;display:flex;flex:1;flex-direction:column;gap:1rem;max-width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs{font-size:.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-separator{margin:0 var(--grid-unit-5)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-block{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block{color:var(--sidebar-black)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block .breadcrumbs-current-block-name{margin-right:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .components-divider{border-color:#ccc;height:1px;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls{align-items:center;align-self:stretch;display:flex;flex-shrink:0;justify-content:space-between;margin:0 var(--grid-unit-20);-webkit-user-select:none;-moz-user-select:none;user-select:none;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .reviews-controls-middle{align-items:center;display:flex;flex:1 0 0;gap:var(--grid-unit-20);justify-content:center}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-next,.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-previous{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-reject{background:var(--Gutenberg-White,#fff);border-radius:2px;box-shadow:inset 0 0 0 1px var(--Gutenberg-Alert-Red,#cc1818);color:var(--Gutenberg-Alert-Red,#cc1818)}.wp-parsely-smart-linking-close-dialog{align-items:flex-start;display:flex;flex-direction:column;width:24rem}.wp-parsely-smart-linking-close-dialog .smart-linking-close-dialog-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;padding-top:var(--grid-unit-30)}.wp-parsely-preview-editor.editor-styles-wrapper{font-size:var(--font-size--medium);padding-bottom:0}.wp-parsely-preview-editor p[role=document]{margin:0}.wp-parsely-preview-editor .smart-linking-highlight{background:hsla(var(--parsely-green-components),.5);border-radius:2px;color:var(--sidebar-black);mix-blend-mode:multiply;text-decoration-line:underline} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-performance-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}.wp-parsely-content-helper .wp-parsely-performance-panel .content-helper-error-message{margin:0!important}.wp-parsely-content-helper .wp-parsely-performance-panel .components-button.wp-parsely-view-post{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .panel-body{width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.5rem;padding:.375rem 0 1rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header{align-items:center;display:flex;gap:.375rem;height:1rem;margin-bottom:0;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2{margin-bottom:.9375rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2 h2{margin-bottom:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-3 h3{font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:1rem;margin-bottom:0;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-subtitle{align-items:center;align-self:stretch;color:var(--Gutenberg-Gray-700,#757575);display:flex;flex:1 0 0;font-size:var(--font-size--smaller);font-style:normal;font-weight:600;gap:.375rem;height:1rem;line-height:1rem;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .components-heading{display:block;font-weight:500;line-height:normal;margin:0}.wp-parsely-content-helper .wp-parsely-performance-panel .components-dropdown-menu{line-height:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points{align-content:flex-start;align-items:flex-start;align-self:stretch;display:flex;flex-wrap:wrap;gap:1rem var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point{align-items:center;background:var(--sidebar-white);border-radius:.25rem;display:flex;flex:1 0 0;flex-direction:column;gap:var(--grid-unit-5);justify-content:center;min-width:100px;padding:var(--grid-unit-20) var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point svg{align-items:flex-start;border-radius:.125rem;display:flex}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-title{align-self:stretch;color:var(--sidebar-black);font-size:.75rem;font-style:normal;font-weight:400;line-height:1rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value{align-self:stretch;color:var(--sidebar-black);font-size:1.25rem;font-style:normal;font-weight:590;line-height:1.75rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value.is-small{font-size:var(--font-size--medium)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar{align-items:flex-start;align-self:stretch;display:flex;height:1rem;margin:1rem 0;position:relative}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill{--radius:2px;align-self:stretch;position:relative;transition:filter .1s ease,transform .1s ease}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:hover{filter:opacity(1)!important;transform:scaleX(1) scaleY(1)!important}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:first-child{border-radius:0 var(--radius) var(--radius) 0}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:last-child{border-radius:var(--radius) 0 0 var(--radius)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar:hover .bar-fill{filter:opacity(.5);transform:scaleX(1) scaleY(.7)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label{align-items:center;align-self:stretch;display:flex;gap:.5rem;justify-content:center}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color{align-items:center;border-radius:.09375rem;display:flex;flex-direction:column;gap:.625rem;height:.625rem;justify-content:center;width:.1875rem}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1 0 0;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-value{color:var(--sidebar-black);font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;text-align:left}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:1rem 0}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-10);justify-content:space-between}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar{display:flex;flex:1;flex-direction:column;gap:.625rem;justify-content:center;max-width:6.25rem}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar{--radius:1.5px;background:var(--gray-400);border-radius:var(--radius);display:flex;height:.1875rem;margin:0;overflow:hidden}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar:after{background:var(--blueberry,#3858e9);border-radius:var(--radius);content:"";height:100%;width:var(--bar-fill)}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-value{color:var(--sidebar-black);flex-shrink:0;font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;min-width:3.125rem;text-align:left} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-related-posts{align-items:flex-start;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-description{font-size:.8125rem;font-style:normal;font-weight:400;gap:.625rem;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body,.wp-parsely-related-posts .related-posts-description{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body{gap:1rem}.wp-parsely-related-posts .related-posts-body>div{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings{align-self:stretch;display:flex;flex-direction:column;gap:1rem;width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings{display:flex;flex-direction:column;gap:var(--grid-unit-20);width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control{height:2.5rem;overflow:hidden}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex{height:2.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex input{margin:0 var(--grid-unit-15)}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-descr{font-size:.8125rem;font-style:normal;font-weight:400;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-empty,.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-loading-message{color:var(--gray-900);font-size:.75rem;font-style:normal;font-weight:700;line-height:var(--grid-unit-20);overflow:hidden;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-title{align-items:center;align-self:stretch;display:flex;flex-direction:column;font-size:.875rem;font-style:normal;font-weight:600;gap:.5rem;justify-content:center;line-height:1.25rem;overflow:hidden;padding:var(--grid-unit-20);text-decoration-line:underline;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions{align-items:center;align-self:stretch;border-top:1px solid var(--gray-400);display:flex;flex-wrap:wrap;padding:0 var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:first-child,.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:last-child{display:flex;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric{align-items:center;display:flex}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric .parsely-post-metric-data{align-items:center;display:flex;gap:var(--grid-unit-5)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-linked{align-items:center;display:flex;margin-right:auto;fill:#008a20}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon path{fill:#1e1e1e}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon:hover path{fill:#0073aa} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper{display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings>div{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding-bottom:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header .parsely-write-titles-text strong{text-transform:lowercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding-top:.375rem}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate .components-button{align-items:center;align-self:stretch;border-radius:2px;display:flex;height:2.5rem;justify-content:center;padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-dropdown-label{align-self:stretch;color:var(--sidebar-black);font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:var(--grid-unit-20);text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title{font-size:1rem;font-weight:600;line-height:1.25rem;margin:0 0 .9375rem;text-align:center}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title-actions{display:flex;gap:.625rem;justify-content:center;margin:.625rem 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion.pinned-title{background:var(--Gutenberg-Gray-100,#f0f0f0)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title{align-items:center;align-self:stretch;color:#1e1e1e;display:flex;flex-direction:column;font-size:.75rem;font-style:normal;font-weight:600;gap:var(--grid-unit-10);justify-content:center;line-height:1.25rem;padding:var(--grid-unit-15) var(--grid-unit-15) 0 var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title .suggested-title-original{align-self:flex-start;margin:0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions{align-items:center;align-self:stretch;border-top:1px solid var(--Gutenberg-Gray-400,#ccc);display:flex;flex-wrap:wrap;height:2.5rem;padding:0 var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-left,.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-right{display:flex;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin-bottom:var(--grid-unit-20);position:relative}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay{align-items:center;background-color:hsla(0,0%,100%,.9);bottom:0;display:flex;flex-direction:column;gap:var(--grid-unit-10);justify-content:center;right:0;position:absolute;left:0;top:0;z-index:1}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay .components-spinner{transform:scale(1.125)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-pinned-suggestions{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-content-helper-error.components-notice{margin-bottom:var(--grid-unit-10)}.wp-parsely-popover .components-popover__content{width:15.5rem}.wp-parsely-suggested-title-modal{align-items:flex-start;display:flex;flex-direction:column;width:20rem}.wp-parsely-suggested-title-modal h2{color:var(--sidebar-black);font-size:1rem;font-style:normal;font-weight:600;line-height:1.5rem}.wp-parsely-suggested-title-modal .suggested-title-modal-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;margin-top:1.5rem} diff --git a/build/content-helper/editor-sidebar.asset.php b/build/content-helper/editor-sidebar.asset.php index 6b985e7ba..5cf3de363 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' => 'c78390535175d02a3a1e'); + 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' => '3749ec1c1c059860b295'); diff --git a/build/content-helper/editor-sidebar.css b/build/content-helper/editor-sidebar.css index 45a1d47d4..53f76d0d3 100644 --- a/build/content-helper/editor-sidebar.css +++ b/build/content-helper/editor-sidebar.css @@ -1,4 +1,4 @@ -#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 var(--grid-unit-15) 0 0;order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate,.wp-parsely-smart-linking .smart-linking-manage{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button,.wp-parsely-smart-linking .smart-linking-manage button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)}.wp-parsely-smart-linking-review-modal{align-items:flex-start;display:flex;flex-direction:column;width:47.875rem}.wp-parsely-smart-linking-review-modal .smart-linking-modal-body{align-self:stretch;display:flex;flex-direction:row;gap:var(--grid-unit-30)}.wp-parsely-smart-linking-review-modal .wp-parsely-link-suggestion-link-details{height:auto;margin-bottom:var(--grid-unit-20);text-align:left}.wp-parsely-smart-linking-review-modal .wp-parsely-link-suggestion-link-details .components-menu-item__item{display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);max-height:25rem;min-width:13.75rem;overflow-y:auto;padding:3px}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header{align-items:center;align-self:stretch;color:var(--sidebar-black);display:flex;font-size:11px;font-style:normal;font-weight:600;gap:6px;line-height:var(--grid-unit-20);margin-bottom:var(--grid-unit-15);text-transform:uppercase}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header>span{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button{align-items:center;display:flex;justify-content:space-between;width:13.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button:focus{box-shadow:none;outline:none}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-label{align-items:center;color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));display:flex;padding-left:var(--grid-unit-10);white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected{background-color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected .smart-linking-menu-label{color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__item{padding-right:0;width:100%}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-item{display:inline;flex-grow:1;overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion{align-items:flex-start;align-self:stretch;display:flex;flex:1;flex-direction:column;gap:16px;max-width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs{font-size:.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-separator{margin:0 var(--grid-unit-5)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-block{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block{color:var(--sidebar-black)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block .breadcrumbs-current-block-name{margin-left:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .components-divider{border-color:#ccc;height:1px;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls{align-items:center;align-self:stretch;display:flex;flex-shrink:0;justify-content:space-between;margin:0 var(--grid-unit-20);-webkit-user-select:none;-moz-user-select:none;user-select:none;width:452px}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .reviews-controls-middle{align-items:center;display:flex;flex:1 0 0;gap:var(--grid-unit-20,16px);justify-content:center}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-next,.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-previous{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-reject{background:var(--Gutenberg-White,#fff);border-radius:2px;box-shadow:inset 0 0 0 1px var(--Gutenberg-Alert-Red,#cc1818);color:var(--Gutenberg-Alert-Red,#cc1818)}.wp-parsely-smart-linking-close-dialog{align-items:flex-start;display:flex;flex-direction:column;width:24rem}.wp-parsely-smart-linking-close-dialog .smart-linking-close-dialog-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;padding-top:var(--grid-unit-30)}.wp-parsely-preview-editor.editor-styles-wrapper{font-size:var(--font-size--medium);padding-bottom:0}.wp-parsely-preview-editor p[role=document]{margin:0}.wp-parsely-preview-editor .smart-linking-highlight{background:hsla(var(--parsely-green-components),.5);border-radius:2px;color:var(--sidebar-black);mix-blend-mode:multiply;text-decoration-line:underline} +#wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-block-overlay{align-items:center;background-color:hsla(0,0%,100%,.85);box-sizing:border-box;display:flex;font-size:1.125rem;height:100%;justify-content:center;left:0;position:absolute;top:0;width:100%}.wp-parsely-block-overlay .wp-parsely-block-overlay-label{align-items:center;display:flex;flex-direction:column;flex-grow:1;gap:var(--grid-unit-10);justify-content:center;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;user-select:none;width:var(--grid-unit-10)}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel{font-size:1.125rem;padding:0;pointer-events:all;-webkit-user-select:none;-moz-user-select:none;user-select:none;z-index:10}.wp-parsely-block-overlay .wp-parsely-block-overlay-cancel:focus{box-shadow:none;outline:none}.wp-parsely-block-overlay svg{height:1.5625rem;width:1.5625rem}.wp-parsely-block-overlay.full-content-overlay{font-size:1.25rem;z-index:999}.wp-parsely-block-overlay.full-content-overlay span{margin-top:.9375rem}.wp-parsely-block-overlay.full-content-overlay svg{height:3.125rem;width:3.125rem}.wp-parsely-panel .components-panel__icon{height:1.5rem;margin:0 var(--grid-unit-15) 0 0;order:-1;width:1.5rem}.wp-parsely-smart-linking .components-panel__row{flex-direction:column;margin-bottom:0}.wp-parsely-smart-linking .components-base-control,.wp-parsely-smart-linking .components-base-control .components-panel__row,.wp-parsely-smart-linking .components-base-control:last-child{margin-bottom:0}.wp-parsely-smart-linking .smart-linking-text{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings{width:100%}.wp-parsely-smart-linking .parsely-panel-settings-body{display:flex;flex-direction:column;gap:.625rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select{align-self:stretch;display:flex;flex-direction:column;gap:1.5rem;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control{height:40px;overflow:hidden}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s,color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-block-select .components-toggle-group-control button:not([data-active-item]){transition:color .2s .1s}.wp-parsely-smart-linking .parsely-panel-settings-body .smart-linking-settings{align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-smart-linking .smart-linking-generate,.wp-parsely-smart-linking .smart-linking-manage{align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-smart-linking .smart-linking-generate button,.wp-parsely-smart-linking .smart-linking-manage button{align-items:center;align-self:stretch;display:flex;justify-content:center;width:100%}.wp-parsely-smart-linking .wp-parsely-smart-linking-suggested-links{margin:0}.wp-parsely-smart-linking .wp-parsely-smart-linking-hint{margin-top:calc(var(--grid-unit-10)*-1)}.wp-parsely-smart-linking-review-modal{align-items:flex-start;display:flex;flex-direction:column;width:47.875rem}.wp-parsely-smart-linking-review-modal .smart-linking-modal-body{align-self:stretch;display:flex;flex-direction:row;gap:var(--grid-unit-30)}.wp-parsely-smart-linking-review-modal .wp-parsely-link-suggestion-link-details{height:auto;margin-bottom:var(--grid-unit-20);text-align:left}.wp-parsely-smart-linking-review-modal .wp-parsely-link-suggestion-link-details .components-menu-item__item{display:inline-block;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);max-height:25rem;min-width:13.75rem;overflow-y:auto;padding:.1875rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header{align-items:center;align-self:stretch;color:var(--sidebar-black);display:flex;font-size:.6875rem;font-style:normal;font-weight:600;gap:.375rem;line-height:var(--grid-unit-20);margin-bottom:var(--grid-unit-15);text-transform:uppercase}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .review-sidebar-header>span{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button{align-items:center;display:flex;justify-content:space-between;width:13.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button:focus{box-shadow:none;outline:none}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-label{align-items:center;color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));display:flex;padding-left:var(--grid-unit-10);white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected{background-color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9));color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button.is-selected .smart-linking-menu-label{color:#fff}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .components-menu-item__item{padding-right:0;width:100%}.wp-parsely-smart-linking-review-modal .smart-linking-review-sidebar .components-button.components-menu-item__button .smart-linking-menu-item{display:inline;flex-grow:1;overflow:hidden;text-align:left;text-overflow:ellipsis;white-space:nowrap}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion{align-items:flex-start;align-self:stretch;display:flex;flex:1;flex-direction:column;gap:1rem;max-width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs{font-size:.75rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-separator{margin:0 var(--grid-unit-5)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-parent-block{color:var(--Gutenberg-Gray-700,#757575)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block{color:var(--sidebar-black)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-suggestions-breadcrumbs .breadcrumbs-current-block .breadcrumbs-current-block-name{margin-left:var(--grid-unit-10)}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .components-divider{border-color:#ccc;height:1px;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls{align-items:center;align-self:stretch;display:flex;flex-shrink:0;justify-content:space-between;margin:0 var(--grid-unit-20);-webkit-user-select:none;-moz-user-select:none;user-select:none;width:28.25rem}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .reviews-controls-middle{align-items:center;display:flex;flex:1 0 0;gap:var(--grid-unit-20);justify-content:center}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-next,.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-previous{color:var(--wp-components-color-accent,var(--wp-admin-theme-color,#3858e9))}.wp-parsely-smart-linking-review-modal .smart-linking-review-suggestion .review-controls .wp-parsely-review-suggestion-reject{background:var(--Gutenberg-White,#fff);border-radius:2px;box-shadow:inset 0 0 0 1px var(--Gutenberg-Alert-Red,#cc1818);color:var(--Gutenberg-Alert-Red,#cc1818)}.wp-parsely-smart-linking-close-dialog{align-items:flex-start;display:flex;flex-direction:column;width:24rem}.wp-parsely-smart-linking-close-dialog .smart-linking-close-dialog-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;padding-top:var(--grid-unit-30)}.wp-parsely-preview-editor.editor-styles-wrapper{font-size:var(--font-size--medium);padding-bottom:0}.wp-parsely-preview-editor p[role=document]{margin:0}.wp-parsely-preview-editor .smart-linking-highlight{background:hsla(var(--parsely-green-components),.5);border-radius:2px;color:var(--sidebar-black);mix-blend-mode:multiply;text-decoration-line:underline} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-performance-panel{border-top:1px solid #ddd;margin-top:-1px;padding:16px}.wp-parsely-content-helper .wp-parsely-performance-panel .content-helper-error-message{margin:0!important}.wp-parsely-content-helper .wp-parsely-performance-panel .components-button.wp-parsely-view-post{align-items:center;display:flex;justify-content:center;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .panel-body{width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.5rem;padding:.375rem 0 1rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header{align-items:center;display:flex;gap:.375rem;height:1rem;margin-bottom:0;width:100%}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2{margin-bottom:.9375rem}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-2 h2{margin-bottom:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-header.level-3 h3{font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:1rem;margin-bottom:0;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-stat-panel .panel-subtitle{align-items:center;align-self:stretch;color:var(--Gutenberg-Gray-700,#757575);display:flex;flex:1 0 0;font-size:var(--font-size--smaller);font-style:normal;font-weight:600;gap:.375rem;height:1rem;line-height:1rem;text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-performance-panel .components-heading{display:block;font-weight:500;line-height:normal;margin:0}.wp-parsely-content-helper .wp-parsely-performance-panel .components-dropdown-menu{line-height:0}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points{align-content:flex-start;align-items:flex-start;align-self:stretch;display:flex;flex-wrap:wrap;gap:1rem var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point{align-items:center;background:var(--sidebar-white);border-radius:.25rem;display:flex;flex:1 0 0;flex-direction:column;gap:var(--grid-unit-5);justify-content:center;min-width:100px;padding:var(--grid-unit-20) var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point svg{align-items:flex-start;border-radius:.125rem;display:flex}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-title{align-self:stretch;color:var(--sidebar-black);font-size:.75rem;font-style:normal;font-weight:400;line-height:1rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value{align-self:stretch;color:var(--sidebar-black);font-size:1.25rem;font-style:normal;font-weight:590;line-height:1.75rem;text-align:center}.wp-parsely-content-helper .wp-parsely-performance-panel .performance-data-points .data-point .data-point-value.is-small{font-size:var(--font-size--medium)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar{align-items:flex-start;align-self:stretch;display:flex;height:1rem;margin:1rem 0;position:relative}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill{--radius:2px;align-self:stretch;position:relative;transition:filter .1s ease,transform .1s ease}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:hover{filter:opacity(1)!important;transform:scaleX(1) scaleY(1)!important}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:first-child{border-radius:var(--radius) 0 0 var(--radius)}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill:last-child{border-radius:0 var(--radius) var(--radius) 0}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar .bar-fill.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel div.multi-percentage-bar:hover .bar-fill{filter:opacity(.5);transform:scaleX(1) scaleY(.7)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label{align-items:center;align-self:stretch;display:flex;gap:.5rem;justify-content:center}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color{align-items:center;border-radius:.09375rem;display:flex;flex-direction:column;gap:.625rem;height:.625rem;justify-content:center;width:.1875rem}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.direct{background-color:hsl(var(--ref-direct))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.internal{background-color:hsl(var(--ref-internal))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.search{background-color:hsl(var(--ref-search))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.social{background-color:hsl(var(--ref-social))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-color.other{background-color:hsl(var(--ref-other))}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-text{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1 0 0;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .percentage-bar-labels .single-label .label-value{color:var(--sidebar-black);font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;text-align:right}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin:1rem 0}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-10);justify-content:space-between}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-title{display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;color:var(--sidebar-black);flex:1;font-feature-settings:"ss06" on;font-size:var(--font-size--small);font-style:normal;font-weight:400;line-height:1rem;overflow:hidden;text-overflow:ellipsis}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar{display:flex;flex:1;flex-direction:column;gap:.625rem;justify-content:center;max-width:6.25rem}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar{--radius:1.5px;background:var(--gray-400);border-radius:var(--radius);display:flex;height:.1875rem;margin:0;overflow:hidden}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-bar .percentage-bar:after{background:var(--blueberry,#3858e9);border-radius:var(--radius);content:"";height:100%;width:var(--bar-fill)}.wp-parsely-content-helper .wp-parsely-performance-panel .referrers-list .referrers-row .referrers-row-value{color:var(--sidebar-black);flex-shrink:0;font-size:var(--font-size--small);font-style:normal;font-weight:590;line-height:1rem;min-width:3.125rem;text-align:right} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-related-posts{align-items:flex-start;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-description{font-size:.8125rem;font-style:normal;font-weight:400;gap:.625rem;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body,.wp-parsely-related-posts .related-posts-description{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body{gap:1rem}.wp-parsely-related-posts .related-posts-body>div{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings{align-self:stretch;display:flex;flex-direction:column;gap:1rem;width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings{display:flex;flex-direction:column;gap:var(--grid-unit-20);width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .components-base-control__field{margin-bottom:0}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control{height:2.5rem;overflow:hidden}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button{background:transparent;outline:2px solid transparent;outline-offset:-3px}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-types .components-toggle-group-control button[data-active-item]{background:var(--sidebar-black);border-radius:3px;box-shadow:0 -3px 0 0 #fff,0 3px 0 0 #fff;transition:background 0s .5s,border-radius 0s .5s,box-shadow 0s .5s}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values{width:100%}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex{height:2.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-filter-settings .related-posts-filter-values .components-combobox-control__suggestions-container .components-flex input{margin:0 var(--grid-unit-15)}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-descr{font-size:.8125rem;font-style:normal;font-weight:400;line-height:1.25rem}.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-empty,.wp-parsely-related-posts .related-posts-body .related-posts-wrapper .related-posts-loading-message{color:var(--gray-900);font-size:.75rem;font-style:normal;font-weight:700;line-height:var(--grid-unit-20);overflow:hidden;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-title{align-items:center;align-self:stretch;display:flex;flex-direction:column;font-size:.875rem;font-style:normal;font-weight:600;gap:.5rem;justify-content:center;line-height:1.25rem;overflow:hidden;padding:var(--grid-unit-20);text-decoration-line:underline;text-overflow:ellipsis}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions{align-items:center;align-self:stretch;border-top:1px solid var(--gray-400);display:flex;flex-wrap:wrap;padding:0 var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:first-child,.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info>div:last-child{display:flex;gap:var(--grid-unit-10)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric{align-items:center;display:flex}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-metric .parsely-post-metric-data{align-items:center;display:flex;gap:var(--grid-unit-5)}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .related-post-linked{align-items:center;display:flex;margin-left:auto;fill:#008a20}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon path{fill:#1e1e1e}.wp-parsely-related-posts .related-posts-body .related-posts-list .related-post-single .related-post-actions .related-post-info .wp-parsely-icon:hover path{fill:#0073aa} #wp-parsely-dashboard-widget,.components-button[aria-controls="wp-parsely-block-editor-sidebar:wp-parsely-content-helper"],.editor-post-excerpt,.settings_page_parsely,.wp-parsely-block-overlay,.wp-parsely-content-helper,.wp-parsely-excerpt-generator,.wp-parsely-panel,.wp-parsely-popover,.wp-parsely-preview-editor,.wp-parsely-smart-linking-close-dialog,.wp-parsely-smart-linking-review-modal,.wp-parsely-suggested-title-modal{--base-font:"source-sans-pro",arial,sans-serif;--numeric-font:"ff-din-round-web",sans-serif;--parsely-green-components:107,42%,46%;--parsely-green:hsl(var(--parsely-green-components));--parsely-green-10:#c7ecb1;--parsely-green-65:#2a691b;--gray-200:#f7f8f9;--gray-300:#edeeef;--gray-400:#d7dbdf;--gray-500:#959da5;--gray-600:#586069;--gray-700:#444d56;--gray-900:#24292e;--blue-500:#44a8e5;--blue-550:#2596db;--green-500:#7bc01b;--green-900:#3d6307;--ref-direct:205,13%,52%;--ref-internal:161,91%,41%;--ref-social:210,72%,41%;--ref-search:42,100%,50%;--ref-other:3,76%,58%;--base-text:var(--gray-900);--base-text-2:var(--gray-600);--base-3:var(--gray-400);--border:var(--gray-400);--data:var(--green-500);--control:var(--blue-500);--grid-unit-5:0.25rem;--grid-unit-10:0.5rem;--grid-unit-15:0.75rem;--grid-unit-20:1rem;--grid-unit-25:1.25rem;--grid-unit-30:1.5rem;--grid-unit-40:2rem;--font-size--smaller:0.688rem;--font-size--small:0.75rem;--font-size--medium:0.875rem;--font-size--large:1rem;--font-size--extra-large:1.2rem;--black:#000;--sidebar-black:#1e1e1e;--sidebar-white:#f0f0f0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper{display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);padding:.375rem 0 var(--grid-unit-20) 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-settings>div{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:.625rem;padding-bottom:var(--grid-unit-20)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-header .parsely-write-titles-text strong{text-transform:lowercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;padding-top:.375rem}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-generate .components-button{align-items:center;align-self:stretch;border-radius:2px;display:flex;height:2.5rem;justify-content:center;padding:var(--grid-unit-10) var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-dropdown-label{align-self:stretch;color:var(--sidebar-black);font-size:var(--font-size--smaller);font-style:normal;font-weight:600;line-height:var(--grid-unit-20);text-transform:uppercase}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title{font-size:1rem;font-weight:600;line-height:1.25rem;margin:0 0 .9375rem;text-align:center}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .parsely-write-titles-accepted-title-container .parsely-write-titles-accepted-title-actions{display:flex;gap:.625rem;justify-content:center;margin:.625rem 0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion{align-items:flex-start;align-self:stretch;border:1px solid var(--Gutenberg-Gray-400,#ccc);border-radius:2px;display:flex;flex-direction:column;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion.pinned-title{background:var(--Gutenberg-Gray-100,#f0f0f0)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title{align-items:center;align-self:stretch;color:#1e1e1e;display:flex;flex-direction:column;font-size:.75rem;font-style:normal;font-weight:600;gap:var(--grid-unit-10);justify-content:center;line-height:1.25rem;padding:var(--grid-unit-15) var(--grid-unit-15) 0 var(--grid-unit-15)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title .suggested-title-original{align-self:flex-start;margin:0}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions{align-items:center;align-self:stretch;border-top:1px solid var(--Gutenberg-Gray-400,#ccc);display:flex;flex-wrap:wrap;height:2.5rem;padding:0 var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container{align-items:center;display:flex;flex-grow:1;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-left,.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-title-suggestion .suggested-title-actions .suggested-title-actions-container .suggested-title-actions-right{display:flex;gap:var(--grid-unit-10)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column;gap:var(--grid-unit-20);margin-bottom:var(--grid-unit-20);position:relative}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay{align-items:center;background-color:hsla(0,0%,100%,.9);bottom:0;display:flex;flex-direction:column;gap:var(--grid-unit-10);justify-content:center;left:0;position:absolute;right:0;top:0;z-index:1}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .title-suggestions-container .wp-parsely-loading-overlay .components-spinner{transform:scale(1.125)}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-pinned-suggestions{align-items:flex-start;align-self:stretch;display:flex;flex-direction:column}.wp-parsely-content-helper .wp-parsely-title-suggestions-wrapper .wp-parsely-content-helper-error.components-notice{margin-bottom:var(--grid-unit-10)}.wp-parsely-popover .components-popover__content{width:15.5rem}.wp-parsely-suggested-title-modal{align-items:flex-start;display:flex;flex-direction:column;width:20rem}.wp-parsely-suggested-title-modal h2{color:var(--sidebar-black);font-size:1rem;font-style:normal;font-weight:600;line-height:1.5rem}.wp-parsely-suggested-title-modal .suggested-title-modal-actions{align-items:center;align-self:stretch;display:flex;gap:var(--grid-unit-15);justify-content:flex-end;margin-top:1.5rem} diff --git a/build/content-helper/editor-sidebar.js b/build/content-helper/editor-sidebar.js index b41f29427..8f756c488 100644 --- a/build/content-helper/editor-sidebar.js +++ b/build/content-helper/editor-sidebar.js @@ -1,4 +1,4 @@ -!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 Vn}});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===N.ParselySuggestionsApiOpenAiError||s.code===N.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===N.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,p.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiSchemaError?s.message=(0,p.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===N.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===N.ParselySuggestionsApiOpenAiSchema?s.message=(0,p.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,p.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return z(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[N.PluginCredentialsNotSetMessageDetected,N.PluginSettingsSiteIdNotSet,N.PluginSettingsApiSecretNotSet].includes(this.code)?M(e):(this.code===N.FetchError&&(this.hint=this.Hint((0,p.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==N.ParselyApiForbidden&&this.code!==N.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===N.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)(B,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z,$=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,R.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},W=window.wp.editor,K=function(){return K=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var l=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,p.__)("NEW","wp-parsely"),(0,i.jsx)(he,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,p.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&l]},e.uid)}))]})})},ge=(0,i.jsxs)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,i.jsx)(d.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,i.jsx)(d.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})]}),ye=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})}),me=(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"})}),we=(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"})}),be=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})}),_e=window.wp.url,xe=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?c(!0):k().then((function(){return t()}))},L=function(e){c(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},E=function(){var e=g.indexOf(b)+1;g[e]&&_(g[e])},C=function(){var e=m().indexOf(b)-1;m()[e]&&_(m()[e])},A=function(){return Oe(void 0,void 0,void 0,(function(){var e,t;return Re(this,(function(n){switch(n.label){case 0:return b.match?(r(b),[4,(i=b.match.blockId,s=b,Oe(void 0,void 0,void 0,(function(){var e,t;return Re(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,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(b),g[t=e+1]?_(g[t]):_(g[0]),[2])}var i,s}))}))},N=function(){return Oe(void 0,void 0,void 0,(function(){var e,t;return Re(this,(function(n){switch(n.label){case 0:return e=g.indexOf(b),g[t=e+1]?_(g[t]):g[0]?_(g[0]):T(),[4,P(b.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Oe(void 0,void 0,void 0,(function(){var e,t,n,r;return Re(this,(function(i){switch(i.label){case 0:return b.match?(e=(0,a.select)("core/block-editor").getBlock(b.match.blockId))?(t=m(),n=t.indexOf(b),r=n-1,[4,j(e,b)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?_(t[r]):_(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:E,up:C,down:E,a:function(){b&&!b.applied&&A()},r:function(){b&&(b.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(ve,{links:g,activeLink:b,setSelectedLink:_}),(0,i.jsx)(Ne,{link:b,hasNext:m().indexOf(b)0,onNext:E,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(b.match){var e=(0,a.select)("core/block-editor").getBlock(b.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(b.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),l&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return L(!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 L(!1)},children:(0,p.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return L(!0)},children:(0,p.__)("Close","wp-parsely")})]})]})]})})),Be=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})]})]})},Me=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,l=e.onSettingChange,c=(0,u.useRef)(),d=(0,u.useState)(""),f=d[0],h=d[1],v=(0,u.useState)(!1),g=v[0],y=v[1],m=(0,u.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(X),n=t.getMaxLinks,r=t.isFullContent,i=t.wasAlreadyClicked,s=t.getApplyTo;return{maxLinks:n(),fullContent:r(),alreadyClicked:i(),applyTo:s()}}),[]),b=w.maxLinks,_=w.fullContent,x=w.alreadyClicked,k=w.applyTo,S=(0,a.useDispatch)(X),P=S.setMaxLinks,j=S.setFullContent,T=S.setAlreadyClicked,L=S.setApplyTo,E=null!==(t=k)&&void 0!==t?t:o?"selected":"all";return(0,u.useEffect)((function(){if(!r){var e=function(){r||(k===Z.Selected&&setTimeout((function(){h((0,p.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),L(null),m((function(e){return!e})))};o||k===Z.All||(g?setTimeout(e,500):e()),j(Z.All===E)}}),[g,k,E,r,o,L,j,h]),(0,u.useEffect)((function(){if(!r&&c.current&&E&&!x&&o){var e=c.current.querySelector('button[data-value="'.concat(E,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(L(E),T(!0))}}),[o,_,r,k]),(0,u.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:c,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:E,label:(0,p.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&_("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 Vn}});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===N.ParselySuggestionsApiOpenAiError||s.code===N.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===N.HttpRequestFailed&&s.message.includes("cURL error 28")?s.message=(0,p.__)("The Parse.ly API did not respond in a timely manner. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiSchemaError?s.message=(0,p.__)("The Parse.ly API returned a validation error. Please try again with different parameters.","wp-parsely"):s.code===N.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===N.ParselySuggestionsApiOpenAiSchema?s.message=(0,p.__)("The Parse.ly API returned an incorrect response. Please try again later.","wp-parsely"):s.code===N.ParselySuggestionsApiAuthUnavailable&&(s.message=(0,p.__)("The Parse.ly API is currently unavailable. Please try again later.","wp-parsely")),s}return z(t,e),t.prototype.Message=function(e){return void 0===e&&(e=null),[N.PluginCredentialsNotSetMessageDetected,N.PluginSettingsSiteIdNotSet,N.PluginSettingsApiSecretNotSet].includes(this.code)?M(e):(this.code===N.FetchError&&(this.hint=this.Hint((0,p.__)("This error can sometimes be caused by ad-blockers or browser tracking protections. Please add this site to any applicable allow lists and try again.","wp-parsely"))),this.code!==N.ParselyApiForbidden&&this.code!==N.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===N.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)(B,{className:null==e?void 0:e.className,testId:"error",children:"

".concat(this.message,"

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

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

")},t}(Error);function q(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}var Z,$=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,R.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},W=window.wp.editor,K=function(){return K=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]s.bottom)&&(r.scrollTop=i.offsetTop-r.offsetTop)}}}}),[t,n]);var l=(0,i.jsxs)("span",{className:"smart-linking-menu-label",children:[(0,p.__)("NEW","wp-parsely"),(0,i.jsx)(he,{})]});return(0,i.jsx)("div",{className:"smart-linking-review-sidebar",ref:a,children:(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{className:"review-sidebar-header",children:[(0,p.__)("Outbound Smart Links","wp-parsely"),(0,i.jsx)("span",{children:null==n?void 0:n.length})]}),null==n?void 0:n.map((function(e,n){return(0,i.jsxs)(s.MenuItem,{ref:function(e){return o.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(){r(e)},children:[(0,i.jsx)("span",{className:"smart-linking-menu-item",children:e.text}),!e.applied&&l]},e.uid)}))]})})},ge=(0,i.jsxs)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:[(0,i.jsx)(d.Path,{d:"M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"}),(0,i.jsx)(d.Path,{d:"M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"})]}),ye=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"M20 11.2H6.8l3.7-3.7-1-1L3.9 12l5.6 5.5 1-1-3.7-3.7H20z"})}),me=(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"})}),we=(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"})}),be=(0,i.jsx)(d.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,i.jsx)(d.Path,{d:"m14.5 6.5-1 1 3.7 3.7H4v1.6h13.2l-3.7 3.7 1 1 5.6-5.5z"})}),_e=window.wp.url,xe=function(){function e(){this.abortControllers=new Map}return e.prototype.cancelRequest=function(e){if(e)(t=this.abortControllers.get(e))&&(t.abort(),this.abortControllers.delete(e));else{var t,n=Array.from(this.abortControllers.keys()).pop();n&&(t=this.abortControllers.get(n))&&(t.abort(),this.abortControllers.delete(n))}},e.prototype.cancelAll=function(){this.abortControllers.forEach((function(e){return e.abort()})),this.abortControllers.clear()},e.prototype.getOrCreateController=function(e){if(e&&this.abortControllers.has(e))return{abortController:this.abortControllers.get(e),abortId:e};var t=null!=e?e:"auto-"+Date.now(),n=new AbortController;return this.abortControllers.set(t,n),{abortController:n,abortId:t}},e.prototype.fetch=function(e,t){return n=this,r=void 0,s=function(){var n,r,i,s,a;return 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&&(l=o[0],(c=l.parentNode)&&(u=document.createTextNode(null!==(p=l.textContent)&&void 0!==p?p:""),c.replaceChild(u,l),(0,a.dispatch)("core/block-editor").updateBlockAttributes(n,{content:s.innerHTML}))),[4,P(t.uid)]):[2]):[2];case 1:return d.sent(),[2]}}))}))},T=function(){h(!1),g.filter((function(e){return!e.applied})).length>0?c(!0):k().then((function(){return t()}))},L=function(e){c(!1),e?(h(!1),k().then((function(){t()}))):h(!0)},E=function(){var e=g.indexOf(b)+1;g[e]&&_(g[e])},C=function(){var e=m().indexOf(b)-1;m()[e]&&_(m()[e])},A=function(){return Oe(void 0,void 0,void 0,(function(){var e,t;return Re(this,(function(n){switch(n.label){case 0:return b.match?(r(b),[4,(i=b.match.blockId,s=b,Oe(void 0,void 0,void 0,(function(){var e,t;return Re(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,S(s)]):[2];case 1:return n.sent(),[2]}}))})))]):[2];case 1:return n.sent(),0===y().length?(T(),[2]):(e=g.indexOf(b),g[t=e+1]?_(g[t]):_(g[0]),[2])}var i,s}))}))},N=function(){return Oe(void 0,void 0,void 0,(function(){var e,t;return Re(this,(function(n){switch(n.label){case 0:return e=g.indexOf(b),g[t=e+1]?_(g[t]):g[0]?_(g[0]):T(),[4,P(b.uid)];case 1:return n.sent(),[2]}}))}))},O=function(){return Oe(void 0,void 0,void 0,(function(){var e,t,n,r;return Re(this,(function(i){switch(i.label){case 0:return b.match?(e=(0,a.select)("core/block-editor").getBlock(b.match.blockId))?(t=m(),n=t.indexOf(b),r=n-1,[4,j(e,b)]):[3,2]:[2];case 1:i.sent(),(t=m())[r]?_(t[r]):_(t[0]),i.label=2;case 2:return[2]}}))}))};return(0,i.jsxs)(i.Fragment,{children:[f&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),className:"wp-parsely-smart-linking-review-modal",onRequestClose:T,shouldCloseOnClickOutside:!1,shouldCloseOnEsc:!1,children:[(0,i.jsx)(s.KeyboardShortcuts,{shortcuts:{left:C,right:E,up:C,down:E,a:function(){b&&!b.applied&&A()},r:function(){b&&(b.applied?O():N())}}}),(0,i.jsxs)("div",{className:"smart-linking-modal-body",children:[(0,i.jsx)(ve,{links:g,activeLink:b,setSelectedLink:_}),(0,i.jsx)(Ne,{link:b,hasNext:m().indexOf(b)0,onNext:E,onPrevious:C,onAccept:A,onReject:N,onRemove:O,onSelectInEditor:function(){if(b.match){var e=(0,a.select)("core/block-editor").getBlock(b.match.blockId);if(e){(0,a.dispatch)("core/block-editor").selectBlock(e.clientId);var t=document.querySelector('[data-block="'.concat(e.clientId,'"]'));if(t){var n=t.ownerDocument,r=t.querySelector('a[data-smartlink="'.concat(b.uid,'"]'));if(r){r.focus();var i=n.createRange();if(r.firstChild){i.setStart(r.firstChild,0),i.setEndAfter(r.firstChild);var s=n.getSelection();s&&(s.removeAllRanges(),s.addRange(i))}}}T()}}}})]})]}),l&&(0,i.jsxs)(s.Modal,{title:(0,p.__)("Review Smart Links","wp-parsely"),onRequestClose:function(){return L(!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 L(!1)},children:(0,p.__)("Go Back","wp-parsely")}),(0,i.jsx)(s.Button,{variant:"primary",onClick:function(){return L(!0)},children:(0,p.__)("Close","wp-parsely")})]})]})]})})),Be=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})]})]})},Me=function(e){var t,n=e.disabled,r=void 0!==n&&n,o=e.selectedBlock,l=e.onSettingChange,c=(0,u.useRef)(),d=(0,u.useState)(""),f=d[0],h=d[1],v=(0,u.useState)(!1),g=v[0],y=v[1],m=(0,u.useState)(!1)[1],w=(0,a.useSelect)((function(e){var t=e(X),n=t.getMaxLinks,r=t.isFullContent,i=t.wasAlreadyClicked,s=t.getApplyTo;return{maxLinks:n(),fullContent:r(),alreadyClicked:i(),applyTo:s()}}),[]),b=w.maxLinks,_=w.fullContent,x=w.alreadyClicked,k=w.applyTo,S=(0,a.useDispatch)(X),P=S.setMaxLinks,j=S.setFullContent,T=S.setAlreadyClicked,L=S.setApplyTo,E=null!==(t=k)&&void 0!==t?t:o?"selected":"all";return(0,u.useEffect)((function(){if(!r){var e=function(){r||(k===Z.Selected&&setTimeout((function(){h((0,p.__)("No block selected. Select a block to apply smart links.","wp-parsely"))}),100),L(null),m((function(e){return!e})))};o||k===Z.All||(g?setTimeout(e,500):e()),j(Z.All===E)}}),[g,k,E,r,o,L,j,h]),(0,u.useEffect)((function(){if(!r&&c.current&&E&&!x&&o){var e=c.current.querySelector('button[data-value="'.concat(E,'"]'));e&&"true"!==e.getAttribute("aria-checked")&&(L(E),T(!0))}}),[o,_,r,k]),(0,u.useEffect)((function(){h(null)}),[o]),(0,i.jsx)("div",{className:"parsely-panel-settings",children:(0,i.jsxs)("div",{className:"parsely-panel-settings-body",children:[(0,i.jsxs)("div",{className:"smart-linking-block-select",children:[(0,i.jsx)(s.Disabled,{isDisabled:r,children:(0,i.jsxs)(s.__experimentalToggleGroupControl,{ref:c,__nextHasNoMarginBottom:!0,__next40pxDefaultSize:!0,isBlock:!0,value:E,label:(0,p.__)("Apply Smart Links to","wp-parsely"),onChange:function(e){return t=void 0,n=void 0,s=function(){return 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&&_("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"),g),{type:"snackbar"}):y(0)}),[w]),(0,u.useEffect)((function(){if(!(Object.keys(O).length>0)){var e={maxLinksPerPost:c.SmartLinking.MaxLinks};ne(e)}}),[ne,c]);var ge=(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]),ye=ge.allBlocks,me=ge.selectedBlock,we=ge.postContent,be=ge.postPermalink,_e=function(e){return Ve(void 0,void 0,void 0,(function(){var t,n,r,i;return Fe(this,(function(s){switch(s.label){case 0:t=[],s.label=1;case 1:return s.trys.push([1,4,,9]),[4,re((n=T||!me)?Z.All:Z.Selected)];case 2:return s.sent(),a=be.replace(/^https?:\/\//i,""),r=["http://"+a,"https://"+a],[4,je.getInstance().generateSmartLinks(me&&!n?(0,F.getBlockContent)(me):we,A,r)];case 3:return t=s.sent(),[3,9];case 4:if((i=s.sent()).code&&i.code===N.ParselyAborted)throw i.numRetries=3-e,i;return e>0&&i.retryFetch?(console.error(i),[4,se(!0)]):[3,8];case 5:return s.sent(),[4,le()];case 6:return s.sent(),[4,_e(e-1)];case 7:return[2,s.sent()];case 8:throw i;case 9:return[2,t]}var a}))}))},xe=function(){for(var e=[],t=0;t[type="button"]').forEach((function(e){e.setAttribute("disabled","disabled")}))},Pe=function(){document.querySelectorAll('.edit-post-header__settings>[type="button"]').forEach((function(e){e.removeAttribute("disabled")})),(0,a.dispatch)("core/editor").unlockPostSaving("wp-parsely-block-overlay")};return(0,i.jsxs)("div",{className:"wp-parsely-smart-linking",children:[(0,i.jsx)($,{isDetectingEnabled:!P,onLinkRemove:function(e){!function(e){J(this,void 0,void 0,(function(){var t,n,r;return ee(this,(function(i){switch(i.label){case 0:return[4,ce((0,F.getBlockContent)(e),e.clientId)];case 1:return t=i.sent(),n=t.missingSmartLinks,r=t.didAnyFixes,n.forEach((function(e){(0,a.dispatch)(X).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)(G,{icon:H,size:18,className:"parsely-external-link-icon"})]})]}),E&&(0,i.jsx)(s.Notice,{status:"info",onRemove:function(){return K(null)},className:"wp-parsely-content-helper-error",children:E.Message()}),w&&g>0&&(0,i.jsx)(s.Notice,{status:"success",onRemove:function(){return b(!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"),g>0?g:C.length)}),(0,i.jsx)(Me,{disabled:S,selectedBlock:null==me?void 0:me.clientId,onSettingChange:function(e,t){var n;f({SmartLinking:De(De({},c.SmartLinking),(n={},n[e]=t,n))}),"MaxLinks"===e&&ie(t)}}),(0,i.jsx)("div",{className:"smart-linking-generate",children:(0,i.jsx)(s.Button,{onClick:function(){return Ve(void 0,void 0,void 0,(function(){var e,t,n,r,i,s;return Fe(this,(function(a){switch(a.label){case 0:return[4,q(!0)];case 1:return a.sent(),[4,he()];case 2:return a.sent(),[4,K(null)];case 3:return a.sent(),b(!1),v.trackEvent("smart_linking_generate_pressed",{is_full_content:T,selected_block:null!==(s=null==me?void 0:me.name)&&void 0!==s?s:"none",context:o}),[4,xe(T?"all":null==me?void 0:me.clientId)];case 4:a.sent(),e=setTimeout((function(){var e;q(!1),v.trackEvent("smart_linking_generate_timeout",{is_full_content:T,selected_block:null!==(e=null==me?void 0:me.name)&&void 0!==e?e:"none",context:o}),ke(T?"all":null==me?void 0:me.clientId)}),18e4),t=I,a.label=5;case 5:return a.trys.push([5,8,10,15]),[4,_e(3)];case 6:return n=a.sent(),[4,(l=n,Ve(void 0,void 0,void 0,(function(){var e;return Fe(this,(function(t){switch(t.label){case 0:return l=l.filter((function(e){return!D.some((function(t){return t.uid===e.uid&&t.applied}))})),e=be.replace(/^https?:\/\//,"").replace(/\/+$/,""),l=l.filter((function(t){return!t.href.includes(e)||(console.warn("PCH Smart Linking: Skipping self-reference link: ".concat(t.href)),!1)})),l=(l=ae(ye,l,{}).filter((function(e){return e.match}))).filter((function(e){if(D.some((function(t){return t.text===e.text&&t.offset===e.offset})))return!1;if(!e.match)return!1;var t=e.match.blockLinkPosition,n=t+e.text.length;return!D.some((function(r){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,Y(l)];case 1:return t.sent(),[2]}}))})))];case 7:return a.sent(),ve(!0),[3,15];case 8:return r=a.sent(),i=(0,p.__)("There was a problem generating smart links.","wp-parsely"),r.code&&r.code===N.ParselyAborted&&(i=(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")),r.message=i),[4,K(r)];case 9:return a.sent(),_("error",i,{type:"snackbar"}),[3,15];case 10:return[4,q(!1)];case 11:return a.sent(),[4,re(t)];case 12:return a.sent(),[4,se(!1)];case 13:return a.sent(),[4,ke(T?"all":null==me?void 0:me.clientId)];case 14:return a.sent(),clearTimeout(e),[7];case 15:return[2]}var l}))}))},variant:"primary",isBusy:S,disabled:S,children:B?(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 */ diff --git a/src/content-helper/editor-sidebar/smart-linking/component-link-monitor.tsx b/src/content-helper/editor-sidebar/smart-linking/component-link-monitor.tsx index e9d820e1e..71101cc0b 100644 --- a/src/content-helper/editor-sidebar/smart-linking/component-link-monitor.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/component-link-monitor.tsx @@ -174,7 +174,6 @@ export const LinkMonitor = ( { } }, debounceValue ); - //console.log( 'Debounced check blocks', isDetectingEnabled ); debouncedCheckBlocks( isDetectingEnabled ); // Clean up the debounced function on component unmount. diff --git a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx index c405050c0..a48bf8c44 100644 --- a/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx +++ b/src/content-helper/editor-sidebar/smart-linking/review-modal/component-suggestion.tsx @@ -383,7 +383,7 @@ export const ReviewSuggestion = ( { hasNext, }: ReviewSuggestionProps ): JSX.Element => { if ( ! link?.match ) { - return <>No match!; + return <>{ __( 'This Smart Link does not have any matches in the current content.', 'wp-parsely' ) }; } const blockId = link.match.blockId; @@ -392,7 +392,7 @@ export const ReviewSuggestion = ( { const isApplied = link.applied; if ( ! block ) { - return <>No block!; + return <>{ __( 'No block is selected.', 'wp-parsely' ) }; } return ( diff --git a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss index 3dc6b2265..29666dbaf 100644 --- a/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss +++ b/src/content-helper/editor-sidebar/smart-linking/smart-linking.scss @@ -207,7 +207,7 @@ .components-menu-item__item { display: inline-block; - max-width: 100%; /* Adjust based on the container size */ + max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; @@ -219,7 +219,7 @@ min-width: to_rem(220px); max-height: to_rem(400px); overflow-y: auto; - padding: 3px; + padding: to_rem(3px); flex-direction: column; align-items: flex-start; gap: var(--grid-unit-20); @@ -229,10 +229,10 @@ margin-bottom: var(--grid-unit-15); display: flex; align-items: center; - gap: 6px; + gap: to_rem(6px); align-self: stretch; color: var(--sidebar-black); - font-size: 11px; + font-size: to_rem(11px); font-style: normal; font-weight: 600; line-height: var(--grid-unit-20); @@ -292,7 +292,7 @@ display: flex; flex-direction: column; align-items: flex-start; - gap: 16px; + gap: to_rem(16px); flex: 1; align-self: stretch; @@ -324,7 +324,7 @@ .review-controls { display: flex; - width: 452px; + width: to_rem(452px); justify-content: space-between; align-items: center; flex-shrink: 0; @@ -336,7 +336,7 @@ display: flex; justify-content: center; align-items: center; - gap: var(--grid-unit-20, 16px); + gap: var(--grid-unit-20); flex: 1 0 0; } diff --git a/src/content-helper/editor-sidebar/smart-linking/store.ts b/src/content-helper/editor-sidebar/smart-linking/store.ts index b0dafc6bf..0f8c5adc4 100644 --- a/src/content-helper/editor-sidebar/smart-linking/store.ts +++ b/src/content-helper/editor-sidebar/smart-linking/store.ts @@ -154,7 +154,7 @@ interface SetApplyToAction { /** * Interface for the SetIsRetryingAction. * - * @since 3.16.0 + * @since 3.15.0 */ interface SetIsRetryingAction { type: 'SET_IS_RETRYING'; diff --git a/src/content-helper/editor-sidebar/smart-linking/utils.ts b/src/content-helper/editor-sidebar/smart-linking/utils.ts index 1ee3ee8cd..8140722fa 100644 --- a/src/content-helper/editor-sidebar/smart-linking/utils.ts +++ b/src/content-helper/editor-sidebar/smart-linking/utils.ts @@ -126,8 +126,14 @@ function findTextNodes( element: Node, searchText: string ): Node[] { * @param {BlockInstance} block The block instance to apply the link to. * @param {SmartLink} link The link suggestion to apply. * @param {HTMLElement} htmlNode The HTML node to apply to the block. + * + * @return {string|undefined} The updated block content, or `undefined` if the block content could not be updated. */ -export function applyNodeToBlock( block: BlockInstance, link: SmartLink, htmlNode: HTMLElement ) { +export function applyNodeToBlock( + block: BlockInstance, + link: SmartLink, + htmlNode: HTMLElement +): string|undefined { const blockContent: string = getBlockContent( block ); const doc = new DOMParser().parseFromString( blockContent, 'text/html' ); @@ -453,6 +459,11 @@ function getLinkOffset( link: HTMLAnchorElement, document: Document ): number { return -1; } +/** + * Represents the return type of the `validateAndFixSmartLinks` function. + * + * @since 3.16.0 + */ type ValidateAndFixSmartLinksReturnType = { missingSmartLinks: SmartLink[], didAnyFixes: boolean From f2ef3f0f8c6edf62a54770b608bb53e972017499 Mon Sep 17 00:00:00 2001 From: Henrique Mouta Date: Thu, 6 Jun 2024 11:37:21 +0100 Subject: [PATCH 44/44] Fix tests (hopefully) --- jest.config.js | 5 +++++ jest.setup.js | 2 ++ 2 files changed, 7 insertions(+) create mode 100644 jest.setup.js diff --git a/jest.config.js b/jest.config.js index d4b0472b2..76088444a 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,4 +5,9 @@ module.exports = { ...baseConfig, silent: false, verbose: true, + globals: { TextEncoder, TextDecoder }, + setupFiles: [ './jest.setup.js' ], + transformIgnorePatterns: [ + 'node_modules/(?!(client-zip)/)', + ], }; diff --git a/jest.setup.js b/jest.setup.js new file mode 100644 index 000000000..57b3912f0 --- /dev/null +++ b/jest.setup.js @@ -0,0 +1,2 @@ +// eslint-disable-next-line @typescript-eslint/no-var-requires +global.TextDecoder = require( 'util' ).TextDecoder;