| @@ -1,5 +1,5 @@ | ||
| 1 | -(function(){"use strict";function v(o,...e){return{__wpdHtml:!0,strings:o,values:e}}function gt(o){return!!o&&o.__wpdHtml===!0}const vt="$$wpd$$",x=/\$\$wpd\$\$(\d+)\$\$/g;function _t(o){let e=o[0];for(let t=1;t<o.length;t++)e+=`${vt}${t-1}$$`+o[t];return e}const Ne=new WeakMap;function Te(o){const e=Ne.get(o);if(e)return e;const t=document.createElement("template");t.innerHTML=_t(o);const s=[],n=(a,l)=>{if(a.nodeType===Node.ELEMENT_NODE){const d=a;for(const m of Array.from(d.attributes)){const u=m.name,p=m.value,f=u[0];if(x.test(p))if(x.lastIndex=0,f==="@"){const b=x.exec(p);x.lastIndex=0,s.push({path:l,kind:"event",name:u.slice(1),valueIndex:b?Number(b[1]):0}),d.removeAttribute(u)}else if(f==="."){const b=x.exec(p);x.lastIndex=0,s.push({path:l,kind:"prop",name:u.slice(1),valueIndex:b?Number(b[1]):0}),d.removeAttribute(u)}else if(f==="?"){const b=x.exec(p);x.lastIndex=0,s.push({path:l,kind:"bool",name:u.slice(1),valueIndex:b?Number(b[1]):0}),d.removeAttribute(u)}else{const b=[],y=[];let w=0,S;for(x.lastIndex=0;(S=x.exec(p))!==null;)b.push(p.slice(w,S.index)),y.push(Number(S[1])),w=S.index+S[0].length;b.push(p.slice(w)),s.push({path:l,kind:"attr",name:u,template:b,valueIndices:y}),d.setAttribute(u,"")}}}const c=Array.from(a.childNodes);let h=0;for(let d=0;d<c.length;d++){const m=c[d],u=d+h;if(m.nodeType===Node.TEXT_NODE){const p=m.textContent||"";if(!x.test(p)){x.lastIndex=0;continue}x.lastIndex=0;const f=m.parentNode;let b=0,y;const w=[],S=[];for(x.lastIndex=0;(y=x.exec(p))!==null;){y.index>b&&w.push(document.createTextNode(p.slice(b,y.index)));const I=document.createTextNode("");w.push(I),S.push({path:[...l,u+w.length-1],kind:"node",valueIndex:Number(y[1])}),b=y.index+y[0].length}b<p.length&&w.push(document.createTextNode(p.slice(b)));for(const I of w)f.insertBefore(I,m);f.removeChild(m),h+=w.length-1,s.push(...S)}else n(m,[...l,u])}};n(t.content,[]);const r={template:t,buildParts:a=>{const l=[];for(const c of s){let h=a;for(const d of c.path)h=h.childNodes[d];c.kind==="node"?l.push({kind:"node",valueIndex:c.valueIndex,child:{anchor:h,state:null}}):c.kind==="attr"?l.push({kind:"attr",element:h,name:c.name,template:c.template,valueIndices:c.valueIndices}):c.kind==="event"?l.push({kind:"event",valueIndex:c.valueIndex,element:h,name:c.name}):c.kind==="prop"?l.push({kind:"prop",valueIndex:c.valueIndex,element:h,name:c.name}):c.kind==="bool"&&l.push({kind:"bool",valueIndex:c.valueIndex,element:h,name:c.name})}return l}};return Ne.set(o,r),r}const Le=new WeakMap;function yt(o,e){for(const t of o.nodes)if(t.parentNode!==e)return!1;return!0}function X(o,e){const t=Le.get(e);if(t&&t.strings===o.strings&&yt(t,e)){Y(t.parts,o.values);return}const s=Te(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),Y(i,o.values),Le.set(e,{strings:o.strings,parts:i,nodes:r})}function Y(o,e){for(const t of o)if(t.kind==="node")de(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+=Ie(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 de(o,e){if(e==null||e===!1){o.state&&(N(o.state),o.state=null);return}if(Array.isArray(e)){St(o,e);return}if(gt(e)){xt(o,e);return}if(e instanceof Node){wt(o,e);return}kt(o,Ie(e))}function wt(o,e){const t=o.state;t?.shape==="node"&&t.node===e||(t&&N(t),Z(o,[e]),o.state={shape:"node",node:e})}function kt(o,e){const t=o.state;if(t?.shape==="text"){t.text!==e&&(t.node.textContent=e,t.text=e);return}t&&N(t);const s=document.createTextNode(e);Z(o,[s]),o.state={shape:"text",node:s,text:e}}function xt(o,e){const t=o.state;if(t?.shape==="template"&&t.strings===e.strings){Y(t.parts,e.values);return}t&&N(t);const s=Te(e.strings),n=s.template.content.cloneNode(!0),i=s.buildParts(n),r=Array.from(n.childNodes);Z(o,[n]),Y(i,e.values),o.state={shape:"template",strings:e.strings,parts:i,nodes:r}}function St(o,e){const t=o.state;if(t?.shape==="array"&&t.entries.length===e.length){for(let n=0;n<e.length;n++)de(t.entries[n],e[n]);return}t&&N(t);const s=[];for(const n of e){const i=document.createTextNode("");Z(o,[i]);const r={anchor:i,state:null};de(r,n),s.push(r)}o.state={shape:"array",entries:s}}function Z(o,e){const t=o.anchor.parentNode;if(t)for(const s of e)t.insertBefore(s,o.anchor)}function N(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&&(N(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&&N(e.state),e.anchor.remove()}function Ie(o){return o==null||o===!1?"":String(o)}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(ze)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,t,s){if(t===s)return;const n=Ct(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=ze(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&&X(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(!R._lightStylesAdopted.has(e)){R._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)}}}};R.props=[],R.styles=[],R.shadow=!0,R._lightStylesAdopted=new WeakSet;let A=R;function $(o,e){customElements.get(o)||customElements.define(o,e)}function ze(o){return o.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function Ct(o){return o.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}const At=(()=>{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(At){const s=new CSSStyleSheet;return s.replaceSync(t),{__wpdCss:!0,sheet:s,cssText:t}}return{__wpdCss:!0,sheet:null,cssText:t}}const J=_`: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 ) )}`,Et=_` .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%}}`,Pe=_` .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%}}`,Me=_` .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}}`,He=_` .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}}`,Fe=_` .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}}`,$t=_` .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%}}`,Rt=_` .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}}`,Nt=_` 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}}`,qe=_` 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-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-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-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}}`,De=_` @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}}`;_` ${J} ${Et} ${Pe} ${Me} ${He} ${Fe} ${$t} ${Rt} ${Nt} ${qe} ${De} `;const Tt=_` ${J} ${Pe} ${Me} ${He} ${Fe} ${De}: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-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 )}}`,O=class O extends A{render(){const e=this.disabled!==null,t=this.busy!==null,s=this.type||"button";return v` | |
| 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 | 4 | class="os-holo-edge os-holo-sheen" |
| 5 | 5 | type=${s} |
| @@ -4,8 +4,9 @@ | ||
| 4 | 4 | class="os-holo-edge os-holo-sheen" |
| 5 | 5 | type=${s} |
| 6 | 6 | ?disabled=${e||t} |
| 7 | 7 | aria-busy=${t?"true":"false"} |
| 8 | + aria-label=${n} | |
| 8 | 9 | > |
| 9 | 10 | ${t?v`<span class="os-button__spinner" aria-hidden="true"></span>`:""} |
| 10 | 11 | <slot></slot> |
| 11 | 12 | <!-- |
| @@ -17,15 +18,15 @@ | ||
| 17 | 18 | --> |
| 18 | 19 | <span class="os-holo-glint" aria-hidden="true"></span> |
| 19 | 20 | <span class="os-holo-ring" aria-hidden="true"></span> |
| 20 | 21 | </button> |
| 21 | - `}};O.props=["variant","disabled","type","busy","fill-cell"],O.styles=[Tt],O.help=void 0;let ue=O;$("os-button",ue);const Lt=_`: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 Q=null;function It(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 Oe(){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=It(a);l&&o.set(r[1],l)}}return o}function zt(o){Q||(Q=Oe());const e=o.startsWith("dashicons-")?o.slice(10):o;return Q.get(e)??null}function Pt(){Q=Oe()}let Ue=!1;function Mt(){if(Ue||typeof window>"u")return;Ue=!0;const o=()=>{Pt()};document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",o,{once:!0}),window.addEventListener("load",o,{once:!0})}Mt();const U=class U extends A{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=zt(t);return n?v`<span | |
| 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 | |
| 22 | 23 | class="os-icon__glyph os-icon__glyph--char dashicons dashicons-${t}" |
| 23 | 24 | aria-hidden="true" |
| 24 | 25 | >${n}</span>`:v`<span |
| 25 | 26 | class="os-icon__glyph dashicons dashicons-${t}" |
| 26 | 27 | aria-hidden="true" |
| 27 | - ></span>`}};U.props=["name","size"],U.styles=[Lt],U.help=void 0;let he=U;$("os-icon",he);const Ht=_`: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}`,W=class W extends A{render(){const e=this.icon||"",t=this.heading||"",s=this.description||"";return v` | |
| 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` | |
| 28 | 29 | ${e?v`<os-icon |
| 29 | 30 | class="os-empty-state__icon" |
| 30 | 31 | name=${e} |
| 31 | 32 | size="28" |
| @@ -35,14 +36,14 @@ | ||
| 35 | 36 | <div class="os-empty-state__cta"> |
| 36 | 37 | <slot name="cta"></slot> |
| 37 | 38 | </div> |
| 38 | 39 | <slot></slot> |
| 39 | - `}};W.props=["icon","heading","description"],W.styles=[Ht],W.help=void 0;let pe=W;$("os-empty-state",pe);const Ft="desktop-mode";function We(){return window.wp?.i18n}function g(o,e=Ft){return We()?.__(o,e)??o}function k(o,...e){const t=We()?.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 ee(){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 qt(o,e,t,s){ee().addAction(o,e,t,s)}function Dt(o,e){return ee().removeAction(o,e)}function Ge(o,e,...t){return ee().applyFilters(o,e,...t)}function Ot(o,...e){ee().doAction(o,...e)}const Ut={GAMES:"os.games"},Wt="os.activity.";function fe(o){return Wt+String(o).replace(/[^a-zA-Z0-9_.-]/g,".")}let Gt=0;const me={publish(o,e){Ot(fe(o),e)},subscribe(o,e){const t=`os/activity-sub/${++Gt}`,s=fe(o);qt(s,t,i=>e(i));let n=!1;return()=>{n||(n=!0,Dt(s,t))}},filter(o,e,...t){return Ge(fe(o),e,...t)}};let be=null;function te(){return!!window.openStationShellOverlays}function jt(o){return new Promise((e,t)=>{const s=document.querySelector('script[data-os-shell-overlays="1"]'),n=()=>{if(te()){e();return}t(new Error("[openstation] shell-overlays bundle loaded but did not set `window.openStationShellOverlays`."))};if(s){te()?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 Bt(o){return te()||!o?Promise.resolve():(be||(be=jt(o)),be)}function Vt(){return window.openStationConfig?.shellOverlaysBundleUrl??""}function Kt(o,e){const t=Vt();if(te()||!t){e();return}Bt(t).then(()=>{o()&&e()}).catch(s=>{typeof console<"u"&&console.warn("[openstation] shell-overlays failed to load; menu/dialog suppressed:",s)})}const Xt=4e3,Yt=200,Zt=1200;function P(o){const e=me.filter("os/toast-requested",{...o});if(!e||e.cancel===!0)return()=>{};let t=!1,s=null;return Kt(()=>!t,()=>{s=Jt(e)}),()=>{t=!0,s&&s()}}function Jt(o){const e=oo(),t=document.createElement("os-toast");t.textContent=o.message,o.action&&(t.setAttribute("action",o.action.label),t.addEventListener("os-toast-action",()=>{o.action?.onClick(),l()})),o.dismissible&&(t.setAttribute("dismissible",""),t.addEventListener("os-toast-dismiss",()=>{o.onDismiss?.(),l()})),e.appendChild(t);let s=!1,n=null,i=o.duration??Xt,r=0;const a=()=>{n!==null&&(window.clearTimeout(n),n=null)},l=()=>{s||(s=!0,a(),to(t),t.setAttribute("state","out"),window.setTimeout(()=>{t.remove(),eo()},Yt))},c=()=>{s||o.persistent||n!==null||(r=Date.now(),n=window.setTimeout(l,i))},h=()=>{n!==null&&(i=Math.max(0,i-(Date.now()-r)),a())};return requestAnimationFrame(()=>{t.setAttribute("state","in")}),t.addEventListener("os-toast-hold",d=>{if(d.detail?.held){h();return}i=Math.max(i,Zt),c()}),Qt(t),c(),me.publish("os/toast-shown",{...o}),l}let oe=null,M=0;function je(o){const e=o.target;e instanceof HTMLElement&&(e.closest("os-toast-container")||(oe=e))}function Qt(o){M===0&&document.addEventListener("focusin",je,!0),M+=1;const e=o.ownerDocument,t=e.activeElement;t instanceof HTMLElement&&t!==e.body&&!t.closest("os-toast-container")&&(oe=t)}function eo(){M=Math.max(0,M-1),M===0&&document.removeEventListener("focusin",je,!0)}function to(o){const e=o.ownerDocument.activeElement;e!==o&&!o.contains(e)||oe?.isConnected===!0&&oe.focus()}function oo(){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 Be(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 so 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 no(o,e,t){if(e.length!==0)throw new so(o,e,t)}const Ve="__openStationSharedStores";function io(){const o=window;let e=o[Ve];return e||(e=new Map,o[Ve]=e),e}function Ke(o,e){const t=io();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 Xe=Ke("desktop-mode/games-registry",()=>({seed:[],listeners:new Set})),se=Xe.state.seed,ge=Xe.state.listeners;function ro(o){no("Game",Be(o,Ze),o);const e=se.findIndex(t=>t.id===o.id);e>=0?se[e]=o:se.push(o),lo()}function ao(o){return ge.add(o),()=>{ge.delete(o)}}function lo(){const o=Array.from(ge);for(const e of o)try{e()}catch(t){typeof console<"u"&&console.error("[openstation] games registry listener threw:",t)}}function Ye(){const o=se.slice(),e=Ge(Ut.GAMES,o);return Array.isArray(e)?e.filter(co):(typeof console<"u"&&console.warn("[openstation] `os.games` filter returned a non-array; falling back to seed list."),o)}function ve(o){return Ye().find(e=>e.id===o)}const Ze=[{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 co(o){return Be(o,Ze).length===0}const uo="http://localhost/";function Je(o,e){const t=typeof window<"u"&&window.location?window.location.href:uo,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")??"/",c=l.endsWith("/")?l:l+"/";s.searchParams.set("rest_route",c+r)}else{const l=s.pathname.endsWith("/")?s.pathname:s.pathname+"/";s.pathname=l+r}return a&&new URLSearchParams(a).forEach((c,h)=>{s.searchParams.append(h,c)}),s.toString()}const Qe="X-WP-Nonce";function ho(o,e){const t=po();if(!t)return e;const s=fo(o);if(!s||!mo(s))return e;const n=e?.headers??(typeof Request<"u"&&o instanceof Request?o.headers:void 0),i=new Headers(n??{});return i.has(Qe)?e:(i.set(Qe,t),{...e??{},headers:i})}function po(){if(typeof window>"u")return;const e=window.openStationConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function fo(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 mo(o){return typeof window>"u"||!window.location||o.origin!==window.location.origin?!1:!!(o.pathname.includes("/wp-json/")||o.searchParams.has("rest_route"))}function et(o,e,t={}){const s=window.wp?.os?.fetch;if(typeof s=="function")return s(o,e,t);const n=ho(o,e);return fetch(o,n)}const bo="desktop-mode/games";function go(){const e=window.wp?.os?.config;return{restUrl:e?.restUrl||"/wp-json/",restNonce:e?.restNonce||""}}async function E(o,e={},t={}){const{restUrl:s,restNonce:n}=go(),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 et(Je(s,o),{...e,headers:i,credentials:"same-origin"},{source:bo,windowId:t.windowId,silent:t.silent}),a=await r.json().catch(()=>null);if(!r.ok){const l=a?.message||`Games request failed (${r.status})`,c=new Error(l);throw c.status=r.status,c}return a}function tt(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)),E(`desktop-mode/v1/games/${o}/scores?${t}`)}function vo(o,e,t={}){return E(`desktop-mode/v1/games/${o}/scores`,{method:"POST",body:JSON.stringify({score:e.score,meta:e.meta??{}})},t)}function _o(){return E("desktop-mode/v1/games/playtime")}function yo(o,e,t={}){return E(`desktop-mode/v1/games/${o}/playtime`,{method:"POST",body:JSON.stringify({seconds:e})},t)}function wo(o={}){const e=new URLSearchParams({box:o.box??"all"});return o.state&&e.set("state",o.state),E(`desktop-mode/v1/games/challenges?${e}`)}function ko(o){return E("desktop-mode/v1/games/challenges",{method:"POST",body:JSON.stringify({game:o.game,recipient_id:o.recipientId,score:o.score,meta:o.meta??{}})})}function xo(o){return E(`desktop-mode/v1/games/challenges/${o}/accept`,{method:"POST"})}function So(o){return E(`desktop-mode/v1/games/challenges/${o}/decline`,{method:"POST"})}function Co(o,e,t={}){return E(`desktop-mode/v1/games/challenges/${o}/complete`,{method:"POST",body:JSON.stringify({score:e.score,meta:e.meta??{}})},t)}const Ao=6e4;function Eo(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,yo(o,l,{windowId:e.windowId,silent:!0}).catch(()=>{s+=l*1e3}))},a=setInterval(r,Ao);return{pause:()=>{i(),t=null},resume:()=>{n||t!==null||(t=Date.now())},stop:()=>{n||(n=!0,clearInterval(a),i(),t=null,r())}}}function $o(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 ot(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 H=Ke("desktop-mode/games-challenges",()=>({rows:new Map,version:0,listeners:new Set}));function ne(o){const e=H.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&&No()}function Ro(o){return H.state.listeners.add(o),()=>{H.state.listeners.delete(o)}}function No(){for(const o of Array.from(H.state.listeners))try{o()}catch(e){typeof console<"u"&&console.error("[openstation] challenges store listener threw:",e)}}function To(){return Array.from(H.state.rows.values()).sort((o,e)=>e.updatedAtMs-o.updatedAtMs)}function st(){return window.wp?.os??{}}const Lo=760,Io=560,zo=480,Po=380;async function Mo(o){if(typeof o.render=="function")return o;const e=st().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,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 ro(n),n}async function nt(o,e={}){const t=st();let s=ve(o);if(!s)throw new Error(`[openstation] Unknown game "${o}".`);s=await Mo(s);const n=s.render;if(typeof n!="function")throw new Error(`[openstation] Game "${o}" did not provide a render callback.`);if(typeof t.registerWindow!="function")throw new Error("[openstation] wp.os.registerWindow is missing — the shell must boot before launching games.");const i=`os-game-${o}`,r=`game:${i}`,a=t.windowManager,l=a?.getByBaseId?.(i)??a?.getById(i);if(l){const f=l.config?.desktopId;f&&a?.switchDesktop&&f!==a?.getActiveDesktopId?.()&&a.switchDesktop(f),t.registerWindow({id:i,title:s.title,icon:s.icon,render:()=>{}});return}t.wallpaper?.suspend(r);let c=!1;const h=()=>{c||(c=!0,t.wallpaper?.resume(r))};let d=null;const m=()=>{d?.stop(),d=null};t.onWindow?.(i,{closed:()=>{m(),h()},minimized:()=>d?.pause(),restored:()=>d?.resume()});const u=(f,b)=>{t.activity?.publish("os/game-score-recorded",{game:o,score:f.score,meta:f.meta??{},windowId:i,challengeId:b})},p=f=>{if(e.challenge){const b=e.challenge.id;return Co(b,f,{windowId:i}).then(({challenge:y})=>{ne([y]),u(f,b)})}return vo(o,f,{windowId:i}).then(()=>u(f))};try{await t.registerWindow({id:i,title:s.title,icon:s.icon,width:s.window?.width??Lo,height:s.window?.height??Io,minWidth:s.window?.minWidth??zo,minHeight:s.window?.minHeight??Po,render:f=>{const b={windowId:i,container:f,config:s.config??{},challenge:e.challenge,submitScore:p,close:()=>{t.windowManager?.getById(i)?.close()}};d=Eo(o,{windowId:i});const y=n(b);return()=>{try{y?.()}finally{m(),h()}}}})}catch(f){throw m(),h(),f}}function Ho(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 Fo=_`: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}}`,it={xs:20,sm:24,md:40,lg:64,xl:96},rt=new Set(["online","inactive","offline"]),G=class G extends A{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 c=e&&!this._imgFailed?"":this._initialsBg(t),h=e&&!this._imgFailed?v`<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 | |
| 40 | 41 | src=${e} |
| 41 | 42 | alt=${n} |
| 42 | 43 | @error=${()=>this._onImgError()} |
| 43 | 44 | loading="lazy" |
| 44 | - />`:this._initials(t),d=a?v`<span | |
| 45 | + />`:this._initials(t),c=a?v`<span | |
| 45 | 46 | class=${`os-avatar__dot os-avatar__dot--${a}`} |
| 46 | 47 | aria-label=${this._presenceLabel(a)} |
| 47 | 48 | ></span>`:v``;return l?v` |
| 48 | 49 | <button |
| @@ -48,21 +49,21 @@ | ||
| 48 | 49 | <button |
| 49 | 50 | type="button" |
| 50 | 51 | class="os-avatar__tile" |
| 51 | 52 | aria-label=${n||"User"} |
| 52 | - style=${c?`background:${c};`:""} | |
| 53 | - @click=${m=>this._onClick(m)} | |
| 54 | - >${h}</button> | |
| 55 | - ${d} | |
| 53 | + style=${d?`background:${d};`:""} | |
| 54 | + @click=${f=>this._onClick(f)} | |
| 55 | + >${u}</button> | |
| 56 | + ${c} | |
| 56 | 57 | `:v` |
| 57 | 58 | <div |
| 58 | 59 | class="os-avatar__tile" |
| 59 | 60 | role="img" |
| 60 | 61 | aria-label=${n||"User"} |
| 61 | - style=${c?`background:${c};`:""} | |
| 62 | - >${h}</div> | |
| 63 | - ${d} | |
| 64 | - `}_attr(e){return this.getAttribute(e)}_resolveSize(e){if(!e)return 32;if(e in it)return it[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=Ho(e);return`linear-gradient(135deg, hsl(${t} 62% 55%), hsl(${(t+24)%360} 58% 42%))`}_presenceForRender(){const e=this._attr("presence");return e&&rt.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&&rt.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=[Fo],G.help=void 0;let _e=G;$("os-avatar",_e);const qo=_` ${J}: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 ) )}: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}`,at='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',j=class j extends A{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(at)),s=Array.from(e.querySelectorAll(at));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` | |
| 62 | + style=${d?`background:${d};`:""} | |
| 63 | + >${u}</div> | |
| 64 | + ${c} | |
| 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` | |
| 65 | 66 | <div part="dialog" class="dialog" tabindex="-1"> |
| 66 | 67 | ${e?v` |
| 67 | 68 | <div class="header"> |
| 68 | 69 | <h2 class="title">${e}</h2> |
| @@ -83,9 +84,9 @@ | ||
| 83 | 84 | <div class="footer"> |
| 84 | 85 | <slot name="footer"></slot> |
| 85 | 86 | </div> |
| 86 | 87 | </div> |
| 87 | - `}};j.props=["open","title","size","mandatory"],j.styles=[qo],j.help=void 0;let ye=j;$("os-modal",ye);const Do=_`: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}`,B=class B extends A{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 et(i,r,{source:"desktop-mode/files-user-search",silent:!0});if(!a.ok)throw new Error(`HTTP ${a.status}`);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,c=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-c}px`,`width:${i}px`,`max-height:${c}px`].join(";"):this._dropdownStyle=["position:fixed",`left:${n}px`,`top:${s}px`,`width:${i}px`,`max-height:${c}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` | |
| 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` | |
| 88 | 89 | <button |
| 89 | 90 | type="button" |
| 90 | 91 | class="item" |
| 91 | 92 | role="option" |
| @@ -113,11 +114,11 @@ | ||
| 113 | 114 | <div class="dropdown" role="listbox" style=${this._dropdownStyle}> |
| 114 | 115 | ${this._dropdownContent()} |
| 115 | 116 | </div> |
| 116 | 117 | `:v``} |
| 117 | - `}};B.props=["placeholder","exclude","endpoint"],B.styles=[Do],B.help=void 0;let we=B;$("os-user-search",we);function Oo(){const e=window.openStationGamesConfig?.usersSearchUrl;if(e)return e;const s=window.wp?.os?.config?.restUrl||"/wp-json/";return Je(s,"desktop-mode/v1/games/users/search")}function lt(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",Oo()),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 c=document.createElement("os-button");c.setAttribute("variant","primary"),c.setAttribute("disabled",""),c.textContent=g("Send challenge"),a.append(l,c),t.appendChild(a);let h=null,d=!1;const m=()=>{t.remove(),e()},u=()=>{if(r.innerHTML="",!h){r.hidden=!0,c.setAttribute("disabled","");return}r.hidden=!1;const p=document.createElement("os-avatar");p.setAttribute("src",h.avatarUrl),p.setAttribute("name",h.name),p.setAttribute("size","sm"),p.setAttribute("user-id",String(h.id)),r.appendChild(p);const f=document.createElement("span");f.textContent=h.name,r.appendChild(f),c.removeAttribute("disabled")};i.addEventListener("os-user-pick",p=>{const f=p.detail?.user;f&&(h=f,u())}),l.addEventListener("click",m),t.addEventListener("os-modal-cancel",m),c.addEventListener("click",()=>{!h||d||(d=!0,c.setAttribute("disabled",""),ko({game:o.game,recipientId:h.id,score:o.score,meta:o.meta}).then(()=>{P({message:k(g("Challenge sent to %s."),h.name)}),m()}).catch(p=>{d=!1,c.removeAttribute("disabled"),P({message:p instanceof Error?p.message:g("Could not send the challenge.")})}))}),document.body.appendChild(t)})}const Uo=_`:host{display:inline;color:inherit;font:inherit}`,ie=new Set;let F=null;const Wo=3e4;function Go(){F===null&&(F=window.setInterval(()=>{for(const o of ie)o.tick()},Wo))}function jo(){F!==null&&ie.size===0&&(window.clearInterval(F),F=null)}function Bo(o){if(!o)return null;const e=t=>{const s=new Date(t);return Number.isNaN(s.getTime())?null:s};return Vo(o)?e(o):e(o.replace(" ","T")+"Z")}function Vo(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 ke=null,xe=null;function ct(){return typeof navigator<"u"&&navigator.language||"en"}function Ko(){return ke||(ke=new Intl.RelativeTimeFormat(ct(),{numeric:"auto"})),ke}function dt(){return xe||(xe=new Intl.RelativeTimeFormat(ct(),{numeric:"always",style:"narrow"})),xe}function Xo(o,e){const t=Ko(),s=o.getTime()-e,n=Math.round(s/1e3),i=Math.abs;return i(n)<45?t.format(0,"second"):ut(t,n)}function ut(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 Yo(o,e){const t=Math.round((o.getTime()-e)/1e3),s=Math.abs;return s(t)<45?dt().format(0,"second"):s(t)>7*24*60*60?o.toLocaleDateString(void 0,{month:"short",day:"numeric"}):ut(dt(),t)}const V=class V extends A{connectedCallback(){super.connectedCallback(),ie.add(this),Go()}disconnectedCallback(){ie.delete(this),jo()}tick(){this.requestUpdate()}render(){const e=this.datetime,t=Bo(e);if(!t)return v`<span>${e??""}</span>`;const s=Date.now(),n=this.hasAttribute("compact")?Yo(t,s):Xo(t,s),i=t.toLocaleString();return v`<time datetime=${t.toISOString()} title=${i} | |
| 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} | |
| 118 | 119 | >${n}</time |
| 119 | - >`}};V.props=["datetime","compact"],V.styles=[Uo],V.help=void 0;let Se=V;$("os-relative-time",Se);const Zo=_` ${J} ${qe}: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 )}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}}`,q="__wpd_expander__",D="__wpd_select__",K=class K extends A{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("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 c=Number(a.dataset.rowIndex);if(!Number.isFinite(c))continue;const h=this._data[c];if(h===void 0)continue;const d=this._getRowId(h,c),m=this._selection.has(d);a.classList.toggle("is-selected",m);const u=a.querySelector("input.select-row-checkbox");u&&u.checked!==m&&(u.checked=m)}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` | |
| 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` | |
| 120 | 121 | <div class="scroll" part="scroll"> |
| 121 | 122 | <table part="table"> |
| 122 | 123 | <colgroup></colgroup> |
| 123 | 124 | <thead></thead> |
| @@ -123,5 +124,5 @@ | ||
| 123 | 124 | <thead></thead> |
| 124 | 125 | <tbody></tbody> |
| 125 | 126 | </table> |
| 126 | 127 | </div> |
| 127 | - `}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")||X(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(),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 d=0;d<t.length;d++)l.push(this._buildFilterCell(t[d],d,s));a||(a=document.createElement("tr"),a.classList.add("filter-row"),a.setAttribute("part","filter-row"),e.appendChild(a));const c=Array.from(a.children);let h=c.length===l.length;if(h){for(let d=0;d<l.length;d++)if(c[d]!==l[d]){h=!1;break}}if(!h){const d=new Set(l);for(const m of l)a.appendChild(m);for(const m of Array.from(a.children))d.has(m)||a.removeChild(m)}}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===D){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===q?"":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===q||e.key===D?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 d=n.control,m=this._resolveFilterOptions(e),u=m.map(p=>p.value).join("|");u!==n.optionsKey?(this._populateSelect(d,m,this._filters[e.key]??""),n.optionsKey=u):d.value=this._filters[e.key]??""}else if(a==="text"){const d=n.control,m=this._filters[e.key]??"";d.value!==m&&d.ownerDocument.activeElement!==d&&(d.value=m)}else a==="custom"&&e.filterRender&&e.filterRender(n.th,{value:this._filters[e.key]??"",setValue:d=>this._onFilterChange(e.key,d),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:d=>this._onFilterChange(e.key,d),col:e}),this._filterCache.set(e.key,{th:l,control:null,optionsKey:"",kind:"custom"}),l;let c,h="";if(a==="select"){const d=document.createElement("select");d.classList.add("filter-select"),d.setAttribute("data-noclick",""),d.setAttribute("aria-label",`Filter ${e.label??e.key}`);const m=this._resolveFilterOptions(e);this._populateSelect(d,m,this._filters[e.key]??""),h=m.map(u=>u.value).join("|"),d.addEventListener("change",()=>{this._onFilterChange(e.key,d.value)}),c=d}else{const d=document.createElement("input");d.type="search",d.classList.add("filter-input"),d.setAttribute("data-noclick",""),d.setAttribute("placeholder","Filter…"),d.setAttribute("aria-label",`Filter ${e.label??e.key}`),d.value=this._filters[e.key]??"",d.addEventListener("input",()=>{this._onFilterChange(e.key,d.value)}),c=d}return l.appendChild(c),this._filterCache.set(e.key,{th:l,control:c,optionsKey:h,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._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");s.classList.add("skeleton"),s.setAttribute("aria-hidden","true");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}_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===D){const l=this._getRowId(s,n),c=document.createElement("input");return c.type="checkbox",c.className="select-row-checkbox",c.setAttribute("data-noclick",""),c.setAttribute("aria-label","Select row"),c.checked=this._selection.has(l),c.addEventListener("change",()=>{c.checked?this.select(l):this.deselect(l)}),r.appendChild(c),r}if(e.key===q){if(!(this._subTable?!!this._subTable(s,n):!1))return r;const c=this._expanded.has(n),h=document.createElement("button");return h.type="button",h.className="expander",h.setAttribute("data-noclick",""),h.setAttribute("aria-expanded",c?"true":"false"),h.setAttribute("aria-label",c?"Collapse row":"Expand row"),h.textContent=c?"▾":"▸",h.addEventListener("click",d=>{this._toggleRow(n,s,d)}),r.appendChild(h),r}const a=s[e.key];if(e.render){const l=e.render(a,s,n);this._mountCellContent(r,l)}else a!=null&&(r.textContent=String(a));return r}_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(ht(e))X(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}ht(t)&&X(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(d=>d.key===r);if(a&&typeof a.filterRender=="function")continue;const l=this._filters[r]??"",c=n[r],h=c==null?"":String(c);if(a?.filter==="select"){if(h!==l){i=!1;break}}else if(!h.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=t.sortValue?t.sortValue(i.row,i.row[t.key]):i.row[t.key],l=t.sortValue?t.sortValue(r.row,r.row[t.key]):r.row[t.key];return Jo(a,l)*s}),n}_uniqueValues(e){const t=new Set;for(const s of this._data){const n=s[e];n!=null&&t.add(String(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 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===q&&e.classList.add("col-expander"),t.key===D&&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:D,label:"",width:"40px",align:"center"}),this._subTable&&e.push({key:q,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 c=0;c<l.length;c++)l[c].classList.contains("is-sticky")&&(l[c].style.insetInlineStart=`${n[c]}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."))}};K.props=["stickyColumns","stickyHeader","striped","hover","compact","bordered","empty","loading","loadingRows","selectable"],K.styles=[Zo],K.help=void 0;let Ce=K;function ht(o){return!!o&&o.__wpdHtml===!0}function Jo(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))}$("os-table",Ce);const pt=25;function Qo(){const o=window.wp;return Number(o?.os?.config?.currentUserId)||0}function es(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 ts(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"?es(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!==Qo())return"";const n=document.createElement("os-button");return n.setAttribute("variant","secondary"),n.setAttribute("size","sm"),n.textContent=g("Challenge…"),n.addEventListener("click",()=>{lt({game:o.id,gameTitle:o.title,score:s.score,meta:s.meta})}),n}}),e}function os(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 c=document.createElement("div");c.setAttribute("slot","empty"),c.className="os-games__scoreboard-empty",c.textContent=g("No scores yet — be the first to play!"),l.appendChild(c),t.appendChild(l),l.columns=ts(e),l.data=[];const h=()=>{s.innerHTML="";const u=Math.max(1,Math.ceil(i/pt));if(u<=1)return;const p=document.createElement("os-button");p.setAttribute("variant","ghost"),p.textContent=g("Previous"),n<=1&&p.setAttribute("disabled",""),p.addEventListener("click",()=>void d(n-1));const f=document.createElement("span");f.className="os-games__pager-label",f.textContent=`${n} / ${u}`;const b=document.createElement("os-button");b.setAttribute("variant","ghost"),b.textContent=g("Next"),n>=u&&b.setAttribute("disabled",""),b.addEventListener("click",()=>void d(n+1)),s.append(p,f,b)},d=async u=>{const p=++r;l.setAttribute("loading","");try{const f=await tt(e.id,{page:u,perPage:pt});if(a||p!==r)return;n=u,i=f.total,l.data=f.scores}catch(f){typeof console<"u"&&console.error("[openstation] scoreboard load failed:",f)}finally{!a&&p===r&&(l.removeAttribute("loading"),h())}},m=me.subscribe("os/game-score-recorded",u=>{a||u?.game!==e.id||d(n)});return d(1),()=>{a=!0,m()}}function ss(o){return ve(o)?.title||o}async function ns(o){const{challenge:e}=await xo(o.id);ne([e]),await nt(o.game,{challenge:{id:o.id,scoreToBeat:o.scoreToBeat,scoreMeta:o.scoreMeta,challengerName:o.challengerName}})}function is(){const o=window.wp;return Number(o?.os?.config?.currentUserId)||0}function rs(o,e){const t=o.recipientId===e,s=t?o.challengerName:o.recipientName,n=ss(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 as(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=rs(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 c=document.createElement("div");c.className="os-games__challenge-actions";const h=document.createElement("os-button");h.setAttribute("variant","primary"),h.setAttribute("size","sm"),h.textContent=g("Accept & Play"),h.addEventListener("click",()=>{h.setAttribute("disabled",""),ns(o).catch(m=>{h.removeAttribute("disabled"),P({message:m instanceof Error?m.message:g("Could not accept the challenge.")})})}),c.appendChild(h);const d=document.createElement("os-button");d.setAttribute("variant","ghost"),d.setAttribute("size","sm"),d.textContent=g("Decline"),d.addEventListener("click",()=>{d.setAttribute("disabled",""),So(o.id).then(({challenge:m})=>ne([m])).catch(m=>{d.removeAttribute("disabled"),P({message:m instanceof Error?m.message:g("Could not decline the challenge.")})})}),c.appendChild(d),s.appendChild(c)}return s}function ls(o,e){o.innerHTML="";const t=document.createElement("ul");t.className="os-games__challenge-list",o.appendChild(t);const s=is(),n=()=>{t.innerHTML="";const r=To().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(as(a,s))},i=Ro(n);return n(),wo({box:"all"}).then(({challenges:r})=>ne(r)).catch(r=>{typeof console<"u"&&console.error("[openstation] challenges resync failed:",r)}),i}const cs="[data-os-games-root]",ds="[data-os-games-grid]",us="[data-os-games-detail]";function hs(){const o=window.wp;return Number(o?.os?.config?.currentUserId)||0}function ft(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 ps(o){const e=o.querySelector(cs),t=o.querySelector(ds),s=o.querySelector(us);if(!e||!t||!s)return;const n=[];let i=[],r=null;const a=()=>{for(const u of i)try{u()}catch{}i=[]},l=async u=>{const p=hs(),b=(await tt(u.id,{perPage:1,userId:p})).scores[0];if(!b){P({message:k(g("Play %s first — you need a score to challenge with."),u.title)});return}await lt({game:u.id,gameTitle:u.title,score:b.score,meta:b.meta})},c=u=>{a(),s.hidden=!1,s.innerHTML="";const p=document.createElement("div");p.className="os-games__hero";const f=document.createElement("div");f.className="os-games__hero-visual",f.appendChild(ft(u.icon)),p.appendChild(f);const b=document.createElement("div");b.className="os-games__hero-info";const y=document.createElement("h2");if(y.className="os-games__hero-title",y.textContent=u.title,b.appendChild(y),u.description){const C=document.createElement("p");C.className="os-games__hero-desc",C.textContent=u.description,b.appendChild(C)}const w=document.createElement("div");w.className="os-games__hero-playtime",w.hidden=!0,b.appendChild(w);let S=!1;i.push(()=>{S=!0});const I=(C,ce)=>{const L=document.createElement("span");L.className="os-games__playtime-stat";const $e=document.createElement("span");$e.className="os-games__playtime-label",$e.textContent=C,L.appendChild($e);const Re=document.createElement("span");return Re.className="os-games__playtime-value",Re.textContent=ce,L.appendChild(Re),L};_o().then(C=>{const ce=Number(C.playtime[u.id])||0;if(S||ce<1)return;const L=$o(C.daily?.[u.id]??{},C.today,14);L>0&&w.appendChild(I(g("Play time (last two weeks)"),ot(L))),w.appendChild(I(g("Play time (total)"),ot(ce))),w.hidden=!1}).catch(()=>{}),p.appendChild(b);const re=document.createElement("div");re.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",""),nt(u.id).catch(C=>{typeof console<"u"&&console.error("[openstation] game launch failed:",C)}).finally(()=>{T.removeAttribute("disabled")})}),re.appendChild(T);const z=document.createElement("os-button");z.setAttribute("variant","secondary"),z.textContent=g("Challenge…"),z.addEventListener("click",()=>{z.setAttribute("disabled",""),l(u).finally(()=>{z.removeAttribute("disabled")})}),re.appendChild(z),p.appendChild(re),s.appendChild(p);const ae=document.createElement("section");ae.className="os-games__section";const Ae=document.createElement("h3");Ae.className="os-games__section-heading",Ae.textContent=g("Scoreboard"),ae.appendChild(Ae);const mt=document.createElement("div");ae.appendChild(mt),s.appendChild(ae),i.push(os(mt,u));const le=document.createElement("section");le.className="os-games__section";const Ee=document.createElement("h3");Ee.className="os-games__section-heading",Ee.textContent=g("Challenges"),le.appendChild(Ee);const bt=document.createElement("div");le.appendChild(bt),s.appendChild(le),i.push(ls(bt,u.id))},h=u=>{const p=ve(u);if(p){r=u;for(const f of Array.from(t.querySelectorAll("[data-game-id]"))){const b=f.getAttribute("data-game-id")===u;f.classList.toggle("os-games__tile--selected",b),f.setAttribute("aria-selected",b?"true":"false")}c(p)}},d=u=>{const p=document.createElement("button");p.type="button",p.className="os-games__tile",p.setAttribute("data-game-id",u.id),p.setAttribute("role","option"),p.setAttribute("aria-selected","false");const f=document.createElement("span");f.className="os-games__tile-visual",f.appendChild(ft(u.icon)),p.appendChild(f);const b=document.createElement("span");return b.className="os-games__tile-title",b.textContent=u.title,p.appendChild(b),p.addEventListener("click",()=>h(u.id)),p},m=()=>{t.innerHTML="";const u=Ye();if(u.length===0){const f=document.createElement("os-empty-state");f.setAttribute("icon","games"),f.setAttribute("heading",g("No games installed")),f.setAttribute("description",g("Plugins can add games with openstation_register_game().")),t.appendChild(f),a(),s.hidden=!0,s.innerHTML="",r=null;return}for(const f of u)t.appendChild(d(f));const p=r&&u.some(f=>f.id===r)?r:u[0].id;h(p)};return m(),n.push(ao(m)),()=>{a();for(const u of n)try{u()}catch{}}}const fs=window.openStationNativeWindows??(window.openStationNativeWindows={});fs["desktop-mode-games"]=ps})(); | |
| 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})(); | |