PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.12
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.12
1.1.12 1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 0.8.9 All 36 releases
← All changes | assets/js/mio.min.js +36 -11 1.1.2 → 1.1.12 View file →
@@ -1,5 +1,5 @@
1 -(function(){"use strict";function uo(){const t=window.wp?.hooks;if(!t)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 t}function at(t,...e){uo().doAction(t,...e)}const Rt=new Set(["window","widget"]),fo=new Set(["dock","shell"]),oe=new Set(["dock"]);function po(t,e,o){const n=[];for(const s of t){const i=s.rect;if(!i||i.width<=0||i.height<=0)continue;let c=i.x-e.left,r=i.y-e.top,a=i.width,l=i.height;o&&fo.has(s.kind)&&(s.face==="right"?(a=c+a,c=0):s.face==="left"?a=Math.max(a,o.width-c):s.face==="top"?l=Math.max(l,o.height-r):(l=r+l,r=0)),n.push({id:s.id,kind:s.kind,face:s.face,x:c,y:r,width:a,height:l})}return n}function mo(t,e,o){let{x:n,y:s}=t;for(const i of o)oe.has(i.kind)&&(n<=i.x-e||n>=i.x+i.width+e||s<=i.y-e||s>=i.y+i.height+e||({x:n,y:s}=ne(i,n,s,e)));return{x:n,y:s}}function ne(t,e,o,n){return t.face==="right"?{x:t.x+t.width+n,y:o}:t.face==="left"?{x:t.x-n,y:o}:t.face==="top"?{x:e,y:t.y-n}:{x:e,y:t.y+t.height+n}}function go(t,e,o){const n=Math.max(o.x-t,0,t-(o.x+o.width)),s=Math.max(o.y-e,0,e-(o.y+o.height));return Math.hypot(n,s)}function xo(t,e,o){return{x:Math.min(Math.max(t,o.x),o.x+o.width),y:Math.min(Math.max(e,o.y),o.y+o.height)}}function yo(t,e,o,n,s){if(s<=0)return null;let i=null,c=1/0;for(const p of n){if(!Rt.has(p.kind))continue;const f=go(t,e,p);f<c&&(c=f,i=p)}if(!i)return null;const r=c-o;if(r>=s)return null;const a=1-Math.max(r,0)/s,l=a*a*(3-2*a),h=xo(t,e,i),u=h.x-t,g=h.y-e,m=Math.hypot(u,g);return m<.001?{dx:0,dy:0,strength:l,gap:r}:{dx:u/m,dy:g/m,strength:l,gap:r}}function bo(t,e,o=8){let n=t.x,s=t.y,i=t.x+t.width,c=t.y+t.height;const r=e.filter(l=>Rt.has(l.kind)&&l!==t);let a=!0;for(;a;){a=!1;for(let l=r.length-1;l>=0;l--){const h=r[l];h.x<i+o&&h.x+h.width>n-o&&h.y<c+o&&h.y+h.height>s-o&&(n=Math.min(n,h.x),s=Math.min(s,h.y),i=Math.max(i,h.x+h.width),c=Math.max(c,h.y+h.height),r.splice(l,1),a=!0)}}return{x:n,y:s,width:i-n,height:c-s}}const vo=.75;function wo(t,e,o,n,s){for(const f of n){if(!oe.has(f.kind)||t<=f.x||t>=f.x+f.width||e<=f.y||e>=f.y+f.height)continue;const d=ne(f,t,e,o+8);return{x:Math.min(Math.max(d.x,o),Math.max(o,s.width-o)),y:Math.min(Math.max(d.y,o),Math.max(o,s.height-o))}}const i=o*vo;let c=null,r=i;for(const f of n){if(!Rt.has(f.kind))continue;const d=Math.min(t-f.x,f.x+f.width-t,e-f.y,f.y+f.height-e);d>r&&(r=d,c=f)}if(!c)return null;const a=bo(c,n),l=o+8,h=a.x+a.width/2,u=a.y+a.height/2,g=[{x:h,y:a.y-l},{x:h,y:a.y+a.height+l},{x:a.x-l,y:u},{x:a.x+a.width+l,y:u}].filter(f=>f.x>=o&&f.y>=o&&f.x<=s.width-o&&f.y<=s.height-o);if(g.length>0){let f=g[0],d=1/0;for(const x of g){const v=Math.hypot(x.x-t,x.y-e);v<d&&(d=v,f=x)}return f}const p=[{size:a.y,x:h,y:a.y/2},{size:s.height-(a.y+a.height),x:h,y:(a.y+a.height+s.height)/2},{size:a.x,x:a.x/2,y:u},{size:s.width-(a.x+a.width),x:(a.x+a.width+s.width)/2,y:u}].sort((f,d)=>d.size-f.size)[0];return p&&p.size>=o?{x:p.x,y:p.y}:{x:s.width/2,y:s.height/2}}function Mo(t,e,o,n){let s=!1;for(const i of e){const c=i.x+i.width,r=i.y+i.height;if(t.x<=i.x||t.x>=c||t.y<=i.y||t.y>=r)continue;const a=t.x-i.x,l=c-t.x,h=t.y-i.y,u=r-t.y,g=Math.min(a,l,h,u);s=!0,g===h?(t.y=i.y,t.vy>0&&(t.vy=-t.vy*o),t.vx*=n):g===u?(t.y=r,t.vy<0&&(t.vy=-t.vy*o),t.vx*=n):g===a?(t.x=i.x,t.vx>0&&(t.vx=-t.vx*o),t.vy*=n):(t.x=c,t.vx<0&&(t.vx=-t.vx*o),t.vy*=n)}return s}function ko(t,e,o,n,s){let i=!1;return t.x<0?(t.x=0,t.vx<0&&(t.vx=-t.vx*n),t.vy*=s,i=!0):t.x>e&&(t.x=e,t.vx>0&&(t.vx=-t.vx*n),t.vy*=s,i=!0),t.y<0?(t.y=0,t.vy<0&&(t.vy=-t.vy*n),t.vx*=s,i=!0):t.y>o&&(t.y=o,t.vy>0&&(t.vy=-t.vy*n),t.vx*=s,i=!0),i}const _o=250;function So(t){const e=new Map,o=new Map;for(const n of t){const s=o.get(n.id)??0;o.set(n.id,s+1),e.set(s===0?n.id:`${n.id}#${s}`,n)}return e}function Ao(t,e){if(t.size!==e.size)return!1;for(const[o,n]of t){const s=e.get(o);if(!s||s.x!==n.x||s.y!==n.y||s.width!==n.width||s.height!==n.height)return!1}return!0}function St(t,e,o){return t+(e-t)*o}function Eo(t){const e=Math.max(1,t);let o=new Map,n=new Map,s=[],i=0,c=!0;return{sample(r,a){const l=a-i;o=n,n=So(r),s=r,i=a,c=l>_o||Ao(o,n)},at(r){if(c)return s;const a=Math.min(1,Math.max(0,(r-i)/e));if(1<=a)return s;const l=[];for(const[h,u]of n){const g=o.get(h);if(!g){l.push(u);continue}l.push({id:u.id,kind:u.kind,face:u.face,x:St(g.x,u.x,a),y:St(g.y,u.y,a),width:St(g.width,u.width,a),height:St(g.height,u.height,a)})}return l},reset(){o=n,c=!0}}}const Lo=250;function Io(){let t=null,e=null,o=!1;const n=new WeakMap,s=()=>{e!==null&&(clearTimeout(e),e=null)},i=(g,m)=>{s(),t={x:g,y:m}},c=g=>{i(g.clientX,g.clientY)},r=()=>{s(),e=setTimeout(()=>{e=null,t=null},Lo)},a=g=>{if(!g)return null;const m=n.get(g);if(m&&m.isConnected&&m.contentWindow===g)return m;const p=document.querySelectorAll("iframe");for(const f of Array.from(p))if(f.contentWindow===g)return n.set(g,f),f;return null},l=g=>{if(g)try{g.postMessage({type:"os-pointer-track",enabled:!0},window.location.origin)}catch{}},h=g=>{const m=document.querySelectorAll("iframe");for(const p of Array.from(m))try{p.contentWindow?.postMessage({type:"os-pointer-track",enabled:g},window.location.origin)}catch{}},u=g=>{if(o||g.origin!==window.location.origin)return;const m=g.data;if(!m||typeof m.type!="string")return;if(m.type==="os-bridge-ready"){l(g.source);return}if(m.type!=="os-pointer-move"||typeof m.x!="number"||typeof m.y!="number")return;const p=a(g.source);if(!p)return;const f=p.getBoundingClientRect();i(f.left+m.x,f.top+m.y)};return window.addEventListener("pointermove",c,{capture:!0,passive:!0}),window.addEventListener("pointerdown",c,{capture:!0,passive:!0}),document.documentElement.addEventListener("mouseleave",r),window.addEventListener("message",u),h(!0),{get:()=>t,destroy:()=>{o||(o=!0,s(),window.removeEventListener("pointermove",c,{capture:!0}),window.removeEventListener("pointerdown",c,{capture:!0}),document.documentElement.removeEventListener("mouseleave",r),window.removeEventListener("message",u),h(!1))}}}function Co(t,e,o){const n=(t%360+360)%360,s=Math.min(1,Math.max(0,e)),i=Math.min(1,Math.max(0,o)),c=(1-Math.abs(2*i-1))*s,r=n/60,a=c*(1-Math.abs(r%2-1));let l=0,h=0,u=0;r<1?(l=c,h=a):r<2?(l=a,h=c):r<3?(h=c,u=a):r<4?(h=a,u=c):r<5?(l=a,u=c):(l=c,u=a);const g=i-c/2,m=p=>Math.min(255,Math.max(0,Math.round((p+g)*255)));return m(l)<<16|m(h)<<8|m(u)}function Po(t,e){const o=Math.min(1,Math.max(0,e)),n=t>>16&255,s=t>>8&255,i=t&255,c=r=>Math.round(r+(255-r)*o);return c(n)<<16|c(s)<<8|c(i)}const No=82,To=36,se=6,Bt=Math.PI*2,ie=Math.PI/180;function $o(t,e){return .68*Math.sin(t*Bt*3+e*ie*2)+.32*Math.sin(t*Bt*5-e*ie*1.3)}function re(t,e){const o=t.normals[e%t.normals.length];return o?o.nx*t.tilt.x+o.ny*t.tilt.y:0}function ae(t,e,o,n,s=0){const i=Math.max(1,Math.round(t)),c=n?Math.max(0,o.iridescence):0,r=new Array(i);for(let a=0;a<i;a++){const l=a/i,h=((l-(o.hueAngle+s)/360)%1+1)%1,u=o.hueLoop?.5-.5*Math.cos(h*Bt):h;let g=o.hueStart+o.hueSpan*u+e;const m=.5+.5*Math.cos((l-1/3)*Math.PI*2);let p=o.lightness*(.72+.28*m),f=o.saturation;if(c>0&&n){const d=re(n,a),x=$o(l,e);g+=c*(No*d+To*x);const v=Math.pow(Math.max(0,d),se);p+=c*(.32*v+.07*x),f*=1-Math.min(1,c)*.45*v}r[a]=Co(g,f,p)}return r}function Do(t,e,o){const n=Math.max(1,Math.round(t)),s=Math.max(0,Math.min(1,e.iridescence)),i=new Array(n);for(let c=0;c<n;c++)i[c]=s*Math.pow(Math.max(0,re(o,c)),se);return i}const zo=144,At=.85,Ro=2,Bo=[{from:.07,to:.22,alpha:.34},{from:.22,to:.4,alpha:.24},{from:.4,to:.6,alpha:.15},{from:.6,to:.8,alpha:.08},{from:.8,to:1,alpha:.035}];function Et(t,e){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function Fo(t,e,o=zo){const n=[],s=t.length;if(s<3)return n;const i=Math.max(2,Math.ceil(Math.max(1,o)/s)),c=i%2===0?i:i+1;for(let r=0;r<s;r++){const a=Et(t[(r+s-1)%s],t[r]),l=t[r],h=Et(t[r],t[(r+1)%s]);for(let u=0;u<c;u++){const g=u/c,m=1-g,p=m*m*a.x+2*g*m*l.x+g*g*h.x,f=m*m*a.y+2*g*m*l.y+g*g*h.y;let d=m*(l.x-a.x)+g*(h.x-l.x),x=m*(l.y-a.y)+g*(h.y-l.y),v=Math.hypot(d,x);if(v<1e-6){d=p-e.x,x=f-e.y,v=Math.hypot(d,x)||1,n.push({x:p,y:f,nx:d/v,ny:x/v});continue}let S=-x/v,P=d/v;S*(p-e.x)+P*(f-e.y)<0&&(S=-S,P=-P),n.push({x:p,y:f,nx:S,ny:P})}}return n}function Ft(t,e,o){return{x:2*e.x-(t.x+o.x)/2,y:2*e.y-(t.y+o.y)/2}}function ce(t,e){return{x:t.x+t.nx*e,y:t.y+t.ny*e}}function le(t,e,o,n,s,i,c){const r=Ft(e,o,n),a=Ft(s,i,c);t.moveTo(e.x,e.y),t.quadraticCurveTo(r.x,r.y,n.x,n.y,At),t.lineTo(c.x,c.y),t.quadraticCurveTo(a.x,a.y,s.x,s.y,At),t.closePath()}function Oo(t,e,o,n){const s=e.length;if(s<3||n<=0)return;const i=Et(e[s-1],e[0]);t.moveTo(i.x,i.y);for(let c=0;c<s;c++){const r=e[c],a=Et(e[c],e[(c+1)%s]);t.quadraticCurveTo(r.x,r.y,a.x,a.y,At)}t.closePath(),t.fill({color:o,alpha:n})}function he(t,e,o,n,s,i,c){const r=e.length,a=Math.max(1,Math.round(c)),l=a%2===0?a/2:0;for(let h=0;h<r;h+=a){const u=e[h],g=e[(h+a)%r];if(l>0){const m=e[(h+l)%r];le(t,n(u),n(m),n(g),s(u),s(m),s(g))}else{const m=n(u),p=n(g),f=s(u),d=s(g);t.poly([m.x,m.y,p.x,p.y,d.x,d.y,f.x,f.y])}t.fill({color:o[h%o.length],alpha:i})}}function Ho(t,e,o,n,s,i,c=2){e.length<3||i<=0||n+s<=0||he(t,e,o,r=>ce(r,n),r=>ce(r,-s),i,c)}function ue(t,e,o,n,s,i,c,r,a=2){if(e.length<3||c<=0||s<=0)return;let l=0;for(const p of e)l+=Math.hypot(p.x-o.x,p.y-o.y);const h=l/e.length;if(!(h>.001))return;const u=p=>f=>{const d=Math.max(0,1+p/h);return{x:o.x+(f.x-o.x)*d,y:o.y+(f.y-o.y)*d}},g=s*h,m=de(g,Math.max(1,Math.round(r)));for(let p=0;p<m;p++){const f=c*Math.pow(1-(p+.5)/m,Ro);he(t,e,n,u((p+1)/m*g),u(p===0?-i:p/m*g),f,a)}}function de(t,e){return Math.max(2,Math.min(e,Math.round(t/14)))}const fe={halo:.16,bloom:.075};function pe(t){return{halo:fe.halo*t,bloom:fe.bloom*t}}function Wo(t,e){const o=pe(e),n=(s,i)=>{const c=s*t;return Math.max(2,c/de(c,i)*2)};return{halo:n(o.halo,me),bloom:n(o.bloom,ge)}}const me=10,ge=5;function qo(t,e,o,n,s,i=6){const c=e.length;if(c<3||s<=0)return;const r=Math.max(1,Math.round(i)),a=r%2===0?r/2:0,l=(h,u)=>({x:h.x+(o.x-h.x)*u,y:h.y+(o.y-h.y)*u});for(const h of Bo)for(let u=0;u<c;u+=r){const g=e[u],m=e[(u+r)%c],p=a>0?e[(u+a)%c]:null,f=l(g,h.from),d=l(m,h.from),x=h.to>=1?o:l(g,h.to),v=h.to>=1?o:l(m,h.to);if(p&&h.to>=1){const S=Ft(f,l(p,h.from),d);t.moveTo(f.x,f.y),t.quadraticCurveTo(S.x,S.y,d.x,d.y,At),t.lineTo(o.x,o.y),t.closePath()}else p?le(t,f,l(p,h.from),d,x,l(p,h.to),v):h.to>=1?t.poly([f.x,f.y,d.x,d.y,o.x,o.y]):t.poly([f.x,f.y,d.x,d.y,v.x,v.y,x.x,x.y]);t.fill({color:n[u%n.length],alpha:h.alpha*s})}}function Go(t){let e=1/0,o=-1/0,n=1/0,s=-1/0;for(const i of t)i.x<e&&(e=i.x),i.x>o&&(o=i.x),i.y<n&&(n=i.y),i.y>s&&(s=i.y);return{width:o-e,height:s-n}}function Xo(t,e){const o=t.radius,{width:n,height:s}=Go(t.rim),i=1+.35*(n/(2*o)-1),c=1+.35*(s/(2*o)-1),r=o*e.eyeScale*Ot(c,.4,1.6),a=r*.46;let l=0,h=0;if(t.gaze){const m=t.gaze.x-t.centre.x,p=t.gaze.y-t.centre.y,f=Math.hypot(m,p);if(f>.001){const d=Math.min(1,f/(o*3));l=m/f*d*o*.16,h=p/f*d*o*.13}}const u=o*.28*Ot(i,.5,1.6),g=t.centre.y-o*.02+h;return{left:{x:t.centre.x-u+l,y:g},right:{x:t.centre.x+u+l,y:g},width:a,height:r*(1-Ot(t.blink,0,1)*.94)}}function Ot(t,e,o){return Math.min(o,Math.max(e,t))}function Uo(t,e,o){const{rim:n}=e;if(n.length<3)return;const s=Fo(n,e.centre);if(s.length<3)return;const i={normals:s,tilt:e.tilt},c=o.hueSpin*e.elapsed,r=ae(s.length,o.hueDrift*e.elapsed,o,i,c),a=o.outlineWidth,l=Math.max(1,a*.4),h=v=>{const S=Math.max(2,Math.round(s.length/v));return S%2===0?S:S+1},u=2,g=h(12),m=o.glow;if(t.halo.clear(),t.bloom.clear(),m>0){const v=pe(m);ue(t.halo,s,e.centre,r,v.halo,l,.2,me,g),ue(t.bloom,s,e.centre,r,v.bloom,l,.4,ge,u)}t.body.clear(),Oo(t.body,n,o.bodyColor,o.bodyAlpha),t.sheen.clear();const p=Math.min(1,Math.max(0,o.iridescence));p>0&&qo(t.sheen,s,e.centre,ae(s.length,o.hueDrift*e.elapsed*.6+140,o,{normals:s,tilt:{x:-e.tilt.y,y:e.tilt.x}},c),p,h(8));const f=Do(s.length,o,i),d=r.map((v,S)=>Po(v,.3+.45*f[S]));t.core.clear(),Ho(t.core,s,d,a*.5,a*.5,1,u);const x=Xo(e,o);if(t.eyes.clear(),x.height>.5){for(const v of[x.left,x.right])t.eyes.roundRect(v.x-x.width/2,v.y-x.height/2,x.width,x.height,Math.min(x.width,x.height)/2);t.eyes.fill({color:o.eyeColor,alpha:1})}}function G(t,...e){return{__wpdHtml:!0,strings:t,values:e}}function Ko(t){return!!t&&t.__wpdHtml===!0}const Vo="$$wpd$$",B=/\$\$wpd\$\$(\d+)\$\$/g;function Yo(t){let e=t[0];for(let o=1;o<t.length;o++)e+=`${Vo}${o-1}$$`+t[o];return e}const xe=new WeakMap;function ye(t){const e=xe.get(t);if(e)return e;const o=document.createElement("template");o.innerHTML=Yo(t);const n=[],s=(r,a)=>{if(r.nodeType===Node.ELEMENT_NODE){const u=r;for(const g of Array.from(u.attributes)){const m=g.name,p=g.value,f=m[0];if(B.test(p))if(B.lastIndex=0,f==="@"){const d=B.exec(p);B.lastIndex=0,n.push({path:a,kind:"event",name:m.slice(1),valueIndex:d?Number(d[1]):0}),u.removeAttribute(m)}else if(f==="."){const d=B.exec(p);B.lastIndex=0,n.push({path:a,kind:"prop",name:m.slice(1),valueIndex:d?Number(d[1]):0}),u.removeAttribute(m)}else if(f==="?"){const d=B.exec(p);B.lastIndex=0,n.push({path:a,kind:"bool",name:m.slice(1),valueIndex:d?Number(d[1]):0}),u.removeAttribute(m)}else{const d=[],x=[];let v=0,S;for(B.lastIndex=0;(S=B.exec(p))!==null;)d.push(p.slice(v,S.index)),x.push(Number(S[1])),v=S.index+S[0].length;d.push(p.slice(v)),n.push({path:a,kind:"attr",name:m,template:d,valueIndices:x}),u.setAttribute(m,"")}}}const l=Array.from(r.childNodes);let h=0;for(let u=0;u<l.length;u++){const g=l[u],m=u+h;if(g.nodeType===Node.TEXT_NODE){const p=g.textContent||"";if(!B.test(p)){B.lastIndex=0;continue}B.lastIndex=0;const f=g.parentNode;let d=0,x;const v=[],S=[];for(B.lastIndex=0;(x=B.exec(p))!==null;){x.index>d&&v.push(document.createTextNode(p.slice(d,x.index)));const P=document.createTextNode("");v.push(P),S.push({path:[...a,m+v.length-1],kind:"node",valueIndex:Number(x[1])}),d=x.index+x[0].length}d<p.length&&v.push(document.createTextNode(p.slice(d)));for(const P of v)f.insertBefore(P,g);f.removeChild(g),h+=v.length-1,n.push(...S)}else s(g,[...a,m])}};s(o.content,[]);const c={template:o,buildParts:r=>{const a=[];for(const l of n){let h=r;for(const u of l.path)h=h.childNodes[u];l.kind==="node"?a.push({kind:"node",valueIndex:l.valueIndex,child:{anchor:h,state:null}}):l.kind==="attr"?a.push({kind:"attr",element:h,name:l.name,template:l.template,valueIndices:l.valueIndices}):l.kind==="event"?a.push({kind:"event",valueIndex:l.valueIndex,element:h,name:l.name}):l.kind==="prop"?a.push({kind:"prop",valueIndex:l.valueIndex,element:h,name:l.name}):l.kind==="bool"&&a.push({kind:"bool",valueIndex:l.valueIndex,element:h,name:l.name})}return a}};return xe.set(t,c),c}const be=new WeakMap;function jo(t,e){for(const o of t.nodes)if(o.parentNode!==e)return!1;return!0}function Zo(t,e){const o=be.get(e);if(o&&o.strings===t.strings&&jo(o,e)){Lt(o.parts,t.values);return}const n=ye(t.strings),s=n.template.content.cloneNode(!0),i=n.buildParts(s),c=Array.from(s.childNodes);for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(s),Lt(i,t.values),be.set(e,{strings:t.strings,parts:i,nodes:c})}function Lt(t,e){for(const o of t)if(o.kind==="node")Ht(o.child,e[o.valueIndex]);else if(o.kind==="attr"){let n=o.template[0];for(let s=0;s<o.valueIndices.length;s++)n+=ve(e[o.valueIndices[s]]),n+=o.template[s+1];n!==o.last&&(o.last=n,n===""?o.element.removeAttribute(o.name):o.element.setAttribute(o.name,n))}else if(o.kind==="event"){const n=e[o.valueIndex];n!==o.current&&(o.current&&o.element.removeEventListener(o.name,o.current),n&&o.element.addEventListener(o.name,n),o.current=n)}else if(o.kind==="prop"){const n=e[o.valueIndex];n!==o.last&&(o.last=n,o.element[o.name]=n)}else if(o.kind==="bool"){const n=!!e[o.valueIndex];n!==o.last&&(o.last=n,n?o.element.setAttribute(o.name,""):o.element.removeAttribute(o.name))}}function Ht(t,e){if(e==null||e===!1){t.state&&(ct(t.state),t.state=null);return}if(Array.isArray(e)){en(t,e);return}if(Ko(e)){tn(t,e);return}if(e instanceof Node){Jo(t,e);return}Qo(t,ve(e))}function Jo(t,e){const o=t.state;o?.shape==="node"&&o.node===e||(o&&ct(o),It(t,[e]),t.state={shape:"node",node:e})}function Qo(t,e){const o=t.state;if(o?.shape==="text"){o.text!==e&&(o.node.textContent=e,o.text=e);return}o&&ct(o);const n=document.createTextNode(e);It(t,[n]),t.state={shape:"text",node:n,text:e}}function tn(t,e){const o=t.state;if(o?.shape==="template"&&o.strings===e.strings){Lt(o.parts,e.values);return}o&&ct(o);const n=ye(e.strings),s=n.template.content.cloneNode(!0),i=n.buildParts(s),c=Array.from(s.childNodes);It(t,[s]),Lt(i,e.values),t.state={shape:"template",strings:e.strings,parts:i,nodes:c}}function en(t,e){const o=t.state;if(o?.shape==="array"&&o.entries.length===e.length){for(let s=0;s<e.length;s++)Ht(o.entries[s],e[s]);return}o&&ct(o);const n=[];for(const s of e){const i=document.createTextNode("");It(t,[i]);const c={anchor:i,state:null};Ht(c,s),n.push(c)}t.state={shape:"array",entries:n}}function It(t,e){const o=t.anchor.parentNode;if(o)for(const n of e)o.insertBefore(n,t.anchor)}function ct(t){if(t.shape==="text"){t.node.remove();return}if(t.shape==="template"){for(const e of t.parts)e.kind==="node"&&e.child.state&&(ct(e.child.state),e.child.state=null);for(const e of t.nodes)e.parentNode&&e.parentNode.removeChild(e);return}if(t.shape==="node"){t.node.parentNode&&t.node.parentNode.removeChild(t.node);return}for(const e of t.entries)e.state&&ct(e.state),e.anchor.remove()}function ve(t){return t==null||t===!1?"":String(t)}const ot=class ot extends HTMLElement{constructor(){super(),this._renderScheduled=!1,this._propValues={},this.constructor.shadow?(this.attachShadow({mode:"open"}),this._renderRoot=this.shadowRoot):this._renderRoot=this,this._installPropAccessors()}static get observedAttributes(){return this.props.map(we)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,o,n){if(o===n)return;const s=on(e);this._propValues[s]=n,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(e){if(e==null){this.removeAttribute("class");return}const n=(Array.isArray(e)?e:String(e).split(/\s+/)).map(s=>String(s).trim()).filter(s=>s!=="");this.className=n.join(" ")}requestUpdate(){this._scheduleRender()}emit(e,o){return this.dispatchEvent(new CustomEvent(e,{detail:o,bubbles:!0,composed:!0}))}_installPropAccessors(){const e=this.constructor;for(const o of e.props){if(Object.getOwnPropertyDescriptor(this,o))continue;const n=we(o);Object.defineProperty(this,o,{get:()=>o in this._propValues?this._propValues[o]:this.getAttribute(n),set:s=>{let i;s==null||s===!1?i=null:s===!0?i="":i=String(s),this._propValues[o]=i,i===null?this.removeAttribute(n):this.setAttribute(n,i),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&Zo(this.render(),this._renderRoot)}))}_adoptStyles(){const e=this.constructor;if(e.styles.length!==0)if(e.shadow&&this.shadowRoot){const o=e.styles.map(n=>n.sheet).filter(n=>n!==null);if(this.shadowRoot.adoptedStyleSheets=o,o.length!==e.styles.length){for(const n of e.styles)if(!n.sheet){const s=document.createElement("style");s.textContent=n.cssText,this.shadowRoot.appendChild(s)}}}else this._adoptLightStyles(e)}_adoptLightStyles(e){if(!ot._lightStylesAdopted.has(e)){ot._lightStylesAdopted.add(e);for(const o of e.styles){const n=document.createElement("style");n.dataset.osUi=this.tagName.toLowerCase(),n.textContent=o.cssText,document.head.appendChild(n)}}}};ot.props=[],ot.styles=[],ot.shadow=!0,ot._lightStylesAdopted=new WeakSet;let lt=ot;function mt(t,e){customElements.get(t)||customElements.define(t,e)}function we(t){return t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function on(t){return t.replace(/-([a-z])/g,(e,o)=>o.toUpperCase())}const nn=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function D(t,...e){let o=t[0];for(let n=1;n<t.length;n++){const s=e[n-1];if(typeof s=="string"||typeof s=="number")o+=String(s);else if(s&&s.__wpdCss)o+=s.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof s);o+=t[n]}if(nn){const n=new CSSStyleSheet;return n.replaceSync(o),{__wpdCss:!0,sheet:n,cssText:o}}return{__wpdCss:!0,sheet:null,cssText:o}}const gt=D`:host{--_holo-fill:var( --os-ui-holo-fill,${"linear-gradient( 124deg, #afa2e8 0%, #f5a8ea 46%, #8ee9f7 100% )"} );--_holo-ink:var( --os-ui-holo-ink,#0c0b0f );--_holo-sheen:var( --os-ui-holo-sheen,linear-gradient( 124deg,rgba( 159,214,255,0.1 ) 0%,rgba( 236,155,255,0.12 ) 34%,rgba( 242,82,252,0.1 ) 58%,rgba( 147,240,198,0.09 ) 100% ) );--_holo-edge:var( --os-ui-holo-edge,linear-gradient( 124deg,rgba( 154,242,255,0.7 ) 0%,rgba( 236,155,255,0.85 ) 38%,rgba( 242,82,252,0.7 ) 62%,rgba( 159,152,255,0.6 ) 100% ) );--_holo-edge-quiet:var( --os-ui-holo-edge-quiet,linear-gradient( 124deg,rgba( 154,242,255,0.22 ) 0%,rgba( 236,155,255,0.28 ) 38%,rgba( 242,82,252,0.22 ) 62%,rgba( 159,152,255,0.2 ) 100% ) );--_holo-glow:var( --os-ui-holo-glow,0 0 0 1px rgba( 242,82,252,0.28 ),0 2px 10px rgba( 242,82,252,0.22 ) );--_holo-glow-strong:var( --os-ui-holo-glow-strong,0 0 0 1px rgba( 242,82,252,0.42 ),0 4px 18px rgba( 242,82,252,0.38 ),0 1px 3px rgba( 12,11,15,0.6 ) );--_holo-track:var( --os-ui-holo-track,rgba( 255,251,255,0.16 ) );--_holo-track-edge:var( --os-ui-holo-track-edge,#8c8f94 );--_holo-ring-color:var( --os-ui-accent-dim,#2271b1 );--_holo-focus:var( --os-ui-focus-ring,0 0 0 2px rgba( 12,11,15,0.9 ),0 0 0 4px #f252fc,0 0 12px 2px rgba( 242,82,252,0.45 ) );--_holo-focus-field:var( --os-ui-focus-ring-field,0 0 0 1px #f252fc,0 0 0 4px rgba( 242,82,252,0.18 ) );--_holo-t:var( --os-ui-holo-transition,220ms );--_holo-t-fast:var( --os-ui-motion-fast,140ms );--_holo-t-slow:var( --os-ui-motion-slow,340ms );--_holo-t-ambient:var( --os-ui-motion-ambient,12s );--_holo-spring:var( --os-ui-ease-spring,cubic-bezier( 0.32,1.5,0.55,1 ) );--_holo-ease:var( --os-ui-ease-out,cubic-bezier( 0.22,0.9,0.28,1 ) );--_holo-loop:var( --os-ui-ease-loop,cubic-bezier( 0.45,0,0.55,1 ) )}`,sn=D` .os-holo-fill{background-color:transparent;background-image:var( --_holo-fill );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;color:var( --_holo-ink );transition:background-position var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,filter var( --_holo-t ) ease}.os-holo-fill:hover{background-position:74% 66%}.os-holo-fill:active{background-position:88% 82%;filter:brightness( 0.94 )}@media ( prefers-reduced-motion:reduce ){.os-holo-fill{transition-duration:1ms}.os-holo-fill:hover,.os-holo-fill:active{background-position:22% 28%}}`,rn=D` .os-holo-sheen{position:relative;isolation:isolate}.os-holo-sheen::before{content:'';position:absolute;inset:0;z-index:-1;border-radius:inherit;background-image:var( --_holo-sheen );background-size:200% 200%;background-position:20% 30%;opacity:0;pointer-events:none;transition:opacity var( --_holo-t ) ease,background-position var( --_holo-t ) ease}.os-holo-sheen:hover::before,.os-holo-sheen:focus-visible::before{opacity:1;background-position:76% 68%}@media ( prefers-reduced-motion:reduce ){.os-holo-sheen::before{transition-duration:1ms}.os-holo-sheen:hover::before,.os-holo-sheen:focus-visible::before{background-position:20% 30%}}`,an=D` .os-holo-edge{position:relative}.os-holo-edge::after{content:'';position:absolute;inset:0;border-radius:inherit;padding:1px;background-image:var( --_holo-edge-quiet );opacity:0;pointer-events:none;-webkit-mask:linear-gradient( #000 0 0 ) content-box,linear-gradient( #000 0 0 );-webkit-mask-composite:xor;mask:linear-gradient( #000 0 0 ) content-box,linear-gradient( #000 0 0 );mask-composite:exclude;transition:opacity var( --_holo-t ) ease}.os-holo-edge:hover::after,.os-holo-edge:focus-visible::after{background-image:var( --_holo-edge );opacity:1}.os-holo-edge.is-lit::after{background-image:var( --_holo-edge );opacity:1}@media ( prefers-reduced-motion:reduce ){.os-holo-edge::after{transition-duration:1ms}}`,cn=D` .os-holo-glint{position:absolute;inset:0;border-radius:inherit;overflow:hidden;pointer-events:none}.os-holo-glint::before{content:'';position:absolute;top:-60%;bottom:-60%;width:45%;inset-inline-start:-60%;background:linear-gradient( 90deg,transparent 0%,rgba( 255,251,255,0.14 ) 45%,rgba( 255,251,255,0.22 ) 50%,rgba( 255,251,255,0.14 ) 55%,transparent 100% );transform:rotate( 18deg ) translateX( 0 );opacity:0}:hover>.os-holo-glint::before,:focus-visible>.os-holo-glint::before,:host(:hover )>.os-holo-glint::before,:host(:focus-visible )>.os-holo-glint::before{animation:os-holo-glint var( --_holo-t-slow ) var( --_holo-ease )}@keyframes os-holo-glint{0%{opacity:0;transform:rotate( 18deg ) translateX( 0 )}15%{opacity:1}85%{opacity:1}100%{opacity:0;transform:rotate( 18deg ) translateX( 240vw )}}@media ( prefers-reduced-motion:reduce ){:hover>.os-holo-glint::before,:focus-visible>.os-holo-glint::before,:host(:hover )>.os-holo-glint::before,:host(:focus-visible )>.os-holo-glint::before{animation:none}}`,ln=D` .os-holo-ring{position:absolute;inset:0;border-radius:inherit;box-shadow:0 0 0 0 var( --_holo-ring-color );opacity:0;pointer-events:none}:active:not(:disabled )>.os-holo-ring,:host(:active:not( [ disabled ] ) )>.os-holo-ring{animation:os-holo-ring var( --_holo-t-slow ) var( --_holo-ease )}@keyframes os-holo-ring{0%{opacity:0.45;box-shadow:0 0 0 0 var( --_holo-ring-color )}100%{opacity:0;box-shadow:0 0 0 10px transparent}}@media ( prefers-reduced-motion:reduce ){:active:not(:disabled )>.os-holo-ring,:host(:active:not( [ disabled ] ) )>.os-holo-ring{animation:none}}`,hn=D` .os-holo-shimmer{background-image:var( --_holo-fill );background-size:300% 300%;background-repeat:no-repeat;animation:os-holo-shimmer 2.4s var( --_holo-loop ) infinite}@keyframes os-holo-shimmer{0%{background-position:0% 50%}100%{background-position:100% 50%}}@media ( prefers-reduced-motion:reduce ){.os-holo-shimmer{animation:none;background-position:30% 50%}}`,un=D` .os-holo-enter{animation:os-holo-enter var( --_holo-t ) var( --_holo-spring )}@keyframes os-holo-enter{from{opacity:0;transform:scale( 0.96 )}}@media ( prefers-reduced-motion:reduce ){.os-holo-enter{animation:none}}`,dn=D` input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ),select,textarea{transition:background-color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):hover:not(:disabled ),select:hover:not(:disabled ),textarea:hover:not(:disabled ){border-color:var( --os-ui-border-strong,#8c8f94 )}input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):focus,input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):focus-visible,select:focus,select:focus-visible,textarea:focus,textarea:focus-visible{outline:none;border-color:var( --os-ui-accent,#2271b1 );box-shadow:var( --_holo-focus-field )}input::placeholder,textarea::placeholder{color:var( --os-ui-fg-faint,#8c8f94 );opacity:1}input::selection,textarea::selection{background:var( --os-ui-selection-bg,rgba( 159,152,255,0.6 ) );color:var( --os-ui-selection-fg,#fffbff )}@media ( prefers-reduced-motion:reduce ){input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ),select,textarea{transition-duration:1ms}}`,Me=D` input[ type='checkbox' ],input[ type='radio' ]{appearance:none;-webkit-appearance:none;position:relative;flex:0 0 auto;box-sizing:border-box;width:16px;height:16px;margin:0;padding:0;border:1px solid var( --_holo-track-edge );border-radius:4px;background-color:var( --_holo-track );background-image:none;background-repeat:no-repeat;cursor:inherit;transition:background-color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input[ type='radio' ]{border-radius:50%}input[ type='checkbox' ]:hover:not(:disabled ),input[ type='radio' ]:hover:not(:disabled ){border-color:var( --os-ui-accent,#2271b1 )}input[ type='checkbox' ]:focus-visible,input[ type='radio' ]:focus-visible{outline:none;box-shadow:var( --_holo-focus )}input[ type='checkbox' ]:checked,input[ type='checkbox' ]:indeterminate,input[ type='radio' ]:checked{border-color:transparent;background-color:var( --os-ui-accent,#2271b1 )}input[ type='checkbox' ]:checked:focus-visible,input[ type='radio' ]:checked:focus-visible{box-shadow:var( --_holo-focus )}input[ type='checkbox' ]:checked::after{content:'';position:absolute;inset-inline-start:50%;top:46%;width:3.5px;height:7.5px;border:solid var( --os-ui-fg-on-accent,#fff );border-width:0 2px 2px 0;transform:translate( -50%,-50% ) rotate( 45deg );animation:os-holo-tick 180ms cubic-bezier( 0.3,1.4,0.6,1 )}input[ type='checkbox' ]:indeterminate::after{content:'';position:absolute;inset-inline-start:50%;top:50%;width:8px;height:2px;border:0;border-radius:1px;background:var( --os-ui-fg-on-accent,#fff );transform:translate( -50%,-50% )}input[ type='radio' ]:checked::after{content:'';position:absolute;inset-inline-start:50%;top:50%;width:6px;height:6px;border-radius:50%;background:var( --os-ui-fg-on-accent,#fff );transform:translate( -50%,-50% );animation:os-holo-tick 180ms cubic-bezier( 0.3,1.4,0.6,1 )}input[ type='checkbox' ]:disabled,input[ type='radio' ]:disabled{cursor:not-allowed}@keyframes os-holo-tick{from{opacity:0;transform:translate( -50%,-50% ) rotate( 45deg ) scale( 0.4 )}}@media ( prefers-reduced-motion:reduce ){input[ type='checkbox' ]:checked::after,input[ type='radio' ]:checked::after{animation:none}}`,fn=D` @keyframes os-holo-drift{0%{background-position:16% 26%}50%{background-position:84% 74%}100%{background-position:16% 26%}}.os-holo-alive{animation:os-holo-drift var( --_holo-t-ambient ) var( --_holo-loop ) infinite}@media ( prefers-reduced-motion:reduce ){.os-holo-alive{animation:none}}`;D` ${gt} ${sn} ${rn} ${an} ${cn} ${ln} ${hn} ${un} ${dn} ${Me} ${fn} `;const pn=D` ${gt}:host{display:none;position:fixed;inset:0;align-items:center;justify-content:center;background:var( --os-ui-scrim,rgba( 0,0,0,0.45 ) );background-image:var( --os-ui-scrim-image,none );background-repeat:var( --os-ui-scrim-image-repeat,repeat );background-size:var( --os-ui-scrim-image-size,auto );background-position:var( --os-ui-scrim-image-position,center );backdrop-filter:blur( 2px );z-index:10000;--os-ui-fg:var( --os-ui-modal-text,#f0f0f1 );--os-ui-fg-muted:var( --os-ui-modal-text-muted,#a7aaad );--os-ui-border:var( --os-ui-modal-border,rgba( 255,255,255,0.25 ) );--os-window-bg:var( --os-ui-modal-field-bg,#2c3338 );--os-ui-button-bg-hover:var( --os-ui-modal-button-bg-hover,rgba( 255,255,255,0.08 ) );--os-ui-surface:var( --os-ui-modal-surface,#2c3338 );--os-ui-surface-elevated:var( --os-ui-modal-surface-elevated,#3c434a );--os-ui-border-strong:var( --os-ui-modal-border-strong,rgba( 255,255,255,0.35 ) );--os-ui-hover:var( --os-ui-modal-hover,rgba( 255,255,255,0.08 ) )}:host( [ open ] ){display:flex;animation:os-modal-scrim var( --_holo-t ) var( --_holo-ease )}:host( [ open ] ) .dialog{animation:os-modal-dialog var( --_holo-t ) var( --_holo-spring )}@keyframes os-modal-scrim{from{opacity:0}}@keyframes os-modal-dialog{from{opacity:0;transform:scale( 0.96 ) translateY( 8px )}}@media ( prefers-reduced-motion:reduce ){:host( [ open ] ),:host( [ open ] ) .dialog{animation:none}}.dialog{max-width:92vw;max-height:90vh;background-color:var( --os-ui-modal-bg,#1d2327 );background-image:var( --os-ui-dialog-bg-image,none );background-repeat:var( --os-ui-dialog-bg-image-repeat,repeat );background-size:var( --os-ui-dialog-bg-image-size,auto );background-position:var( --os-ui-dialog-bg-image-position,center );color:var( --os-ui-modal-fg,var( --os-fg,#fff ) );border:1px solid var( --os-ui-border,rgba( 255,255,255,0.08 ) );border-radius:10px;box-shadow:0 20px 50px rgba( 0,0,0,0.6 );display:flex;flex-direction:column;overflow:hidden}:host( [ size='sm' ] ) .dialog{width:min( 360px,92vw )}:host(:not( [ size ] ) ) .dialog,:host( [ size='md' ] ) .dialog{width:min( 540px,92vw )}:host( [ size='lg' ] ) .dialog{width:min( 760px,94vw )}.header{display:flex;align-items:center;gap:10px;padding:16px 20px 12px;border-bottom:1px solid var( --os-ui-border,rgba( 255,255,255,0.06 ) )}.title{margin:0;flex:1;font-size:15px;font-weight:600}.header-actions{display:flex;gap:6px}.header-actions::slotted( * ){margin-inline-start:6px}.close{background:transparent;border:0;color:inherit;font-size:18px;line-height:1;padding:4px 8px;border-radius:4px;cursor:pointer;opacity:0.7}.close:hover{opacity:1;background:var( --os-ui-hover,rgba( 255,255,255,0.08 ) )}.body{padding:16px 20px;overflow:auto;flex:1 1 auto;font-size:13px;line-height:1.5}.footer{padding:12px 20px 16px;border-top:1px solid var( --os-ui-border,rgba( 255,255,255,0.06 ) )}.footer slot{display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap}:host( [ mandatory ] ) .close{display:none}`,ke='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',bt=class bt extends lt{constructor(){super(...arguments),this._prevFocus=null,this._onKey=e=>{if(e.key==="Escape"&&!this.hasAttribute("mandatory")){e.preventDefault(),this._cancel();return}if(e.key==="Tab"){const o=this._focusables();if(o.length===0)return;const n=o[0],s=o[o.length-1],i=this.ownerDocument,c=i?i.activeElement:null,r=e.composedPath()[0]||c;e.shiftKey&&r===n?(e.preventDefault(),s.focus()):!e.shiftKey&&r===s&&(e.preventDefault(),n.focus())}},this._onBackdrop=e=>{if(this.hasAttribute("mandatory"))return;const o=e.composedPath();(o.length>0?o[0]:e.target)===this&&this._cancel()}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this.addEventListener("keydown",this._onKey),this.addEventListener("click",this._onBackdrop)}disconnectedCallback(){this.removeEventListener("keydown",this._onKey),this.removeEventListener("click",this._onBackdrop)}attributeChangedCallback(e,o,n){if(super.attributeChangedCallback?.(e,o,n),e==="open"){if(n!==null){const s=this.ownerDocument;this._prevFocus=s?s.activeElement:null,queueMicrotask(()=>this._focusFirst())}else if(this._prevFocus){try{this._prevFocus.focus()}catch{}this._prevFocus=null}}}showModal(){this.setAttribute("open","")}hideModal(){this.removeAttribute("open")}_focusables(){const e=this.shadowRoot;if(!e)return[];const o=Array.from(this.querySelectorAll(ke)),n=Array.from(e.querySelectorAll(ke));return[...o,...n].filter(s=>s.offsetParent!==null||s.tagName==="BUTTON")}_focusFirst(){const e=this._focusables();e.length>0?e[0].focus():this.shadowRoot?.querySelector(".dialog")?.focus?.()}_cancel(){const e=new CustomEvent("os-modal-cancel",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e)&&this.hideModal()}render(){const e=this.getAttribute("title")??"",o=this.hasAttribute("mandatory");return G`
1 +(function(){"use strict";function Co(){const t=window.wp?.hooks;if(!t)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 t}function lt(t,...e){Co().doAction(t,...e)}function Lo(t,e,o){(t.screen.width!==e.width||t.screen.height!==e.height)&&t.renderer.resize(e.width,e.height),o(),t.render()}function Io(t,e,o,n){const s=e?1:0;return n?s:t+(s-t)*(1-Math.exp(-Math.max(0,o)*7))}function $o(t,e,o,n){if(o<=.001)return{frame:t,appearance:e};const s=t.elapsed*Math.PI*2/2.8,i=n?-.5:Math.sin(s),r=n?0:(1-Math.cos(s*2))/2,a=o*i*.14,c=1+o*r*.055,l=Math.cos(a),u=Math.sin(a),d=t.rim.map(v=>{const _=(v.x-t.centre.x)*c,$=(v.y-t.centre.y)*c;return{...v,x:t.centre.x+_*l-$*u,y:t.centre.y+_*u+$*l}}),f=t.gaze??t.centre,g=f.x-t.centre.x,p=f.y-t.centre.y,m=Math.min(1,t.radius*3/(Math.hypot(g,p)||1)),h={x:t.centre.x+g*m,y:t.centre.y+p*m},x={x:t.centre.x+t.radius*i*2.5,y:t.centre.y-t.radius*3};return{frame:{...t,rim:d,faceTilt:a,gaze:{x:h.x+(x.x-h.x)*o,y:h.y+(x.y-h.y)*o},blink:Math.max(t.blink,o*(.3+r*.22))},appearance:{...e,glow:e.glow*(1+o*(.08+r*.12)),hueAngle:e.hueAngle+o*(35+i*50)}}}const qt=new Set(["window","widget"]),pe=new Set(["dock","shell"]),me=new Set(["dock"]);function Po(t){return t.filter(e=>pe.has(e.kind))}function No(t,e,o){const n=[];for(const s of t){const i=s.rect;if(!i||i.width<=0||i.height<=0)continue;let r=i.x-e.left,a=i.y-e.top,c=i.width,l=i.height;o&&pe.has(s.kind)&&(s.face==="right"?(c=r+c,r=0):s.face==="left"?c=Math.max(c,o.width-r):s.face==="top"?l=Math.max(l,o.height-a):(l=a+l,a=0)),n.push({id:s.id,kind:s.kind,face:s.face,x:r,y:a,width:c,height:l})}return n}function To(t,e,o){let{x:n,y:s}=t;for(const i of o)me.has(i.kind)&&(n<=i.x-e||n>=i.x+i.width+e||s<=i.y-e||s>=i.y+i.height+e||({x:n,y:s}=ge(i,n,s,e)));return{x:n,y:s}}function ge(t,e,o,n){return t.face==="right"?{x:t.x+t.width+n,y:o}:t.face==="left"?{x:t.x-n,y:o}:t.face==="top"?{x:e,y:t.y-n}:{x:e,y:t.y+t.height+n}}function zo(t,e,o){const n=Math.max(o.x-t,0,t-(o.x+o.width)),s=Math.max(o.y-e,0,e-(o.y+o.height));return Math.hypot(n,s)}function Do(t,e,o){return{x:Math.min(Math.max(t,o.x),o.x+o.width),y:Math.min(Math.max(e,o.y),o.y+o.height)}}function Ro(t,e,o,n,s){if(s<=0)return null;let i=null,r=1/0;for(const p of n){if(!qt.has(p.kind))continue;const m=zo(t,e,p);m<r&&(r=m,i=p)}if(!i)return null;const a=r-o;if(a>=s)return null;const c=1-Math.max(a,0)/s,l=c*c*(3-2*c),u=Do(t,e,i),d=u.x-t,f=u.y-e,g=Math.hypot(d,f);return g<.001?{dx:0,dy:0,strength:l,gap:a}:{dx:d/g,dy:f/g,strength:l,gap:a}}function Fo(t,e,o=8){let n=t.x,s=t.y,i=t.x+t.width,r=t.y+t.height;const a=e.filter(l=>qt.has(l.kind)&&l!==t);let c=!0;for(;c;){c=!1;for(let l=a.length-1;l>=0;l--){const u=a[l];u.x<i+o&&u.x+u.width>n-o&&u.y<r+o&&u.y+u.height>s-o&&(n=Math.min(n,u.x),s=Math.min(s,u.y),i=Math.max(i,u.x+u.width),r=Math.max(r,u.y+u.height),a.splice(l,1),c=!0)}}return{x:n,y:s,width:i-n,height:r-s}}const Oo=.75;function Bo(t,e,o,n,s){for(const m of n){if(!me.has(m.kind)||t<=m.x||t>=m.x+m.width||e<=m.y||e>=m.y+m.height)continue;const h=ge(m,t,e,o+8);return{x:Math.min(Math.max(h.x,o),Math.max(o,s.width-o)),y:Math.min(Math.max(h.y,o),Math.max(o,s.height-o))}}const i=o*Oo;let r=null,a=i;for(const m of n){if(!qt.has(m.kind))continue;const h=Math.min(t-m.x,m.x+m.width-t,e-m.y,m.y+m.height-e);h>a&&(a=h,r=m)}if(!r)return null;const c=Fo(r,n),l=o+8,u=c.x+c.width/2,d=c.y+c.height/2,f=[{x:u,y:c.y-l},{x:u,y:c.y+c.height+l},{x:c.x-l,y:d},{x:c.x+c.width+l,y:d}].filter(m=>m.x>=o&&m.y>=o&&m.x<=s.width-o&&m.y<=s.height-o);if(f.length>0){let m=f[0],h=1/0;for(const x of f){const v=Math.hypot(x.x-t,x.y-e);v<h&&(h=v,m=x)}return m}const p=[{size:c.y,x:u,y:c.y/2},{size:s.height-(c.y+c.height),x:u,y:(c.y+c.height+s.height)/2},{size:c.x,x:c.x/2,y:d},{size:s.width-(c.x+c.width),x:(c.x+c.width+s.width)/2,y:d}].sort((m,h)=>h.size-m.size)[0];return p&&p.size>=o?{x:p.x,y:p.y}:{x:s.width/2,y:s.height/2}}function Wo(t,e,o,n){let s=!1;for(const i of e){const r=i.x+i.width,a=i.y+i.height;if(t.x<=i.x||t.x>=r||t.y<=i.y||t.y>=a)continue;const c=t.x-i.x,l=r-t.x,u=t.y-i.y,d=a-t.y,f=Math.min(c,l,u,d);s=!0,f===u?(t.y=i.y,t.vy>0&&(t.vy=-t.vy*o),t.vx*=n):f===d?(t.y=a,t.vy<0&&(t.vy=-t.vy*o),t.vx*=n):f===c?(t.x=i.x,t.vx>0&&(t.vx=-t.vx*o),t.vy*=n):(t.x=r,t.vx<0&&(t.vx=-t.vx*o),t.vy*=n)}return s}function Ho(t,e,o,n,s){let i=!1;return t.x<0?(t.x=0,t.vx<0&&(t.vx=-t.vx*n),t.vy*=s,i=!0):t.x>e&&(t.x=e,t.vx>0&&(t.vx=-t.vx*n),t.vy*=s,i=!0),t.y<0?(t.y=0,t.vy<0&&(t.vy=-t.vy*n),t.vx*=s,i=!0):t.y>o&&(t.y=o,t.vy>0&&(t.vy=-t.vy*n),t.vx*=s,i=!0),i}const qo=250;function Go(t){const e=new Map,o=new Map;for(const n of t){const s=o.get(n.id)??0;o.set(n.id,s+1),e.set(s===0?n.id:`${n.id}#${s}`,n)}return e}function Xo(t,e){if(t.size!==e.size)return!1;for(const[o,n]of t){const s=e.get(o);if(!s||s.x!==n.x||s.y!==n.y||s.width!==n.width||s.height!==n.height)return!1}return!0}function $t(t,e,o){return t+(e-t)*o}function Ko(t){const e=Math.max(1,t);let o=new Map,n=new Map,s=[],i=0,r=!0;return{sample(a,c){const l=c-i;o=n,n=Go(a),s=a,i=c,r=l>qo||Xo(o,n)},at(a){if(r)return s;const c=Math.min(1,Math.max(0,(a-i)/e));if(1<=c)return s;const l=[];for(const[u,d]of n){const f=o.get(u);if(!f){l.push(d);continue}l.push({id:d.id,kind:d.kind,face:d.face,x:$t(f.x,d.x,c),y:$t(f.y,d.y,c),width:$t(f.width,d.width,c),height:$t(f.height,d.height,c)})}return l},reset(){o=n,r=!0}}}const Uo=250;function Vo(){let t=null,e=null,o=!1;const n=new WeakMap,s=()=>{e!==null&&(clearTimeout(e),e=null)},i=(f,g)=>{s(),t={x:f,y:g}},r=f=>{i(f.clientX,f.clientY)},a=()=>{s(),e=setTimeout(()=>{e=null,t=null},Uo)},c=f=>{if(!f)return null;const g=n.get(f);if(g&&g.isConnected&&g.contentWindow===f)return g;const p=document.querySelectorAll("iframe");for(const m of Array.from(p))if(m.contentWindow===f)return n.set(f,m),m;return null},l=f=>{if(f)try{f.postMessage({type:"os-pointer-track",enabled:!0},window.location.origin)}catch{}},u=f=>{const g=document.querySelectorAll("iframe");for(const p of Array.from(g))try{p.contentWindow?.postMessage({type:"os-pointer-track",enabled:f},window.location.origin)}catch{}},d=f=>{if(o||f.origin!==window.location.origin)return;const g=f.data;if(!g||typeof g.type!="string")return;if(g.type==="os-bridge-ready"){l(f.source);return}if(g.type!=="os-pointer-move"||typeof g.x!="number"||typeof g.y!="number")return;const p=c(f.source);if(!p)return;const m=p.getBoundingClientRect();i(m.left+g.x,m.top+g.y)};return window.addEventListener("pointermove",r,{capture:!0,passive:!0}),window.addEventListener("pointerdown",r,{capture:!0,passive:!0}),document.documentElement.addEventListener("mouseleave",a),window.addEventListener("message",d),u(!0),{get:()=>t,destroy:()=>{o||(o=!0,s(),window.removeEventListener("pointermove",r,{capture:!0}),window.removeEventListener("pointerdown",r,{capture:!0}),document.documentElement.removeEventListener("mouseleave",a),window.removeEventListener("message",d),u(!1))}}}function Yo(t,e,o){const n=(t%360+360)%360,s=Math.min(1,Math.max(0,e)),i=Math.min(1,Math.max(0,o)),r=(1-Math.abs(2*i-1))*s,a=n/60,c=r*(1-Math.abs(a%2-1));let l=0,u=0,d=0;a<1?(l=r,u=c):a<2?(l=c,u=r):a<3?(u=r,d=c):a<4?(u=c,d=r):a<5?(l=c,d=r):(l=r,d=c);const f=i-r/2,g=p=>Math.min(255,Math.max(0,Math.round((p+f)*255)));return g(l)<<16|g(u)<<8|g(d)}function jo(t,e){const o=Math.min(1,Math.max(0,e)),n=t>>16&255,s=t>>8&255,i=t&255,r=a=>Math.round(a+(255-a)*o);return r(n)<<16|r(s)<<8|r(i)}const Zo=82,Jo=36,xe=6,Gt=Math.PI*2,ye=Math.PI/180;function Qo(t,e){return .68*Math.sin(t*Gt*3+e*ye*2)+.32*Math.sin(t*Gt*5-e*ye*1.3)}function be(t,e){const o=t.normals[e%t.normals.length];return o?o.nx*t.tilt.x+o.ny*t.tilt.y:0}function ve(t,e,o,n,s=0){const i=Math.max(1,Math.round(t)),r=n?Math.max(0,o.iridescence):0,a=new Array(i);for(let c=0;c<i;c++){const l=c/i,u=((l-(o.hueAngle+s)/360)%1+1)%1,d=o.hueLoop?.5-.5*Math.cos(u*Gt):u;let f=o.hueStart+o.hueSpan*d+e;const g=.5+.5*Math.cos((l-1/3)*Math.PI*2);let p=o.lightness*(.72+.28*g),m=o.saturation;if(r>0&&n){const h=be(n,c),x=Qo(l,e);f+=r*(Zo*h+Jo*x);const v=Math.pow(Math.max(0,h),xe);p+=r*(.32*v+.07*x),m*=1-Math.min(1,r)*.45*v}a[c]=Yo(f,m,p)}return a}function tn(t,e,o){const n=Math.max(1,Math.round(t)),s=Math.max(0,Math.min(1,e.iridescence)),i=new Array(n);for(let r=0;r<n;r++)i[r]=s*Math.pow(Math.max(0,be(o,r)),xe);return i}const en=144,Pt=.85,on=2,nn=[{from:.07,to:.22,alpha:.34},{from:.22,to:.4,alpha:.24},{from:.4,to:.6,alpha:.15},{from:.6,to:.8,alpha:.08},{from:.8,to:1,alpha:.035}];function Nt(t,e){return{x:(t.x+e.x)/2,y:(t.y+e.y)/2}}function sn(t,e,o=en){const n=[],s=t.length;if(s<3)return n;const i=Math.max(2,Math.ceil(Math.max(1,o)/s)),r=i%2===0?i:i+1;for(let a=0;a<s;a++){const c=Nt(t[(a+s-1)%s],t[a]),l=t[a],u=Nt(t[a],t[(a+1)%s]);for(let d=0;d<r;d++){const f=d/r,g=1-f,p=g*g*c.x+2*f*g*l.x+f*f*u.x,m=g*g*c.y+2*f*g*l.y+f*f*u.y;let h=g*(l.x-c.x)+f*(u.x-l.x),x=g*(l.y-c.y)+f*(u.y-l.y),v=Math.hypot(h,x);if(v<1e-6){h=p-e.x,x=m-e.y,v=Math.hypot(h,x)||1,n.push({x:p,y:m,nx:h/v,ny:x/v});continue}let _=-x/v,$=h/v;_*(p-e.x)+$*(m-e.y)<0&&(_=-_,$=-$),n.push({x:p,y:m,nx:_,ny:$})}}return n}function Xt(t,e,o){return{x:2*e.x-(t.x+o.x)/2,y:2*e.y-(t.y+o.y)/2}}function we(t,e){return{x:t.x+t.nx*e,y:t.y+t.ny*e}}function Me(t,e,o,n,s,i,r){const a=Xt(e,o,n),c=Xt(s,i,r);t.moveTo(e.x,e.y),t.quadraticCurveTo(a.x,a.y,n.x,n.y,Pt),t.lineTo(r.x,r.y),t.quadraticCurveTo(c.x,c.y,s.x,s.y,Pt),t.closePath()}function rn(t,e,o,n){const s=e.length;if(s<3||n<=0)return;const i=Nt(e[s-1],e[0]);t.moveTo(i.x,i.y);for(let r=0;r<s;r++){const a=e[r],c=Nt(e[r],e[(r+1)%s]);t.quadraticCurveTo(a.x,a.y,c.x,c.y,Pt)}t.closePath(),t.fill({color:o,alpha:n})}function ke(t,e,o,n,s,i,r){const a=e.length,c=Math.max(1,Math.round(r)),l=c%2===0?c/2:0;for(let u=0;u<a;u+=c){const d=e[u],f=e[(u+c)%a];if(l>0){const g=e[(u+l)%a];Me(t,n(d),n(g),n(f),s(d),s(g),s(f))}else{const g=n(d),p=n(f),m=s(d),h=s(f);t.poly([g.x,g.y,p.x,p.y,h.x,h.y,m.x,m.y])}t.fill({color:o[u%o.length],alpha:i})}}function _e(t,e,o,n,s,i,r=2){e.length<3||i<=0||n+s<=0||ke(t,e,o,a=>we(a,n),a=>we(a,-s),i,r)}function an(t,e,o,n,s,i=2){n<=0||_e(t,e,[o],-s*.5,s*.5+n,1,i)}function Ae(t,e,o,n,s,i,r,a,c=2){if(e.length<3||r<=0||s<=0)return;let l=0;for(const p of e)l+=Math.hypot(p.x-o.x,p.y-o.y);const u=l/e.length;if(!(u>.001))return;const d=p=>m=>{const h=Math.max(0,1+p/u);return{x:o.x+(m.x-o.x)*h,y:o.y+(m.y-o.y)*h}},f=s*u,g=Ee(f,Math.max(1,Math.round(a)));for(let p=0;p<g;p++){const m=r*Math.pow(1-(p+.5)/g,on);ke(t,e,n,d((p+1)/g*f),d(p===0?-i:p/g*f),m,c)}}function Ee(t,e){return Math.max(2,Math.min(e,Math.round(t/14)))}const Se={halo:.16,bloom:.075};function Ce(t){return{halo:Se.halo*t,bloom:Se.bloom*t}}function cn(t,e){const o=Ce(e),n=(s,i)=>{const r=s*t;return Math.max(2,r/Ee(r,i)*2)};return{halo:n(o.halo,Le),bloom:n(o.bloom,Ie)}}const Le=10,Ie=5;function ln(t,e,o,n,s,i=6){const r=e.length;if(r<3||s<=0)return;const a=Math.max(1,Math.round(i)),c=a%2===0?a/2:0,l=(u,d)=>({x:u.x+(o.x-u.x)*d,y:u.y+(o.y-u.y)*d});for(const u of nn)for(let d=0;d<r;d+=a){const f=e[d],g=e[(d+a)%r],p=c>0?e[(d+c)%r]:null,m=l(f,u.from),h=l(g,u.from),x=u.to>=1?o:l(f,u.to),v=u.to>=1?o:l(g,u.to);if(p&&u.to>=1){const _=Xt(m,l(p,u.from),h);t.moveTo(m.x,m.y),t.quadraticCurveTo(_.x,_.y,h.x,h.y,Pt),t.lineTo(o.x,o.y),t.closePath()}else p?Me(t,m,l(p,u.from),h,x,l(p,u.to),v):u.to>=1?t.poly([m.x,m.y,h.x,h.y,o.x,o.y]):t.poly([m.x,m.y,h.x,h.y,v.x,v.y,x.x,x.y]);t.fill({color:n[d%n.length],alpha:u.alpha*s})}}function dn(t){let e=1/0,o=-1/0,n=1/0,s=-1/0;for(const i of t)i.x<e&&(e=i.x),i.x>o&&(o=i.x),i.y<n&&(n=i.y),i.y>s&&(s=i.y);return{width:o-e,height:s-n}}function un(t,e){const o=t.radius,{width:n,height:s}=dn(t.rim),i=1+.35*(n/(2*o)-1),r=1+.35*(s/(2*o)-1),a=o*e.eyeScale*Kt(r,.4,1.6),c=a*.46;let l=0,u=0;if(t.gaze){const x=t.gaze.x-t.centre.x,v=t.gaze.y-t.centre.y,_=Math.hypot(x,v);if(_>.001){const $=Math.min(1,_/(o*3));l=x/_*$*o*.16,u=v/_*$*o*.13}}const d=o*.28*Kt(i,.5,1.6),f=-o*.02+u,g=t.faceTilt??0,p=Math.cos(g),m=Math.sin(g),h=x=>({x:t.centre.x+x*p-f*m,y:t.centre.y+x*m+f*p});return{left:h(-d+l),right:h(d+l),width:c,height:a*(1-Kt(t.blink,0,1)*.94)}}function Kt(t,e,o){return Math.min(o,Math.max(e,t))}function hn(t,e,o){const{rim:n}=e;if(n.length<3)return;const s=sn(n,e.centre);if(s.length<3)return;const i={normals:s,tilt:e.tilt},r=o.hueSpin*e.elapsed,a=ve(s.length,o.hueDrift*e.elapsed,o,i,r),c=o.outlineWidth,l=Math.max(1,c*.4),u=v=>{const _=Math.max(2,Math.round(s.length/v));return _%2===0?_:_+1},d=2,f=u(12),g=o.glow;if(t.halo.clear(),t.bloom.clear(),g>0){const v=Ce(g);Ae(t.halo,s,e.centre,a,v.halo,l,.2,Le,f),Ae(t.bloom,s,e.centre,a,v.bloom,l,.4,Ie,d)}t.body.clear(),rn(t.body,n,o.bodyColor,o.bodyAlpha),t.sheen.clear();const p=Math.min(1,Math.max(0,o.iridescence));p>0&&ln(t.sheen,s,e.centre,ve(s.length,o.hueDrift*e.elapsed*.6+140,o,{normals:s,tilt:{x:-e.tilt.y,y:e.tilt.x}},r),p,u(8)),t.liner.clear(),an(t.liner,s,o.linerColor,o.linerWidth,c,d);const m=tn(s.length,o,i),h=a.map((v,_)=>jo(v,.3+.45*m[_]));t.core.clear(),_e(t.core,s,h,c*.5,c*.5,1,d);const x=un(e,o);if(t.eyes.clear(),x.height>.5){for(const v of[x.left,x.right])t.eyes.roundRect(v.x-x.width/2,v.y-x.height/2,x.width,x.height,Math.min(x.width,x.height)/2);t.eyes.fill({color:o.eyeColor,alpha:1})}}function G(t,...e){return{__wpdHtml:!0,strings:t,values:e}}function fn(t){return!!t&&t.__wpdHtml===!0}const pn="$$wpd$$",U=/\$\$wpd\$\$(\d+)\$\$/g,mn="$$wpd-node$$",gn=/^\$\$wpd-node\$\$(\d+)\$\$$/,xn=new Set(["style","script","textarea","title"]);function yn(t){let e="",o=!1,n=null,s=!1,i=null,r="",a=!1;for(let c=0;c<t.length;c++){const l=t[c];e+=l;for(let u=0;u<l.length;u++){const d=l[u];if(s){l.startsWith("-->",u)&&(s=!1,u+=2);continue}if(i!==null){d==="<"&&l[u+1]==="/"&&l.slice(u+2,u+2+i.length).toLowerCase()===i&&(u+=1+i.length,i=null,o=!0,a=!1,r="");continue}if(n!==null){d===n&&(n=null);continue}if(o){d==='"'||d==="'"?(n=d,a=!1):d===">"?(o=!1,a=!1,xn.has(r)&&(i=r),r=""):a&&(/[a-zA-Z0-9-]/.test(d)?r+=d.toLowerCase():a=!1);continue}if(l.startsWith("<!--",u)){s=!0,u+=3;continue}const f=l[u+1]??"";d==="<"&&/[a-zA-Z/!]/.test(f)&&(o=!0,r="",a=/[a-zA-Z]/.test(f))}c<t.length-1&&(e+=o||s||i!==null?`${pn}${c}$$`:`<!--${mn}${c}$$-->`)}return e}const $e=new WeakMap;function Pe(t){const e=$e.get(t);if(e)return e;const o=document.createElement("template");o.innerHTML=yn(t);const n=[],s=(a,c)=>{if(a.nodeType===Node.ELEMENT_NODE){const d=a;for(const f of Array.from(d.attributes)){const g=f.name,p=f.value,m=g[0];if(U.test(p))if(U.lastIndex=0,m==="@"){const h=U.exec(p);U.lastIndex=0,n.push({path:c,kind:"event",name:g.slice(1),valueIndex:h?Number(h[1]):0}),d.removeAttribute(g)}else if(m==="."){const h=U.exec(p);U.lastIndex=0,n.push({path:c,kind:"prop",name:g.slice(1),valueIndex:h?Number(h[1]):0}),d.removeAttribute(g)}else if(m==="?"){const h=U.exec(p);U.lastIndex=0,n.push({path:c,kind:"bool",name:g.slice(1),valueIndex:h?Number(h[1]):0}),d.removeAttribute(g)}else{const h=[],x=[];let v=0,_;for(U.lastIndex=0;(_=U.exec(p))!==null;)h.push(p.slice(v,_.index)),x.push(Number(_[1])),v=_.index+_[0].length;h.push(p.slice(v)),n.push({path:c,kind:"attr",name:g,template:h,valueIndices:x}),d.setAttribute(g,"")}}}const l=Array.from(a.childNodes);let u=0;for(let d=0;d<l.length;d++){const f=l[d],g=d+u;if(f.nodeType===Node.COMMENT_NODE){const p=gn.exec(f.data);if(p){const m=document.createTextNode("");f.parentNode.replaceChild(m,f),n.push({path:[...c,g],kind:"node",valueIndex:Number(p[1])})}continue}if(f.nodeType===Node.TEXT_NODE){const p=f.textContent||"";if(!U.test(p)){U.lastIndex=0;continue}U.lastIndex=0;const m=f.parentNode;let h=0,x;const v=[],_=[];for(U.lastIndex=0;(x=U.exec(p))!==null;){x.index>h&&v.push(document.createTextNode(p.slice(h,x.index)));const $=document.createTextNode("");v.push($),_.push({path:[...c,g+v.length-1],kind:"node",valueIndex:Number(x[1])}),h=x.index+x[0].length}h<p.length&&v.push(document.createTextNode(p.slice(h)));for(const $ of v)m.insertBefore($,f);m.removeChild(f),u+=v.length-1,n.push(..._)}else s(f,[...c,g])}};s(o.content,[]);const r={template:o,buildParts:a=>{const c=[];for(const l of n){let u=a;for(const d of l.path)u=u.childNodes[d];l.kind==="node"?c.push({kind:"node",valueIndex:l.valueIndex,child:{anchor:u,state:null}}):l.kind==="attr"?c.push({kind:"attr",element:u,name:l.name,template:l.template,valueIndices:l.valueIndices}):l.kind==="event"?c.push({kind:"event",valueIndex:l.valueIndex,element:u,name:l.name}):l.kind==="prop"?c.push({kind:"prop",valueIndex:l.valueIndex,element:u,name:l.name}):l.kind==="bool"&&c.push({kind:"bool",valueIndex:l.valueIndex,element:u,name:l.name})}return c}};return $e.set(t,r),r}const Ne=new WeakMap;function bn(t,e){for(const o of t.nodes)if(o.parentNode!==e)return!1;return!0}function vn(t,e){const o=Ne.get(e);if(o&&o.strings===t.strings&&bn(o,e)){Tt(o.parts,t.values);return}const n=Pe(t.strings),s=n.template.content.cloneNode(!0),i=n.buildParts(s),r=Array.from(s.childNodes);for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(s),Tt(i,t.values),Ne.set(e,{strings:t.strings,parts:i,nodes:r})}function Tt(t,e){for(const o of t)if(o.kind==="node")zt(o.child,e[o.valueIndex]);else if(o.kind==="attr"){let n=o.template[0];for(let s=0;s<o.valueIndices.length;s++)n+=Te(e[o.valueIndices[s]]),n+=o.template[s+1];n!==o.last&&(o.last=n,n===""?o.element.removeAttribute(o.name):o.element.setAttribute(o.name,n))}else if(o.kind==="event"){const n=e[o.valueIndex];n!==o.current&&(o.current&&o.element.removeEventListener(o.name,o.current),n&&o.element.addEventListener(o.name,n),o.current=n)}else if(o.kind==="prop"){const n=e[o.valueIndex];n!==o.last&&(o.last=n,o.element[o.name]=n)}else if(o.kind==="bool"){const n=!!e[o.valueIndex];n!==o.last&&(o.last=n,n?o.element.setAttribute(o.name,""):o.element.removeAttribute(o.name))}}function zt(t,e){if(e==null||e===!1){t.state&&(st(t.state),t.state=null);return}if(Array.isArray(e)){_n(t,e);return}if(fn(e)){kn(t,e);return}if(e instanceof Node){wn(t,e);return}Mn(t,Te(e))}function wn(t,e){const o=t.state;o?.shape==="node"&&o.node===e||(o&&st(o),yt(t,[e]),t.state={shape:"node",node:e})}function Mn(t,e){const o=t.state;if(o?.shape==="text"){o.text!==e&&(o.node.textContent=e,o.text=e);return}o&&st(o);const n=document.createTextNode(e);yt(t,[n]),t.state={shape:"text",node:n,text:e}}function kn(t,e){const o=t.state;if(o?.shape==="template"&&o.strings===e.strings){Tt(o.parts,e.values);return}o&&st(o);const n=Pe(e.strings),s=n.template.content.cloneNode(!0),i=n.buildParts(s),r=Array.from(s.childNodes);yt(t,[s]),Tt(i,e.values),t.state={shape:"template",strings:e.strings,parts:i,nodes:r}}function _n(t,e){const o=t.state;if(o?.shape==="array"){const s=Math.min(o.entries.length,e.length);for(let i=0;i<s;i++)zt(o.entries[i],e[i]);if(e.length<o.entries.length){for(let i=e.length;i<o.entries.length;i++){const r=o.entries[i];r.state&&st(r.state),r.anchor.remove()}o.entries.length=e.length}else for(let i=o.entries.length;i<e.length;i++){const r=document.createTextNode("");yt(t,[r]);const a={anchor:r,state:null};zt(a,e[i]),o.entries.push(a)}return}o&&st(o);const n=[];for(const s of e){const i=document.createTextNode("");yt(t,[i]);const r={anchor:i,state:null};zt(r,s),n.push(r)}t.state={shape:"array",entries:n}}function yt(t,e){const o=t.anchor.parentNode;if(o)for(const n of e)o.insertBefore(n,t.anchor)}function st(t){if(t.shape==="text"){t.node.remove();return}if(t.shape==="template"){for(const e of t.parts)e.kind==="node"&&e.child.state&&(st(e.child.state),e.child.state=null);for(const e of t.nodes)e.parentNode&&e.parentNode.removeChild(e);return}if(t.shape==="node"){t.node.parentNode&&t.node.parentNode.removeChild(t.node);return}for(const e of t.entries)e.state&&st(e.state),e.anchor.remove()}function Te(t){return t==null||t===!1?"":String(t)}const it=class it extends HTMLElement{constructor(){super(),this._renderScheduled=!1,this._propValues={},this.constructor.shadow?(this.attachShadow({mode:"open"}),this._renderRoot=this.shadowRoot):this._renderRoot=this,this._installPropAccessors()}static get observedAttributes(){return this.props.map(ze)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,o,n){if(o===n)return;const s=An(e);this._propValues[s]=n,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(e){if(e==null){this.removeAttribute("class");return}const n=(Array.isArray(e)?e:String(e).split(/\s+/)).map(s=>String(s).trim()).filter(s=>s!=="");this.className=n.join(" ")}requestUpdate(){this._scheduleRender()}emit(e,o){return this.dispatchEvent(new CustomEvent(e,{detail:o,bubbles:!0,composed:!0}))}_installPropAccessors(){const e=this.constructor;for(const o of e.props){if(Object.getOwnPropertyDescriptor(this,o))continue;const n=ze(o);Object.defineProperty(this,o,{get:()=>o in this._propValues?this._propValues[o]:this.getAttribute(n),set:s=>{let i;s==null||s===!1?i=null:s===!0?i="":i=String(s),this._propValues[o]=i,i===null?this.removeAttribute(n):this.setAttribute(n,i),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&vn(this.render(),this._renderRoot)}))}_adoptStyles(){const e=this.constructor;if(e.styles.length!==0)if(e.shadow&&this.shadowRoot){const o=e.styles.map(n=>n.sheet).filter(n=>n!==null);if(this.shadowRoot.adoptedStyleSheets=o,o.length!==e.styles.length){for(const n of e.styles)if(!n.sheet){const s=document.createElement("style");s.textContent=n.cssText,this.shadowRoot.appendChild(s)}}}else this._adoptLightStyles(e)}_adoptLightStyles(e){if(!it._lightStylesAdopted.has(e)){it._lightStylesAdopted.add(e);for(const o of e.styles){const n=document.createElement("style");n.dataset.osUi=this.tagName.toLowerCase(),n.textContent=o.cssText,document.head.appendChild(n)}}}};it.props=[],it.styles=[],it.shadow=!0,it._lightStylesAdopted=new WeakSet;let ot=it;function dt(t,e){customElements.get(t)||customElements.define(t,e)}function ze(t){return t.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function An(t){return t.replace(/-([a-z])/g,(e,o)=>o.toUpperCase())}const En=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function F(t,...e){let o=t[0];for(let n=1;n<t.length;n++){const s=e[n-1];if(typeof s=="string"||typeof s=="number")o+=String(s);else if(s&&s.__wpdCss)o+=s.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof s);o+=t[n]}if(En){const n=new CSSStyleSheet;return n.replaceSync(o),{__wpdCss:!0,sheet:n,cssText:o}}return{__wpdCss:!0,sheet:null,cssText:o}}function Sn(t){const e=[],o=[];let n=null,s=t.parentElement;for(;s&&!(s===document.body||s===document.documentElement);){const r=s.id||"";if(r.startsWith("wp-window-")){n=r.slice(10);break}if(s.tagName.toLowerCase()==="os-tabpanel"){const a=s.getAttribute("for");a&&o.unshift(a)}s=s.parentElement}n&&e.push(Ut(n));for(const r of o)e.push("tab-"+Ut(r));const i=t.getAttribute("label");return i&&e.push(Ut(i)),e.length===0?"os-unnamed":"os-"+e.filter(r=>r!=="").join("-")}function Ut(t){return t.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Cn(t){if(t.id)return t.id;const e=Sn(t);return t.id=e,e}const ft=F`:host{--_holo-fill:var( --os-ui-holo-fill,${"linear-gradient( 124deg, #afa2e8 0%, #f5a8ea 46%, #8ee9f7 100% )"} );--_holo-ink:var( --os-ui-holo-ink,#0c0b0f );--_holo-sheen:var( --os-ui-holo-sheen,linear-gradient( 124deg,rgba( 159,214,255,0.1 ) 0%,rgba( 236,155,255,0.12 ) 34%,rgba( 242,82,252,0.1 ) 58%,rgba( 147,240,198,0.09 ) 100% ) );--_holo-edge:var( --os-ui-holo-edge,linear-gradient( 124deg,rgba( 154,242,255,0.7 ) 0%,rgba( 236,155,255,0.85 ) 38%,rgba( 242,82,252,0.7 ) 62%,rgba( 159,152,255,0.6 ) 100% ) );--_holo-edge-quiet:var( --os-ui-holo-edge-quiet,linear-gradient( 124deg,rgba( 154,242,255,0.22 ) 0%,rgba( 236,155,255,0.28 ) 38%,rgba( 242,82,252,0.22 ) 62%,rgba( 159,152,255,0.2 ) 100% ) );--_holo-glow:var( --os-ui-holo-glow,0 0 0 1px rgba( 242,82,252,0.28 ),0 2px 10px rgba( 242,82,252,0.22 ) );--_holo-glow-strong:var( --os-ui-holo-glow-strong,0 0 0 1px rgba( 242,82,252,0.42 ),0 4px 18px rgba( 242,82,252,0.38 ),0 1px 3px rgba( 12,11,15,0.6 ) );--_holo-track:var( --os-ui-holo-track,rgba( 255,251,255,0.16 ) );--_holo-track-edge:var( --os-ui-holo-track-edge,#8c8f94 );--_holo-ring-color:var( --os-ui-accent-dim,#2271b1 );--_holo-focus:var( --os-ui-focus-ring,0 0 0 2px rgba( 12,11,15,0.9 ),0 0 0 4px #f252fc,0 0 12px 2px rgba( 242,82,252,0.45 ) );--_holo-focus-field:var( --os-ui-focus-ring-field,0 0 0 1px #f252fc,0 0 0 4px rgba( 242,82,252,0.18 ) );--_holo-t:var( --os-ui-holo-transition,220ms );--_holo-t-fast:var( --os-ui-motion-fast,140ms );--_holo-t-slow:var( --os-ui-motion-slow,340ms );--_holo-t-ambient:var( --os-ui-motion-ambient,12s );--_holo-spring:var( --os-ui-ease-spring,cubic-bezier( 0.32,1.5,0.55,1 ) );--_holo-ease:var( --os-ui-ease-out,cubic-bezier( 0.22,0.9,0.28,1 ) );--_holo-loop:var( --os-ui-ease-loop,cubic-bezier( 0.45,0,0.55,1 ) )}`,Ln=F` .os-holo-fill{background-color:transparent;background-image:var( --_holo-fill );background-size:220% 220%;background-position:22% 28%;background-repeat:no-repeat;color:var( --_holo-ink );transition:background-position var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease,filter var( --_holo-t ) ease}.os-holo-fill:hover{background-position:74% 66%}.os-holo-fill:active{background-position:88% 82%;filter:brightness( 0.94 )}@media ( prefers-reduced-motion:reduce ){.os-holo-fill{transition-duration:1ms}.os-holo-fill:hover,.os-holo-fill:active{background-position:22% 28%}}`,In=F` .os-holo-sheen{position:relative;isolation:isolate}.os-holo-sheen::before{content:'';position:absolute;inset:0;z-index:-1;border-radius:inherit;background-image:var( --_holo-sheen );background-size:200% 200%;background-position:20% 30%;opacity:0;pointer-events:none;transition:opacity var( --_holo-t ) ease,background-position var( --_holo-t ) ease}.os-holo-sheen:hover::before,.os-holo-sheen:focus-visible::before{opacity:1;background-position:76% 68%}@media ( prefers-reduced-motion:reduce ){.os-holo-sheen::before{transition-duration:1ms}.os-holo-sheen:hover::before,.os-holo-sheen:focus-visible::before{background-position:20% 30%}}`,$n=F` .os-holo-edge{position:relative}.os-holo-edge::after{content:'';position:absolute;inset:0;border-radius:inherit;padding:1px;background-image:var( --_holo-edge-quiet );opacity:0;pointer-events:none;-webkit-mask:linear-gradient( #000 0 0 ) content-box,linear-gradient( #000 0 0 );-webkit-mask-composite:xor;mask:linear-gradient( #000 0 0 ) content-box,linear-gradient( #000 0 0 );mask-composite:exclude;transition:opacity var( --_holo-t ) ease}.os-holo-edge:hover::after,.os-holo-edge:focus-visible::after{background-image:var( --_holo-edge );opacity:1}.os-holo-edge.is-lit::after{background-image:var( --_holo-edge );opacity:1}@media ( prefers-reduced-motion:reduce ){.os-holo-edge::after{transition-duration:1ms}}`,Pn=F` .os-holo-glint{position:absolute;inset:0;border-radius:inherit;overflow:hidden;pointer-events:none}.os-holo-glint::before{content:'';position:absolute;top:-60%;bottom:-60%;width:45%;inset-inline-start:-60%;background:linear-gradient( 90deg,transparent 0%,rgba( 255,251,255,0.14 ) 45%,rgba( 255,251,255,0.22 ) 50%,rgba( 255,251,255,0.14 ) 55%,transparent 100% );transform:rotate( 18deg ) translateX( 0 );opacity:0}:hover>.os-holo-glint::before,:focus-visible>.os-holo-glint::before,:host(:hover )>.os-holo-glint::before,:host(:focus-visible )>.os-holo-glint::before{animation:os-holo-glint var( --_holo-t-slow ) var( --_holo-ease )}@keyframes os-holo-glint{0%{opacity:0;transform:rotate( 18deg ) translateX( 0 )}15%{opacity:1}85%{opacity:1}100%{opacity:0;transform:rotate( 18deg ) translateX( 240vw )}}@media ( prefers-reduced-motion:reduce ){:hover>.os-holo-glint::before,:focus-visible>.os-holo-glint::before,:host(:hover )>.os-holo-glint::before,:host(:focus-visible )>.os-holo-glint::before{animation:none}}`,Nn=F` .os-holo-ring{position:absolute;inset:0;border-radius:inherit;box-shadow:0 0 0 0 var( --_holo-ring-color );opacity:0;pointer-events:none}:active:not(:disabled )>.os-holo-ring,:host(:active:not( [ disabled ] ) )>.os-holo-ring{animation:os-holo-ring var( --_holo-t-slow ) var( --_holo-ease )}@keyframes os-holo-ring{0%{opacity:0.45;box-shadow:0 0 0 0 var( --_holo-ring-color )}100%{opacity:0;box-shadow:0 0 0 10px transparent}}@media ( prefers-reduced-motion:reduce ){:active:not(:disabled )>.os-holo-ring,:host(:active:not( [ disabled ] ) )>.os-holo-ring{animation:none}}`,Tn=F` .os-holo-shimmer{background-image:var( --_holo-fill );background-size:300% 300%;background-repeat:no-repeat;animation:os-holo-shimmer 2.4s var( --_holo-loop ) infinite}@keyframes os-holo-shimmer{0%{background-position:0% 50%}100%{background-position:100% 50%}}@media ( prefers-reduced-motion:reduce ){.os-holo-shimmer{animation:none;background-position:30% 50%}}`,zn=F` .os-holo-enter{animation:os-holo-enter var( --_holo-t ) var( --_holo-spring )}@keyframes os-holo-enter{from{opacity:0;transform:scale( 0.96 )}}@media ( prefers-reduced-motion:reduce ){.os-holo-enter{animation:none}}`,De=F` input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ),select,textarea{transition:background-color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):hover:not(:disabled ),select:hover:not(:disabled ),textarea:hover:not(:disabled ){border-color:var( --os-ui-border-strong,#8c8f94 )}input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):focus,input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ):focus-visible,select:focus,select:focus-visible,textarea:focus,textarea:focus-visible{outline:none;border-color:var( --os-ui-accent,#2271b1 );box-shadow:var( --_holo-focus-field )}input::placeholder,textarea::placeholder{color:var( --os-ui-fg-faint,#8c8f94 );opacity:1}input::selection,textarea::selection{background:var( --os-ui-selection-bg,rgba( 159,152,255,0.6 ) );color:var( --os-ui-selection-fg,#fffbff )}@media ( prefers-reduced-motion:reduce ){input:where(:not( [ type='checkbox' ] ):not( [ type='radio' ] ) ),select,textarea{transition-duration:1ms}}`,Re=F` input[ type='checkbox' ],input[ type='radio' ]{appearance:none;-webkit-appearance:none;position:relative;flex:0 0 auto;box-sizing:border-box;width:16px;height:16px;margin:0;padding:0;border:1px solid var( --_holo-track-edge );border-radius:4px;background-color:var( --_holo-track );background-image:none;background-repeat:no-repeat;cursor:inherit;transition:background-color var( --_holo-t ) ease,border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input[ type='radio' ]{border-radius:50%}input[ type='checkbox' ]:hover:not(:disabled ),input[ type='radio' ]:hover:not(:disabled ){border-color:var( --os-ui-accent,#2271b1 )}input[ type='checkbox' ]:focus-visible,input[ type='radio' ]:focus-visible{outline:none;box-shadow:var( --_holo-focus )}input[ type='checkbox' ]:checked,input[ type='checkbox' ]:indeterminate,input[ type='radio' ]:checked{border-color:transparent;background-color:var( --os-ui-accent,#2271b1 )}input[ type='checkbox' ]:checked:focus-visible,input[ type='radio' ]:checked:focus-visible{box-shadow:var( --_holo-focus )}input[ type='checkbox' ]:checked::after{content:'';position:absolute;inset-inline-start:50%;top:46%;width:3.5px;height:7.5px;border:solid var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) );border-width:0 2px 2px 0;transform:translate( -50%,-50% ) rotate( 45deg );animation:os-holo-tick 180ms cubic-bezier( 0.3,1.4,0.6,1 )}input[ type='checkbox' ]:indeterminate::after{content:'';position:absolute;inset-inline-start:50%;top:50%;width:8px;height:2px;border:0;border-radius:1px;background:var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) );transform:translate( -50%,-50% )}input[ type='radio' ]:checked::after{content:'';position:absolute;inset-inline-start:50%;top:50%;width:6px;height:6px;border-radius:50%;background:var( --os-ui-accent-ink,var( --os-ui-fg-on-accent,#fff ) );transform:translate( -50%,-50% );animation:os-holo-tick 180ms cubic-bezier( 0.3,1.4,0.6,1 )}input[ type='checkbox' ]:disabled,input[ type='radio' ]:disabled{cursor:not-allowed}@keyframes os-holo-tick{from{opacity:0;transform:translate( -50%,-50% ) rotate( 45deg ) scale( 0.4 )}}@media ( prefers-reduced-motion:reduce ){input[ type='checkbox' ]:checked::after,input[ type='radio' ]:checked::after{animation:none}}`,Dn=F` @keyframes os-holo-drift{0%{background-position:16% 26%}50%{background-position:84% 74%}100%{background-position:16% 26%}}.os-holo-alive{animation:os-holo-drift var( --_holo-t-ambient ) var( --_holo-loop ) infinite}@media ( prefers-reduced-motion:reduce ){.os-holo-alive{animation:none}}`;F` ${ft} ${Ln} ${In} ${$n} ${Pn} ${Nn} ${Tn} ${zn} ${De} ${Re} ${Dn} `;const Rn=F` ${ft}:host{display:none;position:fixed;inset:0;align-items:center;justify-content:center;background:var( --os-ui-scrim,rgba( 0,0,0,0.45 ) );background-image:var( --os-ui-scrim-image,none );background-repeat:var( --os-ui-scrim-image-repeat,repeat );background-size:var( --os-ui-scrim-image-size,auto );background-position:var( --os-ui-scrim-image-position,center );backdrop-filter:blur( 2px );z-index:10000;--os-ui-fg:var( --os-ui-modal-text,#f0f0f1 );--os-ui-fg-muted:var( --os-ui-modal-text-muted,#a7aaad );--os-ui-border:var( --os-ui-modal-border,rgba( 255,255,255,0.25 ) );--os-window-bg:var( --os-ui-modal-field-bg,#2c3338 );--os-ui-button-bg-hover:var( --os-ui-modal-button-bg-hover,rgba( 255,255,255,0.08 ) );--os-ui-surface:var( --os-ui-modal-surface,#2c3338 );--os-ui-surface-elevated:var( --os-ui-modal-surface-elevated,#3c434a );--os-ui-border-strong:var( --os-ui-modal-border-strong,rgba( 255,255,255,0.35 ) );--os-ui-hover:var( --os-ui-modal-hover,rgba( 255,255,255,0.08 ) );--os-ui-notice-color:var( --os-ui-modal-text,#f0f0f1 );--os-ui-card-bg:var( --os-ui-modal-surface,#2c3338 );--os-ui-card-fg:var( --os-ui-modal-text,#f0f0f1 );--os-ui-card-border:var( --os-ui-modal-border,rgba( 255,255,255,0.25 ) );--os-ui-card-border-hover:var( --os-ui-modal-border-strong,rgba( 255,255,255,0.35 ) )}:host( [ open ] ){display:flex;animation:os-modal-scrim var( --_holo-t ) var( --_holo-ease )}:host( [ open ] ) .dialog{animation:os-modal-dialog var( --_holo-t ) var( --_holo-spring )}@keyframes os-modal-scrim{from{opacity:0}}@keyframes os-modal-dialog{from{opacity:0;transform:scale( 0.96 ) translateY( 8px )}}@media ( prefers-reduced-motion:reduce ){:host( [ open ] ),:host( [ open ] ) .dialog{animation:none}}.dialog{max-width:92vw;max-height:90vh;background-color:var( --os-ui-modal-bg,#1d2327 );background-image:var( --os-ui-dialog-bg-image,none );background-repeat:var( --os-ui-dialog-bg-image-repeat,repeat );background-size:var( --os-ui-dialog-bg-image-size,auto );background-position:var( --os-ui-dialog-bg-image-position,center );color:var( --os-ui-modal-fg,var( --os-fg,#fff ) );border:1px solid var( --os-ui-border,rgba( 255,255,255,0.08 ) );border-radius:10px;box-shadow:0 20px 50px rgba( 0,0,0,0.6 );display:flex;flex-direction:column;overflow:hidden}:host( [ size='sm' ] ) .dialog{width:min( 360px,92vw )}:host(:not( [ size ] ) ) .dialog,:host( [ size='md' ] ) .dialog{width:min( 540px,92vw )}:host( [ size='lg' ] ) .dialog{width:min( 760px,94vw )}.header{display:flex;align-items:center;gap:10px;padding:16px 20px 12px;border-bottom:1px solid var( --os-ui-border,rgba( 255,255,255,0.06 ) )}.title{margin:0;flex:1;font-size:15px;font-weight:600}.header-actions{display:flex;gap:6px}.header-actions::slotted( * ){margin-inline-start:6px}.close{background:transparent;border:0;color:inherit;font-size:18px;line-height:1;padding:4px 8px;border-radius:4px;cursor:pointer;opacity:0.7}.close:hover{opacity:1;background:var( --os-ui-hover,rgba( 255,255,255,0.08 ) )}.body{padding:16px 20px;overflow:auto;flex:1 1 auto;font-size:13px;line-height:1.5}.footer{padding:12px 20px 16px;border-top:1px solid var( --os-ui-border,rgba( 255,255,255,0.06 ) )}.footer slot{display:flex;justify-content:flex-end;gap:10px;flex-wrap:wrap}:host( [ mandatory ] ) .close{display:none}`,Fe='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])',kt=class kt extends ot{constructor(){super(...arguments),this._prevFocus=null,this._onKey=e=>{if(e.key==="Escape"&&!this.hasAttribute("mandatory")){e.preventDefault(),this._cancel();return}if(e.key==="Tab"){const o=this._focusables();if(o.length===0)return;const n=o[0],s=o[o.length-1],i=this.ownerDocument,r=i?i.activeElement:null,a=e.composedPath()[0]||r;e.shiftKey&&a===n?(e.preventDefault(),s.focus()):!e.shiftKey&&a===s&&(e.preventDefault(),n.focus())}},this._onBackdrop=e=>{if(this.hasAttribute("mandatory"))return;const o=e.composedPath();(o.length>0?o[0]:e.target)===this&&this._cancel()}}connectedCallback(){super.connectedCallback(),this.setAttribute("role","dialog"),this.setAttribute("aria-modal","true"),this.addEventListener("keydown",this._onKey),this.addEventListener("click",this._onBackdrop)}disconnectedCallback(){this.removeEventListener("keydown",this._onKey),this.removeEventListener("click",this._onBackdrop)}attributeChangedCallback(e,o,n){if(super.attributeChangedCallback?.(e,o,n),e==="open"){if(n!==null){const s=this.ownerDocument;this._prevFocus=s?s.activeElement:null,queueMicrotask(()=>this._focusFirst())}else if(this._prevFocus){try{this._prevFocus.focus()}catch{}this._prevFocus=null}}}showModal(){this.setAttribute("open","")}hideModal(){this.removeAttribute("open")}_focusables(){const e=this.shadowRoot;if(!e)return[];const o=Array.from(this.querySelectorAll(Fe)),n=Array.from(e.querySelectorAll(Fe));return[...o,...n].filter(s=>s.offsetParent!==null||s.tagName==="BUTTON")}_focusFirst(){const e=this._focusables();e.length>0?e[0].focus():this.shadowRoot?.querySelector(".dialog")?.focus?.()}_cancel(){const e=new CustomEvent("os-modal-cancel",{bubbles:!0,cancelable:!0,composed:!0});this.dispatchEvent(e)&&this.hideModal()}render(){const e=this.getAttribute("title")??"",o=this.hasAttribute("mandatory");return G`
2 2 <div part="dialog" class="dialog" tabindex="-1">
3 3 ${e?G`
4 4 <div class="header">
5 5 <h2 class="title">${e}</h2>
@@ -20,13 +20,13 @@
20 20 <div class="footer">
21 21 <slot name="footer"></slot>
22 22 </div>
23 23 </div>
24 - `}};bt.props=["open","title","size","mandatory"],bt.styles=[pn],bt.help=void 0;let Wt=bt;mt("os-modal",Wt);const mn=D`:host{display:block;margin-block-end:36px}:host( [ hidden ] ){display:none}.os-section__heading{margin:0 0 5px;font-size:20px;font-weight:500;letter-spacing:-0.01em;color:var( --os-ui-fg,#1d2327 )}.os-section__description{margin:0 0 14px;max-width:78ch;font-size:14px;color:var( --os-ui-fg-muted,#646970 );line-height:1.55}.os-section__description:empty{display:none}:host( [ stack ] ) .os-section__body{display:flex;flex-direction:column;gap:var( --os-ui-section-gap,12px )}`,vt=class vt extends lt{render(){const e=this.heading||"",o=this.description||"";return G`
24 + `}};kt.props=["open","title","size","mandatory"],kt.styles=[Rn],kt.help=void 0;let Vt=kt;dt("os-modal",Vt);const Fn=F`:host{display:block;margin-block-end:36px}:host( [ hidden ] ){display:none}.os-section__heading{margin:0 0 5px;font-size:20px;font-weight:500;letter-spacing:-0.01em;color:var( --os-ui-fg,#1d2327 )}.os-section__description{margin:0 0 14px;max-width:78ch;font-size:14px;color:var( --os-ui-fg-muted,#646970 );line-height:1.55}.os-section__description:empty{display:none}:host( [ stack ] ) .os-section__body{display:flex;flex-direction:column;gap:var( --os-ui-section-gap,12px )}`,_t=class _t extends ot{render(){const e=this.heading||"",o=this.description||"";return G`
25 25 ${e?G`<h3 class="os-section__heading">${e}</h3>`:""}
26 26 ${o?G`<p class="os-section__description">${o}</p>`:""}
27 27 <div class="os-section__body" part="body"><slot></slot></div>
28 - `}};vt.props=["heading","description","stack"],vt.styles=[mn],vt.help=void 0;let qt=vt;mt("os-section",qt);const gn=D` ${gt}:host{display:flex;align-items:center;gap:10px;font-size:12px;color:var( --os-ui-fg-muted,#646970 )}input[ type='range' ]{appearance:none;-webkit-appearance:none;flex:1;min-width:0;height:18px;margin:0;padding:0;background:transparent;cursor:pointer}input[ type='range' ]:disabled{cursor:not-allowed;opacity:0.5}input[ type='range' ]::-webkit-slider-runnable-track{height:6px;border-radius:999px;background-image:linear-gradient( var( --_range-angle,90deg ),transparent var( --_fill,0% ),var( --_holo-track ) var( --_fill,0% ) ),linear-gradient( var( --os-ui-accent,#2271b1 ),var( --os-ui-accent,#2271b1 ) );background-size:auto,auto;background-position:center,center;background-repeat:no-repeat;box-shadow:inset 0 0 0 1px var( --_holo-track-edge )}input[ type='range' ]::-moz-range-track{height:6px;border-radius:999px;background-image:linear-gradient( var( --_range-angle,90deg ),transparent var( --_fill,0% ),var( --_holo-track ) var( --_fill,0% ) ),linear-gradient( var( --os-ui-accent,#2271b1 ),var( --os-ui-accent,#2271b1 ) );background-size:auto,auto;background-position:center,center;background-repeat:no-repeat;box-shadow:inset 0 0 0 1px var( --_holo-track-edge )}input[ type='range' ]::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;width:16px;height:16px;margin-top:-5px;border:0;border-radius:50%;background:var( --os-ui-switch-knob,#fffbff );box-shadow:0 1px 3px rgba( 12,11,15,0.5 ),0 0 0 1px rgba( 12,11,15,0.14 );cursor:inherit;transition:transform var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input[ type='range' ]::-moz-range-thumb{width:16px;height:16px;border:0;border-radius:50%;background:var( --os-ui-switch-knob,#fffbff );box-shadow:0 1px 3px rgba( 12,11,15,0.5 ),0 0 0 1px rgba( 12,11,15,0.14 );cursor:inherit;transition:transform var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input[ type='range' ]:active::-webkit-slider-thumb{transform:scale( 1.15 );box-shadow:var( --_holo-glow-strong )}input[ type='range' ]:active::-moz-range-thumb{transform:scale( 1.15 );box-shadow:var( --_holo-glow-strong )}input[ type='range' ]:focus-visible{outline:none}input[ type='range' ]:focus-visible::-webkit-slider-thumb{box-shadow:var( --_holo-focus )}input[ type='range' ]:focus-visible::-moz-range-thumb{box-shadow:var( --_holo-focus )}.os-range-field__value{width:var( --os-ui-range-readout-width,3ch );flex:none;text-align:end;font-variant-numeric:tabular-nums;color:var( --os-ui-fg,#1d2327 )}@media ( prefers-reduced-motion:reduce ){input[ type='range' ]::-webkit-slider-thumb{transition-duration:1ms}input[ type='range' ]::-moz-range-thumb{transition-duration:1ms}}`;function xn(t,e,o){const n=Number.parseFloat(t),s=Number.parseFloat(e),i=Number.parseFloat(o);if(!Number.isFinite(n)||!Number.isFinite(s)||!Number.isFinite(i)||i===s)return"0%";const c=(n-s)/(i-s);return`${Math.min(100,Math.max(0,c*100)).toFixed(2)}%`}function yn(t){const e=t.indexOf(".");return e<0?0:Math.min(3,t.length-e-1)}function bn(t,e,o,n){const s=c=>{const r=Number.parseFloat(c);return Number.isFinite(r)?String(Math.trunc(Math.abs(r))).length+(r<0?1:0):3};return Math.max(s(t),s(e))+(o>0?o+1:0)+n.length}const wt=class wt extends lt{render(){const e=this.label||"",o=this.value||"0",n=this.min||"0",s=this.max||"100",i=this.step||"1",c=this.suffix||"",r=this.decimals,a=r?Math.min(6,Math.max(0,Number.parseInt(r,10)||0)):yn(i),l=Number.parseFloat(o),h=Number.isFinite(l)?l.toFixed(a):o,u=bn(n,s,a,c);return G`
28 + `}};_t.props=["heading","description","stack"],_t.styles=[Fn],_t.help=void 0;let Yt=_t;dt("os-section",Yt);const On=F` ${ft}:host{display:flex;align-items:center;gap:10px;font-size:12px;color:var( --os-ui-fg-muted,#646970 )}input[ type='range' ]{appearance:none;-webkit-appearance:none;flex:1;min-width:0;height:18px;margin:0;padding:0;background:transparent;cursor:pointer}input[ type='range' ]:disabled{cursor:not-allowed;opacity:0.5}input[ type='range' ]::-webkit-slider-runnable-track{height:6px;border-radius:999px;background-image:linear-gradient( var( --_range-angle,90deg ),transparent var( --_fill,0% ),var( --_holo-track ) var( --_fill,0% ) ),linear-gradient( var( --os-ui-accent,#2271b1 ),var( --os-ui-accent,#2271b1 ) );background-size:auto,auto;background-position:center,center;background-repeat:no-repeat;box-shadow:inset 0 0 0 1px var( --_holo-track-edge )}input[ type='range' ]::-moz-range-track{height:6px;border-radius:999px;background-image:linear-gradient( var( --_range-angle,90deg ),transparent var( --_fill,0% ),var( --_holo-track ) var( --_fill,0% ) ),linear-gradient( var( --os-ui-accent,#2271b1 ),var( --os-ui-accent,#2271b1 ) );background-size:auto,auto;background-position:center,center;background-repeat:no-repeat;box-shadow:inset 0 0 0 1px var( --_holo-track-edge )}input[ type='range' ]::-webkit-slider-thumb{appearance:none;-webkit-appearance:none;width:16px;height:16px;margin-top:-5px;border:0;border-radius:50%;background:var( --os-ui-switch-knob,#fffbff );box-shadow:0 1px 3px rgba( 12,11,15,0.5 ),0 0 0 1px rgba( 12,11,15,0.14 );cursor:inherit;transition:transform var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input[ type='range' ]::-moz-range-thumb{width:16px;height:16px;border:0;border-radius:50%;background:var( --os-ui-switch-knob,#fffbff );box-shadow:0 1px 3px rgba( 12,11,15,0.5 ),0 0 0 1px rgba( 12,11,15,0.14 );cursor:inherit;transition:transform var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input[ type='range' ]:active::-webkit-slider-thumb{transform:scale( 1.15 );box-shadow:var( --_holo-glow-strong )}input[ type='range' ]:active::-moz-range-thumb{transform:scale( 1.15 );box-shadow:var( --_holo-glow-strong )}input[ type='range' ]:focus-visible{outline:none}input[ type='range' ]:focus-visible::-webkit-slider-thumb{box-shadow:var( --_holo-focus )}input[ type='range' ]:focus-visible::-moz-range-thumb{box-shadow:var( --_holo-focus )}.os-range-field__value{width:var( --os-ui-range-readout-width,3ch );flex:none;text-align:end;font-variant-numeric:tabular-nums;color:var( --os-ui-fg,#1d2327 )}@media ( prefers-reduced-motion:reduce ){input[ type='range' ]::-webkit-slider-thumb{transition-duration:1ms}input[ type='range' ]::-moz-range-thumb{transition-duration:1ms}}`;function Bn(t,e,o){const n=Number.parseFloat(t),s=Number.parseFloat(e),i=Number.parseFloat(o);if(!Number.isFinite(n)||!Number.isFinite(s)||!Number.isFinite(i)||i===s)return"0%";const r=(n-s)/(i-s);return`${Math.min(100,Math.max(0,r*100)).toFixed(2)}%`}function Wn(t){const e=t.indexOf(".");return e<0?0:Math.min(3,t.length-e-1)}function Hn(t,e,o,n){const s=r=>{const a=Number.parseFloat(r);return Number.isFinite(a)?String(Math.trunc(Math.abs(a))).length+(a<0?1:0):3};return Math.max(s(t),s(e))+(o>0?o+1:0)+n.length}const At=class At extends ot{render(){const e=this.label||"",o=this.value||"0",n=this.min||"0",s=this.max||"100",i=this.step||"1",r=this.suffix||"",a=this.decimals,c=a?Math.min(6,Math.max(0,Number.parseInt(a,10)||0)):Wn(i),l=Number.parseFloat(o),u=Number.isFinite(l)?l.toFixed(c):o,d=Hn(n,s,c,r);return G`
29 29 <label class="os-range-field__label">${e}</label>
30 30 <input
31 31 type="range"
32 32 min=${n}
@@ -31,18 +31,18 @@
31 31 type="range"
32 32 min=${n}
33 33 max=${s}
34 34 step=${i}
35 - style="--_fill: ${xn(o,n,s)}"
35 + style="--_fill: ${Bn(o,n,s)}"
36 36 .value=${o}
37 - @input=${g=>this._onInput(g)}
37 + @input=${f=>this._onInput(f)}
38 38 />
39 39 <span
40 40 class="os-range-field__value"
41 - style="--os-ui-range-readout-width: ${u}ch"
42 - >${h}${c}</span
41 + style="--os-ui-range-readout-width: ${d}ch"
42 + >${u}${r}</span
43 43 >
44 - `}connectedCallback(){super.connectedCallback(),getComputedStyle(this).direction==="rtl"&&this.style.setProperty("--_range-angle","270deg")}_onInput(e){const o=e.target,n=parseFloat(o.value);Number.isFinite(n)&&(this.value=String(n),this.emit("os-range-change",{value:n}))}};wt.props=["label","value","min","max","step","suffix","decimals"],wt.styles=[gn],wt.help=void 0;let Gt=wt;mt("os-range-field",Gt);const vn=D` ${gt}:host{display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var( --os-ui-fg-muted,#646970 )}label{display:inline-flex;align-items:center;gap:8px}input[ type='color' ]{width:28px;height:28px;padding:0;border:1px solid var( --os-ui-border,#c3c4c7 );border-radius:6px;background:transparent;cursor:pointer;transition:border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input[ type='color' ]:hover{border-color:var( --os-ui-border-strong,#8c8f94 )}input[ type='color' ]:focus-visible{outline:none;box-shadow:var( --_holo-focus )}:host( [ variant='block' ] ){display:flex;width:100%}:host( [ variant='block' ] ) label{display:flex;flex:1;align-items:center}:host( [ variant='block' ] ) input[ type='color' ]{flex:1;width:auto;height:32px}input[ type='color' ]::-webkit-color-swatch-wrapper{padding:2px}input[ type='color' ]::-webkit-color-swatch{border:none;border-radius:2px}`,Mt=class Mt extends lt{open(){const e=()=>{const o=this.shadowRoot?.querySelector("input");if(!o)return!1;try{o.showPicker()}catch{o.click()}return!0};e()||queueMicrotask(()=>void e())}render(){const e=this.label||"",o=this.value||"#000000";return G`
44 + `}connectedCallback(){super.connectedCallback(),getComputedStyle(this).direction==="rtl"&&this.style.setProperty("--_range-angle","270deg")}_onInput(e){const o=e.target,n=parseFloat(o.value);Number.isFinite(n)&&(this.value=String(n),this.emit("os-range-change",{value:n}))}};At.props=["name","label","value","min","max","step","suffix","decimals"],At.styles=[On],At.help=void 0;let jt=At;dt("os-range-field",jt);const qn=F` ${ft}:host{display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var( --os-ui-fg-muted,#646970 )}label{display:inline-flex;align-items:center;gap:8px}input[ type='color' ]{width:28px;height:28px;padding:0;border:1px solid var( --os-ui-border,#c3c4c7 );border-radius:6px;background:transparent;cursor:pointer;transition:border-color var( --_holo-t ) ease,box-shadow var( --_holo-t ) ease}input[ type='color' ]:hover{border-color:var( --os-ui-border-strong,#8c8f94 )}input[ type='color' ]:focus-visible{outline:none;box-shadow:var( --_holo-focus )}:host( [ variant='block' ] ){display:flex;width:100%}:host( [ variant='block' ] ) label{display:flex;flex:1;align-items:center}:host( [ variant='block' ] ) input[ type='color' ]{flex:1;width:auto;height:32px}input[ type='color' ]::-webkit-color-swatch-wrapper{padding:2px}input[ type='color' ]::-webkit-color-swatch{border:none;border-radius:2px}`,Et=class Et extends ot{open(){const e=()=>{const o=this.shadowRoot?.querySelector("input");if(!o)return!1;try{o.showPicker()}catch{o.click()}return!0};e()||queueMicrotask(()=>void e())}render(){const e=this.label||"",o=this.value||"#000000";return G`
45 45 <label>
46 46 <span class="os-color-field__label">${e}</span>
47 47 <input
48 48 type="color"
@@ -49,13 +49,13 @@
49 49 .value=${o}
50 50 @input=${n=>this._onInput(n)}
51 51 />
52 52 </label>
53 - `}_onInput(e){const o=e.target;this.value=o.value,this.emit("os-color-change",{value:o.value})}};Mt.props=["label","value","variant"],Mt.styles=[vn],Mt.help=void 0;let Xt=Mt;mt("os-color-field",Xt);const wn=D` ${gt} ${Me}:host{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var( --os-ui-fg,#1d2327 );cursor:pointer}:host( [ disabled ] ){cursor:not-allowed;opacity:0.55}:host( [ block ] ){display:flex;cursor:default}:host( [ block ] ) label{cursor:pointer}:host( [ block ][ disabled ] ) label{cursor:not-allowed}label{display:inline-flex;align-items:center;gap:6px;cursor:inherit}.os-checkbox__label{line-height:1.3}.os-checkbox__label:empty{display:none}`,kt=class kt extends lt{render(){const e=this.checked!==null,o=this.disabled!==null,n=this.label||"",s=this.value;return G`
53 + `}_onInput(e){const o=e.target;this.value=o.value,this.emit("os-color-change",{value:o.value})}};Et.props=["name","label","value","variant"],Et.styles=[qn],Et.help=void 0;let Zt=Et;dt("os-color-field",Zt);const Gn=F` ${ft} ${Re}:host{display:inline-flex;align-items:center;gap:6px;font-size:13px;color:var( --os-ui-fg,#1d2327 );cursor:pointer}:host( [ disabled ] ){cursor:not-allowed;opacity:0.55}:host( [ block ] ){display:flex;cursor:default}:host( [ block ] ) label{cursor:pointer}:host( [ block ][ disabled ] ) label{cursor:not-allowed}label{display:inline-flex;align-items:center;gap:6px;cursor:inherit}.os-checkbox__label{line-height:1.3}.os-checkbox__label:empty{display:none}`,St=class St extends ot{render(){const e=this.checked!==null,o=this.disabled!==null,n=this.label||"",s=this.value;return G`
54 54 <label>
55 55 <input
56 56 type="checkbox"
57 - ?checked=${e}
57 + .checked=${e}
58 58 ?disabled=${o}
59 59 .value=${s??""}
60 60 @change=${i=>this._onChange(i)}
61 61 />
@@ -60,5 +60,30 @@
60 60 @change=${i=>this._onChange(i)}
61 61 />
62 62 <span class="os-checkbox__label">${n}</span>
63 63 </label>
64 - `}_onChange(e){const n=e.target.checked;n?this.setAttribute("checked",""):this.removeAttribute("checked"),this.emit("os-checkbox-change",{checked:n,value:this.value})}};kt.props=["checked","value","label","disabled"],kt.styles=[wn],kt.help=void 0;let Ut=kt;mt("os-checkbox",Ut);let Kt=null;function Ct(){return!!window.openStationShellOverlays}function Mn(t){return new Promise((e,o)=>{const n=document.querySelector('script[data-os-shell-overlays="1"]'),s=()=>{if(Ct()){e();return}o(new Error("[openstation] shell-overlays bundle loaded but did not set `window.openStationShellOverlays`."))};if(n){Ct()?s():(n.addEventListener("load",s),n.addEventListener("error",()=>o(new Error("failed to load shell-overlays bundle"))));return}const i=document.createElement("script");i.src=t,i.async=!0,i.dataset.osShellOverlays="1",i.addEventListener("load",s),i.addEventListener("error",()=>o(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(i)})}function kn(t){return Ct()||!t?Promise.resolve():(Kt||(Kt=Mn(t)),Kt)}function _n(){return window.openStationConfig?.shellOverlaysBundleUrl??""}function _e(t,e){const o=_n();if(Ct()||!o){e();return}kn(o).then(()=>{t()&&e()}).catch(n=>{typeof console<"u"&&console.warn("[openstation] shell-overlays failed to load; menu/dialog suppressed:",n)})}const Sn="desktop-mode";function An(){return window.wp?.i18n}function M(t,e=Sn){return An()?.__(t,e)??t}const Pt={appearance:{bodyColor:789263,eyeColor:16776191},physics:{shapeShuffle:60,idleWobble:.085}},En=["blob","ghost","potato","star","flower","heart","diamond","drop","cloud"];function Ln(t=Math.random){const e=(c,r)=>c+t()*(r-c),o=c=>t()<c,n=c=>c[Math.floor(t()*c.length)%c.length],s=(c,r)=>Math.round(c/r)*r,i=s(e(55,215),1)*(o(.5)?1:-1);return{appearance:{hueStart:s(e(0,360),1),hueSpan:i,hueAngle:s(e(0,360),1),hueLoop:!0,hueSpin:o(.25)?s(e(-14,14),1):0,hueDrift:o(.15)?s(e(-8,8),1):0,saturation:s(e(.68,1),.01),lightness:s(e(.52,.78),.01),outlineWidth:s(e(2,7),.5),glow:s(e(4,16),.1),iridescence:o(.34)?s(e(.45,1.25),.05):0,bodyColor:o(.25)?In(t):Pt.appearance.bodyColor,bodyAlpha:o(.2)?s(e(.78,1),.01):1,eyeColor:Pt.appearance.eyeColor,eyeScale:s(e(.2,.42),.01)},physics:{shapePreset:n(En),shapeAmount:s(e(.7,1.15),.05),shapeAngle:0,idleWobble:s(e(.03,.16),.005),idleWobbleSpeed:s(e(.35,1.1),.05)}}}function In(t){const e=()=>Math.floor(t()*42);return e()<<16|e()<<8|e()}function Se(){const t=window.wp?.os?.mio;return t&&typeof t.setStyle=="function"&&typeof t.commitStyle=="function"?t:null}const Vt="os-mio-menu",Ae="os-mio-panel";function Cn(t){return`#${Math.max(0,Math.min(16777215,Math.floor(t))).toString(16).padStart(6,"0")}`}function Pn(t){const e=/^#?([0-9a-f]{6})$/i.exec(t.trim());return e?Number.parseInt(e[1],16):null}const Nn="2";function z(t,e,o){const n=document.createElement("os-range-field");return n.setAttribute("label",t.label),n.setAttribute("min",String(t.min)),n.setAttribute("max",String(t.max)),n.setAttribute("step",String(t.step)),n.setAttribute("decimals",Nn),n.setAttribute("value",String(e[t.key])),n.addEventListener("os-range-change",s=>{const i=s.detail?.value;typeof i=="number"&&Number.isFinite(i)&&o({[t.key]:i})}),n}function Ee(t,e,o,n){const s=document.createElement("os-color-field");return s.setAttribute("label",e),s.setAttribute("value",Cn(o[t])),s.addEventListener("os-color-change",i=>{const c=i.detail?.value,r=typeof c=="string"?Pn(c):null;r!==null&&n({[t]:r})}),s}function Nt(t,e,o){const n=document.createElement("os-checkbox");return n.setAttribute("label",t),n.setAttribute("block",""),e&&n.setAttribute("checked",""),n.addEventListener("os-checkbox-change",s=>{const i=s.detail;o(i?.checked===!0)}),n}function Tn(){return[{value:"blob",label:M("Blob")},{value:"circle",label:M("Circle")},{value:"potato",label:M("Potato")},{value:"ghost",label:M("Ghost")},{value:"star",label:M("Star")},{value:"flower",label:M("Flower")},{value:"heart",label:M("Heart")},{value:"diamond",label:M("Diamond")},{value:"drop",label:M("Teardrop")},{value:"cloud",label:M("Cloud")},{value:"custom",label:M("Polygon")}]}function $n(t,e){const o=document.createElement("os-select");o.setAttribute("label",M("Shape")),o.setAttribute("value",t);for(const n of Tn()){const s=document.createElement("os-option");s.setAttribute("value",n.value),s.textContent=n.label,o.appendChild(s)}return o.addEventListener("os-pick",n=>{const s=n.detail?.value;s&&e(s)}),o}function et(t,e){const o=document.createElement("os-section");o.setAttribute("heading",t);for(const n of e)o.appendChild(n);return o}function Tt(){const t=document.querySelectorAll(`.${Ae}`);t.length&&(t.forEach(e=>e.remove()),Se()?.commitStyle())}function Dn(){const t=++Le;_e(()=>t===Le,()=>zn())}let Le=0,Ie=0;function zn(){const t=Se();if(!t)return;Tt();const e=document.createElement("os-modal");e.classList.add(Ae),e.setAttribute("title",M("Make it yours")),e.setAttribute("size","md"),e.setAttribute("open","");const o=document.createElement("div"),n=()=>{const r=t.getConfig(),a=r.appearance,l=r.physics,h={...a,...l},u=m=>t.setStyle(m),g=l.shapePreset==="custom"?[z({key:"shapeLobes",label:M("Corners"),min:2,max:8,step:1},h,u)]:[];o.replaceChildren(et(M("Shape"),[$n(l.shapePreset,m=>{u({shapePreset:m}),n()}),...g,z({key:"shapeAmount",label:M("Shape strength"),min:0,max:1.4,step:.05},h,u),z({key:"shapeAngle",label:M("Rotation"),min:0,max:360,step:1},h,u),Nt(M("Change shape on its own"),l.shapeShuffle>0,m=>{u({shapeShuffle:m?Pt.physics.shapeShuffle:0})})]),et(M("Idle"),[Nt(M("Wobble when idle"),l.idleWobble>0,m=>{u({idleWobble:m?Pt.physics.idleWobble:0}),n()}),...l.idleWobble>0?[z({key:"idleWobble",label:M("Wobble strength"),min:0,max:.4,step:.005},h,u),z({key:"idleWobbleSpeed",label:M("Wobble speed"),min:0,max:4,step:.05},h,u)]:[]]),et(M("Colour"),[z({key:"hueStart",label:M("Hue"),min:0,max:360,step:1},h,u),z({key:"hueSpan",label:M("Hue spread"),min:-360,max:360,step:1},h,u),z({key:"saturation",label:M("Saturation"),min:0,max:1,step:.01},h,u),z({key:"lightness",label:M("Brightness"),min:.15,max:1,step:.01},h,u)]),et(M("Ring"),[z({key:"outlineWidth",label:M("Thickness"),min:.5,max:24,step:.5},h,u),z({key:"glow",label:M("Glow"),min:0,max:20,step:.1},h,u)]),et(M("Gradient"),[z({key:"hueAngle",label:M("Gradient angle"),min:0,max:360,step:1},h,u),Nt(M("Loop the gradient (no seam)"),a.hueLoop,m=>u({hueLoop:m})),z({key:"hueSpin",label:M("Spin the gradient"),min:-60,max:60,step:1},h,u),z({key:"hueDrift",label:M("Cycle the colours"),min:-60,max:60,step:1},h,u)]),et(M("Hologram"),[Nt(M("Holographic"),a.iridescence>0,m=>{u({iridescence:m?.7:0}),n()}),...a.iridescence>0?[z({key:"iridescence",label:M("Iridescence"),min:0,max:2,step:.05},h,u)]:[]]),et(M("Body"),[Ee("bodyColor",M("Body colour"),a,u),z({key:"bodyAlpha",label:M("Body opacity"),min:0,max:1,step:.01},h,u)]),et(M("Eyes"),[Ee("eyeColor",M("Eye colour"),a,u),z({key:"eyeScale",label:M("Eye size"),min:.05,max:.6,step:.01},h,u)]))};n(),e.appendChild(o);const s=document.createElement("os-button");s.setAttribute("slot","footer"),s.setAttribute("variant","secondary"),s.textContent=M("Surprise me"),s.addEventListener("click",()=>{const r=Ln();t.setStyle({...r.appearance,...r.physics}),n()});const i=document.createElement("os-button");i.setAttribute("slot","footer"),i.setAttribute("variant","secondary"),i.textContent=M("Restore Mio"),i.addEventListener("click",()=>{t.resetStyle(),n()});const c=document.createElement("os-button");c.setAttribute("slot","footer"),c.setAttribute("variant","primary"),c.textContent=M("Done"),c.addEventListener("click",()=>Tt()),e.appendChild(s),e.appendChild(i),e.appendChild(c),e.addEventListener("os-modal-cancel",()=>Tt()),document.body.appendChild(e)}function xt(){document.querySelectorAll(`.${Vt}`).forEach(t=>t.remove()),document.removeEventListener("pointerdown",Ce,!0),document.removeEventListener("keydown",Pe,!0)}function Ce(t){t.target?.closest(`.${Vt}`)||xt()}function Pe(t){t.key==="Escape"&&xt()}function Rn(t){xt();const e=++Ie;_e(()=>e===Ie,()=>Bn(t))}function Bn(t){const e=document.createElement("os-context-menu");e.classList.add(Vt),e.setAttribute("open",""),e.style.left=`${t.x}px`,e.style.top=`${t.y}px`;const o=document.createElement("os-context-menu-option");o.setAttribute("value","make-it-yours"),o.setAttribute("icon","dashicons-art"),o.dataset.menuItemId="make-it-yours",o.textContent=M("Make it yours"),e.appendChild(o),e.addEventListener("os-context-menu-pick",()=>{xt(),Dn()}),document.body.appendChild(e),document.addEventListener("pointerdown",Ce,!0),document.addEventListener("keydown",Pe,!0)}const Fn=1200,Ne=1.25,Te=Math.PI/2,yt=Math.PI*2,On=.05;function ut(t){return((t+Te)%yt+yt)%yt}function Yt(t,e){return Math.pow(.5+.5*t,e)}function Hn(t){const e=Math.max(0,Math.sin(t)),o=2+3.2*e,n=Math.abs(Math.cos(t)),s=Math.abs(Math.sin(t)),i=1/Math.pow(Math.pow(n,o)+Math.pow(s,o),1/o)-1,c=-.17*Math.pow(e,1.4)*Math.cos(6*t);return i+c}function Wn(t){return .16*Math.cos(2*t+.9)+.095*Math.cos(3*t-2.1)+.036*Math.cos(5*t+1.3)+.019*Math.cos(7*t-.4)}function qn(t){return .58*(Yt(Math.cos(5*t),3)-.3125)}function Gn(t){return .34*(Yt(Math.cos(6*t),2)-.375)}function Xn(t){return .34*(Yt(Math.cos(4*t),2)-.375)}function Un(t){return .72*(Math.pow(Math.max(0,Math.cos(t)),8)-.1367)}function Kn(t){const e=Math.max(0,Math.cos(t)),o=Math.max(0,-Math.cos(t));return .34*(Math.sqrt(e)*(.5+.5*Math.cos(5*t))-.7*o*o-.0247)}function Vn(t){const e=t>Math.PI?yt-t:t,o=-.34*Math.pow(Math.max(0,Math.cos(t)),6),n=.3*Math.pow(Math.max(0,Math.cos(e-1)),3),s=.34*Math.pow(Math.max(0,-Math.cos(t)),8);return o+n+s+.02}function Yn(t,e){switch(e.shapePreset){case"circle":return 0;case"ghost":return Hn(t);case"potato":return Wn(t);case"star":return qn(ut(t));case"flower":return Gn(ut(t));case"diamond":return Xn(ut(t));case"drop":return Un(ut(t));case"cloud":return Kn(ut(t));case"heart":return Vn(ut(t));case"custom":{const o=Math.round(e.shapeLobes);return o<2?0:1/(1+o*o)*Math.cos(o*t)}default:return On*Math.cos(3*(t+Te))}}function $e(t){switch(t.shapePreset){case"star":return 40;case"flower":return 36;case"heart":case"cloud":return 32;case"drop":return 28;case"ghost":return 26;case"potato":case"diamond":return 24;case"custom":return Math.max(12,Math.round(t.shapeLobes)*7);default:return 12}}function jt(t,e){if(e.shapeAmount<=0)return 1;const o=t-e.shapeAngle*Math.PI/180;return 1+e.shapeAmount*Yn(o,e)}function De(t,e,o,n,s){const i=Math.max(3,Math.round(n)),c=[];for(let r=0;r<i;r++){const a=r/i*Math.PI*2,l=o*(s?s(a):1);c.push({angle:a,x:t+Math.cos(a)*l,y:e+Math.sin(a)*l,vx:0,vy:0})}return{core:{x:t,y:e,vx:0,vy:0},rim:c,radius:o,profile:s,restArea:.5*i*o*o*Math.sin(2*Math.PI/i),elapsed:0,accumulator:0}}function jn(t,e){const o=Math.max(3,Math.round(e)),n=t.rim,s=n.length;if(o===s||s<3)return;X(t);const i=t.core.x,c=t.core.y,r=l=>Math.hypot(l.x-i,l.y-c),a=new Array(o);for(let l=0;l<o;l++){const h=l/o*s,u=Math.floor(h),g=h-u,m=n[u%s],p=n[(u+1)%s];let f=m.x+(p.x-m.x)*g,d=m.y+(p.y-m.y)*g;const x=Math.hypot(f-i,d-c);if(x>1e-6){const v=r(m)+(r(p)-r(m))*g;f=i+(f-i)/x*v,d=c+(d-c)/x*v}a[l]={angle:l/o*yt,x:f,y:d,vx:m.vx+(p.vx-m.vx)*g,vy:m.vy+(p.vy-m.vy)*g}}t.rim=a,t.restArea=.5*o*t.radius*t.radius*Math.sin(2*Math.PI/o),X(t)}function Zn(t){let e=0;for(let o=0;o<t.length;o++){const n=t[o],s=t[(o+1)%t.length];e+=n.x*s.y-s.x*n.y}return e/2}function X(t){let e=0,o=0,n=0,s=0;for(const c of t.rim)e+=c.x,o+=c.y,n+=c.vx,s+=c.vy;const i=t.rim.length||1;t.core.x=e/i,t.core.y=o/i,t.core.vx=n/i,t.core.vy=s/i}function ze(t,e,o){X(t);const n=e-t.core.x,s=o-t.core.y;for(const i of t.rim)i.x+=n,i.y+=s;X(t)}function Jn(t,e,o){for(const n of t.rim)n.vx+=e,n.vy+=o;X(t)}function Qn(t,e,o){const n=t.rim.length;for(let s=0;s<n;s++){const i=t.rim[s],c=t.radius*(t.profile?t.profile(i.angle):1);i.x=e+Math.cos(i.angle)*c,i.y=o+Math.sin(i.angle)*c,i.vx=0,i.vy=0}t.accumulator=0,X(t)}function ts(t,e,o){const{physics:n}=o,s=n.subStep,i=Number.isFinite(e)?e:0,c=Math.min(Math.max(i,0),s*n.maxSubSteps);t.accumulator+=c;let r=0;for(;t.accumulator>=s&&r<n.maxSubSteps;)t.accumulator-=s,r++,es(t,s,o);t.accumulator>s*n.maxSubSteps&&(t.accumulator=0),X(t)}function es(t,e,o){const{physics:n,obstacles:s,bounds:i,dragTarget:c}=o,r=t.rim,a=r.length;t.elapsed+=e,X(t);const l=t.core,h=o.magnet,u=h?Math.min(1,Math.max(0,h.strength)):0,g=1-u,m=o.dragTarget?0:g,p=new Float64Array(a),f=new Float64Array(a),d=new Float64Array(a),x=t.profile;for(let b=0;b<a;b++){const A=r[b].angle;d[b]=t.radius*(x?x(A):jt(A,n))}const v=n.idleWobble*m;if(v>0){const b=n.idleWobbleSpeed*t.elapsed;for(let A=0;A<a;A++){const E=r[A].angle,I=.55*Math.sin(2*E+b)+.3*Math.sin(3*E-b*1.37+2.1)+.15*Math.sin(5*E+b*.71+4.2);d[A]*=1+v*I}}if(n.speedStretch>0){const b=Math.hypot(l.vx,l.vy);if(b>1){const E=1+n.speedStretch*Math.min(1,b/Fn),I=E*E,T=l.vx/b,F=l.vy/b;for(let N=0;N<a;N++){const Y=r[N].angle,W=Math.cos(Y)*T+Math.sin(Y)*F,tt=W*W;d[N]/=Math.sqrt(tt/I+I*(1-tt))}}}let S=0;for(let b=0;b<a;b++)S+=d[b]*d[(b+1)%a];if(S*=.5*Math.sin(2*Math.PI/a),n.radialStiffness>0)for(let b=0;b<a;b++){const A=r[b];let E=A.x-l.x,I=A.y-l.y,T=Math.hypot(E,I);T<1e-6&&(E=Math.cos(A.angle),I=Math.sin(A.angle),T=1);const F=n.radialStiffness*(T-d[b]);p[b]-=F*E/T,f[b]-=F*I/T}if(Oe(r,p,f,1,d,Math.sin(Math.PI/a),n.edgeStiffness),a>4&&n.bendStiffness>0&&Oe(r,p,f,2,d,Math.sin(2*Math.PI/a),n.bendStiffness),n.pressure>0){const b=Zn(r),A=Math.abs(b),E=Math.min(2,Math.max(-1,S/Math.max(A,.001)-1));if(E!==0){const I=b<0?-1:1,T=2*t.radius*Math.sin(Math.PI/a),F=n.pressure*E*I/(2*T);for(let N=0;N<a;N++){const Y=r[N],W=r[(N+1)%a],tt=W.x-Y.x,st=(W.y-Y.y)*F,Dt=-tt*F;p[N]+=st,f[N]+=Dt,p[(N+1)%a]+=st,f[(N+1)%a]+=Dt}}}let P=0,U=0;for(let b=0;b<a;b++)P+=p[b],U+=f[b];P/=a,U/=a;const w=n.floatSpeed,K=-n.floatAmplitude*w*w*Math.sin(w*t.elapsed),C=-.17*n.floatAmplitude*w*w*Math.sin(w*.7*t.elapsed+1.1);let q=g*C,O=g*K;if(h){const b=-t.radius*n.magnetGrip,A=Math.max(1,t.radius*.35),E=Math.min(1,Math.max(-1,(h.gap-b)/A)),I=n.magnetStrength*u*E;q+=h.dx*I,O+=h.dy*I;const T=n.magnetDamping*u;q-=l.vx*T,O-=l.vy*T}if(c){const b=t.radius,A=Re(c.x,b,Math.max(b,i.width-b)),E=Re(c.y,b,Math.max(b,i.height-b)),I=n.dragStiffness,T=2*Math.sqrt(I);let F=(A-l.x)*I-l.vx*T,N=(E-l.y)*I-l.vy*T;const Y=Math.hypot(F,N);if(Y>n.dragMaxAccel){const W=n.dragMaxAccel/Y;F*=W,N*=W}q+=F,O+=N}const V=1+n.damping*e,nt=1+n.airDamping*e,Q=l.vx,H=l.vy;for(let b=0;b<a;b++){const A=r[b];let E=A.vx+(p[b]-P+q)*e,I=A.vy+(f[b]-U+O)*e;E=Q+(E-Q)/V,I=H+(I-H)/V,A.vx=E/nt,A.vy=I/nt,A.x+=A.vx*e,A.y+=A.vy*e}const R=new Uint8Array(a),_t=()=>{for(let b=0;b<a;b++){const A=Mo(r[b],s,n.restitution,n.friction),E=ko(r[b],i.width,i.height,n.restitution,n.friction);R[b]=A||E?1:0}},ht=Math.max(1,n.limitIterations);for(let b=0;b<ht;b++)_t(),n.limitIterations>0&&Fe(t,d,n),Be(t,n.minAngularGap);n.limitIterations>0&&(_t(),Fe(t,d,n,R)),Be(t,n.minAngularGap)}function Re(t,e,o){return Math.min(Math.max(t,e),Math.max(e,o))}function Be(t,e){const o=t.rim,n=o.length;if(n<3||e<=0||e>=1)return;X(t);const s=t.core.x,i=t.core.y,c=2*Math.PI/n,r=c*e,a=new Float64Array(n),l=new Float64Array(n);for(let d=0;d<n;d++)a[d]=Math.atan2(o[d].y-i,o[d].x-s);let h=0,u=!0;for(let d=0;d<n;d++){let x=a[(d+1)%n]-a[d];for(;x<=-Math.PI;)x+=2*Math.PI;for(;x>Math.PI;)x-=2*Math.PI;l[d]=x,h+=x,x<r&&(u=!1)}if(u&&Math.abs(h-2*Math.PI)<1e-6)return;const g=2*Math.PI-n*r;let m=0;for(let d=0;d<n;d++){const x=Math.max(l[d],r);l[d]=x,m+=x-r}if(m>1e-9){const d=g/m;for(let x=0;x<n;x++)l[x]=r+(l[x]-r)*d}else l.fill(c);const p=new Float64Array(n);p[0]=a[0];for(let d=1;d<n;d++)p[d]=p[d-1]+l[d-1];let f=0;for(let d=0;d<n;d++){let x=p[d]-a[d];for(;x<=-Math.PI;)x+=2*Math.PI;for(;x>Math.PI;)x-=2*Math.PI;f+=x}f/=n;for(let d=0;d<n;d++){let x=p[d]-f-a[d];for(;x<=-Math.PI;)x+=2*Math.PI;for(;x>Math.PI;)x-=2*Math.PI;x!==0&&os(o[d],s,i,x)}}function os(t,e,o,n){const s=Math.cos(n),i=Math.sin(n),c=t.x-e,r=t.y-o;t.x=e+c*s-r*i,t.y=o+c*i+r*s;const a=t.vx,l=t.vy;t.vx=a*s-l*i,t.vy=a*i+l*s}function ns(t,e,o,n){const s=e.x-t.x,i=e.y-t.y,c=Math.hypot(s,i);if(c<1e-6)return!1;let r=0;if(c>n)r=n;else if(c<o)r=o;else return!1;const a=s/c,l=i/c,h=(c-r)*.5;t.x+=a*h,t.y+=l*h,e.x-=a*h,e.y-=l*h;const u=(e.vx-t.vx)*a+(e.vy-t.vy)*l;if(r===n?u>0:u<0){const m=u*.5;t.vx+=a*m,t.vy+=l*m,e.vx-=a*m,e.vy-=l*m}return!0}function Fe(t,e,o,n=null){const s=t.rim,i=s.length,c=Math.sin(Math.PI/i),r=o.minStretch,a=o.maxStretch;for(let p=0;p<i;p++){const f=(p+1)%i;if(n&&(n[p]||n[f]))continue;const d=(e[p]+e[f])*c;ns(s[p],s[f],d*r,d*a)}X(t);const l=t.core.x,h=t.core.y;let u=0,g=0,m=!1;for(let p=0;p<i;p++){if(n&&n[p])continue;const f=s[p],d=f.x-l,x=f.y-h,v=Math.hypot(d,x);if(v<1e-6)continue;const S=e[p]*r,P=e[p]*a,U=d/v,w=x/v,K=f.vx*U+f.vy*w,C=S*Ne,q=P/Ne;if(v<C&&K<0&&C>S){const R=Math.min(1,(C-v)/(C-S));f.vx-=U*K*R,f.vy-=w*K*R}else if(v>q&&K>0&&P>q){const R=Math.min(1,(v-q)/(P-q));f.vx-=U*K*R,f.vy-=w*K*R}let O=0;if(v<S)O=S;else if(v>P)O=P;else continue;const V=O/v,nt=d*(V-1),Q=x*(V-1);f.x+=nt,f.y+=Q,u+=nt,g+=Q,m=!0;const H=f.vx*U+f.vy*w;(O===S?H<0:H>0)&&(f.vx-=U*H,f.vy-=w*H)}if(m){let p=i;if(n){p=0;for(let f=0;f<i;f++)n[f]||p++}if(p>0){const f=u/p,d=g/p;for(let x=0;x<i;x++)n&&n[x]||(s[x].x-=f,s[x].y-=d)}}X(t)}function Oe(t,e,o,n,s,i,c){if(c<=0)return;const r=t.length;for(let a=0;a<r;a++){const l=(a+n)%r,h=t[a],u=t[l],g=u.x-h.x,m=u.y-h.y,p=Math.hypot(g,m);if(p<1e-6)continue;const f=(s[a]+s[l])*i,d=c*(p-f)/2,x=g/p,v=m/p;e[a]+=d*x,o[a]+=d*v,e[l]-=d*x,o[l]-=d*v}}const He=50,We=2.6,qe=4.5,ss=.14,Ge=2.1,is=.42,rs=900,Xe=2.6,as=64,cs=["circle","blob","ghost","potato","star","flower","heart","diamond","drop","cloud"],Ue=.62,ls=.22;async function hs(t){const e=window.wp?.os;if(e?.loadModules)try{await e.loadModules(["pixijs"])}catch(y){return console.warn("[desktop-mode/mio] PixiJS failed to load.",y),null}const o=window.PIXI;if(!o)return console.warn("[desktop-mode/mio] window.PIXI is undefined; cannot mount."),null;const{host:n,savePosition:s}=t,i=new o.Application;if(await i.init({resizeTo:n,backgroundAlpha:0,antialias:!0,autoDensity:!0,resolution:Math.min(window.devicePixelRatio||1,2)}),!n.isConnected)return i.destroy({removeView:!0},{children:!0,texture:!0}),null;let c=t.config,r=Zt(c);const a=i.canvas;a.style.position="absolute",a.style.inset="0",a.style.width="100%",a.style.height="100%",a.style.pointerEvents="none",n.appendChild(a);const l=us(o,i,r),h=()=>{const y=n.getBoundingClientRect();return{left:y.left,top:y.top}};let u=h();const g=()=>({width:n.clientWidth||1,height:n.clientHeight||1}),m=t.position?{x:t.position.x-u.left,y:t.position.y-u.top}:ds(g(),r.appearance.radius);let p=null,f=0,d=Jt(r.physics.shapeShuffle),x=r.physics.shapePreset;const v=y=>{const k=jt(y,{...r.physics,shapePreset:x});if(!p)return k;const _=jt(y,{...r.physics,shapePreset:p});return _+(k-_)*fs(f/Xe)},S=()=>Math.min(as,Math.max(r.physics.points,$e({...r.physics,shapePreset:x}),p?$e({...r.physics,shapePreset:p}):0)),P=y=>{y!==x&&(p=x,f=0,x=y,d=Jt(r.physics.shapeShuffle),at("os.mio.shape-changed",{shape:x,from:p}))},U=y=>{p&&(f+=y,f>=Xe&&(p=null,f=0));const k=r.physics.shapeShuffle;if(k<=0){P(r.physics.shapePreset),d=0;return}if(d-=y,d>0||p)return;const _=ps(x);d=Jt(k),_!==x&&(p=x,f=0,x=_,at("os.mio.shape-changed",{shape:x,from:p}))};let w=De(Z(m.x,r.appearance.radius,g().width-r.appearance.radius),Z(m.y,r.appearance.radius,g().height-r.appearance.radius),r.appearance.radius,S(),v);const K=()=>{const y=S();y!==w.rim.length&&jn(w,y)},C=document.createElement("div");C.className="os-mio__handle",C.setAttribute("aria-hidden","true"),je(C,r),n.appendChild(C);const q=Io(),O=Eo(He);let V=[],nt=0,Q=!0,H=!1,R=0,_t=We+Math.random()*qe,ht=-1,b=!1,A=0,E=null,I=null,T={x:0,y:0},F=0,N={x:1,y:0},Y=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,W=0,tt=0,$t={x:w.core.x,y:w.core.y};const st=()=>{$t={x:w.core.x,y:w.core.y}},Dt=y=>{if(y>0){const rt=(w.core.x-$t.x)/y,xs=(w.core.y-$t.y)/y,ho=Math.min(1,y*6);W+=(rt-W)*ho,tt+=(xs-tt)*ho}st(),Y||(F+=y*is);let k=Math.cos(F),_=Math.sin(F);const L=Math.hypot(W,tt),$=Math.min(1,L/rs);L>1&&(k=k*(1-$)+W/L*$,_=_*(1-$)+tt/L*$);const J=Math.hypot(k,_)||1,j=Ue+(1-Ue)*$;N={x:k/J*j,y:_/J*j}},ms=y=>{if(y-nt>=He){nt=y,u=h();const k=window.wp?.os?.getWallpaperSurfaces?.();O.sample(Array.isArray(k)?po(k,u,g()):[],y)}V=O.at(y)},Qt=y=>({x:y.x-u.left,y:y.y-u.top}),it=()=>({x:w.core.x+u.left,y:w.core.y+u.top});let dt=0,ft=0,te=0,pt=null;const Ze=()=>typeof performance<"u"?performance.now():R*1e3,gs=y=>{const k=g(),_=w.radius,L=mo(y,_,V);return{x:Z(L.x,_,Math.max(_,k.width-_)),y:Z(L.y,_,Math.max(_,k.height-_))}},Je=y=>{if(b||y.button!==0)return;b=!0,E=y.pointerId;const k=Qt({x:y.clientX,y:y.clientY});T={x:w.core.x-k.x,y:w.core.y-k.y},I={x:w.core.x,y:w.core.y},dt=0,ft=0,te=Ze(),pt={x:k.x,y:k.y},C.classList.add("is-dragging");try{C.setPointerCapture(y.pointerId)}catch{}y.preventDefault(),at("os.mio.grabbed",{position:it()})},Qe=y=>{if(!b||y.pointerId!==E)return;const k=Qt({x:y.clientX,y:y.clientY});I=gs({x:k.x+T.x,y:k.y+T.y});const _=Ze(),L=(_-te)/1e3;if(pt&&L>.001){const $=(k.x-pt.x)/L,J=(k.y-pt.y)/L,j=Math.min(1,L*12);dt+=($-dt)*j,ft+=(J-ft)*j}te=_,pt=k},zt=y=>{if(!b)return;b=!1;const k=E;if(E=null,I=null,pt=null,C.classList.remove("is-dragging"),k!==null)try{C.releasePointerCapture(k)}catch{}if(y){const L=r.physics.throwBoost,$=4e3,J=Math.hypot(dt,ft),j=J>$?$/J*L:L;Jn(w,dt*j,ft*j)}dt=0,ft=0;const _=it();s(_),at("os.mio.dropped",{position:_})},to=y=>{!b||y.pointerId!==E||zt(!0)},eo=y=>{!b||y.pointerId!==E||zt(!1)},oo=()=>zt(!0),no=()=>zt(!1),so=y=>{y.preventDefault(),y.stopPropagation(),Rn({x:y.clientX,y:y.clientY})};C.addEventListener("pointerdown",Je),C.addEventListener("contextmenu",so),C.addEventListener("lostpointercapture",oo),window.addEventListener("pointermove",Qe,!0),window.addEventListener("pointerup",to,!0),window.addEventListener("pointercancel",eo,!0),window.addEventListener("blur",no);const io=()=>{if(H||!Q)return;const y=i.ticker.deltaMS,k=Math.min(y,100)/1e3;R+=k,ms(typeof performance<"u"?performance.now():R*1e3);const _=g();if(b)A=0;else{const rt=wo(w.core.x,w.core.y,w.radius,V,_);rt?(A+=k,A>=ls&&(A=0,Qn(w,rt.x,rt.y),st(),s(it()),at("os.mio.displaced",{position:it()}))):A=0}const L=b?null:yo(w.core.x,w.core.y,w.radius,V,r.physics.magnetRange);ts(w,k,{physics:r.physics,magnet:L,obstacles:V,bounds:_,dragTarget:I}),Dt(k),U(k),K(),ht<0&&R>=_t&&(ht=R);let $=0;if(ht>=0){const rt=(R-ht)/ss;rt>=1?(ht=-1,_t=R+We+Math.random()*qe):$=Math.sin(rt*Math.PI)}const J=q.get();Uo(l,{rim:w.rim,centre:w.core,radius:w.radius,elapsed:R,gaze:J?Qt(J):null,blink:$,tilt:N},r.appearance);const j=w.radius*Ge/2;C.style.transform=`translate3d(${w.core.x-j}px, ${w.core.y-j}px, 0)`};i.ticker.add(io);const ro=new ResizeObserver(()=>{if(H||!n.isConnected||n.clientWidth<=0||n.clientHeight<=0)return;const{width:y,height:k}=g();i.renderer.resize(y,k),u=h(),O.reset();const _=w.radius,L=Z(w.core.x,_,Math.max(_,y-_)),$=Z(w.core.y,_,Math.max(_,k-_));(L!==w.core.x||$!==w.core.y)&&(ze(w,L,$),st())});ro.observe(n);const ao=()=>{lo(!document.hidden)};document.addEventListener("visibilitychange",ao);const ee=typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null,co=()=>{Y=ee?.matches===!0,r=Zt(c)};ee?.addEventListener?.("change",co);function lo(y){H||Q===y||(Q=y,y?(w.accumulator=0,i.ticker.start()):i.ticker.stop())}return at("os.mio.mounted",{position:it()}),{getPosition:()=>it(),setPosition:(y,k)=>{const _=g(),L=w.radius;ze(w,Z(y-u.left,L,Math.max(L,_.width-L)),Z(k-u.top,L,Math.max(L,_.height-L))),st(),s(it())},setAnimating:lo,applyConfig:y=>{c=y;const k=Zt(y),_=k.physics.points!==r.physics.points||k.appearance.radius!==r.appearance.radius,L=k.physics.shapePreset!==r.physics.shapePreset?k.physics.shapePreset:null;if(r=k,L&&P(L),Ve(o,l,r),Ye(o,l,r),je(C,r),_){const $={x:w.core.x,y:w.core.y};w=De($.x,$.y,r.appearance.radius,S(),v),st()}else K()},destroy:()=>{H||(H=!0,n.isConnected&&s(it()),i.ticker.remove(io),ro.disconnect(),document.removeEventListener("visibilitychange",ao),ee?.removeEventListener?.("change",co),C.removeEventListener("pointerdown",Je),C.removeEventListener("contextmenu",so),C.removeEventListener("lostpointercapture",oo),xt(),Tt(),window.removeEventListener("pointermove",Qe,!0),window.removeEventListener("pointerup",to,!0),window.removeEventListener("pointercancel",eo,!0),window.removeEventListener("blur",no),C.remove(),q.destroy(),i.destroy({removeView:!0},{children:!0,texture:!0}),at("os.mio.unmounted",{}))}}}function Zt(t){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches?{appearance:{...t.appearance,hueDrift:0,hueSpin:0},physics:{...t.physics,floatAmplitude:0,shapeShuffle:0}}:t}function us(t,e,o){const n=new t.Container,s=new t.Graphics,i=new t.Graphics,c=new t.Graphics,r=new t.Graphics,a=new t.Graphics,l=new t.Graphics;s.blendMode="add",i.blendMode="add",r.blendMode="add",n.addChild(s),n.addChild(i),n.addChild(c),n.addChild(r),n.addChild(a),n.addChild(l),e.stage.addChild(n);const h={root:n,halo:s,bloom:i,body:c,sheen:r,core:a,eyes:l};return Ve(t,h,o),Ye(t,h,o),h}const Ke="add";function Ve(t,e,o){if(!(o.appearance.glowBlur&&o.appearance.glow>0)||typeof t.BlurFilter!="function"){e.halo.filters=[],e.bloom.filters=[];return}const s=Wo(o.appearance.radius,o.appearance.glow);for(const[i,c]of[[e.halo,s.halo],[e.bloom,s.bloom]])try{i.filters=[new t.BlurFilter({strength:c,quality:2,blendMode:Ke})]}catch{i.filters=[]}}function Ye(t,e,o){if(!(o.appearance.iridescence>0)||typeof t.BlurFilter!="function"){e.sheen.filters=[];return}try{e.sheen.filters=[new t.BlurFilter({strength:Math.min(24,Math.max(3,o.appearance.radius*.12)),quality:2,blendMode:Ke})]}catch{e.sheen.filters=[]}}function je(t,e){const o=`${e.appearance.radius*Ge}px`;t.style.width=o,t.style.height=o}function ds(t,e){return{x:Z(t.width*.22,e,t.width-e),y:Z(t.height*.62,e,t.height-e)}}function Z(t,e,o){return Math.min(Math.max(t,e),Math.max(e,o))}function fs(t){const e=Math.min(1,Math.max(0,t));return e*e*(3-2*e)}function Jt(t){return t>0?t*(.75+Math.random()*.5):0}function ps(t){const e=cs.filter(o=>o!==t);return e[Math.floor(Math.random()*e.length)]??t}window.openStationMountMio=hs})();
64 + `}_onChange(e){const n=e.target.checked;n?this.setAttribute("checked",""):this.removeAttribute("checked"),this.emit("os-checkbox-change",{checked:n,value:this.value})}};St.props=["checked","value","label","disabled"],St.styles=[Gn],St.help=void 0;let Jt=St;dt("os-checkbox",Jt);let Qt=null;function Dt(){return!!window.openStationShellOverlays}function Xn(t){return new Promise((e,o)=>{const n=document.querySelector('script[data-os-shell-overlays="1"]'),s=()=>{if(Dt()){e();return}o(new Error("[openstation] shell-overlays bundle loaded but did not set `window.openStationShellOverlays`."))};if(n){Dt()?s():(n.addEventListener("load",s),n.addEventListener("error",()=>o(new Error("failed to load shell-overlays bundle"))));return}const i=document.createElement("script");i.src=t,i.async=!0,i.dataset.osShellOverlays="1",i.addEventListener("load",s),i.addEventListener("error",()=>o(new Error("failed to load shell-overlays bundle"))),document.head.appendChild(i)})}function Kn(t){return Dt()||!t?Promise.resolve():(Qt||(Qt=Xn(t)),Qt)}function Un(){return window.openStationConfig?.shellOverlaysBundleUrl??""}function Oe(t,e){const o=Un();if(Dt()||!o){e();return}Kn(o).then(()=>{t()&&e()}).catch(n=>{typeof console<"u"&&console.warn("[openstation] shell-overlays failed to load; menu/dialog suppressed:",n)})}const Vn="desktop-mode";function Yn(){return window.wp?.i18n}function w(t,e=Vn){return Yn()?.__(t,e)??t}const bt={appearance:{bodyColor:789263,linerColor:16776191,eyeColor:16776191},physics:{shapeShuffle:60,idleWobble:.085}},jn=["blob","ghost","potato","star","flower","heart","diamond","drop","cloud"];function Zn(t=Math.random){const e=(a,c)=>a+t()*(c-a),o=a=>t()<a,n=a=>a[Math.floor(t()*a.length)%a.length],s=(a,c)=>Math.round(a/c)*c,i=s(e(55,215),1)*(o(.5)?1:-1),r=s(e(2,7),.5);return{appearance:{hueStart:s(e(0,360),1),hueSpan:i,hueAngle:s(e(0,360),1),hueLoop:!0,hueSpin:o(.25)?s(e(-14,14),1):0,hueDrift:o(.15)?s(e(-8,8),1):0,saturation:s(e(.68,1),.01),lightness:s(e(.52,.78),.01),outlineWidth:r,linerWidth:Math.max(1,s(r/2,.5)),linerColor:bt.appearance.linerColor,glow:s(e(4,16),.1),iridescence:o(.34)?s(e(.45,1.25),.05):0,bodyColor:o(.25)?Jn(t):bt.appearance.bodyColor,bodyAlpha:o(.2)?s(e(.78,1),.01):1,eyeColor:bt.appearance.eyeColor,eyeScale:s(e(.2,.42),.01)},physics:{shapePreset:n(jn),shapeAmount:s(e(.7,1.15),.05),shapeAngle:0,idleWobble:s(e(.03,.16),.005),idleWobbleSpeed:s(e(.35,1.1),.05)}}}function Jn(t){const e=()=>Math.floor(t()*42);return e()<<16|e()<<8|e()}function Be(){const t=window.wp?.os?.mio;return t&&typeof t.setStyle=="function"&&typeof t.commitStyle=="function"?t:null}const te="os-mio-menu",We="os-mio-panel";function Qn(t){return`#${Math.max(0,Math.min(16777215,Math.floor(t))).toString(16).padStart(6,"0")}`}function ts(t){const e=/^#?([0-9a-f]{6})$/i.exec(t.trim());return e?Number.parseInt(e[1],16):null}const es="2";function B(t,e,o){const n=document.createElement("os-range-field");return n.setAttribute("label",t.label),n.setAttribute("min",String(t.min)),n.setAttribute("max",String(t.max)),n.setAttribute("step",String(t.step)),n.setAttribute("decimals",es),n.setAttribute("value",String(e[t.key])),n.addEventListener("os-range-change",s=>{const i=s.detail?.value;typeof i=="number"&&Number.isFinite(i)&&o({[t.key]:i})}),n}function ee(t,e,o,n){const s=document.createElement("os-color-field");return s.setAttribute("label",e),s.setAttribute("value",Qn(o[t])),s.addEventListener("os-color-change",i=>{const r=i.detail?.value,a=typeof r=="string"?ts(r):null;a!==null&&n({[t]:a})}),s}function vt(t,e,o){const n=document.createElement("os-checkbox");return n.setAttribute("label",t),n.setAttribute("block",""),e&&n.setAttribute("checked",""),n.addEventListener("os-checkbox-change",s=>{const i=s.detail;o(i?.checked===!0)}),n}function os(){return[{value:"blob",label:w("Blob")},{value:"circle",label:w("Circle")},{value:"potato",label:w("Potato")},{value:"ghost",label:w("Ghost")},{value:"star",label:w("Star")},{value:"flower",label:w("Flower")},{value:"heart",label:w("Heart")},{value:"diamond",label:w("Diamond")},{value:"drop",label:w("Teardrop")},{value:"cloud",label:w("Cloud")},{value:"custom",label:w("Polygon")}]}function ns(t,e){const o=document.createElement("os-select");o.setAttribute("label",w("Shape")),o.setAttribute("value",t);for(const n of os()){const s=document.createElement("os-option");s.setAttribute("value",n.value),s.textContent=n.label,o.appendChild(s)}return o.addEventListener("os-pick",n=>{const s=n.detail?.value;s&&e(s)}),o}function nt(t,e){const o=document.createElement("os-section");o.setAttribute("heading",t);for(const n of e)o.appendChild(n);return o}function Rt(){const t=document.querySelectorAll(`.${We}`);t.length&&(t.forEach(e=>e.remove()),Be()?.commitStyle())}function ss(){const t=++He;Oe(()=>t===He,()=>is())}let He=0,qe=0;function is(){const t=Be();if(!t)return;Rt();const e=document.createElement("os-modal");e.classList.add(We),e.setAttribute("title",w("Make it yours")),e.setAttribute("size","md"),e.setAttribute("open","");const o=document.createElement("div"),n=()=>{const a=t.getConfig(),c=a.appearance,l=a.physics,u={...c,...l},d=g=>t.setStyle(g),f=l.shapePreset==="custom"?[B({key:"shapeLobes",label:w("Corners"),min:2,max:8,step:1},u,d)]:[];o.replaceChildren(nt(w("Desktop"),[vt(w("Show MIO on wallpaper"),window.wp?.os?.getOsSettings?.().mioShowOnWallpaper!==!1,g=>window.wp?.os?.updateOsSettings?.({mioShowOnWallpaper:g}))]),nt(w("Shape"),[ns(l.shapePreset,g=>{d({shapePreset:g}),n()}),...f,B({key:"shapeAmount",label:w("Shape strength"),min:0,max:1.4,step:.05},u,d),B({key:"shapeAngle",label:w("Rotation"),min:0,max:360,step:1},u,d),vt(w("Change shape on its own"),l.shapeShuffle>0,g=>{d({shapeShuffle:g?bt.physics.shapeShuffle:0})})]),nt(w("Idle"),[vt(w("Wobble when idle"),l.idleWobble>0,g=>{d({idleWobble:g?bt.physics.idleWobble:0}),n()}),...l.idleWobble>0?[B({key:"idleWobble",label:w("Wobble strength"),min:0,max:.4,step:.005},u,d),B({key:"idleWobbleSpeed",label:w("Wobble speed"),min:0,max:4,step:.05},u,d)]:[]]),nt(w("Colour"),[B({key:"hueStart",label:w("Hue"),min:0,max:360,step:1},u,d),B({key:"hueSpan",label:w("Hue spread"),min:-360,max:360,step:1},u,d),B({key:"saturation",label:w("Saturation"),min:0,max:1,step:.01},u,d),B({key:"lightness",label:w("Brightness"),min:.15,max:1,step:.01},u,d)]),nt(w("Ring"),[B({key:"outlineWidth",label:w("Thickness"),min:.5,max:24,step:.5},u,d),B({key:"linerWidth",label:w("Inner line"),min:0,max:12,step:.5},u,d),ee("linerColor",w("Inner line colour"),c,d),B({key:"glow",label:w("Glow"),min:0,max:20,step:.1},u,d)]),nt(w("Gradient"),[B({key:"hueAngle",label:w("Gradient angle"),min:0,max:360,step:1},u,d),vt(w("Loop the gradient (no seam)"),c.hueLoop,g=>d({hueLoop:g})),B({key:"hueSpin",label:w("Spin the gradient"),min:-60,max:60,step:1},u,d),B({key:"hueDrift",label:w("Cycle the colours"),min:-60,max:60,step:1},u,d)]),nt(w("Hologram"),[vt(w("Holographic"),c.iridescence>0,g=>{d({iridescence:g?.7:0}),n()}),...c.iridescence>0?[B({key:"iridescence",label:w("Iridescence"),min:0,max:2,step:.05},u,d)]:[]]),nt(w("Body"),[ee("bodyColor",w("Body colour"),c,d),B({key:"bodyAlpha",label:w("Body opacity"),min:0,max:1,step:.01},u,d)]),nt(w("Eyes"),[ee("eyeColor",w("Eye colour"),c,d),B({key:"eyeScale",label:w("Eye size"),min:.05,max:.6,step:.01},u,d)]))};n(),e.appendChild(o);const s=document.createElement("os-button");s.setAttribute("slot","footer"),s.setAttribute("variant","secondary"),s.textContent=w("Surprise me"),s.addEventListener("click",()=>{const a=Zn();t.setStyle({...a.appearance,...a.physics}),n()});const i=document.createElement("os-button");i.setAttribute("slot","footer"),i.setAttribute("variant","secondary"),i.textContent=w("Restore Mio"),i.addEventListener("click",()=>{t.resetStyle(),n()});const r=document.createElement("os-button");r.setAttribute("slot","footer"),r.setAttribute("variant","primary"),r.textContent=w("Done"),r.addEventListener("click",()=>Rt()),e.appendChild(s),e.appendChild(i),e.appendChild(r),e.addEventListener("os-modal-cancel",()=>Rt()),document.body.appendChild(e)}function wt(){document.querySelectorAll(`.${te}`).forEach(t=>t.remove()),document.removeEventListener("pointerdown",Ge,!0),document.removeEventListener("keydown",Xe,!0)}function Ge(t){t.target?.closest(`.${te}`)||wt()}function Xe(t){t.key==="Escape"&&wt()}function rs(t){wt();const e=++qe;Oe(()=>e===qe,()=>as(t))}function as(t){const e=document.createElement("os-context-menu");e.classList.add(te),e.setAttribute("open",""),e.style.left=`${t.x}px`,e.style.top=`${t.y}px`;const o=document.createElement("os-context-menu-option");o.setAttribute("value","make-it-yours"),o.setAttribute("icon","dashicons-art"),o.dataset.menuItemId="make-it-yours",o.textContent=w("Make it yours"),e.appendChild(o),e.addEventListener("os-context-menu-pick",()=>{wt(),ss()}),document.body.appendChild(e),document.addEventListener("pointerdown",Ge,!0),document.addEventListener("keydown",Xe,!0)}const Ke=Math.PI/2,Mt=Math.PI*2,cs=.05;function pt(t){return((t+Ke)%Mt+Mt)%Mt}function oe(t,e){return Math.pow(.5+.5*t,e)}function ls(t){const e=Math.max(0,Math.sin(t)),o=2+3.2*e,n=Math.abs(Math.cos(t)),s=Math.abs(Math.sin(t)),i=1/Math.pow(Math.pow(n,o)+Math.pow(s,o),1/o)-1,r=-.17*Math.pow(e,1.4)*Math.cos(6*t);return i+r}function ds(t){return .16*Math.cos(2*t+.9)+.095*Math.cos(3*t-2.1)+.036*Math.cos(5*t+1.3)+.019*Math.cos(7*t-.4)}function us(t){return .58*(oe(Math.cos(5*t),3)-.3125)}function hs(t){return .34*(oe(Math.cos(6*t),2)-.375)}function fs(t){return .34*(oe(Math.cos(4*t),2)-.375)}function ps(t){return .72*(Math.pow(Math.max(0,Math.cos(t)),8)-.1367)}function ms(t){const e=Math.max(0,Math.cos(t)),o=Math.max(0,-Math.cos(t));return .34*(Math.sqrt(e)*(.5+.5*Math.cos(5*t))-.7*o*o-.0247)}function gs(t){const e=t>Math.PI?Mt-t:t,o=-.34*Math.pow(Math.max(0,Math.cos(t)),6),n=.3*Math.pow(Math.max(0,Math.cos(e-1)),3),s=.34*Math.pow(Math.max(0,-Math.cos(t)),8);return o+n+s+.02}function xs(t,e){switch(e.shapePreset){case"circle":return 0;case"ghost":return ls(t);case"potato":return ds(t);case"star":return us(pt(t));case"flower":return hs(pt(t));case"diamond":return fs(pt(t));case"drop":return ps(pt(t));case"cloud":return ms(pt(t));case"heart":return gs(pt(t));case"custom":{const o=Math.round(e.shapeLobes);return o<2?0:1/(1+o*o)*Math.cos(o*t)}default:return cs*Math.cos(3*(t+Ke))}}function Ue(t){switch(t.shapePreset){case"star":return 40;case"flower":return 36;case"heart":case"cloud":return 32;case"drop":return 28;case"ghost":return 26;case"potato":case"diamond":return 24;case"custom":return Math.max(12,Math.round(t.shapeLobes)*7);default:return 12}}function ne(t,e){if(e.shapeAmount<=0)return 1;const o=t-e.shapeAngle*Math.PI/180;return 1+e.shapeAmount*xs(o,e)}const ys=1200,Ve=1.25;function Ye(t,e,o,n,s){const i=Math.max(3,Math.round(n)),r=[];for(let a=0;a<i;a++){const c=a/i*Math.PI*2,l=o*(s?s(c):1);r.push({angle:c,x:t+Math.cos(c)*l,y:e+Math.sin(c)*l,vx:0,vy:0})}return{core:{x:t,y:e,vx:0,vy:0},rim:r,radius:o,profile:s,restArea:.5*i*o*o*Math.sin(2*Math.PI/i),elapsed:0,accumulator:0}}function bs(t,e){const o=Math.max(3,Math.round(e)),n=t.rim,s=n.length;if(o===s||s<3)return;Q(t);const i=t.core.x,r=t.core.y,a=l=>Math.hypot(l.x-i,l.y-r),c=new Array(o);for(let l=0;l<o;l++){const u=l/o*s,d=Math.floor(u),f=u-d,g=n[d%s],p=n[(d+1)%s];let m=g.x+(p.x-g.x)*f,h=g.y+(p.y-g.y)*f;const x=Math.hypot(m-i,h-r);if(x>1e-6){const v=a(g)+(a(p)-a(g))*f;m=i+(m-i)/x*v,h=r+(h-r)/x*v}c[l]={angle:l/o*Mt,x:m,y:h,vx:g.vx+(p.vx-g.vx)*f,vy:g.vy+(p.vy-g.vy)*f}}t.rim=c,t.restArea=.5*o*t.radius*t.radius*Math.sin(2*Math.PI/o),Q(t)}function vs(t){let e=0;for(let o=0;o<t.length;o++){const n=t[o],s=t[(o+1)%t.length];e+=n.x*s.y-s.x*n.y}return e/2}function Q(t){let e=0,o=0,n=0,s=0;for(const r of t.rim)e+=r.x,o+=r.y,n+=r.vx,s+=r.vy;const i=t.rim.length||1;t.core.x=e/i,t.core.y=o/i,t.core.vx=n/i,t.core.vy=s/i}function je(t,e,o){Q(t);const n=e-t.core.x,s=o-t.core.y;for(const i of t.rim)i.x+=n,i.y+=s;Q(t)}function ws(t,e,o){for(const n of t.rim)n.vx+=e,n.vy+=o;Q(t)}function Ms(t,e,o){const n=t.rim.length;for(let s=0;s<n;s++){const i=t.rim[s],r=t.radius*(t.profile?t.profile(i.angle):1);i.x=e+Math.cos(i.angle)*r,i.y=o+Math.sin(i.angle)*r,i.vx=0,i.vy=0}t.accumulator=0,Q(t)}function ks(t,e,o){const{physics:n}=o,s=n.subStep,i=Number.isFinite(e)?e:0,r=Math.min(Math.max(i,0),s*n.maxSubSteps);t.accumulator+=r;let a=0;for(;t.accumulator>=s&&a<n.maxSubSteps;)t.accumulator-=s,a++,_s(t,s,o);t.accumulator>s*n.maxSubSteps&&(t.accumulator=0),Q(t)}function _s(t,e,o){const{physics:n,obstacles:s,bounds:i,dragTarget:r}=o,a=t.rim,c=a.length;t.elapsed+=e,Q(t);const l=t.core,u=o.magnet,d=u?Math.min(1,Math.max(0,u.strength)):0,f=1-d,g=o.dragTarget?0:f,p=new Float64Array(c),m=new Float64Array(c),h=new Float64Array(c),x=t.profile;for(let y=0;y<c;y++){const S=a[y].angle;h[y]=t.radius*(x?x(S):ne(S,n))}const v=n.idleWobble*g;if(v>0){const y=n.idleWobbleSpeed*t.elapsed;for(let S=0;S<c;S++){const L=a[S].angle,E=.55*Math.sin(2*L+y)+.3*Math.sin(3*L-y*1.37+2.1)+.15*Math.sin(5*L+y*.71+4.2);h[S]*=1+v*E}}if(n.speedStretch>0){const y=Math.hypot(l.vx,l.vy);if(y>1){const L=1+n.speedStretch*Math.min(1,y/ys),E=L*L,T=l.vx/y,D=l.vy/y;for(let P=0;P<c;P++){const q=a[P].angle,J=Math.cos(q)*T+Math.sin(q)*D,rt=J*J;h[P]/=Math.sqrt(rt/E+E*(1-rt))}}}let _=0;for(let y=0;y<c;y++)_+=h[y]*h[(y+1)%c];if(_*=.5*Math.sin(2*Math.PI/c),n.radialStiffness>0)for(let y=0;y<c;y++){const S=a[y];let L=S.x-l.x,E=S.y-l.y,T=Math.hypot(L,E);T<1e-6&&(L=Math.cos(S.angle),E=Math.sin(S.angle),T=1);const D=n.radialStiffness*(T-h[y]);p[y]-=D*L/T,m[y]-=D*E/T}if(Qe(a,p,m,1,h,Math.sin(Math.PI/c),n.edgeStiffness),c>4&&n.bendStiffness>0&&Qe(a,p,m,2,h,Math.sin(2*Math.PI/c),n.bendStiffness),n.pressure>0){const y=vs(a),S=Math.abs(y),L=Math.min(2,Math.max(-1,_/Math.max(S,.001)-1));if(L!==0){const E=y<0?-1:1,T=2*t.radius*Math.sin(Math.PI/c),D=n.pressure*L*E/(2*T);for(let P=0;P<c;P++){const q=a[P],J=a[(P+1)%c],rt=J.x-q.x,ut=(J.y-q.y)*D,ht=-rt*D;p[P]+=ut,m[P]+=ht,p[(P+1)%c]+=ut,m[(P+1)%c]+=ht}}}let $=0,V=0;for(let y=0;y<c;y++)$+=p[y],V+=m[y];$/=c,V/=c;const M=n.floatSpeed,X=-n.floatAmplitude*M*M*Math.sin(M*t.elapsed),N=-.17*n.floatAmplitude*M*M*Math.sin(M*.7*t.elapsed+1.1);let H=f*N,O=f*X;if(u){const y=-t.radius*n.magnetGrip,S=Math.max(1,t.radius*.35),L=Math.min(1,Math.max(-1,(u.gap-y)/S)),E=n.magnetStrength*d*L;H+=u.dx*E,O+=u.dy*E;const T=n.magnetDamping*d;H-=l.vx*T,O-=l.vy*T}if(o.anchor&&!r){const y=t.radius,S=Ft(o.anchor.x,y,Math.max(y,i.width-y)),L=Ft(o.anchor.y,y,Math.max(y,i.height-y)),E=48,T=2*Math.sqrt(E);H=(S-l.x)*E-l.vx*T,O=(L-l.y)*E-l.vy*T}if(r){const y=t.radius,S=Ft(r.x,y,Math.max(y,i.width-y)),L=Ft(r.y,y,Math.max(y,i.height-y)),E=n.dragStiffness,T=2*Math.sqrt(E);let D=(S-l.x)*E-l.vx*T,P=(L-l.y)*E-l.vy*T;const q=Math.hypot(D,P);if(q>n.dragMaxAccel){const J=n.dragMaxAccel/q;D*=J,P*=J}H+=D,O+=P}const R=1+n.damping*e,j=1+n.airDamping*e,tt=l.vx,K=l.vy;for(let y=0;y<c;y++){const S=a[y];let L=S.vx+(p[y]-$+H)*e,E=S.vy+(m[y]-V+O)*e;L=tt+(L-tt)/R,E=K+(E-K)/R,S.vx=L/j,S.vy=E/j,S.x+=S.vx*e,S.y+=S.vy*e}const C=new Uint8Array(c),z=()=>{for(let y=0;y<c;y++){const S=Wo(a[y],s,n.restitution,n.friction),L=Ho(a[y],i.width,i.height,n.restitution,n.friction);C[y]=S||L?1:0}},Z=Math.max(1,n.limitIterations);for(let y=0;y<Z;y++)z(),n.limitIterations>0&&Je(t,h,n),Ze(t,n.minAngularGap);n.limitIterations>0&&(z(),Je(t,h,n,C)),Ze(t,n.minAngularGap)}function Ft(t,e,o){return Math.min(Math.max(t,e),Math.max(e,o))}function Ze(t,e){const o=t.rim,n=o.length;if(n<3||e<=0||e>=1)return;Q(t);const s=t.core.x,i=t.core.y,r=2*Math.PI/n,a=r*e,c=new Float64Array(n),l=new Float64Array(n);for(let h=0;h<n;h++)c[h]=Math.atan2(o[h].y-i,o[h].x-s);let u=0,d=!0;for(let h=0;h<n;h++){let x=c[(h+1)%n]-c[h];for(;x<=-Math.PI;)x+=2*Math.PI;for(;x>Math.PI;)x-=2*Math.PI;l[h]=x,u+=x,x<a&&(d=!1)}if(d&&Math.abs(u-2*Math.PI)<1e-6)return;const f=2*Math.PI-n*a;let g=0;for(let h=0;h<n;h++){const x=Math.max(l[h],a);l[h]=x,g+=x-a}if(g>1e-9){const h=f/g;for(let x=0;x<n;x++)l[x]=a+(l[x]-a)*h}else l.fill(r);const p=new Float64Array(n);p[0]=c[0];for(let h=1;h<n;h++)p[h]=p[h-1]+l[h-1];let m=0;for(let h=0;h<n;h++){let x=p[h]-c[h];for(;x<=-Math.PI;)x+=2*Math.PI;for(;x>Math.PI;)x-=2*Math.PI;m+=x}m/=n;for(let h=0;h<n;h++){let x=p[h]-m-c[h];for(;x<=-Math.PI;)x+=2*Math.PI;for(;x>Math.PI;)x-=2*Math.PI;x!==0&&As(o[h],s,i,x)}}function As(t,e,o,n){const s=Math.cos(n),i=Math.sin(n),r=t.x-e,a=t.y-o;t.x=e+r*s-a*i,t.y=o+r*i+a*s;const c=t.vx,l=t.vy;t.vx=c*s-l*i,t.vy=c*i+l*s}function Es(t,e,o,n){const s=e.x-t.x,i=e.y-t.y,r=Math.hypot(s,i);if(r<1e-6)return!1;let a=0;if(r>n)a=n;else if(r<o)a=o;else return!1;const c=s/r,l=i/r,u=(r-a)*.5;t.x+=c*u,t.y+=l*u,e.x-=c*u,e.y-=l*u;const d=(e.vx-t.vx)*c+(e.vy-t.vy)*l;if(a===n?d>0:d<0){const g=d*.5;t.vx+=c*g,t.vy+=l*g,e.vx-=c*g,e.vy-=l*g}return!0}function Je(t,e,o,n=null){const s=t.rim,i=s.length,r=Math.sin(Math.PI/i),a=o.minStretch,c=o.maxStretch;for(let p=0;p<i;p++){const m=(p+1)%i;if(n&&(n[p]||n[m]))continue;const h=(e[p]+e[m])*r;Es(s[p],s[m],h*a,h*c)}Q(t);const l=t.core.x,u=t.core.y;let d=0,f=0,g=!1;for(let p=0;p<i;p++){if(n&&n[p])continue;const m=s[p],h=m.x-l,x=m.y-u,v=Math.hypot(h,x);if(v<1e-6)continue;const _=e[p]*a,$=e[p]*c,V=h/v,M=x/v,X=m.vx*V+m.vy*M,N=_*Ve,H=$/Ve;if(v<N&&X<0&&N>_){const C=Math.min(1,(N-v)/(N-_));m.vx-=V*X*C,m.vy-=M*X*C}else if(v>H&&X>0&&$>H){const C=Math.min(1,(v-H)/($-H));m.vx-=V*X*C,m.vy-=M*X*C}let O=0;if(v<_)O=_;else if(v>$)O=$;else continue;const R=O/v,j=h*(R-1),tt=x*(R-1);m.x+=j,m.y+=tt,d+=j,f+=tt,g=!0;const K=m.vx*V+m.vy*M;(O===_?K<0:K>0)&&(m.vx-=V*K,m.vy-=M*K)}if(g){let p=i;if(n){p=0;for(let m=0;m<i;m++)n[m]||p++}if(p>0){const m=d/p,h=f/p;for(let x=0;x<i;x++)n&&n[x]||(s[x].x-=m,s[x].y-=h)}}Q(t)}function Qe(t,e,o,n,s,i,r){if(r<=0)return;const a=t.length;for(let c=0;c<a;c++){const l=(c+n)%a,u=t[c],d=t[l],f=d.x-u.x,g=d.y-u.y,p=Math.hypot(f,g);if(p<1e-6)continue;const m=(s[c]+s[l])*i,h=r*(p-m)/2,x=f/p,v=g/p;e[c]+=h*x,o[c]+=h*v,e[l]-=h*x,o[l]-=h*v}}const to=50,eo=2.6,oo=4.5,Ss=.14,no=2.1,Cs=.42,Ls=900,so=2.6,Is=64,$s=["circle","blob","ghost","potato","star","flower","heart","diamond","drop","cloud"],io=.62,Ps=.22;async function Ns(t){const e=window.wp?.os;if(e?.loadModules)try{await e.loadModules(["pixijs"])}catch(b){return console.warn("[desktop-mode/mio] PixiJS failed to load.",b),null}const o=window.PIXI;if(!o)return console.warn("[desktop-mode/mio] window.PIXI is undefined; cannot mount."),null;const{host:n,savePosition:s}=t,i=new o.Application;if(await i.init({resizeTo:n,backgroundAlpha:0,antialias:!0,autoDensity:!0,resolution:Math.min(window.devicePixelRatio||1,2)}),!n.isConnected)return i.destroy({removeView:!0},{children:!0,texture:!0}),null;let r=t.config,a=se(r);const c=i.canvas;c.style.position="absolute",c.style.inset="0",c.style.width="100%",c.style.height="100%",c.style.pointerEvents="none",n.appendChild(c);const l=Ts(o,i,a),u=()=>{const b=n.getBoundingClientRect();return{left:b.left,top:b.top}};let d=u();const f=()=>({width:n.clientWidth||1,height:n.clientHeight||1}),g=t.position?{x:t.position.x-d.left,y:t.position.y-d.top}:zs(f(),a.appearance.radius);let p=null,m=0,h=ie(a.physics.shapeShuffle),x=a.physics.shapePreset;const v=b=>{const k=ne(b,{...a.physics,shapePreset:x});if(!p)return k;const A=ne(b,{...a.physics,shapePreset:p});return A+(k-A)*Ds(m/so)},_=()=>Math.min(Is,Math.max(a.physics.points,Ue({...a.physics,shapePreset:x}),p?Ue({...a.physics,shapePreset:p}):0)),$=b=>{b!==x&&(p=x,m=0,x=b,h=ie(a.physics.shapeShuffle),lt("os.mio.shape-changed",{shape:x,from:p}))},V=b=>{p&&(m+=b,m>=so&&(p=null,m=0));const k=a.physics.shapeShuffle;if(k<=0){$(a.physics.shapePreset),h=0;return}if(h-=b,h>0||p)return;const A=Rs(x);h=ie(k),A!==x&&(p=x,m=0,x=A,lt("os.mio.shape-changed",{shape:x,from:p}))};let M=Ye(et(g.x,a.appearance.radius,f().width-a.appearance.radius),et(g.y,a.appearance.radius,f().height-a.appearance.radius),a.appearance.radius,_(),v);const X=()=>{const b=_();b!==M.rim.length&&bs(M,b)},N=document.createElement("div");N.className="os-mio__handle",N.setAttribute("aria-hidden","true"),lo(N,a),n.appendChild(N);const H=Vo(),O=Ko(to);let R=[],j=0,tt=!0,K=!1,C=0,z=eo+Math.random()*oo,Z=-1,y=!1,S=null,L=!1,E=!1,T=0,D=null,P=null,q={x:0,y:0},J=0,rt=0,le={x:1,y:0},ut=typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches,ht=0,Bt=0,de={x:M.core.x,y:M.core.y};const It=()=>{de={x:M.core.x,y:M.core.y}},Ys=b=>{if(b>0){const Js=(M.core.x-de.x)/b,Qs=(M.core.y-de.y)/b,So=Math.min(1,b*6);ht+=(Js-ht)*So,Bt+=(Qs-Bt)*So}It(),ut||(J+=b*Cs);let k=Math.cos(J),A=Math.sin(J);const I=Math.hypot(ht,Bt),W=Math.min(1,I/Ls);I>1&&(k=k*(1-W)+ht/I*W,A=A*(1-W)+Bt/I*W);const Y=Math.hypot(k,A)||1,ct=io+(1-io)*W;le={x:k/Y*ct,y:A/Y*ct}},js=b=>{if(n.dataset.mioWindow){d=u(),O.reset(),R=[];return}if(b-j>=to){j=b,d=u();const k=window.wp?.os?.getWallpaperSurfaces?.();O.sample(Array.isArray(k)?No(k,d,f()):[],b)}R=O.at(b)},Wt=b=>({x:b.x-d.left,y:b.y-d.top}),at=()=>({x:M.core.x+d.left,y:M.core.y+d.top});let mt=0,gt=0,ue=0,xt=null;const fo=()=>typeof performance<"u"?performance.now():C*1e3,Zs=b=>{const k=f(),A=M.radius,I=To(b,A,R);return{x:et(I.x,A,Math.max(A,k.width-A)),y:et(I.y,A,Math.max(A,k.height-A))}},po=b=>{if(y||b.button!==0)return;y=!0,E||(S=null),D=b.pointerId;const k=Wt({x:b.clientX,y:b.clientY});q={x:M.core.x-k.x,y:M.core.y-k.y},P={x:M.core.x,y:M.core.y},mt=0,gt=0,ue=fo(),xt={x:k.x,y:k.y},N.classList.add("is-dragging");try{N.setPointerCapture(b.pointerId)}catch{}b.preventDefault(),lt("os.mio.grabbed",{position:at()})},mo=b=>{if(!y||b.pointerId!==D)return;const k=Wt({x:b.clientX,y:b.clientY});P=Zs({x:k.x+q.x,y:k.y+q.y});const A=fo(),I=(A-ue)/1e3;if(xt&&I>.001){const W=(k.x-xt.x)/I,Y=(k.y-xt.y)/I,ct=Math.min(1,I*12);mt+=(W-mt)*ct,gt+=(Y-gt)*ct}ue=A,xt=k},Ht=b=>{if(!y)return;y=!1;const k=D;if(D=null,P=null,xt=null,N.classList.remove("is-dragging"),k!==null)try{N.releasePointerCapture(k)}catch{}if(b){const I=a.physics.throwBoost,W=4e3,Y=Math.hypot(mt,gt),ct=Y>W?W/Y*I:I;ws(M,mt*ct,gt*ct)}mt=0,gt=0;const A=at();s(A),lt("os.mio.dropped",{position:A})},go=b=>{!y||b.pointerId!==D||Ht(!0)},xo=b=>{!y||b.pointerId!==D||Ht(!1)},yo=()=>Ht(!0),bo=()=>Ht(!1),vo=b=>{b.preventDefault(),b.stopPropagation(),rs({x:b.clientX,y:b.clientY})};N.addEventListener("pointerdown",po),N.addEventListener("contextmenu",vo),N.addEventListener("lostpointercapture",yo),window.addEventListener("pointermove",mo,!0),window.addEventListener("pointerup",go,!0),window.addEventListener("pointercancel",xo,!0),window.addEventListener("blur",bo);let he=0;const wo=()=>{const b=H.get(),k=$o({rim:M.rim,centre:M.core,radius:M.radius,elapsed:C,gaze:b?Wt(b):null,blink:he,tilt:le},a.appearance,rt,ut);hn(l,k.frame,k.appearance);const A=M.radius*no/2;N.style.transform=`translate3d(${M.core.x-A}px, ${M.core.y-A}px, 0)`},Mo=()=>{if(K||!tt)return;const b=i.ticker.deltaMS,k=Math.min(b,100)/1e3;C+=k,js(typeof performance<"u"?performance.now():C*1e3);const A=f(),I=L?Po(R):R;if(y)T=0;else{const Y=Bo(M.core.x,M.core.y,M.radius,I,A);Y?(T+=k,T>=Ps&&(T=0,Ms(M,Y.x,Y.y),It(),s(at()),lt("os.mio.displaced",{position:at()}))):T=0}const W=y||L?null:Ro(M.core.x,M.core.y,M.radius,I,a.physics.magnetRange);if(ks(M,k,{physics:a.physics,magnet:W,obstacles:I,bounds:A,dragTarget:P,anchor:y?null:S}),Ys(k),V(k),X(),Z<0&&C>=z&&(Z=C),he=0,Z>=0){const Y=(C-Z)/Ss;Y>=1?(Z=-1,z=C+eo+Math.random()*oo):he=Math.sin(Y*Math.PI)}rt=Io(rt,n.dataset.mioThinking==="true",k,ut),wo()};i.ticker.add(Mo);const ko=new ResizeObserver(()=>{if(K||!n.isConnected||n.clientWidth<=0||n.clientHeight<=0)return;const{width:b,height:k}=f();Lo(i,{width:b,height:k},()=>{d=u(),O.reset();const A=M.radius,I=et(M.core.x,A,Math.max(A,b-A)),W=et(M.core.y,A,Math.max(A,k-A));(I!==M.core.x||W!==M.core.y)&&(je(M,I,W),It()),wo()})});ko.observe(n);const _o=()=>{Eo(!document.hidden)};document.addEventListener("visibilitychange",_o);const fe=typeof window.matchMedia=="function"?window.matchMedia("(prefers-reduced-motion: reduce)"):null,Ao=()=>{ut=fe?.matches===!0,a=se(r)};fe?.addEventListener?.("change",Ao);function Eo(b){K||tt===b||(tt=b,b?(M.accumulator=0,i.ticker.start()):i.ticker.stop())}return lt("os.mio.mounted",{position:at()}),{getPosition:()=>at(),setPosition:(b,k)=>{S=null,d=u(),O.reset(),R=[];const A=f(),I=M.radius;je(M,et(b-d.left,I,Math.max(I,A.width-I)),et(k-d.top,I,Math.max(I,A.height-I))),It(),s(at())},setFloating:b=>{L=b},setAnchor:(b,k=!0)=>{d=u(),S=b?Wt(b):null,E=k},setAnimating:Eo,applyConfig:b=>{r=b;const k=se(b),A=k.physics.points!==a.physics.points||k.appearance.radius!==a.appearance.radius,I=k.physics.shapePreset!==a.physics.shapePreset?k.physics.shapePreset:null;if(a=k,I&&$(I),ao(o,l,a),co(o,l,a),lo(N,a),A){const W={x:M.core.x,y:M.core.y};M=Ye(W.x,W.y,a.appearance.radius,_(),v),It()}else X()},destroy:()=>{K||(K=!0,n.isConnected&&s(at()),i.ticker.remove(Mo),ko.disconnect(),document.removeEventListener("visibilitychange",_o),fe?.removeEventListener?.("change",Ao),N.removeEventListener("pointerdown",po),N.removeEventListener("contextmenu",vo),N.removeEventListener("lostpointercapture",yo),wt(),Rt(),window.removeEventListener("pointermove",mo,!0),window.removeEventListener("pointerup",go,!0),window.removeEventListener("pointercancel",xo,!0),window.removeEventListener("blur",bo),N.remove(),H.destroy(),i.destroy({removeView:!0},{children:!0,texture:!0}),lt("os.mio.unmounted",{}))}}}function se(t){return typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches?{appearance:{...t.appearance,hueDrift:0,hueSpin:0},physics:{...t.physics,floatAmplitude:0,shapeShuffle:0}}:t}function Ts(t,e,o){const n=new t.Container,s=new t.Graphics,i=new t.Graphics,r=new t.Graphics,a=new t.Graphics,c=new t.Graphics,l=new t.Graphics,u=new t.Graphics;s.blendMode="add",i.blendMode="add",a.blendMode="add",n.addChild(s),n.addChild(i),n.addChild(r),n.addChild(a),n.addChild(c),n.addChild(l),n.addChild(u),e.stage.addChild(n);const d={root:n,halo:s,bloom:i,body:r,sheen:a,liner:c,core:l,eyes:u};return ao(t,d,o),co(t,d,o),d}const ro="add";function ao(t,e,o){if(!(o.appearance.glowBlur&&o.appearance.glow>0)||typeof t.BlurFilter!="function"){e.halo.filters=[],e.bloom.filters=[];return}const s=cn(o.appearance.radius,o.appearance.glow);for(const[i,r]of[[e.halo,s.halo],[e.bloom,s.bloom]])try{i.filters=[new t.BlurFilter({strength:r,quality:2,blendMode:ro})]}catch{i.filters=[]}}function co(t,e,o){if(!(o.appearance.iridescence>0)||typeof t.BlurFilter!="function"){e.sheen.filters=[];return}try{e.sheen.filters=[new t.BlurFilter({strength:Math.min(24,Math.max(3,o.appearance.radius*.12)),quality:2,blendMode:ro})]}catch{e.sheen.filters=[]}}function lo(t,e){const o=`${e.appearance.radius*no}px`;t.style.width=o,t.style.height=o}function zs(t,e){return{x:et(t.width*.22,e,t.width-e),y:et(t.height*.62,e,t.height-e)}}function et(t,e,o){return Math.min(Math.max(t,e),Math.max(e,o))}function Ds(t){const e=Math.min(1,Math.max(0,t));return e*e*(3-2*e)}function ie(t){return t>0?t*(.75+Math.random()*.5):0}function Rs(t){const e=$s.filter(o=>o!==t);return e[Math.floor(Math.random()*e.length)]??t}const Fs=F` ${ft} ${De}:host{--_field-size:var( --os-ui-field-font-size,13px );--_field-radius:var( --os-ui-field-radius,6px );display:flex;flex-direction:column;gap:4px;font-size:var( --_field-size );color:var( --os-ui-fg,#1d2327 );min-width:0}:host( [ hidden ] ){display:none}.os-textarea__label{font-size:12px;color:var( --os-ui-fg-muted,#646970 )}textarea{appearance:none;-webkit-appearance:none;display:block;width:100%;min-width:0;box-sizing:border-box;padding:8px 10px;background:var( --os-window-bg,#fff );border:1px solid var( --os-ui-border,#dcdcde );border-radius:var( --_field-radius );font:inherit;font-size:var( --_field-size );line-height:1.45;color:var( --os-ui-fg,#1d2327 );resize:vertical}textarea:disabled{opacity:0.55;cursor:not-allowed;background:var( --os-ui-hover,rgba( 0,0,0,0.03 ) )}textarea[ aria-invalid='true' ],textarea[ aria-invalid='true' ]:hover:not(:disabled ){border-color:var( --os-ui-danger,#d63638 )}textarea[ aria-invalid='true' ]:focus,textarea[ aria-invalid='true' ]:focus-visible{border-color:var( --os-ui-danger,#d63638 );box-shadow:0 0 0 1px var( --os-ui-danger,#d63638 ),0 0 0 4px rgba( 214,54,56,0.18 )}:host( [ auto-grow ] ) textarea{resize:none;overflow:hidden}`,Ct=class Ct extends ot{constructor(){super(...arguments),this._textareaEl=null}connectedCallback(){super.connectedCallback(),Cn(this)}render(){const e=this._attr("label")||"",o=this._attr("value")??"",n=this._attr("placeholder")||"",s=this._boolAttr("disabled"),i=this._boolAttr("readonly"),r=this._attr("aria-label")||e,a=this._attr("name")||"",c=Number(this._attr("rows"))||3,l=this._attr("maxlength"),u=this._attr("minlength"),d=this._boolAttr("invalid"),g=`${this.id||"os-unnamed"}__field`;return G`
65 + ${e?G`<label class="os-textarea__label" for=${g}>${e}</label>`:G``}
66 + <textarea
67 + id=${g}
68 + part="textarea"
69 + .value=${o}
70 + placeholder=${n}
71 + ?disabled=${s}
72 + ?readonly=${i}
73 + rows=${c}
74 + maxlength=${l??""}
75 + minlength=${u??""}
76 + name=${a}
77 + aria-invalid=${d?"true":"false"}
78 + aria-label=${r||""}
79 + @input=${p=>this._onInput(p)}
80 + @change=${p=>this._onChange(p)}
81 + @keydown=${p=>this._onKeyDown(p)}
82 + ></textarea>
83 + `}_attr(e){return this.getAttribute(e)}_boolAttr(e){return this.getAttribute(e)!==null}_onInput(e){const o=e.target;this._textareaEl=o,this.setAttribute("value",o.value),this.emit("os-input-change",{value:o.value}),this._boolAttr("auto-grow")&&this._autosize(o)}_onChange(e){const o=e.target;this.emit("os-input-commit",{value:o.value})}_onKeyDown(e){if(!(!this._boolAttr("submit-on-enter")||e.isComposing||e.keyCode===229)&&e.key==="Enter"&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey){e.preventDefault();const o=e.target;this.emit("os-submit",{value:o.value})}}_autosize(e){const o=Number(this._attr("max-rows"))||8,n=window.getComputedStyle(e),s=parseFloat(n.fontSize)||13,i=n.lineHeight,r=i==="normal"?s*1.45:parseFloat(i)||s*1.45,a=parseFloat(n.paddingTop)||0,c=parseFloat(n.paddingBottom)||0,l=(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0),u=r*o+a+c+l;e.style.height="auto",e.style.overflowY="hidden";const d=e.value?e.scrollHeight+l:r*(Number(this._attr("rows"))||3)+a+c+l,f=Math.min(d,u);e.style.height=`${Math.ceil(f)}px`,e.style.overflowY=d>Math.ceil(u)?"auto":"hidden"}refreshAutosize(){this._textareaEl&&this._boolAttr("auto-grow")&&this._autosize(this._textareaEl)}focusInput(){(this.shadowRoot??this).querySelector("textarea")?.focus()}clear(){this.setAttribute("value","");const o=(this.shadowRoot??this).querySelector("textarea");o&&(o.value="",this._boolAttr("auto-grow")&&this._autosize(o))}};Ct.props=["label","value","placeholder","disabled","readonly","ariaLabel","name","rows","maxlength","minlength","invalid","autoGrow","maxRows","submitOnEnter"],Ct.styles=[Fs],Ct.help=void 0;let re=Ct;dt("os-textarea",re);const Os=F`:host{display:inline-flex;align-items:center;justify-content:center;width:var( --os-ui-icon-size,16px );height:var( --os-ui-icon-size,16px );color:inherit;line-height:1}:host( [ hidden ] ){display:none}.os-icon__glyph{font-size:var( --os-ui-icon-size,16px );width:var( --os-ui-icon-size,16px );height:var( --os-ui-icon-size,16px );line-height:1;color:inherit;display:inline-flex;align-items:center;justify-content:center}.os-icon__glyph--char{font-family:dashicons;font-style:normal;font-weight:normal;font-variant:normal;text-transform:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;speak:none}.os-icon__glyph.dashicons{font-family:dashicons}`;let Ot=null;function Bs(t){let e=t.trim();if(e==="")return null;(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'"))&&(e=e.slice(1,-1));const o=e.match(/^\\([0-9a-f]{1,6})\s?$/i);return o?String.fromCodePoint(parseInt(o[1],16)):e||null}function uo(){const t=new Map;if(typeof document>"u")return t;const e=Array.from(document.styleSheets??[]);for(const o of e){let n=null;try{n=o.cssRules}catch{continue}if(n)for(const s of Array.from(n)){const i=s;if(!i||!i.selectorText)continue;const r=i.selectorText.match(/\.dashicons-([a-z0-9-]+)::?before/i);if(!r)continue;const a=i.style?.content;if(!a)continue;const c=Bs(a);c&&t.set(r[1],c)}}return t}function Ws(t){Ot||(Ot=uo());const e=t.startsWith("dashicons-")?t.slice(10):t;return Ot.get(e)??null}function Hs(){Ot=uo()}let ho=!1;function qs(){if(ho||typeof window>"u")return;ho=!0;const t=()=>{Hs()};document.readyState==="loading"&&document.addEventListener("DOMContentLoaded",t,{once:!0}),window.addEventListener("load",t,{once:!0})}qs();const Lt=class Lt extends ot{render(){const e=this.name||"",o=e.startsWith("dashicons-")?e.slice(10):e,n=this.size;n&&/^\d+$/.test(n)&&this.style.setProperty("--os-ui-icon-size",`${n}px`);const s=Ws(o);return s?G`<span
84 + class="os-icon__glyph os-icon__glyph--char dashicons dashicons-${o}"
85 + aria-hidden="true"
86 + >${s}</span>`:G`<span
87 + class="os-icon__glyph dashicons dashicons-${o}"
88 + aria-hidden="true"
89 + ></span>`}};Lt.props=["name","size"],Lt.styles=[Os],Lt.help=void 0;let ae=Lt;dt("os-icon",ae);function Gs(t){let e=null,o=!1;const n=()=>{e?.abort(),e=null};return{update:s=>{if(s&&!e){e=new AbortController,o=t.ownerDocument.activeElement===t;const i=a=>{a.composedPath().includes(t)||(o=!1)},r={capture:!0,signal:e.signal};t.ownerDocument.addEventListener("focusin",i,r),t.ownerDocument.addEventListener("pointerdown",i,r),t.ownerDocument.addEventListener("keydown",a=>{a.key==="Tab"&&(o=!1)},r)}else if(!s&&e){const i=o;n(),queueMicrotask(()=>queueMicrotask(()=>{const r=t.ownerDocument.activeElement;i&&t.isConnected&&!t.hasAttribute("disabled")&&(r===t.ownerDocument.body||r===t)&&t.shadowRoot?.querySelector("button")?.focus({preventScroll:!0})}))}},dispose:n}}function Xs(t,e){const o=document.createElement("div");o.className="os-mio-chat__actions",o.setAttribute("role","group"),o.setAttribute("aria-label",w("Suggested actions"));const n=new Map;return{element:o,destroy:()=>{for(const s of n.values())s.focus.dispose();n.clear()},update:()=>{const s=e.list(t),i=new Set(s.map(r=>r.id));for(const[r,a]of n)i.has(r)||(a.focus.dispose(),a.item.remove(),n.delete(r));for(const r of s){let a=n.get(r.id);if(!a){const c=document.createElement("div");c.className="os-mio-chat__action";const l=document.createElement("os-button");if(l.setAttribute("variant",r.emphasis==="primary"?"primary":"ghost"),l.dataset.mioAction=r.id,r.icon){const f=document.createElement("os-icon");f.setAttribute("name",r.icon),f.setAttribute("aria-hidden","true"),l.append(f," ")}const u=document.createElement("span");if(u.textContent=r.label,r.ariaLabel&&u.setAttribute("aria-hidden","true"),l.append(u),r.ariaLabel){const f=document.createElement("span");f.className="screen-reader-text",f.textContent=r.ariaLabel,l.append(f)}const d=document.createElement("span");d.className="os-mio-chat__action-status",d.setAttribute("role","status"),d.setAttribute("aria-live","polite"),l.addEventListener("click",()=>{e.run(t.id,r.id)}),c.append(l,d),o.appendChild(c),a={item:c,button:l,status:d,focus:Gs(l)},n.set(r.id,a)}a.focus.update(r.pending),a.button.toggleAttribute("busy",r.pending),a.button.toggleAttribute("disabled",!r.available),a.status.textContent!==r.status&&(a.status.textContent=r.status)}o.hidden=s.length===0}}}function Ks(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function ce(t){return t.replace(/\[([^\]]+)\]\(([^)]+)\)/g,(e,o,n)=>/^https?:\/\//i.test(n.trim())?`<a href="${n.trim()}" target="_blank" rel="noopener noreferrer">${o}</a>`:o).replace(/\*\*([^*\n]+?)\*\*/g,"<strong>$1</strong>").replace(/(?<![*\w])\*([^*\n]+?)\*(?![*\w])/g,"<em>$1</em>").replace(/(?<![_\w])_([^_\n]+?)_(?![_\w])/g,"<em>$1</em>").replace(/`([^`\n]+?)`/g,"<code>$1</code>")}function Us(t){if(!t)return"";const e=Ks(t),o=[];let n=[],s=null;const i=()=>{n.length>0&&(o.push(`<p>${n.join("<br>")}</p>`),n=[])},r=()=>{s&&(o.push(`<${s.tag}>${s.items.join("")}</${s.tag}>`),s=null)};for(const a of e.split(/\n/)){const c=a.trim();if(c===""){i(),r();continue}const l=/^(#{1,6})\s+(.*)$/.exec(c);if(l){i(),r();const f=Math.min(6,l[1].length+2);o.push(`<h${f}>${ce(l[2])}</h${f}>`);continue}if(/^(-{3,}|\*{3,}|_{3,})$/.test(c)){i(),r(),o.push("<hr>");continue}const u=/^[-*]\s+(.*)$/.exec(c),d=/^\d+\.\s+(.*)$/.exec(c);if(u||d){i();const f=u?"ul":"ol";(!s||s.tag!==f)&&(r(),s={tag:f,items:[]}),s.items.push(`<li>${ce((u??d)[1])}</li>`);continue}r(),n.push(ce(c))}return i(),r(),o.join("")}function Vs(t,e,o,n){const s=document.createElement("section");s.className="os-mio-chat",s.setAttribute("role","dialog"),s.setAttribute("aria-label",`${w("Chat with MIO")} · ${e}`);const i=document.createElement("header"),r=document.createElement("strong");r.textContent="MIO";const a=document.createElement("span");a.textContent=e;const c=document.createElement("os-button");c.setAttribute("variant","ghost"),c.setAttribute("aria-label",w("Close MIO chat"));const l=document.createElement("span");l.textContent="×",l.setAttribute("aria-hidden","true");const u=document.createElement("span");u.className="screen-reader-text",u.textContent=w("Close MIO chat"),c.append(l,u),c.addEventListener("click",n),i.append(r,a,c);const d=document.createElement("div");d.className="os-mio-chat__log",d.setAttribute("role","log"),d.setAttribute("aria-live","polite"),d.setAttribute("aria-label",w("Conversation"));const f=document.createElement("p");f.className="os-mio-chat__status",f.setAttribute("role","status"),f.textContent=w("Ask about this window, or tell me what to change.");const g=document.createElement("div");g.className="os-mio-chat__activity";const p=document.createElement("span");p.className="os-mio-chat__thinking",p.setAttribute("aria-hidden","true"),p.append(...Array.from({length:3},()=>document.createElement("i"))),g.append(p,f);const m=o.subscribeThinking(C=>{s.dataset.thinking=String(C),d.setAttribute("aria-busy",String(C))}),h=document.createElement("os-textarea");h.setAttribute("aria-label",w("Message MIO")),h.setAttribute("rows","1"),h.setAttribute("auto-grow",""),h.setAttribute("max-rows","2"),h.setAttribute("submit-on-enter",""),h.setAttribute("placeholder",w("Make this space yours…")),h.setAttribute("maxlength","4000");const x=document.createElement("os-button");x.setAttribute("variant","holo"),x.textContent=w("Send");const v=document.createElement("os-button");v.setAttribute("variant","ghost"),v.textContent=w("Stop"),v.hidden=!0;const _=document.createElement("div");_.className="os-mio-chat__composer",_.append(h,x,v);const $=document.createElement("small");$.textContent=w("Conversation stays in this session. Messages are sent to your configured AI provider."),s.append(i,d,g,_,$),t.appendChild(s);let V=-1;const M=new ResizeObserver(C=>{const z=C[0]?.contentRect.width;z!==void 0&&z!==V&&(V=z,h.refreshAutosize())});M.observe(h);let X="",N=!1,H=!1,O="";const R=new Map,j=()=>{const C=d.scrollTop,z=o.conversation.read(),Z=JSON.stringify(z[z.length-1]??null),y=new Set;for(const[L,E]of z.entries()){const T=`${E.id??L}:${E.role}:${E.text}`;y.add(T);const D=R.get(T);if(D){D.update();continue}const P=document.createElement("div");P.className=`os-mio-chat__message os-mio-chat__message--${E.role}`,E.role==="assistant"?P.innerHTML=Us(E.text):P.textContent=E.text;const q=Xs(E,o.responseActions);E.role==="assistant"&&P.appendChild(q.element),q.update(),R.set(T,{bubble:P,update:q.update,destroy:q.destroy}),d.appendChild(P)}for(const[L,E]of R)y.has(L)||(E.destroy(),E.bubble.remove(),R.delete(L));const S=d.lastElementChild;d.scrollTop=Z!==O&&S?S.offsetTop:C,O=Z},tt=o.responseActions.subscribe(()=>{const C=d.scrollTop;for(const z of R.values())z.update();d.scrollTop=C}),K=async()=>{if(N||!X.trim())return;N=!0,x.setAttribute("disabled",""),v.hidden=!1,f.textContent=w("MIO is thinking…");const C=X;X="",h.clear();try{const z=o.ask(C);j(),await z,f.textContent=""}catch(z){if(z instanceof Error&&z.name==="AbortError"){const Z=o.operations.list().some(y=>y.effect==="write"&&y.status==="unknown");f.textContent=w(Z?"Stopped. A submitted save may still complete.":"Stopped.")}else f.textContent=z instanceof Error?z.message:w("MIO could not complete this request.")}finally{H||(N=!1,v.hidden=!0,x.removeAttribute("disabled"),j())}};return h.addEventListener("os-input-change",C=>{X=String(C.detail?.value??"")}),h.addEventListener("os-submit",()=>{K()}),x.addEventListener("click",()=>{K()}),v.addEventListener("click",()=>o.cancel()),s.addEventListener("keydown",C=>{C.key==="Escape"&&(C.stopPropagation(),n())}),j(),customElements.whenDefined("os-textarea").then(()=>{H||h.focusInput()}),{destroy:()=>{H=!0,M.disconnect(),m(),tt();for(const C of R.values())C.destroy();R.clear(),o.cancel(),s.remove()}}}window.openStationMountMio=Ns,window.openStationMountMioChat=Vs})();