|
1
|
|
-(function(){"use strict";function se(){const s=window.wp?.hooks;if(!s)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 s}function Pe(s,e,t,n){se().addAction(s,e,t,n)}function He(s,e){return se().removeAction(s,e)}function T(s,e,...t){return se().applyFilters(s,e,...t)}function h(s,...e){se().doAction(s,...e)}const u={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"},At="desktop-mode.activity.";function _e(s){return`${At}${String(s)}`}let It=0;const be={publish(s,e){h(_e(s),e)},subscribe(s,e){const t=`desktop-mode/activity-sub/${++It}`,n=_e(s);Pe(n,t,i=>e(i));let o=!1;return()=>{o||(o=!0,He(n,t))}},filter(s,e,...t){return T(_e(s),e,...t)}},ge=new Map,ye=new Map;function ne(s,e,t,n){let o=s.get(e);if(!o){if(!n)return;o=new Map,s.set(e,o)}let i=o.get(t);if(!i){if(!n)return;i=new Set,o.set(t,i)}return i}function ze(s,e,t,n){const o={channel:t,windowId:e},i=ne(s,e,t,!1);if(i)for(const l of Array.from(i))try{l(n,o)}catch(d){typeof console<"u"&&console.error(`[desktop-mode] window-channel subscriber for "${t}" threw:`,d)}const r=ne(s,e,"*",!1);if(r)for(const l of Array.from(r))try{l(n,o)}catch(d){typeof console<"u"&&console.error(`[desktop-mode] window-channel wildcard subscriber for "${e}" threw:`,d)}}function xt(s,e,t){const n=ne(ge,s,e,!0);n.add(t);let o=!1;return()=>{o||(o=!0,n.delete(t))}}function Fe(s,e,t){ze(ge,s,e,t)}function Lt(s,e,t){const n=ne(ye,s,e,!0);n.add(t);let o=!1;return()=>{o||(o=!0,n.delete(t))}}function Tt(s,e,t){ze(ye,s,e,t)}const oe=new Set,ie=new Set,G=new Map;function Ue(s){return oe.has(s)}function re(s){ie.has(s)||(ie.add(s),h(u.WINDOW_CONTENT_LOADING,{windowId:s}),typeof document<"u"&&document.dispatchEvent(new CustomEvent("desktop-mode-window-content-loading",{detail:{windowId:s}})))}function R(s){if(!oe.has(s)){oe.add(s);const e=G.get(s);if(e){G.delete(s);for(const t of e)try{t.flush()}catch(n){typeof console<"u"&&console.error(`[desktop-mode] flushing queued window-send for "${t.channel}" threw:`,n)}}}ie.delete(s)&&(h(u.WINDOW_CONTENT_LOADED,{windowId:s}),typeof document<"u"&&document.dispatchEvent(new CustomEvent("desktop-mode-window-content-loaded",{detail:{windowId:s}})))}function Dt(s,e,t,n){let o=G.get(s);o||(o=[],G.set(s,o)),o.push({channel:e,payload:t,flush:n})}function Ot(s){ge.delete(s),ye.delete(s),oe.delete(s),ie.delete(s),G.delete(s)}const Nt=new Map;function Rt(s){return Nt.get(s)??null}const Wt="desktop-mode";function Be(){return window.wp?.i18n}function C(s,e=Wt){return Be()?.__(s,e)??s}function ke(s,...e){const t=Be()?.sprintf;if(t)return t(s,...e);let n=0;return s.replace(/%[sd]/g,()=>String(e[n++]??""))}let Mt=0;function $t(s){const e=++Mt,t=a=>`desktop-mode/native-render-ctx/${s}/${e}/${a}`,n=new AbortController,o=[],i=(a,c,p,f)=>{const m=t(c);Pe(a,m,E=>{p(E)&&f(E)});const _=()=>{He(a,m)};return o.push(_),_},r=a=>!!a&&typeof a=="object"&&a.windowId===s;return{ctx:{window:{send(a,c){typeof a!="string"||a===""||Fe(s,a,c)},on(a,c){return typeof a!="string"||a===""||typeof c!="function"?()=>{}:Lt(s,a,c)},markLoading(){re(s)},markReady(){R(s)}},markLoading(){re(s)},markReady(){R(s)},signal:n.signal,onResize(a){return typeof a!="function"?()=>{}:i(u.WINDOW_BODY_RESIZED,"on-resize",r,c=>{const{width:p,height:f}=c;try{a(p,f)}catch(m){h(u.SHELL_ERROR,{scope:"native-render-ctx/onResize",id:s,error:m})}})},onHide(a){return typeof a!="function"?()=>{}:i(u.WINDOW_MINIMIZED,"on-hide",r,()=>{try{a()}catch(c){h(u.SHELL_ERROR,{scope:"native-render-ctx/onHide",id:s,error:c})}})},onShow(a){return typeof a!="function"?()=>{}:i(u.WINDOW_RESTORED,"on-show",r,()=>{try{a()}catch(c){h(u.SHELL_ERROR,{scope:"native-render-ctx/onShow",id:s,error:c})}})}},dispose:()=>{try{n.abort()}catch{}for(;o.length;){const a=o.pop();try{a?.()}catch{}}}}}function Pt(s){return s.replace(/[^a-zA-Z0-9_-]/g,"")}function W(s){try{const e=new URL(s,window.location.origin);return e.searchParams.delete("desktop_mode_chromeless"),e.searchParams.delete("desktop_mode_portal"),e.pathname.replace(/\/+$/,"")+"?"+e.searchParams.toString()}catch{return s}}const Ht=Symbol.for("desktop-mode/window-config");function zt(s,e){s[Ht]=e}const qe=window.location.origin;function Ge(s){const e=new URL(s,qe);return e.origin!==qe?null:(e.searchParams.set("desktop_mode_chromeless","1"),e.toString())}function V(){const s=document.querySelectorAll(".desktop-mode-window--fullscreen").length>0;document.body.classList.toggle("desktop-mode-has-fullscreen-window",s)}function Ft(){const s=document.createElement("div");s.className="desktop-mode-window__loading",s.setAttribute("aria-hidden","true");const e=document.createElement("wpd-spinner");return e.setAttribute("preset","classic"),e.setAttribute("size","clamp(96px, 14vw, 192px)"),e.setAttribute("label",C("Loading window content")),s.appendChild(e),s}function Ut(s){let e=Ft();const t={windowId:s.id,config:s};if(typeof s.loading?.render=="function")try{s.loading.render(e,t)}catch(n){typeof console<"u"&&console.error(`[desktop-mode] loading.render threw for "${s.id}":`,n)}try{const n=T(u.WINDOW_LOADING_OVERLAY,e,t);n instanceof HTMLElement&&(e=n)}catch(n){typeof console<"u"&&console.error(`[desktop-mode] WINDOW_LOADING_OVERLAY filter threw for "${s.id}":`,n)}return e&&!e.classList.contains("desktop-mode-window__loading")&&e.classList.add("desktop-mode-window__loading"),e}function M(s){const e=document.createElement("span");return e.className=`desktop-mode-window__slot desktop-mode-window__slot--${s}`,e.dataset.slot=s,e}function Bt(s){const e=document.createElement("div");e.className="desktop-mode-window",s.native&&e.classList.add("desktop-mode-window--native"),e.id=`wp-window-${s.id}`,e.setAttribute("role","dialog"),e.setAttribute("aria-labelledby",`wp-window-title-${s.id}`),e.style.left=`${s.x}px`,e.style.top=`${s.y}px`,e.style.width=`${s.width}px`,e.style.height=`${s.height}px`;const t=document.createElement("div");t.className="desktop-mode-window__titlebar";const n=document.createElement("wpd-window-button");n.setAttribute("icon","menu"),n.setAttribute("aria-label",C("Window actions")),n.setAttribute("aria-haspopup","menu"),n.setAttribute("aria-expanded","false"),n.classList.add("desktop-mode-window__btn"),n.classList.add("desktop-mode-window__menu-btn");const o=document.createElement("wpd-menu");o.classList.add("desktop-mode-window__menu-panel"),o.hidden=!0;const i=document.createElement("wpd-menu-item");if(i.setAttribute("role","menuitemcheckbox"),i.setAttribute("value","startup"),i.classList.add("desktop-mode-window__menu-item"),i.classList.add("desktop-mode-window__menu-item--startup"),i.textContent=C("Open on startup"),o.appendChild(i),s.multi){const w=document.createElement("wpd-menu-item");w.setAttribute("role","menuitem"),w.setAttribute("value","open-another"),w.setAttribute("icon","dashicons-plus-alt2"),w.classList.add("desktop-mode-window__menu-item"),w.classList.add("desktop-mode-window__menu-item--open-another"),w.textContent=ke(C("Open another %s"),s.title),o.appendChild(w)}if(!s.native){const w=document.createElement("wpd-menu-item");w.setAttribute("role","menuitem"),w.setAttribute("value","open-in-new-window"),w.setAttribute("icon","dashicons-plus-alt"),w.classList.add("desktop-mode-window__menu-item"),w.classList.add("desktop-mode-window__menu-item--open-in-new-window"),w.textContent=C("Open in new window"),o.appendChild(w)}if(!s.native){const w=document.createElement("wpd-menu-item");w.setAttribute("role","menuitem"),w.setAttribute("value","reload"),w.setAttribute("icon","dashicons-update"),w.classList.add("desktop-mode-window__menu-item"),w.classList.add("desktop-mode-window__menu-item--reload"),w.textContent=C("Reload"),o.appendChild(w);const S=document.createElement("wpd-menu-item");S.setAttribute("role","menuitem"),S.setAttribute("value","open-external"),S.setAttribute("icon","dashicons-external"),S.classList.add("desktop-mode-window__menu-item"),S.classList.add("desktop-mode-window__menu-item--open-external"),S.textContent=C("Open in browser tab"),o.appendChild(S)}const r=M("icon"),l=document.createElement("span");l.className=`desktop-mode-window__icon dashicons ${Pt(s.icon)}`,l.setAttribute("aria-hidden","true"),r.appendChild(l);const d=M("title"),a=document.createElement("span");a.className="desktop-mode-window__title",a.id=`wp-window-title-${s.id}`,a.textContent=s.title,d.appendChild(a);const c=M("before-titlebar"),p=M("before-icon"),f=M("after-title"),m=M("before-controls"),_=M("after-controls"),E=M("after-titlebar"),g=document.createElement("div");g.className="desktop-mode-window__controls";const k=document.createElement("div");k.className="desktop-mode-window__screen-meta";const b=document.createElement("span");b.className="desktop-mode-window__custom-buttons desktop-mode-window__custom-buttons--left";const y=document.createElement("span");y.className="desktop-mode-window__custom-buttons desktop-mode-window__custom-buttons--right";const v=document.createElement("span");v.className="desktop-mode-window__activity";const I=document.createElement("wpd-save-status");I.setAttribute("mode","dot"),I.setAttribute("animation","modem"),I.setAttribute("phase","idle"),I.setAttribute("data-desktop-mode-activity-indicator",""),v.appendChild(I),t.appendChild(p),t.appendChild(r),t.appendChild(v),t.appendChild(d),t.appendChild(f),t.appendChild(b),t.appendChild(k),n&&o&&o.children.length>0&&(t.appendChild(n),t.appendChild(o)),t.appendChild(y),t.appendChild(m),t.appendChild(g),t.appendChild(_);for(const w of Array.from(t.children))w.setAttribute("data-desktop-mode-default-chrome","");const D=document.createElement("div");if(D.className="desktop-mode-window__body desktop-mode-window__body--loading",s.native)D.classList.add("desktop-mode-window__body--native");else{const w=document.createElement("iframe");w.className="desktop-mode-window__iframe",w.setAttribute("name",`desktop-mode-frame-${s.id}`);const S=s.url?Ge(s.url):null;w.src=S??"about:blank",D.appendChild(w);const we=()=>{R(s.id)};w.addEventListener("load",we)}D.appendChild(Ut(s)),re(s.id);const ee=[];for(const w of["ne","nw","se","sw"]){const S=document.createElement("div");S.className=`desktop-mode-window__resize-handle desktop-mode-window__resize-handle--${w}`,S.dataset.dir=w,S.setAttribute("aria-hidden","true"),ee.push(S)}if(e.appendChild(c),e.appendChild(t),e.appendChild(E),!s.native){const w=document.createElement("nav");if(w.className="desktop-mode-window__tabs",w.setAttribute("role","tablist"),w.setAttribute("aria-label",ke(C("%s sub-pages"),s.title)),s.submenu&&s.submenu.length>0&&s.url){const S=W(s.url),we=s.parentUrl??s.url,$n=W(we),Pn=s.submenu.some(te=>W(te.url)===$n)?[...s.submenu]:[{title:s.title,url:we},...s.submenu];for(const te of Pn){const N=document.createElement("button");N.className="desktop-mode-window__tab",N.dataset.kind="submenu",N.setAttribute("type","button"),N.setAttribute("role","tab"),N.dataset.url=te.url,N.textContent=te.title,W(te.url)===S?(N.classList.add("desktop-mode-window__tab--active"),N.setAttribute("aria-selected","true")):N.setAttribute("aria-selected","false"),w.appendChild(N)}}e.appendChild(w)}e.appendChild(D);for(const w of ee)e.appendChild(w);return zt(e,s),e}const qt="wpd-confirm-dialog";let ve=null;function ae(){return typeof window.customElements<"u"&&!!window.customElements.get(qt)}function Gt(s){return new Promise((e,t)=>{const n=document.querySelector('script[data-desktop-mode-shell-overlays="1"]'),o=()=>{if(ae()){e();return}t(new Error("[desktop-mode] shell-overlays bundle loaded but did not register the overlay components."))};if(n){ae()?o():(n.addEventListener("load",o),n.addEventListener("error",()=>t(new Error("failed to load shell-overlays bundle"))));return}const i=document.createElement("script");i.src=s,i.async=!0,i.dataset.desktopModeShellOverlays="1",i.addEventListener("load",o),i.addEventListener("error",()=>t(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(i)})}function Vt(s){return ae()||!s?Promise.resolve():(ve||(ve=Gt(s)),ve)}function Xt(){return window.desktopModeConfig?.shellOverlaysBundleUrl??""}function Kt(s,e){const t=Xt();if(ae()||!t){e();return}Vt(t).then(()=>{s()&&e()}).catch(n=>{typeof console<"u"&&console.warn("[desktop-mode] shell-overlays failed to load; menu/dialog suppressed:",n)})}const Yt=4e3,jt=200;function Ve(s){const e=be.filter("desktop-mode/toast-requested",{...s});if(!e||e.cancel===!0)return()=>{};let t=!1,n=null;return Kt(()=>!t,()=>{n=Zt(e)}),()=>{t=!0,n&&n()}}function Zt(s){const e=Qt(),t=document.createElement("wpd-toast");t.textContent=s.message,s.action&&(t.setAttribute("action",s.action.label),t.addEventListener("wpd-toast-action",()=>{s.action?.onClick(),i()})),e.appendChild(t);let n=!1,o=null;const i=()=>{n||(n=!0,o!==null&&(window.clearTimeout(o),o=null),t.setAttribute("state","out"),window.setTimeout(()=>{t.remove()},jt))};return requestAnimationFrame(()=>{t.setAttribute("state","in")}),o=window.setTimeout(i,s.duration??Yt),be.publish("desktop-mode/toast-shown",{...s}),i}function Qt(){const s=document.querySelector("wpd-toast-container");if(s)return s;const e=document.createElement("wpd-toast-container");return document.body.appendChild(e),e}const de=0,Xe=5,Jt=Xe*Xe,es=3e3;function ts(s,e){const t=s.element.querySelectorAll('.desktop-mode-window__tab[data-kind="submenu"]');if(!t.length)return;if(s._activeTabId!=="primary"){for(const o of t)o.classList.remove("desktop-mode-window__tab--active"),o.setAttribute("aria-selected","false");return}const n=W(e);for(const o of t){const i=o.dataset.url,r=!!i&&W(i)===n;o.classList.toggle("desktop-mode-window__tab--active",r),o.setAttribute("aria-selected",r?"true":"false")}}function Ke(s,e,t){if(!s.iframe)return;const n=s.element.querySelector(".desktop-mode-window__tabs"),o=s.element.querySelector(".desktop-mode-window__body");if(!n||!o)return;ss(s,n);const i=`ext-${++s._externalTabSeq}`,r=document.createElement("button");r.className="desktop-mode-window__tab desktop-mode-window__tab--external",r.dataset.kind="external",r.dataset.tabId=i,r.setAttribute("type","button"),r.setAttribute("role","tab"),r.setAttribute("aria-selected","false"),r.title=e;const l=document.createElement("span");l.className="desktop-mode-window__tab-label",l.textContent=t,r.appendChild(l);const d=document.createElement("wpd-tab-chip");d.setAttribute("variant","detach"),d.dataset.tabAction="detach",d.dataset.tabId=i,d.setAttribute("aria-label",C("Open in a new browser tab")),d.title=C("Open in a new browser tab"),r.appendChild(d);const a=document.createElement("wpd-tab-chip");a.setAttribute("variant","close"),a.dataset.tabAction="close",a.dataset.tabId=i,a.setAttribute("aria-label",C("Close tab")),a.title=C("Close tab"),r.appendChild(a),n.appendChild(r);const c=document.createElement("iframe");c.className="desktop-mode-window__iframe desktop-mode-window__iframe--external",c.dataset.tabId=i,c.style.display="none",c.src=e,o.appendChild(c);let p=!1;const f=()=>{p=!0};c.addEventListener("load",f,{once:!0});const m=window.setTimeout(()=>{p||(c.removeEventListener("load",f),os(s,i))},es),_=()=>{c.removeEventListener("load",f),window.clearTimeout(m)};s._externalTabs.set(i,{tabEl:r,iframe:c,url:e,label:t,cancelProbe:_}),X(s,i),r.scrollIntoView({behavior:"smooth",inline:"end",block:"nearest"}),s._emitChange("state")}function ss(s,e){if(e.querySelector('[data-kind="main"]')||e.querySelector('[data-kind="submenu"]'))return;const t=document.createElement("button");t.className="desktop-mode-window__tab desktop-mode-window__tab--main desktop-mode-window__tab--active",t.dataset.kind="main",t.setAttribute("type","button"),t.setAttribute("role","tab"),t.setAttribute("aria-selected","true"),t.textContent=s.config.title||"Main",e.prepend(t)}function X(s,e){if(s._activeTabId===e)return;s._activeTabId=e,s.iframe&&(s.iframe.style.display=e==="primary"?"":"none");for(const[n,o]of s._externalTabs)o.iframe.style.display=e===n?"":"none";s.element.querySelectorAll(".desktop-mode-window__tab").forEach(n=>{let o;n.dataset.kind==="main"?o=e==="primary":n.dataset.kind==="external"?o=n.dataset.tabId===e:o=e==="primary"&&n.classList.contains("desktop-mode-window__tab--active"),n.classList.toggle("desktop-mode-window__tab--active",o),n.setAttribute("aria-selected",o?"true":"false")})}function Ee(s,e){const t=s._externalTabs.get(e);t&&(t.cancelProbe(),t.tabEl.remove(),t.iframe.remove(),s._externalTabs.delete(e),s._activeTabId===e&&X(s,"primary"),s._externalTabs.size===0&&s.element.querySelector(".desktop-mode-window__tab--main")?.remove(),s._emitChange("state"))}function ns(s,e){const t=s._externalTabs.get(e);if(!t)return;let n=t.url;try{const o=t.iframe.contentWindow?.location.href;o&&o!=="about:blank"&&(n=o)}catch{}window.open(n,"_blank","noopener"),Ee(s,e)}function os(s,e){const t=s._externalTabs.get(e);if(!t)return;const{url:n,label:o}=t;Ee(s,e),Ve({message:ke(C(`Opened "%s" in a new browser tab — this site doesn't allow embedding.`),o),action:{label:C("Open"),onClick:()=>{window.open(n,"_blank","noopener")}}}),window.open(n,"_blank","noopener")}function is(s){return s._externalTabs.size}function rs(s){const e=[];for(const t of s._externalTabs.values()){let n=t.url;try{const o=t.iframe.contentWindow?.location.href;o&&o!=="about:blank"&&(n=o)}catch{}e.push({url:n,label:t.label})}return e}function as(s,e){const t=e.target,n=t.closest("[data-tab-action]");if(n){e.stopPropagation();const l=n.dataset.tabAction,d=n.dataset.tabId;if(!d)return;l==="close"?Ee(s,d):l==="detach"&&ns(s,d);return}const o=t.closest(".desktop-mode-window__tab");if(!o)return;e.stopPropagation();const i=o.dataset.kind,r=o.dataset.tabId;if(i==="external"&&r){X(s,r);return}if(i==="main"){X(s,"primary");return}if(o.dataset.url){const l=Ge(o.dataset.url);l&&s.iframe&&(s.markContentLoading(),s.iframe.src=l),X(s,"primary")}}const Ye="__desktopModeSharedStores";function ds(){const s=window;let e=s[Ye];return e||(e=new Map,s[Ye]=e),e}function $(s,e){const t=ds();let n=t.get(s);n||(n={state:e(),listeners:new Set,rebuild:e},t.set(s,n));const o={get state(){return n.state},set state(i){n.state=i},getState(){return n.state},notify(){for(const i of Array.from(n.listeners))try{i(n.state)}catch(r){console.error(`[desktop-mode/shared-store:${s}] subscriber threw:`,r)}},subscribe(i){return n.listeners.add(i),()=>{n.listeners.delete(i)}},setState(i){const r=n.state;if(typeof r!="object"||r===null){console.warn(`[desktop-mode/shared-store:${s}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(r,i),o.notify()},reset(){const i=n.rebuild(),r=n.state;if(typeof r=="object"&&r!==null&&typeof i=="object"&&i!==null){const l=r;for(const d of Object.keys(l))delete l[d];Object.assign(l,i)}else n.state=i;n.listeners.clear()}};return o}const ls=$("desktop-mode/native-url-remap",()=>({remaps:[],deps:null}));function cs(s){const{deps:e,remaps:t}=ls.state;if(!e||!s)return!1;let n;try{n=new URL(s,e.adminUrl)}catch{return!1}const o=e.getSnapshot();for(const i of t)if(i.matches(s,n)&&!(i.enabled&&!i.enabled(o))){if(i.onMatch)try{i.onMatch(s,n)}catch(r){console.warn(`[desktop-mode] URL remap onMatch hook threw for "${i.id}":`,r)}if(e.openById(i.nativeWindowId))return!0}return!1}const us=$("desktop-mode/destructive-admin-actions",()=>({entries:[]}));function ps(s,e){for(const t of us.state.entries)try{if(t.matches(s,e))return t.id}catch(n){console.warn(`[desktop-mode] destructive-action predicate threw for "${t.id}":`,n)}return null}const hs="desktop-mode-my-wordpress",ms=Object.freeze({userId:null,userName:"",requestedAt:0});function je(){return window.wp?.desktop}let le=null;function fs(){if(le)return le;const s=je()?.createSharedStore;return typeof s!="function"?null:(le=s("desktop-mode/my-wordpress/footprint-target",()=>({...ms})),le)}function ws(s,e=""){const t=fs();if(t){t.state.userId=s,t.state.userName=e,t.state.requestedAt=Date.now(),t.notify();return}window._wpdFootprintTarget={userId:s,userName:e,requestedAt:Date.now()}}function _s(s){const e=Number(s.userId);!Number.isFinite(e)||e<=0||(ws(e,s.userName??""),je()?.openWindow?.(hs,{source:"my-wordpress/open-user-footprint"}))}const F=window.location.origin,bs=$("desktop-mode/admin-link-deps",()=>({deps:null}));function gs(s,e){if(e.origin!==F||!s.iframe||e.source!==s.iframe.contentWindow)return;const t=e.data;if(!(!t||typeof t.type!="string")){if(t.type==="desktop-mode-title-change"&&typeof t.title=="string"&&s.setTitle(t.title),t.type==="desktop-mode-window-publish"&&typeof t.channel=="string"&&t.channel!==""&&Fe(s.id,t.channel,t.payload),typeof t.type=="string"&&t.type.startsWith("desktop-mode-bridge-")&&window.__desktopModeConnectionBridge?.routeIncomingFromIframe(t,s.id),t.type==="desktop-mode-ready"&&(R(s.id),h(u.IFRAME_READY,{windowId:s.id})),t.type==="desktop-mode-navigate"&&typeof t.url=="string"&&t.url!==""&&ys(s,t.url,t.target==="new"?"new":"self"),t.type==="desktop-mode-iframe-admin-link"&&typeof t.url=="string"&&t.url!==""){const n=bs.state.deps;if(cs(t.url))s.close();else if(n){const o=typeof t.label=="string"?t.label:"";Es(s,t.url,o,n)}}if(t.type==="desktop-mode-open-user-footprint"&&typeof t.userId=="number"&&t.userId>0&&_s({userId:t.userId,userName:typeof t.userName=="string"?t.userName:""}),t.type==="desktop-mode-notification"&&typeof t.title=="string"&&t.title!==""&&Cs(t.title,typeof t.body=="string"?t.body:""),t.type==="desktop-mode-focus-request"&&(s.element.classList.contains("desktop-mode-window--overview")||s.onFocusRequest?.(s)),t.type==="desktop-mode-screen-meta"&&Array.isArray(t.panels)&&Ss(s,t.panels),t.type==="desktop-mode-screen-meta-state"&&As(s,typeof t.open=="string"?t.open:null),t.type==="desktop-mode-external-link"&&typeof t.url=="string"&&t.url!==""){const n=typeof t.label=="string"&&t.label!==""?t.label:t.url;Ke(s,t.url,n)}if(t.type==="desktop-mode-iframe-error"&&h(u.IFRAME_ERROR,{windowId:s.id,kind:t.kind==="unhandledrejection"?"unhandledrejection":"error",message:typeof t.message=="string"?t.message:"",filename:typeof t.filename=="string"?t.filename:null,lineno:typeof t.lineno=="number"?t.lineno:null,colno:typeof t.colno=="number"?t.colno:null,stack:typeof t.stack=="string"?t.stack:null}),t.type==="desktop-mode-chrome-theme"&&t.tokens&&typeof t.tokens=="object")try{s.setAppearanceTheme(t.tokens)}catch(n){h(u.SHELL_ERROR,{scope:"window-bridge-chrome-theme",windowId:s.id,error:n})}if(t.type==="desktop-mode-chrome-controls"&&t.config&&typeof t.config=="object")try{s.setAppearanceControls(t.config)}catch(n){h(u.SHELL_ERROR,{scope:"window-bridge-chrome-controls",windowId:s.id,error:n})}if(t.type==="desktop-mode-chrome-slot"&&typeof t.slot=="string"&&typeof t.html=="string")try{s.setAppearanceSlot(t.slot,{html:t.html})}catch(n){h(u.SHELL_ERROR,{scope:"window-bridge-chrome-slot",windowId:s.id,error:n})}if(t.type==="desktop-mode-iframe-network"){const n={windowId:s.id,method:typeof t.method=="string"?t.method:"GET",url:typeof t.url=="string"?t.url:"",status:typeof t.status=="number"?t.status:0,duration:typeof t.duration=="number"?t.duration:0,failed:!!t.failed};t.requestHeaders&&typeof t.requestHeaders=="object"&&(n.requestHeaders=t.requestHeaders),t.responseHeaders&&typeof t.responseHeaders=="object"&&(n.responseHeaders=t.responseHeaders),h(u.IFRAME_NETWORK_COMPLETED,n)}}}function ys(s,e,t){let n;try{n=new URL(e,F)}catch{return}if(n.origin===F){if(t==="new"){window.open(n.toString(),"_blank","noopener,noreferrer");return}s.iframe&&(s.iframe.src=n.toString())}}const ks=new Set(["trash","untrash","delete","spam","unspam","spamcomment","unspamcomment","trashcomment","untrashcomment","deletecomment","approvecomment","unapprovecomment"]);function vs(s){const e=s.searchParams.get("action");return e&&ks.has(e)&&(s.searchParams.has("_wpnonce")||s.searchParams.has("_wp_nonce"))?!0:ps(s.toString(),s)!==null}function Ze(s,e){if(s.searchParams.has("_wp_http_referer"))return s;let t="";try{t=e.iframe?.contentWindow?.location.href??""}catch{}if(t||(t=e.config.url||""),!t)return s;try{const n=new URL(t,F);if(n.origin!==F)return s;const o=new URL(s.href),i=new URL(n.href);return i.searchParams.delete("desktop_mode_chromeless"),o.searchParams.set("_wp_http_referer",i.pathname+(i.search?i.search:"")),o}catch{return s}}function Es(s,e,t,n){let o;try{o=new URL(e,n.adminUrl)}catch{return}if(o.origin!==F)return;const i=o.toString(),r=n.deriveSlug(i),l=s.config.baseId||s.id;if(r!==l&&vs(o)){const f=Ze(o,s),m=s.iframe?.contentWindow;if(m)try{m.location.assign(f.href)}catch{s.iframe&&(s.iframe.src=f.href)}return}if(r===l){const f=s.iframe?.contentWindow;if(f)try{f.location.assign(i)}catch{s.iframe&&(s.iframe.src=i)}return}const d=n.findDockEntry(i),a=t.trim(),c=d?.title||(a!==""?a:r),p=Ze(o,s);n.openWindow({id:r,baseId:r,url:p.toString(),parentUrl:d?.url??i,title:c,icon:d?.icon??"dashicons-admin-generic",submenu:d?.submenu,multi:d?.multi})}function Cs(s,e){const t=e!==""?`${s} — ${e}`:s;Ve({message:t})}function Ss(s,e){const t=s.element.querySelector(".desktop-mode-window__screen-meta");if(!t)return;t.innerHTML="";const n={"screen-options":{icon:"dashicons-admin-generic",label:"Screen Options"},help:{icon:"dashicons-editor-help",label:"Help"}};for(const o of e){const i=n[o];if(!i)continue;const r=document.createElement("button");r.className="desktop-mode-window__meta-btn",r.setAttribute("type","button"),r.setAttribute("aria-label",i.label),r.setAttribute("aria-pressed","false"),r.dataset.panel=o,r.innerHTML=`<span class="dashicons ${i.icon}" aria-hidden="true"></span>`,r.addEventListener("click",l=>{l.stopPropagation(),s.iframe?.contentWindow?.postMessage({type:"desktop-mode-toggle-panel",panel:o},F)}),t.appendChild(r)}}function As(s,e){const t=s.element.querySelector(".desktop-mode-window__screen-meta");t&&t.querySelectorAll(".desktop-mode-window__meta-btn").forEach(n=>{const o=n.dataset.panel===e;n.classList.toggle("desktop-mode-window__meta-btn--active",o),n.setAttribute("aria-pressed",o?"true":"false")})}const Qe=$("desktop-mode/title-bar-buttons-registry",()=>({registry:new Map,listeners:new Set})),Is=Qe.state.registry,Je=Qe.state.listeners;function xs(){return Array.from(Is.values()).sort((s,e)=>(s.order??100)-(e.order??100))}function Ls(s){const e=[],t=[];for(const n of xs()){try{if(!n.match(s))continue}catch{continue}n.placement==="right"?t.push(n):e.push(n)}return{left:e,right:t}}function Ts(s){return Je.add(s),()=>{Je.delete(s)}}const Ds=/^dashicons-[a-z0-9-]+$/i,Os=/^\s*<svg[\s>]/i;function et(s,e){if(e){if(Ds.test(e)){const t=document.createElement("span");t.className=`dashicons ${e}`,t.setAttribute("aria-hidden","true"),s.appendChild(t);return}if(Os.test(e)){const t=document.createElement("span");t.setAttribute("aria-hidden","true"),t.innerHTML=e,s.appendChild(t);return}s.setAttribute("icon",e)}}const tt=$("desktop-mode/window-themes-registry",()=>({registry:new Map,listeners:new Set})),Ns=tt.state.registry,st=tt.state.listeners;function nt(){return Array.from(Ns.values()).sort((s,e)=>(s.priority??100)-(e.priority??100))}function Rs(s){let e=null;for(const t of nt()){try{if(!t.match(s))continue}catch(n){typeof console<"u"&&console.warn(`[desktop-mode] window-theme "${t.id}" match() threw — skipping`,n);continue}e=t}return e}function Ws(s){return st.add(s),()=>{st.delete(s)}}const ce=new WeakMap;function Ms(s,e){let t=null,n={};if(e&&"tokens"in e&&e.tokens)t=null,n={...e.tokens};else if(e&&"themeId"in e&&e.themeId){const i=Ps(e.themeId);i&&(t=i.id,n={...i.tokens})}else{const i=Rs(s);i&&(t=i.id,n={...i.tokens})}const o=T(u.WINDOW_CHROME_THEME,n,{windowId:s.id,themeId:t,config:s.config});return{themeId:t,tokens:o}}function Ce(s,e){const t=s.element;if(!t)return;const n=ce.get(t),{themeId:o,tokens:i}=Ms(s,e);if(n){for(const l of n.keys)if(!(l in i))try{t.style.removeProperty(l)}catch{}}const r=new Set;for(const[l,d]of Object.entries(i))try{t.style.setProperty(l,d),r.add(l)}catch(a){h(u.SHELL_ERROR,{scope:"window-theme-apply",windowId:s.id,key:l,error:a})}ce.set(t,{themeId:o,keys:r}),h(u.WINDOW_CHROME_THEME_CHANGED,{windowId:s.id,themeId:o,tokens:i})}function $s(s){const e=s.element;if(!e)return;const t=ce.get(e);if(t){for(const n of t.keys)try{e.style.removeProperty(n)}catch{}ce.delete(e)}}function Ps(s){for(const e of nt())if(e.id===s)return{id:e.id,tokens:e.tokens};return null}const ot=$("desktop-mode/window-controls-registry",()=>({registry:new Map,listeners:new Set})),Hs=ot.state.registry,it=ot.state.listeners;function zs(){return Array.from(Hs.values()).sort((s,e)=>{const t=s.order??100,n=e.order??100;return t!==n?t-n:s.id.localeCompare(e.id)})}function Fs(s){const e=[],t=[],n=[];for(const o of zs()){try{if(!o.match(s))continue}catch(r){typeof console<"u"&&console.warn(`[desktop-mode] window-control "${o.id}" match() threw — skipping`,r);continue}const i=o.placement??"left";i==="right"?t.push(o):i==="controls"?n.push(o):e.push(o)}return{left:e,right:t,controls:n}}function Us(s){return it.add(s),()=>{it.delete(s)}}function Bs(s,e){const t=Fs(s),n=new Set(e?.hide??[]);let o=t.left.filter(a=>!n.has(a.id)),i=t.right.filter(a=>!n.has(a.id)),r=t.controls.filter(a=>!n.has(a.id));if(e?.custom){for(const a of e.custom){if(n.has(a.id))continue;const c={id:a.id,label:a.label,icon:a.icon,placement:a.placement??"controls",order:a.order??100,match:()=>!0,onClick:a.onClick?(p,f)=>a.onClick(f):void 0,render:a.render?p=>a.render(p):void 0};c.placement==="left"?o.push(c):c.placement==="right"?i.push(c):r.push(c)}o=Se(o),i=Se(i),r=Se(r)}e?.order&&e.order.length>0&&(r=qs(r,e.order));const l=e?.placement??"right",d={windowId:s.id,config:s.config};return o=T(u.WINDOW_CHROME_CONTROLS,o,{...d,placement:"left"}),i=T(u.WINDOW_CHROME_CONTROLS,i,{...d,placement:"right"}),r=T(u.WINDOW_CHROME_CONTROLS,r,{...d,placement:"controls"}),{left:o,right:i,controls:r,placement:l}}function Se(s){return[...s].sort((e,t)=>{const n=e.order??100,o=t.order??100;return n!==o?n-o:e.id.localeCompare(t.id)})}function qs(s,e){const t=new Map;for(const i of s)t.set(i.id,i);const n=[],o=new Set;for(const i of e){const r=t.get(i);r&&!o.has(i)&&(n.push(r),o.add(i))}for(const i of s)o.has(i.id)||n.push(i);return n}function Gs(s,e){const t=document.createElement("wpd-window-button");t.setAttribute("aria-label",s.label),t.classList.add("desktop-mode-window__btn");const n=Vs(s.id);if(t.classList.add(`desktop-mode-window__btn--${n}`),s.id==="core/close"&&t.setAttribute("danger",""),typeof s.render=="function")try{s.render(t,e)}catch(o){return h(u.SHELL_ERROR,{scope:"window-control-render",id:s.id,windowId:e.id,error:o}),{element:t}}else if(et(t,s.icon??""),typeof s.onClick=="function"){const o=i=>{i.stopPropagation();try{s.onClick(e,i)}catch(r){h(u.SHELL_ERROR,{scope:"window-control-onclick",id:s.id,windowId:e.id,error:r})}};return t.addEventListener("wpd-button-activate",o),{element:t,teardown:()=>{t.removeEventListener("wpd-button-activate",o)}}}return{element:t}}function Vs(s){return s.startsWith("core/")?s.slice(5):s.replace(/\//g,"-")}function Xs(s,e){const t=[];for(;e.firstChild;)e.removeChild(e.firstChild);const n=Bs(s,s.config.appearance?.controls);e.classList.toggle("desktop-mode-window__controls--left",n.placement==="left");for(const o of n.controls){const{element:i,teardown:r}=Gs(o,s);e.appendChild(i),r&&t.push(r)}return h(u.WINDOW_CHROME_APPLIED,{windowId:s.id,layer:"controls"}),()=>{for(const o of t)try{o()}catch{}}}const rt=$("desktop-mode/window-slots-registry",()=>({registry:new Map,listeners:new Set})),Ks=rt.state.registry,at=rt.state.listeners;function Ys(){return Array.from(Ks.values()).sort((s,e)=>{const t=s.order??100,n=e.order??100;return t!==n?t-n:s.id.localeCompare(e.id)})}function js(s,e){const t=[];for(const n of Ys())if(n.slot===e){try{if(!n.match(s))continue}catch(o){typeof console<"u"&&console.warn(`[desktop-mode] window-slot "${n.id}" match() threw — skipping`,o);continue}t.push(n)}return t}function Zs(s){return at.add(s),()=>{at.delete(s)}}const dt=["before-titlebar","before-icon","icon","title","after-title","before-controls","after-controls","after-titlebar"],lt=new WeakMap;function ct(s,e){return s.querySelector(`[data-slot="${e}"]`)}function Qs(s){const e=new Map;for(const t of dt){const n=ct(s,t);n&&e.set(t,Array.from(n.childNodes).map(o=>o.cloneNode(!0)))}return e}function K(s){for(;s.firstChild;)s.removeChild(s.firstChild)}function Js(s,e){K(s);for(const t of e)s.appendChild(t.cloneNode(!0))}function en(s){const e=[],t=s.element;if(!t)return()=>{};let n=lt.get(t);n||(n=Qs(t),lt.set(t,n));const o=s.config.appearance?.slots??{};for(const i of dt){const r=ct(t,i);if(!r)continue;const l=n.get(i)??[],d=o[i],a=js(s,i);if(d===null)K(r);else if(d&&"html"in d)K(r),r.textContent=d.html;else if(d&&"render"in d){d.replace!==!1&&K(r);try{const p=d.render(r);typeof p=="function"&&e.push(p)}catch(p){h(u.SHELL_ERROR,{scope:"window-slot-inline-render",windowId:s.id,slot:i,error:p})}}else Js(r,l);if(d!==null){let c=!1;for(const p of a){p.replace!==!1&&!c&&(K(r),c=!0);try{const m=p.render(r,{window:s,slot:i});typeof m=="function"&&e.push(m)}catch(m){h(u.SHELL_ERROR,{scope:"window-slot-registry-render",windowId:s.id,slot:i,id:p.id,error:m})}}}T(u.WINDOW_CHROME_SLOT,r,{windowId:s.id,slot:i,config:s.config})}return h(u.WINDOW_CHROME_APPLIED,{windowId:s.id,layer:"slots"}),()=>{for(const i of e)try{i()}catch{}}}const ut=$("desktop-mode/window-chrome-registry",()=>({registry:new Map,listeners:new Set})),tn=ut.state.registry,pt=ut.state.listeners;function sn(s){return tn.get(s.toLowerCase())??null}function nn(s){return pt.add(s),()=>{pt.delete(s)}}const ue="core/standard",Ae="desktop-mode-window--custom-chrome";function ht(s){const e=s.config.appearance?.chrome??ue;return T(u.WINDOW_CHROME_RENDER,e,{windowId:s.id,config:s.config})}function mt(s){return{title:s.config.title,icon:s.config.icon,focused:s.element.classList.contains("desktop-mode-window--focused"),state:s.state}}function on(s){const e=ht(s);if(e===ue)return null;const t=sn(e);if(!t)return null;try{if(t.match&&!t.match(s))return null}catch{return null}s.element.classList.add(Ae);let n;try{n=t.render(s.element,{window:s,state:mt(s)})}catch(o){return s.element.classList.remove(Ae),h(u.SHELL_ERROR,{scope:"window-chrome-render",windowId:s.id,chromeId:e,error:o}),null}return h(u.WINDOW_CHROME_APPLIED,{windowId:s.id,layer:"chrome",chromeId:e}),{id:e,handle:n}}function ft(s){const e=s.element.querySelector(".desktop-mode-window__menu-panel");e&&(e.hidden?wt(s):P(s))}function wt(s){const e=s.element.querySelector(".desktop-mode-window__menu-panel"),t=s.element.querySelector(".desktop-mode-window__menu-btn");if(!e||!t)return;e.hidden=!1,t.setAttribute("aria-expanded","true");const n=e.querySelector(".desktop-mode-window__menu-item--startup");n&&Ie(s,n),s._boundOnDocumentPointerDown||(s._boundOnDocumentPointerDown=i=>{const r=i.target;r&&(e.contains(r)||t.contains(r)||P(s))}),setTimeout(()=>{s._boundOnDocumentPointerDown&&document.addEventListener("pointerdown",s._boundOnDocumentPointerDown,!0)},0),e.querySelector('[role="menuitem"]')?.focus()}function P(s){const e=s.element.querySelector(".desktop-mode-window__menu-panel"),t=s.element.querySelector(".desktop-mode-window__menu-btn");e&&(e.hidden=!0),t&&t.setAttribute("aria-expanded","false"),s._boundOnDocumentPointerDown&&document.removeEventListener("pointerdown",s._boundOnDocumentPointerDown,!0)}function rn(s){s.hasAttribute("checked")?s.removeAttribute("checked"):s.setAttribute("checked","")}function Ie(s,e){const t=window.wp?.desktop?.config?.defaultWindow;let n=!1;if(t&&t.enabled&&typeof t.url=="string")if(s.config.native)n=t.url===`native:${s.id}`;else try{const o=W(s.getCurrentUrl()),i=W(t.url);n=o===i}catch{n=!1}n?e.setAttribute("checked",""):e.removeAttribute("checked")}function _t(s,e){let t=!1;return()=>{t||(t=!0,requestAnimationFrame(()=>{if(t=!1,!(e==="drag"&&!s._isDragging)&&!(e==="resize"&&!s._isResizing)&&!(s._isDestroyed||!s.element.isConnected))try{h(u.WINDOW_BOUNDS_CHANGED,{windowId:s.id,x:s.element.offsetLeft,y:s.element.offsetTop,width:s.element.offsetWidth,height:s.element.offsetHeight,state:s.state,phase:e})}catch{}}))}}function an(s,e){const t=e.target;if(t.closest(".desktop-mode-window__btn")||t.closest(".desktop-mode-window__custom-buttons")||t.closest(".desktop-mode-window__controls")||t.closest(".desktop-mode-window__screen-meta")||t.closest(".desktop-mode-window__menu-btn")||t.closest(".desktop-mode-window__menu-panel"))return;const n=s.state==="maximized",o=s.state==="snapped-left"||s.state==="snapped-right",i=n||o,r=e.clientX,l=e.clientY,d=e.pointerId,a=i?dn(s,e):null;s._titleBar.setPointerCapture(d);const c=s.snapConfigProvider?.()??{enabled:!1,cellWidth:0,cellHeight:0},p=_t(s,"drag");let f=!1;const m=(b,y)=>{if(f)return;f=!0;let v,I;if(a){const D=ln(s,a,b,y);v=D.left,I=D.top}else v=s.element.offsetLeft,I=s.element.offsetTop;s.element.classList.add("desktop-mode-window--dragging"),c.enabled&&s.element.classList.add("desktop-mode-window--snap-drag"),s._isDragging=!0,s._dragOffsetX=b-v,s._dragOffsetY=y-I,h(u.WINDOW_DRAG_START,{windowId:s.id})};i||m(r,l);const _=b=>{if(!f){const D=b.clientX-r,ee=b.clientY-l;if(D*D+ee*ee<Jt)return;m(b.clientX,b.clientY)}if(!s._isDragging)return;let y=b.clientX-s._dragOffsetX,v=b.clientY-s._dragOffsetY;const I=s.element.parentElement;I&&(y=Math.max(de,Math.min(y,I.clientWidth-de)),v=Math.max(de,Math.min(v,I.clientHeight-de))),c.enabled&&(y=Math.round(y/c.cellWidth)*c.cellWidth,v=Math.round(v/c.cellHeight)*c.cellHeight),s.element.style.left=`${y}px`,s.element.style.top=`${v}px`,s.onDragMove?.(s,b.clientX,b.clientY),p()},E=()=>{try{s._titleBar.releasePointerCapture(d)}catch{}},g=()=>{s._titleBar.removeEventListener("pointermove",_),s._titleBar.removeEventListener("pointerup",k),s._titleBar.removeEventListener("pointercancel",k),s._titleBar.removeEventListener("lostpointercapture",k)},k=()=>{if(!f){E(),g();return}if(!s._isDragging||(s._isDragging=!1,s.element.classList.remove("desktop-mode-window--dragging"),s.element.classList.remove("desktop-mode-window--snap-drag"),E(),g(),s.onDragEnd?.(s)??!1))return;s._emitChange("moved");const y={windowId:s.id,x:s.element.offsetLeft,y:s.element.offsetTop};h(u.WINDOW_DRAG_END,y),h(u.WINDOW_MOVED,y)};s._titleBar.addEventListener("pointermove",_),s._titleBar.addEventListener("pointerup",k),s._titleBar.addEventListener("pointercancel",k),s._titleBar.addEventListener("lostpointercapture",k)}function dn(s,e){const t=s._titleBar.getBoundingClientRect(),n=t.width>0?(e.clientX-t.left)/t.width:.5,o=s.element.parentElement,i=o?Math.min(960,Math.round(o.clientWidth*.6)):640,r=o?Math.min(640,Math.round(o.clientHeight*.7)):480,l=s._savedGeometry?.width??i,d=s._savedGeometry?.height??r,a=o?.getBoundingClientRect();return{isMaximized:s.state==="maximized",cursorRatioX:n,titleBarHeight:t.height,areaLeft:a?.left??0,areaTop:a?.top??0,targetW:l,targetH:d}}function ln(s,e,t,n){s.element.classList.remove("desktop-mode-window--maximized","desktop-mode-window--snapped-left","desktop-mode-window--snapped-right"),s.element.style.width=`${e.targetW}px`,s.element.style.height=`${e.targetH}px`;const o=Math.round(t-e.areaLeft-e.targetW*e.cursorRatioX),i=Math.round(n-e.areaTop-e.titleBarHeight/2);return s.element.style.left=`${o}px`,s.element.style.top=`${i}px`,s.state="normal",s._emitChange("state"),e.isMaximized&&h(u.WINDOW_UNMAXIMIZED,{windowId:s.id}),{left:o,top:i}}function cn(s,e){if(s.state==="maximized"||s.state==="fullscreen")return;e.preventDefault(),e.stopPropagation();const t=e.target,n=t.dataset.dir??"se";s._isResizing=!0,s._resizeStartX=e.clientX,s._resizeStartY=e.clientY,s._resizeStartW=s.element.offsetWidth,s._resizeStartH=s.element.offsetHeight;const o=s.element.offsetLeft,i=s.element.offsetTop;t.setPointerCapture(e.pointerId),s.element.classList.add("desktop-mode-window--resizing"),h(u.WINDOW_RESIZE_START,{windowId:s.id});const r=_t(s,"resize"),l=s.snapConfigProvider?.()??{enabled:!1,cellWidth:0,cellHeight:0};l.enabled&&s.element.classList.add("desktop-mode-window--snap-drag"),(s.state==="snapped-left"||s.state==="snapped-right")&&(s.element.classList.remove("desktop-mode-window--snapped-left","desktop-mode-window--snapped-right"),s.state="normal");const d=c=>{if(!s._isResizing)return;const p=c.clientX-s._resizeStartX,f=c.clientY-s._resizeStartY,m=un(n,p,f,o,i,s._resizeStartW,s._resizeStartH,s.config.minWidth,s.config.minHeight,l);s.element.style.left=`${m.x}px`,s.element.style.top=`${m.y}px`,s.element.style.width=`${m.width}px`,s.element.style.height=`${m.height}px`,r()},a=()=>{if(!s._isResizing)return;s._isResizing=!1,s.element.classList.remove("desktop-mode-window--resizing"),s.element.classList.remove("desktop-mode-window--snap-drag"),t.removeEventListener("pointermove",d),t.removeEventListener("pointerup",a),t.removeEventListener("pointercancel",a),t.removeEventListener("lostpointercapture",a),s._emitChange("resized");const c={windowId:s.id,width:s.element.offsetWidth,height:s.element.offsetHeight};h(u.WINDOW_RESIZE_END,c),h(u.WINDOW_RESIZED,c)};t.addEventListener("pointermove",d),t.addEventListener("pointerup",a),t.addEventListener("pointercancel",a),t.addEventListener("lostpointercapture",a)}function un(s,e,t,n,o,i,r,l,d,a){let c=i,p=r,f=n,m=o;if((s==="ne"||s==="se")&&(c=Math.max(l,i+e)),s==="nw"||s==="sw"){const _=Math.max(l,i-e);f=n+(i-_),c=_}if((s==="se"||s==="sw")&&(p=Math.max(d,r+t)),s==="ne"||s==="nw"){const _=Math.max(d,r-t);m=o+(r-_),p=_}if(a.enabled){const _=Math.max(l,Math.round(c/a.cellWidth)*a.cellWidth),E=Math.max(d,Math.round(p/a.cellHeight)*a.cellHeight);(s==="nw"||s==="sw")&&(f=n+(c-_)),(s==="nw"||s==="ne")&&(m=o+(p-E)),c=_,p=E}return{x:f,y:m,width:c,height:p}}const xe=window.location.origin,me=class me{constructor(e){if(this.state="normal",this._activityCount=0,this._activityPhase="idle",this._activityError=null,this._activityClearTimer=null,this._activitySavingStartedAt=0,this._activitySettleTimer=null,this._isDragging=!1,this._isResizing=!1,this._isDestroyed=!1,this._dragOffsetX=0,this._dragOffsetY=0,this._resizeStartX=0,this._resizeStartY=0,this._resizeStartW=0,this._resizeStartH=0,this._savedGeometry=null,this._savedFullscreenState=null,this._stateBeforeMinimize=null,this._externalTabs=new Map,this._externalTabSeq=0,this._titleBarButtonsUnsubscribe=null,this._windowThemesUnsubscribe=null,this._windowControlsUnsubscribe=null,this._windowControlsTeardown=null,this._windowSlotsUnsubscribe=null,this._windowSlotsTeardown=null,this._chromeHandle=null,this._chromeId=ue,this._windowChromesUnsubscribe=null,this._nativeRenderTeardown=null,this._nativeRenderCtxDispose=null,this._closeSafetyNetTimer=null,this._onCloseTransitionEnd=null,this._isFinalized=!1,this._activeTabId="primary",this.onFocusRequest=null,this.onClose=null,this.onMinimize=null,this.onOpenAnother=null,this.onOpenInNewWindow=null,this.onToggleStartup=null,this.snapConfigProvider=null,this.onDragMove=null,this.onDragEnd=null,this._boundOnDocumentPointerDown=null,this._bodyResizeObserver=null,this._suppressCloseFilter=!1,this.id=e.id,this.config=e,this.element=Bt(e),this.iframe=e.native?null:this.element.querySelector(".desktop-mode-window__iframe"),this._titleBar=this.element.querySelector(".desktop-mode-window__titlebar"),this._titleEl=this.element.querySelector(".desktop-mode-window__title"),this._boundOnMessage=t=>gs(this,t),this.bindEvents(),this.renderCustomTitleBarButtons(),this._titleBarButtonsUnsubscribe=Ts(()=>{this.renderCustomTitleBarButtons()}),Ce(this,this.config.appearance?.theme),this._windowThemesUnsubscribe=Ws(()=>{this._isDestroyed||Ce(this,this.config.appearance?.theme)}),this.repaintWindowControls(),this._windowControlsUnsubscribe=Us(()=>{this._isDestroyed||this.repaintWindowControls()}),this.repaintWindowSlots(),this._windowSlotsUnsubscribe=Zs(()=>{this._isDestroyed||this.repaintWindowSlots()}),this.remountWindowChrome(),this._windowChromesUnsubscribe=nn(()=>{if(this._isDestroyed)return;ht(this)!==this._chromeId&&this.remountWindowChrome()}),this._bodyResizeObserver=this.installBodyResizeObserver(),e.initialState==="minimized"){this.state="minimized",this.element.classList.add("desktop-mode-window--minimized"),this.iframe&&(this.iframe.style.visibility="hidden");return}(e.initialState==="snapped-left"||e.initialState==="snapped-right")&&this.element.classList.add(`desktop-mode-window--${e.initialState}`),this.element.classList.add("desktop-mode-window--opening"),this.element.addEventListener("animationend",()=>{this.element.classList.remove("desktop-mode-window--opening")},{once:!0}),e.initialState&&e.initialState!=="normal"&&requestAnimationFrame(()=>this.applyInitialState(e.initialState))}hydrateNative(){if(!this.config.native||!this.config.render)return;const e=this.element.querySelector(".desktop-mode-window__body");if(!e)return;const t=T(u.NATIVE_WINDOW_BEFORE_RENDER,e,{windowId:this.id,config:this.config}),n=t instanceof HTMLElement?t:e,{ctx:o,dispose:i}=$t(this.id);this._nativeRenderCtxDispose=i;const r=this.config.render(n,o),l=a=>{typeof a=="function"&&(this._nativeRenderTeardown=a)};r instanceof Promise?r.then(a=>{this._isDestroyed||(l(a),R(this.id))},a=>{typeof console<"u"&&console.error(`[desktop-mode] native render rejected for "${this.id}":`,a),h(u.SHELL_ERROR,{scope:"window-open",id:this.id,error:a}),!this._isDestroyed&&R(this.id)}):(l(r),requestAnimationFrame(()=>{this._isDestroyed||R(this.id)})),h(u.NATIVE_WINDOW_AFTER_RENDER,{windowId:this.id,body:n,config:this.config});const d=this.config.autofocus;d&&requestAnimationFrame(()=>{if(this._isDestroyed)return;if(typeof d=="string"){n.querySelector(d)?.focus();return}n.hasAttribute("tabindex")||(n.tabIndex=-1),n.focus()})}applyInitialState(e){e==="minimized"?this.minimize():e==="maximized"?this.toggleMaximize():e==="fullscreen"?this.toggleFullscreen():e==="snapped-left"?this.applySnap("left"):e==="snapped-right"&&this.applySnap("right")}_emitChange(e){document.dispatchEvent(new CustomEvent("desktop-mode-window-changed",{detail:{windowId:this.id,reason:e,state:this.state}}))}snapGeometry(e){const t=this.snapConfigProvider?.();if(!t||!t.enabled)return e;const n=Math.max(this.config.minWidth,Math.round(e.width/t.cellWidth)*t.cellWidth),o=Math.max(this.config.minHeight,Math.round(e.height/t.cellHeight)*t.cellHeight);return{x:Math.round(e.x/t.cellWidth)*t.cellWidth,y:Math.round(e.y/t.cellHeight)*t.cellHeight,width:n,height:o}}getCurrentUrl(){if(!this.iframe)return this.config.url||`#${this.id}`;try{const e=this.iframe.contentWindow?.location.href;if(e&&e!=="about:blank")return e}catch{}return this.iframe.src}bindEvents(){this.element.addEventListener("pointerdown",()=>{this.element.classList.contains("desktop-mode-window--overview")||this.onFocusRequest?.(this)}),this.element.addEventListener("focusin",()=>{this.element.classList.contains("desktop-mode-window--overview")||this.onFocusRequest?.(this)}),this._titleBar.addEventListener("pointerdown",o=>an(this,o)),this.element.querySelectorAll(".desktop-mode-window__resize-handle").forEach(o=>{o.addEventListener("pointerdown",i=>cn(this,i))});const t=this.element.querySelector(".desktop-mode-window__menu-btn"),n=this.element.querySelector(".desktop-mode-window__menu-panel");if(t&&n){t.addEventListener("click",a=>{a.stopPropagation(),ft(this)});const o=n.querySelector(".desktop-mode-window__menu-item--open-another");o&&o.addEventListener("wpd-menu-item-click",a=>{a.stopPropagation(),P(this),this.onOpenAnother?.(this)});const i=n.querySelector(".desktop-mode-window__menu-item--open-in-new-window");i&&i.addEventListener("wpd-menu-item-click",a=>{a.stopPropagation(),P(this),this.onOpenInNewWindow?.(this)});const r=n.querySelector(".desktop-mode-window__menu-item--reload");r&&r.addEventListener("wpd-menu-item-click",a=>{a.stopPropagation(),P(this),this.reload()});const l=n.querySelector(".desktop-mode-window__menu-item--open-external");l&&l.addEventListener("wpd-menu-item-click",a=>{a.stopPropagation(),P(this),this.detach()});const d=n.querySelector(".desktop-mode-window__menu-item--startup");d&&(Ie(this,d),d.addEventListener("wpd-menu-item-click",a=>{a.stopPropagation(),rn(d),this.onToggleStartup?.(this)}),document.addEventListener("desktop-mode-default-window-changed",()=>{Ie(this,d)})),n.addEventListener("keydown",a=>{a.key==="Escape"&&(a.stopPropagation(),P(this),t.focus())})}if(this._titleBar.addEventListener("dblclick",o=>{o.target?.closest('button, [role="button"], [role="menuitem"], [role="menuitemcheckbox"], wpd-window-button, wpd-menu, wpd-menu-item, .desktop-mode-window__menu-panel, .desktop-mode-window__custom-buttons, input, select, textarea, a')||this.toggleMaximize()}),this.iframe){const o=this.iframe,i=this.element.querySelector(".desktop-mode-window__tabs");i&&i.addEventListener("click",r=>as(this,r)),o.addEventListener("load",()=>{try{const r=o.contentWindow?.location.href;r&&ts(this,r)}catch{}}),window.addEventListener("message",this._boundOnMessage)}}addExternalTab(e,t){Ke(this,e,t)}setZIndex(e){this.element.style.zIndex=String(e)}setFocused(e){this.element.classList.toggle("desktop-mode-window--focused",e),this._notifyChromeStateChanged()}setTitle(e){this._titleEl.textContent=e,this.config.title=e,h(u.WINDOW_TITLE_CHANGED,{windowId:this.id,title:e}),this._notifyChromeStateChanged()}repaintWindowControls(){const e=this.element.querySelector(".desktop-mode-window__controls");if(e){if(this._windowControlsTeardown){try{this._windowControlsTeardown()}catch{}this._windowControlsTeardown=null}this._windowControlsTeardown=Xs(this,e)}}setAppearanceControls(e){this.config.appearance={...this.config.appearance??{},controls:e??void 0},this.repaintWindowControls()}repaintWindowSlots(){if(this._windowSlotsTeardown){try{this._windowSlotsTeardown()}catch{}this._windowSlotsTeardown=null}this._windowSlotsTeardown=en(this)}remountWindowChrome(){if(this._chromeHandle){try{this._chromeHandle.destroy()}catch{}this._chromeHandle=null}this.element.classList.remove(Ae);const e=on(this);e?(this._chromeHandle=e.handle,this._chromeId=e.id):this._chromeId=ue}setAppearanceChrome(e){this.config.appearance={...this.config.appearance??{},chrome:e??void 0},this.remountWindowChrome()}_notifyChromeStateChanged(){if(!this._isDestroyed&&this._chromeHandle?.update)try{this._chromeHandle.update(mt(this))}catch{}}setAppearanceSlot(e,t){const o={...this.config.appearance?.slots??{}};t===void 0?delete o[e]:o[e]=t,this.config.appearance={...this.config.appearance??{},slots:o},this.repaintWindowSlots()}setAppearanceTheme(e){let t;e==null?t=void 0:typeof e=="string"?t={themeId:e}:typeof e=="object"&&("themeId"in e||"tokens"in e)?t=e:typeof e=="object"&&(t={tokens:e}),this.config.appearance={...this.config.appearance??{},theme:t},Ce(this,t)}applySnap(e){this._applySnapVisuals(e)&&(this.state=e==="left"?"snapped-left":"snapped-right",this._emitChange("state"))}_applySnapVisuals(e){const t=this.element.parentElement;if(!t)return!1;const n=Math.floor(t.clientWidth/2),o=t.clientHeight;return this.element.classList.remove("desktop-mode-window--maximized","desktop-mode-window--fullscreen","desktop-mode-window--snapped-left","desktop-mode-window--snapped-right"),this.element.classList.add(`desktop-mode-window--snapped-${e}`),this.element.style.left=e==="left"?"0px":`${n}px`,this.element.style.top="0px",this.element.style.width=`${n}px`,this.element.style.height=`${o}px`,!0}isMinimized(){return this.state==="minimized"}isMaximized(){return this.state==="maximized"}isFullscreen(){return this.state==="fullscreen"}isSnapped(e){return e==="left"?this.state==="snapped-left":e==="right"?this.state==="snapped-right":this.state==="snapped-left"||this.state==="snapped-right"}isFocused(){return this.element.classList.contains("desktop-mode-window--focused")}minimize(){if(this.state!=="minimized"){if(this._stateBeforeMinimize=this.state,this.state="minimized",this.element.classList.add("desktop-mode-window--minimized"),this.iframe){const e=this.iframe;this.element.addEventListener("transitionend",t=>{t.propertyName==="opacity"&&this.state==="minimized"&&(e.style.visibility="hidden")},{once:!0})}this.onMinimize?.(this),this._emitChange("state"),h(u.WINDOW_MINIMIZED,{windowId:this.id,element:this.element})}}restore(){this.iframe&&(this.iframe.style.visibility="");const e=this.state==="minimized";this.element.classList.remove("desktop-mode-window--minimized"),e&&(this.state=this._stateBeforeMinimize??"normal",this._stateBeforeMinimize=null,this.state==="fullscreen"&&(V(),this.updateFocusButtonState())),this.onFocusRequest?.(this),this._emitChange("state"),e&&h(u.WINDOW_RESTORED,{windowId:this.id,element:this.element})}maximize(){this.state!=="maximized"&&(this.state==="normal"&&(this._savedGeometry={x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight}),this._applyMaximizeVisuals()&&(this.state="maximized",this._emitChange("state"),h(u.WINDOW_MAXIMIZED,{windowId:this.id,element:this.element})))}_applyMaximizeVisuals(){const e=this.element.parentElement;return e?(this.element.classList.remove("desktop-mode-window--fullscreen","desktop-mode-window--snapped-left","desktop-mode-window--snapped-right"),this.element.classList.add("desktop-mode-window--maximized"),this.element.style.left="0px",this.element.style.top="0px",this.element.style.width=`${e.clientWidth}px`,this.element.style.height=`${e.clientHeight}px`,!0):!1}toggleMaximize(){if(this.element.parentElement){if(this.state==="maximized"){if(this.element.classList.remove("desktop-mode-window--maximized"),this._savedGeometry){const t=this.snapGeometry(this._savedGeometry);this.element.style.left=`${t.x}px`,this.element.style.top=`${t.y}px`,this.element.style.width=`${t.width}px`,this.element.style.height=`${t.height}px`,this._savedGeometry=t}this.state="normal",this._emitChange("state"),h(u.WINDOW_UNMAXIMIZED,{windowId:this.id,element:this.element});return}if(this.state==="fullscreen"){this._savedFullscreenState=null,this._applyMaximizeVisuals(),this.state="maximized",V(),this.updateFocusButtonState(),this._emitChange("state"),h(u.WINDOW_FULLSCREEN_EXITED,{windowId:this.id,element:this.element}),h(u.WINDOW_MAXIMIZED,{windowId:this.id,element:this.element});return}this.maximize()}}toggleFullscreen(){if(this.state==="fullscreen"){this.element.classList.remove("desktop-mode-window--fullscreen");const e=this._savedFullscreenState;this._savedFullscreenState=null;let t=!1;if(e&&e.state==="maximized")this._applyMaximizeVisuals(),this.state="maximized",t=!0;else if(e&&(e.state==="snapped-left"||e.state==="snapped-right")){const n=e.state==="snapped-left"?"left":"right";this._applySnapVisuals(n),this.state=e.state}else e?(this.element.style.left=`${e.x}px`,this.element.style.top=`${e.y}px`,this.element.style.width=`${e.width}px`,this.element.style.height=`${e.height}px`,this.state="normal"):this.state="normal";V(),this.updateFocusButtonState(),this._emitChange("state"),h(u.WINDOW_FULLSCREEN_EXITED,{windowId:this.id,element:this.element}),t&&h(u.WINDOW_MAXIMIZED,{windowId:this.id,element:this.element});return}this.state==="normal"&&(this._savedGeometry={x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight}),this._savedFullscreenState={state:this.state,x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight},this.element.classList.remove("desktop-mode-window--maximized","desktop-mode-window--snapped-left","desktop-mode-window--snapped-right"),this.element.classList.add("desktop-mode-window--fullscreen"),this.state="fullscreen",V(),this.updateFocusButtonState(),this._emitChange("state"),h(u.WINDOW_FULLSCREEN_ENTERED,{windowId:this.id,element:this.element})}updateFocusButtonState(){const e=this.element.querySelector(".desktop-mode-window__btn--focus");if(!e)return;const t=this.state==="fullscreen";e.classList.toggle("desktop-mode-window__btn--active",t),e.setAttribute("aria-pressed",t?"true":"false"),e.setAttribute("aria-label",C(t?"Exit fullscreen":"Enter fullscreen"))}detach(){const e=this.getCurrentUrl();let t;try{t=new URL(e,xe)}catch{return}t.origin===xe&&(t.searchParams.delete("desktop_mode_chromeless"),t.searchParams.delete("desktop_mode_portal"),t.searchParams.set("desktop_mode_classic","1"),window.open(t.toString(),"_blank","noopener"),h(u.WINDOW_DETACHED,{windowId:this.id,url:t.toString()}))}reload(){if(this.config.native||this.element.querySelector(".desktop-mode-window__body")?.classList.contains("desktop-mode-window__body--loading"))return;let t,n;if(this._activeTabId==="primary"){if(!this.iframe)return;const o=this.iframe;t=this.getCurrentUrl(),n=()=>{try{o.contentWindow?.location.reload()}catch{o.src=o.src}}}else{const o=this._externalTabs.get(this._activeTabId);if(!o)return;t=o.url,n=()=>{try{o.iframe.contentWindow?.location.reload()}catch{o.iframe.src=o.url}}}this._spinReloadButton(),this.markContentLoading(),n(),h(u.WINDOW_RELOADED,{windowId:this.id,url:t})}_spinReloadButton(){const e=this.element.querySelector(".desktop-mode-window__btn--reload");e instanceof HTMLElement&&(e.classList.remove("desktop-mode-window__btn--spinning"),e.offsetWidth,e.classList.add("desktop-mode-window__btn--spinning"),e.addEventListener("animationend",()=>{e.classList.remove("desktop-mode-window__btn--spinning")},{once:!0}))}renderCustomTitleBarButtons(){const e=this.element.querySelector(".desktop-mode-window__custom-buttons--left"),t=this.element.querySelector(".desktop-mode-window__custom-buttons--right");if(!e||!t)return;e.innerHTML="",t.innerHTML="";const{left:n,right:o}=Ls(this),i=(r,l)=>{for(const d of l){const a=document.createElement("wpd-window-button");if(et(a,d.icon),a.setAttribute("aria-label",d.label),a.setAttribute("title",d.label),a.classList.add("desktop-mode-window__btn"),a.classList.add("desktop-mode-window__btn--custom"),a.dataset.buttonId=d.id,r.appendChild(a),typeof d.render=="function")try{d.render(a,this)}catch(c){typeof console<"u"&&console.error("[desktop-mode] title-bar-button render threw:",d.id,c)}else typeof d.onClick=="function"&&a.addEventListener("wpd-button-activate",c=>{try{d.onClick(this,c)}catch(p){typeof console<"u"&&console.error("[desktop-mode] title-bar-button onClick threw:",d.id,p)}})}};i(e,n),i(t,o)}send(e,t){if(typeof e!="string"||e==="")return;const n=this.iframe??Rt(this.id);if(!n){Tt(this.id,e,t);return}const o=()=>{try{n.contentWindow?.postMessage({type:"desktop-mode-window-send",channel:e,payload:t},xe)}catch(i){typeof console<"u"&&console.error("[desktop-mode] Window.send: postMessage failed",i)}};if(Ue(this.id)){o();return}Dt(this.id,e,t,o)}on(e,t){return typeof e!="string"||e===""||typeof t!="function"?()=>{}:xt(this.id,e,t)}markContentLoading(){re(this.id)}markContentLoaded(){R(this.id)}whenContentReady(){return Ue(this.id)?Promise.resolve():new Promise(e=>{const t=this.id,n=o=>{const i=o.detail;!i||i.windowId!==t||(document.removeEventListener("desktop-mode-window-content-loaded",n),e())};document.addEventListener("desktop-mode-window-content-loaded",n)})}markActivity(e,t={}){this._activityPhase=e,this._activityError=t.error??null,this._paintActivityIndicator()}trackActivity(e){return this._markActivityStart(),e.then(t=>(this._markActivitySettled(!0),t),t=>{const n=t instanceof Error?t.message:String(t);throw this._markActivitySettled(!1,n),t})}_markActivityStart(){this._activityCount++,this._activitySettleTimer!==null&&(window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=null),this._activityCount===1&&(this._activityPhase="saving",this._activityError=null,this._activitySavingStartedAt=Date.now(),this._paintActivityIndicator())}_markActivitySettled(e,t){if(this._activityCount>0&&this._activityCount--,this._activityCount>0){!e&&t&&(this._activityError=t);return}const n=Date.now()-this._activitySavingStartedAt,o=me.MIN_SAVING_DISPLAY_MS-n;if(o>0){this._activitySettleTimer!==null&&window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=window.setTimeout(()=>{this._activitySettleTimer=null,this._finalizeActivitySettle(e,t)},o);return}this._finalizeActivitySettle(e,t)}_finalizeActivitySettle(e,t){this._activityPhase=e&&!this._activityError?"saved":"failed",!e&&t&&(this._activityError=t),this._paintActivityIndicator(),this._activityClearTimer!==null&&(window.clearTimeout(this._activityClearTimer),this._activityClearTimer=null),this._activityPhase==="saved"&&(this._activityClearTimer=window.setTimeout(()=>{this._activityClearTimer=null,this._activityPhase="idle",this._activityError=null,this._paintActivityIndicator()},2200))}_paintActivityIndicator(){if(this._isDestroyed)return;const e=this._titleBar.querySelector("[data-desktop-mode-activity-indicator]");e&&(e.setAttribute("phase",this._activityPhase),this._activityError?e.setAttribute("error",this._activityError):e.removeAttribute("error"))}requestAttention(e,t={}){const n=be.filter("desktop-mode/window-attention-requested",{windowId:this.id,mode:e,durationMs:t.durationMs,intensity:t.intensity},t);if(!n||n.cancel===!0)return;const o=n.mode??e,i={...t,durationMs:typeof n.durationMs=="number"?n.durationMs:t.durationMs,intensity:typeof n.intensity=="string"?n.intensity:t.intensity},r=T("desktop-mode.window.attention",o,{windowId:this.id,opts:i}),l=window.wp,d=l?.desktop?.dock,a=l?.desktop?.taskbar;let c=!1;if(typeof d?.setAttention=="function"&&(d.setAttention(this.id,r,i),c=!0),typeof a?.setAttention=="function"&&(a.setAttention(this.id,r,i),c=!0),!c&&r!==null){this.setHighlight("persistent");const p=i.durationMs??4e3;p>0&&window.setTimeout(()=>{this.setHighlight(null)},p)}else!c&&r===null&&this.setHighlight(null)}shake(){if(T("desktop-mode.window.shake",!0,{windowId:this.id})===!1)return;const t=this.element;t.classList.remove("desktop-mode-window--shaking"),t.offsetWidth,t.classList.add("desktop-mode-window--shaking");const n=()=>{t.classList.remove("desktop-mode-window--shaking"),t.removeEventListener("animationend",n)};t.addEventListener("animationend",n)}setHighlight(e,t){const n=this.element;n&&(n.classList.remove("wp-window--highlight-preview","wp-window--highlight-persistent"),e==="preview"?n.classList.add("wp-window--highlight-preview"):e==="persistent"&&n.classList.add("wp-window--highlight-persistent"),t?.color?n.style.setProperty("--wp-window-highlight-color",t.color):e===null&&n.style.removeProperty("--wp-window-highlight-color"),h(u.WINDOW_HIGHLIGHT_CHANGED,{windowId:this.id,mode:e,color:t?.color}))}close(){if(!this._isDestroyed&&!(this.config.native&&!this._suppressCloseFilter&&T(u.NATIVE_WINDOW_BEFORE_CLOSE,!0,{windowId:this.id,config:this.config})===!1)){if(this._isDestroyed=!0,this._activityClearTimer!==null&&(window.clearTimeout(this._activityClearTimer),this._activityClearTimer=null),this._activitySettleTimer!==null&&(window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=null),this._titleBarButtonsUnsubscribe&&(this._titleBarButtonsUnsubscribe(),this._titleBarButtonsUnsubscribe=null),this._windowThemesUnsubscribe&&(this._windowThemesUnsubscribe(),this._windowThemesUnsubscribe=null),this._windowControlsUnsubscribe&&(this._windowControlsUnsubscribe(),this._windowControlsUnsubscribe=null),this._windowSlotsUnsubscribe&&(this._windowSlotsUnsubscribe(),this._windowSlotsUnsubscribe=null),this._windowChromesUnsubscribe&&(this._windowChromesUnsubscribe(),this._windowChromesUnsubscribe=null),this._nativeRenderCtxDispose){try{this._nativeRenderCtxDispose()}catch(e){h(u.SHELL_ERROR,{scope:"native-window-ctx-dispose",id:this.id,error:e})}this._nativeRenderCtxDispose=null}this._bodyResizeObserver?.disconnect(),this._bodyResizeObserver=null,Ot(this.id);try{this.config.onClose?.()}catch(e){h(u.SHELL_ERROR,{scope:"native-window-close",id:this.id,error:e})}this.onClose?.(this),this.element.classList.add("desktop-mode-window--closing"),this._onCloseTransitionEnd=e=>{e.propertyName==="opacity"&&this._finalizeClose()},this.element.addEventListener("transitionend",this._onCloseTransitionEnd),this._closeSafetyNetTimer=setTimeout(()=>this._finalizeClose(),300)}}destroy(){if(!this._isFinalized){if(!this._isDestroyed){this._suppressCloseFilter=!0;try{this.close()}finally{this._suppressCloseFilter=!1}}this._finalizeClose()}}_finalizeClose(){if(!this._isFinalized){if(this._isFinalized=!0,this._closeSafetyNetTimer!==null&&(clearTimeout(this._closeSafetyNetTimer),this._closeSafetyNetTimer=null),this._onCloseTransitionEnd&&(this.element.removeEventListener("transitionend",this._onCloseTransitionEnd),this._onCloseTransitionEnd=null),this._windowControlsTeardown){try{this._windowControlsTeardown()}catch{}this._windowControlsTeardown=null}if(this._windowSlotsTeardown){try{this._windowSlotsTeardown()}catch{}this._windowSlotsTeardown=null}if(this._chromeHandle){try{this._chromeHandle.destroy()}catch{}this._chromeHandle=null}if($s(this),this._nativeRenderTeardown){try{this._nativeRenderTeardown()}catch(e){h(u.SHELL_ERROR,{scope:"native-window-teardown",id:this.id,error:e})}this._nativeRenderTeardown=null}window.removeEventListener("message",this._boundOnMessage),this._boundOnDocumentPointerDown&&document.removeEventListener("pointerdown",this._boundOnDocumentPointerDown,!0),this.element.remove(),V()}}installBodyResizeObserver(){const e=this.element.querySelector(".desktop-mode-window__body");if(!e||typeof ResizeObserver>"u")return null;const t=new ResizeObserver(n=>{const o=n[0];if(!o)return;const i=o.contentRect,r=Math.round(i.width),l=Math.round(i.height);try{this.config.onResize?.(r,l)}catch(d){h(u.SHELL_ERROR,{scope:"native-window-resize",id:this.id,error:d})}h(u.WINDOW_BODY_RESIZED,{windowId:this.id,width:r,height:l})});return t.observe(e),t}getSnapshot(){if(this.element.offsetParent===null){const t=n=>{const o=parseFloat(n);return Number.isFinite(o)?Math.round(o):0};return{id:this.id,x:t(this.element.style.left),y:t(this.element.style.top),width:t(this.element.style.width),height:t(this.element.style.height),state:this.state}}return{id:this.id,x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight,state:this.state}}getExternalTabCount(){return is(this)}getExternalTabsSnapshot(){return rs(this)}toggleActionsMenu(){ft(this)}closeActionsMenu(){P(this)}openActionsMenu(){wt(this)}};me.MIN_SAVING_DISPLAY_MS=1200;let Le=me;function O(s,...e){return{__wpdHtml:!0,strings:s,values:e}}function pn(s){return!!s&&s.__wpdHtml===!0}const hn="$$wpd$$",A=/\$\$wpd\$\$(\d+)\$\$/g;function mn(s){let e=s[0];for(let t=1;t<s.length;t++)e+=`${hn}${t-1}$$`+s[t];return e}const bt=new WeakMap;function gt(s){const e=bt.get(s);if(e)return e;const t=document.createElement("template");t.innerHTML=mn(s);const n=[],o=(l,d)=>{if(l.nodeType===Node.ELEMENT_NODE){const p=l;for(const f of Array.from(p.attributes)){const m=f.name,_=f.value,E=m[0];if(A.test(_))if(A.lastIndex=0,E==="@"){const g=A.exec(_);A.lastIndex=0,n.push({path:d,kind:"event",name:m.slice(1),valueIndex:g?Number(g[1]):0}),p.removeAttribute(m)}else if(E==="."){const g=A.exec(_);A.lastIndex=0,n.push({path:d,kind:"prop",name:m.slice(1),valueIndex:g?Number(g[1]):0}),p.removeAttribute(m)}else if(E==="?"){const g=A.exec(_);A.lastIndex=0,n.push({path:d,kind:"bool",name:m.slice(1),valueIndex:g?Number(g[1]):0}),p.removeAttribute(m)}else{const g=[],k=[];let b=0,y;for(A.lastIndex=0;(y=A.exec(_))!==null;)g.push(_.slice(b,y.index)),k.push(Number(y[1])),b=y.index+y[0].length;g.push(_.slice(b)),n.push({path:d,kind:"attr",name:m,template:g,valueIndices:k}),p.setAttribute(m,"")}}}const a=Array.from(l.childNodes);let c=0;for(let p=0;p<a.length;p++){const f=a[p],m=p+c;if(f.nodeType===Node.TEXT_NODE){const _=f.textContent||"";if(!A.test(_)){A.lastIndex=0;continue}A.lastIndex=0;const E=f.parentNode;let g=0,k;const b=[],y=[];for(A.lastIndex=0;(k=A.exec(_))!==null;){k.index>g&&b.push(document.createTextNode(_.slice(g,k.index)));const v=document.createTextNode("");b.push(v),y.push({path:[...d,m+b.length-1],kind:"node",valueIndex:Number(k[1])}),g=k.index+k[0].length}g<_.length&&b.push(document.createTextNode(_.slice(g)));for(const v of b)E.insertBefore(v,f);E.removeChild(f),c+=b.length-1,n.push(...y)}else o(f,[...d,m])}};o(t.content,[]);const r={template:t,buildParts:l=>{const d=[];for(const a of n){let c=l;for(const p of a.path)c=c.childNodes[p];a.kind==="node"?d.push({kind:"node",valueIndex:a.valueIndex,child:{anchor:c,state:null}}):a.kind==="attr"?d.push({kind:"attr",element:c,name:a.name,template:a.template,valueIndices:a.valueIndices}):a.kind==="event"?d.push({kind:"event",valueIndex:a.valueIndex,element:c,name:a.name}):a.kind==="prop"?d.push({kind:"prop",valueIndex:a.valueIndex,element:c,name:a.name}):a.kind==="bool"&&d.push({kind:"bool",valueIndex:a.valueIndex,element:c,name:a.name})}return d}};return bt.set(s,r),r}const yt=new WeakMap;function fn(s,e){const t=yt.get(e);if(t&&t.strings===s.strings){pe(t.parts,s.values);return}const n=gt(s.strings),o=n.template.content.cloneNode(!0),i=n.buildParts(o);for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(o),pe(i,s.values),yt.set(e,{strings:s.strings,parts:i})}function pe(s,e){for(const t of s)if(t.kind==="node")Te(t.child,e[t.valueIndex]);else if(t.kind==="attr"){let n=t.template[0];for(let o=0;o<t.valueIndices.length;o++)n+=kt(e[t.valueIndices[o]]),n+=t.template[o+1];n!==t.last&&(t.last=n,n===""?t.element.removeAttribute(t.name):t.element.setAttribute(t.name,n))}else if(t.kind==="event"){const n=e[t.valueIndex];n!==t.current&&(t.current&&t.element.removeEventListener(t.name,t.current),n&&t.element.addEventListener(t.name,n),t.current=n)}else if(t.kind==="prop"){const n=e[t.valueIndex];n!==t.last&&(t.last=n,t.element[t.name]=n)}else if(t.kind==="bool"){const n=!!e[t.valueIndex];n!==t.last&&(t.last=n,n?t.element.setAttribute(t.name,""):t.element.removeAttribute(t.name))}}function Te(s,e){if(e==null||e===!1){s.state&&(U(s.state),s.state=null);return}if(Array.isArray(e)){gn(s,e);return}if(pn(e)){bn(s,e);return}if(e instanceof Node){wn(s,e);return}_n(s,kt(e))}function wn(s,e){const t=s.state;t?.shape==="node"&&t.node===e||(t&&U(t),he(s,[e]),s.state={shape:"node",node:e})}function _n(s,e){const t=s.state;if(t?.shape==="text"){t.text!==e&&(t.node.textContent=e,t.text=e);return}t&&U(t);const n=document.createTextNode(e);he(s,[n]),s.state={shape:"text",node:n,text:e}}function bn(s,e){const t=s.state;if(t?.shape==="template"&&t.strings===e.strings){pe(t.parts,e.values);return}t&&U(t);const n=gt(e.strings),o=n.template.content.cloneNode(!0),i=n.buildParts(o),r=Array.from(o.childNodes);he(s,[o]),pe(i,e.values),s.state={shape:"template",strings:e.strings,parts:i,nodes:r}}function gn(s,e){const t=s.state;if(t?.shape==="array"&&t.entries.length===e.length){for(let o=0;o<e.length;o++)Te(t.entries[o],e[o]);return}t&&U(t);const n=[];for(const o of e){const i=document.createTextNode("");he(s,[i]);const r={anchor:i,state:null};Te(r,o),n.push(r)}s.state={shape:"array",entries:n}}function he(s,e){const t=s.anchor.parentNode;if(t)for(const n of e)t.insertBefore(n,s.anchor)}function U(s){if(s.shape==="text"){s.node.remove();return}if(s.shape==="template"){for(const e of s.nodes)e.parentNode&&e.parentNode.removeChild(e);return}if(s.shape==="node"){s.node.parentNode&&s.node.parentNode.removeChild(s.node);return}for(const e of s.entries)e.state&&U(e.state),e.anchor.remove()}function kt(s){return s==null||s===!1?"":String(s)}const z=class z extends HTMLElement{constructor(){super(),this._renderScheduled=!1,this._propValues={},this.constructor.shadow?(this.attachShadow({mode:"open"}),this._renderRoot=this.shadowRoot):this._renderRoot=this,this._installPropAccessors()}static get observedAttributes(){return this.props.map(vt)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,t,n){if(t===n)return;const o=yn(e);this._propValues[o]=n,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(e){if(e==null){this.removeAttribute("class");return}const n=(Array.isArray(e)?e:String(e).split(/\s+/)).map(o=>String(o).trim()).filter(o=>o!=="");this.className=n.join(" ")}requestUpdate(){this._scheduleRender()}emit(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_installPropAccessors(){const e=this.constructor;for(const t of e.props){if(Object.getOwnPropertyDescriptor(this,t))continue;const n=vt(t);Object.defineProperty(this,t,{get:()=>t in this._propValues?this._propValues[t]:this.getAttribute(n),set:o=>{let i;o==null||o===!1?i=null:o===!0?i="":i=String(o),this._propValues[t]=i,i===null?this.removeAttribute(n):this.setAttribute(n,i),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&fn(this.render(),this._renderRoot)}))}_adoptStyles(){const e=this.constructor;if(e.styles.length!==0)if(e.shadow&&this.shadowRoot){const t=e.styles.map(n=>n.sheet).filter(n=>n!==null);if(this.shadowRoot.adoptedStyleSheets=t,t.length!==e.styles.length){for(const n of e.styles)if(!n.sheet){const o=document.createElement("style");o.textContent=n.cssText,this.shadowRoot.appendChild(o)}}}else this._adoptLightStyles(e)}_adoptLightStyles(e){if(!z._lightStylesAdopted.has(e)){z._lightStylesAdopted.add(e);for(const t of e.styles){const n=document.createElement("style");n.dataset.wpdUi=this.tagName.toLowerCase(),n.textContent=t.cssText,document.head.appendChild(n)}}}};z.props=[],z.styles=[],z.shadow=!0,z._lightStylesAdopted=new WeakSet;let H=z;function B(s,e){customElements.get(s)||customElements.define(s,e)}function vt(s){return s.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function yn(s){return s.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}const kn=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function q(s,...e){let t=s[0];for(let n=1;n<s.length;n++){const o=e[n-1];if(typeof o=="string"||typeof o=="number")t+=String(o);else if(o&&o.__wpdCss)t+=o.cssText;else throw new TypeError("[wpd-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof o);t+=s[n]}if(kn){const n=new CSSStyleSheet;return n.replaceSync(t),{__wpdCss:!0,sheet:n,cssText:t}}return{__wpdCss:!0,sheet:null,cssText:t}}const vn=q`:host{display:inline-flex}button{display:flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:none;border-radius:5px;background:transparent;color:var( --wpd-btn-color,currentColor );cursor:pointer;transition:background-color 0.15s ease,color 0.15s ease}button:hover{color:var( --wpd-btn-color-hover,currentColor );background:var( --wpd-btn-bg-hover,rgba( 0,0,0,0.06 ) )}button:focus-visible{color:var( --wpd-btn-color-hover,currentColor );background:var( --wpd-btn-bg-hover,rgba( 0,0,0,0.06 ) );outline:2px solid var( --wpd-btn-outline,currentColor );outline-offset:1px}:host( [ active ] ) button{color:var( --wpd-btn-color-hover,currentColor );background:var( --wpd-btn-bg-active,rgba( 0,0,0,0.08 ) )}:host( [ danger ] ) button:hover{color:#fff;background:var( --wpd-btn-danger-hover,#d63638 )}svg{display:block;pointer-events:none;flex-shrink:0}svg:empty{display:none}::slotted( span ){line-height:1}::slotted( svg ){display:block}`,En={minimize:'<path d="M3 6h6" stroke="currentColor" stroke-width="1.25" stroke-linecap="round"/>',maximize:'<rect x="3" y="3" width="6" height="6" rx="1" stroke="currentColor" stroke-width="1.25" fill="none"/>',fullscreen:'<path d="M4.5 2H2v2.5M10 4.5V2H7.5M4.5 10H2V7.5M10 7.5V10H7.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',"fullscreen-exit":'<path d="M2 4.5H4.5V2M7.5 2V4.5H10M2 7.5H4.5V10M7.5 10V7.5H10" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',detach:'<path d="M5 2H2.5v7.5H10V7M6.5 2H10v3.5M10 2L5.5 6.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',reload:'<g transform="translate(0.6 0.6) scale(0.021)" fill="currentColor"><path d="m504.554 233.704-76.447 91.467c-6.329 7.572-15.417 11.479-24.571 11.479a31.872 31.872 0 0 1-20.504-7.447l-91.467-76.447c-13.561-11.334-15.366-31.515-4.032-45.075s31.515-15.366 45.075-4.032l37.506 31.347c-10.274-74.891-74.668-132.774-152.337-132.774C132.984 102.223 64 171.207 64 256s68.984 153.777 153.777 153.777c17.673 0 32 14.327 32 32s-14.327 32-32 32c-58.17 0-112.859-22.653-153.991-63.785C22.653 368.859 0 314.17 0 256s22.653-112.859 63.786-153.992c41.132-41.132 95.821-63.785 153.991-63.785s112.859 22.653 153.992 63.785c32.517 32.516 53.471 73.508 60.829 117.991l22.849-27.339c11.334-13.56 31.515-15.364 45.075-4.032 13.56 11.335 15.365 31.516 4.032 45.076z"/></g>',close:'<path d="M3.25 3.25l5.5 5.5M3.25 8.75l5.5-5.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round"/>',menu:'<circle cx="3" cy="6" r="1.2" fill="currentColor"/><circle cx="6" cy="6" r="1.2" fill="currentColor"/><circle cx="9" cy="6" r="1.2" fill="currentColor"/>'},Y=class Y extends H{constructor(){super(...arguments),this._activateWired=!1}render(){const e=this.icon||"",t=En[e]||"";return O` |
|
1
|
+(function(){"use strict";function xe(){const e=window.wp?.hooks;if(!e)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 e}function Mt(e,t,n,o){xe().addAction(e,t,n,o)}function Pt(e,t){return xe().removeAction(e,t)}function T(e,t,...n){return xe().applyFilters(e,t,...n)}function m(e,...t){xe().doAction(e,...t)}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"},Po="os.activity.";function Ve(e){return Po+String(e).replace(/[^a-zA-Z0-9_.-]/g,".")}let $o=0;const Ke={publish(e,t){m(Ve(e),t)},subscribe(e,t){const n=`os/activity-sub/${++$o}`,o=Ve(e);Mt(o,n,s=>t(s));let i=!1;return()=>{i||(i=!0,Pt(o,n))}},filter(e,t,...n){return T(Ve(e),t,...n)}},$t="__openStationSharedStores";function zo(){const e=window;let t=e[$t];return t||(t=new Map,e[$t]=t),t}function k(e,t){const n=zo();let o=n.get(e);o||(o={state:t(),listeners:new Set,rebuild:t},n.set(e,o));const i={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(r){console.error(`[desktop-mode/shared-store:${e}] subscriber threw:`,r)}},subscribe(s){return o.listeners.add(s),()=>{o.listeners.delete(s)}},setState(s){const r=o.state;if(typeof r!="object"||r===null){console.warn(`[desktop-mode/shared-store:${e}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(r,s),i.notify()},reset(){const s=o.rebuild(),r=o.state;if(typeof r=="object"&&r!==null&&typeof s=="object"&&s!==null){const d=r;for(const a of Object.keys(d))delete d[a];Object.assign(d,s)}else o.state=s;o.listeners.clear()}};return i}const G=k("desktop-mode/window-channels",()=>({parentSubs:new Map,nativeSubs:new Map,readyWindows:new Set,loadingWindows:new Set,pendingSends:new Map}));function Te(e,t,n,o){let i=e.get(t);if(!i){if(!o)return;i=new Map,e.set(t,i)}let s=i.get(n);if(!s){if(!o)return;s=new Set,i.set(n,s)}return s}function zt(e,t,n,o){const i={channel:n,windowId:t},s=Te(e,t,n,!1);if(s)for(const d of Array.from(s))try{d(o,i)}catch(a){typeof console<"u"&&console.error(`[openstation] window-channel subscriber for "${n}" threw:`,a)}const r=Te(e,t,"*",!1);if(r)for(const d of Array.from(r))try{d(o,i)}catch(a){typeof console<"u"&&console.error(`[openstation] window-channel wildcard subscriber for "${t}" threw:`,a)}}function Ho(e,t,n){const o=Te(G.state.parentSubs,e,t,!0);o.add(n);let i=!1;return()=>{i||(i=!0,o.delete(n))}}function Ht(e,t,n){zt(G.state.parentSubs,e,t,n)}function Fo(e,t,n){const o=Te(G.state.nativeSubs,e,t,!0);o.add(n);let i=!1;return()=>{i||(i=!0,o.delete(n))}}function Uo(e,t,n){zt(G.state.nativeSubs,e,t,n)}function Ft(e){return G.state.readyWindows.has(e)}function Ie(e){const{loadingWindows:t}=G.state;t.has(e)||(t.add(e),m(f.WINDOW_CONTENT_LOADING,{windowId:e}),typeof document<"u"&&document.dispatchEvent(new CustomEvent("os-window-content-loading",{detail:{windowId:e}})))}function $(e){const{readyWindows:t,loadingWindows:n,pendingSends:o}=G.state;if(!t.has(e)){t.add(e);const i=o.get(e);if(i){o.delete(e);for(const s of i)try{s.flush()}catch(r){typeof console<"u"&&console.error(`[openstation] flushing queued window-send for "${s.channel}" threw:`,r)}}}n.delete(e)&&(m(f.WINDOW_CONTENT_LOADED,{windowId:e}),typeof document<"u"&&document.dispatchEvent(new CustomEvent("os-window-content-loaded",{detail:{windowId:e}})))}function Go(e,t,n,o){const{pendingSends:i}=G.state;let s=i.get(e);s||(s=[],i.set(e,s)),s.push({channel:t,payload:n,flush:o})}function Bo(e){const t=G.state;t.parentSubs.delete(e),t.nativeSubs.delete(e),t.readyWindows.delete(e),t.loadingWindows.delete(e),t.pendingSends.delete(e)}const qo=k("desktop-mode/connection",()=>({connSeq:0,connections:new Map,connectionsByTarget:new Map,syntheticIframes:new Map}));function Vo(e){return qo.state.syntheticIframes.get(e)??null}const Ko="data-os-mode";function Ut(e=typeof document<"u"?document.documentElement:null){return!!e&&e.getAttribute(Ko)==="mobile"}const jo=Object.freeze({top:0,right:0,bottom:0,left:0});function Yo(e,t,n){return{x:n.left,y:n.top,width:Math.max(0,e-n.left-n.right),height:Math.max(0,t-n.top-n.bottom)}}const Xo="os/work-area";function Zo(){return{insets:{...jo},rect:{x:0,y:0,width:0,height:0},viewport:{x:0,y:0,width:0,height:0},area:{width:0,height:0}}}const je=k(Xo,()=>({snapshot:Zo(),installed:!1,areaEl:null}));function Ye(e){const t=e??je.state.areaEl;if(!t)return{...je.state.snapshot.rect};const n=t.clientWidth||t.getBoundingClientRect().width,o=t.clientHeight||t.getBoundingClientRect().height;return Yo(n,o,je.state.snapshot.insets)}const Qo="desktop-mode";function Gt(){return window.wp?.i18n}function _(e,t=Qo){return Gt()?.__(e,t)??e}function ie(e,...t){const n=Gt()?.sprintf;if(n)return n(e,...t);let o=0;return e.replace(/%(?:(\d+)\$)?[sd]/g,(i,s)=>{const r=s?Number.parseInt(s,10)-1:o++;return String(t[r]??"")})}const Jo="openstation";function ei(e,t){let n;if(typeof e=="string")try{n=new URL(e,t??(typeof window<"u"?window.location.href:void 0))}catch{return!1}else n=e;return n.pathname.slice(n.pathname.lastIndexOf("/")+1)==="admin.php"&&n.searchParams.get("page")===Jo}const Bt="os_tab",ti=k("desktop-mode/native-url-remap",()=>({remaps:[],deps:null}));function Xe(e,t={}){const{deps:n,remaps:o}=ti.state;if(!n||!e)return!1;let i;try{i=new URL(e,n.adminUrl)}catch{return!1}const s=n.getSnapshot();for(const r of o){if(!r.matches(e,i)||r.enabled&&!r.enabled(s))continue;if(r.onMatch)try{r.onMatch(e,i)}catch(u){console.warn(`[openstation] URL remap onMatch hook threw for "${r.id}":`,u)}let d;const a=i.searchParams.get(Bt);if(r.params)try{d=r.params(e,i)??void 0}catch(u){console.warn(`[openstation] URL remap params hook threw for "${r.id}":`,u)}a&&/^[a-z0-9_-]+$/.test(a)&&(d={...d??{},tab:a});const c=t.newInstance&&n.openNewById?n.openNewById:n.openById;if(d?c(r.nativeWindowId,{params:d}):c(r.nativeWindowId))return!0}return!1}const ni="os-window-tab-change";function Ze(e){return Array.from(e.querySelectorAll(".os-window__tab"))}function qt(e){return e.replace(/[^a-zA-Z0-9_-]/g,"-")}function Vt(e,t){return`${e.id||"os-window"}-tab-${qt(t)}`}function Kt(e,t){return`${e.id||"os-window"}-panel-${qt(t)}`}function jt(e){const t=e.querySelector(".os-window__tab-plate");if(!t)return;const n=e.querySelector(".os-window__tab--active");if(!n){t.dataset.empty="",e.dataset.tabPlateEmpty="";return}delete t.dataset.empty,delete e.dataset.tabPlateEmpty,e.style.setProperty("--_tab-plate-x",`${n.offsetLeft}px`),e.style.setProperty("--_tab-plate-w",`${n.offsetWidth}px`),e.style.setProperty("--_tab-strip-w",`${e.clientWidth}px`),n.offsetWidth>0&&(t.dataset.placed="")}function le(e){if(e){if(e.querySelector(":scope > .os-window__tab")){e.setAttribute("role","tablist");const t=e.dataset.tablistLabel;t&&e.setAttribute("aria-label",t);return}e.setAttribute("role","presentation"),e.removeAttribute("aria-label")}}function Yt(e){const t=Ze(e);if(t.length===0)return;const n=t.find(o=>o.classList.contains("os-window__tab--active"))??t[0];for(const o of t){const i=o===n?0:-1;o.tabIndex!==i&&(o.tabIndex=i)}}function oi(e,t){const n=t;if(n.altKey||n.ctrlKey||n.metaKey)return;const i=n.target?.closest(".os-window__tab");if(!i)return;const s=Ze(e),r=s.indexOf(i);if(r<0)return;const d=getComputedStyle(e).direction==="rtl";let a;switch(n.key){case"ArrowRight":a=s[d?r-1:r+1];break;case"ArrowLeft":a=s[d?r+1:r-1];break;case"Home":a=s[0];break;case"End":a=s[s.length-1];break;default:return}!a||a===i||(n.preventDefault(),i.tabIndex=-1,a.tabIndex=0,a.focus(),a.scrollIntoView?.({block:"nearest",inline:"nearest"}))}function Xt(e){const t=new Map;for(const n of Ze(e))n.dataset.kind==="panel"&&n.dataset.panel&&t.set(n.dataset.panel,n);return t}function Zt(e){const t=e.querySelector(".os-window__body");return t?Array.from(t.querySelectorAll("os-tabpanel[ for ]")).filter(n=>!n.parentElement?.closest("os-tabpanel, os-tabs")):[]}function Qe(e,t){const n=e.querySelector(".os-window__tabs");if(!n)return;let o=!1;for(const[i,s]of Xt(n)){const r=i===t;o=o||r,s.classList.toggle("os-window__tab--active",r),s.setAttribute("aria-selected",r?"true":"false")}if(o){for(const i of Zt(e)){const s=i.getAttribute("for")===t;i.toggleAttribute("hidden",!s),i.setAttribute("aria-hidden",s?"false":"true")}Yt(n),jt(n),e.dispatchEvent(new CustomEvent(ni,{bubbles:!0,detail:{value:t}}))}}function ii(e,t,n){const o=e.querySelector(".os-window__tabs");if(!o)return;const i=Xt(o),s=Array.from(i.entries()).find(([,l])=>l.classList.contains("os-window__tab--active"))?.[0];let r=o.querySelector(".os-window__tab-plate");for(const l of t){let u=i.get(l.value);if(u)i.delete(l.value);else{const p=document.createElement("button");p.type="button",u=p,u.className="os-window__tab",u.dataset.kind="panel",u.dataset.panel=l.value,u.setAttribute("role","tab"),u.setAttribute("aria-selected","false"),u.tabIndex=-1}u.textContent!==l.label&&(u.textContent=l.label),u.id=Vt(e,l.value),u.setAttribute("aria-controls",Kt(e,l.value)),u.previousElementSibling!==r&&o.insertBefore(u,r?r.nextSibling:o.firstChild),r=u}for(const l of i.values())l.remove();le(o);const d=o.querySelector(":scope > .os-window__tab")!==null;for(const l of Zt(e)){const u=l.getAttribute("for");u&&(l.id=Kt(e,u),d?l.setAttribute("aria-labelledby",Vt(e,u)):l.removeAttribute("aria-labelledby"))}const a=l=>l!==void 0&&t.some(u=>u.value===l),c=[n,s,t[0]?.value].find(a);c!==void 0&&Qe(e,c)}let si=0;function ri(e,t={}){const n=++si,o=l=>`desktop-mode/native-render-ctx/${e}/${n}/${l}`,i=new AbortController,s=[],r=(l,u,p,g)=>{const b=o(u);Mt(l,b,w=>{p(w)&&g(w)});const y=()=>{Pt(l,b)};return s.push(y),y},d=l=>!!l&&typeof l=="object"&&l.windowId===e;return{ctx:{window:{send(l,u){typeof l!="string"||l===""||Ht(e,l,u)},on(l,u){return typeof l!="string"||l===""||typeof u!="function"?()=>{}:Fo(e,l,u)},markLoading(){Ie(e)},markReady(){$(e)}},markLoading(){Ie(e)},markReady(){$(e)},signal:i.signal,onResize(l){return typeof l!="function"?()=>{}:r(f.WINDOW_BODY_RESIZED,"on-resize",d,u=>{const{width:p,height:g}=u;try{l(p,g)}catch(b){m(f.SHELL_ERROR,{scope:"native-render-ctx/onResize",id:e,error:b})}})},onHide(l){return typeof l!="function"?()=>{}:r(f.WINDOW_MINIMIZED,"on-hide",d,()=>{try{l()}catch(u){m(f.SHELL_ERROR,{scope:"native-render-ctx/onHide",id:e,error:u})}})},onShow(l){return typeof l!="function"?()=>{}:r(f.WINDOW_RESTORED,"on-show",d,()=>{try{l()}catch(u){m(f.SHELL_ERROR,{scope:"native-render-ctx/onShow",id:e,error:u})}})},params:t},dispose:()=>{try{i.abort()}catch{}for(;s.length;){const l=s.pop();try{l?.()}catch{}}}}}const Qt=["post_type","page","taxonomy","path","post","c","tag_ID","item","p"].filter(e=>e!=="p"),Je=[];function ai(e){if(!e.pathname.endsWith("/admin.php")||!e.searchParams.get("page"))return Je;const t=e.searchParams.get("action");return t==="edit"&&e.searchParams.get("id")?["id"]:t==="new"?["action"]:Je}function Jt(e){try{const t=new URL(e,window.location.origin),n=new URLSearchParams,o=[...Qt,...ai(t)];for(const s of o){const r=t.searchParams.get(s);r?n.set(s,r):s==="post_type"&&(t.pathname.endsWith("/edit.php")||t.pathname.endsWith("/post-new.php"))&&n.set(s,"post")}n.sort();const i=n.toString();return t.pathname.replace(/\/+$/,"")+(i?`?${i}`:"")}catch{return e}}function Y(e){try{const t=new URL(e,window.location.origin);return t.searchParams.delete("openstation_chromeless"),t.searchParams.delete("desktop_mode_portal"),t.pathname.replace(/\/+$/,"")+"?"+t.searchParams.toString()}catch{return e}}const en="X-WP-Nonce";function li(e,t){const n=ci();if(!n)return t;const o=di(e);if(!o||!ui(o))return t;const i=t?.headers??(typeof Request<"u"&&e instanceof Request?e.headers:void 0),s=new Headers(i??{});return s.has(en)?t:(s.set(en,n),{...t??{},headers:s})}function ci(){if(typeof window>"u")return;const t=window.openStationConfig?.restNonce;return typeof t=="string"&&t.length>0?t:void 0}function di(e){try{const t=typeof window<"u"&&window.location?window.location.href:void 0;return typeof e=="string"?new URL(e,t):e instanceof URL?e:typeof Request<"u"&&e instanceof Request?new URL(e.url,t):null}catch{return null}}function ui(e){return typeof window>"u"||!window.location||e.origin!==window.location.origin?!1:!!(e.pathname.includes("/wp-json/")||e.searchParams.has("rest_route"))}function hi(e,t,n={}){const o=window.wp?.os?.fetch;if(typeof o=="function")return o(e,t,n);const i=li(e,t);return fetch(e,i)}const tn=k("desktop-mode/dock-rail-registry",()=>({registry:new Map,listeners:new Set,activeId:"default"}));tn.state.registry,tn.state.listeners;function fi(e,t){if(!e||typeof e!="object")return["def (not an object)"];const n=e,o=[];for(const i of t)i.valid(n)||o.push(`${i.field} (${i.message})`);return o}class pi extends Error{constructor(t,n,o){super(`[openstation] ${t} registration rejected — fields: `+n.join(", ")+"."),this.name="RegistrationError",this.kind=t,this.errors=n,this.def=o}}function et(e,t,n){if(t.length!==0)throw new pi(e,t,n)}function nn(e,t,n){typeof console>"u"||console.warn(`[openstation] ${e} registration rejected — fields: `+t.join(", ")+".",n)}const X=[[0,0],[100,0],[100,100],[0,100]],mi=48,gi=80,tt=6,nt=8,on=4,sn=3,rn=64,ot=105,Z=2;function an(e){return`${Math.round(e*1e3)/1e3}%`}function Q(e){return e.slice().reverse()}function ce(e,t,n,o){return[[e,t],[n,t],[n,o],[e,o]]}function _i(e,t,n,o){const i=[];for(let s=0;s<o;s++){const r=s/o*Math.PI*2;i.push([e+Math.cos(r)*n,t+Math.sin(r)*n])}return i}function z(e,t=[]){const n=[],o=i=>{n.push(`${an(i[0])} ${an(i[1])}`)};for(const i of e)o(i);if(t.length>0){o(e[0]);for(const i of t){for(const s of i)o(s);o(i[0]),o(e[0])}}return`polygon( ${n.join(", ")} )`}function ln(e){return z(X,[Q(_i(50,50,e,mi))])}function cn(e){return z(X,[Q(ce(50-e,-Z,50+e,100+Z))])}function dn(e){const t=100/tt,n=[];for(let o=0;o<tt;o++){const i=o*t;n.push(Q(ce(-Z,i,100+Z,i+e)))}return z(X,n)}function un(e){return z(X,[Q(ce(-Z,50-e,100+Z,50+e))])}function hn(e){const t=100/nt,n=[];for(let o=0;o<nt;o++){const i=o*t;n.push(Q(ce(i,-Z,i+e,100+Z)))}return z(X,n)}function fn(e){return z(X,[Q([[50,50-e],[50+e,50],[50,50+e],[50-e,50]])])}function pn(e){const t=100/on,n=100/sn,o=[];for(let i=0;i<sn;i++)for(let s=0;s<on;s++){const r=s*t+t/2,d=i*n+n/2,a=t/2*e,c=n/2*e;o.push(Q(ce(r-a,d-c,r+a,d+c)))}return z(X,o)}function mn(e){const t=-Math.PI/2,n=e/180*Math.PI,o=[[50,50]];for(let i=0;i<rn;i++){const s=t+i/(rn-1)*n;o.push([50+Math.cos(s)*ot,50+Math.sin(s)*ot])}return z(X,[Q(o)])}function bi(){return{from:ln(0),to:ln(gi)}}function wi(){return{from:cn(0),to:cn(52)}}function yi(){return{from:dn(0),to:dn(100/tt+.5)}}function vi(){return{from:un(0),to:un(52)}}function Ei(){return{from:hn(0),to:hn(100/nt+.5)}}function Ai(){return{from:fn(0),to:fn(ot)}}function Si(){return{from:pn(0),to:pn(1.04)}}function Ci(){return{from:mn(0),to:mn(360)}}function ki(){return{from:"inset( 0% 0% 0% 0% )",to:"inset( 0% 0% 100% 0% )"}}function xi(){return{from:"inset( 0% 0% 0% 0% )",to:"inset( 0% 0% 0% 100% )"}}function Ti(){return{from:z([[-60,0],[100,0],[100,100],[0,100]]),to:z([[100,0],[260,0],[260,100],[160,100]])}}const it=6,st=100,se=st/2,Le=200,gn=90,_n=["#5c5c6d","#525261","#484855","#3e3e49","#34343d","#2a2a31"],Ii="#101014",Li=1.25,re="http://www.w3.org/2000/svg";let Ni=0;function Ne(e){return Math.round(e*1e3)/1e3}function rt(e){return e/it*Math.PI*2-Math.PI/2}function Ri(e){const n=rt(e)+Math.PI/it+Math.PI/2;return{x:Math.cos(n),y:Math.sin(n)}}function Oi(e){const t=rt(e),n=rt(e+1);return[[se,se],[se+Math.cos(t)*Le,se+Math.sin(t)*Le],[se+Math.cos(n)*Le,se+Math.sin(n)*Le]]}function bn(e,t){const n=Oi(e),o=document.createElementNS(re,"path");return o.setAttribute("d",`M ${n.map(([i,s])=>`${Ne(i)} ${Ne(s)}`).join(" L ")} Z`),t?o.setAttribute("fill","#fff"):(o.setAttribute("fill",_n[e%_n.length]),o.setAttribute("stroke",Ii),o.setAttribute("stroke-width",String(Li)),o.setAttribute("vector-effect","non-scaling-stroke"),o.setAttribute("stroke-linejoin","round")),o}function Di(){const e=`os-iris-${++Ni}`,t=document.createElementNS(re,"svg");t.setAttribute("viewBox",`0 0 ${st} ${st}`),t.setAttribute("preserveAspectRatio","none"),t.setAttribute("aria-hidden","true"),t.style.width="100%",t.style.height="100%",t.style.display="block";const n=document.createElementNS(re,"defs"),o=document.createElementNS(re,"mask");o.setAttribute("id",e);const i=document.createElementNS(re,"g"),s=document.createElementNS(re,"g");s.setAttribute("mask",`url(#${e})`);const r=[];for(let a=0;a<it;a++){const c=bn(a,!0),l=bn(a,!1);i.appendChild(c),s.appendChild(l),r.push({el:c,index:a},{el:l,index:a})}o.appendChild(i),n.appendChild(o),t.appendChild(n),t.appendChild(s);const d=document.createElement("div");return d.appendChild(t),{element:d,play:a=>r.map(({el:c,index:l})=>{const u=Ri(l),p=Ne(u.x*gn),g=Ne(u.y*gn);return c.animate([{transform:"translate( 0px, 0px )"},{transform:`translate( ${p}px, ${g}px )`}],{duration:a.duration,easing:a.easing,delay:a.delay,fill:"both"})})}}const at="none",Wi=70,Mi=600,wn=k("desktop-mode/window-reveal-registry",()=>({registry:new Map,listeners:new Set})),yn=wn.state.registry,Pi=wn.state.listeners,vn=/^[a-z0-9_/-]+$/;function En(e){const t=/^\s*([a-zA-Z-]+)\s*\(/.exec(e);return t?t[1].toLowerCase():""}const $i=0;function zi(e){return typeof e!="number"||!Number.isFinite(e)?Wi:Math.min(Mi,Math.max(0,e))}function Hi(e){return typeof e.render=="function"?[]:Array.isArray(e.layers)&&e.layers.length>0?e.layers:typeof e.from=="string"&&typeof e.to=="string"?[{from:e.from,to:e.to}]:[]}function An(e,t){const n=[],o=typeof e.from=="string"&&e.from.trim()!=="",i=typeof e.to=="string"&&e.to.trim()!=="";if(o||n.push(`${t}.from (missing — the clip-path covering the window)`),i||n.push(`${t}.to (missing — the clip-path uncovering the window)`),o&&i){const s=En(e.from),r=En(e.to);s===""||r===""?n.push(`${t}.from|to (must be shape functions, e.g. \`inset( … )\` or \`polygon( … )\` — bare keywords like \`none\` cannot be animated)`):s!==r&&n.push(`${t}.from|to (must use the same shape function to interpolate — got \`${s}()\` and \`${r}()\`)`)}return n}function Fi(e){if(typeof KeyframeEffect!="function")return!0;try{return new KeyframeEffect(null,null,{easing:e}),!0}catch{return!1}}function W(e){const t=[];if(!e||typeof e!="object")t.push("def (not an object)");else{typeof e.id!="string"||e.id.trim()===""?t.push("id (missing)"):vn.test(e.id.trim().toLowerCase())?e.id.trim().toLowerCase()===at&&t.push('id ("none" is reserved)'):t.push(`id (must match ${vn} — lowercase alphanum, hyphens, underscores, slashes for vendor/sub-id)`),(typeof e.label!="string"||e.label.trim()==="")&&t.push("label (missing)");const o=e.render!==void 0,i=Array.isArray(e.layers),s=e.from!==void 0||e.to!==void 0;o&&typeof e.render!="function"?t.push("render (not a function)"):o&&(i||s)?t.push("render|layers|from|to (supply exactly one of: a from/to pair, a layers array, or a render function)"):o||(i&&s?t.push("layers|from|to (supply EITHER a single from/to pair OR a layers array, not both)"):i?(e.layers.length===0&&t.push("layers (empty — supply at least one matched pair)"),e.layers.forEach((r,d)=>{if(!r||typeof r!="object"){t.push(`layers[ ${d} ] (not an object)`);return}t.push(...An(r,`layers[ ${d} ]`))})):t.push(...An(e,"").map(r=>r.replace(/^\./,"")))),e.easing!==void 0&&(typeof e.easing!="string"||e.easing.trim()===""?t.push("easing (not a non-empty string)"):Fi(e.easing)||t.push("easing (not an easing the browser can parse — `Element.animate()` would throw at play time, with the covering surface already over the window)"))}et("WindowReveal",t,e);const n=e.id.trim().toLowerCase();yn.set(n,{...e,id:n}),Bi()}function Ui(){const e=Array.from(yn.values()),t=T(f.WINDOW_REVEALS,e);return Array.isArray(t)?t:(typeof console<"u"&&console.warn("[openstation] `os.window-reveals` filter returned a non-array; falling back to registry list."),e)}function Gi(e){return Ui().find(t=>t.id===e)}function Bi(){const e=Array.from(Pi);for(const t of e)try{t()}catch(n){typeof console<"u"&&console.error("[openstation] window-reveal registry listener threw:",n)}}W({id:"sweep",label:_("Sweep"),description:_("A straight edge travels across the window, uncovering the page behind it."),...xi(),duration:420}),W({id:"iris",label:_("Iris"),description:_("The page opens out from the centre of the window, like a camera shutter."),...bi(),duration:520}),W({id:"curtain",label:_("Curtain"),description:_("Two panels part from the middle of the window and slide off the sides."),...wi(),duration:480}),W({id:"blinds",label:_("Blinds"),description:_("Six horizontal slats retract at once, letting the page through between them."),...yi(),duration:560}),W({id:"diagonal",label:_("Diagonal"),description:_("A slanted edge sweeps off the trailing corner of the window."),...Ti(),duration:460}),W({id:"rise",label:_("Rise"),description:_("The page rises into the window from the bottom edge upward."),...ki(),duration:440}),W({id:"shutter",label:_("Shutter"),description:_("Two panels part from the middle of the window and slide off the top and bottom."),...vi(),duration:480}),W({id:"slats",label:_("Slats"),description:_("Eight vertical slats retract at once, letting the page through between them."),...Ei(),duration:560}),W({id:"diamond",label:_("Diamond"),description:_("The page opens out from the centre of the window through a growing rhombus."),...Ai(),duration:520}),W({id:"mosaic",label:_("Mosaic"),description:_("The page arrives as a grid of tiles, each opening out from its own centre."),...Si(),duration:600}),W({id:"obturator",label:_("Camera shutter"),description:_("Six wedges slide aside in unison, opening a hexagonal aperture from the centre like the iris of a camera lens."),render:Di,duration:720,edgeLag:0}),W({id:"radar",label:_("Radar"),description:_("A spoke sweeps a full turn around the centre of the window, uncovering the page behind it."),...Ci(),duration:760});const Sn={dockSize:["compact","default","large"],desktopLayout:["classic","unified"],dockPlacement:["bottom","left","right"],windowRadius:["sharp","default","round"],adminBarMode:["static","dynamic","hidden"]},Cn=["dockRailRenderer","windowReveal","accent"],kn={windowRevealDuration:{min:80,max:4e3}},qi=/^[a-z0-9_-]+$/;[...Object.keys(Sn),...Cn,...Object.keys(kn)];function Vi(e){if(!e||typeof e!="object"||Array.isArray(e))return{};const t=e,n={},o={};for(const[i,s]of Object.entries(Sn)){const r=t[i];typeof r=="string"&&s.includes(r)&&(n[i]=r)}for(const i of Cn){const s=t[i];typeof s=="string"&&qi.test(s)&&(n[i]=s)}for(const[i,s]of Object.entries(kn)){const r=t[i];typeof r=="number"&&Number.isFinite(r)&&(o[i]=Math.min(s.max,Math.max(s.min,Math.round(r))))}return{...n,...o}}const Ki=/^[a-z0-9_-]+$/,xn=128;function ji(e){return typeof e!="string"||e===""||e.length>2048?!1:e.startsWith("dashicons-")||e.startsWith("https://")||e.startsWith("http://")||e.startsWith("data:image/")}function Yi(e){if(!e||typeof e!="object")return null;const t=e,n=typeof t.slug=="string"?t.slug:"";if(!Ki.test(n))return null;const o={};if(t.icons&&typeof t.icons=="object"){let a=0;for(const[c,l]of Object.entries(t.icons)){if(a>=xn)break;c===""||!ji(l)||(o[c]=l,a+=1)}}const i={};if(t.tokens&&typeof t.tokens=="object")for(const[a,c]of Object.entries(t.tokens))typeof c=="string"&&(i[a]=c);const s=[];if(Array.isArray(t.fonts))for(const a of t.fonts)typeof a=="string"&&a!==""&&s.push(a);const r={};if(t.iconColors&&typeof t.iconColors=="object"){let a=0;for(const[c,l]of Object.entries(t.iconColors)){if(a>=xn)break;c===""||typeof l!="string"||l===""||(r[c]=l,a+=1)}}const d=a=>typeof t[a]=="string"?t[a]:"";return{id:d("id")||n,slug:n,name:d("name")||n,version:d("version"),author:d("author"),description:d("description"),previewUrl:d("previewUrl"),cssUrl:d("cssUrl"),cssText:d("cssText"),tokens:i,fonts:s,icons:o,iconColors:r,recommendedOsSettings:Vi(t.recommendedOsSettings),installedAt:typeof t.installedAt=="number"?t.installedAt:0,source:t.source==="code"?"code":"upload",cssDeferred:t.cssDeferred===!0}}function Xi(){const t=window.openStationConfig?.serverDesktopThemes,n=[];if(Array.isArray(t))for(const o of t){const i=Yi(o);i&&n.push(i)}return{themes:n,activeId:null,activeIcons:null,activeIconColors:null}}const Zi=k("desktop-mode/desktop-themes",Xi);function Tn(){return Zi}function In(e){const t=Tn().state;if(t.activeIcons===null||!e)return null;const n=t.activeIcons[e];if(typeof n!="string"||n==="")return null;const o=T(f.DESKTOP_THEME_ICON,n,{slot:e,themeId:t.activeId??""});return typeof o=="string"&&o!==""?o:null}function Ln(e){const t=Tn().state;if(t.activeIconColors===null||!e)return null;const n=t.activeIconColors[e];if(typeof n!="string"||n==="")return null;const o=T(f.DESKTOP_THEME_ICON_COLOR,n,{slot:e,themeId:t.activeId??""});return typeof o=="string"&&o!==""?Qi(o):null}function Qi(e){const t=e.trim();if(t===""||t.length>64||/[;{}<>"'\\]/.test(t))return null;let n=0;for(const o of t)if(o==="(")n+=1;else if(o===")"&&(n-=1,n<0))return null;return n===0?t:null}const de={OS_SETTINGS:"OS_SETTINGS",RECYCLE_BIN:"RECYCLE_BIN",BUG_REPORT:"BUG_REPORT",EXIT_OPENSTATION:"EXIT_OPENSTATION",PWA_INSTALL:"PWA_INSTALL"},Ji={"desktop-mode-os-settings":de.OS_SETTINGS,"desktop-mode-recycle-bin":de.RECYCLE_BIN,"desktop-mode-bug-report":de.BUG_REPORT,"os-exit":de.EXIT_OPENSTATION,"os-pwa-install":de.PWA_INSTALL};function es(e){if(typeof e!="string"||e==="")return"";const t=Ji[e];if(t)return t;const n=e.toLowerCase().replace(/[^a-z0-9_-]/g,"");return n===""?"":`APP:${n}`}function ts(e){if(typeof e!="string"||e==="")return"";const t=e.replace(/^core\//,"").toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"");return t===""?"":`WINDOW_CONTROL_${t}`}function lt(e,t){const n=ts(t),o=In(n),i=Ln(n);if(o===null&&i===null)return!1;if(i!==null?e.style.setProperty("--os-ui-btn-icon-color",i):e.style.removeProperty("--os-ui-btn-icon-color"),o===null)return e.style.setProperty("color",i),!1;if(o.startsWith("dashicons-")){e.removeAttribute("icon-src"),e.removeAttribute("icon");const s=document.createElement("span");return s.className=`dashicons ${o}`,s.setAttribute("aria-hidden","true"),i!==null&&(s.style.color=i),e.appendChild(s),!0}return e.setAttribute("icon-src",o),!0}let ct=null;function Re(){return!!window.openStationShellOverlays}function ns(e){return new Promise((t,n)=>{const o=document.querySelector('script[data-os-shell-overlays="1"]'),i=()=>{if(Re()){t();return}n(new Error("[openstation] shell-overlays bundle loaded but did not set `window.openStationShellOverlays`."))};if(o){Re()?i():(o.addEventListener("load",i),o.addEventListener("error",()=>n(new Error("failed to load shell-overlays bundle"))));return}const s=document.createElement("script");s.src=e,s.async=!0,s.dataset.osShellOverlays="1",s.addEventListener("load",i),s.addEventListener("error",()=>n(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(s)})}function os(e){return Re()||!e?Promise.resolve():(ct||(ct=ns(e)),ct)}function is(){return window.openStationConfig?.shellOverlaysBundleUrl??""}function ss(e,t){const n=is();if(Re()||!n){t();return}os(n).then(()=>{e()&&t()}).catch(o=>{typeof console<"u"&&console.warn("[openstation] shell-overlays failed to load; menu/dialog suppressed:",o)})}const rs=4e3,as=200,ls=1200;function dt(e){const t=Ke.filter("os/toast-requested",{...e});if(!t||t.cancel===!0)return()=>{};let n=!1,o=null;return ss(()=>!n,()=>{o=us(t)}),()=>{n=!0,o&&o()}}const cs={success:"positive",warning:"warning",error:"critical","shell-error":"critical"};function ds(e){return e?window.openStationConfig?.toastTypes?.find(o=>o.id===e)?.tone??cs[e]??null:null}function us(e){const t=ms(),n=document.createElement("os-toast");n.textContent=e.message;const o=ds(e.type);o&&n.setAttribute("tone",o),e.action&&(n.setAttribute("action",e.action.label),n.addEventListener("os-toast-action",()=>{e.action?.onClick(),c()})),e.dismissible&&(n.setAttribute("dismissible",""),n.addEventListener("os-toast-dismiss",()=>{e.onDismiss?.(),c()})),t.appendChild(n);let i=!1,s=null,r=e.duration??rs,d=0;const a=()=>{s!==null&&(window.clearTimeout(s),s=null)},c=()=>{i||(i=!0,a(),ps(n),n.setAttribute("state","out"),window.setTimeout(()=>{n.remove(),fs()},as))},l=()=>{i||e.persistent||s!==null||(d=Date.now(),s=window.setTimeout(c,r))},u=()=>{s!==null&&(r=Math.max(0,r-(Date.now()-d)),a())};return requestAnimationFrame(()=>{n.setAttribute("state","in")}),n.addEventListener("os-toast-hold",p=>{if(p.detail?.held){u();return}r=Math.max(r,ls),l()}),hs(n),l(),Ke.publish("os/toast-shown",{...e}),c}let Oe=null,ue=0;function Nn(e){const t=e.target;t instanceof HTMLElement&&(t.closest("os-toast-container")||(Oe=t))}function hs(e){ue===0&&document.addEventListener("focusin",Nn,!0),ue+=1;const t=e.ownerDocument,n=t.activeElement;n instanceof HTMLElement&&n!==t.body&&!n.closest("os-toast-container")&&(Oe=n)}function fs(){ue=Math.max(0,ue-1),ue===0&&document.removeEventListener("focusin",Nn,!0)}function ps(e){const t=e.ownerDocument.activeElement;t!==e&&!e.contains(t)||Oe?.isConnected===!0&&Oe.focus()}function ms(){const e=document.querySelector("os-toast-container");if(e)return e;const t=document.createElement("os-toast-container");return document.body.appendChild(t),t}const gs="http://localhost/";function _s(e,t){const n=typeof window<"u"&&window.location?window.location.href:gs,o=new URL(e,n),i=t.replace(/^\/+/,""),s=i.indexOf("?"),r=s===-1?i:i.slice(0,s),d=s===-1?"":i.slice(s+1);if(o.searchParams.has("rest_route")){const a=o.searchParams.get("rest_route")??"/",c=a.endsWith("/")?a:a+"/";o.searchParams.set("rest_route",c+r)}else{const a=o.pathname.endsWith("/")?o.pathname:o.pathname+"/";o.pathname=a+r}return d&&new URLSearchParams(d).forEach((c,l)=>{o.searchParams.append(l,c)}),o.toString()}`${btoa('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="6" stroke-linejoin="round"><rect x="6" y="6" width="27" height="27" rx="5"/><rect x="43" y="6" width="15" height="15" rx="5"/><rect x="43" y="31" width="15" height="27" rx="5"/><rect x="6" y="43" width="27" height="15" rx="5"/></svg>')}`,`${btoa('<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" fill="none" stroke="currentColor" stroke-width="6" stroke-linecap="round"><path d="M10 22h44M10 42h44"/><circle cx="24" cy="22" r="7" fill="currentColor" stroke="none"/><circle cx="42" cy="42" r="7" fill="currentColor" stroke="none"/></svg>')}`;function bs(e){try{(window.top??window).location.assign(e)}catch{window.location.assign(e)}}const Rn=800;function ws(e,t=Rn){window.setTimeout(()=>{if(e){bs(e);return}try{(window.top??window).location.reload()}catch{window.location.reload()}},t)}const ys="desktop-mode/v1",vs=3e4,Es=3,he=k("desktop-mode/plugin-presence",()=>({confirmInFlight:!1,lastConfirmAt:null,exiting:!1,booted:!1,negativeConfirms:0}));function ut(){return window.wp?.os?.config??{}}function As(){const e=ut().adminUrl||"/wp-admin/";let t;try{t=new URL(e,window.location.href).pathname}catch{t="/wp-admin/"}return t.endsWith("/")?t:`${t}/`}function Ss(){const e=ut().restUrl;return e?_s(e,ys):null}function Cs(){he.state.negativeConfirms=0}async function ks(){const e=he.state;if(e.exiting||e.confirmInFlight||e.negativeConfirms>=Es)return;const t=Ss();if(!t)return;const n=Date.now();if(!(e.lastConfirmAt!==null&&n-e.lastConfirmAt<vs)){e.lastConfirmAt=n,e.confirmInFlight=!0;try{const o=await hi(t,{credentials:"same-origin"},{silent:!0,source:"desktop-mode/plugin-presence"});if(o.status!==404){e.negativeConfirms+=1;return}if((await o.json())?.code!=="rest_no_route"){e.negativeConfirms+=1;return}xs()}catch{}finally{e.confirmInFlight=!1}}}function xs(){if(!he.state.exiting){he.state.exiting=!0,ws(ut().adminUrl||"");try{dt({message:_("OpenStation is no longer active. Returning to the WordPress dashboard…"),duration:Rn})}catch{}}}function ht(e){if(he.state.exiting)return;let t=null;try{t=e.contentDocument}catch{return}if(!(!t?.body||!t.location)&&t.location.pathname.startsWith(As())){if(t.body.classList.contains("os-chromeless")){Cs();return}ks()}}const B=0,ft=40,On=5,Ts=On*On,Is=3e3,Ls=250,Ns=15e3,Rs=120,pt="os-window__loading",Dn="os-window__loading--visible",Os=k("desktop-mode/window-reveal-active",()=>({id:at,duration:$i}));function Ds(){const e=Os.state.id;return!e||e===at?null:Gi(e)??null}const mt="os-window__reveal",Ws="os-window__reveal--edge",Ms="os-window__reveal--custom",Wn="data-os-reveal",Mn="data-os-reveal-layer",Ps=k("desktop-mode/window-reveal-rendered",()=>({plays:new WeakMap})).state.plays;function Pn(e,t,n,o){const i=document.createElement("div");i.className=o?`${mt} ${Ws}`:mt;const s=o?e.edgeColor:t.color??e.surfaceColor;return typeof s=="string"&&s!==""&&(i.style.background=s),i.setAttribute("aria-hidden","true"),i.setAttribute(Wn,e.id),i.setAttribute(Mn,String(n)),i.style.clipPath=t.from,i}function $s(){const e=Ds();if(!e)return[];if(typeof e.render=="function"){let o;try{o=e.render()}catch(s){return typeof console<"u"&&console.error(`[openstation] window reveal "${e.id}" render threw:`,s),[]}if(!o?.element||typeof o.play!="function")return[];const i=o.element;return i.classList.add(mt),i.classList.add(Ms),i.setAttribute("aria-hidden","true"),i.setAttribute(Wn,e.id),i.setAttribute(Mn,"0"),Ps.set(i,o.play),[i]}const t=Hi(e);if(t.length===0)return[];const n=[];return zi(e.edgeLag)>0&&t.forEach((o,i)=>n.push(Pn(e,o,i,!0))),t.forEach((o,i)=>n.push(Pn(e,o,i,!1))),n}const $n="os-window__body--loading",zn="data-os-loading-at",Hn="data-os-loading-cycle";function zs(e){return e.getAttribute(Hn)??"0"}function Hs(e){e.setAttribute(zn,String(Date.now())),e.setAttribute(Hn,String(Number(zs(e))+1))}function Fs(e,t){const n=Number(e.getAttribute(zn)),o=Number.isFinite(n)&&n>0?Date.now()-n:0,i=Rs-o;if(i<=0){t.classList.add(Dn);return}window.setTimeout(()=>{t.isConnected&&e.classList.contains($n)&&t.classList.add(Dn)},i)}const Us=Symbol.for("desktop-mode/window-config");function Gs(e,t){e[Us]=t}const gt=window.location.origin;function Bs(e){try{return new URL(e,gt).searchParams.has(Bt)}catch{return!1}}function fe(e){const t=new URL(e,gt);return t.origin!==gt||ei(t)?null:(t.searchParams.set("openstation_chromeless","1"),t.toString())}function J(){const e=document.querySelectorAll(".os-window--fullscreen:not(.os-window--minimized)").length>0;document.body.classList.toggle("os-has-fullscreen-window",e)}function qs(){const e=document.createElement("div");e.className=pt,e.setAttribute("role","status"),e.setAttribute("aria-live","polite");const t=document.createElement("os-spinner");return t.setAttribute("preset","classic"),t.setAttribute("size","clamp(96px, 14vw, 192px)"),t.setAttribute("label",_("Loading window content")),e.appendChild(t),e}function Vs(e){let t=qs();const n={windowId:e.id,config:e};if(typeof e.loading?.render=="function")try{e.loading.render(t,n)}catch(o){typeof console<"u"&&console.error(`[openstation] loading.render threw for "${e.id}":`,o)}try{const o=T(f.WINDOW_LOADING_OVERLAY,t,n);o instanceof HTMLElement&&(t=o)}catch(o){typeof console<"u"&&console.error(`[openstation] WINDOW_LOADING_OVERLAY filter threw for "${e.id}":`,o)}return t&&!t.classList.contains(pt)&&t.classList.add(pt),t}function ee(e){const t=document.createElement("span");return t.className=`os-window__slot os-window__slot--${e}`,t.dataset.slot=e,t}function Ks(e){const t=document.createElement("div");t.className="os-window",e.native&&t.classList.add("os-window--native"),t.id=`wp-window-${e.id}`,t.setAttribute("role","dialog"),t.setAttribute("aria-labelledby",`wp-window-title-${e.id}`),t.setAttribute("aria-busy","true"),t.style.left=`${e.x}px`,t.style.top=`${e.y}px`,t.style.width=`${e.width}px`,t.style.height=`${e.height}px`;const n=document.createElement("div");n.className="os-window__titlebar";const o=document.createElement("os-window-button");o.setAttribute("icon","menu"),lt(o,"core/menu"),o.setAttribute("aria-label",_("Window actions")),o.setAttribute("aria-haspopup","menu"),o.setAttribute("aria-expanded","false"),o.classList.add("os-window__btn"),o.classList.add("os-window__menu-btn");const i=document.createElement("os-menu");i.classList.add("os-window__menu-panel"),i.hidden=!0;const s=document.createElement("os-menu-item");if(s.setAttribute("role","menuitemcheckbox"),s.setAttribute("value","startup"),s.classList.add("os-window__menu-item"),s.classList.add("os-window__menu-item--startup"),s.textContent=_("Open on startup"),i.appendChild(s),e.multi){const h=document.createElement("os-menu-item");h.setAttribute("role","menuitem"),h.setAttribute("value","open-another"),h.setAttribute("icon","dashicons-plus-alt2"),h.classList.add("os-window__menu-item"),h.classList.add("os-window__menu-item--open-another"),h.textContent=ie(_("Open another %s"),e.title),i.appendChild(h)}if(!e.native){const h=document.createElement("os-menu-item");h.setAttribute("role","menuitem"),h.setAttribute("value","open-in-new-window"),h.setAttribute("icon","dashicons-plus-alt"),h.classList.add("os-window__menu-item"),h.classList.add("os-window__menu-item--open-in-new-window"),h.textContent=_("Open in new window"),i.appendChild(h)}if(!e.native||e.render){const h=document.createElement("os-menu-item");h.setAttribute("role","menuitem"),h.setAttribute("value","reload"),h.setAttribute("icon","dashicons-update"),h.classList.add("os-window__menu-item"),h.classList.add("os-window__menu-item--reload"),h.textContent=_("Reload"),i.appendChild(h)}if(!e.native){const h=document.createElement("os-menu-item");h.setAttribute("role","menuitem"),h.setAttribute("value","open-external"),h.setAttribute("icon","dashicons-external"),h.classList.add("os-window__menu-item"),h.classList.add("os-window__menu-item--open-external"),h.textContent=_("Open in browser tab"),i.appendChild(h)}const r=ee("icon"),d=ee("title"),a=document.createElement("span");a.className="os-window__title",a.id=`wp-window-title-${e.id}`,a.textContent=e.title,d.appendChild(a);const c=ee("before-titlebar"),l=ee("before-icon"),u=ee("after-title"),p=ee("before-controls"),g=ee("after-controls"),b=ee("after-titlebar"),y=document.createElement("div");y.className="os-window__controls";const w=document.createElement("div");w.className="os-window__screen-meta";const S=document.createElement("span");S.className="os-window__custom-buttons os-window__custom-buttons--left";const E=document.createElement("span");E.className="os-window__custom-buttons os-window__custom-buttons--right";const C=document.createElement("os-save-status");C.className="os-window__status",C.setAttribute("mode","icon"),C.setAttribute("variant","ring"),C.setAttribute("phase","idle"),C.setAttribute("data-os-activity-indicator","");const N=document.createElement("span");N.className="os-window__activity-status",N.setAttribute("role","status"),N.setAttribute("aria-live","polite"),n.appendChild(N),n.appendChild(C),n.appendChild(l),n.appendChild(r),n.appendChild(d),n.appendChild(u),n.appendChild(S),n.appendChild(w),o&&i&&i.children.length>0&&(n.appendChild(o),n.appendChild(i)),n.appendChild(E),n.appendChild(p),n.appendChild(y),n.appendChild(g);for(const h of Array.from(n.children))h.setAttribute("data-os-default-chrome","");const D=document.createElement("div");if(D.className=`os-window__body ${$n}`,Hs(D),e.native)D.classList.add("os-window__body--native");else{const h=document.createElement("iframe");h.className="os-window__iframe",h.setAttribute("name",`os-frame-${e.id}`);const v=e.url?fe(e.url):null;h.src=v??"about:blank",D.appendChild(h);const I=()=>{$(e.id),ht(h)};h.addEventListener("load",I)}const Se=Vs(e);D.appendChild(Se),Fs(D,Se);for(const h of $s())D.appendChild(h);Ie(e.id);const j=[];for(const h of["ne","nw","se","sw"]){const v=document.createElement("div");v.className=`os-window__resize-handle os-window__resize-handle--${h}`,v.dataset.dir=h,v.setAttribute("aria-hidden","true"),j.push(v)}t.appendChild(c),t.appendChild(n),t.appendChild(b);{const h=document.createElement("nav");h.className="os-window__tabs";const v=document.createElement("span");v.className="os-window__tab-plate",v.setAttribute("aria-hidden","true");const I=document.createElement("span");I.className="os-window__tab-plate-fill";const H=document.createElement("span");H.className="os-window__tab-plate-joint",v.appendChild(I),v.appendChild(H),h.appendChild(v),e.native?h.dataset.tablistLabel=ie(_("%s sections"),e.title):h.dataset.tablistLabel=ie(_("%s sub-pages"),e.title);const P=(e.submenu??[]).filter(F=>!F.offSite&&!Bs(F.url));if(P.length>0&&e.url){const F=Y(e.url),Ce=e.parentUrl??e.url,Ol=Y(Ce),Dl=P.some(ke=>Y(ke.url)===Ol)?[...P]:[{title:e.selfLabel||e.title,url:Ce},...P];for(const ke of Dl){const U=document.createElement("button");U.className="os-window__tab",U.dataset.kind="submenu",U.setAttribute("type","button"),U.setAttribute("role","tab"),U.dataset.url=ke.url,U.textContent=ke.title,Y(ke.url)===F?(U.classList.add("os-window__tab--active"),U.setAttribute("aria-selected","true")):U.setAttribute("aria-selected","false"),h.appendChild(U)}}le(h),t.appendChild(h)}t.appendChild(D);for(const h of j)t.appendChild(h);return Gs(t,e),t}const Fn=window.location.origin;let Un=0;function js(e,{timeoutMs:t=Ls}={}){const n=e?.contentWindow;if(!n)return Promise.resolve(!1);Un+=1;const o=`os-unsaved-guard-${Date.now()}-${Un}`;return new Promise(i=>{let s=null,r=!1;const d=c=>{r||(r=!0,window.removeEventListener("message",a),s!==null&&window.clearTimeout(s),i(c))},a=c=>{if(c.origin!==Fn)return;const l=c?.data;!l||typeof l!="object"||l.type!=="os-bridge-beforeunload-response"||l.requestId!==o||d(l.prevent===!0)};window.addEventListener("message",a),s=window.setTimeout(()=>d(!1),t);try{n.postMessage({type:"os-bridge-beforeunload-query",requestId:o},Fn)}catch{d(!1)}})}function _t(e,{commit:t,navigate:n}){if(!e._iframeBridgeReady||!e.iframe){t(),n();return}e._unsavedGuardPending=!0,js(e.iframe).then(o=>{if(e._unsavedGuardPending=!1,!e._isDestroyed){if(!o){t(),n();return}e._deferNavigationCommit(t,Ns),n()}})}function Ys(e,t){let n;try{n=new URL(t,window.location.origin)}catch{return null}const o=Jt(t);let i=null,s=-1;for(const r of e){const d=r.dataset.url;if(!d||Jt(d)!==o)continue;let a;try{a=new URL(d,window.location.origin)}catch{continue}let c=0,l=!1;for(const[u,p]of a.searchParams){if(u==="openstation_chromeless"||u==="desktop_mode_portal"||Qt.includes(u))continue;if(n.searchParams.get(u)!==p){l=!0;break}c++}!l&&c>s&&(i=r,s=c)}return i}function pe(e,t){const n=e.element.querySelectorAll('.os-window__tab[data-kind="submenu"]');if(!n.length)return;if(e._activeTabId!=="primary"){for(const s of n)s.classList.remove("os-window__tab--active"),s.setAttribute("aria-selected","false");return}const o=Y(t);let i=null;for(const s of n){const r=s.dataset.url;if(r&&Y(r)===o){i=s;break}}if(i||(i=Ys(n,t)),!i){if(Array.from(n).some(d=>d.classList.contains("os-window__tab--active")))return;let r=!1;try{const d=new URL(t,window.location.origin);r=d.pathname.endsWith("/admin.php")&&d.searchParams.has("page")}catch{return}if(!r||!n[0])return;i=n[0]}for(const s of n){const r=s===i;s.classList.toggle("os-window__tab--active",r),s.setAttribute("aria-selected",r?"true":"false")}}function Gn(e,t,n){if(!e.iframe)return;const o=e.element.querySelector(".os-window__tabs"),i=e.element.querySelector(".os-window__body");if(!o||!i)return;Xs(e,o);const s=`ext-${++e._externalTabSeq}`,r=document.createElement("button");r.className="os-window__tab os-window__tab--external",r.dataset.kind="external",r.dataset.tabId=s,r.setAttribute("type","button"),r.setAttribute("role","tab"),r.setAttribute("aria-selected","false"),r.title=t;const d=document.createElement("span");d.className="os-window__tab-label",d.textContent=n,r.appendChild(d);const a=document.createElement("os-tab-chip");a.setAttribute("variant","detach"),a.dataset.tabAction="detach",a.dataset.tabId=s,a.setAttribute("aria-label",_("Open in a new browser tab")),a.title=_("Open in a new browser tab"),r.appendChild(a);const c=document.createElement("os-tab-chip");c.setAttribute("variant","close"),c.dataset.tabAction="close",c.dataset.tabId=s,c.setAttribute("aria-label",_("Close tab")),c.title=_("Close tab"),r.appendChild(c),o.appendChild(r),le(o);const l=document.createElement("iframe");l.className="os-window__iframe os-window__iframe--external",l.dataset.tabId=s,l.style.display="none",l.src=t,i.appendChild(l);let u=!1;const p=()=>{u=!0};l.addEventListener("load",p,{once:!0});const g=window.setTimeout(()=>{u||(l.removeEventListener("load",p),Qs(e,s))},Is),b=()=>{l.removeEventListener("load",p),window.clearTimeout(g)};e._externalTabs.set(s,{tabEl:r,iframe:l,url:t,label:n,cancelProbe:b}),me(e,s),r.scrollIntoView({behavior:"smooth",inline:"end",block:"nearest"}),e._emitChange("state")}function Xs(e,t){if(t.querySelector('[data-kind="main"]')||t.querySelector('[data-kind="submenu"]'))return;const n=document.createElement("button");n.className="os-window__tab os-window__tab--main os-window__tab--active",n.dataset.kind="main",n.setAttribute("type","button"),n.setAttribute("role","tab"),n.setAttribute("aria-selected","true"),n.textContent=e.config.title||"Main",t.prepend(n),le(t)}function me(e,t){if(e._activeTabId===t)return;e._activeTabId=t,e.iframe&&(e.iframe.style.display=t==="primary"?"":"none");for(const[o,i]of e._externalTabs)i.iframe.style.display=t===o?"":"none";e.element.querySelectorAll(".os-window__tab").forEach(o=>{let i;o.dataset.kind==="main"?i=t==="primary":o.dataset.kind==="external"?i=o.dataset.tabId===t:i=t==="primary"&&o.classList.contains("os-window__tab--active"),o.classList.toggle("os-window__tab--active",i),o.setAttribute("aria-selected",i?"true":"false")})}function bt(e,t){const n=e._externalTabs.get(t);n&&(n.cancelProbe(),n.tabEl.remove(),n.iframe.remove(),e._externalTabs.delete(t),e._activeTabId===t&&me(e,"primary"),e._externalTabs.size===0&&e.element.querySelector(".os-window__tab--main")?.remove(),le(e.element.querySelector(".os-window__tabs")),e._emitChange("state"))}function Zs(e,t){const n=e._externalTabs.get(t);if(!n)return;let o=n.url;try{const i=n.iframe.contentWindow?.location.href;i&&i!=="about:blank"&&(o=i)}catch{}window.open(o,"_blank","noopener"),bt(e,t)}function Qs(e,t){const n=e._externalTabs.get(t);if(!n)return;const{url:o,label:i}=n;bt(e,t),dt({message:ie(_(`Opened "%s" in a new browser tab — this site doesn't allow embedding.`),i),action:{label:_("Open"),onClick:()=>{window.open(o,"_blank","noopener")}}}),window.open(o,"_blank","noopener")}function Js(e){return e._externalTabs.size}function er(e){const t=[];for(const n of e._externalTabs.values()){let o=n.url;try{const i=n.iframe.contentWindow?.location.href;i&&i!=="about:blank"&&(o=i)}catch{}t.push({url:o,label:n.label})}return t}function tr(e,t){const n=t.target,o=n.closest("[data-tab-action]");if(o){t.stopPropagation();const d=o.dataset.tabAction,a=o.dataset.tabId;if(!a)return;d==="close"?bt(e,a):d==="detach"&&Zs(e,a);return}const i=n.closest(".os-window__tab");if(!i)return;t.stopPropagation();const s=i.dataset.kind,r=i.dataset.tabId;if(s==="external"&&r){me(e,r);return}if(s==="main"){me(e,"primary");return}if(s==="panel"&&i.dataset.panel){Qe(e.element,i.dataset.panel);return}if(i.dataset.url){const d=i.dataset.url;if(Xe(d))return;const a=fe(d);me(e,"primary");const c=()=>{e.markContentLoading(),pe(e,d)};a&&e.iframe?_t(e,{commit:c,navigate:()=>{e.iframe&&(e.iframe.src=a)}}):pe(e,d)}}const wt=1;function nr(e,t){const n=Math.max(0,e.scrollWidth-e.clientWidth);if(n<=wt){delete e.dataset.overflow;return}const o=Math.abs(e.scrollLeft),i=o<=wt,s=o>=n-wt,r=t??window.getComputedStyle(e).direction==="rtl",d=r?!s:!i,a=r?!i:!s;d&&a?e.dataset.overflow="both":d?e.dataset.overflow="left":a?e.dataset.overflow="right":delete e.dataset.overflow}function or(e){let t=null,n=null;const o=()=>{n===null&&(n=window.requestAnimationFrame(()=>{n=null,t===null&&(t=window.getComputedStyle(e).direction==="rtl"),nr(e,t),jt(e),Yt(e)}))},i=()=>{t=null,o()};e.addEventListener("scroll",o,{passive:!0});const s=typeof ResizeObserver>"u"?null:new ResizeObserver(i);s?.observe(e);const r=typeof MutationObserver>"u"?null:new MutationObserver(i);return r?.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["class"]}),o(),()=>{e.removeEventListener("scroll",o),s?.disconnect(),r?.disconnect(),n!==null&&(window.cancelAnimationFrame(n),n=null)}}const ir=k("desktop-mode/destructive-admin-actions",()=>({entries:[]}));function sr(e,t){for(const n of ir.state.entries)try{if(n.matches(e,t))return n.id}catch(o){console.warn(`[openstation] destructive-action predicate threw for "${n.id}":`,o)}return null}const rr=32,ar=64,lr=/^[a-z0-9_/-]+$/,q=k("desktop-mode/window-links",()=>({contentByWindow:new Map,focusSeq:new Map,seq:0,listeners:new Set,lastGroupsSignature:"",manager:null,started:!1}));function De(e){return`${e.type}:${e.id}`}function Bn(e){return e.root?De(e.root):De(e)}function qn(e){const t=o=>typeof o=="number"&&Number.isFinite(o)||typeof o=="string"&&o.trim()!=="",n=o=>typeof o=="string"&&lr.test(o.trim().toLowerCase());return fi(e,[{field:"type",valid:o=>n(o.type),message:"must match /^[a-z0-9_/-]+$/ — lowercase alphanum, hyphens, underscores, slashes for vendor/sub-type"},{field:"id",valid:o=>t(o.id),message:"must be a finite number or non-empty string"},{field:"root",valid:o=>o.root===void 0||!!o.root&&typeof o.root=="object"&&n(o.root.type)&&t(o.root.id),message:"when present, must be { type, id } with the same shapes as the ref itself"},{field:"related",valid:o=>o.related===void 0||Array.isArray(o.related)&&o.related.every(i=>!!i&&typeof i=="object"&&typeof i.id=="string"&&i.id.trim()!==""&&typeof i.group=="string"&&i.group.trim()!==""&&typeof i.label=="string"&&i.label.trim()!==""&&typeof i.url=="string"&&i.url.trim()!==""&&(i.groupLabel===void 0||typeof i.groupLabel=="string")&&(i.icon===void 0||typeof i.icon=="string")&&(i.count===void 0||typeof i.count=="number"&&Number.isFinite(i.count))),message:"when present, must be an array of { id, group, label, url, groupLabel?, icon?, count? } entries with non-empty strings"},{field:"links",valid:o=>o.links===void 0||Array.isArray(o.links)&&o.links.every(i=>!!i&&typeof i=="object"&&n(i.type)&&t(i.id)&&(i.rel===void 0||i.rel==="references"||i.rel==="child")),message:"when present, must be an array of { type, id, rel?: 'references'|'child' } entries"},{field:"revisionCount",valid:o=>o.revisionCount===void 0||typeof o.revisionCount=="number"&&Number.isFinite(o.revisionCount),message:"when present, must be a finite number"}])}function Vn(e){if(!(typeof e!="string"||e===""))try{return new URL(e,window.location.origin).origin===window.location.origin?e:void 0}catch{return}}function cr(e,t){const n={type:e.type.trim().toLowerCase(),id:e.id,source:t};e.root&&(n.root={type:e.root.type.trim().toLowerCase(),id:e.root.id}),Array.isArray(e.links)&&e.links.length>0&&(n.links=e.links.slice(0,rr).map(s=>{const r={type:s.type.trim().toLowerCase(),id:s.id};return s.rel==="child"&&(r.rel="child"),r})),typeof e.label=="string"&&e.label!==""&&(n.label=e.label);const o=Vn(e.previewUrl);o&&(n.previewUrl=o);const i=Vn(e.revisionsUrl);return i&&(n.revisionsUrl=i,typeof e.revisionCount=="number"&&Number.isFinite(e.revisionCount)&&(n.revisionCount=Math.max(0,Math.trunc(e.revisionCount)))),Array.isArray(e.related)&&e.related.length>0&&(n.related=e.related.slice(0,ar).map(s=>{const r={id:s.id,group:s.group,label:s.label,url:s.url};return typeof s.groupLabel=="string"&&s.groupLabel!==""&&(r.groupLabel=s.groupLabel),typeof s.icon=="string"&&s.icon!==""&&(r.icon=s.icon),typeof s.count=="number"&&(r.count=s.count),r})),n}function Kn(e){return!e||!e.related?"":e.related.map(t=>`${t.id}\0${t.group}\0${t.label}\0${t.url}\0${t.groupLabel??""}\0${t.icon??""}\0${t.count??""}`).join("|")}function yt(e){return e?[De(e),Bn(e),...(e.links??[]).map(t=>De(t)+(t.rel==="child"?"!child":""))].join("|"):""}function dr(e,t,n={}){const o=n.source??"api";if(typeof e!="string"||e===""){et("WindowContentRef",["windowId (must be a non-empty string)"],t);return}let i=null;if(t!=null){const d=qn(t);if(d.length>0){o==="api"&&et("WindowContentRef",d,t),nn("WindowContentRef",d,t);return}i=cr(t,o)}if(i=T(f.WINDOW_LINKS_CONTENT,i,{windowId:e,source:o}),i!==null&&(!i||qn(i).length>0)){nn("WindowContentRef",["filter (os.window-links.content returned an invalid ref)"],i);return}const s=q.state.contentByWindow.get(e)??null;if(i===null&&s===null||i!==null&&s!==null&&yt(i)===yt(s)&&i.label===s.label&&i.previewUrl===s.previewUrl&&i.revisionsUrl===s.revisionsUrl&&i.revisionCount===s.revisionCount&&Kn(i)===Kn(s))return;i===null?q.state.contentByWindow.delete(e):q.state.contentByWindow.set(e,i);const r={windowId:e,content:i,previous:s,source:o};document.dispatchEvent(new CustomEvent("os-window-content-changed",{detail:r})),m(f.WINDOW_CONTENT_CHANGED,r),pr(),hr()}function ur(){const e=new Map;for(const[i,s]of q.state.contentByWindow){const r=Bn(s);let d=e.get(r);d||(d={key:r,root:s.root?{...s.root}:{type:s.type,id:s.id},rootWindowIds:[],children:[]},e.set(r,d)),s.root?d.children.push({windowId:i,content:s}):d.rootWindowIds.push(i)}const t=q.state.focusSeq;for(const i of e.values())i.rootWindowIds.sort((s,r)=>(t.get(r)??0)-(t.get(s)??0));const n=Array.from(e.values()),o=T(f.WINDOW_LINK_GROUPS,n);return Array.isArray(o)?o:(typeof console<"u"&&console.warn("[openstation] `os.window-links.groups` filter returned a non-array; falling back to computed groups."),n)}function hr(){for(const e of Array.from(q.state.listeners))try{e()}catch(t){typeof console<"u"&&console.error("[openstation] window-links listener threw:",t)}}function fr(){return Array.from(q.state.contentByWindow).map(([e,t])=>`${e}=${yt(t)}`).sort().join(";")}function pr(){const e=fr();if(e===q.state.lastGroupsSignature)return;q.state.lastGroupsSignature=e;const n={groups:ur()};document.dispatchEvent(new CustomEvent("os-window-link-groups-changed",{detail:n})),m(f.WINDOW_LINK_GROUPS_CHANGED,n)}const mr="my-wordpress",gr=Object.freeze({userId:null,userName:"",requestedAt:0});function jn(){return window.wp?.os}let We=null;function _r(){if(We)return We;const e=jn()?.createSharedStore;return typeof e!="function"?null:(We=e("desktop-mode/my-wordpress/footprint-target",()=>({...gr})),We)}function br(e,t=""){const n=_r();if(n){n.state.userId=e,n.state.userName=t,n.state.requestedAt=Date.now(),n.notify();return}window._wpdFootprintTarget={userId:e,userName:t,requestedAt:Date.now()}}function wr(e){const t=Number(e.userId);if(!Number.isFinite(t)||t<=0)return;const n=e.userName??"";br(t,n),jn()?.openWindow?.(mr,{source:"my-wordpress/open-user-footprint",params:{footprint:t,fpName:n}})}const M=window.location.origin,vt=k("desktop-mode/admin-link-deps",()=>({deps:null}));function yr(e,t){if(t.origin!==M||!e.iframe||t.source!==e.iframe.contentWindow)return;const n=t.data;if(!(!n||typeof n.type!="string")){if(n.type==="os-title-change"&&typeof n.title=="string"&&e.setTitle(n.title),n.type==="os-content-identity"&&dr(e.id,n.identity??null,{source:"bridge"}),n.type==="os-window-publish"&&typeof n.channel=="string"&&n.channel!==""&&Ht(e.id,n.channel,n.payload),typeof n.type=="string"&&n.type.startsWith("os-bridge-")&&window.__openStationConnectionBridge?.routeIncomingFromIframe(n,e.id),n.type==="os-iframe-navigated"&&e._settleNavigationActivity(),n.type==="os-ready"&&(e._iframeBridgeReady=!0,e._clearDeferredNavigation(),e._settleNavigationActivity(!0)||e._resetActivity(),$(e.id),m(f.IFRAME_READY,{windowId:e.id})),n.type==="os-iframe-unloading"&&e._commitDeferredNavigation(),n.type==="os-bridge-beforeunload-response"){if(e._isDestroyed||typeof n.requestId=="string"&&n.requestId!=="")return;e._closePending=!1,e._iframeCloseTimeout&&(clearTimeout(e._iframeCloseTimeout),e._iframeCloseTimeout=null),n.prevent?Promise.resolve().then(()=>Rl).then(({osConfirm:o})=>o({title:typeof n.message=="string"&&n.message?n.message:_("Unsaved changes"),message:_("You have unsaved changes. Are you sure you want to close this window?"),confirmLabel:_("Close window"),danger:!0})).then(o=>{o&&e.destroy()}).catch(()=>{e.destroy()}):e.destroy()}if(n.type==="os-navigate"&&typeof n.url=="string"&&n.url!==""&&Er(e,n.url,n.target==="new"?"new":"self"),n.type==="os-iframe-other-admin-link"&&typeof n.url=="string"&&n.url!==""&&vt.state.deps?.openOtherAdmin?.(n.url),n.type==="os-iframe-admin-link"&&typeof n.url=="string"&&n.url!==""){const o=vt.state.deps;if(Xe(n.url))e.close();else if(o){const i=typeof n.label=="string"?n.label:"";xr(e,n.url,i,o,n.newContext===!0)}}if(n.type==="os-open-user-footprint"&&typeof n.userId=="number"&&n.userId>0&&wr({userId:n.userId,userName:typeof n.userName=="string"?n.userName:""}),n.type==="os-notification"&&typeof n.title=="string"&&n.title!==""&&Or(n.title,typeof n.body=="string"?n.body:""),n.type==="os-focus-request"&&(e.element.classList.contains("os-window--overview")||e.onFocusRequest?.(e)),n.type==="os-screen-meta"&&Array.isArray(n.panels)&&Dr(e,n.panels),n.type==="os-screen-meta-state"&&Wr(e,typeof n.open=="string"?n.open:null),n.type==="os-external-link"&&typeof n.url=="string"&&n.url!==""){const o=typeof n.label=="string"&&n.label!==""?n.label:n.url;Gn(e,n.url,o)}if(n.type==="os-iframe-error"&&m(f.IFRAME_ERROR,{windowId:e.id,kind:n.kind==="unhandledrejection"?"unhandledrejection":"error",message:typeof n.message=="string"?n.message:"",filename:typeof n.filename=="string"?n.filename:null,lineno:typeof n.lineno=="number"?n.lineno:null,colno:typeof n.colno=="number"?n.colno:null,stack:typeof n.stack=="string"?n.stack:null}),n.type==="os-chrome-theme"&&n.tokens&&typeof n.tokens=="object")try{e.setAppearanceTheme(n.tokens)}catch(o){m(f.SHELL_ERROR,{scope:"window-bridge-chrome-theme",windowId:e.id,error:o})}if(n.type==="os-chrome-controls"&&n.config&&typeof n.config=="object")try{e.setAppearanceControls(n.config)}catch(o){m(f.SHELL_ERROR,{scope:"window-bridge-chrome-controls",windowId:e.id,error:o})}if(n.type==="os-chrome-slot"&&typeof n.slot=="string"&&typeof n.html=="string")try{e.setAppearanceSlot(n.slot,{html:n.html})}catch(o){m(f.SHELL_ERROR,{scope:"window-bridge-chrome-slot",windowId:e.id,error:o})}if(n.type==="os-iframe-activity"){if(n.phase==="start")e._markActivityStart(),n.navigation&&e._noteNavigationActivity();else if(n.phase==="end"){const o=!!n.failed,i=typeof n.status=="number"?n.status:0;e._markActivitySettled(!o,o?vr(i):void 0)}}if(n.type==="os-iframe-network"){const o={windowId:e.id,method:typeof n.method=="string"?n.method:"GET",url:typeof n.url=="string"?n.url:"",status:typeof n.status=="number"?n.status:0,duration:typeof n.duration=="number"?n.duration:0,failed:!!n.failed};n.requestHeaders&&typeof n.requestHeaders=="object"&&(o.requestHeaders=n.requestHeaders),n.responseHeaders&&typeof n.responseHeaders=="object"&&(o.responseHeaders=n.responseHeaders),m(f.IFRAME_NETWORK_COMPLETED,o)}}}function vr(e){return e<=0?_("Request failed."):ie(_("Request failed (HTTP %d)."),e)}function Er(e,t,n){let o;try{o=new URL(t,M)}catch{return}if(o.origin===M){if(n==="new"){window.open(o.toString(),"_blank","noopener,noreferrer");return}e.iframe&&(e.iframe.src=o.toString())}}const Ar=new Set(["trash","untrash","delete","spam","unspam","spamcomment","unspamcomment","trashcomment","untrashcomment","deletecomment","approvecomment","unapprovecomment"]);function Sr(e){const t=e.searchParams.get("action");return t&&Ar.has(t)&&(e.searchParams.has("_wpnonce")||e.searchParams.has("_wp_nonce"))?!0:sr(e.toString(),e)!==null}function Yn(e,t){if(e.searchParams.has("_wp_http_referer"))return e;let n="";try{n=t.iframe?.contentWindow?.location.href??""}catch{}if(n||(n=t.config.url||""),!n)return e;try{const o=new URL(n,M);if(o.origin!==M)return e;const i=new URL(e.href),s=new URL(o.href);return s.searchParams.delete("openstation_chromeless"),i.searchParams.set("_wp_http_referer",s.pathname+(s.search?s.search:"")),i}catch{return e}}function Cr(e,t){let n="";try{n=e.getCurrentUrl?.()??""}catch{return""}if(!n||n.startsWith("#")||n==="about:blank")return"";try{const o=new URL(n,t.adminUrl);return o.origin!==M?"":t.deriveSlug(o.toString())}catch{return""}}function kr(e,t,n){if(t===(e.config.baseId||e.id))return!0;const o=Cr(e,n);return o!==""&&o===t}function xr(e,t,n,o,i=!1){let s;try{s=new URL(t,o.adminUrl)}catch{return}if(s.origin!==M)return;if(i){Et(e,s,n,o);return}const r=s.toString(),d=o.deriveSlug(r),a=kr(e,d,o);if(!a&&Sr(s)){const c=Yn(s,e),l=e.iframe?.contentWindow;if(l)try{l.location.assign(c.href)}catch{e.iframe&&(e.iframe.src=c.href)}return}if(a){const c=e.iframe?.contentWindow;if(c)try{c.location.assign(r)}catch{e.iframe&&(e.iframe.src=r)}return}Et(e,s,n,o)}function Et(e,t,n,o){const i=t.toString(),s=o.deriveSlug(i),r=o.findDockEntry(i),d=n.trim(),a=r?.title||(d!==""?d:s),c=Yn(t,e);o.openWindow({id:s,baseId:s,url:c.toString(),parentUrl:r?.url??i,title:a,titleFromPage:!r,icon:r?.icon??"dashicons-admin-generic",submenu:r?.submenu,selfLabel:r?.selfLabel,multi:r?.multi})}function Me(e){if(!e||e.startsWith("#"))return"";try{const t=new URL(e,M);return t.origin!==M?"":t.pathname.split("/").pop()??""}catch{return""}}const Tr=new Set(["revision.php"]);function Ir(e,t){try{const o=e.iframe?.contentWindow?.performance?.getEntriesByType?.("navigation")?.[0]?.name??"";if(o&&Me(o)===Me(t))return o}catch{}return t}function Lr(e,t){const n=Me(e.config.url??"");if(!n||!Tr.has(n))return!1;const o=Me(t);if(!o||o===n)return!1;if(Xe(t))return e.close(),!0;const i=vt.state.deps;if(!i)return!1;let s;try{s=new URL(Ir(e,t),i.adminUrl)}catch{return!1}return s.origin!==M?!1:(Et(e,s,"",i),e.close(),!0)}function Nr(e){if(!e.config.titleFromPage)return;let t="";try{t=e.iframe?.contentDocument?.title??""}catch{return}const n=Rr(t);n!==""&&n!==e.config.title&&e.setTitle(n)}function Rr(e){const t=e.trim(),n=t.indexOf(" ‹ ");return(n>0?t.slice(0,n):t).trim()}function Or(e,t){const n=t!==""?`${e} — ${t}`:e;dt({message:n})}function Dr(e,t){const n=e.element.querySelector(".os-window__screen-meta");if(!n)return;n.innerHTML="";const o={"screen-options":{icon:"dashicons-admin-generic",label:"Screen Options"},help:{icon:"dashicons-editor-help",label:"Help"}};for(const i of t){const s=o[i];if(!s)continue;const r=document.createElement("button");r.className="os-window__meta-btn",r.setAttribute("type","button"),r.setAttribute("aria-label",s.label),r.setAttribute("aria-pressed","false"),r.dataset.panel=i,r.innerHTML=`<span class="dashicons ${s.icon}" aria-hidden="true"></span>`,r.addEventListener("click",d=>{d.stopPropagation(),e.iframe?.contentWindow?.postMessage({type:"os-toggle-panel",panel:i},M)}),n.appendChild(r)}}function Wr(e,t){const n=e.element.querySelector(".os-window__screen-meta");n&&n.querySelectorAll(".os-window__meta-btn").forEach(o=>{const i=o.dataset.panel===t;o.classList.toggle("os-window__meta-btn--active",i),o.setAttribute("aria-pressed",i?"true":"false")})}const Xn=k("desktop-mode/title-bar-buttons-registry",()=>({registry:new Map,listeners:new Set})),Mr=Xn.state.registry,At=Xn.state.listeners;function Pr(){return Array.from(Mr.values()).sort((e,t)=>(e.order??100)-(t.order??100))}function $r(e){const t=[],n=[];for(const o of Pr()){try{if(!o.match(e))continue}catch{continue}o.placement==="right"?n.push(o):t.push(o)}return{left:t,right:n}}function zr(e){return At.add(e),()=>{At.delete(e)}}function Hr(){const e=Array.from(At);for(const t of e)try{t()}catch(n){typeof console<"u"&&console.error("[openstation] title-bar-button registry listener threw:",n)}}typeof document<"u"&&document.addEventListener("os-settings-save-lifecycle",e=>{const t=e.detail;t&&t.phase==="saved"&&Hr()});const Fr=/^dashicons-[a-z0-9-]+$/i,Ur=/^\s*<svg[\s>]/i;function Zn(e,t){if(t){if(Fr.test(t)){const n=document.createElement("span");n.className=`dashicons ${t}`,n.setAttribute("aria-hidden","true"),e.appendChild(n);return}if(Ur.test(t)){const n=document.createElement("span");n.setAttribute("aria-hidden","true"),n.innerHTML=t,e.appendChild(n);return}e.setAttribute("icon",t)}}const Qn=k("desktop-mode/window-themes-registry",()=>({registry:new Map,listeners:new Set})),Gr=Qn.state.registry,Jn=Qn.state.listeners;function eo(){return Array.from(Gr.values()).sort((e,t)=>(e.priority??100)-(t.priority??100))}function Br(e){let t=null;for(const n of eo()){try{if(!n.match(e))continue}catch(o){typeof console<"u"&&console.warn(`[openstation] window-theme "${n.id}" match() threw — skipping`,o);continue}t=n}return t}function qr(e){return Jn.add(e),()=>{Jn.delete(e)}}const Pe=new WeakMap;function Vr(e,t){let n=null,o={};if(t&&"tokens"in t&&t.tokens)n=null,o={...t.tokens};else if(t&&"themeId"in t&&t.themeId){const s=jr(t.themeId);s&&(n=s.id,o={...s.tokens})}else{const s=Br(e);s&&(n=s.id,o={...s.tokens})}const i=T(f.WINDOW_CHROME_THEME,o,{windowId:e.id,themeId:n,config:e.config});return{themeId:n,tokens:i}}function St(e,t){const n=e.element;if(!n)return;const o=Pe.get(n),{themeId:i,tokens:s}=Vr(e,t);if(o){for(const d of o.keys)if(!(d in s))try{n.style.removeProperty(d)}catch{}}const r=new Set;for(const[d,a]of Object.entries(s))try{n.style.setProperty(d,a),r.add(d)}catch(c){m(f.SHELL_ERROR,{scope:"window-theme-apply",windowId:e.id,key:d,error:c})}Pe.set(n,{themeId:i,keys:r}),m(f.WINDOW_CHROME_THEME_CHANGED,{windowId:e.id,themeId:i,tokens:s})}function Kr(e){const t=e.element;if(!t)return;const n=Pe.get(t);if(n){for(const o of n.keys)try{t.style.removeProperty(o)}catch{}Pe.delete(t)}}function jr(e){for(const t of eo())if(t.id===e)return{id:t.id,tokens:t.tokens};return null}const to=k("desktop-mode/window-controls-registry",()=>({registry:new Map,listeners:new Set})),Yr=to.state.registry,no=to.state.listeners;function Xr(){return Array.from(Yr.values()).sort((e,t)=>{const n=e.order??100,o=t.order??100;return n!==o?n-o:e.id.localeCompare(t.id)})}function Zr(e){const t=[],n=[],o=[];for(const i of Xr()){try{if(!i.match(e))continue}catch(r){typeof console<"u"&&console.warn(`[openstation] window-control "${i.id}" match() threw — skipping`,r);continue}const s=i.placement??"left";s==="right"?n.push(i):s==="controls"?o.push(i):t.push(i)}return{left:t,right:n,controls:o}}function Qr(e){return no.add(e),()=>{no.delete(e)}}function Jr(e,t){const n=Zr(e),o=new Set(t?.hide??[]);let i=n.left.filter(c=>!o.has(c.id)),s=n.right.filter(c=>!o.has(c.id)),r=n.controls.filter(c=>!o.has(c.id));if(t?.custom){for(const c of t.custom){if(o.has(c.id))continue;const l={id:c.id,label:c.label,icon:c.icon,placement:c.placement??"controls",order:c.order??100,match:()=>!0,onClick:c.onClick?(u,p)=>c.onClick(p):void 0,render:c.render?u=>c.render(u):void 0};l.placement==="left"?i.push(l):l.placement==="right"?s.push(l):r.push(l)}i=Ct(i),s=Ct(s),r=Ct(r)}t?.order&&t.order.length>0&&(r=ea(r,t.order));const d=t?.placement??"right",a={windowId:e.id,config:e.config};return i=T(f.WINDOW_CHROME_CONTROLS,i,{...a,placement:"left"}),s=T(f.WINDOW_CHROME_CONTROLS,s,{...a,placement:"right"}),r=T(f.WINDOW_CHROME_CONTROLS,r,{...a,placement:"controls"}),{left:i,right:s,controls:r,placement:d}}function Ct(e){return[...e].sort((t,n)=>{const o=t.order??100,i=n.order??100;return o!==i?o-i:t.id.localeCompare(n.id)})}function ea(e,t){const n=new Map;for(const s of e)n.set(s.id,s);const o=[],i=new Set;for(const s of t){const r=n.get(s);r&&!i.has(s)&&(o.push(r),i.add(s))}for(const s of e)i.has(s.id)||o.push(s);return o}function ta(e,t){const n=document.createElement("os-window-button");n.setAttribute("aria-label",e.label||e.id),n.classList.add("os-window__btn");const o=na(e.id);if(n.classList.add(`os-window__btn--${o}`),e.id==="core/close"&&n.setAttribute("danger",""),typeof e.render=="function")try{e.render(n,t)}catch(i){return m(f.SHELL_ERROR,{scope:"window-control-render",id:e.id,windowId:t.id,error:i}),{element:n}}else if(lt(n,e.id)||Zn(n,e.icon??""),typeof e.onClick=="function"){const i=s=>{s.stopPropagation();try{e.onClick(t,s)}catch(r){m(f.SHELL_ERROR,{scope:"window-control-onclick",id:e.id,windowId:t.id,error:r})}};return n.addEventListener("os-button-activate",i),{element:n,teardown:()=>{n.removeEventListener("os-button-activate",i)}}}return{element:n}}function na(e){return e.startsWith("core/")?e.slice(5):e.replace(/\//g,"-")}function oa(e,t){const n=[];for(;t.firstChild;)t.removeChild(t.firstChild);const o=Jr(e,e.config.appearance?.controls);t.classList.toggle("os-window__controls--left",o.placement==="left");for(const i of o.controls){const{element:s,teardown:r}=ta(i,e);t.appendChild(s),r&&n.push(r)}return m(f.WINDOW_CHROME_APPLIED,{windowId:e.id,layer:"controls"}),()=>{for(const i of n)try{i()}catch{}}}function ia(e){if(!e)return 214;let t=5381;for(let n=0;n<e.length;n++)t=Math.imul(t,33)+e.charCodeAt(n);return(t%360+360)%360}function sa(e){return typeof e!="string"||e===""||e.length>4096||!/^(https?:\/\/|data:image\/)/i.test(e)?!1:!/['"()\\<>\s]/.test(e)}function oo(e,t,n){if(!sa(t))return!1;const o=`url("${t}") center / contain no-repeat`;return e.style.backgroundImage="none",e.style.backgroundColor=n,e.style.setProperty("-webkit-mask",o),e.style.setProperty("mask",o),!0}const io="data:image/svg+xml;base64,",$e=new Map;function ra(e){const t=$e.get(e);if(t!==void 0)return t;let n=!1;try{n=atob(e.slice(io.length)).includes("currentColor")}catch{}return $e.size>=256&&$e.clear(),$e.set(e,n),n}function aa(e,t){const n=t.className??"",o=t.title??"";let i=null;if(t.slot){const a=In(t.slot);a!==null&&(e=a),i=Ln(t.slot)}if(typeof e=="string"&&e.startsWith("dashicons-")){const a=document.createElement("span");return a.className=`dashicons ${e} ${n}`.trim(),a.setAttribute("aria-hidden","true"),i!==null&&(a.style.color=i),a}if(i!==null&&typeof e=="string"){const a=document.createElement("span");if(a.className=n,a.setAttribute("aria-hidden","true"),a.style.display="inline-block",oo(a,e,i))return a}if(typeof e=="string"&&e.startsWith("data:image/svg+xml;base64,")){const a=e.slice(io.length);if(/^[A-Za-z0-9+/=]+$/.test(a)){const c=document.createElement("span");return c.className=n,c.setAttribute("aria-hidden","true"),c.style.display="inline-block",ra(e)&&oo(c,e,"currentColor")||(c.style.backgroundImage=`url("${e}")`,c.style.backgroundRepeat="no-repeat",c.style.backgroundPosition="center",c.style.backgroundSize="contain"),c}}if(typeof e=="string"&&/^data:image\/(png|jpeg|jpg|gif|webp|x-icon|vnd\.microsoft\.icon);base64,/i.test(e)){const a=e.indexOf(","),c=a>=0?e.slice(a+1):"";if(/^[A-Za-z0-9+/=]+$/.test(c))return so(e,n)}if(typeof e=="string"&&(e.startsWith("http://")||e.startsWith("https://")))return so(e,n);const s=document.createElement("span");s.className=`${n} os-icon-letter`.trim(),s.setAttribute("aria-hidden","true");const r=la(o);s.textContent=r;const d=ia(o);return s.style.backgroundColor=`hsl( ${d}, 60%, 45% )`,s.style.color="#fff",s.style.display="inline-flex",s.style.alignItems="center",s.style.justifyContent="center",s.style.fontWeight="600",s.style.borderRadius="4px",s}function so(e,t){const n=document.createElement("img");return n.className=t,n.src=e,n.alt="",n.setAttribute("aria-hidden","true"),n.draggable=!1,n}function la(e){const t=(e??"").trim();if(t==="")return"?";const n=t.split(/\s+/);if(n.length>=2)return(n[0][0]+n[1][0]).toUpperCase();const o=n[0];return o.length>=2?o.slice(0,2).toUpperCase():o.toUpperCase()}const ro=k("desktop-mode/window-slots-registry",()=>({registry:new Map,listeners:new Set})),ca=ro.state.registry,ao=ro.state.listeners;function da(){return Array.from(ca.values()).sort((e,t)=>{const n=e.order??100,o=t.order??100;return n!==o?n-o:e.id.localeCompare(t.id)})}function ua(e,t){const n=[];for(const o of da())if(o.slot===t){try{if(!o.match(e))continue}catch(i){typeof console<"u"&&console.warn(`[openstation] window-slot "${o.id}" match() threw — skipping`,i);continue}n.push(o)}return n}function ha(e){return ao.add(e),()=>{ao.delete(e)}}const lo=["before-titlebar","before-icon","icon","title","after-title","before-controls","after-controls","after-titlebar"],co=new WeakMap;function uo(e,t){return e.querySelector(`[data-slot="${t}"]`)}function fa(e){const t=new Map;for(const n of lo){const o=uo(e,n);o&&t.set(n,Array.from(o.childNodes).map(i=>i.cloneNode(!0)))}return t}function ge(e){for(;e.firstChild;)e.removeChild(e.firstChild)}function pa(e,t){ge(e);for(const n of t)e.appendChild(n.cloneNode(!0))}function ma(e,t){const n=e.querySelector(".os-window__title");n&&(n.textContent=t)}function ga(e){const t=[],n=e.element;if(!n)return()=>{};let o=co.get(n);o||(o=fa(n),co.set(n,o));const i=e.config.appearance?.slots??{};for(const s of lo){const r=uo(n,s);if(!r)continue;const d=o.get(s)??[],a=i[s],c=ua(e,s);if(a===null)ge(r);else if(a&&"html"in a)ge(r),r.textContent=a.html;else if(a&&"render"in a){a.replace!==!1&&ge(r);try{const u=a.render(r);typeof u=="function"&&t.push(u)}catch(u){m(f.SHELL_ERROR,{scope:"window-slot-inline-render",windowId:e.id,slot:s,error:u})}}else pa(r,d),s==="title"&&ma(r,e.config.title);if(a!==null){let l=!1;for(const u of c){u.replace!==!1&&!l&&(ge(r),l=!0);try{const g=u.render(r,{window:e,slot:s});typeof g=="function"&&t.push(g)}catch(g){m(f.SHELL_ERROR,{scope:"window-slot-registry-render",windowId:e.id,slot:s,id:u.id,error:g})}}}T(f.WINDOW_CHROME_SLOT,r,{windowId:e.id,slot:s,config:e.config})}return m(f.WINDOW_CHROME_APPLIED,{windowId:e.id,layer:"slots"}),()=>{for(const s of t)try{s()}catch{}}}const ho=k("desktop-mode/window-chrome-registry",()=>({registry:new Map,listeners:new Set})),_a=ho.state.registry,fo=ho.state.listeners;function ba(e){return _a.get(e.toLowerCase())??null}function wa(e){return fo.add(e),()=>{fo.delete(e)}}const ze="core/standard",kt="os-window--custom-chrome";function po(e){const t=e.config.appearance?.chrome??ze;return T(f.WINDOW_CHROME_RENDER,t,{windowId:e.id,config:e.config})}function mo(e){return{title:e.config.title,icon:e.config.icon,focused:e.element.classList.contains("os-window--focused"),state:e.state}}function ya(e){const t=po(e);if(t===ze)return null;const n=ba(t);if(!n)return null;try{if(n.match&&!n.match(e))return null}catch{return null}e.element.classList.add(kt);let o;try{o=n.render(e.element,{window:e,state:mo(e)})}catch(i){return e.element.classList.remove(kt),m(f.SHELL_ERROR,{scope:"window-chrome-render",windowId:e.id,chromeId:t,error:i}),null}return m(f.WINDOW_CHROME_APPLIED,{windowId:e.id,layer:"chrome",chromeId:t}),{id:t,handle:o}}const go=k("desktop-mode/window-actions-registry",()=>({registry:new Map,listeners:new Set})),va=go.state.registry,_o=go.state.listeners;function Ea(){return Array.from(va.values()).sort((e,t)=>(e.order??100)-(t.order??100))}function Aa(e){return _o.add(e),()=>{_o.delete(e)}}function Sa(e,t){if(typeof e.label=="function")try{return String(e.label(t)??"")}catch{return""}return e.label}function Ca(e,t){if(typeof e.icon=="function")try{return String(e.icon(t)??"")}catch{return""}return e.icon??""}function ka(e,t){if(!e.checkable||typeof e.checked!="function")return!1;try{return!!e.checked(t)}catch{return!1}}function xa(e,t){if(typeof e.isVisible!="function")return!0;try{return!!e.isVisible(t)}catch{return!1}}function bo(e){const t=e.element.querySelector(".os-window__menu-panel");t&&(t.hidden?wo(e):V(e))}function wo(e){const t=e.element.querySelector(".os-window__menu-panel"),n=e.element.querySelector(".os-window__menu-btn");if(!t||!n)return;t.hidden=!1,n.setAttribute("aria-expanded","true");const o=t.querySelector(".os-window__menu-item--startup");o&&xt(e,o),vo(e,t),e._unsubscribeWindowActions?.(),e._unsubscribeWindowActions=Aa(()=>{t.hidden||vo(e,t)}),m(f.WINDOW_MENU_OPENED,{windowId:e.id,element:t}),e._boundOnDocumentPointerDown||(e._boundOnDocumentPointerDown=s=>{const r=s.target;r&&(t.contains(r)||n.contains(r)||V(e))}),setTimeout(()=>{e._boundOnDocumentPointerDown&&document.addEventListener("pointerdown",e._boundOnDocumentPointerDown,!0)},0),t.querySelector('[role="menuitem"]')?.focus()}function V(e){const t=e.element.querySelector(".os-window__menu-panel"),n=e.element.querySelector(".os-window__menu-btn");t&&(t.hidden=!0),n&&n.setAttribute("aria-expanded","false"),e._boundOnDocumentPointerDown&&document.removeEventListener("pointerdown",e._boundOnDocumentPointerDown,!0),e._unsubscribeWindowActions?.(),e._unsubscribeWindowActions=null}function yo(e){e.hasAttribute("checked")?e.removeAttribute("checked"):e.setAttribute("checked","")}function xt(e,t){const n=window.wp?.os?.config?.defaultWindow;let o=!1;if(n&&n.enabled&&typeof n.url=="string")if(e.config.native)o=n.url===`native:${e.id}`;else try{const i=Y(e.getCurrentUrl()),s=Y(n.url);o=i===s}catch{o=!1}o?t.setAttribute("checked",""):t.removeAttribute("checked")}function vo(e,t){for(const n of Array.from(t.querySelectorAll(".os-window__menu-item--action")))n.remove();for(const n of Ea()){if(!xa(n,e))continue;const o=Sa(n,e);if(!o)continue;const i=document.createElement("os-menu-item");if(i.setAttribute("value",n.id),i.classList.add("os-window__menu-item"),i.classList.add("os-window__menu-item--action"),i.setAttribute("data-action-id",n.id),i.textContent=o,n.checkable)i.setAttribute("role","menuitemcheckbox"),ka(n,e)&&i.setAttribute("checked","");else{i.setAttribute("role","menuitem");const r=Ca(n,e);r&&i.setAttribute("icon",r)}const s=n.closeOnSelect??!n.checkable;i.addEventListener("os-menu-item-click",r=>{r.stopPropagation(),n.checkable&&yo(i),s&&V(e);try{n.onSelect(e)}catch(d){typeof console<"u"&&console.error(`[openstation] window action "${n.id}" threw:`,d)}}),t.appendChild(i)}}const Ta={minDurationMs:1e3,minReversals:5,minAmplitudePx:14,maxGapMs:320,cooldownMs:600},Ia="os-pointer-shake";function La(e={}){const t={...Ta,...e};let n={origin:0,dir:0,extent:0},o={origin:0,dir:0,extent:0},i=[],s=!1,r=-1/0;const d=()=>{n={origin:0,dir:0,extent:0},o={origin:0,dir:0,extent:0},i=[],s=!1},a=(l,u)=>{if(l.dir===0){const g=u-l.origin;return Math.abs(g)>=t.minAmplitudePx&&(l.dir=g>0?1:-1,l.extent=Math.abs(g)),!1}const p=(u-l.origin)*l.dir;if(p>=l.extent)return l.extent=p,!1;if(l.extent-p>=t.minAmplitudePx){const g=l.origin+l.dir*l.extent;return l.origin=g,l.dir=l.dir===1?-1:1,l.extent=l.extent-p,l.extent>=0}return!1};return{feed:(l,u,p)=>{if(p<r)return null;if(!s)return s=!0,n.origin=l,o.origin=u,null;const g=i[i.length-1];g&&p-g.t>t.maxGapMs&&(i=[]);const b=a(n,l),y=a(o,u);if(b&&i.push({t:p,axis:"x"}),y&&i.push({t:p,axis:"y"}),!b&&!y||i.length<t.minReversals)return null;const w=p-i[0].t;if(w<t.minDurationMs)return null;let S=0;for(const C of i)C.axis==="x"&&S++;const E={x:l,y:u,durationMs:w,reversals:i.length,axis:S*2>=i.length?"x":"y"};return d(),r=p+t.cooldownMs,E},reset:d}}function Na(e,t){e.dispatchEvent(new CustomEvent(Ia,{detail:t,bubbles:!0,composed:!0}))}function Eo(e,t){let n=!1;return()=>{n||(n=!0,requestAnimationFrame(()=>{if(n=!1,!(t==="drag"&&!e._isDragging)&&!(t==="resize"&&!e._isResizing)&&!(e._isDestroyed||!e.element.isConnected))try{m(f.WINDOW_BOUNDS_CHANGED,{windowId:e.id,x:e.element.offsetLeft,y:e.element.offsetTop,width:e.element.offsetWidth,height:e.element.offsetHeight,state:e.state,phase:t})}catch{}}))}}function Ra(e,t){const n=t.target;if(n.closest(".os-window__btn")||n.closest(".os-window__custom-buttons")||n.closest(".os-window__controls")||n.closest(".os-window__screen-meta")||n.closest(".os-window__menu-btn")||n.closest(".os-window__menu-panel")||Ut())return;const o=e.state==="maximized",i=e.state==="snapped-left"||e.state==="snapped-right",s=o||i,r=t.clientX,d=t.clientY,a=t.pointerId,c=s?Oa(e,t):null;e._titleBar.setPointerCapture(a);const l=e.snapConfigProvider?.()??{enabled:!1,cellWidth:0,cellHeight:0},u=Eo(e,"drag"),p=La();let g=!1,b=r,y=d;const w=(h,v,I)=>{h===g||!e._isDragging||(g=h,e.onDragGesture?.(e,{type:"modifier",active:h,clientX:v,clientY:I}))},S=h=>{h.key==="Alt"&&(h.preventDefault(),w(h.type==="keydown",b,y))};let E=!1;const C=(h,v)=>{if(E)return;E=!0;let I,H;if(c){const P=Da(e,c,h,v);I=P.left,H=P.top}else I=e.element.offsetLeft,H=e.element.offsetTop;e.element.classList.add("os-window--dragging"),l.enabled&&e.element.classList.add("os-window--snap-drag"),e._isDragging=!0,e._dragOffsetX=h-I,e._dragOffsetY=v-H,window.addEventListener("keydown",S),window.addEventListener("keyup",S),m(f.WINDOW_DRAG_START,{windowId:e.id})};s||C(r,d);const N=h=>{if(!E){const F=h.clientX-r,Ce=h.clientY-d;if(F*F+Ce*Ce<Ts)return;C(h.clientX,h.clientY)}if(!e._isDragging)return;let v=h.clientX-e._dragOffsetX,I=h.clientY-e._dragOffsetY;const H=e.element.parentElement;if(H){const F=Pa(v,I,e.element.offsetWidth,{x:0,y:0,width:H.clientWidth,height:H.clientHeight});v=F.x,I=F.y}l.enabled&&(v=Math.round(v/l.cellWidth)*l.cellWidth,I=Math.round(I/l.cellHeight)*l.cellHeight),e.element.style.left=`${v}px`,e.element.style.top=`${I}px`,b=h.clientX,y=h.clientY,w(h.altKey,h.clientX,h.clientY),e.onDragMove?.(e,h.clientX,h.clientY);const P=p.feed(h.clientX,h.clientY,h.timeStamp);P&&(Na(e.element,P),m(f.POINTER_SHAKE,{...P,windowId:e.id}),e.onDragGesture?.(e,{type:"shake",clientX:h.clientX,clientY:h.clientY})),u()},D=()=>{try{e._titleBar.releasePointerCapture(a)}catch{}},Se=()=>{e._titleBar.removeEventListener("pointermove",N),e._titleBar.removeEventListener("pointerup",j),e._titleBar.removeEventListener("pointercancel",j),e._titleBar.removeEventListener("lostpointercapture",j),window.removeEventListener("keydown",S),window.removeEventListener("keyup",S),p.reset()},j=()=>{if(!E){D(),Se();return}if(!e._isDragging||(e._isDragging=!1,e.element.classList.remove("os-window--dragging"),e.element.classList.remove("os-window--snap-drag"),D(),Se(),e.onDragEnd?.(e)??!1))return;e._gridSpan=null,e._emitChange("moved");const v={windowId:e.id,x:e.element.offsetLeft,y:e.element.offsetTop};m(f.WINDOW_DRAG_END,v),m(f.WINDOW_MOVED,v)};e._titleBar.addEventListener("pointermove",N),e._titleBar.addEventListener("pointerup",j),e._titleBar.addEventListener("pointercancel",j),e._titleBar.addEventListener("lostpointercapture",j)}function Oa(e,t){const n=e._titleBar.getBoundingClientRect(),o=n.width>0?(t.clientX-n.left)/n.width:.5,i=e.element.parentElement,s=i?Ye(i):null,r=s?Math.min(960,Math.round(s.width*.6)):640,d=s?Math.min(640,Math.round(s.height*.7)):480,a=e._savedGeometry?.width??r,c=e._savedGeometry?.height??d,l=i?.getBoundingClientRect();return{isMaximized:e.state==="maximized",cursorRatioX:o,titleBarHeight:n.height,areaLeft:l?.left??0,areaTop:l?.top??0,targetW:a,targetH:c}}function Da(e,t,n,o){e.element.classList.remove("os-window--maximized","os-window--snapped-left","os-window--snapped-right"),e.element.style.width=`${t.targetW}px`,e.element.style.height=`${t.targetH}px`;const i=Math.max(B,Math.round(n-t.areaLeft-t.targetW*t.cursorRatioX)),s=Math.max(B,Math.round(o-t.areaTop-t.titleBarHeight/2));return e.element.style.left=`${i}px`,e.element.style.top=`${s}px`,e.state="normal",e._emitChange("state"),t.isMaximized&&m(f.WINDOW_UNMAXIMIZED,{windowId:e.id}),{left:i,top:s}}function Wa(e,t){if(e.state==="maximized"||e.state==="fullscreen")return;t.preventDefault(),t.stopPropagation();const n=t.target,o=n.dataset.dir??"se";e._isResizing=!0,e._resizeStartX=t.clientX,e._resizeStartY=t.clientY,e._resizeStartW=e.element.offsetWidth,e._resizeStartH=e.element.offsetHeight;const i=e.element.offsetLeft,s=e.element.offsetTop;n.setPointerCapture(t.pointerId),e.element.classList.add("os-window--resizing"),m(f.WINDOW_RESIZE_START,{windowId:e.id});const r=Eo(e,"resize"),d=e.snapConfigProvider?.()??{enabled:!1,cellWidth:0,cellHeight:0};d.enabled&&e.element.classList.add("os-window--snap-drag"),(e.state==="snapped-left"||e.state==="snapped-right")&&(e.element.classList.remove("os-window--snapped-left","os-window--snapped-right"),e.state="normal");const a=l=>{if(!e._isResizing)return;const u=l.clientX-e._resizeStartX,p=l.clientY-e._resizeStartY,g=Ma(o,u,p,i,s,e._resizeStartW,e._resizeStartH,e.config.minWidth,e.config.minHeight,d);e.element.style.left=`${g.x}px`,e.element.style.top=`${g.y}px`,e.element.style.width=`${g.width}px`,e.element.style.height=`${g.height}px`,r()},c=()=>{if(!e._isResizing)return;e._isResizing=!1,e.element.classList.remove("os-window--resizing"),e.element.classList.remove("os-window--snap-drag"),n.removeEventListener("pointermove",a),n.removeEventListener("pointerup",c),n.removeEventListener("pointercancel",c),n.removeEventListener("lostpointercapture",c),e._gridSpan=null,e._emitChange("resized");const l={windowId:e.id,width:e.element.offsetWidth,height:e.element.offsetHeight};m(f.WINDOW_RESIZE_END,l),m(f.WINDOW_RESIZED,l)};n.addEventListener("pointermove",a),n.addEventListener("pointerup",c),n.addEventListener("pointercancel",c),n.addEventListener("lostpointercapture",c)}function Ma(e,t,n,o,i,s,r,d,a,c){let l=s,u=r,p=o,g=i;if((e==="ne"||e==="se")&&(l=Math.max(d,s+t)),e==="nw"||e==="sw"){const b=Math.max(d,s-t);p=o+(s-b),l=b}if((e==="se"||e==="sw")&&(u=Math.max(a,r+n)),e==="ne"||e==="nw"){const b=Math.max(a,r-n);g=i+(r-b),u=b}if(c.enabled){const b=Math.max(d,Math.round(l/c.cellWidth)*c.cellWidth),y=Math.max(a,Math.round(u/c.cellHeight)*c.cellHeight);(e==="nw"||e==="sw")&&(p=o+(l-b)),(e==="nw"||e==="ne")&&(g=i+(u-y)),l=b,u=y}if(p<B){const b=B-p;p=B,l=Math.max(d,l-b)}if(g<B){const b=B-g;g=B,u=Math.max(a,u-b)}return{x:p,y:g,width:l,height:u}}function Pa(e,t,n,o){const i=o.x+ft-n,s=o.x+o.width-ft,r=Math.max(i,Math.min(e,s)),d=o.y+B,a=o.y+o.height-ft,c=Math.max(d,Math.min(t,a));return{x:r,y:c}}const $a="os-speculate-doc",Ao=new Map,za=1e3;function Ha(e){if(typeof navigator>"u"||!("serviceWorker"in navigator)||!navigator.serviceWorker.controller)return;let t;try{const i=new URL(e,window.location.href);if(i.origin!==window.location.origin)return;t=i.toString()}catch{return}const n=Date.now(),o=Ao.get(t);if(!(o!==void 0&&n-o<za)){Ao.set(t,n);try{navigator.serviceWorker.controller.postMessage({type:$a,url:t})}catch{}}}const Tt=window.location.origin,Fa="os-window-open",Ua=300;function Ga(e){if(!window.wp?.os?.getOsSettings?.().windowPrewarmEnabled)return;const n=fe(e);n&&Ha(n)}const Ba=120,ae=class ae{constructor(t){if(this.state="normal",this._activityCount=0,this._activityPhase="idle",this._activityError=null,this._activityClearTimer=null,this._activitySavingStartedAt=0,this._activitySettleTimer=null,this._navigationActivity="none",this._navigationActivityTimer=null,this._isDragging=!1,this._isResizing=!1,this._isDestroyed=!1,this._dragOffsetX=0,this._dragOffsetY=0,this._resizeStartX=0,this._resizeStartY=0,this._resizeStartW=0,this._resizeStartH=0,this._savedGeometry=null,this._gridSpan=null,this._savedFullscreenState=null,this._stateBeforeMinimize=null,this._minimizeAnimation=null,this._restoreAnimation=null,this._externalTabs=new Map,this._externalTabSeq=0,this._titleBarButtonsUnsubscribe=null,this._windowThemesUnsubscribe=null,this._windowControlsUnsubscribe=null,this._windowControlsTeardown=null,this._windowSlotsUnsubscribe=null,this._windowSlotsTeardown=null,this._chromeHandle=null,this._chromeId=ze,this._windowChromesUnsubscribe=null,this._nativeRenderTeardown=null,this._nativeRenderCtxDispose=null,this._closeSafetyNetTimer=null,this._clearOpeningClassRemoval=null,this._onCloseTransitionEnd=null,this._isFinalized=!1,this._iframeBridgeReady=!1,this._iframeCloseTimeout=null,this._closePending=!1,this._unsavedGuardPending=!1,this._deferredNavigationCommit=null,this._deferredNavigationTimer=null,this._activeTabId="primary",this.onFocusRequest=null,this.onClose=null,this.onMinimize=null,this.onRestore=null,this.onOpenAnother=null,this.onOpenInNewWindow=null,this.onToggleStartup=null,this.snapConfigProvider=null,this.onDragMove=null,this.onDragEnd=null,this.onDragGesture=null,this._boundOnDocumentPointerDown=null,this._unsubscribeWindowActions=null,this._bodyResizeObserver=null,this._tabOverflowTeardown=null,this._tabSpeculateTimer=null,this._swapBuffer=null,this._swapBufferTimer=null,this._suppressCloseFilter=!1,this.id=t.id,this.config=t,this.element=Ks(t),this.iframe=t.native?null:this.element.querySelector(".os-window__iframe"),this._titleBar=this.element.querySelector(".os-window__titlebar"),this._titleEl=this.element.querySelector(".os-window__title"),this._boundOnMessage=n=>yr(this,n),this.bindEvents(),this.iframe&&this._wireContentFocusForwarder(this.iframe),this.renderCustomTitleBarButtons(),this._titleBarButtonsUnsubscribe=zr(()=>{this.renderCustomTitleBarButtons()}),St(this,this.config.appearance?.theme),this._windowThemesUnsubscribe=qr(()=>{this._isDestroyed||St(this,this.config.appearance?.theme)}),this.repaintWindowControls(),this._windowControlsUnsubscribe=Qr(()=>{this._isDestroyed||this.repaintWindowControls()}),this.repaintWindowSlots(),this._windowSlotsUnsubscribe=ha(()=>{this._isDestroyed||this.repaintWindowSlots()}),this.remountWindowChrome(),this._windowChromesUnsubscribe=wa(()=>{if(this._isDestroyed)return;po(this)!==this._chromeId&&this.remountWindowChrome()}),this._bodyResizeObserver=this.installBodyResizeObserver(),t.initialState==="minimized"){this.state="minimized",this.element.classList.add("os-window--minimized"),this.iframe&&(this.iframe.style.visibility="hidden"),this.element.style.setProperty("content-visibility","hidden");return}(t.initialState==="snapped-left"||t.initialState==="snapped-right")&&this.element.classList.add(`os-window--${t.initialState}`),document.hidden||(this.element.classList.add("os-window--opening"),this._armOpeningClassRemoval()),t.initialState&&t.initialState!=="normal"&&requestAnimationFrame(()=>this.applyInitialState(t.initialState))}_armOpeningClassRemoval(){const t=this.element;let n=null,o=!1;const i=()=>{o||(o=!0,this._clearOpeningClassRemoval=null,n!==null&&(window.clearTimeout(n),n=null),t.removeEventListener("animationend",s),t.removeEventListener("animationcancel",s),t.classList.remove("os-window--opening"))},s=r=>{r.target!==t||r.animationName!==Fa||i()};t.addEventListener("animationend",s),t.addEventListener("animationcancel",s),n=window.setTimeout(()=>{n=null,i()},Ua),this._clearOpeningClassRemoval=i}hydrateNative(){if(!this.config.native||!this.config.render)return;const t=this.element.querySelector(".os-window__body");if(!t)return;const n=T(f.NATIVE_WINDOW_BEFORE_RENDER,t,{windowId:this.id,config:this.config}),o=n instanceof HTMLElement?n:t,{ctx:i,dispose:s}=ri(this.id,this.config.params??{});this._nativeRenderCtxDispose=s;const r=this.config.render(o,i),d=c=>{typeof c=="function"&&(this._nativeRenderTeardown=c)};r instanceof Promise?r.then(c=>{this._isDestroyed||(d(c),$(this.id))},c=>{typeof console<"u"&&console.error(`[openstation] native render rejected for "${this.id}":`,c),m(f.SHELL_ERROR,{scope:"window-open",id:this.id,error:c}),!this._isDestroyed&&$(this.id)}):(d(r),requestAnimationFrame(()=>{this._isDestroyed||$(this.id)})),m(f.NATIVE_WINDOW_AFTER_RENDER,{windowId:this.id,body:o,config:this.config});const a=this.config.autofocus;a&&requestAnimationFrame(()=>{if(this._isDestroyed)return;if(typeof a=="string"){o.querySelector(a)?.focus();return}o.hasAttribute("tabindex")||(o.tabIndex=-1),o.focus()})}applyInitialState(t){t==="minimized"?this.minimize():t==="maximized"?this.toggleMaximize():t==="fullscreen"?this.toggleFullscreen():t==="snapped-left"?this.applySnap("left"):t==="snapped-right"&&this.applySnap("right")}_emitChange(t){t==="state"&&(this._gridSpan=null),document.dispatchEvent(new CustomEvent("os-window-changed",{detail:{windowId:this.id,reason:t,state:this.state}}))}snapGeometry(t){const n=this.snapConfigProvider?.();if(!n||!n.enabled)return t;const o=Math.max(this.config.minWidth,Math.round(t.width/n.cellWidth)*n.cellWidth),i=Math.max(this.config.minHeight,Math.round(t.height/n.cellHeight)*n.cellHeight);return{x:Math.round(t.x/n.cellWidth)*n.cellWidth,y:Math.round(t.y/n.cellHeight)*n.cellHeight,width:o,height:i}}getCurrentUrl(){if(!this.iframe)return this.config.url||`#${this.id}`;try{const t=this.iframe.contentWindow?.location.href;if(t&&t!=="about:blank")return t}catch{}return this.iframe.src}bindEvents(){this.element.addEventListener("pointerdown",()=>{this.element.classList.contains("os-window--overview")||this.onFocusRequest?.(this)}),this.element.addEventListener("focusin",()=>{this.element.classList.contains("os-window--overview")||this.onFocusRequest?.(this)}),this._titleBar.addEventListener("pointerdown",s=>Ra(this,s)),this.element.querySelectorAll(".os-window__resize-handle").forEach(s=>{s.addEventListener("pointerdown",r=>Wa(this,r))});const n=this.element.querySelector(".os-window__menu-btn"),o=this.element.querySelector(".os-window__menu-panel");if(n&&o){n.addEventListener("click",l=>{l.stopPropagation(),bo(this)});const s=o.querySelector(".os-window__menu-item--open-another");s&&s.addEventListener("os-menu-item-click",l=>{l.stopPropagation(),V(this),this.onOpenAnother?.(this)});const r=o.querySelector(".os-window__menu-item--open-in-new-window");r&&r.addEventListener("os-menu-item-click",l=>{l.stopPropagation(),V(this),this.onOpenInNewWindow?.(this)});const d=o.querySelector(".os-window__menu-item--reload");d&&d.addEventListener("os-menu-item-click",l=>{l.stopPropagation(),V(this),this.reload()});const a=o.querySelector(".os-window__menu-item--open-external");a&&a.addEventListener("os-menu-item-click",l=>{l.stopPropagation(),V(this),this.detach()});const c=o.querySelector(".os-window__menu-item--startup");c&&(xt(this,c),c.addEventListener("os-menu-item-click",l=>{l.stopPropagation(),yo(c),this.onToggleStartup?.(this)}),document.addEventListener("os-default-window-changed",()=>{xt(this,c)})),o.addEventListener("keydown",l=>{l.key==="Escape"&&(l.stopPropagation(),V(this),n.focus())})}this._titleBar.addEventListener("dblclick",s=>{s.target?.closest('button, [role="button"], [role="menuitem"], [role="menuitemcheckbox"], os-window-button, os-menu, os-menu-item, .os-window__menu-panel, .os-window__custom-buttons, input, select, textarea, a')||Ut()||this.toggleMaximize()});const i=this.element.querySelector(".os-window__tabs");if(i&&(i.addEventListener("click",s=>tr(this,s)),i.addEventListener("keydown",s=>oi(i,s)),i.addEventListener("pointerover",s=>{const r=s;if(r.pointerType!=="mouse")return;const d=r.target?.closest?.(".os-window__tab[data-url]"),a=d?.dataset.url;a&&(d?.classList.contains("is-active")||(this._tabSpeculateTimer&&window.clearTimeout(this._tabSpeculateTimer),this._tabSpeculateTimer=window.setTimeout(()=>{this._tabSpeculateTimer=null,Ga(a)},Ba)))}),i.addEventListener("pointerleave",()=>{this._tabSpeculateTimer&&(window.clearTimeout(this._tabSpeculateTimer),this._tabSpeculateTimer=null)}),this._tabOverflowTeardown=or(i)),this.iframe){const s=this.iframe;this._wireTabNavSync(s),window.addEventListener("message",this._boundOnMessage)}}addExternalTab(t,n){Gn(this,t,n)}setTabs(t,n){ii(this.element,t,n)}activateTab(t){Qe(this.element,t)}setZIndex(t){this.element.style.zIndex=String(t)}setFocused(t){this.element.classList.toggle("os-window--focused",t),this._notifyChromeStateChanged()}setTitle(t){const n=this.element.querySelector(".os-window__title");n&&(this._titleEl=n,n.textContent=t),this.config.title=t,m(f.WINDOW_TITLE_CHANGED,{windowId:this.id,title:t}),this._notifyChromeStateChanged()}repaintWindowControls(){const t=this.element.querySelector(".os-window__controls");if(t){if(this._windowControlsTeardown){try{this._windowControlsTeardown()}catch{}this._windowControlsTeardown=null}this._windowControlsTeardown=oa(this,t)}}repaintThemedChrome(){const t=this.element.querySelector(".os-window__slot--icon");if(t){const o=t.querySelector(".os-window__icon");o&&o.replaceWith(aa(this.config.icon,{title:this.config.title,className:"os-window__icon",slot:es(this.config.id)}))}const n=this.element.querySelector(".os-window__menu-btn");n&&(n.querySelectorAll(":scope > .dashicons").forEach(o=>o.remove()),n.removeAttribute("icon-src"),n.setAttribute("icon","menu"),lt(n,"core/menu"))}setAppearanceControls(t){this.config.appearance={...this.config.appearance??{},controls:t??void 0},this.repaintWindowControls()}repaintWindowSlots(){if(this._windowSlotsTeardown){try{this._windowSlotsTeardown()}catch{}this._windowSlotsTeardown=null}this._windowSlotsTeardown=ga(this)}remountWindowChrome(){if(this._chromeHandle){try{this._chromeHandle.destroy()}catch{}this._chromeHandle=null}this.element.classList.remove(kt);const t=ya(this);t?(this._chromeHandle=t.handle,this._chromeId=t.id):this._chromeId=ze}setAppearanceChrome(t){this.config.appearance={...this.config.appearance??{},chrome:t??void 0},this.remountWindowChrome()}_notifyChromeStateChanged(){if(!this._isDestroyed&&this._chromeHandle?.update)try{this._chromeHandle.update(mo(this))}catch{}}setAppearanceSlot(t,n){const i={...this.config.appearance?.slots??{}};n===void 0?delete i[t]:i[t]=n,this.config.appearance={...this.config.appearance??{},slots:i},this.repaintWindowSlots()}setAppearanceTheme(t){let n;t==null?n=void 0:typeof t=="string"?n={themeId:t}:typeof t=="object"&&("themeId"in t||"tokens"in t)?n=t:typeof t=="object"&&(n={tokens:t}),this.config.appearance={...this.config.appearance??{},theme:n},St(this,n)}applySnap(t){this._applySnapVisuals(t)&&(this.state=t==="left"?"snapped-left":"snapped-right",this._emitChange("state"))}_applySnapVisuals(t){const n=this.element.parentElement;if(!n)return!1;const o=Ye(n),i=Math.floor(o.width/2);return this.element.classList.remove("os-window--maximized","os-window--fullscreen","os-window--snapped-left","os-window--snapped-right"),this.element.classList.add(`os-window--snapped-${t}`),this.element.style.left=`${t==="left"?o.x:o.x+o.width-i}px`,this.element.style.top=`${o.y}px`,this.element.style.width=`${i}px`,this.element.style.height=`${o.height}px`,!0}isMinimized(){return this.state==="minimized"}isMaximized(){return this.state==="maximized"}isFullscreen(){return this.state==="fullscreen"}isSnapped(t){return t==="left"?this.state==="snapped-left":t==="right"?this.state==="snapped-right":this.state==="snapped-left"||this.state==="snapped-right"}isFocused(){return this.element.classList.contains("os-window--focused")}_prefersReducedMotion(){try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!1}}_getDockTarget(){const t=[],n=s=>{typeof s=="string"&&s!==""&&!t.includes(s)&&t.push(s)};n(this.id),n(this.config.baseId);for(const s of t){let r=s;try{typeof CSS<"u"&&typeof CSS.escape=="function"&&(r=CSS.escape(s))}catch{r=s}const d=[`.os-dock__item[data-os-window-base-id="${r}"] .os-dock__item-primary`,`.os-dock__item[data-os-window-base-id="${r}"]`,`.os-dock__item[data-menu-slug="${r}"] .os-dock__item-primary`,`.os-dock__item[data-system-id="${r}"] .os-dock__item-primary`,`.os-dock__item[data-nav-id="${r}"] .os-dock__item-primary`,`.os-dock__item[data-menu-slug="${r}"]`,`.os-dock__item[data-system-id="${r}"]`,`.os-dock__item[data-nav-id="${r}"]`];for(const a of d){const c=document.querySelector(a);if(c){const l=c.getBoundingClientRect();if(l.width>0&&l.height>0)return c}}}const o=['.os-dock__item[data-os-window-base-id="os-system"] .os-dock__item-primary','.os-dock__item[data-system-id="os-system"] .os-dock__item-primary','.os-dock__item[data-os-window-base-id="os-system"]','.os-dock__item[data-system-id="os-system"]'];if(this.id==="desktop-mode-os-settings"||this.id==="os-settings"||this.config.baseId==="desktop-mode-os-settings")for(const s of o){const r=document.querySelector(s);if(r){const d=r.getBoundingClientRect();if(d.width>0&&d.height>0)return r}}const i=document.querySelector("#os-dock")??document.querySelector(".os-dock");if(i){const s=i.getBoundingClientRect();if(s.width>0&&s.height>0)return i}return null}_clearGenieStyles(){this.element.style.removeProperty("will-change"),this.element.style.removeProperty("transform"),this.element.style.removeProperty("opacity")}_cancelGenieAnimation(t){const n=t==="minimize",o=n?this._minimizeAnimation:this._restoreAnimation;if(o){try{o.cancel()}catch{}n?(this._minimizeAnimation=null,this.element.classList.remove("os-window--minimizing")):(this._restoreAnimation=null,this.element.classList.remove("os-window--restoring")),this._clearGenieStyles()}}_buildGenieTransform(t,n,o){const i=n.left+n.width/2-(t.left+t.width/2),s=n.top+n.height/2-(t.top+t.height/2),r=Math.min(n.width/t.width,n.height/t.height);return{dx:i,dy:s,scale:Math.max(.06,Math.min(r,o))}}_canGenieAnimate(t){return!!t&&!this._prefersReducedMotion()&&typeof this.element.animate=="function"&&!document.hidden&&!this.element.classList.contains("os-window--overview")}_installMinimizeContentVisibilityGuard(){const t=()=>{this.state==="minimized"&&!this.element.classList.contains("os-window--overview")&&(this.iframe&&(this.iframe.style.visibility="hidden"),this.element.style.setProperty("content-visibility","hidden"))};t(),this.element.addEventListener("transitionend",n=>{n.propertyName==="opacity"&&t()},{once:!0})}minimize(){if(this.state==="minimized")return;this._cancelGenieAnimation("restore"),this._cancelGenieAnimation("minimize"),this._stateBeforeMinimize=this.state;const t=this._getDockTarget();if(this._canGenieAnimate(t)){const n=this.element.getBoundingClientRect(),o=t.getBoundingClientRect();if(n.width>0&&n.height>0&&o.width>0&&o.height>0){this.state="minimized",this.element.classList.add("os-window--minimizing"),this.element.style.willChange="transform";const{dx:s,dy:r,scale:d}=this._buildGenieTransform(n,o,.22);let a=null;try{a=this.element.animate([{transform:"translate(0px, 0px) scale(1)",opacity:1},{offset:.6,transform:`translate(${s*.6}px, ${r*.6}px) scale(${1-(1-d)*.6})`,opacity:1},{transform:`translate(${s}px, ${r}px) scale(${d})`,opacity:0}],{duration:480,easing:"cubic-bezier(0.32, 0.72, 0, 1)",fill:"forwards"})}catch{a=null}if(a){this._minimizeAnimation=a,a.onfinish=()=>{if(this._minimizeAnimation===a){this._minimizeAnimation=null,this.element.classList.add("os-window--minimized"),this.element.classList.remove("os-window--minimizing"),this._clearGenieStyles();try{a.cancel()}catch{}this._installMinimizeContentVisibilityGuard()}},a.oncancel=()=>{this._minimizeAnimation===a&&(this._minimizeAnimation=null,this.element.classList.remove("os-window--minimizing"),this._clearGenieStyles())},this.onMinimize?.(this),this._emitChange("state"),m(f.WINDOW_MINIMIZED,{windowId:this.id,element:this.element}),this._stateBeforeMinimize==="fullscreen"&&J();return}this.element.classList.remove("os-window--minimizing"),this._clearGenieStyles()}}this.state="minimized",this.element.classList.add("os-window--minimized"),this._installMinimizeContentVisibilityGuard(),this.onMinimize?.(this),this._emitChange("state"),m(f.WINDOW_MINIMIZED,{windowId:this.id,element:this.element}),this._stateBeforeMinimize==="fullscreen"&&J()}restore(){this._cancelGenieAnimation("minimize"),this._cancelGenieAnimation("restore");const t=this.state==="minimized",n=t?this._getDockTarget():null;if(t&&this._canGenieAnimate(n)){this.element.style.removeProperty("content-visibility"),this.iframe&&(this.iframe.style.visibility=""),this.element.classList.remove("os-window--minimized"),this.element.classList.add("os-window--restoring"),this.element.style.willChange="transform";const o=this._stateBeforeMinimize??"normal";this.state=o,this._stateBeforeMinimize=null,o==="fullscreen"&&(J(),this.updateFocusButtonState());const i=this.element.getBoundingClientRect(),s=n.getBoundingClientRect();if(i.width>0&&i.height>0&&s.width>0&&s.height>0){const{dx:d,dy:a,scale:c}=this._buildGenieTransform(i,s,.24);let l=null;try{l=this.element.animate([{transform:`translate(${d}px, ${a}px) scale(${c})`,opacity:0},{offset:.4,transform:`translate(${d*.4}px, ${a*.4}px) scale(${1-(1-c)*.4})`,opacity:1},{transform:"translate(0px, 0px) scale(1)",opacity:1}],{duration:480,easing:"cubic-bezier(0.32, 0.72, 0, 1)",fill:"forwards"})}catch{l=null}if(l){this._restoreAnimation=l;const u=()=>{if(this._restoreAnimation===l){this._restoreAnimation=null,this.element.classList.remove("os-window--restoring"),this._clearGenieStyles();try{l.cancel()}catch{}}};l.onfinish=u,l.oncancel=()=>{this._restoreAnimation===l&&(this._restoreAnimation=null,this.element.classList.remove("os-window--restoring"),this._clearGenieStyles())},this.onRestore?.(this),this.onFocusRequest?.(this),this._emitChange("state"),m(f.WINDOW_RESTORED,{windowId:this.id,element:this.element});return}}this.element.classList.remove("os-window--restoring"),this._clearGenieStyles(),this.onRestore?.(this),this.onFocusRequest?.(this),this._emitChange("state"),m(f.WINDOW_RESTORED,{windowId:this.id,element:this.element});return}this.element.style.removeProperty("content-visibility"),this.iframe&&(this.iframe.style.visibility=""),this.element.classList.remove("os-window--minimized"),t&&(this.state=this._stateBeforeMinimize??"normal",this._stateBeforeMinimize=null,this.state==="fullscreen"&&(J(),this.updateFocusButtonState())),t&&this.onRestore?.(this),this.onFocusRequest?.(this),this._emitChange("state"),t&&m(f.WINDOW_RESTORED,{windowId:this.id,element:this.element})}maximize(){this.state!=="maximized"&&(this.state==="normal"&&(this._savedGeometry={x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight}),this._applyMaximizeVisuals()&&(this.state="maximized",this._emitChange("state"),m(f.WINDOW_MAXIMIZED,{windowId:this.id,element:this.element})))}_applyMaximizeVisuals(){const t=this.element.parentElement;if(!t)return!1;this.element.classList.remove("os-window--fullscreen","os-window--snapped-left","os-window--snapped-right"),this.element.classList.add("os-window--maximized");const n=Ye(t);return this.element.style.left=`${n.x}px`,this.element.style.top=`${n.y}px`,this.element.style.width=`${n.width}px`,this.element.style.height=`${n.height}px`,!0}toggleMaximize(){if(this.element.parentElement){if(this.state==="maximized"){if(this.element.classList.remove("os-window--maximized"),this._savedGeometry){const n=this.snapGeometry(this._savedGeometry);this.element.style.left=`${n.x}px`,this.element.style.top=`${n.y}px`,this.element.style.width=`${n.width}px`,this.element.style.height=`${n.height}px`,this._savedGeometry=n}this.state="normal",this._emitChange("state"),m(f.WINDOW_UNMAXIMIZED,{windowId:this.id,element:this.element});return}if(this.state==="fullscreen"){this._savedFullscreenState=null,this._applyMaximizeVisuals(),this.state="maximized",J(),this.updateFocusButtonState(),this._emitChange("state"),m(f.WINDOW_FULLSCREEN_EXITED,{windowId:this.id,element:this.element}),m(f.WINDOW_MAXIMIZED,{windowId:this.id,element:this.element});return}this.maximize()}}toggleFullscreen(){if(this.state==="fullscreen"){this.element.classList.remove("os-window--fullscreen");const t=this._savedFullscreenState;this._savedFullscreenState=null;let n=!1;if(t&&t.state==="maximized")this._applyMaximizeVisuals(),this.state="maximized",n=!0;else if(t&&(t.state==="snapped-left"||t.state==="snapped-right")){const o=t.state==="snapped-left"?"left":"right";this._applySnapVisuals(o),this.state=t.state}else t?(this.element.style.left=`${t.x}px`,this.element.style.top=`${t.y}px`,this.element.style.width=`${t.width}px`,this.element.style.height=`${t.height}px`,this.state="normal"):this.state="normal";J(),this.updateFocusButtonState(),this._emitChange("state"),m(f.WINDOW_FULLSCREEN_EXITED,{windowId:this.id,element:this.element}),n&&m(f.WINDOW_MAXIMIZED,{windowId:this.id,element:this.element});return}this.state==="normal"&&(this._savedGeometry={x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight}),this._savedFullscreenState={state:this.state,x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight},this.element.classList.remove("os-window--maximized","os-window--snapped-left","os-window--snapped-right"),this.element.classList.add("os-window--fullscreen"),this.state="fullscreen",J(),this.updateFocusButtonState(),this._emitChange("state"),m(f.WINDOW_FULLSCREEN_ENTERED,{windowId:this.id,element:this.element})}updateFocusButtonState(){const t=this.element.querySelector(".os-window__btn--focus");if(!t)return;const n=this.state==="fullscreen";t.classList.toggle("os-window__btn--active",n),t.setAttribute("aria-pressed",n?"true":"false"),t.setAttribute("aria-label",_(n?"Exit fullscreen":"Enter fullscreen"))}detach(){const t=this.getCurrentUrl();let n;try{n=new URL(t,Tt)}catch{return}n.origin===Tt&&(n.searchParams.delete("openstation_chromeless"),n.searchParams.delete("desktop_mode_portal"),n.searchParams.set("desktop_mode_classic","1"),window.open(n.toString(),"_blank","noopener"),m(f.WINDOW_DETACHED,{windowId:this.id,url:n.toString()}))}reload(){if(this.element.querySelector(".os-window__body")?.classList.contains("os-window__body--loading")||this._unsavedGuardPending)return;if(this.config.native){this._reloadNative();return}let n,o;if(this._activeTabId==="primary"){if(!this.iframe)return;const r=this.iframe;n=this.getCurrentUrl(),o=()=>{try{r.contentWindow?.location.reload()}catch{r.src=r.src}}}else{const r=this._externalTabs.get(this._activeTabId);if(!r)return;n=r.url,o=()=>{try{r.iframe.contentWindow?.location.reload()}catch{r.iframe.src=r.url}}}this._spinReloadButton();const i=()=>{this.markContentLoading()},s=()=>{o(),m(f.WINDOW_RELOADED,{windowId:this.id,url:n})};this._activeTabId==="primary"?_t(this,{commit:i,navigate:s}):(i(),s())}_reloadNative(){if(!this.config.render)return;const t=this.element.querySelector(".os-window__body");if(t){if(this._nativeRenderCtxDispose){try{this._nativeRenderCtxDispose()}catch(n){m(f.SHELL_ERROR,{scope:"native-window-ctx-dispose",id:this.id,error:n})}this._nativeRenderCtxDispose=null}if(this._nativeRenderTeardown){try{this._nativeRenderTeardown()}catch(n){m(f.SHELL_ERROR,{scope:"native-window-teardown",id:this.id,error:n})}this._nativeRenderTeardown=null}t.replaceChildren(),this._spinReloadButton(),this.markContentLoading(),this.hydrateNative(),m(f.WINDOW_RELOADED,{windowId:this.id,url:this.config.url??""})}}navigateTo(t){if(this.config.native||!this.iframe)return!1;const n=fe(t);return n?(_t(this,{commit:()=>{this.markContentLoading(),pe(this,t)},navigate:()=>{const o=this.iframe?.contentWindow;if(o)try{o.location.assign(n);return}catch{}this.iframe&&(this.iframe.src=n)}}),!0):!1}_wireContentFocusForwarder(t){const n=()=>{let o=null;try{o=t.contentDocument}catch{return}o&&(o.location&&o.location.pathname.indexOf("/wp-admin/")!==-1||o.addEventListener("pointerdown",()=>{this.element.classList.contains("os-window--overview")||this.onFocusRequest?.(this)},{capture:!0,passive:!0}))};t.addEventListener("load",n),n()}_wireTabNavSync(t){t.addEventListener("load",()=>{try{const n=t.contentWindow?.location.href;if(!n||Lr(this,n))return;Nr(this),pe(this,n)}catch{}})}_discardSwapBuffer(){this._swapBufferTimer!==null&&(window.clearTimeout(this._swapBufferTimer),this._swapBufferTimer=null),this._swapBuffer&&(this._swapBuffer.remove(),this._swapBuffer=null,this.iframe?.classList.remove("os-window__iframe--swap-front"))}swapReload(t){if(this.config.native||!this.iframe||this._isDestroyed)return;if(this._activeTabId!=="primary"){this.reload();return}const n=t?fe(t):this.getCurrentUrl();if(!n)return;this._discardSwapBuffer();const o=this.iframe;o.classList.add("os-window__iframe--swap-front");const i=document.createElement("iframe");i.className="os-window__iframe os-window__iframe--buffer",i.setAttribute("aria-hidden","true"),i.setAttribute("name",`os-frame-${this.id}-buffer`),this._swapBuffer=i,this._swapBufferTimer=window.setTimeout(()=>{this._swapBuffer===i&&this._discardSwapBuffer()},2e4),i.addEventListener("load",()=>{if(this._swapBuffer!==i||this._isDestroyed)return;this._swapBuffer=null,this._swapBufferTimer!==null&&(window.clearTimeout(this._swapBufferTimer),this._swapBufferTimer=null);let s=0,r=0;try{s=o.contentWindow?.scrollX??0,r=o.contentWindow?.scrollY??0}catch{}if(s||r)try{i.contentWindow?.scrollTo(s,r)}catch{}i.classList.remove("os-window__iframe--buffer"),i.removeAttribute("aria-hidden"),i.setAttribute("name",`os-frame-${this.id}`),o.remove(),this.iframe=i,$(this.id),ht(i),i.addEventListener("load",()=>{$(this.id),ht(i)}),this._wireContentFocusForwarder(i),this._wireTabNavSync(i),pe(this,n),m(f.WINDOW_RELOADED,{windowId:this.id,url:n,silent:!0})},{once:!0}),o.insertAdjacentElement("afterend",i),i.src=n}_spinReloadButton(){const t=this.element.querySelector(".os-window__btn--reload");t instanceof HTMLElement&&(t.classList.remove("os-window__btn--spinning"),t.offsetWidth,t.classList.add("os-window__btn--spinning"),t.addEventListener("animationend",()=>{t.classList.remove("os-window__btn--spinning")},{once:!0}))}renderCustomTitleBarButtons(){const t=this.element.querySelector(".os-window__custom-buttons--left"),n=this.element.querySelector(".os-window__custom-buttons--right");if(!t||!n)return;t.innerHTML="",n.innerHTML="";const{left:o,right:i}=$r(this),s=(r,d)=>{for(const a of d){const c=document.createElement("os-window-button");if(Zn(c,a.icon),c.setAttribute("aria-label",a.label),c.setAttribute("title",a.label),c.classList.add("os-window__btn"),c.classList.add("os-window__btn--custom"),c.dataset.buttonId=a.id,r.appendChild(c),typeof a.render=="function")try{a.render(c,this)}catch(l){typeof console<"u"&&console.error("[openstation] title-bar-button render threw:",a.id,l)}else typeof a.onClick=="function"&&c.addEventListener("os-button-activate",l=>{try{a.onClick(this,l)}catch(u){typeof console<"u"&&console.error("[openstation] title-bar-button onClick threw:",a.id,u)}})}};s(t,o),s(n,i)}send(t,n){if(typeof t!="string"||t==="")return;const o=this.iframe??Vo(this.id);if(!o){Uo(this.id,t,n);return}const i=()=>{try{o.contentWindow?.postMessage({type:"os-window-send",channel:t,payload:n},Tt)}catch(s){typeof console<"u"&&console.error("[openstation] Window.send: postMessage failed",s)}};if(Ft(this.id)){i();return}Go(this.id,t,n,i)}on(t,n){return typeof t!="string"||t===""||typeof n!="function"?()=>{}:Ho(this.id,t,n)}markContentLoading(){Ie(this.id)}markContentLoaded(){$(this.id)}whenContentReady(){return Ft(this.id)?Promise.resolve():new Promise(t=>{const n=this.id,o=i=>{const s=i.detail;!s||s.windowId!==n||(document.removeEventListener("os-window-content-loaded",o),t())};document.addEventListener("os-window-content-loaded",o)})}markActivity(t,n={}){this._activityPhase=t,this._activityError=n.error??null,this._paintActivityIndicator()}_resetActivity(){this._activitySettleTimer!==null&&(window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=null),this._activityClearTimer!==null&&(window.clearTimeout(this._activityClearTimer),this._activityClearTimer=null),this._activityCount=0,this._activityPhase="idle",this._activityError=null,this._paintActivityIndicator()}_deferNavigationCommit(t,n){this._clearDeferredNavigation(),this._deferredNavigationCommit=t,this._deferredNavigationTimer=window.setTimeout(()=>{this._deferredNavigationTimer=null,this._deferredNavigationCommit=null},n)}_commitDeferredNavigation(){const t=this._deferredNavigationCommit;this._clearDeferredNavigation(),!(!t||this._isDestroyed)&&t()}_clearDeferredNavigation(){this._deferredNavigationTimer!==null&&(window.clearTimeout(this._deferredNavigationTimer),this._deferredNavigationTimer=null),this._deferredNavigationCommit=null}_noteNavigationActivity(){this._navigationActivity="pending",this._navigationActivityTimer!==null&&window.clearTimeout(this._navigationActivityTimer),this._navigationActivityTimer=window.setTimeout(()=>{this._navigationActivityTimer=null,this._navigationActivity="none",this._resetActivity()},ae.NAVIGATION_ACTIVITY_TIMEOUT_MS)}_settleNavigationActivity(t=!1){const n=this._navigationActivity!=="none";return this._navigationActivity==="pending"&&(this._navigationActivity="settled",this._navigationActivityTimer!==null&&(window.clearTimeout(this._navigationActivityTimer),this._navigationActivityTimer=null),this._resetActivity(),this._finalizeActivitySettle(!0)),t&&(this._navigationActivity="none"),n}trackActivity(t){return this._markActivityStart(),t.then(n=>(this._markActivitySettled(!0),n),n=>{const o=n instanceof Error?n.message:String(n);throw this._markActivitySettled(!1,o),n})}_markActivityStart(){this._activityCount++,this._activitySettleTimer!==null&&(window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=null),this._activityCount===1&&(this._activityPhase="saving",this._activityError=null,this._activitySavingStartedAt=Date.now(),this._paintActivityIndicator())}_markActivitySettled(t,n){if(this._activityCount>0&&this._activityCount--,this._activityCount>0){!t&&n&&(this._activityError=n);return}const o=Date.now()-this._activitySavingStartedAt,i=ae.MIN_SAVING_DISPLAY_MS-o;if(i>0){this._activitySettleTimer!==null&&window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=window.setTimeout(()=>{this._activitySettleTimer=null,this._finalizeActivitySettle(t,n)},i);return}this._finalizeActivitySettle(t,n)}_finalizeActivitySettle(t,n){this._activityPhase=t&&!this._activityError?"saved":"failed",!t&&n&&(this._activityError=n),this._paintActivityIndicator(),this._activityClearTimer!==null&&(window.clearTimeout(this._activityClearTimer),this._activityClearTimer=null),this._activityPhase==="saved"&&(this._activityClearTimer=window.setTimeout(()=>{this._activityClearTimer=null,this._activityPhase="idle",this._activityError=null,this._paintActivityIndicator()},2200))}_paintActivityIndicator(){if(this._isDestroyed)return;const t=this._activityPhase;t==="idle"?this._titleBar.removeAttribute("data-os-activity"):this._titleBar.setAttribute("data-os-activity",t);const n=this._titleBar.querySelector(".os-window__activity-status");if(n){const i=t==="failed";n.setAttribute("role",i?"alert":"status"),n.setAttribute("aria-live",i?"assertive":"polite"),n.textContent=this._activityStatusText()}this._titleBar.querySelectorAll("[data-os-activity-indicator]").forEach(i=>{i.setAttribute("phase",t),this._activityError?i.setAttribute("error",this._activityError):i.removeAttribute("error")})}_activityStatusText(){switch(this._activityPhase){case"saved":return _("Saved");case"failed":return this._activityError?ie(_("Not saved. %s"),this._activityError):_("Not saved.");default:return""}}requestAttention(t,n={}){const o=Ke.filter("os/window-attention-requested",{windowId:this.id,mode:t,durationMs:n.durationMs,intensity:n.intensity},n);if(!o||o.cancel===!0)return;const i=o.mode??t,s={...n,durationMs:typeof o.durationMs=="number"?o.durationMs:n.durationMs,intensity:typeof o.intensity=="string"?o.intensity:n.intensity},r=T("os.window.attention",i,{windowId:this.id,opts:s}),d=window.wp,a=d?.os?.dock,c=d?.os?.taskbar;let l=!1;if(typeof a?.setAttention=="function"&&(a.setAttention(this.id,r,s),l=!0),typeof c?.setAttention=="function"&&(c.setAttention(this.id,r,s),l=!0),!l&&r!==null){this.setHighlight("persistent");const u=s.durationMs??4e3;u>0&&window.setTimeout(()=>{this.setHighlight(null)},u)}else!l&&r===null&&this.setHighlight(null)}shake(){if(T("os.window.shake",!0,{windowId:this.id})===!1)return;const n=this.element;n.classList.remove("os-window--shaking"),n.offsetWidth,n.classList.add("os-window--shaking");const o=()=>{n.classList.remove("os-window--shaking"),n.removeEventListener("animationend",o)};n.addEventListener("animationend",o)}setHighlight(t,n){const o=this.element;o&&(o.classList.remove("wp-window--highlight-preview","wp-window--highlight-persistent"),t==="preview"?o.classList.add("wp-window--highlight-preview"):t==="persistent"&&o.classList.add("wp-window--highlight-persistent"),n?.color?o.style.setProperty("--wp-window-highlight-color",n.color):t===null&&o.style.removeProperty("--wp-window-highlight-color"),m(f.WINDOW_HIGHLIGHT_CHANGED,{windowId:this.id,mode:t,color:n?.color}))}close(){if(!this._isDestroyed){if(this.config.native&&!this._suppressCloseFilter){if(T(f.NATIVE_WINDOW_BEFORE_CLOSE,!0,{windowId:this.id,config:this.config})===!1)return}else if(!this.config.native&&!this._suppressCloseFilter&&this._iframeBridgeReady&&this.iframe){if(this._closePending)return;this._closePending=!0;try{this.iframe.contentWindow?.postMessage({type:"os-bridge-beforeunload-query"},location.origin),this._iframeCloseTimeout=setTimeout(()=>{this._isDestroyed||(this._suppressCloseFilter=!0,this._closePending=!1,this.close())},500);return}catch{this._closePending=!1}}if(this._isDestroyed=!0,this._discardSwapBuffer(),this._clearDeferredNavigation(),this._activityClearTimer!==null&&(window.clearTimeout(this._activityClearTimer),this._activityClearTimer=null),this._activitySettleTimer!==null&&(window.clearTimeout(this._activitySettleTimer),this._activitySettleTimer=null),this._navigationActivityTimer!==null&&(window.clearTimeout(this._navigationActivityTimer),this._navigationActivityTimer=null),this._titleBarButtonsUnsubscribe&&(this._titleBarButtonsUnsubscribe(),this._titleBarButtonsUnsubscribe=null),this._windowThemesUnsubscribe&&(this._windowThemesUnsubscribe(),this._windowThemesUnsubscribe=null),this._windowControlsUnsubscribe&&(this._windowControlsUnsubscribe(),this._windowControlsUnsubscribe=null),this._windowSlotsUnsubscribe&&(this._windowSlotsUnsubscribe(),this._windowSlotsUnsubscribe=null),this._windowChromesUnsubscribe&&(this._windowChromesUnsubscribe(),this._windowChromesUnsubscribe=null),this._nativeRenderCtxDispose){try{this._nativeRenderCtxDispose()}catch(t){m(f.SHELL_ERROR,{scope:"native-window-ctx-dispose",id:this.id,error:t})}this._nativeRenderCtxDispose=null}this._bodyResizeObserver?.disconnect(),this._bodyResizeObserver=null,this._tabSpeculateTimer&&(window.clearTimeout(this._tabSpeculateTimer),this._tabSpeculateTimer=null),this._tabOverflowTeardown?.(),this._tabOverflowTeardown=null,Bo(this.id);try{this.config.onClose?.()}catch(t){m(f.SHELL_ERROR,{scope:"native-window-close",id:this.id,error:t})}this.onClose?.(this),this.element.classList.add("os-window--closing"),this._onCloseTransitionEnd=t=>{t.propertyName==="opacity"&&this._finalizeClose()},this.element.addEventListener("transitionend",this._onCloseTransitionEnd),this._closeSafetyNetTimer=setTimeout(()=>this._finalizeClose(),300)}}destroy(){if(!this._isFinalized){if(!this._isDestroyed){this._suppressCloseFilter=!0;try{this.close()}finally{this._suppressCloseFilter=!1}}this._finalizeClose()}}_finalizeClose(){if(!this._isFinalized){if(this._isFinalized=!0,this._closeSafetyNetTimer!==null&&(clearTimeout(this._closeSafetyNetTimer),this._closeSafetyNetTimer=null),this._iframeCloseTimeout!==null&&(clearTimeout(this._iframeCloseTimeout),this._iframeCloseTimeout=null),this._clearOpeningClassRemoval&&this._clearOpeningClassRemoval(),this._onCloseTransitionEnd&&(this.element.removeEventListener("transitionend",this._onCloseTransitionEnd),this._onCloseTransitionEnd=null),this._cancelGenieAnimation("minimize"),this._cancelGenieAnimation("restore"),this._windowControlsTeardown){try{this._windowControlsTeardown()}catch{}this._windowControlsTeardown=null}if(this._windowSlotsTeardown){try{this._windowSlotsTeardown()}catch{}this._windowSlotsTeardown=null}if(this._chromeHandle){try{this._chromeHandle.destroy()}catch{}this._chromeHandle=null}if(Kr(this),this._nativeRenderTeardown){try{this._nativeRenderTeardown()}catch(t){m(f.SHELL_ERROR,{scope:"native-window-teardown",id:this.id,error:t})}this._nativeRenderTeardown=null}window.removeEventListener("message",this._boundOnMessage),this._boundOnDocumentPointerDown&&document.removeEventListener("pointerdown",this._boundOnDocumentPointerDown,!0),this._unsubscribeWindowActions?.(),this._unsubscribeWindowActions=null,this.element.remove(),J()}}installBodyResizeObserver(){const t=this.element.querySelector(".os-window__body");if(!t||typeof ResizeObserver>"u")return null;const n=new ResizeObserver(o=>{const i=o[0];if(!i)return;const s=i.contentRect,r=Math.round(s.width),d=Math.round(s.height);try{this.config.onResize?.(r,d)}catch(a){m(f.SHELL_ERROR,{scope:"native-window-resize",id:this.id,error:a})}m(f.WINDOW_BODY_RESIZED,{windowId:this.id,width:r,height:d})});return n.observe(t),n}getSnapshot(){if(this.element.offsetParent===null){const n=o=>{const i=parseFloat(o);return Number.isFinite(i)?Math.round(i):0};return{id:this.id,x:n(this.element.style.left),y:n(this.element.style.top),width:n(this.element.style.width),height:n(this.element.style.height),state:this.state}}return{id:this.id,x:this.element.offsetLeft,y:this.element.offsetTop,width:this.element.offsetWidth,height:this.element.offsetHeight,state:this.state}}getExternalTabCount(){return Js(this)}getExternalTabsSnapshot(){return er(this)}toggleActionsMenu(){bo(this)}closeActionsMenu(){V(this)}openActionsMenu(){wo(this)}};ae.NAVIGATION_ACTIVITY_TIMEOUT_MS=3e4,ae.MIN_SAVING_DISPLAY_MS=1200;let It=ae;function A(e,...t){return{__wpdHtml:!0,strings:e,values:t}}function qa(e){return!!e&&e.__wpdHtml===!0}const Va="$$wpd$$",L=/\$\$wpd\$\$(\d+)\$\$/g,Ka="$$wpd-node$$",ja=/^\$\$wpd-node\$\$(\d+)\$\$$/,Ya=new Set(["style","script","textarea","title"]);function Xa(e){let t="",n=!1,o=null,i=!1,s=null,r="",d=!1;for(let a=0;a<e.length;a++){const c=e[a];t+=c;for(let l=0;l<c.length;l++){const u=c[l];if(i){c.startsWith("-->",l)&&(i=!1,l+=2);continue}if(s!==null){u==="<"&&c[l+1]==="/"&&c.slice(l+2,l+2+s.length).toLowerCase()===s&&(l+=1+s.length,s=null,n=!0,d=!1,r="");continue}if(o!==null){u===o&&(o=null);continue}if(n){u==='"'||u==="'"?(o=u,d=!1):u===">"?(n=!1,d=!1,Ya.has(r)&&(s=r),r=""):d&&(/[a-zA-Z0-9-]/.test(u)?r+=u.toLowerCase():d=!1);continue}if(c.startsWith("<!--",l)){i=!0,l+=3;continue}const p=c[l+1]??"";u==="<"&&/[a-zA-Z/!]/.test(p)&&(n=!0,r="",d=/[a-zA-Z]/.test(p))}a<e.length-1&&(t+=n||i||s!==null?`${Va}${a}$$`:`<!--${Ka}${a}$$-->`)}return t}const So=new WeakMap;function Co(e){const t=So.get(e);if(t)return t;const n=document.createElement("template");n.innerHTML=Xa(e);const o=[],i=(d,a)=>{if(d.nodeType===Node.ELEMENT_NODE){const u=d;for(const p of Array.from(u.attributes)){const g=p.name,b=p.value,y=g[0];if(L.test(b))if(L.lastIndex=0,y==="@"){const w=L.exec(b);L.lastIndex=0,o.push({path:a,kind:"event",name:g.slice(1),valueIndex:w?Number(w[1]):0}),u.removeAttribute(g)}else if(y==="."){const w=L.exec(b);L.lastIndex=0,o.push({path:a,kind:"prop",name:g.slice(1),valueIndex:w?Number(w[1]):0}),u.removeAttribute(g)}else if(y==="?"){const w=L.exec(b);L.lastIndex=0,o.push({path:a,kind:"bool",name:g.slice(1),valueIndex:w?Number(w[1]):0}),u.removeAttribute(g)}else{const w=[],S=[];let E=0,C;for(L.lastIndex=0;(C=L.exec(b))!==null;)w.push(b.slice(E,C.index)),S.push(Number(C[1])),E=C.index+C[0].length;w.push(b.slice(E)),o.push({path:a,kind:"attr",name:g,template:w,valueIndices:S}),u.setAttribute(g,"")}}}const c=Array.from(d.childNodes);let l=0;for(let u=0;u<c.length;u++){const p=c[u],g=u+l;if(p.nodeType===Node.COMMENT_NODE){const b=ja.exec(p.data);if(b){const y=document.createTextNode("");p.parentNode.replaceChild(y,p),o.push({path:[...a,g],kind:"node",valueIndex:Number(b[1])})}continue}if(p.nodeType===Node.TEXT_NODE){const b=p.textContent||"";if(!L.test(b)){L.lastIndex=0;continue}L.lastIndex=0;const y=p.parentNode;let w=0,S;const E=[],C=[];for(L.lastIndex=0;(S=L.exec(b))!==null;){S.index>w&&E.push(document.createTextNode(b.slice(w,S.index)));const N=document.createTextNode("");E.push(N),C.push({path:[...a,g+E.length-1],kind:"node",valueIndex:Number(S[1])}),w=S.index+S[0].length}w<b.length&&E.push(document.createTextNode(b.slice(w)));for(const N of E)y.insertBefore(N,p);y.removeChild(p),l+=E.length-1,o.push(...C)}else i(p,[...a,g])}};i(n.content,[]);const r={template:n,buildParts:d=>{const a=[];for(const c of o){let l=d;for(const u of c.path)l=l.childNodes[u];c.kind==="node"?a.push({kind:"node",valueIndex:c.valueIndex,child:{anchor:l,state:null}}):c.kind==="attr"?a.push({kind:"attr",element:l,name:c.name,template:c.template,valueIndices:c.valueIndices}):c.kind==="event"?a.push({kind:"event",valueIndex:c.valueIndex,element:l,name:c.name}):c.kind==="prop"?a.push({kind:"prop",valueIndex:c.valueIndex,element:l,name:c.name}):c.kind==="bool"&&a.push({kind:"bool",valueIndex:c.valueIndex,element:l,name:c.name})}return a}};return So.set(e,r),r}const ko=new WeakMap;function Za(e,t){for(const n of e.nodes)if(n.parentNode!==t)return!1;return!0}function Qa(e,t){const n=ko.get(t);if(n&&n.strings===e.strings&&Za(n,t)){He(n.parts,e.values);return}const o=Co(e.strings),i=o.template.content.cloneNode(!0),s=o.buildParts(i),r=Array.from(i.childNodes);for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(i),He(s,e.values),ko.set(t,{strings:e.strings,parts:s,nodes:r})}function He(e,t){for(const n of e)if(n.kind==="node")Fe(n.child,t[n.valueIndex]);else if(n.kind==="attr"){let o=n.template[0];for(let i=0;i<n.valueIndices.length;i++)o+=xo(t[n.valueIndices[i]]),o+=n.template[i+1];o!==n.last&&(n.last=o,o===""?n.element.removeAttribute(n.name):n.element.setAttribute(n.name,o))}else if(n.kind==="event"){const o=t[n.valueIndex];o!==n.current&&(n.current&&n.element.removeEventListener(n.name,n.current),o&&n.element.addEventListener(n.name,o),n.current=o)}else if(n.kind==="prop"){const o=t[n.valueIndex];o!==n.last&&(n.last=o,n.element[n.name]=o)}else if(n.kind==="bool"){const o=!!t[n.valueIndex];o!==n.last&&(n.last=o,o?n.element.setAttribute(n.name,""):n.element.removeAttribute(n.name))}}function Fe(e,t){if(t==null||t===!1){e.state&&(te(e.state),e.state=null);return}if(Array.isArray(t)){nl(e,t);return}if(qa(t)){tl(e,t);return}if(t instanceof Node){Ja(e,t);return}el(e,xo(t))}function Ja(e,t){const n=e.state;n?.shape==="node"&&n.node===t||(n&&te(n),_e(e,[t]),e.state={shape:"node",node:t})}function el(e,t){const n=e.state;if(n?.shape==="text"){n.text!==t&&(n.node.textContent=t,n.text=t);return}n&&te(n);const o=document.createTextNode(t);_e(e,[o]),e.state={shape:"text",node:o,text:t}}function tl(e,t){const n=e.state;if(n?.shape==="template"&&n.strings===t.strings){He(n.parts,t.values);return}n&&te(n);const o=Co(t.strings),i=o.template.content.cloneNode(!0),s=o.buildParts(i),r=Array.from(i.childNodes);_e(e,[i]),He(s,t.values),e.state={shape:"template",strings:t.strings,parts:s,nodes:r}}function nl(e,t){const n=e.state;if(n?.shape==="array"){const i=Math.min(n.entries.length,t.length);for(let s=0;s<i;s++)Fe(n.entries[s],t[s]);if(t.length<n.entries.length){for(let s=t.length;s<n.entries.length;s++){const r=n.entries[s];r.state&&te(r.state),r.anchor.remove()}n.entries.length=t.length}else for(let s=n.entries.length;s<t.length;s++){const r=document.createTextNode("");_e(e,[r]);const d={anchor:r,state:null};Fe(d,t[s]),n.entries.push(d)}return}n&&te(n);const o=[];for(const i of t){const s=document.createTextNode("");_e(e,[s]);const r={anchor:s,state:null};Fe(r,i),o.push(r)}e.state={shape:"array",entries:o}}function _e(e,t){const n=e.anchor.parentNode;if(n)for(const o of t)n.insertBefore(o,e.anchor)}function te(e){if(e.shape==="text"){e.node.remove();return}if(e.shape==="template"){for(const t of e.parts)t.kind==="node"&&t.child.state&&(te(t.child.state),t.child.state=null);for(const t of e.nodes)t.parentNode&&t.parentNode.removeChild(t);return}if(e.shape==="node"){e.node.parentNode&&e.node.parentNode.removeChild(e.node);return}for(const t of e.entries)t.state&&te(t.state),t.anchor.remove()}function xo(e){return e==null||e===!1?"":String(e)}const ne=class ne extends HTMLElement{constructor(){super(),this._renderScheduled=!1,this._propValues={},this.constructor.shadow?(this.attachShadow({mode:"open"}),this._renderRoot=this.shadowRoot):this._renderRoot=this,this._installPropAccessors()}static get observedAttributes(){return this.props.map(To)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(t,n,o){if(n===o)return;const i=ol(t);this._propValues[i]=o,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(t){if(t==null){this.removeAttribute("class");return}const o=(Array.isArray(t)?t:String(t).split(/\s+/)).map(i=>String(i).trim()).filter(i=>i!=="");this.className=o.join(" ")}requestUpdate(){this._scheduleRender()}emit(t,n){return this.dispatchEvent(new CustomEvent(t,{detail:n,bubbles:!0,composed:!0}))}_installPropAccessors(){const t=this.constructor;for(const n of t.props){if(Object.getOwnPropertyDescriptor(this,n))continue;const o=To(n);Object.defineProperty(this,n,{get:()=>n in this._propValues?this._propValues[n]:this.getAttribute(o),set:i=>{let s;i==null||i===!1?s=null:i===!0?s="":s=String(i),this._propValues[n]=s,s===null?this.removeAttribute(o):this.setAttribute(o,s),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&Qa(this.render(),this._renderRoot)}))}_adoptStyles(){const t=this.constructor;if(t.styles.length!==0)if(t.shadow&&this.shadowRoot){const n=t.styles.map(o=>o.sheet).filter(o=>o!==null);if(this.shadowRoot.adoptedStyleSheets=n,n.length!==t.styles.length){for(const o of t.styles)if(!o.sheet){const i=document.createElement("style");i.textContent=o.cssText,this.shadowRoot.appendChild(i)}}}else this._adoptLightStyles(t)}_adoptLightStyles(t){if(!ne._lightStylesAdopted.has(t)){ne._lightStylesAdopted.add(t);for(const n of t.styles){const o=document.createElement("style");o.dataset.osUi=this.tagName.toLowerCase(),o.textContent=n.cssText,document.head.appendChild(o)}}}};ne.props=[],ne.styles=[],ne.shadow=!0,ne._lightStylesAdopted=new WeakSet;let K=ne;function oe(e,t){customElements.get(e)||customElements.define(e,t)}function To(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function ol(e){return e.replace(/-([a-z])/g,(t,n)=>n.toUpperCase())}const il=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function x(e,...t){let n=e[0];for(let o=1;o<e.length;o++){const i=t[o-1];if(typeof i=="string"||typeof i=="number")n+=String(i);else if(i&&i.__wpdCss)n+=i.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof i);n+=e[o]}if(il){const o=new CSSStyleSheet;return o.replaceSync(n),{__wpdCss:!0,sheet:o,cssText:n}}return{__wpdCss:!0,sheet:null,cssText:n}}const sl=x`:host{display:inline-flex}button{display:flex;align-items:center;justify-content:center;width:30px;height:30px;padding:0;border:none;border-radius:var( --os-ui-btn-radius,5px );background-color:var( --os-ui-btn-bg,transparent );background-image:var( --os-ui-btn-bg-image,none );background-repeat:var( --os-ui-btn-bg-image-repeat,no-repeat );background-size:var( --os-ui-btn-bg-image-size,auto );background-position:var( --os-ui-btn-bg-image-position,center );color:var( --os-ui-btn-color,currentColor );cursor:pointer;transition:background-color 0.15s ease,color 0.15s ease,transform 80ms ease}button:active:not(:disabled){transform:scale( 0.9 )}@media ( prefers-reduced-motion:reduce ){button:active:not(:disabled){transform:none}}button:disabled{opacity:0.5;cursor:default}button:hover:not(:disabled){color:var( --os-ui-btn-color-hover,currentColor );background-color:var( --os-ui-btn-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.06 ) ) )}button:focus-visible{color:var( --os-ui-btn-color-hover,currentColor );background-color:var( --os-ui-btn-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.06 ) ) );outline:2px solid var( --os-ui-btn-outline,currentColor );outline-offset:1px}:host( [ active ] ) button{color:var( --os-ui-btn-color-hover,currentColor );background-color:var( --os-ui-btn-bg-active,var( --os-ui-hover,rgba( 0,0,0,0.08 ) ) )}:host( [ danger ] ) button:hover{color:var( --os-ui-fg-on-accent,#fff );background-color:var( --os-ui-btn-danger-hover,var( --os-ui-danger,#d63638 ) )}svg{display:block;pointer-events:none;flex-shrink:0}svg:empty{display:none}.themed-icon{display:block;width:14px;height:14px;flex-shrink:0;pointer-events:none;background-color:var( --os-ui-btn-icon-color,currentColor )}::slotted( span ){line-height:1}::slotted( svg ){display:block}`,rl={minimize:'<path d="M3 6h6" stroke="currentColor" stroke-width="1.25" stroke-linecap="round"/>',maximize:'<rect x="3" y="3" width="6" height="6" rx="1" stroke="currentColor" stroke-width="1.25" fill="none"/>',fullscreen:'<path d="M4.5 2H2v2.5M10 4.5V2H7.5M4.5 10H2V7.5M10 7.5V10H7.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',"fullscreen-exit":'<path d="M2 4.5H4.5V2M7.5 2V4.5H10M2 7.5H4.5V10M7.5 10V7.5H10" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',detach:'<path d="M5 2H2.5v7.5H10V7M6.5 2H10v3.5M10 2L5.5 6.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round" stroke-linejoin="round" fill="none"/>',reload:'<g transform="translate(0.6 0.6) scale(0.021)" fill="currentColor"><path d="m504.554 233.704-76.447 91.467c-6.329 7.572-15.417 11.479-24.571 11.479a31.872 31.872 0 0 1-20.504-7.447l-91.467-76.447c-13.561-11.334-15.366-31.515-4.032-45.075s31.515-15.366 45.075-4.032l37.506 31.347c-10.274-74.891-74.668-132.774-152.337-132.774C132.984 102.223 64 171.207 64 256s68.984 153.777 153.777 153.777c17.673 0 32 14.327 32 32s-14.327 32-32 32c-58.17 0-112.859-22.653-153.991-63.785C22.653 368.859 0 314.17 0 256s22.653-112.859 63.786-153.992c41.132-41.132 95.821-63.785 153.991-63.785s112.859 22.653 153.992 63.785c32.517 32.516 53.471 73.508 60.829 117.991l22.849-27.339c11.334-13.56 31.515-15.364 45.075-4.032 13.56 11.335 15.365 31.516 4.032 45.076z"/></g>',close:'<path d="M3.25 3.25l5.5 5.5M3.25 8.75l5.5-5.5" stroke="currentColor" stroke-width="1.25" stroke-linecap="round"/>',menu:'<circle cx="3" cy="6" r="1.2" fill="currentColor"/><circle cx="6" cy="6" r="1.2" fill="currentColor"/><circle cx="9" cy="6" r="1.2" fill="currentColor"/>'};function al(e){const t=(e??"").trim();return t===""||t.length>4096||!/^(https?:\/\/|data:image\/)/i.test(t)||/['"()\\<>\s]/.test(t)?"":t}const be=class be extends K{constructor(){super(...arguments),this._activateWired=!1}static get observedAttributes(){return[...super.observedAttributes,"aria-label","aria-pressed"]}render(){const t=al(this["icon-src"]||this.getAttribute("icon-src")||""),n=t?"":this.icon||"",o=rl[n]||"",i=this.getAttribute("aria-label")||"";return t?A` |