| @@ -1,30 +1,20 @@ | ||
| 1 | -(function(){"use strict";function L(n,...e){return{__wpdHtml:!0,strings:n,values:e}}function pe(n){return!!n&&n.__wpdHtml===!0}const he="$$wpd$$",y=/\$\$wpd\$\$(\d+)\$\$/g;function fe(n){let e=n[0];for(let t=1;t<n.length;t++)e+=`${he}${t-1}$$`+n[t];return e}const Y=new WeakMap;function J(n){const e=Y.get(n);if(e)return e;const t=document.createElement("template");t.innerHTML=fe(n);const o=[],s=(p,c)=>{if(p.nodeType===Node.ELEMENT_NODE){const b=p;for(const f of Array.from(b.attributes)){const g=f.name,h=f.value,w=g[0];if(y.test(h))if(y.lastIndex=0,w==="@"){const u=y.exec(h);y.lastIndex=0,o.push({path:c,kind:"event",name:g.slice(1),valueIndex:u?Number(u[1]):0}),b.removeAttribute(g)}else if(w==="."){const u=y.exec(h);y.lastIndex=0,o.push({path:c,kind:"prop",name:g.slice(1),valueIndex:u?Number(u[1]):0}),b.removeAttribute(g)}else if(w==="?"){const u=y.exec(h);y.lastIndex=0,o.push({path:c,kind:"bool",name:g.slice(1),valueIndex:u?Number(u[1]):0}),b.removeAttribute(g)}else{const u=[],_=[];let x=0,k;for(y.lastIndex=0;(k=y.exec(h))!==null;)u.push(h.slice(x,k.index)),_.push(Number(k[1])),x=k.index+k[0].length;u.push(h.slice(x)),o.push({path:c,kind:"attr",name:g,template:u,valueIndices:_}),b.setAttribute(g,"")}}}const i=Array.from(p.childNodes);let m=0;for(let b=0;b<i.length;b++){const f=i[b],g=b+m;if(f.nodeType===Node.TEXT_NODE){const h=f.textContent||"";if(!y.test(h)){y.lastIndex=0;continue}y.lastIndex=0;const w=f.parentNode;let u=0,_;const x=[],k=[];for(y.lastIndex=0;(_=y.exec(h))!==null;){_.index>u&&x.push(document.createTextNode(h.slice(u,_.index)));const C=document.createTextNode("");x.push(C),k.push({path:[...c,g+x.length-1],kind:"node",valueIndex:Number(_[1])}),u=_.index+_[0].length}u<h.length&&x.push(document.createTextNode(h.slice(u)));for(const C of x)w.insertBefore(C,f);w.removeChild(f),m+=x.length-1,o.push(...k)}else s(f,[...c,g])}};s(t.content,[]);const a={template:t,buildParts:p=>{const c=[];for(const i of o){let m=p;for(const b of i.path)m=m.childNodes[b];i.kind==="node"?c.push({kind:"node",valueIndex:i.valueIndex,child:{anchor:m,state:null}}):i.kind==="attr"?c.push({kind:"attr",element:m,name:i.name,template:i.template,valueIndices:i.valueIndices}):i.kind==="event"?c.push({kind:"event",valueIndex:i.valueIndex,element:m,name:i.name}):i.kind==="prop"?c.push({kind:"prop",valueIndex:i.valueIndex,element:m,name:i.name}):i.kind==="bool"&&c.push({kind:"bool",valueIndex:i.valueIndex,element:m,name:i.name})}return c}};return Y.set(n,a),a}const Z=new WeakMap;function me(n,e){for(const t of n.nodes)if(t.parentNode!==e)return!1;return!0}function ge(n,e){const t=Z.get(e);if(t&&t.strings===n.strings&&me(t,e)){D(t.parts,n.values);return}const o=J(n.strings),s=o.template.content.cloneNode(!0),r=o.buildParts(s),a=Array.from(s.childNodes);for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(s),D(r,n.values),Z.set(e,{strings:n.strings,parts:r,nodes:a})}function D(n,e){for(const t of n)if(t.kind==="node")z(t.child,e[t.valueIndex]);else if(t.kind==="attr"){let o=t.template[0];for(let s=0;s<t.valueIndices.length;s++)o+=Q(e[t.valueIndices[s]]),o+=t.template[s+1];o!==t.last&&(t.last=o,o===""?t.element.removeAttribute(t.name):t.element.setAttribute(t.name,o))}else if(t.kind==="event"){const o=e[t.valueIndex];o!==t.current&&(t.current&&t.element.removeEventListener(t.name,t.current),o&&t.element.addEventListener(t.name,o),t.current=o)}else if(t.kind==="prop"){const o=e[t.valueIndex];o!==t.last&&(t.last=o,t.element[t.name]=o)}else if(t.kind==="bool"){const o=!!e[t.valueIndex];o!==t.last&&(t.last=o,o?t.element.setAttribute(t.name,""):t.element.removeAttribute(t.name))}}function z(n,e){if(e==null||e===!1){n.state&&(I(n.state),n.state=null);return}if(Array.isArray(e)){ye(n,e);return}if(pe(e)){xe(n,e);return}if(e instanceof Node){we(n,e);return}be(n,Q(e))}function we(n,e){const t=n.state;t?.shape==="node"&&t.node===e||(t&&I(t),M(n,[e]),n.state={shape:"node",node:e})}function be(n,e){const t=n.state;if(t?.shape==="text"){t.text!==e&&(t.node.textContent=e,t.text=e);return}t&&I(t);const o=document.createTextNode(e);M(n,[o]),n.state={shape:"text",node:o,text:e}}function xe(n,e){const t=n.state;if(t?.shape==="template"&&t.strings===e.strings){D(t.parts,e.values);return}t&&I(t);const o=J(e.strings),s=o.template.content.cloneNode(!0),r=o.buildParts(s),a=Array.from(s.childNodes);M(n,[s]),D(r,e.values),n.state={shape:"template",strings:e.strings,parts:r,nodes:a}}function ye(n,e){const t=n.state;if(t?.shape==="array"&&t.entries.length===e.length){for(let s=0;s<e.length;s++)z(t.entries[s],e[s]);return}t&&I(t);const o=[];for(const s of e){const r=document.createTextNode("");M(n,[r]);const a={anchor:r,state:null};z(a,s),o.push(a)}n.state={shape:"array",entries:o}}function M(n,e){const t=n.anchor.parentNode;if(t)for(const o of e)t.insertBefore(o,n.anchor)}function I(n){if(n.shape==="text"){n.node.remove();return}if(n.shape==="template"){for(const e of n.parts)e.kind==="node"&&e.child.state&&(I(e.child.state),e.child.state=null);for(const e of n.nodes)e.parentNode&&e.parentNode.removeChild(e);return}if(n.shape==="node"){n.node.parentNode&&n.node.parentNode.removeChild(n.node);return}for(const e of n.entries)e.state&&I(e.state),e.anchor.remove()}function Q(n){return n==null||n===!1?"":String(n)}const S=class S 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(te)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,t,o){if(t===o)return;const s=_e(e);this._propValues[s]=o,this.requestUpdate()}get classNames(){return Array.from(this.classList)}set classNames(e){if(e==null){this.removeAttribute("class");return}const o=(Array.isArray(e)?e:String(e).split(/\s+/)).map(s=>String(s).trim()).filter(s=>s!=="");this.className=o.join(" ")}requestUpdate(){this._scheduleRender()}emit(e,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_installPropAccessors(){const e=this.constructor;for(const t of e.props){if(Object.getOwnPropertyDescriptor(this,t))continue;const o=te(t);Object.defineProperty(this,t,{get:()=>t in this._propValues?this._propValues[t]:this.getAttribute(o),set:s=>{let r;s==null||s===!1?r=null:s===!0?r="":r=String(s),this._propValues[t]=r,r===null?this.removeAttribute(o):this.setAttribute(o,r),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&ge(this.render(),this._renderRoot)}))}_adoptStyles(){const e=this.constructor;if(e.styles.length!==0)if(e.shadow&&this.shadowRoot){const t=e.styles.map(o=>o.sheet).filter(o=>o!==null);if(this.shadowRoot.adoptedStyleSheets=t,t.length!==e.styles.length){for(const o of e.styles)if(!o.sheet){const s=document.createElement("style");s.textContent=o.cssText,this.shadowRoot.appendChild(s)}}}else this._adoptLightStyles(e)}_adoptLightStyles(e){if(!S._lightStylesAdopted.has(e)){S._lightStylesAdopted.add(e);for(const t of e.styles){const o=document.createElement("style");o.dataset.wpdUi=this.tagName.toLowerCase(),o.textContent=t.cssText,document.head.appendChild(o)}}}};S.props=[],S.styles=[],S.shadow=!0,S._lightStylesAdopted=new WeakSet;let O=S;function ee(n,e){customElements.get(n)||customElements.define(n,e)}function te(n){return n.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function _e(n){return n.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}const ve=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function ne(n,...e){let t=n[0];for(let o=1;o<n.length;o++){const s=e[o-1];if(typeof s=="string"||typeof s=="number")t+=String(s);else if(s&&s.__wpdCss)t+=s.cssText;else throw new TypeError("[wpd-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof s);t+=n[o]}if(ve){const o=new CSSStyleSheet;return o.replaceSync(t),{__wpdCss:!0,sheet:o,cssText:t}}return{__wpdCss:!0,sheet:null,cssText:t}}function ke(n){const e=[],t=[];let o=null,s=n.parentElement;for(;s&&!(s===document.body||s===document.documentElement);){const a=s.id||"";if(a.startsWith("wp-window-")){o=a.slice(10);break}if(s.tagName.toLowerCase()==="wpd-tabpanel"){const p=s.getAttribute("for");p&&t.unshift(p)}s=s.parentElement}o&&e.push(H(o));for(const a of t)e.push("tab-"+H(a));const r=n.getAttribute("label");return r&&e.push(H(r)),e.length===0?"wpd-unnamed":"wpd-"+e.filter(a=>a!=="").join("-")}function H(n){return n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ee(n){if(n.id)return n.id;const e=ke(n);return n.id=e,e}const Ne=ne`:host{display:inline-flex;align-items:center;gap:6px;font-size:12px;color:var( --wpd-fg,#1d2327 );cursor:pointer}label{display:inline-flex;align-items:center;gap:6px;cursor:pointer}input[ type='checkbox' ]{accent-color:var( --wp-admin-theme-color,#2271b1 );cursor:pointer}:host( [ disabled ] ){opacity:0.5;cursor:not-allowed}:host( [ disabled ] ) label,:host( [ disabled ] ) input[ type='checkbox' ]{cursor:not-allowed}`,R=class R extends O{render(){const e=this.label||"",t=this.checked!==null,o=this.disabled!==null;return L` | |
| 2 | - <label> | |
| 3 | - <input | |
| 4 | - type="checkbox" | |
| 5 | - ?checked=${t} | |
| 6 | - ?disabled=${o} | |
| 7 | - @change=${s=>this._onChange(s)} | |
| 8 | - /> | |
| 9 | - <span class="wpd-checkbox-label__text">${e}</span> | |
| 10 | - </label> | |
| 11 | - `}_onChange(e){if(this.disabled!==null)return;const t=e.target.checked;t?this.setAttribute("checked",""):this.removeAttribute("checked"),this.emit("wpd-checkbox-change",{checked:t})}};R.props=["label","checked","disabled"],R.styles=[Ne],R.help=void 0;let X=R;ee("wpd-checkbox-label",X);const Ce=ne`:host{display:flex;flex-direction:column;gap:4px;font-size:13px;color:var( --wpd-fg,#1d2327 );min-width:0}:host( [ hidden ] ){display:none}.wpd-textarea__label{font-size:12px;color:var( --wpd-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( --desktop-mode-window-bg,#fff );border:1px solid var( --wpd-border,#dcdcde );border-radius:6px;font:inherit;font-size:13px;line-height:1.45;color:var( --wpd-fg,#1d2327 );resize:vertical;transition:border-color 0.12s ease,box-shadow 0.12s ease}textarea:hover{border-color:var( --wpd-fg-muted,#8c8f94 )}textarea:focus-visible{outline:none;border-color:var( --wp-admin-theme-color,#2271b1 );box-shadow:0 0 0 1px var( --wp-admin-theme-color,#2271b1 )}textarea:disabled{opacity:0.55;cursor:not-allowed;background:var( --wpd-hover,rgba( 0,0,0,0.03 ) )}textarea[ aria-invalid='true' ]{border-color:var( --wpd-danger,#d63638 )}textarea[ aria-invalid='true' ]:focus-visible{box-shadow:0 0 0 1px #d63638}:host( [ auto-grow ] ) textarea{resize:none;overflow:hidden}`,T=class T extends O{constructor(){super(...arguments),this._textareaEl=null}connectedCallback(){super.connectedCallback(),Ee(this)}render(){const e=this._attr("label")||"",t=this._attr("value")??"",o=this._attr("placeholder")||"",s=this._boolAttr("disabled"),r=this._boolAttr("readonly"),a=this._attr("aria-label")||e,p=this._attr("name")||"",c=Number(this._attr("rows"))||3,i=this._attr("maxlength"),m=this._attr("minlength"),b=this._boolAttr("invalid"),g=`${this.id||"wpd-unnamed"}__field`;return L` | |
| 12 | - ${e?L`<label class="wpd-textarea__label" for=${g}>${e}</label>`:L``} | |
| 1 | +(function(){"use strict";function D(o,...e){return{__wpdHtml:!0,strings:o,values:e}}function le(o){return!!o&&o.__wpdHtml===!0}const ce="$$wpd$$",x=/\$\$wpd\$\$(\d+)\$\$/g,de="$$wpd-node$$",ue=/^\$\$wpd-node\$\$(\d+)\$\$$/,he=new Set(["style","script","textarea","title"]);function pe(o){let e="",t=!1,n=null,s=!1,r=null,a="",c=!1;for(let l=0;l<o.length;l++){const i=o[l];e+=i;for(let d=0;d<i.length;d++){const u=i[d];if(s){i.startsWith("-->",d)&&(s=!1,d+=2);continue}if(r!==null){u==="<"&&i[d+1]==="/"&&i.slice(d+2,d+2+r.length).toLowerCase()===r&&(d+=1+r.length,r=null,t=!0,c=!1,a="");continue}if(n!==null){u===n&&(n=null);continue}if(t){u==='"'||u==="'"?(n=u,c=!1):u===">"?(t=!1,c=!1,he.has(a)&&(r=a),a=""):c&&(/[a-zA-Z0-9-]/.test(u)?a+=u.toLowerCase():c=!1);continue}if(i.startsWith("<!--",d)){s=!0,d+=3;continue}const h=i[d+1]??"";u==="<"&&/[a-zA-Z/!]/.test(h)&&(t=!0,a="",c=/[a-zA-Z]/.test(h))}l<o.length-1&&(e+=t||s||r!==null?`${ce}${l}$$`:`<!--${de}${l}$$-->`)}return e}const G=new WeakMap;function Y(o){const e=G.get(o);if(e)return e;const t=document.createElement("template");t.innerHTML=pe(o);const n=[],s=(c,l)=>{if(c.nodeType===Node.ELEMENT_NODE){const u=c;for(const h of Array.from(u.attributes)){const b=h.name,m=h.value,v=b[0];if(x.test(m))if(x.lastIndex=0,v==="@"){const g=x.exec(m);x.lastIndex=0,n.push({path:l,kind:"event",name:b.slice(1),valueIndex:g?Number(g[1]):0}),u.removeAttribute(b)}else if(v==="."){const g=x.exec(m);x.lastIndex=0,n.push({path:l,kind:"prop",name:b.slice(1),valueIndex:g?Number(g[1]):0}),u.removeAttribute(b)}else if(v==="?"){const g=x.exec(m);x.lastIndex=0,n.push({path:l,kind:"bool",name:b.slice(1),valueIndex:g?Number(g[1]):0}),u.removeAttribute(b)}else{const g=[],y=[];let w=0,k;for(x.lastIndex=0;(k=x.exec(m))!==null;)g.push(m.slice(w,k.index)),y.push(Number(k[1])),w=k.index+k[0].length;g.push(m.slice(w)),n.push({path:l,kind:"attr",name:b,template:g,valueIndices:y}),u.setAttribute(b,"")}}}const i=Array.from(c.childNodes);let d=0;for(let u=0;u<i.length;u++){const h=i[u],b=u+d;if(h.nodeType===Node.COMMENT_NODE){const m=ue.exec(h.data);if(m){const v=document.createTextNode("");h.parentNode.replaceChild(v,h),n.push({path:[...l,b],kind:"node",valueIndex:Number(m[1])})}continue}if(h.nodeType===Node.TEXT_NODE){const m=h.textContent||"";if(!x.test(m)){x.lastIndex=0;continue}x.lastIndex=0;const v=h.parentNode;let g=0,y;const w=[],k=[];for(x.lastIndex=0;(y=x.exec(m))!==null;){y.index>g&&w.push(document.createTextNode(m.slice(g,y.index)));const T=document.createTextNode("");w.push(T),k.push({path:[...l,b+w.length-1],kind:"node",valueIndex:Number(y[1])}),g=y.index+y[0].length}g<m.length&&w.push(document.createTextNode(m.slice(g)));for(const T of w)v.insertBefore(T,h);v.removeChild(h),d+=w.length-1,n.push(...k)}else s(h,[...l,b])}};s(t.content,[]);const a={template:t,buildParts:c=>{const l=[];for(const i of n){let d=c;for(const u of i.path)d=d.childNodes[u];i.kind==="node"?l.push({kind:"node",valueIndex:i.valueIndex,child:{anchor:d,state:null}}):i.kind==="attr"?l.push({kind:"attr",element:d,name:i.name,template:i.template,valueIndices:i.valueIndices}):i.kind==="event"?l.push({kind:"event",valueIndex:i.valueIndex,element:d,name:i.name}):i.kind==="prop"?l.push({kind:"prop",valueIndex:i.valueIndex,element:d,name:i.name}):i.kind==="bool"&&l.push({kind:"bool",valueIndex:i.valueIndex,element:d,name:i.name})}return l}};return G.set(o,a),a}const Z=new WeakMap;function fe(o,e){for(const t of o.nodes)if(t.parentNode!==e)return!1;return!0}function me(o,e){const t=Z.get(e);if(t&&t.strings===o.strings&&fe(t,e)){z(t.parts,o.values);return}const n=Y(o.strings),s=n.template.content.cloneNode(!0),r=n.buildParts(s),a=Array.from(s.childNodes);for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(s),z(r,o.values),Z.set(e,{strings:o.strings,parts:r,nodes:a})}function z(o,e){for(const t of o)if(t.kind==="node")M(t.child,e[t.valueIndex]);else if(t.kind==="attr"){let n=t.template[0];for(let s=0;s<t.valueIndices.length;s++)n+=J(e[t.valueIndices[s]]),n+=t.template[s+1];n!==t.last&&(t.last=n,n===""?t.element.removeAttribute(t.name):t.element.setAttribute(t.name,n))}else if(t.kind==="event"){const n=e[t.valueIndex];n!==t.current&&(t.current&&t.element.removeEventListener(t.name,t.current),n&&t.element.addEventListener(t.name,n),t.current=n)}else if(t.kind==="prop"){const n=e[t.valueIndex];n!==t.last&&(t.last=n,t.element[t.name]=n)}else if(t.kind==="bool"){const n=!!e[t.valueIndex];n!==t.last&&(t.last=n,n?t.element.setAttribute(t.name,""):t.element.removeAttribute(t.name))}}function M(o,e){if(e==null||e===!1){o.state&&(A(o.state),o.state=null);return}if(Array.isArray(e)){we(o,e);return}if(le(e)){ve(o,e);return}if(e instanceof Node){ge(o,e);return}be(o,J(e))}function ge(o,e){const t=o.state;t?.shape==="node"&&t.node===e||(t&&A(t),I(o,[e]),o.state={shape:"node",node:e})}function be(o,e){const t=o.state;if(t?.shape==="text"){t.text!==e&&(t.node.textContent=e,t.text=e);return}t&&A(t);const n=document.createTextNode(e);I(o,[n]),o.state={shape:"text",node:n,text:e}}function ve(o,e){const t=o.state;if(t?.shape==="template"&&t.strings===e.strings){z(t.parts,e.values);return}t&&A(t);const n=Y(e.strings),s=n.template.content.cloneNode(!0),r=n.buildParts(s),a=Array.from(s.childNodes);I(o,[s]),z(r,e.values),o.state={shape:"template",strings:e.strings,parts:r,nodes:a}}function we(o,e){const t=o.state;if(t?.shape==="array"){const s=Math.min(t.entries.length,e.length);for(let r=0;r<s;r++)M(t.entries[r],e[r]);if(e.length<t.entries.length){for(let r=e.length;r<t.entries.length;r++){const a=t.entries[r];a.state&&A(a.state),a.anchor.remove()}t.entries.length=e.length}else for(let r=t.entries.length;r<e.length;r++){const a=document.createTextNode("");I(o,[a]);const c={anchor:a,state:null};M(c,e[r]),t.entries.push(c)}return}t&&A(t);const n=[];for(const s of e){const r=document.createTextNode("");I(o,[r]);const a={anchor:r,state:null};M(a,s),n.push(a)}o.state={shape:"array",entries:n}}function I(o,e){const t=o.anchor.parentNode;if(t)for(const n of e)t.insertBefore(n,o.anchor)}function A(o){if(o.shape==="text"){o.node.remove();return}if(o.shape==="template"){for(const e of o.parts)e.kind==="node"&&e.child.state&&(A(e.child.state),e.child.state=null);for(const e of o.nodes)e.parentNode&&e.parentNode.removeChild(e);return}if(o.shape==="node"){o.node.parentNode&&o.node.parentNode.removeChild(o.node);return}for(const e of o.entries)e.state&&A(e.state),e.anchor.remove()}function J(o){return o==null||o===!1?"":String(o)}const $=class $ extends HTMLElement{constructor(){super(),this._renderScheduled=!1,this._propValues={},this.constructor.shadow?(this.attachShadow({mode:"open"}),this._renderRoot=this.shadowRoot):this._renderRoot=this,this._installPropAccessors()}static get observedAttributes(){return this.props.map(Q)}connectedCallback(){this._adoptStyles(),this.requestUpdate()}attributeChangedCallback(e,t,n){if(t===n)return;const s=_e(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,t){return this.dispatchEvent(new CustomEvent(e,{detail:t,bubbles:!0,composed:!0}))}_installPropAccessors(){const e=this.constructor;for(const t of e.props){if(Object.getOwnPropertyDescriptor(this,t))continue;const n=Q(t);Object.defineProperty(this,t,{get:()=>t in this._propValues?this._propValues[t]:this.getAttribute(n),set:s=>{let r;s==null||s===!1?r=null:s===!0?r="":r=String(s),this._propValues[t]=r,r===null?this.removeAttribute(n):this.setAttribute(n,r),this.requestUpdate()},enumerable:!0,configurable:!0})}}_scheduleRender(){this._renderScheduled||!this.isConnected||(this._renderScheduled=!0,queueMicrotask(()=>{this._renderScheduled=!1,this.isConnected&&me(this.render(),this._renderRoot)}))}_adoptStyles(){const e=this.constructor;if(e.styles.length!==0)if(e.shadow&&this.shadowRoot){const t=e.styles.map(n=>n.sheet).filter(n=>n!==null);if(this.shadowRoot.adoptedStyleSheets=t,t.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(!$._lightStylesAdopted.has(e)){$._lightStylesAdopted.add(e);for(const t of e.styles){const n=document.createElement("style");n.dataset.osUi=this.tagName.toLowerCase(),n.textContent=t.cssText,document.head.appendChild(n)}}}};$.props=[],$.styles=[],$.shadow=!0,$._lightStylesAdopted=new WeakSet;let O=$;function xe(o,e){customElements.get(o)||customElements.define(o,e)}function Q(o){return o.replace(/[A-Z]/g,e=>"-"+e.toLowerCase())}function _e(o){return o.replace(/-([a-z])/g,(e,t)=>t.toUpperCase())}const ye=(()=>{try{return typeof new CSSStyleSheet().replaceSync=="function"}catch{return!1}})();function _(o,...e){let t=o[0];for(let n=1;n<o.length;n++){const s=e[n-1];if(typeof s=="string"||typeof s=="number")t+=String(s);else if(s&&s.__wpdCss)t+=s.cssText;else throw new TypeError("[os-ui] css`` interpolations must be strings, numbers, or other css`` results. Got: "+typeof s);t+=o[n]}if(ye){const n=new CSSStyleSheet;return n.replaceSync(t),{__wpdCss:!0,sheet:n,cssText:t}}return{__wpdCss:!0,sheet:null,cssText:t}}function ke(o){const e=[],t=[];let n=null,s=o.parentElement;for(;s&&!(s===document.body||s===document.documentElement);){const a=s.id||"";if(a.startsWith("wp-window-")){n=a.slice(10);break}if(s.tagName.toLowerCase()==="os-tabpanel"){const c=s.getAttribute("for");c&&t.unshift(c)}s=s.parentElement}n&&e.push(H(n));for(const a of t)e.push("tab-"+H(a));const r=o.getAttribute("label");return r&&e.push(H(r)),e.length===0?"os-unnamed":"os-"+e.filter(a=>a!=="").join("-")}function H(o){return o.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function Ne(o){if(o.id)return o.id;const e=ke(o);return o.id=e,e}const ee=_`: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 ) )}`,Ee=_` .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%}}`,Ce=_` .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%}}`,Ae=_` .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}}`,$e=_` .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}}`,Se=_` .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}}`,Te=_` .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%}}`,Ie=_` .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}}`,te=_` 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=_` 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}}`,Le=_` @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}}`;_` ${ee} ${Ee} ${Ce} ${Ae} ${$e} ${Se} ${Te} ${Ie} ${te} ${Re} ${Le} `;const ze=_` ${ee} ${te}: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}`,R=class R extends O{constructor(){super(...arguments),this._textareaEl=null}connectedCallback(){super.connectedCallback(),Ne(this)}render(){const e=this._attr("label")||"",t=this._attr("value")??"",n=this._attr("placeholder")||"",s=this._boolAttr("disabled"),r=this._boolAttr("readonly"),a=this._attr("aria-label")||e,c=this._attr("name")||"",l=Number(this._attr("rows"))||3,i=this._attr("maxlength"),d=this._attr("minlength"),u=this._boolAttr("invalid"),b=`${this.id||"os-unnamed"}__field`;return D` | |
| 2 | + ${e?D`<label class="os-textarea__label" for=${b}>${e}</label>`:D``} | |
| 13 | 3 | <textarea |
| 14 | - id=${g} | |
| 4 | + id=${b} | |
| 15 | 5 | part="textarea" |
| 16 | 6 | .value=${t} |
| 17 | - placeholder=${o} | |
| 7 | + placeholder=${n} | |
| 18 | 8 | ?disabled=${s} |
| 19 | 9 | ?readonly=${r} |
| 20 | - rows=${c} | |
| 10 | + rows=${l} | |
| 21 | 11 | maxlength=${i??""} |
| 22 | - minlength=${m??""} | |
| 23 | - name=${p} | |
| 24 | - aria-invalid=${b?"true":"false"} | |
| 12 | + minlength=${d??""} | |
| 13 | + name=${c} | |
| 14 | + aria-invalid=${u?"true":"false"} | |
| 25 | 15 | aria-label=${a||""} |
| 26 | - @input=${h=>this._onInput(h)} | |
| 27 | - @change=${h=>this._onChange(h)} | |
| 28 | - @keydown=${h=>this._onKeyDown(h)} | |
| 16 | + @input=${m=>this._onInput(m)} | |
| 17 | + @change=${m=>this._onChange(m)} | |
| 18 | + @keydown=${m=>this._onKeyDown(m)} | |
| 29 | 19 | ></textarea> |
| 30 | - `}_attr(e){return this.getAttribute(e)}_boolAttr(e){return this.getAttribute(e)!==null}_onInput(e){const t=e.target;this._textareaEl=t,this.setAttribute("value",t.value),this.emit("wpd-input-change",{value:t.value}),this._boolAttr("auto-grow")&&this._autosize(t)}_onChange(e){const t=e.target;this.emit("wpd-input-commit",{value:t.value})}_onKeyDown(e){if(this._boolAttr("submit-on-enter")&&e.key==="Enter"&&!e.shiftKey&&!e.altKey&&!e.metaKey&&!e.ctrlKey){e.preventDefault();const t=e.target;this.emit("wpd-submit",{value:t.value})}}_autosize(e){const t=Number(this._attr("max-rows"))||8,o=window.getComputedStyle(e),s=parseFloat(o.fontSize)||13,r=o.lineHeight,a=r==="normal"?s*1.45:parseFloat(r)||s*1.45,p=parseFloat(o.paddingTop)||0,c=parseFloat(o.paddingBottom)||0,i=a*t+p+c;e.style.height="auto";const m=Math.min(e.scrollHeight,i);e.style.height=`${m}px`}refreshAutosize(){this._textareaEl&&this._boolAttr("auto-grow")&&this._autosize(this._textareaEl)}focusInput(){(this.shadowRoot??this).querySelector("textarea")?.focus()}clear(){this.setAttribute("value","");const t=(this.shadowRoot??this).querySelector("textarea");t&&(t.value="",this._boolAttr("auto-grow")&&this._autosize(t))}};T.props=["label","value","placeholder","disabled","readonly","ariaLabel","name","rows","maxlength","minlength","invalid","autoGrow","maxRows","submitOnEnter"],T.styles=[Ce],T.help=void 0;let q=T;ee("wpd-textarea",q);const Ae="desktop-mode";function Se(){return window.wp?.i18n}function v(n,e=Ae){return Se()?.__(n,e)??n}const $=["butter","blush","sky","mint","lilac","peach"];function K(n){return $.includes(n)?n:$[0]}function B(n){const e=$.indexOf(K(n));return $[(e+1)%$.length]}function Ie(n){let e=2166136261;for(let o=0;o<n.length;o++)e^=n.charCodeAt(o),e=Math.imul(e,16777619)>>>0;return e>>>1||1}const $e=56,Re=52;function Te(n){return`${n.replace(/\/$/,"")}/assets/images/pushpin.svg`}function Pe(n){const e=document.createElement("img");return e.src=Te(n),e.alt="",e.width=$e,e.height=Re,e.draggable=!1,e.className="desktop-mode-pinned-note__pin-img",e}const oe="X-WP-Nonce";function Le(n,e){const t=De();if(!t)return e;const o=Me(n);if(!o||!Oe(o))return e;const s=e?.headers??(typeof Request<"u"&&n instanceof Request?n.headers:void 0),r=new Headers(s??{});return r.has(oe)?e:(r.set(oe,t),{...e??{},headers:r})}function De(){if(typeof window>"u")return;const e=window.desktopModeConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function Me(n){try{const e=typeof window<"u"&&window.location?window.location.href:void 0;return typeof n=="string"?new URL(n,e):n instanceof URL?n:typeof Request<"u"&&n instanceof Request?new URL(n.url,e):null}catch{return null}}function Oe(n){return typeof window>"u"||!window.location||n.origin!==window.location.origin?!1:!!(n.pathname.includes("/wp-json/")||n.searchParams.has("rest_route"))}function Ue(n,e,t={}){const o=window.wp?.desktop?.fetch;if(typeof o=="function")return o(n,e,t);const s=Le(n,e);return fetch(n,s)}let j=null;function ze(n){j=n}function He(){if(!j)throw new Error("[desktop-mode] notes REST client called before installNotesRestDeps().");return j}function Xe(n){const e=window.desktopModeConfig;return typeof e?.restNonce=="string"&&e.restNonce?e.restNonce:n}class qe extends Error{constructor(e){super("Note was changed by another session."),this.status=409,this.name="NotesConflictError",this.current=e}}async function Ke(n,e){const{baseUrl:t,nonce:o}=He(),s=t,r=new Headers(e.headers??{});r.set("X-WP-Nonce",Xe(o)),e.body&&!r.has("Content-Type")&&r.set("Content-Type","application/json");const a=await Ue(s,{...e,headers:r,credentials:"same-origin"},{source:"desktop-mode/notes"}),p=await a.text();let c=null;if(p)try{c=JSON.parse(p)}catch{c=null}if(!a.ok){if(a.status===409){const m=c?.data?.current;throw new qe(m??null)}const i=c;throw new Error(`[desktop-mode] notes REST ${a.status}: ${i?.code??""} ${i?.message??""}`.trim())}if(c===null)throw new Error(`[desktop-mode] notes REST ${a.status}: empty or unparseable body.`);return c}function Be(n){return Ke("",{method:"POST",body:JSON.stringify(n)})}const je="note-draft",Ve="desktop-mode-note-created",Fe="desktop-mode/notes";function We(){return window.desktopModeConfig??{}}function Ge(){return window.wp?.desktop?.dragManager??null}const Ye=(n,e)=>{let t=!1;const o=We(),s=!!o.notesUrl;s&&ze({baseUrl:o.notesUrl,nonce:o.restNonce??""});let r=K(e.storage.get("color")??$[0]),a=e.storage.get("public")??!1,p="";const c=document.createElement("div");c.className="dm-notes-pad";const i=document.createElement("div");i.className="dm-notes-pad__stack";const m=document.createElement("div");m.className="dm-notes-pad__under dm-notes-pad__under--2";const b=document.createElement("div");b.className="dm-notes-pad__under dm-notes-pad__under--1";const f=document.createElement("div");f.className="dm-notes-pad__sheet";const g=document.createElement("div");g.className="dm-notes-pad__peel",g.setAttribute("aria-hidden","true");const h=document.createElement("span");h.className="dm-notes-pad__peel-hint",h.textContent=v("Drag to pin","desktop-mode"),g.appendChild(h);const w=document.createElement("wpd-textarea");w.className="dm-notes-pad__editor",w.setAttribute("aria-label",v("New note","desktop-mode")),w.setAttribute("placeholder",v("Write a note…","desktop-mode")),w.setAttribute("rows","5"),w.setAttribute("auto-grow",""),w.setAttribute("max-rows","8");const u=document.createElement("button");u.type="button",u.className="dm-notes-pad__corner",f.append(g,w,u),i.append(m,b,f);const _=document.createElement("div");_.className="dm-notes-pad__footer";const x=document.createElement("div");x.className="dm-notes-pad__swatches",x.setAttribute("role","radiogroup"),x.setAttribute("aria-label",v("Paper color","desktop-mode"));const k=new Map;for(const d of $){const l=document.createElement("button");l.type="button",l.className="dm-notes-pad__swatch",l.dataset.noteColor=d,l.setAttribute("role","radio"),l.setAttribute("aria-label",d),l.addEventListener("click",()=>re(d)),k.set(d,l),x.appendChild(l)}const C=document.createElement("wpd-checkbox-label");C.className="dm-notes-pad__public",C.setAttribute("label",v("Public — visible to other desktop users","desktop-mode")),a&&C.setAttribute("checked",""),C.addEventListener("wpd-checkbox-change",d=>{a=d.detail.checked,e.storage.set("public",a)});const N=document.createElement("button");N.type="button",N.className="dm-notes-pad__pin-btn",N.textContent=v("Pin to desktop","desktop-mode"),N.title=v("Pin the note without dragging (Ctrl+Enter)","desktop-mode"),_.append(x,C,N),c.append(i,_),n.appendChild(c);function se(){const d=B(r),l=B(d);f.dataset.noteColor=r,i.dataset.noteColor=r,b.dataset.noteColor=d,m.dataset.noteColor=l,u.dataset.noteColor=d,u.setAttribute("aria-label",`${v("Next paper color","desktop-mode")}: ${d}`);for(const[E,A]of k)A.setAttribute("aria-checked",E===r?"true":"false"),A.classList.toggle("is-selected",E===r)}function re(d){r=K(d),e.storage.set("color",r),se()}const ae=()=>re(B(r));u.addEventListener("click",ae),se();const Je=d=>{p=d.detail.value};w.addEventListener("wpd-input-change",Je);const Ze=d=>{const l=d;l.key==="Enter"&&(l.ctrlKey||l.metaKey)&&(l.preventDefault(),ce()),l.stopPropagation()};["keydown","keypress","keyup"].forEach(d=>w.addEventListener(d,l=>{d==="keydown"?Ze(l):l.stopPropagation()}));const ie=()=>{p="",w.setAttribute("value","")},F=()=>{typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches||f.animate?.([{transform:"translateX(0)"},{transform:"translateX(-4px)"},{transform:"translateX(4px)"},{transform:"translateX(0)"}],{duration:200,easing:"ease-out"})},Qe=()=>{const l=document.createElement("div");l.className="desktop-mode-pinned-note-ghost",l.dataset.noteColor=r,l.style.width="208px";const E=document.createElement("div");E.className="desktop-mode-pinned-note-ghost__swing",E.dataset.noteColor=r;const A=208/2,U=10;E.style.transformOrigin=`${A}px ${U}px`;const P=document.createElement("span");P.className="desktop-mode-pinned-note__pin",P.style.setProperty("--dm-pin-dx","0px"),P.style.setProperty("--dm-pin-rot","0deg"),P.appendChild(Pe(e.pluginUrl));const W=document.createElement("div");W.className="desktop-mode-pinned-note__paper desktop-mode-pinned-note-ghost__paper";const G=document.createElement("div");return G.className="desktop-mode-pinned-note__body",G.textContent=p,W.appendChild(G),E.append(P,W),l.appendChild(E),{root:l,tipX:A,tipY:U}},de=d=>{if(t||!s||d.target?.closest("wpd-textarea, .dm-notes-pad__corner"))return;if(!p.trim()){F();return}const E=Ge();if(!E)return;d.preventDefault(),f.ownerDocument.defaultView?.getSelection()?.removeAllRanges();const A=Qe(),U={text:p,color:r,isPublic:a};E.start({payload:{type:je,source:f,data:U,ghost:{element:A.root,offsetX:A.tipX,offsetY:A.tipY,hint:{neutral:v("Drop on the desktop to pin","desktop-mode"),accept:v("Pin here","desktop-mode"),reject:v("Can’t pin here","desktop-mode")}}},origin:d,onClickOnly:()=>w.focusInput?.(),onCommit:()=>{ie(),le()}})};f.addEventListener("pointerdown",de);const le=()=>{typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches||f.animate?.([{transform:"translate(3px, 4px) rotate(1.1deg)",opacity:.9},{transform:"translate(-1px, -2px) rotate(-0.4deg)",offset:.7},{transform:"translate(0, 0) rotate(0deg)",opacity:1}],{duration:260,easing:"cubic-bezier(0.2, 0.7, 0.2, 1)"})};async function ce(){if(!(t||!s)){if(!p.trim()){F(),w.focusInput?.();return}N.disabled=!0;try{const d=Math.floor(Date.now()/1e3)%5,l=await Be({text:p,color:r,x:.55+d*.04,y:.12+d*.05,public:a,seed:Ie(p)});if(t)return;ie(),le(),document.dispatchEvent(new CustomEvent(Ve,{detail:{note:l}}))}catch(d){console.error("[desktop-mode] note pad: create failed:",d),F();const l=window.wp?.desktop?.showToast;l?.({message:v("Could not pin the note. Please try again.","desktop-mode"),duration:5e3})}finally{N.disabled=!1}}}const ue=()=>{ce()};return N.addEventListener("click",ue),s||(c.classList.add("dm-notes-pad--unavailable"),w.setAttribute("disabled",""),N.disabled=!0),()=>{t=!0,f.removeEventListener("pointerdown",de),u.removeEventListener("click",ae),N.removeEventListener("click",ue)}},V=window;V.desktopModeWidgets=V.desktopModeWidgets??{},V.desktopModeWidgets[Fe]=Ye})(); | |
| 20 | + `}_attr(e){return this.getAttribute(e)}_boolAttr(e){return this.getAttribute(e)!==null}_onInput(e){const t=e.target;this._textareaEl=t,this.setAttribute("value",t.value),this.emit("os-input-change",{value:t.value}),this._boolAttr("auto-grow")&&this._autosize(t)}_onChange(e){const t=e.target;this.emit("os-input-commit",{value:t.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 t=e.target;this.emit("os-submit",{value:t.value})}}_autosize(e){const t=Number(this._attr("max-rows"))||8,n=window.getComputedStyle(e),s=parseFloat(n.fontSize)||13,r=n.lineHeight,a=r==="normal"?s*1.45:parseFloat(r)||s*1.45,c=parseFloat(n.paddingTop)||0,l=parseFloat(n.paddingBottom)||0,i=(parseFloat(n.borderTopWidth)||0)+(parseFloat(n.borderBottomWidth)||0),d=a*t+c+l+i;e.style.height="auto",e.style.overflowY="hidden";const u=e.value?e.scrollHeight+i:a*(Number(this._attr("rows"))||3)+c+l+i,h=Math.min(u,d);e.style.height=`${Math.ceil(h)}px`,e.style.overflowY=u>Math.ceil(d)?"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 t=(this.shadowRoot??this).querySelector("textarea");t&&(t.value="",this._boolAttr("auto-grow")&&this._autosize(t))}};R.props=["label","value","placeholder","disabled","readonly","ariaLabel","name","rows","maxlength","minlength","invalid","autoGrow","maxRows","submitOnEnter"],R.styles=[ze],R.help=void 0;let U=R;xe("os-textarea",U);const Me="desktop-mode";function Pe(){return window.wp?.i18n}function E(o,e=Me){return Pe()?.__(o,e)??o}const S=["butter","blush","sky","mint","lilac","peach"];function W(o){return S.includes(o)?o:S[0]}function X(o){const e=S.indexOf(W(o));return S[(e+1)%S.length]}function De(o){let e=2166136261;for(let n=0;n<o.length;n++)e^=o.charCodeAt(n),e=Math.imul(e,16777619)>>>0;return e>>>1||1}const Oe=56,He=52;function Ue(o){return`${o.replace(/\/$/,"")}/assets/images/pushpin.svg`}function We(o){const e=document.createElement("img");return e.src=Ue(o),e.alt="",e.width=Oe,e.height=He,e.draggable=!1,e.className="os-pinned-note__pin-img",e}const oe="X-WP-Nonce";function Xe(o,e){const t=qe();if(!t)return e;const n=Ke(o);if(!n||!Fe(n))return e;const s=e?.headers??(typeof Request<"u"&&o instanceof Request?o.headers:void 0),r=new Headers(s??{});return r.has(oe)?e:(r.set(oe,t),{...e??{},headers:r})}function qe(){if(typeof window>"u")return;const e=window.openStationConfig?.restNonce;return typeof e=="string"&&e.length>0?e:void 0}function Ke(o){try{const e=typeof window<"u"&&window.location?window.location.href:void 0;return typeof o=="string"?new URL(o,e):o instanceof URL?o:typeof Request<"u"&&o instanceof Request?new URL(o.url,e):null}catch{return null}}function Fe(o){return typeof window>"u"||!window.location||o.origin!==window.location.origin?!1:!!(o.pathname.includes("/wp-json/")||o.searchParams.has("rest_route"))}function Be(o,e,t={}){const n=window.wp?.os?.fetch;if(typeof n=="function")return n(o,e,t);const s=Xe(o,e);return fetch(o,s)}let q=null;function je(o){q=o}function Ve(){if(!q)throw new Error("[openstation] notes REST client called before installNotesRestDeps().");return q}function Ge(o){const e=window.openStationConfig;return typeof e?.restNonce=="string"&&e.restNonce?e.restNonce:o}class Ye extends Error{constructor(e){super("Note was changed by another session."),this.status=409,this.name="NotesConflictError",this.current=e}}async function Ze(o,e){const{baseUrl:t,nonce:n}=Ve(),s=t,r=new Headers(e.headers??{});r.set("X-WP-Nonce",Ge(n)),e.body&&!r.has("Content-Type")&&r.set("Content-Type","application/json");const a=await Be(s,{...e,headers:r,credentials:"same-origin"},{source:"desktop-mode/notes"}),c=await a.text();let l=null;if(c)try{l=JSON.parse(c)}catch{l=null}if(!a.ok){if(a.status===409){const d=l?.data?.current;throw new Ye(d??null)}const i=l;throw new Error(`[openstation] notes REST ${a.status}: ${i?.code??""} ${i?.message??""}`.trim())}if(l===null)throw new Error(`[openstation] notes REST ${a.status}: empty or unparseable body.`);return l}function Je(o){return Ze("",{method:"POST",body:JSON.stringify(o)})}const Qe="note-draft",et="os-note-created",tt="desktop-mode/notes";function ot(){return window.openStationConfig??{}}function nt(){return window.wp?.os?.dragManager??null}const st=(o,e)=>{let t=!1;const n=ot(),s=!!n.notesUrl;s&&je({baseUrl:n.notesUrl,nonce:n.restNonce??""});let r=W(e.storage.get("color")??S[0]);const a=!1;let c="";const l=document.createElement("div");l.className="dm-notes-pad";const i=document.createElement("div");i.className="dm-notes-pad__stack";const d=document.createElement("div");d.className="dm-notes-pad__under dm-notes-pad__under--2";const u=document.createElement("div");u.className="dm-notes-pad__under dm-notes-pad__under--1";const h=document.createElement("div");h.className="dm-notes-pad__sheet";const b=document.createElement("div");b.className="dm-notes-pad__peel",b.setAttribute("aria-hidden","true");const m=document.createElement("span");m.className="dm-notes-pad__peel-hint",m.textContent=E("Drag to pin","desktop-mode"),b.appendChild(m);const v=document.createElement("os-textarea");v.className="dm-notes-pad__editor",v.setAttribute("aria-label",E("New note","desktop-mode")),v.setAttribute("placeholder",E("Write a note…","desktop-mode")),v.setAttribute("rows","5"),v.setAttribute("auto-grow",""),v.setAttribute("max-rows","8");const g=document.createElement("button");g.type="button",g.className="dm-notes-pad__corner",h.append(b,v,g),i.append(d,u,h);const y=document.createElement("div");y.className="dm-notes-pad__footer";const w=document.createElement("div");w.className="dm-notes-pad__swatches",w.setAttribute("role","radiogroup"),w.setAttribute("aria-label",E("Paper color","desktop-mode"));const k=new Map;for(const f of S){const p=document.createElement("button");p.type="button",p.className="dm-notes-pad__swatch",p.dataset.noteColor=f,p.setAttribute("role","radio"),p.setAttribute("aria-label",f),p.addEventListener("click",()=>ne(f)),k.set(f,p),w.appendChild(p)}y.append(w),l.append(i,y),o.appendChild(l);function T(){const f=X(r),p=X(f);h.dataset.noteColor=r,i.dataset.noteColor=r,u.dataset.noteColor=f,d.dataset.noteColor=p,g.dataset.noteColor=f,g.setAttribute("aria-label",`${E("Next paper color","desktop-mode")}: ${f}`);for(const[N,C]of k)C.setAttribute("aria-checked",N===r?"true":"false"),C.classList.toggle("is-selected",N===r)}function ne(f){r=W(f),e.storage.set("color",r),T()}const se=()=>ne(X(r));g.addEventListener("click",se),T();const rt=f=>{c=f.detail.value};v.addEventListener("os-input-change",rt);const at=f=>{const p=f;p.key==="Enter"&&(p.ctrlKey||p.metaKey)&&(p.preventDefault(),lt()),p.stopPropagation()};["keydown","keypress","keyup"].forEach(f=>v.addEventListener(f,p=>{f==="keydown"?at(p):p.stopPropagation()}));const re=()=>{c="",v.setAttribute("value","")},F=()=>{typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches||h.animate?.([{transform:"translateX(0)"},{transform:"translateX(-4px)"},{transform:"translateX(4px)"},{transform:"translateX(0)"}],{duration:200,easing:"ease-out"})},it=()=>{const p=document.createElement("div");p.className="os-pinned-note-ghost",p.dataset.noteColor=r,p.style.width="208px";const N=document.createElement("div");N.className="os-pinned-note-ghost__swing",N.dataset.noteColor=r;const C=208/2,P=10;N.style.transformOrigin=`${C}px ${P}px`;const L=document.createElement("span");L.className="os-pinned-note__pin",L.style.setProperty("--dm-pin-dx","0px"),L.style.setProperty("--dm-pin-rot","0deg"),L.appendChild(We(e.pluginUrl));const j=document.createElement("div");j.className="os-pinned-note__paper os-pinned-note-ghost__paper";const V=document.createElement("div");return V.className="os-pinned-note__body",V.textContent=c,j.appendChild(V),N.append(L,j),p.appendChild(N),{root:p,tipX:C,tipY:P}},ae=f=>{if(t||!s||f.target?.closest("os-textarea, .dm-notes-pad__corner"))return;if(!c.trim()){F();return}const N=nt();if(!N)return;f.preventDefault(),h.ownerDocument.defaultView?.getSelection()?.removeAllRanges();const C=it(),P={text:c,color:r,isPublic:a};N.start({payload:{type:Qe,source:h,data:P,ghost:{element:C.root,offsetX:C.tipX,offsetY:C.tipY,hint:{neutral:E("Drop on the desktop to pin","desktop-mode"),accept:E("Pin here","desktop-mode"),reject:E("Can’t pin here","desktop-mode")}}},origin:f,onClickOnly:()=>v.focusInput?.(),onCommit:()=>{re(),ie()}})};h.addEventListener("pointerdown",ae);const ie=()=>{typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches||h.animate?.([{transform:"translate(3px, 4px) rotate(1.1deg)",opacity:.9},{transform:"translate(-1px, -2px) rotate(-0.4deg)",offset:.7},{transform:"translate(0, 0) rotate(0deg)",opacity:1}],{duration:260,easing:"cubic-bezier(0.2, 0.7, 0.2, 1)"})};let B=!1;async function lt(){if(!(t||!s||B)){if(!c.trim()){F(),v.focusInput?.();return}B=!0;try{const f=Math.floor(Date.now()/1e3)%5,p=await Je({text:c,color:r,x:.55+f*.04,y:.12+f*.05,public:a,seed:De(c)});if(t)return;re(),ie(),document.dispatchEvent(new CustomEvent(et,{detail:{note:p}}))}catch(f){console.error("[openstation] note pad: create failed:",f),F();const p=window.wp?.os?.showToast;p?.({message:E("Could not pin the note. Please try again.","desktop-mode"),duration:5e3})}finally{B=!1}}}return s||(l.classList.add("dm-notes-pad--unavailable"),v.setAttribute("disabled","")),()=>{t=!0,h.removeEventListener("pointerdown",ae),g.removeEventListener("click",se)}},K=window;K.openStationWidgets=K.openStationWidgets??{},K.openStationWidgets[tt]=st})(); | |