PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.12
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.12
1.1.13 1.1.12 1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 All 37 releases
← All changes | assets/js/apps/my-wordpress.min.js +229 -229 1.1.9 → 1.1.12 View file →
@@ -1,20 +1,20 @@
1 -var openStationApp_myWordpress=function(E){"use strict";const et="desktop-mode";function De(){return window.wp?.i18n}function r(e,t=et){return De()?.__(e,t)??e}function q(e,t,s,n=et){return De()?._n(e,t,s,n)??(s===1?e:t)}function b(e,...t){const s=De()?.sprintf;if(s)return s(e,...t);let n=0;return e.replace(/%(?:(\d+)\$)?[sd]/g,(o,i)=>{const a=i?Number.parseInt(i,10)-1:n++;return String(t[a]??"")})}function c(e,...t){return{__wpdHtml:!0,strings:e,values:t}}function Jt(e){return!!e&&e.__wpdHtml===!0}const xt="$$wpd$$",D=/\$\$wpd\$\$(\d+)\$\$/g,es="$$wpd-node$$",ts=/^\$\$wpd-node\$\$(\d+)\$\$$/,ss=new Set(["style","script","textarea","title"]);function ns(e){let t="",s=!1,n=null,o=!1,i=null,a="",l=!1;for(let d=0;d<e.length;d++){const u=e[d];t+=u;for(let p=0;p<u.length;p++){const f=u[p];if(o){u.startsWith("-->",p)&&(o=!1,p+=2);continue}if(i!==null){f==="<"&&u[p+1]==="/"&&u.slice(p+2,p+2+i.length).toLowerCase()===i&&(p+=1+i.length,i=null,s=!0,l=!1,a="");continue}if(n!==null){f===n&&(n=null);continue}if(s){f==='"'||f==="'"?(n=f,l=!1):f===">"?(s=!1,l=!1,ss.has(a)&&(i=a),a=""):l&&(/[a-zA-Z0-9-]/.test(f)?a+=f.toLowerCase():l=!1);continue}if(u.startsWith("<!--",p)){o=!0,p+=3;continue}const m=u[p+1]??"";f==="<"&&/[a-zA-Z/!]/.test(m)&&(s=!0,a="",l=/[a-zA-Z]/.test(m))}d<e.length-1&&(t+=s||o||i!==null?`${xt}${d}$$`:`<!--${es}${d}$$-->`)}return t}const tt=new WeakMap;function st(e){const t=tt.get(e);if(t)return t;const s=document.createElement("template");s.innerHTML=ns(e);const n=[],o=(l,d)=>{if(l.nodeType===Node.ELEMENT_NODE){const f=l;for(const m of Array.from(f.attributes)){const h=m.name,$=m.value,v=h[0];if(D.test($))if(D.lastIndex=0,v==="@"){const w=D.exec($);D.lastIndex=0,n.push({path:d,kind:"event",name:h.slice(1),valueIndex:w?Number(w[1]):0}),f.removeAttribute(h)}else if(v==="."){const w=D.exec($);D.lastIndex=0,n.push({path:d,kind:"prop",name:h.slice(1),valueIndex:w?Number(w[1]):0}),f.removeAttribute(h)}else if(v==="?"){const w=D.exec($);D.lastIndex=0,n.push({path:d,kind:"bool",name:h.slice(1),valueIndex:w?Number(w[1]):0}),f.removeAttribute(h)}else{const w=[],g=[];let y=0,_;for(D.lastIndex=0;(_=D.exec($))!==null;)w.push($.slice(y,_.index)),g.push(Number(_[1])),y=_.index+_[0].length;w.push($.slice(y)),n.push({path:d,kind:"attr",name:h,template:w,valueIndices:g}),f.setAttribute(h,"")}}}const u=Array.from(l.childNodes);let p=0;for(let f=0;f<u.length;f++){const m=u[f],h=f+p;if(m.nodeType===Node.COMMENT_NODE){const $=ts.exec(m.data);if($){const v=document.createTextNode("");m.parentNode.replaceChild(v,m),n.push({path:[...d,h],kind:"node",valueIndex:Number($[1])})}continue}if(m.nodeType===Node.TEXT_NODE){const $=m.textContent||"";if(!D.test($)){D.lastIndex=0;continue}D.lastIndex=0;const v=m.parentNode;let w=0,g;const y=[],_=[];for(D.lastIndex=0;(g=D.exec($))!==null;){g.index>w&&y.push(document.createTextNode($.slice(w,g.index)));const M=document.createTextNode("");y.push(M),_.push({path:[...d,h+y.length-1],kind:"node",valueIndex:Number(g[1])}),w=g.index+g[0].length}w<$.length&&y.push(document.createTextNode($.slice(w)));for(const M of y)v.insertBefore(M,m);v.removeChild(m),p+=y.length-1,n.push(..._)}else o(m,[...d,h])}};o(s.content,[]);const a={template:s,buildParts:l=>{const d=[];for(const u of n){let p=l;for(const f of u.path)p=p.childNodes[f];u.kind==="node"?d.push({kind:"node",valueIndex:u.valueIndex,child:{anchor:p,state:null}}):u.kind==="attr"?d.push({kind:"attr",element:p,name:u.name,template:u.template,valueIndices:u.valueIndices}):u.kind==="event"?d.push({kind:"event",valueIndex:u.valueIndex,element:p,name:u.name}):u.kind==="prop"?d.push({kind:"prop",valueIndex:u.valueIndex,element:p,name:u.name}):u.kind==="bool"&&d.push({kind:"bool",valueIndex:u.valueIndex,element:p,name:u.name})}return d}};return tt.set(e,a),a}const nt=new WeakMap;function os(e,t){for(const s of e.nodes)if(s.parentNode!==t)return!1;return!0}function is(e,t){const s=nt.get(t);if(s&&s.strings===e.strings&&os(s,t)){ae(s.parts,e.values);return}const n=st(e.strings),o=n.template.content.cloneNode(!0),i=n.buildParts(o),a=Array.from(o.childNodes);for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(o),ae(i,e.values),nt.set(t,{strings:e.strings,parts:i,nodes:a})}function ae(e,t){for(const s of e)if(s.kind==="node")le(s.child,t[s.valueIndex]);else if(s.kind==="attr"){let n=s.template[0];for(let o=0;o<s.valueIndices.length;o++)n+=ot(t[s.valueIndices[o]]),n+=s.template[o+1];n!==s.last&&(s.last=n,n===""?s.element.removeAttribute(s.name):s.element.setAttribute(s.name,n))}else if(s.kind==="event"){const n=t[s.valueIndex];n!==s.current&&(s.current&&s.element.removeEventListener(s.name,s.current),n&&s.element.addEventListener(s.name,n),s.current=n)}else if(s.kind==="prop"){const n=t[s.valueIndex];n!==s.last&&(s.last=n,s.element[s.name]=n)}else if(s.kind==="bool"){const n=!!t[s.valueIndex];n!==s.last&&(s.last=n,n?s.element.setAttribute(s.name,""):s.element.removeAttribute(s.name))}}function le(e,t){if(t==null||t===!1){e.state&&(F(e.state),e.state=null);return}if(Array.isArray(t)){ds(e,t);return}if(Jt(t)){ls(e,t);return}if(t instanceof Node){rs(e,t);return}as(e,ot(t))}function rs(e,t){const s=e.state;s?.shape==="node"&&s.node===t||(s&&F(s),J(e,[t]),e.state={shape:"node",node:t})}function as(e,t){const s=e.state;if(s?.shape==="text"){s.text!==t&&(s.node.textContent=t,s.text=t);return}s&&F(s);const n=document.createTextNode(t);J(e,[n]),e.state={shape:"text",node:n,text:t}}function ls(e,t){const s=e.state;if(s?.shape==="template"&&s.strings===t.strings){ae(s.parts,t.values);return}s&&F(s);const n=st(t.strings),o=n.template.content.cloneNode(!0),i=n.buildParts(o),a=Array.from(o.childNodes);J(e,[o]),ae(i,t.values),e.state={shape:"template",strings:t.strings,parts:i,nodes:a}}function ds(e,t){const s=e.state;if(s?.shape==="array"){const o=Math.min(s.entries.length,t.length);for(let i=0;i<o;i++)le(s.entries[i],t[i]);if(t.length<s.entries.length){for(let i=t.length;i<s.entries.length;i++){const a=s.entries[i];a.state&&F(a.state),a.anchor.remove()}s.entries.length=t.length}else for(let i=s.entries.length;i<t.length;i++){const a=document.createTextNode("");J(e,[a]);const l={anchor:a,state:null};le(l,t[i]),s.entries.push(l)}return}s&&F(s);const n=[];for(const o of t){const i=document.createTextNode("");J(e,[i]);const a={anchor:i,state:null};le(a,o),n.push(a)}e.state={shape:"array",entries:n}}function J(e,t){const s=e.anchor.parentNode;if(s)for(const n of t)s.insertBefore(n,e.anchor)}function F(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&&(F(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&&F(t.state),t.anchor.remove()}function ot(e){return e==null||e===!1?"":String(e)}function I(e,t="short"){if(e===""||e===null||e===void 0)return"";const s=typeof e=="string"&&/^\d{4}-\d{2}$/.test(e)?`${e}-01T00:00:00`:e,n=s instanceof Date?s:new Date(s);if(Number.isNaN(n.getTime()))return String(e);try{switch(t){case"long":return n.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});case"month":return n.toLocaleDateString(void 0,{year:"numeric",month:"long"});case"datetime":return n.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"});case"iso":return n.toISOString();default:return n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}}catch{return String(e)}}function cs(){let e="";const t=new Map;let s=0,n=1,o=0,i=!1,a=!0,l=null,d,u=async()=>{},p=()=>{};const f=()=>{const $=[],v=new Set;for(const w of Array.from(t.keys()).sort((g,y)=>g-y))for(const g of t.get(w)??[])v.has(g.id)||(v.add(g.id),$.push(g));return $},m=()=>n>Math.max(...Array.from(t.keys()),1),h=$=>{!$.some(v=>v.isIntersecting)||i||!a||(a=!1,i=!0,o=Math.max(1,...Array.from(t.keys()))+1,p(),u().finally(()=>{i=!1,o=0,p()}))};return{accumulate($,v){return v?(e!==$&&(e=$,t.clear()),t.set(v.page,v.items),s=v.total,n=v.pages,f()):(e="",t.clear(),s=0,n=1,[])},items:f,get total(){return s},get pageCount(){return n},get loadingPage(){return o},hasMore:m,ghosts($){return o===0||t.has(o)||!m()?0:Math.max(1,Math.min($,s-f().length))},sync($){u=$.load,p=$.repaint,!d&&typeof IntersectionObserver<"u"&&(d=new IntersectionObserver(h)),d?.disconnect(),$.sentinel&&d?.observe($.sentinel),$.canvas!==l&&(l=$.canvas,l?.addEventListener("scroll",()=>{a=!0},{passive:!0})),l&&l.scrollHeight<=l.clientHeight+4&&(a=!0)},dispose(){d?.disconnect(),d=void 0}}}function it(e,t,s,n){if(n.shift&&e.length>0){const o=e[e.length-1],i=t.indexOf(o),a=t.indexOf(s);if(i!==-1&&a!==-1){const l=t.slice(Math.min(i,a),Math.max(i,a)+1),d=new Set([...e,...l]);return Array.from(d)}}return n.ctrl?e.includes(s)?e.filter(o=>o!==s):[...e,s]:[s]}function us(e){const{root:t,select:s}=e,n=e.item??"[data-item-id]";let o=null;const i=d=>{if(d.button!==0||!d.target?.closest(e.canvas)||d.target.closest(n))return;const p=document.createElement("div");p.className=e.className??"os-app__marquee",document.body.appendChild(p),o={x:d.clientX,y:d.clientY,box:p},!d.ctrlKey&&!d.metaKey&&!d.shiftKey&&s([])},a=d=>{if(!o)return;const u=Math.min(o.x,d.clientX),p=Math.min(o.y,d.clientY),f=Math.abs(d.clientX-o.x),m=Math.abs(d.clientY-o.y);Object.assign(o.box.style,{left:`${u}px`,top:`${p}px`,width:`${f}px`,height:`${m}px`});const h=[];for(const $ of Array.from(t.querySelectorAll(n))){const v=$.getBoundingClientRect();v.left<u+f&&v.right>u&&v.top<p+m&&v.bottom>p&&h.push(Number($.getAttribute("data-item-id")))}s(h)},l=()=>{o&&(o.box.remove(),o=null)};return t.addEventListener("pointerdown",i),document.addEventListener("pointermove",a),document.addEventListener("pointerup",l),()=>{t.removeEventListener("pointerdown",i),document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",l),l()}}async function ps(e){if(e==="")return!1;const t=globalThis.navigator?.clipboard;if(t?.writeText)try{return await t.writeText(e),!0}catch{}return fs(e)}function fs(e){const t=globalThis.document;if(!t?.body||typeof t.execCommand!="function")return!1;const s=t.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.setAttribute("aria-hidden","true"),s.style.position="fixed",s.style.insetInlineStart="-9999px",s.style.opacity="0",t.body.appendChild(s);const n=t.activeElement;s.select();let o=!1;try{o=t.execCommand("copy")}catch{o=!1}return s.remove(),n?.focus?.(),o}const ms="data-os-mode";function H(e=typeof document<"u"?document.documentElement:null){return!!e&&e.getAttribute(ms)==="mobile"}function hs(e,t){const s=t.local??{},n={id:e,hasLocal:a=>Object.prototype.hasOwnProperty.call(s,a),runLocal:(a,l,d,u)=>{const p=s[a];if(!p)return l;const f={...l},m=p(f,d,u);return m===void 0?f:m},render:a=>{is(t.view(a),a.root),t.updated?.(a)},mounted:a=>t.mounted?.(a)},{placeholder:o}=t;o&&(n.placeholder=a=>o(a));const i=window;return(i.openStationApps??(i.openStationApps={}))[e]=n,n}function T(){return window.wp?.os??{}}function gs(){return{menu:null,folderSel:null,quickEdit:null,trashHidden:new Map,trashPage:null,previewTarget:0,previewScope:"",previewLoading:!1,previewRevision:0,previewError:!1,zoom:!1,columnsMenu:null,revealSelection:!1,list:cs(),abilityQuery:"",abilityOpen:new Map,nameError:"",agentDraft:null,agentDraftFor:0,agentBusy:!1,agentBackfilled:new Set,agentDropTargets:new Map,rosterStamp:"",chatAfterCreate:!1,fp:null}}function k(e){return e.ui(gs)}const rt="__openStationSharedStores";function ys(){const e=window;let t=e[rt];return t||(t=new Map,e[rt]=t),t}function de(e,t){const s=ys();let n=s.get(e);n||(n={state:t(),listeners:new Set,rebuild:t},s.set(e,n));const o={get state(){return n.state},set state(i){n.state=i},getState(){return n.state},notify(){for(const i of Array.from(n.listeners))try{i(n.state)}catch(a){console.error(`[desktop-mode/shared-store:${e}] subscriber threw:`,a)}},subscribe(i){return n.listeners.add(i),()=>{n.listeners.delete(i)}},setState(i){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,i),o.notify()},reset(){const i=n.rebuild(),a=n.state;if(typeof a=="object"&&a!==null&&typeof i=="object"&&i!==null){const l=a;for(const d of Object.keys(l))delete l[d];Object.assign(l,i)}else n.state=i;n.listeners.clear()}};return o}const L=de("openstation/trash-optimistic",()=>({changes:new Map,reconcile:new Set})),$s=e=>`${e.type}:${e.id}`;function ws(e){return{subtitle:"",mime:"",preview:"",icon:"",deleted_at:new Date().toISOString(),deleted_by:"",deleted_by_id:0,can_restore:!1,can_purge:!1,edit_link:"",...e}}function ce(){return Array.from(L.state.changes.values())}function _s(e,t){const s=L.subscribe(e);return t&&L.state.reconcile.add(t),()=>{s(),t&&L.state.reconcile.delete(t)}}function vs(e,t="in"){const s=$s(e);if(L.state.changes.get(s)?.pending)return null;const n={item:e,direction:t,pending:!0};return L.state.changes.set(s,n),L.notify(),{async finish(o){L.state.changes.get(s)!==n||!n.pending||(n.pending=!1,o&&(L.notify(),await Promise.allSettled(Array.from(L.state.reconcile,async i=>i()))),L.state.changes.get(s)===n&&(L.state.changes.delete(s),L.notify()))}}}function ue(e=null){const t=e??(typeof document<"u"?document.documentElement:null);return t&&H(t)?!0:typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function pe(e){return[e.section,e.query,e.sort].join("|")}function fe(e,t,s){const n=e.filter(i=>{if(i.sections&&i.sections.length>0&&!(i.sections.includes(t.entityId)||i.sections.includes("*")||!!t.postType&&i.sections.includes(t.postType)))return!1;if(i.mime){if(!t.mime)return!1;try{if(!new RegExp(i.mime).test(t.mime))return!1}catch{return!1}}return!0}),o=s?.applyFilters("os.my-wordpress.preview-actions",n,t);return Array.isArray(o)?o:n}function x(e,t,s){return{entityId:e.id,kind:e.kind,postType:e.post_type,mime:t.mime||void 0,item:t,itemId:t.id,surface:s}}function at(e,t){try{e.onSelect?.(t)}catch{console.error(`[my-wordpress] preview action ${e.id} threw.`)}}function X(e,t){return e.sections.find(s=>s.id===t)??null}function lt(e,t){const s=e?.applyFilters("os.my-wordpress.list-bands",null,t);return!s||!Array.isArray(s.bands)||s.bands.length===0||typeof s.assign!="function"?null:s}function Le(e,t){return e.startsWith("dashicons-")?c`<span class="${t} dashicons ${e}" aria-hidden="true"></span>`:c`<span
1 +var openStationApp_myWordpress=function(E){"use strict";const st="desktop-mode";function Le(){return window.wp?.i18n}function r(e,t=st){return Le()?.__(e,t)??e}function B(e,t,s,n=st){return Le()?._n(e,t,s,n)??(s===1?e:t)}function b(e,...t){const s=Le()?.sprintf;if(s)return s(e,...t);let n=0;return e.replace(/%(?:(\d+)\$)?[sd]/g,(o,i)=>{const a=i?Number.parseInt(i,10)-1:n++;return String(t[a]??"")})}function c(e,...t){return{__wpdHtml:!0,strings:e,values:t}}function es(e){return!!e&&e.__wpdHtml===!0}const ts="$$wpd$$",D=/\$\$wpd\$\$(\d+)\$\$/g,ss="$$wpd-node$$",ns=/^\$\$wpd-node\$\$(\d+)\$\$$/,os=new Set(["style","script","textarea","title"]);function is(e){let t="",s=!1,n=null,o=!1,i=null,a="",l=!1;for(let u=0;u<e.length;u++){const d=e[u];t+=d;for(let p=0;p<d.length;p++){const f=d[p];if(o){d.startsWith("-->",p)&&(o=!1,p+=2);continue}if(i!==null){f==="<"&&d[p+1]==="/"&&d.slice(p+2,p+2+i.length).toLowerCase()===i&&(p+=1+i.length,i=null,s=!0,l=!1,a="");continue}if(n!==null){f===n&&(n=null);continue}if(s){f==='"'||f==="'"?(n=f,l=!1):f===">"?(s=!1,l=!1,os.has(a)&&(i=a),a=""):l&&(/[a-zA-Z0-9-]/.test(f)?a+=f.toLowerCase():l=!1);continue}if(d.startsWith("<!--",p)){o=!0,p+=3;continue}const m=d[p+1]??"";f==="<"&&/[a-zA-Z/!]/.test(m)&&(s=!0,a="",l=/[a-zA-Z]/.test(m))}u<e.length-1&&(t+=s||o||i!==null?`${ts}${u}$$`:`<!--${ss}${u}$$-->`)}return t}const nt=new WeakMap;function ot(e){const t=nt.get(e);if(t)return t;const s=document.createElement("template");s.innerHTML=is(e);const n=[],o=(l,u)=>{if(l.nodeType===Node.ELEMENT_NODE){const f=l;for(const m of Array.from(f.attributes)){const h=m.name,$=m.value,_=h[0];if(D.test($))if(D.lastIndex=0,_==="@"){const w=D.exec($);D.lastIndex=0,n.push({path:u,kind:"event",name:h.slice(1),valueIndex:w?Number(w[1]):0}),f.removeAttribute(h)}else if(_==="."){const w=D.exec($);D.lastIndex=0,n.push({path:u,kind:"prop",name:h.slice(1),valueIndex:w?Number(w[1]):0}),f.removeAttribute(h)}else if(_==="?"){const w=D.exec($);D.lastIndex=0,n.push({path:u,kind:"bool",name:h.slice(1),valueIndex:w?Number(w[1]):0}),f.removeAttribute(h)}else{const w=[],g=[];let y=0,v;for(D.lastIndex=0;(v=D.exec($))!==null;)w.push($.slice(y,v.index)),g.push(Number(v[1])),y=v.index+v[0].length;w.push($.slice(y)),n.push({path:u,kind:"attr",name:h,template:w,valueIndices:g}),f.setAttribute(h,"")}}}const d=Array.from(l.childNodes);let p=0;for(let f=0;f<d.length;f++){const m=d[f],h=f+p;if(m.nodeType===Node.COMMENT_NODE){const $=ns.exec(m.data);if($){const _=document.createTextNode("");m.parentNode.replaceChild(_,m),n.push({path:[...u,h],kind:"node",valueIndex:Number($[1])})}continue}if(m.nodeType===Node.TEXT_NODE){const $=m.textContent||"";if(!D.test($)){D.lastIndex=0;continue}D.lastIndex=0;const _=m.parentNode;let w=0,g;const y=[],v=[];for(D.lastIndex=0;(g=D.exec($))!==null;){g.index>w&&y.push(document.createTextNode($.slice(w,g.index)));const M=document.createTextNode("");y.push(M),v.push({path:[...u,h+y.length-1],kind:"node",valueIndex:Number(g[1])}),w=g.index+g[0].length}w<$.length&&y.push(document.createTextNode($.slice(w)));for(const M of y)_.insertBefore(M,m);_.removeChild(m),p+=y.length-1,n.push(...v)}else o(m,[...u,h])}};o(s.content,[]);const a={template:s,buildParts:l=>{const u=[];for(const d of n){let p=l;for(const f of d.path)p=p.childNodes[f];d.kind==="node"?u.push({kind:"node",valueIndex:d.valueIndex,child:{anchor:p,state:null}}):d.kind==="attr"?u.push({kind:"attr",element:p,name:d.name,template:d.template,valueIndices:d.valueIndices}):d.kind==="event"?u.push({kind:"event",valueIndex:d.valueIndex,element:p,name:d.name}):d.kind==="prop"?u.push({kind:"prop",valueIndex:d.valueIndex,element:p,name:d.name}):d.kind==="bool"&&u.push({kind:"bool",valueIndex:d.valueIndex,element:p,name:d.name})}return u}};return nt.set(e,a),a}const it=new WeakMap;function rs(e,t){for(const s of e.nodes)if(s.parentNode!==t)return!1;return!0}function as(e,t){const s=it.get(t);if(s&&s.strings===e.strings&&rs(s,t)){le(s.parts,e.values);return}const n=ot(e.strings),o=n.template.content.cloneNode(!0),i=n.buildParts(o),a=Array.from(o.childNodes);for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(o),le(i,e.values),it.set(t,{strings:e.strings,parts:i,nodes:a})}function le(e,t){for(const s of e)if(s.kind==="node")de(s.child,t[s.valueIndex]);else if(s.kind==="attr"){let n=s.template[0];for(let o=0;o<s.valueIndices.length;o++)n+=rt(t[s.valueIndices[o]]),n+=s.template[o+1];n!==s.last&&(s.last=n,n===""?s.element.removeAttribute(s.name):s.element.setAttribute(s.name,n))}else if(s.kind==="event"){const n=t[s.valueIndex];n!==s.current&&(s.current&&s.element.removeEventListener(s.name,s.current),n&&s.element.addEventListener(s.name,n),s.current=n)}else if(s.kind==="prop"){const n=t[s.valueIndex];n!==s.last&&(s.last=n,s.element[s.name]=n)}else if(s.kind==="bool"){const n=!!t[s.valueIndex];n!==s.last&&(s.last=n,n?s.element.setAttribute(s.name,""):s.element.removeAttribute(s.name))}}function de(e,t){if(t==null||t===!1){e.state&&(F(e.state),e.state=null);return}if(Array.isArray(t)){us(e,t);return}if(es(t)){cs(e,t);return}if(t instanceof Node){ls(e,t);return}ds(e,rt(t))}function ls(e,t){const s=e.state;s?.shape==="node"&&s.node===t||(s&&F(s),x(e,[t]),e.state={shape:"node",node:t})}function ds(e,t){const s=e.state;if(s?.shape==="text"){s.text!==t&&(s.node.textContent=t,s.text=t);return}s&&F(s);const n=document.createTextNode(t);x(e,[n]),e.state={shape:"text",node:n,text:t}}function cs(e,t){const s=e.state;if(s?.shape==="template"&&s.strings===t.strings){le(s.parts,t.values);return}s&&F(s);const n=ot(t.strings),o=n.template.content.cloneNode(!0),i=n.buildParts(o),a=Array.from(o.childNodes);x(e,[o]),le(i,t.values),e.state={shape:"template",strings:t.strings,parts:i,nodes:a}}function us(e,t){const s=e.state;if(s?.shape==="array"){const o=Math.min(s.entries.length,t.length);for(let i=0;i<o;i++)de(s.entries[i],t[i]);if(t.length<s.entries.length){for(let i=t.length;i<s.entries.length;i++){const a=s.entries[i];a.state&&F(a.state),a.anchor.remove()}s.entries.length=t.length}else for(let i=s.entries.length;i<t.length;i++){const a=document.createTextNode("");x(e,[a]);const l={anchor:a,state:null};de(l,t[i]),s.entries.push(l)}return}s&&F(s);const n=[];for(const o of t){const i=document.createTextNode("");x(e,[i]);const a={anchor:i,state:null};de(a,o),n.push(a)}e.state={shape:"array",entries:n}}function x(e,t){const s=e.anchor.parentNode;if(s)for(const n of t)s.insertBefore(n,e.anchor)}function F(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&&(F(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&&F(t.state),t.anchor.remove()}function rt(e){return e==null||e===!1?"":String(e)}function I(e,t="short"){if(e===""||e===null||e===void 0)return"";const s=typeof e=="string"&&/^\d{4}-\d{2}$/.test(e)?`${e}-01T00:00:00`:e,n=s instanceof Date?s:new Date(s);if(Number.isNaN(n.getTime()))return String(e);try{switch(t){case"long":return n.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"});case"month":return n.toLocaleDateString(void 0,{year:"numeric",month:"long"});case"datetime":return n.toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"});case"iso":return n.toISOString();default:return n.toLocaleDateString(void 0,{month:"short",day:"numeric"})}}catch{return String(e)}}function ps(){let e="";const t=new Map;let s=0,n=1,o=0,i=!1,a=!0,l=null,u,d=async()=>{},p=()=>{};const f=()=>{const $=[],_=new Set;for(const w of Array.from(t.keys()).sort((g,y)=>g-y))for(const g of t.get(w)??[])_.has(g.id)||(_.add(g.id),$.push(g));return $},m=()=>n>Math.max(...Array.from(t.keys()),1),h=$=>{!$.some(_=>_.isIntersecting)||i||!a||(a=!1,i=!0,o=Math.max(1,...Array.from(t.keys()))+1,p(),d().finally(()=>{i=!1,o=0,p()}))};return{accumulate($,_){return _?(e!==$&&(e=$,t.clear()),t.set(_.page,_.items),s=_.total,n=_.pages,f()):(e="",t.clear(),s=0,n=1,[])},items:f,get total(){return s},get pageCount(){return n},get loadingPage(){return o},hasMore:m,ghosts($){return o===0||t.has(o)||!m()?0:Math.max(1,Math.min($,s-f().length))},sync($){d=$.load,p=$.repaint,!u&&typeof IntersectionObserver<"u"&&(u=new IntersectionObserver(h)),u?.disconnect(),$.sentinel&&u?.observe($.sentinel),$.canvas!==l&&(l=$.canvas,l?.addEventListener("scroll",()=>{a=!0},{passive:!0})),l&&l.scrollHeight<=l.clientHeight+4&&(a=!0)},dispose(){u?.disconnect(),u=void 0}}}function at(e,t,s,n){if(n.shift&&e.length>0){const o=e[e.length-1],i=t.indexOf(o),a=t.indexOf(s);if(i!==-1&&a!==-1){const l=t.slice(Math.min(i,a),Math.max(i,a)+1),u=new Set([...e,...l]);return Array.from(u)}}return n.ctrl?e.includes(s)?e.filter(o=>o!==s):[...e,s]:[s]}function fs(e){const{root:t,select:s}=e,n=e.item??"[data-item-id]";let o=null;const i=u=>{if(u.button!==0||!u.target?.closest(e.canvas)||u.target.closest(n))return;const p=document.createElement("div");p.className=e.className??"os-app__marquee",document.body.appendChild(p),o={x:u.clientX,y:u.clientY,box:p},!u.ctrlKey&&!u.metaKey&&!u.shiftKey&&s([])},a=u=>{if(!o)return;const d=Math.min(o.x,u.clientX),p=Math.min(o.y,u.clientY),f=Math.abs(u.clientX-o.x),m=Math.abs(u.clientY-o.y);Object.assign(o.box.style,{left:`${d}px`,top:`${p}px`,width:`${f}px`,height:`${m}px`});const h=[];for(const $ of Array.from(t.querySelectorAll(n))){const _=$.getBoundingClientRect();_.left<d+f&&_.right>d&&_.top<p+m&&_.bottom>p&&h.push(Number($.getAttribute("data-item-id")))}s(h)},l=()=>{o&&(o.box.remove(),o=null)};return t.addEventListener("pointerdown",i),document.addEventListener("pointermove",a),document.addEventListener("pointerup",l),()=>{t.removeEventListener("pointerdown",i),document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",l),l()}}async function ms(e){if(e==="")return!1;const t=globalThis.navigator?.clipboard;if(t?.writeText)try{return await t.writeText(e),!0}catch{}return hs(e)}function hs(e){const t=globalThis.document;if(!t?.body||typeof t.execCommand!="function")return!1;const s=t.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.setAttribute("aria-hidden","true"),s.style.position="fixed",s.style.insetInlineStart="-9999px",s.style.opacity="0",t.body.appendChild(s);const n=t.activeElement;s.select();let o=!1;try{o=t.execCommand("copy")}catch{o=!1}return s.remove(),n?.focus?.(),o}const gs="data-os-mode";function H(e=typeof document<"u"?document.documentElement:null){return!!e&&e.getAttribute(gs)==="mobile"}function ys(e,t){const s=t.local??{},n={id:e,hasLocal:a=>Object.prototype.hasOwnProperty.call(s,a),runLocal:(a,l,u,d)=>{const p=s[a];if(!p)return l;const f={...l},m=p(f,u,d);return m===void 0?f:m},render:a=>{as(t.view(a),a.root),t.updated?.(a)},mounted:a=>t.mounted?.(a)},{placeholder:o}=t;o&&(n.placeholder=a=>o(a));const i=window;return(i.openStationApps??(i.openStationApps={}))[e]=n,n}function T(){return window.wp?.os??{}}function $s(){return{menu:null,folderSel:null,quickEdit:null,trashHidden:new Map,trashPage:null,previewTarget:0,previewScope:"",previewLoading:!1,previewRevision:0,previewError:!1,zoom:!1,columnsMenu:null,revealSelection:!1,list:ps(),abilityQuery:"",abilityOpen:new Map,nameError:"",agentDraft:null,agentDraftFor:0,agentBusy:!1,agentBackfilled:new Set,agentDropTargets:new Map,rosterStamp:"",chatAfterCreate:!1,fp:null}}function k(e){return e.ui($s)}const lt="__openStationSharedStores";function ws(){const e=window;let t=e[lt];return t||(t=new Map,e[lt]=t),t}function ce(e,t){const s=ws();let n=s.get(e);n||(n={state:t(),listeners:new Set,rebuild:t},s.set(e,n));const o={get state(){return n.state},set state(i){n.state=i},getState(){return n.state},notify(){for(const i of Array.from(n.listeners))try{i(n.state)}catch(a){console.error(`[desktop-mode/shared-store:${e}] subscriber threw:`,a)}},subscribe(i){return n.listeners.add(i),()=>{n.listeners.delete(i)}},setState(i){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,i),o.notify()},reset(){const i=n.rebuild(),a=n.state;if(typeof a=="object"&&a!==null&&typeof i=="object"&&i!==null){const l=a;for(const u of Object.keys(l))delete l[u];Object.assign(l,i)}else n.state=i;n.listeners.clear()}};return o}const L=ce("openstation/trash-optimistic",()=>({changes:new Map,reconcile:new Set})),vs=e=>`${e.type}:${e.id}`;function _s(e){return{subtitle:"",mime:"",preview:"",icon:"",deleted_at:new Date().toISOString(),deleted_by:"",deleted_by_id:0,can_restore:!1,can_purge:!1,edit_link:"",...e}}function ue(){return Array.from(L.state.changes.values())}function bs(e,t){const s=L.subscribe(e);return t&&L.state.reconcile.add(t),()=>{s(),t&&L.state.reconcile.delete(t)}}function ks(e,t="in"){const s=vs(e);if(L.state.changes.get(s)?.pending)return null;const n={item:e,direction:t,pending:!0};return L.state.changes.set(s,n),L.notify(),{async finish(o){L.state.changes.get(s)!==n||!n.pending||(n.pending=!1,o&&(L.notify(),await Promise.allSettled(Array.from(L.state.reconcile,async i=>i()))),L.state.changes.get(s)===n&&(L.state.changes.delete(s),L.notify()))}}}function pe(e=null){const t=e??(typeof document<"u"?document.documentElement:null);return t&&H(t)?!0:typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer: coarse)").matches}function fe(e){return[e.section,e.query,e.sort].join("|")}function me(e,t,s){const n=e.filter(i=>{if(i.sections&&i.sections.length>0&&!(i.sections.includes(t.entityId)||i.sections.includes("*")||!!t.postType&&i.sections.includes(t.postType)))return!1;if(i.mime){if(!t.mime)return!1;try{if(!new RegExp(i.mime).test(t.mime))return!1}catch{return!1}}return!0}),o=s?.applyFilters("os.my-wordpress.preview-actions",n,t);return Array.isArray(o)?o:n}function ee(e,t,s){return{entityId:e.id,kind:e.kind,postType:e.post_type,mime:t.mime||void 0,item:t,itemId:t.id,surface:s}}function dt(e,t){try{e.onSelect?.(t)}catch{console.error(`[my-wordpress] preview action ${e.id} threw.`)}}function X(e,t){return e.sections.find(s=>s.id===t)??null}function ct(e,t){const s=e?.applyFilters("os.my-wordpress.list-bands",null,t);return!s||!Array.isArray(s.bands)||s.bands.length===0||typeof s.assign!="function"?null:s}function Pe(e,t){return e.startsWith("dashicons-")?c`<span class="${t} dashicons ${e}" aria-hidden="true"></span>`:c`<span
2 2 class="${t} os-mywp__icon-mask"
3 3 style="--mywp-icon:url(&quot;${e.replace(/"/g,"%22")}&quot;)"
4 4 aria-hidden="true"
5 - ></span>`}function dt(e,t){if(t.length<=e.length||!e.every((i,a)=>t[a]?.id===i.id))return t;const s=t.slice(e.length),n=s.filter(i=>i.id.startsWith("agent-send-to-"));if(n.length===0)return t;const o=s.filter(i=>!i.id.startsWith("agent-send-to-"));return[...t.slice(0,e.length),...o,{id:"send-to-heading",label:r("Send to"),heading:!0},...n]}function ct(e,t,s){const n=[];t.canEdit&&n.push({id:"edit",label:e.kind==="user"?r("Edit profile"):r("Open in editor")}),n.push({id:"open",label:r("Navigate into")}),e.kind==="post"&&t.canEdit&&!e.flat&&(n.push({id:"quick-edit",label:r("Edit…")}),t.status!=="publish"&&n.push({id:"publish",label:r("Publish")})),t.link&&n.push({id:"copy-link",label:r("Copy link")}),t.shortlink&&n.push({id:"copy-shortlink",label:r("Copy shortlink")}),n.push({id:"copy-id",label:r("Copy ID")}),e.kind==="post"&&!e.flat&&n.push({id:"trash",label:r("Move to Trash"),danger:!0,disabled:!t.canDelete});for(const o of s)n.push({id:o.id,label:o.label,icon:o.icon});return n}const me=e=>JSON.stringify([e.state.group,e.state.section,e.state.query,e.state.into,e.state.relation,e.state.footprint]);function ut(e){const t=Object.create(e);return Object.defineProperty(t,"state",{get:()=>{const s=k(e);return s.previewLoading&&s.previewScope===me(e)?{...e.state,item:s.previewTarget}:e.state}}),t}function pt(e){e=ut(e);const t=e.data.detail,s=X(e.data,e.state.section);return t?.id===e.state.item&&t.kind===s?.kind?t:null}function bs(e){const t=k(e);return t.previewError?r("Could not load details."):t.previewLoading?r("Loading details…"):r("Details are not available for this item.")}function O(e,t){const s=k(e),n=s.previewLoading;s.previewTarget=t,s.previewScope=me(e),s.previewError=!1,s.previewRevision++,s.previewLoading=n||t>0,e.local("preview",{item:t}),!(n||t===0)&&(s.previewLoading=!0,(async()=>{try{let o;do{o=s.previewRevision;const i=s.previewTarget,a=s.previewScope,l=await e.dispatch("open",{item:i});if(a!==me(e)){if(o!==s.previewRevision&&s.previewScope===me(e))continue;break}e.local("preview",{item:s.previewTarget}),o===s.previewRevision&&(s.previewError=!l)}while(o!==s.previewRevision&&s.previewTarget>0)}catch{s.previewError=!0}finally{s.previewLoading=!1,e.repaint()}})())}function ks(e,t,s){const n=k(e),o=pe(e.state),i=n.trashHidden.get(o)??new Set;if(n.trashPage!==e.data.list){n.trashPage=e.data.list;for(const l of e.data.list?.items??[])he(t,l.id)||i.delete(l.id)}const a=new Set(ce().filter(l=>l.direction==="in"&&l.item.type===t.post_type).map(l=>l.item.id));return s.filter(l=>!i.has(l.id)&&!a.has(l.id))}function he(e,t){return ce().some(s=>s.direction==="in"&&s.item.type===e.post_type&&s.item.id===t)}function Ss(e){let t=null;return _s(()=>e.repaint(),()=>(t??(t=Promise.resolve().then(async()=>{if(t=null,await e.dispatch("refresh")){const n=k(e),o=X(e.data,e.state.section),i=pe(e.state),a=n.trashHidden.get(i)??new Set;for(const d of ce())d.direction==="in"&&!d.pending&&d.item.type===o?.post_type&&!e.data.list?.items.some(u=>u.id===d.item.id)&&a.add(d.item.id);n.trashHidden.set(i,a);const l=ce().filter(d=>!d.pending&&d.direction==="in"&&d.item.type===o?.post_type).map(d=>d.item.id);e.local("select-set",{ids:e.state.selected.filter(d=>!l.includes(d))}),l.includes(e.state.item)&&O(e,0)}})),t))}async function ft(e,t,s){if(s.length===0||!await e.host.confirm?.({message:s.length>1?b(r("Move %d items to the Trash?"),s.length):r("Move this to the Trash?"),confirmLabel:r("Trash"),danger:!0}))return;const o=s.flatMap(d=>{const u=vs(ws({id:d.id,type:t.post_type??"post",title:d.title,subtitle:d.subtitle,preview:d.thumb}));return u?[{row:d,operation:u}]:[]});if(o.length===0)return;if(!t.restPath){let d=!1;try{o.length===1?d=await e.dispatch("trash",{item:o[0].row.id}):(e.local("select-set",{ids:o.map(({row:u})=>u.id)}),d=await e.dispatch("bulk-trash"))}finally{o.forEach(({operation:u})=>void u.finish(d))}return}const i=await Promise.allSettled(o.map(async({row:d})=>{if(!(await e.fetch(`${t.restPath.replace(/\/+$/,"")}/${d.id}`,{method:"DELETE"})).ok)throw new Error(r("Could not move this item to Trash."))})),a=o.filter((d,u)=>i[u].status==="fulfilled").map(({row:d})=>d.id);a.length>0&&(e.host.announce?.(t.post_type??"post","trashed",a),e.local("select-set",{ids:e.state.selected.filter(d=>!a.includes(d))}),a.includes(e.state.item)&&O(e,0)),i.forEach((d,u)=>{o[u].operation.finish(d.status==="fulfilled")});const l=i.length-a.length;e.host.toast?.({message:l>0?b(r("%d item(s) could not be moved to Trash."),l):b(r("Moved %d item(s) to the Trash."),a.length)})}const mt="desktop-mode-user-edit";function ee(e,t={}){if(!Number.isFinite(e)||e<=0)return!1;const s=window.wp?.os;return s?.openWindow?.(mt,{source:t.source??"user-edit/open",params:{userId:e}})?(s?.relations?.set?.(mt,{type:"user",id:e}),!0):(t.fallback?.(),!1)}const As=500,Ms=10,Y=new WeakMap;function ge(e){const t=Y.get(e);t&&(clearTimeout(t.timer),Y.delete(e))}function Ts(e){return e.isPrimary&&(e.pointerType==="touch"||e.pointerType==="pen")}function Pe(e,t=()=>!0){return{pointerdown:s=>{const n=s.currentTarget;if(ge(n),!Ts(s)||!t(s))return;const o=s.clientX,i=s.clientY,a=setTimeout(()=>{Y.delete(n);const l=d=>{d.stopPropagation(),d.preventDefault()};n.addEventListener("click",l,{capture:!0,once:!0}),setTimeout(()=>n.removeEventListener("click",l,{capture:!0}),700),e(o,i)},As);Y.set(n,{pointerId:s.pointerId,x:o,y:i,timer:a})},pointermove:s=>{const n=s.currentTarget,o=Y.get(n);!o||o.pointerId!==s.pointerId||Math.hypot(s.clientX-o.x,s.clientY-o.y)>Ms&&ge(n)},pointerup:s=>{const n=s.currentTarget;Y.get(n)?.pointerId===s.pointerId&&ge(n)},pointercancel:s=>{ge(s.currentTarget)}}}function Re(e,t,s,n){const o=(a,l)=>{k(e).menu={x:a,y:l,item:s},e.repaint()},i=()=>{if(t.kind==="user"){if(T().hooks?.applyFilters("os.my-wordpress.user-activate",!1,{entityId:t.id,kind:t.kind,item:s})===!0)return;e.dispatch("footprint",{user:s.id,name:s.title});return}s.canEdit&&e.dispatch("edit",{item:s.id})};return{select:a=>{if(e.local("select",{item:s.id,ctrl:a.ctrlKey||a.metaKey,shift:a.shiftKey,order:n}),!(a.ctrlKey||a.metaKey||a.shiftKey)){if(ue()&&(t.kind==="user"||s.canEdit)){i();return}O(e,s.id)}},activate:i,menu:a=>{a.preventDefault(),a.stopPropagation(),o(a.clientX,a.clientY)},menuAt:a=>{const l=a.getBoundingClientRect();o(l.left,l.bottom+2)},press:Pe(o)}}async function Oe(e,t,s){const n=await ps(t);e.host.toast?.({message:n?s:r("Could not copy — the clipboard is not available here.")})}function ht(e){return b(r("Copied ID %d."),e)}function Fe(e,t,s){const n=t.map(i=>String(i[s]??"")).filter(Boolean);let o=b(r("Copied %d links."),n.length);n.length===1&&(o=r(s==="shortlink"?"Copied the shortlink.":"Copied the link.")),Oe(e,n.join(`
6 -`),o)}function Cs(e,t){const s=t.map(n=>n.id);Oe(e,s.join(", "),s.length===1?ht(s[0]):b(r("Copied %d IDs."),s.length))}function Es(e){if(e===""||e==="publish")return"";const t={draft:"warning",pending:"info",future:"info",private:"neutral"},s={draft:r("Draft"),pending:r("Pending"),future:r("Scheduled"),private:r("Private")};return c`<os-badge tone=${t[e]??"neutral"} no-dot class="os-mywp__cell-badge">${s[e]??e}</os-badge>`}function We(e,t){const s=e.thumb?c`<img class="os-mywp__cell-thumb" src=${e.thumb} alt="" loading="lazy" />`:Le(t.icon,"os-mywp__cell-glyph");return c`
5 + ></span>`}function ut(e,t){if(t.length<=e.length||!e.every((i,a)=>t[a]?.id===i.id))return t;const s=t.slice(e.length),n=s.filter(i=>i.id.startsWith("agent-send-to-"));if(n.length===0)return t;const o=s.filter(i=>!i.id.startsWith("agent-send-to-"));return[...t.slice(0,e.length),...o,{id:"send-to-heading",label:r("Send to"),heading:!0},...n]}function pt(e,t,s){const n=[];t.canEdit&&n.push({id:"edit",label:e.kind==="user"?r("Edit profile"):r("Open in editor")}),n.push({id:"open",label:r("Navigate into")}),e.kind==="post"&&t.canEdit&&!e.flat&&(n.push({id:"quick-edit",label:r("Edit…")}),t.status!=="publish"&&n.push({id:"publish",label:r("Publish")})),t.link&&n.push({id:"copy-link",label:r("Copy link")}),t.shortlink&&n.push({id:"copy-shortlink",label:r("Copy shortlink")}),n.push({id:"copy-id",label:r("Copy ID")}),e.kind==="post"&&!e.flat&&n.push({id:"trash",label:r("Move to Trash"),danger:!0,disabled:!t.canDelete});for(const o of s)n.push({id:o.id,label:o.label,icon:o.icon});return n}const he=e=>JSON.stringify([e.state.group,e.state.section,e.state.query,e.state.into,e.state.relation,e.state.footprint]);function ft(e){const t=Object.create(e);return Object.defineProperty(t,"state",{get:()=>{const s=k(e);return s.previewLoading&&s.previewScope===he(e)?{...e.state,item:s.previewTarget}:e.state}}),t}function mt(e){e=ft(e);const t=e.data.detail,s=X(e.data,e.state.section);return t?.id===e.state.item&&t.kind===s?.kind?t:null}function Ss(e){const t=k(e);return t.previewError?r("Could not load details."):t.previewLoading?r("Loading details…"):r("Details are not available for this item.")}function O(e,t){const s=k(e),n=s.previewLoading;s.previewTarget=t,s.previewScope=he(e),s.previewError=!1,s.previewRevision++,s.previewLoading=n||t>0,e.local("preview",{item:t}),!(n||t===0)&&(s.previewLoading=!0,(async()=>{try{let o;do{o=s.previewRevision;const i=s.previewTarget,a=s.previewScope,l=await e.dispatch("open",{item:i});if(a!==he(e)){if(o!==s.previewRevision&&s.previewScope===he(e))continue;break}e.local("preview",{item:s.previewTarget}),o===s.previewRevision&&(s.previewError=!l)}while(o!==s.previewRevision&&s.previewTarget>0)}catch{s.previewError=!0}finally{s.previewLoading=!1,e.repaint()}})())}function As(e,t,s){const n=k(e),o=fe(e.state),i=n.trashHidden.get(o)??new Set;if(n.trashPage!==e.data.list){n.trashPage=e.data.list;for(const l of e.data.list?.items??[])ge(t,l.id)||i.delete(l.id)}const a=new Set(ue().filter(l=>l.direction==="in"&&l.item.type===t.post_type).map(l=>l.item.id));return s.filter(l=>!i.has(l.id)&&!a.has(l.id))}function ge(e,t){return ue().some(s=>s.direction==="in"&&s.item.type===e.post_type&&s.item.id===t)}function Ms(e){let t=null;return bs(()=>e.repaint(),()=>(t??(t=Promise.resolve().then(async()=>{if(t=null,await e.dispatch("refresh")){const n=k(e),o=X(e.data,e.state.section),i=fe(e.state),a=n.trashHidden.get(i)??new Set;for(const u of ue())u.direction==="in"&&!u.pending&&u.item.type===o?.post_type&&!e.data.list?.items.some(d=>d.id===u.item.id)&&a.add(u.item.id);n.trashHidden.set(i,a);const l=ue().filter(u=>!u.pending&&u.direction==="in"&&u.item.type===o?.post_type).map(u=>u.item.id);e.local("select-set",{ids:e.state.selected.filter(u=>!l.includes(u))}),l.includes(e.state.item)&&O(e,0)}})),t))}async function ht(e,t,s){if(s.length===0||!await e.host.confirm?.({message:s.length>1?b(r("Move %d items to the Trash?"),s.length):r("Move this to the Trash?"),confirmLabel:r("Trash"),danger:!0}))return;const o=s.flatMap(u=>{const d=ks(_s({id:u.id,type:t.post_type??"post",title:u.title,subtitle:u.subtitle,preview:u.thumb}));return d?[{row:u,operation:d}]:[]});if(o.length===0)return;if(!t.restPath){let u=!1;try{o.length===1?u=await e.dispatch("trash",{item:o[0].row.id}):(e.local("select-set",{ids:o.map(({row:d})=>d.id)}),u=await e.dispatch("bulk-trash"))}finally{o.forEach(({operation:d})=>void d.finish(u))}return}const i=await Promise.allSettled(o.map(async({row:u})=>{if(!(await e.fetch(`${t.restPath.replace(/\/+$/,"")}/${u.id}`,{method:"DELETE"})).ok)throw new Error(r("Could not move this item to Trash."))})),a=o.filter((u,d)=>i[d].status==="fulfilled").map(({row:u})=>u.id);a.length>0&&(e.host.announce?.(t.post_type??"post","trashed",a),e.local("select-set",{ids:e.state.selected.filter(u=>!a.includes(u))}),a.includes(e.state.item)&&O(e,0)),i.forEach((u,d)=>{o[d].operation.finish(u.status==="fulfilled")});const l=i.length-a.length;e.host.toast?.({message:l>0?b(r("%d item(s) could not be moved to Trash."),l):b(r("Moved %d item(s) to the Trash."),a.length)})}const gt="desktop-mode-user-edit";function te(e,t={}){if(!Number.isFinite(e)||e<=0)return!1;const s=window.wp?.os;return s?.openWindow?.(gt,{source:t.source??"user-edit/open",params:{userId:e}})?(s?.relations?.set?.(gt,{type:"user",id:e}),!0):(t.fallback?.(),!1)}const Ts=500,Cs=10,Y=new WeakMap;function ye(e){const t=Y.get(e);t&&(clearTimeout(t.timer),Y.delete(e))}function Es(e){return e.isPrimary&&(e.pointerType==="touch"||e.pointerType==="pen")}function Re(e,t=()=>!0){return{pointerdown:s=>{const n=s.currentTarget;if(ye(n),!Es(s)||!t(s))return;const o=s.clientX,i=s.clientY,a=setTimeout(()=>{Y.delete(n);const l=u=>{u.stopPropagation(),u.preventDefault()};n.addEventListener("click",l,{capture:!0,once:!0}),setTimeout(()=>n.removeEventListener("click",l,{capture:!0}),700),e(o,i)},Ts);Y.set(n,{pointerId:s.pointerId,x:o,y:i,timer:a})},pointermove:s=>{const n=s.currentTarget,o=Y.get(n);!o||o.pointerId!==s.pointerId||Math.hypot(s.clientX-o.x,s.clientY-o.y)>Cs&&ye(n)},pointerup:s=>{const n=s.currentTarget;Y.get(n)?.pointerId===s.pointerId&&ye(n)},pointercancel:s=>{ye(s.currentTarget)}}}function Oe(e,t,s,n){const o=(a,l)=>{k(e).menu={x:a,y:l,item:s},e.repaint()},i=()=>{if(t.kind==="user"){if(T().hooks?.applyFilters("os.my-wordpress.user-activate",!1,{entityId:t.id,kind:t.kind,item:s})===!0)return;e.dispatch("footprint",{user:s.id,name:s.title});return}s.canEdit&&e.dispatch("edit",{item:s.id})};return{select:a=>{if(e.local("select",{item:s.id,ctrl:a.ctrlKey||a.metaKey,shift:a.shiftKey,order:n}),!(a.ctrlKey||a.metaKey||a.shiftKey)){if(pe()&&(t.kind==="user"||s.canEdit)){i();return}O(e,s.id)}},activate:i,menu:a=>{a.preventDefault(),a.stopPropagation(),o(a.clientX,a.clientY)},menuAt:a=>{const l=a.getBoundingClientRect();o(l.left,l.bottom+2)},press:Re(o)}}async function Fe(e,t,s){const n=await ms(t);e.host.toast?.({message:n?s:r("Could not copy — the clipboard is not available here.")})}function yt(e){return b(r("Copied ID %d."),e)}function We(e,t,s){const n=t.map(i=>String(i[s]??"")).filter(Boolean);let o=b(r("Copied %d links."),n.length);n.length===1&&(o=r(s==="shortlink"?"Copied the shortlink.":"Copied the link.")),Fe(e,n.join(`
6 +`),o)}function Is(e,t){const s=t.map(n=>n.id);Fe(e,s.join(", "),s.length===1?yt(s[0]):b(r("Copied %d IDs."),s.length))}function Ns(e){if(e===""||e==="publish")return"";const t={draft:"warning",pending:"info",future:"info",private:"neutral"},s={draft:r("Draft"),pending:r("Pending"),future:r("Scheduled"),private:r("Private")};return c`<os-badge tone=${t[e]??"neutral"} no-dot class="os-mywp__cell-badge">${s[e]??e}</os-badge>`}function Ue(e,t){const s=e.thumb?c`<img class="os-mywp__cell-thumb" src=${e.thumb} alt="" loading="lazy" />`:Pe(t.icon,"os-mywp__cell-glyph");return c`
7 7 <span class="os-mywp__cell-title">
8 8 ${s}
9 9 <span class="os-mywp__cell-text">${e.title}</span>
10 - ${t.kind==="post"?Es(e.status):""}
10 + ${t.kind==="post"?Ns(e.status):""}
11 11 ${e.lockedBy?c`<span
12 12 class="dashicons dashicons-lock os-mywp__cell-lock"
13 13 title=${b(r("%s is editing"),e.lockedBy)}
14 14 ></span>`:""}
15 15 </span>
16 - `}function Ue(e){return e?c`<time datetime=${e} title=${I(e,"datetime")}>${I(e,"long")}</time>`:""}function gt(e){return e?c`<os-relative-time datetime=${e} title=${I(e,"datetime")}></os-relative-time>`:""}const Be={id:"id",label:r("ID"),sort:{asc:"id-asc",desc:"id-desc",first:"desc"},mono:!0,align:"end",locked:!0,render:e=>e.id},ye={id:"actions",label:r("Actions"),align:"end",locked:!0,render:()=>""};function Is(e){const t=[Be,{id:"title",label:r("Title"),sort:{asc:"title-asc",desc:"title-desc",first:"asc"},width:"1fr",locked:!0,render:We},{id:"slug",label:r("Slug"),sort:{asc:"slug-asc",desc:"slug-desc",first:"asc"},mono:!0,render:s=>s.slug??""},{id:"author",label:r("Author"),render:s=>s.author??""},{id:"status",label:r("Status"),render:s=>s.status},{id:"date",label:r("Date"),sort:{asc:"oldest",desc:"default",first:"desc"},render:s=>Ue(s.date)},{id:"modified",label:r("Modified"),sort:{asc:"modified-asc",desc:"modified",first:"desc"},render:s=>gt(s.modified)},{id:"comments",label:r("Comments"),sort:{asc:"comments-asc",desc:"comments",first:"desc"},align:"end",mono:!0,render:s=>s.comments??0}];return e.hierarchical&&t.push({id:"parent",label:r("Parent"),render:s=>s.parent&&s.parent>0?c`<span class="os-mywp__cell-parent"><span class="os-mywp__cell-id">#${s.parent}</span> ${s.parentTitle??""}</span>`:""}),t.push({id:"words",label:r("Words"),align:"end",mono:!0,hidden:!0,render:s=>s.words??0},ye),t}function Ns(){return[Be,{id:"title",label:r("File"),sort:{asc:"title-asc",desc:"title-desc",first:"asc"},width:"1fr",locked:!0,render:We},{id:"file",label:r("File name"),sort:{asc:"slug-asc",desc:"slug-desc",first:"asc"},mono:!0,render:e=>e.file??""},{id:"mime",label:r("Type"),mono:!0,render:e=>e.mime},{id:"size",label:r("Size"),align:"end",mono:!0,render:e=>e.size??""},{id:"dimensions",label:r("Dimensions"),mono:!0,render:e=>e.dimensions??""},{id:"parent",label:r("Attached to"),render:e=>e.parent&&e.parent>0?c`<span class="os-mywp__cell-parent"><span class="os-mywp__cell-id">#${e.parent}</span> ${e.parentTitle??""}</span>`:c`<span class="os-mywp__cell-muted">${r("Unattached")}</span>`},{id:"author",label:r("Uploaded by"),hidden:!0,render:e=>e.author??""},{id:"date",label:r("Uploaded"),sort:{asc:"oldest",desc:"default",first:"desc"},render:e=>Ue(e.date)},{id:"modified",label:r("Modified"),sort:{asc:"modified-asc",desc:"modified",first:"desc"},hidden:!0,render:e=>gt(e.modified)},ye]}function Ds(){return[Be,{id:"title",label:r("Name"),sort:{asc:"default",desc:"title-desc",first:"asc"},width:"1fr",locked:!0,render:We},{id:"login",label:r("Username"),sort:{asc:"login-asc",desc:"login-desc",first:"asc"},mono:!0,render:e=>e.login??""},{id:"email",label:r("Email"),sort:{asc:"email-asc",desc:"email-desc",first:"asc"},render:e=>e.email??e.subtitle},{id:"roles",label:r("Role"),render:e=>e.status},{id:"posts",label:r("Posts"),sort:{asc:"posts-asc",desc:"posts",first:"desc"},align:"end",mono:!0,render:e=>e.posts??0},{id:"registered",label:r("Registered"),sort:{asc:"oldest",desc:"newest",first:"desc"},render:e=>Ue(e.registered)},ye]}function $e(e){let t;e.kind==="user"?t=Ds():e.kind==="media"?t=Ns():t=Is(e);const s=T().hooks?.applyFilters("os.my-wordpress.list-columns",t,e);if(!Array.isArray(s))return t;const n=s.filter(i=>{if(!i||typeof i!="object")return!1;const a=i;return typeof a.id=="string"&&a.id!==""&&typeof a.render=="function"}),o=new Set(n.map(i=>i.id));return o.has("title")||n.unshift(t.find(i=>i.id==="title")),o.has("actions")||n.push(ye),n}function we(e,t,s){const n=e.data.hiddenColumns?.[t.id];return Array.isArray(n)?new Set(n.map(String)):new Set(s.filter(o=>o.hidden).map(o=>o.id))}function yt(e,t){if(!e.sort)return t;const{asc:s,desc:n,first:o}=e.sort,i=o==="asc"?s:n;return t===i?o==="asc"?n:s:i}function Ls(e,t){return!!e.sort&&e.sort.asc in t&&e.sort.desc in t}function _e(e,t,s){return c`
16 + `}function qe(e){return e?c`<time datetime=${e} title=${I(e,"datetime")}>${I(e,"long")}</time>`:""}function $t(e){return e?c`<os-relative-time datetime=${e} title=${I(e,"datetime")}></os-relative-time>`:""}const Be={id:"id",label:r("ID"),sort:{asc:"id-asc",desc:"id-desc",first:"desc"},mono:!0,align:"end",locked:!0,render:e=>e.id},$e={id:"actions",label:r("Actions"),align:"end",locked:!0,render:()=>""};function Ds(e){const t=[Be,{id:"title",label:r("Title"),sort:{asc:"title-asc",desc:"title-desc",first:"asc"},width:"1fr",locked:!0,render:Ue},{id:"slug",label:r("Slug"),sort:{asc:"slug-asc",desc:"slug-desc",first:"asc"},mono:!0,render:s=>s.slug??""},{id:"author",label:r("Author"),render:s=>s.author??""},{id:"status",label:r("Status"),render:s=>s.status},{id:"date",label:r("Date"),sort:{asc:"oldest",desc:"default",first:"desc"},render:s=>qe(s.date)},{id:"modified",label:r("Modified"),sort:{asc:"modified-asc",desc:"modified",first:"desc"},render:s=>$t(s.modified)},{id:"comments",label:r("Comments"),sort:{asc:"comments-asc",desc:"comments",first:"desc"},align:"end",mono:!0,render:s=>s.comments??0}];return e.hierarchical&&t.push({id:"parent",label:r("Parent"),render:s=>s.parent&&s.parent>0?c`<span class="os-mywp__cell-parent"><span class="os-mywp__cell-id">#${s.parent}</span> ${s.parentTitle??""}</span>`:""}),t.push({id:"words",label:r("Words"),align:"end",mono:!0,hidden:!0,render:s=>s.words??0},$e),t}function Ls(){return[Be,{id:"title",label:r("File"),sort:{asc:"title-asc",desc:"title-desc",first:"asc"},width:"1fr",locked:!0,render:Ue},{id:"file",label:r("File name"),sort:{asc:"slug-asc",desc:"slug-desc",first:"asc"},mono:!0,render:e=>e.file??""},{id:"mime",label:r("Type"),mono:!0,render:e=>e.mime},{id:"size",label:r("Size"),align:"end",mono:!0,render:e=>e.size??""},{id:"dimensions",label:r("Dimensions"),mono:!0,render:e=>e.dimensions??""},{id:"parent",label:r("Attached to"),render:e=>e.parent&&e.parent>0?c`<span class="os-mywp__cell-parent"><span class="os-mywp__cell-id">#${e.parent}</span> ${e.parentTitle??""}</span>`:c`<span class="os-mywp__cell-muted">${r("Unattached")}</span>`},{id:"author",label:r("Uploaded by"),hidden:!0,render:e=>e.author??""},{id:"date",label:r("Uploaded"),sort:{asc:"oldest",desc:"default",first:"desc"},render:e=>qe(e.date)},{id:"modified",label:r("Modified"),sort:{asc:"modified-asc",desc:"modified",first:"desc"},hidden:!0,render:e=>$t(e.modified)},$e]}function Ps(){return[Be,{id:"title",label:r("Name"),sort:{asc:"default",desc:"title-desc",first:"asc"},width:"1fr",locked:!0,render:Ue},{id:"login",label:r("Username"),sort:{asc:"login-asc",desc:"login-desc",first:"asc"},mono:!0,render:e=>e.login??""},{id:"email",label:r("Email"),sort:{asc:"email-asc",desc:"email-desc",first:"asc"},render:e=>e.email??e.subtitle},{id:"roles",label:r("Role"),render:e=>e.status},{id:"posts",label:r("Posts"),sort:{asc:"posts-asc",desc:"posts",first:"desc"},align:"end",mono:!0,render:e=>e.posts??0},{id:"registered",label:r("Registered"),sort:{asc:"oldest",desc:"newest",first:"desc"},render:e=>qe(e.registered)},$e]}function we(e){let t;e.kind==="user"?t=Ps():e.kind==="media"?t=Ls():t=Ds(e);const s=T().hooks?.applyFilters("os.my-wordpress.list-columns",t,e);if(!Array.isArray(s))return t;const n=s.filter(i=>{if(!i||typeof i!="object")return!1;const a=i;return typeof a.id=="string"&&a.id!==""&&typeof a.render=="function"}),o=new Set(n.map(i=>i.id));return o.has("title")||n.unshift(t.find(i=>i.id==="title")),o.has("actions")||n.push($e),n}function ve(e,t,s){const n=e.data.hiddenColumns?.[t.id];return Array.isArray(n)?new Set(n.map(String)):new Set(s.filter(o=>o.hidden).map(o=>o.id))}function wt(e,t){if(!e.sort)return t;const{asc:s,desc:n,first:o}=e.sort,i=o==="asc"?s:n;return t===i?o==="asc"?n:s:i}function Rs(e,t){return!!e.sort&&e.sort.asc in t&&e.sort.desc in t}function _e(e,t,s){return c`
17 17 <os-button
18 18 variant="ghost"
19 19 class="os-mywp__row-action"
20 20 title=${t}
@@ -23,9 +23,9 @@
23 23 @dblclick=${n=>n.stopPropagation()}
24 24 >
25 25 <span class="dashicons ${e}" aria-hidden="true"></span>
26 26 </os-button>
27 - `}function Ps(e,t,s,n){const o=Re(e,t,s,n),i=[];return s.canEdit&&i.push(_e("dashicons-edit",t.kind==="user"?r("Edit profile"):r("Open in editor"),()=>{t.kind==="user"?ee(s.id,{source:"my-wordpress-app/list-view",fallback:()=>void e.dispatch("edit",{item:s.id})}):e.dispatch("edit",{item:s.id})})),t.kind==="user"&&i.push(_e("dashicons-chart-area",r("View activity footprint"),()=>void e.dispatch("footprint",{user:s.id,name:s.title}))),s.link&&i.push(_e("dashicons-admin-links",t.kind==="media"?r("Copy URL"):r("Copy link"),()=>Fe(e,[s],"link"))),s.shortlink&&i.push(_e("dashicons-shortcode",r("Copy shortlink"),()=>Fe(e,[s],"shortlink"))),i.push(c`
27 + `}function Os(e,t,s,n){const o=Oe(e,t,s,n),i=[];return s.canEdit&&i.push(_e("dashicons-edit",t.kind==="user"?r("Edit profile"):r("Open in editor"),()=>{t.kind==="user"?te(s.id,{source:"my-wordpress-app/list-view",fallback:()=>void e.dispatch("edit",{item:s.id})}):e.dispatch("edit",{item:s.id})})),t.kind==="user"&&i.push(_e("dashicons-chart-area",r("View activity footprint"),()=>void e.dispatch("footprint",{user:s.id,name:s.title}))),s.link&&i.push(_e("dashicons-admin-links",t.kind==="media"?r("Copy URL"):r("Copy link"),()=>We(e,[s],"link"))),s.shortlink&&i.push(_e("dashicons-shortcode",r("Copy shortlink"),()=>We(e,[s],"shortlink"))),i.push(c`
28 28 <os-button
29 29 variant="ghost"
30 30 class="os-mywp__row-action"
31 31 title=${r("More actions")}
@@ -35,19 +35,19 @@
35 35 @dblclick=${a=>a.stopPropagation()}
36 36 >
37 37 <span class="dashicons dashicons-ellipsis" aria-hidden="true"></span>
38 38 </os-button>
39 - `),c`<span class="os-mywp__row-actions">${i}</span>`}function Rs(e,t,s,n,o){const i=["os-mywp__td",t.align==="end"?"os-mywp__td--end":"",t.mono?"os-mywp__td--mono":"",`os-mywp__td--${t.id}`].filter(Boolean).join(" ");if(t.id==="id")return c`
39 + `),c`<span class="os-mywp__row-actions">${i}</span>`}function Fs(e,t,s,n,o){const i=["os-mywp__td",t.align==="end"?"os-mywp__td--end":"",t.mono?"os-mywp__td--mono":"",`os-mywp__td--${t.id}`].filter(Boolean).join(" ");if(t.id==="id")return c`
40 40 <td class=${i}>
41 41 <button
42 42 type="button"
43 43 class="os-mywp__cell-id os-mywp__cell-id--copy"
44 44 title=${r("Copy ID")}
45 - @click=${l=>{l.stopPropagation(),Oe(e,String(s.id),ht(s.id))}}
45 + @click=${l=>{l.stopPropagation(),Fe(e,String(s.id),yt(s.id))}}
46 46 @dblclick=${l=>l.stopPropagation()}
47 47 >${s.id}</button>
48 48 </td>
49 - `;if(t.id==="actions")return c`<td class=${i}>${Ps(e,n,s,o)}</td>`;let a;try{a=t.render(s,n)}catch{a=""}return c`<td class=${i}>${a}</td>`}function Os(e,t,s,n,o){const{state:i}=e,a=i.selected.includes(s.id),l=i.item===s.id,d=Re(e,t,s,o),u=p=>{const f=p.currentTarget;p.key==="Enter"?(p.preventDefault(),d.activate()):p.key===" "?(p.preventDefault(),e.local("select",{item:s.id,ctrl:p.ctrlKey||p.metaKey,shift:p.shiftKey,order:o}),O(e,s.id)):(p.key==="ArrowDown"||p.key==="ArrowUp")&&(p.preventDefault(),(p.key==="ArrowDown"?f.nextElementSibling:f.previousElementSibling)?.focus?.())};return c`
49 + `;if(t.id==="actions")return c`<td class=${i}>${Os(e,n,s,o)}</td>`;let a;try{a=t.render(s,n)}catch{a=""}return c`<td class=${i}>${a}</td>`}function Ws(e,t,s,n,o){const{state:i}=e,a=i.selected.includes(s.id),l=i.item===s.id,u=Oe(e,t,s,o),d=p=>{const f=p.currentTarget;p.key==="Enter"?(p.preventDefault(),u.activate()):p.key===" "?(p.preventDefault(),e.local("select",{item:s.id,ctrl:p.ctrlKey||p.metaKey,shift:p.shiftKey,order:o}),O(e,s.id)):(p.key==="ArrowDown"||p.key==="ArrowUp")&&(p.preventDefault(),(p.key==="ArrowDown"?f.nextElementSibling:f.previousElementSibling)?.focus?.())};return c`
50 50 <tr
51 51 class="os-mywp__row ${l?"is-open":""} ${a?"is-selected":""}"
52 52 data-item-id=${String(s.id)}
53 53 data-mywp-drag=${t.kind==="user"?"user":t.post_type}
@@ -53,20 +53,20 @@
53 53 data-mywp-drag=${t.kind==="user"?"user":t.post_type}
54 54 role="row"
55 55 aria-selected=${a?"true":"false"}
56 56 tabindex="0"
57 - @click=${d.select}
58 - @dblclick=${d.activate}
59 - @contextmenu=${d.menu}
60 - @pointerdown=${d.press.pointerdown}
61 - @pointermove=${d.press.pointermove}
62 - @pointerup=${d.press.pointerup}
63 - @pointercancel=${d.press.pointercancel}
64 - @keydown=${u}
57 + @click=${u.select}
58 + @dblclick=${u.activate}
59 + @contextmenu=${u.menu}
60 + @pointerdown=${u.press.pointerdown}
61 + @pointermove=${u.press.pointermove}
62 + @pointerup=${u.press.pointerup}
63 + @pointercancel=${u.press.pointercancel}
64 + @keydown=${d}
65 65 >
66 - ${n.map(p=>Rs(e,p,s,t,o))}
66 + ${n.map(p=>Fs(e,p,s,t,o))}
67 67 </tr>
68 - `}function Fs(e,t,s){const n=k(e),o=$e(t),i=we(e,t,o),a=o.filter(g=>!i.has(g.id)),l=s.map(g=>g.id),d=e.state.sort||"default",u=e.data.sortOptions??{},p=n.list.hasMore(),f=n.list.ghosts(e.data.list?.perPage??24),m=g=>{const y=yt(g,d);e.local("set-sort",{sort:y==="default"?"":y}),e.dispatch("sort")},h=g=>g.sort?d===g.sort.asc?"ascending":d===g.sort.desc?"descending":"none":"none",$=g=>{const y=["os-mywp__th",g.align==="end"?"os-mywp__th--end":"",`os-mywp__th--${g.id}`].filter(Boolean).join(" ");if(g.id==="actions")return c`
68 + `}function Us(e,t,s){const n=k(e),o=we(t),i=ve(e,t,o),a=o.filter(g=>!i.has(g.id)),l=s.map(g=>g.id),u=e.state.sort||"default",d=e.data.sortOptions??{},p=n.list.hasMore(),f=n.list.ghosts(e.data.list?.perPage??24),m=g=>{const y=wt(g,u);e.local("set-sort",{sort:y==="default"?"":y}),e.dispatch("sort")},h=g=>g.sort?u===g.sort.asc?"ascending":u===g.sort.desc?"descending":"none":"none",$=g=>{const y=["os-mywp__th",g.align==="end"?"os-mywp__th--end":"",`os-mywp__th--${g.id}`].filter(Boolean).join(" ");if(g.id==="actions")return c`
69 69 <th class=${y} scope="col">
70 70 <os-button
71 71 variant="ghost"
72 72 class="os-mywp__row-action os-mywp__columns-btn"
@@ -77,24 +77,24 @@
77 77 >
78 78 <span class="dashicons dashicons-screenoptions" aria-hidden="true"></span>
79 79 </os-button>
80 80 </th>
81 - `;if(!Ls(g,u))return c`<th class=${y} scope="col">${g.label}</th>`;const _=h(g),M={ascending:"▲",descending:"▼"};return c`
82 - <th class=${y} scope="col" aria-sort=${_}>
81 + `;if(!Rs(g,d))return c`<th class=${y} scope="col">${g.label}</th>`;const v=h(g),M={ascending:"▲",descending:"▼"};return c`
82 + <th class=${y} scope="col" aria-sort=${v}>
83 83 <button
84 84 type="button"
85 - class="os-mywp__sort ${_!=="none"?"is-active":""}"
85 + class="os-mywp__sort ${v!=="none"?"is-active":""}"
86 86 @click=${()=>m(g)}
87 87 >
88 88 <span>${g.label}</span>
89 - <span class="os-mywp__sort-arrow" aria-hidden="true">${M[_]??""}</span>
89 + <span class="os-mywp__sort-arrow" aria-hidden="true">${M[v]??""}</span>
90 90 </button>
91 91 </th>
92 - `},v=g=>{g.preventDefault(),n.menu={x:g.clientX,y:g.clientY,item:null},e.repaint()},w=Pe((g,y)=>{n.menu={x:g,y,item:null},e.repaint()},g=>!g.target?.closest("[data-item-id]"));return c`
92 + `},_=g=>{g.preventDefault(),n.menu={x:g.clientX,y:g.clientY,item:null},e.repaint()},w=Re((g,y)=>{n.menu={x:g,y,item:null},e.repaint()},g=>!g.target?.closest("[data-item-id]"));return c`
93 93 <div
94 94 class="os-mywp__canvas os-mywp__table-wrap"
95 95 data-mywp-list
96 - @contextmenu=${v}
96 + @contextmenu=${_}
97 97 @pointerdown=${w.pointerdown}
98 98 @pointermove=${w.pointermove}
99 99 @pointerup=${w.pointerup}
100 100 @pointercancel=${w.pointercancel}
@@ -111,9 +111,9 @@
111 111 <thead>
112 112 <tr role="row">${a.map($)}</tr>
113 113 </thead>
114 114 <tbody>
115 - ${s.map(g=>Os(e,t,g,a,l))}
115 + ${s.map(g=>Ws(e,t,g,a,l))}
116 116 ${Array.from({length:f},(g,y)=>c`
117 117 <tr class="os-mywp__row os-mywp__row--ghost" data-ghost-index=${String(y)} aria-hidden="true">
118 118 <td colspan=${String(a.length)}><span class="os-mywp__ghost-line"></span></td>
119 119 </tr>
@@ -122,9 +122,9 @@
122 122 </table>
123 123 ${s.length===0&&f===0?c`<p class="os-mywp__table-empty">${e.state.query?r("Nothing matches the search."):r("Nothing here yet.")}</p>`:""}
124 124 ${p?c`<div class="os-mywp__sentinel" data-mywp-sentinel></div>`:""}
125 125 </div>
126 - `}function Ws(e,t){const s=k(e);if(!s.columnsMenu||!t)return"";const{x:n,y:o}=s.columnsMenu,i=$e(t),a=we(e,t,i),l=()=>{s.columnsMenu=null,e.repaint()},d=p=>{const f=String(p.detail?.id??"");if(f==="reset"){l(),e.dispatch("set-columns",{reset:!0});return}const m=new Set(a);m.has(f)?m.delete(f):m.add(f),e.dispatch("set-columns",{hidden:Array.from(m)})},u=i.filter(p=>!p.locked);return c`
126 + `}function qs(e,t){const s=k(e);if(!s.columnsMenu||!t)return"";const{x:n,y:o}=s.columnsMenu,i=we(t),a=ve(e,t,i),l=()=>{s.columnsMenu=null,e.repaint()},u=p=>{const f=String(p.detail?.id??"");if(f==="reset"){l(),e.dispatch("set-columns",{reset:!0});return}const m=new Set(a);m.has(f)?m.delete(f):m.add(f),e.dispatch("set-columns",{hidden:Array.from(m)})},d=i.filter(p=>!p.locked);return c`
127 127 <div
128 128 class="os-mywp__menu-backdrop"
129 129 @click=${l}
130 130 @contextmenu=${p=>{p.preventDefault(),l()}}
@@ -132,12 +132,12 @@
132 132 <os-context-menu
133 133 open
134 134 class="os-mywp__menu os-mywp__columns-menu"
135 135 style="position:fixed;left:${n}px;top:${o}px;visibility:hidden"
136 - @os-context-menu-pick=${d}
136 + @os-context-menu-pick=${u}
137 137 >
138 138 <os-context-menu-option heading>${r("Columns")}</os-context-menu-option>
139 - ${u.map(p=>c`
139 + ${d.map(p=>c`
140 140 <os-context-menu-option id=${p.id} ?checked=${!a.has(p.id)}>
141 141 ${p.label}
142 142 </os-context-menu-option>
143 143 `)}
@@ -142,14 +142,14 @@
142 142 </os-context-menu-option>
143 143 `)}
144 144 <os-context-menu-option id="reset">${r("Reset columns")}</os-context-menu-option>
145 145 </os-context-menu>
146 - `}function Us(e){const t=e.state.sort||"default",s=e.data.sortOptions?.[t];return s?b(r("Sorted by %s"),s):""}function Bs(e,t){const s=$e(t),n=we(e,t,s),o=s.filter(i=>n.has(i.id)).length;return o===0?"":b(q("%d column hidden","%d columns hidden",o),o)}function qs(e){const{data:t,state:s}=e,n=s.group,o=t.sections.filter(u=>n?u.group===n:!u.group),i=n?[]:t.groups.map(u=>({...u,count:t.sections.filter(p=>p.group===u.id).reduce((p,f)=>p+f.count,0)})),a=k(e),l=(u,p,f,m,h)=>c`
146 + `}function Bs(e){const t=e.state.sort||"default",s=e.data.sortOptions?.[t];return s?b(r("Sorted by %s"),s):""}function js(e,t){const s=we(t),n=ve(e,t,s),o=s.filter(i=>n.has(i.id)).length;return o===0?"":b(B("%d column hidden","%d columns hidden",o),o)}function Ks(e){const{data:t,state:s}=e,n=s.group,o=t.sections.filter(d=>n?d.group===n:!d.group),i=n?[]:t.groups.map(d=>({...d,count:t.sections.filter(p=>p.group===d.id).reduce((p,f)=>p+f.count,0)})),a=k(e),l=(d,p,f,m,h)=>c`
147 147 <button
148 148 type="button"
149 - class="os-mywp__tile ${a.folderSel===u?"is-selected":""}"
150 - aria-pressed=${a.folderSel===u?"true":"false"}
151 - @click=${()=>{if(ue()){a.folderSel=null,h();return}a.folderSel=u,e.repaint()}}
149 + class="os-mywp__tile ${a.folderSel===d?"is-selected":""}"
150 + aria-pressed=${a.folderSel===d?"true":"false"}
151 + @click=${()=>{if(pe()){a.folderSel=null,h();return}a.folderSel=d,e.repaint()}}
152 152 @dblclick=${()=>{a.folderSel=null,h()}}
153 153 @keydown=${$=>{$.key==="Enter"&&($.preventDefault(),a.folderSel=null,h())}}
154 154 >
155 155 ${f}
@@ -154,9 +154,9 @@
154 154 >
155 155 ${f}
156 156 <span class="os-mywp__tile-label">${p} · ${m}</span>
157 157 </button>
158 - `,d=u=>u.kind==="agent"&&/^(https?:|data:)/.test(u.icon)?c`<img class="os-mywp__icon-img" src=${u.icon} alt="" width="48" height="48" />`:Le(u.icon,"os-mywp__tile-icon");return c`
158 + `,u=d=>d.kind==="agent"&&/^(https?:|data:)/.test(d.icon)?c`<img class="os-mywp__icon-img" src=${d.icon} alt="" width="48" height="48" />`:Pe(d.icon,"os-mywp__tile-icon");return c`
159 159 ${n?c`<div
160 160 class="os-my-wordpress__group-extras"
161 161 data-mywp-group-extras=${n}
162 162 os-preserve
@@ -161,12 +161,12 @@
161 161 data-mywp-group-extras=${n}
162 162 os-preserve
163 163 ></div>`:""}
164 164 <div class="os-mywp__root" role="list">
165 - ${o.map(u=>l(`section:${u.id}`,u.label,d(u),u.count,()=>void e.dispatch("go",{group:n,section:u.id})))}
166 - ${i.map(u=>l(`group:${u.id}`,u.label,Le(u.icon,"os-mywp__tile-icon"),u.count,()=>void e.dispatch("go",{group:u.id})))}
165 + ${o.map(d=>l(`section:${d.id}`,d.label,u(d),d.count,()=>void e.dispatch("go",{group:n,section:d.id})))}
166 + ${i.map(d=>l(`group:${d.id}`,d.label,Pe(d.icon,"os-mywp__tile-icon"),d.count,()=>void e.dispatch("go",{group:d.id})))}
167 167 </div>
168 - `}function qe(e,t,s,n){const{state:o}=e,i=o.selected.includes(s.id),a=o.item===s.id,l=Re(e,t,s,n);return c`
168 + `}function je(e,t,s,n){const{state:o}=e,i=o.selected.includes(s.id),a=o.item===s.id,l=Oe(e,t,s,n);return c`
169 169 <div
170 170 class="os-mywp__cell ${a?"is-open":""}"
171 171 data-item-id=${String(s.id)}
172 172 data-mywp-drag=${t.kind==="user"?"user":t.post_type}
@@ -193,13 +193,13 @@
193 193 ></os-tile>
194 194 ${s.lockedBy?c`<span class="os-mywp__lock" title=${b(r("%s is editing"),s.lockedBy)}>🔒</span>`:""}
195 195 </span>
196 196 </div>
197 - `}function js(e,t,s){if(e.state.view==="list")return Fs(e,t,s);if(s.length===0)return c`
197 + `}function zs(e,t,s){if(e.state.view==="list")return Us(e,t,s);if(s.length===0)return c`
198 198 <os-empty-state icon=${t.icon.startsWith("dashicons-")?t.icon:"dashicons-portfolio"}>
199 199 ${e.state.query?r("Nothing matches the search."):r("Nothing here yet.")}
200 200 </os-empty-state>
201 - `;const n=k(e),o=f=>{f.preventDefault(),n.menu={x:f.clientX,y:f.clientY,item:null},e.repaint()},i=Pe((f,m)=>{n.menu={x:f,y:m,item:null},e.repaint()},f=>!f.target?.closest("[data-item-id]")),a=n.list.hasMore(),l=n.list.ghosts(e.data.list?.perPage??24),d=c`
201 + `;const n=k(e),o=f=>{f.preventDefault(),n.menu={x:f.clientX,y:f.clientY,item:null},e.repaint()},i=Re((f,m)=>{n.menu={x:f,y:m,item:null},e.repaint()},f=>!f.target?.closest("[data-item-id]")),a=n.list.hasMore(),l=n.list.ghosts(e.data.list?.perPage??24),u=c`
202 202 ${Array.from({length:l},(f,m)=>c`
203 203 <div class="os-mywp__cell os-mywp__cell--ghost" data-ghost-index=${String(m)} aria-hidden="true">
204 204 <span class="os-mywp__ghost">
205 205 <span class="os-mywp__ghost-visual"></span>
@@ -206,9 +206,9 @@
206 206 <span class="os-mywp__ghost-label"></span>
207 207 </span>
208 208 </div>
209 209 `)}
210 - `,u=lt(T().hooks,t);if(u){const f=new Set(u.bands.map(w=>w.id)),m=new Map,h=[];for(const w of s){const g=u.assign(w);g!==null&&f.has(g)?m.set(g,[...m.get(g)??[],w]):h.push(w)}const $=[...u.bands].sort((w,g)=>(w.order??0)-(g.order??0)),v=[...$.flatMap(w=>m.get(w.id)??[]),...h].map(w=>w.id);return c`
210 + `,d=ct(T().hooks,t);if(d){const f=new Set(d.bands.map(w=>w.id)),m=new Map,h=[];for(const w of s){const g=d.assign(w);g!==null&&f.has(g)?m.set(g,[...m.get(g)??[],w]):h.push(w)}const $=[...d.bands].sort((w,g)=>(w.order??0)-(g.order??0)),_=[...$.flatMap(w=>m.get(w.id)??[]),...h].map(w=>w.id);return c`
211 211 <div
212 212 class="os-mywp__tiles os-mywp__canvas os-mywp__tiles--banded"
213 213 role="listbox"
214 214 aria-multiselectable="true"
@@ -224,16 +224,16 @@
224 224 <span>${w.label}</span>
225 225 <span class="os-mywp__band-count">${g.length}</span>
226 226 </h3>
227 227 <div class="os-mywp__band-grid" role="presentation">
228 - ${g.map(y=>qe(e,t,y,v))}
228 + ${g.map(y=>je(e,t,y,_))}
229 229 </div>
230 230 </section>
231 231 `})}
232 232 ${h.length>0?c`<div class="os-mywp__band-grid" role="presentation">
233 - ${h.map(w=>qe(e,t,w,v))}
233 + ${h.map(w=>je(e,t,w,_))}
234 234 </div>`:""}
235 - ${l>0?c`<div class="os-mywp__band-grid" role="presentation">${d}</div>`:""}
235 + ${l>0?c`<div class="os-mywp__band-grid" role="presentation">${u}</div>`:""}
236 236 ${a?c`<div class="os-mywp__sentinel" data-mywp-sentinel></div>`:""}
237 237 </div>
238 238 `}const p=s.map(f=>f.id);return c`
239 239 <div
@@ -245,13 +245,13 @@
245 245 @pointermove=${i.pointermove}
246 246 @pointerup=${i.pointerup}
247 247 @pointercancel=${i.pointercancel}
248 248 >
249 - ${s.map(f=>qe(e,t,f,p))}
250 - ${d}
249 + ${s.map(f=>je(e,t,f,p))}
250 + ${u}
251 251 ${a?c`<div class="os-mywp__sentinel" data-mywp-sentinel></div>`:""}
252 252 </div>
253 - `}function Ks(e,t){const s=k(e);if(!s.menu)return"";const{x:n,y:o,item:i}=s.menu,a=()=>{k(e).menu=null,e.repaint()},l=e.state.sort||"default";let d=[];i&&(d=e.state.selected.includes(i.id)&&e.state.selected.length>1?e.state.selected:[i.id]);const u=s.list.items();let p=[];if(i){const m=fe(e.data.previewActions,x(t,i,"menu"),T().hooks);p=ct(t,i,m);const h=T().hooks?.applyFilters("os.my-wordpress.tile-context-menu",p,{entityId:t.id,kind:t.kind,item:i});Array.isArray(h)&&(p=dt(p,h))}return c`
253 + `}function Hs(e,t){const s=k(e);if(!s.menu)return"";const{x:n,y:o,item:i}=s.menu,a=()=>{k(e).menu=null,e.repaint()},l=e.state.sort||"default";let u=[];i&&(u=e.state.selected.includes(i.id)&&e.state.selected.length>1?e.state.selected:[i.id]);const d=s.list.items();let p=[];if(i){const m=me(e.data.previewActions,ee(t,i,"menu"),T().hooks);p=pt(t,i,m);const h=T().hooks?.applyFilters("os.my-wordpress.tile-context-menu",p,{entityId:t.id,kind:t.kind,item:i});Array.isArray(h)&&(p=ut(p,h))}return c`
254 254 <div
255 255 class="os-mywp__menu-backdrop"
256 256 @click=${a}
257 257 @contextmenu=${m=>{m.preventDefault(),a()}}
@@ -259,9 +259,9 @@
259 259 <os-context-menu
260 260 open
261 261 class="os-mywp__menu"
262 262 style="position:fixed;left:${n}px;top:${o}px;visibility:hidden"
263 - @os-context-menu-pick=${m=>{const h=String(m.detail?.id??"");if(a(),h.startsWith("sort:")){e.local("set-sort",{sort:h.slice(5)}),e.dispatch("sort");return}if(h==="refresh"){e.dispatch("refresh");return}if(!i)return;const $=p.find(v=>v.id===h);if($?.onSelect){$.onSelect();return}if(h==="open")t.kind==="post"&&!t.flat?e.dispatch("into",{item:i.id}):O(e,i.id);else if(h==="edit")t.kind==="user"?ee(i.id,{source:"my-wordpress-app/context-menu",fallback:()=>void e.dispatch("edit",{item:i.id})}):e.dispatch("edit",{item:i.id});else if(h==="quick-edit")k(e).quickEdit={ids:d,status:"",comments:"",author:"",sticky:"",categories:[],tags:[]},e.repaint();else if(h==="publish")e.dispatch("quick-edit",{items:d,status:"publish"});else if(h==="copy-link"||h==="copy-shortlink"||h==="copy-id"){const v=u.filter(w=>d.includes(w.id));h==="copy-id"?Cs(e,v):Fe(e,v,h==="copy-link"?"link":"shortlink")}else if(h==="trash")ft(e,t,u.filter(v=>d.includes(v.id)));else{const v=fe(e.data.previewActions,x(t,i,"menu"),T().hooks).find(w=>w.id===h);v&&at(v,x(t,i,"menu"))}}}
263 + @os-context-menu-pick=${m=>{const h=String(m.detail?.id??"");if(a(),h.startsWith("sort:")){e.local("set-sort",{sort:h.slice(5)}),e.dispatch("sort");return}if(h==="refresh"){e.dispatch("refresh");return}if(!i)return;const $=p.find(_=>_.id===h);if($?.onSelect){$.onSelect();return}if(h==="open")t.kind==="post"&&!t.flat?e.dispatch("into",{item:i.id}):O(e,i.id);else if(h==="edit")t.kind==="user"?te(i.id,{source:"my-wordpress-app/context-menu",fallback:()=>void e.dispatch("edit",{item:i.id})}):e.dispatch("edit",{item:i.id});else if(h==="quick-edit")k(e).quickEdit={ids:u,status:"",comments:"",author:"",sticky:"",categories:[],tags:[]},e.repaint();else if(h==="publish")e.dispatch("quick-edit",{items:u,status:"publish"});else if(h==="copy-link"||h==="copy-shortlink"||h==="copy-id"){const _=d.filter(w=>u.includes(w.id));h==="copy-id"?Is(e,_):We(e,_,h==="copy-link"?"link":"shortlink")}else if(h==="trash")ht(e,t,d.filter(_=>u.includes(_.id)));else{const _=me(e.data.previewActions,ee(t,i,"menu"),T().hooks).find(w=>w.id===h);_&&dt(_,ee(t,i,"menu"))}}}
264 264 >
265 265 ${i?p.map(m=>m.heading?c`<os-context-menu-option heading>${m.label}</os-context-menu-option>`:c`
266 266 <os-context-menu-option
267 267 id=${m.id}
@@ -278,9 +278,9 @@
278 278 `)}
279 279 <os-context-menu-option id="refresh" icon="dashicons-update">${r("Refresh")}</os-context-menu-option>
280 280 `}
281 281 </os-context-menu>
282 - `}function zs(e,t){const s=k(e),n=s.quickEdit;if(!n||!t)return"";const o=()=>{s.quickEdit=null,e.repaint()},i=()=>{const p={items:n.ids};n.status&&(p.status=n.status),n.comments&&(p.comments=n.comments),n.author&&(p.author=Number(n.author)),n.sticky&&(p.sticky=n.sticky),n.categories.length>0&&(p.categories=n.categories),n.tags.length>0&&(p.tags=n.tags.map(f=>f.label).join(", ")),o(),e.dispatch("quick-edit",p)},a=["",r("— No change —")],l=p=>f=>{n[p]=String(f.detail?.value??"")},d=(p,f,m)=>c`
282 + `}function Xs(e,t){const s=k(e),n=s.quickEdit;if(!n||!t)return"";const o=()=>{s.quickEdit=null,e.repaint()},i=()=>{const p={items:n.ids};n.status&&(p.status=n.status),n.comments&&(p.comments=n.comments),n.author&&(p.author=Number(n.author)),n.sticky&&(p.sticky=n.sticky),n.categories.length>0&&(p.categories=n.categories),n.tags.length>0&&(p.tags=n.tags.map(f=>f.label).join(", ")),o(),e.dispatch("quick-edit",p)},a=["",r("— No change —")],l=p=>f=>{n[p]=String(f.detail?.value??"")},u=(p,f,m)=>c`
283 283 <label class="os-mywp__qe-row">
284 284 <span>${p}</span>
285 285 <os-select value=${n[f]} @os-pick=${l(f)}>
286 286 ${m.map(([h,$])=>c`
@@ -287,9 +287,9 @@
287 287 <os-option value=${h} ?selected=${h===n[f]}>${$}</os-option>
288 288 `)}
289 289 </os-select>
290 290 </label>
291 - `,u=t.post_type==="post";return c`
291 + `,d=t.post_type==="post";return c`
292 292 <os-modal
293 293 open
294 294 size="sm"
295 295 title=${b(r("Edit %1$d %2$s"),n.ids.length,t.label)}
@@ -298,13 +298,13 @@
298 298 <os-notice tone="info" class="os-mywp__qe-notice" not-dismissible>
299 299 ${r("Only the fields you change are applied. Categories and tags are added to what each entry already has.")}
300 300 </os-notice>
301 301 <div class="os-mywp__qe">
302 - ${d(r("Status"),"status",[a,["publish",r("Published")],["pending",r("Pending Review")],["draft",r("Draft")],["private",r("Private")]])}
303 - ${e.data.authors.length>0?d(r("Author"),"author",[a,...e.data.authors.map(p=>[String(p.id),p.name])]):""}
304 - ${d(r("Comments"),"comments",[a,["open",r("Allow")],["closed",r("Do not allow")]])}
305 - ${u?d(r("Sticky"),"sticky",[a,["sticky",r("Sticky")],["not-sticky",r("Not sticky")]]):""}
306 - ${u&&e.data.categories.length>0?c`
302 + ${u(r("Status"),"status",[a,["publish",r("Published")],["pending",r("Pending Review")],["draft",r("Draft")],["private",r("Private")]])}
303 + ${e.data.authors.length>0?u(r("Author"),"author",[a,...e.data.authors.map(p=>[String(p.id),p.name])]):""}
304 + ${u(r("Comments"),"comments",[a,["open",r("Allow")],["closed",r("Do not allow")]])}
305 + ${d?u(r("Sticky"),"sticky",[a,["sticky",r("Sticky")],["not-sticky",r("Not sticky")]]):""}
306 + ${d&&e.data.categories.length>0?c`
307 307 <div class="os-mywp__qe-row">
308 308 <span>${r("Add categories")}</span>
309 309 <os-category-picker
310 310 .items=${e.data.categories}
@@ -312,9 +312,9 @@
312 312 @os-categories-change=${p=>{n.categories=[...p.detail?.value??[]],e.repaint()}}
313 313 ></os-category-picker>
314 314 </div>
315 315 `:""}
316 - ${u?c`
316 + ${d?c`
317 317 <div class="os-mywp__qe-row">
318 318 <span>${r("Add tags")}</span>
319 319 <os-tag-input
320 320 creatable
@@ -332,13 +332,13 @@
332 332 <os-button variant="ghost" @click=${o}>${r("Cancel")}</os-button>
333 333 <os-button variant="primary" @click=${i}>${r("Update")}</os-button>
334 334 </div>
335 335 </os-modal>
336 - `}function Hs(e){const t=k(e),s=e.data.detail;return!t.zoom||!s?.full?"":c`
336 + `}function Ys(e){const t=k(e),s=e.data.detail;return!t.zoom||!s?.full?"":c`
337 337 <div class="os-mywp__zoom" @click=${()=>{t.zoom=!1,e.repaint()}}>
338 338 <img src=${s.full} alt=${s.title} />
339 339 </div>
340 - `}const Xs=["bio","stats","activity","milestones","recent","terms"];function Ys(e,t){if(e.kind!=="user")return null;const s=T().hooks?.applyFilters("os.my-wordpress.user-dossier-sections",Xs,{entityId:t.id,kind:t.kind,userId:e.id});return Array.isArray(s)?new Set(s):null}function Gs(e,t){return t?e.facts.filter(s=>!s[2]||t.has(s[2])):e.facts}function Vs(e,t,s){const n=t.kind==="user"?t.stats:null;if(!n)return"";const o=p=>!s||s.has(p),i=n.counts?.posts??{},a=n.counts?.pages??{},l=p=>b(r("%d published"),p.publish??0),d=[];n.profile?.registered&&d.push([r("Member since"),I(n.profile.registered,"month")]),n.milestones?.firstPublished&&d.push([r("First published"),I(n.milestones.firstPublished,"month")]),n.milestones?.lastPublished&&d.push([r("Last published"),I(n.milestones.lastPublished,"month")]);const u=n.topTerms??[];return c`
340 + `}const Gs=["bio","stats","activity","milestones","recent","terms"];function Vs(e,t){if(e.kind!=="user")return null;const s=T().hooks?.applyFilters("os.my-wordpress.user-dossier-sections",Gs,{entityId:t.id,kind:t.kind,userId:e.id});return Array.isArray(s)?new Set(s):null}function Qs(e,t){return t?e.facts.filter(s=>!s[2]||t.has(s[2])):e.facts}function Js(e,t,s){const n=t.kind==="user"?t.stats:null;if(!n)return"";const o=p=>!s||s.has(p),i=n.counts?.posts??{},a=n.counts?.pages??{},l=p=>b(r("%d published"),p.publish??0),u=[];n.profile?.registered&&u.push([r("Member since"),I(n.profile.registered,"month")]),n.milestones?.firstPublished&&u.push([r("First published"),I(n.milestones.firstPublished,"month")]),n.milestones?.lastPublished&&u.push([r("Last published"),I(n.milestones.lastPublished,"month")]);const d=n.topTerms??[];return c`
341 341 ${o("stats")?c`<div class="os-mywp__stats">
342 342 ${j(i.total??0,r("Posts"),l(i))}
343 343 ${j(a.total??0,r("Pages"))}
344 344 ${j(n.counts?.commentsReceived??0,r("Comments received"))}
@@ -343,35 +343,35 @@
343 343 ${j(a.total??0,r("Pages"))}
344 344 ${j(n.counts?.commentsReceived??0,r("Comments received"))}
345 345 ${j(n.counts?.commentsLeft??0,r("Comments left"))}
346 346 </div>`:""}
347 - ${o("activity")?je(n.activity??[]):""}
348 - ${o("milestones")&&d.length>0?be(d):""}
349 - ${o("recent")?Ke(e,n.recent??[]):""}
350 - ${o("terms")&&u.length>0?c`
347 + ${o("activity")?Ke(n.activity??[]):""}
348 + ${o("milestones")&&u.length>0?ke(u):""}
349 + ${o("recent")?ze(e,n.recent??[]):""}
350 + ${o("terms")&&d.length>0?c`
351 351 <h3 class="os-mywp__pane-h">${r("Top categories & tags")}</h3>
352 352 <div class="os-mywp__chips">
353 - ${u.map(p=>c`<span class="os-mywp__chip os-mywp__chip--static">${p.name} · ${p.count}</span>`)}
353 + ${d.map(p=>c`<span class="os-mywp__chip os-mywp__chip--static">${p.name} · ${p.count}</span>`)}
354 354 </div>
355 355 `:""}
356 - `}function Qs(e,t,s,n){const o=[{id:"footprint",label:r("View activity footprint"),title:r("Open the full activity footprint surface for this user."),variant:"primary",onSelect:()=>void e.dispatch("footprint",{user:s.id,name:s.title})}];s.canEdit&&o.push({id:"open-profile",label:r("Edit profile"),variant:"secondary",onSelect:()=>ee(s.id,{source:"my-wordpress-app/user-pane",fallback:()=>void e.dispatch("edit",{item:s.id})})});const i=T().hooks?.applyFilters("os.my-wordpress.user-preview-actions",o,{entityId:t.id,kind:t.kind,item:{...n??{},...s}});return(Array.isArray(i)?i:o).filter(l=>!!l&&typeof l.onSelect=="function")}function $t(e,t){return c`
356 + `}function Zs(e,t,s,n){const o=[{id:"footprint",label:r("View activity footprint"),title:r("Open the full activity footprint surface for this user."),variant:"primary",onSelect:()=>void e.dispatch("footprint",{user:s.id,name:s.title})}];s.canEdit&&o.push({id:"open-profile",label:r("Edit profile"),variant:"secondary",onSelect:()=>te(s.id,{source:"my-wordpress-app/user-pane",fallback:()=>void e.dispatch("edit",{item:s.id})})});const i=T().hooks?.applyFilters("os.my-wordpress.user-preview-actions",o,{entityId:t.id,kind:t.kind,item:{...n??{},...s}});return(Array.isArray(i)?i:o).filter(l=>!!l&&typeof l.onSelect=="function")}function vt(e,t){return c`
357 357 <div class="os-mywp__split ${t?"":"os-mywp__split--solo"}">
358 358 <div class="os-mywp__list-pane">${e}</div>
359 359 ${t?c`<aside class="os-mywp__detail-pane">${t}</aside>`:""}
360 360 </div>
361 - `}function ve(e,t){return c`<div
361 + `}function be(e,t){return c`<div
362 362 class="os-my-wordpress__article-slot os-my-wordpress__article-slot--${e}"
363 363 data-mywp-slot=${e}
364 364 data-mywp-extras-item=${String(t)}
365 365 os-preserve
366 - ></div>`}function wt(e,t){const{data:s}=e,n=pt(e);if(!n){const f=k(e).list.items().find(m=>m.id===e.state.item);return c`<article class="os-mywp__detail" aria-busy=${k(e).previewLoading?"true":"false"}>
366 + ></div>`}function _t(e,t){const{data:s}=e,n=mt(e);if(!n){const f=k(e).list.items().find(m=>m.id===e.state.item);return c`<article class="os-mywp__detail" aria-busy=${k(e).previewLoading?"true":"false"}>
367 367 <os-button variant="ghost" class="os-mywp__pane-close" aria-label=${r("Close details")} @click=${()=>O(e,0)}>✕</os-button>
368 368 ${f?.thumb?c`<img class="os-mywp__hero" src=${f.thumb} alt=${f.title}/>`:""}
369 369 <h2 class="os-mywp__detail-title">${f?.title??""}</h2>
370 370 <p>${f?.subtitle??""}</p>
371 371 <p>${f?.excerpt??""}</p>
372 - <p role="status">${bs(e)}</p>
373 - </article>`}const o=k(e).list.items().find(f=>f.id===n.id)??(s.list?.items??[]).find(f=>f.id===n.id),i=o?fe(s.previewActions,x(t,o,"pane"),T().hooks):[],a=Ys(n,t),l=Gs(n,a),d=n.kind==="user"?n.stats?.profile?.roleLabels?.[0]??"":"",u=n.kind==="user"?n.stats?.profile?.link??"":"";let p="";return n.kind==="user"?p=Qs(e,t,n,o??null).map(f=>c`
372 + <p role="status">${Ss(e)}</p>
373 + </article>`}const o=k(e).list.items().find(f=>f.id===n.id)??(s.list?.items??[]).find(f=>f.id===n.id),i=o?me(s.previewActions,ee(t,o,"pane"),T().hooks):[],a=Vs(n,t),l=Qs(n,a),u=n.kind==="user"?n.stats?.profile?.roleLabels?.[0]??"":"",d=n.kind==="user"?n.stats?.profile?.link??"":"";let p="";return n.kind==="user"?p=Zs(e,t,n,o??null).map(f=>c`
374 374 <os-button
375 375 variant=${f.variant??"secondary"}
376 376 title=${f.title??""}
377 377 @click=${()=>f.onSelect()}
@@ -393,22 +393,22 @@
393 393 alt=${n.title}
394 394 @click=${()=>{n.kind==="media"&&(k(e).zoom=!0,e.repaint())}}
395 395 />`:""}
396 396 <h2 class="os-mywp__detail-title">${n.title}</h2>
397 - ${d||u?c`<p class="os-mywp__user-meta">
398 - ${d?c`<os-badge no-dot>${d.toUpperCase()}</os-badge>`:""}
399 - ${u?c`<a class="os-mywp__crumb-link" href=${u} target="_blank" rel="noreferrer">${r("Author archive")}</a>`:""}
397 + ${u||d?c`<p class="os-mywp__user-meta">
398 + ${u?c`<os-badge no-dot>${u.toUpperCase()}</os-badge>`:""}
399 + ${d?c`<a class="os-mywp__crumb-link" href=${d} target="_blank" rel="noreferrer">${r("Author archive")}</a>`:""}
400 400 </p>`:""}
401 - ${ve("header",n.id)}
401 + ${be("header",n.id)}
402 402 ${n.lockedBy?c`<os-notice tone="warning" not-dismissible>${b(r("%s is editing this right now."),n.lockedBy)}</os-notice>`:""}
403 - ${be(l)}
404 - ${_t(n.usedIn)}
403 + ${ke(l)}
404 + ${bt(n.usedIn)}
405 405 ${n.content!==void 0?c`
406 406 <h3 class="os-mywp__pane-h">${r("Preview")}</h3>
407 407 <div class="os-mywp__content" data-mywp-content="detail" os-preserve></div>
408 408 `:""}
409 - ${ve("meta",n.id)}
410 - ${Vs(e,n,a)}
409 + ${be("meta",n.id)}
410 + ${Js(e,n,a)}
411 411 <div class="os-mywp__actions">
412 412 ${n.kind==="post"&&!t.flat?c`<os-button
413 413 variant="secondary"
414 414 title=${r("See author, comments, categories, tags, attached media, and revisions for this entry.")}
@@ -415,20 +415,20 @@
415 415 @click=${()=>void e.dispatch("into",{item:n.id})}
416 416 >${r("Explore details")}</os-button>`:""}
417 417 ${p}
418 418 ${i.map(f=>c`
419 - <os-button variant="secondary" @click=${()=>o&&at(f,x(t,o,"pane"))}>
419 + <os-button variant="secondary" @click=${()=>o&&dt(f,ee(t,o,"pane"))}>
420 420 ${f.label}
421 421 </os-button>
422 422 `)}
423 423 ${n.kind==="post"&&n.canDelete?c`<os-button
424 424 variant="danger"
425 - @click=${()=>o&&void ft(e,t,[o])}
425 + @click=${()=>o&&void ht(e,t,[o])}
426 426 >${r("Trash")}</os-button>`:""}
427 427 </div>
428 - ${ve("footer",n.id)}
428 + ${be("footer",n.id)}
429 429 </article>
430 - `}function Zs(e){const t=e.data.folder;return t?c`
430 + `}function xs(e){const t=e.data.folder;return t?c`
431 431 <div class="os-mywp__split">
432 432 <div class="os-mywp__list-pane">
433 433 <div class="os-mywp__tiles" role="list">
434 434 ${t.folders.map(s=>c`
@@ -440,9 +440,9 @@
440 440 ref=${s.relation}
441 441 label=${`${s.label} · ${s.count}`}
442 442 icon=${s.icon}
443 443 ?selected=${k(e).folderSel===`relation:${s.relation}`}
444 - @click=${()=>{if(ue()){s.disabled||(k(e).folderSel=null,e.dispatch("relation",{relation:s.relation}));return}k(e).folderSel=`relation:${s.relation}`,e.repaint()}}
444 + @click=${()=>{if(pe()){s.disabled||(k(e).folderSel=null,e.dispatch("relation",{relation:s.relation}));return}k(e).folderSel=`relation:${s.relation}`,e.repaint()}}
445 445 @dblclick=${()=>{s.disabled||(k(e).folderSel=null,e.dispatch("relation",{relation:s.relation}))}}
446 446 ></os-tile>
447 447 </span>
448 448 </div>
@@ -452,13 +452,13 @@
452 452 <aside class="os-mywp__detail-pane">
453 453 <article class="os-mywp__detail">
454 454 <h2 class="os-mywp__detail-title">${t.title}</h2>
455 455 <div class="os-mywp__content" data-mywp-content="folder" os-preserve></div>
456 - ${ve("meta",t.id)}
456 + ${be("meta",t.id)}
457 457 </article>
458 458 </aside>
459 459 </div>
460 - `:c`<os-empty-state>${r("This item no longer exists.")}</os-empty-state>`}function j(e,t,s=""){return c`<os-stat value=${String(e)} label=${t} caption=${s}></os-stat>`}function je(e){const t=new Map(e.map(i=>[i.ym,i.count])),s=[],n=new Date;n.setDate(1),n.setMonth(n.getMonth()-11);for(let i=0;i<12;i++){const a=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}`;s.push({ym:a,label:n.toLocaleDateString(void 0,{month:"short"}),count:t.get(a)??0}),n.setMonth(n.getMonth()+1)}const o=Math.max(1,...s.map(i=>i.count));return c`
460 + `:c`<os-empty-state>${r("This item no longer exists.")}</os-empty-state>`}function j(e,t,s=""){return c`<os-stat value=${String(e)} label=${t} caption=${s}></os-stat>`}function Ke(e){const t=new Map(e.map(i=>[i.ym,i.count])),s=[],n=new Date;n.setDate(1),n.setMonth(n.getMonth()-11);for(let i=0;i<12;i++){const a=`${n.getFullYear()}-${String(n.getMonth()+1).padStart(2,"0")}`;s.push({ym:a,label:n.toLocaleDateString(void 0,{month:"short"}),count:t.get(a)??0}),n.setMonth(n.getMonth()+1)}const o=Math.max(1,...s.map(i=>i.count));return c`
461 461 <h3 class="os-mywp__pane-h">${r("Activity (last 12 months)")}</h3>
462 462 <div class="os-mywp__activity" role="img" aria-label=${r("Posts per month")}>
463 463 ${s.map(i=>c`
464 464 <div class="os-mywp__activity-col" title="${i.label} · ${i.count}">
@@ -466,9 +466,9 @@
466 466 <span class="os-mywp__activity-label">${i.label}</span>
467 467 </div>
468 468 `)}
469 469 </div>
470 - `}function Ke(e,t){return t.length===0?"":c`
470 + `}function ze(e,t){return t.length===0?"":c`
471 471 <h3 class="os-mywp__pane-h">${r("Recent posts")}</h3>
472 472 <div class="os-mywp__recent">
473 473 ${t.slice(0,6).map(s=>c`
474 474 <button
@@ -480,26 +480,26 @@
480 480 <span class="os-mywp__subtitle">${new Date(s.date).toLocaleString()}${s.status?` · ${s.status}`:""}</span>
481 481 </button>
482 482 `)}
483 483 </div>
484 - `}function be(e){return c`
485 - <dl class="os-mywp__facts">
484 + `}function ke(e){return c`
485 + <os-facts>
486 486 ${e.map(([t,s])=>c`
487 - <div class="os-mywp__fact"><dt>${t}</dt><dd>${s}</dd></div>
487 + <os-fact label=${t}>${s}</os-fact>
488 488 `)}
489 - </dl>
490 - `}function _t(e){return e?c`
489 + </os-facts>
490 + `}function bt(e){return e?c`
491 491 <h3 class="os-mywp__pane-h">${r("Used in")}</h3>
492 492 ${e.length>0?c`<ul class="os-mywp__used-in">
493 493 ${e.map(t=>c`<li>${t.title} <span class="os-mywp__subtitle">${t.usedAs}</span></li>`)}
494 494 </ul>`:c`<p class="os-mywp__subtitle">${r("Not used anywhere yet.")}</p>`}
495 - `:""}function vt(e){return c`
495 + `:""}function kt(e){return c`
496 496 ${e.avatar?c`<os-avatar src=${e.avatar} name=${e.title} size="xl"></os-avatar>`:""}
497 497 ${e.image?c`<img class="os-mywp__hero" src=${e.image} alt=${e.title} />`:""}
498 498 <h2 class="os-mywp__detail-title">${e.title}</h2>
499 - ${be(e.facts)}
500 - ${_t(e.usedIn)}
501 - `}function Js(e){const t=e.data.subDetail;if(!t)return null;if(t.kind==="term"){const s=t.stats,n=s.counts?.posts??{},o=n.publish??0;return c`
499 + ${ke(e.facts)}
500 + ${bt(e.usedIn)}
501 + `}function en(e){const t=e.data.subDetail;if(!t)return null;if(t.kind==="term"){const s=t.stats,n=s.counts?.posts??{},o=n.publish??0;return c`
502 502 <article class="os-mywp__detail">
503 503 <header class="os-mywp__term-head">
504 504 <span class="os-mywp__term-swatch" aria-hidden="true"></span>
505 505 <div>
@@ -512,10 +512,10 @@
512 512 ${j(n.total??0,r("Posts"),b(r("%d published"),o))}
513 513 ${j(s.counts?.commentsReceived??0,r("Comments"))}
514 514 ${j(s.counts?.distinctAuthors??0,r("Authors"))}
515 515 </div>
516 - ${je(s.activity??[])}
517 - ${be([...s.milestones?.firstPosted?[[r("First post"),I(s.milestones.firstPosted,"month")]]:[],...s.milestones?.lastPosted?[[r("Last post"),I(s.milestones.lastPosted,"month")]]:[]])}
516 + ${Ke(s.activity??[])}
517 + ${ke([...s.milestones?.firstPosted?[[r("First post"),I(s.milestones.firstPosted,"month")]]:[],...s.milestones?.lastPosted?[[r("Last post"),I(s.milestones.lastPosted,"month")]]:[]])}
518 518 ${(s.topAuthors??[]).length>0?c`
519 519 <h3 class="os-mywp__pane-h">${r("Top contributors")}</h3>
520 520 <div class="os-mywp__people">
521 521 ${(s.topAuthors??[]).map(i=>c`
@@ -521,9 +521,9 @@
521 521 ${(s.topAuthors??[]).map(i=>c`
522 522 <div class="os-mywp__person">
523 523 <os-avatar src=${i.userAvatarUrl} name=${i.userName} size="sm"></os-avatar>
524 524 <span class="os-mywp__person-name">${i.userName}</span>
525 - <span class="os-mywp__subtitle">${b(q("%d post","%d posts",i.count),i.count)}</span>
525 + <span class="os-mywp__subtitle">${b(B("%d post","%d posts",i.count),i.count)}</span>
526 526 </div>
527 527 `)}
528 528 </div>
529 529 `:""}
@@ -538,15 +538,15 @@
538 538 >${i.name} · ${i.count}</button>
539 539 `)}
540 540 </div>
541 541 `:""}
542 - ${Ke(e,s.recent??[])}
542 + ${ze(e,s.recent??[])}
543 543 </article>
544 544 `}if(t.kind==="user")return c`
545 545 <article class="os-mywp__detail">
546 - ${vt(t.detail)}
547 - ${je(t.stats?.activity??[])}
548 - ${Ke(e,t.stats?.recent??[])}
546 + ${kt(t.detail)}
547 + ${Ke(t.stats?.activity??[])}
548 + ${ze(e,t.stats?.recent??[])}
549 549 </article>
550 550 `;if(t.kind==="comment"){const s=t.stats;return c`
551 551 <article class="os-mywp__detail">
552 552 <h2 class="os-mywp__detail-title">${s.author?.name??r("Comment")}</h2>
@@ -555,9 +555,9 @@
555 555 ${s.post?.id?c`<os-button variant="secondary" @click=${()=>void e.dispatch("sub-open-post",{post:s.post?.id})}>
556 556 ${r("Open the post")}
557 557 </os-button>`:""}
558 558 </article>
559 - `}return t.kind==="media"?c`<article class="os-mywp__detail">${vt(t.detail)}</article>`:c`
559 + `}return t.kind==="media"?c`<article class="os-mywp__detail">${kt(t.detail)}</article>`:c`
560 560 <article class="os-mywp__detail">
561 561 <h2 class="os-mywp__detail-title">${t.title}</h2>
562 562 <p class="os-mywp__subtitle">${t.author}${t.date?` · ${t.date}`:""}</p>
563 563 <h3 class="os-mywp__pane-h">${r("Preview")}</h3>
@@ -562,9 +562,9 @@
562 562 <p class="os-mywp__subtitle">${t.author}${t.date?` · ${t.date}`:""}</p>
563 563 <h3 class="os-mywp__pane-h">${r("Preview")}</h3>
564 564 <div class="os-mywp__content" data-mywp-content="sub" os-preserve></div>
565 565 </article>
566 - `}function xs(e){const t=e.data.sub;return t?$t(c`
566 + `}function tn(e){const t=e.data.sub;return t?vt(c`
567 567 ${t.rows.length===0?c`<os-empty-state>${r("Nothing here yet.")}</os-empty-state>`:c`
568 568 <div class="os-mywp__tiles" role="list">
569 569 ${t.rows.map(s=>c`
570 570 <div
@@ -580,9 +580,9 @@
580 580 label=${s.title}
581 581 icon=${s.thumb?"":s.icon??"dashicons-media-default"}
582 582 thumbnail=${s.thumb??""}
583 583 ?selected=${e.state.item===s.id}
584 - @click=${()=>{if(ue()&&s.editUrl){e.dispatch("sub-open",{row:s.id});return}e.dispatch("open",{item:s.id})}}
584 + @click=${()=>{if(pe()&&s.editUrl){e.dispatch("sub-open",{row:s.id});return}e.dispatch("open",{item:s.id})}}
585 585 @dblclick=${()=>s.editUrl&&void e.dispatch("sub-open",{row:s.id})}
586 586 ></os-tile>
587 587 </span>
588 588 </div>
@@ -588,18 +588,18 @@
588 588 </div>
589 589 `)}
590 590 </div>
591 591 `}
592 - `,Js(e)):c`<os-empty-state>${r("This item no longer exists.")}</os-empty-state>`}function en(e,t){const s=k(e);if(s.fp&&s.fp.userId===t)return s.fp;const n={userId:t,status:"loading",payload:null};return s.fp=n,e.fetch(`desktop-mode/v1/user-footprint/${t}`).then(async o=>{if(!o.ok)throw new Error(String(o.status));return await o.json()}).then(o=>{s.fp===n&&(n.status="ready",n.payload=o,e.repaint())}).catch(()=>{s.fp===n&&(n.status="error",e.repaint())}),n}function tn(e){const t=Number(e.state.footprint);if(!(t>0))return null;const s=k(e).fp;if(!s||s.userId!==t||s.status==="loading")return[r("Loading footprint…"),""];if(s.status==="error"||!s.payload)return[r("Could not load footprint."),""];const n=s.payload;return[b(r("%1$d posts · %2$d comments tracked"),n.totals.posts+n.totals.pages,n.totals.comments),b(r("Window %1$s → %2$s"),I(n.range.from),I(n.range.to))]}function sn(e){const t=e.trim().split(/\s+/).filter(s=>s.length>0);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase()}function te(e,t,s){return c`
592 + `,en(e)):c`<os-empty-state>${r("This item no longer exists.")}</os-empty-state>`}const St="X-WP-Nonce";function sn(e,t){const s=nn();if(!s)return t;const n=on(e);if(!n||!rn(n))return t;const o=t?.headers??(typeof Request<"u"&&e instanceof Request?e.headers:void 0),i=new Headers(o??{});return i.has(St)?t:(i.set(St,s),{...t??{},headers:i})}function nn(){if(typeof window>"u")return;const t=window.openStationConfig?.restNonce;return typeof t=="string"&&t.length>0?t:void 0}function on(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 rn(e){return typeof window>"u"||!window.location||e.origin!==window.location.origin?!1:!!(e.pathname.includes("/wp-json/")||e.searchParams.has("rest_route"))}function He(e,t,s={}){const n=window.wp?.os?.fetch;if(typeof n=="function")return n(e,t,s);const o=sn(e,t);return fetch(e,o)}class Xe extends Error{constructor(t,s){super(t||s.serverMessage||`HTTP ${s.status}`),this.name="RestError",this.status=s.status,this.code=s.code,this.data=s.data,this.serverMessage=s.serverMessage??""}}function an(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 se(e,t,s=""){return new Xe(s,{status:e,...an(t)})}async function ln(e,t=""){let s=null;try{s=await e.json()}catch{s=null}return se(e.status,s,t)}function dn(e,t){const s=k(e);if(s.fp&&s.fp.userId===t)return s.fp;const n={userId:t,status:"loading",payload:null};return s.fp=n,e.fetch(`desktop-mode/v1/user-footprint/${t}`).then(async o=>{if(!o.ok)throw await ln(o);return await o.json()}).then(o=>{s.fp===n&&(n.status="ready",n.payload=o,e.repaint())}).catch(()=>{s.fp===n&&(n.status="error",e.repaint())}),n}function cn(e){const t=Number(e.state.footprint);if(!(t>0))return null;const s=k(e).fp;if(!s||s.userId!==t||s.status==="loading")return[r("Loading footprint…"),""];if(s.status==="error"||!s.payload)return[r("Could not load footprint."),""];const n=s.payload;return[b(r("%1$d posts · %2$d comments tracked"),n.totals.posts+n.totals.pages,n.totals.comments),b(r("Window %1$s → %2$s"),I(n.range.from),I(n.range.to))]}function un(e){const t=e.trim().split(/\s+/).filter(s=>s.length>0);return t.length===0?"?":t.length===1?t[0].slice(0,2).toUpperCase():(t[0][0]+t[t.length-1][0]).toUpperCase()}function ne(e,t,s){return c`
593 593 <div class="os-my-wordpress__user-stat">
594 594 <span class="os-my-wordpress__user-stat-value">${e}</span>
595 595 <span class="os-my-wordpress__user-stat-label">${t}</span>
596 596 ${s?c`<span class="os-my-wordpress__user-stat-caption">${s}</span>`:""}
597 597 </div>
598 - `}function nn(e){const t=e.profile.roleLabels??[];return c`
598 + `}function pn(e){const t=e.profile.roleLabels??[];return c`
599 599 <header class="os-my-wordpress__footprint-hero">
600 600 <div class="os-my-wordpress__footprint-avatar">
601 - ${e.profile.avatarUrl?c`<img src=${e.profile.avatarUrl} alt="" />`:c`<span class="os-my-wordpress__user-tile-initials">${sn(e.profile.name)}</span>`}
601 + ${e.profile.avatarUrl?c`<img src=${e.profile.avatarUrl} alt="" />`:c`<span class="os-my-wordpress__user-tile-initials">${un(e.profile.name)}</span>`}
602 602 </div>
603 603 <div class="os-my-wordpress__footprint-headline">
604 604 <h1 class="os-my-wordpress__footprint-title">${e.profile.name}</h1>
605 605 <div class="os-my-wordpress__footprint-meta">
@@ -610,22 +610,22 @@
610 610 <a href=${e.profile.link} target="_blank" rel="noopener noreferrer">${r("Author archive")}</a>
611 611 </div>`:""}
612 612 </div>
613 613 </header>
614 - `}function on(e){const t=e.totals.posts+e.totals.pages,s=e.totals.updates??0,n=e.streak.longestRange;return c`
614 + `}function fn(e){const t=e.totals.posts+e.totals.pages,s=e.totals.updates??0,n=e.streak.longestRange;return c`
615 615 <section class="os-my-wordpress__footprint-section os-my-wordpress__footprint-stats-row">
616 - ${te(t.toLocaleString(),r("Total content"),e.totals.posts>0&&e.totals.pages>0?b(r("%1$d posts · %2$d pages"),e.totals.posts,e.totals.pages):"")}
617 - ${te(e.totals.comments.toLocaleString(),r("Comments left"),"")}
618 - ${s>0?te(s.toLocaleString(),r("Updates"),r("Saves on existing posts")):""}
619 - ${te(b(q("%d day","%d days",e.streak.longest),e.streak.longest),r("Longest streak"),n.from&&n.to?b(r("%1$s → %2$s"),I(n.from),I(n.to)):"")}
620 - ${te(b(q("%d day","%d days",e.streak.current),e.streak.current),r("Current streak"),e.streak.current===0?r("No activity today"):r("Including today"))}
616 + ${ne(t.toLocaleString(),r("Total content"),e.totals.posts>0&&e.totals.pages>0?b(r("%1$d posts · %2$d pages"),e.totals.posts,e.totals.pages):"")}
617 + ${ne(e.totals.comments.toLocaleString(),r("Comments left"),"")}
618 + ${s>0?ne(s.toLocaleString(),r("Updates"),r("Saves on existing posts")):""}
619 + ${ne(b(B("%d day","%d days",e.streak.longest),e.streak.longest),r("Longest streak"),n.from&&n.to?b(r("%1$s → %2$s"),I(n.from),I(n.to)):"")}
620 + ${ne(b(B("%d day","%d days",e.streak.current),e.streak.current),r("Current streak"),e.streak.current===0?r("No activity today"):r("Including today"))}
621 621 </section>
622 - `}function rn(e){const t=f=>f.posts+f.comments+(f.updates??0),s=e.daily.reduce((f,m)=>{const h=t(m);return h>f?h:f},0),n=f=>{if(f<=0||s<=0)return 0;const m=f/s;return m>.75?4:m>.5?3:m>.25?2:1},o=e.daily.map(f=>new Date(f.date+"T00:00:00Z"));if(o.length===0)return c`
622 + `}function mn(e){const t=f=>f.posts+f.comments+(f.updates??0),s=e.daily.reduce((f,m)=>{const h=t(m);return h>f?h:f},0),n=f=>{if(f<=0||s<=0)return 0;const m=f/s;return m>.75?4:m>.5?3:m>.25?2:1},o=e.daily.map(f=>new Date(f.date+"T00:00:00Z"));if(o.length===0)return c`
623 623 <section class="os-my-wordpress__footprint-section os-my-wordpress__footprint-calendar-section">
624 624 <h3>${r("A year of activity")}</h3>
625 625 <p class="os-my-wordpress__article-meta">${r("No activity recorded in the last year.")}</p>
626 626 </section>
627 - `;const i=o[0].getUTCDay(),a=f=>`grid-row:${f%7+2};grid-column:${Math.floor(f/7)+2}`,l=[new Date(Date.UTC(2024,11,2)),new Date(Date.UTC(2024,11,4)),new Date(Date.UTC(2024,11,6))],d=[3,5,7],u=[];let p=-1;for(let f=0;f<e.daily.length;f+=1){const m=o[f].getUTCMonth();if(m===p)continue;p=m;const h=i+f,$=Math.floor(h/7);$===0&&h%7!==0||u.push(c`<span
627 + `;const i=o[0].getUTCDay(),a=f=>`grid-row:${f%7+2};grid-column:${Math.floor(f/7)+2}`,l=[new Date(Date.UTC(2024,11,2)),new Date(Date.UTC(2024,11,4)),new Date(Date.UTC(2024,11,6))],u=[3,5,7],d=[];let p=-1;for(let f=0;f<e.daily.length;f+=1){const m=o[f].getUTCMonth();if(m===p)continue;p=m;const h=i+f,$=Math.floor(h/7);$===0&&h%7!==0||d.push(c`<span
628 628 class="os-my-wordpress__footprint-month"
629 629 style="grid-row:1;grid-column:${$+2}"
630 630 >${o[f].toLocaleDateString(void 0,{month:"short"})}</span>`)}return c`
631 631 <section class="os-my-wordpress__footprint-section os-my-wordpress__footprint-calendar-section">
@@ -633,11 +633,11 @@
633 633 <div class="os-my-wordpress__footprint-calendar">
634 634 <div class="os-my-wordpress__footprint-grid">
635 635 ${l.map((f,m)=>c`<span
636 636 class="os-my-wordpress__footprint-weekday"
637 - style="grid-column:1;grid-row:${d[m]+1}"
637 + style="grid-column:1;grid-row:${u[m]+1}"
638 638 >${f.toLocaleDateString(void 0,{weekday:"short"})}</span>`)}
639 - ${u}
639 + ${d}
640 640 ${Array.from({length:i},(f,m)=>c`<span
641 641 class="os-my-wordpress__footprint-cell os-my-wordpress__footprint-cell--pad"
642 642 aria-hidden="true"
643 643 style=${a(m)}
@@ -655,9 +655,9 @@
655 655 <span class="os-my-wordpress__footprint-legend-label">${r("More")}</span>
656 656 </div>
657 657 </div>
658 658 </section>
659 - `}function bt(e,t,s){const n=Math.max(1,...e);return c`
659 + `}function At(e,t,s){const n=Math.max(1,...e);return c`
660 660 <div class="os-my-wordpress__footprint-bars">
661 661 ${e.map((o,i)=>c`
662 662 <div class="os-my-wordpress__footprint-bar-col">
663 663 <div
@@ -668,29 +668,29 @@
668 668 <span class="os-my-wordpress__footprint-bar-label">${t[i]??""}</span>
669 669 </div>
670 670 `)}
671 671 </div>
672 - `}function an(e){const t=[r("S"),r("M"),r("T"),r("W"),r("T"),r("F"),r("S")],s=[r("Sunday"),r("Monday"),r("Tuesday"),r("Wednesday"),r("Thursday"),r("Friday"),r("Saturday")],n=Array.from({length:24},(i,a)=>a%3===0?String(a):""),o=Array.from({length:24},(i,a)=>b(r("%d:00"),a));return c`
672 + `}function hn(e){const t=[r("S"),r("M"),r("T"),r("W"),r("T"),r("F"),r("S")],s=[r("Sunday"),r("Monday"),r("Tuesday"),r("Wednesday"),r("Thursday"),r("Friday"),r("Saturday")],n=Array.from({length:24},(i,a)=>a%3===0?String(a):""),o=Array.from({length:24},(i,a)=>b(r("%d:00"),a));return c`
673 673 <section class="os-my-wordpress__footprint-section os-my-wordpress__footprint-rhythm">
674 674 <h3>${r("Publishing rhythm")}</h3>
675 675 <div class="os-my-wordpress__footprint-rhythm-grid">
676 676 <div class="os-my-wordpress__footprint-chart">
677 677 <div class="os-my-wordpress__footprint-chart-caption">${r("By weekday")}</div>
678 - ${bt(e.weekday,t,s)}
678 + ${At(e.weekday,t,s)}
679 679 </div>
680 680 <div class="os-my-wordpress__footprint-chart">
681 681 <div class="os-my-wordpress__footprint-chart-caption">${r("By hour of day (site time)")}</div>
682 - ${bt(e.hour,n,o)}
682 + ${At(e.hour,n,o)}
683 683 </div>
684 684 </div>
685 685 </section>
686 - `}function ln(e){const t=e.totals.mostProlificMonth;return t?c`
686 + `}function gn(e){const t=e.totals.mostProlificMonth;return t?c`
687 687 <section class="os-my-wordpress__footprint-section os-my-wordpress__footprint-callout">
688 688 <span class="os-my-wordpress__footprint-callout-label">${r("Most prolific month")}</span>
689 689 <h3 class="os-my-wordpress__footprint-callout-value">${I(t.ym,"month")}</h3>
690 - <p class="os-my-wordpress__footprint-callout-detail">${b(q("%d post published — their personal record.","%d posts published — their personal record.",t.n),t.n)}</p>
690 + <p class="os-my-wordpress__footprint-callout-detail">${b(B("%d post published — their personal record.","%d posts published — their personal record.",t.n),t.n)}</p>
691 691 </section>
692 - `:""}function dn(e){const t=o=>o==="comment"?"dashicons-admin-comments":o==="post-update"?"dashicons-edit":"dashicons-admin-post",s=o=>{const i=o.title||r("(no title)");return o.kind==="comment"?b(r("Commented on “%s”"),i):o.kind==="post-update"?b(r("Updated “%s”"),i):i},n=o=>{const i=[I(o.date,"long")];return o.status&&o.status!=="publish"&&o.status!=="approved"&&i.push(o.status),i.join(" · ")};return c`
692 + `:""}function yn(e){const t=o=>o==="comment"?"dashicons-admin-comments":o==="post-update"?"dashicons-edit":"dashicons-admin-post",s=o=>{const i=o.title||r("(no title)");return o.kind==="comment"?b(r("Commented on “%s”"),i):o.kind==="post-update"?b(r("Updated “%s”"),i):i},n=o=>{const i=[I(o.date,"long")];return o.status&&o.status!=="publish"&&o.status!=="approved"&&i.push(o.status),i.join(" · ")};return c`
693 693 <section class="os-my-wordpress__footprint-section os-my-wordpress__footprint-timeline-section">
694 694 <h3>${r("Recent activity")}</h3>
695 695 ${e.timeline.length===0?c`<p class="os-my-wordpress__article-meta">${r("Nothing to show yet.")}</p>`:c`<ul class="os-my-wordpress__footprint-timeline">
696 696 ${e.timeline.map(o=>c`
@@ -710,9 +710,9 @@
710 710 </li>
711 711 `)}
712 712 </ul>`}
713 713 </section>
714 - `}function cn(e,t,s){return c`
714 + `}function $n(e,t,s){return c`
715 715 <footer class="os-my-wordpress__footprint-section os-my-wordpress__footprint-footer">
716 716 <os-button
717 717 variant="ghost"
718 718 ?disabled=${!t.profile.link}
@@ -719,12 +719,12 @@
719 719 @click=${()=>{t.profile.link&&window.open(t.profile.link,"_blank","noopener,noreferrer")}}
720 720 >${r("View author archive")}</os-button>
721 721 <os-button
722 722 variant="primary"
723 - @click=${()=>ee(s,{source:"my-wordpress-app/footprint",fallback:()=>void e.dispatch("edit",{item:s})})}
723 + @click=${()=>te(s,{source:"my-wordpress-app/footprint",fallback:()=>void e.dispatch("edit",{item:s})})}
724 724 >${r("Show profile")}</os-button>
725 725 </footer>
726 - `}function un(e){const t=Number(e.state.footprint),s=en(e,t);if(s.status==="loading")return c`
726 + `}function wn(e){const t=Number(e.state.footprint),s=dn(e,t);if(s.status==="loading")return c`
727 727 <div class="os-my-wordpress__footprint">
728 728 <div class="os-my-wordpress__preview-loading"><os-spinner></os-spinner></div>
729 729 </div>
730 730 `;if(s.status==="error"||!s.payload)return c`
@@ -732,24 +732,24 @@
732 732 <os-empty-state>${r("Could not load footprint.")}</os-empty-state>
733 733 </div>
734 734 `;const n=s.payload;return c`
735 735 <div class="os-my-wordpress__footprint">
736 - ${nn(n)}
737 - ${on(n)}
738 - ${rn(n)}
739 - ${an(n)}
740 - ${ln(n)}
741 - ${dn(n)}
742 - ${cn(e,n,t)}
736 + ${pn(n)}
737 + ${fn(n)}
738 + ${mn(n)}
739 + ${hn(n)}
740 + ${gn(n)}
741 + ${yn(n)}
742 + ${$n(e,n,t)}
743 743 </div>
744 - `}const W={appearance:{radius:56,bodyColor:789263,bodyAlpha:1,hueStart:296.5,hueSpan:-52.5,hueAngle:225,hueDrift:0,hueSpin:0,hueLoop:!0,saturation:1,lightness:.75,iridescence:0,outlineWidth:4,linerWidth:2,linerColor:16776191,glow:10,glowBlur:!0,eyeColor:16776191,eyeScale:.3},physics:{points:12,shapePreset:"blob",shapeLobes:3,shapeAmount:1,shapeAngle:0,shapeShuffle:60,radialStiffness:460,edgeStiffness:540,bendStiffness:170,pressure:2400,damping:9,airDamping:.5,magnetStrength:2200,magnetRange:260,magnetGrip:.24,magnetDamping:7,floatAmplitude:10,floatSpeed:1.1,idleWobble:.085,idleWobbleSpeed:.55,speedStretch:.3,friction:.86,restitution:.2,dragStiffness:480,throwBoost:1,minStretch:.55,maxStretch:1.7,minAngularGap:.25,limitIterations:3,dragMaxAccel:9e3,subStep:1/240,maxSubSteps:8}};function pn(e,t,s){const n=(e%360+360)%360,o=Math.min(1,Math.max(0,t)),i=Math.min(1,Math.max(0,s)),a=(1-Math.abs(2*i-1))*o,l=n/60,d=a*(1-Math.abs(l%2-1));let u=0,p=0,f=0;l<1?(u=a,p=d):l<2?(u=d,p=a):l<3?(p=a,f=d):l<4?(p=d,f=a):l<5?(u=d,f=a):(u=a,f=d);const m=i-a/2,h=$=>Math.min(255,Math.max(0,Math.round(($+m)*255)));return h(u)<<16|h(p)<<8|h(f)}const fn=Math.PI*2;function mn(e,t,s,n,o=0){const i=Math.max(1,Math.round(e)),a=new Array(i);for(let l=0;l<i;l++){const d=l/i,u=((d-(s.hueAngle+o)/360)%1+1)%1,p=s.hueLoop?.5-.5*Math.cos(u*fn):u;let f=s.hueStart+s.hueSpan*p+t;const m=.5+.5*Math.cos((d-1/3)*Math.PI*2);let h=s.lightness*(.72+.28*m),$=s.saturation;a[l]=pn(f,$,h)}return a}const kt=Math.PI/2,G=Math.PI*2,hn=.05;function V(e){return((e+kt)%G+G)%G}function ze(e,t){return Math.pow(.5+.5*e,t)}function gn(e){const t=Math.max(0,Math.sin(e)),s=2+3.2*t,n=Math.abs(Math.cos(e)),o=Math.abs(Math.sin(e)),i=1/Math.pow(Math.pow(n,s)+Math.pow(o,s),1/s)-1,a=-.17*Math.pow(t,1.4)*Math.cos(6*e);return i+a}function yn(e){return .16*Math.cos(2*e+.9)+.095*Math.cos(3*e-2.1)+.036*Math.cos(5*e+1.3)+.019*Math.cos(7*e-.4)}function $n(e){return .58*(ze(Math.cos(5*e),3)-.3125)}function wn(e){return .34*(ze(Math.cos(6*e),2)-.375)}function _n(e){return .34*(ze(Math.cos(4*e),2)-.375)}function vn(e){return .72*(Math.pow(Math.max(0,Math.cos(e)),8)-.1367)}function bn(e){const t=Math.max(0,Math.cos(e)),s=Math.max(0,-Math.cos(e));return .34*(Math.sqrt(t)*(.5+.5*Math.cos(5*e))-.7*s*s-.0247)}function kn(e){const t=e>Math.PI?G-e:e,s=-.34*Math.pow(Math.max(0,Math.cos(e)),6),n=.3*Math.pow(Math.max(0,Math.cos(t-1)),3),o=.34*Math.pow(Math.max(0,-Math.cos(e)),8);return s+n+o+.02}function Sn(e,t){switch(t.shapePreset){case"circle":return 0;case"ghost":return gn(e);case"potato":return yn(e);case"star":return $n(V(e));case"flower":return wn(V(e));case"diamond":return _n(V(e));case"drop":return vn(V(e));case"cloud":return bn(V(e));case"heart":return kn(V(e));case"custom":{const s=Math.round(t.shapeLobes);return s<2?0:1/(1+s*s)*Math.cos(s*e)}default:return hn*Math.cos(3*(e+kt))}}function St(e,t){if(t.shapeAmount<=0)return 1;const s=e-t.shapeAngle*Math.PI/180;return 1+t.shapeAmount*Sn(s,t)}const ke=72,An=16,At=[[1,.1],[.6,.14],[.28,.2]];function C(e){const t=Number(e.toFixed(2));return(Object.is(t,-0)?0:t).toFixed(2)}function Se(e){return"#"+(e&16777215).toString(16).padStart(6,"0")}function Mn(e,t){const s=[];for(let a=0;a<ke;a++){const l=a/ke*G,d=t*St(l,e.physics);s.push([d*Math.cos(l),d*Math.sin(l)])}const n=s.length,o=a=>s[(a%n+n)%n];let i=`M${C(s[0][0])} ${C(s[0][1])}`;for(let a=0;a<n;a++){const l=o(a-1),d=o(a),u=o(a+1),p=o(a+2),f=d[0]+(u[0]-l[0])/6,m=d[1]+(u[1]-l[1])/6,h=u[0]-(p[0]-d[0])/6,$=u[1]-(p[1]-d[1])/6;i+=`C${C(f)} ${C(m)},${C(h)} ${C($)},${C(u[0])} ${C(u[1])}`}return i+"Z"}function Tn(e){let t=0;for(let s=0;s<ke;s++)t=Math.max(t,St(s/ke*G,e.physics));return t}function Cn(e={},t=96,s=""){const n={appearance:{...W.appearance,...e.appearance},physics:{...W.physics,...e.physics}},{appearance:o}=n,i=100,a=i/W.appearance.radius,l=o.outlineWidth*a,d=o.linerWidth*a,u=o.glow/10*i*.18,p=i*Tn(n)+l/2+u*At[0][0],f=C(p),m=C(p*2),h=Mn(n,i),$=mn(An,0,o),v=String(s).replace(/[^A-Za-z0-9_-]/g,""),w=`r${v}`,g=`s${v}`,y=`c${v}`,_=$.map((U,Z)=>`<stop offset="${C(Z/($.length-1)*100)}%" stop-color="${Se(U)}"/>`).join(""),M=At.map(([U,Z])=>`<use href="#${g}" fill="none" stroke="url(#${w})" stroke-width="${C(l+u*U*2)}" stroke-opacity="${C(Z)}" stroke-linejoin="round"/>`).join(""),S=i*o.eyeScale,A=S*.46,N=i*.28,R=-i*.02-S/2,re=U=>`<rect x="${C(U-A/2)}" y="${C(R)}" width="${C(A)}" height="${C(S)}" rx="${C(A/2)}" fill="${Se(o.eyeColor)}"/>`,Ne=d>0?`<use href="#${g}" fill="none" stroke="${Se(o.linerColor)}" stroke-width="${C(l+d*2)}" stroke-linejoin="round" clip-path="url(#${y})"/>`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="-${f} -${f} ${m} ${m}"><defs><linearGradient id="${w}" x1="0" y1="0" x2="0.85" y2="1">${_}</linearGradient><path id="${g}" d="${h}"/><clipPath id="${y}"><use href="#${g}"/></clipPath></defs>`+M+`<use href="#${g}" fill="${Se(o.bodyColor)}" fill-opacity="${C(o.bodyAlpha)}"/>`+Ne+`<use href="#${g}" fill="none" stroke="url(#${w})" stroke-width="${C(l)}" stroke-linejoin="round"/>`+re(-N)+re(N)+"</svg>"}function En(e={},t=96){const s=Cn(e,t);return`data:image/svg+xml;base64,${typeof btoa=="function"?btoa(s):Buffer.from(s,"utf8").toString("base64")}`}const In=["blob","ghost","potato","star","flower","heart","diamond","drop","cloud"];function Nn(e=Math.random){const t=(l,d)=>l+e()*(d-l),s=l=>e()<l,n=l=>l[Math.floor(e()*l.length)%l.length],o=(l,d)=>Math.round(l/d)*d,i=o(t(55,215),1)*(s(.5)?1:-1),a=o(t(2,7),.5);return{appearance:{hueStart:o(t(0,360),1),hueSpan:i,hueAngle:o(t(0,360),1),hueLoop:!0,hueSpin:s(.25)?o(t(-14,14),1):0,hueDrift:s(.15)?o(t(-8,8),1):0,saturation:o(t(.68,1),.01),lightness:o(t(.52,.78),.01),outlineWidth:a,linerWidth:Math.max(1,o(a/2,.5)),linerColor:W.appearance.linerColor,glow:o(t(4,16),.1),iridescence:s(.34)?o(t(.45,1.25),.05):0,bodyColor:s(.25)?Dn(e):W.appearance.bodyColor,bodyAlpha:s(.2)?o(t(.78,1),.01):1,eyeColor:W.appearance.eyeColor,eyeScale:o(t(.2,.42),.01)},physics:{shapePreset:n(In),shapeAmount:o(t(.7,1.15),.05),shapeAngle:0,idleWobble:o(t(.03,.16),.005),idleWobbleSpeed:o(t(.35,1.1),.05)}}}function Dn(e){const t=()=>Math.floor(e()*42);return t()<<16|t()<<8|t()}function Ln(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let s=t;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296}}const He=12;function Ae(e){const t=Nn(Ln(e));return{appearance:t.appearance,physics:t.physics}}function Pn(e,t=He){return Array.from({length:t},(s,n)=>({seed:e+n,look:Ae(e+n)}))}function se(e,t){return En(e??{},t)}function Mt(e){return e?Object.keys(e.appearance??{}).length>0||Object.keys(e.physics??{}).length>0:!1}function Rn(e){const t=e?.physics?.shapePreset;return typeof t=="string"&&t!==""?t:W.physics.shapePreset}const On=["rose","amber","gold","lime","green","mint","teal","azure","blue","violet","purple","magenta"];function Fn(e){const t=e?.appearance?.hueStart,n=((typeof t=="number"&&Number.isFinite(t)?t:W.appearance.hueStart)%360+360)%360;return On[Math.floor((n+15)%360/30)]}const P=de("desktop-mode/agents-chat",()=>({activeAgent:null,transcripts:{},conversationIds:{},conversationsRev:0}));function Xe(e){P.state.activeAgent=e,P.state.transcripts[e.id]||(P.state.transcripts[e.id]=[]),P.state.conversationIds||(P.state.conversationIds={},P.state.conversationsRev=0),P.notify()}const Wn=["post","page","media","user","comment"],Un=12,Bn=4;function qn(){return Math.floor(Math.random()*16777215)+1}function Tt(e,t){return{brief:"",name:"",description:"",vibes:"",instructions:"",role:e,abilities:[],triggers:[{kind:"chat",config:{}}],copiedFrom:"",faceSeed:t,face:Ae(t),stripSeed:t,drafting:!1}}function Ct(e){return!e||e.length===0||e.some(t=>t.slug==="author")?"author":e[0].slug}function Me(e,t){return Mt(e.face)&&e.avatarUrl!==""?e.avatarUrl:e.faceSeed>0?se(Ae(e.faceSeed),t):e.avatarUrl}function Et(e){return e.map(t=>`${t.id}:${t.triggers.map(s=>s.kind).sort().join("+")}`).join("|")}let jn=0;const It=new WeakMap;function Nt(e){let t=It.get(e);return t||(t=++jn,It.set(e,t)),t}function Kn(){T().openOsSettings?.({tabId:"features"})}function Dt(e,t){Xe({id:t.id,name:t.name,description:t.description,avatarUrl:t.avatarUrl}),!T().openWindow?.(e.runWindowId,{source:"agents"})&&typeof T().openWindow!="function"&&console.warn("[desktop-mode/agents] wp.os.openWindow is missing — desktop shell may not be ready.")}function zn(e){ee(e.id,{source:"agents/profile",fallback:()=>{e.profileUrl&&T().windowManager?.open({id:`user-edit-${e.id}`,url:e.profileUrl,title:e.name,icon:"dashicons-admin-users"})}})}function Hn(e){const t=T();if(!t.windowManager?.open){window.open(e,"_blank","noopener,noreferrer");return}const s=typeof t.deriveWindowId=="function"?t.deriveWindowId(e):"options-connectors";t.windowManager.open({id:s,url:e,title:r("Connectors"),icon:"dashicons-admin-settings"})}async function Xn(e){const t=T().files;if(!t?.rest?.createPlacement)return r("The desktop files API is not available in this context.");let s=[];try{const i=t.store?.getState?.()?.placementsByFolder?.get(0);Array.isArray(i)&&(s=i)}catch{}let n=16,o=16;for(let i=0;i<200&&(n=16+i%5*96,o=16+Math.floor(i/5)*110,!!s.some(l=>Math.abs((l.x??-9999)-n)<48&&Math.abs((l.y??-9999)-o)<55));i++);try{const i=await t.rest.createPlacement({type:"user",ref:String(e.id),x:n,y:o});return t.store?.upsertPlacement?.(i),r("Agent added to the desktop.")}catch(i){return i instanceof Error?i.message:String(i)}}function Lt(e,t){const s=e.some(n=>n.slug===t);return c`
744 + `}const W={appearance:{radius:56,bodyColor:789263,bodyAlpha:1,hueStart:296.5,hueSpan:-52.5,hueAngle:225,hueDrift:0,hueSpin:0,hueLoop:!0,saturation:1,lightness:.75,iridescence:0,outlineWidth:4,linerWidth:2,linerColor:16776191,glow:10,glowBlur:!0,eyeColor:16776191,eyeScale:.3},physics:{points:12,shapePreset:"blob",shapeLobes:3,shapeAmount:1,shapeAngle:0,shapeShuffle:60,radialStiffness:460,edgeStiffness:540,bendStiffness:170,pressure:2400,damping:9,airDamping:.5,magnetStrength:2200,magnetRange:260,magnetGrip:.24,magnetDamping:7,floatAmplitude:10,floatSpeed:1.1,idleWobble:.085,idleWobbleSpeed:.55,speedStretch:.3,friction:.86,restitution:.2,dragStiffness:480,throwBoost:1,minStretch:.55,maxStretch:1.7,minAngularGap:.25,limitIterations:3,dragMaxAccel:9e3,subStep:1/240,maxSubSteps:8}};function vn(e,t,s){const n=(e%360+360)%360,o=Math.min(1,Math.max(0,t)),i=Math.min(1,Math.max(0,s)),a=(1-Math.abs(2*i-1))*o,l=n/60,u=a*(1-Math.abs(l%2-1));let d=0,p=0,f=0;l<1?(d=a,p=u):l<2?(d=u,p=a):l<3?(p=a,f=u):l<4?(p=u,f=a):l<5?(d=u,f=a):(d=a,f=u);const m=i-a/2,h=$=>Math.min(255,Math.max(0,Math.round(($+m)*255)));return h(d)<<16|h(p)<<8|h(f)}const _n=Math.PI*2;function bn(e,t,s,n,o=0){const i=Math.max(1,Math.round(e)),a=new Array(i);for(let l=0;l<i;l++){const u=l/i,d=((u-(s.hueAngle+o)/360)%1+1)%1,p=s.hueLoop?.5-.5*Math.cos(d*_n):d;let f=s.hueStart+s.hueSpan*p+t;const m=.5+.5*Math.cos((u-1/3)*Math.PI*2);let h=s.lightness*(.72+.28*m),$=s.saturation;a[l]=vn(f,$,h)}return a}const Mt=Math.PI/2,G=Math.PI*2,kn=.05;function V(e){return((e+Mt)%G+G)%G}function Ye(e,t){return Math.pow(.5+.5*e,t)}function Sn(e){const t=Math.max(0,Math.sin(e)),s=2+3.2*t,n=Math.abs(Math.cos(e)),o=Math.abs(Math.sin(e)),i=1/Math.pow(Math.pow(n,s)+Math.pow(o,s),1/s)-1,a=-.17*Math.pow(t,1.4)*Math.cos(6*e);return i+a}function An(e){return .16*Math.cos(2*e+.9)+.095*Math.cos(3*e-2.1)+.036*Math.cos(5*e+1.3)+.019*Math.cos(7*e-.4)}function Mn(e){return .58*(Ye(Math.cos(5*e),3)-.3125)}function Tn(e){return .34*(Ye(Math.cos(6*e),2)-.375)}function Cn(e){return .34*(Ye(Math.cos(4*e),2)-.375)}function En(e){return .72*(Math.pow(Math.max(0,Math.cos(e)),8)-.1367)}function In(e){const t=Math.max(0,Math.cos(e)),s=Math.max(0,-Math.cos(e));return .34*(Math.sqrt(t)*(.5+.5*Math.cos(5*e))-.7*s*s-.0247)}function Nn(e){const t=e>Math.PI?G-e:e,s=-.34*Math.pow(Math.max(0,Math.cos(e)),6),n=.3*Math.pow(Math.max(0,Math.cos(t-1)),3),o=.34*Math.pow(Math.max(0,-Math.cos(e)),8);return s+n+o+.02}function Dn(e,t){switch(t.shapePreset){case"circle":return 0;case"ghost":return Sn(e);case"potato":return An(e);case"star":return Mn(V(e));case"flower":return Tn(V(e));case"diamond":return Cn(V(e));case"drop":return En(V(e));case"cloud":return In(V(e));case"heart":return Nn(V(e));case"custom":{const s=Math.round(t.shapeLobes);return s<2?0:1/(1+s*s)*Math.cos(s*e)}default:return kn*Math.cos(3*(e+Mt))}}function Tt(e,t){if(t.shapeAmount<=0)return 1;const s=e-t.shapeAngle*Math.PI/180;return 1+t.shapeAmount*Dn(s,t)}const Se=72,Ln=16,Ct=[[1,.1],[.6,.14],[.28,.2]];function C(e){const t=Number(e.toFixed(2));return(Object.is(t,-0)?0:t).toFixed(2)}function Ae(e){return"#"+(e&16777215).toString(16).padStart(6,"0")}function Pn(e,t){const s=[];for(let a=0;a<Se;a++){const l=a/Se*G,u=t*Tt(l,e.physics);s.push([u*Math.cos(l),u*Math.sin(l)])}const n=s.length,o=a=>s[(a%n+n)%n];let i=`M${C(s[0][0])} ${C(s[0][1])}`;for(let a=0;a<n;a++){const l=o(a-1),u=o(a),d=o(a+1),p=o(a+2),f=u[0]+(d[0]-l[0])/6,m=u[1]+(d[1]-l[1])/6,h=d[0]-(p[0]-u[0])/6,$=d[1]-(p[1]-u[1])/6;i+=`C${C(f)} ${C(m)},${C(h)} ${C($)},${C(d[0])} ${C(d[1])}`}return i+"Z"}function Rn(e){let t=0;for(let s=0;s<Se;s++)t=Math.max(t,Tt(s/Se*G,e.physics));return t}function On(e={},t=96,s=""){const n={appearance:{...W.appearance,...e.appearance},physics:{...W.physics,...e.physics}},{appearance:o}=n,i=100,a=i/W.appearance.radius,l=o.outlineWidth*a,u=o.linerWidth*a,d=o.glow/10*i*.18,p=i*Rn(n)+l/2+d*Ct[0][0],f=C(p),m=C(p*2),h=Pn(n,i),$=bn(Ln,0,o),_=String(s).replace(/[^A-Za-z0-9_-]/g,""),w=`r${_}`,g=`s${_}`,y=`c${_}`,v=$.map((U,Z)=>`<stop offset="${C(Z/($.length-1)*100)}%" stop-color="${Ae(U)}"/>`).join(""),M=Ct.map(([U,Z])=>`<use href="#${g}" fill="none" stroke="url(#${w})" stroke-width="${C(l+d*U*2)}" stroke-opacity="${C(Z)}" stroke-linejoin="round"/>`).join(""),S=i*o.eyeScale,A=S*.46,N=i*.28,R=-i*.02-S/2,J=U=>`<rect x="${C(U-A/2)}" y="${C(R)}" width="${C(A)}" height="${C(S)}" rx="${C(A/2)}" fill="${Ae(o.eyeColor)}"/>`,De=u>0?`<use href="#${g}" fill="none" stroke="${Ae(o.linerColor)}" stroke-width="${C(l+u*2)}" stroke-linejoin="round" clip-path="url(#${y})"/>`:"";return`<svg xmlns="http://www.w3.org/2000/svg" width="${t}" height="${t}" viewBox="-${f} -${f} ${m} ${m}"><defs><linearGradient id="${w}" x1="0" y1="0" x2="0.85" y2="1">${v}</linearGradient><path id="${g}" d="${h}"/><clipPath id="${y}"><use href="#${g}"/></clipPath></defs>`+M+`<use href="#${g}" fill="${Ae(o.bodyColor)}" fill-opacity="${C(o.bodyAlpha)}"/>`+De+`<use href="#${g}" fill="none" stroke="url(#${w})" stroke-width="${C(l)}" stroke-linejoin="round"/>`+J(-N)+J(N)+"</svg>"}function Fn(e={},t=96){const s=On(e,t);return`data:image/svg+xml;base64,${typeof btoa=="function"?btoa(s):Buffer.from(s,"utf8").toString("base64")}`}const Wn=["blob","ghost","potato","star","flower","heart","diamond","drop","cloud"];function Un(e=Math.random){const t=(l,u)=>l+e()*(u-l),s=l=>e()<l,n=l=>l[Math.floor(e()*l.length)%l.length],o=(l,u)=>Math.round(l/u)*u,i=o(t(55,215),1)*(s(.5)?1:-1),a=o(t(2,7),.5);return{appearance:{hueStart:o(t(0,360),1),hueSpan:i,hueAngle:o(t(0,360),1),hueLoop:!0,hueSpin:s(.25)?o(t(-14,14),1):0,hueDrift:s(.15)?o(t(-8,8),1):0,saturation:o(t(.68,1),.01),lightness:o(t(.52,.78),.01),outlineWidth:a,linerWidth:Math.max(1,o(a/2,.5)),linerColor:W.appearance.linerColor,glow:o(t(4,16),.1),iridescence:s(.34)?o(t(.45,1.25),.05):0,bodyColor:s(.25)?qn(e):W.appearance.bodyColor,bodyAlpha:s(.2)?o(t(.78,1),.01):1,eyeColor:W.appearance.eyeColor,eyeScale:o(t(.2,.42),.01)},physics:{shapePreset:n(Wn),shapeAmount:o(t(.7,1.15),.05),shapeAngle:0,idleWobble:o(t(.03,.16),.005),idleWobbleSpeed:o(t(.35,1.1),.05)}}}function qn(e){const t=()=>Math.floor(e()*42);return t()<<16|t()<<8|t()}function Bn(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let s=t;return s=Math.imul(s^s>>>15,s|1),s^=s+Math.imul(s^s>>>7,s|61),((s^s>>>14)>>>0)/4294967296}}const Ge=12;function Me(e){const t=Un(Bn(e));return{appearance:t.appearance,physics:t.physics}}function jn(e,t=Ge){return Array.from({length:t},(s,n)=>({seed:e+n,look:Me(e+n)}))}function oe(e,t){return Fn(e??{},t)}function Et(e){return e?Object.keys(e.appearance??{}).length>0||Object.keys(e.physics??{}).length>0:!1}function Kn(e){const t=e?.physics?.shapePreset;return typeof t=="string"&&t!==""?t:W.physics.shapePreset}const zn=["rose","amber","gold","lime","green","mint","teal","azure","blue","violet","purple","magenta"];function Hn(e){const t=e?.appearance?.hueStart,n=((typeof t=="number"&&Number.isFinite(t)?t:W.appearance.hueStart)%360+360)%360;return zn[Math.floor((n+15)%360/30)]}const P=ce("desktop-mode/agents-chat",()=>({activeAgent:null,transcripts:{},conversationIds:{},conversationsRev:0}));function Ve(e){P.state.activeAgent=e,P.state.transcripts[e.id]||(P.state.transcripts[e.id]=[]),P.state.conversationIds||(P.state.conversationIds={},P.state.conversationsRev=0),P.notify()}const Xn=["post","page","media","user","comment"],Yn=12,Gn=4;function Vn(){return Math.floor(Math.random()*16777215)+1}function It(e,t){return{brief:"",name:"",description:"",vibes:"",instructions:"",role:e,abilities:[],triggers:[{kind:"chat",config:{}}],copiedFrom:"",faceSeed:t,face:Me(t),stripSeed:t,drafting:!1}}function Nt(e){return!e||e.length===0||e.some(t=>t.slug==="author")?"author":e[0].slug}function Te(e,t){return Et(e.face)&&e.avatarUrl!==""?e.avatarUrl:e.faceSeed>0?oe(Me(e.faceSeed),t):e.avatarUrl}function Dt(e){return e.map(t=>`${t.id}:${t.triggers.map(s=>s.kind).sort().join("+")}`).join("|")}let Qn=0;const Lt=new WeakMap;function Pt(e){let t=Lt.get(e);return t||(t=++Qn,Lt.set(e,t)),t}function Jn(){T().openOsSettings?.({tabId:"features"})}function Rt(e,t){Ve({id:t.id,name:t.name,description:t.description,avatarUrl:t.avatarUrl}),!T().openWindow?.(e.runWindowId,{source:"agents"})&&typeof T().openWindow!="function"&&console.warn("[desktop-mode/agents] wp.os.openWindow is missing — desktop shell may not be ready.")}function Zn(e){te(e.id,{source:"agents/profile",fallback:()=>{e.profileUrl&&T().windowManager?.open({id:`user-edit-${e.id}`,url:e.profileUrl,title:e.name,icon:"dashicons-admin-users"})}})}function xn(e){const t=T();if(!t.windowManager?.open){window.open(e,"_blank","noopener,noreferrer");return}const s=typeof t.deriveWindowId=="function"?t.deriveWindowId(e):"options-connectors";t.windowManager.open({id:s,url:e,title:r("Connectors"),icon:"dashicons-admin-settings"})}async function eo(e){const t=T().files;if(!t?.rest?.createPlacement)return r("The desktop files API is not available in this context.");let s=[];try{const i=t.store?.getState?.()?.placementsByFolder?.get(0);Array.isArray(i)&&(s=i)}catch{}let n=16,o=16;for(let i=0;i<200&&(n=16+i%5*96,o=16+Math.floor(i/5)*110,!!s.some(l=>Math.abs((l.x??-9999)-n)<48&&Math.abs((l.y??-9999)-o)<55));i++);try{const i=await t.rest.createPlacement({type:"user",ref:String(e.id),x:n,y:o});return t.store?.upsertPlacement?.(i),r("Agent added to the desktop.")}catch(i){return i instanceof Error?i.message:String(i)}}function Ot(e,t){const s=e.some(n=>n.slug===t);return c`
745 745 ${e.map(n=>c`<os-option value=${n.slug}>${n.label}</os-option>`)}
746 746 ${t&&!s?c`<os-option value=${t}>${t}</os-option>`:""}
747 - `}function ne(e,t,s){const n=k(e);return n.agentBusy=!0,e.repaint(),e.dispatch(t,s).finally(()=>{n.agentBusy=!1,e.repaint()})}function Yn(e){if(!e.enabled||e.aiReady)return"";const t=r("No AI provider is configured — agents cannot run until a connector is set up."),s=r("This WordPress does not ship the AI Client (WordPress 7.0+). Agents can be defined but not run."),n=c`
747 + `}function ie(e,t,s){const n=k(e);return n.agentBusy=!0,e.repaint(),e.dispatch(t,s).finally(()=>{n.agentBusy=!1,e.repaint()})}function to(e){if(!e.enabled||e.aiReady)return"";const t=r("No AI provider is configured — agents cannot run until a connector is set up."),s=r("This WordPress does not ship the AI Client (WordPress 7.0+). Agents can be defined but not run."),n=c`
748 748 <a
749 749 href=${e.connectorsUrl}
750 750 rel="noreferrer"
751 - @click=${o=>{o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||(o.preventDefault(),Hn(e.connectorsUrl))}}
751 + @click=${o=>{o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey||(o.preventDefault(),xn(e.connectorsUrl))}}
752 752 >
753 753 ${r("Open Connectors settings")}
754 754 </a>
755 755 `;return c`
@@ -755,9 +755,9 @@
755 755 `;return c`
756 756 <os-notice tone="warning" class="dm-agents__ai-notice">
757 757 ${e.aiAvailable?c`${t} ${n}`:s}
758 758 </os-notice>
759 - `}function Pt(e,t,s,n,o){return c`
759 + `}function Ft(e,t,s,n,o){return c`
760 760 <div class="dm-agents__cast-inner">
761 761 ${e}
762 762 <span class="dm-agents__cast-name">${t}</span>
763 763 ${s?c`<span class="dm-agents__cast-vibes">${s}</span>`:""}
@@ -763,9 +763,9 @@
763 763 ${s?c`<span class="dm-agents__cast-vibes">${s}</span>`:""}
764 764 <span class="dm-agents__cast-good">${n}</span>
765 765 <os-badge>${o}</os-badge>
766 766 </div>
767 - `}function Gn(e){const t=e.preview??[];return t.length===0?null:c`
767 + `}function so(e){const t=e.preview??[];return t.length===0?null:c`
768 768 <div class="dm-agents__cast-head">
769 769 <h3>${r("The crew you would get")}</h3>
770 770 <span class="dm-agents__cast-count">${t.length}</span>
771 771 </div>
@@ -771,11 +771,11 @@
771 771 </div>
772 772 <div class="dm-agents__cast dm-agents__cast--preview" role="list">
773 773 ${t.map(s=>c`
774 774 <os-card class="dm-agents__cast-card" role="listitem">
775 - ${Pt(c`<img
775 + ${Ft(c`<img
776 776 class="dm-agents__cast-face"
777 - src=${se(s.face,88)}
777 + src=${oe(s.face,88)}
778 778 alt=""
779 779 width="88"
780 780 height="88"
781 781 />`,s.name,s.vibes,s.description,s.roleLabel)}
@@ -781,18 +781,18 @@
781 781 />`,s.name,s.vibes,s.description,s.roleLabel)}
782 782 </os-card>
783 783 `)}
784 784 </div>
785 - `}function Vn(e,t){if(!t.enabled){const o=t.canEnable?r("Turn the Agents framework on in OpenStation Preferences → Features to hire this crew, or cast your own."):r("Ask an administrator to turn the Agents framework on in OpenStation Preferences → Features."),i=t.canEnable?c`
785 + `}function no(e,t){if(!t.enabled){const o=t.canEnable?r("Turn the Agents framework on in OpenStation Preferences → Features to hire this crew, or cast your own."):r("Ask an administrator to turn the Agents framework on in OpenStation Preferences → Features."),i=t.canEnable?c`
786 786 <os-button
787 787 slot="cta"
788 788 class="dm-agents__enable"
789 789 variant="primary"
790 - @click=${()=>Kn()}
790 + @click=${()=>Jn()}
791 791 >
792 792 ${r("Turn on Agents")}
793 793 </os-button>
794 - `:"",a=Gn(t);return a===null?c`
794 + `:"",a=so(t);return a===null?c`
795 795 <os-empty-state
796 796 icon="superhero"
797 797 heading=${r("Agents are turned off")}
798 798 description=${o}
@@ -840,11 +840,11 @@
840 840 data-agent-id=${String(o.id)}
841 841 ?selected=${o.id===e.state.item}
842 842 @os-card-click=${()=>void e.dispatch("open",{item:o.id})}
843 843 >
844 - ${Pt(c`<img
844 + ${Ft(c`<img
845 845 class="dm-agents__cast-face"
846 - src=${Me(o,88)}
846 + src=${Te(o,88)}
847 847 alt=""
848 848 width="88"
849 849 height="88"
850 850 />`,o.name,o.vibes,o.description||r("No description yet."),n(o.role))}
@@ -867,9 +867,9 @@
867 867 </div>
868 868 </os-card>
869 869 `:""}
870 870 </div>
871 - `}const Qn="my-wordpress",Ye=Object.freeze({userId:null,userName:"",requestedAt:0});function Rt(){return window.wp?.os}let Te=null;function Ce(){if(Te)return Te;const e=Rt()?.createSharedStore;return typeof e!="function"?null:(Te=e("desktop-mode/my-wordpress/footprint-target",()=>({...Ye})),Te)}function Zn(e,t=""){const s=Ce();if(s){s.state.userId=e,s.state.userName=t,s.state.requestedAt=Date.now(),s.notify();return}window._wpdFootprintTarget={userId:e,userName:t,requestedAt:Date.now()}}function Jn(){const e=Ce();return e?{...e.state}:window._wpdFootprintTarget??{...Ye}}function xn(){const e=Ce();e&&(e.state.userId=null,e.state.userName="",e.state.requestedAt=0,e.notify());const t=window;t._wpdFootprintTarget&&(t._wpdFootprintTarget={...Ye})}function eo(e){const t=Ce();return t?t.subscribe(s=>e({...s})):()=>{}}function to(e){const t=Number(e.userId);!Number.isFinite(t)||t<=0||(Zn(t,e.userName??""),Rt()?.openWindow?.(Qn,{source:"my-wordpress/open-user-footprint"}))}function Ot(e,t,s,n,o={}){const i=k(e),a=t.abilities,l=i.abilityQuery.trim().toLowerCase(),d=m=>l===""||m.label.toLowerCase().includes(l)||m.description.toLowerCase().includes(l)||m.slug.toLowerCase().includes(l),u=new Map;for(const m of a.filter(d)){const h=m.category||r("Other");u.set(h,[...u.get(h)??[],m])}const p=a.length>Un,f=(m,h)=>l!==""?!0:i.abilityOpen.get(m)??(!p||h.some($=>s.includes($.slug)));return c`
871 + `}const oo="my-wordpress",Qe=Object.freeze({userId:null,userName:"",requestedAt:0});function Wt(){return window.wp?.os}let Ce=null;function Ee(){if(Ce)return Ce;const e=Wt()?.createSharedStore;return typeof e!="function"?null:(Ce=e("desktop-mode/my-wordpress/footprint-target",()=>({...Qe})),Ce)}function io(e,t=""){const s=Ee();if(s){s.state.userId=e,s.state.userName=t,s.state.requestedAt=Date.now(),s.notify();return}window._wpdFootprintTarget={userId:e,userName:t,requestedAt:Date.now()}}function ro(){const e=Ee();return e?{...e.state}:window._wpdFootprintTarget??{...Qe}}function ao(){const e=Ee();e&&(e.state.userId=null,e.state.userName="",e.state.requestedAt=0,e.notify());const t=window;t._wpdFootprintTarget&&(t._wpdFootprintTarget={...Qe})}function lo(e){const t=Ee();return t?t.subscribe(s=>e({...s})):()=>{}}function co(e){const t=Number(e.userId);if(!Number.isFinite(t)||t<=0)return;const s=e.userName??"";io(t,s),Wt()?.openWindow?.(oo,{source:"my-wordpress/open-user-footprint",params:{footprint:t,fpName:s}})}function Ut(e,t,s,n,o={}){const i=k(e),a=t.abilities,l=i.abilityQuery.trim().toLowerCase(),u=m=>l===""||m.label.toLowerCase().includes(l)||m.description.toLowerCase().includes(l)||m.slug.toLowerCase().includes(l),d=new Map;for(const m of a.filter(u)){const h=m.category||r("Other");d.set(h,[...d.get(h)??[],m])}const p=a.length>Yn,f=(m,h)=>l!==""?!0:i.abilityOpen.get(m)??(!p||h.some($=>s.includes($.slug)));return c`
872 872 ${p||l!==""?c`
873 873 <os-text-field
874 874 class="dm-agents__ability-search"
875 875 type="search"
@@ -878,12 +878,12 @@
878 878 placeholder=${r("custom fields, orders, media…")}
879 879 @os-input-change=${m=>{i.abilityQuery=m.detail?.value??"",e.repaint()}}
880 880 ></os-text-field>
881 881 `:""}
882 - ${u.size===0?c`<p class="dm-agents__hint">
882 + ${d.size===0?c`<p class="dm-agents__hint">
883 883 ${b(r('No ability matches "%s".'),i.abilityQuery.trim())}
884 884 </p>`:""}
885 - ${[...u.entries()].map(([m,h])=>{const $=h.filter(w=>s.includes(w.slug)).length,v=$>0?b(r("%1$d of %2$d"),$,h.length):String(h.length);return c`
885 + ${[...d.entries()].map(([m,h])=>{const $=h.filter(w=>s.includes(w.slug)).length,_=$>0?b(r("%1$d of %2$d"),$,h.length):String(h.length);return c`
886 886 <details
887 887 class="dm-agents__ability-group"
888 888 ?open=${f(m,h)}
889 889 @toggle=${w=>{i.abilityOpen.set(m,w.target.open)}}
@@ -889,9 +889,9 @@
889 889 @toggle=${w=>{i.abilityOpen.set(m,w.target.open)}}
890 890 >
891 891 <summary class="dm-agents__category">
892 892 <span class="dm-agents__category-name">${m}</span>
893 - <span class="dm-agents__category-count">${v}</span>
893 + <span class="dm-agents__category-count">${_}</span>
894 894 </summary>
895 895 ${h.map(w=>c`
896 896 <div class="dm-agents__ability">
897 897 <os-checkbox-label
@@ -907,9 +907,9 @@
907 907 </div>
908 908 `)}
909 909 </details>
910 910 `})}
911 - `}function Ft(e,t){return e.findIndex(s=>s.kind===t)}function so(e){const t=e.config_schema;return!!t?.properties&&"entityKinds"in t.properties}function Ge(e,t){e(Ft(t,"chat")===-1?[{kind:"chat",config:{}},...t]:t)}function no(e,t,s,n){const o=t[s],i=a=>{Ge(n,t.map((l,d)=>d===s?{kind:l.kind,config:{...l.config,...a}}:l))};if(o.kind==="hook"){const a=e.hooks.map(l=>l.hook);return c`
911 + `}function qt(e,t){return e.findIndex(s=>s.kind===t)}function uo(e){const t=e.config_schema;return!!t?.properties&&"entityKinds"in t.properties}function Je(e,t){e(qt(t,"chat")===-1?[{kind:"chat",config:{}},...t]:t)}function po(e,t,s,n){const o=t[s],i=a=>{Je(n,t.map((l,u)=>u===s?{kind:l.kind,config:{...l.config,...a}}:l))};if(o.kind==="hook"){const a=e.hooks.map(l=>l.hook);return c`
912 912 <div class="dm-agents__trigger-config">
913 913 <os-text-field
914 914 label=${r("Hook name")}
915 915 value=${String(o.config.hook??"")}
@@ -928,11 +928,11 @@
928 928 ?readonly=${!e.canManage}
929 929 @os-input-commit=${a=>i({capability:a.detail.value})}
930 930 ></os-text-field>
931 931 </div>
932 - `:""}function oo(e,t,s,n,o){const i=Ft(n,s.slug),a=i===-1?null:n[i],l=!t.canManage||k(e).agentBusy,d=()=>n.filter(p=>p.kind!==s.slug);let u="";if(s.slug==="chat")u="";else if(so(s)){const p=a?.config.entityKinds,f=Array.isArray(p)?p.filter(h=>typeof h=="string"):[],m=(h,$)=>{const v=$?[...new Set([...f,h])]:f.filter(g=>g!==h),w=d();v.length>0&&w.push({kind:s.slug,config:{...a?.config??{},entityKinds:v}}),Ge(o,w)};u=c`
932 + `:""}function fo(e,t,s,n,o){const i=qt(n,s.slug),a=i===-1?null:n[i],l=!t.canManage||k(e).agentBusy,u=()=>n.filter(p=>p.kind!==s.slug);let d="";if(s.slug==="chat")d="";else if(uo(s)){const p=a?.config.entityKinds,f=Array.isArray(p)?p.filter(h=>typeof h=="string"):[],m=(h,$)=>{const _=$?[...new Set([...f,h])]:f.filter(g=>g!==h),w=u();_.length>0&&w.push({kind:s.slug,config:{...a?.config??{},entityKinds:_}}),Je(o,w)};d=c`
933 933 <div class="dm-agents__trigger-config">
934 - ${Wn.map(h=>c`
934 + ${Xn.map(h=>c`
935 935 <os-checkbox-label
936 936 label=${h}
937 937 ?checked=${f.includes(h)}
938 938 ?disabled=${l}
@@ -939,18 +939,18 @@
939 939 @os-checkbox-change=${$=>m(h,$.detail?.checked===!0)}
940 940 ></os-checkbox-label>
941 941 `)}
942 942 </div>
943 - `}else u=c`
943 + `}else d=c`
944 944 <div class="dm-agents__trigger-config">
945 945 <os-checkbox-label
946 946 label=${r("On")}
947 947 ?checked=${a!==null}
948 948 ?disabled=${l}
949 - @os-checkbox-change=${p=>Ge(o,p.detail?.checked===!0?[...d(),{kind:s.slug,config:{}}]:d())}
949 + @os-checkbox-change=${p=>Je(o,p.detail?.checked===!0?[...u(),{kind:s.slug,config:{}}]:u())}
950 950 ></os-checkbox-label>
951 951 </div>
952 - ${a?no(t,n,i,o):""}
952 + ${a?po(t,n,i,o):""}
953 953 `;return c`
954 954 <div class="dm-agents__trigger">
955 955 <div class="dm-agents__trigger-head">
956 956 <strong>${s.label}</strong>
@@ -956,18 +956,18 @@
956 956 <strong>${s.label}</strong>
957 957 ${s.slug==="chat"?c`<os-badge tone="neutral">${r("Always on")}</os-badge>`:""}
958 958 </div>
959 959 ${s.description?c`<p class="dm-agents__trigger-desc">${s.description}</p>`:""}
960 - ${u}
960 + ${d}
961 961 </div>
962 - `}function Wt(e,t,s,n){const o=t.triggerKinds.filter(i=>i.wired!==!1);return c`
962 + `}function Bt(e,t,s,n){const o=t.triggerKinds.filter(i=>i.wired!==!1);return c`
963 963 <div class="dm-agents__pane">
964 964 <p class="dm-agents__hint">
965 965 ${r("Chat is always on. Tick where else this site should reach the agent; a door with nothing ticked stays closed.")}
966 966 </p>
967 - ${o.map(i=>oo(e,t,i,s,n))}
967 + ${o.map(i=>fo(e,t,i,s,n))}
968 968 </div>
969 - `}function io(e,t){return(!e.agentDraft||e.agentDraftFor!==t.id)&&(e.agentDraft={name:t.name,description:t.description,instructions:t.instructions,role:t.role},e.agentDraftFor=t.id),e.agentDraft}function ro(e,t,s){const n=k(e),o=!t.canManage,i=io(n,s),a=i.name!==s.name||i.description!==s.description||i.instructions!==s.instructions||i.role!==s.role;return c`
969 + `}function mo(e,t){return(!e.agentDraft||e.agentDraftFor!==t.id)&&(e.agentDraft={name:t.name,description:t.description,instructions:t.instructions,role:t.role},e.agentDraftFor=t.id),e.agentDraft}function ho(e,t,s){const n=k(e),o=!t.canManage,i=mo(n,s),a=i.name!==s.name||i.description!==s.description||i.instructions!==s.instructions||i.role!==s.role;return c`
970 970 <div class="dm-agents__pane">
971 971 <os-text-field
972 972 label=${r("Name")}
973 973 value=${i.name}
@@ -993,9 +993,9 @@
993 993 label=${r("Role")}
994 994 value=${i.role}
995 995 @os-pick=${l=>{i.role=l.detail?.value??i.role,e.repaint()}}
996 996 >
997 - ${Lt(t.roles,i.role)}
997 + ${Ot(t.roles,i.role)}
998 998 </os-select>
999 999 `:c`
1000 1000 <os-select label=${r("Role")} value=${i.role} disabled>
1001 1001 <os-option value=${i.role}>${i.role}</os-option>
@@ -1005,22 +1005,22 @@
1005 1005 ${r("The agent acts with this role's capabilities — pick the least privilege that still lets it do its job.")}
1006 1006 </p>
1007 1007 <os-button
1008 1008 ?disabled=${n.agentBusy||!a}
1009 - @click=${()=>void ne(e,"agent-update",{id:s.id,name:i.name,description:i.description,instructions:i.instructions,role:i.role})}
1009 + @click=${()=>void ie(e,"agent-update",{id:s.id,name:i.name,description:i.description,instructions:i.instructions,role:i.role})}
1010 1010 >
1011 1011 ${r("Save")}
1012 1012 </os-button>
1013 1013 `}
1014 1014 </div>
1015 - `}function ao(e,t,s){return c`
1015 + `}function go(e,t,s){return c`
1016 1016 <div class="dm-agents__pane">
1017 1017 <p class="dm-agents__hint">
1018 1018 ${r("The agent may only call abilities ticked here — and every call is still gated by the ability's own permission check against the agent's role.")}
1019 1019 </p>
1020 - ${Ot(e,t,s.abilities,(n,o)=>{const i=o?Array.from(new Set([...s.abilities,n])):s.abilities.filter(a=>a!==n);ne(e,"agent-update",{id:s.id,abilities:i})},{disabled:!t.canManage||k(e).agentBusy})}
1020 + ${Ut(e,t,s.abilities,(n,o)=>{const i=o?Array.from(new Set([...s.abilities,n])):s.abilities.filter(a=>a!==n);ie(e,"agent-update",{id:s.id,abilities:i})},{disabled:!t.canManage||k(e).agentBusy})}
1021 1021 </div>
1022 - `}function lo(e,t,s){const n=k(e),o=e.state,i=e.data.sections.some(l=>l.id==="users"),a=c`
1022 + `}function yo(e,t,s){const n=k(e),o=e.state,i=e.data.sections.some(l=>l.id==="users"),a=c`
1023 1023 <os-tabs
1024 1024 class="dm-agents__tabs"
1025 1025 value=${o.pane}
1026 1026 label=${r("Agent detail")}
@@ -1025,10 +1025,10 @@
1025 1025 value=${o.pane}
1026 1026 label=${r("Agent detail")}
1027 1027 @os-tab-change=${l=>{l.detail.value&&e.local("agent-pane",{pane:l.detail.value})}}
1028 1028 >
1029 - ${[["define",r("Define")],["tools",r("Tools")],["triggers",r("Triggers")]].map(([l,d])=>c`
1030 - <os-tab value=${l}>${d}</os-tab>
1029 + ${[["define",r("Define")],["tools",r("Tools")],["triggers",r("Triggers")]].map(([l,u])=>c`
1030 + <os-tab value=${l}>${u}</os-tab>
1031 1031 `)}
1032 1032 </os-tabs>
1033 1033 `;return c`
1034 1034 <os-button class="dm-agents__back" variant="link" @click=${()=>void e.dispatch("open",{item:0})}>
@@ -1034,9 +1034,9 @@
1034 1034 <os-button class="dm-agents__back" variant="link" @click=${()=>void e.dispatch("open",{item:0})}>
1035 1035 ${r("‹ Your cast")}
1036 1036 </os-button>
1037 1037 <div class="dm-agents__detail-head">
1038 - <img class="dm-agents__detail-avatar" src=${Me(s,96)} alt="" />
1038 + <img class="dm-agents__detail-avatar" src=${Te(s,96)} alt="" />
1039 1039 <div class="dm-agents__detail-title">
1040 1040 <h3>${s.name}</h3>
1041 1041 <span class="dm-agents__detail-slug">@agent-${s.slug}</span>
1042 1042 </div>
@@ -1041,14 +1041,14 @@
1041 1041 <span class="dm-agents__detail-slug">@agent-${s.slug}</span>
1042 1042 </div>
1043 1043 </div>
1044 1044 <div class="dm-agents__detail-actions">
1045 - <os-button @click=${()=>zn(s)}>
1045 + <os-button @click=${()=>Zn(s)}>
1046 1046 ${r("Open profile")}
1047 1047 </os-button>
1048 1048 ${i?c`
1049 1049 <os-button
1050 - @click=${()=>to({userId:s.id,userName:s.name})}
1050 + @click=${()=>co({userId:s.id,userName:s.name})}
1051 1051 >
1052 1052 ${r("View contributions")}
1053 1053 </os-button>
1054 1054 `:""}
@@ -1054,9 +1054,9 @@
1054 1054 `:""}
1055 1055 ${t.canManage?c`
1056 1056 <os-button
1057 1057 ?disabled=${n.agentBusy}
1058 - @click=${()=>void Xn(s).then(l=>e.local("agent-notice",{notice:l}))}
1058 + @click=${()=>void eo(s).then(l=>e.local("agent-notice",{notice:l}))}
1059 1059 >
1060 1060 ${r("Send to Desktop")}
1061 1061 </os-button>
1062 1062 `:""}
@@ -1063,9 +1063,9 @@
1063 1063 ${t.canInvoke?c`
1064 1064 <os-button
1065 1065 variant="primary"
1066 1066 ?disabled=${!t.aiReady}
1067 - @click=${()=>Dt(t,s)}
1067 + @click=${()=>Rt(t,s)}
1068 1068 >
1069 1069 ${r("Chat")}
1070 1070 </os-button>
1071 1071 `:""}
@@ -1082,20 +1082,20 @@
1082 1082 </os-button>
1083 1083 `:""}
1084 1084 </div>
1085 1085 ${a}
1086 - ${o.pane==="define"?ro(e,t,s):""}
1087 - ${o.pane==="tools"?ao(e,t,s):""}
1088 - ${o.pane==="triggers"?Wt(e,t,s.triggers,l=>{ne(e,"agent-update",{id:s.id,triggers:l})}):""}
1089 - `}const co=()=>[r("Describe"),r("Meet"),r("Powers"),r("Summon"),r("Launch")];function Ve(e){return e.name.trim()!==""}function uo(e,t){const s=e.state.cast,n=e.state.wstep,o=c`
1086 + ${o.pane==="define"?ho(e,t,s):""}
1087 + ${o.pane==="tools"?go(e,t,s):""}
1088 + ${o.pane==="triggers"?Bt(e,t,s.triggers,l=>{ie(e,"agent-update",{id:s.id,triggers:l})}):""}
1089 + `}const $o=()=>[r("Describe"),r("Meet"),r("Powers"),r("Summon"),r("Launch")];function Ze(e){return e.name.trim()!==""}function wo(e,t){const s=e.state.cast,n=e.state.wstep,o=c`
1090 1090 <os-steps horizontal class="dm-agents__trail">
1091 - ${co().map((i,a)=>c`
1091 + ${$o().map((i,a)=>c`
1092 1092 <os-step
1093 1093 title=${i}
1094 1094 ?done=${a<n}
1095 1095 ?current=${a===n}
1096 - ?interactive=${a<n}
1097 - @os-step-click=${()=>{a<n&&e.local("agent-step",{step:a})}}
1096 + ?interactive=${a!==n}
1097 + @os-step-click=${()=>{a!==n&&e.local("agent-step",{step:a})}}
1098 1098 ></os-step>
1099 1099 `)}
1100 1100 </os-steps>
1101 1101 `;return c`
@@ -1103,15 +1103,15 @@
1103 1103 <div class="dm-agents__wiz-head">
1104 1104 <h3>${r("New agent")}</h3>
1105 1105 </div>
1106 1106 ${o}
1107 - ${n===0?po(e,t,s):""}
1108 - ${n===1?fo(e,s):""}
1109 - ${n===2?mo(e,t,s):""}
1110 - ${n===3?go(e,t,s):""}
1111 - ${n===4?yo(e,t,s):""}
1107 + ${n===0?vo(e,t,s):""}
1108 + ${n===1?_o(e,s):""}
1109 + ${n===2?bo(e,t,s):""}
1110 + ${n===3?So(e,t,s):""}
1111 + ${n===4?Ao(e,t,s):""}
1112 1112 </div>
1113 - `}function oe(e,t){return c`
1113 + `}function re(e,t){return c`
1114 1114 <os-button
1115 1115 variant="ghost"
1116 1116 ?disabled=${k(e).agentBusy||t.drafting}
1117 1117 @click=${()=>e.local("agent-cancel")}
@@ -1117,9 +1117,9 @@
1117 1117 @click=${()=>e.local("agent-cancel")}
1118 1118 >
1119 1119 ${r("Cancel")}
1120 1120 </os-button>
1121 - `}function po(e,t,s){const n=()=>{s.instructions===""&&s.brief.trim()!==""&&(s.instructions=s.brief.trim())},o=()=>{if(s.brief.trim()===""){e.local("agent-brief-error",{msg:r("Describe the agent first. A sentence is enough.")});return}s.drafting=!0,ne(e,"agent-draft")};return c`
1121 + `}function vo(e,t,s){const n=()=>{if(s.brief.trim()===""){e.local("agent-brief-error",{msg:r("Describe the agent first. A sentence is enough.")});return}s.drafting=!0,ie(e,"agent-draft")};return c`
1122 1122 ${t.list.length>0?c`
1123 1123 <h4 class="dm-agents__wiz-heading">${r("Start from someone")}</h4>
1124 1124 <p class="dm-agents__hint">
1125 1125 ${r("Copies their instructions and abilities, and rolls a new face. Nothing you pick is changed.")}
@@ -1124,24 +1124,24 @@
1124 1124 <p class="dm-agents__hint">
1125 1125 ${r("Copies their instructions and abilities, and rolls a new face. Nothing you pick is changed.")}
1126 1126 </p>
1127 1127 <div class="dm-agents__starters">
1128 - ${t.list.map(i=>c`
1128 + ${t.list.map(o=>c`
1129 1129 <os-card
1130 1130 class="dm-agents__starter"
1131 1131 interactive
1132 - @os-card-click=${()=>e.local("agent-start",{from:i})}
1132 + @os-card-click=${()=>e.local("agent-start",{from:o})}
1133 1133 >
1134 1134 <img
1135 1135 class="dm-agents__starter-face"
1136 - src=${Me(i,76)}
1136 + src=${Te(o,76)}
1137 1137 alt=""
1138 1138 width="76"
1139 1139 height="76"
1140 1140 />
1141 - <span class="dm-agents__starter-name">${i.name}</span>
1141 + <span class="dm-agents__starter-name">${o.name}</span>
1142 1142 <span class="dm-agents__starter-vibes">
1143 - ${i.vibes||i.description}
1143 + ${o.vibes||o.description}
1144 1144 </span>
1145 1145 </os-card>
1146 1146 `)}
1147 1147 </div>
@@ -1159,9 +1159,9 @@
1159 1159 value=${s.brief}
1160 1160 rows="5"
1161 1161 placeholder=${r("Go through my drafts once a week and tell me which ones are closest to finished.")}
1162 1162 ?invalid=${e.state.briefError!==""}
1163 - @os-input-change=${i=>{s.brief=i.detail?.value??"",e.state.briefError!==""&&e.local("agent-brief-error",{msg:""})}}
1163 + @os-input-change=${o=>{s.brief=o.detail?.value??"",e.state.briefError!==""&&e.local("agent-brief-error",{msg:""})}}
1164 1164 ></os-textarea>
1165 1165 </os-field-row>
1166 1166 <div class="dm-agents__actions">
1167 1167 ${t.aiReady?c`
@@ -1167,9 +1167,9 @@
1167 1167 ${t.aiReady?c`
1168 1168 <os-button
1169 1169 variant="holo"
1170 1170 ?busy=${s.drafting}
1171 - @click=${o}
1171 + @click=${n}
1172 1172 >
1173 1173 ${r("Draft it for me")}
1174 1174 </os-button>
1175 1175 `:""}
@@ -1175,21 +1175,21 @@
1175 1175 `:""}
1176 1176 <os-button
1177 1177 variant=${t.aiReady?"ghost":"primary"}
1178 1178 ?disabled=${s.drafting}
1179 - @click=${()=>{n(),e.local("agent-step",{step:1})}}
1179 + @click=${()=>e.local("agent-step",{step:1})}
1180 1180 >
1181 1181 ${t.aiReady?r("I will fill it in myself"):r("Continue")}
1182 1182 </os-button>
1183 1183 <span class="os-app__spacer"></span>
1184 - ${oe(e,s)}
1184 + ${re(e,s)}
1185 1185 </div>
1186 - `}function fo(e,t){const s=k(e),n=Pn(t.stripSeed,He);return c`
1186 + `}function _o(e,t){const s=k(e),n=jn(t.stripSeed,Ge);return c`
1187 1187 <div class="dm-agents__meet">
1188 1188 <div class="dm-agents__portrait">
1189 1189 <img
1190 1190 class="dm-agents__portrait-face"
1191 - src=${se(t.face,176)}
1191 + src=${oe(t.face,176)}
1192 1192 alt=""
1193 1193 width="176"
1194 1194 height="176"
1195 1195 />
@@ -1201,21 +1201,21 @@
1201 1201 role="radio"
1202 1202 aria-checked=${o.seed===t.faceSeed?"true":"false"}
1203 1203 @click=${()=>e.local("agent-wiz",{faceSeed:o.seed,face:o.look})}
1204 1204 >
1205 - <img src=${se(o.look,44)} alt="" width="44" height="44" />
1205 + <img src=${oe(o.look,44)} alt="" width="44" height="44" />
1206 1206 </button>
1207 1207 `)}
1208 1208 </div>
1209 1209 <os-button
1210 1210 variant="secondary"
1211 - @click=${()=>e.local("agent-wiz",{stripSeed:t.stripSeed+He})}
1211 + @click=${()=>e.local("agent-wiz",{stripSeed:t.stripSeed+Ge})}
1212 1212 >
1213 1213 ${r("Surprise me")}
1214 1214 </os-button>
1215 1215 <div class="dm-agents__portrait-chips">
1216 - <os-chip size="compact" label=${Rn(t.face)}></os-chip>
1217 - <os-chip size="compact" label=${Fn(t.face)}></os-chip>
1216 + <os-chip size="compact" label=${Kn(t.face)}></os-chip>
1217 + <os-chip size="compact" label=${Hn(t.face)}></os-chip>
1218 1218 </div>
1219 1219 </div>
1220 1220 <div class="dm-agents__meet-fields">
1221 1221 ${t.copiedFrom?c`<os-notice tone="info">
@@ -1226,9 +1226,9 @@
1226 1226 os-field-control
1227 1227 label=${r("Name")}
1228 1228 value=${t.name}
1229 1229 ?invalid=${s.nameError!==""}
1230 - @os-input-change=${o=>{const i=Ve(t)&&s.nameError==="";t.name=o.detail?.value??"",s.nameError="",i!==Ve(t)&&e.repaint()}}
1230 + @os-input-change=${o=>{const i=Ze(t)&&s.nameError==="";t.name=o.detail?.value??"",s.nameError="",i!==Ze(t)&&e.repaint()}}
1231 1231 ></os-text-field>
1232 1232 </os-field-row>
1233 1233 <os-text-field
1234 1234 label=${r("Vibes")}
@@ -1253,16 +1253,16 @@
1253 1253 </os-button>
1254 1254 <span class="os-app__spacer"></span>
1255 1255 <os-button
1256 1256 variant="primary"
1257 - ?disabled=${!Ve(t)}
1257 + ?disabled=${!Ze(t)}
1258 1258 @click=${()=>e.local("agent-step",{step:2})}
1259 1259 >
1260 1260 ${r("Continue")}
1261 1261 </os-button>
1262 - ${oe(e,t)}
1262 + ${re(e,t)}
1263 1263 </div>
1264 - `}function mo(e,t,s){return c`
1264 + `}function bo(e,t,s){return c`
1265 1265 <os-select
1266 1266 class="dm-agents__role-select"
1267 1267 label=${r("Role")}
1268 1268 value=${s.role}
@@ -1267,9 +1267,9 @@
1267 1267 label=${r("Role")}
1268 1268 value=${s.role}
1269 1269 @os-pick=${n=>e.local("agent-wiz",{role:n.detail?.value??s.role})}
1270 1270 >
1271 - ${t.roles===null?c`<os-option value=${s.role}>${s.role}</os-option>`:Lt(t.roles,s.role)}
1271 + ${t.roles===null?c`<os-option value=${s.role}>${s.role}</os-option>`:Ot(t.roles,s.role)}
1272 1272 </os-select>
1273 1273 <p class="dm-agents__hint">
1274 1274 ${r("The agent acts with this role's capabilities. Pick the least privilege that still lets it do its job.")}
1275 1275 </p>
@@ -1274,9 +1274,9 @@
1274 1274 ${r("The agent acts with this role's capabilities. Pick the least privilege that still lets it do its job.")}
1275 1275 </p>
1276 1276 <h4 class="dm-agents__wiz-heading">${r("What it may call (abilities)")}</h4>
1277 1277 ${t.abilities.length===0?"":c`
1278 - ${ho(e,t,s)}
1278 + ${ko(e,t,s)}
1279 1279 <p class="dm-agents__hint">
1280 1280 ${r("The agent may only call abilities ticked here, and every call is still gated by the ability's own permission check against the agent's role.")}
1281 1281 </p>
1282 1282 `}
@@ -1287,12 +1287,12 @@
1287 1287 <span class="os-app__spacer"></span>
1288 1288 <os-button variant="primary" @click=${()=>e.local("agent-step",{step:3})}>
1289 1289 ${r("Continue")}
1290 1290 </os-button>
1291 - ${oe(e,s)}
1291 + ${re(e,s)}
1292 1292 </div>
1293 - `}function ho(e,t,s){return Ot(e,t,s.abilities,(n,o)=>{const i=new Set(s.abilities);o?i.add(n):i.delete(n),e.local("agent-wiz",{abilities:[...i]})})}function go(e,t,s){return c`
1294 - ${Wt(e,t,s.triggers,n=>e.local("agent-wiz",{triggers:n}))}
1293 + `}function ko(e,t,s){return Ut(e,t,s.abilities,(n,o)=>{const i=new Set(s.abilities);o?i.add(n):i.delete(n),e.local("agent-wiz",{abilities:[...i]})})}function So(e,t,s){return c`
1294 + ${Bt(e,t,s.triggers,n=>e.local("agent-wiz",{triggers:n}))}
1295 1295 <div class="dm-agents__actions">
1296 1296 <os-button variant="ghost" @click=${()=>e.local("agent-step",{step:2})}>
1297 1297 ${r("Back")}
1298 1298 </os-button>
@@ -1298,19 +1298,19 @@
1298 1298 </os-button>
1299 1299 <span class="os-app__spacer"></span>
1300 1300 <os-button
1301 1301 variant="primary"
1302 - @click=${()=>e.local("agent-step",{step:Bn})}
1302 + @click=${()=>e.local("agent-step",{step:Gn})}
1303 1303 >
1304 1304 ${r("Continue")}
1305 1305 </os-button>
1306 - ${oe(e,s)}
1306 + ${re(e,s)}
1307 1307 </div>
1308 - `}function yo(e,t,s){const n=k(e),o=t.canInvoke&&t.aiReady,i=p=>t.abilities.find(f=>f.slug===p)?.label??p,a=p=>t.triggerKinds.find(f=>f.slug===p)?.label??p,l=t.roles?.find(p=>p.slug===s.role)?.label??t.roleLabels[s.role]??s.role,d=s.triggers.length===0?r("No triggers configured: reachable in chat."):b(r("Starts from: %s."),s.triggers.map(p=>a(p.kind)).join(", ")),u=p=>{if(s.name.trim()===""){n.nameError=r("Agent name is required."),e.local("agent-step",{step:1});return}n.chatAfterCreate=p,ne(e,"agent-create")};return c`
1308 + `}function Ao(e,t,s){const n=k(e),o=t.canInvoke&&t.aiReady,i=p=>t.abilities.find(f=>f.slug===p)?.label??p,a=p=>t.triggerKinds.find(f=>f.slug===p)?.label??p,l=t.roles?.find(p=>p.slug===s.role)?.label??t.roleLabels[s.role]??s.role,u=s.triggers.length===0?r("No triggers configured: reachable in chat."):b(r("Starts from: %s."),s.triggers.map(p=>a(p.kind)).join(", ")),d=p=>{if(s.name.trim()===""){n.nameError=r("Agent name is required."),e.local("agent-step",{step:1});return}n.chatAfterCreate=p,ie(e,"agent-create")};return c`
1309 1309 <os-card class="dm-agents__summary">
1310 1310 <img
1311 1311 class="dm-agents__summary-face"
1312 - src=${se(s.face,96)}
1312 + src=${oe(s.face,96)}
1313 1313 alt=""
1314 1314 width="96"
1315 1315 height="96"
1316 1316 />
@@ -1324,14 +1324,14 @@
1324 1324 <os-chip size="compact" label=${l}></os-chip>
1325 1325 ${s.abilities.map(p=>c`<os-chip size="compact" label=${i(p)}></os-chip>`)}
1326 1326 </div>
1327 1327 ${s.instructions===""?c`<p class="dm-agents__hint">
1328 - ${r("No instructions yet: the agent will improvise. You can add them any time in Define.")}
1328 + ${r("No instructions yet: the agent will improvise. Add them in Describe, or any time after in Define.")}
1329 1329 </p>`:c`<p class="dm-agents__summary-instr">${s.instructions}</p>`}
1330 1330 ${s.abilities.length===0?c`<p class="dm-agents__hint">
1331 1331 ${r("No abilities ticked: the agent can talk, but not touch the site.")}
1332 1332 </p>`:""}
1333 - <p class="dm-agents__hint">${d}</p>
1333 + <p class="dm-agents__hint">${u}</p>
1334 1334 </div>
1335 1335 </os-card>
1336 1336 <div class="dm-agents__actions">
1337 1337 <os-button variant="ghost" @click=${()=>e.local("agent-step",{step:3})}>
@@ -1340,9 +1340,9 @@
1340 1340 <span class="os-app__spacer"></span>
1341 1341 <os-button
1342 1342 variant=${o?"secondary":"primary"}
1343 1343 ?disabled=${n.agentBusy}
1344 - @click=${()=>u(!1)}
1344 + @click=${()=>d(!1)}
1345 1345 >
1346 1346 ${r("Create agent")}
1347 1347 </os-button>
1348 1348 ${o?c`
@@ -1348,22 +1348,22 @@
1348 1348 ${o?c`
1349 1349 <os-button
1350 1350 variant="primary"
1351 1351 ?disabled=${n.agentBusy}
1352 - @click=${()=>u(!0)}
1352 + @click=${()=>d(!0)}
1353 1353 >
1354 1354 ${r("Create and chat")}
1355 1355 </os-button>
1356 1356 `:""}
1357 - ${oe(e,s)}
1357 + ${re(e,s)}
1358 1358 </div>
1359 - `}function $o(e){const t=e.data.agents;if(!t)return c`<os-empty-state>${r("This section is not available.")}</os-empty-state>`;const s=!t.enabled,n=e.state,o=t.list.find(a=>a.id===n.item)??null;let i;return n.casting&&n.cast?i=uo(e,t):o?i=c`<div class="dm-agents__detail">${lo(e,t,o)}</div>`:i=Vn(e,t),c`
1359 + `}function Mo(e){const t=e.data.agents;if(!t)return c`<os-empty-state>${r("This section is not available.")}</os-empty-state>`;const s=!t.enabled,n=e.state,o=t.list.find(a=>a.id===n.item)??null;let i;return n.casting&&n.cast?i=wo(e,t):o?i=c`<div class="dm-agents__detail">${yo(e,t,o)}</div>`:i=no(e,t),c`
1360 1360 <div class="dm-agents ${s?"is-disabled":""}">
1361 - ${Yn(t)}
1361 + ${to(t)}
1362 1362 ${n.agentNotice?c`<os-notice class="dm-agents__notice">${n.agentNotice}</os-notice>`:""}
1363 1363 <div class="dm-agents__view">${i}</div>
1364 1364 </div>
1365 - `}const Ut=8;function wo(e,t){e.style.visibility="hidden";const s=()=>{e.isConnected&&(t(e.getBoundingClientRect()),e.style.visibility="")};typeof requestAnimationFrame=="function"?requestAnimationFrame(s):s()}function _o(e){wo(e,t=>{t.right>window.innerWidth&&(e.style.left=`${Math.max(0,window.innerWidth-t.width-Ut)}px`),t.bottom>window.innerHeight&&(e.style.top=`${Math.max(0,window.innerHeight-t.height-Ut)}px`)})}const K=de("desktop-mode/my-wordpress/open-target",()=>({kind:null,entityId:"",id:0,title:"",requestedAt:0}));function vo(){return{...K.state}}function bo(){K.state.kind=null,K.state.entityId="",K.state.id=0,K.state.title="",K.notify()}function ko(e){return K.subscribe(t=>e({...t}))}const ie=de("desktop-mode/agents/editor-target",()=>({agentId:null,requestedAt:0}));function So(){return{...ie.state}}function Ao(){ie.state.agentId=null,ie.state.requestedAt=0,ie.notify()}function Mo(e){return ie.subscribe(t=>e({...t}))}function Ee(){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 To(e,t,s,n){Ee().addFilter(e,t,s,n)}function Co(e,t,s,n){Ee().addAction(e,t,s,n)}function Eo(e,t){return Ee().removeAction(e,t)}function Io(e,t){return Ee().removeFilter(e,t)}const Bt="X-WP-Nonce";function No(e,t){const s=Do();if(!s)return t;const n=Lo(e);if(!n||!Po(n))return t;const o=t?.headers??(typeof Request<"u"&&e instanceof Request?e.headers:void 0),i=new Headers(o??{});return i.has(Bt)?t:(i.set(Bt,s),{...t??{},headers:i})}function Do(){if(typeof window>"u")return;const t=window.openStationConfig?.restNonce;return typeof t=="string"&&t.length>0?t:void 0}function Lo(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 Po(e){return typeof window>"u"||!window.location||e.origin!==window.location.origin?!1:!!(e.pathname.includes("/wp-json/")||e.searchParams.has("rest_route"))}function Qe(e,t,s={}){const n=window.wp?.os?.fetch;if(typeof n=="function")return n(e,t,s);const o=No(e,t);return fetch(e,o)}const Ro="http://localhost/";function qt(e,t){const s=typeof window<"u"&&window.location?window.location.href:Ro,n=new URL(e,s),o=t.replace(/^\/+/,""),i=o.indexOf("?"),a=i===-1?o:o.slice(0,i),l=i===-1?"":o.slice(i+1);if(n.searchParams.has("rest_route")){const d=n.searchParams.get("rest_route")??"/",u=d.endsWith("/")?d:d+"/";n.searchParams.set("rest_route",u+a)}else{const d=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";n.pathname=d+a}return l&&new URLSearchParams(l).forEach((u,p)=>{n.searchParams.append(p,u)}),n.toString()}function Oo(){const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]%16+64,e[8]=e[8]%64+128;const t=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}class Q extends Error{constructor(t,s){super(t),this.retryable=s}}async function Fo(e,t,s){const n=new AbortController,o=window.setTimeout(()=>n.abort(),15e3);try{const i=await Qe(qt(e.restRoot,t),{method:s?"POST":"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":e.restNonce},body:s?JSON.stringify(s):void 0,signal:n.signal,cache:"no-store"},{source:"desktop-mode/agents",silent:!s}),a=await i.json().catch(()=>null);if(!i.ok)throw new Q(a?.message||`HTTP ${i.status}`,i.status>=500&&!a?.code||i.status===408);if(!a||!a.jobId&&typeof a.text!="string")throw new Q(r("The job status could not be read.","desktop-mode"),!0);return a}finally{window.clearTimeout(o)}}function Wo(e){return new Promise(t=>window.setTimeout(t,e))}async function Uo(e,t,s,n,o=()=>{}){const i=`desktop-mode/v1/agents/${e}`,a=Date.now()+2*60*60*1e3;let l=!1,d=2e3;for(;Date.now()<a;){try{const u=await Fo(s,l?`${i}/jobs/${n}`:`${i}/invoke`,l?void 0:{...t,async:!0,requestId:n});if(!("jobId"in u))return u;if(u.jobId!==n)throw new Q(r("The server returned a different job.","desktop-mode"),!1);if(l=!0,u.status==="completed"&&u.result)return u.result;if(u.status==="failed")throw new Q(u.error?.message||r("The agent job failed.","desktop-mode"),!1);if(u.status!=="queued"&&u.status!=="running")throw new Q(r("The server returned an invalid job state.","desktop-mode"),!1);o(u.status),d=Math.min(1e4,Math.max(d*1.25,(u.pollAfter||3)*1e3))}catch(u){if(u instanceof Q&&!u.retryable)throw u;o("reconnecting"),d=Math.min(d*2,3e4)}await Wo(document.hidden?Math.max(d,15e3):d)}throw new Error(r("The background job has not returned a result. Some work may already have been applied. Check the site before submitting again.","desktop-mode"))}const jt="desktop-mode/v1/agents/conversations";async function Kt(e,t,s={}){const n=await Qe(qt(e.restRoot,t),{...s,headers:{"Content-Type":"application/json","X-WP-Nonce":e.restNonce,...s.headers??{}}},{source:"desktop-mode/agents",silent:!0}),o=await n.json().catch(()=>null);if(!n.ok){const i=o&&typeof o=="object"&&typeof o.message=="string"?o.message:`HTTP ${n.status}`;throw new Error(i)}return o}function Bo(e){return e.filter(t=>!t.pending)}async function qo(e,t){const s=P.state,n=Bo(s.transcripts[e.id]??[]);if(n.length!==0){s.conversationIds||(s.conversationIds={});try{const o=s.conversationIds[e.id];if(o)await Kt(t,`${jt}/${o}`,{method:"PUT",body:JSON.stringify({messages:n})});else{const i=await Kt(t,jt,{method:"POST",body:JSON.stringify({agentId:e.id,messages:n})});s.conversationIds[e.id]=i.id}s.conversationsRev=(s.conversationsRev??0)+1,P.notify()}catch(o){console.warn("[desktop-mode/agents] conversation save failed:",o)}}}const zt={post:"post",page:"page",attachment:"media",media:"media",user:"user",comment:"comment"};function Ht(e){const t=Number.parseInt(String(e??""),10);return Number.isFinite(t)&&t>0?t:0}function Xt(e){if(e.type==="shortcut"){const t=e.data;let s=zt[String(t.kind??"")];s==="post"&&t.bridgePayload?.postType==="page"&&(s="page");const n=Ht(t.ref);return!s||!n?null:{kind:s,id:n,title:String(t.title??"")||`#${n}`}}if(e.type==="desktop-file"){const s=e.data.placement?.file;if(!s)return null;const n=zt[String(s.type??"")],o=Ht(s.ref);return!n||!o?null:{kind:n,id:o,title:String(s.title??"")||`#${o}`}}return null}function jo(e){const t=e.find(n=>n.kind==="drag");if(!t)return null;const s=t.config?.entityKinds;return Array.isArray(s)?s.map(String):[]}function Ko(e,t,s){return!t||s&&t.kind==="user"&&t.id===s||e==null?!1:e.length===0?!0:e.includes(t.kind)}function zo(e){return b(r('The user dropped the %1$s "%2$s" (id %3$s) onto you. Handle it according to your instructions, using your tools as needed.',"desktop-mode"),e.kind,e.title,String(e.id))}function Ho(e){return b(r('The user sent you the %1$s "%2$s" (id %3$s) from the "Send to" menu. Handle it according to your instructions, using your tools as needed.',"desktop-mode"),e.kind,e.title,String(e.id))}function Xo(e,t,s){return Gt(e,"agents-send-to"),Vt(e,Ho(t),s,"send-to",Yt(t))}function Yt(e){return{kind:e.kind,id:e.id,title:e.title}}function Gt(e,t="agents"){Xe(e);const s=window.wp?.os?.openWindow;typeof s=="function"&&s("desktop-mode-agent-run",{source:t})}async function Vt(e,t,s,n,o){Xe(e);const i=P.state.transcripts[e.id],a=i.filter(d=>!d.pending&&d.role!=="error").map(d=>({role:d.role,text:d.text}));i.push({role:"user",text:t,at:Date.now(),attachment:o});const l={role:"agent",text:r("Working…","desktop-mode"),at:Date.now(),pending:!0};i.push(l),P.notify();try{const d=await Uo(e.id,{message:t,source:n,history:a},s,Oo(),u=>{const p={queued:r("Queued — waiting for a WordPress worker…","desktop-mode"),reconnecting:r("Reconnecting to the background job…","desktop-mode"),running:r("Working in the background…","desktop-mode")};l.text=p[u],P.notify()});l.text=d.text||r("The agent finished without a text answer.","desktop-mode"),l.toolCalls=d.toolCalls,Array.isArray(d.callToActions)&&d.callToActions.length>0&&(l.callToActions=d.callToActions)}catch(d){l.role="error",l.text=d instanceof Error?d.message:String(d)}l.pending=!1,P.notify(),qo(e,s)}function Yo(e,t,s){return Gt(e,"agents-drop"),Vt(e,zo(t),s,"drag",Yt(t))}const Go={source:"desktop-mode/agents"};function Qt(){const e=window.wp?.os?.config;return{restRoot:String(e?.restUrl??""),restNonce:String(e?.restNonce??"")}}function Vo(e=""){return`${Qt().restRoot.replace(/\/+$/,"")}/desktop-mode/v1/agents${e}`}async function Qo(e,t={}){const s=await Qe(e,{...t,headers:{"Content-Type":"application/json","X-WP-Nonce":Qt().restNonce,...t.headers||{}}},Go),n=await s.json().catch(()=>null);if(!s.ok){const o=n&&typeof n=="object"&&typeof n.message=="string"?n.message:`HTTP ${s.status}`;throw new Error(o)}return n}function Zo(){return Qo(Vo())}let z=null,Ze=!1,Je=null;function Zt(e){Je===!1&&e&&(z=null),Je=e}function Jo(){return Je===!0}async function xe(){if(!(Ze||z!==null||!Jo())){Ze=!0;try{z=await Zo()}catch{z=[]}finally{Ze=!1}}}function xo(){z=null,xe()}function ei(e){return z===null?(xe(),[]):z.filter(t=>{const s=t.triggers.find(o=>o.kind==="send-to");if(!s)return!1;const n=Array.isArray(s.config?.entityKinds)?s.config.entityKinds:[];return n.length===0||n.includes(e)})}function ti(e){return e.kind==="user"?"user":e.kind==="attachment"||e.kind==="media"?"media":e.kind==="post"?e.entityId==="pages"?"page":"post":null}function si(e){const t=e.title?.rendered;if(typeof t=="string"&&t!==""){const s=document.createElement("div");return s.innerHTML=t,s.textContent??""}return typeof e.title=="string"&&e.title!==""?e.title:typeof e.name=="string"&&e.name!==""?e.name:""}const Ie="desktop-mode/agents-send-to";function ni(){Io("os.my-wordpress.tile-context-menu",Ie),To("os.my-wordpress.tile-context-menu",Ie,oi),Eo("os.agents.roster-changed",Ie),Co("os.agents.roster-changed",Ie,()=>{xo()}),xe()}function oi(e,t){const s=ti(t);if(!s)return e;const n=Number.parseInt(String(t.item?.id??""),10);if(!n)return e;const o=ei(s);if(o.length===0)return e;const i=si(t.item)||`#${n}`;return[...e,...o.map(a=>({id:`agent-send-to-${a.id}`,label:b(r("Send to %s","desktop-mode"),a.name),icon:"dashicons-share-alt",onSelect:()=>{const l=window.wp?.os?.config;Xo({id:a.id,name:a.name,description:a.description,avatarUrl:a.avatarUrl},{kind:s,id:n,title:i},{restRoot:String(l?.restUrl??""),restNonce:String(l?.restNonce??"")})}}))]}function ii(e){const{root:t}=e,s=k(e),n=[],o=y=>{if(y.button!==0||y.shiftKey||y.ctrlKey||y.metaKey||H())return;const _=y.target?.closest("[data-mywp-drag][data-item-id]");if(!_)return;const M=T().dragManager;if(!M)return;const S=Number(_.getAttribute("data-item-id")),A=_.getAttribute("data-mywp-drag")??"",N=s.list.items(),R=N.find(B=>B.id===S);if(!R)return;const re=X(e.data,e.state.section),Ne=re?.id??"",U=String(re?.restPath??""),Z=e.state.selected.includes(S)?N.filter(B=>e.state.selected.includes(B.id)):[R];M.start({payload:{type:"shortcut",source:_,data:{kind:A,ref:String(R.id),title:R.title,icon:R.thumb||"",entityId:Ne,restPath:U,...Z.length>1?{items:Z.map(B=>({kind:A,ref:String(B.id),title:B.title,icon:B.thumb||"",entityId:Ne,restPath:U}))}:{}}},origin:y})};t.addEventListener("pointerdown",o),n.push(()=>t.removeEventListener("pointerdown",o)),H()||n.push(us({root:t,canvas:".os-mywp__canvas",className:"os-mywp__marquee",select:y=>e.local("select-set",{ids:y})})),n.push(()=>s.list.dispose());const i=T().hooks,a=`openstation-apps/my-wordpress/${Nt(t)}`;i?.addAction?.("os.extended-options.changed",a,y=>{const _=y?.options;_&&typeof _.agents=="boolean"&&e.dispatch("refresh")}),n.push(()=>{i?.removeAction?.("os.extended-options.changed",a);for(const y of s.agentDropTargets.values())y();s.agentDropTargets.clear()});let l=null,d=0;const u=()=>{l?.remove(),l=null,d=0},p=(y,_)=>{let S=_.clientX+16,A=_.clientY+16;const N=y.getBoundingClientRect();S+N.width>window.innerWidth-8&&(S=Math.max(8,_.clientX-N.width-16)),A+N.height>window.innerHeight-8&&(A=Math.max(8,_.clientY-N.height-16)),y.style.left=`${S}px`,y.style.top=`${A}px`},f=y=>{const _=document.createElement("div");_.className="os-my-wordpress__tooltip",_.setAttribute("role","tooltip");const M=document.createElement("div");if(M.className="os-my-wordpress__tooltip-title",M.textContent=y.title,_.appendChild(M),y.lockedBy){const A=document.createElement("div");A.className="os-my-wordpress__tooltip-lock";const N=document.createElement("span");N.className="dashicons dashicons-lock",N.setAttribute("aria-hidden","true"),A.appendChild(N);const R=document.createElement("span");R.textContent=b(r("%s is currently editing"),y.lockedBy),A.appendChild(R),_.appendChild(A)}if(y.thumb){const A=document.createElement("img");A.className="os-my-wordpress__tooltip-thumb",A.src=y.thumb,A.alt="",_.appendChild(A)}const S=y.excerpt||y.subtitle;if(S){const A=document.createElement("p");A.className="os-my-wordpress__tooltip-excerpt",A.textContent=S.length>240?S.slice(0,237)+"…":S,_.appendChild(A)}return _},m=y=>{const _=y.target?.closest("[data-mywp-drag][data-item-id]");if(!_||_.closest("[data-mywp-list]"))return;const M=Number(_.getAttribute("data-item-id"));if(M===d)return;const S=s.list.items().find(N=>N.id===M);if(!S)return;u(),d=M;const A=i?.applyFilters("os.my-wordpress.hover-card",null,S,{build:f,cell:_,event:y});A instanceof HTMLElement&&(l=A,document.body.appendChild(l),p(l,y))},h=y=>{if(!l)return;if(!y.target?.closest("[data-mywp-drag][data-item-id]")){u();return}p(l,y)};t.addEventListener("mouseover",m),t.addEventListener("mousemove",h),t.addEventListener("mouseleave",u),t.addEventListener("pointerdown",u),t.addEventListener("contextmenu",u),n.push(()=>{t.removeEventListener("mouseover",m),t.removeEventListener("mousemove",h),t.removeEventListener("mouseleave",u),t.removeEventListener("pointerdown",u),t.removeEventListener("contextmenu",u),u()});const $=y=>{if(y.key!=="Escape")return;const _=k(e);_.menu?(_.menu=null,e.repaint()):_.columnsMenu?(_.columnsMenu=null,e.repaint()):_.zoom?(_.zoom=!1,e.repaint()):e.state.footprint>0?e.dispatch("back"):e.state.item>0&&O(e,0)};t.addEventListener("keydown",$),n.push(()=>t.removeEventListener("keydown",$));const v=y=>{const _=Number(y.userId);!Number.isFinite(_)||_<=0||(xn(),e.dispatch("footprint",{user:_,name:y.userName}))};v(Jn()),n.push(eo(v));const w=y=>{!y.kind||!(Number(y.id)>0)||(bo(),e.dispatch("go",{section:y.entityId}),y.kind==="media"?e.dispatch("open",{item:y.id}):e.dispatch("into",{item:y.id}))};w(vo()),n.push(ko(w));const g=y=>{const _=Number(y.agentId);!Number.isFinite(_)||_<=0||(Ao(),e.dispatch("go",{section:"agents"}),e.dispatch("open",{item:_}))};return g(So()),n.push(Mo(g)),Zt(e.data.agentsEnabled===!0),window.wp?.hooks&&ni(),()=>n.forEach(y=>y())}function ri(e){const t=T().hooks;if(!t?.doAction)return;const s=e.root.querySelector("[data-mywp-group-extras]");if(s){const l=s.dataset.mywpGroupExtras??"";if(s.dataset.mywpExtrasFor!==l){s.dataset.mywpExtrasFor=l,s.replaceChildren();try{t.doAction("os.my-wordpress.group-extras",{container:s,groupId:l,group:e.data.groups.find(d=>d.id===l)??null,entityIds:e.data.sections.filter(d=>d.group===l).map(d=>d.id)})}catch(d){console.error("[my-wordpress] a group-extras subscriber threw.",d)}}}const n=X(e.data,e.state.section);if(!n||n.kind==="agent")return;const o=new Map;for(const l of k(e).list.items())o.set(l.id,l);const i=e.data.detail,a=e.data.folder;for(const l of Array.from(e.root.querySelectorAll("[data-mywp-slot]"))){const d=l.dataset.mywpSlot??"",u=Number(l.dataset.mywpExtrasItem??0),p=`${n.id}:${d}:${u}`;if(l.dataset.mywpExtrasFor===p)continue;l.dataset.mywpExtrasFor=p,l.replaceChildren();let f=null;if(i&&i.id===u?f={...o.get(u)??{},...i}:a&&a.id===u&&(f={...o.get(u)??{},id:a.id,title:a.title,status:a.status}),!!f)try{t.doAction("os.my-wordpress.preview-extras",{slot:d,container:l,entityId:n.id,kind:n.kind,item:f})}catch(m){console.error("[my-wordpress] a preview-extras subscriber threw.",m)}}for(const l of Array.from(e.root.querySelectorAll("[data-mywp-drag][data-item-id]"))){const d=l.querySelector("os-tile"),u=Number(l.getAttribute("data-item-id")),p=o.get(u);if(!(!d||!p||d.dataset.mywpDecorated===String(u))){d.dataset.mywpDecorated=String(u);try{t.doAction("os.my-wordpress.list-tile",{tile:d,entityId:n.id,kind:n.kind,item:p})}catch(f){console.error("[my-wordpress] a list-tile subscriber threw.",f)}}}}function ai(e){const t=k(e);if(Zt(e.data.agentsEnabled===!0),li(e),t.list.sync({sentinel:e.root.querySelector("[data-mywp-sentinel]"),canvas:e.root.querySelector(".os-mywp__canvas"),load:()=>e.dispatch("more"),repaint:()=>e.repaint()}),t.revealSelection){t.revealSelection=!1;const i=e.state.item>0?e.state.item:e.state.selected[0]??0;i>0&&e.root.querySelector(`[data-item-id="${i}"]`)?.scrollIntoView?.({block:"nearest"})}for(const i of Array.from(e.root.querySelectorAll("os-context-menu.os-mywp__menu")))(t.menu||t.columnsMenu)&&_o(i);const s=e.data.subDetail;let n;s?.kind==="revision"?n=s.content:s?.kind==="comment"&&(n=String(s.stats.comment?.content??""));const o=s?{id:e.state.item,content:n}:null;for(const[i,a]of[["detail",pt(e)],["folder",e.data.folder],["sub",o]]){const l=e.root.querySelector(`[data-mywp-content="${i}"]`);if(l&&a?.content!==void 0){const d=`${a.id}:${a.content.length}`;l.dataset.mywpStamp!==d&&(l.dataset.mywpStamp=d,l.innerHTML=a.content)}}ri(e)}function li(e){const t=k(e),s=e.data.agents,n=X(e.data,e.state.section);if(!(!!s&&n?.kind==="agent")||!s){for(const u of t.agentDropTargets.values())u();t.agentDropTargets.clear();return}const i=Et(s.list);if(t.rosterStamp!==i){const u=t.rosterStamp===""&&s.list.length>0;t.rosterStamp=i||"·",!u&&i!==""&&T().hooks?.doAction?.("os.agents.roster-changed")}if(t.chatAfterCreate&&!e.state.casting&&e.state.item>0){const u=s.list.find(p=>p.id===e.state.item);u&&(t.chatAfterCreate=!1,Dt(s,u))}t.chatAfterCreate&&e.state.casting&&e.state.agentNotice!==""&&(t.chatAfterCreate=!1);const a=T().dragManager,l=Nt(e.root),d=new Set;a?.registerDropTarget&&e.root.querySelectorAll(".dm-agents__cast-card[data-agent-id]").forEach(u=>{const p=Number.parseInt(u.dataset.agentId??"",10),f=s.list.find(m=>m.id===p);f&&(d.add(p),u.dataset.dmAgentDragOut||(u.dataset.dmAgentDragOut="1",u.addEventListener("pointerdown",m=>{if(m.button!==0||m.shiftKey||m.ctrlKey||m.metaKey||H())return;const h=T().dragManager;h&&h.start({payload:{type:"shortcut",source:u,data:{kind:"user",ref:String(p),title:f.name,icon:"dashicons-admin-users",entityId:"agents"}},origin:m})})),t.agentDropTargets.set(p,a.registerDropTarget({id:`dm-agents-row-${l}-${p}`,element:u,accept:m=>Ko(jo(f.triggers),Xt(m),f.id),acceptLabel:r("Send to agent"),onDrop:m=>{const h=Xt(m.payload);h&&Yo({id:f.id,name:f.name,description:f.description,avatarUrl:f.avatarUrl},h,{restRoot:s.restRoot,restNonce:s.restNonce})}})))});for(const[u,p]of t.agentDropTargets)d.has(u)||(p(),t.agentDropTargets.delete(u));if(s.canManage&&!t.agentBusy){const u=s.list.find(p=>!Mt(p.face)&&p.faceSeed>0&&!t.agentBackfilled.has(p.id));u&&(t.agentBackfilled.add(u.id),e.dispatch("agent-update",{id:u.id,face:Ae(u.faceSeed),faceSeed:u.faceSeed}))}}function di(e,t,s,n,o){return e.state.footprint>0?un(e):t?t.kind==="agent"?$o(e):n?xs(e):s?Zs(e):e.state.item>0&&!he(t,e.state.item)&&H()?c`<div class="os-mywp__detail-page">${wt(e,t)}</div>`:$t(js(e,t,o),e.state.item>0&&!he(t,e.state.item)?wt(e,t):null):qs(e)}function ci(e){const{state:t}=e,s=n=>{const o=String(n.detail?.value??"");o!=="icons"&&o!=="list"||o===t.view||(k(e).revealSelection=!0,e.local("set-view",{view:o}),e.dispatch("view"))};return c`
1365 + `}const jt=8;function To(e,t){e.style.visibility="hidden";const s=()=>{e.isConnected&&(t(e.getBoundingClientRect()),e.style.visibility="")};typeof requestAnimationFrame=="function"?requestAnimationFrame(s):s()}function Co(e){To(e,t=>{t.right>window.innerWidth&&(e.style.left=`${Math.max(0,window.innerWidth-t.width-jt)}px`),t.bottom>window.innerHeight&&(e.style.top=`${Math.max(0,window.innerHeight-t.height-jt)}px`)})}const K=ce("desktop-mode/my-wordpress/open-target",()=>({kind:null,entityId:"",id:0,title:"",requestedAt:0}));function Eo(){return{...K.state}}function Io(){K.state.kind=null,K.state.entityId="",K.state.id=0,K.state.title="",K.notify()}function No(e){return K.subscribe(t=>e({...t}))}const ae=ce("desktop-mode/agents/editor-target",()=>({agentId:null,requestedAt:0}));function Do(){return{...ae.state}}function Lo(){ae.state.agentId=null,ae.state.requestedAt=0,ae.notify()}function Po(e){return ae.subscribe(t=>e({...t}))}function Ie(){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 Ro(e,t,s,n){Ie().addFilter(e,t,s,n)}function Oo(e,t,s,n){Ie().addAction(e,t,s,n)}function Fo(e,t){return Ie().removeAction(e,t)}function Wo(e,t){return Ie().removeFilter(e,t)}const Uo="http://localhost/";function Kt(e,t){const s=typeof window<"u"&&window.location?window.location.href:Uo,n=new URL(e,s),o=t.replace(/^\/+/,""),i=o.indexOf("?"),a=i===-1?o:o.slice(0,i),l=i===-1?"":o.slice(i+1);if(n.searchParams.has("rest_route")){const u=n.searchParams.get("rest_route")??"/",d=u.endsWith("/")?u:u+"/";n.searchParams.set("rest_route",d+a)}else{const u=n.pathname.endsWith("/")?n.pathname:n.pathname+"/";n.pathname=u+a}return l&&new URLSearchParams(l).forEach((d,p)=>{n.searchParams.append(p,d)}),n.toString()}function qo(){const e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]%16+64,e[8]=e[8]%64+128;const t=Array.from(e,s=>s.toString(16).padStart(2,"0")).join("");return`${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}class Q extends Xe{constructor(t,s,n=new Xe("",{status:0})){super(t,{status:n.status,code:n.code,data:n.data,serverMessage:n.serverMessage}),this.name="JobRequestError",this.retryable=s}}async function Bo(e,t,s){const n=new AbortController,o=window.setTimeout(()=>n.abort(),15e3);try{const i=await He(Kt(e.restRoot,t),{method:s?"POST":"GET",headers:{"Content-Type":"application/json","X-WP-Nonce":e.restNonce},body:s?JSON.stringify(s):void 0,signal:n.signal,cache:"no-store"},{source:"desktop-mode/agents",silent:!s}),a=await i.json().catch(()=>null);if(!i.ok)throw new Q(a?.message||`HTTP ${i.status}`,i.status>=500&&!a?.code||i.status===408,se(i.status,a));if(!a||!a.jobId&&typeof a.text!="string")throw new Q(r("The job status could not be read.","desktop-mode"),!0,se(i.status,null));return a}finally{window.clearTimeout(o)}}function jo(e){return new Promise(t=>window.setTimeout(t,e))}async function Ko(e,t,s,n,o=()=>{}){const i=`desktop-mode/v1/agents/${e}`,a=Date.now()+2*60*60*1e3;let l=!1,u=2e3;for(;Date.now()<a;){try{const d=await Bo(s,l?`${i}/jobs/${n}`:`${i}/invoke`,l?void 0:{...t,async:!0,requestId:n});if(!("jobId"in d))return d;if(d.jobId!==n)throw new Q(r("The server returned a different job.","desktop-mode"),!1);if(l=!0,d.status==="completed"&&d.result)return d.result;if(d.status==="failed")throw new Q(d.error?.message||r("The agent job failed.","desktop-mode"),!1);if(d.status!=="queued"&&d.status!=="running")throw new Q(r("The server returned an invalid job state.","desktop-mode"),!1);o(d.status),u=Math.min(1e4,Math.max(u*1.25,(d.pollAfter||3)*1e3))}catch(d){if(d instanceof Q&&!d.retryable)throw d;o("reconnecting"),u=Math.min(u*2,3e4)}await jo(document.hidden?Math.max(u,15e3):u)}throw new Error(r("The background job has not returned a result. Some work may already have been applied. Check the site before submitting again.","desktop-mode"))}const zt="desktop-mode/v1/agents/conversations";async function Ht(e,t,s={}){const n=await He(Kt(e.restRoot,t),{...s,headers:{"Content-Type":"application/json","X-WP-Nonce":e.restNonce,...s.headers??{}}},{source:"desktop-mode/agents",silent:!0}),o=await n.json().catch(()=>null);if(!n.ok)throw se(n.status,o);return o}function zo(e){return e.filter(t=>!t.pending)}async function Ho(e,t){const s=P.state,n=zo(s.transcripts[e.id]??[]);if(n.length!==0){s.conversationIds||(s.conversationIds={});try{const o=s.conversationIds[e.id];if(o)await Ht(t,`${zt}/${o}`,{method:"PUT",body:JSON.stringify({messages:n})});else{const i=await Ht(t,zt,{method:"POST",body:JSON.stringify({agentId:e.id,messages:n})});s.conversationIds[e.id]=i.id}s.conversationsRev=(s.conversationsRev??0)+1,P.notify()}catch(o){console.warn("[desktop-mode/agents] conversation save failed:",o)}}}const Xt={post:"post",page:"page",attachment:"media",media:"media",user:"user",comment:"comment"};function Yt(e){const t=Number.parseInt(String(e??""),10);return Number.isFinite(t)&&t>0?t:0}function Gt(e){if(e.type==="shortcut"){const t=e.data;let s=Xt[String(t.kind??"")];s==="post"&&t.bridgePayload?.postType==="page"&&(s="page");const n=Yt(t.ref);return!s||!n?null:{kind:s,id:n,title:String(t.title??"")||`#${n}`}}if(e.type==="desktop-file"){const s=e.data.placement?.file;if(!s)return null;const n=Xt[String(s.type??"")],o=Yt(s.ref);return!n||!o?null:{kind:n,id:o,title:String(s.title??"")||`#${o}`}}return null}function Xo(e){const t=e.find(n=>n.kind==="drag");if(!t)return null;const s=t.config?.entityKinds;return Array.isArray(s)?s.map(String):[]}function Yo(e,t,s){return!t||s&&t.kind==="user"&&t.id===s||e==null?!1:e.length===0?!0:e.includes(t.kind)}function Go(e){return b(r('The user dropped the %1$s "%2$s" (id %3$s) onto you. Handle it according to your instructions, using your tools as needed.',"desktop-mode"),e.kind,e.title,String(e.id))}function Vo(e){return b(r('The user sent you the %1$s "%2$s" (id %3$s) from the "Send to" menu. Handle it according to your instructions, using your tools as needed.',"desktop-mode"),e.kind,e.title,String(e.id))}function Qo(e,t,s){return Qt(e,"agents-send-to"),Jt(e,Vo(t),s,"send-to",Vt(t))}function Vt(e){return{kind:e.kind,id:e.id,title:e.title}}function Qt(e,t="agents"){Ve(e);const s=window.wp?.os?.openWindow;typeof s=="function"&&s("desktop-mode-agent-run",{source:t})}async function Jt(e,t,s,n,o){Ve(e);const i=P.state.transcripts[e.id],a=r("The agent finished without a text answer.","desktop-mode"),l=i.filter(d=>!d.pending&&d.role!=="error"&&!(d.role==="agent"&&d.text===a)).map(d=>({role:d.role,text:d.text}));i.push({role:"user",text:t,at:Date.now(),attachment:o});const u={role:"agent",text:r("Working…","desktop-mode"),at:Date.now(),pending:!0};i.push(u),P.notify();try{const d=await Ko(e.id,{message:t,source:n,history:l},s,qo(),p=>{const f={queued:r("Queued — waiting for a WordPress worker…","desktop-mode"),reconnecting:r("Reconnecting to the background job…","desktop-mode"),running:r("Working in the background…","desktop-mode")};u.text=f[p],P.notify()});d.text?.trim()?u.text=d.text:(u.role="error",u.text=a),u.toolCalls=d.toolCalls,Array.isArray(d.callToActions)&&d.callToActions.length>0&&(u.callToActions=d.callToActions)}catch(d){u.role="error",u.text=d instanceof Error?d.message:String(d)}u.pending=!1,P.notify(),Ho(e,s)}function Jo(e,t,s){return Qt(e,"agents-drop"),Jt(e,Go(t),s,"drag",Vt(t))}const Zo={source:"desktop-mode/agents"};function Zt(){const e=window.wp?.os?.config;return{restRoot:String(e?.restUrl??""),restNonce:String(e?.restNonce??"")}}function xo(e=""){return`${Zt().restRoot.replace(/\/+$/,"")}/desktop-mode/v1/agents${e}`}async function ei(e,t={}){const s=await He(e,{...t,headers:{"Content-Type":"application/json","X-WP-Nonce":Zt().restNonce,...t.headers||{}}},Zo),n=await s.json().catch(()=>null);if(!s.ok)throw se(s.status,n);return n}function ti(){return ei(xo())}let z=null,xe=!1,et=null;function xt(e){et===!1&&e&&(z=null),et=e}function si(){return et===!0}async function tt(){if(!(xe||z!==null||!si())){xe=!0;try{z=await ti()}catch{z=[]}finally{xe=!1}}}function ni(){z=null,tt()}function oi(e){return z===null?(tt(),[]):z.filter(t=>{const s=t.triggers.find(o=>o.kind==="send-to");if(!s)return!1;const n=Array.isArray(s.config?.entityKinds)?s.config.entityKinds:[];return n.length===0||n.includes(e)})}function ii(e){return e.kind==="user"?"user":e.kind==="attachment"||e.kind==="media"?"media":e.kind==="post"?e.entityId==="pages"?"page":"post":null}function ri(e){const t=e.title?.rendered;if(typeof t=="string"&&t!==""){const s=document.createElement("div");return s.innerHTML=t,s.textContent??""}return typeof e.title=="string"&&e.title!==""?e.title:typeof e.name=="string"&&e.name!==""?e.name:""}const Ne="desktop-mode/agents-send-to";function ai(){Wo("os.my-wordpress.tile-context-menu",Ne),Ro("os.my-wordpress.tile-context-menu",Ne,li),Fo("os.agents.roster-changed",Ne),Oo("os.agents.roster-changed",Ne,()=>{ni()}),tt()}function li(e,t){const s=ii(t);if(!s)return e;const n=Number.parseInt(String(t.item?.id??""),10);if(!n)return e;const o=oi(s);if(o.length===0)return e;const i=ri(t.item)||`#${n}`;return[...e,...o.map(a=>({id:`agent-send-to-${a.id}`,label:b(r("Send to %s","desktop-mode"),a.name),icon:"dashicons-share-alt",onSelect:()=>{const l=window.wp?.os?.config;Qo({id:a.id,name:a.name,description:a.description,avatarUrl:a.avatarUrl},{kind:s,id:n,title:i},{restRoot:String(l?.restUrl??""),restNonce:String(l?.restNonce??"")})}}))]}function di(e,t){if(!(!e||!t.link)){if(e.kind==="media")return{kind:"attachment",id:t.id,url:t.link,title:t.title,alt:t.alt??"",mime:t.mime,thumbnailUrl:t.thumb||void 0};if(e.kind==="user")return{kind:"user",id:t.id,url:t.link,title:t.title};if(e.kind==="post"&&!e.flat)return{kind:"post",id:t.id,postType:e.post_type,url:t.link,title:t.title}}}function ci(e){const{root:t}=e,s=k(e),n=[],o=y=>{if(y.button!==0||y.shiftKey||y.ctrlKey||y.metaKey||H())return;const v=y.target?.closest("[data-mywp-drag][data-item-id]");if(!v)return;const M=T().dragManager;if(!M)return;const S=Number(v.getAttribute("data-item-id")),A=v.getAttribute("data-mywp-drag")??"",N=s.list.items(),R=N.find(q=>q.id===S);if(!R)return;const J=X(e.data,e.state.section),De=J?.id??"",U=String(J?.restPath??""),Z=e.state.selected.includes(S)?N.filter(q=>e.state.selected.includes(q.id)):[R];M.start({payload:{type:"shortcut",source:v,data:{kind:A,ref:String(R.id),title:R.title,icon:R.thumb||"",entityId:De,restPath:U,bridgePayload:di(J,R),...Z.length>1?{items:Z.map(q=>({kind:A,ref:String(q.id),title:q.title,icon:q.thumb||"",entityId:De,restPath:U}))}:{}}},origin:y})};t.addEventListener("pointerdown",o),n.push(()=>t.removeEventListener("pointerdown",o)),H()||n.push(fs({root:t,canvas:".os-mywp__canvas",className:"os-mywp__marquee",select:y=>e.local("select-set",{ids:y})})),n.push(()=>s.list.dispose());const i=T().hooks,a=`openstation-apps/my-wordpress/${Pt(t)}`;i?.addAction?.("os.extended-options.changed",a,y=>{const v=y?.options;v&&typeof v.agents=="boolean"&&e.dispatch("refresh")}),n.push(()=>{i?.removeAction?.("os.extended-options.changed",a);for(const y of s.agentDropTargets.values())y();s.agentDropTargets.clear()});let l=null,u=0;const d=()=>{l?.remove(),l=null,u=0},p=(y,v)=>{let S=v.clientX+16,A=v.clientY+16;const N=y.getBoundingClientRect();S+N.width>window.innerWidth-8&&(S=Math.max(8,v.clientX-N.width-16)),A+N.height>window.innerHeight-8&&(A=Math.max(8,v.clientY-N.height-16)),y.style.left=`${S}px`,y.style.top=`${A}px`},f=y=>{const v=document.createElement("div");v.className="os-my-wordpress__tooltip",v.setAttribute("role","tooltip");const M=document.createElement("div");if(M.className="os-my-wordpress__tooltip-title",M.textContent=y.title,v.appendChild(M),y.lockedBy){const A=document.createElement("div");A.className="os-my-wordpress__tooltip-lock";const N=document.createElement("span");N.className="dashicons dashicons-lock",N.setAttribute("aria-hidden","true"),A.appendChild(N);const R=document.createElement("span");R.textContent=b(r("%s is currently editing"),y.lockedBy),A.appendChild(R),v.appendChild(A)}if(y.thumb){const A=document.createElement("img");A.className="os-my-wordpress__tooltip-thumb",A.src=y.thumb,A.alt="",v.appendChild(A)}const S=y.excerpt||y.subtitle;if(S){const A=document.createElement("p");A.className="os-my-wordpress__tooltip-excerpt",A.textContent=S.length>240?S.slice(0,237)+"…":S,v.appendChild(A)}return v},m=y=>{const v=y.target?.closest("[data-mywp-drag][data-item-id]");if(!v||v.closest("[data-mywp-list]"))return;const M=Number(v.getAttribute("data-item-id"));if(M===u)return;const S=s.list.items().find(N=>N.id===M);if(!S)return;d(),u=M;const A=i?.applyFilters("os.my-wordpress.hover-card",null,S,{build:f,cell:v,event:y});A instanceof HTMLElement&&(l=A,document.body.appendChild(l),p(l,y))},h=y=>{if(!l)return;if(!y.target?.closest("[data-mywp-drag][data-item-id]")){d();return}p(l,y)};t.addEventListener("mouseover",m),t.addEventListener("mousemove",h),t.addEventListener("mouseleave",d),t.addEventListener("pointerdown",d),t.addEventListener("contextmenu",d),n.push(()=>{t.removeEventListener("mouseover",m),t.removeEventListener("mousemove",h),t.removeEventListener("mouseleave",d),t.removeEventListener("pointerdown",d),t.removeEventListener("contextmenu",d),d()});const $=y=>{if(y.key!=="Escape")return;const v=k(e);v.menu?(v.menu=null,e.repaint()):v.columnsMenu?(v.columnsMenu=null,e.repaint()):v.zoom?(v.zoom=!1,e.repaint()):e.state.footprint>0?e.dispatch("back"):e.state.item>0&&O(e,0)};t.addEventListener("keydown",$),n.push(()=>t.removeEventListener("keydown",$));const _=y=>{const v=Number(y.userId);!Number.isFinite(v)||v<=0||(ao(),Number(e.state.footprint)!==v&&e.dispatch("footprint",{user:v,name:y.userName}))};_(ro()),n.push(lo(_));const w=y=>{!y.kind||!(Number(y.id)>0)||(Io(),e.dispatch("go",{section:y.entityId}),y.kind==="media"?e.dispatch("open",{item:y.id}):e.dispatch("into",{item:y.id}))};w(Eo()),n.push(No(w));const g=y=>{const v=Number(y.agentId);!Number.isFinite(v)||v<=0||(Lo(),e.dispatch("go",{section:"agents"}),e.dispatch("open",{item:v}))};return g(Do()),n.push(Po(g)),xt(e.data.agentsEnabled===!0),window.wp?.hooks&&ai(),()=>n.forEach(y=>y())}function ui(e){const t=T().hooks;if(!t?.doAction)return;const s=e.root.querySelector("[data-mywp-group-extras]");if(s){const l=s.dataset.mywpGroupExtras??"";if(s.dataset.mywpExtrasFor!==l){s.dataset.mywpExtrasFor=l,s.replaceChildren();try{t.doAction("os.my-wordpress.group-extras",{container:s,groupId:l,group:e.data.groups.find(u=>u.id===l)??null,entityIds:e.data.sections.filter(u=>u.group===l).map(u=>u.id)})}catch(u){console.error("[my-wordpress] a group-extras subscriber threw.",u)}}}const n=X(e.data,e.state.section);if(!n||n.kind==="agent")return;const o=new Map;for(const l of k(e).list.items())o.set(l.id,l);const i=e.data.detail,a=e.data.folder;for(const l of Array.from(e.root.querySelectorAll("[data-mywp-slot]"))){const u=l.dataset.mywpSlot??"",d=Number(l.dataset.mywpExtrasItem??0),p=`${n.id}:${u}:${d}`;if(l.dataset.mywpExtrasFor===p)continue;l.dataset.mywpExtrasFor=p,l.replaceChildren();let f=null;if(i&&i.id===d?f={...o.get(d)??{},...i}:a&&a.id===d&&(f={...o.get(d)??{},id:a.id,title:a.title,status:a.status}),!!f)try{t.doAction("os.my-wordpress.preview-extras",{slot:u,container:l,entityId:n.id,kind:n.kind,item:f})}catch(m){console.error("[my-wordpress] a preview-extras subscriber threw.",m)}}for(const l of Array.from(e.root.querySelectorAll("[data-mywp-drag][data-item-id]"))){const u=l.querySelector("os-tile"),d=Number(l.getAttribute("data-item-id")),p=o.get(d);if(!(!u||!p||u.dataset.mywpDecorated===String(d))){u.dataset.mywpDecorated=String(d);try{t.doAction("os.my-wordpress.list-tile",{tile:u,entityId:n.id,kind:n.kind,item:p})}catch(f){console.error("[my-wordpress] a list-tile subscriber threw.",f)}}}}function pi(e){const t=k(e);if(xt(e.data.agentsEnabled===!0),fi(e),t.list.sync({sentinel:e.root.querySelector("[data-mywp-sentinel]"),canvas:e.root.querySelector(".os-mywp__canvas"),load:()=>e.dispatch("more"),repaint:()=>e.repaint()}),t.revealSelection){t.revealSelection=!1;const i=e.state.item>0?e.state.item:e.state.selected[0]??0;i>0&&e.root.querySelector(`[data-item-id="${i}"]`)?.scrollIntoView?.({block:"nearest"})}for(const i of Array.from(e.root.querySelectorAll("os-context-menu.os-mywp__menu")))(t.menu||t.columnsMenu)&&Co(i);const s=e.data.subDetail;let n;s?.kind==="revision"?n=s.content:s?.kind==="comment"&&(n=String(s.stats.comment?.content??""));const o=s?{id:e.state.item,content:n}:null;for(const[i,a]of[["detail",mt(e)],["folder",e.data.folder],["sub",o]]){const l=e.root.querySelector(`[data-mywp-content="${i}"]`);if(l&&a?.content!==void 0){const u=`${a.id}:${a.content.length}`;l.dataset.mywpStamp!==u&&(l.dataset.mywpStamp=u,l.innerHTML=a.content)}}ui(e)}function fi(e){const t=k(e),s=e.data.agents,n=X(e.data,e.state.section);if(!(!!s&&n?.kind==="agent")||!s){for(const d of t.agentDropTargets.values())d();t.agentDropTargets.clear();return}const i=Dt(s.list);if(t.rosterStamp!==i){const d=t.rosterStamp===""&&s.list.length>0;t.rosterStamp=i||"·",!d&&i!==""&&T().hooks?.doAction?.("os.agents.roster-changed")}if(t.chatAfterCreate&&!e.state.casting&&e.state.item>0){const d=s.list.find(p=>p.id===e.state.item);d&&(t.chatAfterCreate=!1,Rt(s,d))}t.chatAfterCreate&&e.state.casting&&e.state.agentNotice!==""&&(t.chatAfterCreate=!1);const a=T().dragManager,l=Pt(e.root),u=new Set;a?.registerDropTarget&&e.root.querySelectorAll(".dm-agents__cast-card[data-agent-id]").forEach(d=>{const p=Number.parseInt(d.dataset.agentId??"",10),f=s.list.find(m=>m.id===p);f&&(u.add(p),d.dataset.dmAgentDragOut||(d.dataset.dmAgentDragOut="1",d.addEventListener("pointerdown",m=>{if(m.button!==0||m.shiftKey||m.ctrlKey||m.metaKey||H())return;const h=T().dragManager;h&&h.start({payload:{type:"shortcut",source:d,data:{kind:"user",ref:String(p),title:f.name,icon:"dashicons-admin-users",entityId:"agents"}},origin:m})})),t.agentDropTargets.set(p,a.registerDropTarget({id:`dm-agents-row-${l}-${p}`,element:d,accept:m=>Yo(Xo(f.triggers),Gt(m),f.id),acceptLabel:r("Send to agent"),onDrop:m=>{const h=Gt(m.payload);h&&Jo({id:f.id,name:f.name,description:f.description,avatarUrl:f.avatarUrl},h,{restRoot:s.restRoot,restNonce:s.restNonce})}})))});for(const[d,p]of t.agentDropTargets)u.has(d)||(p(),t.agentDropTargets.delete(d));if(s.canManage&&!t.agentBusy){const d=s.list.find(p=>!Et(p.face)&&p.faceSeed>0&&!t.agentBackfilled.has(p.id));d&&(t.agentBackfilled.add(d.id),e.dispatch("agent-update",{id:d.id,face:Me(d.faceSeed),faceSeed:d.faceSeed}))}}function mi(e,t,s,n,o){return e.state.footprint>0?wn(e):t?t.kind==="agent"?Mo(e):n?tn(e):s?xs(e):e.state.item>0&&!ge(t,e.state.item)&&H()?c`<div class="os-mywp__detail-page">${_t(e,t)}</div>`:vt(zs(e,t,o),e.state.item>0&&!ge(t,e.state.item)?_t(e,t):null):Ks(e)}function hi(e){const{state:t}=e,s=n=>{const o=String(n.detail?.value??"");o!=="icons"&&o!=="list"||o===t.view||(k(e).revealSelection=!0,e.local("set-view",{view:o}),e.dispatch("view"))};return c`
1366 1366 <os-segmented
1367 1367 class="os-mywp__view-switch"
1368 1368 value=${t.view}
1369 1369 label=${r("View as")}
@@ -1377,9 +1377,9 @@
1377 1377 <span class="dashicons dashicons-list-view" aria-hidden="true"></span>
1378 1378 <span class="os-mywp__view-label">${r("List")}</span>
1379 1379 </os-segment>
1380 1380 </os-segmented>
1381 - `}const ui=hs("my-wordpress",{local:{"search-query":(e,t)=>{e.query=String(t.value??""),e.page=1,e.item=0,e.selected=[]},preview:(e,t)=>{e.item=Number(t.item)||0,e.pane="define",e.agentNotice=""},select:(e,t)=>{const s=Array.isArray(t.order)?t.order:[];e.selected=it(e.selected,s,Number(t.item),{ctrl:!!t.ctrl,shift:!!t.shift})},"select-set":(e,t)=>{e.selected=(Array.isArray(t.ids)?t.ids:[]).slice()},"clear-select":e=>{e.selected=[]},"set-sort":(e,t)=>{e.sort=String(t.sort??"")},"set-view":(e,t)=>{e.view=t.view==="list"?"list":"icons",e.view==="list"&&e.sort===""&&(e.sort="id-desc",e.page=1)},"agent-start":(e,t,s)=>{const n=t.from??null,o=qn(),i=Tt(Ct(s.agents?.roles??null),o);n&&(i.name=b(r("%s copy"),n.name),i.description=n.description,i.vibes=n.vibes,i.instructions=n.instructions,i.role=n.role,i.abilities=[...n.abilities],i.triggers=n.triggers.map(a=>({kind:a.kind,config:{...a.config}})),i.copiedFrom=n.name),e.casting=!0,e.item=0,e.wstep=n?1:0,e.cast=i,e.agentNotice="",e.briefError=""},"agent-cancel":e=>{e.casting=!1,e.wstep=0,e.cast=null,e.agentNotice="",e.briefError=""},"agent-step":(e,t)=>{e.wstep=Math.max(0,Math.min(4,Number(t.step))),e.agentNotice=""},"agent-pane":(e,t)=>{const s=String(t.pane??"define");e.pane=["define","tools","triggers"].includes(s)?s:"define",e.agentNotice=""},"agent-wiz":(e,t)=>{e.cast={...e.cast??{},...t}},"agent-brief-error":(e,t)=>{e.briefError=String(t.msg??"")},"agent-notice":(e,t)=>{e.agentNotice=String(t.notice??"")}},view:e=>{e=ut(e);const{state:t,data:s}=e,n=X(s,t.section),o=s.groups.find(S=>S.id===t.group)??null,i=t.footprint>0,a=!!(o||n)||i,l=(S,A)=>c`<button type="button" class="os-mywp__crumb-link" @click=${A}>${S}</button>`,d=S=>c`<span class="os-mywp__crumb-current" aria-current="page">${S}</span>`,u=()=>c`<span class="os-mywp__sep" aria-hidden="true">›</span>`,p=n&&t.into>0,f=p&&t.relation!=="",m=!!n&&!p&&n.kind!=="agent"&&t.item>0&&H(),h=[];a?(h.push(l(s.siteName,()=>void e.dispatch("go"))),o&&(h.push(u()),h.push(n?l(o.label,()=>void e.dispatch("go",{group:o.id})):d(o.label))),n&&(h.push(u()),h.push(p||i||m?l(n.label,()=>void e.dispatch("go",{group:t.group,section:n.id})):d(n.label))),m&&s.detail&&(h.push(u()),h.push(d(s.detail.title))),i&&(h.push(u()),h.push(d(t.fpName||r("Activity footprint")))),p&&s.folder&&(h.push(u()),h.push(f?l(s.folder.title,()=>void e.dispatch("relation",{relation:""})):d(s.folder.title))),f&&s.sub&&(h.push(u()),h.push(d(s.sub.label)))):h.push(d(s.siteName));const $=n&&!p?ks(e,n,k(e).list.accumulate(pe(t),s.list)):[],v=$.length,w=n?t.selected.filter(S=>!he(n,S)).length:t.selected.length;let g=null;f&&s.sub?g=[b(q("%d item","%d items",s.sub.rows.length),s.sub.rows.length),""]:p&&s.folder&&(g=[b(r("%d folders"),s.folder.folders.length),s.folder.status]);const y=n?.kind==="agent";y&&(g=s.agents?.enabled?[b(q("%d agent","%d agents",s.agents.list.length),s.agents.list.length),""]:["",""]),i&&(g=tn(e));const _=n&&!p?`${b(r("%1$d of %2$d items"),v,s.list?.total??0)}${w>0?" — "+b(r("%d selected"),w):""}`:b(r("%d folders"),t.group?s.sections.filter(S=>S.group===t.group).length:s.sections.filter(S=>!S.group).length+s.groups.length);let M=n&&!p?b(r("Page %1$d of %2$d"),s.list?.page??1,s.list?.pages??1):"";return n&&!p&&!y&&t.view==="list"&&(M=[Bs(e,n),Us(e),M].filter(Boolean).join(" · ")),c`
1381 + `}const gi=ys("my-wordpress",{local:{"search-query":(e,t)=>{e.query=String(t.value??""),e.page=1,e.item=0,e.selected=[]},preview:(e,t)=>{e.item=Number(t.item)||0,e.pane="define",e.agentNotice=""},select:(e,t)=>{const s=Array.isArray(t.order)?t.order:[];e.selected=at(e.selected,s,Number(t.item),{ctrl:!!t.ctrl,shift:!!t.shift})},"select-set":(e,t)=>{e.selected=(Array.isArray(t.ids)?t.ids:[]).slice()},"clear-select":e=>{e.selected=[]},"set-sort":(e,t)=>{e.sort=String(t.sort??"")},"set-view":(e,t)=>{e.view=t.view==="list"?"list":"icons",e.view==="list"&&e.sort===""&&(e.sort="id-desc",e.page=1)},"agent-start":(e,t,s)=>{const n=t.from??null,o=Vn(),i=It(Nt(s.agents?.roles??null),o);n&&(i.name=b(r("%s copy"),n.name),i.description=n.description,i.vibes=n.vibes,i.instructions=n.instructions,i.brief=n.instructions,i.role=n.role,i.abilities=[...n.abilities],i.triggers=n.triggers.map(a=>({kind:a.kind,config:{...a.config}})),i.copiedFrom=n.name),e.casting=!0,e.item=0,e.wstep=n?1:0,e.cast=i,e.agentNotice="",e.briefError=""},"agent-cancel":e=>{e.casting=!1,e.wstep=0,e.cast=null,e.agentNotice="",e.briefError=""},"agent-step":(e,t)=>{const s=Math.max(0,Math.min(4,Number(t.step)));e.wstep===0&&s!==0&&e.cast&&(e.cast={...e.cast,instructions:String(e.cast.brief??"").trim()}),e.wstep=s,e.agentNotice=""},"agent-pane":(e,t)=>{const s=String(t.pane??"define");e.pane=["define","tools","triggers"].includes(s)?s:"define",e.agentNotice=""},"agent-wiz":(e,t)=>{e.cast={...e.cast??{},...t}},"agent-brief-error":(e,t)=>{e.briefError=String(t.msg??"")},"agent-notice":(e,t)=>{e.agentNotice=String(t.notice??"")}},view:e=>{e=ft(e);const{state:t,data:s}=e,n=X(s,t.section),o=s.groups.find(S=>S.id===t.group)??null,i=t.footprint>0,a=!!(o||n)||i,l=(S,A)=>c`<button type="button" class="os-mywp__crumb-link" @click=${A}>${S}</button>`,u=S=>c`<span class="os-mywp__crumb-current" aria-current="page">${S}</span>`,d=()=>c`<span class="os-mywp__sep" aria-hidden="true">›</span>`,p=n&&t.into>0,f=p&&t.relation!=="",m=!!n&&!p&&n.kind!=="agent"&&t.item>0&&H(),h=[];a?(h.push(l(s.siteName,()=>void e.dispatch("go"))),o&&(h.push(d()),h.push(n?l(o.label,()=>void e.dispatch("go",{group:o.id})):u(o.label))),n&&(h.push(d()),h.push(p||i||m?l(n.label,()=>void e.dispatch("go",{group:t.group,section:n.id})):u(n.label))),m&&s.detail&&(h.push(d()),h.push(u(s.detail.title))),i&&(h.push(d()),h.push(u(t.fpName||r("Activity footprint")))),p&&s.folder&&(h.push(d()),h.push(f?l(s.folder.title,()=>void e.dispatch("relation",{relation:""})):u(s.folder.title))),f&&s.sub&&(h.push(d()),h.push(u(s.sub.label)))):h.push(u(s.siteName));const $=n&&!p?As(e,n,k(e).list.accumulate(fe(t),s.list)):[],_=$.length,w=n?t.selected.filter(S=>!ge(n,S)).length:t.selected.length;let g=null;f&&s.sub?g=[b(B("%d item","%d items",s.sub.rows.length),s.sub.rows.length),""]:p&&s.folder&&(g=[b(r("%d folders"),s.folder.folders.length),s.folder.status]);const y=n?.kind==="agent";y&&(g=s.agents?.enabled?[b(B("%d agent","%d agents",s.agents.list.length),s.agents.list.length),""]:["",""]),i&&(g=cn(e));const v=n&&!p?`${b(r("%1$d of %2$d items"),_,s.list?.total??0)}${w>0?" — "+b(r("%d selected"),w):""}`:b(r("%d folders"),t.group?s.sections.filter(S=>S.group===t.group).length:s.sections.filter(S=>!S.group).length+s.groups.length);let M=n&&!p?b(r("Page %1$d of %2$d"),s.list?.page??1,s.list?.pages??1):"";return n&&!p&&!y&&t.view==="list"&&(M=[js(e,n),Bs(e),M].filter(Boolean).join(" · ")),c`
1382 1382 <div class="os-mywp" tabindex="-1">
1383 1383 <header class="os-mywp__header">
1384 1384 ${a?c`<button
1385 1385 type="button"
@@ -1398,9 +1398,9 @@
1398 1398 clearable
1399 1399 @os-input-change=${S=>e.local("search-query",S.detail)}
1400 1400 os-action="refresh"
1401 1401 ></os-text-field>
1402 - ${ci(e)}
1402 + ${hi(e)}
1403 1403 ${n.kind==="user"&&n.canAdd?c`<os-button
1404 1404 variant="secondary"
1405 1405 class="os-mywp__add-user"
1406 1406 @click=${()=>void e.dispatch("add-user")}
@@ -1408,16 +1408,16 @@
1408 1408 ${r("Add user")}
1409 1409 </os-button>`:""}
1410 1410 </div>`:""}
1411 1411 <div class="os-mywp__body">
1412 - ${di(e,n,!!p,!!f,$)}
1412 + ${mi(e,n,!!p,!!f,$)}
1413 1413 </div>
1414 1414 <footer class="os-mywp__status">
1415 - <span>${g?g[0]:_}</span>
1415 + <span>${g?g[0]:v}</span>
1416 1416 <span>${g?g[1]:M}</span>
1417 1417 </footer>
1418 - ${n&&!y?Ks(e,n):""}
1419 - ${Ws(e,n)}
1420 - ${zs(e,n)}
1421 - ${Hs(e)}
1418 + ${n&&!y?Hs(e,n):""}
1419 + ${qs(e,n)}
1420 + ${Xs(e,n)}
1421 + ${Ys(e)}
1422 1422 </div>
1423 - `},mounted:e=>{const t=ii(e),s=Ss(e),n=()=>e.repaint();return document.addEventListener("os-mode-changed",n),()=>{s(),t(),document.removeEventListener("os-mode-changed",n)}},updated:e=>ai(e)});return E.agentDefaultRole=Ct,E.agentFaceSrc=Me,E.agentsRosterStamp=Et,E.applySelection=it,E.buildMenuOptions=ct,E.columnsFor=$e,E.default=ui,E.emptyCast=Tt,E.hiddenFor=we,E.listKey=pe,E.nextSort=yt,E.resolveActions=fe,E.resolveBanding=lt,E.withSendToHeading=dt,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),E}({});
1423 + `},mounted:e=>{const t=ci(e),s=Ms(e),n=()=>e.repaint();return document.addEventListener("os-mode-changed",n),()=>{s(),t(),document.removeEventListener("os-mode-changed",n)}},updated:e=>pi(e)});return E.agentDefaultRole=Nt,E.agentFaceSrc=Te,E.agentsRosterStamp=Dt,E.applySelection=at,E.buildMenuOptions=pt,E.columnsFor=we,E.default=gi,E.emptyCast=It,E.hiddenFor=ve,E.listKey=fe,E.nextSort=wt,E.resolveActions=me,E.resolveBanding=ct,E.withSendToHeading=ut,Object.defineProperties(E,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}}),E}({});