← Back
Editing: editor-audits.js
(function(_elementor_editor_floating_panels, _elementor_store, _elementor_editor_app_bar, _wordpress_i18n, react, _elementor_icons, _elementor_ui, _elementor_editor_elements, _elementor_http_client, _elementor_editor_props, _elementor_session, _elementor_editor_notifications, _elementor_editor_v1_adapters, _elementor_events, _elementor_editor_mcp) { //#region \0rolldown/runtime.js var __create = Object.create; var __defProp = Object.defineProperty; var __name = (target, value) => __defProp(target, "name", { value, configurable: true }); var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf; var __hasOwnProp = Object.prototype.hasOwnProperty; var __exportAll = (all, no_symbols) => { let target = {}; for (var name in all) { __defProp(target, name, { get: all[name], enumerable: true }); } if (!no_symbols) { __defProp(target, Symbol.toStringTag, { value: "Module" }); } return target; }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) { key = keys[i]; if (!__hasOwnProp.call(to, key) && key !== except) { __defProp(to, key, { get: ((k) => from[k]).bind(null, key), enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } } } return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod)); //#endregion react = __toESM(react); //#region packages/packages/core/editor-audits/src/store/slice.ts var initialState = { status: "idle", report: null, error: null, isStale: false }; var slice = (0, _elementor_store.__createSlice)({ name: "audits", initialState, reducers: { runStarted(state) { state.status = "loading"; state.error = null; }, runSucceeded(state, action) { state.status = "ready"; state.report = action.payload; state.isStale = false; }, runFailed(state, action) { state.status = "error"; state.error = action.payload; }, runAborted(state) { state.status = state.report ? "ready" : "idle"; }, reportRestored(state, action) { state.status = "ready"; state.report = action.payload; state.error = null; state.isStale = false; }, reportCleared(state) { state.status = "idle"; state.report = null; state.error = null; state.isStale = false; }, reportStale(state) { if (state.report) state.isStale = true; } } }); //#endregion //#region packages/packages/core/editor-audits/src/store/selectors.ts function selectStatus(state) { return state.audits.status; } function selectReport(state) { return state.audits.report; } function selectError(state) { return state.audits.error; } function selectIsStale(state) { return state.audits.isStale; } //#endregion //#region packages/packages/core/editor-audits/src/components/audit-toggle-icon.tsx function AuditToggleIcon() { const isStale = (0, _elementor_store.__useSelector)((state) => selectIsStale(state)); return /* @__PURE__ */ react.createElement(_elementor_ui.Badge, { variant: "dot", color: "warning", invisible: !isStale, overlap: "circular", slotProps: { badge: { "data-testid": "audit-stale-indicator" } } }, /* @__PURE__ */ react.createElement(_elementor_icons.ShieldCheckIcon, null)); } //#endregion //#region packages/packages/core/editor-audits/src/constants.ts var AUDIT_PANEL_ID = "audit-panel"; var REPORT_STORAGE_KEY_PREFIX = "elementor/audits/report"; var CREATE_WIDGET_EVENT = "elementor/editor/create-widget"; var ANGIE_FIX_ENTRY_POINT = "audit_violation"; var FEEDBACK_EXPERIMENT_NAME = "in_editor_feedback"; var FEEDBACK_ENTRY_POINT = "audit_panel"; var FEEDBACK_CLICKED_EVENT = "audit_feedback_clicked"; var FEEDBACK_SENT_EVENT = "audit_feedback_sent"; var FEEDBACK_CANCELLED_EVENT = "audit_feedback_cancelled"; var FEEDBACK_CLOSED_EVENT = "audit_feedback_closed"; var ALL_CATEGORIES = [ "best-practices", "seo", "accessibility", "performance", "compliance" ]; var CATEGORY_LABELS = { "best-practices": (0, _wordpress_i18n.__)("Best Practices", "elementor"), seo: (0, _wordpress_i18n.__)("SEO", "elementor"), accessibility: (0, _wordpress_i18n.__)("Accessibility", "elementor"), performance: (0, _wordpress_i18n.__)("Performance", "elementor"), compliance: (0, _wordpress_i18n.__)("Site compliance", "elementor") }; //#endregion //#region packages/packages/core/editor-audits/src/utils/window-config.ts function getWindowConfig() { const config = window.elementorAudits; if (!config) return { restNamespace: "elementor/v1", nonce: "" }; return config; } //#endregion //#region packages/packages/core/editor-audits/src/utils/session-expiration.ts var NONCE_INVALID_CODE = "rest_cookie_invalid_nonce"; var DEFAULT_AJAX_URL = "/wp-admin/admin-ajax.php"; var SessionExpiredError = class extends Error {}; var nonceRefreshPromise = null; function isNonceInvalidError(error) { const response = error?.response; return response?.status === 403 && response?.data?.code === NONCE_INVALID_CODE; } async function refreshAuditsNonce() { if (nonceRefreshPromise) return nonceRefreshPromise; nonceRefreshPromise = requestFreshNonce(); try { return await nonceRefreshPromise; } finally { nonceRefreshPromise = null; } } async function requestFreshNonce() { const ajaxUrl = window.elementorCommon?.ajax?.config?.url ?? DEFAULT_AJAX_URL; const url = new URL(ajaxUrl, window.location.origin); url.searchParams.set("action", "rest-nonce"); const response = await fetch(url.toString(), { credentials: "same-origin" }); if (!response.ok) throw new Error(`Failed to refresh audits nonce: HTTP ${response.status}`); const nonce = await response.text(); if (!nonce || "0" === nonce) throw new SessionExpiredError("Session expired — received invalid nonce"); window.elementorAudits = { ...getWindowConfig(), nonce }; return nonce; } //#endregion //#region packages/packages/core/editor-audits/src/api/page-context-client.ts async function fetchPageContext(documentId, imageSizeRequests) { return requestPageContext(documentId, imageSizeRequests, true); } async function requestPageContext(documentId, imageSizeRequests, allowNonceRetry) { const { restNamespace, nonce } = getWindowConfig(); const url = `${restNamespace}/audits/page-context`; try { return (await (0, _elementor_http_client.httpService)().get(url, { params: { document_id: documentId, image_size_requests: imageSizeRequests }, headers: { "X-WP-Nonce": nonce } })).data; } catch (error) { if (!allowNonceRetry || !isNonceInvalidError(error)) throw error; await refreshAuditsNonce(); return requestPageContext(documentId, imageSizeRequests, false); } } //#endregion //#region packages/packages/core/editor-audits/src/registry.ts var registry = /* @__PURE__ */ new Map(); function registerAudit(audit) { registry.set(audit.id, audit); } function getRegisteredAudits() { return Array.from(registry.values()); } //#endregion //#region packages/packages/core/editor-audits/src/utils/is-scored-audit.ts function isScoredAudit(audit) { return audit.weight > 0; } //#endregion //#region packages/packages/core/editor-audits/src/utils/sort-failed-audits.ts var SEVERITY_SORTING_RANK = { error: 0, warning: 1, info: 2 }; function sortFailedAuditResults(results) { return [...results].sort((a, b) => { const rankDiff = SEVERITY_SORTING_RANK[a.audit.severity] - SEVERITY_SORTING_RANK[b.audit.severity]; if (rankDiff !== 0) return rankDiff; return a.audit.title.localeCompare(b.audit.title); }); } //#endregion //#region packages/packages/core/editor-audits/src/utils/audit-status-summary.ts function partitionAuditResults(report, options = {}) { const { category, sortFailed = true } = options; const failed = []; const passed = []; const skipped = []; let totalViolations = 0; for (const run of report.auditResults) { if (category && !run.audit.categories.includes(category)) continue; switch (run.result.status) { case "fail": failed.push({ ...run, result: run.result }); if (isScoredAudit(run.audit)) totalViolations += run.result.violations.length; break; case "pass": passed.push({ ...run, result: run.result }); break; case "skipped": skipped.push({ ...run, result: run.result }); break; } } return { failed: sortFailed ? sortFailedAuditResults(failed) : failed, passed, skipped, totalViolations }; } function getPopulatedCategories(categoryTotals, categories) { return categories.filter((category) => categoryTotals[category].total > 0); } //#endregion //#region packages/packages/core/editor-audits/src/utils/compute-report.ts function computeReport(documentId, results) { const accumulators = Object.fromEntries(ALL_CATEGORIES.map((c) => [c, { totalWeight: 0, passedWeight: 0, total: 0, failed: 0 }])); for (const { audit, result } of results) { if (result.status === "skipped") continue; for (const category of audit.categories) { const acc = accumulators[category]; acc.total++; acc.totalWeight += audit.weight; if (result.status === "pass") acc.passedWeight += audit.weight; else acc.failed++; } } const categories = Object.fromEntries(ALL_CATEGORIES.map((c) => { const acc = accumulators[c]; return [c, { score: acc.totalWeight === 0 ? 0 : Math.round(acc.passedWeight / acc.totalWeight * 100), failed: acc.failed, total: acc.total }]; })); const populated = getPopulatedCategories(categories, ALL_CATEGORIES); const overall = populated.length === 0 ? 0 : Math.round(populated.reduce((sum, c) => sum + categories[c].score, 0) / populated.length); return { documentId, runAt: Date.now(), overall, categories, auditResults: results }; } //#endregion //#region packages/packages/core/editor-audits/src/utils/fetch-rendered-html.ts var FETCH_TIMEOUT_MS = 1e4; async function fetchRenderedHtml(url) { if (!url) return null; const timeoutController = new AbortController(); const timeoutId = setTimeout(() => timeoutController.abort(), FETCH_TIMEOUT_MS); try { const response = await fetch(url, { credentials: "omit", signal: timeoutController.signal }); if (!response.ok) return null; return await response.text(); } catch { return null; } finally { clearTimeout(timeoutId); } } //#endregion //#region packages/packages/core/editor-audits/src/utils/walk.ts function walkElements(tree, visit) { recurse(tree, [], visit); } function recurse(nodes, parents, visit) { for (const node of nodes) { visit(node, parents); parents.push(node); recurse(node.elements, parents, visit); parents.pop(); } } //#endregion //#region packages/packages/core/editor-audits/src/utils/atomic-image-sources.ts var ATOMIC_CONTENT_IMAGE_PROP_KEYS = ["image"]; var ATOMIC_IMAGE_PROP_KEYS = [...ATOMIC_CONTENT_IMAGE_PROP_KEYS, "poster"]; function walkAtomicImageSources(tree, visit, propKeys = ATOMIC_IMAGE_PROP_KEYS) { walkElements(tree, (node) => { if (node.elType !== "widget") return; for (const key of propKeys) { const media = extractAtomicImageMedia(node.settings[key]); if (media) visit({ node, media }); } }); } function extractAtomicImageMedia(imageProp) { const image = _elementor_editor_props.imagePropTypeUtil.extract(imageProp); if (!image) return null; const src = _elementor_editor_props.imageSrcPropTypeUtil.extract(image.src); if (!src) return null; const id = _elementor_editor_props.imageAttachmentIdPropType.extract(src.id) ?? void 0; const url = _elementor_editor_props.urlPropTypeUtil.extract(src.url) ?? void 0; if (!id && !url) return null; return { id, url, alt: _elementor_editor_props.stringPropTypeUtil.extract(src.alt) ?? void 0, size: _elementor_editor_props.stringPropTypeUtil.extract(image.size) ?? void 0 }; } //#endregion //#region packages/packages/core/editor-audits/src/utils/atomic-background-image-sources.ts function walkAtomicBackgroundImageSources(tree, visit) { walkElements(tree, (node) => { const styles = (0, _elementor_editor_elements.getElementStyles)(node.id); if (!styles) return; for (const media of extractBackgroundImageMedia(styles)) visit({ node, media }); }); } function extractBackgroundImageMedia(styles) { const sources = []; for (const style of Object.values(styles)) for (const variant of style.variants) { const background = _elementor_editor_props.backgroundPropTypeUtil.extract(variant.props.background); const overlays = _elementor_editor_props.backgroundOverlayPropTypeUtil.extract(background?.["background-overlay"]) ?? []; for (const overlay of overlays) { const media = extractAtomicImageMedia(_elementor_editor_props.backgroundImageOverlayPropTypeUtil.extract(overlay)?.image); if (media) sources.push(media); } } return sources; } //#endregion //#region packages/packages/core/editor-audits/src/utils/background-image-sources.ts var BACKGROUND_IMAGE_SETTING_KEYS = [ "background_image", "background_hover_image", "background_overlay_image", "background_overlay_hover_image", "_background_image", "_background_hover_image" ]; function walkBackgroundImageSources(tree, visit) { walkElements(tree, (node) => { for (const key of BACKGROUND_IMAGE_SETTING_KEYS) { const media = node.settings[key]; if (media?.id || media?.url) visit({ node, media }); } }); } //#endregion //#region packages/packages/core/editor-audits/src/utils/image-like-sources.ts var IMAGE_LIKE_WIDGETS = /* @__PURE__ */ new Set([ "image", "image-box", "image-carousel", "gallery", "image-gallery" ]); function walkImageLikeSources(tree, visit) { walkElements(tree, (node) => { if (node.elType !== "widget") return; if (!IMAGE_LIKE_WIDGETS.has(node.widgetType ?? "")) return; for (const media of collectMediaFromNode(node)) visit({ node, media }); }); } function collectMediaFromNode(node) { const sources = []; const image = node.settings.image; if (image?.id || image?.url) sources.push({ ...image, size: node.settings.image_size }); const gallery = node.settings.carousel ?? node.settings.gallery ?? node.settings.wp_gallery; if (Array.isArray(gallery)) { const gallerySize = node.settings.thumbnail_size; for (const item of gallery) if (item?.id || item?.url) sources.push({ ...item, size: gallerySize }); } return sources; } //#endregion //#region packages/packages/core/editor-audits/src/utils/all-image-sources.ts function walkAllImageSources(tree, visit) { walkImageLikeSources(tree, visit); walkBackgroundImageSources(tree, visit); walkAtomicImageSources(tree, visit); walkAtomicBackgroundImageSources(tree, visit); } //#endregion //#region packages/packages/core/editor-audits/src/utils/image-size-key.ts function buildImageSizeKey({ id, size }) { return `${id}:${size || "full"}`; } //#endregion //#region packages/packages/core/editor-audits/src/utils/page-attachments.ts function extractImageSizeRequests(tree) { const keys = /* @__PURE__ */ new Set(); walkAllImageSources(tree, ({ media }) => { if (media.id) keys.add(buildImageSizeKey({ id: media.id, size: media.size })); }); return Array.from(keys).sort(); } //#endregion //#region packages/packages/core/editor-audits/src/utils/read-kit-snapshot.ts function hasNonEmptyGlobalValue(item) { return item.value.length > 0; } async function readKitSnapshot(kitId) { const [colorsFromApi, fontsFromApi] = await Promise.all([readGlobalsFromApi("globals/colors", mapApiColor, hasNonEmptyGlobalValue), readGlobalsFromApi("globals/typography", mapApiTypography, hasNonEmptyGlobalValue)]); const documentSettings = colorsFromApi.length === 0 || fontsFromApi.length === 0 ? getKitDocumentSettings(kitId) : null; return { id: kitId, globals: { colors: colorsFromApi.length > 0 ? colorsFromApi : readColorsFromKitDocumentSettings(documentSettings), fonts: fontsFromApi.length > 0 ? fontsFromApi : readFontsFromKitDocumentSettings(documentSettings) } }; } async function readGlobalsFromApi(command, mapItem, hasValue) { const $e = window.$e; if (!$e?.data?.get) return []; try { const data = (await $e.data.get(command))?.data ?? {}; return Object.values(data).map((item) => mapItem(item)).filter(hasValue); } catch { return []; } } function mapApiColor(item) { return { id: item.id, value: item.value ?? "", title: item.title ?? item.id }; } function mapApiTypography(item) { return { id: item.id, value: item.value?.typography_font_family ?? "", title: item.title ?? item.id }; } function readColorsFromKitDocumentSettings(settings) { if (!settings) return []; return [...settings.system_colors ?? [], ...settings.custom_colors ?? []].map((row) => ({ id: row._id, value: row.color, title: row.title ?? row._id })).filter(hasNonEmptyGlobalValue); } function readFontsFromKitDocumentSettings(settings) { if (!settings) return []; return [...settings.system_typography ?? [], ...settings.custom_typography ?? []].map((row) => ({ id: row._id, value: row.typography_font_family ?? "", title: row.title ?? row._id })).filter(hasNonEmptyGlobalValue); } function getKitDocumentSettings(kitId) { return (window.elementor?.documents?.get?.(kitId))?.config?.settings?.settings ?? null; } //#endregion //#region packages/packages/core/editor-audits/src/utils/v1-snapshot.ts function buildSnapshotTree(elements) { if (elements.length === 0) return []; return (elements[0].children ?? []).map(toSnapshot); } function toSnapshot(element) { const model = element.model; const settings = element.settings?.toJSON?.() ?? {}; return { id: element.id, elType: model.get("elType") ?? "", widgetType: model.get("widgetType"), settings, elements: (element.children ?? []).map(toSnapshot) }; } //#endregion //#region packages/packages/core/editor-audits/src/runner.ts async function runPageAudit(documentId) { if (documentId !== (0, _elementor_editor_elements.getHostDocumentId)()) throw new Error("runPageAudit: documentId must match the host document."); const tree = buildSnapshotTree((0, _elementor_editor_elements.getHostDocumentElements)()); const pageContext = await fetchPageContext(documentId, extractImageSizeRequests(tree)); const elements = { documentId, tree }; const [kit, renderedHtml] = await Promise.all([readKitSnapshot(pageContext.kit_id), fetchRenderedHtml(pageContext.frontend_url)]); const ctx = { documentId, elements, pageContext, kit, renderedHtml }; const registered = getRegisteredAudits(); return computeReport(documentId, await Promise.all(registered.map(async (audit) => { const { evaluate: _evaluate, ...meta } = audit; try { return { audit: meta, result: await audit.evaluate(ctx) }; } catch (error) { return { audit: meta, result: { status: "skipped", reason: error instanceof Error ? error.message : "unknown-error" } }; } }))); } //#endregion //#region packages/packages/core/editor-audits/src/utils/report-storage.ts function getStorageKey(documentId) { return `${REPORT_STORAGE_KEY_PREFIX}/${documentId}`; } function getPersistedReport(documentId) { return (0, _elementor_session.getSessionStorageItem)(getStorageKey(documentId)) ?? null; } function persistReport(documentId, report) { (0, _elementor_session.setSessionStorageItem)(getStorageKey(documentId), report); } //#endregion //#region packages/packages/core/editor-audits/src/hooks/use-audit-report.ts function useAuditReport() { const status = (0, _elementor_store.__useSelector)((state) => selectStatus(state)); const report = (0, _elementor_store.__useSelector)((state) => selectReport(state)); const error = (0, _elementor_store.__useSelector)((state) => selectError(state)); const isStale = (0, _elementor_store.__useSelector)((state) => selectIsStale(state)); const dispatch = (0, _elementor_store.__useDispatch)(); const documentId = (0, _elementor_editor_elements.getHostDocumentId)() ?? 0; (0, react.useEffect)(() => { if (!documentId || report?.documentId === documentId) return; const persisted = getPersistedReport(documentId); if (persisted) dispatch(slice.actions.reportRestored(persisted)); else if (report) dispatch(slice.actions.reportCleared()); }, [ documentId, report, dispatch ]); const run = async (documentIdToRun) => { dispatch(slice.actions.runStarted()); try { const nextReport = await runPageAudit(documentIdToRun); dispatch(slice.actions.runSucceeded(nextReport)); persistReport(documentIdToRun, nextReport); } catch (e) { if (e instanceof SessionExpiredError) { dispatch(slice.actions.runAborted()); return; } dispatch(slice.actions.runFailed(e instanceof Error ? e.message : "Unknown error")); } }; return { status, report, error, isStale, run }; } //#endregion //#region packages/packages/core/editor-audits/src/components/audit-feedback.tsx var FEEDBACK_SUBJECT = "Page Audit Tool"; var FEEDBACK_SUBJECT_LABEL = (0, _wordpress_i18n.__)("Page Audit Tool", "elementor"); var SUCCESS_NOTIFICATION_ID = "audit-feedback-success"; var ERROR_NOTIFICATION_ID = "audit-feedback-error"; var DIALOG_TITLE_ID = "audit-feedback-dialog-title"; var DIALOG_DESCRIPTION_ID = "audit-feedback-dialog-description"; var isUserConnected = () => Boolean(window.elementorCommon?.config?.library_connect?.is_connected || window.elementorPro?.config?.isActive); var notifySuccess = () => (0, _elementor_editor_notifications.notify)({ id: SUCCESS_NOTIFICATION_ID, type: "success", message: (0, _wordpress_i18n.__)("Feedback sent. Thanks for helping us out.", "elementor") }); var notifyError = () => (0, _elementor_editor_notifications.notify)({ id: ERROR_NOTIFICATION_ID, type: "error", message: (0, _wordpress_i18n.__)("Something went wrong. Please try sending your feedback again.", "elementor") }); function AuditFeedback() { const [isOpen, setIsOpen] = (0, react.useState)(false); const [feedbackText, setFeedbackText] = (0, react.useState)(""); const [isSubmitting, setIsSubmitting] = (0, react.useState)(false); const { dispatchEvent: trackEvent = (...args) => void 0 } = (0, _elementor_events.useMixpanel)(); const panelZIndex = (0, _elementor_editor_floating_panels.useFloatingPanelZIndex)(AUDIT_PANEL_ID); if (!(0, _elementor_editor_v1_adapters.isExperimentActive)("in_editor_feedback")) return null; const connected = isUserConnected(); const connectUrl = window.elementor?.config?.user?.top_bar?.connect_url; if (!connected && !connectUrl) return null; const triggerLabel = (0, _wordpress_i18n.__)("Give feedback", "elementor"); const handleOpen = () => { if (!connected) { window.open(connectUrl, "_blank", "noopener"); trackEvent(FEEDBACK_CLICKED_EVENT, { entry_point: FEEDBACK_ENTRY_POINT, connected: false }); return; } setIsOpen(true); trackEvent(FEEDBACK_CLICKED_EVENT, { entry_point: FEEDBACK_ENTRY_POINT, connected: true }); }; const dismiss = (eventName) => { setIsOpen(false); setFeedbackText(""); trackEvent(eventName, { entry_point: FEEDBACK_ENTRY_POINT }); }; const handleCancel = () => dismiss(FEEDBACK_CANCELLED_EVENT); const handleClose = () => dismiss(FEEDBACK_CLOSED_EVENT); const handleSubmit = () => { setIsSubmitting(true); (0, _elementor_http_client.httpService)().post("elementor/v1/feedback/submit", { subject: FEEDBACK_SUBJECT, description: feedbackText.trim() }).then((response) => { if (!response.data.success) { notifyError(); return; } setIsOpen(false); setFeedbackText(""); notifySuccess(); trackEvent(FEEDBACK_SENT_EVENT, { entry_point: FEEDBACK_ENTRY_POINT }); }).catch(notifyError).finally(() => setIsSubmitting(false)); }; return /* @__PURE__ */ react.createElement(react.Fragment, null, /* @__PURE__ */ react.createElement(_elementor_ui.Tooltip, { title: triggerLabel, placement: "top", PopperProps: { sx: { zIndex: panelZIndex } } }, /* @__PURE__ */ react.createElement(_elementor_ui.IconButton, { size: "small", "aria-label": triggerLabel, onClick: handleOpen }, /* @__PURE__ */ react.createElement(_elementor_icons.MessageLinesIcon, { fontSize: "small" }))), /* @__PURE__ */ react.createElement(_elementor_ui.Dialog, { open: isOpen, onClose: handleClose, "aria-labelledby": DIALOG_TITLE_ID, "aria-describedby": DIALOG_DESCRIPTION_ID, PaperProps: { sx: { borderRadius: 1 } } }, /* @__PURE__ */ react.createElement(_elementor_ui.DialogHeader, { logo: false, onClose: handleClose }, /* @__PURE__ */ react.createElement(_elementor_ui.DialogTitle, { id: DIALOG_TITLE_ID }, (0, _wordpress_i18n.__)("Let us know what you think", "elementor"))), /* @__PURE__ */ react.createElement(_elementor_ui.DialogContent, { dividers: true }, /* @__PURE__ */ react.createElement(_elementor_ui.Stack, { direction: "column", gap: 2 }, /* @__PURE__ */ react.createElement(_elementor_ui.TextField, { value: FEEDBACK_SUBJECT_LABEL, disabled: true, fullWidth: true, size: "small" }), /* @__PURE__ */ react.createElement(_elementor_ui.TextField, { placeholder: (0, _wordpress_i18n.__)("Tell us what you had in mind, what we can improve or fix to make this feature better.", "elementor"), fullWidth: true, multiline: true, rows: 4, disabled: isSubmitting, onChange: (event) => setFeedbackText(event.target.value), value: feedbackText }), /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { id: DIALOG_DESCRIPTION_ID, variant: "caption", color: "text.secondary" }, (0, _wordpress_i18n.__)("We appreciate your feedback! While we review all submissions, we can't guarantee that every suggestion will result in a change or update.", "elementor")))), /* @__PURE__ */ react.createElement(_elementor_ui.DialogActions, null, /* @__PURE__ */ react.createElement(_elementor_ui.Button, { variant: "text", color: "secondary", onClick: handleCancel }, (0, _wordpress_i18n.__)("Cancel", "elementor")), /* @__PURE__ */ react.createElement(_elementor_ui.Button, { variant: "contained", color: "primary", disabled: isSubmitting || feedbackText.trim().length === 0, onClick: handleSubmit }, (0, _wordpress_i18n.__)("Send", "elementor"))))); } //#endregion //#region packages/packages/core/editor-audits/src/components/pages/error-page.tsx function ErrorPage({ message, onRetry }) { return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { display: "flex", flexDirection: "column", alignItems: "center", gap: 1.5, p: 4 } }, /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "body2", color: "error", textAlign: "center" }, message), /* @__PURE__ */ react.createElement(_elementor_ui.Button, { variant: "contained", size: "small", onClick: onRetry }, (0, _wordpress_i18n.__)("Try again", "elementor"))); } //#endregion //#region packages/packages/core/editor-audits/src/components/pages/loading-page.tsx function LoadingPage() { return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { display: "flex", flexDirection: "column", alignItems: "center", gap: 1.5, p: 4 } }, /* @__PURE__ */ react.createElement(_elementor_ui.CircularProgress, { size: 32 }), /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "body2" }, (0, _wordpress_i18n.__)("Audit in progress.", "elementor"))); } //#endregion //#region packages/packages/core/editor-audits/src/components/pages/welcome-page.tsx var INFORMATION_IMAGE_PATH = "images/information.svg"; function WelcomePage() { const assetsUrl = window.elementorCommon?.config?.urls?.assets ?? ""; return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", gap: 1, p: 3 } }, /* @__PURE__ */ react.createElement("img", { className: "elementor-nerd-box-icon", src: `${assetsUrl}${INFORMATION_IMAGE_PATH}`, loading: "lazy", alt: (0, _wordpress_i18n.__)("Elementor", "elementor") }), /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "subtitle1", component: "h3", sx: { marginBlockStart: 2 } }, (0, _wordpress_i18n.__)("Audit your page!", "elementor")), /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "caption", textAlign: "center" }, (0, _wordpress_i18n.__)("Check SEO, accessibility, performance, and best practices. Click \"Run page audit\" to begin.", "elementor"))); } //#endregion //#region packages/packages/core/editor-audits/src/hooks/use-single-expanded-card.ts function useSingleExpandedCard(initialId = null) { const [expandedId, setExpandedId] = (0, react.useState)(initialId); const toggle = (id) => { setExpandedId((current) => current === id ? null : id); }; return { expandedId, toggle }; } //#endregion //#region packages/packages/core/editor-audits/src/components/category-icons.ts var CATEGORY_ICONS = { "best-practices": _elementor_icons.Settings2Icon, seo: _elementor_icons.FileSearchIcon, accessibility: _elementor_icons.ElementorAccessibilityIcon, performance: _elementor_icons.BoltIcon, compliance: _elementor_icons.ShieldCheckIcon }; //#endregion //#region packages/packages/core/editor-audits/src/components/status-section.tsx function StatusSection({ label, count, color = "default", defaultExpanded = false, children }) { const [expanded, setExpanded] = (0, react.useState)(defaultExpanded); if (react.Children.count(children) === 0) return null; return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { paddingBlock: 1 } }, /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { display: "flex", alignItems: "center", gap: .5, cursor: "pointer" }, onClick: () => setExpanded((v) => !v) }, /* @__PURE__ */ react.createElement(_elementor_ui.IconButton, { size: "small", "aria-label": expanded ? (0, _wordpress_i18n.__)("Collapse", "elementor") : (0, _wordpress_i18n.__)("Expand", "elementor") }, /* @__PURE__ */ react.createElement(_elementor_icons.ChevronDownIcon, { fontSize: "small", sx: { transform: expanded ? "rotate(180deg)" : void 0, transition: "transform .2s" } })), /* @__PURE__ */ react.createElement(_elementor_ui.Chip, { label: `${label} (${count})`, size: "small", color, variant: "standard" })), /* @__PURE__ */ react.createElement(_elementor_ui.Collapse, { in: expanded }, /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { paddingInlineStart: 4.25, paddingBlock: 2 } }, children))); } //#endregion //#region packages/packages/core/editor-audits/src/components/subpage-header.tsx function SubpageHeader({ title, onBack, backLabel, icon }) { const isRtl = "rtl" === (0, _elementor_ui.useTheme)().direction; return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { display: "flex", alignItems: "center", gap: .5, p: 1 } }, /* @__PURE__ */ react.createElement(_elementor_ui.IconButton, { size: "small", onClick: onBack, "aria-label": backLabel ?? (0, _wordpress_i18n.__)("Back", "elementor") }, /* @__PURE__ */ react.createElement(_elementor_ui.Rotate, { in: isRtl }, /* @__PURE__ */ react.createElement(_elementor_icons.ArrowLeftIcon, { fontSize: "small" }))), icon, /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "subtitle2", fontWeight: "bold" }, title)); } //#endregion //#region packages/packages/core/editor-audits/src/hooks/focus-violation.ts var SCROLL_TO_VIEW_DELAY_MS = 200; function focusViolation(violation) { if (violation.elementId) { const container = (0, _elementor_editor_elements.getContainer)(violation.elementId); if (container) { (0, _elementor_editor_elements.selectElement)(violation.elementId); const domElement = container.view?.getDomElement?.(); if (domElement) window.elementor?.helpers?.scrollToView?.(domElement, SCROLL_TO_VIEW_DELAY_MS); } if (violation.targetHint === "element-settings") (0, _elementor_editor_v1_adapters.__privateRunCommand)("panel/editor/open"); return; } if (violation.externalUrl) { window.open(violation.externalUrl, "_blank"); return; } if (violation.targetHint === "page-settings") { (0, _elementor_editor_v1_adapters.__privateOpenRoute)("panel/page-settings/settings"); return; } if (violation.targetHint === "site-settings") { (0, _elementor_editor_v1_adapters.__privateRunCommand)("panel/global/open"); return; } if (violation.targetHint === "site-identity-settings") (0, _elementor_editor_v1_adapters.__privateRunCommand)("panel/global/open").then(() => { (0, _elementor_editor_v1_adapters.__privateOpenRoute)("panel/global/settings-site-identity"); }); } //#endregion //#region packages/packages/core/editor-audits/src/utils/build-angie-prompt.ts function buildAngiePrompt(violationText) { return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Help me fix: %s", "elementor"), violationText); } //#endregion //#region packages/packages/core/editor-audits/src/utils/keyboard-click.ts function onKeyboardClick(callback) { return (event) => { if (event.key === "Enter" || event.key === " ") { event.preventDefault(); callback(); } }; } //#endregion //#region packages/packages/core/editor-audits/src/components/fix-violation-with-angie.tsx function FixViolationWithAngie({ prompt, panelZIndex, variant = "icon" }) { const label = (0, _wordpress_i18n.__)("Fix with Angie", "elementor"); const href = `#angie-prompt=${encodeURIComponent(prompt)}`; const handleClick = (event) => { event.stopPropagation(); event.preventDefault(); if ((0, _elementor_editor_mcp.isAngieAvailable)()) { (0, _elementor_editor_mcp.sendPromptToAngie)(prompt); return; } window.dispatchEvent(new CustomEvent(CREATE_WIDGET_EVENT, { detail: { entry_point: ANGIE_FIX_ENTRY_POINT, prompt } })); }; if (variant === "button") return /* @__PURE__ */ react.createElement(_elementor_ui.Button, { component: "a", href, size: "small", color: "secondary", variant: "outlined", startIcon: /* @__PURE__ */ react.createElement(_elementor_icons.AngieIcon, { fontSize: "tiny", "aria-hidden": true }), onClick: handleClick }, label); return /* @__PURE__ */ react.createElement(_elementor_ui.Tooltip, { title: label, placement: "top", PopperProps: { sx: { zIndex: panelZIndex } } }, /* @__PURE__ */ react.createElement(_elementor_ui.IconButton, { component: "a", href, size: "small", "aria-label": label, onClick: handleClick }, /* @__PURE__ */ react.createElement(_elementor_icons.AngieIcon, { fontSize: "tiny" }))); } //#endregion //#region packages/packages/core/editor-audits/src/components/severity-icons.tsx var SEVERITY_CONFIG = { error: { Icon: _elementor_icons.AlertTriangleFilledIcon, color: "error" }, warning: { Icon: _elementor_icons.AlertCircleIcon, color: "warning" }, info: { Icon: _elementor_icons.BulbIcon, color: "info" } }; var INFO_ICON_VERTICAL_NUDGE = "translateY(-2px)"; function SeverityIcon({ severity }) { const { Icon, color } = SEVERITY_CONFIG[severity]; const sx = "info" === severity ? { transform: INFO_ICON_VERTICAL_NUDGE } : void 0; return /* @__PURE__ */ react.createElement(Icon, { fontSize: "small", color, sx }); } //#endregion //#region packages/packages/core/editor-audits/src/components/violation-cta-button.tsx function ViolationCtaButton({ ctaLabel, externalUrl, variant = "outlined", withIcon = false }) { const handleClick = (event) => { event.stopPropagation(); event.preventDefault(); window.open(externalUrl, "_blank", "noopener"); }; return /* @__PURE__ */ react.createElement(_elementor_ui.Button, { variant, color: "secondary", size: "small", startIcon: withIcon ? /* @__PURE__ */ react.createElement(_elementor_icons.WandIcon, { fontSize: "tiny", "aria-hidden": true }) : void 0, onClick: handleClick }, ctaLabel); } //#endregion //#region packages/packages/core/editor-audits/src/components/violation-icons.tsx function ViolationIcon({ violation, widgetIcon }) { if (widgetIcon) return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { component: "i", className: widgetIcon, "aria-hidden": true, sx: { fontSize: "inherit", width: "1em", textAlign: "center" } }); if (violation.targetHint === "page-settings") return /* @__PURE__ */ react.createElement(_elementor_icons.FileSettingsIcon, { fontSize: "inherit", "aria-hidden": true }); if (violation.targetHint === "site-settings" || violation.targetHint === "site-identity-settings") return /* @__PURE__ */ react.createElement(_elementor_icons.SettingsIcon, { fontSize: "inherit", "aria-hidden": true }); return /* @__PURE__ */ react.createElement(_elementor_icons.SettingsIcon, { fontSize: "inherit", "aria-hidden": true }); } //#endregion //#region packages/packages/core/editor-audits/src/components/violation-row.tsx function SkipReasonTooltip({ reason }) { return /* @__PURE__ */ react.createElement(_elementor_ui.Tooltip, { title: reason, placement: "top" }, /* @__PURE__ */ react.createElement(_elementor_ui.Box, { "aria-label": reason, component: "span", sx: { display: "inline-flex", alignItems: "center" } }, /* @__PURE__ */ react.createElement(_elementor_icons.HelpIcon, { fontSize: "small", color: "action" }))); } function StatusIndicator({ audit, violations }) { if (violations) return /* @__PURE__ */ react.createElement(react.Fragment, null, /* @__PURE__ */ react.createElement(SeverityIcon, { severity: audit.severity }), isScoredAudit(audit) && /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "caption", color: "text.secondary", fontWeight: "bold" }, violations.length)); return /* @__PURE__ */ react.createElement(_elementor_icons.CheckIcon, { fontSize: "small", color: "success" }); } function GuidanceAction({ violation, sharedAngiePrompt, panelZIndex }) { const hasPrimaryCta = !!(violation.ctaLabel && violation.externalUrl); if (!hasPrimaryCta && !sharedAngiePrompt) return null; return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { display: "flex", alignItems: "center", gap: 1, mt: 1 }, hasPrimaryCta && /* @__PURE__ */ react.createElement(ViolationCtaButton, { ctaLabel: violation.ctaLabel, externalUrl: violation.externalUrl, withIcon: true }), hasPrimaryCta && violation.secondaryCtaLabel && violation.secondaryCtaUrl && /* @__PURE__ */ react.createElement(ViolationCtaButton, { ctaLabel: violation.secondaryCtaLabel, externalUrl: violation.secondaryCtaUrl, variant: "text" }), sharedAngiePrompt && /* @__PURE__ */ react.createElement(FixViolationWithAngie, { prompt: sharedAngiePrompt, panelZIndex, variant: "button" })); } function getSharedAngiePrompt(violations) { if (!violations || violations.length < 2) return; const [first, ...rest] = violations; if (!first.angieFix || !first.angiePrompt) return; return rest.every((violation) => violation.angieFix && violation.angiePrompt === first.angiePrompt) ? first.angiePrompt : void 0; } function ViolationRow({ audit, expanded, onToggleExpand, skipReason, violations }) { const primaryViolation = violations?.[0]; const isGuidanceFocusable = !!primaryViolation; const panelZIndex = (0, _elementor_editor_floating_panels.useFloatingPanelZIndex)(AUDIT_PANEL_ID); const sharedAngiePrompt = getSharedAngiePrompt(violations); const handleGuidanceClick = () => { if (isGuidanceFocusable && primaryViolation) focusViolation(primaryViolation); }; return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { borderBottom: 1, borderColor: "divider", paddingBlock: .5 } }, /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { display: "flex", alignItems: "center", gap: .5 } }, /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { alignItems: "center", cursor: "pointer", display: "flex", flex: 1, gap: .5, minWidth: 0 }, onClick: onToggleExpand }, /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "subtitle2", color: "text.secondary", sx: { flex: 1 } }, audit.title), !skipReason && /* @__PURE__ */ react.createElement(StatusIndicator, { audit, violations })), skipReason && /* @__PURE__ */ react.createElement(SkipReasonTooltip, { reason: skipReason }), /* @__PURE__ */ react.createElement(_elementor_ui.IconButton, { size: "small", "aria-label": expanded ? (0, _wordpress_i18n.__)("Collapse", "elementor") : (0, _wordpress_i18n.__)("Expand", "elementor"), onClick: onToggleExpand }, /* @__PURE__ */ react.createElement(_elementor_icons.ChevronDownIcon, { fontSize: "small", sx: { transform: expanded ? "rotate(180deg)" : void 0, transition: "transform .2s" } }))), /* @__PURE__ */ react.createElement(_elementor_ui.Collapse, { in: expanded }, /* @__PURE__ */ react.createElement(_elementor_ui.Box, { paddingBlock: 1 }, /* @__PURE__ */ react.createElement(_elementor_ui.Tooltip, { title: audit.fixHint, placement: "top" }, /* @__PURE__ */ react.createElement(_elementor_ui.Alert, { severity: "secondary", sx: { p: 1, cursor: isGuidanceFocusable ? "pointer" : void 0 }, icon: /* @__PURE__ */ react.createElement(_elementor_icons.InfoCircleIcon, { fontSize: "small", "aria-hidden": true }), role: isGuidanceFocusable ? "button" : void 0, tabIndex: isGuidanceFocusable ? 0 : void 0, onClick: isGuidanceFocusable ? handleGuidanceClick : void 0, onKeyDown: isGuidanceFocusable ? onKeyboardClick(handleGuidanceClick) : void 0 }, /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "caption", component: "p", color: "text.secondary" }, audit.description), primaryViolation && /* @__PURE__ */ react.createElement(GuidanceAction, { violation: primaryViolation, sharedAngiePrompt, panelZIndex })))), violations && violations.length > 0 && /* @__PURE__ */ react.createElement(_elementor_ui.Box, { role: "list", sx: { paddingBlockEnd: 1 } }, violations.map((violation, idx) => { const widgetIcon = violation.elementId ? (0, _elementor_editor_elements.getElementIcon)(violation.elementId) : null; const elementTitle = violation.elementId ? (0, _elementor_editor_elements.getElementTitle)(violation.elementId) : null; const displayLabel = elementTitle ?? violation.label; const angiePromptContext = elementTitle ? `${elementTitle} - ${violation.label}` : violation.label; const showsOwnFixAction = !!violation.angieFix && !sharedAngiePrompt; return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { key: idx, role: "button", tabIndex: 0, onClick: () => focusViolation(violation), onKeyDown: onKeyboardClick(() => focusViolation(violation)), sx: { display: "flex", alignItems: "center", gap: 1, paddingBlock: .5, paddingInline: 1, borderRadius: 1, cursor: "pointer", "&:hover": { bgcolor: "action.hover" }, "&:hover .violation-row-fix-action, &:focus-visible .violation-row-fix-action": { opacity: 1 } } }, /* @__PURE__ */ react.createElement(ViolationIcon, { violation, widgetIcon }), /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { flex: 1 } }, /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "caption" }, displayLabel), violation.detail && /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "caption", color: "text.secondary" }, violation.detail)), showsOwnFixAction && /* @__PURE__ */ react.createElement(_elementor_ui.Box, { className: "violation-row-fix-action", sx: { opacity: 0, transition: "opacity .15s" } }, /* @__PURE__ */ react.createElement(FixViolationWithAngie, { prompt: violation.angiePrompt ?? buildAngiePrompt(angiePromptContext), panelZIndex }))); })))); } //#endregion //#region packages/packages/core/editor-audits/src/components/pages/category-page.tsx function CategoryPage({ category, report, onBack }) { const Icon = CATEGORY_ICONS[category]; const { failed, passed, skipped, totalViolations } = partitionAuditResults(report, { category }); const { expandedId, toggle } = useSingleExpandedCard(); return /* @__PURE__ */ react.createElement(react.Fragment, null, /* @__PURE__ */ react.createElement(SubpageHeader, { title: CATEGORY_LABELS[category], onBack, backLabel: (0, _wordpress_i18n.__)("Back to all issues", "elementor"), icon: /* @__PURE__ */ react.createElement(Icon, { fontSize: "small", color: "action" }) }), /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { p: 1 } }, /* @__PURE__ */ react.createElement(StatusSection, { label: (0, _wordpress_i18n.__)("Failed audits", "elementor"), count: totalViolations, color: "error", defaultExpanded: true }, failed.map((r) => /* @__PURE__ */ react.createElement(ViolationRow, { key: r.audit.id, audit: r.audit, violations: r.result.violations, expanded: expandedId === r.audit.id, onToggleExpand: () => toggle(r.audit.id) }))), /* @__PURE__ */ react.createElement(StatusSection, { label: (0, _wordpress_i18n.__)("Passed audits", "elementor"), count: passed.length, color: "success" }, passed.map((r) => /* @__PURE__ */ react.createElement(ViolationRow, { key: r.audit.id, audit: r.audit, expanded: expandedId === r.audit.id, onToggleExpand: () => toggle(r.audit.id) }))), /* @__PURE__ */ react.createElement(StatusSection, { label: (0, _wordpress_i18n.__)("Skipped audits", "elementor"), count: skipped.length, color: "default" }, skipped.map((r) => /* @__PURE__ */ react.createElement(ViolationRow, { key: r.audit.id, audit: r.audit, skipReason: r.result.reason, expanded: expandedId === r.audit.id, onToggleExpand: () => toggle(r.audit.id) }))))); } //#endregion //#region packages/packages/core/editor-audits/src/utils/severity-counts.ts var ALL_SEVERITIES = [ "error", "warning", "info" ]; function countSeverities(report, category) { const counts = { error: 0, warning: 0, info: 0 }; for (const { audit, result } of report.auditResults) { if (result.status !== "fail") continue; if (category && !audit.categories.includes(category)) continue; if (!isScoredAudit(audit)) continue; counts[audit.severity] += result.violations.length; } return counts; } function severityPluralLabel(severity) { switch (severity) { case "error": return (0, _wordpress_i18n.__)("Errors", "elementor"); case "warning": return (0, _wordpress_i18n.__)("Warnings", "elementor"); case "info": return (0, _wordpress_i18n.__)("Suggestions", "elementor"); } } //#endregion //#region packages/packages/core/editor-audits/src/components/issues-category-row.tsx function IssuesCategoryRow({ category, label, counts, onClick }) { const isRtl = "rtl" === (0, _elementor_ui.useTheme)().direction; const Icon = CATEGORY_ICONS[category]; return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { role: "button", tabIndex: 0, onClick, onKeyDown: onKeyboardClick(onClick), sx: { display: "flex", alignItems: "center", gap: 1, px: 2, py: 1.5, cursor: "pointer", borderRadius: 1, border: 1, borderColor: "divider", "&:hover": { bgcolor: "action.hover" }, outline: "none", "&:focus-visible": { outline: "2px solid", outlineColor: "primary.main" } } }, /* @__PURE__ */ react.createElement(Icon, { fontSize: "small", color: "action" }), /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "body2", fontWeight: "bold", sx: { flex: 1 } }, label), /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { display: "flex", alignItems: "center", gap: .5 } }, ALL_SEVERITIES.filter((s) => counts[s] > 0).map((severity) => /* @__PURE__ */ react.createElement(_elementor_ui.Box, { key: severity, sx: { display: "flex", alignItems: "center", gap: .25 } }, /* @__PURE__ */ react.createElement(SeverityIcon, { severity }), /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "caption", color: "text.primary", fontWeight: "bold" }, counts[severity])))), /* @__PURE__ */ react.createElement(_elementor_ui.Rotate, { in: isRtl }, /* @__PURE__ */ react.createElement(_elementor_icons.ChevronRightIcon, { fontSize: "small", color: "action" }))); } //#endregion //#region packages/packages/core/editor-audits/src/register-promotions.ts function firstFailExternalUrl(run) { return run.result.status === "fail" ? run.result.violations[0]?.externalUrl : void 0; } var PROMOTIONS = [ { auditId: "audits/images-alt-text", icon: _elementor_icons.PhotoIcon, ctaLabel: (0, _wordpress_i18n.__)("Fix with Ally", "elementor"), formatSubtitle: (run) => { if (run.result.status !== "fail") return null; const count = run.result.metadata?.missingAltImageCount ?? 0; if (count === 0) return null; return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n._n)("%d image", "%d images", count, "elementor"), count); }, getCtaUrl: firstFailExternalUrl }, { auditId: "audits/cookie-policy", icon: _elementor_icons.ElementorCookieIcon, ctaLabel: (0, _wordpress_i18n.__)("Fix with Cookiez", "elementor"), formatSubtitle: (run) => run.result.status === "fail" ? (0, _wordpress_i18n.__)("Generate cookie policy", "elementor") : null, getCtaUrl: firstFailExternalUrl }, { auditId: "audits/scan-for-cookies", icon: _elementor_icons.ElementorCookieIcon, ctaLabel: (0, _wordpress_i18n.__)("Scan", "elementor"), formatSubtitle: (run) => run.result.status === "fail" ? (0, _wordpress_i18n.__)("Scan this page for cookies", "elementor") : null, getCtaUrl: firstFailExternalUrl }, { auditId: "audits/images-too-large", icon: _elementor_icons.ShieldHalfFilledIcon, ctaLabel: (0, _wordpress_i18n.__)("Optimize all", "elementor"), formatSubtitle: (run) => { if (run.result.status !== "fail") return null; const count = run.result.metadata?.oversizedImageCount ?? 0; if (count === 0) return null; return (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n._n)("%d image", "%d images", count, "elementor"), count); }, getCtaUrl: firstFailExternalUrl } ]; //#endregion //#region packages/packages/core/editor-audits/src/utils/find-audit-run.ts function findAuditRun(report, auditId) { return report.auditResults.find((run) => run.audit.id === auditId); } //#endregion //#region packages/packages/core/editor-audits/src/components/promotion-card.tsx function PromotionCard({ ctaDisabled, ctaLabel, icon: Icon, onCtaClick, subtitle, title }) { return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { alignItems: "center", border: 1, borderColor: "divider", borderRadius: 1, display: "flex", gap: 1, px: 2, py: 1.5 } }, /* @__PURE__ */ react.createElement(Icon, { fontSize: "small", color: "action" }), /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { display: "flex", flex: 1, flexDirection: "column", gap: .25, minWidth: 0 } }, /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "body2", fontWeight: "bold" }, title), /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "caption", color: "text.secondary" }, subtitle)), /* @__PURE__ */ react.createElement(_elementor_ui.Button, { variant: "outlined", color: "secondary", size: "small", disabled: ctaDisabled, onClick: onCtaClick }, ctaLabel)); } //#endregion //#region packages/packages/core/editor-audits/src/components/promotions.tsx function Promotions({ report }) { const cards = PROMOTIONS.flatMap((config) => { const run = findAuditRun(report, config.auditId); if (!run || run.result.status !== "fail") return []; const subtitle = config.formatSubtitle(run); if (!subtitle) return []; return [{ config, ctaUrl: config.getCtaUrl(run), key: config.auditId, run, subtitle }]; }); if (cards.length === 0) return null; return /* @__PURE__ */ react.createElement(react.Fragment, null, /* @__PURE__ */ react.createElement(_elementor_ui.Divider, null), /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "subtitle1", fontWeight: "bold" }, (0, _wordpress_i18n.__)("Quick actions", "elementor")), /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { display: "flex", flexDirection: "column", gap: 1 } }, cards.map(({ config, ctaUrl, key, run, subtitle }) => /* @__PURE__ */ react.createElement(PromotionCard, { key, icon: config.icon, title: run.audit.title, subtitle, ctaLabel: config.ctaLabel, ctaDisabled: !ctaUrl, onCtaClick: () => { if (ctaUrl) window.open(ctaUrl, "_blank"); } })))); } //#endregion //#region packages/packages/core/editor-audits/src/components/severity-summary-cards.tsx function SeveritySummaryCards({ report }) { const counts = countSeverities(report); return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { display: "flex", gap: 1.5 }, ALL_SEVERITIES.map((severity) => /* @__PURE__ */ react.createElement(SeverityCard, { key: severity, severity, count: counts[severity] }))); } function SeverityCard({ severity, count }) { return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { display: "flex", flex: 1, flexDirection: "column", gap: 1, bgcolor: "action.hover", borderRadius: 1.5, px: 1.5, py: 1 }, /* @__PURE__ */ react.createElement(SeverityIcon, { severity }), /* @__PURE__ */ react.createElement(_elementor_ui.Box, { display: "flex", flexDirection: "column" }, /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "h5", fontWeight: 700, component: "span" }, count), /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "caption", color: "text.secondary" }, severityPluralLabel(severity)))); } //#endregion //#region packages/packages/core/editor-audits/src/components/pages/overview-page.tsx function OverviewPage({ onCategoryClick, report }) { const categoryRows = getPopulatedCategories(report.categories, ALL_CATEGORIES).map((category) => ({ category, counts: countSeverities(report, category) })).filter(({ counts }) => Object.values(counts).some((count) => count > 0)); return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { display: "flex", flexDirection: "column", gap: 3, p: 2 }, /* @__PURE__ */ react.createElement(SeveritySummaryCards, { report }), /* @__PURE__ */ react.createElement(_elementor_ui.Box, { display: "flex", flexDirection: "column", gap: 1 }, /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "subtitle1", component: "h2" }, (0, _wordpress_i18n.__)("All issues", "elementor")), /* @__PURE__ */ react.createElement(_elementor_ui.Box, { display: "flex", flexDirection: "column", gap: 1 }, categoryRows.map(({ category, counts }) => /* @__PURE__ */ react.createElement(IssuesCategoryRow, { key: category, category, label: CATEGORY_LABELS[category], counts, onClick: () => onCategoryClick(category) })))), /* @__PURE__ */ react.createElement(Promotions, { report })); } //#endregion //#region packages/packages/core/editor-audits/src/components/report-shell.tsx function isCategoryPage(page) { return typeof page === "object" && "category" in page; } function ReportShell({ report }) { const [activePage, setActivePage] = (0, react.useState)("overview"); const openCategory = (category) => setActivePage({ category }); const backToOverview = () => setActivePage("overview"); return /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { flex: 1, minHeight: 0, overflowY: "auto" } }, activePage === "overview" && /* @__PURE__ */ react.createElement(OverviewPage, { report, onCategoryClick: openCategory }), isCategoryPage(activePage) && /* @__PURE__ */ react.createElement(CategoryPage, { category: activePage.category, report, onBack: backToOverview })); } //#endregion //#region packages/packages/core/editor-audits/src/components/rescan-button.tsx function RescanButton({ hasScanned, isStale, disabled, onClick }) { const panelZIndex = (0, _elementor_editor_floating_panels.useFloatingPanelZIndex)(AUDIT_PANEL_ID); return /* @__PURE__ */ react.createElement(_elementor_ui.Tooltip, { title: (0, _wordpress_i18n.__)("Page content changed - rescan advised", "elementor"), disableHoverListener: !isStale, PopperProps: { sx: { zIndex: panelZIndex } } }, /* @__PURE__ */ react.createElement(_elementor_ui.Badge, { variant: "dot", color: "warning", invisible: !isStale, overlap: "rectangular" }, /* @__PURE__ */ react.createElement(_elementor_ui.Button, { variant: "contained", size: "small", startIcon: hasScanned ? /* @__PURE__ */ react.createElement(_elementor_icons.ReloadIcon, { fontSize: "small" }) : void 0, onClick, disabled }, hasScanned ? (0, _wordpress_i18n.__)("Rescan", "elementor") : (0, _wordpress_i18n.__)("Run page audit", "elementor")))); } //#endregion //#region packages/packages/core/editor-audits/src/components/audit-panel.tsx function AuditPanel() { const { status, report, error, isStale, run } = useAuditReport(); const hostDocumentId = (0, _elementor_editor_elements.getHostDocumentId)() ?? 0; const onRun = () => run(hostDocumentId); const lastScanLabel = report ? new Date(report.runAt).toLocaleTimeString() : null; return /* @__PURE__ */ react.createElement(react.Fragment, null, /* @__PURE__ */ react.createElement(_elementor_editor_floating_panels.FloatingPanelHeader, { panelId: AUDIT_PANEL_ID, title: (0, _wordpress_i18n.__)("Page Audit", "elementor"), badge: (0, _wordpress_i18n.__)("Beta", "elementor"), titleVariant: "subtitle2" }), /* @__PURE__ */ react.createElement(_elementor_editor_floating_panels.FloatingPanelBody, { sx: status === "ready" ? { display: "flex", flexDirection: "column", overflow: "hidden", minHeight: 0 } : void 0 }, status === "idle" && /* @__PURE__ */ react.createElement(WelcomePage, null), status === "loading" && /* @__PURE__ */ react.createElement(LoadingPage, null), status === "error" && /* @__PURE__ */ react.createElement(ErrorPage, { message: error ?? "", onRetry: onRun }), status === "ready" && report && /* @__PURE__ */ react.createElement(ReportShell, { report })), /* @__PURE__ */ react.createElement(_elementor_editor_floating_panels.FloatingPanelFooter, null, lastScanLabel ? /* @__PURE__ */ react.createElement(_elementor_ui.Typography, { variant: "caption", sx: { flex: 1 } }, (0, _wordpress_i18n.__)("Last scan:", "elementor"), " ", lastScanLabel) : /* @__PURE__ */ react.createElement(_elementor_ui.Box, { sx: { flex: 1 } }), lastScanLabel && /* @__PURE__ */ react.createElement(AuditFeedback, null), /* @__PURE__ */ react.createElement(RescanButton, { hasScanned: Boolean(lastScanLabel), isStale, disabled: status === "loading" || hostDocumentId === 0, onClick: onRun }))); } //#endregion //#region packages/packages/core/editor-audits/src/editor-panel.tsx var auditPanel = (0, _elementor_editor_floating_panels.createFloatingPanel)({ id: AUDIT_PANEL_ID, title: "Audit", icon: () => null, component: AuditPanel, isDraggable: true, isResizable: true, defaults: { width: 360, height: 600, minWidth: 280, minHeight: 400 } }); //#endregion //#region packages/packages/core/editor-audits/src/hooks/use-audit-toggle-props.ts function useAuditToggleProps() { const { isOpen } = auditPanel.useFloatingPanelStatus(); const { toggle } = auditPanel.useFloatingPanelActions(); return { title: (0, _wordpress_i18n.__)("Audit Page", "elementor"), icon: AuditToggleIcon, selected: isOpen, onClick: () => toggle() }; } //#endregion //#region packages/packages/core/editor-audits/src/editor-app-bar.tsx var AUDIT_TOGGLE_PRIORITY = 24; function registerAppBarAuditsToggle() { _elementor_editor_app_bar.utilitiesMenu.registerToggleAction({ id: "toggle-audit-panel", priority: AUDIT_TOGGLE_PRIORITY, useProps: useAuditToggleProps }); } //#endregion //#region packages/packages/core/editor-audits/src/audits/accessibility-policy.ts var audit$23 = { id: "audits/accessibility-policy", title: (0, _wordpress_i18n.__)("Accessibility policy", "elementor"), description: (0, _wordpress_i18n.__)("An accessibility policy demonstrates your commitment to digital inclusion and may be legally required in some regions.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Install the Ally plugin to add an accessibility policy to your website.", "elementor"), categories: ["compliance"], severity: "info", weight: 1, evaluate: (ctx) => { if (ctx.pageContext.ally_plugin_active) return { status: "pass" }; return { status: "fail", violations: [{ auditId: audit$23.id, label: (0, _wordpress_i18n.__)("Ally plugin is not installed or active.", "elementor"), externalUrl: ctx.pageContext.ally_plugin_url }] }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/accessibility-statement.ts var audit$22 = { id: "audits/accessibility-statement", title: (0, _wordpress_i18n.__)("Create an accessibility statement", "elementor"), description: (0, _wordpress_i18n.__)("An accessibility statement showcases your efforts to create an inclusive online space, highlighting helpful features and a commitment to accessibility.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Use Ally to create and publish an accessibility statement for your site.", "elementor"), categories: ["accessibility"], severity: "info", weight: 1, evaluate: (ctx) => { const isReady = ctx.pageContext.ally_plugin_active; if (isReady && ctx.pageContext.ally_accessibility_statement_created) return { status: "pass" }; return { status: "fail", violations: [{ auditId: audit$22.id, label: (0, _wordpress_i18n.__)("No accessibility statement has been created for this site.", "elementor"), externalUrl: isReady ? ctx.pageContext.ally_accessibility_statement_url : ctx.pageContext.ally_plugin_url, ctaLabel: (0, _wordpress_i18n.__)("Create", "elementor"), secondaryCtaLabel: (0, _wordpress_i18n.__)("Learn more", "elementor"), secondaryCtaUrl: "https://elementor.com/help/start-using-ally/#statement" }] }; } }; //#endregion //#region packages/packages/core/editor-audits/src/utils/scan-accessibility-widgets.ts var ACCESSIBILITY_WIDGET_SCRIPT_SOURCES = ["cdn.elementor.com/a11y/widget.js"]; function hasAccessibilityWidgetScript(html) { return ACCESSIBILITY_WIDGET_SCRIPT_SOURCES.some((src) => html.includes(src)); } //#endregion //#region packages/packages/core/editor-audits/src/audits/accessibility-widget.ts var audit$21 = { id: "audits/accessibility-widget", title: (0, _wordpress_i18n.__)("Add an accessibility widget", "elementor"), description: (0, _wordpress_i18n.__)("Make your site more inclusive by adding an accessibility widget.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Activate Ally’s accessibility widget to give visitors on-page accessibility tools.", "elementor"), categories: ["accessibility"], severity: "info", weight: 1, evaluate: (ctx) => { if (!ctx.pageContext.frontend_url) return { status: "skipped", reason: (0, _wordpress_i18n.__)("Page is not published.", "elementor") }; if (!ctx.renderedHtml) return { status: "skipped", reason: (0, _wordpress_i18n.__)("Could not fetch the published page.", "elementor") }; if (hasAccessibilityWidgetScript(ctx.renderedHtml)) return { status: "pass" }; const isReady = ctx.pageContext.ally_plugin_active; return { status: "fail", violations: [{ auditId: audit$21.id, label: (0, _wordpress_i18n.__)("No accessibility widget is active on this site.", "elementor"), externalUrl: isReady ? ctx.pageContext.ally_widget_settings_url : ctx.pageContext.ally_plugin_url, ctaLabel: (0, _wordpress_i18n.__)("Activate", "elementor") }] }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/cookie-policy.ts var audit$20 = { id: "audits/cookie-policy", title: (0, _wordpress_i18n.__)("Cookie policy", "elementor"), description: (0, _wordpress_i18n.__)("A cookie policy is required by privacy regulations such as GDPR (EU) or CCPA (US) to inform visitors about tracking and data collection.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Install the Cookiez plugin to add a cookie policy to your website.", "elementor"), categories: ["compliance"], severity: "info", weight: 1, evaluate: (ctx) => { if (ctx.pageContext.cookiez_plugin_active) return { status: "pass" }; return { status: "fail", violations: [{ auditId: audit$20.id, label: (0, _wordpress_i18n.__)("Cookiez plugin is not installed or active.", "elementor"), externalUrl: ctx.pageContext.cookiez_plugin_url, ctaLabel: (0, _wordpress_i18n.__)("Set up cookie consent", "elementor") }] }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/deep-nesting.ts var MAX_NESTING_DEPTH = 6; function isNestingElement(node, widgetsCache) { if (node.elType === "container") return true; return !!widgetsCache?.[node.elType]?.meta?.is_container; } var audit$19 = { id: "audits/deep-nesting", title: (0, _wordpress_i18n.__)("Deep container nesting", "elementor"), description: (0, _wordpress_i18n.__)("Container nesting exceeds the recommended depth. Deep DOM trees hurt rendering performance and readability.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Flatten the layout by removing unnecessary wrapper containers.", "elementor"), categories: ["performance", "best-practices"], severity: "warning", weight: 5, evaluate: (ctx) => { if (ctx.elements.tree.length === 0) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No elements", "elementor") }; const widgetsCache = (0, _elementor_editor_elements.getWidgetsCache)(); const violations = []; walkElements(ctx.elements.tree, (node, parents) => { if (!isNestingElement(node, widgetsCache)) return; if (parents.filter((parent) => isNestingElement(parent, widgetsCache)).length + 1 > MAX_NESTING_DEPTH) violations.push({ auditId: audit$19.id, elementId: node.id, targetHint: "element-settings", label: (0, _wordpress_i18n.__)("Container nesting is too deep.", "elementor") }); }); return violations.length === 0 ? { status: "pass" } : { status: "fail", violations }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/default-design-system.ts var audit$18 = { id: "audits/default-design-system", title: (0, _wordpress_i18n.__)("Default website kit", "elementor"), description: (0, _wordpress_i18n.__)("Your website is using the default design system colors and fonts. Custom branding makes the website feel uniquely yours.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Open Site Settings and customize your kit (colors, fonts, layout).", "elementor"), categories: ["best-practices"], severity: "info", weight: 1, evaluate: (ctx) => { if (!ctx.pageContext.kit_is_default_unchanged) return { status: "pass" }; return { status: "fail", violations: [{ auditId: audit$18.id, label: (0, _wordpress_i18n.__)("Kit appears unchanged from default.", "elementor"), targetHint: "site-settings" }] }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/deprecated-widgets.ts var DEPRECATION_CONTROL_NAME = "deprecation_message"; var audit$17 = { id: "audits/deprecated-widgets", title: (0, _wordpress_i18n.__)("Deprecated widgets", "elementor"), description: (0, _wordpress_i18n.__)("Deprecated widgets should not be used. For better capabilities use the recommended replacement.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Replace each deprecated widget with the recommended new widget shown in its panel.", "elementor"), categories: ["best-practices", "performance"], severity: "warning", weight: 7, evaluate: (ctx) => { const widgetsCache = (0, _elementor_editor_elements.getWidgetsCache)(); if (!widgetsCache) return { status: "skipped", reason: "widgets-cache-unavailable" }; const violations = []; walkElements(ctx.elements.tree, (node) => { if (node.elType !== "widget") return; const config = widgetsCache[node.widgetType ?? ""]; if (!config?.controls) return; const deprecationControl = config.controls[DEPRECATION_CONTROL_NAME]; if (!deprecationControl || typeof deprecationControl !== "object") return; violations.push({ auditId: audit$17.id, elementId: node.id, targetHint: "element-settings", label: (0, _wordpress_i18n.__)("Using deprecated widget.", "elementor") }); }); return violations.length === 0 ? { status: "pass" } : { status: "fail", violations }; } }; //#endregion //#region packages/packages/core/editor-audits/src/utils/scan-consent-signals.ts var GOOGLE_TRACKING_PATTERNS = [ /googletagmanager\.com\/gtag\/js\?id=(G|AW)-/, /googletagmanager\.com\/gtm\.js/, /\bGTM-[A-Z0-9]+\b/, /gtag\(\s*['"]config['"]\s*,\s*['"](G|AW)-/ ]; var CONSENT_DEFAULT_PATTERNS = [/gtag\(\s*['"]consent['"]\s*,\s*['"]default['"]/, /dataLayer\.push\(\s*\[\s*['"]consent['"]\s*,\s*['"]default['"]/]; function hasGoogleTracking(html) { return GOOGLE_TRACKING_PATTERNS.some((pattern) => pattern.test(html)); } function hasConsentDefaultCall(html) { return CONSENT_DEFAULT_PATTERNS.some((pattern) => pattern.test(html)); } //#endregion //#region packages/packages/core/editor-audits/src/audits/google-consent-mode.ts var audit$16 = { id: "audits/google-consent-mode", title: (0, _wordpress_i18n.__)("Google Consent Mode", "elementor"), description: (0, _wordpress_i18n.__)("Google Analytics, Ads, or Tag Manager are running on this site and may not receive a consent signal, which risks losing conversion/analytics data and compliance exposure.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Turn on Google Consent Mode in your cookie consent plugin so Google tags respect visitor consent choices.", "elementor"), categories: ["compliance"], severity: "warning", weight: 1, evaluate: (ctx) => { if (!ctx.pageContext.frontend_url) return { status: "skipped", reason: (0, _wordpress_i18n.__)("Page is not published.", "elementor") }; if (!ctx.renderedHtml) return { status: "skipped", reason: (0, _wordpress_i18n.__)("Could not fetch the published page.", "elementor") }; if (!hasGoogleTracking(ctx.renderedHtml)) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No Google tracking product detected.", "elementor") }; if (hasConsentDefaultCall(ctx.renderedHtml)) return { status: "pass" }; const label = (0, _wordpress_i18n.__)("No Google Consent Mode signal was found on the page.", "elementor"); if (ctx.pageContext.cookiez_plugin_installed && ctx.pageContext.cookiez_plugin_active) return { status: "fail", violations: [{ auditId: audit$16.id, label, ctaLabel: (0, _wordpress_i18n.__)("Enable", "elementor"), externalUrl: ctx.pageContext.cookiez_consent_mode_settings_url }] }; return { status: "fail", violations: [{ auditId: audit$16.id, label, externalUrl: ctx.pageContext.cookiez_plugin_action_url }] }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/heading-structure.ts var HEADING_LEVELS = [ "h1", "h2", "h3", "h4", "h5", "h6" ]; var HEADING_CONTROLS_REGISTRY = { heading: [{ control: "header_size", requiresNonEmpty: "title" }], "e-heading": [{ control: "tag", requiresNonEmpty: "title" }], "icon-box": [{ control: "title_size", requiresNonEmpty: "title_text" }], "image-box": [{ control: "title_size", requiresNonEmpty: "title_text" }], counter: [{ control: "title_tag", requiresNonEmpty: "title" }], progress: [{ control: "title_tag", when: { title_display: "yes" }, requiresNonEmpty: "title" }], accordion: [{ control: "title_html_tag", repeat: { items: "tabs", textField: "tab_title" } }], toggle: [{ control: "title_html_tag", repeat: { items: "tabs", textField: "tab_title" } }], divider: [{ control: "html_tag", when: { look: "line_text" }, requiresNonEmpty: "text" }], "nested-accordion": [{ control: "title_tag", repeat: { items: "items", textField: "item_title" } }], "link-in-bio": [ { control: "bio_heading_tag", requiresNonEmpty: "bio_heading" }, { control: "bio_title_tag", requiresNonEmpty: "bio_title" }, { control: "bio_about_tag", requiresNonEmpty: "bio_about" } ], "animated-headline": [{ control: "tag", requiresAnyNonEmpty: [ "before_text", "highlighted_text", "rotating_text", "after_text" ] }], "author-box": [{ control: "author_name_tag", requiresNonEmpty: "author_name" }], "call-to-action": [{ control: "title_tag", requiresNonEmpty: "title" }, { control: "description_tag", requiresNonEmpty: "description" }], "flip-box": [ { control: "title_tag", requiresNonEmpty: "title_text_a" }, { control: "description_tag", requiresNonEmpty: "description_text_a" }, { control: "title_tag", requiresNonEmpty: "title_text_b" }, { control: "description_tag", requiresNonEmpty: "description_text_b" } ], "price-list": [{ control: "title_tag", repeat: { items: "price_list", textField: "title" } }, { control: "description_tag", repeat: { items: "price_list", textField: "item_description" } }], "price-table": [{ control: "heading_tag", requiresNonEmpty: "heading" }], slides: [{ control: "slides_title_tag", repeat: { items: "slides", textField: "heading" } }, { control: "slides_description_tag", repeat: { items: "slides", textField: "description" } }], "table-of-contents": [{ control: "html_tag", requiresNonEmpty: "title" }], "video-playlist": [ { control: "playlist_title_tag", requiresNonEmpty: "playlist_title" }, { control: "section_html_tag", repeat: { items: "tabs", tagSource: "item", itemWhen: { type: "section" }, textField: "title" } }, { control: "video_html_tag", repeat: { items: "tabs", tagSource: "item", itemWhen: { type: [ "youtube", "vimeo", "hosted" ] }, textField: "title" } } ], sitemap: [{ control: "sitemap_title_tag", repeat: { items: "sitemap_items", textField: "sitemap_title" } }], "loop-grid": [{ control: "nothing_found_message_html_tag", when: { enable_nothing_found_message: "yes" }, requiresNonEmpty: "nothing_found_message_text" }], search: [{ control: "nothing_found_message_html_tag", when: { enable_nothing_found_message: "yes" }, requiresNonEmpty: "nothing_found_message_text" }], posts: [{ control: "title_tag", when: { show_title: "yes" } }], "archive-posts": [{ control: "title_tag", when: { show_title: "yes" } }], portfolio: [{ control: "title_tag", when: { show_title: "yes" } }], "theme-post-title": [{ control: "header_size" }], "theme-page-title": [{ control: "header_size" }], "theme-archive-title": [{ control: "header_size" }], "theme-site-title": [{ control: "header_size" }], "woocommerce-product-title": [{ control: "header_size" }] }; function isNonEmptyString(value) { return typeof value === "string" && value.trim() !== ""; } function matchesWhen(settings, when) { if (!when) return true; return Object.entries(when).every(([key, expected]) => { const actual = settings[key]; if (Array.isArray(expected)) return expected.includes(String(actual)); return String(actual) === expected; }); } function hasRequiredText(settings, key) { if (!key) return true; return isNonEmptyString(settings[key]); } function hasAnyRequiredText(settings, keys) { if (!keys?.length) return true; return keys.some((key) => isNonEmptyString(settings[key])); } function parseHeadingLevel(raw) { if (typeof raw !== "string") return null; const idx = HEADING_LEVELS.indexOf(raw.toLowerCase()); return idx >= 0 ? idx + 1 : null; } function getRepeaterRows(settings, key) { const rows = settings[key]; return Array.isArray(rows) ? rows : []; } function pushHeading(headings, elementId, raw) { const level = parseHeadingLevel(raw); if (level !== null) headings.push({ elementId, level }); } function extractHeadingsFromWidget(elementId, widgetType, settings) { const descriptors = HEADING_CONTROLS_REGISTRY[widgetType]; if (!descriptors) return []; const headings = []; for (const descriptor of descriptors) { if (!matchesWhen(settings, descriptor.when)) continue; if (!hasRequiredText(settings, descriptor.requiresNonEmpty)) continue; if (!hasAnyRequiredText(settings, descriptor.requiresAnyNonEmpty)) continue; if (descriptor.repeat) { const { items, textField, itemWhen, tagSource = "widget" } = descriptor.repeat; for (const row of getRepeaterRows(settings, items)) { if (!matchesWhen(row, itemWhen)) continue; if (textField && !hasRequiredText(row, textField)) continue; pushHeading(headings, elementId, tagSource === "item" ? row[descriptor.control] : settings[descriptor.control]); } } else pushHeading(headings, elementId, settings[descriptor.control]); } return headings; } function extractPageHeadings(tree) { const headings = []; walkElements(tree, (node) => { if (node.elType !== "widget" || !node.widgetType) return; headings.push(...extractHeadingsFromWidget(node.id, node.widgetType, node.settings)); }); return headings; } var audit$15 = { id: "audits/heading-structure", title: (0, _wordpress_i18n.__)("Heading structure", "elementor"), description: (0, _wordpress_i18n.__)("Pages should have exactly one H1 and a non-skipping heading order.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Ensure your page has one H1 and that heading levels do not skip (no H2 → H4).", "elementor"), categories: ["seo", "accessibility"], severity: "error", weight: 10, evaluate: (ctx) => { if (ctx.elements.tree.length === 0) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No elements", "elementor") }; const headings = extractPageHeadings(ctx.elements.tree); const violations = []; if (headings.length === 0) violations.push({ auditId: audit$15.id, label: (0, _wordpress_i18n.__)("No headings found on the page.", "elementor") }); else { const h1Count = headings.filter((h) => h.level === 1).length; if (h1Count === 0) violations.push({ auditId: audit$15.id, label: (0, _wordpress_i18n.__)("No H1 on the page.", "elementor") }); if (h1Count > 1) headings.filter((h) => h.level === 1).slice(1).forEach((h) => violations.push({ auditId: audit$15.id, elementId: h.elementId, targetHint: "element-settings", label: (0, _wordpress_i18n.__)("More than one H1 on the page.", "elementor") })); for (let i = 1; i < headings.length; i++) if (headings[i].level - headings[i - 1].level > 1) violations.push({ auditId: audit$15.id, elementId: headings[i].elementId, targetHint: "element-settings", label: (0, _wordpress_i18n.__)("Heading level skipped.", "elementor") }); } return violations.length === 0 ? { status: "pass" } : { status: "fail", violations }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/hidden-elements.ts function isHiddenOnAllDevices(settings) { return Boolean(settings.hide_desktop) && Boolean(settings.hide_tablet) && Boolean(settings.hide_mobile); } var audit$14 = { id: "audits/hidden-elements", title: (0, _wordpress_i18n.__)("Hidden elements", "elementor"), description: (0, _wordpress_i18n.__)("Elements hidden on all devices simultaneously are effectively dead code in the page tree.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Remove the element or make it visible on at least one device breakpoint.", "elementor"), categories: ["best-practices", "performance"], severity: "info", weight: 3, evaluate: (ctx) => { if (ctx.elements.tree.length === 0) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No elements", "elementor") }; const violations = []; walkElements(ctx.elements.tree, (node) => { if (isHiddenOnAllDevices(node.settings)) violations.push({ auditId: audit$14.id, elementId: node.id, targetHint: "element-settings", label: (0, _wordpress_i18n.__)("Element is hidden on all devices.", "elementor") }); }); return violations.length === 0 ? { status: "pass" } : { status: "fail", violations }; } }; //#endregion //#region packages/packages/core/editor-audits/src/utils/alt-text-image-sources.ts function walkAltTextImageSources(tree, visit) { walkImageLikeSources(tree, visit); walkAtomicImageSources(tree, visit, ATOMIC_CONTENT_IMAGE_PROP_KEYS); } function hasAltTextImages(tree) { let found = false; walkAltTextImageSources(tree, ({ media }) => { if (media.id || media.url) found = true; }); return found; } //#endregion //#region packages/packages/core/editor-audits/src/utils/image-alt.ts function hasMeaningfulAlt(media, pageContext) { if (!media.id && !media.url) return true; if (media.id) { const key = buildImageSizeKey({ id: media.id, size: media.size }); return (pageContext.image_sizes[key]?.alt ?? "").trim().length > 0; } return (media.alt ?? "").trim().length > 0; } function isImageSourcePresent(media) { return Boolean(media.id || media.url); } //#endregion //#region packages/packages/core/editor-audits/src/audits/images-alt-text.ts var audit$13 = { id: "audits/images-alt-text", title: (0, _wordpress_i18n.__)("Images alt text", "elementor"), description: (0, _wordpress_i18n.__)("Every image needs a meaningful alt attribute for screen readers and image-search.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Open the image's settings and add an Alt Text describing the image.", "elementor"), categories: ["seo", "accessibility"], severity: "error", weight: 10, evaluate: (ctx) => { if (!hasAltTextImages(ctx.elements.tree)) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No images", "elementor") }; const isReady = ctx.pageContext.ally_plugin_active; const violations = []; const failedWidgetIds = /* @__PURE__ */ new Set(); let missingAltImageCount = 0; walkAltTextImageSources(ctx.elements.tree, ({ node, media }) => { if (!isImageSourcePresent(media) || hasMeaningfulAlt(media, ctx.pageContext)) return; missingAltImageCount++; if (!failedWidgetIds.has(node.id)) { failedWidgetIds.add(node.id); violations.push({ auditId: audit$13.id, elementId: node.id, targetHint: "element-settings", label: (0, _wordpress_i18n.__)("Image is missing alt text.", "elementor"), externalUrl: isReady ? ctx.pageContext.ally_scan_url : ctx.pageContext.ally_plugin_url, ctaLabel: (0, _wordpress_i18n.__)("Fix with Ally", "elementor") }); } }); return violations.length === 0 ? { status: "pass" } : { status: "fail", violations, metadata: { missingAltImageCount } }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/images-inefficient-format.ts var LEGACY_RASTER_MIME_TYPES = /* @__PURE__ */ new Set([ "image/jpeg", "image/png", "image/gif", "image/bmp", "image/tiff" ]); var audit$12 = { id: "audits/images-inefficient-format", title: (0, _wordpress_i18n.__)("Inefficient image format", "elementor"), description: (0, _wordpress_i18n.__)("Image isn't served in a modern, efficient format like WebP or AVIF.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Convert the image to a modern format like WebP or AVIF, or enable image optimization.", "elementor"), categories: ["performance"], severity: "info", weight: 1, evaluate: (ctx) => { const isReady = ctx.pageContext.image_optimization_plugin_active; const offendingElementIds = /* @__PURE__ */ new Set(); let hasAnyImage = false; let inefficientImageFormatCount = 0; const evaluateSource = (node, media) => { if (media.id || media.url) hasAnyImage = true; const id = media.id; if (!id) return; const mime = ctx.pageContext.image_sizes[buildImageSizeKey({ id, size: media.size })]?.mime; if (!mime || !LEGACY_RASTER_MIME_TYPES.has(mime)) return; inefficientImageFormatCount++; offendingElementIds.add(node.id); }; walkAllImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media)); if (!hasAnyImage) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No images", "elementor") }; const violations = Array.from(offendingElementIds).map((elementId) => ({ auditId: audit$12.id, elementId, targetHint: "element-settings", label: (0, _wordpress_i18n.__)("Image isn't served in a modern format like WebP or AVIF.", "elementor"), externalUrl: isReady ? ctx.pageContext.image_optimization_settings_url : ctx.pageContext.image_optimization_plugin_url, ctaLabel: (0, _wordpress_i18n.__)("Optimize all", "elementor") })); return violations.length === 0 ? { status: "pass" } : { status: "fail", violations, metadata: { inefficientImageFormatCount } }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/images-too-large.ts var SIZE_THRESHOLD_BYTES = 500 * 1024; var BYTES_PER_KB = 1024; var audit$11 = { id: "audits/images-too-large", title: (0, _wordpress_i18n.__)("Oversized images", "elementor"), description: (0, _wordpress_i18n.__)("Large image files slow down the page.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Replace the image with a smaller version or enable image optimization.", "elementor"), categories: ["performance"], severity: "warning", weight: 7, evaluate: (ctx) => { const isReady = ctx.pageContext.image_optimization_plugin_active; const widgetMaxKb = /* @__PURE__ */ new Map(); let oversizedImageCount = 0; let hasAnyImage = false; const evaluateSource = (node, media) => { if (media.id || media.url) hasAnyImage = true; const id = media.id; if (!id) return; const size = ctx.pageContext.image_sizes[buildImageSizeKey({ id, size: media.size })]; if (!size || size.filesize_bytes <= SIZE_THRESHOLD_BYTES) return; oversizedImageCount++; const kb = Math.round(size.filesize_bytes / BYTES_PER_KB); const currentMax = widgetMaxKb.get(node.id) ?? 0; widgetMaxKb.set(node.id, Math.max(currentMax, kb)); }; walkAllImageSources(ctx.elements.tree, ({ node, media }) => evaluateSource(node, media)); if (!hasAnyImage) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No images", "elementor") }; const violations = Array.from(widgetMaxKb.entries()).map(([elementId, kb]) => ({ auditId: audit$11.id, elementId, targetHint: "element-settings", label: (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("Image is %d KB (over 500 KB).", "elementor"), kb), externalUrl: isReady ? ctx.pageContext.image_optimization_settings_url : ctx.pageContext.image_optimization_plugin_url, ctaLabel: (0, _wordpress_i18n.__)("Optimize all", "elementor") })); return violations.length === 0 ? { status: "pass" } : { status: "fail", violations, metadata: { oversizedImageCount } }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/nested-boxed-containers.ts function isBoxed(settings) { return settings.content_width === "boxed"; } var audit$10 = { id: "audits/nested-boxed-containers", title: (0, _wordpress_i18n.__)("Boxed container nested inside a boxed parent", "elementor"), description: (0, _wordpress_i18n.__)("An inner container does not need to be boxed when its parent already is.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Change the inner container's content width to Full Width.", "elementor"), categories: ["best-practices", "performance"], severity: "info", weight: 5, evaluate: (ctx) => { if (ctx.elements.tree.length === 0) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No elements", "elementor") }; const violations = []; walkElements(ctx.elements.tree, (node, parents) => { if (node.elType !== "container" || !isBoxed(node.settings)) return; const nearestContainerAncestor = [...parents].reverse().find((p) => p.elType === "container"); if (nearestContainerAncestor && isBoxed(nearestContainerAncestor.settings)) violations.push({ auditId: audit$10.id, elementId: node.id, targetHint: "element-settings", label: (0, _wordpress_i18n.__)("Nested boxed container.", "elementor"), angieFix: true, angiePrompt: (0, _wordpress_i18n.__)("Find containers that have nested containers. Containers can be deep-nested. Update the nested container styling so that when a parent container already uses a boxed setting, any inner container inside it is set to Full Width. Keep the first parent container boxed, remove all boxed styling from the nested inner containers, and preserve the inner container’s content, spacing, alignment, and hierarchy.", "elementor") }); }); return violations.length === 0 ? { status: "pass" } : { status: "fail", violations }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/page-excerpt.ts var audit$9 = { id: "audits/page-excerpt", title: (0, _wordpress_i18n.__)("Page excerpt", "elementor"), description: (0, _wordpress_i18n.__)("A descriptive excerpt helps search engines and previews summarize the page.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Open Page Settings and write a short excerpt.", "elementor"), categories: ["seo"], severity: "warning", weight: 5, evaluate: (ctx) => { if (ctx.pageContext.post_excerpt) return { status: "pass" }; return { status: "fail", violations: [{ auditId: audit$9.id, label: (0, _wordpress_i18n.__)("Page has no excerpt.", "elementor"), targetHint: "page-settings", angieFix: true }] }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/page-featured-image.ts var audit$8 = { id: "audits/page-featured-image", title: (0, _wordpress_i18n.__)("Page featured image", "elementor"), description: (0, _wordpress_i18n.__)("Featured images are used by social shares and many themes for hero visuals.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Open Page Settings and set a featured image.", "elementor"), categories: ["seo"], severity: "info", weight: 5, evaluate: (ctx) => { if (ctx.pageContext.featured_image_id) return { status: "pass" }; return { status: "fail", violations: [{ auditId: audit$8.id, label: (0, _wordpress_i18n.__)("No featured image set.", "elementor"), targetHint: "page-settings" }] }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/page-title.ts var MAX_TITLE_LENGTH = 60; var audit$7 = { id: "audits/page-title", title: (0, _wordpress_i18n.__)("Page title", "elementor"), description: (0, _wordpress_i18n.__)("Pages need a clear title for SEO and screen-reader navigation.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Open Page Settings and add a title.", "elementor"), categories: ["seo"], severity: "error", weight: 10, evaluate: (ctx) => { const title = ctx.pageContext.post_title; if (!title) return { status: "fail", violations: [{ auditId: audit$7.id, label: (0, _wordpress_i18n.__)("Page has no title.", "elementor"), targetHint: "page-settings", angieFix: true, angiePrompt: (0, _wordpress_i18n.__)("Based on this page's contents, generate a title for this page.", "elementor") }] }; if (title.length > MAX_TITLE_LENGTH) return { status: "fail", violations: [{ auditId: audit$7.id, label: (0, _wordpress_i18n.__)("Page title is too long.", "elementor"), targetHint: "page-settings", angieFix: true }] }; return { status: "pass" }; } }; //#endregion //#region packages/packages/core/editor-audits/src/utils/collect-hardcoded-colors.ts var RESERVED_SETTING_KEYS$1 = /* @__PURE__ */ new Set(["__globals__", "__dynamic__"]); var REPEATER_ROW_ID_KEY$1 = "_id"; var HEX_COLOR_PATTERN = /^#[0-9a-f]{3,8}$/i; var RGB_COLOR_PATTERN = /^rgba?\(/i; function isGlobalColorReference(value) { return value.startsWith("globals/"); } function isHardcodedColorCandidate(value) { const trimmed = value.trim(); return HEX_COLOR_PATTERN.test(trimmed) || RGB_COLOR_PATTERN.test(trimmed); } function formatPath$1(prefix, key) { return prefix ? `${prefix}.${key}` : key; } __name(formatPath$1, "formatPath"); function formatArrayPath$1(prefix, index) { return `${prefix}[${index}]`; } __name(formatArrayPath$1, "formatArrayPath"); function collectHardcodedColors(settings, pathPrefix = "") { const linkedGlobals = settings.__globals__ ?? {}; const results = []; for (const [key, value] of Object.entries(settings)) { if (RESERVED_SETTING_KEYS$1.has(key) || key === REPEATER_ROW_ID_KEY$1) continue; if (linkedGlobals[key]) continue; if (typeof value === "string") { if (!isGlobalColorReference(value) && isHardcodedColorCandidate(value)) results.push({ path: formatPath$1(pathPrefix, key), value }); continue; } if (Array.isArray(value)) { const arrayPath = formatPath$1(pathPrefix, key); value.forEach((item, index) => { if (item && typeof item === "object" && !Array.isArray(item)) results.push(...collectHardcodedColors(item, formatArrayPath$1(arrayPath, index))); }); continue; } if (value && typeof value === "object") results.push(...collectHardcodedColors(value, formatPath$1(pathPrefix, key))); } return results; } //#endregion //#region packages/packages/core/editor-audits/src/utils/match-global-by-value.ts function findMatchingGlobalByValue(value, globals) { const trimmed = value.trim(); return globals.find((global) => global.value === trimmed) ?? null; } //#endregion //#region packages/packages/core/editor-audits/src/audits/prefer-global-colors.ts var audit$6 = { id: "audits/prefer-global-colors", title: (0, _wordpress_i18n.__)("Prefer global colors", "elementor"), description: (0, _wordpress_i18n.__)("Global colors make the design consistent and easy to update site-wide.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Replace the hard-coded value with the matching global color.", "elementor"), categories: ["best-practices"], severity: "info", weight: 3, evaluate: (ctx) => { if (ctx.elements.tree.length === 0) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No elements", "elementor") }; if (ctx.kit.globals.colors.length === 0) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No global colors", "elementor") }; const violations = []; walkElements(ctx.elements.tree, (node) => { for (const { value } of collectHardcodedColors(node.settings)) { const global = findMatchingGlobalByValue(value, ctx.kit.globals.colors); if (!global) continue; violations.push({ auditId: audit$6.id, elementId: node.id, targetHint: "element-settings", angieFix: true, label: (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("replace \"%1$s\" with \"%2$s\" global color", "elementor"), value, global.title) }); } }); return violations.length === 0 ? { status: "pass" } : { status: "fail", violations }; } }; //#endregion //#region packages/packages/core/editor-audits/src/utils/collect-hardcoded-fonts.ts var RESERVED_SETTING_KEYS = /* @__PURE__ */ new Set(["__globals__", "__dynamic__"]); var REPEATER_ROW_ID_KEY = "_id"; var FONT_FAMILY_KEY_PATTERN = /font_family/; function isGlobalFontReference(value) { return value.startsWith("globals/"); } function isHardcodedFontCandidate(key, value) { return FONT_FAMILY_KEY_PATTERN.test(key) && value.trim().length > 0; } function formatPath(prefix, key) { return prefix ? `${prefix}.${key}` : key; } function formatArrayPath(prefix, index) { return `${prefix}[${index}]`; } function collectHardcodedFonts(settings, pathPrefix = "") { const linkedGlobals = settings.__globals__ ?? {}; const results = []; for (const [key, value] of Object.entries(settings)) { if (RESERVED_SETTING_KEYS.has(key) || key === REPEATER_ROW_ID_KEY) continue; if (linkedGlobals[key]) continue; if (typeof value === "string") { if (!isGlobalFontReference(value) && isHardcodedFontCandidate(key, value)) results.push({ path: formatPath(pathPrefix, key), value }); continue; } if (Array.isArray(value)) { const arrayPath = formatPath(pathPrefix, key); value.forEach((item, index) => { if (item && typeof item === "object" && !Array.isArray(item)) results.push(...collectHardcodedFonts(item, formatArrayPath(arrayPath, index))); }); continue; } if (value && typeof value === "object") results.push(...collectHardcodedFonts(value, formatPath(pathPrefix, key))); } return results; } //#endregion //#region packages/packages/core/editor-audits/src/audits/prefer-global-fonts.ts var audit$5 = { id: "audits/prefer-global-fonts", title: (0, _wordpress_i18n.__)("Prefer global fonts", "elementor"), description: (0, _wordpress_i18n.__)("Global fonts make the design consistent and easy to update site-wide.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Replace the hard-coded value with the matching global font.", "elementor"), categories: ["best-practices", "performance"], severity: "info", weight: 3, evaluate: (ctx) => { if (ctx.elements.tree.length === 0) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No elements", "elementor") }; if (ctx.kit.globals.fonts.length === 0) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No global fonts", "elementor") }; const violations = []; walkElements(ctx.elements.tree, (node) => { for (const { value } of collectHardcodedFonts(node.settings)) { const global = findMatchingGlobalByValue(value, ctx.kit.globals.fonts); if (!global) continue; violations.push({ auditId: audit$5.id, elementId: node.id, targetHint: "element-settings", label: (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n.__)("replace hardcoded typography with \"%s\" global font", "elementor"), global.title) }); } }); return violations.length === 0 ? { status: "pass" } : { status: "fail", violations }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/privacy-policy.ts var audit$4 = { id: "audits/privacy-policy", title: (0, _wordpress_i18n.__)("Privacy policy", "elementor"), description: (0, _wordpress_i18n.__)("A privacy policy page is required by privacy regulations such as GDPR (EU) and CCPA (US).", "elementor"), fixHint: (0, _wordpress_i18n.__)("Go to Settings > Privacy in the WordPress admin and assign a published privacy policy page.", "elementor"), categories: ["compliance"], severity: "info", weight: 1, evaluate: (ctx) => { if (ctx.pageContext.privacy_policy_url) return { status: "pass" }; return { status: "fail", violations: [{ auditId: audit$4.id, label: (0, _wordpress_i18n.__)("No privacy policy page is set.", "elementor"), externalUrl: ctx.pageContext.privacy_settings_url, ctaLabel: (0, _wordpress_i18n.__)("Create", "elementor") }] }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/robots-noindex.ts var audit$3 = { id: "audits/robots-noindex", title: (0, _wordpress_i18n.__)("Search engine visibility", "elementor"), description: (0, _wordpress_i18n.__)("When search engine visibility is checked in WordPress Settings -> Reading -> Search Engine Visibility, search engines are discouraged from indexing the website.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Go to Settings → Reading in the WordPress admin and uncheck \"Discourage search engines from indexing this site\" when the website should be indexed.", "elementor"), categories: ["seo"], severity: "error", weight: 7, evaluate: (ctx) => { if (!ctx.pageContext.is_noindex) return { status: "pass" }; return { status: "fail", violations: [{ auditId: audit$3.id, label: (0, _wordpress_i18n.__)("Search engines are discouraged from indexing this website.", "elementor"), externalUrl: ctx.pageContext.reading_settings_url }] }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/scan-for-cookies.ts var audit$2 = { id: "audits/scan-for-cookies", title: (0, _wordpress_i18n.__)("Scan for cookies", "elementor"), description: (0, _wordpress_i18n.__)("Your site may be setting cookies you haven't disclosed. Some countries require a banner even without a full consent policy. Scan to see what needs disclosure.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Run a Cookiez scan on this page to see which cookies need disclosure.", "elementor"), categories: ["compliance"], severity: "info", weight: 0, evaluate: (ctx) => { const isReady = ctx.pageContext.cookiez_plugin_installed && ctx.pageContext.cookiez_plugin_active; return { status: "fail", violations: [{ auditId: audit$2.id, label: (0, _wordpress_i18n.__)("This page has not been scanned for cookies yet.", "elementor"), externalUrl: isReady ? ctx.pageContext.cookiez_scan_url : ctx.pageContext.cookiez_plugin_action_url }] }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/sections-and-columns.ts var audit$1 = { id: "audits/sections-and-columns", title: (0, _wordpress_i18n.__)("Sections and columns", "elementor"), description: (0, _wordpress_i18n.__)("Sections and columns are legacy elements. Containers render fewer DOM nodes and are more flexible.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Use the Container Converter to replace each section/column with a container.", "elementor"), categories: ["best-practices", "performance"], severity: "warning", weight: 7, evaluate: (ctx) => { if (ctx.elements.tree.length === 0) return { status: "skipped", reason: (0, _wordpress_i18n.__)("No elements", "elementor") }; const violations = []; walkElements(ctx.elements.tree, (node) => { if (node.elType === "section" || node.elType === "column") violations.push({ auditId: audit$1.id, elementId: node.id, label: node.elType === "section" ? (0, _wordpress_i18n.__)("Section element", "elementor") : (0, _wordpress_i18n.__)("Column element", "elementor") }); }); return violations.length === 0 ? { status: "pass" } : { status: "fail", violations }; } }; //#endregion //#region packages/packages/core/editor-audits/src/audits/site-identity.ts var audit = { id: "audits/site-identity", title: (0, _wordpress_i18n.__)("Site identity", "elementor"), description: (0, _wordpress_i18n.__)("Site name, description, logo, and favicon establish your brand and appear in search results and browser tabs.", "elementor"), fixHint: (0, _wordpress_i18n.__)("Open Site Settings → Site Identity and complete all the missing fields.", "elementor"), categories: ["best-practices", "seo"], severity: "info", weight: 7, evaluate: (ctx) => { const { site_identity: identity } = ctx.pageContext; const violations = []; if (!identity.site_name_set) violations.push({ auditId: audit.id, label: (0, _wordpress_i18n.__)("Site name is missing or still uses the default.", "elementor"), targetHint: "site-identity-settings" }); if (!identity.site_description_set) violations.push({ auditId: audit.id, label: (0, _wordpress_i18n.__)("Site description is missing or still uses the default.", "elementor"), targetHint: "site-identity-settings", angieFix: true }); if (!identity.site_logo_set) violations.push({ auditId: audit.id, label: (0, _wordpress_i18n.__)("Site logo is not set.", "elementor"), targetHint: "site-identity-settings" }); if (!identity.site_favicon_set) violations.push({ auditId: audit.id, label: (0, _wordpress_i18n.__)("Site favicon is not set.", "elementor"), targetHint: "site-identity-settings" }); if (violations.length === 0) return { status: "pass" }; return { status: "fail", violations }; } }; //#endregion //#region packages/packages/core/editor-audits/src/register-audits.ts var AUDITS = [ audit$7, audit$9, audit$8, audit$14, audit$17, audit$1, audit$19, audit$10, audit$18, audit, audit$6, audit$5, audit$15, audit$13, audit$11, audit$12, audit$3, audit$4, audit$23, audit$22, audit$21, audit$20, audit$2, audit$16 ]; function registerAllAudits() { for (const audit of AUDITS) registerAudit(audit); } //#endregion //#region packages/packages/core/editor-audits/src/sync-report-staleness.ts function syncReportStaleness() { (0, _elementor_editor_v1_adapters.__privateListenTo)((0, _elementor_editor_v1_adapters.commandEndEvent)("document/save/set-is-modified"), (e) => { if (e.args?.status) (0, _elementor_store.__dispatch)(slice.actions.reportStale()); }); } //#endregion //#region packages/packages/core/editor-audits/src/init.ts function init() { (0, _elementor_store.__registerSlice)(slice); registerAllAudits(); (0, _elementor_editor_floating_panels.registerFloatingPanel)(auditPanel.panel); registerAppBarAuditsToggle(); syncReportStaleness(); } //#endregion //#region packages/packages/core/editor-audits/src/index.ts var src_exports = /* @__PURE__ */ __exportAll({ init: () => init, registerAudit: () => registerAudit, runPageAudit: () => runPageAudit }); //#endregion //#region \0elementor-package-library-entry (window.elementorV2 = window.elementorV2 || {}).editorAudits = src_exports; //#endregion })(elementorV2.editorFloatingPanels, elementorV2.store, elementorV2.editorAppBar, wp.i18n, React, elementorV2.icons, elementorV2.ui, elementorV2.editorElements, elementorV2.httpClient, elementorV2.editorProps, elementorV2.session, elementorV2.editorNotifications, elementorV2.editorV1Adapters, elementorV2.events, elementorV2.editorMcp); window.elementorV2.editorAudits?.init?.(); //# sourceMappingURL=editor-audits.js.map
Save File
Cancel