| @@ -173,5 +173,5 @@ | ||
| 173 | 173 | <path d="M1 8C1 8 3.5 3 8 3s7 5 7 5-2.5 5-7 5S1 8 1 8z" /> |
| 174 | 174 | <circle cx="8" cy="8" r="2" /> |
| 175 | 175 | <line x1="2" y1="2" x2="14" y2="14" /> |
| 176 | 176 | </svg> |
| 177 | - `}function Pe(){const o=window.wp?.hooks;if(!o)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 o}function Rt(o,e,t,n){Pe().addAction(o,e,t,n)}function Dt(o,e){return Pe().removeAction(o,e)}const le={WINDOW_MINIMIZED:"os.window.minimized",WINDOW_RESTORED:"os.window.restored",WINDOW_TITLE_CHANGED:"os.window.title-changed",DESKTOP_SWITCHED:"os.os.switched"},Vt="desktop-mode";function ze(){return window.wp?.i18n}function E(o,e=Vt){return ze()?.__(o,e)??o}function He(o,...e){const t=ze()?.sprintf;if(t)return t(o,...e);let n=0;return o.replace(/%(?:(\d+)\$)?[sd]/g,(i,r)=>{const s=r?Number.parseInt(r,10)-1:n++;return String(e[s]??"")})}const Bt=.35,Ot=.6,Wt=24,Re=10,De=64,qt=44;function Zt(o){const{dx:e,dy:t,velocity:n,width:i}=o,r=Math.abs(e);return r<=Math.abs(t)?"cancel":i>0&&r>=i*Bt||Math.abs(n)>=Ot&&r>=Wt&&Math.sign(n)===Math.sign(e)?"commit":"cancel"}function Ve(o,e=De){return e<=0?o>0?1:0:Math.min(1,Math.max(0,o/e))}function jt(o,e){const t=e.threshold??De;let n=null,i=0,r=0,s=!1;const d=()=>{n=null,s=!1,e.onProgress?.(0)},a=c=>{if(!(n!==null||!c.isPrimary)){n=c.pointerId,i=c.clientX,r=c.clientY,s=!1;try{o.setPointerCapture(c.pointerId)}catch{}c.preventDefault()}},l=c=>{if(c.pointerId!==n||s)return;const h=c.clientX-i,p=c.clientY-r;if(Math.abs(p)>Re&&Math.abs(p)>Math.abs(h)){s=!0,e.onProgress?.(0);return}e.onProgress?.(Ve(h,t))},m=c=>{if(c.pointerId!==n)return;const h=!s&&Ve(c.clientX-i,t)>=1;d(),h&&e.onCommit()},f=c=>{c.pointerId===n&&d()};return o.addEventListener("pointerdown",a),o.addEventListener("pointermove",l),o.addEventListener("pointerup",m),o.addEventListener("pointercancel",f),()=>{o.removeEventListener("pointerdown",a),o.removeEventListener("pointermove",l),o.removeEventListener("pointerup",m),o.removeEventListener("pointercancel",f)}}function Be(o){const e=t=>{t.cancelable&&t.preventDefault()};return o.addEventListener("touchstart",e,{passive:!1}),()=>{o.removeEventListener("touchstart",e)}}function Xt(o,e){return Oe(o,"up",e)}function Kt(o,e){return Oe(o,"down",e)}function Oe(o,e,t){const n=t.threshold??qt,i=e==="up"?1:-1;let r=null,s=0,d=0,a=!1;const l=()=>{const h=p=>{p.stopPropagation(),p.preventDefault()};o.addEventListener("click",h,{capture:!0,once:!0}),setTimeout(()=>o.removeEventListener("click",h,{capture:!0}),350)},m=h=>{r!==null||!h.isPrimary||h.pointerType==="mouse"||(r=h.pointerId,s=h.clientX,d=h.clientY,a=!1)},f=h=>{if(h.pointerId!==r||a)return;const p=(d-h.clientY)*i,x=Math.abs(h.clientX-s);p>=n&&p>x&&(a=!0,l(),t.onCommit())},c=h=>{h.pointerId===r&&(r=null)};return o.addEventListener("pointerdown",m),o.addEventListener("pointermove",f),o.addEventListener("pointerup",c),o.addEventListener("pointercancel",c),()=>{o.removeEventListener("pointerdown",m),o.removeEventListener("pointermove",f),o.removeEventListener("pointerup",c),o.removeEventListener("pointercancel",c)}}const Ft=new Set(["os-mio-toggle","os-overview"]);function We(o){return Ft.has(o.id)?!1:!!(o.windowId||o.tile||o.menu?.url||o.entry?.url)}function qe(o){if(!o)return{apps:[],system:[]};const e=new Set,t=r=>{const s=[];for(const d of r)for(const a of d)e.has(a.id)||o.ephemeral.has(a.id)||!We(a)||(e.add(a.id),s.push(a));return s},n=t([o.dock.core,o.sidebar,o.dock.apps,o.desktop]),i=t([o.dock.controls]);return{apps:n,system:i}}function Ze(o,e){const t=e.trim().toLocaleLowerCase();return t?o.filter(n=>n.title.toLocaleLowerCase().includes(t)):o.slice()}function je(o){return o>99?"99+":String(o)}function Ut(o,e){const t=document.createElement("div");t.className="os-mobile-home",t.setAttribute("role","region"),t.setAttribute("aria-label",E("Home"));const n=document.createElement("div");n.className="os-mobile-home__search";const i=document.createElement("os-text-field");i.setAttribute("type","search"),i.setAttribute("placeholder",E("Search apps")),i.setAttribute("aria-label",E("Search apps")),i.setAttribute("autocomplete","off"),n.appendChild(i);const r=document.createElement("div");r.className="os-mobile-home__scroll";const s=document.createElement("div");s.className="os-mobile-home__content",r.appendChild(s),t.append(n,r),o.appendChild(t);let d={apps:[],system:[]},a="";const l=c=>{const h=document.createElement("div");h.className="os-mobile-grid__cell",h.setAttribute("role","listitem");const p=document.createElement("button");p.type="button",p.className="os-mobile-tile",p.dataset.navId=c.id;const x=document.createElement("span");x.className="os-mobile-tile__icon",x.appendChild(e.renderIcon(e.getArt?.(c)||c.icon,{title:c.title,className:"os-mobile-tile__glyph"}));const v=e.getBadge(c);if(v>0){const A=document.createElement("span");A.className="os-mobile-tile__badge",A.textContent=je(v),A.setAttribute("aria-hidden","true"),x.appendChild(A)}const C=document.createElement("span");return C.className="os-mobile-tile__label",C.textContent=c.title,p.append(x,C),p.setAttribute("aria-label",v>0?`${c.title}, ${je(v)}`:c.title),p.addEventListener("click",()=>e.onOpen(c)),h.appendChild(p),h},m=(c,h)=>{if(h.length===0)return null;const p=document.createElement("section");p.className="os-mobile-home__section";const x=document.createElement("h2");x.className="os-mobile-home__heading",x.textContent=c;const v=document.createElement("div");v.className="os-mobile-grid",v.setAttribute("role","list");for(const C of h)v.appendChild(l(C));return p.append(x,v),p},f=()=>{if(s.replaceChildren(),a.trim()){const p=Ze([...d.apps,...d.system],a),x=m(E("Results"),p);if(x)s.appendChild(x);else{const v=document.createElement("p");v.className="os-mobile-home__empty",v.textContent=E("Nothing matches."),s.appendChild(v)}return}const c=m(E("Apps"),d.apps),h=m(E("System"),d.system);if(c&&s.appendChild(c),h&&s.appendChild(h),!c&&!h){const p=document.createElement("p");p.className="os-mobile-home__empty",p.textContent=E("Nothing to show yet."),s.appendChild(p)}};return i.addEventListener("os-input-change",c=>{a=c.detail?.value??"",f()}),i.addEventListener("os-submit",()=>{const c=Ze([...d.apps,...d.system],a)[0];c&&e.onOpen(c)}),{el:t,render(c){d=qe(c),f()},setHidden(c){t.hidden=c},reset(){a&&(a="",i.setAttribute("value",""),i.value="",f()),r.scrollTop=0}}}const Xe={close:{a:'fill="currentColor"',b:'<path d="m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z" />'},check:{a:'fill="currentColor"',b:'<path d="M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" />'},"chevron-right":{a:'fill="currentColor"',b:'<path d="M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" />'},"arrow-up-right":{a:'fill="currentColor"',b:'<path d="M10 6H18V14H16.5V8.5L7 18L6 17L15.5 7.5H10V6Z" />'},plus:{a:'fill="currentColor"',b:'<path d="M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" />'},search:{a:'fill="currentColor"',b:'<path d="M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" />'},pin:{a:'fill="currentColor"',b:'<path d="m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z" />'},trash:{a:'fill="currentColor"',b:'<path fill-rule="evenodd" clip-rule="evenodd" d="M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" />'},download:{a:'fill="currentColor"',b:'<path d="M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z" />'},settings:{a:'fill="currentColor"',b:'<path d="m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z" /><path d="m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z" />'},info:{a:'fill="currentColor"',b:'<path fill-rule="evenodd" clip-rule="evenodd" d="M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z" />'},bell:{a:'fill="currentColor"',b:'<path fill-rule="evenodd" clip-rule="evenodd" d="M17 11.5c0 1.353.17 2.368.976 3 .266.209.602.376 1.024.5v1H5v-1c.422-.124.757-.291 1.024-.5.806-.632.976-1.647.976-3V9c0-2.8 2.2-5 5-5s5 2.2 5 5v2.5ZM15.5 9v2.5c0 .93.066 1.98.515 2.897l.053.103H7.932a4.018 4.018 0 0 0 .053-.103c.449-.917.515-1.967.515-2.897V9c0-1.972 1.528-3.5 3.5-3.5s3.5 1.528 3.5 3.5Zm-5.492 9.008c0-.176.023-.346.065-.508h3.854A1.996 1.996 0 0 1 12 20c-1.1 0-1.992-.892-1.992-1.992Z" />'},more:{a:'fill="currentColor"',b:'<path d="M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z" />'},maximize:{a:'fill="currentColor"',b:'<path d="M6 4a2 2 0 0 0-2 2v3h1.5V6a.5.5 0 0 1 .5-.5h3V4H6Zm3 14.5H6a.5.5 0 0 1-.5-.5v-3H4v3a2 2 0 0 0 2 2h3v-1.5Zm6 1.5v-1.5h3a.5.5 0 0 0 .5-.5v-3H20v3a2 2 0 0 1-2 2h-3Zm3-16a2 2 0 0 1 2 2v3h-1.5V6a.5.5 0 0 0-.5-.5h-3V4h3Z" />'},edit:{a:'fill="currentColor"',b:'<path d="m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" />'},color:{a:'fill="currentColor"',b:'<path d="M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z" />'},wallpaper:{a:'fill="currentColor"',b:'<path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v8.4l-3-2.9c-.3-.3-.8-.3-1 0L11.9 14 9 12c-.3-.2-.6-.2-.8 0l-3.6 2.6V5c-.1-.3.1-.5.4-.5zm14 15H5c-.3 0-.5-.2-.5-.5v-2.4l4.1-3 3 1.9c.3.2.7.2.9-.1L16 12l3.5 3.4V19c0 .3-.2.5-.5.5z" />'},warning:{a:'fill="currentColor"',b:'<path fill-rule="evenodd" clip-rule="evenodd" d="M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm-.75 12v-1.5h1.5V16h-1.5Zm0-8v5h1.5V8h-1.5Z" />'},minimize:{a:'fill="currentColor"',b:'<path d="M5 11.25h14v1.5H5z" />'},window:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="4.125" y="5.4375" width="15.75" height="13.125" rx="1.75"/><path d="M4.125 9.8125h15.75"/><circle cx="7.275" cy="7.625" r="0.7438" fill="currentColor" stroke="none"/>'},windows:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.6875" y="8.5" width="11.375" height="10.0625" rx="1.75"/><path d="M3.6875 12h11.375"/><path d="M8.5 8.5V7.1875a1.75 1.75 0 0 1 1.75-1.75h7.875A1.75 1.75 0 0 1 19.875 7.1875v7a1.75 1.75 0 0 1-1.75 1.75h-3.0625"/>'},dock:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.25" y="8.5" width="17.5" height="7" rx="3.5"/><circle cx="7.625" cy="12" r="1.0062" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.0062" fill="currentColor" stroke="none"/><circle cx="16.375" cy="12" r="1.0062" fill="currentColor" stroke="none"/>'},spaces:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.6875" y="5.4375" width="7.4375" height="7.875" rx="1.75"/><rect x="12.875" y="5.4375" width="7.4375" height="7.875" rx="1.75"/><circle cx="9.375" cy="17.6875" r="0.7875" fill="currentColor" stroke="none"/><circle cx="12" cy="17.6875" r="0.7875" fill="currentColor" stroke="none"/><circle cx="14.625" cy="17.6875" r="0.7875" fill="currentColor" stroke="none"/>'},copilot:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<path d="M10 2.5Q10.9 8.5 17.5 10Q10.9 11.5 10 17.5Q9.1 11.5 2.5 10Q9.1 8.5 10 2.5Z" fill="currentColor" stroke="none"/><path d="M17.9 14Q18.35 17.1 21.5 17.6Q18.35 18.1 17.9 21.2Q17.45 18.1 14.3 17.6Q17.45 17.1 17.9 14Z" fill="currentColor" stroke="none"/>'},snap:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.6875" y="5.4375" width="16.625" height="13.125" rx="1.75"/><path d="M12 5.4375v13.125"/><path d="M12 12h8.3125"/>'},command:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<path d="M14.625 6.75v10.5a2.625 2.625 0 1 0 2.625-2.625H6.75a2.625 2.625 0 1 0 2.625 2.625V6.75a2.625 2.625 0 1 0-2.625 2.625h10.5a2.625 2.625 0 1 0-2.625-2.625"/>'},apps:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="4.125" y="4.125" width="6.5625" height="6.5625" rx="1.75"/><rect x="13.3125" y="4.125" width="6.5625" height="6.5625" rx="1.75"/><rect x="4.125" y="13.3125" width="6.5625" height="6.5625" rx="1.75"/><rect x="13.3125" y="13.3125" width="6.5625" height="6.5625" rx="1.75"/>'},widgets:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.6875" y="3.6875" width="9.625" height="9.625" rx="1.75"/><rect x="15.0625" y="3.6875" width="5.25" height="5.25" rx="1.75"/><rect x="15.0625" y="10.6875" width="5.25" height="9.625" rx="1.75"/><rect x="3.6875" y="15.0625" width="9.625" height="5.25" rx="1.75"/>'},user:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<circle cx="12" cy="8.9375" r="3.5"/><path d="M5.4375 19.4375a6.5625 6.5625 0 0 1 13.125 0"/>'},lock:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="5.4375" y="10.6875" width="13.125" height="8.75" rx="1.75"/><path d="M8.5 10.6875V8.0625a3.5 3.5 0 0 1 7 0v2.625"/>'}};function Ke(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Yt(o){return Object.prototype.hasOwnProperty.call(Xe,o)?Xe[o]:null}function Gt(o,e={}){const t=Yt(o);if(!t)return"";const{size:n=24,className:i,title:r,rotate:s}=e,d=['xmlns="http://www.w3.org/2000/svg"','viewBox="0 0 24 24"'];n!=null&&d.push(`width="${n}"`,`height="${n}"`),d.push(t.a),i&&d.push(`class="${Ke(i)}"`),r?d.push('role="img"',`aria-label="${Ke(r)}"`):d.push('aria-hidden="true"','focusable="false"');const a=s?`<g transform="rotate(${s} 12 12)">${t.b}</g>`:t.b;return`<svg ${d.join(" ")}>${a}</svg>`}function G(o,e={}){const t=Gt(o,e),n=document.createElement("div");n.innerHTML=t;const i=n.firstElementChild;return i instanceof SVGSVGElement?i:document.createElementNS("http://www.w3.org/2000/svg","svg")}function Qt(o,e){const t=document.createElement("div");t.className="os-mobile-switcher",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",E("Open apps")),t.hidden=!0;const n=document.createElement("div");n.className="os-mobile-switcher__backdrop",n.addEventListener("click",()=>e.onDismiss());const i=document.createElement("div");i.className="os-mobile-switcher__sheet";const r=document.createElement("header");r.className="os-mobile-switcher__header";const s=document.createElement("h2");s.className="os-mobile-switcher__title",s.textContent=E("Open apps");const d=document.createElement("button");d.type="button",d.className="os-mobile-switcher__close",d.setAttribute("aria-label",E("Close the switcher")),d.appendChild(G("close",{size:20})),d.addEventListener("click",()=>e.onDismiss()),r.append(s,d);const a=document.createElement("div");a.className="os-mobile-switcher__list";const l=document.createElement("footer");l.className="os-mobile-switcher__footer";const m=document.createElement("os-button");m.setAttribute("variant","secondary"),m.textContent=E("Close all"),m.addEventListener("click",()=>e.onCloseAll()),l.appendChild(m),i.append(r,a,l),t.append(n,i),o.appendChild(t);let f=!1,c=!1,h=null,p=null;const x=b=>{b.key==="Escape"&&(b.preventDefault(),e.onDismiss())},v=b=>{const _=document.createElement("div");_.className="os-mobile-card",_.dataset.cardId=b.id,b.active&&_.classList.add("os-mobile-card--active");const w=document.createElement("button");w.type="button",w.className="os-mobile-card__body",b.active&&w.setAttribute("aria-current","true"),w.setAttribute("aria-label",b.title);const L=document.createElement("span");L.className="os-mobile-card__icon",L.appendChild(e.renderIcon(b.icon,{title:b.title,className:"os-mobile-card__glyph"}));const S=document.createElement("span");S.className="os-mobile-card__text";const N=document.createElement("span");N.className="os-mobile-card__title",N.textContent=b.title;const B=document.createElement("span");if(B.className="os-mobile-card__subtitle",B.textContent=b.subtitle,S.append(N,B),b.active){const O=document.createElement("span");O.className="os-mobile-card__status",O.textContent=E("Active"),N.appendChild(O)}const W=document.createElement("span");W.className="os-mobile-card__bar",W.append(L,S);const z=document.createElement("span");z.className="os-mobile-card__preview",z.setAttribute("aria-hidden","true"),w.append(W,z),w.addEventListener("click",()=>e.onPick(b));const D=document.createElement("button");return D.type="button",D.className="os-mobile-card__close",D.setAttribute("aria-label",He(E("Close %s"),b.title)),D.appendChild(G("close",{size:16})),D.addEventListener("click",O=>{O.stopPropagation(),C(_,b,1)}),_.append(w,D),A(_,b),_},C=(b,_,w)=>{b.classList.add("os-mobile-card--out"),b.style.setProperty("--os-mobile-card-dir",String(w));let L=!1;const S=()=>{L||(L=!0,e.onClose(_))};b.addEventListener("transitionend",S,{once:!0}),setTimeout(S,240)},A=(b,_)=>{let w=null,L=0,S=0,N=0,B=0,W=0,z=!1;const D=()=>{if(b.classList.remove("os-mobile-card--dragging"),b.style.transform="",b.style.opacity="",w=null,z=!1,c=!1,h){const I=h;h=null,P(I)}};b.addEventListener("pointerdown",I=>{!I.isPrimary||w!==null||(w=I.pointerId,L=N=I.clientX,S=I.clientY,B=I.timeStamp,W=0,z=!1)}),b.addEventListener("pointermove",I=>{if(I.pointerId!==w)return;const V=I.clientX-L,K=I.clientY-S;if(!z){if(Math.abs(V)<Re)return;if(Math.abs(K)>Math.abs(V)){w=null;return}z=!0,c=!0,b.classList.add("os-mobile-card--dragging");try{b.setPointerCapture(I.pointerId)}catch{}}const q=Math.max(1,I.timeStamp-B);W=(I.clientX-N)/q,N=I.clientX,B=I.timeStamp,b.style.transform=`translateX(${V}px)`,b.style.opacity=String(Math.max(.35,1-Math.abs(V)/Math.max(1,b.offsetWidth)))});const O=I=>{if(I.pointerId!==w)return;if(!z){w=null;return}const V=I.clientX-L,K=I.clientY-S,q=Zt({dx:V,dy:K,velocity:W,width:b.offsetWidth}),ce=ne=>{ne.stopPropagation(),ne.preventDefault()};if(b.addEventListener("click",ce,{capture:!0,once:!0}),setTimeout(()=>b.removeEventListener("click",ce,{capture:!0}),300),q==="commit"){b.classList.remove("os-mobile-card--dragging"),w=null,z=!1,c=!1,C(b,_,V<0?-1:1);return}D()};b.addEventListener("pointerup",O),b.addEventListener("pointercancel",I=>{I.pointerId===w&&D()})},M=b=>{const _=document.createElement("section");_.className="os-mobile-deck";const w=document.createElement("div");return w.className="os-mobile-deck__cards",b.forEach((L,S)=>{const N=v(L);N.style.zIndex=String(b.length-S),w.appendChild(N)}),_.appendChild(w),_},P=b=>{if(a.replaceChildren(),b.length===0){const _=document.createElement("p");_.className="os-mobile-switcher__empty",_.textContent=E("Nothing open. Pick something from Home."),a.appendChild(_),l.hidden=!0;return}a.appendChild(M(b)),l.hidden=!1};return{el:t,isOpen:()=>f,open(b){if(f){this.update(b);return}f=!0;const _=t.ownerDocument.activeElement;p=_ instanceof HTMLElement?_:null,P(b),t.hidden=!1,document.addEventListener("keydown",x),(a.querySelector(".os-mobile-card__body")??d).focus()},update(b){if(f){if(c){h=b;return}P(b)}},close(){if(!f)return;f=!1,c=!1,h=null,t.hidden=!0,document.removeEventListener("keydown",x);const b=p;p=null,b&&b.isConnected&&b.focus()}}}const Jt=["post_type","page","taxonomy","path","post","c","tag_ID","item","p"],ge=[];function eo(o){if(!o.pathname.endsWith("/admin.php")||!o.searchParams.get("page"))return ge;const e=o.searchParams.get("action");return e==="edit"&&o.searchParams.get("id")?["id"]:e==="new"?["action"]:ge}function Fe(o){let e=o;try{e=decodeURIComponent(o)}catch{e=o}return e.replace(/\.php/g,"-php").replace(/[?&=/]/g,"-").replace(/[^a-zA-Z0-9_-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")||"index"}function to(o,e){let t=null;try{t=new URL(o,e)}catch{t=null}if(t){const i=new URL(e).pathname,r=t.pathname.replace(i,"").replace(/^\/+/,""),s=new URLSearchParams,d=[...Jt,...eo(t)];for(const l of d){const m=t.searchParams.get(l);m&&s.set(l,m)}const a=s.toString();return Fe(a?`${r}?${a}`:r)}let n=o.replace(e,"");return n.startsWith("/")&&(n=n.substring(1)),Fe(n)}const oo=3;function Ue(o,e){if(o.windowId)return o.windowId;const t=o.menu?.url||o.entry?.url;if(!t)return null;try{return to(t,e)}catch{return null}}function no(o,e,t=oo){if(!o||t<=0)return[];const n=[...o.dock.core,...o.sidebar,...o.dock.apps,...o.desktop],i=new Map;for(const a of n)i.has(a.id)||i.set(a.id,a);const r=a=>!!a&&!a.locked&&!o.ephemeral.has(a.id)&&We(a),s=[],d=new Set;for(const a of e){const l=i.get(a);if(r(l)&&!d.has(l.id)&&(d.add(l.id),s.push(l),s.length>=t))return s}if(s.length>0)return s;for(const a of n){if(s.length>=t)break;r(a)&&!d.has(a.id)&&(d.add(a.id),s.push(a))}return s}function io(o,e){const t=document.createElement("nav");t.className="os-mobile-tabs",t.setAttribute("aria-label",E("Primary")),o.appendChild(t);let n=[],i=null,r=null,s=null;const d=(l,m,f)=>{const c=document.createElement("button");c.type="button",c.className="os-mobile-tabs__item",c.dataset.tab=l;const h=document.createElement("span");h.className="os-mobile-tabs__icon",h.appendChild(f);const p=document.createElement("span");return p.className="os-mobile-tabs__label",p.textContent=m,c.append(h,p),c},a=l=>{for(const m of n)m.dataset.tab===l.active?m.setAttribute("aria-current","page"):m.removeAttribute("aria-current");i&&(i.hidden=l.openCount===0,i.textContent=i.hidden?"":String(Math.min(l.openCount,99))),s?.classList.toggle("os-mobile-tabs__icon--counted",l.openCount>0),r&&r.setAttribute("aria-label",He(E("Open apps (%d)"),l.openCount))};return{el:t,render(l,m){t.replaceChildren(),n=[];const f=d("home",E("Home"),G("apps",{size:22}));f.addEventListener("click",e.onHome),n.push(f);for(const c of l){const h=d(c.id,c.title,e.renderIcon(c.icon,{title:c.title,className:"os-mobile-tabs__glyph"})),p=e.getBadge(c);if(p>0){const x=document.createElement("span");x.className="os-mobile-tabs__badge",x.textContent=p>99?"99+":String(p),x.setAttribute("aria-hidden","true"),h.querySelector(".os-mobile-tabs__icon")?.appendChild(x),h.setAttribute("aria-label",`${c.title}, ${p>99?"99+":p}`)}h.addEventListener("click",()=>e.onOpen(c)),n.push(h)}r=d("switcher",E("Open apps"),G("windows",{size:22})),s=r.querySelector(".os-mobile-tabs__icon"),i=document.createElement("span"),i.className="os-mobile-tabs__count",i.setAttribute("aria-hidden","true"),s?.appendChild(i),r.addEventListener("click",e.onSwitcher),n.push(r),t.append(...n),a(m)},setState:a}}function ro(o,e){const t=document.createElement("header");t.className="os-mobile-top",t.hidden=!0;const n=document.createElement("div");n.className="os-mobile-top__identity";const i=document.createElement("span");i.className="os-mobile-top__icon",i.setAttribute("aria-hidden","true");const r=document.createElement("h1");r.className="os-mobile-top__title",n.append(i,r);const s=document.createElement("div");s.className="os-mobile-top__controls";const d=document.createElement("button");d.type="button",d.className="os-mobile-top__button os-mobile-top__close",d.setAttribute("aria-label",E("Close app")),d.appendChild(G("close",{size:20})),d.addEventListener("click",e.onClose),s.append(d),t.append(n,s),o.appendChild(t);let a="";return{el:t,update(l){if(!l){r.textContent="",i.replaceChildren(),a="";return}r.textContent!==l.title&&(r.textContent=l.title),l.icon!==a&&(a=l.icon,i.replaceChildren(e.renderIcon(l.icon,{title:l.title,className:"os-mobile-top__glyph"})))},setHidden(l){t.hidden=l},setBackProgress(l){t.style.setProperty("--os-mobile-back-progress",String(l)),t.classList.toggle("os-mobile-top--peeking",l>0)}}}const Ye="openstation/mobile-layer",Ge="openstation/mobile",Qe="os-mobile-enter",Je="os-mobile-hero",so="os-overview",et="os-mobile-open-switcher",ao=800;function tt(o){const e=globalThis.CSS;return typeof e?.escape=="function"?e.escape(o):o.replace(/["\\]/g,"\\$&")}const lo={osMobile:"app"};function co(o){if(o.config.native)return E("App");try{const e=new URL(o.getCurrentUrl(),window.location.origin),t=e.pathname.split("/").pop()||e.pathname,n=e.searchParams.get("page")||e.searchParams.get("post_type");return n?`${t} · ${n}`:t}catch{return""}}function ot(o){return o.element.querySelector(".os-window__title")?.textContent?.trim()||o.config.title||""}function uo(o){const{manager:e,shell:t,area:n}=o,i=t.querySelector(".os-shell__body"),r=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;t.classList.add("os-mobile"),o.wallpaper.suspend(Ge);const s=ro(t,{renderIcon:o.renderIcon,onClose:()=>go()});i&&t.insertBefore(s.el,i);const d=Ut(n,{renderIcon:o.renderIcon,getBadge:o.getBadge,getArt:o.getArt,onOpen:u=>K(u)}),a=io(t,{renderIcon:o.renderIcon,getBadge:o.getBadge,onHome:()=>q(),onSwitcher:()=>po(),onOpen:u=>K(u)}),l=Qt(t,{renderIcon:o.renderIcon,onPick:u=>bo(u),onClose:u=>mo(u),onCloseAll:()=>{fo()},onDismiss:()=>re()}),m=document.createElement("div");m.className="os-mobile-edge os-mobile-edge--start",m.setAttribute("aria-hidden","true"),n.appendChild(m);const f=document.createElement("div");f.className="os-mobile-edge os-mobile-edge--end",f.setAttribute("aria-hidden","true"),n.appendChild(f);const c=u=>{const g=e.getActiveDesktopId();return(u.config.desktopId??g)===g},h=()=>e.getAll().filter(c),p=()=>{const u=h();for(let g=u.length-1;g>=0;g--)if(!u[g].isMinimized())return u[g];return null},x=()=>l.isOpen()?"switcher":p()?"app":"home";let v=[],C=null,A=null,M=0,P=!1,b=!1,_=!1;const w=(u,g)=>{let k=null;if(u==="home")k="home";else if(u==="switcher")k="switcher";else if(g){const H=g.config.baseId||g.id;k=v.find(R=>Ue(R,o.adminUrl)===H)?.id??null}return{active:k,openCount:h().length}},L=()=>{b=!1;const u=h().length;l.isOpen()&&A==="switcher"&&u===0&&M>0&&l.close(),M=u;const g=p(),k=x();if(t.dataset.osMobileState=k,d.setHidden(k!=="home"),s.setHidden(!g),s.update(g?{title:ot(g),icon:g.config.icon}:null),a.setState(w(k,g)),k==="home"&&A!=="home"&&d.reset(),g&&g.id!==C&&!r&&!_&&(g.element.classList.add(Qe),g.element.addEventListener("animationend",()=>g.element.classList.remove(Qe),{once:!0})),k==="app"&&!P)try{history.pushState(lo,""),P=!0}catch{}l.isOpen()&&l.update(ne()),C=g?.id??null,A=k},S=()=>{b||(b=!0,typeof requestAnimationFrame=="function"?requestAnimationFrame(L):setTimeout(L,0))},N=()=>Array.from(a.el.querySelectorAll(".os-mobile-tabs__item")).map(u=>u.dataset.tab??""),B=u=>{for(const g of a.el.querySelectorAll(".os-mobile-tabs__item"))if(u){const k=(g.dataset.tab??"").replace(/[^a-zA-Z0-9_-]/g,"_");g.style.setProperty("view-transition-name",`os-tab-${k}`),g.style.setProperty("view-transition-class","os-tab")}else g.style.removeProperty("view-transition-name"),g.style.removeProperty("view-transition-class")},W=u=>{const g=w(x(),p()),k=document,H=N(),R=["home",...u.map(ve=>ve.id),"switcher"];if(H.length===R.length&&H.every((ve,Co)=>ve===R[Co])||H.length===0||r||typeof k.startViewTransition!="function"||_){a.render(u,g);return}_=!0,B(!0),k.startViewTransition(()=>{a.render(u,g),B(!0)}).finished.catch(()=>{}).then(()=>{B(!1),_=!1})},z=()=>{const u=o.getNav();d.render(u),v=no(u,o.getPinnedTabIds()),W(v)},D=u=>d.el.querySelector(`.os-mobile-tile[data-nav-id="${tt(u)}"] .os-mobile-tile__icon`),O=u=>{const g=u.config.baseId||u.id,k=o.getNav();if(!k)return null;const{apps:H,system:R}=qe(k),de=[...H,...R].find(at=>Ue(at,o.adminUrl)===g);return de?D(de.id):null},I=(u=["os-window-opened","os-window-reopened","os-window-focused"])=>new Promise(g=>{let k=0;const H=()=>{for(const R of u)document.removeEventListener(R,H);clearTimeout(k),g()};for(const R of u)document.addEventListener(R,H);k=window.setTimeout(H,ao)}),V=(u,g,k)=>{const H=document;if(r||typeof H.startViewTransition!="function"||_){Promise.resolve(g()).then(L);return}_=!0,u?.style.setProperty("view-transition-name",Je);let R=null;H.startViewTransition(async()=>{u?.style.removeProperty("view-transition-name"),await g(),L(),R=k(),R?.style.setProperty("view-transition-name",Je)}).finished.catch(()=>{}).then(()=>{R?.style.removeProperty("view-transition-name"),_=!1})},K=u=>{if(u.id===so){ie();return}l.close();const g=x()==="home";V(g?D(u.id):null,async()=>{o.openNavItem(u)&&await I()},()=>p()?.element??null)},q=()=>{l.close();const u=p();V(u?.element??null,()=>{e.minimizeAll()},()=>u?O(u):null)},ce=()=>{if(l.isOpen()){re();return}if(P&&history.state&&history.state.osMobile==="app"){history.back();return}q()},ne=()=>{const u=p();return h().slice().reverse().map(g=>({id:g.id,title:ot(g),icon:g.config.icon,subtitle:co(g),active:g===u}))},ie=()=>{l.open(ne()),S()},re=()=>{l.close(),S()},po=()=>{l.isOpen()?re():ie()},bo=u=>{if(u.active){re();return}const g=l.el.querySelector(`.os-mobile-card[data-card-id="${tt(u.id)}"]`),k=e.getById(u.id);V(g,()=>{l.close(),k&&(k.isMinimized()&&k.restore(),e.focus(k))},()=>k?.element??null)},mo=u=>{e.getById(u.id)?.close(),S()},fo=async()=>{h().length===0||!await Nt({title:E("Close all apps?"),message:E("Anything unsaved in them will ask before it goes."),confirmLabel:E("Close all"),danger:!0})||(e.closeAll(),l.close(),S())},go=()=>{const u=p();u&&V(u.element,()=>{u.minimize(),u.close()},()=>O(u))},nt=["os-window-opened","os-window-closed","os-window-focused","os-window-blurred","os-window-changed","os-window-reopened"];for(const u of nt)document.addEventListener(u,S);const it=[le.WINDOW_MINIMIZED,le.WINDOW_RESTORED,le.WINDOW_TITLE_CHANGED,le.DESKTOP_SWITCHED];for(const u of it)Rt(u,Ye,S);const rt=()=>{history.state?.osMobile!=="app"&&P&&(P=!1,x()!=="home"&&q())};window.addEventListener("popstate",rt);const st=()=>ie();document.addEventListener(et,st);const vo=jt(m,{onProgress:u=>s.setBackProgress(u),onCommit:()=>ce()}),xo=[Be(m),Be(f)],yo=Xt(a.el,{onCommit:()=>ie()}),_o=Kt(s.el,{onCommit:()=>q()}),ko=o.subscribeNav(z),wo=o.subscribeArt?.(z)??(()=>{});return z(),L(),{unmount(){for(const u of nt)document.removeEventListener(u,S);for(const u of it)Dt(u,Ye);window.removeEventListener("popstate",rt),document.removeEventListener(et,st),vo();for(const u of xo)u();yo(),_o(),ko(),wo(),l.close(),s.el.remove(),d.el.remove(),a.el.remove(),l.el.remove(),m.remove(),f.remove(),delete t.dataset.osMobileState,t.classList.remove("os-mobile"),o.wallpaper.resume(Ge)},refresh:z,goHome:q,openSwitcher:ie,closeSwitcher:re,getState:x}}const ho={mount:uo};window.openStationMobile=ho})(); | |
| 177 | + `}function Pe(){const o=window.wp?.hooks;if(!o)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 o}function Rt(o,e,t,n){Pe().addAction(o,e,t,n)}function Dt(o,e){return Pe().removeAction(o,e)}const le={WINDOW_MINIMIZED:"os.window.minimized",WINDOW_RESTORED:"os.window.restored",WINDOW_TITLE_CHANGED:"os.window.title-changed",DESKTOP_SWITCHED:"os.os.switched"},Vt="desktop-mode";function ze(){return window.wp?.i18n}function E(o,e=Vt){return ze()?.__(o,e)??o}function He(o,...e){const t=ze()?.sprintf;if(t)return t(o,...e);let n=0;return o.replace(/%(?:(\d+)\$)?[sd]/g,(i,r)=>{const s=r?Number.parseInt(r,10)-1:n++;return String(e[s]??"")})}const Bt=.35,Ot=.6,Wt=24,Re=10,De=64,qt=44;function Zt(o){const{dx:e,dy:t,velocity:n,width:i}=o,r=Math.abs(e);return r<=Math.abs(t)?"cancel":i>0&&r>=i*Bt||Math.abs(n)>=Ot&&r>=Wt&&Math.sign(n)===Math.sign(e)?"commit":"cancel"}function Ve(o,e=De){return e<=0?o>0?1:0:Math.min(1,Math.max(0,o/e))}function jt(o,e){const t=e.threshold??De;let n=null,i=0,r=0,s=!1;const d=()=>{n=null,s=!1,e.onProgress?.(0)},a=c=>{if(!(n!==null||!c.isPrimary)){n=c.pointerId,i=c.clientX,r=c.clientY,s=!1;try{o.setPointerCapture(c.pointerId)}catch{}c.preventDefault()}},l=c=>{if(c.pointerId!==n||s)return;const h=c.clientX-i,p=c.clientY-r;if(Math.abs(p)>Re&&Math.abs(p)>Math.abs(h)){s=!0,e.onProgress?.(0);return}e.onProgress?.(Ve(h,t))},m=c=>{if(c.pointerId!==n)return;const h=!s&&Ve(c.clientX-i,t)>=1;d(),h&&e.onCommit()},f=c=>{c.pointerId===n&&d()};return o.addEventListener("pointerdown",a),o.addEventListener("pointermove",l),o.addEventListener("pointerup",m),o.addEventListener("pointercancel",f),()=>{o.removeEventListener("pointerdown",a),o.removeEventListener("pointermove",l),o.removeEventListener("pointerup",m),o.removeEventListener("pointercancel",f)}}function Be(o){const e=t=>{t.cancelable&&t.preventDefault()};return o.addEventListener("touchstart",e,{passive:!1}),()=>{o.removeEventListener("touchstart",e)}}function Xt(o,e){return Oe(o,"up",e)}function Kt(o,e){return Oe(o,"down",e)}function Oe(o,e,t){const n=t.threshold??qt,i=e==="up"?1:-1;let r=null,s=0,d=0,a=!1;const l=()=>{const h=p=>{p.stopPropagation(),p.preventDefault()};o.addEventListener("click",h,{capture:!0,once:!0}),setTimeout(()=>o.removeEventListener("click",h,{capture:!0}),350)},m=h=>{r!==null||!h.isPrimary||h.pointerType==="mouse"||(r=h.pointerId,s=h.clientX,d=h.clientY,a=!1)},f=h=>{if(h.pointerId!==r||a)return;const p=(d-h.clientY)*i,x=Math.abs(h.clientX-s);p>=n&&p>x&&(a=!0,l(),t.onCommit())},c=h=>{h.pointerId===r&&(r=null)};return o.addEventListener("pointerdown",m),o.addEventListener("pointermove",f),o.addEventListener("pointerup",c),o.addEventListener("pointercancel",c),()=>{o.removeEventListener("pointerdown",m),o.removeEventListener("pointermove",f),o.removeEventListener("pointerup",c),o.removeEventListener("pointercancel",c)}}const Ft=new Set(["os-mio-toggle","os-overview","os-site-assistant"]);function We(o){return Ft.has(o.id)?!1:!!(o.windowId||o.tile||o.menu?.url||o.entry?.url)}function qe(o){if(!o)return{apps:[],system:[]};const e=new Set,t=r=>{const s=[];for(const d of r)for(const a of d)e.has(a.id)||o.ephemeral.has(a.id)||!We(a)||(e.add(a.id),s.push(a));return s},n=t([o.dock.core,o.sidebar,o.dock.apps,o.desktop]),i=t([o.dock.controls]);return{apps:n,system:i}}function Ze(o,e){const t=e.trim().toLocaleLowerCase();return t?o.filter(n=>n.title.toLocaleLowerCase().includes(t)):o.slice()}function je(o){return o>99?"99+":String(o)}function Ut(o,e){const t=document.createElement("div");t.className="os-mobile-home",t.setAttribute("role","region"),t.setAttribute("aria-label",E("Home"));const n=document.createElement("div");n.className="os-mobile-home__search";const i=document.createElement("os-text-field");i.setAttribute("type","search"),i.setAttribute("placeholder",E("Search apps")),i.setAttribute("aria-label",E("Search apps")),i.setAttribute("autocomplete","off"),n.appendChild(i);const r=document.createElement("div");r.className="os-mobile-home__scroll";const s=document.createElement("div");s.className="os-mobile-home__content",r.appendChild(s),t.append(n,r),o.appendChild(t);let d={apps:[],system:[]},a="";const l=c=>{const h=document.createElement("div");h.className="os-mobile-grid__cell",h.setAttribute("role","listitem");const p=document.createElement("button");p.type="button",p.className="os-mobile-tile",p.dataset.navId=c.id;const x=document.createElement("span");x.className="os-mobile-tile__icon",x.appendChild(e.renderIcon(e.getArt?.(c)||c.icon,{title:c.title,className:"os-mobile-tile__glyph"}));const v=e.getBadge(c);if(v>0){const A=document.createElement("span");A.className="os-mobile-tile__badge",A.textContent=je(v),A.setAttribute("aria-hidden","true"),x.appendChild(A)}const C=document.createElement("span");return C.className="os-mobile-tile__label",C.textContent=c.title,p.append(x,C),p.setAttribute("aria-label",v>0?`${c.title}, ${je(v)}`:c.title),p.addEventListener("click",()=>e.onOpen(c)),h.appendChild(p),h},m=(c,h)=>{if(h.length===0)return null;const p=document.createElement("section");p.className="os-mobile-home__section";const x=document.createElement("h2");x.className="os-mobile-home__heading",x.textContent=c;const v=document.createElement("div");v.className="os-mobile-grid",v.setAttribute("role","list");for(const C of h)v.appendChild(l(C));return p.append(x,v),p},f=()=>{if(s.replaceChildren(),a.trim()){const p=Ze([...d.apps,...d.system],a),x=m(E("Results"),p);if(x)s.appendChild(x);else{const v=document.createElement("p");v.className="os-mobile-home__empty",v.textContent=E("Nothing matches."),s.appendChild(v)}return}const c=m(E("Apps"),d.apps),h=m(E("System"),d.system);if(c&&s.appendChild(c),h&&s.appendChild(h),!c&&!h){const p=document.createElement("p");p.className="os-mobile-home__empty",p.textContent=E("Nothing to show yet."),s.appendChild(p)}};return i.addEventListener("os-input-change",c=>{a=c.detail?.value??"",f()}),i.addEventListener("os-submit",()=>{const c=Ze([...d.apps,...d.system],a)[0];c&&e.onOpen(c)}),{el:t,render(c){d=qe(c),f()},setHidden(c){t.hidden=c},reset(){a&&(a="",i.setAttribute("value",""),i.value="",f()),r.scrollTop=0}}}const Xe={close:{a:'fill="currentColor"',b:'<path d="m13.06 12 6.47-6.47-1.06-1.06L12 10.94 5.53 4.47 4.47 5.53 10.94 12l-6.47 6.47 1.06 1.06L12 13.06l6.47 6.47 1.06-1.06L13.06 12Z" />'},check:{a:'fill="currentColor"',b:'<path d="M16.5 7.5 10 13.9l-2.5-2.4-1 1 3.5 3.6 7.5-7.6z" />'},"chevron-right":{a:'fill="currentColor"',b:'<path d="M10.6 6L9.4 7l4.6 5-4.6 5 1.2 1 5.4-6z" />'},"arrow-up-right":{a:'fill="currentColor"',b:'<path d="M10 6H18V14H16.5V8.5L7 18L6 17L15.5 7.5H10V6Z" />'},plus:{a:'fill="currentColor"',b:'<path d="M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z" />'},search:{a:'fill="currentColor"',b:'<path d="M13 5c-3.3 0-6 2.7-6 6 0 1.4.5 2.7 1.3 3.7l-3.8 3.8 1.1 1.1 3.8-3.8c1 .8 2.3 1.3 3.7 1.3 3.3 0 6-2.7 6-6S16.3 5 13 5zm0 10.5c-2.5 0-4.5-2-4.5-4.5s2-4.5 4.5-4.5 4.5 2 4.5 4.5-2 4.5-4.5 4.5z" />'},pin:{a:'fill="currentColor"',b:'<path d="m21.5 9.1-6.6-6.6-4.2 5.6c-1.2-.1-2.4.1-3.6.7-.1 0-.1.1-.2.1-.5.3-.9.6-1.2.9l3.7 3.7-5.7 5.7v1.1h1.1l5.7-5.7 3.7 3.7c.4-.4.7-.8.9-1.2.1-.1.1-.2.2-.3.6-1.1.8-2.4.6-3.6l5.6-4.1zm-7.3 3.5.1.9c.1.9 0 1.8-.4 2.6l-6-6c.8-.4 1.7-.5 2.6-.4l.9.1L15 4.9 19.1 9l-4.9 3.6z" />'},trash:{a:'fill="currentColor"',b:'<path fill-rule="evenodd" clip-rule="evenodd" d="M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z" />'},download:{a:'fill="currentColor"',b:'<path d="M18 11.3l-1-1.1-4 4V3h-1.5v11.3L7 10.2l-1 1.1 6.2 5.8 5.8-5.8zm.5 3.7v3.5h-13V15H4v5h16v-5h-1.5z" />'},settings:{a:'fill="currentColor"',b:'<path d="m19 7.5h-7.628c-.3089-.87389-1.1423-1.5-2.122-1.5-.97966 0-1.81309.62611-2.12197 1.5h-2.12803v1.5h2.12803c.30888.87389 1.14231 1.5 2.12197 1.5.9797 0 1.8131-.62611 2.122-1.5h7.628z" /><path d="m19 15h-2.128c-.3089-.8739-1.1423-1.5-2.122-1.5s-1.8131.6261-2.122 1.5h-7.628v1.5h7.628c.3089.8739 1.1423 1.5 2.122 1.5s1.8131-.6261 2.122-1.5h2.128z" />'},info:{a:'fill="currentColor"',b:'<path fill-rule="evenodd" clip-rule="evenodd" d="M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm.75 4v1.5h-1.5V8h1.5Zm0 8v-5h-1.5v5h1.5Z" />'},bell:{a:'fill="currentColor"',b:'<path fill-rule="evenodd" clip-rule="evenodd" d="M17 11.5c0 1.353.17 2.368.976 3 .266.209.602.376 1.024.5v1H5v-1c.422-.124.757-.291 1.024-.5.806-.632.976-1.647.976-3V9c0-2.8 2.2-5 5-5s5 2.2 5 5v2.5ZM15.5 9v2.5c0 .93.066 1.98.515 2.897l.053.103H7.932a4.018 4.018 0 0 0 .053-.103c.449-.917.515-1.967.515-2.897V9c0-1.972 1.528-3.5 3.5-3.5s3.5 1.528 3.5 3.5Zm-5.492 9.008c0-.176.023-.346.065-.508h3.854A1.996 1.996 0 0 1 12 20c-1.1 0-1.992-.892-1.992-1.992Z" />'},more:{a:'fill="currentColor"',b:'<path d="M11 13h2v-2h-2v2zm-6 0h2v-2H5v2zm12-2v2h2v-2h-2z" />'},maximize:{a:'fill="currentColor"',b:'<path d="M6 4a2 2 0 0 0-2 2v3h1.5V6a.5.5 0 0 1 .5-.5h3V4H6Zm3 14.5H6a.5.5 0 0 1-.5-.5v-3H4v3a2 2 0 0 0 2 2h3v-1.5Zm6 1.5v-1.5h3a.5.5 0 0 0 .5-.5v-3H20v3a2 2 0 0 1-2 2h-3Zm3-16a2 2 0 0 1 2 2v3h-1.5V6a.5.5 0 0 0-.5-.5h-3V4h3Z" />'},edit:{a:'fill="currentColor"',b:'<path d="m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z" />'},color:{a:'fill="currentColor"',b:'<path d="M17.2 10.9c-.5-1-1.2-2.1-2.1-3.2-.6-.9-1.3-1.7-2.1-2.6L12 4l-1 1.1c-.6.9-1.3 1.7-2 2.6-.8 1.2-1.5 2.3-2 3.2-.6 1.2-1 2.2-1 3 0 3.4 2.7 6.1 6.1 6.1s6.1-2.7 6.1-6.1c0-.8-.3-1.8-1-3zm-5.1 7.6c-2.5 0-4.6-2.1-4.6-4.6 0-.3.1-1 .8-2.3.5-.9 1.1-1.9 2-3.1.7-.9 1.3-1.7 1.8-2.3.7.8 1.3 1.6 1.8 2.3.8 1.1 1.5 2.2 2 3.1.7 1.3.8 2 .8 2.3 0 2.5-2.1 4.6-4.6 4.6z" />'},wallpaper:{a:'fill="currentColor"',b:'<path d="M19 3H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V5c0-1.1-.9-2-2-2zM5 4.5h14c.3 0 .5.2.5.5v8.4l-3-2.9c-.3-.3-.8-.3-1 0L11.9 14 9 12c-.3-.2-.6-.2-.8 0l-3.6 2.6V5c-.1-.3.1-.5.4-.5zm14 15H5c-.3 0-.5-.2-.5-.5v-2.4l4.1-3 3 1.9c.3.2.7.2.9-.1L16 12l3.5 3.4V19c0 .3-.2.5-.5.5z" />'},warning:{a:'fill="currentColor"',b:'<path fill-rule="evenodd" clip-rule="evenodd" d="M5.5 12a6.5 6.5 0 1 0 13 0 6.5 6.5 0 0 0-13 0ZM12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16Zm-.75 12v-1.5h1.5V16h-1.5Zm0-8v5h1.5V8h-1.5Z" />'},minimize:{a:'fill="currentColor"',b:'<path d="M5 11.25h14v1.5H5z" />'},window:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="4.125" y="5.4375" width="15.75" height="13.125" rx="1.75"/><path d="M4.125 9.8125h15.75"/><circle cx="7.275" cy="7.625" r="0.7438" fill="currentColor" stroke="none"/>'},windows:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.6875" y="8.5" width="11.375" height="10.0625" rx="1.75"/><path d="M3.6875 12h11.375"/><path d="M8.5 8.5V7.1875a1.75 1.75 0 0 1 1.75-1.75h7.875A1.75 1.75 0 0 1 19.875 7.1875v7a1.75 1.75 0 0 1-1.75 1.75h-3.0625"/>'},dock:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.25" y="8.5" width="17.5" height="7" rx="3.5"/><circle cx="7.625" cy="12" r="1.0062" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.0062" fill="currentColor" stroke="none"/><circle cx="16.375" cy="12" r="1.0062" fill="currentColor" stroke="none"/>'},spaces:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.6875" y="5.4375" width="7.4375" height="7.875" rx="1.75"/><rect x="12.875" y="5.4375" width="7.4375" height="7.875" rx="1.75"/><circle cx="9.375" cy="17.6875" r="0.7875" fill="currentColor" stroke="none"/><circle cx="12" cy="17.6875" r="0.7875" fill="currentColor" stroke="none"/><circle cx="14.625" cy="17.6875" r="0.7875" fill="currentColor" stroke="none"/>'},copilot:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<path d="M10 2.5Q10.9 8.5 17.5 10Q10.9 11.5 10 17.5Q9.1 11.5 2.5 10Q9.1 8.5 10 2.5Z" fill="currentColor" stroke="none"/><path d="M17.9 14Q18.35 17.1 21.5 17.6Q18.35 18.1 17.9 21.2Q17.45 18.1 14.3 17.6Q17.45 17.1 17.9 14Z" fill="currentColor" stroke="none"/>'},snap:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.6875" y="5.4375" width="16.625" height="13.125" rx="1.75"/><path d="M12 5.4375v13.125"/><path d="M12 12h8.3125"/>'},command:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<path d="M14.625 6.75v10.5a2.625 2.625 0 1 0 2.625-2.625H6.75a2.625 2.625 0 1 0 2.625 2.625V6.75a2.625 2.625 0 1 0-2.625 2.625h10.5a2.625 2.625 0 1 0-2.625-2.625"/>'},apps:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="4.125" y="4.125" width="6.5625" height="6.5625" rx="1.75"/><rect x="13.3125" y="4.125" width="6.5625" height="6.5625" rx="1.75"/><rect x="4.125" y="13.3125" width="6.5625" height="6.5625" rx="1.75"/><rect x="13.3125" y="13.3125" width="6.5625" height="6.5625" rx="1.75"/>'},widgets:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="3.6875" y="3.6875" width="9.625" height="9.625" rx="1.75"/><rect x="15.0625" y="3.6875" width="5.25" height="5.25" rx="1.75"/><rect x="15.0625" y="10.6875" width="5.25" height="9.625" rx="1.75"/><rect x="3.6875" y="15.0625" width="9.625" height="5.25" rx="1.75"/>'},user:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<circle cx="12" cy="8.9375" r="3.5"/><path d="M5.4375 19.4375a6.5625 6.5625 0 0 1 13.125 0"/>'},lock:{a:'fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"',b:'<rect x="5.4375" y="10.6875" width="13.125" height="8.75" rx="1.75"/><path d="M8.5 10.6875V8.0625a3.5 3.5 0 0 1 7 0v2.625"/>'}};function Ke(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Yt(o){return Object.prototype.hasOwnProperty.call(Xe,o)?Xe[o]:null}function Gt(o,e={}){const t=Yt(o);if(!t)return"";const{size:n=24,className:i,title:r,rotate:s}=e,d=['xmlns="http://www.w3.org/2000/svg"','viewBox="0 0 24 24"'];n!=null&&d.push(`width="${n}"`,`height="${n}"`),d.push(t.a),i&&d.push(`class="${Ke(i)}"`),r?d.push('role="img"',`aria-label="${Ke(r)}"`):d.push('aria-hidden="true"','focusable="false"');const a=s?`<g transform="rotate(${s} 12 12)">${t.b}</g>`:t.b;return`<svg ${d.join(" ")}>${a}</svg>`}function G(o,e={}){const t=Gt(o,e),n=document.createElement("div");n.innerHTML=t;const i=n.firstElementChild;return i instanceof SVGSVGElement?i:document.createElementNS("http://www.w3.org/2000/svg","svg")}function Qt(o,e){const t=document.createElement("div");t.className="os-mobile-switcher",t.setAttribute("role","dialog"),t.setAttribute("aria-modal","true"),t.setAttribute("aria-label",E("Open apps")),t.hidden=!0;const n=document.createElement("div");n.className="os-mobile-switcher__backdrop",n.addEventListener("click",()=>e.onDismiss());const i=document.createElement("div");i.className="os-mobile-switcher__sheet";const r=document.createElement("header");r.className="os-mobile-switcher__header";const s=document.createElement("h2");s.className="os-mobile-switcher__title",s.textContent=E("Open apps");const d=document.createElement("button");d.type="button",d.className="os-mobile-switcher__close",d.setAttribute("aria-label",E("Close the switcher")),d.appendChild(G("close",{size:20})),d.addEventListener("click",()=>e.onDismiss()),r.append(s,d);const a=document.createElement("div");a.className="os-mobile-switcher__list";const l=document.createElement("footer");l.className="os-mobile-switcher__footer";const m=document.createElement("os-button");m.setAttribute("variant","secondary"),m.textContent=E("Close all"),m.addEventListener("click",()=>e.onCloseAll()),l.appendChild(m),i.append(r,a,l),t.append(n,i),o.appendChild(t);let f=!1,c=!1,h=null,p=null;const x=b=>{b.key==="Escape"&&(b.preventDefault(),e.onDismiss())},v=b=>{const _=document.createElement("div");_.className="os-mobile-card",_.dataset.cardId=b.id,b.active&&_.classList.add("os-mobile-card--active");const w=document.createElement("button");w.type="button",w.className="os-mobile-card__body",b.active&&w.setAttribute("aria-current","true"),w.setAttribute("aria-label",b.title);const L=document.createElement("span");L.className="os-mobile-card__icon",L.appendChild(e.renderIcon(b.icon,{title:b.title,className:"os-mobile-card__glyph"}));const S=document.createElement("span");S.className="os-mobile-card__text";const N=document.createElement("span");N.className="os-mobile-card__title",N.textContent=b.title;const B=document.createElement("span");if(B.className="os-mobile-card__subtitle",B.textContent=b.subtitle,S.append(N,B),b.active){const O=document.createElement("span");O.className="os-mobile-card__status",O.textContent=E("Active"),N.appendChild(O)}const W=document.createElement("span");W.className="os-mobile-card__bar",W.append(L,S);const z=document.createElement("span");z.className="os-mobile-card__preview",z.setAttribute("aria-hidden","true"),w.append(W,z),w.addEventListener("click",()=>e.onPick(b));const D=document.createElement("button");return D.type="button",D.className="os-mobile-card__close",D.setAttribute("aria-label",He(E("Close %s"),b.title)),D.appendChild(G("close",{size:16})),D.addEventListener("click",O=>{O.stopPropagation(),C(_,b,1)}),_.append(w,D),A(_,b),_},C=(b,_,w)=>{b.classList.add("os-mobile-card--out"),b.style.setProperty("--os-mobile-card-dir",String(w));let L=!1;const S=()=>{L||(L=!0,e.onClose(_))};b.addEventListener("transitionend",S,{once:!0}),setTimeout(S,240)},A=(b,_)=>{let w=null,L=0,S=0,N=0,B=0,W=0,z=!1;const D=()=>{if(b.classList.remove("os-mobile-card--dragging"),b.style.transform="",b.style.opacity="",w=null,z=!1,c=!1,h){const I=h;h=null,P(I)}};b.addEventListener("pointerdown",I=>{!I.isPrimary||w!==null||(w=I.pointerId,L=N=I.clientX,S=I.clientY,B=I.timeStamp,W=0,z=!1)}),b.addEventListener("pointermove",I=>{if(I.pointerId!==w)return;const V=I.clientX-L,K=I.clientY-S;if(!z){if(Math.abs(V)<Re)return;if(Math.abs(K)>Math.abs(V)){w=null;return}z=!0,c=!0,b.classList.add("os-mobile-card--dragging");try{b.setPointerCapture(I.pointerId)}catch{}}const q=Math.max(1,I.timeStamp-B);W=(I.clientX-N)/q,N=I.clientX,B=I.timeStamp,b.style.transform=`translateX(${V}px)`,b.style.opacity=String(Math.max(.35,1-Math.abs(V)/Math.max(1,b.offsetWidth)))});const O=I=>{if(I.pointerId!==w)return;if(!z){w=null;return}const V=I.clientX-L,K=I.clientY-S,q=Zt({dx:V,dy:K,velocity:W,width:b.offsetWidth}),ce=ne=>{ne.stopPropagation(),ne.preventDefault()};if(b.addEventListener("click",ce,{capture:!0,once:!0}),setTimeout(()=>b.removeEventListener("click",ce,{capture:!0}),300),q==="commit"){b.classList.remove("os-mobile-card--dragging"),w=null,z=!1,c=!1,C(b,_,V<0?-1:1);return}D()};b.addEventListener("pointerup",O),b.addEventListener("pointercancel",I=>{I.pointerId===w&&D()})},M=b=>{const _=document.createElement("section");_.className="os-mobile-deck";const w=document.createElement("div");return w.className="os-mobile-deck__cards",b.forEach((L,S)=>{const N=v(L);N.style.zIndex=String(b.length-S),w.appendChild(N)}),_.appendChild(w),_},P=b=>{if(a.replaceChildren(),b.length===0){const _=document.createElement("p");_.className="os-mobile-switcher__empty",_.textContent=E("Nothing open. Pick something from Home."),a.appendChild(_),l.hidden=!0;return}a.appendChild(M(b)),l.hidden=!1};return{el:t,isOpen:()=>f,open(b){if(f){this.update(b);return}f=!0;const _=t.ownerDocument.activeElement;p=_ instanceof HTMLElement?_:null,P(b),t.hidden=!1,document.addEventListener("keydown",x),(a.querySelector(".os-mobile-card__body")??d).focus()},update(b){if(f){if(c){h=b;return}P(b)}},close(){if(!f)return;f=!1,c=!1,h=null,t.hidden=!0,document.removeEventListener("keydown",x);const b=p;p=null,b&&b.isConnected&&b.focus()}}}const Jt=["post_type","page","taxonomy","path","post","c","tag_ID","item","p"],ge=[];function eo(o){if(!o.pathname.endsWith("/admin.php")||!o.searchParams.get("page"))return ge;const e=o.searchParams.get("action");return e==="edit"&&o.searchParams.get("id")?["id"]:e==="new"?["action"]:ge}function Fe(o){let e=o;try{e=decodeURIComponent(o)}catch{e=o}return e.replace(/\.php/g,"-php").replace(/[?&=/]/g,"-").replace(/[^a-zA-Z0-9_-]/g,"").replace(/-+/g,"-").replace(/^-|-$/g,"")||"index"}function to(o,e){let t=null;try{t=new URL(o,e)}catch{t=null}if(t){const i=new URL(e).pathname,r=t.pathname.replace(i,"").replace(/^\/+/,""),s=new URLSearchParams,d=[...Jt,...eo(t)];for(const l of d){const m=t.searchParams.get(l);m&&s.set(l,m)}const a=s.toString();return Fe(a?`${r}?${a}`:r)}let n=o.replace(e,"");return n.startsWith("/")&&(n=n.substring(1)),Fe(n)}const oo=3;function Ue(o,e){if(o.windowId)return o.windowId;const t=o.menu?.url||o.entry?.url;if(!t)return null;try{return to(t,e)}catch{return null}}function no(o,e,t=oo){if(!o||t<=0)return[];const n=[...o.dock.core,...o.sidebar,...o.dock.apps,...o.desktop],i=new Map;for(const a of n)i.has(a.id)||i.set(a.id,a);const r=a=>!!a&&!a.locked&&!o.ephemeral.has(a.id)&&We(a),s=[],d=new Set;for(const a of e){const l=i.get(a);if(r(l)&&!d.has(l.id)&&(d.add(l.id),s.push(l),s.length>=t))return s}if(s.length>0)return s;for(const a of n){if(s.length>=t)break;r(a)&&!d.has(a.id)&&(d.add(a.id),s.push(a))}return s}function io(o,e){const t=document.createElement("nav");t.className="os-mobile-tabs",t.setAttribute("aria-label",E("Primary")),o.appendChild(t);let n=[],i=null,r=null,s=null;const d=(l,m,f)=>{const c=document.createElement("button");c.type="button",c.className="os-mobile-tabs__item",c.dataset.tab=l;const h=document.createElement("span");h.className="os-mobile-tabs__icon",h.appendChild(f);const p=document.createElement("span");return p.className="os-mobile-tabs__label",p.textContent=m,c.append(h,p),c},a=l=>{for(const m of n)m.dataset.tab===l.active?m.setAttribute("aria-current","page"):m.removeAttribute("aria-current");i&&(i.hidden=l.openCount===0,i.textContent=i.hidden?"":String(Math.min(l.openCount,99))),s?.classList.toggle("os-mobile-tabs__icon--counted",l.openCount>0),r&&r.setAttribute("aria-label",He(E("Open apps (%d)"),l.openCount))};return{el:t,render(l,m){t.replaceChildren(),n=[];const f=d("home",E("Home"),G("apps",{size:22}));f.addEventListener("click",e.onHome),n.push(f);for(const c of l){const h=d(c.id,c.title,e.renderIcon(c.icon,{title:c.title,className:"os-mobile-tabs__glyph"})),p=e.getBadge(c);if(p>0){const x=document.createElement("span");x.className="os-mobile-tabs__badge",x.textContent=p>99?"99+":String(p),x.setAttribute("aria-hidden","true"),h.querySelector(".os-mobile-tabs__icon")?.appendChild(x),h.setAttribute("aria-label",`${c.title}, ${p>99?"99+":p}`)}h.addEventListener("click",()=>e.onOpen(c)),n.push(h)}r=d("switcher",E("Open apps"),G("windows",{size:22})),s=r.querySelector(".os-mobile-tabs__icon"),i=document.createElement("span"),i.className="os-mobile-tabs__count",i.setAttribute("aria-hidden","true"),s?.appendChild(i),r.addEventListener("click",e.onSwitcher),n.push(r),t.append(...n),a(m)},setState:a}}function ro(o,e){const t=document.createElement("header");t.className="os-mobile-top",t.hidden=!0;const n=document.createElement("div");n.className="os-mobile-top__identity";const i=document.createElement("span");i.className="os-mobile-top__icon",i.setAttribute("aria-hidden","true");const r=document.createElement("h1");r.className="os-mobile-top__title",n.append(i,r);const s=document.createElement("div");s.className="os-mobile-top__controls";const d=document.createElement("button");d.type="button",d.className="os-mobile-top__button os-mobile-top__close",d.setAttribute("aria-label",E("Close app")),d.appendChild(G("close",{size:20})),d.addEventListener("click",e.onClose),s.append(d),t.append(n,s),o.appendChild(t);let a="";return{el:t,update(l){if(!l){r.textContent="",i.replaceChildren(),a="";return}r.textContent!==l.title&&(r.textContent=l.title),l.icon!==a&&(a=l.icon,i.replaceChildren(e.renderIcon(l.icon,{title:l.title,className:"os-mobile-top__glyph"})))},setHidden(l){t.hidden=l},setBackProgress(l){t.style.setProperty("--os-mobile-back-progress",String(l)),t.classList.toggle("os-mobile-top--peeking",l>0)}}}const Ye="openstation/mobile-layer",Ge="openstation/mobile",Qe="os-mobile-enter",Je="os-mobile-hero",so="os-overview",et="os-mobile-open-switcher",ao=800;function tt(o){const e=globalThis.CSS;return typeof e?.escape=="function"?e.escape(o):o.replace(/["\\]/g,"\\$&")}const lo={osMobile:"app"};function co(o){if(o.config.native)return E("App");try{const e=new URL(o.getCurrentUrl(),window.location.origin),t=e.pathname.split("/").pop()||e.pathname,n=e.searchParams.get("page")||e.searchParams.get("post_type");return n?`${t} · ${n}`:t}catch{return""}}function ot(o){return o.element.querySelector(".os-window__title")?.textContent?.trim()||o.config.title||""}function uo(o){const{manager:e,shell:t,area:n}=o,i=t.querySelector(".os-shell__body"),r=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches;t.classList.add("os-mobile"),o.wallpaper.suspend(Ge);const s=ro(t,{renderIcon:o.renderIcon,onClose:()=>go()});i&&t.insertBefore(s.el,i);const d=Ut(n,{renderIcon:o.renderIcon,getBadge:o.getBadge,getArt:o.getArt,onOpen:u=>K(u)}),a=io(t,{renderIcon:o.renderIcon,getBadge:o.getBadge,onHome:()=>q(),onSwitcher:()=>po(),onOpen:u=>K(u)}),l=Qt(t,{renderIcon:o.renderIcon,onPick:u=>bo(u),onClose:u=>mo(u),onCloseAll:()=>{fo()},onDismiss:()=>re()}),m=document.createElement("div");m.className="os-mobile-edge os-mobile-edge--start",m.setAttribute("aria-hidden","true"),n.appendChild(m);const f=document.createElement("div");f.className="os-mobile-edge os-mobile-edge--end",f.setAttribute("aria-hidden","true"),n.appendChild(f);const c=u=>{const g=e.getActiveDesktopId();return(u.config.desktopId??g)===g},h=()=>e.getAll().filter(c),p=()=>{const u=h();for(let g=u.length-1;g>=0;g--)if(!u[g].isMinimized())return u[g];return null},x=()=>l.isOpen()?"switcher":p()?"app":"home";let v=[],C=null,A=null,M=0,P=!1,b=!1,_=!1;const w=(u,g)=>{let k=null;if(u==="home")k="home";else if(u==="switcher")k="switcher";else if(g){const H=g.config.baseId||g.id;k=v.find(R=>Ue(R,o.adminUrl)===H)?.id??null}return{active:k,openCount:h().length}},L=()=>{b=!1;const u=h().length;l.isOpen()&&A==="switcher"&&u===0&&M>0&&l.close(),M=u;const g=p(),k=x();if(t.dataset.osMobileState=k,d.setHidden(k!=="home"),s.setHidden(!g),s.update(g?{title:ot(g),icon:g.config.icon}:null),a.setState(w(k,g)),k==="home"&&A!=="home"&&d.reset(),g&&g.id!==C&&!r&&!_&&(g.element.classList.add(Qe),g.element.addEventListener("animationend",()=>g.element.classList.remove(Qe),{once:!0})),k==="app"&&!P)try{history.pushState(lo,""),P=!0}catch{}l.isOpen()&&l.update(ne()),C=g?.id??null,A=k},S=()=>{b||(b=!0,typeof requestAnimationFrame=="function"?requestAnimationFrame(L):setTimeout(L,0))},N=()=>Array.from(a.el.querySelectorAll(".os-mobile-tabs__item")).map(u=>u.dataset.tab??""),B=u=>{for(const g of a.el.querySelectorAll(".os-mobile-tabs__item"))if(u){const k=(g.dataset.tab??"").replace(/[^a-zA-Z0-9_-]/g,"_");g.style.setProperty("view-transition-name",`os-tab-${k}`),g.style.setProperty("view-transition-class","os-tab")}else g.style.removeProperty("view-transition-name"),g.style.removeProperty("view-transition-class")},W=u=>{const g=w(x(),p()),k=document,H=N(),R=["home",...u.map(ve=>ve.id),"switcher"];if(H.length===R.length&&H.every((ve,Co)=>ve===R[Co])||H.length===0||r||typeof k.startViewTransition!="function"||_){a.render(u,g);return}_=!0,B(!0),k.startViewTransition(()=>{a.render(u,g),B(!0)}).finished.catch(()=>{}).then(()=>{B(!1),_=!1})},z=()=>{const u=o.getNav();d.render(u),v=no(u,o.getPinnedTabIds()),W(v)},D=u=>d.el.querySelector(`.os-mobile-tile[data-nav-id="${tt(u)}"] .os-mobile-tile__icon`),O=u=>{const g=u.config.baseId||u.id,k=o.getNav();if(!k)return null;const{apps:H,system:R}=qe(k),de=[...H,...R].find(at=>Ue(at,o.adminUrl)===g);return de?D(de.id):null},I=(u=["os-window-opened","os-window-reopened","os-window-focused"])=>new Promise(g=>{let k=0;const H=()=>{for(const R of u)document.removeEventListener(R,H);clearTimeout(k),g()};for(const R of u)document.addEventListener(R,H);k=window.setTimeout(H,ao)}),V=(u,g,k)=>{const H=document;if(r||typeof H.startViewTransition!="function"||_){Promise.resolve(g()).then(L);return}_=!0,u?.style.setProperty("view-transition-name",Je);let R=null;H.startViewTransition(async()=>{u?.style.removeProperty("view-transition-name"),await g(),L(),R=k(),R?.style.setProperty("view-transition-name",Je)}).finished.catch(()=>{}).then(()=>{R?.style.removeProperty("view-transition-name"),_=!1})},K=u=>{if(u.id===so){ie();return}l.close();const g=x()==="home";V(g?D(u.id):null,async()=>{o.openNavItem(u)&&await I()},()=>p()?.element??null)},q=()=>{l.close();const u=p();V(u?.element??null,()=>{e.minimizeAll()},()=>u?O(u):null)},ce=()=>{if(l.isOpen()){re();return}if(P&&history.state&&history.state.osMobile==="app"){history.back();return}q()},ne=()=>{const u=p();return h().slice().reverse().map(g=>({id:g.id,title:ot(g),icon:g.config.icon,subtitle:co(g),active:g===u}))},ie=()=>{l.open(ne()),S()},re=()=>{l.close(),S()},po=()=>{l.isOpen()?re():ie()},bo=u=>{if(u.active){re();return}const g=l.el.querySelector(`.os-mobile-card[data-card-id="${tt(u.id)}"]`),k=e.getById(u.id);V(g,()=>{l.close(),k&&(k.isMinimized()&&k.restore(),e.focus(k))},()=>k?.element??null)},mo=u=>{e.getById(u.id)?.close(),S()},fo=async()=>{h().length===0||!await Nt({title:E("Close all apps?"),message:E("Anything unsaved in them will ask before it goes."),confirmLabel:E("Close all"),danger:!0})||(e.closeAll(),l.close(),S())},go=()=>{const u=p();u&&V(u.element,()=>{u.minimize(),u.close()},()=>O(u))},nt=["os-window-opened","os-window-closed","os-window-focused","os-window-blurred","os-window-changed","os-window-reopened"];for(const u of nt)document.addEventListener(u,S);const it=[le.WINDOW_MINIMIZED,le.WINDOW_RESTORED,le.WINDOW_TITLE_CHANGED,le.DESKTOP_SWITCHED];for(const u of it)Rt(u,Ye,S);const rt=()=>{history.state?.osMobile!=="app"&&P&&(P=!1,x()!=="home"&&q())};window.addEventListener("popstate",rt);const st=()=>ie();document.addEventListener(et,st);const vo=jt(m,{onProgress:u=>s.setBackProgress(u),onCommit:()=>ce()}),xo=[Be(m),Be(f)],yo=Xt(a.el,{onCommit:()=>ie()}),_o=Kt(s.el,{onCommit:()=>q()}),ko=o.subscribeNav(z),wo=o.subscribeArt?.(z)??(()=>{});return z(),L(),{unmount(){for(const u of nt)document.removeEventListener(u,S);for(const u of it)Dt(u,Ye);window.removeEventListener("popstate",rt),document.removeEventListener(et,st),vo();for(const u of xo)u();yo(),_o(),ko(),wo(),l.close(),s.el.remove(),d.el.remove(),a.el.remove(),l.el.remove(),m.remove(),f.remove(),delete t.dataset.osMobileState,t.classList.remove("os-mobile"),o.wallpaper.resume(Ge)},refresh:z,goHome:q,openSwitcher:ie,closeSwitcher:re,getState:x}}const ho={mount:uo};window.openStationMobile=ho})(); | |