PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 0.9.8
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v0.9.8
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 0.8.9 0.8.8 0.8.7 All 34 releases
desktop-mode / assets / js / ai-assistant.min.js

ai-assistant.min.js in OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin 0.9.8, at assets/js/ai-assistant.min.js

172 lines 39.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function(){"use strict";function O(){const d=window.wp?.hooks;if(!d)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 d}function b(d,e,...t){return O().applyFilters(d,e,...t)}function N(d,...e){O().doAction(d,...e)}const h={INIT:"desktop-mode.init",WALLPAPERS:"desktop-mode.wallpapers",GAMES:"desktop-mode.games",UNFOCUS_EFFECTS:"desktop-mode.unfocus-effects",WINDOW_REVEALS:"desktop-mode.window-reveals",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",WALLPAPER_SUSPEND:"desktop-mode.wallpaper.suspend",WALLPAPER_PREVIEW_PARAMS:"desktop-mode.wallpaper.preview-params",WALLPAPER_SETTINGS_CHANGED:"desktop-mode.wallpaper.settings-changed",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",DESKTOP_THEME_CHANGED:"desktop-mode.desktop-theme.changed",DESKTOP_THEME_ICON:"desktop-mode.desktop-theme.icon",DESKTOP_THEME_ICON_COLOR:"desktop-mode.desktop-theme.icon-color",WALLPAPERS_SERVER_CHANGED:"desktop-mode.wallpapers.server-changed",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_FOCUS_ON_DRAG_HOVER:"desktop-mode.window.focus-on-drag-hover",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",WINDOW_CONTENT_CHANGED:"desktop-mode.window-links.content-changed",WINDOW_LINK_GROUPS_CHANGED:"desktop-mode.window-links.groups-changed",WINDOW_LINKS_CONTENT:"desktop-mode.window-links.content",WINDOW_LINK_GROUPS:"desktop-mode.window-links.groups",WINDOW_LINK_EDGES:"desktop-mode.window-links.edges",RELATED_ENTITIES_ITEMS:"desktop-mode.related-entities.items",WINDOW_LINK_RENDERERS:"desktop-mode.window-links.renderers",WINDOW_LINK_RENDERER:"desktop-mode.window-links.renderer",EDITOR_PREVIEW_WINDOW_CONFIG:"desktop-mode.editor-preview.window-config",EDITOR_PREVIEW_LIVE:"desktop-mode.editor-preview.live",EDITOR_PREVIEW_OPENED:"desktop-mode.editor-preview.opened",EDITOR_PREVIEW_CLOSED:"desktop-mode.editor-preview.closed",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",AUTH_LOST:"desktop-mode.auth.lost",AUTH_RESTORED:"desktop-mode.auth.restored"},T="wpd-confirm-dialog";let p=null;function E(){return typeof window.customElements<"u"&&!!window.customElements.get(T)}function W(d){return new Promise((e,t)=>{const s=document.querySelector('script[data-desktop-mode-shell-overlays="1"]'),i=()=>{if(E()){e();return}t(new Error("[desktop-mode] shell-overlays bundle loaded but did not register the overlay components."))};if(s){E()?i():(s.addEventListener("load",i),s.addEventListener("error",()=>t(new Error("failed to load shell-overlays bundle"))));return}const o=document.createElement("script");o.src=d,o.async=!0,o.dataset.desktopModeShellOverlays="1",o.addEventListener("load",i),o.addEventListener("error",()=>t(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(o)})}function M(d){return E()||!d?Promise.resolve():(p||(p=W(d)),p)}function P(){return window.desktopModeConfig?.shellOverlaysBundleUrl??""}async function $(d){return await M(P()),new Promise(e=>{const t=document.createElement("wpd-confirm-dialog");t.setAttribute("open",""),d.title&&t.setAttribute("title",d.title),t.setAttribute("message",d.message),d.confirmLabel&&t.setAttribute("confirm-label",d.confirmLabel),d.cancelLabel&&t.setAttribute("cancel-label",d.cancelLabel),d.danger&&t.setAttribute("danger",""),d.hideCancel&&t.setAttribute("hide-cancel",""),d.dismissable&&t.setAttribute("dismissable","");const s=o=>{t.remove(),e(o)};t.addEventListener("wpd-confirm",()=>s(!0)),t.addEventListener("wpd-cancel",()=>s(!1)),document.body.appendChild(t),(t.shadowRoot?.querySelector(".dialog")??t).focus?.()})}const I="X-WP-Nonce";function U(d,e){const t=H();if(!t)return e;const s=F(d);if(!s||!G(s))return e;const i=e?.headers??(typeof Request<"u"&&d instanceof Request?d.headers:void 0),o=new Headers(i??{});return o.has(I)?e:(o.set(I,t),{...e??{},headers:o})}function H(){if(typeof window>"u")return;const e=window.desktopModeConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function F(d){try{const e=typeof window<"u"&&window.location?window.location.href:void 0;return typeof d=="string"?new URL(d,e):d instanceof URL?d:typeof Request<"u"&&d instanceof Request?new URL(d.url,e):null}catch{return null}}function G(d){return typeof window>"u"||!window.location||d.origin!==window.location.origin?!1:!!(d.pathname.includes("/wp-json/")||d.searchParams.has("rest_route"))}function D(d,e,t={}){const s=window.wp?.desktop?.fetch;if(typeof s=="function")return s(d,e,t);const i=U(d,e);return fetch(d,i)}function x(d){const e=document.createElement("textarea");return e.innerHTML=d,e.value}const A="__desktopModeSharedStores";function B(){const d=window;let e=d[A];return e||(e=new Map,d[A]=e),e}function q(d,e){const t=B();let s=t.get(d);s||(s={state:e(),listeners:new Set,rebuild:e},t.set(d,s));const i={get state(){return s.state},set state(o){s.state=o},getState(){return s.state},notify(){for(const o of Array.from(s.listeners))try{o(s.state)}catch(n){console.error(`[desktop-mode/shared-store:${d}] subscriber threw:`,n)}},subscribe(o){return s.listeners.add(o),()=>{s.listeners.delete(o)}},setState(o){const n=s.state;if(typeof n!="object"||n===null){console.warn(`[desktop-mode/shared-store:${d}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(n,o),i.notify()},reset(){const o=s.rebuild(),n=s.state;if(typeof n=="object"&&n!==null&&typeof o=="object"&&o!==null){const r=n;for(const a of Object.keys(r))delete r[a];Object.assign(r,o)}else s.state=o;s.listeners.clear()}};return i}const R=q("desktop-mode/commands-registry",()=>({registry:new Map,listeners:new Set})),k=R.state.registry,L=R.state.listeners;function f(){return Array.from(k.values())}function u(){return Array.from(k.values()).filter(d=>d.eager===!0)}function g(d){return k.get(d.toLowerCase())??null}function y(d){const e=d.trim().toLowerCase();return e===""?f():f().filter(t=>t.slug.toLowerCase().startsWith(e)||t.label.toLowerCase().includes(e))}function K(d){return L.add(d),()=>{L.delete(d)}}function m(d){if(!d.startsWith("/"))return{isCommand:!1,slug:"",args:"",hasArgsPart:!1};const e=d.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 V(d){return d.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function w(d){return d.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,t,s)=>/^https?:\/\//i.test(s.trim())?`<a href="${s.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 j(d){if(!d)return"";const e=V(d),t=[];let s=[],i=null;const o=()=>{s.length>0&&(t.push(`<p>${s.join("<br>")}</p>`),s=[])},n=()=>{i&&(t.push(`<${i.tag}>${i.items.join("")}</${i.tag}>`),i=null)};for(const r of e.split(/\n/)){const a=r.trim();if(a===""){o(),n();continue}const l=/^(#{1,6})\s+(.*)$/.exec(a);if(l){o(),n();const _=Math.min(6,l[1].length+2);t.push(`<h${_}>${w(l[2])}</h${_}>`);continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(a)){o(),n(),t.push("<hr>");continue}const c=/^[-*]\s+(.*)$/.exec(a),v=/^\d+\.\s+(.*)$/.exec(a);if(c||v){o();const _=c?"ul":"ol";(!i||i.tag!==_)&&(n(),i={tag:_,items:[]}),i.items.push(`<li>${w((c??v)[1])}</li>`);continue}n(),s.push(w(a))}return o(),n(),t.join("")}const S=`<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>`,Z=`<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>`,z=`<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 <polyline points="14,4 14,10 3,10"/>
8 <polyline points="6,7 3,10 6,13"/>
9 </svg>`,Y=`<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">
10 <circle cx="10" cy="10" r="7" stroke-opacity="0.25"/>
11 <path d="M10 3 A7 7 0 0 1 17 10" stroke-opacity="1"/>
12 </svg>`,C=`<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>`,X=`<svg viewBox="0 0 20 20" width="15" height="15" aria-hidden="true" focusable="false" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
15 <circle cx="9" cy="9" r="6"/>
16 <line x1="13.5" y1="13.5" x2="18" y2="18"/>
17 </svg>`,J=`<svg viewBox="0 0 24 24" width="18" height="18" fill="currentColor" aria-hidden="true" focusable="false">
18 <path d="M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8Zm0 1.5c3.4 0 6.2 2.7 6.5 6l-1.2-.6-.8-.4c-.1 0-.2 0-.3-.1H16c-.1-.2-.4-.2-.7 0l-2.9 2.1L9 11.3h-.7L5.5 13v-1.1c0-3.6 2.9-6.5 6.5-6.5Zm0 13c-2.7 0-5-1.7-6-4l2.8-1.7 3.5 1.2h.4s.2 0 .4-.2l2.9-2.1.4.2c.6.3 1.4.7 2.1 1.1-.5 3.1-3.2 5.4-6.4 5.4Z"/>
19 </svg>`,Q=["Find my post about…","Where can I see categories?","Do I have any spam comments?","Take me to plugin settings"];class ee{constructor(e){this._isOpen=!1,this._isSearching=!1,this._previousFocus=null,this._currentStream=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("[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._adminUrl=e.adminUrl,this._getTransport=e.getTransport??(()=>"off"),this._isAiAvailable=e.isAiAvailable??(()=>!1),this._isOverrideEnabled=e.isOverrideEnabled??(()=>!1),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(),K(()=>{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._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}_aiModeAllowed(){return this._isAiAvailable()&&this._isOverrideEnabled()}_defaultMode(){return this._aiModeAllowed()?"ai":"commands"}_setMode(e){const t=e==="ai"&&!this._aiModeAllowed()?"commands":e;t!==this._mode&&(this._modeInput[this._mode]=this._input.value,this._mode=t,this._input.value=this._modeInput[t],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(){const e=this._aiModeAllowed(),t=this._el.querySelector(".desktop-mode-ai__modes");t&&(t.hidden=!e,t.querySelectorAll("[data-mode]").forEach(i=>{const o=i.dataset.mode===this._mode;i.classList.toggle("is-active",o),i.setAttribute("aria-pressed",String(o))})),this._input.placeholder=this._mode==="ai"?"How can I help?":"Search commands…";const s=this._el.querySelector(".desktop-mode-ai__input-icon");s&&(s.innerHTML=this._mode==="ai"?S:X)}_isPickMode(e){return e.isCommand&&e.hasArgsPart?!1:e.isCommand||this._mode==="commands"?!0:this._input.value===""&&u().length>0}_commandMatches(){const e=m(this._input.value);if(e.isCommand)return this._sortCommands(y(e.slug).filter(i=>i.eager!==!0));if(this._mode==="ai")return this._sortCommands(u());const t=this._input.value.trim();return[...this._sortCommands(t===""?f():y(t)),...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(m(this._input.value).isCommand||this._mode==="commands"){this._renderCommandMode();return}const t=u().length>0;if(this._input.value.trim()===""){t?this._renderCommandMode():this._renderSuggestions();return}this._resultsEl.querySelector(".desktop-mode-ai__bubble")||(t?this._renderCommandMode():this._resultsEl.querySelector(".desktop-mode-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 t=e.target;(!(t instanceof Element)||!t.closest(".desktop-mode-ai__panel"))&&this.close()}),this._el.addEventListener("keydown",e=>{if(e.key!=="Tab")return;const t=[this._closeBtn,this._input,this._submitBtn].filter(n=>!n.disabled),s=t[0],i=t[t.length-1],o=this._el.ownerDocument.activeElement;e.shiftKey&&o===s?(e.preventDefault(),i.focus()):!e.shiftKey&&o===i&&(e.preventDefault(),s.focus())}),document.addEventListener("desktop-mode-open-ai",()=>this.open()),this._closeBtn.addEventListener("click",()=>this.close()),this._el.querySelectorAll(".desktop-mode-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 t=m(this._input.value);if(this._isPickMode(t)){const s=this._commandMatches();if(e.key==="ArrowDown"){e.preventDefault(),this._selectedCommand=Math.min(this._selectedCommand+1,Math.max(0,s.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"&&s.length>0&&t.isCommand){e.preventDefault();const i=s[this._selectedCommand]??s[0];this._input.value=`/${i.slug} `,this._submitBtn.classList.add("has-value"),this._selectedSuggestion=0,this._renderCommandMode();return}if(e.key==="Enter"&&!e.shiftKey){if(e.preventDefault(),s.length===0){t.isCommand&&this._showError(`Unknown command: /${t.slug}`);return}const i=s[this._selectedCommand]??s[0];this._pickCommand(i);return}}if(t.isCommand&&t.hasArgsPart){const s=g(t.slug);if(!!s&&typeof s.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 o=this._currentSuggestions[this._selectedSuggestion];o&&(this._input.value=`/${t.slug} ${o.value}`);return}if(e.key==="Enter"&&!e.shiftKey&&s){e.preventDefault();const o=this._currentSuggestions[this._selectedSuggestion],n=o?o.value:t.args;this._runCommand(s,n);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 t=m(this._input.value),s=this._input.value.trim();!t.isCommand&&this._mode==="commands"&&s.length>0?this._fetchRemoteCommands(s):(this._currentRemoteCommands=[],this._remoteSearchToken++),this._renderForMode()}),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(){if(this._isSearching)return;const e=m(this._input.value);if(this._isPickMode(e)){const s=this._commandMatches(),i=s[this._selectedCommand]??s[0];i&&this._pickCommand(i);return}const t=this._input.value.trim();if(t){if(e.isCommand){const s=g(e.slug);if(!s){this._showError(`Unknown command: /${e.slug}`);return}await this._runCommand(s,e.args);return}await this._runSearch(t,null,0)}}async _runCommand(e,t){if(this._isSearching)return;const s=b(h.COMMAND_BEFORE_RUN,{proceed:!0,slug:e.slug,args:t,command:e});if(s&&s.proceed===!1){this._showError(s.reason??`Command /${e.slug} was cancelled.`);return}this._isSearching=!0,this._submitBtn.disabled=!0,this._input.disabled=!0,this._showThinking(`Running /${e.slug}`);const i={close:()=>{this._previousFocus=null,this.close()},openInWindow:(o,n,r)=>this._openInLegacyWindow(o,n,r),confirm:(o,n)=>this._confirm(o,n)};try{const o=await Promise.resolve(e.run(t,i));this._renderCommandResult(e,o),N(h.COMMAND_AFTER_RUN,{slug:e.slug,args:t,command:e,result:o})}catch(o){const n=o instanceof Error?o.message:String(o);this._showError(`Command /${e.slug} failed: ${n}`),N(h.COMMAND_ERROR,{slug:e.slug,args:t,command:e,error:o})}finally{this._isSearching=!1,this._submitBtn.disabled=!1,this._input.disabled=!1,this._input.focus()}}_confirm(e,t){return $({title:t?e:void 0,message:t??e})}_renderCommandResult(e,t){if(t==null){this._isOpen?this._renderForMode():(this._resultsEl.innerHTML="",this._resultsEl.hidden=!0);return}const s=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("",s)}_runSearch(e,t,s){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,s):this._runSearchFetch(e,t,s)}_runSearchStream(e,t,s){const i=new URL(this._aiSearchStreamUrl,window.location.origin);i.searchParams.set("nonce",this._restNonce),i.searchParams.set("query",e),t&&(i.searchParams.set("resume_tool",t),i.searchParams.set("start_offset",String(s))),this._closeStream();const o=new EventSource(i.toString());this._currentStream=o;const n=()=>{o.close(),this._currentStream=null,this._isSearching=!1,this._submitBtn.disabled=!1,this._input.disabled=!1,this._input.focus()};o.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}},o.onerror=()=>{this._currentStream===o&&(this._showError("Lost connection to the assistant. Please try again."),n())}}async _runSearchFetch(e,t,s){try{const i={query:e};t&&(i.resume_tool=t,i.start_offset=s);const o=await D(this._aiSearchUrl,{method:"POST",headers:{"Content-Type":"application/json","X-WP-Nonce":this._restNonce},body:JSON.stringify(i)},{source:"desktop-mode/ai-search"});if(!o.ok){const n=await o.json().catch(()=>({}));this._showError(n.message??`Server returned ${o.status}`,n.code);return}this._showResult(e,await o.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)}async _fetchRemoteCommands(e){const t=++this._remoteSearchToken;try{if(await new Promise(o=>setTimeout(o,200)),t!==this._remoteSearchToken)return;const s=await D(`/wp-json/wp/v2/search?search=${encodeURIComponent(e)}&subtype=post,page`,{headers:{"X-WP-Nonce":this._restNonce}},{silent:!0});if(!s.ok)return;const i=await s.json().catch(()=>[]);if(t!==this._remoteSearchToken)return;this._currentRemoteCommands=i.map(o=>{const n=o.subtype==="page",r=new URL("post.php",this._adminUrl);r.searchParams.set("post",String(o.id)),r.searchParams.set("action","edit");const a=r.toString(),l=x(o.title||"(No title)"),c=n?"dashicons-admin-page":"dashicons-admin-post";return{slug:`post-${o.id}`,label:l,description:n?"Page":"Post",icon:c,eager:!1,run:(v,_)=>{_.openInWindow(a,l,c)}}}),this._isOpen&&this._renderForMode()}catch{}}_getDesktopShell(){return window.wp?.desktop??null}_openAssistantSettings(){const e=this._getDesktopShell();this._previousFocus=null,this.close(),e?.openOsSettings?.({tabId:"features"})}_openInLegacyWindow(e,t,s){const i=this._getDesktopShell();if(!i||!i.windowManager){window.open(e,"_blank","noopener");return}const o=i.deriveWindowId?i.deriveWindowId(e,this._adminUrl):"desktop-mode-ai-"+e.replace(/[^a-z0-9]+/gi,"-").slice(0,80);i.windowManager.open({id:o,url:e,title:t,icon:s??"dashicons-admin-generic"}),this.close()}_renderCommandMode(){this._resultsEl.hidden=!1;const e=m(this._input.value);if(e.hasArgsPart){const n=g(e.slug);if(n){this._renderArgsMode(n,e.args);return}}const t=this._commandMatches();if(t.length===0){const n=e.isCommand?`/${e.slug}`:this._input.value.trim();this._resultsEl.innerHTML=`
20 <div class="desktop-mode-ai__state desktop-mode-ai__state--empty">
21 <span>No commands matching <strong>${this._esc(n)}</strong>.</span>
22 </div>
23 `;return}this._selectedCommand>=t.length&&(this._selectedCommand=0);const s=this._isPickMode(e),i=t.map((n,r)=>{const a=s&&r===this._selectedCommand?" is-selected":"",l=this._isEntityResultCommand(n);return`
24 <button
25 type="button"
26 class="desktop-mode-ai__cmd-item${a}${l?" is-entity-result":""}"
27 data-slug="${this._esc(n.slug)}"
28 data-index="${r}"
29 >
30 ${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>`}
31 <span class="desktop-mode-ai__cmd-body">
32 <span class="desktop-mode-ai__cmd-title">
33 ${this._esc(n.label)}
34 ${n.hint?`<span class="desktop-mode-ai__cmd-hint">${this._esc(n.hint)}</span>`:""}
35 </span>
36 ${n.description?`<span class="desktop-mode-ai__cmd-desc">${this._esc(n.description)}</span>`:""}
37 </span>
38 </button>
39 `}).join(""),o=this._mode==="ai"&&u().length>0?'<p class="desktop-mode-ai__suggestions-label">Suggested commands</p>':"";this._resultsEl.innerHTML=`
40 <div class="desktop-mode-ai__cmd-list">
41 ${o}
42 ${i}
43 </div>
44 `,this._resultsEl.querySelectorAll(".desktop-mode-ai__cmd-item").forEach(n=>{n.addEventListener("click",()=>{const r=parseInt(n.dataset.index??"",10);if(!Number.isNaN(r)){const l=this._commandMatches()[r];l&&this._pickCommand(l)}}),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 s=++this._suggestToken,i={close:()=>this.close(),openInWindow:(r,a,l)=>this._openInLegacyWindow(r,a,l),confirm:(r,a)=>this._confirm(r,a)};let o;try{o=e.suggest(t,i)}catch{o=[]}const n=r=>{s===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),c=r[l];c&&(this._input.value=`/${e.slug} ${c.value}`,this._runCommand(e,c.value))}),a.addEventListener("mouseenter",()=>{const l=parseInt(a.dataset.index??"0",10);Number.isNaN(l)||(this._selectedSuggestion=l,this._paintSuggestionSelection())})}))};o&&typeof o.then=="function"?(this._resultsEl.innerHTML=this._renderCommandHeader(e,!1),o.then(r=>n(Array.isArray(r)?r:[])).catch(()=>n([]))):n(Array.isArray(o)?o:[])}_renderCommandHeader(e,t){return`
45 <div class="desktop-mode-ai__cmd-active">
46 <span class="desktop-mode-ai__cmd-icon dashicons ${this._esc(e.icon??"dashicons-arrow-right-alt")}" aria-hidden="true"></span>
47 <div class="desktop-mode-ai__cmd-body">
48 <span class="desktop-mode-ai__cmd-title">
49 /${this._esc(e.slug)}
50 ${e.hint?`<span class="desktop-mode-ai__cmd-hint">${this._esc(e.hint)}</span>`:""}
51 </span>
52 ${e.description?`<span class="desktop-mode-ai__cmd-desc">${this._esc(e.description)}</span>`:""}
53 ${t?'<span class="desktop-mode-ai__cmd-enter-hint">Press <kbd>↵</kbd> to run</span>':""}
54 </div>
55 </div>
56 `}_renderSuggestionList(e){return e.length===0?`
57 <div class="desktop-mode-ai__state desktop-mode-ai__state--empty">
58 <span>No suggestionspress <kbd></kbd> to run with the text you typed.</span>
59 </div>
60 `:`<div class="desktop-mode-ai__cmd-suggest-list">${e.map((s,i)=>`
61 <button
62 type="button"
63 class="desktop-mode-ai__cmd-suggest-item${i===this._selectedSuggestion?" is-selected":""}"
64 data-index="${i}"
65 >
66 <span class="desktop-mode-ai__cmd-icon dashicons ${this._esc(s.icon??"dashicons-arrow-right-alt")}" aria-hidden="true"></span>
67 <span class="desktop-mode-ai__cmd-body">
68 <span class="desktop-mode-ai__cmd-suggest-label">${this._esc(s.label)}</span>
69 ${s.description?`<span class="desktop-mode-ai__cmd-desc">${this._esc(s.description)}</span>`:""}
70 </span>
71 </button>
72 `).join("")}</div>`}_sortCommands(e){return e.slice().sort((t,s)=>{const i=typeof t.owner=="string"&&t.owner.startsWith("iframe:")?0:1,o=typeof s.owner=="string"&&s.owner.startsWith("iframe:")?0:1;return i-o})}_isEntityResultCommand(e){return this._currentRemoteCommands.includes(e)}_paintCommandSelection(){const e=this._resultsEl.querySelectorAll(".desktop-mode-ai__cmd-item");e.forEach((i,o)=>{i.classList.toggle("is-selected",o===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 s=e[this._selectedCommand];s&&typeof s.scrollIntoView=="function"&&s.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=`
73 <div class="desktop-mode-ai__suggestions">
74 <p class="desktop-mode-ai__suggestions-label">${this._esc("Try asking")}</p>
75 <div class="desktop-mode-ai__suggestions-list">
76 ${Q.map(e=>`<button type="button" class="desktop-mode-ai__suggestion" data-prompt="${this._esc(e)}">
77 ${this._esc(e)}
78 </button>`).join("")}
79 </div>
80 </div>
81 `,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=`
82 <div class="desktop-mode-ai__state desktop-mode-ai__state--thinking">
83 ${Y}
84 <span>${this._esc(e)}</span>
85 </div>
86 `}_showError(e,t){if(this._resultsEl.hidden=!1,t==="desktop_mode_ai_disabled"){const s=this._esc(e),i=r=>`<button type="button" class="desktop-mode-ai__settings-link">${r}</button>`,o=/OS Settings.*?Features/,n=o.test(s)?s.replace(o,r=>i(r)):`${s} ${i("Features")}`;this._resultsEl.innerHTML=`
87 <div class="desktop-mode-ai__state desktop-mode-ai__state--error">
88 <span>${n}</span>
89 </div>
90 `,this._resultsEl.querySelector(".desktop-mode-ai__settings-link")?.addEventListener("click",()=>this._openAssistantSettings());return}this._resultsEl.innerHTML=`
91 <div class="desktop-mode-ai__state desktop-mode-ai__state--error">
92 <span>${this._esc(e)}</span>
93 </div>
94 `}_showResult(e,t){e!==""&&(this._lastAiResult={query:e,data:t}),this._resultsEl.hidden=!1;const s=`
95 <div class="desktop-mode-ai__bubble">
96 <span class="desktop-mode-ai__bubble-icon">${S}</span>
97 <div class="desktop-mode-ai__bubble-text">${j(t.message||"")}</div>
98 </div>
99 `;let i="";t.answer_type==="entity"&&t.entity?i=this._renderEntityCard(t.entity):t.answer_type==="navigation"&&t.admin_links&&t.admin_links.length>0&&(i=this._renderAdminLinks(t.admin_links)),t.continue&&(i+=`
100 <button type="button" class="desktop-mode-ai__continue-btn"
101 data-tool="${this._esc(t.continue.tool)}"
102 data-offset="${t.continue.offset}"
103 data-query="${this._esc(e)}">
104 ${this._esc(t.continue.label)}
105 </button>
106 `),this._resultsEl.innerHTML=s+i,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 o=this._resultsEl.querySelector(".desktop-mode-ai__continue-btn");o&&o.addEventListener("click",()=>{const n=o.dataset.tool??null,r=parseInt(o.dataset.offset??"0",10),a=o.dataset.query??e;this._runSearch(a,n,r)})}_renderEntityCard(e){const t=e.type==="comment",s=t?`Comment on${this._esc(e.post_title??"post")}`:this._esc(e.title??"Untitled"),i=this._esc(e.ai_summary||e.excerpt||""),o=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",`
107 <div class="desktop-mode-ai__entity">
108 <div class="desktop-mode-ai__entity-header">
109 ${n}
110 <span class="desktop-mode-ai__entity-type">${this._esc(o)}</span>
111 </div>
112 <h3 class="desktop-mode-ai__entity-title">${s}</h3>
113 <p class="desktop-mode-ai__entity-summary">${i}</p>
114 <button type="button"
115 class="desktop-mode-ai__entity-open"
116 data-url="${this._esc(e.edit_url)}"
117 data-title="${this._esc(e.title??e.post_title??o)}"
118 data-icon="${r}">
119 <span>${this._esc(`Open ${o.toLowerCase()} in desktop`)}</span>
120 ${C}
121 </button>
122 </div>
123 `}_renderAdminLinks(e){return`<div class="desktop-mode-ai__admin-links">${e.map(s=>`
124 <button type="button"
125 class="desktop-mode-ai__admin-link"
126 data-url="${this._esc(s.url)}"
127 data-title="${this._esc(s.title)}"
128 data-icon="${this._esc(s.icon)}">
129 <span class="desktop-mode-ai__admin-link-icon dashicons ${this._esc(s.icon)}" aria-hidden="true"></span>
130 <span class="desktop-mode-ai__admin-link-body">
131 <span class="desktop-mode-ai__admin-link-title">${this._esc(s.title)}</span>
132 <span class="desktop-mode-ai__admin-link-desc">${this._esc(s.description)}</span>
133 </span>
134 <span class="desktop-mode-ai__admin-link-arrow">${C}</span>
135 </button>
136 `).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","Site Assistant"),e.setAttribute("aria-hidden","true"),e.setAttribute("hidden",""),e.innerHTML=`
137 <div class="desktop-mode-ai__backdrop" aria-hidden="true"></div>
138 <div class="desktop-mode-ai__panel">
139 <div class="desktop-mode-ai__header">
140 <span class="desktop-mode-ai__header-icon">${J}</span>
141 <span class="desktop-mode-ai__header-label">Site Assistant</span>
142 <div class="desktop-mode-ai__modes" role="group" aria-label="Assistant mode" hidden>
143 <button type="button" class="desktop-mode-ai__mode" data-mode="ai" aria-pressed="false">Ask AI</button>
144 <button type="button" class="desktop-mode-ai__mode" data-mode="commands" aria-pressed="false">Commands</button>
145 </div>
146 <button type="button" class="desktop-mode-ai__close" aria-label="Close">
147 ${Z}
148 </button>
149 </div>
150 <div class="desktop-mode-ai__input-wrap">
151 <span class="desktop-mode-ai__input-icon">${S}</span>
152 <input
153 class="desktop-mode-ai__input"
154 type="text"
155 placeholder="How can I help?"
156 autocomplete="off"
157 spellcheck="false"
158 aria-label="Ask the assistant"
159 />
160 <button type="button" class="desktop-mode-ai__submit" aria-label="Send">
161 ${z}
162 </button>
163 </div>
164 <div class="desktop-mode-ai__results" hidden></div>
165 <div class="desktop-mode-ai__footer">
166 <span class="desktop-mode-ai__footer-hint">
167 Your assistant to quickly navigate and manage your entire site.
168 </span>
169 </div>
170 </div>
171 `,e}}const te=d=>new ee(d);window.desktopModeCreateAiAssistant=te})();
172