monowind 0.2.5 → 0.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn.js +42 -6
- package/dist/cdn.js.map +1 -1
- package/dist/element.d.ts.map +1 -1
- package/dist/index.js +578 -541
- package/dist/index.js.map +1 -1
- package/dist/paint.d.ts +1 -0
- package/dist/paint.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/styles.css +37 -2
package/dist/cdn.js
CHANGED
|
@@ -1008,7 +1008,8 @@ input:where([type='button'], [type='reset'], [type='submit']),
|
|
|
1008
1008
|
<pre id="grid" aria-hidden="true"></pre>
|
|
1009
1009
|
<slot></slot>
|
|
1010
1010
|
</div>
|
|
1011
|
-
`,Ta=`grid`,Ea=`data-mw-semantic-selection`,Da=[`pointerover`,`pointerleave`,`pointerdown`,`pointerup`,`pointercancel`,`keydown`,`keyup`,`focusin`,`focusout`,`input`,`change`],Oa=/^(color|opacity|border-(top|right|bottom|left)-color|border-color)$/,ka=3e4,Aa=200,ja=3,Ma=4,Na=8,Pa=100,Fa=160,Ia=typeof HTMLElement>`u`?class{}:HTMLElement,La=class e extends Ia{static observedAttributes=[`select`];static#e=new Set;static#t=null;static#n=()=>{for(let t of e.#e)t.#Ce()};static#r(t){t instanceof HTMLLinkElement&&t.rel===`stylesheet`&&!t.sheet&&t.addEventListener(`load`,e.#n,{once:!0})}static#i(t){if(e.#e.add(t),e.#t)return;for(let t of document.querySelectorAll(`link[rel=stylesheet]`))e.#r(t);let n=new MutationObserver(t=>{for(let n of t)for(let t of n.addedNodes)e.#r(t);e.#n()});n.observe(document.head,{childList:!0,subtree:!0,characterData:!0}),e.#t=n}static#a(t){e.#e.delete(t),e.#e.size===0&&(e.#t?.disconnect(),e.#t=null)}#o;#s;#c;#l=null;#u=null;#d=!1;#f=null;#p=null;#m=null;#h=null;#g=!1;#_=[];#v=new Map;#y=new WeakMap;#b=null;#x=null;#S=``;#C=null;#w=[];#T(){this.#u?.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`class`,`style`,`colspan`,`rowspan`,`span`,...c()]})}constructor(){super(),this.#o=this.attachShadow({mode:`open`}),this.#o.innerHTML=wa,this.#s=this.#o.getElementById(`grid`),this.#c=document.createElement(`span`),this.#c.setAttribute(`aria-hidden`,`true`),this.#c.setAttribute(`data-mw-probe`,``),this.#c.style.cssText=`position:absolute!important;top:0!important;left:0!important;visibility:hidden!important;pointer-events:none!important;user-select:none!important;white-space:pre!important;overflow-wrap:normal!important;padding:0!important;margin:0!important;border:0!important;`,this.#c.textContent=`M`.repeat(100)}connectedCallback(){this.hasAttribute(`select`)||this.setAttribute(`select`,Ta),this.#c.parentNode!==this&&this.appendChild(this.#c),this.#l=new ResizeObserver(()=>this.#Ce()),this.#l.observe(this),this.#q(),this.#l.observe(this.#c),window.addEventListener(`resize`,this.#ye),this.#u=new MutationObserver(()=>this.#Ce()),this.#T(),this.#m=l(()=>{this.#T(),this.#Ce()}),this.#h=re(()=>this.#Ce()),document.fonts?.ready.then(this.#be).catch(e=>{console.warn(`[monowind] document.fonts.ready failed:`,e)}),document.fonts?.addEventListener(`loadingdone`,this.#be);for(let e of Da)this.addEventListener(e,this.#ve);this.addEventListener(`transitionrun`,this.#he),this.addEventListener(`transitionend`,this.#ge),this.addEventListener(`transitioncancel`,this.#ge),this.addEventListener(`pointermove`,this.#X),this.addEventListener(`pointerleave`,this.#oe),this.addEventListener(`pointerdown`,this.#se),this.addEventListener(`scroll`,this.#H,{capture:!0,passive:!0}),this.addEventListener(`scrollend`,this.#U,{capture:!0}),this.addEventListener(`wheel`,this.#G,{passive:!1}),this.addEventListener(`copy`,this.#Z),this.addEventListener(`mousedown`,this.#Q),document.addEventListener(`selectionchange`,this.#ae),window.addEventListener(`pointerup`,this.#ce),window.addEventListener(`pointercancel`,this.#ce),document.addEventListener(`scroll`,this.#le,{capture:!0,passive:!0}),e.#i(this),this.#Ce()}disconnectedCallback(){window.removeEventListener(`resize`,this.#ye),this.#l?.disconnect(),this.#u?.disconnect(),this.#l=null,this.#u=null,this.#m?.(),this.#m=null,this.#h?.(),this.#h=null,document.fonts?.removeEventListener(`loadingdone`,this.#be);for(let e of Da)this.removeEventListener(e,this.#ve);this.removeEventListener(`transitionrun`,this.#he),this.removeEventListener(`transitionend`,this.#ge),this.removeEventListener(`transitioncancel`,this.#ge),this.#fe=0,this.removeEventListener(`pointermove`,this.#X),this.removeEventListener(`pointerleave`,this.#oe),this.removeEventListener(`pointerdown`,this.#se),this.removeEventListener(`scroll`,this.#H,{capture:!0}),this.removeEventListener(`scrollend`,this.#U,{capture:!0}),this.removeEventListener(`wheel`,this.#G),this.removeEventListener(`copy`,this.#Z),this.removeEventListener(`mousedown`,this.#Q),document.removeEventListener(`selectionchange`,this.#ae);for(let e of this.#v.values())clearTimeout(e);this.#v.clear(),this.#x=null,this.#b=null,window.removeEventListener(`pointerup`,this.#ce),window.removeEventListener(`pointercancel`,this.#ce),document.removeEventListener(`scroll`,this.#le,{capture:!0}),this.#j=null,this.#O=null,this.#k=!1,this.#A=!1,this.#ue(),e.#a(this)}#E=new Set;#D=new Set;#O=null;#k=!1;#A=!1;#j=null;#M=NaN;#N=NaN;#P=null;static#F=typeof matchMedia>`u`?null:matchMedia(`(hover: hover)`);#I(){if(this.#g||this.#d)return;this.#g=!0;let e=!1,t=()=>{if(e)return;e=!0,this.#g=!1;let t=this.#f;this.isConnected&&this.#p&&t&&(this.#L(t),this.#A=!Rr(this.#p,this.#s,this.#k),this.#ue())};requestAnimationFrame(t),setTimeout(t,50)}#L(e,t){for(let n of this.#_){let r=n.source,{maxX:i,maxY:a}=n.scrollRange,o=t?.get(r);n.scroll=o?{x:o.pinX?i:Math.min(o.x,i),y:o.pinY?a:Math.min(o.y,a)}:this.#R(n,e)}}#R(e,t){let n=e.source,{maxX:r,maxY:i}=e.scrollRange,a=e.scroll??{x:0,y:0};return{x:za(n,`x`,t.width,r,a.x),y:za(n,`y`,t.height,i,a.y)}}#z(){let e=new Map,t=this.#f;if(!t)return e;for(let n of this.#_){let r=n.source,{maxX:i,maxY:a}=n.scrollRange,{x:o,y:s}=this.#R(n,t);e.set(r,{top:r.scrollTop,left:r.scrollLeft,x:o,y:s,pinX:i>0&&o>=i,pinY:a>0&&s>=a})}return e}#B(e){for(let t of this.#_){let n=t.source,r=e.get(n);r&&(n.scrollTop,n.scrollLeft,n.scrollTop=r.pinY?n.scrollHeight:r.top,n.scrollLeft=r.pinX?n.scrollWidth:r.left)}}#V(e,t){clearTimeout(this.#v.get(e)),this.#v.set(e,setTimeout(()=>this.#W(e),t))}#H=e=>{let t=e.target;t instanceof HTMLElement&&t!==this&&t.hasAttribute(`data-mw-scroll`)&&(this.#I(),!(Date.now()-(this.#y.get(t)??0)<Aa)&&(clearTimeout(this.#v.get(t)),`onscrollend`in window||this.#V(t,Fa)))};#U=e=>{let t=e.target;t instanceof HTMLElement&&t!==this&&t.hasAttribute(`data-mw-scroll`)&&(Date.now()-(this.#y.get(t)??0)<Aa||this.#V(t,Pa))};#W(e){if(this.#x?.el===e)return;this.#I();let t=this.#f,n=this.#_.find(t=>t.source===e);if(!t||!n)return;let r=n.scrollRange,i=n.scroll??this.#R(n,t),a=i.y===r.maxY?e.scrollHeight-e.clientHeight:i.y*t.height,o=i.x===r.maxX?e.scrollWidth-e.clientWidth:i.x*t.width;(Math.abs(e.scrollTop-a)>.5||Math.abs(e.scrollLeft-o)>.5)&&e.scrollTo({top:a,left:o,behavior:`instant`})}#G=e=>{if(this.getAttribute(`select`)!==`grid`)return;let t=this.#p,n=this.#f;if(!t||!n||this.#_.length===0)return;let r=e,i=r.deltaMode===1?n.height:r.deltaMode===2?this.clientHeight:1,a=r.deltaX*i,o=r.deltaY*i;if(!r.cancelable&&this.#K(a,o))return;let{col:s,row:c}=this.#J(r.clientX,r.clientY,n),l=Date.now(),u=Math.abs(a)+Math.abs(o);if(u===0){this.#b=null,r.preventDefault();return}let d=e=>{let t=e.scrollRange,n=e.source;return o!==0&&t.maxY>0&&(o>0&&n.scrollTop<n.scrollHeight-n.clientHeight-.5||o<0&&n.scrollTop>.5)||a!==0&&t.maxX>0&&(a>0&&n.scrollLeft<n.scrollWidth-n.clientWidth-.5||a<0&&n.scrollLeft>.5)},f=this.#b,p=Math.abs(a)>=Math.abs(o)?`x`:`y`,m=f!==null&&u>f.mag*1.25+1,h=f!==null&&(Math.abs(r.clientX-f.x)>ja||Math.abs(r.clientY-f.y)>ja),g=f!==null&&f.decayed>=Na,_=f!==null&&l-f.at<Aa&&p===f.axis&&(h?u<=f.mag:!(g&&m)),v=null;if(_){if(f.decayed=u<=f.mag&&u>=f.mag*.5?f.decayed+1:g?f.decayed:0,f.mag=u,f.at=l,!f.el)return;v=this.#_.find(e=>e.source===f.el)??null}if(!v){let e=hr(t,s,c);for(let t=e.length-1;t>=0;t--){let n=e[t].node;if(!n.scrollRange)continue;if(d(n)){v=n;break}let r=n.style.overscroll;if(o!==0&&!r.y||a!==0&&!r.x){v=n;break}}if(!v&&u<Ma){r.preventDefault();return}this.#b={el:v?v.source:null,x:r.clientX,y:r.clientY,axis:p,at:l,mag:u,decayed:0}}if(!v||(r.preventDefault(),!d(v)))return;let y=v.source,b=v.scrollRange,x={behavior:`instant`};o!==0&&b.maxY>0&&(x.top=o),a!==0&&b.maxX>0&&(x.left=a),y.scrollBy(x),this.#y.set(y,l),this.#V(y,Aa)};#K(e,t){return this.#w.some(n=>t>0&&n.scrollTop<n.scrollHeight-n.clientHeight-.5||t<0&&n.scrollTop>.5||e>0&&n.scrollLeft<n.scrollWidth-n.clientWidth-.5||e<0&&n.scrollLeft>.5)}#q(){let e=this.parentElement;if(e&&this.#l){this.#l.observe(e);for(let t of e.children)t!==this&&this.#l.observe(t)}}#J(e,t,n){if(!this.#P){let e=this.#s.getBoundingClientRect();this.#P={left:e.left,top:e.top}}return{col:Math.floor((e-this.#P.left)/n.width),row:Math.floor((t-this.#P.top)/n.height)}}#Y(e,t){let n=this.#p,r=this.#f;if(!n||!r||this.#_.length===0)return null;let{col:i,row:a}=this.#J(e,t,r),o=hr(n,i,a);for(let n=o.length-1;n>=0;n--){let{node:s,x:c,y:l}=o[n],u=s.scrollRange;if(!u)continue;let d=s.source,{y:f,x:p}=fr(s,c,l);if(f&&u.maxY>0&&i>=f.col&&i<f.col+f.thick&&a>=f.row&&a<f.row+f.len){let e=pr(f.len,u.sizeY,u.maxY,0).len,n=Math.max(1,(f.len-e)*r.height);return{el:d,axis:`y`,startClient:t,startPx:d.scrollTop,factor:u.maxY*r.height/n}}if(p&&u.maxX>0&&a>=p.row&&a<p.row+p.thick&&i>=p.col&&i<p.col+p.len){let t=pr(p.len,u.sizeX,u.maxX,0).len,n=Math.max(1,(p.len-t)*r.width);return{el:d,axis:`x`,startClient:e,startPx:d.scrollLeft,factor:u.maxX*r.width/n}}}return null}#X=e=>{if(Va(e))return;let{clientX:t,clientY:n}=e,r=this.#x;if(r){let e=(r.axis===`y`?n:t)-r.startClient,i=r.startPx+e*r.factor;r.axis===`y`?r.el.scrollTop=i:r.el.scrollLeft=i;return}let i=this.#C;i&&e.buttons&1&&this.#$(i,t,n),this.#j={x:t,y:n};let a=this.#f;if(a){let{col:e,row:r}=this.#J(t,n,a);if(e===this.#M&&r===this.#N)return}this.#ue()};#Z=e=>{let{clipboardData:t}=e,n=this.#p,r=this.#ie();t&&n&&r&&(t.setData(`text/plain`,Sr(n,r)),e.preventDefault())};#Q=e=>{let t=e;if(t.button!==0||this.getAttribute(`select`)!==`grid`||!t.composedPath().includes(this.#s))return;if(t.detail<=1){t.detail===1&&this.removeAttribute(Ea);return}if(this.#S!==`mouse`&&this.#S!==`pen`)return;t.preventDefault();let n=document.activeElement;n instanceof HTMLElement&&n!==document.body&&this.contains(n)&&n.blur();let r=t.detail===2?`word`:`paragraph`,i=document.getSelection(),a=this.#p,o=this.#f;if(!i||!a||!o)return;let{col:s,row:c}=this.#J(t.clientX,t.clientY,o),l=this.#te(s,c,r);if(!l){i.removeAllRanges(),this.#C=null;return}this.#re(l);let u=t.shiftKey&&i.anchorNode&&this.#ie()?Ua({node:i.anchorNode,offset:i.anchorOffset}):l;this.#ee(i,u,l),this.#C={unit:r,anchor:u}};#$(e,t,n){let r=this.#f,i=document.getSelection();if(!r||!i)return;let{col:a,row:o}=this.#J(t,n,r),s=this.#te(a,o,e.unit);s&&this.#ee(i,e.anchor,s)}#ee(e,t,n){if(Ga(t,n)){Wa(e,n.start,n.end);return}let r=this.#ne(t),i=this.#ne(n);_r(r.start.node,r.start.offset,i.start.node,i.start.offset)<=0?Wa(e,r.start,i.end):Wa(e,r.end,i.start)}#te(e,t,n){let r=this.#p;if(!r)return null;let i=hr(r,e,t);for(let r=i.length-1;r>=0;r--){let{node:a,x:o,y:c}=i[r];if(!Or(a))continue;let l=s(a.source.tagName)?.selectionTarget?.(a.source);if(n===`word`&&!l){let n=dr(a,o,c,e,t);if(n===null)return null;let r=jr(a,n),i=r&&yr(a,r.start),s=r&&yr(a,r.end);if(i&&s)return{start:i,end:s}}let u=l??a.source;return{start:{node:u,offset:0},end:{node:u,offset:u.childNodes.length}}}return null}#ne(e){let t=e.start.node.getRootNode();if(!(t instanceof ShadowRoot)||t===this.#s.getRootNode())return e;let n=t.host,r=n.parentNode;if(!r)return e;let i=Array.prototype.indexOf.call(r.childNodes,n),a=n.previousSibling,o=n.nextSibling;return{start:Ha(a)?{node:a,offset:a instanceof Text?a.length:a.childNodes.length}:{node:r,offset:i},end:Ha(o)?{node:o,offset:0}:{node:r,offset:i+1}}}#re(e){this.setAttribute(Ea,``);let t=e.start.node,n=t instanceof Element?t:t.parentElement;n&&getComputedStyle(n).userSelect}#ie(){let e=br(this.#s.getRootNode());return!e||xr(this,this.#s,e)!==`light`||e.startContainer===e.endContainer&&e.startOffset===e.endOffset?null:e}#ae=()=>{this.hasAttribute(Ea)&&(this.#ie()||this.removeAttribute(Ea))};#oe=()=>{this.#j=null,this.#ue()};#se=e=>{let t=e;if(!t.isPrimary||t.button!==0||(this.#S=t.pointerType,Va(t)))return;let n=this.#Y(t.clientX,t.clientY);if(n){this.#x=n,t.preventDefault(),t.isTrusted&&this.setPointerCapture(t.pointerId);return}this.#j={x:t.clientX,y:t.clientY},this.#k=!0,this.#ue(!0)};#ce=e=>{if(e.isPrimary){if(this.#C=null,this.#x){this.#W(this.#x.el),this.#x=null;return}(this.#k||this.#O)&&(this.#k=!1,this.#O=null,this.#ue(),this.#A&&this.#Ce())}};#le=e=>{if(!this.#j)return;let t=e.target;t instanceof HTMLElement&&t.hasAttribute(`data-mw-scroll`)||(this.#P=null,this.#ue())};#ue(t=!1){let n=this.#p,r=this.#f,i=[];if(this.#j&&n&&r&&this.isConnected&&this.getAttribute(`select`)===`grid`&&(this.#k||e.#F?.matches)){let{col:e,row:t}=this.#J(this.#j.x,this.#j.y,r);this.#M=e,this.#N=t,i=gr(n,e,t)}else this.#M=NaN,this.#N=NaN;let a=i.at(-1)??null;t&&(this.#O=a);let o=e.#F?.matches?i:[],s=this.#O?i.indexOf(this.#O):-1,c=s>=0?i.slice(0,s+1):[],l=this.#de(`data-mw-hover`,this.#E,o);l=this.#de(`data-mw-active`,this.#D,c)||l;let u=a?getComputedStyle(a).cursor:``;this.#s.style.cursor=u===`auto`?``:u,l&&this.isConnected&&this.#Ce()}#de(e,t,n){let r=!1,i=new Set(n);for(let n of t)i.has(n)||(n.removeAttribute(e),r=!0);for(let n of i)t.has(n)||(n.setAttribute(e,``),r=!0);t.clear();for(let e of i)t.add(e);return r}#fe=0;#pe=!1;#me=0;#he=e=>{Oa.test(e.propertyName)&&(this.#fe++,this.#me=performance.now(),this.#_e())};#ge=e=>{Oa.test(e.propertyName)&&(this.#fe=Math.max(0,this.#fe-1))};#_e(){if(this.#pe)return;this.#pe=!0;let e=()=>{if(!this.isConnected||this.#fe===0&&!_()||performance.now()-this.#me>ka){this.#pe=!1,this.#fe=0,this.#Ce();return}this.#Se(),requestAnimationFrame(e)};requestAnimationFrame(e)}#ve=e=>{if(!Va(e)){if((e.type===`focusin`||e.type===`focusout`)&&e.target instanceof HTMLSelectElement){this.#Se();return}this.#Ce()}};attributeChangedCallback(e,t,r){if(e===`select`&&r!==`text`&&r!==`grid`){r!==null&&console.warn(`[monowind] Ignoring unrecognized select="${r}". Expected "grid" (default) or "text".`,n(this)),this.setAttribute(`select`,Ta);return}e===`select`&&this.#ue(),this.#Ce()}toPlainText(){return this.#d&&this.#we(),this.#p?er(this.#p):``}#ye=()=>{this.#Ce()};#be=()=>{requestAnimationFrame(()=>this.#Ce())};#xe(){let e=document.activeElement;if(!(e instanceof HTMLSelectElement)||!this.contains(e))return!1;try{return e.matches(`:open`)}catch{return!1}}#Se(){try{this.#we()}catch(e){console.error(`[monowind] layout failed:`,e)}}#Ce(){this.#d||(this.#d=!0,requestAnimationFrame(()=>{if(this.#d=!1,this.#xe()){this.#Ce();return}this.#Se()}))}#we(){if(!this.isConnected)return;let e=this.#z(),t=new Map,r=getComputedStyle(this).getPropertyValue(`--mw-cw`).trim(),i=parseFloat(r);if(Number.isFinite(i)&&i>0)for(let e of this.querySelectorAll(`textarea`)){let n=getComputedStyle(e),r=e.clientWidth-(parseFloat(n.paddingLeft)||0)-(parseFloat(n.paddingRight)||0);t.set(e,Math.max(0,Math.round(r/i)))}this.setAttribute(`measuring`,``);try{this.#c.parentNode!==this&&this.appendChild(this.#c);let r=I(this,this.#c),i=this.#f;(i===null||i.width!==r.width||i.height!==r.height||i.letterSpacing!==r.letterSpacing||i.inkOverhang!==r.inkOverhang)&&(this.style.setProperty(`--mw-cw`,`${r.width}px`),this.style.setProperty(`--mw-ch`,`${r.height}px`),this.style.setProperty(`--mw-rls`,`${r.letterSpacing}px`),this.style.setProperty(`--mw-ink`,`${r.inkOverhang??0}px`)),this.#f=r;let a=getComputedStyle(this),o=(parseFloat(a.paddingLeft)||0)+(parseFloat(a.paddingRight)||0),s=Math.max(0,Math.floor((this.clientWidth-o)/r.width));if(s===0)return;let c=L(),l=[];for(let e of Array.from(this.children)){if(e===this.#c)continue;let n=ra(e,c,r,t);n&&l.push(n)}if(ba(this)?(this.hasAttribute(`data-mw-dropped-text`)||console.warn(`[monowind] ${xa}`,n(this)),this.setAttribute(`data-mw-dropped-text`,``)):this.removeAttribute(`data-mw-dropped-text`),l.length===0){this.#s.replaceChildren(),this.#p=null,this.setAttribute(`data-mw-ready`,``);return}let u={source:this,style:tt(),children:l,text:``,intrinsicWidth:0,intrinsicHeight:0,localRect:{x:0,y:0,width:0,height:0},unclampedHeight:0,resolvedPadding:nt()},{height:d}=Tn(u,s);Kr(u),this.#_=Ka(u),this.#L(r,e),this.#A=!Rr(u,this.#s,this.#k),this.#p=u;let f=`${u.localRect.width*r.width}px`,p=`${u.localRect.height*r.height}px`;this.#s.style.width!==f&&(this.#s.style.width=f),this.#s.style.height!==p&&(this.#s.style.height=p);let m=a.boxSizing===`border-box`?(parseFloat(a.paddingTop)||0)+(parseFloat(a.paddingBottom)||0)+(parseFloat(a.borderTopWidth)||0)+(parseFloat(a.borderBottomWidth)||0):0,h=`${d*r.height+m}px`;this.style.height!==h&&(this.style.height=h);let g=a.boxSizing===`border-box`?o+(parseFloat(a.borderLeftWidth)||0)+(parseFloat(a.borderRightWidth)||0):0,_=`${s*r.width+g}px`;this.style.getPropertyValue(`--mw-host-w`)!==_&&this.style.setProperty(`--mw-host-w`,_),this.hasAttribute(`data-mw-ready`)||this.setAttribute(`data-mw-ready`,``)}finally{this.setAttribute(`settling`,``),this.removeAttribute(`measuring`),getComputedStyle(this).transitionProperty,this.removeAttribute(`settling`),this.#B(e),this.#u?.takeRecords(),g(this)&&(_()?(this.#me=performance.now(),this.#_e()):this.#Ce()),this.#q(),this.#w=[];let t=document.scrollingElement??document.documentElement;for(let e=this.parentElement;e;e=e.parentElement)(e===t||/auto|scroll/.test(getComputedStyle(e).overflow))&&this.#w.push(e);this.#P=null,this.#j&&this.#ue()}}};function Ra(){typeof customElements>`u`||customElements.get(`mono-wind`)||customElements.define(`mono-wind`,La)}function za(e,t,n,r,i){return Ba(t===`y`?e.scrollTop:e.scrollLeft,t===`y`?e.scrollHeight-e.clientHeight:e.scrollWidth-e.clientWidth,n,r,i)}function Ba(e,t,n,r,i){if(r>0&&e>0&&e>=t-1)return r;let a=e/n-i,o=Math.abs(a)<=.5?i:i+Math.sign(a)*Math.round(Math.abs(a));return Math.min(Math.max(0,o),r)}function Va(e){return e instanceof PointerEvent&&e.pointerType===`touch`&&e.type!==`pointerup`}function Ha(e){return e!==null&&!(e instanceof Element&&e.shadowRoot)}function Ua(e){return{start:e,end:e}}function Wa(e,t,n){e.setBaseAndExtent(t.node,t.offset,n.node,n.offset)}function Ga(e,t){return e.start.node===t.start.node&&e.start.offset===t.start.offset&&e.end.node===t.end.node&&e.end.offset===t.end.offset}function Ka(e){let t=[],n=e=>{e.scrollRange&&t.push(e);for(let t of e.children)n(t)};return n(e),t}var qa=`/* Gap decorations (specs/gap-decorations.md): css-gaps-1 rules for flex
|
|
1011
|
+
`,Ta=`grid`,Ea=`data-mw-semantic-selection`,Da=`a, button, input, select, textarea, label, [tabindex], [role='button']`,Oa=[`pointerover`,`pointerleave`,`pointerdown`,`pointerup`,`pointercancel`,`keydown`,`keyup`,`focusin`,`focusout`,`input`,`change`],ka=/^(color|opacity|border-(top|right|bottom|left)-color|border-color)$/,Aa=3e4,ja=200,Ma=3,Na=4,Pa=8,Fa=100,Ia=160,La=typeof HTMLElement>`u`?class{}:HTMLElement,Ra=class e extends La{static observedAttributes=[`select`];static#e=new Set;static#t=null;static#n=()=>{for(let t of e.#e)t.#Me()};static#r(t){t instanceof HTMLLinkElement&&t.rel===`stylesheet`&&!t.sheet&&t.addEventListener(`load`,e.#n,{once:!0})}static#i(t){if(e.#e.add(t),e.#t)return;for(let t of document.querySelectorAll(`link[rel=stylesheet]`))e.#r(t);let n=new MutationObserver(t=>{for(let n of t)for(let t of n.addedNodes)e.#r(t);e.#n()});n.observe(document.head,{childList:!0,subtree:!0,characterData:!0}),e.#t=n}static#a(t){e.#e.delete(t),e.#e.size===0&&(e.#t?.disconnect(),e.#t=null)}#o;#s;#c;#l=null;#u=null;#d=!1;#f=null;#p=null;#m=null;#h=null;#g=!1;#_=[];#v=new Map;#y=new WeakMap;#b=null;#x=null;#S=``;#C=null;#w=null;#T=!1;#E=[];#D(){this.#u?.observe(this,{childList:!0,subtree:!0,characterData:!0,attributes:!0,attributeFilter:[`class`,`style`,`colspan`,`rowspan`,`span`,...c()]})}constructor(){super(),this.#o=this.attachShadow({mode:`open`}),this.#o.innerHTML=wa,this.#s=this.#o.getElementById(`grid`),this.#c=document.createElement(`span`),this.#c.setAttribute(`aria-hidden`,`true`),this.#c.setAttribute(`data-mw-probe`,``),this.#c.style.cssText=`position:absolute!important;top:0!important;left:0!important;visibility:hidden!important;pointer-events:none!important;user-select:none!important;white-space:pre!important;overflow-wrap:normal!important;padding:0!important;margin:0!important;border:0!important;`,this.#c.textContent=`M`.repeat(100)}connectedCallback(){this.hasAttribute(`select`)||this.setAttribute(`select`,Ta),this.#c.parentNode!==this&&this.appendChild(this.#c),this.#l=new ResizeObserver(()=>this.#Me()),this.#l.observe(this),this.#Y(),this.#l.observe(this.#c),window.addEventListener(`resize`,this.#Oe),this.#u=new MutationObserver(()=>this.#Me()),this.#D(),this.#m=l(()=>{this.#D(),this.#Me()}),this.#h=re(()=>this.#Me()),document.fonts?.ready.then(this.#ke).catch(e=>{console.warn(`[monowind] document.fonts.ready failed:`,e)}),document.fonts?.addEventListener(`loadingdone`,this.#ke);for(let e of Oa)this.addEventListener(e,this.#De);this.addEventListener(`transitionrun`,this.#we),this.addEventListener(`transitionend`,this.#Te),this.addEventListener(`transitioncancel`,this.#Te),this.addEventListener(`pointermove`,this.#Q),this.addEventListener(`pointerleave`,this.#he),this.addEventListener(`pointerdown`,this.#ge),this.addEventListener(`scroll`,this.#W,{capture:!0,passive:!0}),this.addEventListener(`scrollend`,this.#G,{capture:!0}),this.addEventListener(`wheel`,this.#q,{passive:!1}),this.addEventListener(`copy`,this.#$),this.addEventListener(`mousedown`,this.#ee),document.addEventListener(`selectionchange`,this.#me),window.addEventListener(`pointerup`,this.#_e),window.addEventListener(`pointercancel`,this.#_e),document.addEventListener(`scroll`,this.#ve,{capture:!0,passive:!0}),e.#i(this),this.#Me()}disconnectedCallback(){window.removeEventListener(`resize`,this.#Oe),this.#l?.disconnect(),this.#u?.disconnect(),this.#l=null,this.#u=null,this.#m?.(),this.#m=null,this.#h?.(),this.#h=null,document.fonts?.removeEventListener(`loadingdone`,this.#ke);for(let e of Oa)this.removeEventListener(e,this.#De);this.removeEventListener(`transitionrun`,this.#we),this.removeEventListener(`transitionend`,this.#Te),this.removeEventListener(`transitioncancel`,this.#Te),this.#xe=0,this.removeEventListener(`pointermove`,this.#Q),this.removeEventListener(`pointerleave`,this.#he),this.removeEventListener(`pointerdown`,this.#ge),this.removeEventListener(`scroll`,this.#W,{capture:!0}),this.removeEventListener(`scrollend`,this.#G,{capture:!0}),this.removeEventListener(`wheel`,this.#q),this.removeEventListener(`copy`,this.#$),this.removeEventListener(`mousedown`,this.#ee),document.removeEventListener(`selectionchange`,this.#me);for(let e of this.#v.values())clearTimeout(e);this.#v.clear(),this.#x=null,this.#b=null,window.removeEventListener(`pointerup`,this.#_e),window.removeEventListener(`pointercancel`,this.#_e),document.removeEventListener(`scroll`,this.#ve,{capture:!0}),this.#N=null,this.#A=null,this.#j=!1,this.#M=!1,this.#ye(),e.#a(this)}#O=new Set;#k=new Set;#A=null;#j=!1;#M=!1;#N=null;#P=NaN;#F=NaN;#I=null;static#L=typeof matchMedia>`u`?null:matchMedia(`(hover: hover)`);#R(){if(this.#g||this.#d)return;this.#g=!0;let e=!1,t=()=>{if(e)return;e=!0,this.#g=!1;let t=this.#f;this.isConnected&&this.#p&&t&&(this.#z(t),this.#M=!Rr(this.#p,this.#s,this.#ne()),this.#ye())};requestAnimationFrame(t),setTimeout(t,50)}#z(e,t){for(let n of this.#_){let r=n.source,{maxX:i,maxY:a}=n.scrollRange,o=t?.get(r);n.scroll=o?{x:o.pinX?i:Math.min(o.x,i),y:o.pinY?a:Math.min(o.y,a)}:this.#B(n,e)}}#B(e,t){let n=e.source,{maxX:r,maxY:i}=e.scrollRange,a=e.scroll??{x:0,y:0};return{x:Ba(n,`x`,t.width,r,a.x),y:Ba(n,`y`,t.height,i,a.y)}}#V(){let e=new Map,t=this.#f;if(!t)return e;for(let n of this.#_){let r=n.source,{maxX:i,maxY:a}=n.scrollRange,{x:o,y:s}=this.#B(n,t);e.set(r,{top:r.scrollTop,left:r.scrollLeft,x:o,y:s,pinX:i>0&&o>=i,pinY:a>0&&s>=a})}return e}#H(e){for(let t of this.#_){let n=t.source,r=e.get(n);r&&(n.scrollTop,n.scrollLeft,n.scrollTop=r.pinY?n.scrollHeight:r.top,n.scrollLeft=r.pinX?n.scrollWidth:r.left)}}#U(e,t){clearTimeout(this.#v.get(e)),this.#v.set(e,setTimeout(()=>this.#K(e),t))}#W=e=>{let t=e.target;t instanceof HTMLElement&&t!==this&&t.hasAttribute(`data-mw-scroll`)&&(this.#R(),!(Date.now()-(this.#y.get(t)??0)<ja)&&(clearTimeout(this.#v.get(t)),`onscrollend`in window||this.#U(t,Ia)))};#G=e=>{let t=e.target;t instanceof HTMLElement&&t!==this&&t.hasAttribute(`data-mw-scroll`)&&(Date.now()-(this.#y.get(t)??0)<ja||this.#U(t,Fa))};#K(e){if(this.#x?.el===e)return;this.#R();let t=this.#f,n=this.#_.find(t=>t.source===e);if(!t||!n)return;let r=n.scrollRange,i=n.scroll??this.#B(n,t),a=i.y===r.maxY?e.scrollHeight-e.clientHeight:i.y*t.height,o=i.x===r.maxX?e.scrollWidth-e.clientWidth:i.x*t.width;(Math.abs(e.scrollTop-a)>.5||Math.abs(e.scrollLeft-o)>.5)&&e.scrollTo({top:a,left:o,behavior:`instant`})}#q=e=>{if(this.getAttribute(`select`)!==`grid`)return;let t=this.#p,n=this.#f;if(!t||!n||this.#_.length===0)return;let r=e,i=r.deltaMode===1?n.height:r.deltaMode===2?this.clientHeight:1,a=r.deltaX*i,o=r.deltaY*i;if(!r.cancelable&&this.#J(a,o))return;let{col:s,row:c}=this.#X(r.clientX,r.clientY,n),l=Date.now(),u=Math.abs(a)+Math.abs(o);if(u===0){this.#b=null,r.preventDefault();return}let d=e=>{let t=e.scrollRange,n=e.source;return o!==0&&t.maxY>0&&(o>0&&n.scrollTop<n.scrollHeight-n.clientHeight-.5||o<0&&n.scrollTop>.5)||a!==0&&t.maxX>0&&(a>0&&n.scrollLeft<n.scrollWidth-n.clientWidth-.5||a<0&&n.scrollLeft>.5)},f=this.#b,p=Math.abs(a)>=Math.abs(o)?`x`:`y`,m=f!==null&&u>f.mag*1.25+1,h=f!==null&&(Math.abs(r.clientX-f.x)>Ma||Math.abs(r.clientY-f.y)>Ma),g=f!==null&&f.decayed>=Pa,_=f!==null&&l-f.at<ja&&p===f.axis&&(h?u<=f.mag:!(g&&m)),v=null;if(_){if(f.decayed=u<=f.mag&&u>=f.mag*.5?f.decayed+1:g?f.decayed:0,f.mag=u,f.at=l,!f.el)return;v=this.#_.find(e=>e.source===f.el)??null}if(!v){let e=hr(t,s,c);for(let t=e.length-1;t>=0;t--){let n=e[t].node;if(!n.scrollRange)continue;if(d(n)){v=n;break}let r=n.style.overscroll;if(o!==0&&!r.y||a!==0&&!r.x){v=n;break}}if(!v&&u<Na){r.preventDefault();return}this.#b={el:v?v.source:null,x:r.clientX,y:r.clientY,axis:p,at:l,mag:u,decayed:0}}if(!v||(r.preventDefault(),!d(v)))return;let y=v.source,b=v.scrollRange,x={behavior:`instant`};o!==0&&b.maxY>0&&(x.top=o),a!==0&&b.maxX>0&&(x.left=a),y.scrollBy(x),this.#y.set(y,l),this.#U(y,ja)};#J(e,t){return this.#E.some(n=>t>0&&n.scrollTop<n.scrollHeight-n.clientHeight-.5||t<0&&n.scrollTop>.5||e>0&&n.scrollLeft<n.scrollWidth-n.clientWidth-.5||e<0&&n.scrollLeft>.5)}#Y(){let e=this.parentElement;if(e&&this.#l){this.#l.observe(e);for(let t of e.children)t!==this&&this.#l.observe(t)}}#X(e,t,n){if(!this.#I){let e=this.#s.getBoundingClientRect();this.#I={left:e.left,top:e.top}}return{col:Math.floor((e-this.#I.left)/n.width),row:Math.floor((t-this.#I.top)/n.height)}}#Z(e,t){let n=this.#p,r=this.#f;if(!n||!r||this.#_.length===0)return null;let{col:i,row:a}=this.#X(e,t,r),o=hr(n,i,a);for(let n=o.length-1;n>=0;n--){let{node:s,x:c,y:l}=o[n],u=s.scrollRange;if(!u)continue;let d=s.source,{y:f,x:p}=fr(s,c,l);if(f&&u.maxY>0&&i>=f.col&&i<f.col+f.thick&&a>=f.row&&a<f.row+f.len){let e=pr(f.len,u.sizeY,u.maxY,0).len,n=Math.max(1,(f.len-e)*r.height);return{el:d,axis:`y`,startClient:t,startPx:d.scrollTop,factor:u.maxY*r.height/n}}if(p&&u.maxX>0&&a>=p.row&&a<p.row+p.thick&&i>=p.col&&i<p.col+p.len){let t=pr(p.len,u.sizeX,u.maxX,0).len,n=Math.max(1,(p.len-t)*r.width);return{el:d,axis:`x`,startClient:e,startPx:d.scrollLeft,factor:u.maxX*r.width/n}}}return null}#Q=e=>{if(Ha(e))return;let{clientX:t,clientY:n}=e,r=this.#x;if(r){let e=(r.axis===`y`?n:t)-r.startClient,i=r.startPx+e*r.factor;r.axis===`y`?r.el.scrollTop=i:r.el.scrollLeft=i;return}let i=!!(e.buttons&1);i&&this.#C&&this.#ce(this.#C,t,n),i&&this.#w&&this.#se(this.#w,t,n),i&&this.#T&&!this.hasAttribute(`data-mw-dragging`)&&this.setAttribute(`data-mw-dragging`,``),this.#N={x:t,y:n};let a=this.#f;if(a){let{col:e,row:r}=this.#X(t,n,a);if(e===this.#P&&r===this.#F)return}this.#ye()};#$=e=>{let{clipboardData:t}=e,n=this.#p,r=this.#pe();t&&n&&r&&(t.setData(`text/plain`,Sr(n,r)),e.preventDefault())};#ee=e=>{let t=e;if(t.button!==0||this.getAttribute(`select`)!==`grid`)return;let n=t.composedPath().includes(this.#s);if(!n&&!this.#re(t.target))return;let r=this.#S===`mouse`||this.#S===`pen`;if(t.detail<=1){if(t.detail!==1)return;this.removeAttribute(Ea);let e=this.#te();r&&(!n||e)&&(e?.blur(),this.#oe(t));return}if(!r)return;let i=t.detail===2?`word`:`paragraph`,a=document.getSelection(),o=this.#p,s=this.#f;if(!a||!o||!s)return;let{col:c,row:l}=this.#X(t.clientX,t.clientY,s),u=this.#ue(c,l,i);if(!u){this.removeAttribute(Ea),this.#C=null;return}t.preventDefault(),this.#te()?.blur(),this.#fe(u);let d=t.shiftKey&&a.anchorNode&&this.#pe()?Wa({node:a.anchorNode,offset:a.anchorOffset}):u;this.#le(a,d,u),this.#C={unit:i,anchor:d}};#te(){let e=document.activeElement;return e instanceof HTMLElement&&e!==document.body&&this.contains(e)?e:null}#ne(){return this.#j&&!this.#w}#re(e){return e instanceof Element&&e!==this&&this.contains(e)&&!e.matches(Da)}#ie(e,t){let n=this.#s.textContent.split(`
|
|
1012
|
+
`),r=Math.max(0,Math.min(t,n.length-1)),i=0;for(let e=0;e<r;e++)i+=n[e].length+1;return i+Math.max(0,Math.min(e,n[r]?.length??0))}#ae(e,t){let n=this.#f;if(!n)return null;let{col:r,row:i}=this.#X(e,t,n),a=this.#ie(r,i),o=Ur(this.#s,a);return o&&{offset:a,at:o}}#oe(e){let t=this.#ae(e.clientX,e.clientY);t&&(e.preventDefault(),document.getSelection()?.setBaseAndExtent(...t.at,...t.at),this.#w={anchor:t.offset})}#se(e,t,n){let r=Ur(this.#s,e.anchor),i=this.#ae(t,n);r&&i&&document.getSelection()?.setBaseAndExtent(...r,...i.at)}#ce(e,t,n){let r=this.#f,i=document.getSelection();if(!r||!i)return;let{col:a,row:o}=this.#X(t,n,r),s=this.#ue(a,o,e.unit);s&&this.#le(i,e.anchor,s)}#le(e,t,n){if(Ka(t,n)){Ga(e,n.start,n.end);return}let r=this.#de(t),i=this.#de(n);_r(r.start.node,r.start.offset,i.start.node,i.start.offset)<=0?Ga(e,r.start,i.end):Ga(e,r.end,i.start)}#ue(e,t,n){let r=this.#p;if(!r)return null;let i=hr(r,e,t);for(let r=i.length-1;r>=0;r--){let{node:a,x:o,y:c}=i[r];if(!Or(a))continue;let l=dr(a,o,c,e,t);if(l===null)return null;let u=s(a.source.tagName)?.selectionTarget?.(a.source);if(n===`word`&&!u){let e=jr(a,l),t=e&&yr(a,e.start),n=e&&yr(a,e.end);if(t&&n)return{start:t,end:n}}let d=u??a.source;return{start:{node:d,offset:0},end:{node:d,offset:d.childNodes.length}}}return null}#de(e){let t=e.start.node.getRootNode();if(!(t instanceof ShadowRoot)||t===this.#s.getRootNode())return e;let n=t.host,r=n.parentNode;if(!r)return e;let i=Array.prototype.indexOf.call(r.childNodes,n),a=n.previousSibling,o=n.nextSibling;return{start:Ua(a)?{node:a,offset:a instanceof Text?a.length:a.childNodes.length}:{node:r,offset:i},end:Ua(o)?{node:o,offset:0}:{node:r,offset:i+1}}}#fe(e){this.setAttribute(Ea,``);let t=e.start.node,n=t instanceof Element?t:t.parentElement;n&&getComputedStyle(n).userSelect}#pe(){let e=br(this.#s.getRootNode());return!e||xr(this,this.#s,e)!==`light`||e.startContainer===e.endContainer&&e.startOffset===e.endOffset?null:e}#me=()=>{this.hasAttribute(Ea)&&(this.#pe()||this.removeAttribute(Ea))};#he=()=>{this.#N=null,this.#ye()};#ge=e=>{let t=e;if(!t.isPrimary||t.button!==0||(this.#S=t.pointerType,Ha(t)))return;let n=this.#Z(t.clientX,t.clientY);if(n){this.#x=n,t.preventDefault(),t.isTrusted&&this.setPointerCapture(t.pointerId);return}this.#N={x:t.clientX,y:t.clientY},this.#j=!0,this.#T=t.composedPath().includes(this.#s),this.#ye(!0)};#_e=e=>{if(e.isPrimary){if(this.#C=null,this.#w=null,this.#T=!1,this.removeAttribute(`data-mw-dragging`),this.#x){this.#K(this.#x.el),this.#x=null;return}(this.#j||this.#A)&&(this.#j=!1,this.#A=null,this.#ye(),this.#M&&this.#Me())}};#ve=e=>{if(!this.#N)return;let t=e.target;t instanceof HTMLElement&&t.hasAttribute(`data-mw-scroll`)||(this.#I=null,this.#ye())};#ye(t=!1){let n=this.#p,r=this.#f,i=[];if(this.#N&&n&&r&&this.isConnected&&this.getAttribute(`select`)===`grid`&&(this.#j||e.#L?.matches)){let{col:e,row:t}=this.#X(this.#N.x,this.#N.y,r);this.#P=e,this.#F=t,i=gr(n,e,t)}else this.#P=NaN,this.#F=NaN;let a=i.at(-1)??null;t&&(this.#A=a);let o=e.#L?.matches?i:[],s=this.#A?i.indexOf(this.#A):-1,c=s>=0?i.slice(0,s+1):[],l=this.#be(`data-mw-hover`,this.#O,o);l=this.#be(`data-mw-active`,this.#k,c)||l;let u=a?getComputedStyle(a).cursor:``;this.#s.style.cursor=u===`auto`?``:u,l&&this.isConnected&&this.#Me()}#be(e,t,n){let r=!1,i=new Set(n);for(let n of t)i.has(n)||(n.removeAttribute(e),r=!0);for(let n of i)t.has(n)||(n.setAttribute(e,``),r=!0);t.clear();for(let e of i)t.add(e);return r}#xe=0;#Se=!1;#Ce=0;#we=e=>{ka.test(e.propertyName)&&(this.#xe++,this.#Ce=performance.now(),this.#Ee())};#Te=e=>{ka.test(e.propertyName)&&(this.#xe=Math.max(0,this.#xe-1))};#Ee(){if(this.#Se)return;this.#Se=!0;let e=()=>{if(!this.isConnected||this.#xe===0&&!_()||performance.now()-this.#Ce>Aa){this.#Se=!1,this.#xe=0,this.#Me();return}this.#je(),requestAnimationFrame(e)};requestAnimationFrame(e)}#De=e=>{if(!Ha(e)){if((e.type===`focusin`||e.type===`focusout`)&&e.target instanceof HTMLSelectElement){this.#je();return}this.#Me()}};attributeChangedCallback(e,t,r){if(e===`select`&&r!==`text`&&r!==`grid`){r!==null&&console.warn(`[monowind] Ignoring unrecognized select="${r}". Expected "grid" (default) or "text".`,n(this)),this.setAttribute(`select`,Ta);return}e===`select`&&this.#ye(),this.#Me()}toPlainText(){return this.#d&&this.#Ne(),this.#p?er(this.#p):``}#Oe=()=>{this.#Me()};#ke=()=>{requestAnimationFrame(()=>this.#Me())};#Ae(){let e=document.activeElement;if(!(e instanceof HTMLSelectElement)||!this.contains(e))return!1;try{return e.matches(`:open`)}catch{return!1}}#je(){try{this.#Ne()}catch(e){console.error(`[monowind] layout failed:`,e)}}#Me(){this.#d||(this.#d=!0,requestAnimationFrame(()=>{if(this.#d=!1,this.#Ae()){this.#Me();return}this.#je()}))}#Ne(){if(!this.isConnected)return;let e=this.#V(),t=new Map,r=getComputedStyle(this).getPropertyValue(`--mw-cw`).trim(),i=parseFloat(r);if(Number.isFinite(i)&&i>0)for(let e of this.querySelectorAll(`textarea`)){let n=getComputedStyle(e),r=e.clientWidth-(parseFloat(n.paddingLeft)||0)-(parseFloat(n.paddingRight)||0);t.set(e,Math.max(0,Math.round(r/i)))}this.setAttribute(`measuring`,``);try{this.#c.parentNode!==this&&this.appendChild(this.#c);let r=I(this,this.#c),i=this.#f;(i===null||i.width!==r.width||i.height!==r.height||i.letterSpacing!==r.letterSpacing||i.inkOverhang!==r.inkOverhang)&&(this.style.setProperty(`--mw-cw`,`${r.width}px`),this.style.setProperty(`--mw-ch`,`${r.height}px`),this.style.setProperty(`--mw-rls`,`${r.letterSpacing}px`),this.style.setProperty(`--mw-ink`,`${r.inkOverhang??0}px`)),this.#f=r;let a=getComputedStyle(this),o=(parseFloat(a.paddingLeft)||0)+(parseFloat(a.paddingRight)||0),s=Math.max(0,Math.floor((this.clientWidth-o)/r.width));if(s===0)return;let c=L(),l=[];for(let e of Array.from(this.children)){if(e===this.#c)continue;let n=ra(e,c,r,t);n&&l.push(n)}if(ba(this)?(this.hasAttribute(`data-mw-dropped-text`)||console.warn(`[monowind] ${xa}`,n(this)),this.setAttribute(`data-mw-dropped-text`,``)):this.removeAttribute(`data-mw-dropped-text`),l.length===0){this.#s.replaceChildren(),this.#p=null,this.setAttribute(`data-mw-ready`,``);return}let u={source:this,style:tt(),children:l,text:``,intrinsicWidth:0,intrinsicHeight:0,localRect:{x:0,y:0,width:0,height:0},unclampedHeight:0,resolvedPadding:nt()},{height:d}=Tn(u,s);Kr(u),this.#_=qa(u),this.#z(r,e),this.#M=!Rr(u,this.#s,this.#ne()),this.#p=u;let f=`${u.localRect.width*r.width}px`,p=`${u.localRect.height*r.height}px`;this.#s.style.width!==f&&(this.#s.style.width=f),this.#s.style.height!==p&&(this.#s.style.height=p);let m=a.boxSizing===`border-box`?(parseFloat(a.paddingTop)||0)+(parseFloat(a.paddingBottom)||0)+(parseFloat(a.borderTopWidth)||0)+(parseFloat(a.borderBottomWidth)||0):0,h=`${d*r.height+m}px`;this.style.height!==h&&(this.style.height=h);let g=a.boxSizing===`border-box`?o+(parseFloat(a.borderLeftWidth)||0)+(parseFloat(a.borderRightWidth)||0):0,_=`${s*r.width+g}px`;this.style.getPropertyValue(`--mw-host-w`)!==_&&this.style.setProperty(`--mw-host-w`,_),this.hasAttribute(`data-mw-ready`)||this.setAttribute(`data-mw-ready`,``)}finally{this.setAttribute(`settling`,``),this.removeAttribute(`measuring`),getComputedStyle(this).transitionProperty,this.removeAttribute(`settling`),this.#H(e),this.#u?.takeRecords(),g(this)&&(_()?(this.#Ce=performance.now(),this.#Ee()):this.#Me()),this.#Y(),this.#E=[];let t=document.scrollingElement??document.documentElement;for(let e=this.parentElement;e;e=e.parentElement)(e===t||/auto|scroll/.test(getComputedStyle(e).overflow))&&this.#E.push(e);this.#I=null,this.#N&&this.#ye()}}};function za(){typeof customElements>`u`||customElements.get(`mono-wind`)||customElements.define(`mono-wind`,Ra)}function Ba(e,t,n,r,i){return Va(t===`y`?e.scrollTop:e.scrollLeft,t===`y`?e.scrollHeight-e.clientHeight:e.scrollWidth-e.clientWidth,n,r,i)}function Va(e,t,n,r,i){if(r>0&&e>0&&e>=t-1)return r;let a=e/n-i,o=Math.abs(a)<=.5?i:i+Math.sign(a)*Math.round(Math.abs(a));return Math.min(Math.max(0,o),r)}function Ha(e){return e instanceof PointerEvent&&e.pointerType===`touch`&&e.type!==`pointerup`}function Ua(e){return e!==null&&!(e instanceof Element&&e.shadowRoot)}function Wa(e){return{start:e,end:e}}function Ga(e,t,n){e.setBaseAndExtent(t.node,t.offset,n.node,n.offset)}function Ka(e,t){return e.start.node===t.start.node&&e.start.offset===t.start.offset&&e.end.node===t.end.node&&e.end.offset===t.end.offset}function qa(e){let t=[],n=e=>{e.scrollRange&&t.push(e);for(let t of e.children)n(t)};return n(e),t}var Ja=`/* Gap decorations (specs/gap-decorations.md): css-gaps-1 rules for flex
|
|
1012
1013
|
* and grid gaps, engine-painted as glyph runs. The utilities set the
|
|
1013
1014
|
* real CSS properties (forward-compat; unknown ones drop harmlessly)
|
|
1014
1015
|
* AND the --mw-* mirrors the engine reads — compiled by the consumer's
|
|
@@ -1236,7 +1237,7 @@ input:where([type='button'], [type='reset'], [type='submit']),
|
|
|
1236
1237
|
inherits: false;
|
|
1237
1238
|
initial-value: 0;
|
|
1238
1239
|
}
|
|
1239
|
-
`,
|
|
1240
|
+
`,Ya=`/* monowind companion stylesheet — loaded into the light DOM by the app.
|
|
1240
1241
|
* The shadow root has its own baked-in styles; this file targets the light-DOM
|
|
1241
1242
|
* subtree the host owns.
|
|
1242
1243
|
*
|
|
@@ -1630,6 +1631,14 @@ input:where([type='button'], [type='reset'], [type='submit']),
|
|
|
1630
1631
|
color: var(--mw-bg);
|
|
1631
1632
|
caret-color: var(--mw-bg);
|
|
1632
1633
|
}
|
|
1634
|
+
/* Grid-mode light elements carry the grid's text cursor: Firefox
|
|
1635
|
+
* hit-tests a multicol spanner's anonymous wrapper as its container
|
|
1636
|
+
* despite \`pointer-events: none\`, and would show an arrow there.
|
|
1637
|
+
* Interactives keep their own (UA and authored cursors win). */
|
|
1638
|
+
mono-wind[select="grid"]
|
|
1639
|
+
[data-mw-laid-out]:not(a, button, input, select, textarea, label, [tabindex], [role="button"]) {
|
|
1640
|
+
cursor: text;
|
|
1641
|
+
}
|
|
1633
1642
|
}
|
|
1634
1643
|
|
|
1635
1644
|
/* === Modes and selection (engine-owned from here down) =============== */
|
|
@@ -1637,7 +1646,9 @@ input:where([type='button'], [type='reset'], [type='submit']),
|
|
|
1637
1646
|
/* select="grid": pass pointer events through non-interactive light-DOM
|
|
1638
1647
|
* elements so drag lands on the grid <pre> (native drag-selection of
|
|
1639
1648
|
* the ASCII); interactives opt back into \`auto\` so clicks still work.
|
|
1640
|
-
* (The slot itself is pointer-events: none in the shadow CSS.)
|
|
1649
|
+
* (The slot itself is pointer-events: none in the shadow CSS.) The
|
|
1650
|
+
* interactive list is mirrored by INTERACTIVE in element.ts and by the
|
|
1651
|
+
* two rules below — change all of them together. */
|
|
1641
1652
|
mono-wind[select="grid"] * {
|
|
1642
1653
|
pointer-events: none !important;
|
|
1643
1654
|
}
|
|
@@ -1645,15 +1656,40 @@ mono-wind[select="grid"]
|
|
|
1645
1656
|
:is(a, button, input, select, textarea, label, [tabindex], [role="button"]) {
|
|
1646
1657
|
pointer-events: auto !important;
|
|
1647
1658
|
}
|
|
1659
|
+
/* While a drag that began on the grid is in flight, interactives drop
|
|
1660
|
+
* their pointer events too, so the native selection sweeps through
|
|
1661
|
+
* their cells instead of stalling at their edge (a click is a press and
|
|
1662
|
+
* release in place — unaffected). */
|
|
1663
|
+
mono-wind[select="grid"][data-mw-dragging]
|
|
1664
|
+
:is(a, button, input, select, textarea, label, [tabindex], [role="button"]) {
|
|
1665
|
+
pointer-events: none !important;
|
|
1666
|
+
}
|
|
1667
|
+
/* The grid-mode selection lock, explicit on the light DOM: the shadow
|
|
1668
|
+
* slot's \`user-select: none\` reaches slotted content in Chromium and
|
|
1669
|
+
* WebKit but not Firefox, where a drag that strays onto a light element
|
|
1670
|
+
* would select it. Lifted with a semantic selection
|
|
1671
|
+
* (specs/semantic-selection.md). Editable controls keep their own
|
|
1672
|
+
* selection (Firefox honors an explicit \`none\` on a text field's
|
|
1673
|
+
* value; the slot's inherited value never reached it). */
|
|
1674
|
+
mono-wind[select="grid"]:not([data-mw-semantic-selection])
|
|
1675
|
+
:not(input, textarea, [contenteditable], [contenteditable] *) {
|
|
1676
|
+
user-select: none;
|
|
1677
|
+
-webkit-user-select: none;
|
|
1678
|
+
}
|
|
1648
1679
|
/* Touch panning (specs/scrolling.md): where the primary pointer is a
|
|
1649
1680
|
* finger, scroll containers take pointer events in grid mode so a
|
|
1650
1681
|
* drag pans them NATIVELY (physics, momentum, chaining) — their
|
|
1651
1682
|
* children stay inert, so the touch lands on the container itself.
|
|
1652
|
-
*
|
|
1683
|
+
* A long-press there selects the element's text (an element
|
|
1684
|
+
* selection, copied by the engine like a semantic one). */
|
|
1653
1685
|
@media (pointer: coarse) {
|
|
1654
1686
|
mono-wind[select="grid"] [data-mw-scroll] {
|
|
1655
1687
|
pointer-events: auto !important;
|
|
1656
1688
|
}
|
|
1689
|
+
mono-wind[select="grid"] :is([data-mw-scroll], [data-mw-scroll] *) {
|
|
1690
|
+
user-select: text;
|
|
1691
|
+
-webkit-user-select: text;
|
|
1692
|
+
}
|
|
1657
1693
|
}
|
|
1658
1694
|
|
|
1659
1695
|
/* Scroll containers (specs/scrolling.md): the gutter ink IS the
|
|
@@ -2158,7 +2194,7 @@ mono-wind:not([measuring]) [data-mw-table-hidden] {
|
|
|
2158
2194
|
mono-wind:not([measuring]) [data-mw-text-align-blocked] {
|
|
2159
2195
|
text-align: start !important;
|
|
2160
2196
|
}
|
|
2161
|
-
`,
|
|
2197
|
+
`,Xa=`/* Synthesized pointer states (specs/cell-model.md "Pointer states"):
|
|
2162
2198
|
* under select="grid" the light DOM is pointer-events: none, so
|
|
2163
2199
|
* :hover/:active never match — the engine hit-tests the pointer's
|
|
2164
2200
|
* cell and marks the chain with data-mw-hover / data-mw-active. These
|
|
@@ -2175,5 +2211,5 @@ mono-wind:not([measuring]) [data-mw-text-align-blocked] {
|
|
|
2175
2211
|
}
|
|
2176
2212
|
}
|
|
2177
2213
|
@custom-variant active (&:is(:active, [data-mw-active]));
|
|
2178
|
-
`,
|
|
2214
|
+
`,Za=document.createElement(`style`);Za.setAttribute(`data-monowind`,``),Za.textContent=Ya,document.head.appendChild(Za);var Qa=document.createElement(`style`);Qa.setAttribute(`type`,`text/tailwindcss`),Qa.setAttribute(`data-monowind-rules`,``),Qa.textContent=`${Ja}\n${Xa}`,document.head.appendChild(Qa),za(),Object.assign(globalThis,{monowind:{...globalThis.monowind,version:`0.2.6`,registerLeafRenderer:a,invalidateLeaves:o}})})();
|
|
2179
2215
|
//# sourceMappingURL=cdn.js.map
|