PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.12
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.12
1.1.12 1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 All 36 releases
← All changes | assets/js/games.min.js +51 -40 0.9.7 → 1.1.12 View file →
@@ -1,65 +1,76 @@
1 -(function(){"use strict";function w(n,...e){return{__wpdHtml:!0,strings:n,values:e}}function nt(n){return!!n&&n.__wpdHtml===!0}const it="$$wpd$$",v=/\$\$wpd\$\$(\d+)\$\$/g;function rt(n){let e=n[0];for(let t=1;t<n.length;t++)e+=`${it}${t-1}$$`+n[t];return e}const Se=new WeakMap;function Ae(n){const e=Se.get(n);if(e)return e;const t=document.createElement("template");t.innerHTML=rt(n);const s=[],i=(a,d)=>{if(a.nodeType===Node.ELEMENT_NODE){const c=a;for(const f of Array.from(c.attributes)){const u=f.name,h=f.value,m=u[0];if(v.test(h))if(v.lastIndex=0,m==="@"){const g=v.exec(h);v.lastIndex=0,s.push({path:d,kind:"event",name:u.slice(1),valueIndex:g?Number(g[1]):0}),c.removeAttribute(u)}else if(m==="."){const g=v.exec(h);v.lastIndex=0,s.push({path:d,kind:"prop",name:u.slice(1),valueIndex:g?Number(g[1]):0}),c.removeAttribute(u)}else if(m==="?"){const g=v.exec(h);v.lastIndex=0,s.push({path:d,kind:"bool",name:u.slice(1),valueIndex:g?Number(g[1]):0}),c.removeAttribute(u)}else{const g=[],k=[];let _=0,x;for(v.lastIndex=0;(x=v.exec(h))!==null;)g.push(h.slice(_,x.index)),k.push(Number(x[1])),_=x.index+x[0].length;g.push(h.slice(_)),s.push({path:d,kind:"attr",name:u,template:g,valueIndices:k}),c.setAttribute(u,"")}}}const l=Array.from(a.childNodes);let p=0;for(let c=0;c<l.length;c++){const f=l[c],u=c+p;if(f.nodeType===Node.TEXT_NODE){const h=f.textContent||"";if(!v.test(h)){v.lastIndex=0;continue}v.lastIndex=0;const m=f.parentNode;let g=0,k;const _=[],x=[];for(v.lastIndex=0;(k=v.exec(h))!==null;){k.index>g&&_.push(document.createTextNode(h.slice(g,k.index)));const I=document.createTextNode("");_.push(I),x.push({path:[...d,u+_.length-1],kind:"node",valueIndex:Number(k[1])}),g=k.index+k[0].length}g<h.length&&_.push(document.createTextNode(h.slice(g)));for(const I of _)m.insertBefore(I,f);m.removeChild(f),p+=_.length-1,s.push(...x)}else i(f,[...d,u])}};i(t.content,[]);const o={template:t,buildParts:a=>{const d=[];for(const l of s){let p=a;for(const c of l.path)p=p.childNodes[c];l.kind==="node"?d.push({kind:"node",valueIndex:l.valueIndex,child:{anchor:p,state:null}}):l.kind==="attr"?d.push({kind:"attr",element:p,name:l.name,template:l.template,valueIndices:l.valueIndices}):l.kind==="event"?d.push({kind:"event",valueIndex:l.valueIndex,element:p,name:l.name}):l.kind==="prop"?d.push({kind:"prop",valueIndex:l.valueIndex,element:p,name:l.name}):l.kind==="bool"&&d.push({kind:"bool",valueIndex:l.valueIndex,element:p,name:l.name})}return d}};return Se.set(n,o),o}const Ee=new WeakMap;function ot(n,e){for(const t of n.nodes)if(t.parentNode!==e)return!1;return!0}function K(n,e){const t=Ee.get(e);if(t&&t.strings===n.strings&&ot(t,e)){X(t.parts,n.values);return}const s=Ae(n.strings),i=s.template.content.cloneNode(!0),r=s.buildParts(i),o=Array.from(i.childNodes);for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(i),X(r,n.values),Ee.set(e,{strings:n.strings,parts:r,nodes:o})}function X(n,e){for(const t of n)if(t.kind==="node")oe(t.child,e[t.valueIndex]);else if(t.kind==="attr"){let s=t.template[0];for(let i=0;i<t.valueIndices.length;i++)s+=$e(e[t.valueIndices[i]]),s+=t.template[i+1];s!==t.last&&(t.last=s,s===""?t.element.removeAttribute(t.name):t.element.setAttribute(t.name,s))}else if(t.kind==="event"){const s=e[t.valueIndex];s!==t.current&&(t.current&&t.element.removeEventListener(t.name,t.current),s&&t.element.addEventListener(t.name,s),t.current=s)}else if(t.kind==="prop"){const s=e[t.valueIndex];s!==t.last&&(t.last=s,t.element[t.name]=s)}else if(t.kind==="bool"){const s=!!e[t.valueIndex];s!==t.last&&(t.last=s,s?t.element.setAttribute(t.name,""):t.element.removeAttribute(t.name))}}function oe(n,e){if(e==null||e===!1){n.state&&(T(n.state),n.state=null);return}if(Array.isArray(e)){ct(n,e);return}if(nt(e)){lt(n,e);return}if(e instanceof Node){at(n,e);return}dt(n,$e(e))}function at(n,e){const t=n.state;t?.shape==="node"&&t.node===e||(t&&T(t),Y(n,[e]),n.state={shape:"node",node:e})}function dt(n,e){const t=n.state;if(t?.shape==="text"){t.text!==e&&(t.node.textContent=e,t.text=e);return}t&&T(t);const s=document.createTextNode(e);Y(n,[s]),n.state={shape:"text",node:s,text:e}}function lt(n,e){const t=n.state;if(t?.shape==="template"&&t.strings===e.strings){X(t.parts,e.values);return}t&&T(t);const s=Ae(e.strings),i=s.template.content.cloneNode(!0),r=s.buildParts(i),o=Array.from(i.childNodes);Y(n,[i]),X(r,e.values),n.state={shape:"template",strings:e.strings,parts:r,nodes:o}}function ct(n,e){const t=n.state;if(t?.shape==="array"&&t.entries.length===e.length){for(let i=0;i<e.length;i++)oe(t.entries[i],e[i]);return}t&&T(t);const s=[];for(const i of e){const r=document.createTextNode("");Y(n,[r]);const o={anchor:r,state:null};oe(o,i),s.push(o)}n.state={shape:"array",entries:s}}function Y(n,e){const t=n.anchor.parentNode;if(t)for(const s of e)t.insertBefore(s,n.anchor)}function T(n){if(n.shape==="text"){n.node.remove();return}if(n.shape==="template"){for(const e of n.nodes)e.parentNode&&e.parentNode.removeChild(e);return}if(n.shape==="node"){n.node.parentNode&&n.node.parentNode.removeChild(n.node);return}for(const e of n.entries)e.state&&T(e.state),e.anchor.remove()}function $e(n){return n==null||n===!1?"":String(n)}const R=class R 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(Re)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,t,s){if(t===s)return;const i=ht(e);this._propValues[i]=s,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(e){if(e==null){this.removeAttribute("class");return}const s=(Array.isArray(e)?e:String(e).split(/\s+/)).map(i=>String(i).trim()).filter(i=>i!=="");this.className=s.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 s=Re(t);Object.defineProperty(this,t,{get:()=>t in this._propValues?this._propValues[t]:this.getAttribute(s),set:i=>{let r;i==null||i===!1?r=null:i===!0?r="":r=String(i),this._propValues[t]=r,r===null?this.removeAttribute(s):this.setAttribute(s,r),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&K(this.render(),this._renderRoot)}))}_adoptStyles(){const e=this.constructor;if(e.styles.length!==0)if(e.shadow&&this.shadowRoot){const t=e.styles.map(s=>s.sheet).filter(s=>s!==null);if(this.shadowRoot.adoptedStyleSheets=t,t.length!==e.styles.length){for(const s of e.styles)if(!s.sheet){const i=document.createElement("style");i.textContent=s.cssText,this.shadowRoot.appendChild(i)}}}else this._adoptLightStyles(e)}_adoptLightStyles(e){if(!R._lightStylesAdopted.has(e)){R._lightStylesAdopted.add(e);for(const t of e.styles){const s=document.createElement("style");s.dataset.wpdUi=this.tagName.toLowerCase(),s.textContent=t.cssText,document.head.appendChild(s)}}}};R.props=[],R.styles=[],R.shadow=!0,R._lightStylesAdopted=new WeakSet;let S=R;function E(n,e){customElements.get(n)||customElements.define(n,e)}function Re(n){return n.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function ht(n){return n.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}const ut=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function $(n,...e){let t=n[0];for(let s=1;s<n.length;s++){const i=e[s-1];if(typeof i=="string"||typeof i=="number")t+=String(i);else if(i&&i.__wpdCss)t+=i.cssText;else throw new TypeError("[wpd-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof i);t+=n[s]}if(ut){const s=new CSSStyleSheet;return s.replaceSync(t),{__wpdCss:!0,sheet:s,cssText:t}}return{__wpdCss:!0,sheet:null,cssText:t}}const pt=$`:host{display:inline-flex}:host( [ fill-cell ] ){display:flex;width:100%}button{appearance:none;display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:var( --wpd-button-padding,6px 12px );border-radius:var( --wpd-button-border-radius,6px );font:inherit;font-weight:500;cursor:pointer;transition:background-color 0.12s ease,color 0.12s ease,border-color 0.12s ease;background:var( --wpd-button-bg,transparent );color:var( --wpd-button-fg,var( --desktop-mode-text,#1d2327 ) );border:var( --wpd-button-border,1px solid var( --desktop-mode-border,#c3c4c7 ) )}:host( [ fill-cell ] ) button{width:100%;min-height:var( --wpd-button-min-height,44px )}button:disabled{opacity:0.5;cursor:not-allowed}button:hover:not(:disabled ){background:var( --wpd-button-bg-hover,rgba( 0,0,0,0.04 ) )}:host( [ variant='primary' ] ) button{background:var( --wpd-button-bg,var( --wp-admin-theme-color,#2271b1 ) );color:var( --wpd-button-fg,#fff );border:var( --wpd-button-border,1px solid transparent )}:host( [ variant='primary' ] ) button:hover:not(:disabled ){filter:brightness( 1.06 );background:var( --wpd-button-bg,var( --wp-admin-theme-color,#2271b1 ) )}:host( [ variant='secondary' ] ) button{background:var( --wpd-button-bg,rgba( 0,0,0,0.06 ) );color:var( --wpd-button-fg,var( --desktop-mode-text,#1d2327 ) );border:var( --wpd-button-border,1px solid transparent )}:host( [ variant='secondary' ] ) button:hover:not(:disabled ){background:var( --wpd-button-bg-hover,rgba( 0,0,0,0.1 ) )}:host( [ variant='danger' ] ) button{background:var( --wpd-button-bg,transparent );color:var( --wpd-button-fg,#d63638 );border:var( --wpd-button-border,1px solid currentColor )}:host( [ variant='danger' ] ) button:hover:not(:disabled ){background:#d63638;color:#fff}:host( [ variant='link' ] ) button{background:transparent;color:var( --wpd-button-fg,var( --wp-admin-theme-color,#2271b1 ) );border:0;padding:0;text-decoration:underline}:host( [ busy ] ) button{pointer-events:none;opacity:0.75}.wpd-button__spinner{box-sizing:border-box;display:inline-block;width:12px;height:12px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:wpd-button-spin 0.6s linear infinite;flex-shrink:0}@keyframes wpd-button-spin{to{transform:rotate( 360deg )}}`,D=class D extends S{render(){const e=this.disabled!==null,t=this.busy!==null,s=this.type||"button";return w`
1 +(function(){"use strict";function v(o,...e){return{__wpdHtml:!0,strings:o,values:e}}function xt(o){return!!o&&o.__wpdHtml===!0}const wt="$$wpd$$",x=/\$\$wpd\$\$(\d+)\$\$/g,Ct="$$wpd-node$$",St=/^\$\$wpd-node\$\$(\d+)\$\$$/,Et=new Set(["style","script","textarea","title"]);function At(o){let e="",t=!1,s=null,n=!1,i=null,r="",a=!1;for(let l=0;l<o.length;l++){const d=o[l];e+=d;for(let u=0;u<d.length;u++){const c=d[u];if(n){d.startsWith("-->",u)&&(n=!1,u+=2);continue}if(i!==null){c==="<"&&d[u+1]==="/"&&d.slice(u+2,u+2+i.length).toLowerCase()===i&&(u+=1+i.length,i=null,t=!0,a=!1,r="");continue}if(s!==null){c===s&&(s=null);continue}if(t){c==='"'||c==="'"?(s=c,a=!1):c===">"?(t=!1,a=!1,Et.has(r)&&(i=r),r=""):a&&(/[a-zA-Z0-9-]/.test(c)?r+=c.toLowerCase():a=!1);continue}if(d.startsWith("<!--",u)){n=!0,u+=3;continue}const f=d[u+1]??"";c==="<"&&/[a-zA-Z/!]/.test(f)&&(t=!0,r="",a=/[a-zA-Z]/.test(f))}l<o.length-1&&(e+=t||n||i!==null?`${wt}${l}$$`:`<!--${Ct}${l}$$-->`)}return e}const ze=new WeakMap;function Ie(o){const e=ze.get(o);if(e)return e;const t=document.createElement("template");t.innerHTML=At(o);const s=[],n=(a,l)=>{if(a.nodeType===Node.ELEMENT_NODE){const c=a;for(const f of Array.from(c.attributes)){const p=f.name,h=f.value,m=p[0];if(x.test(h))if(x.lastIndex=0,m==="@"){const b=x.exec(h);x.lastIndex=0,s.push({path:l,kind:"event",name:p.slice(1),valueIndex:b?Number(b[1]):0}),c.removeAttribute(p)}else if(m==="."){const b=x.exec(h);x.lastIndex=0,s.push({path:l,kind:"prop",name:p.slice(1),valueIndex:b?Number(b[1]):0}),c.removeAttribute(p)}else if(m==="?"){const b=x.exec(h);x.lastIndex=0,s.push({path:l,kind:"bool",name:p.slice(1),valueIndex:b?Number(b[1]):0}),c.removeAttribute(p)}else{const b=[],w=[];let y=0,C;for(x.lastIndex=0;(C=x.exec(h))!==null;)b.push(h.slice(y,C.index)),w.push(Number(C[1])),y=C.index+C[0].length;b.push(h.slice(y)),s.push({path:l,kind:"attr",name:p,template:b,valueIndices:w}),c.setAttribute(p,"")}}}const d=Array.from(a.childNodes);let u=0;for(let c=0;c<d.length;c++){const f=d[c],p=c+u;if(f.nodeType===Node.COMMENT_NODE){const h=St.exec(f.data);if(h){const m=document.createTextNode("");f.parentNode.replaceChild(m,f),s.push({path:[...l,p],kind:"node",valueIndex:Number(h[1])})}continue}if(f.nodeType===Node.TEXT_NODE){const h=f.textContent||"";if(!x.test(h)){x.lastIndex=0;continue}x.lastIndex=0;const m=f.parentNode;let b=0,w;const y=[],C=[];for(x.lastIndex=0;(w=x.exec(h))!==null;){w.index>b&&y.push(document.createTextNode(h.slice(b,w.index)));const M=document.createTextNode("");y.push(M),C.push({path:[...l,p+y.length-1],kind:"node",valueIndex:Number(w[1])}),b=w.index+w[0].length}b<h.length&&y.push(document.createTextNode(h.slice(b)));for(const M of y)m.insertBefore(M,f);m.removeChild(f),u+=y.length-1,s.push(...C)}else n(f,[...l,p])}};n(t.content,[]);const r={template:t,buildParts:a=>{const l=[];for(const d of s){let u=a;for(const c of d.path)u=u.childNodes[c];d.kind==="node"?l.push({kind:"node",valueIndex:d.valueIndex,child:{anchor:u,state:null}}):d.kind==="attr"?l.push({kind:"attr",element:u,name:d.name,template:d.template,valueIndices:d.valueIndices}):d.kind==="event"?l.push({kind:"event",valueIndex:d.valueIndex,element:u,name:d.name}):d.kind==="prop"?l.push({kind:"prop",valueIndex:d.valueIndex,element:u,name:d.name}):d.kind==="bool"&&l.push({kind:"bool",valueIndex:d.valueIndex,element:u,name:d.name})}return l}};return ze.set(o,r),r}const Me=new WeakMap;function $t(o,e){for(const t of o.nodes)if(t.parentNode!==e)return!1;return!0}function Y(o,e){const t=Me.get(e);if(t&&t.strings===o.strings&&$t(t,e)){Z(t.parts,o.values);return}const s=Ie(o.strings),n=s.template.content.cloneNode(!0),i=s.buildParts(n),r=Array.from(n.childNodes);for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(n),Z(i,o.values),Me.set(e,{strings:o.strings,parts:i,nodes:r})}function Z(o,e){for(const t of o)if(t.kind==="node")J(t.child,e[t.valueIndex]);else if(t.kind==="attr"){let s=t.template[0];for(let n=0;n<t.valueIndices.length;n++)s+=Pe(e[t.valueIndices[n]]),s+=t.template[n+1];s!==t.last&&(t.last=s,s===""?t.element.removeAttribute(t.name):t.element.setAttribute(t.name,s))}else if(t.kind==="event"){const s=e[t.valueIndex];s!==t.current&&(t.current&&t.element.removeEventListener(t.name,t.current),s&&t.element.addEventListener(t.name,s),t.current=s)}else if(t.kind==="prop"){const s=e[t.valueIndex];s!==t.last&&(t.last=s,t.element[t.name]=s)}else if(t.kind==="bool"){const s=!!e[t.valueIndex];s!==t.last&&(t.last=s,s?t.element.setAttribute(t.name,""):t.element.removeAttribute(t.name))}}function J(o,e){if(e==null||e===!1){o.state&&($(o.state),o.state=null);return}if(Array.isArray(e)){Lt(o,e);return}if(xt(e)){Tt(o,e);return}if(e instanceof Node){Rt(o,e);return}Nt(o,Pe(e))}function Rt(o,e){const t=o.state;t?.shape==="node"&&t.node===e||(t&&$(t),H(o,[e]),o.state={shape:"node",node:e})}function Nt(o,e){const t=o.state;if(t?.shape==="text"){t.text!==e&&(t.node.textContent=e,t.text=e);return}t&&$(t);const s=document.createTextNode(e);H(o,[s]),o.state={shape:"text",node:s,text:e}}function Tt(o,e){const t=o.state;if(t?.shape==="template"&&t.strings===e.strings){Z(t.parts,e.values);return}t&&$(t);const s=Ie(e.strings),n=s.template.content.cloneNode(!0),i=s.buildParts(n),r=Array.from(n.childNodes);H(o,[n]),Z(i,e.values),o.state={shape:"template",strings:e.strings,parts:i,nodes:r}}function Lt(o,e){const t=o.state;if(t?.shape==="array"){const n=Math.min(t.entries.length,e.length);for(let i=0;i<n;i++)J(t.entries[i],e[i]);if(e.length<t.entries.length){for(let i=e.length;i<t.entries.length;i++){const r=t.entries[i];r.state&&$(r.state),r.anchor.remove()}t.entries.length=e.length}else for(let i=t.entries.length;i<e.length;i++){const r=document.createTextNode("");H(o,[r]);const a={anchor:r,state:null};J(a,e[i]),t.entries.push(a)}return}t&&$(t);const s=[];for(const n of e){const i=document.createTextNode("");H(o,[i]);const r={anchor:i,state:null};J(r,n),s.push(r)}o.state={shape:"array",entries:s}}function H(o,e){const t=o.anchor.parentNode;if(t)for(const s of e)t.insertBefore(s,o.anchor)}function $(o){if(o.shape==="text"){o.node.remove();return}if(o.shape==="template"){for(const e of o.parts)e.kind==="node"&&e.child.state&&($(e.child.state),e.child.state=null);for(const e of o.nodes)e.parentNode&&e.parentNode.removeChild(e);return}if(o.shape==="node"){o.node.parentNode&&o.node.parentNode.removeChild(o.node);return}for(const e of o.entries)e.state&&$(e.state),e.anchor.remove()}function Pe(o){return o==null||o===!1?"":String(o)}const N=class N 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(He)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,t,s){if(t===s)return;const n=zt(e);this._propValues[n]=s,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(e){if(e==null){this.removeAttribute("class");return}const s=(Array.isArray(e)?e:String(e).split(/\s+/)).map(n=>String(n).trim()).filter(n=>n!=="");this.className=s.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 s=He(t);Object.defineProperty(this,t,{get:()=>t in this._propValues?this._propValues[t]:this.getAttribute(s),set:n=>{let i;n==null||n===!1?i=null:n===!0?i="":i=String(n),this._propValues[t]=i,i===null?this.removeAttribute(s):this.setAttribute(s,i),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&Y(this.render(),this._renderRoot)}))}_adoptStyles(){const e=this.constructor;if(e.styles.length!==0)if(e.shadow&&this.shadowRoot){const t=e.styles.map(s=>s.sheet).filter(s=>s!==null);if(this.shadowRoot.adoptedStyleSheets=t,t.length!==e.styles.length){for(const s of e.styles)if(!s.sheet){const n=document.createElement("style");n.textContent=s.cssText,this.shadowRoot.appendChild(n)}}}else this._adoptLightStyles(e)}_adoptLightStyles(e){if(!N._lightStylesAdopted.has(e)){N._lightStylesAdopted.add(e);for(const t of e.styles){const s=document.createElement("style");s.dataset.osUi=this.tagName.toLowerCase(),s.textContent=t.cssText,document.head.appendChild(s)}}}};N.props=[],N.styles=[],N.shadow=!0,N._lightStylesAdopted=new WeakSet;let E=N;function R(o,e){customElements.get(o)||customElements.define(o,e)}function He(o){return o.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function zt(o){return o.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}const It=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function _(o,...e){let t=o[0];for(let s=1;s<o.length;s++){const n=e[s-1];if(typeof n=="string"||typeof n=="number")t+=String(n);else if(n&&n.__wpdCss)t+=n.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof n);t+=o[s]}if(It){const s=new CSSStyleSheet;return s.replaceSync(t),{__wpdCss:!0,sheet:s,cssText:t}}return{__wpdCss:!0,sheet:null,cssText:t}}const Q=_`:host{--_holo-fill:var( --os-ui-holo-fill,${"linear-gradient( 124deg, #afa2e8 0%, #f5a8ea 46%, #8ee9f7 100% )"} );--_holo-ink:var( --os-ui-holo-ink,#0c0b0f );--_holo-sheen:var( --os-ui-holo-sheen,linear-gradient( 124deg,rgba( 159,214,255,0.1 ) 0%,rgba( 236,155,255,0.12 ) 34%,rgba( 242,82,252,0.1 ) 58%,rgba( 147,240,198,0.09 ) 100% ) );--_holo-edge:var( --os-ui-holo-edge,linear-gradient( 124deg,rgba( 154,242,255,0.7 ) 0%,rgba( 236,155,255,0.85 ) 38%,rgba( 242,82,252,0.7 ) 62%,rgba( 159,152,255,0.6 ) 100% ) );--_holo-edge-quiet:var( --os-ui-holo-edge-quiet,linear-gradient( 124deg,rgba( 154,242,255,0.22 ) 0%,rgba( 236,155,255,0.28 ) 38%,rgba( 242,82,252,0.22 ) 62%,rgba( 159,152,255,0.2 ) 100% ) );--_holo-glow:var( --os-ui-holo-glow,0 0 0 1px rgba( 242,82,252,0.28 ),0 2px 10px rgba( 242,82,252,0.22 ) );--_holo-glow-strong:var( --os-ui-holo-glow-strong,0 0 0 1px rgba( 242,82,252,0.42 ),0 4px 18px rgba( 242,82,252,0.38 ),0 1px 3px rgba( 12,11,15,0.6 ) );--_holo-track:var( --os-ui-holo-track,rgba( 255,251,255,0.16 ) );--_holo-track-edge:var( --os-ui-holo-track-edge,#8c8f94 );--_holo-ring-color:var( --os-ui-accent-dim,#2271b1 );--_holo-focus:var( --os-ui-focus-ring,0 0 0 2px rgba( 12,11,15,0.9 ),0 0 0 4px #f252fc,0 0 12px 2px rgba( 242,82,252,0.45 ) );--_holo-focus-field:var( --os-ui-focus-ring-field,0 0 0 1px #f252fc,0 0 0 4px rgba( 242,82,252,0.18 ) );--_holo-t:var( --os-ui-holo-transition,220ms );--_holo-t-fast:var( --os-ui-motion-fast,140ms );--_holo-t-slow:var( --os-ui-motion-slow,340ms );--_holo-t-ambient:var( --os-ui-motion-ambient,12s );--_holo-spring:var( --os-ui-ease-spring,cubic-bezier( 0.32,1.5,0.55,1 ) );--_holo-ease:var( --os-ui-ease-out,cubic-bezier( 0.22,0.9,0.28,1 ) );--_holo-loop:var( --os-ui-ease-loop,cubic-bezier( 0.45,0,0.55,1 ) )}`,Mt=_` .os-holo-fill{background-color:transparent;background-image:var( --_holo-fill );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;color:var( --_holo-ink );transition:background-position var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,filter var( --_holo-t ) ease}.os-holo-fill:hover{background-position:74% 66%}.os-holo-fill:active{background-position:88% 82%;filter:brightness( 0.94 )}@media ( prefers-reduced-motion:reduce ){.os-holo-fill{transition-duration:1ms}.os-holo-fill:hover,.os-holo-fill:active{background-position:22% 28%}}`,Fe=_` .os-holo-sheen{position:relative;isolation:isolate}.os-holo-sheen::before{content:'';position:absolute;inset:0;z-index:-1;border-radius:inherit;background-image:var( --_holo-sheen );background-size:200% 200%;background-position:20% 30%;opacity:0;pointer-events:none;transition:opacity var( --_holo-t ) ease,background-position var( --_holo-t ) ease}.os-holo-sheen:hover::before,.os-holo-sheen:focus-visible::before{opacity:1;background-position:76% 68%}@media ( prefers-reduced-motion:reduce ){.os-holo-sheen::before{transition-duration:1ms}.os-holo-sheen:hover::before,.os-holo-sheen:focus-visible::before{background-position:20% 30%}}`,qe=_` .os-holo-edge{position:relative}.os-holo-edge::after{content:'';position:absolute;inset:0;border-radius:inherit;padding:1px;background-image:var( --_holo-edge-quiet );opacity:0;pointer-events:none;-webkit-mask:linear-gradient( #000 0 0 ) content-box,linear-gradient( #000 0 0 );-webkit-mask-composite:xor;mask:linear-gradient( #000 0 0 ) content-box,linear-gradient( #000 0 0 );mask-composite:exclude;transition:opacity var( --_holo-t ) ease}.os-holo-edge:hover::after,.os-holo-edge:focus-visible::after{background-image:var( --_holo-edge );opacity:1}.os-holo-edge.is-lit::after{background-image:var( --_holo-edge );opacity:1}@media ( prefers-reduced-motion:reduce ){.os-holo-edge::after{transition-duration:1ms}}`,De=_` .os-holo-glint{position:absolute;inset:0;border-radius:inherit;overflow:hidden;pointer-events:none}.os-holo-glint::before{content:'';position:absolute;top:-60%;bottom:-60%;width:45%;inset-inline-start:-60%;background:linear-gradient( 90deg,transparent 0%,rgba( 255,251,255,0.14 ) 45%,rgba( 255,251,255,0.22 ) 50%,rgba( 255,251,255,0.14 ) 55%,transparent 100% );transform:rotate( 18deg ) translateX( 0 );opacity:0}:hover>.os-holo-glint::before,:focus-visible>.os-holo-glint::before,:host(:hover )>.os-holo-glint::before,:host(:focus-visible )>.os-holo-glint::before{animation:os-holo-glint var( --_holo-t-slow ) var( --_holo-ease )}@keyframes os-holo-glint{0%{opacity:0;transform:rotate( 18deg ) translateX( 0 )}15%{opacity:1}85%{opacity:1}100%{opacity:0;transform:rotate( 18deg ) translateX( 240vw )}}@media ( prefers-reduced-motion:reduce ){:hover>.os-holo-glint::before,:focus-visible>.os-holo-glint::before,:host(:hover )>.os-holo-glint::before,:host(:focus-visible )>.os-holo-glint::before{animation:none}}`,Oe=_` .os-holo-ring{position:absolute;inset:0;border-radius:inherit;box-shadow:0 0 0 0 var( --_holo-ring-color );opacity:0;pointer-events:none}:active:not(:disabled )>.os-holo-ring,:host(:active:not( [ disabled ] ) )>.os-holo-ring{animation:os-holo-ring var( --_holo-t-slow ) var( --_holo-ease )}@keyframes os-holo-ring{0%{opacity:0.45;box-shadow:0 0 0 0 var( --_holo-ring-color )}100%{opacity:0;box-shadow:0 0 0 10px transparent}}@media ( prefers-reduced-motion:reduce ){:active:not(:disabled )>.os-holo-ring,:host(:active:not( [ disabled ] ) )>.os-holo-ring{animation:none}}`,Pt=_` .os-holo-shimmer{background-image:var( --_holo-fill );background-size:300% 300%;background-repeat:no-repeat;animation:os-holo-shimmer 2.4s var( --_holo-loop ) infinite}@keyframes os-holo-shimmer{0%{background-position:0% 50%}100%{background-position:100% 50%}}@media ( prefers-reduced-motion:reduce ){.os-holo-shimmer{animation:none;background-position:30% 50%}}`,Ht=_` .os-holo-enter{animation:os-holo-enter var( --_holo-t ) var( --_holo-spring )}@keyframes os-holo-enter{from{opacity:0;transform:scale( 0.96 )}}@media ( prefers-reduced-motion:reduce ){.os-holo-enter{animation:none}}`,Ft=_` input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ),select,textarea{transition:background-color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):hover:not(:disabled ),select:hover:not(:disabled ),textarea:hover:not(:disabled ){border-color:var( --os-ui-border-strong,#8c8f94 )}input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):focus,input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):focus-visible,select:focus,select:focus-visible,textarea:focus,textarea:focus-visible{outline:none;border-color:var( --os-ui-accent,#2271b1 );box-shadow:var( --_holo-focus-field )}input::placeholder,textarea::placeholder{color:var( --os-ui-fg-faint,#8c8f94 );opacity:1}input::selection,textarea::selection{background:var( --os-ui-selection-bg,rgba( 159,152,255,0.6 ) );color:var( --os-ui-selection-fg,#fffbff )}@media ( prefers-reduced-motion:reduce ){input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ),select,textarea{transition-duration:1ms}}`,Ue=_` input[ type='checkbox' ],input[ type='radio' ]{appearance:none;-webkit-appearance:none;position:relative;flex:0 0 auto;box-sizing:border-box;width:16px;height:16px;margin:0;padding:0;border:1px solid var( --_holo-track-edge );border-radius:4px;background-color:var( --_holo-track );background-image:none;background-repeat:no-repeat;cursor:inherit;transition:background-color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input[ type='radio' ]{border-radius:50%}input[ type='checkbox' ]:hover:not(:disabled ),input[ type='radio' ]:hover:not(:disabled ){border-color:var( --os-ui-accent,#2271b1 )}input[ type='checkbox' ]:focus-visible,input[ type='radio' ]:focus-visible{outline:none;box-shadow:var( --_holo-focus )}input[ type='checkbox' ]:checked,input[ type='checkbox' ]:indeterminate,input[ type='radio' ]:checked{border-color:transparent;background-color:var( --os-ui-accent,#2271b1 )}input[ type='checkbox' ]:checked:focus-visible,input[ type='radio' ]:checked:focus-visible{box-shadow:var( --_holo-focus )}input[ type='checkbox' ]:checked::after{content:'';position:absolute;inset-inline-start:50%;top:46%;width:3.5px;height:7.5px;border:solid var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) );border-width:0 2px 2px 0;transform:translate( -50%,-50% ) rotate( 45deg );animation:os-holo-tick 180ms cubic-bezier( 0.3,1.4,0.6,1 )}input[ type='checkbox' ]:indeterminate::after{content:'';position:absolute;inset-inline-start:50%;top:50%;width:8px;height:2px;border:0;border-radius:1px;background:var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) );transform:translate( -50%,-50% )}input[ type='radio' ]:checked::after{content:'';position:absolute;inset-inline-start:50%;top:50%;width:6px;height:6px;border-radius:50%;background:var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) );transform:translate( -50%,-50% );animation:os-holo-tick 180ms cubic-bezier( 0.3,1.4,0.6,1 )}input[ type='checkbox' ]:disabled,input[ type='radio' ]:disabled{cursor:not-allowed}@keyframes os-holo-tick{from{opacity:0;transform:translate( -50%,-50% ) rotate( 45deg ) scale( 0.4 )}}@media ( prefers-reduced-motion:reduce ){input[ type='checkbox' ]:checked::after,input[ type='radio' ]:checked::after{animation:none}}`,We=_` @keyframes os-holo-drift{0%{background-position:16% 26%}50%{background-position:84% 74%}100%{background-position:16% 26%}}.os-holo-alive{animation:os-holo-drift var( --_holo-t-ambient ) var( --_holo-loop ) infinite}@media ( prefers-reduced-motion:reduce ){.os-holo-alive{animation:none}}`;_` ${Q} ${Mt} ${Fe} ${qe} ${De} ${Oe} ${Pt} ${Ht} ${Ft} ${Ue} ${We} `;const qt=_` ${Q} ${Fe} ${qe} ${De} ${Oe} ${We}:host{display:inline-flex}:host( [ fill-cell ] ){display:flex;width:100%}button{appearance:none;display:inline-flex;align-items:center;justify-content:center;gap:6px;padding:var( --os-ui-button-padding,6px 12px );border-radius:var( --os-ui-button-border-radius,6px );font:inherit;font-weight:500;cursor:pointer;transition:background-color var( --_holo-t ) ease,color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,transform 80ms ease;background:var( --os-ui-button-bg,transparent );background-image:var( --os-ui-button-bg-image,none );background-repeat:var( --os-ui-button-bg-image-repeat,repeat );background-size:var( --os-ui-button-bg-image-size,auto );background-position:var( --os-ui-button-bg-image-position,center );color:var( --os-ui-button-fg,var( --os-ui-fg,#1d2327 ) );border:var( --os-ui-button-border,1px solid var( --os-ui-border,#c3c4c7 ) )}:host( [ fill-cell ] ) button{width:100%;min-height:var( --os-ui-button-min-height,44px )}button:disabled{opacity:0.5;cursor:not-allowed}button:active:not(:disabled ){transform:translateY( 1px )}button:hover:not(:disabled ){background-color:var( --os-ui-button-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.04 ) ) )}button:focus-visible{outline:none;box-shadow:var( --_holo-focus )}button:disabled::before,button:disabled::after,button:disabled .os-holo-glint{opacity:0 !important}:host( [ variant='primary' ] ) button{background-color:var( --os-ui-button-bg,var( --wp-admin-theme-color,#2271b1 ) );color:var( --os-ui-button-fg,var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) ) );border:var( --os-ui-button-border,1px solid transparent )}:host( [ variant='primary' ] ) button:hover:not(:disabled ){filter:brightness( 1.06 );background-color:var( --os-ui-button-bg,var( --wp-admin-theme-color,#2271b1 ) );box-shadow:var( --_holo-glow )}:host( [ variant='holo' ] ) button{background-color:transparent;background-image:var( --_holo-fill );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;color:var( --os-ui-button-fg,var( --_holo-ink ) );border:var( --os-ui-button-border,1px solid transparent );box-shadow:var( --_holo-glow );font-weight:600;transition:background-position var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,filter var( --_holo-t ) ease,transform 80ms ease}:host( [ variant='holo' ] ) button:hover:not(:disabled ){background-color:transparent;background-position:74% 66%;box-shadow:var( --_holo-glow-strong )}:host( [ variant='holo' ] ) button:active:not(:disabled ){background-position:88% 82%;filter:brightness( 0.94 )}:host( [ variant='holo' ] ) button::before{display:none}@media ( prefers-reduced-motion:reduce ){:host( [ variant='holo' ] ) button:hover:not(:disabled ),:host( [ variant='holo' ] ) button:active:not(:disabled ){background-position:22% 28%}}:host( [ variant='secondary' ] ) button{background-color:var( --os-ui-button-bg,var( --os-ui-hover,rgba( 0,0,0,0.06 ) ) );color:var( --os-ui-button-fg,var( --os-ui-fg,#1d2327 ) );border:var( --os-ui-button-border,1px solid transparent )}:host( [ variant='secondary' ] ) button:hover:not(:disabled ){background-color:var( --os-ui-button-bg-hover,var( --os-ui-hover,rgba( 0,0,0,0.1 ) ) )}:host( [ variant='danger' ] ) button{background-color:var( --os-ui-button-bg,transparent );color:var( --os-ui-button-fg,var( --os-ui-danger,#d63638 ) );border:var( --os-ui-button-border,1px solid currentColor )}:host( [ variant='danger' ] ) button:hover:not(:disabled ){background-color:var( --os-ui-danger,#d63638 );color:var( --os-ui-fg-on-accent,#fff )}:host( [ variant='danger' ] ) button::after{display:none}:host( [ variant='link' ] ) button{background-color:transparent;background-image:none;color:var( --os-ui-button-fg,var( --wp-admin-theme-color,#2271b1 ) );border:0;padding:0;text-decoration:underline}:host( [ variant='link' ] ) button::before,:host( [ variant='link' ] ) button::after,:host( [ variant='link' ] ) .os-holo-glint,:host( [ variant='link' ] ) .os-holo-ring{display:none}:host( [ variant='link' ] ) button:active:not(:disabled ){transform:none}:host( [ busy ] ) button{pointer-events:none;opacity:0.75}:host( [ variant='holo' ][ busy ] ) button{animation:os-holo-drift 12s ease-in-out infinite}@media ( prefers-reduced-motion:reduce ){:host( [ variant='holo' ][ busy ] ) button{animation:none}}.os-button__spinner{box-sizing:border-box;display:inline-block;width:12px;height:12px;border:2px solid currentColor;border-right-color:transparent;border-radius:50%;animation:os-button-spin 0.6s linear infinite;flex-shrink:0}@keyframes os-button-spin{to{transform:rotate( 360deg )}}`,U=class U extends E{static get observedAttributes(){return[...super.observedAttributes,"aria-label"]}render(){const e=this.disabled!==null,t=this.busy!==null,s=this.type||"button",n=this.getAttribute("aria-label")||"";return v`
2 2 <button
3 3 part="button"
4 + class="os-holo-edge os-holo-sheen"
4 5 type=${s}
5 6 ?disabled=${e||t}
6 7 aria-busy=${t?"true":"false"}
8 + aria-label=${n}
7 9 >
8 - ${t?w`<span class="wpd-button__spinner" aria-hidden="true"></span>`:""}
10 + ${t?v`<span class="os-button__spinner" aria-hidden="true"></span>`:""}
9 11 <slot></slot>
12 + <!--
13 + The two motion layers. Elements rather than
14 + pseudo-elements because the sheen and the hairline
15 + have already taken this button's ::before and
16 + ::after — see the pseudo-element budget note in
17 + src/ui/holo.ts. Both are inert and aria-hidden.
18 + -->
19 + <span class="os-holo-glint" aria-hidden="true"></span>
20 + <span class="os-holo-ring" aria-hidden="true"></span>
10 21 </button>
11 - `}};D.props=["variant","disabled","type","busy","fill-cell"],D.styles=[pt],D.help=void 0;let ae=D;E("wpd-button",ae);const ft=$`:host{display:inline-flex;align-items:center;justify-content:center;width:var( --wpd-icon-size,16px );height:var( --wpd-icon-size,16px );color:inherit;line-height:1}:host( [ hidden ] ){display:none}.wpd-icon__glyph{font-size:var( --wpd-icon-size,16px );width:var( --wpd-icon-size,16px );height:var( --wpd-icon-size,16px );line-height:1;color:inherit;display:inline-flex;align-items:center;justify-content:center}.wpd-icon__glyph--char{font-family:dashicons;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none}.wpd-icon__glyph.dashicons{font-family:dashicons}`;let Z=null;function mt(n){let e=n.trim();if(e==="")return null;(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1));const t=e.match(/^\\([0-9a-f]{1,6})\s?$/i);return t?String.fromCodePoint(parseInt(t[1],16)):e||null}function Ne(){const n=new Map;if(typeof document>"u")return n;const e=Array.from(document.styleSheets??[]);for(const t of e){let s=null;try{s=t.cssRules}catch{continue}if(s)for(const i of Array.from(s)){const r=i;if(!r||!r.selectorText)continue;const o=r.selectorText.match(/\.dashicons-([a-z0-9-]+)::?before/i);if(!o)continue;const a=r.style?.content;if(!a)continue;const d=mt(a);d&&n.set(o[1],d)}}return n}function bt(n){Z||(Z=Ne());const e=n.startsWith("dashicons-")?n.slice(10):n;return Z.get(e)??null}function gt(){Z=Ne()}let Le=!1;function wt(){if(Le||typeof window>"u")return;Le=!0;const n=()=>{gt()};document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",n,{once:!0}),window.addEventListener("load",n,{once:!0})}wt();const F=class F extends S{render(){const e=this.name||"",t=e.startsWith("dashicons-")?e.slice(10):e,s=this.size;s&&/^\d+$/.test(s)&&this.style.setProperty("--wpd-icon-size",`${s}px`);const i=bt(t);return i?w`<span
12 - class="wpd-icon__glyph wpd-icon__glyph--char dashicons dashicons-${t}"
22 + `}};U.props=["variant","disabled","type","busy","fill-cell"],U.styles=[qt],U.help=void 0;let he=U;R("os-button",he);const Dt=_`:host{display:inline-flex;align-items:center;justify-content:center;width:var( --os-ui-icon-size,16px );height:var( --os-ui-icon-size,16px );color:inherit;line-height:1}:host( [ hidden ] ){display:none}.os-icon__glyph{font-size:var( --os-ui-icon-size,16px );width:var( --os-ui-icon-size,16px );height:var( --os-ui-icon-size,16px );line-height:1;color:inherit;display:inline-flex;align-items:center;justify-content:center}.os-icon__glyph--char{font-family:dashicons;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none}.os-icon__glyph.dashicons{font-family:dashicons}`;let ee=null;function Ot(o){let e=o.trim();if(e==="")return null;(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1));const t=e.match(/^\\([0-9a-f]{1,6})\s?$/i);return t?String.fromCodePoint(parseInt(t[1],16)):e||null}function je(){const o=new Map;if(typeof document>"u")return o;const e=Array.from(document.styleSheets??[]);for(const t of e){let s=null;try{s=t.cssRules}catch{continue}if(s)for(const n of Array.from(s)){const i=n;if(!i||!i.selectorText)continue;const r=i.selectorText.match(/\.dashicons-([a-z0-9-]+)::?before/i);if(!r)continue;const a=i.style?.content;if(!a)continue;const l=Ot(a);l&&o.set(r[1],l)}}return o}function Ut(o){ee||(ee=je());const e=o.startsWith("dashicons-")?o.slice(10):o;return ee.get(e)??null}function Wt(){ee=je()}let Ge=!1;function jt(){if(Ge||typeof window>"u")return;Ge=!0;const o=()=>{Wt()};document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",o,{once:!0}),window.addEventListener("load",o,{once:!0})}jt();const W=class W extends E{render(){const e=this.name||"",t=e.startsWith("dashicons-")?e.slice(10):e,s=this.size;s&&/^\d+$/.test(s)&&this.style.setProperty("--os-ui-icon-size",`${s}px`);const n=Ut(t);return n?v`<span
23 + class="os-icon__glyph os-icon__glyph--char dashicons dashicons-${t}"
13 24 aria-hidden="true"
14 - >${i}</span>`:w`<span
15 - class="wpd-icon__glyph dashicons dashicons-${t}"
25 + >${n}</span>`:v`<span
26 + class="os-icon__glyph dashicons dashicons-${t}"
16 27 aria-hidden="true"
17 - ></span>`}};F.props=["name","size"],F.styles=[ft],F.help=void 0;let de=F;E("wpd-icon",de);const _t=$`:host{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:32px 24px;text-align:center;color:var( --wpd-empty-state-fg,var( --desktop-mode-muted,#646970 ) )}:host( [ hidden ] ){display:none}.wpd-empty-state__icon{margin-bottom:4px;color:var( --wpd-empty-state-icon-color,currentColor );opacity:0.75}.wpd-empty-state__heading{margin:0;font-size:14px;font-weight:600;color:var( --desktop-mode-text,#1d2327 )}.wpd-empty-state__description{margin:0;font-size:12px;line-height:1.4;max-width:48ch}.wpd-empty-state__description:empty{display:none}.wpd-empty-state__cta{margin-top:8px}.wpd-empty-state__cta:empty{display:none}`,U=class U extends S{render(){const e=this.icon||"",t=this.heading||"",s=this.description||"";return w`
18 - ${e?w`<wpd-icon
19 - class="wpd-empty-state__icon"
28 + ></span>`}};W.props=["name","size"],W.styles=[Dt],W.help=void 0;let pe=W;R("os-icon",pe);const Gt=_`:host{display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;padding:32px 24px;text-align:center;color:var( --os-ui-empty-state-fg,var( --os-ui-fg-muted,#646970 ) )}:host( [ hidden ] ){display:none}.os-empty-state__icon{margin-bottom:4px;color:var( --os-ui-empty-state-icon-color,currentColor );opacity:0.75}.os-empty-state__heading{margin:0;font-size:14px;font-weight:600;color:var( --os-ui-fg,#1d2327 )}.os-empty-state__description{margin:0;font-size:12px;line-height:1.4;max-width:48ch}.os-empty-state__description:empty{display:none}.os-empty-state__cta{margin-top:8px}.os-empty-state__cta:empty{display:none}`,j=class j extends E{render(){const e=this.icon||"",t=this.heading||"",s=this.description||"";return v`
29 + ${e?v`<os-icon
30 + class="os-empty-state__icon"
20 31 name=${e}
21 32 size="28"
22 - ></wpd-icon>`:null}
23 - <h3 class="wpd-empty-state__heading">${t}</h3>
24 - <p class="wpd-empty-state__description">${s}</p>
25 - <div class="wpd-empty-state__cta">
33 + ></os-icon>`:null}
34 + <h3 class="os-empty-state__heading">${t}</h3>
35 + <p class="os-empty-state__description">${s}</p>
36 + <div class="os-empty-state__cta">
26 37 <slot name="cta"></slot>
27 38 </div>
28 39 <slot></slot>
29 - `}};U.props=["icon","heading","description"],U.styles=[_t],U.help=void 0;let le=U;E("wpd-empty-state",le);const yt="desktop-mode";function Te(){return window.wp?.i18n}function b(n,e=yt){return Te()?.__(n,e)??n}function y(n,...e){const t=Te()?.sprintf;if(t)return t(n,...e);let s=0;return n.replace(/%(?:(\d+)\$)?[sd]/g,(i,r)=>{const o=r?Number.parseInt(r,10)-1:s++;return String(e[o]??"")})}function J(){const n=window.wp?.hooks;if(!n)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 n}function vt(n,e,t,s){J().addAction(n,e,t,s)}function kt(n,e){return J().removeAction(n,e)}function Ie(n,e,...t){return J().applyFilters(n,e,...t)}function xt(n,...e){J().doAction(n,...e)}const Ct={GAMES:"desktop-mode.games"},St="desktop-mode.activity.";function ce(n){return`${St}${String(n)}`}let At=0;const Pe={publish(n,e){xt(ce(n),e)},subscribe(n,e){const t=`desktop-mode/activity-sub/${++At}`,s=ce(n);vt(s,t,r=>e(r));let i=!1;return()=>{i||(i=!0,kt(s,t))}},filter(n,e,...t){return Ie(ce(n),e,...t)}},Et="wpd-confirm-dialog";let he=null;function Q(){return typeof window.customElements<"u"&&!!window.customElements.get(Et)}function $t(n){return new Promise((e,t)=>{const s=document.querySelector('script[data-desktop-mode-shell-overlays="1"]'),i=()=>{if(Q()){e();return}t(new Error("[desktop-mode] shell-overlays bundle loaded but did not register the overlay components."))};if(s){Q()?i():(s.addEventListener("load",i),s.addEventListener("error",()=>t(new Error("failed to load shell-overlays bundle"))));return}const r=document.createElement("script");r.src=n,r.async=!0,r.dataset.desktopModeShellOverlays="1",r.addEventListener("load",i),r.addEventListener("error",()=>t(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(r)})}function Rt(n){return Q()||!n?Promise.resolve():(he||(he=$t(n)),he)}function Nt(){return window.desktopModeConfig?.shellOverlaysBundleUrl??""}function Lt(n,e){const t=Nt();if(Q()||!t){e();return}Rt(t).then(()=>{n()&&e()}).catch(s=>{typeof console<"u"&&console.warn("[desktop-mode] shell-overlays failed to load; menu/dialog suppressed:",s)})}const Tt=4e3,It=200;function M(n){const e=Pe.filter("desktop-mode/toast-requested",{...n});if(!e||e.cancel===!0)return()=>{};let t=!1,s=null;return Lt(()=>!t,()=>{s=Pt(e)}),()=>{t=!0,s&&s()}}function Pt(n){const e=Mt(),t=document.createElement("wpd-toast");t.textContent=n.message,n.action&&(t.setAttribute("action",n.action.label),t.addEventListener("wpd-toast-action",()=>{n.action?.onClick(),r()})),n.dismissible&&(t.setAttribute("dismissible",""),t.addEventListener("wpd-toast-dismiss",()=>{n.onDismiss?.(),r()})),e.appendChild(t);let s=!1,i=null;const r=()=>{s||(s=!0,i!==null&&(window.clearTimeout(i),i=null),t.setAttribute("state","out"),window.setTimeout(()=>{t.remove()},It))};return requestAnimationFrame(()=>{t.setAttribute("state","in")}),n.persistent||(i=window.setTimeout(r,n.duration??Tt)),Pe.publish("desktop-mode/toast-shown",{...n}),r}function Mt(){const n=document.querySelector("wpd-toast-container");if(n)return n;const e=document.createElement("wpd-toast-container");return document.body.appendChild(e),e}function Me(n,e){if(!n||typeof n!="object")return["def (not an object)"];const t=n,s=[];for(const i of e)i.valid(t)||s.push(`${i.field} (${i.message})`);return s}class zt extends Error{constructor(e,t,s){super(`[desktop-mode] ${e} registration rejected — fields: `+t.join(", ")+"."),this.name="RegistrationError",this.kind=e,this.errors=t,this.def=s}}function Ot(n,e,t){if(e.length!==0)throw new zt(n,e,t)}const ze="__desktopModeSharedStores";function Ht(){const n=window;let e=n[ze];return e||(e=new Map,n[ze]=e),e}function Oe(n,e){const t=Ht();let s=t.get(n);s||(s={state:e(),listeners:new Set,rebuild:e},t.set(n,s));const i={get state(){return s.state},set state(r){s.state=r},getState(){return s.state},notify(){for(const r of Array.from(s.listeners))try{r(s.state)}catch(o){console.error(`[desktop-mode/shared-store:${n}] subscriber threw:`,o)}},subscribe(r){return s.listeners.add(r),()=>{s.listeners.delete(r)}},setState(r){const o=s.state;if(typeof o!="object"||o===null){console.warn(`[desktop-mode/shared-store:${n}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(o,r),i.notify()},reset(){const r=s.rebuild(),o=s.state;if(typeof o=="object"&&o!==null&&typeof r=="object"&&r!==null){const a=o;for(const d of Object.keys(a))delete a[d];Object.assign(a,r)}else s.state=r;s.listeners.clear()}};return i}const He=Oe("desktop-mode/games-registry",()=>({seed:[],listeners:new Set})),ee=He.state.seed,ue=He.state.listeners;function qt(n){Ot("Game",Me(n,De),n);const e=ee.findIndex(t=>t.id===n.id);e>=0?ee[e]=n:ee.push(n),Ft()}function Dt(n){return ue.add(n),()=>{ue.delete(n)}}function Ft(){const n=Array.from(ue);for(const e of n)try{e()}catch(t){typeof console<"u"&&console.error("[desktop-mode] games registry listener threw:",t)}}function qe(){const n=ee.slice(),e=Ie(Ct.GAMES,n);return Array.isArray(e)?e.filter(Ut):(typeof console<"u"&&console.warn("[desktop-mode] `desktop-mode.games` filter returned a non-array; falling back to seed list."),n)}function pe(n){return qe().find(e=>e.id===n)}const De=[{field:"id",message:"missing or not a non-empty string",valid:n=>typeof n.id=="string"&&n.id!==""},{field:"title",message:"missing or not a non-empty string",valid:n=>typeof n.title=="string"&&n.title!==""},{field:"scoreColumns",message:"must be an array",valid:n=>Array.isArray(n.scoreColumns)},{field:"render/scriptUrl",message:"needs a `render` callback or a `scriptUrl` to lazily load one",valid:n=>typeof n.render=="function"||typeof n.scriptUrl=="string"&&n.scriptUrl!==""}];function Ut(n){return Me(n,De).length===0}const Gt="http://localhost/";function Fe(n,e){const t=typeof window<"u"&&window.location?window.location.href:Gt,s=new URL(n,t),i=e.replace(/^\/+/,""),r=i.indexOf("?"),o=r===-1?i:i.slice(0,r),a=r===-1?"":i.slice(r+1);if(s.searchParams.has("rest_route")){const d=s.searchParams.get("rest_route")??"/",l=d.endsWith("/")?d:d+"/";s.searchParams.set("rest_route",l+o)}else{const d=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";s.pathname=d+o}return a&&new URLSearchParams(a).forEach((l,p)=>{s.searchParams.append(p,l)}),s.toString()}const Ue="X-WP-Nonce";function jt(n,e){const t=Bt();if(!t)return e;const s=Wt(n);if(!s||!Vt(s))return e;const i=e?.headers??(typeof Request<"u"&&n instanceof Request?n.headers:void 0),r=new Headers(i??{});return r.has(Ue)?e:(r.set(Ue,t),{...e??{},headers:r})}function Bt(){if(typeof window>"u")return;const e=window.desktopModeConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function Wt(n){try{const e=typeof window<"u"&&window.location?window.location.href:void 0;return typeof n=="string"?new URL(n,e):n instanceof URL?n:typeof Request<"u"&&n instanceof Request?new URL(n.url,e):null}catch{return null}}function Vt(n){return typeof window>"u"||!window.location||n.origin!==window.location.origin?!1:!!(n.pathname.includes("/wp-json/")||n.searchParams.has("rest_route"))}function Ge(n,e,t={}){const s=window.wp?.desktop?.fetch;if(typeof s=="function")return s(n,e,t);const i=jt(n,e);return fetch(n,i)}const Kt="desktop-mode/games";function Xt(){const e=window.wp?.desktop?.config;return{restUrl:e?.restUrl||"/wp-json/",restNonce:e?.restNonce||""}}async function A(n,e={},t={}){const{restUrl:s,restNonce:i}=Xt(),r=new Headers(e.headers??{});r.set("X-WP-Nonce",i),e.body&&!r.has("Content-Type")&&r.set("Content-Type","application/json");const o=await Ge(Fe(s,n),{...e,headers:r,credentials:"same-origin"},{source:Kt,windowId:t.windowId,silent:t.silent}),a=await o.json().catch(()=>null);if(!o.ok){const d=a?.message||`Games request failed (${o.status})`,l=new Error(d);throw l.status=o.status,l}return a}function je(n,e={}){const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??25),orderby:e.orderby??"score",order:e.order??"desc"});return e.userId&&t.set("user_id",String(e.userId)),A(`desktop-mode/v1/games/${n}/scores?${t}`)}function Yt(n,e,t={}){return A(`desktop-mode/v1/games/${n}/scores`,{method:"POST",body:JSON.stringify({score:e.score,meta:e.meta??{}})},t)}function Zt(){return A("desktop-mode/v1/games/playtime")}function Jt(n,e,t={}){return A(`desktop-mode/v1/games/${n}/playtime`,{method:"POST",body:JSON.stringify({seconds:e})},t)}function Qt(n={}){const e=new URLSearchParams({box:n.box??"all"});return n.state&&e.set("state",n.state),A(`desktop-mode/v1/games/challenges?${e}`)}function es(n){return A("desktop-mode/v1/games/challenges",{method:"POST",body:JSON.stringify({game:n.game,recipient_id:n.recipientId,score:n.score,meta:n.meta??{}})})}function ts(n){return A(`desktop-mode/v1/games/challenges/${n}/accept`,{method:"POST"})}function ss(n){return A(`desktop-mode/v1/games/challenges/${n}/decline`,{method:"POST"})}function ns(n,e,t={}){return A(`desktop-mode/v1/games/challenges/${n}/complete`,{method:"POST",body:JSON.stringify({score:e.score,meta:e.meta??{}})},t)}const is=6e4;function rs(n,e={}){let t=Date.now(),s=0,i=!1;const r=()=>{if(t===null)return;const d=Date.now();s+=Math.max(0,d-t),t=d},o=()=>{r();const d=Math.floor(s/1e3);d<1||(s-=d*1e3,Jt(n,d,{windowId:e.windowId,silent:!0}).catch(()=>{s+=d*1e3}))},a=setInterval(o,is);return{pause:()=>{r(),t=null},resume:()=>{i||t!==null||(t=Date.now())},stop:()=>{i||(i=!0,clearInterval(a),r(),t=null,o())}}}function os(n,e,t){const s=new Date(`${e}T00:00:00Z`);if(isNaN(s.getTime())||t<1)return 0;const i=new Date(s.getTime()-(t-1)*864e5).toISOString().slice(0,10);let r=0;for(const[o,a]of Object.entries(n))o>=i&&o<=e&&(r+=Math.max(0,Math.floor(Number(a)||0)));return r}function Be(n){const e=Math.max(0,Math.floor(Number(n)||0)),t=Math.floor(e/3600),s=Math.floor(e%3600/60);return t>0?y(b("%1$dh %2$dm"),t,s):s>0?y(b("%dm"),s):y(b("%ds"),e)}function We(){return window.wp?.desktop??{}}const as=760,ds=560,ls=480,cs=380;async function hs(n){if(typeof n.render=="function")return n;const e=We().loadVendorScript;if(!n.scriptUrl||typeof e!="function")throw new Error(`[desktop-mode] Game "${n.id}" has no render callback and no loadable script.`);await e(n.scriptUrl,{translations:n.scriptTranslations,l10n:n.scriptL10n,before:n.scriptBefore,after:n.scriptAfter});const s=window.desktopModeGames?.[n.id];if(!s||typeof s.render!="function")throw new Error(`[desktop-mode] No game def on window.desktopModeGames["${n.id}"]. Script loaded but didn't publish a def — check the plugin's global assignment.`);const i={...n,render:s.render,window:s.window??n.window};return qt(i),i}async function Ve(n,e={}){const t=We();let s=pe(n);if(!s)throw new Error(`[desktop-mode] Unknown game "${n}".`);s=await hs(s);const i=s.render;if(typeof i!="function")throw new Error(`[desktop-mode] Game "${n}" did not provide a render callback.`);if(typeof t.registerWindow!="function")throw new Error("[desktop-mode] wp.desktop.registerWindow is missing — the shell must boot before launching games.");const r=`desktop-mode-game-${n}`,o=`game:${r}`,a=t.windowManager,d=a?.getByBaseId?.(r)??a?.getById(r);if(d){const h=d.config?.desktopId;h&&a?.switchDesktop&&h!==a?.getActiveDesktopId?.()&&a.switchDesktop(h),t.registerWindow({id:r,title:s.title,icon:s.icon,render:()=>{}});return}t.wallpaper?.suspend(o);let l=!1;const p=()=>{l||(l=!0,t.wallpaper?.resume(o))};let c=null;const f=()=>{c?.stop(),c=null};t.onWindow?.(r,{closed:()=>{f(),p()},minimized:()=>c?.pause(),restored:()=>c?.resume()});const u=h=>e.challenge?ns(e.challenge.id,h,{windowId:r}).then(()=>{}):Yt(n,h,{windowId:r}).then(()=>{});try{await t.registerWindow({id:r,title:s.title,icon:s.icon,width:s.window?.width??as,height:s.window?.height??ds,minWidth:s.window?.minWidth??ls,minHeight:s.window?.minHeight??cs,render:h=>{const m={windowId:r,container:h,config:s.config??{},challenge:e.challenge,submitScore:u,close:()=>{t.windowManager?.getById(r)?.close()}};c=rs(n,{windowId:r});const g=i(m);return()=>{try{g?.()}finally{f(),p()}}}})}catch(h){throw f(),p(),h}}function us(n){if(!n)return 214;let e=5381;for(let t=0;t<n.length;t++)e=Math.imul(e,33)+n.charCodeAt(t);return(e%360+360)%360}const ps=$`:host{display:inline-flex;position:relative;width:var( --wpd-avatar-size,32px );height:var( --wpd-avatar-size,32px );flex:0 0 auto;vertical-align:middle;line-height:0;perspective:calc( var( --wpd-avatar-size,32px ) * 8 );--wpd-avatar-tilt-x:0deg;--wpd-avatar-tilt-y:0deg;--wpd-avatar-hover:0;--wpd-avatar-glare-x:50%;--wpd-avatar-glare-y:50%}:host( [ hidden ] ){display:none}.wpd-avatar__tile{position:relative;width:100%;height:100%;border-radius:50%;overflow:hidden;background:var( --desktop-mode-window-bg,#f0f0f1 );color:#fff;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:calc( var( --wpd-avatar-size,32px ) * 0.48 );line-height:1;letter-spacing:0;font-feature-settings:'tnum' 1;user-select:none;transform-style:preserve-3d;transform:rotateX( var( --wpd-avatar-tilt-x ) ) rotateY( var( --wpd-avatar-tilt-y ) ) scale( calc( 1 + var( --wpd-avatar-hover ) * 0.07 ) );transition:transform 220ms cubic-bezier( 0.2,0.8,0.2,1 ),box-shadow 220ms cubic-bezier( 0.2,0.8,0.2,1 );box-shadow:inset 0 0 0 1px rgba( 255,255,255,calc( 0.18 + 0.22 * var( --wpd-avatar-hover ) ) ),inset 0 0 0 calc( 1px + var( --wpd-avatar-hover ) * 1px ) rgba( 0,0,0,calc( 0.08 + 0.04 * var( --wpd-avatar-hover ) ) ),0 calc( 1px + var( --wpd-avatar-hover ) * 8px ) calc( 6px + var( --wpd-avatar-hover ) * 18px ) rgba( 0,0,0,calc( 0.08 + 0.18 * var( --wpd-avatar-hover ) ) )}.wpd-avatar__tile::after{content:'';position:absolute;inset:0;border-radius:50%;background:radial-gradient( circle at var( --wpd-avatar-glare-x ) var( --wpd-avatar-glare-y ),rgba( 255,255,255,0.55 ) 0%,rgba( 255,255,255,0 ) 55% );opacity:var( --wpd-avatar-hover );mix-blend-mode:overlay;pointer-events:none;transition:opacity 220ms cubic-bezier( 0.2,0.8,0.2,1 )}.wpd-avatar__tile::before{content:'';position:absolute;inset:calc( var( --wpd-avatar-hover ) * -3px );border-radius:50%;background:radial-gradient( circle at var( --wpd-avatar-glare-x ) var( --wpd-avatar-glare-y ),rgba( 99,102,241,calc( 0.35 * var( --wpd-avatar-hover ) ) ) 0%,rgba( 99,102,241,0 ) 70% );filter:blur( 4px );pointer-events:none;z-index:-1;transition:inset 220ms cubic-bezier( 0.2,0.8,0.2,1 ),background 220ms}.wpd-avatar__tile img{width:100%;height:100%;object-fit:cover;display:block;transform:translateZ( 1px )}.wpd-avatar__dot{position:absolute;bottom:0;inset-inline-end:0;width:calc( var( --wpd-avatar-size,32px ) * 0.32 );height:calc( var( --wpd-avatar-size,32px ) * 0.32 );min-width:8px;min-height:8px;border-radius:50%;box-sizing:border-box;border:2px solid var( --wpd-avatar-dot-ring,var( --desktop-mode-window-bg,#fff ) );background:var( --wpd-avatar-dot-color,transparent );z-index:2}.wpd-avatar__dot--online{background:var( --desktop-mode-success,#00a32a )}.wpd-avatar__dot--inactive{background:var( --desktop-mode-warning,#dba617 )}.wpd-avatar__dot--offline{background:var( --desktop-mode-muted,#8c8f94 )}@media ( prefers-reduced-motion:reduce ){.wpd-avatar__tile{transform:none;transition:box-shadow 200ms}.wpd-avatar__tile::after,.wpd-avatar__tile::before{display:none}}`,Ke={xs:20,sm:24,md:40,lg:64,xl:96},Xe=new Set(["online","inactive","offline"]),G=class G extends S{constructor(){super(...arguments),this._presenceHandler=null,this._imgFailed=!1,this._onPointerMove=null,this._onPointerEnter=null,this._onPointerLeave=null,this._tiltRaf=0,this._pendingTiltX="0deg",this._pendingTiltY="0deg",this._pendingGlareX="50%",this._pendingGlareY="50%"}connectedCallback(){super.connectedCallback(),this._maybeAttachPresenceListener(),this._attachHoverEffect()}disconnectedCallback(){this._presenceHandler&&(document.removeEventListener("desktop-mode-presence-changed",this._presenceHandler),this._presenceHandler=null),this._detachHoverEffect()}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e==="src"&&(this._imgFailed=!1),(e==="user-id"||e==="presence")&&this._maybeAttachPresenceListener()}render(){const e=this._attr("src"),t=this._attr("name")||"",s=this._attr("alt"),i=s!==null?s:t,r=this._attr("size"),o=this._resolveSize(r),a=this._presenceForRender(),d=this._attr("clickable")!==null;this.style.setProperty("--wpd-avatar-size",`${o}px`);const l=e&&!this._imgFailed?"":this._initialsBg(t),p=e&&!this._imgFailed?w`<img
40 + `}};j.props=["icon","heading","description"],j.styles=[Gt],j.help=void 0;let fe=j;R("os-empty-state",fe);const Bt="desktop-mode";function Be(){return window.wp?.i18n}function g(o,e=Bt){return Be()?.__(o,e)??o}function k(o,...e){const t=Be()?.sprintf;if(t)return t(o,...e);let s=0;return o.replace(/%(?:(\d+)\$)?[sd]/g,(n,i)=>{const r=i?Number.parseInt(i,10)-1:s++;return String(e[r]??"")})}function te(){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 Kt(o,e,t,s){te().addAction(o,e,t,s)}function Vt(o,e){return te().removeAction(o,e)}function Ke(o,e,...t){return te().applyFilters(o,e,...t)}function Xt(o,...e){te().doAction(o,...e)}const Yt={GAMES:"os.games"},Zt="os.activity.";function me(o){return Zt+String(o).replace(/[^a-zA-Z0-9_.-]/g,".")}let Jt=0;const be={publish(o,e){Xt(me(o),e)},subscribe(o,e){const t=`os/activity-sub/${++Jt}`,s=me(o);Kt(s,t,i=>e(i));let n=!1;return()=>{n||(n=!0,Vt(s,t))}},filter(o,e,...t){return Ke(me(o),e,...t)}};let ge=null;function oe(){return!!window.openStationShellOverlays}function Qt(o){return new Promise((e,t)=>{const s=document.querySelector('script[data-os-shell-overlays="1"]'),n=()=>{if(oe()){e();return}t(new Error("[openstation] shell-overlays bundle loaded but did not set `window.openStationShellOverlays`."))};if(s){oe()?n():(s.addEventListener("load",n),s.addEventListener("error",()=>t(new Error("failed to load shell-overlays bundle"))));return}const i=document.createElement("script");i.src=o,i.async=!0,i.dataset.osShellOverlays="1",i.addEventListener("load",n),i.addEventListener("error",()=>t(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(i)})}function eo(o){return oe()||!o?Promise.resolve():(ge||(ge=Qt(o)),ge)}function to(){return window.openStationConfig?.shellOverlaysBundleUrl??""}function oo(o,e){const t=to();if(oe()||!t){e();return}eo(t).then(()=>{o()&&e()}).catch(s=>{typeof console<"u"&&console.warn("[openstation] shell-overlays failed to load; menu/dialog suppressed:",s)})}const so=4e3,no=200,io=1200;function F(o){const e=be.filter("os/toast-requested",{...o});if(!e||e.cancel===!0)return()=>{};let t=!1,s=null;return oo(()=>!t,()=>{s=lo(e)}),()=>{t=!0,s&&s()}}const ro={success:"positive",warning:"warning",error:"critical","shell-error":"critical"};function ao(o){return o?window.openStationConfig?.toastTypes?.find(s=>s.id===o)?.tone??ro[o]??null:null}function lo(o){const e=po(),t=document.createElement("os-toast");t.textContent=o.message;const s=ao(o.type);s&&t.setAttribute("tone",s),o.action&&(t.setAttribute("action",o.action.label),t.addEventListener("os-toast-action",()=>{o.action?.onClick(),d()})),o.dismissible&&(t.setAttribute("dismissible",""),t.addEventListener("os-toast-dismiss",()=>{o.onDismiss?.(),d()})),e.appendChild(t);let n=!1,i=null,r=o.duration??so,a=0;const l=()=>{i!==null&&(window.clearTimeout(i),i=null)},d=()=>{n||(n=!0,l(),ho(t),t.setAttribute("state","out"),window.setTimeout(()=>{t.remove(),uo()},no))},u=()=>{n||o.persistent||i!==null||(a=Date.now(),i=window.setTimeout(d,r))},c=()=>{i!==null&&(r=Math.max(0,r-(Date.now()-a)),l())};return requestAnimationFrame(()=>{t.setAttribute("state","in")}),t.addEventListener("os-toast-hold",f=>{if(f.detail?.held){c();return}r=Math.max(r,io),u()}),co(t),u(),be.publish("os/toast-shown",{...o}),d}let se=null,q=0;function Ve(o){const e=o.target;e instanceof HTMLElement&&(e.closest("os-toast-container")||(se=e))}function co(o){q===0&&document.addEventListener("focusin",Ve,!0),q+=1;const e=o.ownerDocument,t=e.activeElement;t instanceof HTMLElement&&t!==e.body&&!t.closest("os-toast-container")&&(se=t)}function uo(){q=Math.max(0,q-1),q===0&&document.removeEventListener("focusin",Ve,!0)}function ho(o){const e=o.ownerDocument.activeElement;e!==o&&!o.contains(e)||se?.isConnected===!0&&se.focus()}function po(){const o=document.querySelector("os-toast-container");if(o)return o;const e=document.createElement("os-toast-container");return document.body.appendChild(e),e}function Xe(o,e){if(!o||typeof o!="object")return["def (not an object)"];const t=o,s=[];for(const n of e)n.valid(t)||s.push(`${n.field} (${n.message})`);return s}class fo extends Error{constructor(e,t,s){super(`[openstation] ${e} registration rejected — fields: `+t.join(", ")+"."),this.name="RegistrationError",this.kind=e,this.errors=t,this.def=s}}function mo(o,e,t){if(e.length!==0)throw new fo(o,e,t)}const Ye="__openStationSharedStores";function bo(){const o=window;let e=o[Ye];return e||(e=new Map,o[Ye]=e),e}function ve(o,e){const t=bo();let s=t.get(o);s||(s={state:e(),listeners:new Set,rebuild:e},t.set(o,s));const n={get state(){return s.state},set state(i){s.state=i},getState(){return s.state},notify(){for(const i of Array.from(s.listeners))try{i(s.state)}catch(r){console.error(`[desktop-mode/shared-store:${o}] subscriber threw:`,r)}},subscribe(i){return s.listeners.add(i),()=>{s.listeners.delete(i)}},setState(i){const r=s.state;if(typeof r!="object"||r===null){console.warn(`[desktop-mode/shared-store:${o}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(r,i),n.notify()},reset(){const i=s.rebuild(),r=s.state;if(typeof r=="object"&&r!==null&&typeof i=="object"&&i!==null){const a=r;for(const l of Object.keys(a))delete a[l];Object.assign(a,i)}else s.state=i;s.listeners.clear()}};return n}const Ze=ve("desktop-mode/games-registry",()=>({seed:[],listeners:new Set})),ne=Ze.state.seed,_e=Ze.state.listeners;function go(o){mo("Game",Xe(o,Qe),o);const e=ne.findIndex(t=>t.id===o.id);e>=0?ne[e]=o:ne.push(o),_o()}function vo(o){return _e.add(o),()=>{_e.delete(o)}}function _o(){const o=Array.from(_e);for(const e of o)try{e()}catch(t){typeof console<"u"&&console.error("[openstation] games registry listener threw:",t)}}function Je(){const o=ne.slice(),e=Ke(Yt.GAMES,o);return Array.isArray(e)?e.filter(yo):(typeof console<"u"&&console.warn("[openstation] `os.games` filter returned a non-array; falling back to seed list."),o)}function ye(o){return Je().find(e=>e.id===o)}const Qe=[{field:"id",message:"missing or not a non-empty string",valid:o=>typeof o.id=="string"&&o.id!==""},{field:"title",message:"missing or not a non-empty string",valid:o=>typeof o.title=="string"&&o.title!==""},{field:"scoreColumns",message:"must be an array",valid:o=>Array.isArray(o.scoreColumns)},{field:"render/scriptUrl",message:"needs a `render` callback or a `scriptUrl` to lazily load one",valid:o=>typeof o.render=="function"||typeof o.scriptUrl=="string"&&o.scriptUrl!==""}];function yo(o){return Xe(o,Qe).length===0}const et=new Set;function ko(o){if(et.has(o))return;const t=window.openStationConfig?.deferredStyles?.[o];if(!t?.url)return;et.add(o);const s=t.url.replace(/\\/g,"\\\\").replace(/"/g,'\\"');if(!document.head.querySelector(`link[rel="stylesheet"][href="${s}"]`)){const i=document.createElement("link");i.rel="stylesheet",i.href=t.url,i.dataset.osStyleHandle=o,document.head.appendChild(i)}for(const i of t.inline??[]){if(typeof i!="string"||i==="")continue;const r=document.createElement("style");r.dataset.osStyleHandle=o,r.textContent=i,document.head.appendChild(r)}}const xo="http://localhost/";function tt(o,e){const t=typeof window<"u"&&window.location?window.location.href:xo,s=new URL(o,t),n=e.replace(/^\/+/,""),i=n.indexOf("?"),r=i===-1?n:n.slice(0,i),a=i===-1?"":n.slice(i+1);if(s.searchParams.has("rest_route")){const l=s.searchParams.get("rest_route")??"/",d=l.endsWith("/")?l:l+"/";s.searchParams.set("rest_route",d+r)}else{const l=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";s.pathname=l+r}return a&&new URLSearchParams(a).forEach((d,u)=>{s.searchParams.append(u,d)}),s.toString()}const ot="X-WP-Nonce";function wo(o,e){const t=Co();if(!t)return e;const s=So(o);if(!s||!Eo(s))return e;const n=e?.headers??(typeof Request<"u"&&o instanceof Request?o.headers:void 0),i=new Headers(n??{});return i.has(ot)?e:(i.set(ot,t),{...e??{},headers:i})}function Co(){if(typeof window>"u")return;const e=window.openStationConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function So(o){try{const e=typeof window<"u"&&window.location?window.location.href:void 0;return typeof o=="string"?new URL(o,e):o instanceof URL?o:typeof Request<"u"&&o instanceof Request?new URL(o.url,e):null}catch{return null}}function Eo(o){return typeof window>"u"||!window.location||o.origin!==window.location.origin?!1:!!(o.pathname.includes("/wp-json/")||o.searchParams.has("rest_route"))}function st(o,e,t={}){const s=window.wp?.os?.fetch;if(typeof s=="function")return s(o,e,t);const n=wo(o,e);return fetch(o,n)}class Ao extends Error{constructor(e,t){super(e||t.serverMessage||`HTTP ${t.status}`),this.name="RestError",this.status=t.status,this.code=t.code,this.data=t.data,this.serverMessage=t.serverMessage??""}}function $o(o){const e=typeof o=="object"&&o!==null?o:void 0;return{code:typeof e?.code=="string"?e.code:void 0,data:e?.data,serverMessage:typeof e?.message=="string"?e.message:""}}function nt(o,e,t=""){return new Ao(t,{status:o,...$o(e)})}async function Ro(o,e=""){let t=null;try{t=await o.json()}catch{t=null}return nt(o.status,t,e)}const No="desktop-mode/games";function To(){const e=window.wp?.os?.config;return{restUrl:e?.restUrl||"/wp-json/",restNonce:e?.restNonce||""}}async function A(o,e={},t={}){const{restUrl:s,restNonce:n}=To(),i=new Headers(e.headers??{});i.set("X-WP-Nonce",n),e.body&&!i.has("Content-Type")&&i.set("Content-Type","application/json");const r=await st(tt(s,o),{...e,headers:i,credentials:"same-origin"},{source:No,windowId:t.windowId,silent:t.silent}),a=await r.json().catch(()=>null);if(!r.ok)throw nt(r.status,a);return a}function it(o,e={}){const t=new URLSearchParams({page:String(e.page??1),per_page:String(e.perPage??25),orderby:e.orderby??"score",order:e.order??"desc"});return e.userId&&t.set("user_id",String(e.userId)),A(`desktop-mode/v1/games/${o}/scores?${t}`)}function Lo(o,e,t={}){return A(`desktop-mode/v1/games/${o}/scores`,{method:"POST",body:JSON.stringify({score:e.score,meta:e.meta??{}})},t)}function zo(){return A("desktop-mode/v1/games/playtime")}function Io(o,e,t={}){return A(`desktop-mode/v1/games/${o}/playtime`,{method:"POST",body:JSON.stringify({seconds:e})},t)}function Mo(o={}){const e=new URLSearchParams({box:o.box??"all"});return o.state&&e.set("state",o.state),A(`desktop-mode/v1/games/challenges?${e}`)}function Po(o){return A("desktop-mode/v1/games/challenges",{method:"POST",body:JSON.stringify({game:o.game,recipient_id:o.recipientId,score:o.score,meta:o.meta??{}})})}function Ho(o){return A(`desktop-mode/v1/games/challenges/${o}/accept`,{method:"POST"})}function Fo(o){return A(`desktop-mode/v1/games/challenges/${o}/decline`,{method:"POST"})}function qo(o,e,t={}){return A(`desktop-mode/v1/games/challenges/${o}/complete`,{method:"POST",body:JSON.stringify({score:e.score,meta:e.meta??{}})},t)}const Do=6e4;function Oo(o,e={}){let t=Date.now(),s=0,n=!1;const i=()=>{if(t===null)return;const l=Date.now();s+=Math.max(0,l-t),t=l},r=()=>{i();const l=Math.floor(s/1e3);l<1||(s-=l*1e3,Io(o,l,{windowId:e.windowId,silent:!0}).catch(()=>{s+=l*1e3}))},a=setInterval(r,Do);return{pause:()=>{i(),t=null},resume:()=>{n||t!==null||(t=Date.now())},stop:()=>{n||(n=!0,clearInterval(a),i(),t=null,r())}}}function Uo(o,e,t){const s=new Date(`${e}T00:00:00Z`);if(isNaN(s.getTime())||t<1)return 0;const n=new Date(s.getTime()-(t-1)*864e5).toISOString().slice(0,10);let i=0;for(const[r,a]of Object.entries(o))r>=n&&r<=e&&(i+=Math.max(0,Math.floor(Number(a)||0)));return i}function rt(o){const e=Math.max(0,Math.floor(Number(o)||0)),t=Math.floor(e/3600),s=Math.floor(e%3600/60);return t>0?k(g("%1$dh %2$dm"),t,s):s>0?k(g("%dm"),s):k(g("%ds"),e)}const D=ve("desktop-mode/games-challenges",()=>({rows:new Map,version:0,listeners:new Set}));function ie(o){const e=D.state;let t=!1;for(const s of o){if(!s||typeof s.id!="number")continue;const n=e.rows.get(s.id);(!n||n.updatedAtMs!==s.updatedAtMs)&&(e.rows.set(s.id,s),t=!0),s.updatedAtMs>e.version&&(e.version=s.updatedAtMs)}t&&jo()}function Wo(o){return D.state.listeners.add(o),()=>{D.state.listeners.delete(o)}}function jo(){for(const o of Array.from(D.state.listeners))try{o()}catch(e){typeof console<"u"&&console.error("[openstation] challenges store listener threw:",e)}}function Go(){return Array.from(D.state.rows.values()).sort((o,e)=>e.updatedAtMs-o.updatedAtMs)}function at(){return window.wp?.os??{}}const Bo=760,Ko=560,Vo=480,Xo=380;function Yo(){const o=window.openStationConfig?.gameStyleHandles??[];for(const e of o)ko(e)}async function Zo(o){if(typeof o.render=="function")return o;const e=at().loadVendorScript;if(!o.scriptUrl||typeof e!="function")throw new Error(`[openstation] Game "${o.id}" has no render callback and no loadable script.`);await e(o.scriptUrl,{translations:o.scriptTranslations,deps:o.scriptDeps,l10n:o.scriptL10n,before:o.scriptBefore,after:o.scriptAfter});const s=window.openStationGames?.[o.id];if(!s||typeof s.render!="function")throw new Error(`[openstation] No game def on window.openStationGames["${o.id}"]. Script loaded but didn't publish a def — check the plugin's global assignment.`);const n={...o,render:s.render,window:s.window??o.window};return go(n),n}async function lt(o,e={}){const t=at(),s=ye(o);if(!s)throw new Error(`[openstation] Unknown game "${o}".`);if(Yo(),typeof t.registerWindow!="function")throw new Error("[openstation] wp.os.registerWindow is missing — the shell must boot before launching games.");const n=`os-game-${o}`,i=`game:${n}`,r=t.windowManager,a=r?.getByBaseId?.(n)??r?.getById(n);if(a){const h=a.config?.desktopId;h&&r?.switchDesktop&&h!==r?.getActiveDesktopId?.()&&r.switchDesktop(h),t.registerWindow({id:n,title:s.title,icon:s.icon,render:()=>{}});return}t.wallpaper?.suspend(i);let l=!1;const d=()=>{l||(l=!0,t.wallpaper?.resume(i))};let u=null;const c=()=>{u?.stop(),u=null};t.onWindow?.(n,{closed:()=>{c(),d()},minimized:()=>u?.pause(),restored:()=>u?.resume()});const f=(h,m)=>{t.activity?.publish("os/game-score-recorded",{game:o,score:h.score,meta:h.meta??{},windowId:n,challengeId:m})},p=h=>{if(e.challenge){const m=e.challenge.id;return qo(m,h,{windowId:n}).then(({challenge:b})=>{ie([b]),f(h,m)})}return Lo(o,h,{windowId:n}).then(()=>f(h))};try{await t.registerWindow({id:n,title:s.title,icon:s.icon,width:s.window?.width??Bo,height:s.window?.height??Ko,minWidth:s.window?.minWidth??Vo,minHeight:s.window?.minHeight??Xo,render:async h=>{const m=await Zo(s),b=m.render;if(typeof b!="function")throw new Error(`[openstation] Game "${o}" did not provide a render callback.`);const w={windowId:n,container:h,config:m.config??{},challenge:e.challenge,submitScore:p,close:()=>{t.windowManager?.getById(n)?.close()}};u=Oo(o,{windowId:n});const y=b(w);return()=>{try{y?.()}finally{c(),d()}}}})}catch(h){throw c(),d(),h}}function Jo(o){if(!o)return 214;let e=5381;for(let t=0;t<o.length;t++)e=Math.imul(e,33)+o.charCodeAt(t);return(e%360+360)%360}const Qo=_`:host{display:inline-flex;position:relative;width:var( --os-ui-avatar-size,32px );height:var( --os-ui-avatar-size,32px );flex:0 0 auto;vertical-align:middle;line-height:0;perspective:calc( var( --os-ui-avatar-size,32px ) * 8 );--os-ui-avatar-tilt-x:0deg;--os-ui-avatar-tilt-y:0deg;--os-ui-avatar-hover:0;--os-ui-avatar-glare-x:50%;--os-ui-avatar-glare-y:50%}:host( [ hidden ] ){display:none}.os-avatar__tile{position:relative;width:100%;height:100%;border-radius:50%;overflow:hidden;background:var( --os-window-bg,#f0f0f1 );color:var( --os-ui-fg-on-accent,#fff );display:flex;align-items:center;justify-content:center;font-weight:700;font-size:calc( var( --os-ui-avatar-size,32px ) * 0.48 );line-height:1;letter-spacing:0;font-feature-settings:'tnum' 1;user-select:none;transform-style:preserve-3d;transform:rotateX( var( --os-ui-avatar-tilt-x ) ) rotateY( var( --os-ui-avatar-tilt-y ) ) scale( calc( 1 + var( --os-ui-avatar-hover ) * 0.07 ) );transition:transform 220ms cubic-bezier( 0.2,0.8,0.2,1 ),box-shadow 220ms cubic-bezier( 0.2,0.8,0.2,1 );box-shadow:inset 0 0 0 1px rgba( 255,255,255,calc( 0.18 + 0.22 * var( --os-ui-avatar-hover ) ) ),inset 0 0 0 calc( 1px + var( --os-ui-avatar-hover ) * 1px ) rgba( 0,0,0,calc( 0.08 + 0.04 * var( --os-ui-avatar-hover ) ) ),0 calc( 1px + var( --os-ui-avatar-hover ) * 8px ) calc( 6px + var( --os-ui-avatar-hover ) * 18px ) rgba( 0,0,0,calc( 0.08 + 0.18 * var( --os-ui-avatar-hover ) ) )}.os-avatar__tile::after{content:'';position:absolute;inset:0;border-radius:50%;background:radial-gradient( circle at var( --os-ui-avatar-glare-x ) var( --os-ui-avatar-glare-y ),var( --os-ui-scrim,rgba( 255,255,255,0.55 ) ) 0%,var( --os-ui-hover,rgba( 255,255,255,0 ) ) 55% );opacity:var( --os-ui-avatar-hover );mix-blend-mode:overlay;pointer-events:none;transition:opacity 220ms cubic-bezier( 0.2,0.8,0.2,1 )}.os-avatar__tile::before{content:'';position:absolute;inset:calc( var( --os-ui-avatar-hover ) * -3px );border-radius:50%;background:radial-gradient( circle at var( --os-ui-avatar-glare-x ) var( --os-ui-avatar-glare-y ),color-mix( in srgb,var( --os-ui-avatar-halo,rgb( 99,102,241 ) ) calc( 35% * var( --os-ui-avatar-hover ) ),transparent ) 0%,transparent 70% );filter:blur( 4px );pointer-events:none;z-index:-1;transition:inset 220ms cubic-bezier( 0.2,0.8,0.2,1 ),background 220ms}.os-avatar__tile img{width:calc( 100% + 2px );height:calc( 100% + 2px );margin:-1px;object-fit:cover;display:block;transform:translateZ( 1px )}.os-avatar__dot{position:absolute;bottom:0;inset-inline-end:0;width:calc( var( --os-ui-avatar-size,32px ) * 0.32 );height:calc( var( --os-ui-avatar-size,32px ) * 0.32 );min-width:8px;min-height:8px;border-radius:50%;box-sizing:border-box;border:2px solid var( --os-ui-avatar-dot-ring,var( --os-window-bg,#fff ) );background:var( --os-ui-avatar-dot-color,transparent );z-index:2}.os-avatar__dot--online{background:var( --os-ui-success-fg,#00a32a )}.os-avatar__dot--online::after{content:'';position:absolute;inset:-2px;border-radius:50%;border:1px solid var( --os-ui-success-fg,#00a32a );animation:os-avatar-presence 6s var( --os-ui-ease-out,cubic-bezier( 0.22,0.9,0.28,1 ) ) infinite;pointer-events:none}@keyframes os-avatar-presence{0%{opacity:0.6;transform:scale( 1 )}20%{opacity:0;transform:scale( 2.2 )}100%{opacity:0;transform:scale( 2.2 )}}.os-avatar__dot--inactive{background:var( --os-ui-warning-fg,#dba617 )}.os-avatar__dot--offline{background:var( --os-ui-fg-muted,#8c8f94 )}@media ( prefers-reduced-motion:reduce ){.os-avatar__dot--online::after{animation:none;opacity:0.6}.os-avatar__tile{transform:none;transition:box-shadow 200ms}.os-avatar__tile::after,.os-avatar__tile::before{display:none}}`,ct={xs:20,sm:24,md:40,lg:64,xl:96},dt=new Set(["online","inactive","offline"]),G=class G extends E{constructor(){super(...arguments),this._presenceHandler=null,this._imgFailed=!1,this._onPointerMove=null,this._onPointerEnter=null,this._onPointerLeave=null,this._tiltRaf=0,this._pendingTiltX="0deg",this._pendingTiltY="0deg",this._pendingGlareX="50%",this._pendingGlareY="50%"}connectedCallback(){super.connectedCallback(),this._maybeAttachPresenceListener(),this._attachHoverEffect()}disconnectedCallback(){this._presenceHandler&&(document.removeEventListener("os-presence-changed",this._presenceHandler),this._presenceHandler=null),this._detachHoverEffect()}attributeChangedCallback(e,t,s){super.attributeChangedCallback(e,t,s),e==="src"&&(this._imgFailed=!1),(e==="user-id"||e==="presence")&&this._maybeAttachPresenceListener()}render(){const e=this._attr("src"),t=this._attr("name")||"",s=this._attr("alt"),n=s!==null?s:t,i=this._attr("size"),r=this._resolveSize(i),a=this._presenceForRender(),l=this._attr("clickable")!==null;this.style.setProperty("--os-ui-avatar-size",`${r}px`);const d=e&&!this._imgFailed?"":this._initialsBg(t),u=e&&!this._imgFailed?v`<img
30 41 src=${e}
31 - alt=${i}
42 + alt=${n}
32 43 @error=${()=>this._onImgError()}
33 44 loading="lazy"
34 - />`:this._initials(t),c=a?w`<span
35 - class=${`wpd-avatar__dot wpd-avatar__dot--${a}`}
45 + />`:this._initials(t),c=a?v`<span
46 + class=${`os-avatar__dot os-avatar__dot--${a}`}
36 47 aria-label=${this._presenceLabel(a)}
37 - ></span>`:w``;return d?w`
48 + ></span>`:v``;return l?v`
38 49 <button
39 50 type="button"
40 - class="wpd-avatar__tile"
41 - aria-label=${i||"User"}
42 - style=${l?`background:${l};`:""}
51 + class="os-avatar__tile"
52 + aria-label=${n||"User"}
53 + style=${d?`background:${d};`:""}
43 54 @click=${f=>this._onClick(f)}
44 - >${p}</button>
55 + >${u}</button>
45 56 ${c}
46 - `:w`
57 + `:v`
47 58 <div
48 - class="wpd-avatar__tile"
59 + class="os-avatar__tile"
49 60 role="img"
50 - aria-label=${i||"User"}
51 - style=${l?`background:${l};`:""}
52 - >${p}</div>
61 + aria-label=${n||"User"}
62 + style=${d?`background:${d};`:""}
63 + >${u}</div>
53 64 ${c}
54 - `}_attr(e){return this.getAttribute(e)}_resolveSize(e){if(!e)return 32;if(e in Ke)return Ke[e];const t=Number(e);return Number.isFinite(t)&&t>0?t:32}_initials(e){const t=e.trim();return t?Array.from(t)[0]?.toUpperCase()??"?":"?"}_initialsBg(e){const t=us(e);return`linear-gradient(135deg, hsl(${t} 62% 55%), hsl(${(t+24)%360} 58% 42%))`}_presenceForRender(){const e=this._attr("presence");return e&&Xe.has(e)?e:null}_presenceLabel(e){switch(e){case"online":return"Online";case"inactive":return"Inactive";case"offline":return"Offline"}}_onImgError(){this._imgFailed=!0,this.requestUpdate()}_onClick(e){const t=this._attr("user-id"),s={userId:t!==null&&Number(t)||null,originalEvent:e};this.emit("wpd-avatar-click",s)}_attachHoverEffect(){typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||(this._onPointerEnter=()=>{this.style.setProperty("--wpd-avatar-hover","1")},this._onPointerLeave=()=>{this.style.setProperty("--wpd-avatar-hover","0"),this._pendingTiltX="0deg",this._pendingTiltY="0deg",this._pendingGlareX="50%",this._pendingGlareY="50%",this._flushTilt()},this._onPointerMove=t=>{const s=this.getBoundingClientRect();if(s.width===0||s.height===0)return;const i=(t.clientX-s.left)/s.width-.5,r=(t.clientY-s.top)/s.height-.5,o=14;this._pendingTiltY=`${(i*o).toFixed(2)}deg`,this._pendingTiltX=`${(-r*o).toFixed(2)}deg`;const a=Math.max(0,Math.min(100,(i+.5)*100)),d=Math.max(0,Math.min(100,(r+.5)*100));this._pendingGlareX=`${a.toFixed(1)}%`,this._pendingGlareY=`${d.toFixed(1)}%`,this._tiltRaf||(this._tiltRaf=requestAnimationFrame(()=>this._flushTilt()))},this.addEventListener("pointerenter",this._onPointerEnter),this.addEventListener("pointerleave",this._onPointerLeave),this.addEventListener("pointermove",this._onPointerMove))}_flushTilt(){this._tiltRaf=0,this.style.setProperty("--wpd-avatar-tilt-x",this._pendingTiltX),this.style.setProperty("--wpd-avatar-tilt-y",this._pendingTiltY),this.style.setProperty("--wpd-avatar-glare-x",this._pendingGlareX),this.style.setProperty("--wpd-avatar-glare-y",this._pendingGlareY)}_detachHoverEffect(){this._onPointerMove&&(this.removeEventListener("pointermove",this._onPointerMove),this._onPointerMove=null),this._onPointerEnter&&(this.removeEventListener("pointerenter",this._onPointerEnter),this._onPointerEnter=null),this._onPointerLeave&&(this.removeEventListener("pointerleave",this._onPointerLeave),this._onPointerLeave=null),this._tiltRaf&&(cancelAnimationFrame(this._tiltRaf),this._tiltRaf=0)}_maybeAttachPresenceListener(){const e=this._attr("user-id"),t=this._attr("presence"),s=!!e&&!t;s&&!this._presenceHandler?(this._presenceHandler=i=>{const r=i.detail;r&&String(r.userId)===String(e)&&r.newStatus&&Xe.has(r.newStatus)&&this.setAttribute("presence",r.newStatus)},document.addEventListener("desktop-mode-presence-changed",this._presenceHandler)):!s&&this._presenceHandler&&(document.removeEventListener("desktop-mode-presence-changed",this._presenceHandler),this._presenceHandler=null)}};G.props=["src","alt","name","size","presence","userId","clickable"],G.styles=[ps],G.help=void 0;let fe=G;E("wpd-avatar",fe);const fs=$`:host{display:none;position:fixed;inset:0;align-items:center;justify-content:center;background:rgba( 0,0,0,0.45 );backdrop-filter:blur( 2px );z-index:10000;--desktop-mode-text:#f0f0f1;--desktop-mode-text-muted:#bbc1c7;--desktop-mode-muted:#a7aaad;--desktop-mode-muted-fg:#a7aaad;--desktop-mode-border:rgba( 255,255,255,0.25 );--desktop-mode-window-bg:#2c3338;--wpd-button-bg-hover:rgba( 255,255,255,0.08 )}:host( [ open ] ){display:flex}.dialog{max-width:92vw;max-height:90vh;background:var( --wpd-modal-bg,var( --desktop-mode-bg,#1d2327 ) );color:var( --wpd-modal-fg,var( --desktop-mode-fg,#fff ) );border:1px solid rgba( 255,255,255,0.08 );border-radius:10px;box-shadow:0 20px 50px rgba( 0,0,0,0.6 );display:flex;flex-direction:column;overflow:hidden}:host( [ size='sm' ] ) .dialog{width:min( 360px,92vw )}:host(:not( [ size ] ) ) .dialog,:host( [ size='md' ] ) .dialog{width:min( 540px,92vw )}:host( [ size='lg' ] ) .dialog{width:min( 760px,94vw )}.header{display:flex;align-items:center;gap:10px;padding:16px 20px 12px;border-bottom:1px solid rgba( 255,255,255,0.06 )}.title{margin:0;flex:1;font-size:15px;font-weight:600}.header-actions{display:flex;gap:6px}.header-actions::slotted( * ){margin-inline-start:6px}.close{background:transparent;border:0;color:inherit;font-size:18px;line-height:1;padding:4px 8px;border-radius:4px;cursor:pointer;opacity:0.7}.close:hover{opacity:1;background:rgba( 255,255,255,0.08 )}.body{padding:16px 20px;overflow:auto;flex:1 1 auto;font-size:13px;line-height:1.5}.footer{padding:12px 20px 16px;border-top:1px solid rgba( 255,255,255,0.06 )}.footer slot{display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap}:host( [ mandatory ] ) .close{display:none}`,Ye='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',j=class j extends S{constructor(){super(...arguments),this._prevFocus=null,this._onKey=e=>{if(e.key==="Escape"&&!this.hasAttribute("mandatory")){e.preventDefault(),this._cancel();return}if(e.key==="Tab"){const t=this._focusables();if(t.length===0)return;const s=t[0],i=t[t.length-1],r=this.ownerDocument,o=r?r.activeElement:null,a=e.composedPath()[0]||o;e.shiftKey&&a===s?(e.preventDefault(),i.focus()):!e.shiftKey&&a===i&&(e.preventDefault(),s.focus())}},this._onBackdrop=e=>{if(this.hasAttribute("mandatory"))return;const t=e.composedPath();(t.length>0?t[0]:e.target)===this&&this._cancel()}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this.addEventListener("keydown",this._onKey),this.addEventListener("click",this._onBackdrop)}disconnectedCallback(){this.removeEventListener("keydown",this._onKey),this.removeEventListener("click",this._onBackdrop)}attributeChangedCallback(e,t,s){if(super.attributeChangedCallback?.(e,t,s),e==="open"){if(s!==null){const i=this.ownerDocument;this._prevFocus=i?i.activeElement:null,queueMicrotask(()=>this._focusFirst())}else if(this._prevFocus){try{this._prevFocus.focus()}catch{}this._prevFocus=null}}}showModal(){this.setAttribute("open","")}hideModal(){this.removeAttribute("open")}_focusables(){const e=this.shadowRoot;if(!e)return[];const t=Array.from(this.querySelectorAll(Ye)),s=Array.from(e.querySelectorAll(Ye));return[...t,...s].filter(i=>i.offsetParent!==null||i.tagName==="BUTTON")}_focusFirst(){const e=this._focusables();e.length>0?e[0].focus():this.shadowRoot?.querySelector(".dialog")?.focus?.()}_cancel(){const e=new CustomEvent("wpd-modal-cancel",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e)&&this.hideModal()}render(){const e=this.getAttribute("title")??"",t=this.hasAttribute("mandatory");return w`
55 - <div class="dialog" tabindex="-1">
56 - ${e?w`
65 + `}_attr(e){return this.getAttribute(e)}_resolveSize(e){if(!e)return 32;if(e in ct)return ct[e];const t=Number(e);return Number.isFinite(t)&&t>0?t:32}_initials(e){const t=e.trim();return t?Array.from(t)[0]?.toUpperCase()??"?":"?"}_initialsBg(e){const t=Jo(e);return`linear-gradient(135deg, hsl(${t} 62% 55%), hsl(${(t+24)%360} 58% 42%))`}_presenceForRender(){const e=this._attr("presence");return e&&dt.has(e)?e:null}_presenceLabel(e){switch(e){case"online":return"Online";case"inactive":return"Inactive";case"offline":return"Offline"}}_onImgError(){this._imgFailed=!0,this.requestUpdate()}_onClick(e){const t=this._attr("user-id"),s={userId:t!==null&&Number(t)||null,originalEvent:e};this.emit("os-avatar-click",s)}_attachHoverEffect(){typeof window<"u"&&window.matchMedia?.("(prefers-reduced-motion: reduce)").matches||(this._onPointerEnter=()=>{this.style.setProperty("--os-ui-avatar-hover","1")},this._onPointerLeave=()=>{this.style.setProperty("--os-ui-avatar-hover","0"),this._pendingTiltX="0deg",this._pendingTiltY="0deg",this._pendingGlareX="50%",this._pendingGlareY="50%",this._flushTilt()},this._onPointerMove=t=>{const s=this.getBoundingClientRect();if(s.width===0||s.height===0)return;const n=(t.clientX-s.left)/s.width-.5,i=(t.clientY-s.top)/s.height-.5,r=14;this._pendingTiltY=`${(n*r).toFixed(2)}deg`,this._pendingTiltX=`${(-i*r).toFixed(2)}deg`;const a=Math.max(0,Math.min(100,(n+.5)*100)),l=Math.max(0,Math.min(100,(i+.5)*100));this._pendingGlareX=`${a.toFixed(1)}%`,this._pendingGlareY=`${l.toFixed(1)}%`,this._tiltRaf||(this._tiltRaf=requestAnimationFrame(()=>this._flushTilt()))},this.addEventListener("pointerenter",this._onPointerEnter),this.addEventListener("pointerleave",this._onPointerLeave),this.addEventListener("pointermove",this._onPointerMove))}_flushTilt(){this._tiltRaf=0,this.style.setProperty("--os-ui-avatar-tilt-x",this._pendingTiltX),this.style.setProperty("--os-ui-avatar-tilt-y",this._pendingTiltY),this.style.setProperty("--os-ui-avatar-glare-x",this._pendingGlareX),this.style.setProperty("--os-ui-avatar-glare-y",this._pendingGlareY)}_detachHoverEffect(){this._onPointerMove&&(this.removeEventListener("pointermove",this._onPointerMove),this._onPointerMove=null),this._onPointerEnter&&(this.removeEventListener("pointerenter",this._onPointerEnter),this._onPointerEnter=null),this._onPointerLeave&&(this.removeEventListener("pointerleave",this._onPointerLeave),this._onPointerLeave=null),this._tiltRaf&&(cancelAnimationFrame(this._tiltRaf),this._tiltRaf=0)}_maybeAttachPresenceListener(){const e=this._attr("user-id"),t=this._attr("presence"),s=!!e&&!t;s&&!this._presenceHandler?(this._presenceHandler=n=>{const i=n.detail;i&&String(i.userId)===String(e)&&i.newStatus&&dt.has(i.newStatus)&&this.setAttribute("presence",i.newStatus)},document.addEventListener("os-presence-changed",this._presenceHandler)):!s&&this._presenceHandler&&(document.removeEventListener("os-presence-changed",this._presenceHandler),this._presenceHandler=null)}};G.props=["src","alt","name","size","presence","userId","clickable"],G.styles=[Qo],G.help=void 0;let ke=G;R("os-avatar",ke);const es=_` ${Q}:host{display:none;position:fixed;inset:0;align-items:center;justify-content:center;background:var( --os-ui-scrim,rgba( 0,0,0,0.45 ) );background-image:var( --os-ui-scrim-image,none );background-repeat:var( --os-ui-scrim-image-repeat,repeat );background-size:var( --os-ui-scrim-image-size,auto );background-position:var( --os-ui-scrim-image-position,center );backdrop-filter:blur( 2px );z-index:10000;--os-ui-fg:var( --os-ui-modal-text,#f0f0f1 );--os-ui-fg-muted:var( --os-ui-modal-text-muted,#a7aaad );--os-ui-border:var( --os-ui-modal-border,rgba( 255,255,255,0.25 ) );--os-window-bg:var( --os-ui-modal-field-bg,#2c3338 );--os-ui-button-bg-hover:var( --os-ui-modal-button-bg-hover,rgba( 255,255,255,0.08 ) );--os-ui-surface:var( --os-ui-modal-surface,#2c3338 );--os-ui-surface-elevated:var( --os-ui-modal-surface-elevated,#3c434a );--os-ui-border-strong:var( --os-ui-modal-border-strong,rgba( 255,255,255,0.35 ) );--os-ui-hover:var( --os-ui-modal-hover,rgba( 255,255,255,0.08 ) );--os-ui-notice-color:var( --os-ui-modal-text,#f0f0f1 );--os-ui-card-bg:var( --os-ui-modal-surface,#2c3338 );--os-ui-card-fg:var( --os-ui-modal-text,#f0f0f1 );--os-ui-card-border:var( --os-ui-modal-border,rgba( 255,255,255,0.25 ) );--os-ui-card-border-hover:var( --os-ui-modal-border-strong,rgba( 255,255,255,0.35 ) )}:host( [ open ] ){display:flex;animation:os-modal-scrim var( --_holo-t ) var( --_holo-ease )}:host( [ open ] ) .dialog{animation:os-modal-dialog var( --_holo-t ) var( --_holo-spring )}@keyframes os-modal-scrim{from{opacity:0}}@keyframes os-modal-dialog{from{opacity:0;transform:scale( 0.96 ) translateY( 8px )}}@media ( prefers-reduced-motion:reduce ){:host( [ open ] ),:host( [ open ] ) .dialog{animation:none}}.dialog{max-width:92vw;max-height:90vh;background-color:var( --os-ui-modal-bg,#1d2327 );background-image:var( --os-ui-dialog-bg-image,none );background-repeat:var( --os-ui-dialog-bg-image-repeat,repeat );background-size:var( --os-ui-dialog-bg-image-size,auto );background-position:var( --os-ui-dialog-bg-image-position,center );color:var( --os-ui-modal-fg,var( --os-fg,#fff ) );border:1px solid var( --os-ui-border,rgba( 255,255,255,0.08 ) );border-radius:10px;box-shadow:0 20px 50px rgba( 0,0,0,0.6 );display:flex;flex-direction:column;overflow:hidden}:host( [ size='sm' ] ) .dialog{width:min( 360px,92vw )}:host(:not( [ size ] ) ) .dialog,:host( [ size='md' ] ) .dialog{width:min( 540px,92vw )}:host( [ size='lg' ] ) .dialog{width:min( 760px,94vw )}.header{display:flex;align-items:center;gap:10px;padding:16px 20px 12px;border-bottom:1px solid var( --os-ui-border,rgba( 255,255,255,0.06 ) )}.title{margin:0;flex:1;font-size:15px;font-weight:600}.header-actions{display:flex;gap:6px}.header-actions::slotted( * ){margin-inline-start:6px}.close{background:transparent;border:0;color:inherit;font-size:18px;line-height:1;padding:4px 8px;border-radius:4px;cursor:pointer;opacity:0.7}.close:hover{opacity:1;background:var( --os-ui-hover,rgba( 255,255,255,0.08 ) )}.body{padding:16px 20px;overflow:auto;flex:1 1 auto;font-size:13px;line-height:1.5}.footer{padding:12px 20px 16px;border-top:1px solid var( --os-ui-border,rgba( 255,255,255,0.06 ) )}.footer slot{display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap}:host( [ mandatory ] ) .close{display:none}`,ut='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',B=class B extends E{constructor(){super(...arguments),this._prevFocus=null,this._onKey=e=>{if(e.key==="Escape"&&!this.hasAttribute("mandatory")){e.preventDefault(),this._cancel();return}if(e.key==="Tab"){const t=this._focusables();if(t.length===0)return;const s=t[0],n=t[t.length-1],i=this.ownerDocument,r=i?i.activeElement:null,a=e.composedPath()[0]||r;e.shiftKey&&a===s?(e.preventDefault(),n.focus()):!e.shiftKey&&a===n&&(e.preventDefault(),s.focus())}},this._onBackdrop=e=>{if(this.hasAttribute("mandatory"))return;const t=e.composedPath();(t.length>0?t[0]:e.target)===this&&this._cancel()}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this.addEventListener("keydown",this._onKey),this.addEventListener("click",this._onBackdrop)}disconnectedCallback(){this.removeEventListener("keydown",this._onKey),this.removeEventListener("click",this._onBackdrop)}attributeChangedCallback(e,t,s){if(super.attributeChangedCallback?.(e,t,s),e==="open"){if(s!==null){const n=this.ownerDocument;this._prevFocus=n?n.activeElement:null,queueMicrotask(()=>this._focusFirst())}else if(this._prevFocus){try{this._prevFocus.focus()}catch{}this._prevFocus=null}}}showModal(){this.setAttribute("open","")}hideModal(){this.removeAttribute("open")}_focusables(){const e=this.shadowRoot;if(!e)return[];const t=Array.from(this.querySelectorAll(ut)),s=Array.from(e.querySelectorAll(ut));return[...t,...s].filter(n=>n.offsetParent!==null||n.tagName==="BUTTON")}_focusFirst(){const e=this._focusables();e.length>0?e[0].focus():this.shadowRoot?.querySelector(".dialog")?.focus?.()}_cancel(){const e=new CustomEvent("os-modal-cancel",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e)&&this.hideModal()}render(){const e=this.getAttribute("title")??"",t=this.hasAttribute("mandatory");return v`
66 + <div part="dialog" class="dialog" tabindex="-1">
67 + ${e?v`
57 68 <div class="header">
58 69 <h2 class="title">${e}</h2>
59 70 <div class="header-actions">
60 71 <slot name="header-actions"></slot>
61 - ${t?w``:w`<button
72 + ${t?v``:v`<button
62 73 type="button"
63 74 class="close"
64 75 aria-label="Close"
65 76 @click=${()=>this._cancel()}
@@ -65,9 +76,9 @@
65 76 @click=${()=>this._cancel()}
66 77 >×</button>`}
67 78 </div>
68 79 </div>
69 - `:w``}
80 + `:v``}
70 81 <div class="body">
71 82 <slot></slot>
72 83 </div>
73 84 <div class="footer">
@@ -73,9 +84,9 @@
73 84 <div class="footer">
74 85 <slot name="footer"></slot>
75 86 </div>
76 87 </div>
77 - `}};j.props=["open","title","size","mandatory"],j.styles=[fs],j.help=void 0;let me=j;E("wpd-modal",me);const ms=$`:host{display:block;position:relative;font-size:13px}.input{width:100%;padding:8px 10px;background:var( --wpd-input-bg,rgba( 255,255,255,0.06 ) );color:inherit;border:1px solid rgba( 255,255,255,0.12 );border-radius:6px;font:inherit;box-sizing:border-box}.input:focus{outline:2px solid var( --wp-admin-theme-color,#2271b1 );outline-offset:-1px}.dropdown{background:var( --desktop-mode-bg,#1d2327 );color:var( --desktop-mode-fg,#fff );border:1px solid rgba( 255,255,255,0.18 );border-radius:6px;overflow:auto;z-index:11000;box-shadow:0 12px 32px rgba( 0,0,0,0.5 )}.empty.error{color:#ff8080}.item{display:flex;align-items:center;gap:10px;padding:8px 10px;cursor:pointer;border:0;background:transparent;color:inherit;width:100%;text-align:start;font:inherit}.item:hover,.item:focus{background:rgba( 255,255,255,0.06 );outline:none}.avatar{width:24px;height:24px;border-radius:50%;flex:0 0 auto;background:rgba( 255,255,255,0.1 )}.name{font-weight:500}.slug{opacity:0.6;font-size:12px}.empty{padding:12px;color:rgba( 255,255,255,0.5 );font-size:12px}`,B=class B extends S{constructor(){super(...arguments),this._timer=null,this._abort=null,this._results=[],this._query="",this._open=!1,this._phase="idle",this._error="",this._dropdownStyle="",this._onScrollOrResize=()=>{},this._onInput=e=>{const t=e.target.value;this._query=t,this._scheduleSearch(t)},this._onFocus=()=>{if(this._results.length===0&&this._phase==="idle"){this._scheduleSearch(this._query);return}this._open=!0,this._positionDropdown(),this.requestUpdate()},this._onBlur=()=>{setTimeout(()=>{this._open=!1,this.requestUpdate()},150)},this._pick=e=>{this.emit("wpd-user-pick",{user:e}),this._results=[],this._open=!1,this._phase="idle",this._query="";const t=this.shadowRoot?.querySelector(".input");t&&(t.value=""),this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this._onScrollOrResize=()=>{this._open&&(this._positionDropdown(),this.requestUpdate())},window.addEventListener("resize",this._onScrollOrResize),window.addEventListener("scroll",this._onScrollOrResize,!0)}disconnectedCallback(){this._timer&&clearTimeout(this._timer),this._abort&&this._abort.abort(),window.removeEventListener("resize",this._onScrollOrResize),window.removeEventListener("scroll",this._onScrollOrResize,!0)}_endpoint(){const e=this.getAttribute("endpoint");return e||window.desktopModeConfig?.filesUsersSearchUrl||""}_scheduleSearch(e){this._timer&&clearTimeout(this._timer),this._phase="loading",this._open=!0,this._positionDropdown(),this.requestUpdate(),this._timer=setTimeout(()=>this._runSearch(e),200)}async _runSearch(e){const t=this._endpoint();if(!t){this._phase="error",this._error="Search endpoint is not configured.",this._results=[],this._open=!0,this.requestUpdate();return}this._abort&&this._abort.abort();const s=new AbortController;this._abort=s;const i=this.getAttribute("exclude")||"",r=t+"?q="+encodeURIComponent(e)+"&exclude="+encodeURIComponent(i);try{const o={signal:s.signal,credentials:"same-origin"},a=await Ge(r,o,{source:"desktop-mode/files-user-search",silent:!0});if(!a.ok)throw new Error(`HTTP ${a.status}`);const d=await a.json();this._results=d&&Array.isArray(d.users)?d.users:[],this._phase="ready",this._error="",this._open=!0}catch(o){if(o.name==="AbortError")return;this._results=[],this._phase="error",this._error=o.message||"Search failed.",this._open=!0}this._positionDropdown(),this.requestUpdate()}_positionDropdown(){const e=this.shadowRoot?.querySelector(".input");if(!e)return;const t=e.getBoundingClientRect(),s=t.bottom+4,i=t.left,r=t.width,a=window.innerHeight-t.bottom,d=t.top,l=Math.max(120,Math.min(280,Math.max(a,d)-16));a<200&&d>a?this._dropdownStyle=["position:fixed",`left:${i}px`,`top:${t.top-4-l}px`,`width:${r}px`,`max-height:${l}px`].join(";"):this._dropdownStyle=["position:fixed",`left:${i}px`,`top:${s}px`,`width:${r}px`,`max-height:${l}px`].join(";")}_dropdownContent(){if(this._phase==="loading")return w`<div class="empty">Searching…</div>`;if(this._phase==="error")return w`<div class="empty error">${this._error}</div>`;if(this._results.length===0){const e=this._query?"No matches.":"No users available.";return w`<div class="empty">${e}</div>`}return this._results.map(e=>w`
88 + `}};B.props=["open","title","size","mandatory"],B.styles=[es],B.help=void 0;let xe=B;R("os-modal",xe);const ts=_`:host{display:block;position:relative;font-size:13px}.input{width:100%;padding:8px 10px;background:var( --os-ui-input-bg,var( --os-ui-hover,rgba( 255,255,255,0.06 ) ) );color:inherit;border:1px solid var( --os-ui-border,rgba( 255,255,255,0.12 ) );border-radius:6px;font:inherit;box-sizing:border-box}.input:focus{outline:none;border-color:var( --os-ui-accent,#2271b1 );box-shadow:var( --os-ui-focus-ring-field,0 0 0 1px #2271b1,0 0 0 4px rgba( 34,113,177,0.18 ) )}.dropdown{background:var( --os-bg,#1d2327 );color:var( --os-fg,#fff );border:1px solid var( --os-ui-border,rgba( 255,255,255,0.18 ) );border-radius:6px;overflow:auto;z-index:11000;box-shadow:0 12px 32px rgba( 0,0,0,0.5 )}.empty.error{color:var( --os-ui-danger-hover,#ff8080 )}.item{display:flex;align-items:center;gap:10px;padding:8px 10px;cursor:pointer;border:0;background:transparent;color:inherit;width:100%;text-align:start;font:inherit}.item:hover,.item:focus{background:var( --os-ui-hover,rgba( 255,255,255,0.06 ) );outline:none}.avatar{width:24px;height:24px;border-radius:50%;flex:0 0 auto;background:var( --os-ui-hover,rgba( 255,255,255,0.1 ) )}.name{font-weight:500}.slug{opacity:0.6;font-size:12px}.empty{padding:12px;color:var( --os-ui-fg-muted,rgba( 255,255,255,0.5 ) );font-size:12px}`,K=class K extends E{constructor(){super(...arguments),this._timer=null,this._abort=null,this._results=[],this._query="",this._open=!1,this._phase="idle",this._error="",this._dropdownStyle="",this._onScrollOrResize=()=>{},this._onInput=e=>{const t=e.target.value;this._query=t,this._scheduleSearch(t)},this._onFocus=()=>{if(this._results.length===0&&this._phase==="idle"){this._scheduleSearch(this._query);return}this._open=!0,this._positionDropdown(),this.requestUpdate()},this._onBlur=()=>{setTimeout(()=>{this._open=!1,this.requestUpdate()},150)},this._pick=e=>{this.emit("os-user-pick",{user:e}),this._results=[],this._open=!1,this._phase="idle",this._query="";const t=this.shadowRoot?.querySelector(".input");t&&(t.value=""),this.requestUpdate()}}connectedCallback(){super.connectedCallback(),this._onScrollOrResize=()=>{this._open&&(this._positionDropdown(),this.requestUpdate())},window.addEventListener("resize",this._onScrollOrResize),window.addEventListener("scroll",this._onScrollOrResize,!0)}disconnectedCallback(){this._timer&&clearTimeout(this._timer),this._abort&&this._abort.abort(),window.removeEventListener("resize",this._onScrollOrResize),window.removeEventListener("scroll",this._onScrollOrResize,!0)}_endpoint(){const e=this.getAttribute("endpoint");return e||window.openStationConfig?.filesUsersSearchUrl||""}_scheduleSearch(e){this._timer&&clearTimeout(this._timer),this._phase="loading",this._open=!0,this._positionDropdown(),this.requestUpdate(),this._timer=setTimeout(()=>this._runSearch(e),200)}async _runSearch(e){const t=this._endpoint();if(!t){this._phase="error",this._error="Search endpoint is not configured.",this._results=[],this._open=!0,this.requestUpdate();return}this._abort&&this._abort.abort();const s=new AbortController;this._abort=s;const n=this.getAttribute("exclude")||"",i=t+"?q="+encodeURIComponent(e)+"&exclude="+encodeURIComponent(n);try{const r={signal:s.signal,credentials:"same-origin"},a=await st(i,r,{source:"desktop-mode/files-user-search",silent:!0});if(!a.ok)throw await Ro(a);const l=await a.json();this._results=l&&Array.isArray(l.users)?l.users:[],this._phase="ready",this._error="",this._open=!0}catch(r){if(r.name==="AbortError")return;this._results=[],this._phase="error",this._error=r.message||"Search failed.",this._open=!0}this._positionDropdown(),this.requestUpdate()}_positionDropdown(){const e=this.shadowRoot?.querySelector(".input");if(!e)return;const t=e.getBoundingClientRect(),s=t.bottom+4,n=t.left,i=t.width,a=window.innerHeight-t.bottom,l=t.top,d=Math.max(120,Math.min(280,Math.max(a,l)-16));a<200&&l>a?this._dropdownStyle=["position:fixed",`left:${n}px`,`top:${t.top-4-d}px`,`width:${i}px`,`max-height:${d}px`].join(";"):this._dropdownStyle=["position:fixed",`left:${n}px`,`top:${s}px`,`width:${i}px`,`max-height:${d}px`].join(";")}_dropdownContent(){if(this._phase==="loading")return v`<div class="empty">Searching…</div>`;if(this._phase==="error")return v`<div class="empty error">${this._error}</div>`;if(this._results.length===0){const e=this._query?"No matches.":"No users available.";return v`<div class="empty">${e}</div>`}return this._results.map(e=>v`
78 89 <button
79 90 type="button"
80 91 class="item"
81 92 role="option"
@@ -87,9 +98,9 @@
87 98 <div class="name">${e.name}</div>
88 99 <div class="slug">${e.slug}</div>
89 100 </div>
90 101 </button>
91 - `)}render(){const e=this.getAttribute("placeholder")||"Search users…";return w`
102 + `)}render(){const e=this.getAttribute("placeholder")||"Search users…";return v`
92 103 <input
93 104 class="input"
94 105 type="search"
95 106 placeholder=${e}
@@ -98,16 +109,16 @@
98 109 @focus=${this._onFocus}
99 110 @blur=${this._onBlur}
100 111 .value=${this._query}
101 112 />
102 - ${this._open?w`
113 + ${this._open?v`
103 114 <div class="dropdown" role="listbox" style=${this._dropdownStyle}>
104 115 ${this._dropdownContent()}
105 116 </div>
106 - `:w``}
107 - `}};B.props=["placeholder","exclude","endpoint"],B.styles=[ms],B.help=void 0;let be=B;E("wpd-user-search",be);function bs(){const e=window.desktopModeGamesConfig?.usersSearchUrl;if(e)return e;const s=window.wp?.desktop?.config?.restUrl||"/wp-json/";return Fe(s,"desktop-mode/v1/games/users/search")}function Ze(n){return new Promise(e=>{const t=document.createElement("wpd-modal");t.setAttribute("open",""),t.setAttribute("title",b("Send a challenge")),t.setAttribute("size","sm");const s=document.createElement("div");s.className="desktop-mode-games__challenge-dialog";const i=document.createElement("p");i.className="desktop-mode-games__challenge-summary",i.textContent=y(b("Challenge someone to beat your %1$s score of %2$s."),n.gameTitle,String(n.score)),s.appendChild(i);const r=document.createElement("wpd-user-search");r.setAttribute("placeholder",b("Find a player…")),r.setAttribute("endpoint",bs()),s.appendChild(r);const o=document.createElement("div");o.className="desktop-mode-games__challenge-picked",o.hidden=!0,s.appendChild(o),t.appendChild(s);const a=document.createElement("div");a.setAttribute("slot","footer"),a.className="desktop-mode-games__challenge-footer";const d=document.createElement("wpd-button");d.setAttribute("variant","ghost"),d.textContent=b("Cancel");const l=document.createElement("wpd-button");l.setAttribute("variant","primary"),l.setAttribute("disabled",""),l.textContent=b("Send challenge"),a.append(d,l),t.appendChild(a);let p=null,c=!1;const f=()=>{t.remove(),e()},u=()=>{if(o.innerHTML="",!p){o.hidden=!0,l.setAttribute("disabled","");return}o.hidden=!1;const h=document.createElement("wpd-avatar");h.setAttribute("src",p.avatarUrl),h.setAttribute("name",p.name),h.setAttribute("size","sm"),h.setAttribute("user-id",String(p.id)),o.appendChild(h);const m=document.createElement("span");m.textContent=p.name,o.appendChild(m),l.removeAttribute("disabled")};r.addEventListener("wpd-user-pick",h=>{const m=h.detail?.user;m&&(p=m,u())}),d.addEventListener("click",f),t.addEventListener("wpd-modal-cancel",f),l.addEventListener("click",()=>{!p||c||(c=!0,l.setAttribute("disabled",""),es({game:n.game,recipientId:p.id,score:n.score,meta:n.meta}).then(()=>{M({message:y(b("Challenge sent to %s."),p.name)}),f()}).catch(h=>{c=!1,l.removeAttribute("disabled"),M({message:h instanceof Error?h.message:b("Could not send the challenge.")})}))}),document.body.appendChild(t)})}const gs=$`:host{display:inline;color:inherit;font:inherit}`,te=new Set;let z=null;const ws=3e4;function _s(){z===null&&(z=window.setInterval(()=>{for(const n of te)n.tick()},ws))}function ys(){z!==null&&te.size===0&&(window.clearInterval(z),z=null)}function vs(n){if(!n)return null;const e=t=>{const s=new Date(t);return Number.isNaN(s.getTime())?null:s};return n.includes("T")||n.endsWith("Z")?e(n):e(n.replace(" ","T")+"Z")}let ge=null;function ks(){if(!ge){const n=typeof navigator<"u"&&navigator.language||"en";ge=new Intl.RelativeTimeFormat(n,{numeric:"auto"})}return ge}function xs(n,e){const t=ks(),s=n.getTime()-e,i=Math.round(s/1e3),r=Math.abs;if(r(i)<45)return t.format(0,"second");const o=Math.round(i/60);if(r(o)<45)return t.format(o,"minute");const a=Math.round(o/60);if(r(a)<22)return t.format(a,"hour");const d=Math.round(a/24);if(r(d)<26)return t.format(d,"day");const l=Math.round(d/30);if(r(l)<11)return t.format(l,"month");const p=Math.round(d/365);return t.format(p,"year")}const W=class W extends S{connectedCallback(){super.connectedCallback(),te.add(this),_s()}disconnectedCallback(){te.delete(this),ys()}tick(){this.requestUpdate()}render(){const e=this.datetime,t=vs(e);if(!t)return w`<span>${e??""}</span>`;const s=xs(t,Date.now()),i=t.toLocaleString();return w`<time datetime=${t.toISOString()} title=${i}
108 - >${s}</time
109 - >`}};W.props=["datetime"],W.styles=[gs],W.help=void 0;let we=W;E("wpd-relative-time",we);const Cs=$`:host{display:block;--wpd-table-bg:var( --wpd-surface,#fff );--wpd-table-border:var( --wpd-border,rgba( 0,0,0,0.08 ) );--wpd-table-column-border:var( --wpd-border-strong,rgba( 0,0,0,0.14 ) );--wpd-table-header-bg:var( --wpd-surface-elevated,#f6f7f7 );--wpd-table-row-hover:rgba( 0,0,0,0.04 );--wpd-table-stripe:rgba( 0,0,0,0.03 );--wpd-table-cell-padding:8px 12px;--wpd-table-font-size:13px;--wpd-table-max-height:none;font-size:var( --wpd-table-font-size );color:inherit}:host( [ hidden ] ){display:none}.scroll{position:relative;overflow:auto;max-height:var( --wpd-table-max-height );border:1px solid var( --wpd-table-border );border-radius:4px;background:var( --wpd-table-bg )}table{width:100%;border-collapse:separate;border-spacing:0;background:var( --wpd-table-bg )}thead th{text-align:start;font-weight:600;background-color:var( --wpd-table-header-bg );padding:var( --wpd-table-cell-padding );border-bottom:1px solid var( --wpd-table-border );white-space:nowrap}tbody td{padding:var( --wpd-table-cell-padding );border-bottom:1px solid var( --wpd-table-border );background-color:var( --wpd-table-bg );vertical-align:middle}tbody tr:last-child td{border-bottom:0}:host( [ striped ] ) tbody tr:nth-child( odd ) td{background-image:linear-gradient( var( --wpd-table-stripe ),var( --wpd-table-stripe ) )}:host( [ hover ] ) tbody tr:hover td{background-image:linear-gradient( var( --wpd-table-row-hover ),var( --wpd-table-row-hover ) )}:host( [ hover ] [ striped ] ) tbody tr:nth-child( odd ):hover td{background-image:linear-gradient( var( --wpd-table-row-hover ),var( --wpd-table-row-hover ) ),linear-gradient( var( --wpd-table-stripe ),var( --wpd-table-stripe ) )}:host( [ compact ] ){--wpd-table-cell-padding:4px 8px;--wpd-table-font-size:12px}:host( [ bordered ] ) thead th,:host( [ bordered ] ) tbody td{border-inline-end:1px solid var( --wpd-table-column-border )}:host( [ bordered ] ) thead th:last-child,:host( [ bordered ] ) tbody td:last-child{border-inline-end:0}th.is-sticky,td.is-sticky{position:sticky;z-index:10}tbody td.is-sticky{background-color:var( --wpd-table-bg )}thead th.is-sticky{background-color:var( --wpd-table-header-bg );z-index:30}:host( [ sticky-header ] ) thead th{position:sticky;top:0;z-index:20}:host( [ sticky-header ] ) thead tr.filter-row th{top:var( --wpd-table-header-height,33px );z-index:20}:host( [ sticky-header ] ) thead th.is-sticky{z-index:40}:host( [ sticky-header ] ) thead tr.filter-row th.is-sticky{z-index:40}th.is-sticky-edge,td.is-sticky-edge{border-inline-end:var( --wpd-table-sticky-edge,2px solid var( --wpd-table-border ) )}.align-center{text-align:center}.align-end{text-align:end}.filter-row th{padding:4px 8px;background-color:var( --wpd-table-header-bg );border-bottom:1px solid var( --wpd-table-border );font-weight:400}.filter-input,.filter-select{width:100%;min-width:60px;box-sizing:border-box;padding:4px 6px;font:inherit;color:inherit;background-color:var( --wpd-table-bg );border:1px solid var( --wpd-table-border );border-radius:3px}.filter-input:focus,.filter-select:focus{outline:2px solid var( --wp-admin-theme-color,#2271b1 );outline-offset:-1px}.expander{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:0;background:transparent;color:inherit;cursor:pointer;border-radius:3px;font-size:11px;line-height:1}.expander:hover{background:rgba( 0,0,0,0.06 )}td.col-expander,th.col-expander{width:36px;min-width:36px;padding-left:0;padding-right:0;text-align:center}tr.subtable td{padding:0;background-color:var( --wpd-table-bg );background-image:linear-gradient( var( --wpd-table-stripe ),var( --wpd-table-stripe ) );border-bottom:1px solid var( --wpd-table-border )}tr.subtable .subtable-inner{padding:8px 12px 8px 32px}tr.empty td{padding:24px;text-align:center;color:var( --wpd-text-muted,rgba( 0,0,0,0.55 ) );font-style:italic}thead th.is-sortable{cursor:pointer;user-select:none}thead th.is-sortable:hover{background-image:linear-gradient( var( --wpd-table-row-hover ),var( --wpd-table-row-hover ) )}thead th.is-sortable:focus-visible{outline:2px solid var( --wp-admin-theme-color,#2271b1 );outline-offset:-2px}.sort-indicator{font-size:10px;color:var( --wpd-text-muted,rgba( 0,0,0,0.55 ) );margin-inline-start:2px}thead th.sort-asc .sort-indicator,thead th.sort-desc .sort-indicator{color:var( --wp-admin-theme-color,#2271b1 )}td.col-select,th.col-select{width:40px;min-width:40px;padding-left:0;padding-right:0;text-align:center}.select-all-checkbox,.select-row-checkbox{cursor:pointer;margin:0}tbody tr.is-selected td{background-color:color-mix( in srgb,var( --wp-admin-theme-color,#2271b1 ) 10%,var( --wpd-table-bg ) );background-image:none}tbody tr.is-selected:hover td{background-color:color-mix( in srgb,var( --wp-admin-theme-color,#2271b1 ) 16%,var( --wpd-table-bg ) )}tbody tr.skeleton td{padding:var( --wpd-table-cell-padding )}.skeleton-bar{display:block;height:12px;border-radius:3px;background:linear-gradient( 90deg,var( --wpd-table-skeleton-color,rgba( 0,0,0,0.06 ) ) 0%,var( --wpd-table-skeleton-highlight,rgba( 0,0,0,0.14 ) ) 50%,var( --wpd-table-skeleton-color,rgba( 0,0,0,0.06 ) ) 100% );background-size:200% 100%;animation:wpd-table-skeleton-pulse 1.4s ease-in-out infinite}@keyframes wpd-table-skeleton-pulse{0%{background-position:200% 50%}100%{background-position:-200% 50%}}@media ( prefers-reduced-motion:reduce ){.skeleton-bar{animation:none}}`,O="__wpd_expander__",H="__wpd_select__",V=class V extends S{constructor(){super(...arguments),this._data=[],this._columns=[],this._filters={},this._expanded=new Set,this._subTable=null,this._sort=null,this._selection=new Set,this._getRowId=(e,t)=>t,this._filterCache=new Map,this._paintScheduled=!1,this._stickyHeaderWarned=!1,this._stickyRaceWarned=!1,this._resizeObserver=null,this._stickyMicroScheduled=!1,this._stickyRafHandle=null,this._loadingDesyncWarned=!1,this._lastStickyIndex=-1}get data(){return this._data}set data(e){this._data=Array.isArray(e)?e.slice():[],this._expanded.clear(),this._schedulePaint()}get columns(){return this._columns}set columns(e){this._columns=Array.isArray(e)?e.slice():[];const t=new Set(this._columns.map(s=>s.key));for(const s of Object.keys(this._filters))t.has(s)||delete this._filters[s];for(const s of Array.from(this._filterCache.keys()))t.has(s)||this._filterCache.delete(s);this._sort&&!t.has(this._sort.key)&&(this._sort=null),this._schedulePaint()}get filters(){return{...this._filters}}set filters(e){this._filters=e?{...e}:{},this._schedulePaint()}get sort(){return this._sort?{...this._sort}:null}set sort(e){this._sort=e?{...e}:null,this._schedulePaint()}get selection(){return new Set(this._selection)}set selection(e){this._selection=new Set(e??[]),this._schedulePaint()}get selectedRows(){const e=[];return this._data.forEach((t,s)=>{this._selection.has(this._getRowId(t,s))&&e.push(t)}),e}get visibleRows(){return this._filteredRows().map(e=>e.row)}get getRowId(){return this._getRowId}set getRowId(e){this._getRowId=typeof e=="function"?e:(t,s)=>s,this._schedulePaint()}get subTable(){return this._subTable}set subTable(e){this._subTable=typeof e=="function"?e:null,this._expanded.clear(),this._schedulePaint()}get expanded(){return new Set(this._expanded)}set expanded(e){this._expanded=new Set(e??[]),this._schedulePaint()}expand(e){e<0||e>=this._data.length||this._expanded.has(e)||(this._expanded.add(e),this.emit("wpd-table-expand-change",{row:this._data[e],index:e,expanded:!0}),this._schedulePaint())}collapse(e){this._expanded.has(e)&&(this._expanded.delete(e),this.emit("wpd-table-expand-change",{row:this._data[e],index:e,expanded:!1}),this._schedulePaint())}expandAll(){if(!this._subTable)return;let e=!1;for(let t=0;t<this._data.length;t++)this._subTable(this._data[t],t)&&(this._expanded.has(t)||(this._expanded.add(t),e=!0));e&&this._schedulePaint()}collapseAll(){this._expanded.size!==0&&(this._expanded.clear(),this._schedulePaint())}isExpanded(e){return this._expanded.has(e)}clearFilters(){Object.keys(this._filters).length!==0&&(this._filters={},this.emit("wpd-table-filter-change",{filters:{}}),this._schedulePaint())}clearSort(){this._sort!==null&&(this._sort=null,this.emit("wpd-table-sort-change",{sort:null}),this._schedulePaint())}select(e){if(this._selection.has(e))return;const t=this._readSelectable(),s=t==="single"?Array.from(this._selection):[];t==="single"&&this._selection.clear(),this._selection.add(e),this._emitSelectionChange(),this._syncSelectionDom([e,...s])}deselect(e){this._selection.delete(e)&&(this._emitSelectionChange(),this._syncSelectionDom([e]))}selectAll(){if(this._readSelectable()==="multi"){for(const{row:e,index:t}of this._filteredRows())this._selection.add(this._getRowId(e,t));this._emitSelectionChange(),this._syncSelectionDom("all")}}clearSelection(){this._selection.size!==0&&(this._selection.clear(),this._emitSelectionChange(),this._syncSelectionDom("all"))}_syncSelectionDom(e){const t=this.shadowRoot;if(!t)return;const s=t.querySelector("tbody");if(!s)return;let i=null;if(e!=="all"){i=new Set;for(const a of e)i.add(String(a))}const r=s.querySelectorAll("tr[data-row-id]");for(const a of r){const d=a.dataset.rowId;if(d===void 0||i&&!i.has(d))continue;const l=Number(a.dataset.rowIndex);if(!Number.isFinite(l))continue;const p=this._data[l];if(p===void 0)continue;const c=this._getRowId(p,l),f=this._selection.has(c);a.classList.toggle("is-selected",f);const u=a.querySelector("input.select-row-checkbox");u&&u.checked!==f&&(u.checked=f)}const o=t.querySelector("thead .select-all-checkbox");if(o){const{total:a,selected:d}=this._visibleSelectionStats();o.checked=a>0&&d===a,o.indeterminate=d>0&&d<a}}scrollToRow(e){const t=this.shadowRoot;if(!t)return;const i=t.querySelectorAll("tbody tr:not(.subtable):not(.empty):not(.skeleton)")[e];i&&i.scrollIntoView({block:"nearest",inline:"nearest"})}connectedCallback(){super.connectedCallback(),this._schedulePaint()}disconnectedCallback(){this._resizeObserver?.disconnect(),this._resizeObserver=null,this._stickyRafHandle!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this._stickyRafHandle),this._stickyRafHandle=null)}recomputeLayout(){this._applyStickyOffsets(),this._measureHeaderHeight()}render(){return w`
117 + `:v``}
118 + `}};K.props=["placeholder","exclude","endpoint"],K.styles=[ts],K.help=void 0;let we=K;R("os-user-search",we);function os(){const e=window.openStationGamesConfig?.usersSearchUrl;if(e)return e;const s=window.wp?.os?.config?.restUrl||"/wp-json/";return tt(s,"desktop-mode/v1/games/users/search")}function ht(o){return new Promise(e=>{const t=document.createElement("os-modal");t.setAttribute("open",""),t.setAttribute("title",g("Send a challenge")),t.setAttribute("size","sm");const s=document.createElement("div");s.className="os-games__challenge-dialog";const n=document.createElement("p");n.className="os-games__challenge-summary",n.textContent=k(g("Challenge someone to beat your %1$s score of %2$s."),o.gameTitle,String(o.score)),s.appendChild(n);const i=document.createElement("os-user-search");i.setAttribute("placeholder",g("Find a player…")),i.setAttribute("endpoint",os()),s.appendChild(i);const r=document.createElement("div");r.className="os-games__challenge-picked",r.hidden=!0,s.appendChild(r),t.appendChild(s);const a=document.createElement("div");a.setAttribute("slot","footer"),a.className="os-games__challenge-footer";const l=document.createElement("os-button");l.setAttribute("variant","ghost"),l.textContent=g("Cancel");const d=document.createElement("os-button");d.setAttribute("variant","primary"),d.setAttribute("disabled",""),d.textContent=g("Send challenge"),a.append(l,d),t.appendChild(a);let u=null,c=!1;const f=()=>{t.remove(),e()},p=()=>{if(r.innerHTML="",!u){r.hidden=!0,d.setAttribute("disabled","");return}r.hidden=!1;const h=document.createElement("os-avatar");h.setAttribute("src",u.avatarUrl),h.setAttribute("name",u.name),h.setAttribute("size","sm"),h.setAttribute("user-id",String(u.id)),r.appendChild(h);const m=document.createElement("span");m.textContent=u.name,r.appendChild(m),d.removeAttribute("disabled")};i.addEventListener("os-user-pick",h=>{const m=h.detail?.user;m&&(u=m,p())}),l.addEventListener("click",f),t.addEventListener("os-modal-cancel",f),d.addEventListener("click",()=>{!u||c||(c=!0,d.setAttribute("disabled",""),Po({game:o.game,recipientId:u.id,score:o.score,meta:o.meta}).then(()=>{F({message:k(g("Challenge sent to %s."),u.name)}),f()}).catch(h=>{c=!1,d.removeAttribute("disabled"),F({message:h instanceof Error?h.message:g("Could not send the challenge.")})}))}),document.body.appendChild(t)})}const ss=_`:host{display:inline;color:inherit;font:inherit}`,re=new Set;let O=null;const ns=3e4;function is(){O===null&&(O=window.setInterval(()=>{for(const o of re)o.tick()},ns))}function rs(){O!==null&&re.size===0&&(window.clearInterval(O),O=null)}function as(o){if(!o)return null;const e=t=>{const s=new Date(t);return Number.isNaN(s.getTime())?null:s};return ls(o)?e(o):e(o.replace(" ","T")+"Z")}function ls(o){const e=Math.max(o.indexOf("T"),o.indexOf(" ")),t=e===-1?"":o.slice(e+1);return/(?:[Zz]|[+-]\d{2}:?\d{2})$/.test(t)}let Ce=null,Se=null;function pt(){return typeof navigator<"u"&&navigator.language||"en"}function cs(){return Ce||(Ce=new Intl.RelativeTimeFormat(pt(),{numeric:"auto"})),Ce}function ft(){return Se||(Se=new Intl.RelativeTimeFormat(pt(),{numeric:"always",style:"narrow"})),Se}function ds(o,e){const t=cs(),s=o.getTime()-e,n=Math.round(s/1e3),i=Math.abs;return i(n)<45?t.format(0,"second"):mt(t,n)}function mt(o,e){const t=Math.abs,s=Math.round(e/60);if(t(s)<45)return o.format(s,"minute");const n=Math.round(s/60);if(t(n)<22)return o.format(n,"hour");const i=Math.round(n/24);if(t(i)<26)return o.format(i,"day");const r=Math.round(i/30);if(t(r)<11)return o.format(r,"month");const a=Math.round(i/365);return o.format(a,"year")}function us(o,e){const t=Math.round((o.getTime()-e)/1e3),s=Math.abs;return s(t)<45?ft().format(0,"second"):s(t)>7*24*60*60?o.toLocaleDateString(void 0,{month:"short",day:"numeric"}):mt(ft(),t)}const V=class V extends E{connectedCallback(){super.connectedCallback(),re.add(this),is()}disconnectedCallback(){re.delete(this),rs()}tick(){this.requestUpdate()}render(){const e=this.datetime,t=as(e);if(!t)return v`<span>${e??""}</span>`;const s=Date.now(),n=this.hasAttribute("compact")?us(t,s):ds(t,s),i=t.toLocaleString();return v`<time datetime=${t.toISOString()} title=${i}
119 + >${n}</time
120 + >`}};V.props=["datetime","compact"],V.styles=[ss],V.help=void 0;let Ee=V;R("os-relative-time",Ee);const hs=_` ${Q} ${Ue}:host{display:block;--_bg:var( --os-ui-table-bg,var( --os-ui-surface,#fff ) );--_border:var( --os-ui-table-border,var( --os-ui-border,rgba( 0,0,0,0.08 ) ) );--_column-border:var( --os-ui-table-column-border,var( --os-ui-border-strong,rgba( 0,0,0,0.14 ) ) );--_header-bg:var( --os-ui-table-header-bg,var( --os-ui-surface-elevated,#f6f7f7 ) );--_row-hover:var( --os-ui-table-row-hover,var( --os-ui-hover,rgba( 0,0,0,0.04 ) ) );--_stripe:var( --os-ui-table-stripe,var( --os-ui-surface-subtle,rgba( 0,0,0,0.03 ) ) );--_cell-padding:var( --os-ui-table-cell-padding,8px 12px );--_font-size:var( --os-ui-table-font-size,13px );--_max-height:var( --os-ui-table-max-height,none );font-size:var( --_font-size );color:inherit}:host( [ hidden ] ){display:none}.scroll{position:relative;overflow:auto;max-height:var( --_max-height );border:1px solid var( --_border );border-radius:4px;background:var( --_bg )}table{width:100%;border-collapse:separate;border-spacing:0;background:var( --_bg )}thead th{text-align:start;font-weight:600;background-color:var( --_header-bg );background-image:var( --os-ui-table-header-bg-image,none );background-repeat:var( --os-ui-table-header-bg-image-repeat,repeat );background-size:var( --os-ui-table-header-bg-image-size,auto );background-position:var( --os-ui-table-header-bg-image-position,center );padding:var( --_cell-padding );border-bottom:1px solid var( --_border );white-space:nowrap}tbody td{padding:var( --_cell-padding );border-bottom:1px solid var( --_border );background-color:var( --_bg );vertical-align:middle}tbody tr:last-child td{border-bottom:0}:host( [ striped ] ) tbody tr:nth-child( odd ) td{background-image:linear-gradient( var( --_stripe ),var( --_stripe ) )}:host( [ hover ] ) tbody tr:hover td{background-image:linear-gradient( var( --_row-hover ),var( --_row-hover ) )}:host( [ hover ][ striped ] ) tbody tr:nth-child( odd ):hover td{background-image:linear-gradient( var( --_row-hover ),var( --_row-hover ) ),linear-gradient( var( --_stripe ),var( --_stripe ) )}:host( [ compact ] ){--os-ui-table-cell-padding:4px 8px;--os-ui-table-font-size:12px}:host( [ bordered ] ) thead th,:host( [ bordered ] ) tbody td{border-inline-end:1px solid var( --_column-border )}:host( [ bordered ] ) thead th:last-child,:host( [ bordered ] ) tbody td:last-child{border-inline-end:0}th.is-sticky,td.is-sticky{position:sticky;z-index:10}tbody td.is-sticky{background-color:var( --_bg )}thead th.is-sticky{background-color:var( --_header-bg );background-image:var( --os-ui-table-header-bg-image,none );background-repeat:var( --os-ui-table-header-bg-image-repeat,repeat );background-size:var( --os-ui-table-header-bg-image-size,auto );background-position:var( --os-ui-table-header-bg-image-position,center );z-index:30}:host( [ sticky-header ] ) thead th{position:sticky;top:0;z-index:20}:host( [ sticky-header ] ) thead tr.filter-row th{top:var( --os-ui-table-header-height,33px );z-index:20}:host( [ sticky-header ] ) thead th.is-sticky{z-index:40}:host( [ sticky-header ] ) thead tr.filter-row th.is-sticky{z-index:40}th.is-sticky-edge,td.is-sticky-edge{border-inline-end:var( --os-ui-table-sticky-edge,2px solid var( --_border ) )}.align-center{text-align:center}.align-end{text-align:end}.filter-row th{padding:4px 8px;background-color:var( --_header-bg );background-image:var( --os-ui-table-header-bg-image,none );background-repeat:var( --os-ui-table-header-bg-image-repeat,repeat );background-size:var( --os-ui-table-header-bg-image-size,auto );background-position:var( --os-ui-table-header-bg-image-position,center );border-bottom:1px solid var( --_border );font-weight:400}.filter-input,.filter-select{width:100%;min-width:60px;box-sizing:border-box;padding:4px 6px;font:inherit;color:inherit;background-color:var( --_bg );border:1px solid var( --_border );border-radius:3px}.filter-input:focus,.filter-select:focus{outline:none;border-color:var( --os-ui-accent,#2271b1 );box-shadow:var( --_holo-focus-field )}.expander{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;padding:0;border:0;background:transparent;color:inherit;cursor:pointer;border-radius:3px;font-size:11px;line-height:1}.expander:hover{background:var( --os-ui-hover,rgba( 0,0,0,0.06 ) )}td.col-expander,th.col-expander{width:36px;min-width:36px;padding-left:0;padding-right:0;text-align:center}tr.subtable td{padding:0;background-color:var( --_bg );background-image:linear-gradient( var( --_stripe ),var( --_stripe ) );border-bottom:1px solid var( --_border )}tr.subtable .subtable-inner{padding:8px 12px 8px 32px}tr.empty td{padding:24px;text-align:center;color:var( --os-ui-text-muted,var( --os-ui-fg-muted,rgba( 0,0,0,0.55 ) ) );font-style:italic}thead th.is-sortable{cursor:pointer;user-select:none}thead th.is-sortable:hover{background-image:linear-gradient( var( --_row-hover ),var( --_row-hover ) )}thead th.is-sortable:focus-visible{outline:none;box-shadow:inset 0 0 0 2px var( --os-ui-accent,#2271b1 )}.sort-indicator{font-size:10px;color:var( --os-ui-text-muted,var( --os-ui-fg-muted,rgba( 0,0,0,0.55 ) ) );margin-inline-start:2px}thead th.sort-asc .sort-indicator,thead th.sort-desc .sort-indicator{color:var( --wp-admin-theme-color,#2271b1 )}td.col-select,th.col-select{width:40px;min-width:40px;padding-left:0;padding-right:0;text-align:center}.select-all-checkbox,.select-row-checkbox{cursor:pointer;margin:0}tbody tr.is-selected td{background-color:color-mix( in srgb,var( --wp-admin-theme-color,#2271b1 ) 10%,var( --_bg ) );background-image:none}tbody tr.is-selected:hover td{background-color:color-mix( in srgb,var( --wp-admin-theme-color,#2271b1 ) 16%,var( --_bg ) )}tbody tr.is-selected td:first-child{box-shadow:inset 3px 0 0 0 var( --os-ui-accent,#2271b1 )}tbody:dir( rtl ) tr.is-selected td:first-child{box-shadow:inset -3px 0 0 0 var( --os-ui-accent,#2271b1 )}:host( [ stacked ] ) .scroll{border:0;border-radius:0}:host( [ stacked ] ) table,:host( [ stacked ] ) tbody{display:block;width:100%}:host( [ stacked ] ) colgroup,:host( [ stacked ] ) thead{display:none}:host( [ stacked ] ) tbody tr{display:flex;align-items:flex-start;gap:12px;padding:12px 14px;border-bottom:1px solid var( --_border );background-color:var( --_bg )}:host( [ stacked ] ) tbody tr:last-child{border-bottom:0}:host( [ stacked ] ) tbody td{display:block;padding:0;border:0;background-color:transparent;background-image:none;box-shadow:none;min-width:0;width:auto;vertical-align:baseline}:host( [ stacked ] ) tbody tr.is-selected td,:host( [ stacked ] ) tbody tr.is-selected:hover td,:host( [ stacked ][ striped ] ) tbody tr:nth-child( odd ) td,:host( [ stacked ][ hover ] ) tbody tr:hover td,:host( [ stacked ][ hover ][ striped ] ) tbody tr:nth-child( odd ):hover td,:host( [ stacked ][ bordered ] ) tbody td{padding:0;border:0;background-color:transparent;background-image:none;box-shadow:none}:host( [ stacked ][ hover ] ) tbody tr:hover{background-image:linear-gradient( var( --_row-hover ),var( --_row-hover ) )}:host( [ stacked ] ) tbody tr.is-selected,:host( [ stacked ] ) tbody tr.is-selected:hover{background-color:color-mix( in srgb,var( --wp-admin-theme-color,#2271b1 ) 10%,var( --_bg ) );background-image:none;box-shadow:inset 3px 0 0 0 var( --os-ui-accent,#2271b1 )}:host( [ stacked ] ) tbody:dir( rtl ) tr.is-selected{box-shadow:inset -3px 0 0 0 var( --os-ui-accent,#2271b1 )}:host( [ stacked ] ) tbody td.col-select,:host( [ stacked ] ) tbody td.col-expander{flex:0 0 auto;display:flex;align-items:center;justify-content:center;min-width:0}:host( [ stacked ] ) tbody td.col-select{width:44px;height:44px;margin:-11px 0 -11px -11px;cursor:pointer}:host( [ stacked ] ) .select-row-checkbox{width:22px;height:22px}:host( [ stacked ] ) tbody td.col-expander{width:28px;height:22px;margin-inline-start:-4px}:host( [ stacked ] ) tbody td.stack-body{flex:1 1 auto;display:flex;flex-direction:column;gap:4px;min-width:0}.stack-cell{display:flex;align-items:baseline;gap:6px;min-width:0;line-height:1.4}.stack-title{font-size:15px;font-weight:600;line-height:1.35}.stack-meta{font-size:13px}.stack-label{flex:0 0 auto;font-size:12px;color:var( --os-ui-text-muted,var( --os-ui-fg-muted,rgba( 0,0,0,0.55 ) ) )}.stack-label::after{content:'·';margin-inline-start:6px}.stack-value{flex:1 1 auto;min-width:0;display:flex;align-items:center;flex-wrap:wrap;gap:6px}.stack-actions{margin-block-start:6px}.stack-actions .stack-value{gap:8px}.stack-actions .stack-value>*{justify-content:flex-start;max-width:100%}:host( [ stacked ] ) tr.subtable,:host( [ stacked ] ) tr.empty{display:block;padding:0}:host( [ stacked ] ) tr.subtable td{background-image:linear-gradient( var( --_stripe ),var( --_stripe ) )}:host( [ stacked ] ) tr.subtable .subtable-inner{padding:8px 14px 12px}:host( [ stacked ] ) tr.empty td{padding:24px}:host( [ stacked ] ) tr.skeleton{display:block;padding:14px;border-bottom:1px solid var( --_border )}:host( [ stacked ] ) tr.skeleton td.stack-body{gap:8px}:host( [ stacked ] ) tr.skeleton .skeleton-bar:first-child{height:15px}tbody tr.skeleton td{padding:var( --_cell-padding )}.skeleton-bar{display:block;height:12px;border-radius:3px;background:linear-gradient( 90deg,var( --os-ui-table-skeleton-color,var( --os-ui-hover,rgba( 0,0,0,0.06 ) ) ) 0%,var( --os-ui-table-skeleton-highlight,var( --os-ui-hover,rgba( 0,0,0,0.14 ) ) ) 50%,var( --os-ui-table-skeleton-color,var( --os-ui-hover,rgba( 0,0,0,0.06 ) ) ) 100% );background-size:200% 100%;animation:os-table-skeleton-pulse 1.4s ease-in-out infinite}@keyframes os-table-skeleton-pulse{0%{background-position:200% 50%}100%{background-position:-200% 50%}}@media ( prefers-reduced-motion:reduce ){.skeleton-bar{animation:none}}`,z="__wpd_expander__",I="__wpd_select__",X=class X extends E{constructor(){super(...arguments),this._data=[],this._columns=[],this._filters={},this._expanded=new Set,this._subTable=null,this._sort=null,this._selection=new Set,this._getRowId=(e,t)=>t,this._filterCache=new Map,this._paintScheduled=!1,this._stacked=!1,this._stickyHeaderWarned=!1,this._stickyRaceWarned=!1,this._resizeObserver=null,this._stickyMicroScheduled=!1,this._stickyRafHandle=null,this._loadingDesyncWarned=!1,this._lastStickyIndex=-1}get data(){return this._data}set data(e){this._data=Array.isArray(e)?e.slice():[],this._expanded.clear(),this._schedulePaint()}get columns(){return this._columns}set columns(e){this._columns=Array.isArray(e)?e.slice():[];const t=new Set(this._columns.map(s=>s.key));for(const s of Object.keys(this._filters))t.has(s)||delete this._filters[s];for(const s of Array.from(this._filterCache.keys()))t.has(s)||this._filterCache.delete(s);this._sort&&!t.has(this._sort.key)&&(this._sort=null),this._schedulePaint()}get filters(){return{...this._filters}}set filters(e){this._filters=e?{...e}:{},this._schedulePaint()}get sort(){return this._sort?{...this._sort}:null}set sort(e){this._sort=e?{...e}:null,this._schedulePaint()}get selection(){return new Set(this._selection)}set selection(e){this._selection=new Set(e??[]),this._schedulePaint()}get selectedRows(){const e=[];return this._data.forEach((t,s)=>{this._selection.has(this._getRowId(t,s))&&e.push(t)}),e}get visibleRows(){return this._filteredRows().map(e=>e.row)}get getRowId(){return this._getRowId}set getRowId(e){this._getRowId=typeof e=="function"?e:(t,s)=>s,this._schedulePaint()}get subTable(){return this._subTable}set subTable(e){this._subTable=typeof e=="function"?e:null,this._expanded.clear(),this._schedulePaint()}get expanded(){return new Set(this._expanded)}set expanded(e){this._expanded=new Set(e??[]),this._schedulePaint()}expand(e){e<0||e>=this._data.length||this._expanded.has(e)||(this._expanded.add(e),this.emit("os-table-expand-change",{row:this._data[e],index:e,expanded:!0}),this._schedulePaint())}collapse(e){this._expanded.has(e)&&(this._expanded.delete(e),this.emit("os-table-expand-change",{row:this._data[e],index:e,expanded:!1}),this._schedulePaint())}expandAll(){if(!this._subTable)return;let e=!1;for(let t=0;t<this._data.length;t++)this._subTable(this._data[t],t)&&(this._expanded.has(t)||(this._expanded.add(t),e=!0));e&&this._schedulePaint()}collapseAll(){this._expanded.size!==0&&(this._expanded.clear(),this._schedulePaint())}isExpanded(e){return this._expanded.has(e)}clearFilters(){Object.keys(this._filters).length!==0&&(this._filters={},this.emit("os-table-filter-change",{filters:{}}),this._schedulePaint())}clearSort(){this._sort!==null&&(this._sort=null,this.emit("os-table-sort-change",{sort:null}),this._schedulePaint())}select(e){if(this._selection.has(e))return;const t=this._readSelectable(),s=t==="single"?Array.from(this._selection):[];t==="single"&&this._selection.clear(),this._selection.add(e),this._emitSelectionChange(),this._syncSelectionDom([e,...s])}deselect(e){this._selection.delete(e)&&(this._emitSelectionChange(),this._syncSelectionDom([e]))}selectAll(){if(this._readSelectable()==="multi"){for(const{row:e,index:t}of this._filteredRows())this._selection.add(this._getRowId(e,t));this._emitSelectionChange(),this._syncSelectionDom("all")}}clearSelection(){this._selection.size!==0&&(this._selection.clear(),this._emitSelectionChange(),this._syncSelectionDom("all"))}_syncSelectionDom(e){const t=this.shadowRoot;if(!t)return;const s=t.querySelector("tbody");if(!s)return;let n=null;if(e!=="all"){n=new Set;for(const a of e)n.add(String(a))}const i=s.querySelectorAll("tr[data-row-id]");for(const a of i){const l=a.dataset.rowId;if(l===void 0||n&&!n.has(l))continue;const d=Number(a.dataset.rowIndex);if(!Number.isFinite(d))continue;const u=this._data[d];if(u===void 0)continue;const c=this._getRowId(u,d),f=this._selection.has(c);a.classList.toggle("is-selected",f);const p=a.querySelector("input.select-row-checkbox");p&&p.checked!==f&&(p.checked=f)}const r=t.querySelector("thead .select-all-checkbox");if(r){const{total:a,selected:l}=this._visibleSelectionStats();r.checked=a>0&&l===a,r.indeterminate=l>0&&l<a}}scrollToRow(e){const t=this.shadowRoot;if(!t)return;const n=t.querySelectorAll("tbody tr:not(.subtable):not(.empty):not(.skeleton)")[e];n&&n.scrollIntoView({block:"nearest",inline:"nearest"})}connectedCallback(){super.connectedCallback(),this._schedulePaint()}disconnectedCallback(){this._resizeObserver?.disconnect(),this._resizeObserver=null,this._stickyRafHandle!==null&&typeof cancelAnimationFrame<"u"&&(cancelAnimationFrame(this._stickyRafHandle),this._stickyRafHandle=null)}recomputeLayout(){this._applyStickyOffsets(),this._measureHeaderHeight()}render(){return v`
110 121 <div class="scroll" part="scroll">
111 122 <table part="table">
112 123 <colgroup></colgroup>
113 124 <thead></thead>
@@ -113,5 +124,5 @@
113 124 <thead></thead>
114 125 <tbody></tbody>
115 126 </table>
116 127 </div>
117 - `}requestUpdate(){super.requestUpdate(),this._schedulePaint()}_schedulePaint(){this._paintScheduled||!this.isConnected||(this._paintScheduled=!0,queueMicrotask(()=>{this._paintScheduled=!1,this.isConnected&&this._paint()}))}_paint(){const e=this.shadowRoot;if(!e)return;e.querySelector("tbody")||K(this.render(),e);const t=e.querySelector("colgroup"),s=e.querySelector("thead"),i=e.querySelector("tbody");if(!t||!s||!i)return;const r=this._effectiveColumns(),o=this._readStickyColumns();this._lastStickyIndex=this._computeLastStickyIndex(r,o),this._paintColgroup(t,r),this._paintHead(s,r,o),this._paintBody(i,r,o),this._applyStickyOffsets(),this._measureHeaderHeight(),this._scheduleStickyOffsets(),this._maybeWarnStickyHeader(),this._maybeWarnLoadingDesync(i),this._ensureResizeObserver()}_maybeWarnLoadingDesync(e){this._loadingDesyncWarned||this.hasAttribute("loading")&&(e.querySelector("tr.skeleton")||(this._loadingDesyncWarned=!0,console.warn("[wpd-table] `loading` attribute is set but no skeleton rows rendered. Either attributeChangedCallback didn't route through requestUpdate (framework regression), or `loading` was set after the most recent paint and no follow-up trigger ran. Toggling `data` will force a paint as a workaround.")))}_scheduleStickyOffsets(){this._stickyMicroScheduled||(this._stickyMicroScheduled=!0,queueMicrotask(()=>{this._stickyMicroScheduled=!1,this.isConnected&&this._applyStickyOffsets()})),this._stickyRafHandle===null&&typeof requestAnimationFrame<"u"&&(this._stickyRafHandle=requestAnimationFrame(()=>{this._stickyRafHandle=null,this.isConnected&&(this._applyStickyOffsets(),this._measureHeaderHeight())}))}_ensureResizeObserver(){if(this._resizeObserver||typeof ResizeObserver>"u")return;const e=this.shadowRoot?.querySelector(".scroll");e&&(this._resizeObserver=new ResizeObserver(()=>{this.isConnected&&(this._applyStickyOffsets(),this._measureHeaderHeight(),this._stickyHeaderWarned=!1,this._maybeWarnStickyHeader())}),this._resizeObserver.observe(e),this._resizeObserver.observe(this))}_paintColgroup(e,t){const s=[];for(const i of t){const r=document.createElement("col");i.width&&(r.style.width=i.width),s.push(r)}e.replaceChildren(...s)}_paintHead(e,t,s){const i=document.createElement("tr");i.setAttribute("part","header-row");for(let d=0;d<t.length;d++)i.appendChild(this._buildHeaderCell(t[d],d,s));const r=e.querySelector(':scope > tr[part="header-row"]');r?e.replaceChild(i,r):e.insertBefore(i,e.firstChild);const o=t.some(d=>d.filter||Array.isArray(d.filterOptions)||typeof d.filterRender=="function");let a=e.querySelector(":scope > tr.filter-row");if(o){const d=[];for(let c=0;c<t.length;c++)d.push(this._buildFilterCell(t[c],c,s));a||(a=document.createElement("tr"),a.classList.add("filter-row"),a.setAttribute("part","filter-row"),e.appendChild(a));const l=Array.from(a.children);let p=l.length===d.length;if(p){for(let c=0;c<d.length;c++)if(l[c]!==d[c]){p=!1;break}}if(!p){const c=new Set(d);for(const f of d)a.appendChild(f);for(const f of Array.from(a.children))c.has(f)||a.removeChild(f)}}else a&&a.remove()}_buildHeaderCell(e,t,s){const i=document.createElement("th");if(i.setAttribute("scope","col"),i.dataset.key=e.key,this._applyCellClasses(i,e,t,s),e.minWidth&&(i.style.minWidth=e.minWidth),e.key===H){if(this._readSelectable()==="multi"){const o=document.createElement("input");o.type="checkbox",o.className="select-all-checkbox",o.setAttribute("data-noclick",""),o.setAttribute("aria-label","Select all rows");const{total:a,selected:d}=this._visibleSelectionStats();o.checked=a>0&&d===a,o.indeterminate=d>0&&d<a,o.addEventListener("change",()=>{o.checked?this.selectAll():this.clearSelection()}),i.appendChild(o)}return i}if(i.textContent=e.label??(e.key===O?"":e.key),e.sortable){i.classList.add("is-sortable");const r=this._sort?.key===e.key,o=document.createElement("span");o.className="sort-indicator";let a="";r&&(a=this._sort.direction==="asc"?" ▲":" ▼"),o.textContent=a,i.appendChild(o),r&&i.classList.add(this._sort.direction==="asc"?"sort-asc":"sort-desc"),i.addEventListener("click",()=>this._cycleSort(e.key))}return i}_buildFilterCell(e,t,s){const i=this._filterCache.get(e.key),r=Array.isArray(e.filterOptions),o=typeof e.filterRender=="function";let a;if(!e.filter&&!r&&!o||e.key===O||e.key===H?a="none":o?a="custom":e.filter==="select"||r?a="select":a="text",i&&i.kind===a){if(i.th.className="",this._applyCellClasses(i.th,e,t,s),a==="select"){const c=i.control,f=this._resolveFilterOptions(e),u=f.map(h=>h.value).join("|");u!==i.optionsKey?(this._populateSelect(c,f,this._filters[e.key]??""),i.optionsKey=u):c.value=this._filters[e.key]??""}else if(a==="text"){const c=i.control,f=this._filters[e.key]??"";c.value!==f&&c.ownerDocument.activeElement!==c&&(c.value=f)}else a==="custom"&&e.filterRender&&e.filterRender(i.th,{value:this._filters[e.key]??"",setValue:c=>this._onFilterChange(e.key,c),col:e});return i.th}const d=document.createElement("th");if(this._applyCellClasses(d,e,t,s),a==="none")return this._filterCache.set(e.key,{th:d,control:null,optionsKey:"",kind:"none"}),d;if(a==="custom"&&e.filterRender)return e.filterRender(d,{value:this._filters[e.key]??"",setValue:c=>this._onFilterChange(e.key,c),col:e}),this._filterCache.set(e.key,{th:d,control:null,optionsKey:"",kind:"custom"}),d;let l,p="";if(a==="select"){const c=document.createElement("select");c.classList.add("filter-select"),c.setAttribute("data-noclick",""),c.setAttribute("aria-label",`Filter ${e.label??e.key}`);const f=this._resolveFilterOptions(e);this._populateSelect(c,f,this._filters[e.key]??""),p=f.map(u=>u.value).join("|"),c.addEventListener("change",()=>{this._onFilterChange(e.key,c.value)}),l=c}else{const c=document.createElement("input");c.type="search",c.classList.add("filter-input"),c.setAttribute("data-noclick",""),c.setAttribute("placeholder","Filter…"),c.setAttribute("aria-label",`Filter ${e.label??e.key}`),c.value=this._filters[e.key]??"",c.addEventListener("input",()=>{this._onFilterChange(e.key,c.value)}),l=c}return d.appendChild(l),this._filterCache.set(e.key,{th:d,control:l,optionsKey:p,kind:a}),d}_populateSelect(e,t,s){e.replaceChildren();const i=document.createElement("option");i.value="",i.textContent="All",e.appendChild(i);for(const r of t){const o=document.createElement("option");o.value=r.value,o.textContent=r.label,r.value===s&&(o.selected=!0),e.appendChild(o)}e.value=s}_resolveFilterOptions(e){return Array.isArray(e.filterOptions)?e.filterOptions:this._uniqueValues(e.key).map(t=>({value:t,label:t}))}_paintBody(e,t,s){if(e.replaceChildren(),this.hasAttribute("loading")){const r=this._readLoadingRows();for(let o=0;o<r;o++)e.appendChild(this._buildSkeletonRow(t,o));return}const i=this._sortedRows(this._filteredRows());if(i.length===0){e.appendChild(this._buildEmptyRow(t.length));return}for(const{row:r,index:o}of i)if(e.appendChild(this._buildBodyRow(r,o,t,s)),this._expanded.has(o)&&this._subTable){const a=this._subTable(r,o);a&&e.appendChild(this._buildSubTableRow(a,t.length))}}_buildEmptyRow(e){const t=document.createElement("tr");t.classList.add("empty");const s=document.createElement("td");s.colSpan=e;const i=document.createElement("slot");return i.name="empty",i.textContent=this.getAttribute("empty")||"No data",s.appendChild(i),t.appendChild(s),t}_buildSkeletonRow(e,t){const s=document.createElement("tr");s.classList.add("skeleton"),s.setAttribute("aria-hidden","true");for(const i of e){const r=document.createElement("td"),o=document.createElement("span");o.className="skeleton-bar";const a=50+(t*7+s.children.length*13)%40;o.style.width=`${a}%`,r.appendChild(o),s.appendChild(r)}return s}_buildBodyRow(e,t,s,i){const r=document.createElement("tr");r.setAttribute("part","row"),r.dataset.rowIndex=String(t);const o=this._getRowId(e,t);r.dataset.rowId=String(o),this._selection.has(o)&&r.classList.add("is-selected"),r.addEventListener("click",a=>{this._onRowClick(e,t,a)});for(let a=0;a<s.length;a++)r.appendChild(this._buildBodyCell(s[a],a,e,t,i));return r}_buildBodyCell(e,t,s,i,r){const o=document.createElement("td");if(this._applyCellClasses(o,e,t,r),e.minWidth&&(o.style.minWidth=e.minWidth),e.key===H){const d=this._getRowId(s,i),l=document.createElement("input");return l.type="checkbox",l.className="select-row-checkbox",l.setAttribute("data-noclick",""),l.setAttribute("aria-label","Select row"),l.checked=this._selection.has(d),l.addEventListener("change",()=>{l.checked?this.select(d):this.deselect(d)}),o.appendChild(l),o}if(e.key===O){if(!(this._subTable?!!this._subTable(s,i):!1))return o;const l=this._expanded.has(i),p=document.createElement("button");return p.type="button",p.className="expander",p.setAttribute("data-noclick",""),p.setAttribute("aria-expanded",l?"true":"false"),p.setAttribute("aria-label",l?"Collapse row":"Expand row"),p.textContent=l?"▾":"▸",p.addEventListener("click",c=>{this._toggleRow(i,s,c)}),o.appendChild(p),o}const a=s[e.key];if(e.render){const d=e.render(a,s,i);this._mountCellContent(o,d)}else a!=null&&(o.textContent=String(a));return o}_buildSubTableRow(e,t){const s=document.createElement("tr");s.classList.add("subtable"),s.setAttribute("part","subtable-row");const i=document.createElement("td");i.colSpan=t;const r=document.createElement("div");if(r.classList.add("subtable-inner"),e instanceof Node)r.appendChild(e);else if(Je(e))K(e,r);else{const o=document.createElement("wpd-table");o.columns=e.columns,o.data=e.data,e.subTable&&(o.subTable=e.subTable),r.appendChild(o)}return i.appendChild(r),s.appendChild(i),s}_mountCellContent(e,t){if(typeof t=="string"){e.textContent=t;return}if(t instanceof Node){e.appendChild(t);return}Je(t)&&K(t,e)}_onFilterChange(e,t){t===""?delete this._filters[e]:this._filters[e]=t,this.emit("wpd-table-filter-change",{filters:{...this._filters}});const i=this.shadowRoot?.querySelector("tbody");if(i){const r=this._effectiveColumns(),o=this._readStickyColumns();this._lastStickyIndex=this._computeLastStickyIndex(r,o),this._paintBody(i,r,o),this._applyStickyOffsets()}}_onRowClick(e,t,s){const i=s.composedPath?.()??[];for(const r of i){if(r instanceof Element&&r.hasAttribute("data-noclick"))return;if(r===this)break}this.emit("wpd-table-row-click",{row:e,index:t,originalEvent:s})}_toggleRow(e,t,s){s.stopPropagation();const i=this._expanded.has(e);i?this._expanded.delete(e):this._expanded.add(e),this.emit("wpd-table-expand-change",{row:t,index:e,expanded:!i}),this._schedulePaint()}_cycleSort(e){!this._sort||this._sort.key!==e?this._sort={key:e,direction:"asc"}:this._sort.direction==="asc"?this._sort={key:e,direction:"desc"}:this._sort=null,this.emit("wpd-table-sort-change",{sort:this._sort?{...this._sort}:null}),this._schedulePaint()}_emitSelectionChange(){this.emit("wpd-table-selection-change",{selection:Array.from(this._selection),rows:this.selectedRows})}_filteredRows(){const e=[],t=Object.keys(this._filters).filter(s=>this._filters[s]!=="");for(let s=0;s<this._data.length;s++){const i=this._data[s];let r=!0;for(const o of t){const a=this._columns.find(c=>c.key===o);if(a&&typeof a.filterRender=="function")continue;const d=this._filters[o]??"",l=i[o],p=l==null?"":String(l);if(a?.filter==="select"){if(p!==d){r=!1;break}}else if(!p.toLowerCase().includes(d.toLowerCase())){r=!1;break}}r&&e.push({row:i,index:s})}return e}_sortedRows(e){if(!this._sort)return e;const t=this._columns.find(r=>r.key===this._sort.key);if(!t)return e;const s=this._sort.direction==="desc"?-1:1,i=e.slice();return i.sort((r,o)=>{const a=t.sortValue?t.sortValue(r.row,r.row[t.key]):r.row[t.key],d=t.sortValue?t.sortValue(o.row,o.row[t.key]):o.row[t.key];return Ss(a,d)*s}),i}_uniqueValues(e){const t=new Set;for(const s of this._data){const i=s[e];i!=null&&t.add(String(i))}return Array.from(t).sort()}_visibleSelectionStats(){let e=0,t=0;for(const{row:s,index:i}of this._filteredRows())e++,this._selection.has(this._getRowId(s,i))&&t++;return{total:e,selected:t}}_readStickyColumns(){const e=parseInt(this.getAttribute("sticky-columns")||"0",10);return Number.isFinite(e)&&e>0?e:0}_readLoadingRows(){const e=parseInt(this.getAttribute("loading-rows")||"5",10);return Number.isFinite(e)&&e>0?Math.min(e,100):5}_readSelectable(){const e=this.getAttribute("selectable");return e==="single"?"single":e==="multi"||e===""?"multi":null}_isStickyIndex(e,t,s){return s.sticky===!1?!1:s.sticky===!0?!0:e<t}_computeLastStickyIndex(e,t){let s=-1;for(let i=0;i<e.length;i++)this._isStickyIndex(i,t,e[i])&&(s=i);return s}_applyCellClasses(e,t,s,i){t.key===O&&e.classList.add("col-expander"),t.key===H&&e.classList.add("col-select"),t.align==="center"&&e.classList.add("align-center"),t.align==="end"&&e.classList.add("align-end"),this._isStickyIndex(s,i,t)&&(e.classList.add("is-sticky"),s===this._lastStickyIndex&&e.classList.add("is-sticky-edge"))}_effectiveColumns(){const e=[];return this._readSelectable()&&e.push({key:H,label:"",width:"40px",align:"center"}),this._subTable&&e.push({key:O,label:"",width:"36px",align:"center"}),e.push(...this._columns),e}_applyStickyOffsets(){const e=this.shadowRoot;if(!e)return;const t=e.querySelector("thead tr");if(!t)return;const s=Array.from(t.children),i=[];let r=0;for(let a=0;a<s.length;a++)i[a]=r,s[a].classList.contains("is-sticky")&&(r+=s[a].offsetWidth);e.querySelectorAll("thead tr, tbody tr:not(.subtable):not(.empty):not(.skeleton)").forEach(a=>{const d=Array.from(a.children);for(let l=0;l<d.length;l++)d[l].classList.contains("is-sticky")&&(d[l].style.insetInlineStart=`${i[l]}px`)}),this._maybeWarnStickyOffsetRace(s,i)}_maybeWarnStickyOffsetRace(e,t){if(this._stickyRaceWarned)return;const s=this._readStickyColumns();if(s<2)return;const i=Math.min(s-1,e.length-1);if(i<=0||t[i]!==0||this.offsetWidth===0)return;this._stickyRaceWarned=!0;const r=e[0]?.offsetWidth??0;console.warn(`[wpd-table] sticky-columns: column ${i} resolved to inset-inline-start: 0px while the host is visible. ths[0].offsetWidth was ${r}px at measurement time. Likely a layout race — call recomputeLayout() after the panel finishes its mount/transition, or wrap the assignment of \`data\` in a requestAnimationFrame.`)}_measureHeaderHeight(){const e=this.shadowRoot;if(!e)return;const t=e.querySelector("thead tr");if(!t)return;const s=t.offsetHeight;s>0&&this.style.setProperty("--wpd-table-header-height",`${s}px`)}_maybeWarnStickyHeader(){if(this._stickyHeaderWarned||!this.hasAttribute("sticky-header")||this.hasAttribute("loading")||this._data.length<8)return;const e=this.shadowRoot?.querySelector(".scroll");e&&e.offsetWidth!==0&&e.scrollHeight<=e.clientHeight+1&&(this._stickyHeaderWarned=!0,console.warn("[wpd-table] sticky-header is set but the table has no scroll container. Set --wpd-table-max-height on the host (or wrap it in a scrolling parent) so the header has something to stick to."))}};V.props=["stickyColumns","stickyHeader","striped","hover","compact","bordered","empty","loading","loadingRows","selectable"],V.styles=[Cs],V.help=void 0;let _e=V;function Je(n){return!!n&&n.__wpdHtml===!0}function Ss(n,e){if(n===e)return 0;if(n==null)return-1;if(e==null)return 1;if(typeof n=="number"&&typeof e=="number")return n-e;if(n instanceof Date&&e instanceof Date)return n.getTime()-e.getTime();const t=Number(n),s=Number(e);return Number.isFinite(t)&&Number.isFinite(s)?t-s:String(n).localeCompare(String(e))}E("wpd-table",_e);const Qe=25;function As(){const n=window.wp;return Number(n?.desktop?.config?.currentUserId)||0}function Es(n){const e=Math.max(0,Math.round(Number(n)||0)),t=Math.floor(e/60),s=e%60;return`${t}:${String(s).padStart(2,"0")}`}function $s(n){const e=[{key:"userName",label:b("Player"),render:(t,s)=>{const i=document.createElement("span");i.style.cssText="display:inline-flex;align-items:center;gap:8px;min-width:0;";const r=document.createElement("wpd-avatar");r.setAttribute("src",s.userAvatar),r.setAttribute("name",s.userName),r.setAttribute("size","xs"),r.setAttribute("user-id",String(s.userId)),i.appendChild(r);const o=document.createElement("span");return o.textContent=s.userName,i.appendChild(o),i}}];for(const t of n.scoreColumns)e.push({key:t.key,label:t.label,render:(s,i)=>{const r=t.key==="score"?i.score:i.meta[t.key];return r==null?"—":t.type==="time"?Es(r):String(r)}});return e.push({key:"createdAtMs",label:b("When"),render:(t,s)=>{const i=document.createElement("wpd-relative-time");return i.setAttribute("datetime",new Date(s.createdAtMs).toISOString()),i}}),e.push({key:"__actions",label:"",render:(t,s)=>{if(s.userId!==As())return"";const i=document.createElement("wpd-button");return i.setAttribute("variant","secondary"),i.setAttribute("size","sm"),i.textContent=b("Challenge…"),i.addEventListener("click",()=>{Ze({game:n.id,gameTitle:n.title,score:s.score,meta:s.meta})}),i}}),e}function Rs(n,e){n.innerHTML="";const t=document.createElement("div");t.className="desktop-mode-games__scoreboard-table",n.appendChild(t);const s=document.createElement("div");s.className="desktop-mode-games__pager",n.appendChild(s);let i=1,r=0,o=0,a=!1;const d=document.createElement("wpd-table");d.setAttribute("sticky-header",""),d.setAttribute("hover",""),d.setAttribute("striped","");const l=document.createElement("div");l.setAttribute("slot","empty"),l.className="desktop-mode-games__scoreboard-empty",l.textContent=b("No scores yet — be the first to play!"),d.appendChild(l),t.appendChild(d),d.columns=$s(e),d.data=[];const p=()=>{s.innerHTML="";const f=Math.max(1,Math.ceil(r/Qe));if(f<=1)return;const u=document.createElement("wpd-button");u.setAttribute("variant","ghost"),u.textContent=b("Previous"),i<=1&&u.setAttribute("disabled",""),u.addEventListener("click",()=>void c(i-1));const h=document.createElement("span");h.className="desktop-mode-games__pager-label",h.textContent=`${i} / ${f}`;const m=document.createElement("wpd-button");m.setAttribute("variant","ghost"),m.textContent=b("Next"),i>=f&&m.setAttribute("disabled",""),m.addEventListener("click",()=>void c(i+1)),s.append(u,h,m)},c=async f=>{const u=++o;d.setAttribute("loading","");try{const h=await je(e.id,{page:f,perPage:Qe});if(a||u!==o)return;i=f,r=h.total,d.data=h.scores}catch(h){typeof console<"u"&&console.error("[desktop-mode] scoreboard load failed:",h)}finally{!a&&u===o&&(d.removeAttribute("loading"),p())}};return c(1),()=>{a=!0}}const q=Oe("desktop-mode/games-challenges",()=>({rows:new Map,version:0,listeners:new Set}));function ye(n){const e=q.state;let t=!1;for(const s of n){if(!s||typeof s.id!="number")continue;const i=e.rows.get(s.id);(!i||i.updatedAtMs!==s.updatedAtMs)&&(e.rows.set(s.id,s),t=!0),s.updatedAtMs>e.version&&(e.version=s.updatedAtMs)}t&&Ls()}function Ns(n){return q.state.listeners.add(n),()=>{q.state.listeners.delete(n)}}function Ls(){for(const n of Array.from(q.state.listeners))try{n()}catch(e){typeof console<"u"&&console.error("[desktop-mode] challenges store listener threw:",e)}}function Ts(){return Array.from(q.state.rows.values()).sort((n,e)=>e.updatedAtMs-n.updatedAtMs)}function Is(n){return pe(n)?.title||n}async function Ps(n){const{challenge:e}=await ts(n.id);ye([e]),await Ve(n.game,{challenge:{id:n.id,scoreToBeat:n.scoreToBeat,scoreMeta:n.scoreMeta,challengerName:n.challengerName}})}function Ms(){const n=window.wp;return Number(n?.desktop?.config?.currentUserId)||0}function zs(n,e){const t=n.recipientId===e,s=t?n.challengerName:n.recipientName,i=Is(n.game),r=String(n.scoreToBeat);if(n.state==="pending")return y(b(t?"%1$s challenged you to %2$s — beat %3$s.":"Waiting for %1$s to accept your %2$s challenge (%3$s)."),s,i,r);if(n.state==="accepted")return t?y(b("You accepted — play %1$s and beat %2$s!"),i,r):y(b("%1$s accepted your %2$s challenge and is playing."),s,i);if(n.state==="declined")return y(b(t?"You declined %1$s’s %2$s challenge.":"%1$s declined your %2$s challenge."),s,i);const o=n.result==="beaten",a=String(n.resultScore??0);return t?y(b(o?"You beat the %1$s challenge: %2$s vs %3$s.":"You missed the %1$s challenge: %2$s vs %3$s."),i,a,r):y(b(o?"%1$s beat your score: %2$s vs %3$s.":"%1$s did not beat your score: %2$s vs %3$s."),s,a,r)}function Os(n,e){const t=n.recipientId===e,s=document.createElement("li");s.className=`desktop-mode-games__challenge desktop-mode-games__challenge--${n.state}`;const i=document.createElement("wpd-avatar"),r=t?n.challengerId:n.recipientId;i.setAttribute("src",t?n.challengerAvatar:n.recipientAvatar),i.setAttribute("name",t?n.challengerName:n.recipientName),i.setAttribute("size","sm"),i.setAttribute("user-id",String(r)),s.appendChild(i);const o=document.createElement("div");o.className="desktop-mode-games__challenge-main";const a=document.createElement("p");a.textContent=zs(n,e),o.appendChild(a);const d=document.createElement("wpd-relative-time");if(d.setAttribute("datetime",new Date(n.updatedAtMs).toISOString()),o.appendChild(d),s.appendChild(o),t&&n.state==="pending"){const l=document.createElement("div");l.className="desktop-mode-games__challenge-actions";const p=document.createElement("wpd-button");p.setAttribute("variant","primary"),p.setAttribute("size","sm"),p.textContent=b("Accept & Play"),p.addEventListener("click",()=>{p.setAttribute("disabled",""),Ps(n).catch(f=>{p.removeAttribute("disabled"),M({message:f instanceof Error?f.message:b("Could not accept the challenge.")})})}),l.appendChild(p);const c=document.createElement("wpd-button");c.setAttribute("variant","ghost"),c.setAttribute("size","sm"),c.textContent=b("Decline"),c.addEventListener("click",()=>{c.setAttribute("disabled",""),ss(n.id).then(({challenge:f})=>ye([f])).catch(f=>{c.removeAttribute("disabled"),M({message:f instanceof Error?f.message:b("Could not decline the challenge.")})})}),l.appendChild(c),s.appendChild(l)}return s}function Hs(n,e){n.innerHTML="";const t=document.createElement("ul");t.className="desktop-mode-games__challenge-list",n.appendChild(t);const s=Ms(),i=()=>{t.innerHTML="";const o=Ts().filter(a=>!e||a.game===e);if(o.length===0){const a=document.createElement("wpd-empty-state");a.setAttribute("icon","awards"),a.setAttribute("heading",b("No challenges yet")),a.setAttribute("description",b("Press Challenge to throw down one of your scores, or pick a row from the scoreboard.")),t.appendChild(a);return}for(const a of o)t.appendChild(Os(a,s))},r=Ns(i);return i(),Qt({box:"all"}).then(({challenges:o})=>ye(o)).catch(o=>{typeof console<"u"&&console.error("[desktop-mode] challenges resync failed:",o)}),r}const qs="[data-desktop-mode-games-root]",Ds="[data-desktop-mode-games-grid]",Fs="[data-desktop-mode-games-detail]";function Us(){const n=window.wp;return Number(n?.desktop?.config?.currentUserId)||0}function et(n){if(n.startsWith("data:")||/^https?:\/\//.test(n)){const t=document.createElement("img");return t.src=n,t.alt="",t.className="desktop-mode-games__icon-img",t}const e=document.createElement("span");return e.className=`dashicons ${n||"dashicons-admin-generic"} desktop-mode-games__icon-dashicon`,e.setAttribute("aria-hidden","true"),e}function Gs(n){const e=n.querySelector(qs),t=n.querySelector(Ds),s=n.querySelector(Fs);if(!e||!t||!s)return;const i=[];let r=[],o=null;const a=()=>{for(const u of r)try{u()}catch{}r=[]},d=async u=>{const h=Us(),g=(await je(u.id,{perPage:1,userId:h})).scores[0];if(!g){M({message:y(b("Play %s first — you need a score to challenge with."),u.title)});return}await Ze({game:u.id,gameTitle:u.title,score:g.score,meta:g.meta})},l=u=>{a(),s.hidden=!1,s.innerHTML="";const h=document.createElement("div");h.className="desktop-mode-games__hero";const m=document.createElement("div");m.className="desktop-mode-games__hero-visual",m.appendChild(et(u.icon)),h.appendChild(m);const g=document.createElement("div");g.className="desktop-mode-games__hero-info";const k=document.createElement("h2");if(k.className="desktop-mode-games__hero-title",k.textContent=u.title,g.appendChild(k),u.description){const C=document.createElement("p");C.className="desktop-mode-games__hero-desc",C.textContent=u.description,g.appendChild(C)}const _=document.createElement("div");_.className="desktop-mode-games__hero-playtime",_.hidden=!0,g.appendChild(_);let x=!1;r.push(()=>{x=!0});const I=(C,re)=>{const L=document.createElement("span");L.className="desktop-mode-games__playtime-stat";const xe=document.createElement("span");xe.className="desktop-mode-games__playtime-label",xe.textContent=C,L.appendChild(xe);const Ce=document.createElement("span");return Ce.className="desktop-mode-games__playtime-value",Ce.textContent=re,L.appendChild(Ce),L};Zt().then(C=>{const re=Number(C.playtime[u.id])||0;if(x||re<1)return;const L=os(C.daily?.[u.id]??{},C.today,14);L>0&&_.appendChild(I(b("Play time (last two weeks)"),Be(L))),_.appendChild(I(b("Play time (total)"),Be(re))),_.hidden=!1}).catch(()=>{}),h.appendChild(g);const se=document.createElement("div");se.className="desktop-mode-games__hero-actions";const N=document.createElement("wpd-button");N.setAttribute("variant","primary"),N.setAttribute("size","lg"),N.textContent=b("Play"),N.addEventListener("click",()=>{N.setAttribute("disabled",""),Ve(u.id).catch(C=>{typeof console<"u"&&console.error("[desktop-mode] game launch failed:",C)}).finally(()=>{N.removeAttribute("disabled")})}),se.appendChild(N);const P=document.createElement("wpd-button");P.setAttribute("variant","secondary"),P.textContent=b("Challenge…"),P.addEventListener("click",()=>{P.setAttribute("disabled",""),d(u).finally(()=>{P.removeAttribute("disabled")})}),se.appendChild(P),h.appendChild(se),s.appendChild(h);const ne=document.createElement("section");ne.className="desktop-mode-games__section";const ve=document.createElement("h3");ve.className="desktop-mode-games__section-heading",ve.textContent=b("Scoreboard"),ne.appendChild(ve);const tt=document.createElement("div");ne.appendChild(tt),s.appendChild(ne),r.push(Rs(tt,u));const ie=document.createElement("section");ie.className="desktop-mode-games__section";const ke=document.createElement("h3");ke.className="desktop-mode-games__section-heading",ke.textContent=b("Challenges"),ie.appendChild(ke);const st=document.createElement("div");ie.appendChild(st),s.appendChild(ie),r.push(Hs(st,u.id))},p=u=>{const h=pe(u);if(h){o=u;for(const m of Array.from(t.querySelectorAll("[data-game-id]"))){const g=m.getAttribute("data-game-id")===u;m.classList.toggle("desktop-mode-games__tile--selected",g),m.setAttribute("aria-selected",g?"true":"false")}l(h)}},c=u=>{const h=document.createElement("button");h.type="button",h.className="desktop-mode-games__tile",h.setAttribute("data-game-id",u.id),h.setAttribute("role","option"),h.setAttribute("aria-selected","false");const m=document.createElement("span");m.className="desktop-mode-games__tile-visual",m.appendChild(et(u.icon)),h.appendChild(m);const g=document.createElement("span");return g.className="desktop-mode-games__tile-title",g.textContent=u.title,h.appendChild(g),h.addEventListener("click",()=>p(u.id)),h},f=()=>{t.innerHTML="";const u=qe();if(u.length===0){const m=document.createElement("wpd-empty-state");m.setAttribute("icon","games"),m.setAttribute("heading",b("No games installed")),m.setAttribute("description",b("Plugins can add games with desktop_mode_register_game().")),t.appendChild(m),a(),s.hidden=!0,s.innerHTML="",o=null;return}for(const m of u)t.appendChild(c(m));const h=o&&u.some(m=>m.id===o)?o:u[0].id;p(h)};return f(),i.push(Dt(f)),()=>{a();for(const u of i)try{u()}catch{}}}const js=window.desktopModeNativeWindows??(window.desktopModeNativeWindows={});js["desktop-mode-games"]=Gs})();
128 + `}requestUpdate(){super.requestUpdate(),this._schedulePaint()}_schedulePaint(){this._paintScheduled||!this.isConnected||(this._paintScheduled=!0,queueMicrotask(()=>{this._paintScheduled=!1,this.isConnected&&this._paint()}))}_paint(){const e=this.shadowRoot;if(!e)return;e.querySelector("tbody")||Y(this.render(),e);const t=e.querySelector("colgroup"),s=e.querySelector("thead"),n=e.querySelector("tbody");if(!t||!s||!n)return;const i=this._effectiveColumns();this._stacked=this.hasAttribute("stacked");const r=this._readStickyColumns();this._lastStickyIndex=this._computeLastStickyIndex(i,r),this._paintColgroup(t,i),this._paintHead(s,i,r),this._paintBody(n,i,r),this._applyStickyOffsets(),this._measureHeaderHeight(),this._scheduleStickyOffsets(),this._maybeWarnStickyHeader(),this._maybeWarnLoadingDesync(n),this._ensureResizeObserver()}_maybeWarnLoadingDesync(e){this._loadingDesyncWarned||this.hasAttribute("loading")&&(e.querySelector("tr.skeleton")||(this._loadingDesyncWarned=!0,console.warn("[os-table] `loading` attribute is set but no skeleton rows rendered. Either attributeChangedCallback didn't route through requestUpdate (framework regression), or `loading` was set after the most recent paint and no follow-up trigger ran. Toggling `data` will force a paint as a workaround.")))}_scheduleStickyOffsets(){this._stickyMicroScheduled||(this._stickyMicroScheduled=!0,queueMicrotask(()=>{this._stickyMicroScheduled=!1,this.isConnected&&this._applyStickyOffsets()})),this._stickyRafHandle===null&&typeof requestAnimationFrame<"u"&&(this._stickyRafHandle=requestAnimationFrame(()=>{this._stickyRafHandle=null,this.isConnected&&(this._applyStickyOffsets(),this._measureHeaderHeight())}))}_ensureResizeObserver(){if(this._resizeObserver||typeof ResizeObserver>"u")return;const e=this.shadowRoot?.querySelector(".scroll");e&&(this._resizeObserver=new ResizeObserver(()=>{this.isConnected&&(this._applyStickyOffsets(),this._measureHeaderHeight(),this._stickyHeaderWarned=!1,this._maybeWarnStickyHeader())}),this._resizeObserver.observe(e),this._resizeObserver.observe(this))}_paintColgroup(e,t){const s=[];for(const n of t){const i=document.createElement("col");n.width&&(i.style.width=n.width),s.push(i)}e.replaceChildren(...s)}_paintHead(e,t,s){const n=document.createElement("tr");n.setAttribute("part","header-row");for(let l=0;l<t.length;l++)n.appendChild(this._buildHeaderCell(t[l],l,s));const i=e.querySelector(':scope > tr[part="header-row"]');i?e.replaceChild(n,i):e.insertBefore(n,e.firstChild);const r=t.some(l=>l.filter||Array.isArray(l.filterOptions)||typeof l.filterRender=="function");let a=e.querySelector(":scope > tr.filter-row");if(r){const l=[];for(let c=0;c<t.length;c++)l.push(this._buildFilterCell(t[c],c,s));a||(a=document.createElement("tr"),a.classList.add("filter-row"),a.setAttribute("part","filter-row"),e.appendChild(a));const d=Array.from(a.children);let u=d.length===l.length;if(u){for(let c=0;c<l.length;c++)if(d[c]!==l[c]){u=!1;break}}if(!u){const c=new Set(l);for(const f of l)a.appendChild(f);for(const f of Array.from(a.children))c.has(f)||a.removeChild(f)}}else a&&a.remove()}_buildHeaderCell(e,t,s){const n=document.createElement("th");if(n.setAttribute("scope","col"),n.dataset.key=e.key,this._applyCellClasses(n,e,t,s),e.minWidth&&(n.style.minWidth=e.minWidth),e.key===I){if(this._readSelectable()==="multi"){const r=document.createElement("input");r.type="checkbox",r.className="select-all-checkbox",r.setAttribute("data-noclick",""),r.setAttribute("aria-label","Select all rows");const{total:a,selected:l}=this._visibleSelectionStats();r.checked=a>0&&l===a,r.indeterminate=l>0&&l<a,r.addEventListener("change",()=>{r.checked?this.selectAll():this.clearSelection()}),n.appendChild(r)}return n}if(n.textContent=e.label??(e.key===z?"":e.key),e.sortable){n.classList.add("is-sortable");const i=this._sort?.key===e.key,r=document.createElement("span");r.className="sort-indicator";let a="";i&&(a=this._sort.direction==="asc"?" ▲":" ▼"),r.textContent=a,n.appendChild(r),i&&n.classList.add(this._sort.direction==="asc"?"sort-asc":"sort-desc"),n.addEventListener("click",()=>this._cycleSort(e.key))}return n}_buildFilterCell(e,t,s){const n=this._filterCache.get(e.key),i=Array.isArray(e.filterOptions),r=typeof e.filterRender=="function";let a;if(!e.filter&&!i&&!r||e.key===z||e.key===I?a="none":r?a="custom":e.filter==="select"||i?a="select":a="text",n&&n.kind===a){if(n.th.className="",this._applyCellClasses(n.th,e,t,s),a==="select"){const c=n.control,f=this._resolveFilterOptions(e),p=f.map(h=>h.value).join("|");p!==n.optionsKey?(this._populateSelect(c,f,this._filters[e.key]??""),n.optionsKey=p):c.value=this._filters[e.key]??""}else if(a==="text"){const c=n.control,f=this._filters[e.key]??"";c.value!==f&&c.ownerDocument.activeElement!==c&&(c.value=f)}else a==="custom"&&e.filterRender&&e.filterRender(n.th,{value:this._filters[e.key]??"",setValue:c=>this._onFilterChange(e.key,c),col:e});return n.th}const l=document.createElement("th");if(this._applyCellClasses(l,e,t,s),a==="none")return this._filterCache.set(e.key,{th:l,control:null,optionsKey:"",kind:"none"}),l;if(a==="custom"&&e.filterRender)return e.filterRender(l,{value:this._filters[e.key]??"",setValue:c=>this._onFilterChange(e.key,c),col:e}),this._filterCache.set(e.key,{th:l,control:null,optionsKey:"",kind:"custom"}),l;let d,u="";if(a==="select"){const c=document.createElement("select");c.classList.add("filter-select"),c.setAttribute("data-noclick",""),c.setAttribute("aria-label",`Filter ${e.label??e.key}`);const f=this._resolveFilterOptions(e);this._populateSelect(c,f,this._filters[e.key]??""),u=f.map(p=>p.value).join("|"),c.addEventListener("change",()=>{this._onFilterChange(e.key,c.value)}),d=c}else{const c=document.createElement("input");c.type="search",c.classList.add("filter-input"),c.setAttribute("data-noclick",""),c.setAttribute("placeholder","Filter…"),c.setAttribute("aria-label",`Filter ${e.label??e.key}`),c.value=this._filters[e.key]??"",c.addEventListener("input",()=>{this._onFilterChange(e.key,c.value)}),d=c}return l.appendChild(d),this._filterCache.set(e.key,{th:l,control:d,optionsKey:u,kind:a}),l}_populateSelect(e,t,s){e.replaceChildren();const n=document.createElement("option");n.value="",n.textContent="All",e.appendChild(n);for(const i of t){const r=document.createElement("option");r.value=i.value,r.textContent=i.label,i.value===s&&(r.selected=!0),e.appendChild(r)}e.value=s}_resolveFilterOptions(e){return Array.isArray(e.filterOptions)?e.filterOptions:this._uniqueValues(e.key).map(t=>({value:t,label:t}))}_paintBody(e,t,s){if(e.replaceChildren(),this.hasAttribute("loading")){const i=this._readLoadingRows();for(let r=0;r<i;r++)e.appendChild(this._buildSkeletonRow(t,r));return}const n=this._sortedRows(this._filteredRows());if(n.length===0){e.appendChild(this._buildEmptyRow(t.length));return}for(const{row:i,index:r}of n)if(e.appendChild(this._stacked?this._buildStackedRow(i,r,t):this._buildBodyRow(i,r,t,s)),this._expanded.has(r)&&this._subTable){const a=this._subTable(i,r);a&&e.appendChild(this._buildSubTableRow(a,t.length))}}_buildEmptyRow(e){const t=document.createElement("tr");t.classList.add("empty");const s=document.createElement("td");s.colSpan=e;const n=document.createElement("slot");return n.name="empty",n.textContent=this.getAttribute("empty")||"No data",s.appendChild(n),t.appendChild(s),t}_buildSkeletonRow(e,t){const s=document.createElement("tr");if(s.classList.add("skeleton"),s.setAttribute("aria-hidden","true"),this._stacked){s.classList.add("stack-row");const n=document.createElement("td");n.className="stack-body",n.colSpan=Math.max(1,e.length);for(const i of[55+t*7%25,30+t*11%15]){const r=document.createElement("span");r.className="skeleton-bar",r.style.width=`${i}%`,n.appendChild(r)}return s.appendChild(n),s}for(const n of e){const i=document.createElement("td"),r=document.createElement("span");r.className="skeleton-bar";const a=50+(t*7+s.children.length*13)%40;r.style.width=`${a}%`,i.appendChild(r),s.appendChild(i)}return s}_buildBodyRow(e,t,s,n){const i=document.createElement("tr");i.setAttribute("part","row"),i.dataset.rowIndex=String(t);const r=this._getRowId(e,t);i.dataset.rowId=String(r),this._selection.has(r)&&i.classList.add("is-selected"),i.addEventListener("click",a=>{this._onRowClick(e,t,a)});for(let a=0;a<s.length;a++)i.appendChild(this._buildBodyCell(s[a],a,e,t,n));return i}_buildStackedRow(e,t,s){const n=document.createElement("tr");n.setAttribute("part","row"),n.classList.add("stack-row"),n.dataset.rowIndex=String(t);const i=this._getRowId(e,t);n.dataset.rowId=String(i),this._selection.has(i)&&n.classList.add("is-selected"),n.addEventListener("click",d=>{this._onRowClick(e,t,d)});const r=document.createElement("td");r.className="stack-body";let a=0,l=0;for(let d=0;d<s.length;d++){const u=s[d];if(u.key===I||u.key===z){n.appendChild(this._buildBodyCell(u,d,e,t,0));continue}l++;const c=ps(u,a++);if(c==="hidden")continue;const f=document.createElement("div");if(f.className=`stack-cell stack-${c}`,f.dataset.key=u.key,c==="meta"&&u.label){const b=document.createElement("span");b.className="stack-label",b.textContent=u.label,f.appendChild(b)}const p=document.createElement("span");p.className="stack-value";const h=e[u.key],m=ae(h);u.render?this._mountCellContent(p,u.render(h,e,t)):m!==null?p.appendChild(this._slotFor(m)):h!=null&&(p.textContent=String(h)),f.appendChild(p),r.appendChild(f)}return r.colSpan=Math.max(1,l),n.appendChild(r),n}_buildBodyCell(e,t,s,n,i){const r=document.createElement("td");if(this._applyCellClasses(r,e,t,i),e.minWidth&&(r.style.minWidth=e.minWidth),e.key===I){const d=this._getRowId(s,n),u=document.createElement("input");return u.type="checkbox",u.className="select-row-checkbox",u.setAttribute("data-noclick",""),u.setAttribute("aria-label","Select row"),u.checked=this._selection.has(d),u.addEventListener("change",()=>{u.checked?this.select(d):this.deselect(d)}),r.appendChild(u),this._stacked&&(r.setAttribute("data-noclick",""),r.addEventListener("click",c=>{c.target===r&&(u.checked=!u.checked,u.dispatchEvent(new Event("change")))})),r}if(e.key===z){if(!(this._subTable?!!this._subTable(s,n):!1))return r;const u=this._expanded.has(n),c=document.createElement("button");return c.type="button",c.className="expander",c.setAttribute("data-noclick",""),c.setAttribute("aria-expanded",u?"true":"false"),c.setAttribute("aria-label",u?"Collapse row":"Expand row"),c.textContent=u?"▾":"▸",c.addEventListener("click",f=>{this._toggleRow(n,s,f)}),r.appendChild(c),r}const a=s[e.key],l=ae(a);if(e.render){const d=e.render(a,s,n);this._mountCellContent(r,d)}else l!==null?r.appendChild(this._slotFor(l)):a!=null&&(r.textContent=String(a));return r}_slotFor(e){const t=document.createElement("slot");return t.name=e,t}_buildSubTableRow(e,t){const s=document.createElement("tr");s.classList.add("subtable"),s.setAttribute("part","subtable-row");const n=document.createElement("td");n.colSpan=t;const i=document.createElement("div");if(i.classList.add("subtable-inner"),e instanceof Node)i.appendChild(e);else if(bt(e))Y(e,i);else{const r=document.createElement("os-table");r.columns=e.columns,r.data=e.data,e.subTable&&(r.subTable=e.subTable),i.appendChild(r)}return n.appendChild(i),s.appendChild(n),s}_mountCellContent(e,t){if(typeof t=="string"){e.textContent=t;return}if(t instanceof Node){e.appendChild(t);return}bt(t)&&Y(t,e)}_onFilterChange(e,t){t===""?delete this._filters[e]:this._filters[e]=t,this.emit("os-table-filter-change",{filters:{...this._filters}});const n=this.shadowRoot?.querySelector("tbody");if(n){const i=this._effectiveColumns(),r=this._readStickyColumns();this._lastStickyIndex=this._computeLastStickyIndex(i,r),this._paintBody(n,i,r),this._applyStickyOffsets()}}_onRowClick(e,t,s){const n=s.composedPath?.()??[];for(const i of n){if(i instanceof Element&&i.hasAttribute("data-noclick"))return;if(i===this)break}this.emit("os-table-row-click",{row:e,index:t,originalEvent:s})}_toggleRow(e,t,s){s.stopPropagation();const n=this._expanded.has(e);n?this._expanded.delete(e):this._expanded.add(e),this.emit("os-table-expand-change",{row:t,index:e,expanded:!n}),this._schedulePaint()}_cycleSort(e){!this._sort||this._sort.key!==e?this._sort={key:e,direction:"asc"}:this._sort.direction==="asc"?this._sort={key:e,direction:"desc"}:this._sort=null,this.emit("os-table-sort-change",{sort:this._sort?{...this._sort}:null}),this._schedulePaint()}_emitSelectionChange(){this.emit("os-table-selection-change",{selection:Array.from(this._selection),rows:this.selectedRows})}_filteredRows(){const e=[],t=Object.keys(this._filters).filter(s=>this._filters[s]!=="");for(let s=0;s<this._data.length;s++){const n=this._data[s];let i=!0;for(const r of t){const a=this._columns.find(c=>c.key===r);if(a&&typeof a.filterRender=="function")continue;const l=this._filters[r]??"",d=n[r],u=$e(d);if(a?.filter==="select"){if(u!==l){i=!1;break}}else if(!u.toLowerCase().includes(l.toLowerCase())){i=!1;break}}i&&e.push({row:n,index:s})}return e}_sortedRows(e){if(!this._sort)return e;const t=this._columns.find(i=>i.key===this._sort.key);if(!t)return e;const s=this._sort.direction==="desc"?-1:1,n=e.slice();return n.sort((i,r)=>{const a=i.row[t.key],l=r.row[t.key],d=t.sortValue?t.sortValue(i.row,a):gt(a),u=t.sortValue?t.sortValue(r.row,l):gt(l);return fs(d,u)*s}),n}_uniqueValues(e){const t=new Set;for(const s of this._data){const n=s[e];n!=null&&t.add($e(n))}return Array.from(t).sort()}_visibleSelectionStats(){let e=0,t=0;for(const{row:s,index:n}of this._filteredRows())e++,this._selection.has(this._getRowId(s,n))&&t++;return{total:e,selected:t}}_readStickyColumns(){const e=parseInt(this.getAttribute("sticky-columns")||"0",10);return Number.isFinite(e)&&e>0?e:0}_readLoadingRows(){const e=parseInt(this.getAttribute("loading-rows")||"5",10);return Number.isFinite(e)&&e>0?Math.min(e,100):5}_readSelectable(){const e=this.getAttribute("selectable");return e==="single"?"single":e==="multi"||e===""?"multi":null}_isStickyIndex(e,t,s){return this._stacked||s.sticky===!1?!1:s.sticky===!0?!0:e<t}_computeLastStickyIndex(e,t){let s=-1;for(let n=0;n<e.length;n++)this._isStickyIndex(n,t,e[n])&&(s=n);return s}_applyCellClasses(e,t,s,n){t.key===z&&e.classList.add("col-expander"),t.key===I&&e.classList.add("col-select"),t.align==="center"&&e.classList.add("align-center"),t.align==="end"&&e.classList.add("align-end"),this._isStickyIndex(s,n,t)&&(e.classList.add("is-sticky"),s===this._lastStickyIndex&&e.classList.add("is-sticky-edge"))}_effectiveColumns(){const e=[];return this._readSelectable()&&e.push({key:I,label:"",width:"40px",align:"center"}),this._subTable&&e.push({key:z,label:"",width:"36px",align:"center"}),e.push(...this._columns),e}_applyStickyOffsets(){const e=this.shadowRoot;if(!e)return;const t=e.querySelector("thead tr");if(!t)return;const s=Array.from(t.children),n=[];let i=0;for(let a=0;a<s.length;a++)n[a]=i,s[a].classList.contains("is-sticky")&&(i+=s[a].offsetWidth);e.querySelectorAll("thead tr, tbody tr:not(.subtable):not(.empty):not(.skeleton)").forEach(a=>{const l=Array.from(a.children);for(let d=0;d<l.length;d++)l[d].classList.contains("is-sticky")&&(l[d].style.insetInlineStart=`${n[d]}px`)}),this._maybeWarnStickyOffsetRace(s,n)}_maybeWarnStickyOffsetRace(e,t){if(this._stickyRaceWarned)return;const s=this._readStickyColumns();if(s<2)return;const n=Math.min(s-1,e.length-1);if(n<=0||t[n]!==0||this.offsetWidth===0)return;this._stickyRaceWarned=!0;const i=e[0]?.offsetWidth??0;console.warn(`[os-table] sticky-columns: column ${n} resolved to inset-inline-start: 0px while the host is visible. ths[0].offsetWidth was ${i}px at measurement time. Likely a layout race — call recomputeLayout() after the panel finishes its mount/transition, or wrap the assignment of \`data\` in a requestAnimationFrame.`)}_measureHeaderHeight(){const e=this.shadowRoot;if(!e)return;const t=e.querySelector("thead tr");if(!t)return;const s=t.offsetHeight;s>0&&this.style.setProperty("--os-ui-table-header-height",`${s}px`)}_maybeWarnStickyHeader(){if(this._stickyHeaderWarned||!this.hasAttribute("sticky-header")||this.hasAttribute("loading")||this._data.length<8)return;const e=this.shadowRoot?.querySelector(".scroll");e&&e.offsetWidth!==0&&e.scrollHeight<=e.clientHeight+1&&(this._stickyHeaderWarned=!0,console.warn("[os-table] sticky-header is set but the table has no scroll container. Set --os-ui-table-max-height on the host (or wrap it in a scrolling parent) so the header has something to stick to."))}};X.props=["stickyColumns","stickyHeader","striped","hover","compact","bordered","empty","loading","loadingRows","selectable","stacked"],X.styles=[hs],X.help=void 0;let Ae=X;function bt(o){return!!o&&o.__wpdHtml===!0}function ps(o,e){return o.stack?o.stack:e===0?"title":o.label?"meta":"actions"}function ae(o){return o&&typeof o=="object"&&typeof o.slot=="string"?o.slot:null}function $e(o){if(o==null)return"";if(ae(o)!==null){const e=o.text;return e==null?"":String(e)}return String(o)}function gt(o){return ae(o)!==null?$e(o):o}function fs(o,e){if(o===e)return 0;if(o==null)return-1;if(e==null)return 1;if(typeof o=="number"&&typeof e=="number")return o-e;if(o instanceof Date&&e instanceof Date)return o.getTime()-e.getTime();const t=Number(o),s=Number(e);return Number.isFinite(t)&&Number.isFinite(s)?t-s:String(o).localeCompare(String(e))}R("os-table",Ae);const vt=25;function ms(){const o=window.wp;return Number(o?.os?.config?.currentUserId)||0}function bs(o){const e=Math.max(0,Math.round(Number(o)||0)),t=Math.floor(e/60),s=e%60;return`${t}:${String(s).padStart(2,"0")}`}function gs(o){const e=[{key:"userName",label:g("Player"),render:(t,s)=>{const n=document.createElement("span");n.style.cssText="display:inline-flex;align-items:center;gap:8px;min-width:0;";const i=document.createElement("os-avatar");i.setAttribute("src",s.userAvatar),i.setAttribute("name",s.userName),i.setAttribute("size","xs"),i.setAttribute("user-id",String(s.userId)),n.appendChild(i);const r=document.createElement("span");return r.textContent=s.userName,n.appendChild(r),n}}];for(const t of o.scoreColumns)e.push({key:t.key,label:t.label,render:(s,n)=>{const i=t.key==="score"?n.score:n.meta[t.key];return i==null?"—":t.type==="time"?bs(i):String(i)}});return e.push({key:"createdAtMs",label:g("When"),render:(t,s)=>{const n=document.createElement("os-relative-time");return n.setAttribute("datetime",new Date(s.createdAtMs).toISOString()),n}}),e.push({key:"__actions",label:"",render:(t,s)=>{if(s.userId!==ms())return"";const n=document.createElement("os-button");return n.setAttribute("variant","secondary"),n.setAttribute("size","sm"),n.textContent=g("Challenge…"),n.addEventListener("click",()=>{ht({game:o.id,gameTitle:o.title,score:s.score,meta:s.meta})}),n}}),e}function vs(o,e){o.innerHTML="";const t=document.createElement("div");t.className="os-games__scoreboard-table",o.appendChild(t);const s=document.createElement("div");s.className="os-games__pager",o.appendChild(s);let n=1,i=0,r=0,a=!1;const l=document.createElement("os-table");l.setAttribute("sticky-header",""),l.setAttribute("hover",""),l.setAttribute("striped","");const d=document.createElement("div");d.setAttribute("slot","empty"),d.className="os-games__scoreboard-empty",d.textContent=g("No scores yet — be the first to play!"),l.appendChild(d),t.appendChild(l),l.columns=gs(e),l.data=[];const u=()=>{s.innerHTML="";const p=Math.max(1,Math.ceil(i/vt));if(p<=1)return;const h=document.createElement("os-button");h.setAttribute("variant","ghost"),h.textContent=g("Previous"),n<=1&&h.setAttribute("disabled",""),h.addEventListener("click",()=>void c(n-1));const m=document.createElement("span");m.className="os-games__pager-label",m.textContent=`${n} / ${p}`;const b=document.createElement("os-button");b.setAttribute("variant","ghost"),b.textContent=g("Next"),n>=p&&b.setAttribute("disabled",""),b.addEventListener("click",()=>void c(n+1)),s.append(h,m,b)},c=async p=>{const h=++r;l.setAttribute("loading","");try{const m=await it(e.id,{page:p,perPage:vt});if(a||h!==r)return;n=p,i=m.total,l.data=m.scores}catch(m){typeof console<"u"&&console.error("[openstation] scoreboard load failed:",m)}finally{!a&&h===r&&(l.removeAttribute("loading"),u())}},f=be.subscribe("os/game-score-recorded",p=>{a||p?.game!==e.id||c(n)});return c(1),()=>{a=!0,f()}}ve("desktop-mode/heartbeat-bus",()=>({suppliers:new Map,subscribers:new Map,booted:!1}));function _s(o){return ye(o)?.title||o}async function ys(o){const{challenge:e}=await Ho(o.id);ie([e]),await lt(o.game,{challenge:{id:o.id,scoreToBeat:o.scoreToBeat,scoreMeta:o.scoreMeta,challengerName:o.challengerName}})}function ks(){const o=window.wp;return Number(o?.os?.config?.currentUserId)||0}function xs(o,e){const t=o.recipientId===e,s=t?o.challengerName:o.recipientName,n=_s(o.game),i=String(o.scoreToBeat);if(o.state==="pending")return k(g(t?"%1$s challenged you to %2$s — beat %3$s.":"Waiting for %1$s to accept your %2$s challenge (%3$s)."),s,n,i);if(o.state==="accepted")return t?k(g("You accepted — play %1$s and beat %2$s!"),n,i):k(g("%1$s accepted your %2$s challenge and is playing."),s,n);if(o.state==="declined")return k(g(t?"You declined %1$s’s %2$s challenge.":"%1$s declined your %2$s challenge."),s,n);const r=o.result==="beaten",a=String(o.resultScore??0);return t?k(g(r?"You beat the %1$s challenge: %2$s vs %3$s.":"You missed the %1$s challenge: %2$s vs %3$s."),n,a,i):k(g(r?"%1$s beat your score: %2$s vs %3$s.":"%1$s did not beat your score: %2$s vs %3$s."),s,a,i)}function ws(o,e){const t=o.recipientId===e,s=document.createElement("li");s.className=`os-games__challenge os-games__challenge--${o.state}`;const n=document.createElement("os-avatar"),i=t?o.challengerId:o.recipientId;n.setAttribute("src",t?o.challengerAvatar:o.recipientAvatar),n.setAttribute("name",t?o.challengerName:o.recipientName),n.setAttribute("size","sm"),n.setAttribute("user-id",String(i)),s.appendChild(n);const r=document.createElement("div");r.className="os-games__challenge-main";const a=document.createElement("p");a.textContent=xs(o,e),r.appendChild(a);const l=document.createElement("os-relative-time");if(l.setAttribute("datetime",new Date(o.updatedAtMs).toISOString()),r.appendChild(l),s.appendChild(r),t&&o.state==="pending"){const d=document.createElement("div");d.className="os-games__challenge-actions";const u=document.createElement("os-button");u.setAttribute("variant","primary"),u.setAttribute("size","sm"),u.textContent=g("Accept & Play"),u.addEventListener("click",()=>{u.setAttribute("disabled",""),ys(o).catch(f=>{u.removeAttribute("disabled"),F({message:f instanceof Error?f.message:g("Could not accept the challenge.")})})}),d.appendChild(u);const c=document.createElement("os-button");c.setAttribute("variant","ghost"),c.setAttribute("size","sm"),c.textContent=g("Decline"),c.addEventListener("click",()=>{c.setAttribute("disabled",""),Fo(o.id).then(({challenge:f})=>ie([f])).catch(f=>{c.removeAttribute("disabled"),F({message:f instanceof Error?f.message:g("Could not decline the challenge.")})})}),d.appendChild(c),s.appendChild(d)}return s}function Cs(o,e){o.innerHTML="";const t=document.createElement("ul");t.className="os-games__challenge-list",o.appendChild(t);const s=ks(),n=()=>{t.innerHTML="";const r=Go().filter(a=>!e||a.game===e);if(r.length===0){const a=document.createElement("os-empty-state");a.setAttribute("icon","awards"),a.setAttribute("heading",g("No challenges yet")),a.setAttribute("description",g("Press Challenge to throw down one of your scores, or pick a row from the scoreboard.")),t.appendChild(a);return}for(const a of r)t.appendChild(ws(a,s))},i=Wo(n);return n(),Mo({box:"all"}).then(({challenges:r})=>ie(r)).catch(r=>{typeof console<"u"&&console.error("[openstation] challenges resync failed:",r)}),i}const Ss="[data-os-games-root]",Es="[data-os-games-grid]",As="[data-os-games-detail]";function $s(){const o=window.wp;return Number(o?.os?.config?.currentUserId)||0}function _t(o){if(o.startsWith("data:")||/^https?:\/\//.test(o)){const t=document.createElement("img");return t.src=o,t.alt="",t.className="os-games__icon-img",t}const e=document.createElement("span");return e.className=`dashicons ${o||"dashicons-admin-generic"} os-games__icon-dashicon`,e.setAttribute("aria-hidden","true"),e}function Rs(o){const e=o.querySelector(Ss),t=o.querySelector(Es),s=o.querySelector(As);if(!e||!t||!s)return;const n=[];let i=[],r=null;const a=()=>{for(const p of i)try{p()}catch{}i=[]},l=async p=>{const h=$s(),b=(await it(p.id,{perPage:1,userId:h})).scores[0];if(!b){F({message:k(g("Play %s first — you need a score to challenge with."),p.title)});return}await ht({game:p.id,gameTitle:p.title,score:b.score,meta:b.meta})},d=p=>{a(),s.hidden=!1,s.innerHTML="";const h=document.createElement("div");h.className="os-games__hero";const m=document.createElement("div");m.className="os-games__hero-visual",m.appendChild(_t(p.icon)),h.appendChild(m);const b=document.createElement("div");b.className="os-games__hero-info";const w=document.createElement("h2");if(w.className="os-games__hero-title",w.textContent=p.title,b.appendChild(w),p.description){const S=document.createElement("p");S.className="os-games__hero-desc",S.textContent=p.description,b.appendChild(S)}const y=document.createElement("div");y.className="os-games__hero-playtime",y.hidden=!0,b.appendChild(y);let C=!1;i.push(()=>{C=!0});const M=(S,ue)=>{const L=document.createElement("span");L.className="os-games__playtime-stat";const Te=document.createElement("span");Te.className="os-games__playtime-label",Te.textContent=S,L.appendChild(Te);const Le=document.createElement("span");return Le.className="os-games__playtime-value",Le.textContent=ue,L.appendChild(Le),L};zo().then(S=>{const ue=Number(S.playtime[p.id])||0;if(C||ue<1)return;const L=Uo(S.daily?.[p.id]??{},S.today,14);L>0&&y.appendChild(M(g("Play time (last two weeks)"),rt(L))),y.appendChild(M(g("Play time (total)"),rt(ue))),y.hidden=!1}).catch(()=>{}),h.appendChild(b);const le=document.createElement("div");le.className="os-games__hero-actions";const T=document.createElement("os-button");T.setAttribute("variant","primary"),T.setAttribute("size","lg"),T.textContent=g("Play"),T.addEventListener("click",()=>{T.setAttribute("disabled",""),lt(p.id).catch(S=>{typeof console<"u"&&console.error("[openstation] game launch failed:",S)}).finally(()=>{T.removeAttribute("disabled")})}),le.appendChild(T);const P=document.createElement("os-button");P.setAttribute("variant","secondary"),P.textContent=g("Challenge…"),P.addEventListener("click",()=>{P.setAttribute("disabled",""),l(p).finally(()=>{P.removeAttribute("disabled")})}),le.appendChild(P),h.appendChild(le),s.appendChild(h);const ce=document.createElement("section");ce.className="os-games__section";const Re=document.createElement("h3");Re.className="os-games__section-heading",Re.textContent=g("Scoreboard"),ce.appendChild(Re);const yt=document.createElement("div");ce.appendChild(yt),s.appendChild(ce),i.push(vs(yt,p));const de=document.createElement("section");de.className="os-games__section";const Ne=document.createElement("h3");Ne.className="os-games__section-heading",Ne.textContent=g("Challenges"),de.appendChild(Ne);const kt=document.createElement("div");de.appendChild(kt),s.appendChild(de),i.push(Cs(kt,p.id))},u=p=>{const h=ye(p);if(h){r=p;for(const m of Array.from(t.querySelectorAll("[data-game-id]"))){const b=m.getAttribute("data-game-id")===p;m.classList.toggle("os-games__tile--selected",b),m.setAttribute("aria-selected",b?"true":"false")}d(h)}},c=p=>{const h=document.createElement("button");h.type="button",h.className="os-games__tile",h.setAttribute("data-game-id",p.id),h.setAttribute("role","option"),h.setAttribute("aria-selected","false");const m=document.createElement("span");m.className="os-games__tile-visual",m.appendChild(_t(p.icon)),h.appendChild(m);const b=document.createElement("span");return b.className="os-games__tile-title",b.textContent=p.title,h.appendChild(b),h.addEventListener("click",()=>u(p.id)),h},f=()=>{t.innerHTML="";const p=Je();if(p.length===0){const m=document.createElement("os-empty-state");m.setAttribute("icon","games"),m.setAttribute("heading",g("No games installed")),m.setAttribute("description",g("Plugins can add games with openstation_register_game().")),t.appendChild(m),a(),s.hidden=!0,s.innerHTML="",r=null;return}for(const m of p)t.appendChild(c(m));const h=r&&p.some(m=>m.id===r)?r:p[0].id;u(h)};return f(),n.push(vo(f)),()=>{a();for(const p of n)try{p()}catch{}}}const Ns=window.openStationNativeWindows??(window.openStationNativeWindows={});Ns["desktop-mode-games"]=Rs})();