| 1 |
(function(){"use strict";function ne(){const e=window.wp?.hooks;if(!e)throw new Error("[openstation] `window.wp.hooks` is not available. The plugin declares `wp-hooks` as a script dependency; if you are seeing this error, verify the enqueue order.");return e}function R(e,t,o,n){ne().addFilter(e,t,o,n)}function F(e,t,o,n){ne().addAction(e,t,o,n)}const re="__openStationSharedStores";function Oe(){const e=window;let t=e[re];return t||(t=new Map,e[re]=t),t}function Re(e,t){const o=Oe();let n=o.get(e);n||(n={state:t(),listeners:new Set,rebuild:t},o.set(e,n));const r={get state(){return n.state},set state(s){n.state=s},getState(){return n.state},notify(){for(const s of Array.from(n.listeners))try{s(n.state)}catch(a){console.error(`[desktop-mode/shared-store:${e}] subscriber threw:`,a)}},subscribe(s){return n.listeners.add(s),()=>{n.listeners.delete(s)}},setState(s){const a=n.state;if(typeof a!="object"||a===null){console.warn(`[desktop-mode/shared-store:${e}] setState called on a primitive store; use the state setter instead.`);return}Object.assign(a,s),r.notify()},reset(){const s=n.rebuild(),a=n.state;if(typeof a=="object"&&a!==null&&typeof s=="object"&&s!==null){const d=a;for(const c of Object.keys(d))delete d[c];Object.assign(d,s)}else n.state=s;n.listeners.clear()}};return r}const Le="os_person_view",se=Re("desktop-mode/native-url-remap",()=>({remaps:[],deps:null}));function Ue(e){if(!e||typeof e.id!="string"||e.id.trim()==="")return()=>{};if(typeof e.nativeWindowId!="string"||e.nativeWindowId==="")return()=>{};if(typeof e.matches!="function")return()=>{};const t=se.state.remaps,o=t.findIndex(n=>n.id===e.id);return o>=0&&t.splice(o,1),t.push(e),()=>Pe(e.id)}function Pe(e){const t=se.state.remaps,o=t.findIndex(n=>n.id===e);o>=0&&t.splice(o,1)}const ie="desktop-mode";function K(){return window.wp?.i18n}function i(e,t=ie){return K()?.__(e,t)??e}function I(e,t,o,n=ie){return K()?._n(e,t,o,n)??(o===1?e:t)}function m(e,...t){const o=K()?.sprintf;if(o)return o(e,...t);let n=0;return e.replace(/%(?:(\d+)\$)?[sd]/g,(r,s)=>{const a=s?Number.parseInt(s,10)-1:n++;return String(t[a]??"")})}const ae="X-WP-Nonce";function We(e,t){const o=Me();if(!o)return t;const n=qe(e);if(!n||!Fe(n))return t;const r=t?.headers??(typeof Request<"u"&&e instanceof Request?e.headers:void 0),s=new Headers(r??{});return s.has(ae)?t:(s.set(ae,o),{...t??{},headers:s})}function Me(){if(typeof window>"u")return;const t=window.openStationConfig?.restNonce;return typeof t=="string"&&t.length>0?t:void 0}function qe(e){try{const t=typeof window<"u"&&window.location?window.location.href:void 0;return typeof e=="string"?new URL(e,t):e instanceof URL?e:typeof Request<"u"&&e instanceof Request?new URL(e.url,t):null}catch{return null}}function Fe(e){return typeof window>"u"||!window.location||e.origin!==window.location.origin?!1:!!(e.pathname.includes("/wp-json/")||e.searchParams.has("rest_route"))}function De(e,t,o={}){const n=window.wp?.os?.fetch;if(typeof n=="function")return n(e,t,o);const r=We(e,t);return fetch(e,r)}class de extends Error{constructor(t,o){super(t||o.serverMessage||`HTTP ${o.status}`),this.name="RestError",this.status=o.status,this.code=o.code,this.data=o.data,this.serverMessage=o.serverMessage??""}}function ce(e){return e instanceof de}function je(e){const t=typeof e=="object"&&e!==null?e:void 0;return{code:typeof t?.code=="string"?t.code:void 0,data:t?.data,serverMessage:typeof t?.message=="string"?t.message:""}}function ze(e,t,o=""){return new de(o,{status:e,...je(t)})}async function Be(e,t=""){let o=null;try{o=await e.json()}catch{o=null}return ze(e.status,o,t)}const He="rest_cookie_invalid_nonce",le=()=>i("Could not reach the site. Check your connection and try again.","desktop-mode");function ue(e){return typeof navigator<"u"&&navigator.onLine===!1?!0:e instanceof TypeError}function Ve(e){return ce(e)?e.code===He||e.status===401?"session":e.status>=200&&e.status<300?"unreadable":e.status===404?"gone":e.status>=500?"server":e.status>=400?"refused":"unknown":ue(e)?"offline":"unknown"}function Ke(e){return ce(e)?e.serverMessage:ue(e)?le():e instanceof Error?e.message:""}function pe(e,t){const{fallback:o,lead:n}=t,r=Ve(e),s=r==="offline"||r==="unreadable"?"warning":"error";let a="",d=!0;switch(r){case"offline":a=le();break;case"session":a=i("Your session has expired. Reload the page and try again.","desktop-mode");break;case"unreadable":a=i("The site sent an unreadable reply. Reload the page to check whether the change went through.","desktop-mode");break;case"gone":case"refused":case"server":{const p=e;p.serverMessage?a=p.serverMessage:r==="gone"?(a=i("It no longer exists. Reload the page to catch up.","desktop-mode"),d=!1):r==="server"?(a=m(i("The server answered with error %d.","desktop-mode"),p.status),d=!1):(a=m(i("The server refused the request (HTTP %d).","desktop-mode"),p.status),d=!1);break}case"unknown":default:a=Ke(e);break}let c;return n?c=a?`${n}: ${a}`:o:a?d?c=a:c=`${o} ${a}`:c=o,{message:c,reason:a,kind:r,type:s}}function me(e,...t){return{__wpdHtml:!0,strings:e,values:t}}function Xe(e){return!!e&&e.__wpdHtml===!0}const Ge="$$wpd$$",w=/\$\$wpd\$\$(\d+)\$\$/g,Ze="$$wpd-node$$",Je=/^\$\$wpd-node\$\$(\d+)\$\$$/,Ye=new Set(["style","script","textarea","title"]);function Qe(e){let t="",o=!1,n=null,r=!1,s=null,a="",d=!1;for(let c=0;c<e.length;c++){const p=e[c];t+=p;for(let u=0;u<p.length;u++){const h=p[u];if(r){p.startsWith("-->",u)&&(r=!1,u+=2);continue}if(s!==null){h==="<"&&p[u+1]==="/"&&p.slice(u+2,u+2+s.length).toLowerCase()===s&&(u+=1+s.length,s=null,o=!0,d=!1,a="");continue}if(n!==null){h===n&&(n=null);continue}if(o){h==='"'||h==="'"?(n=h,d=!1):h===">"?(o=!1,d=!1,Ye.has(a)&&(s=a),a=""):d&&(/[a-zA-Z0-9-]/.test(h)?a+=h.toLowerCase():d=!1);continue}if(p.startsWith("<!--",u)){r=!0,u+=3;continue}const k=p[u+1]??"";h==="<"&&/[a-zA-Z/!]/.test(k)&&(o=!0,a="",d=/[a-zA-Z]/.test(k))}c<e.length-1&&(t+=o||r||s!==null?`${Ge}${c}$$`:`<!--${Ze}${c}$$-->`)}return t}const fe=new WeakMap;function he(e){const t=fe.get(e);if(t)return t;const o=document.createElement("template");o.innerHTML=Qe(e);const n=[],r=(d,c)=>{if(d.nodeType===Node.ELEMENT_NODE){const h=d;for(const k of Array.from(h.attributes)){const x=k.name,v=k.value,A=x[0];if(w.test(v))if(w.lastIndex=0,A==="@"){const g=w.exec(v);w.lastIndex=0,n.push({path:c,kind:"event",name:x.slice(1),valueIndex:g?Number(g[1]):0}),h.removeAttribute(x)}else if(A==="."){const g=w.exec(v);w.lastIndex=0,n.push({path:c,kind:"prop",name:x.slice(1),valueIndex:g?Number(g[1]):0}),h.removeAttribute(x)}else if(A==="?"){const g=w.exec(v);w.lastIndex=0,n.push({path:c,kind:"bool",name:x.slice(1),valueIndex:g?Number(g[1]):0}),h.removeAttribute(x)}else{const g=[],N=[];let C=0,T;for(w.lastIndex=0;(T=w.exec(v))!==null;)g.push(v.slice(C,T.index)),N.push(Number(T[1])),C=T.index+T[0].length;g.push(v.slice(C)),n.push({path:c,kind:"attr",name:x,template:g,valueIndices:N}),h.setAttribute(x,"")}}}const p=Array.from(d.childNodes);let u=0;for(let h=0;h<p.length;h++){const k=p[h],x=h+u;if(k.nodeType===Node.COMMENT_NODE){const v=Je.exec(k.data);if(v){const A=document.createTextNode("");k.parentNode.replaceChild(A,k),n.push({path:[...c,x],kind:"node",valueIndex:Number(v[1])})}continue}if(k.nodeType===Node.TEXT_NODE){const v=k.textContent||"";if(!w.test(v)){w.lastIndex=0;continue}w.lastIndex=0;const A=k.parentNode;let g=0,N;const C=[],T=[];for(w.lastIndex=0;(N=w.exec(v))!==null;){N.index>g&&C.push(document.createTextNode(v.slice(g,N.index)));const oe=document.createTextNode("");C.push(oe),T.push({path:[...c,x+C.length-1],kind:"node",valueIndex:Number(N[1])}),g=N.index+N[0].length}g<v.length&&C.push(document.createTextNode(v.slice(g)));for(const oe of C)A.insertBefore(oe,k);A.removeChild(k),u+=C.length-1,n.push(...T)}else r(k,[...c,x])}};r(o.content,[]);const a={template:o,buildParts:d=>{const c=[];for(const p of n){let u=d;for(const h of p.path)u=u.childNodes[h];p.kind==="node"?c.push({kind:"node",valueIndex:p.valueIndex,child:{anchor:u,state:null}}):p.kind==="attr"?c.push({kind:"attr",element:u,name:p.name,template:p.template,valueIndices:p.valueIndices}):p.kind==="event"?c.push({kind:"event",valueIndex:p.valueIndex,element:u,name:p.name}):p.kind==="prop"?c.push({kind:"prop",valueIndex:p.valueIndex,element:u,name:p.name}):p.kind==="bool"&&c.push({kind:"bool",valueIndex:p.valueIndex,element:u,name:p.name})}return c}};return fe.set(e,a),a}const be=new WeakMap;function et(e,t){for(const o of e.nodes)if(o.parentNode!==t)return!1;return!0}function tt(e,t){const o=be.get(t);if(o&&o.strings===e.strings&&et(o,t)){D(o.parts,e.values);return}const n=he(e.strings),r=n.template.content.cloneNode(!0),s=n.buildParts(r),a=Array.from(r.childNodes);for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(r),D(s,e.values),be.set(t,{strings:e.strings,parts:s,nodes:a})}function D(e,t){for(const o of e)if(o.kind==="node")j(o.child,t[o.valueIndex]);else if(o.kind==="attr"){let n=o.template[0];for(let r=0;r<o.valueIndices.length;r++)n+=ge(t[o.valueIndices[r]]),n+=o.template[r+1];n!==o.last&&(o.last=n,n===""?o.element.removeAttribute(o.name):o.element.setAttribute(o.name,n))}else if(o.kind==="event"){const n=t[o.valueIndex];n!==o.current&&(o.current&&o.element.removeEventListener(o.name,o.current),n&&o.element.addEventListener(o.name,n),o.current=n)}else if(o.kind==="prop"){const n=t[o.valueIndex];n!==o.last&&(o.last=n,o.element[o.name]=n)}else if(o.kind==="bool"){const n=!!t[o.valueIndex];n!==o.last&&(o.last=n,n?o.element.setAttribute(o.name,""):o.element.removeAttribute(o.name))}}function j(e,t){if(t==null||t===!1){e.state&&(E(e.state),e.state=null);return}if(Array.isArray(t)){st(e,t);return}if(Xe(t)){rt(e,t);return}if(t instanceof Node){ot(e,t);return}nt(e,ge(t))}function ot(e,t){const o=e.state;o?.shape==="node"&&o.node===t||(o&&E(o),U(e,[t]),e.state={shape:"node",node:t})}function nt(e,t){const o=e.state;if(o?.shape==="text"){o.text!==t&&(o.node.textContent=t,o.text=t);return}o&&E(o);const n=document.createTextNode(t);U(e,[n]),e.state={shape:"text",node:n,text:t}}function rt(e,t){const o=e.state;if(o?.shape==="template"&&o.strings===t.strings){D(o.parts,t.values);return}o&&E(o);const n=he(t.strings),r=n.template.content.cloneNode(!0),s=n.buildParts(r),a=Array.from(r.childNodes);U(e,[r]),D(s,t.values),e.state={shape:"template",strings:t.strings,parts:s,nodes:a}}function st(e,t){const o=e.state;if(o?.shape==="array"){const r=Math.min(o.entries.length,t.length);for(let s=0;s<r;s++)j(o.entries[s],t[s]);if(t.length<o.entries.length){for(let s=t.length;s<o.entries.length;s++){const a=o.entries[s];a.state&&E(a.state),a.anchor.remove()}o.entries.length=t.length}else for(let s=o.entries.length;s<t.length;s++){const a=document.createTextNode("");U(e,[a]);const d={anchor:a,state:null};j(d,t[s]),o.entries.push(d)}return}o&&E(o);const n=[];for(const r of t){const s=document.createTextNode("");U(e,[s]);const a={anchor:s,state:null};j(a,r),n.push(a)}e.state={shape:"array",entries:n}}function U(e,t){const o=e.anchor.parentNode;if(o)for(const n of t)o.insertBefore(n,e.anchor)}function E(e){if(e.shape==="text"){e.node.remove();return}if(e.shape==="template"){for(const t of e.parts)t.kind==="node"&&t.child.state&&(E(t.child.state),t.child.state=null);for(const t of e.nodes)t.parentNode&&t.parentNode.removeChild(t);return}if(e.shape==="node"){e.node.parentNode&&e.node.parentNode.removeChild(e.node);return}for(const t of e.entries)t.state&&E(t.state),t.anchor.remove()}function ge(e){return e==null||e===!1?"":String(e)}const $=class $ 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(ve)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(t,o,n){if(o===n)return;const r=it(t);this._propValues[r]=n,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(t){if(t==null){this.removeAttribute("class");return}const n=(Array.isArray(t)?t:String(t).split(/\s+/)).map(r=>String(r).trim()).filter(r=>r!=="");this.className=n.join(" ")}requestUpdate(){this._scheduleRender()}emit(t,o){return this.dispatchEvent(new CustomEvent(t,{detail:o,bubbles:!0,composed:!0}))}_installPropAccessors(){const t=this.constructor;for(const o of t.props){if(Object.getOwnPropertyDescriptor(this,o))continue;const n=ve(o);Object.defineProperty(this,o,{get:()=>o in this._propValues?this._propValues[o]:this.getAttribute(n),set:r=>{let s;r==null||r===!1?s=null:r===!0?s="":s=String(r),this._propValues[o]=s,s===null?this.removeAttribute(n):this.setAttribute(n,s),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&tt(this.render(),this._renderRoot)}))}_adoptStyles(){const t=this.constructor;if(t.styles.length!==0)if(t.shadow&&this.shadowRoot){const o=t.styles.map(n=>n.sheet).filter(n=>n!==null);if(this.shadowRoot.adoptedStyleSheets=o,o.length!==t.styles.length){for(const n of t.styles)if(!n.sheet){const r=document.createElement("style");r.textContent=n.cssText,this.shadowRoot.appendChild(r)}}}else this._adoptLightStyles(t)}_adoptLightStyles(t){if(!$._lightStylesAdopted.has(t)){$._lightStylesAdopted.add(t);for(const o of t.styles){const n=document.createElement("style");n.dataset.osUi=this.tagName.toLowerCase(),n.textContent=o.cssText,document.head.appendChild(n)}}}};$.props=[],$.styles=[],$.shadow=!0,$._lightStylesAdopted=new WeakSet;let z=$;function ke(e,t){customElements.get(e)||customElements.define(e,t)}function ve(e){return e.replace(/[A-Z]/g,t=>"-"+t.toLowerCase())}function it(e){return e.replace(/-([a-z])/g,(t,o)=>o.toUpperCase())}const at=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function _(e,...t){let o=e[0];for(let n=1;n<e.length;n++){const r=t[n-1];if(typeof r=="string"||typeof r=="number")o+=String(r);else if(r&&r.__wpdCss)o+=r.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof r);o+=e[n]}if(at){const n=new CSSStyleSheet;return n.replaceSync(o),{__wpdCss:!0,sheet:n,cssText:o}}return{__wpdCss:!0,sheet:null,cssText:o}}const dt=_`:host{position:absolute;width:var( --os-ui-ribbon-size,90px );height:var( --os-ui-ribbon-size,90px );overflow:hidden;pointer-events:none;z-index:var( --os-ui-ribbon-z,2 )}:host( [ hidden ] ){display:none}.banner{position:absolute;display:block;width:var( --os-ui-ribbon-banner-width,140px );padding:var( --os-ui-ribbon-padding,4px 0 );text-align:center;font:var( --os-ui-ribbon-font,700 10px/1.4 var( --os-font,system-ui ) );letter-spacing:var( --os-ui-ribbon-tracking,0.06em );text-transform:uppercase;color:var( --os-ui-ribbon-fg,var( --os-ui-fg-on-accent,#fff ) );background:var( --os-ui-ribbon-bg,var( --wp-admin-theme-color,#2271b1 ) );background-size:260% 260%;background-position:30% 40%;box-shadow:var( --os-ui-ribbon-shadow,0 2px 4px rgba( 0,0,0,0.2 ) )}:host(:not( [ placement ] ) ),:host( [ placement='top-end' ] ){inset-block-start:0;inset-inline-end:0}:host(:not( [ placement ] ) ) .banner,:host( [ placement='top-end' ] ) .banner{inset-block-start:var( --os-ui-ribbon-banner-offset,20px );inset-inline-end:var( --os-ui-ribbon-banner-pull,-36px );transform:rotate( 45deg )}:host( [ placement='top-start' ] ){inset-block-start:0;inset-inline-start:0}:host( [ placement='top-start' ] ) .banner{inset-block-start:var( --os-ui-ribbon-banner-offset,20px );inset-inline-start:var( --os-ui-ribbon-banner-pull,-36px );transform:rotate( -45deg )}:host( [ placement='bottom-end' ] ){inset-block-end:0;inset-inline-end:0}:host( [ placement='bottom-end' ] ) .banner{inset-block-end:var( --os-ui-ribbon-banner-offset,20px );inset-inline-end:var( --os-ui-ribbon-banner-pull,-36px );transform:rotate( -45deg )}:host( [ placement='bottom-start' ] ){inset-block-end:0;inset-inline-start:0}:host( [ placement='bottom-start' ] ) .banner{inset-block-end:var( --os-ui-ribbon-banner-offset,20px );inset-inline-start:var( --os-ui-ribbon-banner-pull,-36px );transform:rotate( 45deg )}:host-context( [ dir='rtl' ] ):host(:not( [ placement ] ) ) .banner,:host-context( [ dir='rtl' ] ):host( [ placement='top-end' ] ) .banner{transform:rotate( -45deg )}:host-context( [ dir='rtl' ] ):host( [ placement='top-start' ] ) .banner{transform:rotate( 45deg )}:host-context( [ dir='rtl' ] ):host( [ placement='bottom-end' ] ) .banner{transform:rotate( 45deg )}:host-context( [ dir='rtl' ] ):host( [ placement='bottom-start' ] ) .banner{transform:rotate( -45deg )}:host( [ tone='success' ] ) .banner{background:var( --os-ui-ribbon-success,var( --os-ui-success-fg,#1a7f37 ) )}:host( [ tone='warning' ] ) .banner{background:var( --os-ui-ribbon-warning,var( --os-ui-warning-bg,#9a6700 ) )}:host( [ tone='danger' ] ) .banner{background:var( --os-ui-ribbon-danger,var( --os-ui-danger,#cf222e ) )}:host( [ tone='info' ] ) .banner{background:var( --os-ui-ribbon-info,var( --os-ui-info-bg,#0969da ) )}:host( [ tone='neutral' ] ) .banner{background:var( --os-ui-ribbon-neutral,var( --os-ui-surface,#57606a ) )}`,M=class M extends z{render(){return me`<span class="banner" part="banner"><slot></slot></span>`}};M.props=["placement","tone"],M.styles=[dt],M.help=void 0;let X=M;ke("os-ribbon",X);const we=_`: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 ) )}`,ct=_` .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%}}`,lt=_` .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%}}`,ut=_` .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}}`,pt=_` .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}}`,mt=_` .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}}`,ft=_` .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}}`,bt=_` 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}}`,gt=_` 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}}`,kt=_` @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}}`;_` ${we} ${ct} ${lt} ${ut} ${pt} ${mt} ${ft} ${ht} ${bt} ${gt} ${kt} `;const vt=_` ${we}:host{display:inline-flex;align-items:center;gap:var( --os-ui-badge-gap,6px );padding:var( --os-ui-badge-padding,2px 8px );font:var( --os-ui-badge-font,500 12px/1.4 var( --os-font,system-ui ) );color:var( --os-ui-badge-color,var( --os-ui-fg,#1d2327 ) );background:var( --os-ui-badge-bg,var( --os-ui-hover,rgba( 0,0,0,0.06 ) ) );border:var( --os-ui-badge-border,1px solid transparent );border-radius:var( --os-ui-badge-border-radius,999px );white-space:nowrap;vertical-align:baseline}:host( [ hidden ] ){display:none}.dot{width:var( --os-ui-badge-dot-size,8px );height:var( --os-ui-badge-dot-size,8px );border-radius:50%;background:currentColor;flex:0 0 auto}:host( [ tone="success" ] ){--os-ui-badge-color:var( --os-ui-badge-success,var( --os-ui-success-fg,#1a7f37 ) );--os-ui-badge-bg:var( --os-ui-badge-success-bg,rgba( 26,127,55,0.12 ) )}:host( [ tone="warning" ] ){--os-ui-badge-color:var( --os-ui-badge-warning,var( --os-ui-warning-fg,#9a6700 ) );--os-ui-badge-bg:var( --os-ui-badge-warning-bg,rgba( 154,103,0,0.12 ) )}:host( [ tone="danger" ] ){--os-ui-badge-color:var( --os-ui-badge-danger,var( --os-ui-danger,#cf222e ) );--os-ui-badge-bg:var( --os-ui-badge-danger-bg,rgba( 207,34,46,0.12 ) )}:host( [ tone="info" ] ){--os-ui-badge-color:var( --os-ui-badge-info,var( --os-ui-info-fg,#0969da ) );--os-ui-badge-bg:var( --os-ui-badge-info-bg,rgba( 9,105,218,0.12 ) )}:host( [ tone="neutral" ] ){--os-ui-badge-color:var( --os-ui-badge-neutral,var( --os-ui-fg-muted,#57606a ) );--os-ui-badge-bg:var( --os-ui-badge-neutral-bg,rgba( 87,96,106,0.12 ) )}:host( [ tone="accent" ] ){--os-ui-badge-color:var( --os-ui-badge-accent,var( --_holo-ink ) );background-color:transparent;background-image:var( --os-ui-badge-accent-bg,var( --_holo-fill ) );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;box-shadow:var( --_holo-glow );font-weight:600}:host( [ tone="accent" ] ) .dot{display:none}:host( [ no-dot ] ) .dot{display:none}`,q=class q extends z{render(){return me`<span class="dot" aria-hidden="true"></span><slot></slot>`}};q.props=["tone","noDot"],q.styles=[vt],q.help=void 0;let G=q;ke("os-badge",G);const b="os-woo-panel",_e=5,Z="wc-orders",J="cpt-product",xe="cpt-shop_coupon",L="wc-customers";function O(){const e=window.openStationWooConfig;return e&&typeof e.restRoot=="string"?e:null}async function Y(e){const t=O();if(!t)return{error:i("WooCommerce data is unavailable.","desktop-mode")};const o=t.restRoot+e;try{const n=await De(o,{method:"GET",credentials:"same-origin",headers:{"X-WP-Nonce":t.restNonce,Accept:"application/json"}},{source:"desktop-mode/woocommerce"});return n.ok?{data:await n.json()}:(console.warn(`[openstation] WooCommerce request failed: ${n.status} ${o}`),{error:pe(await Be(n),{fallback:i("Could not load WooCommerce details.","desktop-mode")}).message})}catch(n){return console.warn(`[openstation] WooCommerce request errored: ${o}`,n),{error:pe(n,{fallback:i("Could not load WooCommerce details.","desktop-mode")}).message}}}function S(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return e}}function l(e,t){if(t===null||t==="")return null;const o=document.createElement("dt");o.className=`${b}__label`,o.textContent=e;const n=document.createElement("dd");n.className=`${b}__value`,typeof t=="string"?n.textContent=t:n.appendChild(t);const r=document.createElement("div");return r.className=`${b}__row`,r.append(o,n),r}function y(e,t){if(!t)return document.createTextNode(e);const o=document.createElement("a");return o.className=`${b}__link`,o.href=t,o.textContent=e,o.rel="noopener noreferrer",o.addEventListener("click",n=>{n.defaultPrevented||n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||(n.preventDefault(),W(t,e))}),o}function Q(e){if(!e||e.length===0)return null;const t=document.createElement("span");return e.forEach((o,n)=>{n>0&&t.appendChild(document.createTextNode(", ")),t.appendChild(y(o.label,o.editUrl))}),t}function wt(e,t,o){const n=document.createElement("section");n.className=`${b} ${b}--${o}`;const r=document.createElement("h3");r.className=`${b}__title`,r.textContent=e,n.appendChild(r);const s=document.createElement("dl");return s.className=`${b}__rows`,t.forEach(a=>{a&&s.appendChild(a)}),n.appendChild(s),n}function P(e,t){const o=document.createElement("os-badge");return o.setAttribute("tone",t),o.className=`${b}__pill`,o.textContent=e,o}function _t(e,t){const o=document.createElement("span");if(t){const r=document.createElement("s");r.className=`${b}__was`,r.textContent=t,o.append(r,document.createTextNode(" "))}const n=document.createElement("strong");return n.textContent=e,o.appendChild(n),o}function xt(e){return e.filter(([o])=>o).map(([,o])=>o).join(" · ")}function ye(e,t,o,n,r){const s=Array.from({length:n},()=>{const c=document.createElement("div");return c.className=`${b}__row ${b}__row--placeholder`,c.setAttribute("aria-hidden","true"),c.append(document.createElement("span"),document.createElement("span")),c}),a=wt(t,s,o);a.setAttribute("aria-busy","true"),e.appendChild(a);const d=c=>{const p=a.querySelector(`.${b}__rows`);if(!p)return;p.replaceChildren();const u=document.createElement("p");u.className=`${b}__error`,u.textContent=c,p.appendChild(u)};r().then(c=>{if(!a.isConnected)return;if(a.removeAttribute("aria-busy"),"error"in c){d(c.error);return}const p=a.querySelector(`.${b}__rows`);p&&(p.replaceChildren(),c.rows.forEach(u=>{u&&p.appendChild(u)}))}).catch(c=>{a.isConnected&&(a.removeAttribute("aria-busy"),console.warn("[openstation] WooCommerce panel failed to render",c),d(i("Could not show WooCommerce details.","desktop-mode")))})}function yt(e,t){return e==="outofstock"?"danger":e==="onbackorder"||t!==null&&t<=_e?"warning":"success"}function Ce(e){return e==="completed"?"success":e==="processing"||e==="on-hold"||e==="pending"?"warning":e==="cancelled"||e==="failed"||e==="refunded"?"danger":"neutral"}function Ne(e){return e==="vip"?"success":e==="lapsed"?"warning":"neutral"}function Ct(e){const t=e.stockLevel===null?e.stockLabel:m(i("%1$s (%2$d)","desktop-mode"),e.stockLabel,e.stockLevel),o=Number(e.reviews)||0,n=o>0?m(i("%1$s � |
| 2 |
(%2$d)","desktop-mode"),(Number(e.rating)||0).toFixed(1),o):"",r=e.variations>0?m(i("%1$s · %2$d variations","desktop-mode"),e.productType,e.variations):e.productType;return[l(i("SKU","desktop-mode"),e.sku),l(e.onSale?i("Price (on sale)","desktop-mode"):i("Price","desktop-mode"),_t(e.price,e.regular)),l(i("Stock","desktop-mode"),P(t,yt(e.stockStatus,e.stockLevel))),l(i("Sold","desktop-mode"),e.sold>0?m(i("%d units","desktop-mode"),e.sold):""),l(i("Rating","desktop-mode"),n),l(i("Type","desktop-mode"),r),l(i("Categories","desktop-mode"),(e.categories??[]).join(", ")),l(i("Open","desktop-mode"),e.editUrl||e.permalink?(()=>{const s=document.createElement("span");return e.editUrl&&s.appendChild(y(i("Edit","desktop-mode"),e.editUrl)),e.editUrl&&e.permalink&&s.appendChild(document.createTextNode(" · ")),e.permalink&&s.appendChild(y(i("View in shop","desktop-mode"),e.permalink)),s})():null)]}function Nt(e){const t=document.createElement("ul");t.className=`${b}__items`;const o=e.items??[];o.forEach(r=>{const s=document.createElement("li");s.className=`${b}__item`;const a=document.createElement("span"),d=document.createElement("span");d.className=`${b}__item-qty`,d.textContent=m(i("%d×","desktop-mode"),r.quantity),a.append(d,y(r.name,r.editUrl));const c=document.createElement("span");c.className=`${b}__item-total`,c.textContent=r.total,s.append(a,c),t.appendChild(s)});const n=document.createElement("span");if(n.appendChild(y(e.customer,e.customerUrl)),e.email){const r=document.createElement("a");r.className=`${b}__email`,r.href=`mailto:${e.email}`,r.textContent=e.email,n.append(document.createElement("br"),r)}return[l(i("Status","desktop-mode"),P(e.statusLabel,Ce(e.status))),l(i("Total","desktop-mode"),e.total),l(i("Subtotal","desktop-mode"),e.subtotal),l(i("Shipping","desktop-mode"),e.shipping),l(i("Discount","desktop-mode"),e.discount),l(i("Coupons","desktop-mode"),(e.coupons??[]).join(", ")),l(i("Paid via","desktop-mode"),e.paymentVia),l(i("Customer","desktop-mode"),n),l(i("Placed","desktop-mode"),S(e.placed)),l(m(i("Items (%d)","desktop-mode"),e.itemCount),o.length>0?t:null),l(i("Open","desktop-mode"),e.editUrl?y(i("Edit in WooCommerce","desktop-mode"),e.editUrl):null)]}function Et(e){const t=e.usageLimit>0?m(i("%1$d of %2$d","desktop-mode"),e.used,e.usageLimit):m(i("%d (no limit)","desktop-mode"),e.used),o=xt([[e.individualUse,i("Individual use only","desktop-mode")],[e.excludeSale,i("Excludes sale items","desktop-mode")],[e.freeShipping,i("Grants free shipping","desktop-mode")]]);return[l(i("Status","desktop-mode"),e.active?P(i("Active","desktop-mode"),"success"):P(e.inactiveWhy||i("Inactive","desktop-mode"),"danger")),l(i("Discount","desktop-mode"),e.discount),l(i("Description","desktop-mode"),e.description),l(i("Used","desktop-mode"),t),l(i("Per customer","desktop-mode"),e.perUserLimit>0?m(i("%d uses","desktop-mode"),e.perUserLimit):""),l(i("Limit to items","desktop-mode"),e.limitToItems>0?String(e.limitToItems):""),l(i("Discount given","desktop-mode"),e.granted),l(i("Created","desktop-mode"),S(e.created)),l(i("Expires","desktop-mode"),e.expires?S(e.expires):i("Never","desktop-mode")),l(i("Minimum spend","desktop-mode"),e.minSpend),l(i("Maximum spend","desktop-mode"),e.maxSpend),l(i("Restrictions","desktop-mode"),o),l(i("Products","desktop-mode"),Q(e.products)),l(i("Excludes","desktop-mode"),Q(e.excluded)),l(i("Categories","desktop-mode"),Q(e.categories)),l(i("Allowed emails","desktop-mode"),(e.emails??[]).join(", ")),l(i("Open","desktop-mode"),e.editUrl?y(i("Edit coupon","desktop-mode"),e.editUrl):null)]}function Ee(e){if(e===null||!Number.isFinite(e))return"";if(e<=0)return i("Today","desktop-mode");if(e<60)return m(I("%d day ago","%d days ago",e),e);const t=Math.round(e/30);if(t<24)return m(I("%d month ago","%d months ago",t),t);const o=Math.round(e/365);return m(I("%d year ago","%d years ago",o),o)}function St(e){const t=Number(e.orders)||0,o=Ee(e.daysSince??null);return[l(i("Lifetime spend","desktop-mode"),e.spend?(()=>{const n=document.createElement("span"),r=document.createElement("strong");return r.textContent=e.spend,n.appendChild(r),e.bandLabel&&(n.appendChild(document.createTextNode(" ")),n.appendChild(P(e.bandLabel,Ne(e.band)))),n})():null),l(i("Orders","desktop-mode"),t>0?m(I("%d order","%d orders",t),t):i("None yet","desktop-mode")),l(i("Average order","desktop-mode"),e.aov),l(i("Last order","desktop-mode"),e.lastOrderNo?(()=>{const n=document.createElement("span");n.appendChild(y(m(i("#%s","desktop-mode"),e.lastOrderNo),e.lastOrderUrl));const r=[e.lastOrderTotal,o].filter(Boolean);return r.length&&n.appendChild(document.createTextNode(` · ${r.join(" · ")}`)),n})():null),l(i("First order","desktop-mode"),S(e.firstOrder)),l(i("Buys most","desktop-mode"),e.favourite?(()=>{const n=document.createElement("span");return n.appendChild(y(e.favourite.label,e.favourite.editUrl)),e.favourite.quantity>1&&n.appendChild(document.createTextNode(` · ${m(i("×%d","desktop-mode"),e.favourite.quantity)}`)),n})():null),l(i("Location","desktop-mode"),e.location),l(i("Email","desktop-mode"),e.email),l(i("Customer since","desktop-mode"),S(e.registered)),l(i("Open","desktop-mode"),t>0&&e.ordersUrl?y(i("All their orders","desktop-mode"),e.ordersUrl):null)]}const $t={product:i("Product","desktop-mode"),order:i("Order","desktop-mode"),coupon:i("Coupon","desktop-mode"),customer:i("Customer","desktop-mode")},At={product:8,order:10,coupon:12,customer:9};function Tt(e){return e===Z?"order":e===J?"product":e===xe?"coupon":null}function It(e){return e.entityId===L?O()?.canCustomers?"customer":null:e.kind==="user"?O()?.canCustomers&&B(e.item)?"customer":null:Tt(e.entityId)}function Ot(e){const t=e.openstation_woo;return t&&typeof t.stockStatus=="string"?t:null}function Se(e){const t=e.openstation_woo;return t&&typeof t.band=="string"?t.band:null}function B(e){const t=e.openstation_woo_customer;return t&&typeof t.band=="string"?t:null}function Rt(e){return O()?.customerBands?.find(o=>o.id===e)?.label??""}R("os.my-wordpress.list-bands","desktop-mode/woocommerce",(e,t)=>{const o=O();if(!o)return e;if(t.id===Z&&o.orderBands?.length){const n=o.orderBands,r=new Map;return n.forEach(s=>{(s.statuses??[]).forEach(a=>r.set(a,s.id))}),{bands:n,assign:s=>r.get(String(s.wcStatus??""))??null}}return t.id===J&&o.productBands?.length?{bands:o.productBands,assign:n=>Se(n)}:t.id===xe&&o.couponBands?.length?{bands:o.couponBands,assign:n=>Se(n)}:e});const Lt=new Set(["slug","comments","words"]);R("os.my-wordpress.list-columns","desktop-mode/woocommerce",(e,t)=>{if(t.id!==Z||!Array.isArray(e))return e;const o=O()?.orderStatuses??{};return e.filter(n=>!Lt.has(n.id)).map(n=>n.id==="author"?{id:"customer",label:i("Customer","desktop-mode"),render:r=>String(r.customer??"")}:n.id==="status"?{...n,render:r=>{const s=String(r.wcStatus??"");return o[`wc-${s}`]??s}}:n)});function Ut(e){if(e.kind!=="user")return!1;const t=B(e.item);return t?(e.entityId===L&&e.tile.querySelector(".os-my-wordpress__user-tile-sub")?.remove(),(t.band==="vip"||t.band==="lapsed")&&(e.tile.dataset.wooCustomerBand=t.band,$e(e.tile)),!0):!1}function $e(e){const t=e.dataset.wooCustomerBand;if(!t||e.querySelector(".os-woo-customer-band"))return;const o=e.querySelector(".os-file-tile__visual");if(!o)return;o.classList.add("os-woo-customer-avatar");const n=Rt(t)||i(t==="vip"?"VIP":"Lapsed","desktop-mode"),r=document.createElement("span");r.className=`os-woo-customer-band os-woo-customer-band--${t}`,r.textContent=n,r.setAttribute("aria-hidden","true"),o.appendChild(r)}F("os.my-wordpress.list-tile","desktop-mode/woocommerce",e=>{if(Ut(e)||e.entityId!==J)return;const t=Ot(e.item);if(!t)return;let o="",n="warning";t.stockStatus==="outofstock"?(o=i("Sold out","desktop-mode"),n="danger"):t.stockStatus==="onbackorder"?(o=i("Backorder","desktop-mode"),n="warning"):t.stockLevel!==null&&t.stockLevel<=_e?(o=m(i("%d left","desktop-mode"),t.stockLevel),n="warning"):t.onSale&&(o=i("Sale","desktop-mode"),n="success"),o&&(e.tile.dataset.wooRibbon=`${n}|${o}`,Ae(e.tile))});function Ae(e){const t=e.dataset.wooRibbon;if(!t||e.querySelector(":scope > os-ribbon.os-woo-ribbon"))return;const o=t.indexOf("|"),n=t.slice(0,o),r=t.slice(o+1),s=document.createElement("os-ribbon");s.setAttribute("placement","top-start"),s.setAttribute("tone",n),s.className="os-woo-ribbon",s.textContent=r,e.appendChild(s)}F("os.tile.rendered","desktop-mode/woocommerce",e=>{Ae(e.tile),$e(e.tile)}),F("os.my-wordpress.preview-extras","desktop-mode/woocommerce",e=>{const t=It(e);if(!t||e.slot!==(t==="customer"?"meta":"header"))return;const o=Number(e.item?.id);!Number.isFinite(o)||o<=0||ye(e.container,$t[t],t,At[t],async()=>{const n=await Y(`summary/${t}/${o}`);if("error"in n)return n;const{data:r}=n;return r.type==="product"?{rows:Ct(r)}:r.type==="order"?{rows:Nt(r)}:r.type==="coupon"?{rows:Et(r)}:r.type==="customer"?{rows:St(r)}:{rows:[]}})}),R("os.my-wordpress.user-dossier-sections","desktop-mode/woocommerce",(e,t)=>t.entityId!==L?e:Array.isArray(e)?e.filter(o=>o==="bio"):e),R("os.my-wordpress.user-preview-actions","desktop-mode/woocommerce",(e,t)=>{if(t.entityId!==L||!Array.isArray(e))return e;const o=e.filter(r=>r?.id!=="footprint"),n=B(t.item);return n?.ordersUrl?[{id:"wc-orders",label:i("View their orders","desktop-mode"),title:i("Open the orders screen filtered to this customer, in its own window.","desktop-mode"),variant:"primary",onSelect:()=>W(n.ordersUrl,i("Orders","desktop-mode"))},...o]:o.map(r=>r.id==="open-profile"?{...r,variant:"primary"}:r)});function W(e,t){const o=window.wp?.os,n=o?.windowManager;if(!n||typeof n.open!="function"){window.open(e,"_blank","noopener,noreferrer");return}const r=typeof o?.deriveWindowId=="function"?o.deriveWindowId(e):`os-woo-${e.replace(/[^a-z0-9]+/gi,"-").slice(-60)}`;n.open({id:r,url:e,title:t,icon:"dashicons-cart"})}F("os.my-wordpress.group-extras","desktop-mode/woocommerce",e=>{if(e.groupId!=="plugin:woocommerce")return;const t=O();t?.canOrders&&ye(e.container,i("Store","desktop-mode"),"store",t.canCustomers?6:3,async()=>{const o=await Y("store");if("error"in o)return o;const{data:n}=o,r=Number(n.customers)||0,s=Number(n.vips)||0,a=Number(n.lapsed)||0,d=Number(n.guestOrders)||0;let c=null;return n.bandsCapped?c=i("Not counted on a store this large","desktop-mode"):(s>0||a>0)&&(c=m(i("%1$d · %2$d","desktop-mode"),s,a)),{rows:[l(i("Revenue this month","desktop-mode"),n.revenue),l(i("Awaiting action","desktop-mode"),m(i("%d orders","desktop-mode"),n.processing)),l(i("Out of stock","desktop-mode"),n.outOfStock>0?m(i("%d products","desktop-mode"),n.outOfStock):i("None","desktop-mode")),l(i("Customers","desktop-mode"),r>0?m(I("%d person","%d people",r),r):null),l(i("VIP · lapsed","desktop-mode"),c),l(i("Guest checkout","desktop-mode"),n.guestSpend?m(i("%1$s over %2$d orders","desktop-mode"),n.guestSpend,d):null)]}})});const H="desktop-mode-woo-customer";function Pt(e,t,o){const r=e.closest('[id^="wp-window-"]')?.id.slice(10);if(!r)return;const s=window.wp?.os?.relations?.set;typeof s=="function"&&s(r,t>0?{type:"user",id:t,label:o||void 0}:null)}function Te(e,t){if(!Number.isFinite(e)||e<=0)return!1;const o=window.wp?.os?.openWindow;return typeof o!="function"?!1:o(H,{source:"woocommerce/customer-tile",params:{customerId:e,customerName:t}})===!0}Ue({id:"desktop-mode/woo-customer",nativeWindowId:H,matches:(e,t)=>t.searchParams.get(Le)==="wc-customer"&&Number(t.searchParams.get("user_id"))>0,params:(e,t)=>({customerId:Number(t.searchParams.get("user_id"))||0})}),R("os.my-wordpress.user-activate","desktop-mode/woocommerce",(e,t)=>{if(e||t.entityId!==L)return e;const o=Number(t.item?.id),n=String(t.item?.name??"");return Te(o,n)}),R("os.my-wordpress.tile-context-menu","desktop-mode/woocommerce",(e,t)=>{if(t.kind!=="user"||t.entityId!==L||!Array.isArray(e))return e;const o=Number(t.item?.id),n=String(t.item?.name??""),r=B(t.item),s=e.filter(d=>d?.id!=="footprint"&&d?.id!=="author-archive"),a=[{id:"wc-customer-window",label:i("Open customer","desktop-mode"),icon:"dashicons-businessperson",onSelect:()=>{Te(o,n)}}];return r?.ordersUrl&&a.push({id:"wc-customer-orders",label:i("View their orders","desktop-mode"),icon:"dashicons-cart",onSelect:()=>{W(r.ordersUrl,i("Orders","desktop-mode"))}}),[...a,...s]});const f="os-woo-customer-window";function V(e,t,o=""){const n=document.createElement("div");n.className=`${f}__stat`;const r=document.createElement("div");r.className=`${f}__stat-value`,r.textContent=e,n.appendChild(r);const s=document.createElement("div");if(s.className=`${f}__stat-label`,s.textContent=t,n.appendChild(s),o){const a=document.createElement("div");a.className=`${f}__stat-hint`,a.textContent=o,n.appendChild(a)}return n}function ee(e,t){if(!t)return null;const o=document.createElement("section");o.className=`${f}__section`;const n=document.createElement("h3");return n.className=`${f}__section-title`,n.textContent=e,o.append(n,t),o}function Wt(e){const t=document.createElement("header");if(t.className=`${f}__header`,e.avatar){const s=document.createElement("img");s.className=`${f}__avatar`,s.src=e.avatar,s.alt="",s.width=64,s.height=64,t.appendChild(s)}const o=document.createElement("div");o.className=`${f}__identity`;const n=document.createElement("h2");n.className=`${f}__name`,n.textContent=e.name||e.username||`#${e.id}`,o.appendChild(n);const r=[e.email,e.phone].filter(Boolean).join(" · ");if(r){const s=document.createElement("p");s.className=`${f}__contact`,s.textContent=r,o.appendChild(s)}if(e.bandLabel){const s=document.createElement("os-badge");s.setAttribute("tone",Ne(e.band)),s.className=`${f}__band`,s.textContent=e.bandLabel,o.appendChild(s)}return t.appendChild(o),t}function Mt(e){const t=document.createElement("div");t.className=`${f}__stats`;const o=Number(e.orders)||0;return t.append(V(e.spend||"—",i("Lifetime spend","desktop-mode"),e.aov?m(i("%s average","desktop-mode"),e.aov):""),V(String(o),I("Order","Orders",o),e.firstOrder?m(i("since %s","desktop-mode"),S(e.firstOrder)):""),V(Ee(e.daysSince??null)||"—",i("Last order","desktop-mode"),e.lastOrderTotal),V(e.location||"—",i("Location","desktop-mode"),e.registered?m(i("joined %s","desktop-mode"),S(e.registered)):"")),t}function qt(e){const t=Array.isArray(e.recentOrders)?e.recentOrders:[];if(t.length===0)return null;const o=document.createElement("ul");o.className=`${f}__orders`;for(const n of t){const r=document.createElement("li");r.className=`${f}__order`;const s=document.createElement("div");s.className=`${f}__order-head`,s.appendChild(y(m(i("#%s","desktop-mode"),n.number),n.editUrl));const a=document.createElement("os-badge");a.setAttribute("tone",Ce(n.status)),a.textContent=n.statusLabel,s.appendChild(a),r.appendChild(s);const d=document.createElement("div");d.className=`${f}__order-meta`,d.textContent=[S(n.date),m(I("%d item","%d items",n.items),n.items)].filter(Boolean).join(" · "),r.appendChild(d);const c=document.createElement("div");c.className=`${f}__order-total`,c.textContent=n.total,r.appendChild(c),o.appendChild(r)}return o}function Ft(e){const t=[];if(e.billing&&t.push([i("Billing","desktop-mode"),e.billing]),e.shipping&&e.shipping!==e.billing&&t.push([i("Shipping","desktop-mode"),e.shipping]),t.length===0)return null;const o=document.createElement("div");o.className=`${f}__addresses`;for(const[n,r]of t){const s=document.createElement("div");s.className=`${f}__address`;const a=document.createElement("div");a.className=`${f}__address-label`,a.textContent=n;const d=document.createElement("div");d.className=`${f}__address-value`,d.textContent=r,s.append(a,d),o.appendChild(s)}return o}function Dt(e){const t=document.createElement("footer");t.className=`${f}__actions`;const o=(n,r,s)=>{const a=document.createElement("os-button");a.setAttribute("variant",r),a.textContent=n,a.addEventListener("click",s),t.appendChild(a)};return e.ordersUrl&&Number(e.orders)>0&&o(i("All orders","desktop-mode"),"primary",()=>W(e.ordersUrl,i("Orders","desktop-mode"))),e.profileUrl&&o(i("Edit profile","desktop-mode"),"secondary",()=>W(e.profileUrl,e.name)),e.email&&o(i("Send email","desktop-mode"),"secondary",()=>{window.location.href=`mailto:${encodeURIComponent(e.email)}`}),t}let Ie=0;async function jt(e,t,o){const n=++Ie,r=()=>!e.isConnected||n!==Ie,s=document.createElement("div");if(s.className=`${f}__loading`,s.appendChild(document.createElement("os-spinner")),e.replaceChildren(s),!Number.isFinite(t)||t<=0){const u=document.createElement("p");u.className=`${f}__empty`,u.textContent=i("No customer selected. Open one from the Customers folder.","desktop-mode"),e.replaceChildren(u);return}const a=await Y(`summary/customer/${t}`);if(r())return;if("error"in a){const u=document.createElement("p");u.className=`${f}__empty`,u.textContent=a.error,e.replaceChildren(u);return}const d=a.data,c=document.createDocumentFragment();c.append(Wt(d),Mt(d));const p=d.favourite?(()=>{const u=document.createElement("p");return u.className=`${f}__favourite`,u.appendChild(y(d.favourite.label,d.favourite.editUrl)),d.favourite.quantity>1&&u.appendChild(document.createTextNode(` · ${m(i("×%d bought","desktop-mode"),d.favourite.quantity)}`)),u})():null;for(const u of[ee(i("Buys most","desktop-mode"),p),ee(i("Recent orders","desktop-mode"),qt(d)),ee(i("Addresses","desktop-mode"),Ft(d))])u&&c.appendChild(u);c.appendChild(Dt(d)),e.replaceChildren(c),e.dataset.customerId=String(t),e.dataset.customerName=d.name||o}const te=window;te.openStationNativeWindows=te.openStationNativeWindows??{},te.openStationNativeWindows[H]=(e,t)=>{const o=e.querySelector("[data-os-woo-customer-root]")??e,n=s=>{const a=Number(s.customerId??0),d=String(s.customerName??"");Pt(e,a,d),jt(o,a,d)};n(t?.params??{});const r=s=>{const a=s.detail;a?.windowId!==H||!o.isConnected||n(a.params??{})};return document.addEventListener("os-window-reopened",r),()=>{document.removeEventListener("os-window-reopened",r)}}})(); |