PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.12
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.12
1.1.13 1.1.12 1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 All 37 releases
← All changes | assets/js/ai-assistant.min.js +107 -112 0.9.2 → 1.1.12 View file →
@@ -1,165 +1,160 @@
1 -(function(){"use strict";function w(){const i=window.wp?.hooks;if(!i)throw new Error("[desktop-mode] `window.wp.hooks` is not available. The plugin declares `wp-hooks` as a script dependency; if you are seeing this error, verify the enqueue order.");return i}function L(i,e,...t){return w().applyFilters(i,e,...t)}function S(i,...e){w().doAction(i,...e)}const _={INIT:"desktop-mode.init",WALLPAPERS:"desktop-mode.wallpapers",UNFOCUS_EFFECTS:"desktop-mode.unfocus-effects",WALLPAPER_MOUNTING:"desktop-mode.wallpaper.mounting",WALLPAPER_MOUNTED:"desktop-mode.wallpaper.mounted",WALLPAPER_UNMOUNTING:"desktop-mode.wallpaper.unmounting",WALLPAPER_MOUNT_FAILED:"desktop-mode.wallpaper.mount-failed",WALLPAPER_VISIBILITY:"desktop-mode.wallpaper.visibility",IFRAME_READY:"desktop-mode.iframe.ready",IFRAME_ERROR:"desktop-mode.iframe.error",IFRAME_NETWORK_COMPLETED:"desktop-mode.iframe.network-completed",SHELL_ERROR:"desktop-mode.shell.error",BROADCAST:"desktop-mode.broadcast",MONITOR_ENTRY:"desktop-mode.monitor.entry",WALLPAPER_SURFACES:"desktop-mode.wallpaper.surfaces",WINDOW_GEOMETRY:"desktop-mode.window.geometry",WINDOW_OPENED:"desktop-mode.window.opened",WINDOW_CONTENT_LOADING:"desktop-mode.window.content-loading",WINDOW_CONTENT_LOADED:"desktop-mode.window.content-loaded",WINDOW_LOADING_OVERLAY:"desktop-mode.window.loading-overlay",WINDOW_REOPENED:"desktop-mode.window.reopened",WINDOW_CLOSING:"desktop-mode.window.closing",WINDOW_CLOSED:"desktop-mode.window.closed",WINDOW_FOCUSED:"desktop-mode.window.focused",WINDOW_BLURRED:"desktop-mode.window.blurred",WINDOW_MINIMIZED:"desktop-mode.window.minimized",WINDOW_RESTORED:"desktop-mode.window.restored",WINDOW_MAXIMIZED:"desktop-mode.window.maximized",WINDOW_UNMAXIMIZED:"desktop-mode.window.unmaximized",WINDOW_FULLSCREEN_ENTERED:"desktop-mode.window.fullscreen-entered",WINDOW_FULLSCREEN_EXITED:"desktop-mode.window.fullscreen-exited",WINDOW_AUTO_EXIT_FULLSCREEN:"desktop-mode.window.auto-exit-fullscreen",WINDOW_BOUNDS_CHANGED:"desktop-mode.window.bounds-changed",WINDOW_MOVED:"desktop-mode.window.moved",WINDOW_RESIZED:"desktop-mode.window.resized",WINDOW_DRAG_START:"desktop-mode.window.drag-start",WINDOW_DRAG_END:"desktop-mode.window.drag-end",WINDOW_RESIZE_START:"desktop-mode.window.resize-start",WINDOW_RESIZE_END:"desktop-mode.window.resize-end",WINDOW_DETACHED:"desktop-mode.window.detached",WINDOW_RELOADED:"desktop-mode.window.reloaded",WINDOW_TITLE_CHANGED:"desktop-mode.window.title-changed",WINDOW_HIGHLIGHT_CHANGED:"desktop-mode.window.highlight-changed",WINDOW_BODY_RESIZED:"desktop-mode.window.body-resized",NATIVE_WINDOW_BEFORE_RENDER:"desktop-mode.native-window.before-render",NATIVE_WINDOW_AFTER_RENDER:"desktop-mode.native-window.after-render",NATIVE_WINDOW_BEFORE_CLOSE:"desktop-mode.native-window.before-close",WINDOW_CHROME_THEME:"desktop-mode.window.chrome.theme",WINDOW_CHROME_CONTROLS:"desktop-mode.window.chrome.controls",WINDOW_CHROME_SLOT:"desktop-mode.window.chrome.slot",WINDOW_CHROME_RENDER:"desktop-mode.window.chrome.render",WINDOW_CHROME_APPLIED:"desktop-mode.window.chrome.applied",WINDOW_CHROME_THEME_CHANGED:"desktop-mode.window.chrome.theme-changed",DESKTOP_ICON_CLICKED:"desktop-mode.desktop-icon.clicked",DESKTOP_ICONS_RENDERED:"desktop-mode.desktop-icons.rendered",ICON_BADGE_CHANGED:"desktop-mode.icon.badge-changed",COMPONENTS_REGISTERED:"desktop-mode.components.registered",DOCK_ITEM_APPENDED:"desktop-mode.dock.item-appended",DOCK_ITEM_REMOVED:"desktop-mode.dock.item-removed",DOCK_BEFORE_RENDER:"desktop-mode.dock.before-render",DOCK_AFTER_RENDER:"desktop-mode.dock.after-render",DOCK_TILE_CLASS:"desktop-mode.dock.tile-class",DOCK_TILE_ELEMENT:"desktop-mode.dock.tile-element",DOCK_TILE_RENDERED:"desktop-mode.dock.tile-rendered",DOCK_TILE_TOOLTIP:"desktop-mode.dock.tile-tooltip",DOCK_PEEK_CARD_CONTENT:"desktop-mode.dock.peek-card-content",DOCK_PEEK_CARD_ELEMENT:"desktop-mode.dock.peek-card-element",OVERVIEW_ENTERING:"desktop-mode.overview.entering",OVERVIEW_ENTERED:"desktop-mode.overview.entered",OVERVIEW_EXITING:"desktop-mode.overview.exiting",OVERVIEW_EXITED:"desktop-mode.overview.exited",OVERVIEW_WINDOW_HOVER:"desktop-mode.overview.window-hover",OVERVIEW_WINDOW_UNHOVER:"desktop-mode.overview.window-unhover",OVERVIEW_WINDOW_CLICK:"desktop-mode.overview.window-click",ARRANGE_CASCADE_STARTING:"desktop-mode.arrange.cascade.starting",ARRANGE_CASCADE_APPLIED:"desktop-mode.arrange.cascade.applied",ARRANGE_TILE_STARTING:"desktop-mode.arrange.tile.starting",ARRANGE_TILE_APPLIED:"desktop-mode.arrange.tile.applied",ARRANGE_TILE_DIMENSIONS:"desktop-mode.arrange.tile.dimensions",ARRANGE_SNAP_CHANGED:"desktop-mode.arrange.snap.changed",ARRANGE_SNAP_CELL_SIZE:"desktop-mode.arrange.snap.cell-size",ARRANGE_CUSTOM_ACTION:"desktop-mode.arrange.custom-action",SNAP_ZONE_PENDING:"desktop-mode.snap.zone-pending",SNAP_ZONE_CANCELED:"desktop-mode.snap.zone-canceled",SNAP_ZONE_COMMITTED:"desktop-mode.snap.zone-committed",SNAP_SPLIT_FILLED:"desktop-mode.snap.split-filled",WIDGETS:"desktop-mode.widgets",WIDGET_MOUNTING:"desktop-mode.widget.mounting",WIDGET_MOUNTED:"desktop-mode.widget.mounted",WIDGET_UNMOUNTING:"desktop-mode.widget.unmounting",WIDGET_MOUNT_FAILED:"desktop-mode.widget.mount-failed",WIDGET_ADDED:"desktop-mode.widget.added",WIDGET_REMOVED:"desktop-mode.widget.removed",DESKTOP_CREATED:"desktop-mode.desktop.created",DESKTOP_CLOSED:"desktop-mode.desktop.closed",DESKTOP_SWITCHED:"desktop-mode.desktop.switched",PRIMARY_DESKTOP_ID:"desktop-mode.primary-desktop-id",WINDOWS_BEFORE_CLOSE_ALL:"desktop-mode.windows.before-close-all",WINDOWS_CLOSE_ALL:"desktop-mode.windows.close-all",WINDOWS_AFTER_CLOSE_ALL:"desktop-mode.windows.after-close-all",COMMAND_BEFORE_RUN:"desktop-mode.command.before-run",COMMAND_AFTER_RUN:"desktop-mode.command.after-run",COMMAND_ERROR:"desktop-mode.command.error",SHELL_RESIZED:"desktop-mode.shell.resized",SHELL_VISIBILITY:"desktop-mode.shell.visibility",CONNECTION_OPENED:"desktop-mode.connection.opened",CONNECTION_CLOSED:"desktop-mode.connection.closed",CONNECTION_MESSAGE:"desktop-mode.connection.message",IFRAME_CONNECTION_REQUEST:"desktop-mode.iframe.connection-request",FILE_DROP_FILES_DETECTED:"desktop-mode.drop.files-detected",FILE_DROP_FILES_REJECTED:"desktop-mode.drop.files-rejected",FILE_DROP_DIALOG_FIELDS:"desktop-mode.drop.dialog-fields",FILE_DROP_BEFORE_UPLOAD:"desktop-mode.drop.before-upload",FILE_DROP_UPLOAD_STARTED:"desktop-mode.drop.upload-started",FILE_DROP_UPLOAD_PROGRESS:"desktop-mode.drop.upload-progress",FILE_DROP_AFTER_UPLOAD:"desktop-mode.drop.after-upload",FILE_DROP_UPLOAD_FAILED:"desktop-mode.drop.upload-failed"},b="wpd-confirm-dialog";let u=null;function p(){return typeof window.customElements<"u"&&!!window.customElements.get(b)}function C(i){return new Promise((e,t)=>{const o=document.querySelector('script[data-desktop-mode-shell-overlays="1"]'),d=()=>{if(p()){e();return}t(new Error("[desktop-mode] shell-overlays bundle loaded but did not register the overlay components."))};if(o){p()?d():(o.addEventListener("load",d),o.addEventListener("error",()=>t(new Error("failed to load shell-overlays bundle"))));return}const s=document.createElement("script");s.src=i,s.async=!0,s.dataset.desktopModeShellOverlays="1",s.addEventListener("load",d),s.addEventListener("error",()=>t(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(s)})}function R(i){return p()||!i?Promise.resolve():(u||(u=C(i)),u)}function T(){return window.desktopModeConfig?.shellOverlaysBundleUrl??""}async function W(i){return await R(T()),new Promise(e=>{const t=document.createElement("wpd-confirm-dialog");t.setAttribute("open",""),i.title&&t.setAttribute("title",i.title),t.setAttribute("message",i.message),i.confirmLabel&&t.setAttribute("confirm-label",i.confirmLabel),i.cancelLabel&&t.setAttribute("cancel-label",i.cancelLabel),i.danger&&t.setAttribute("danger",""),i.hideCancel&&t.setAttribute("hide-cancel",""),i.dismissable&&t.setAttribute("dismissable","");const o=s=>{t.remove(),e(s)};t.addEventListener("wpd-confirm",()=>o(!0)),t.addEventListener("wpd-cancel",()=>o(!1)),document.body.appendChild(t),(t.shadowRoot?.querySelector(".dialog")??t).focus?.()})}const v="X-WP-Nonce";function M(i,e){const t=$();if(!t)return e;const o=P(i);if(!o||!U(o))return e;const d=e?.headers??(typeof Request<"u"&&i instanceof Request?i.headers:void 0),s=new Headers(d??{});return s.has(v)?e:(s.set(v,t),{...e??{},headers:s})}function $(){if(typeof window>"u")return;const e=window.desktopModeConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function P(i){try{const e=typeof window<"u"&&window.location?window.location.href:void 0;return typeof i=="string"?new URL(i,e):i instanceof URL?i:typeof Request<"u"&&i instanceof Request?new URL(i.url,e):null}catch{return null}}function U(i){return typeof window>"u"||!window.location||i.origin!==window.location.origin?!1:!!(i.pathname.includes("/wp-json/")||i.searchParams.has("rest_route"))}function F(i,e,t={}){const o=window.wp?.desktop?.fetch;if(typeof o=="function")return o(i,e,t);const d=M(i,e);return fetch(i,d)}const O="__desktopModeSharedStores";function H(){const i=window;let e=i[O];return e||(e=new Map,i[O]=e),e}function G(i,e){const t=H();let o=t.get(i);o||(o={state:e(),listeners:new Set,rebuild:e},t.set(i,o));const d={get state(){return o.state},set state(s){o.state=s},getState(){return o.state},notify(){for(const s of Array.from(o.listeners))try{s(o.state)}catch(n){console.error(`[desktop-mode/shared-store:${i}] subscriber threw:`,n)}},subscribe(s){return o.listeners.add(s),()=>{o.listeners.delete(s)}},setState(s){const n=o.state;if(typeof n!="object"||n===null){console.warn(`[desktop-mode/shared-store:${i}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(n,s),d.notify()},reset(){const s=o.rebuild(),n=o.state;if(typeof n=="object"&&n!==null&&typeof s=="object"&&s!==null){const r=n;for(const a of Object.keys(r))delete r[a];Object.assign(r,s)}else o.state=s;o.listeners.clear()}};return d}const N=G("desktop-mode/commands-registry",()=>({registry:new Map,listeners:new Set})),m=N.state.registry,D=N.state.listeners;function y(){return Array.from(m.values())}function c(){return Array.from(m.values()).filter(i=>i.eager===!0)}function h(i){return m.get(i.toLowerCase())??null}function I(i){const e=i.trim().toLowerCase();return e===""?y():y().filter(t=>t.slug.toLowerCase().startsWith(e)||t.label.toLowerCase().includes(e))}function x(i){return D.add(i),()=>{D.delete(i)}}function g(i){if(!i.startsWith("/"))return{isCommand:!1,slug:"",args:"",hasArgsPart:!1};const e=i.slice(1),t=e.indexOf(" ");return t===-1?{isCommand:!0,slug:e,args:"",hasArgsPart:!1}:{isCommand:!0,slug:e.slice(0,t),args:e.slice(t+1),hasArgsPart:!0}}function B(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function f(i){return i.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,o)=>/^https?:\/\//i.test(o.trim())?`<a href="${o.trim()}" target="_blank" rel="noopener noreferrer">${t}</a>`:t).replace(/\*\*([^*\n]+?)\*\*/g,"<strong>$1</strong>").replace(/(?<![*\w])\*([^*\n]+?)\*(?![*\w])/g,"<em>$1</em>").replace(/(?<![_\w])_([^_\n]+?)_(?![_\w])/g,"<em>$1</em>").replace(/`([^`\n]+?)`/g,"<code>$1</code>")}function q(i){if(!i)return"";const t=B(i).split(/\n\s*\n/),o=[];for(const d of t){const s=d.split(/\n/).map(a=>a.trim()).filter(a=>a!=="");if(s.length===0)continue;const n=s.every(a=>/^[-*]\s+/.test(a)),r=s.every(a=>/^\d+\.\s+/.test(a));if(n){const a=s.map(l=>`<li>${f(l.replace(/^[-*]\s+/,""))}</li>`);o.push(`<ul>${a.join("")}</ul>`)}else if(r){const a=s.map(l=>`<li>${f(l.replace(/^\d+\.\s+/,""))}</li>`);o.push(`<ol>${a.join("")}</ol>`)}else o.push(`<p>${f(s.join("<br>"))}</p>`)}return o.join("")}const E=`<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true" focusable="false" fill="currentColor">
2 - <path d="M10 2 L11.8 7.8 L17.5 9.5 L11.8 11.2 L10 17 L8.2 11.2 L2.5 9.5 L8.2 7.8 Z"/>
3 -</svg>`,K=`<svg viewBox="0 0 14 14" width="12" height="12" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" aria-hidden="true" focusable="false">
4 - <line x1="2" y1="2" x2="12" y2="12"/>
5 - <line x1="12" y1="2" x2="2" y2="12"/>
6 -</svg>`,V=`<svg viewBox="0 0 16 16" width="13" height="13" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
1 +(function(){"use strict";function b(){const n=window.wp?.hooks;if(!n)throw new Error("[openstation] `window.wp.hooks` is not available. The plugin declares `wp-hooks` as a script dependency; if you are seeing this error, verify the enqueue order.");return n}function F(n,e,...s){return b().applyFilters(n,e,...s)}function R(n,...e){b().doAction(n,...e)}const f={INIT:"os.init",WALLPAPERS:"os.wallpapers",GAMES:"os.games",UNFOCUS_EFFECTS:"os.unfocus-effects",WINDOW_REVEALS:"os.window-reveals",WALLPAPER_MOUNTING:"os.wallpaper.mounting",WALLPAPER_MOUNTED:"os.wallpaper.mounted",WALLPAPER_UNMOUNTING:"os.wallpaper.unmounting",WALLPAPER_MOUNT_FAILED:"os.wallpaper.mount-failed",WALLPAPER_VISIBILITY:"os.wallpaper.visibility",WALLPAPER_SUSPEND:"os.wallpaper.suspend",WALLPAPER_PREVIEW_PARAMS:"os.wallpaper.preview-params",WALLPAPER_SETTINGS_CHANGED:"os.wallpaper.settings-changed",IFRAME_READY:"os.iframe.ready",IFRAME_ERROR:"os.iframe.error",IFRAME_NETWORK_COMPLETED:"os.iframe.network-completed",SHELL_ERROR:"os.shell.error",BROADCAST:"os.broadcast",MONITOR_ENTRY:"os.monitor.entry",WALLPAPER_SURFACES:"os.wallpaper.surfaces",DESKTOP_THEME_CHANGED:"os.os-theme.changed",DESKTOP_THEME_ICON:"os.os-theme.icon",DESKTOP_THEME_ICON_COLOR:"os.os-theme.icon-color",WALLPAPERS_SERVER_CHANGED:"os.wallpapers.server-changed",EXTENDED_OPTIONS_CHANGED:"os.extended-options.changed",WINDOW_GEOMETRY:"os.window.geometry",WINDOW_OPENED:"os.window.opened",WINDOW_CONTENT_LOADING:"os.window.content-loading",WINDOW_CONTENT_LOADED:"os.window.content-loaded",WINDOW_LOADING_OVERLAY:"os.window.loading-overlay",WINDOW_REOPENED:"os.window.reopened",WINDOW_MENU_OPENED:"os.window.menu-opened",WINDOW_CLOSING:"os.window.closing",WINDOW_CLOSED:"os.window.closed",WINDOW_FOCUSED:"os.window.focused",WINDOW_BLURRED:"os.window.blurred",WINDOW_MINIMIZED:"os.window.minimized",WINDOW_RESTORED:"os.window.restored",WINDOW_CHILD_BLOCKED:"os.window.child-blocked",WINDOW_MAXIMIZED:"os.window.maximized",WINDOW_UNMAXIMIZED:"os.window.unmaximized",WINDOW_FULLSCREEN_ENTERED:"os.window.fullscreen-entered",WINDOW_FULLSCREEN_EXITED:"os.window.fullscreen-exited",WINDOW_AUTO_EXIT_FULLSCREEN:"os.window.auto-exit-fullscreen",WINDOW_FOCUS_ON_DRAG_HOVER:"os.window.focus-on-drag-hover",WINDOW_BOUNDS_CHANGED:"os.window.bounds-changed",WINDOW_MOVED:"os.window.moved",WINDOW_RESIZED:"os.window.resized",WINDOW_DRAG_START:"os.window.drag-start",WINDOW_DRAG_END:"os.window.drag-end",WINDOW_RESIZE_START:"os.window.resize-start",WINDOW_RESIZE_END:"os.window.resize-end",WINDOW_DETACHED:"os.window.detached",WINDOW_RELOADED:"os.window.reloaded",WINDOW_TITLE_CHANGED:"os.window.title-changed",WINDOW_HIGHLIGHT_CHANGED:"os.window.highlight-changed",WINDOW_BODY_RESIZED:"os.window.body-resized",NATIVE_WINDOW_BEFORE_RENDER:"os.native-window.before-render",NATIVE_WINDOW_AFTER_RENDER:"os.native-window.after-render",NATIVE_WINDOW_BEFORE_CLOSE:"os.native-window.before-close",WINDOW_CHROME_THEME:"os.window.chrome.theme",WINDOW_CHROME_CONTROLS:"os.window.chrome.controls",WINDOW_CHROME_SLOT:"os.window.chrome.slot",WINDOW_CHROME_RENDER:"os.window.chrome.render",WINDOW_CHROME_APPLIED:"os.window.chrome.applied",WINDOW_CHROME_THEME_CHANGED:"os.window.chrome.theme-changed",DESKTOP_ICON_CLICKED:"os.os-icon.clicked",DESKTOP_ICONS_RENDERED:"os.os-icons.rendered",ICON_BADGE_CHANGED:"os.icon.badge-changed",COMPONENTS_REGISTERED:"os.components.registered",DOCK_ITEM_APPENDED:"os.dock.item-appended",DOCK_ITEM_REMOVED:"os.dock.item-removed",DOCK_BEFORE_RENDER:"os.dock.before-render",DOCK_AFTER_RENDER:"os.dock.after-render",DOCK_REFRESH_ACTIVE:"os.dock.refresh-active",DOCK_TILE_CLASS:"os.dock.tile-class",DOCK_TILE_ELEMENT:"os.dock.tile-element",DOCK_TILE_RENDERED:"os.dock.tile-rendered",DOCK_TILE_TOOLTIP:"os.dock.tile-tooltip",DOCK_PEEK_CARD_CONTENT:"os.dock.peek-card-content",DOCK_PEEK_CARD_ELEMENT:"os.dock.peek-card-element",CONSTELLATION_PANEL:"os.constellation.panel",CONSTELLATION_OPENED:"os.constellation.opened",CONSTELLATION_CLOSED:"os.constellation.closed",OVERVIEW_ENTERING:"os.overview.entering",OVERVIEW_ENTERED:"os.overview.entered",OVERVIEW_EXITING:"os.overview.exiting",OVERVIEW_EXITED:"os.overview.exited",OVERVIEW_WINDOW_HOVER:"os.overview.window-hover",OVERVIEW_WINDOW_UNHOVER:"os.overview.window-unhover",OVERVIEW_WINDOW_CLICK:"os.overview.window-click",WORK_AREA_CHANGED:"os.work-area.changed",ARRANGE_CASCADE_STARTING:"os.arrange.cascade.starting",ARRANGE_CASCADE_APPLIED:"os.arrange.cascade.applied",ARRANGE_TILE_STARTING:"os.arrange.tile.starting",ARRANGE_TILE_APPLIED:"os.arrange.tile.applied",ARRANGE_TILE_DIMENSIONS:"os.arrange.tile.dimensions",ARRANGE_COLUMNS_STARTING:"os.arrange.columns.starting",ARRANGE_COLUMNS_APPLIED:"os.arrange.columns.applied",ARRANGE_FOCUS_SPLIT:"os.arrange.focus.split",ARRANGE_FOCUS_STARTING:"os.arrange.focus.starting",ARRANGE_FOCUS_APPLIED:"os.arrange.focus.applied",ARRANGE_SNAP_CHANGED:"os.arrange.snap.changed",ARRANGE_SNAP_CELL_SIZE:"os.arrange.snap.cell-size",POINTER_SHAKE:"os.pointer.shake",GRID_SNAP_DIMENSIONS:"os.grid-snap.dimensions",GRID_SNAP_ARMED:"os.grid-snap.armed",GRID_SNAP_CHANGED:"os.grid-snap.changed",GRID_SNAP_ANCHOR_RESET:"os.grid-snap.anchor-reset",GRID_SNAP_CANCELED:"os.grid-snap.canceled",GRID_SNAP_COMMITTED:"os.grid-snap.committed",GRID_SNAP_REFLOWED:"os.grid-snap.reflowed",SNAP_ZONE_PENDING:"os.snap.zone-pending",SNAP_ZONE_CANCELED:"os.snap.zone-canceled",SNAP_ZONE_COMMITTED:"os.snap.zone-committed",SNAP_SPLIT_FILLED:"os.snap.split-filled",WIDGETS:"os.widgets",WIDGET_MOUNTING:"os.widget.mounting",WIDGET_MOUNTED:"os.widget.mounted",WIDGET_UNMOUNTING:"os.widget.unmounting",WIDGET_MOUNT_FAILED:"os.widget.mount-failed",WIDGET_ADDED:"os.widget.added",WIDGET_REMOVED:"os.widget.removed",DESKTOP_CREATED:"os.os.created",DESKTOP_CLOSED:"os.os.closed",DESKTOP_SWITCHED:"os.os.switched",DESKTOP_RENAMED:"os.os.renamed",WINDOW_DESKTOP_CHANGED:"os.os.window-moved",PRIMARY_DESKTOP_ID:"os.primary-desktop-id",WORKSPACE_PRESETS:"os.workspaces.presets",WORKSPACE_PROFILE:"os.workspaces.profile",WORKSPACE_UPDATED:"os.workspaces.updated",WORKSPACE_PROVISIONED:"os.workspaces.provisioned",WINDOWS_BEFORE_CLOSE_ALL:"os.windows.before-close-all",WINDOWS_CLOSE_ALL:"os.windows.close-all",WINDOWS_AFTER_CLOSE_ALL:"os.windows.after-close-all",COMMAND_BEFORE_RUN:"os.command.before-run",COMMAND_AFTER_RUN:"os.command.after-run",COMMAND_ERROR:"os.command.error",SHELL_RESIZED:"os.shell.resized",SHELL_VISIBILITY:"os.shell.visibility",CONNECTION_OPENED:"os.connection.opened",CONNECTION_CLOSED:"os.connection.closed",CONNECTION_MESSAGE:"os.connection.message",IFRAME_CONNECTION_REQUEST:"os.iframe.connection-request",WINDOW_CONTENT_CHANGED:"os.window-links.content-changed",WINDOW_LINK_GROUPS_CHANGED:"os.window-links.groups-changed",WINDOW_LINKS_CONTENT:"os.window-links.content",WINDOW_LINK_GROUPS:"os.window-links.groups",WINDOW_LINK_EDGES:"os.window-links.edges",RELATED_ENTITIES_ITEMS:"os.related-entities.items",WINDOW_LINK_RENDERERS:"os.window-links.renderers",WINDOW_LINK_RENDERER:"os.window-links.renderer",EDITOR_PREVIEW_WINDOW_CONFIG:"os.editor-preview.window-config",EDITOR_PREVIEW_LIVE:"os.editor-preview.live",EDITOR_PREVIEW_OPENED:"os.editor-preview.opened",EDITOR_PREVIEW_CLOSED:"os.editor-preview.closed",REVISIONS_WINDOW_CONFIG:"os.revisions.window-config",REVISIONS_OPENED:"os.revisions.opened",FILE_DROP_FILES_DETECTED:"os.drop.files-detected",FILE_DROP_FILES_REJECTED:"os.drop.files-rejected",FILE_DROP_DIALOG_FIELDS:"os.drop.dialog-fields",FILE_DROP_BEFORE_UPLOAD:"os.drop.before-upload",FILE_DROP_UPLOAD_STARTED:"os.drop.upload-started",FILE_DROP_UPLOAD_PROGRESS:"os.drop.upload-progress",FILE_DROP_AFTER_UPLOAD:"os.drop.after-upload",FILE_DROP_UPLOAD_FAILED:"os.drop.upload-failed",AUTH_LOST:"os.auth.lost",AUTH_RESTORED:"os.auth.restored",MODE_CHANGED:"os.mode.changed",SESSION_SNAPSHOT:"os.session.snapshot"},y="desktop-mode";function g(){return window.wp?.i18n}function l(n,e=y){return g()?.__(n,e)??n}function G(n,e,s=y){return g()?._x(n,e,s)??n}function _(n,...e){const s=g()?.sprintf;if(s)return s(n,...e);let t=0;return n.replace(/%(?:(\d+)\$)?[sd]/g,(o,i)=>{const r=i?Number.parseInt(i,10)-1:t++;return String(e[r]??"")})}let w=null;function v(){return!!window.openStationShellOverlays}function U(n){return new Promise((e,s)=>{const t=document.querySelector('script[data-os-shell-overlays="1"]'),o=()=>{if(v()){e();return}s(new Error("[openstation] shell-overlays bundle loaded but did not set `window.openStationShellOverlays`."))};if(t){v()?o():(t.addEventListener("load",o),t.addEventListener("error",()=>s(new Error("failed to load shell-overlays bundle"))));return}const i=document.createElement("script");i.src=n,i.async=!0,i.dataset.osShellOverlays="1",i.addEventListener("load",o),i.addEventListener("error",()=>s(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(i)})}function V(n){return v()||!n?Promise.resolve():(w||(w=U(n)),w)}function K(){return window.openStationConfig?.shellOverlaysBundleUrl??""}async function q(n){return await V(K()),new Promise(e=>{const s=document.createElement("os-confirm-dialog");s.setAttribute("open",""),n.title&&s.setAttribute("title",n.title),s.setAttribute("message",n.message),n.confirmLabel&&s.setAttribute("confirm-label",n.confirmLabel),n.cancelLabel&&s.setAttribute("cancel-label",n.cancelLabel),n.danger&&s.setAttribute("danger",""),n.hideCancel&&s.setAttribute("hide-cancel",""),n.dismissable&&s.setAttribute("dismissable",""),n.rememberLabel&&s.setAttribute("remember-label",n.rememberLabel);const t=o=>{s.remove(),e(o)};s.addEventListener("os-confirm",o=>{n.onRemember?.(o.detail?.remember===!0),t(!0)}),s.addEventListener("os-cancel",()=>t(!1)),document.body.appendChild(s)})}const L="X-WP-Nonce";function z(n,e){const s=B();if(!s)return e;const t=Z(n);if(!t||!j(t))return e;const o=e?.headers??(typeof Request<"u"&&n instanceof Request?n.headers:void 0),i=new Headers(o??{});return i.has(L)?e:(i.set(L,s),{...e??{},headers:i})}function B(){if(typeof window>"u")return;const e=window.openStationConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function Z(n){try{const e=typeof window<"u"&&window.location?window.location.href:void 0;return typeof n=="string"?new URL(n,e):n instanceof URL?n:typeof Request<"u"&&n instanceof Request?new URL(n.url,e):null}catch{return null}}function j(n){return typeof window>"u"||!window.location||n.origin!==window.location.origin?!1:!!(n.pathname.includes("/wp-json/")||n.searchParams.has("rest_route"))}function k(n,e,s={}){const t=window.wp?.os?.fetch;if(typeof t=="function")return t(n,e,s);const o=z(n,e);return fetch(n,o)}function X(n){const e=document.createElement("textarea");return e.innerHTML=n,e.value}const T={close:{a:'fill="currentColor"',b:'<path d="m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z" />'},check:{a:'fill="currentColor"',b:'<path d="M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" />'},"chevron-right":{a:'fill="currentColor"',b:'<path d="M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" />'},"arrow-up-right":{a:'fill="currentColor"',b:'<path d="M10 6H18V14H16.5V8.5L7 18L6 17L15.5 7.5H10V6Z" />'},plus:{a:'fill="currentColor"',b:'<path d="M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" />'},search:{a:'fill="currentColor"',b:'<path d="M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" />'},pin:{a:'fill="currentColor"',b:'<path d="m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z" />'},trash:{a:'fill="currentColor"',b:'<path fill-rule="evenodd" clip-rule="evenodd" d="M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" />'},download:{a:'fill="currentColor"',b:'<path d="M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z" />'},settings:{a:'fill="currentColor"',b:'<path d="m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z" /><path d="m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z" />'},info:{a:'fill="currentColor"',b:'<path fill-rule="evenodd" clip-rule="evenodd" d="M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z" />'},bell:{a:'fill="currentColor"',b:'<path fill-rule="evenodd" clip-rule="evenodd" d="M17 11.5c0 1.353.17 2.368.976 3 .266.209.602.376 1.024.5v1H5v-1c.422-.124.757-.291 1.024-.5.806-.632.976-1.647.976-3V9c0-2.8 2.2-5 5-5s5 2.2 5 5v2.5ZM15.5 9v2.5c0 .93.066 1.98.515 2.897l.053.103H7.932a4.018 4.018 0 0 0 .053-.103c.449-.917.515-1.967.515-2.897V9c0-1.972 1.528-3.5 3.5-3.5s3.5 1.528 3.5 3.5Zm-5.492 9.008c0-.176.023-.346.065-.508h3.854A1.996 1.996 0 0 1 12 20c-1.1 0-1.992-.892-1.992-1.992Z" />'},more:{a:'fill="currentColor"',b:'<path d="M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z" />'},maximize:{a:'fill="currentColor"',b:'<path d="M6 4a2 2 0 0 0-2 2v3h1.5V6a.5.5 0 0 1 .5-.5h3V4H6Zm3 14.5H6a.5.5 0 0 1-.5-.5v-3H4v3a2 2 0 0 0 2 2h3v-1.5Zm6 1.5v-1.5h3a.5.5 0 0 0 .5-.5v-3H20v3a2 2 0 0 1-2 2h-3Zm3-16a2 2 0 0 1 2 2v3h-1.5V6a.5.5 0 0 0-.5-.5h-3V4h3Z" />'},edit:{a:'fill="currentColor"',b:'<path d="m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" />'},color:{a:'fill="currentColor"',b:'<path d="M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z" />'},wallpaper:{a:'fill="currentColor"',b:'<path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v8.4l-3-2.9c-.3-.3-.8-.3-1 0L11.9 14 9 12c-.3-.2-.6-.2-.8 0l-3.6 2.6V5c-.1-.3.1-.5.4-.5zm14 15H5c-.3 0-.5-.2-.5-.5v-2.4l4.1-3 3 1.9c.3.2.7.2.9-.1L16 12l3.5 3.4V19c0 .3-.2.5-.5.5z" />'},warning:{a:'fill="currentColor"',b:'<path fill-rule="evenodd" clip-rule="evenodd" d="M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm-.75 12v-1.5h1.5V16h-1.5Zm0-8v5h1.5V8h-1.5Z" />'},minimize:{a:'fill="currentColor"',b:'<path d="M5 11.25h14v1.5H5z" />'},window:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="4.125" y="5.4375" width="15.75" height="13.125" rx="1.75"/><path d="M4.125 9.8125h15.75"/><circle cx="7.275" cy="7.625" r="0.7438" fill="currentColor" stroke="none"/>'},windows:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.6875" y="8.5" width="11.375" height="10.0625" rx="1.75"/><path d="M3.6875 12h11.375"/><path d="M8.5 8.5V7.1875a1.75 1.75 0 0 1 1.75-1.75h7.875A1.75 1.75 0 0 1 19.875 7.1875v7a1.75 1.75 0 0 1-1.75 1.75h-3.0625"/>'},dock:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.25" y="8.5" width="17.5" height="7" rx="3.5"/><circle cx="7.625" cy="12" r="1.0062" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.0062" fill="currentColor" stroke="none"/><circle cx="16.375" cy="12" r="1.0062" fill="currentColor" stroke="none"/>'},spaces:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.6875" y="5.4375" width="7.4375" height="7.875" rx="1.75"/><rect x="12.875" y="5.4375" width="7.4375" height="7.875" rx="1.75"/><circle cx="9.375" cy="17.6875" r="0.7875" fill="currentColor" stroke="none"/><circle cx="12" cy="17.6875" r="0.7875" fill="currentColor" stroke="none"/><circle cx="14.625" cy="17.6875" r="0.7875" fill="currentColor" stroke="none"/>'},copilot:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<path d="M10 2.5Q10.9 8.5 17.5 10Q10.9 11.5 10 17.5Q9.1 11.5 2.5 10Q9.1 8.5 10 2.5Z" fill="currentColor" stroke="none"/><path d="M17.9 14Q18.35 17.1 21.5 17.6Q18.35 18.1 17.9 21.2Q17.45 18.1 14.3 17.6Q17.45 17.1 17.9 14Z" fill="currentColor" stroke="none"/>'},snap:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.6875" y="5.4375" width="16.625" height="13.125" rx="1.75"/><path d="M12 5.4375v13.125"/><path d="M12 12h8.3125"/>'},command:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<path d="M14.625 6.75v10.5a2.625 2.625 0 1 0 2.625-2.625H6.75a2.625 2.625 0 1 0 2.625 2.625V6.75a2.625 2.625 0 1 0-2.625 2.625h10.5a2.625 2.625 0 1 0-2.625-2.625"/>'},apps:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="4.125" y="4.125" width="6.5625" height="6.5625" rx="1.75"/><rect x="13.3125" y="4.125" width="6.5625" height="6.5625" rx="1.75"/><rect x="4.125" y="13.3125" width="6.5625" height="6.5625" rx="1.75"/><rect x="13.3125" y="13.3125" width="6.5625" height="6.5625" rx="1.75"/>'},widgets:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.6875" y="3.6875" width="9.625" height="9.625" rx="1.75"/><rect x="15.0625" y="3.6875" width="5.25" height="5.25" rx="1.75"/><rect x="15.0625" y="10.6875" width="5.25" height="9.625" rx="1.75"/><rect x="3.6875" y="15.0625" width="9.625" height="5.25" rx="1.75"/>'},user:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<circle cx="12" cy="8.9375" r="3.5"/><path d="M5.4375 19.4375a6.5625 6.5625 0 0 1 13.125 0"/>'},lock:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="5.4375" y="10.6875" width="13.125" height="8.75" rx="1.75"/><path d="M8.5 10.6875V8.0625a3.5 3.5 0 0 1 7 0v2.625"/>'}};function W(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function Y(n){return Object.prototype.hasOwnProperty.call(T,n)?T[n]:null}function S(n,e={}){const s=Y(n);if(!s)return"";const{size:t=24,className:o,title:i,rotate:r}=e,a=['xmlns="http://www.w3.org/2000/svg"','viewBox="0 0 24 24"'];t!=null&&a.push(`width="${t}"`,`height="${t}"`),a.push(s.a),o&&a.push(`class="${W(o)}"`),i?a.push('role="img"',`aria-label="${W(i)}"`):a.push('aria-hidden="true"','focusable="false"');const d=r?`<g transform="rotate(${r} 12 12)">${s.b}</g>`:s.b;return`<svg ${a.join(" ")}>${d}</svg>`}const M="__openStationSharedStores";function Q(){const n=window;let e=n[M];return e||(e=new Map,n[M]=e),e}function J(n,e){const s=Q();let t=s.get(n);t||(t={state:e(),listeners:new Set,rebuild:e},s.set(n,t));const o={get state(){return t.state},set state(i){t.state=i},getState(){return t.state},notify(){for(const i of Array.from(t.listeners))try{i(t.state)}catch(r){console.error(`[desktop-mode/shared-store:${n}] subscriber threw:`,r)}},subscribe(i){return t.listeners.add(i),()=>{t.listeners.delete(i)}},setState(i){const r=t.state;if(typeof r!="object"||r===null){console.warn(`[desktop-mode/shared-store:${n}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(r,i),o.notify()},reset(){const i=t.rebuild(),r=t.state;if(typeof r=="object"&&r!==null&&typeof i=="object"&&i!==null){const a=r;for(const d of Object.keys(a))delete a[d];Object.assign(a,i)}else t.state=i;t.listeners.clear()}};return o}const P=J("desktop-mode/commands-registry",()=>({registry:new Map,listeners:new Set})),O=P.state.registry,$=P.state.listeners;function N(){return Array.from(O.values())}function E(){return Array.from(O.values()).filter(n=>n.eager===!0)}function A(n){return O.get(n.toLowerCase())??null}function H(n){const e=n.trim().toLowerCase();return e===""?N():N().filter(s=>s.slug.toLowerCase().startsWith(e)||s.label.toLowerCase().includes(e))}function ee(n){return $.add(n),()=>{$.delete(n)}}function p(n){if(!n.startsWith("/"))return{isCommand:!1,slug:"",args:"",hasArgsPart:!1};const e=n.slice(1),s=e.indexOf(" ");return s===-1?{isCommand:!0,slug:e,args:"",hasArgsPart:!1}:{isCommand:!0,slug:e.slice(0,s),args:e.slice(s+1),hasArgsPart:!0}}function se(n){return n.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function C(n){return n.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,s,t)=>/^https?:\/\//i.test(t.trim())?`<a href="${t.trim()}" target="_blank" rel="noopener noreferrer">${s}</a>`:s).replace(/\*\*([^*\n]+?)\*\*/g,"<strong>$1</strong>").replace(/(?<![*\w])\*([^*\n]+?)\*(?![*\w])/g,"<em>$1</em>").replace(/(?<![_\w])_([^_\n]+?)_(?![_\w])/g,"<em>$1</em>").replace(/`([^`\n]+?)`/g,"<code>$1</code>")}function te(n){if(!n)return"";const e=se(n),s=[];let t=[],o=null;const i=()=>{t.length>0&&(s.push(`<p>${t.join("<br>")}</p>`),t=[])},r=()=>{o&&(s.push(`<${o.tag}>${o.items.join("")}</${o.tag}>`),o=null)};for(const a of e.split(/\n/)){const d=a.trim();if(d===""){i(),r();continue}const c=/^(#{1,6})\s+(.*)$/.exec(d);if(c){i(),r();const h=Math.min(6,c[1].length+2);s.push(`<h${h}>${C(c[2])}</h${h}>`);continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(d)){i(),r(),s.push("<hr>");continue}const u=/^[-*]\s+(.*)$/.exec(d),m=/^\d+\.\s+(.*)$/.exec(d);if(u||m){i();const h=u?"ul":"ol";(!o||o.tag!==h)&&(r(),o={tag:h,items:[]}),o.items.push(`<li>${C((u??m)[1])}</li>`);continue}r(),t.push(C(d))}return i(),r(),s.join("")}const I=S("copilot",{size:16}),x=S("chevron-right",{size:16}),ie=S("search",{size:16}),ne=`<svg viewBox="0 0 16 16" width="13" height="13" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round">
7 2 <polyline points="14,4 14,10 3,10"/>
8 3 <polyline points="6,7 3,10 6,13"/>
9 -</svg>`,j=`<svg viewBox="0 0 20 20" width="16" height="16" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" class="desktop-mode-ai__spinner-icon">
4 +</svg>`,oe=`<svg viewBox="0 0 20 20" width="16" height="16" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" class="os-ai__spinner-icon">
10 5 <circle cx="10" cy="10" r="7" stroke-opacity="0.25"/>
11 6 <path d="M10 3 A7 7 0 0 1 17 10" stroke-opacity="1"/>
12 -</svg>`,A=`<svg viewBox="0 0 16 16" width="12" height="12" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
13 - <polyline points="6,3 11,8 6,13"/>
14 -</svg>`,z=["Find my post about…","Where can I see categories?","Do I have any spam comments?","Take me to plugin settings"];class Z{constructor(e){this._isOpen=!1,this._isSearching=!1,this._previousFocus=null,this._currentStream=null,this._selectedCommand=0,this._keyboardNav=!1,this._selectedSuggestion=0,this._currentSuggestions=[],this._suggestToken=0,this.ask=()=>{throw new Error("[desktop-mode] wp.desktop.ai.ask called before the shell finished booting.")},this._aiSearchUrl=e.aiSearchUrl,this._aiSearchStreamUrl=e.aiSearchStreamUrl,this._restNonce=e.restNonce,this._getTransport=e.getTransport??(()=>"off"),this._el=this._buildDOM(),document.body.appendChild(this._el),this._input=this._el.querySelector(".desktop-mode-ai__input"),this._submitBtn=this._el.querySelector(".desktop-mode-ai__submit"),this._closeBtn=this._el.querySelector(".desktop-mode-ai__close"),this._resultsEl=this._el.querySelector(".desktop-mode-ai__results"),this._bindEvents(),this._renderSuggestions(),x(()=>{this._isOpen&&(this._input.value.startsWith("/")?this._renderCommandMode():this._input.value===""&&c().length>0&&this._renderCommandMode())})}open(){if(this._isOpen){this._input.focus(),this._input.select();return}this._isOpen=!0,this._previousFocus=this._el.ownerDocument.activeElement,this._input.value="",this._selectedCommand=0,this._submitBtn.classList.remove("has-value"),c().length>0?this._renderCommandMode():this._renderSuggestions(),this._el.removeAttribute("hidden"),this._el.offsetHeight,this._el.classList.add("is-open"),this._el.setAttribute("aria-hidden","false"),requestAnimationFrame(()=>this._input.focus())}close(){if(!this._isOpen)return;this._isOpen=!1,this._el.classList.remove("is-open"),this._el.setAttribute("aria-hidden","true"),this._closeStream(),this._isSearching=!1,this._submitBtn.disabled=!1,this._input.disabled=!1;const e=t=>{t.target!==this._el||t.propertyName!=="opacity"||(this._el.setAttribute("hidden",""),this._el.removeEventListener("transitionend",e),this._previousFocus instanceof HTMLElement&&this._previousFocus.focus())};this._el.addEventListener("transitionend",e)}toggle(){this._isOpen?this.close():this.open()}get isOpen(){return this._isOpen}attachAsk(e){this.ask=e}_bindEvents(){this._el.addEventListener("keydown",e=>{e.key==="Escape"&&(e.stopPropagation(),this.close())}),this._el.addEventListener("keydown",e=>{if(e.key!=="Tab")return;const t=[this._closeBtn,this._input,this._submitBtn].filter(n=>!n.disabled),o=t[0],d=t[t.length-1],s=this._el.ownerDocument.activeElement;e.shiftKey&&s===o?(e.preventDefault(),d.focus()):!e.shiftKey&&s===d&&(e.preventDefault(),o.focus())}),document.addEventListener("desktop-mode-open-ai",()=>this.open()),this._closeBtn.addEventListener("click",()=>this.close()),this._submitBtn.addEventListener("click",()=>this._onSubmit()),this._input.addEventListener("keydown",e=>{const t=g(this._input.value),o=t.isCommand===!1&&this._input.value===""&&c().length>0;if(t.isCommand&&!t.hasArgsPart||o){const d=this._sortCommands(o?c():I(t.slug).filter(s=>s.eager!==!0));if(e.key==="ArrowDown"){e.preventDefault(),this._selectedCommand=Math.min(this._selectedCommand+1,Math.max(0,d.length-1)),this._keyboardNav=!0,this._paintCommandSelection();return}if(e.key==="ArrowUp"){e.preventDefault(),this._selectedCommand=Math.max(0,this._selectedCommand-1),this._keyboardNav=!0,this._paintCommandSelection();return}if(e.key==="Tab"&&d.length>0&&!o){e.preventDefault();const s=d[this._selectedCommand]??d[0];this._input.value=`/${s.slug} `,this._submitBtn.classList.add("has-value"),this._selectedSuggestion=0,this._renderCommandMode();return}if(e.key==="Enter"&&!e.shiftKey){if(e.preventDefault(),d.length===0){this._showError(`Unknown command: /${t.slug}`);return}const s=d[this._selectedCommand]??d[0];this._runCommand(s,"");return}}if(t.isCommand&&t.hasArgsPart){const d=h(t.slug);if(!!d&&typeof d.suggest=="function"&&this._currentSuggestions.length>0){if(e.key==="ArrowDown"){e.preventDefault(),this._selectedSuggestion=Math.min(this._selectedSuggestion+1,this._currentSuggestions.length-1),this._paintSuggestionSelection();return}if(e.key==="ArrowUp"){e.preventDefault(),this._selectedSuggestion=Math.max(0,this._selectedSuggestion-1),this._paintSuggestionSelection();return}if(e.key==="Tab"){e.preventDefault();const n=this._currentSuggestions[this._selectedSuggestion];n&&(this._input.value=`/${t.slug} ${n.value}`);return}if(e.key==="Enter"&&!e.shiftKey&&d){e.preventDefault();const n=this._currentSuggestions[this._selectedSuggestion],r=n?n.value:t.args;this._runCommand(d,r);return}}}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this._onSubmit())}),this._input.addEventListener("input",()=>{const e=this._input.value.trim().length>0;this._submitBtn.classList.toggle("has-value",e),this._selectedCommand=0,this._selectedSuggestion=0,this._input.value.startsWith("/")?this._renderCommandMode():e||(c().length>0?this._renderCommandMode():this._renderSuggestions())}),this._resultsEl.addEventListener("mousemove",()=>{if(this._keyboardNav){this._keyboardNav=!1;const e=this._resultsEl.querySelector(".desktop-mode-ai__cmd-list");e&&e.classList.remove("desktop-mode-ai__cmd-list--kb-nav")}})}async _onSubmit(){const e=this._input.value.trim();if(!e||this._isSearching)return;const t=g(this._input.value);if(t.isCommand){const o=h(t.slug);if(!o){this._showError(`Unknown command: /${t.slug}`);return}await this._runCommand(o,t.args);return}await this._runSearch(e,null,0)}async _runCommand(e,t){if(this._isSearching)return;const o=L(_.COMMAND_BEFORE_RUN,{proceed:!0,slug:e.slug,args:t,command:e});if(o&&o.proceed===!1){this._showError(o.reason??`Command /${e.slug} was cancelled.`);return}this._isSearching=!0,this._submitBtn.disabled=!0,this._input.disabled=!0,this._showThinking(`Running /${e.slug}…`);const d={close:()=>{this._previousFocus=null,this.close()},openInWindow:(s,n,r)=>this._openInLegacyWindow(s,n,r),confirm:(s,n)=>this._confirm(s,n)};try{const s=await Promise.resolve(e.run(t,d));this._renderCommandResult(e,s),S(_.COMMAND_AFTER_RUN,{slug:e.slug,args:t,command:e,result:s})}catch(s){const n=s instanceof Error?s.message:String(s);this._showError(`Command /${e.slug} failed: ${n}`),S(_.COMMAND_ERROR,{slug:e.slug,args:t,command:e,error:s})}finally{this._isSearching=!1,this._submitBtn.disabled=!1,this._input.disabled=!1,this._input.focus()}}_confirm(e,t){return W({title:t?e:void 0,message:t??e})}_renderCommandResult(e,t){if(t==null){this._resultsEl.innerHTML="",this._resultsEl.hidden=!0;return}const o=typeof t=="string"?{answer_type:"chat",message:t,entity:null,admin_links:null,iterations:0,exhausted:!0,continue:null}:{answer_type:t.answer_type??"chat",message:t.message,entity:t.entity??null,admin_links:t.admin_links??null,iterations:0,exhausted:!0,continue:null};this._showResult("",o)}_runSearch(e,t,o){if(this._isSearching)return;this._isSearching=!0,this._submitBtn.disabled=!0,this._input.disabled=!0,this._showThinking("Thinking…"),this._getTransport()==="sse"&&typeof EventSource<"u"&&!!this._aiSearchStreamUrl?this._runSearchStream(e,t,o):this._runSearchFetch(e,t,o)}_runSearchStream(e,t,o){const d=new URL(this._aiSearchStreamUrl,window.location.origin);d.searchParams.set("nonce",this._restNonce),d.searchParams.set("query",e),t&&(d.searchParams.set("resume_tool",t),d.searchParams.set("start_offset",String(o))),this._closeStream();const s=new EventSource(d.toString());this._currentStream=s;const n=()=>{s.close(),this._currentStream=null,this._isSearching=!1,this._submitBtn.disabled=!1,this._input.disabled=!1,this._input.focus()};s.onmessage=r=>{let a;try{a=JSON.parse(r.data)}catch{return}if(!(!a||typeof a!="object"))switch(a.event){case"open":break;case"progress":typeof a.message=="string"&&this._showThinking(a.message);break;case"done":a.result&&this._showResult(e,a.result),n();break;case"error":this._showError(a.message??"Something went wrong.",a.code),n();break}},s.onerror=()=>{this._currentStream===s&&(this._showError("Lost connection to the assistant. Please try again."),n())}}async _runSearchFetch(e,t,o){try{const d={query:e};t&&(d.resume_tool=t,d.start_offset=o);const s=await F(this._aiSearchUrl,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":this._restNonce},body:JSON.stringify(d)},{source:"desktop-mode/ai-search"});if(!s.ok){const n=await s.json().catch(()=>({}));this._showError(n.message??`Server returned ${s.status}`,n.code);return}this._showResult(e,await s.json())}catch{this._showError("Network error — please check your connection and try again.")}finally{this._isSearching=!1,this._submitBtn.disabled=!1,this._input.disabled=!1,this._input.focus()}}_closeStream(){this._currentStream&&(this._currentStream.close(),this._currentStream=null)}_getDesktopShell(){return window.wp?.desktop??null}_openAiSettings(){const e=this._getDesktopShell();this._previousFocus=null,this.close(),e?.openOsSettings?.({tabId:"ai"})}_openInLegacyWindow(e,t,o){const d=this._getDesktopShell();if(!d||!d.windowManager){window.open(e,"_blank","noopener");return}const s=d.deriveWindowId?d.deriveWindowId(e):"desktop-mode-ai-"+e.replace(/[^a-z0-9]+/gi,"-").slice(0,80);d.windowManager.open({id:s,url:e,title:t,icon:o??"dashicons-admin-generic"}),this.close()}_renderCommandMode(){this._resultsEl.hidden=!1;const e=g(this._input.value);if(e.hasArgsPart){const n=h(e.slug);if(n){this._renderArgsMode(n,e.args);return}}const o=e.isCommand===!1&&this._input.value===""?c():I(e.slug).filter(n=>n.eager!==!0),d=this._sortCommands(o);if(d.length===0){this._resultsEl.innerHTML=`
15 - <div class="desktop-mode-ai__state desktop-mode-ai__state--empty">
16 - <span>No commands matching <strong>/${this._esc(e.slug)}</strong>.</span>
7 +</svg>`;function re(){return[l("Find my post about…"),l("Where can I see categories?"),l("Do I have any spam comments?"),l("Take me to plugin settings")]}class ae{constructor(e){this._isOpen=!1,this._isSearching=!1,this._previousFocus=null,this._closeFadeCleanup=null,this._searchAbort=null,this._mode="commands",this._modeInput={commands:"",ai:""},this._lastAiResult=null,this._currentRemoteCommands=[],this._remoteSearchToken=0,this._selectedCommand=0,this._keyboardNav=!1,this._selectedSuggestion=0,this._currentSuggestions=[],this._suggestToken=0,this.ask=()=>{throw new Error("[openstation] wp.os.ai.ask called before the shell finished booting.")},this._aiSearchUrl=e.aiSearchUrl,this._restNonce=e.restNonce,this._adminUrl=e.adminUrl,this._isAiSupported=e.isAiSupported??(()=>!0),this._canConnectProvider=e.canConnectProvider??(()=>!0),this._isAiAvailable=e.isAiAvailable??(()=>!1),this._isOverrideEnabled=e.isOverrideEnabled??(()=>!1),this._el=this._buildDOM(),document.body.appendChild(this._el),this._input=this._el.querySelector(".os-ai__input"),this._submitBtn=this._el.querySelector(".os-ai__submit"),this._resultsEl=this._el.querySelector(".os-ai__results"),this._bindEvents(),this._renderSuggestions(),ee(()=>{this._isOpen&&this._renderForMode()})}open(){if(this._isOpen){this._input.focus(),this._input.select();return}this._isOpen=!0,this._previousFocus=this._el.ownerDocument.activeElement,this._input.value="",this._modeInput={commands:"",ai:""},this._lastAiResult=null,this._currentRemoteCommands=[],this._remoteSearchToken++,this._selectedCommand=0,this._submitBtn.classList.remove("has-value"),this._mode=this._defaultMode(),this._updateModeUI(),this._renderForMode(),this._closeFadeCleanup?.(),this._el.removeAttribute("hidden"),this._el.offsetHeight,this._el.classList.add("is-open"),this._el.setAttribute("aria-hidden","false"),document.dispatchEvent(new CustomEvent("os-palette-opened",{detail:{id:"desktop-mode-ai-assistant"}})),requestAnimationFrame(()=>this._input.focus())}close(){if(!this._isOpen)return;this._isOpen=!1,this._el.classList.remove("is-open"),this._el.setAttribute("aria-hidden","true"),this._abortSearch(),this._isSearching=!1,this._submitBtn.disabled=!1,this._input.disabled=!1,document.dispatchEvent(new CustomEvent("os-palette-closed",{detail:{id:"desktop-mode-ai-assistant"}})),this._closeFadeCleanup?.();const e=s=>{s.target!==this._el||s.propertyName!=="opacity"||(this._el.removeEventListener("transitionend",e),this._closeFadeCleanup=null,!this._isOpen&&(this._el.setAttribute("hidden",""),this._previousFocus instanceof HTMLElement&&this._previousFocus.focus()))};this._closeFadeCleanup=()=>{this._el.removeEventListener("transitionend",e),this._closeFadeCleanup=null},this._el.addEventListener("transitionend",e)}toggle(){this._isOpen?this.close():this.open()}get isOpen(){return this._isOpen}attachAsk(e){this.ask=e}_aiModeAllowed(){return this._isAiAvailable()&&this._isOverrideEnabled()}_defaultMode(){return this._aiModeAllowed()?"ai":"commands"}_aiNeedsSetup(){return this._mode==="ai"&&!this._aiModeAllowed()}_setMode(e){e!==this._mode&&(this._modeInput[this._mode]=this._input.value,this._mode=e,this._input.value=this._modeInput[e],this._submitBtn.classList.toggle("has-value",this._input.value.trim().length>0)),this._selectedCommand=0,this._selectedSuggestion=0,this._updateModeUI(),this._mode==="ai"&&this._lastAiResult&&this._lastAiResult.query===this._input.value.trim()?this._showResult(this._lastAiResult.query,this._lastAiResult.data):this._renderForMode(),this._input.focus()}_updateModeUI(){this._el.querySelectorAll(".os-ai__modes [data-mode]").forEach(t=>{const o=t.dataset.mode===this._mode;t.classList.toggle("is-active",o),t.setAttribute("aria-pressed",String(o))});const e=this._aiNeedsSetup();this._input.readOnly=e,e?this._input.setAttribute("aria-describedby","os-ai-setup-message"):this._input.removeAttribute("aria-describedby"),e?this._input.placeholder=l("The AI assistant isn’t set up yet"):this._input.placeholder=this._mode==="ai"?l("How can I help?"):l("Search commands…");const s=this._el.querySelector(".os-ai__input-icon");s&&(s.innerHTML=this._mode==="ai"?I:ie)}_isPickMode(e){return this._aiNeedsSetup()||e.isCommand&&e.hasArgsPart?!1:e.isCommand||this._mode==="commands"?!0:this._input.value===""&&E().length>0}_commandMatches(){const e=p(this._input.value);if(e.isCommand)return this._sortCommands(H(e.slug).filter(o=>o.eager!==!0));if(this._mode==="ai")return this._sortCommands(E());const s=this._input.value.trim();return[...this._sortCommands(s===""?N():H(s)),...this._currentRemoteCommands]}_pickCommand(e){if(typeof e.suggest=="function"){this._input.value=`/${e.slug} `,this._submitBtn.classList.add("has-value"),this._input.focus(),this._renderCommandMode();return}this._runCommand(e,"")}_renderForMode(){if(p(this._input.value).isCommand||this._mode==="commands"){this._renderCommandMode();return}if(this._aiNeedsSetup()){this._renderAiSetup();return}const s=E().length>0;if(this._input.value.trim()===""){s?this._renderCommandMode():this._renderSuggestions();return}this._resultsEl.querySelector(".os-ai__bubble")||(s?this._renderCommandMode():this._resultsEl.querySelector(".os-ai__suggestions")&&(this._resultsEl.innerHTML="",this._resultsEl.hidden=!0))}_bindEvents(){this._el.addEventListener("keydown",e=>{e.key==="Escape"&&(e.stopPropagation(),this.close())}),this._el.addEventListener("mousedown",e=>{const s=e.target;(!(s instanceof Element)||!s.closest(".os-ai__panel"))&&this.close()}),this._el.addEventListener("keydown",e=>{if(e.key!=="Tab")return;const s=[this._input,this._submitBtn,...this._el.querySelectorAll(".os-ai__mode, .os-ai__settings-link")].filter(r=>!r.disabled),t=s[0],o=s[s.length-1],i=this._el.ownerDocument.activeElement;e.shiftKey&&i===t?(e.preventDefault(),o.focus()):!e.shiftKey&&i===o&&(e.preventDefault(),t.focus())}),document.addEventListener("os-open-ai",()=>this.open()),this._el.querySelectorAll(".os-ai__mode").forEach(e=>{e.addEventListener("click",()=>this._setMode(e.dataset.mode==="ai"?"ai":"commands"))}),this._submitBtn.addEventListener("click",()=>this._onSubmit()),this._input.addEventListener("keydown",e=>{const s=p(this._input.value);if(this._isPickMode(s)){const t=this._commandMatches();if(e.key==="ArrowDown"){e.preventDefault(),this._selectedCommand=Math.min(this._selectedCommand+1,Math.max(0,t.length-1)),this._keyboardNav=!0,this._paintCommandSelection();return}if(e.key==="ArrowUp"){e.preventDefault(),this._selectedCommand=Math.max(0,this._selectedCommand-1),this._keyboardNav=!0,this._paintCommandSelection();return}if(e.key==="Tab"&&t.length>0&&s.isCommand){e.preventDefault();const o=t[this._selectedCommand]??t[0];this._input.value=`/${o.slug} `,this._submitBtn.classList.add("has-value"),this._selectedSuggestion=0,this._renderCommandMode();return}if(e.key==="Enter"&&!e.shiftKey){if(e.preventDefault(),t.length===0){s.isCommand&&this._showError(_(l("Unknown command: /%s"),s.slug));return}const o=t[this._selectedCommand]??t[0];this._pickCommand(o);return}}if(s.isCommand&&s.hasArgsPart){const t=A(s.slug);if(!!t&&typeof t.suggest=="function"&&this._currentSuggestions.length>0){if(e.key==="ArrowDown"){e.preventDefault(),this._selectedSuggestion=Math.min(this._selectedSuggestion+1,this._currentSuggestions.length-1),this._paintSuggestionSelection();return}if(e.key==="ArrowUp"){e.preventDefault(),this._selectedSuggestion=Math.max(0,this._selectedSuggestion-1),this._paintSuggestionSelection();return}if(e.key==="Tab"){e.preventDefault();const i=this._currentSuggestions[this._selectedSuggestion];i&&(this._input.value=`/${s.slug} ${i.value}`);return}if(e.key==="Enter"&&!e.shiftKey&&t){e.preventDefault();const i=this._currentSuggestions[this._selectedSuggestion],r=i?i.value:s.args;this._runCommand(t,r);return}}}e.key==="Enter"&&!e.shiftKey&&(e.preventDefault(),this._onSubmit())}),this._input.addEventListener("input",()=>{const e=this._input.value.trim().length>0;this._submitBtn.classList.toggle("has-value",e),this._selectedCommand=0,this._selectedSuggestion=0;const s=p(this._input.value),t=this._input.value.trim();!s.isCommand&&this._mode==="commands"&&t.length>0?this._fetchRemoteCommands(t):(this._currentRemoteCommands=[],this._remoteSearchToken++),this._renderForMode()}),this._resultsEl.addEventListener("mousemove",()=>{if(this._keyboardNav){this._keyboardNav=!1;const e=this._resultsEl.querySelector(".os-ai__cmd-list");e&&e.classList.remove("os-ai__cmd-list--kb-nav")}})}async _onSubmit(){if(this._isSearching){this._warnBusy("submit");return}if(this._aiNeedsSetup()){this._aiSetupRoute()==="preferences"&&this._openAssistantSettings("features");return}const e=p(this._input.value);if(this._isPickMode(e)){const t=this._commandMatches(),o=t[this._selectedCommand]??t[0];o&&this._pickCommand(o);return}const s=this._input.value.trim();if(s){if(e.isCommand){const t=A(e.slug);if(!t){this._showError(_(l("Unknown command: /%s"),e.slug));return}await this._runCommand(t,e.args);return}await this._runSearch(s,null,0)}}async _runCommand(e,s){if(this._isSearching){this._warnBusy(`run /${e.slug}`);return}const t=F(f.COMMAND_BEFORE_RUN,{proceed:!0,slug:e.slug,args:s,command:e});if(t&&t.proceed===!1){this._showError(t.reason??_(l("Command /%s was cancelled."),e.slug));return}this._isSearching=!0,this._submitBtn.disabled=!0,this._input.disabled=!0,this._showThinking(_(l("Running /%s…"),e.slug));const o={close:()=>{this._previousFocus=null,this.close()},openInWindow:(i,r,a)=>this._openInLegacyWindow(i,r,a),confirm:(i,r)=>this._confirm(i,r)};try{const i=await Promise.resolve(e.run(s,o));this._renderCommandResult(e,i),R(f.COMMAND_AFTER_RUN,{slug:e.slug,args:s,command:e,result:i})}catch(i){const r=i instanceof Error?i.message:String(i);this._showError(_(l("Command /%1$s failed: %2$s"),e.slug,r)),R(f.COMMAND_ERROR,{slug:e.slug,args:s,command:e,error:i})}finally{this._isSearching=!1,this._submitBtn.disabled=!1,this._input.disabled=!1,this._input.focus()}}_warnBusy(e){console.warn(`[openstation] command palette is busy — ignored: ${e}. A search or command is still running.`)}_confirm(e,s){return q({title:s?e:void 0,message:s??e})}_renderCommandResult(e,s){if(s==null){this._isOpen?this._renderForMode():(this._resultsEl.innerHTML="",this._resultsEl.hidden=!0);return}const t=typeof s=="string"?{answer_type:"chat",message:s,entity:null,admin_links:null,iterations:0,exhausted:!0,continue:null}:{answer_type:s.answer_type??"chat",message:s.message,entity:s.entity??null,admin_links:s.admin_links??null,iterations:0,exhausted:!0,continue:null};this._showResult("",t)}_runSearch(e,s,t){this._isSearching||(this._isSearching=!0,this._submitBtn.disabled=!0,this._input.disabled=!0,this._showThinking(l("Thinking…")),this._runSearchRequest(e,s,t))}_abortSearch(){this._searchAbort&&(this._searchAbort.abort(),this._searchAbort=null)}async _runSearchRequest(e,s,t){this._abortSearch();const o=new AbortController;this._searchAbort=o;try{const i={query:e};s&&(i.resume_tool=s,i.start_offset=t);const r=await k(this._aiSearchUrl,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":this._restNonce},body:JSON.stringify(i),signal:o.signal},{source:"desktop-mode/ai-search"});if(o.signal.aborted)return;if(!r.ok){const a=await r.json().catch(()=>({}));this._showError(a.message??_(l("Server returned %d"),r.status),a.data?.settings_tab);return}this._showResult(e,await r.json())}catch{o.signal.aborted||this._showError(l("Network error — please check your connection and try again."))}finally{this._searchAbort===o&&(this._searchAbort=null,this._isSearching=!1,this._submitBtn.disabled=!1,this._input.disabled=!1,this._input.focus())}}async _fetchRemoteCommands(e){const s=++this._remoteSearchToken;try{if(await new Promise(i=>setTimeout(i,200)),s!==this._remoteSearchToken)return;const t=await k(`/wp-json/wp/v2/search?search=${encodeURIComponent(e)}&subtype=post,page&_embed=self`,{headers:{"X-WP-Nonce":this._restNonce}},{silent:!0});if(!t.ok)return;const o=await t.json().catch(()=>[]);if(s!==this._remoteSearchToken)return;this._currentRemoteCommands=o.map(i=>{const r=i.subtype==="page",a=i._embedded?.self?.[0]?._links?.self?.[0]?.targetHints?.allow,d=!a||a.includes("PUT"),c=new URL("post.php",this._adminUrl);c.searchParams.set("post",String(i.id)),c.searchParams.set("action","edit");const u=d?c.toString():i.url,m=X(i.title||l("(No title)")),h=r?"dashicons-admin-page":"dashicons-admin-post";let D;return d?D=l(r?"Edit page":"Edit post"):D=l(r?"View page":"View post"),{slug:`post-${i.id}`,label:m,description:D,icon:h,eager:!1,run:(ce,de)=>{de.openInWindow(u,m,h)}}}),this._isOpen&&this._renderForMode()}catch{}}_getDesktopShell(){return window.wp?.os??null}_openAssistantSettings(e){const s=this._getDesktopShell();this._previousFocus=null,this.close(),s?.openOsSettings?.({tabId:e})}_openInLegacyWindow(e,s,t){const o=this._getDesktopShell();if(!o||!o.windowManager){window.open(e,"_blank","noopener");return}const i=o.deriveWindowId?o.deriveWindowId(e,this._adminUrl):"os-ai-"+e.replace(/[^a-z0-9]+/gi,"-").slice(0,80);o.windowManager.open({id:i,url:e,title:s,icon:t??"dashicons-admin-generic"}),this.close()}_renderCommandMode(){this._resultsEl.hidden=!1;const e=p(this._input.value);if(e.hasArgsPart){const r=A(e.slug);if(r){this._renderArgsMode(r,e.args);return}}const s=this._commandMatches();if(s.length===0){const r=e.isCommand?`/${e.slug}`:this._input.value.trim(),a=_(l("No commands matching %s."),`<strong>${this._esc(r)}</strong>`);this._resultsEl.innerHTML=`
8 + <div class="os-ai__state os-ai__state--empty">
9 + <span>${a}</span>
17 10 </div>
18 - `;return}this._selectedCommand>=d.length&&(this._selectedCommand=0);const s=d.map((n,r)=>`
11 + `;return}this._selectedCommand>=s.length&&(this._selectedCommand=0);const t=this._isPickMode(e),o=s.map((r,a)=>{const d=t&&a===this._selectedCommand?" is-selected":"",c=this._isEntityResultCommand(r);return`
19 12 <button
20 13 type="button"
21 - class="desktop-mode-ai__cmd-item${r===this._selectedCommand?" is-selected":""}"
22 - data-slug="${this._esc(n.slug)}"
23 - data-index="${r}"
14 + class="os-ai__cmd-item${d}${c?" is-entity-result":""}"
15 + data-slug="${this._esc(r.slug)}"
16 + data-index="${a}"
24 17 >
25 - ${n.iconSvg?`<span class="desktop-mode-ai__cmd-icon desktop-mode-ai__cmd-icon--svg" aria-hidden="true">${n.iconSvg}</span>`:`<span class="desktop-mode-ai__cmd-icon dashicons ${this._esc(n.icon??"dashicons-arrow-right-alt")}" aria-hidden="true"></span>`}
26 - <span class="desktop-mode-ai__cmd-body">
27 - <span class="desktop-mode-ai__cmd-title">
28 - ${this._esc(n.label)}
29 - ${n.hint?`<span class="desktop-mode-ai__cmd-hint">${this._esc(n.hint)}</span>`:""}
18 + ${r.iconSvg?`<span class="os-ai__cmd-icon os-ai__cmd-icon--svg" aria-hidden="true">${r.iconSvg}</span>`:`<span class="os-ai__cmd-icon dashicons ${this._esc(r.icon??"dashicons-arrow-right-alt")}" aria-hidden="true"></span>`}
19 + <span class="os-ai__cmd-body">
20 + <span class="os-ai__cmd-title">
21 + ${this._esc(r.label)}
22 + ${r.hint?`<span class="os-ai__cmd-hint">${this._esc(r.hint)}</span>`:""}
30 23 </span>
31 - ${n.description?`<span class="desktop-mode-ai__cmd-desc">${this._esc(n.description)}</span>`:""}
24 + ${r.description?`<span class="os-ai__cmd-desc">${this._esc(r.description)}</span>`:""}
32 25 </span>
33 26 </button>
34 - `).join("");this._resultsEl.innerHTML=`
35 - <div class="desktop-mode-ai__cmd-list">
36 - <p class="desktop-mode-ai__suggestions-label">Commands</p>
37 - ${s}
27 + `}).join(""),i=this._mode==="ai"&&E().length>0?`<p class="os-ai__suggestions-label">${this._esc(l("Suggested commands"))}</p>`:"";this._resultsEl.innerHTML=`
28 + <div class="os-ai__cmd-list">
29 + ${i}
30 + ${o}
38 31 </div>
39 - `,this._resultsEl.querySelectorAll(".desktop-mode-ai__cmd-item").forEach(n=>{n.addEventListener("click",()=>{const r=n.dataset.slug??"";this._input.value=`/${r} `,this._submitBtn.classList.add("has-value"),this._input.focus(),this._renderCommandMode()}),n.addEventListener("mouseenter",()=>{if(this._keyboardNav)return;const r=parseInt(n.dataset.index??"0",10);Number.isNaN(r)||(this._selectedCommand=r,this._resultsEl.querySelectorAll(".desktop-mode-ai__cmd-item").forEach((a,l)=>a.classList.toggle("is-selected",l===r)))})})}_renderArgsMode(e,t){if(typeof e.suggest!="function"){this._currentSuggestions=[],this._resultsEl.innerHTML=this._renderCommandHeader(e,!0);return}const o=++this._suggestToken,d={close:()=>this.close(),openInWindow:(r,a,l)=>this._openInLegacyWindow(r,a,l),confirm:(r,a)=>this._confirm(r,a)};let s;try{s=e.suggest(t,d)}catch{s=[]}const n=r=>{o===this._suggestToken&&(this._currentSuggestions=r,this._selectedSuggestion>=r.length&&(this._selectedSuggestion=0),this._resultsEl.innerHTML=this._renderCommandHeader(e,!1)+this._renderSuggestionList(r),this._resultsEl.querySelectorAll(".desktop-mode-ai__cmd-suggest-item").forEach(a=>{a.addEventListener("click",()=>{const l=parseInt(a.dataset.index??"0",10),k=r[l];k&&(this._input.value=`/${e.slug} ${k.value}`,this._runCommand(e,k.value))}),a.addEventListener("mouseenter",()=>{const l=parseInt(a.dataset.index??"0",10);Number.isNaN(l)||(this._selectedSuggestion=l,this._paintSuggestionSelection())})}))};s&&typeof s.then=="function"?(this._resultsEl.innerHTML=this._renderCommandHeader(e,!1),s.then(r=>n(Array.isArray(r)?r:[])).catch(()=>n([]))):n(Array.isArray(s)?s:[])}_renderCommandHeader(e,t){return`
40 - <div class="desktop-mode-ai__cmd-active">
41 - <span class="desktop-mode-ai__cmd-icon dashicons ${this._esc(e.icon??"dashicons-arrow-right-alt")}" aria-hidden="true"></span>
42 - <div class="desktop-mode-ai__cmd-body">
43 - <span class="desktop-mode-ai__cmd-title">
32 + `,this._resultsEl.querySelectorAll(".os-ai__cmd-item").forEach(r=>{const a=parseInt(r.dataset.index??"",10),d=Number.isNaN(a)?void 0:s[a];r.addEventListener("click",()=>{d&&this._pickCommand(d)}),r.addEventListener("mouseenter",()=>{this._keyboardNav||Number.isNaN(a)||(this._selectedCommand=a,this._resultsEl.querySelectorAll(".os-ai__cmd-item").forEach((c,u)=>c.classList.toggle("is-selected",u===a)))})})}_renderArgsMode(e,s){if(typeof e.suggest!="function"){this._currentSuggestions=[],this._resultsEl.innerHTML=this._renderCommandHeader(e,!0);return}const t=++this._suggestToken,o={close:()=>this.close(),openInWindow:(a,d,c)=>this._openInLegacyWindow(a,d,c),confirm:(a,d)=>this._confirm(a,d)};let i;try{i=e.suggest(s,o)}catch{i=[]}const r=a=>{t===this._suggestToken&&(this._currentSuggestions=a,this._selectedSuggestion>=a.length&&(this._selectedSuggestion=0),this._resultsEl.innerHTML=this._renderCommandHeader(e,!1)+this._renderSuggestionList(a),this._resultsEl.querySelectorAll(".os-ai__cmd-suggest-item").forEach(d=>{d.addEventListener("click",()=>{const c=parseInt(d.dataset.index??"0",10),u=a[c];u&&(this._input.value=`/${e.slug} ${u.value}`,this._runCommand(e,u.value))}),d.addEventListener("mouseenter",()=>{const c=parseInt(d.dataset.index??"0",10);Number.isNaN(c)||(this._selectedSuggestion=c,this._paintSuggestionSelection())})}))};i&&typeof i.then=="function"?(this._resultsEl.innerHTML=this._renderCommandHeader(e,!1),i.then(a=>r(Array.isArray(a)?a:[])).catch(()=>r([]))):r(Array.isArray(i)?i:[])}_renderCommandHeader(e,s){return`
33 + <div class="os-ai__cmd-active">
34 + <span class="os-ai__cmd-icon dashicons ${this._esc(e.icon??"dashicons-arrow-right-alt")}" aria-hidden="true"></span>
35 + <div class="os-ai__cmd-body">
36 + <span class="os-ai__cmd-title">
44 37 /${this._esc(e.slug)}
45 - ${e.hint?`<span class="desktop-mode-ai__cmd-hint">${this._esc(e.hint)}</span>`:""}
38 + ${e.hint?`<span class="os-ai__cmd-hint">${this._esc(e.hint)}</span>`:""}
46 39 </span>
47 - ${e.description?`<span class="desktop-mode-ai__cmd-desc">${this._esc(e.description)}</span>`:""}
48 - ${t?'<span class="desktop-mode-ai__cmd-enter-hint">Press <kbd>↵</kbd> to run</span>':""}
40 + ${e.description?`<span class="os-ai__cmd-desc">${this._esc(e.description)}</span>`:""}
41 + ${s?`<span class="os-ai__cmd-enter-hint">${_(l("Press %s to run"),"<kbd>↵</kbd>")}</span>`:""}
49 42 </div>
50 43 </div>
51 44 `}_renderSuggestionList(e){return e.length===0?`
52 - <div class="desktop-mode-ai__state desktop-mode-ai__state--empty">
53 - <span>No suggestions — press <kbd>↵</kbd> to run with the text you typed.</span>
45 + <div class="os-ai__state os-ai__state--empty">
46 + <span>${_(l("No suggestions — press %s to run with the text you typed."),"<kbd>↵</kbd>")}</span>
54 47 </div>
55 - `:`<div class="desktop-mode-ai__cmd-suggest-list">${e.map((o,d)=>`
48 + `:`<div class="os-ai__cmd-suggest-list">${e.map((t,o)=>`
56 49 <button
57 50 type="button"
58 - class="desktop-mode-ai__cmd-suggest-item${d===this._selectedSuggestion?" is-selected":""}"
59 - data-index="${d}"
51 + class="os-ai__cmd-suggest-item${o===this._selectedSuggestion?" is-selected":""}"
52 + data-index="${o}"
60 53 >
61 - <span class="desktop-mode-ai__cmd-icon dashicons ${this._esc(o.icon??"dashicons-arrow-right-alt")}" aria-hidden="true"></span>
62 - <span class="desktop-mode-ai__cmd-body">
63 - <span class="desktop-mode-ai__cmd-suggest-label">${this._esc(o.label)}</span>
64 - ${o.description?`<span class="desktop-mode-ai__cmd-desc">${this._esc(o.description)}</span>`:""}
54 + <span class="os-ai__cmd-icon dashicons ${this._esc(t.icon??"dashicons-arrow-right-alt")}" aria-hidden="true"></span>
55 + <span class="os-ai__cmd-body">
56 + <span class="os-ai__cmd-suggest-label">${this._esc(t.label)}</span>
57 + ${t.description?`<span class="os-ai__cmd-desc">${this._esc(t.description)}</span>`:""}
65 58 </span>
66 59 </button>
67 - `).join("")}</div>`}_sortCommands(e){return e.slice().sort((t,o)=>{const d=typeof t.owner=="string"&&t.owner.startsWith("iframe:")?0:1,s=typeof o.owner=="string"&&o.owner.startsWith("iframe:")?0:1;return d-s})}_paintCommandSelection(){const e=this._resultsEl.querySelectorAll(".desktop-mode-ai__cmd-item");e.forEach((d,s)=>{d.classList.toggle("is-selected",s===this._selectedCommand)});const t=this._resultsEl.querySelector(".desktop-mode-ai__cmd-list");t&&t.classList.toggle("desktop-mode-ai__cmd-list--kb-nav",this._keyboardNav);const o=e[this._selectedCommand];o&&typeof o.scrollIntoView=="function"&&o.scrollIntoView({block:"nearest"})}_paintSuggestionSelection(){this._resultsEl.querySelectorAll(".desktop-mode-ai__cmd-suggest-item").forEach((e,t)=>{e.classList.toggle("is-selected",t===this._selectedSuggestion)})}_renderSuggestions(){this._resultsEl.hidden=!1,this._resultsEl.innerHTML=`
68 - <div class="desktop-mode-ai__suggestions">
69 - <p class="desktop-mode-ai__suggestions-label">${this._esc("Try asking")}</p>
70 - <div class="desktop-mode-ai__suggestions-list">
71 - ${z.map(e=>`<button type="button" class="desktop-mode-ai__suggestion" data-prompt="${this._esc(e)}">
60 + `).join("")}</div>`}_sortCommands(e){return e.slice().sort((s,t)=>{const o=typeof s.owner=="string"&&s.owner.startsWith("iframe:")?0:1,i=typeof t.owner=="string"&&t.owner.startsWith("iframe:")?0:1;return o-i})}_isEntityResultCommand(e){return this._currentRemoteCommands.includes(e)}_paintCommandSelection(){const e=this._resultsEl.querySelectorAll(".os-ai__cmd-item");e.forEach((o,i)=>{o.classList.toggle("is-selected",i===this._selectedCommand)});const s=this._resultsEl.querySelector(".os-ai__cmd-list");s&&s.classList.toggle("os-ai__cmd-list--kb-nav",this._keyboardNav);const t=e[this._selectedCommand];t&&typeof t.scrollIntoView=="function"&&t.scrollIntoView({block:"nearest"})}_paintSuggestionSelection(){this._resultsEl.querySelectorAll(".os-ai__cmd-suggest-item").forEach((e,s)=>{e.classList.toggle("is-selected",s===this._selectedSuggestion)})}_renderSuggestions(){this._resultsEl.hidden=!1,this._resultsEl.innerHTML=`
61 + <div class="os-ai__suggestions">
62 + <p class="os-ai__suggestions-label">${this._esc(l("Try asking"))}</p>
63 + <div class="os-ai__suggestions-list">
64 + ${re().map(e=>`<button type="button" class="os-ai__suggestion" data-prompt="${this._esc(e)}">
72 65 ${this._esc(e)}
73 66 </button>`).join("")}
74 67 </div>
75 68 </div>
76 - `,this._resultsEl.querySelectorAll(".desktop-mode-ai__suggestion").forEach(e=>{e.addEventListener("click",()=>{const t=e.dataset.prompt??"";this._input.value=t,this._submitBtn.classList.add("has-value"),this._input.focus()})})}_showThinking(e="Thinking…"){this._resultsEl.hidden=!1,this._resultsEl.innerHTML=`
77 - <div class="desktop-mode-ai__state desktop-mode-ai__state--thinking">
78 - ${j}
69 + `,this._resultsEl.querySelectorAll(".os-ai__suggestion").forEach(e=>{e.addEventListener("click",()=>{const s=e.dataset.prompt??"";this._input.value=s,this._submitBtn.classList.add("has-value"),this._input.focus()})})}_aiSetupRoute(){return this._isAiSupported()?!this._isAiAvailable()&&!this._canConnectProvider()?"ask-admin":"preferences":"unavailable"}_renderAiSetup(){this._resultsEl.hidden=!1;const e=this._aiSetupRoute();if(e!=="preferences"){const t=l(e==="unavailable"?"AI features aren’t available on this site. You can still use Commands.":"Ask a site administrator to connect an AI provider to use the AI assistant.");this._resultsEl.innerHTML=`
70 + <div class="os-ai__state">
71 + <span id="os-ai-setup-message">${this._esc(t)}</span>
72 + </div>
73 + `;return}const s=`<button type="button" class="os-ai__settings-link">${this._esc(l("Set up the AI assistant"))}</button>`;this._resultsEl.innerHTML=`
74 + <div class="os-ai__state">
75 + <span id="os-ai-setup-message">${_(this._esc(l("%s to find content and ask questions about your site.")),s)}</span>
76 + </div>
77 + `,this._resultsEl.querySelector(".os-ai__settings-link")?.addEventListener("click",()=>this._openAssistantSettings("features"))}_showThinking(e=l("Thinking…")){this._resultsEl.hidden=!1,this._resultsEl.innerHTML=`
78 + <div class="os-ai__state os-ai__state--thinking">
79 + ${oe}
79 80 <span>${this._esc(e)}</span>
80 81 </div>
81 - `}_showError(e,t){if(this._resultsEl.hidden=!1,t==="desktop_mode_ai_disabled"){const o=this._esc(e),d=r=>`<button type="button" class="desktop-mode-ai__settings-link">${r}</button>`,s=/OS Settings.*?AI Settings/,n=s.test(o)?o.replace(s,r=>d(r)):`${o} ${d("AI Settings")}`;this._resultsEl.innerHTML=`
82 - <div class="desktop-mode-ai__state desktop-mode-ai__state--error">
83 - <span>${n}</span>
82 + `}_showError(e,s){if(this._resultsEl.hidden=!1,s){const t=`<button type="button" class="os-ai__settings-link">${this._esc(l("Open Preferences"))}</button>`;this._resultsEl.innerHTML=`
83 + <div class="os-ai__state os-ai__state--error">
84 + <span>${this._esc(e)} ${t}</span>
84 85 </div>
85 - `,this._resultsEl.querySelector(".desktop-mode-ai__settings-link")?.addEventListener("click",()=>this._openAiSettings());return}this._resultsEl.innerHTML=`
86 - <div class="desktop-mode-ai__state desktop-mode-ai__state--error">
86 + `,this._resultsEl.querySelector(".os-ai__settings-link")?.addEventListener("click",()=>this._openAssistantSettings(s));return}this._resultsEl.innerHTML=`
87 + <div class="os-ai__state os-ai__state--error">
87 88 <span>${this._esc(e)}</span>
88 89 </div>
89 - `}_showResult(e,t){this._resultsEl.hidden=!1;const o=`
90 - <div class="desktop-mode-ai__bubble">
91 - <span class="desktop-mode-ai__bubble-icon">${E}</span>
92 - <div class="desktop-mode-ai__bubble-text">${q(t.message||"")}</div>
90 + `}_showResult(e,s){e!==""&&(this._lastAiResult={query:e,data:s}),this._resultsEl.hidden=!1;const t=`
91 + <div class="os-ai__bubble">
92 + <span class="os-ai__bubble-icon">${I}</span>
93 + <div class="os-ai__bubble-text">${te(s.message||"")}</div>
93 94 </div>
94 - `;let d="";t.answer_type==="entity"&&t.entity?d=this._renderEntityCard(t.entity):t.answer_type==="navigation"&&t.admin_links&&t.admin_links.length>0&&(d=this._renderAdminLinks(t.admin_links)),t.continue&&(d+=`
95 - <button type="button" class="desktop-mode-ai__continue-btn"
96 - data-tool="${this._esc(t.continue.tool)}"
97 - data-offset="${t.continue.offset}"
95 + `;let o="";s.answer_type==="entity"&&s.entity?o=this._renderEntityCard(s.entity):s.answer_type==="navigation"&&s.admin_links&&s.admin_links.length>0&&(o=this._renderAdminLinks(s.admin_links)),s.continue&&(o+=`
96 + <button type="button" class="os-ai__continue-btn"
97 + data-tool="${this._esc(s.continue.tool)}"
98 + data-offset="${s.continue.offset}"
98 99 data-query="${this._esc(e)}">
99 - ${this._esc(t.continue.label)}
100 + ${this._esc(s.continue.label)}
100 101 </button>
101 - `),this._resultsEl.innerHTML=o+d,this._resultsEl.querySelectorAll(".desktop-mode-ai__entity-open").forEach(n=>{n.addEventListener("click",()=>{const r=n.dataset.url??"",a=n.dataset.title??"",l=n.dataset.icon??"dashicons-admin-generic";r&&this._openInLegacyWindow(r,a,l)})}),this._resultsEl.querySelectorAll(".desktop-mode-ai__admin-link").forEach(n=>{n.addEventListener("click",()=>{const r=n.dataset.url??"",a=n.dataset.title??"",l=n.dataset.icon??"dashicons-admin-generic";r&&this._openInLegacyWindow(r,a,l)})});const s=this._resultsEl.querySelector(".desktop-mode-ai__continue-btn");s&&s.addEventListener("click",()=>{const n=s.dataset.tool??null,r=parseInt(s.dataset.offset??"0",10),a=s.dataset.query??e;this._runSearch(a,n,r)})}_renderEntityCard(e){const t=e.type==="comment",o=t?`Comment on “${this._esc(e.post_title??"post")}”`:this._esc(e.title??"Untitled"),d=this._esc(e.ai_summary||e.excerpt||""),s=e.type.charAt(0).toUpperCase()+e.type.slice(1),n=e.topic?`<span class="desktop-mode-ai__entity-topic">${this._esc(e.topic)}</span>`:"";let r;return t?r="dashicons-admin-comments":e.type==="page"?r="dashicons-admin-page":r="dashicons-admin-post",`
102 - <div class="desktop-mode-ai__entity">
103 - <div class="desktop-mode-ai__entity-header">
104 - ${n}
105 - <span class="desktop-mode-ai__entity-type">${this._esc(s)}</span>
102 + `),this._resultsEl.innerHTML=t+o,this._resultsEl.querySelectorAll(".os-ai__entity-open").forEach(r=>{r.addEventListener("click",()=>{const a=r.dataset.url??"",d=r.dataset.title??"",c=r.dataset.icon??"dashicons-admin-generic";a&&this._openInLegacyWindow(a,d,c)})}),this._resultsEl.querySelectorAll(".os-ai__admin-link").forEach(r=>{r.addEventListener("click",()=>{const a=r.dataset.url??"",d=r.dataset.title??"",c=r.dataset.icon??"dashicons-admin-generic";a&&this._openInLegacyWindow(a,d,c)})});const i=this._resultsEl.querySelector(".os-ai__continue-btn");i&&i.addEventListener("click",()=>{const r=i.dataset.tool??null,a=parseInt(i.dataset.offset??"0",10),d=i.dataset.query??e;this._runSearch(d,r,a)})}_entityTypeLabel(e){switch(e){case"page":return l("Page");case"comment":return l("Comment");default:return l("Post")}}_entityOpenLabel(e){switch(e){case"page":return l("Open page in desktop");case"comment":return l("Open comment in desktop");default:return l("Open post in desktop")}}_renderEntityCard(e){const s=e.type==="comment",t=s?_(l("Comment on “%s”"),this._esc(e.post_title??G("post","fallback name for the post a comment was left on"))):this._esc(e.title??l("Untitled")),o=this._esc(e.ai_summary||e.excerpt||""),i=this._entityTypeLabel(e.type),r=e.topic?`<span class="os-ai__entity-topic">${this._esc(e.topic)}</span>`:"";let a;return s?a="dashicons-admin-comments":e.type==="page"?a="dashicons-admin-page":a="dashicons-admin-post",`
103 + <div class="os-ai__entity">
104 + <div class="os-ai__entity-header">
105 + ${r}
106 + <span class="os-ai__entity-type">${this._esc(i)}</span>
106 107 </div>
107 - <h3 class="desktop-mode-ai__entity-title">${o}</h3>
108 - <p class="desktop-mode-ai__entity-summary">${d}</p>
108 + <h3 class="os-ai__entity-title">${t}</h3>
109 + <p class="os-ai__entity-summary">${o}</p>
109 110 <button type="button"
110 - class="desktop-mode-ai__entity-open"
111 + class="os-ai__entity-open"
111 112 data-url="${this._esc(e.edit_url)}"
112 - data-title="${this._esc(e.title??e.post_title??s)}"
113 - data-icon="${r}">
114 - <span>${this._esc(`Open ${s.toLowerCase()} in desktop`)}</span>
115 - ${A}
113 + data-title="${this._esc(e.title??e.post_title??i)}"
114 + data-icon="${a}">
115 + <span>${this._esc(this._entityOpenLabel(e.type))}</span>
116 + ${x}
116 117 </button>
117 118 </div>
118 - `}_renderAdminLinks(e){return`<div class="desktop-mode-ai__admin-links">${e.map(o=>`
119 + `}_renderAdminLinks(e){return`<div class="os-ai__admin-links">${e.map(t=>`
119 120 <button type="button"
120 - class="desktop-mode-ai__admin-link"
121 - data-url="${this._esc(o.url)}"
122 - data-title="${this._esc(o.title)}"
123 - data-icon="${this._esc(o.icon)}">
124 - <span class="desktop-mode-ai__admin-link-icon dashicons ${this._esc(o.icon)}" aria-hidden="true"></span>
125 - <span class="desktop-mode-ai__admin-link-body">
126 - <span class="desktop-mode-ai__admin-link-title">${this._esc(o.title)}</span>
127 - <span class="desktop-mode-ai__admin-link-desc">${this._esc(o.description)}</span>
121 + class="os-ai__admin-link"
122 + data-url="${this._esc(t.url)}"
123 + data-title="${this._esc(t.title)}"
124 + data-icon="${this._esc(t.icon)}">
125 + <span class="os-ai__admin-link-icon dashicons ${this._esc(t.icon)}" aria-hidden="true"></span>
126 + <span class="os-ai__admin-link-body">
127 + <span class="os-ai__admin-link-title">${this._esc(t.title)}</span>
128 + <span class="os-ai__admin-link-desc">${this._esc(t.description)}</span>
128 129 </span>
129 - <span class="desktop-mode-ai__admin-link-arrow">${A}</span>
130 + <span class="os-ai__admin-link-arrow">${x}</span>
130 131 </button>
131 - `).join("")}</div>`}_esc(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}_buildDOM(){const e=document.createElement("div");return e.id="desktop-mode-ai-assistant",e.className="desktop-mode-ai",e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-label","AI Assistant"),e.setAttribute("aria-hidden","true"),e.setAttribute("hidden",""),e.innerHTML=`
132 - <div class="desktop-mode-ai__backdrop" aria-hidden="true"></div>
133 - <div class="desktop-mode-ai__panel">
134 - <div class="desktop-mode-ai__header">
135 - <span class="desktop-mode-ai__header-icon">${E}</span>
136 - <span class="desktop-mode-ai__header-label">AI Assistant</span>
137 - <button type="button" class="desktop-mode-ai__close" aria-label="Close">
138 - ${K}
139 - </button>
140 - </div>
141 - <div class="desktop-mode-ai__input-wrap">
142 - <span class="desktop-mode-ai__input-icon">${E}</span>
132 + `).join("")}</div>`}_esc(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}_buildDOM(){const e=document.createElement("div");return e.id="desktop-mode-ai-assistant",e.className="os-ai",e.setAttribute("role","dialog"),e.setAttribute("aria-modal","true"),e.setAttribute("aria-label",l("Site assistant")),e.setAttribute("aria-hidden","true"),e.setAttribute("hidden",""),e.innerHTML=`
133 + <div class="os-ai__backdrop" aria-hidden="true"></div>
134 + <div class="os-ai__panel">
135 + <div class="os-ai__input-wrap">
136 + <span class="os-ai__input-icon">${I}</span>
143 137 <input
144 - class="desktop-mode-ai__input"
138 + class="os-ai__input"
145 139 type="text"
146 - placeholder="How can I help?"
140 + placeholder="${this._esc(l("How can I help?"))}"
147 141 autocomplete="off"
148 142 spellcheck="false"
149 - aria-label="Ask the AI assistant"
143 + aria-label="${this._esc(l("Ask the assistant"))}"
150 144 />
151 - <button type="button" class="desktop-mode-ai__submit" aria-label="Send">
152 - ${V}
145 + <button type="button" class="os-ai__submit" aria-label="${this._esc(l("Send"))}">
146 + ${ne}
153 147 </button>
148 + <div class="os-ai__modes" role="group" aria-label="${this._esc(l("Assistant mode"))}">
149 + <button type="button" class="os-ai__mode" data-mode="ai" aria-pressed="false">${this._esc(l("Ask AI"))}</button>
150 + <button type="button" class="os-ai__mode" data-mode="commands" aria-pressed="false">${this._esc(l("Commands"))}</button>
151 + </div>
154 152 </div>
155 - <div class="desktop-mode-ai__results" hidden></div>
156 - <div class="desktop-mode-ai__footer">
157 - <span class="desktop-mode-ai__footer-hint">
158 - Your assistant for finding content and navigating wp-admin
153 + <div class="os-ai__results" hidden></div>
154 + <div class="os-ai__footer">
155 + <span class="os-ai__footer-hint">
156 + ${this._esc(l("Your assistant to quickly navigate and manage your entire site."))}
159 157 </span>
160 - <span class="desktop-mode-ai__footer-keys" aria-hidden="true">
161 - <kbd>&#8629;</kbd> ask
162 - </span>
163 158 </div>
164 159 </div>
165 - `,e}}const Y=i=>new Z(i);window.desktopModeCreateAiAssistant=Y})();
160 + `,e}}const le=n=>new ae(n);window.openStationCreateAiAssistant=le})();