@bangerpage/core 0.2.2 → 0.2.3

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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{g as ye,j as xe,k as G,l as we}from"./chunks/chunk-BYI63O6E.js";import{A as Ae,B as Re,C as ze,a as V,b,c as m,d as fe,e as le,f as h,g as F,h as v,i as k,j as y,k as U,l as w,m as $,n as x,o as f,p as H,q as be,r as Se,s as X,t as Me,u as $e,v as T,w as ce,x as Ee,y as ke,z as Pe}from"./chunks/chunk-6BFFJEGA.js";import{b as p,c as ve,e as D}from"./chunks/chunk-ISQU3ATQ.js";var Te=/^-?\d+$/;function Z(r,o){return r.stops[o]?.steps??0}function E(r,o){if(o.stops.length===0)return{stop:0,step:0};let e=Math.min(Math.max(Math.trunc(r.stop)||0,0),o.stops.length-1),t=Math.min(Math.max(Math.trunc(r.step)||0,0),Z(o,e));return{stop:e,step:t}}function Le(r,o){let e=new URLSearchParams(r.startsWith("#")?r.slice(1):r),t=e.get("stop"),n=e.get("step"),s=t!==null&&Te.test(t)?Number(t):0,a=E({stop:s,step:0},o).stop,i=0;return n==="last"?i=Z(o,a):n!==null&&Te.test(n)&&(i=Number(n)),E({stop:a,step:i},o)}function J(r){return`#stop=${r.stop}&step=${r.step}`}function Ce(r,o){let e=E(r,o);return e.step<Z(o,e.stop)?{stop:e.stop,step:e.step+1}:e.stop<o.stops.length-1?{stop:e.stop+1,step:0}:e}function Oe(r,o){let e=E(r,o);return e.step>0?{stop:e.stop,step:e.step-1}:e.stop>0?{stop:e.stop-1,step:Z(o,e.stop-1)}:e}function Ne(r,o,e){let t=E(o,e),n=0;for(let a=0;a<t.stop;a++){let i=e.stops[a];i.kind!=="overview"&&i.frame===r&&(n=Math.max(n,i.steps))}let s=e.stops[t.stop];return s&&s.kind!=="overview"&&s.frame===r&&(n=Math.max(n,t.step)),n}function Ie(r){if(r===null)return null;let o=r.split(",");if(o.length!==4||o.some(a=>a.trim()===""))return null;let[e,t,n,s]=o.map(Number);return![e,t,n,s].every(Number.isFinite)||e<0||t<0||n<=0||s<=0||e+n>1+1e-9||t+s>1+1e-9?null:{x:e,y:t,w:n,h:s}}function _e(r,o,e){if(r===null)return e;let t=r.split(",").map(a=>a.trim());if(t.length!==2||!t.every(a=>/^\d+$/.test(a)))return e;let[n,s]=t.map(Number);return n>=o&&s>=o?[n,s]:e}function Fe(r){return _e(r,0,[0,0])}function He(r){return _e(r,1,[1,1])}var R=1920,z=1080;var pe=r=>Math.min(Math.max(r,0),1);function dt(r,o,e){let[t,n]=r,[s,a]=o;return{x:t*(1920+e),y:n*(1080+e),w:s*1920+(s-1)*e,h:a*1080+(a-1)*e}}function je(r,o){return Object.fromEntries(r.map(e=>[e.id,dt(e.at,e.span,o)]))}function he(r,o){return{x:r.x+o.x*r.w,y:r.y+o.y*r.h,w:o.w*r.w,h:o.h*r.h}}function Q(r){if(r.length===0)return{x:0,y:0,w:0,h:0};let o=Math.min(...r.map(s=>s.x)),e=Math.min(...r.map(s=>s.y)),t=Math.max(...r.map(s=>s.x+s.w)),n=Math.max(...r.map(s=>s.y+s.h));return{x:o,y:e,w:t-o,h:n-e}}function Y(r,o){return{x:r.x-o,y:r.y-o,w:r.w+2*o,h:r.h+2*o}}function qe(r,o){return o.x>=r.x&&o.x<=r.x+r.w&&o.y>=r.y&&o.y<=r.y+r.h}function L(r,o){return{cx:r.x+r.w/2,cy:r.y+r.h/2,zoom:Math.min(o.w/r.w,o.h/r.h)}}function jt(r,o,e){let t=r.kind==="overview"||r.frame===void 0?void 0:o[r.frame];return L(t?r.kind==="region"&&r.region?he(t,r.region):t:Q(Object.values(o)),e)}var We=.5,ut=.8;function Ue(r,o,e){let t=Math.max(r.w*o.zoom/e.w,r.h*o.zoom/e.h),n=pe((t-We)/(ut-We));return n*n*(3-2*n)}function Ke(r,o,e){let t=e.w/e.h,n=Math.max(r.w,r.h*t),s=n/t;if(n>=o.w||s>=o.h)return o;let a=Math.min(Math.max(r.x+r.w/2-n/2,o.x),o.x+o.w-n),i=Math.min(Math.max(r.y+r.h/2-s/2,o.y),o.y+o.h-s);return{x:a,y:i,w:n,h:s}}function Be(r){let o=Math.min(r.w/1920,r.h/1080);return{w:1920*o,h:1080*o}}function mt(r,o,e){let t=Math.hypot(o.cx-r.cx,o.cy-r.cy),n=(r.zoom+o.zoom)/2,s=t*n/e.w+Math.abs(Math.log(o.zoom/r.zoom));return Math.min(Math.max(400+100*s,400),800)}function gt(r){let o=pe(r);return o<.5?4*o*o*o:1-Math.pow(-2*o+2,3)/2}function ft(r,o,e){let t=Math.max(e.w/r.zoom,e.w/o.zoom),n=Math.max(e.h/r.zoom,e.h/o.zoom),s=Math.abs(o.cx-r.cx),a=Math.abs(o.cy-r.cy);if(Math.hypot(s/t,a/n)<1.5)return 0;let i=Math.min(e.w/(s+t),e.h/(a+n)),l=(Math.log(r.zoom)+Math.log(o.zoom))/2;return Math.min(0,Math.log(i)-l)}function bt(r,o,e,t){let n=ft(r,o,t),s=Math.min(mt(r,o,t)-250*n,1300);return{from:r,to:o,start:e,duration:s,pullBack:n}}function de(r,o){let e=pe((o-r.start)/r.duration);if(e<=0)return{...r.from};if(e>=1)return{...r.to};let t=gt(e),{from:n,to:s}=r;return{cx:n.cx+(s.cx-n.cx)*t,cy:n.cy+(s.cy-n.cy)*t,zoom:n.zoom*Math.pow(s.zoom/n.zoom,t)*Math.exp(r.pullBack*Math.sin(Math.PI*t))}}function Ve(r,o,e,t){return bt(r,o,e,t)}function De(r,o,e){let t=(a,i)=>{let l=(a-i*o.zoom)/2;return Math.abs(l)<1e-9?0:Math.max(0,l)},n=t(e.w,r.w),s=t(e.h,r.h);return{top:s,right:n,bottom:s,left:n}}function Ge(r,o,e){let{tx:t,ty:n,scale:s}=ue(o,e);return{x:(r.x-t)/s,y:(r.y-n)/s}}function ue(r,o,e=!0){let t=o.w/2-r.cx*r.zoom,n=o.h/2-r.cy*r.zoom,s=e?`translate3d(${t}px, ${n}px, 0)`:`translate(${t}px, ${n}px)`;return{tx:t,ty:n,scale:r.zoom,css:`${s} scale(${r.zoom})`}}var S=class extends y{constructor(){super(...arguments);this.at="0,0";this.span="1,1";this.tone="default";this.ground="default";this.valign="center";this.currentStep=0}static{this.styles=b`
1
+ import{g as xe,j as we,k as G,l as Se}from"./chunks/chunk-BYI63O6E.js";import{A as Re,B as Te,C as ze,a as V,b,c as h,d as be,e as ce,f as u,g as z,h as v,i as k,j as y,k as j,l as w,m as $,n as x,o as f,p as H,q as ve,r as Me,s as X,t as $e,u as Pe,v as C,w as pe,x as ke,y as Ee,z as Ae}from"./chunks/chunk-6BFFJEGA.js";import{b as p,c as ye,e as B}from"./chunks/chunk-ISQU3ATQ.js";var Ce=/^-?\d+$/;function Z(n,o){return n.stops[o]?.steps??0}function P(n,o){if(o.stops.length===0)return{stop:0,step:0};let e=Math.min(Math.max(Math.trunc(n.stop)||0,0),o.stops.length-1),t=Math.min(Math.max(Math.trunc(n.step)||0,0),Z(o,e));return{stop:e,step:t}}function Oe(n,o){let e=new URLSearchParams(n.startsWith("#")?n.slice(1):n),t=e.get("stop"),r=e.get("step"),s=t!==null&&Ce.test(t)?Number(t):0,i=P({stop:s,step:0},o).stop,a=0;return r==="last"?a=Z(o,i):r!==null&&Ce.test(r)&&(a=Number(r)),P({stop:i,step:a},o)}function J(n){return`#stop=${n.stop}&step=${n.step}`}function Le(n,o){let e=P(n,o);return e.step<Z(o,e.stop)?{stop:e.stop,step:e.step+1}:e.stop<o.stops.length-1?{stop:e.stop+1,step:0}:e}function Ne(n,o){let e=P(n,o);return e.step>0?{stop:e.stop,step:e.step-1}:e.stop>0?{stop:e.stop-1,step:Z(o,e.stop-1)}:e}function Ie(n,o,e){let t=P(o,e),r=0;for(let i=0;i<t.stop;i++){let a=e.stops[i];a.kind!=="overview"&&a.frame===n&&(r=Math.max(r,a.steps))}let s=e.stops[t.stop];return s&&s.kind!=="overview"&&s.frame===n&&(r=Math.max(r,t.step)),r}function _e(n){if(n===null)return null;let o=n.split(",");if(o.length!==4||o.some(i=>i.trim()===""))return null;let[e,t,r,s]=o.map(Number);return![e,t,r,s].every(Number.isFinite)||e<0||t<0||r<=0||s<=0||e+r>1+1e-9||t+s>1+1e-9?null:{x:e,y:t,w:r,h:s}}function Fe(n,o,e){if(n===null)return e;let t=n.split(",").map(i=>i.trim());if(t.length!==2||!t.every(i=>/^\d+$/.test(i)))return e;let[r,s]=t.map(Number);return r>=o&&s>=o?[r,s]:e}function He(n){return Fe(n,0,[0,0])}function Ue(n){return Fe(n,1,[1,1])}var R=1920,T=1080;var Q=n=>Math.min(Math.max(n,0),1);function vt(n,o,e){let[t,r]=n,[s,i]=o;return{x:t*(1920+e),y:r*(1080+e),w:s*1920+(s-1)*e,h:i*1080+(i-1)*e}}function We(n,o){return Object.fromEntries(n.map(e=>[e.id,vt(e.at,e.span,o)]))}function ue(n,o){return{x:n.x+o.x*n.w,y:n.y+o.y*n.h,w:o.w*n.w,h:o.h*n.h}}function Y(n){if(n.length===0)return{x:0,y:0,w:0,h:0};let o=Math.min(...n.map(s=>s.x)),e=Math.min(...n.map(s=>s.y)),t=Math.max(...n.map(s=>s.x+s.w)),r=Math.max(...n.map(s=>s.y+s.h));return{x:o,y:e,w:t-o,h:r-e}}function ee(n,o){return{x:n.x-o,y:n.y-o,w:n.w+2*o,h:n.h+2*o}}function je(n,o){return o.x>=n.x&&o.x<=n.x+n.w&&o.y>=n.y&&o.y<=n.y+n.h}function O(n,o){return{cx:n.x+n.w/2,cy:n.y+n.h/2,zoom:Math.min(o.w/n.w,o.h/n.h)}}function Yt(n,o,e){let t=n.kind==="overview"||n.frame===void 0?void 0:o[n.frame];return O(t?n.kind==="region"&&n.region?ue(t,n.region):t:Y(Object.values(o)),e)}var De=.5,yt=.8;function qe(n,o,e){let t=Math.max(n.w*o.zoom/e.w,n.h*o.zoom/e.h),r=Q((t-De)/(yt-De));return r*r*(3-2*r)}function Ke(n,o,e){let t=e.w/e.h,r=Math.max(n.w,n.h*t),s=r/t;if(r>=o.w||s>=o.h)return o;let i=Math.min(Math.max(n.x+n.w/2-r/2,o.x),o.x+o.w-r),a=Math.min(Math.max(n.y+n.h/2-s/2,o.y),o.y+o.h-s);return{x:i,y:a,w:r,h:s}}function Ve(n){let o=Math.min(n.w/1920,n.h/1080);return{w:1920*o,h:1080*o}}function Be(n,o,e){let t=Math.hypot(o.cx-n.cx,o.cy-n.cy),r=(n.zoom+o.zoom)/2;return t*r/e.w+Math.abs(Math.log(o.zoom/n.zoom))}function xt(n,o,e){let t=Be(n,o,e);return Math.min(Math.max(400+100*t,400),800)}function wt(n){let o=Q(n);return o<.5?4*o*o*o:1-Math.pow(-2*o+2,3)/2}function St(n){let o=Q(n);return 1-Math.pow(1-o,4)}function Mt(n,o,e){let t=Math.max(e.w/n.zoom,e.w/o.zoom),r=Math.max(e.h/n.zoom,e.h/o.zoom),s=Math.abs(o.cx-n.cx),i=Math.abs(o.cy-n.cy);if(Math.hypot(s/t,i/r)<1.5)return 0;let a=Math.min(e.w/(s+t),e.h/(i+r)),l=(Math.log(n.zoom)+Math.log(o.zoom))/2;return Math.min(0,Math.log(a)-l)}function $t(n,o,e,t,r){if(r?.motion==="swift"){let a=Math.min(180+25*Be(n,o,t),280);return{from:n,to:o,start:e,duration:a,pullBack:0,curve:"swift"}}let s=Mt(n,o,t),i=Math.min(xt(n,o,t)-250*s,1300);return{from:n,to:o,start:e,duration:i,pullBack:s}}function he(n,o){let e=Q((o-n.start)/n.duration);if(e<=0)return{...n.from};if(e>=1)return{...n.to};let t=(n.curve==="swift"?St:wt)(e),{from:r,to:s}=n;return{cx:r.cx+(s.cx-r.cx)*t,cy:r.cy+(s.cy-r.cy)*t,zoom:r.zoom*Math.pow(s.zoom/r.zoom,t)*Math.exp(n.pullBack*Math.sin(Math.PI*t))}}function Ge(n,o,e,t,r){return $t(n,o,e,t,r)}function Xe(n,o,e){let t=(i,a)=>{let l=(i-a*o.zoom)/2;return Math.abs(l)<1e-9?0:Math.max(0,l)},r=t(e.w,n.w),s=t(e.h,n.h);return{top:s,right:r,bottom:s,left:r}}function Ze(n,o,e){let{tx:t,ty:r,scale:s}=de(o,e);return{x:(n.x-t)/s,y:(n.y-r)/s}}function de(n,o,e=!0){let t=o.w/2-n.cx*n.zoom,r=o.h/2-n.cy*n.zoom,s=e?`translate3d(${t}px, ${r}px, 0)`:`translate(${t}px, ${r}px)`;return{tx:t,ty:r,scale:n.zoom,css:`${s} scale(${n.zoom})`}}var M=class extends y{constructor(){super(...arguments);this.at="0,0";this.span="1,1";this.tone="default";this.ground="default";this.valign="center";this.currentStep=0}static{this.styles=b`
2
2
  :host {
3
3
  position: absolute;
4
4
  display: block;
@@ -17,7 +17,7 @@ import{g as ye,j as xe,k as G,l as we}from"./chunks/chunk-BYI63O6E.js";import{A
17
17
  --bang-band-border: initial;
18
18
  }
19
19
  ${V(G.map(e=>`:host([tone="${e}"]) {
20
- ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});`).join(`
20
+ ${Object.keys(B.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});`).join(`
21
21
  `)}
22
22
  }`).join(`
23
23
  `))}
@@ -100,30 +100,30 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
100
100
  :host([valign="spread"]) .frame {
101
101
  justify-content: space-between;
102
102
  }
103
- `}frameText(e){let t=this.closest("bang-root")?.getAttribute("lang")?.toLowerCase();return(t?this.getAttribute(`${e}-${t}`)?.trim():"")||this[e]?.trim()||""}render(){f(this,"tone",["default","accent","inverse"],"default"),f(this,"ground",["default","cover"],"default"),f(this,"valign",["center","spread"],"center");let e=this.frameText("crumb"),t=this.frameText("label");return m`<div class="frame">${e?m`<div class="crumb">${e}</div>`:""}<slot></slot>${t?m`<div class="label" aria-hidden="true">${t}</div>`:""}<div class="fog" aria-hidden="true"></div></div>`}};p([h()],S.prototype,"at",2),p([h()],S.prototype,"span",2),p([h()],S.prototype,"tone",2),p([h()],S.prototype,"ground",2),p([h()],S.prototype,"crumb",2),p([h()],S.prototype,"label",2),p([h()],S.prototype,"valign",2),p([h({attribute:!1})],S.prototype,"currentStep",2);v("bang-frame",S);var ee=class extends y{static{this.styles=b`
103
+ `}frameText(e){let t=this.closest("bang-root")?.getAttribute("lang")?.toLowerCase();return(t?this.getAttribute(`${e}-${t}`)?.trim():"")||this[e]?.trim()||""}render(){f(this,"tone",["default","accent","inverse"],"default"),f(this,"ground",["default","cover"],"default"),f(this,"valign",["center","spread"],"center");let e=this.frameText("crumb"),t=this.frameText("label");return h`<div class="frame">${e?h`<div class="crumb">${e}</div>`:""}<slot></slot>${t?h`<div class="label" aria-hidden="true">${t}</div>`:""}<div class="fog" aria-hidden="true"></div></div>`}};p([u()],M.prototype,"at",2),p([u()],M.prototype,"span",2),p([u()],M.prototype,"tone",2),p([u()],M.prototype,"ground",2),p([u()],M.prototype,"crumb",2),p([u()],M.prototype,"label",2),p([u()],M.prototype,"valign",2),p([u({attribute:!1})],M.prototype,"currentStep",2);v("bang-frame",M);var te=class extends y{static{this.styles=b`
104
104
  :host {
105
105
  display: none;
106
106
  }
107
- `}render(){return m`<slot></slot>`}};v("bang-path",ee);function Xe(r){let o=(r.textContent??"").split(`
107
+ `}render(){return h`<slot></slot>`}};v("bang-path",te);function Je(n){let o=(n.textContent??"").split(`
108
108
  `).map(e=>e.trim());for(;o.length>0&&o[0]==="";)o.shift();for(;o.length>0&&o[o.length-1]==="";)o.pop();return o.join(`
109
- `)}var te=class extends y{static{this.styles=b`
109
+ `)}var ne=class extends y{static{this.styles=b`
110
110
  :host {
111
111
  display: none;
112
112
  }
113
- `}};v("bang-notes",te);var vt=999,P=class extends y{constructor(){super(...arguments);this.overview=!1}static{this.styles=b`
113
+ `}};v("bang-notes",ne);var Pt=999,E=class extends y{constructor(){super(...arguments);this.overview=!1}static{this.styles=b`
114
114
  :host {
115
115
  display: none;
116
116
  }
117
- `}render(){return m`<slot></slot>`}};p([h()],P.prototype,"frame",2),p([h({attribute:"focus"})],P.prototype,"focusId",2),p([h()],P.prototype,"region",2),p([h({type:Boolean})],P.prototype,"overview",2),p([h({type:Number})],P.prototype,"steps",2);v("bang-stop",P);function Ze(r,o=""){let e=[...r.children].filter(d=>d.localName==="bang-notes"),t=o.toLowerCase(),n=(t?e.find(d=>(d.getAttribute("lang")??"").toLowerCase()===t):void 0)??(t?e.find(d=>!d.getAttribute("lang")):void 0)??e[0],s=n?Xe(n):"",a=!r.hasAttribute("steps"),i=H(r,"steps",0,vt,0),l=r.getAttribute("frame")??void 0;if(r.hasAttribute("overview")||l===void 0)return r.hasAttribute("overview")||x("stop-no-frame","[banger] <bang-stop> has neither frame nor overview; treated as overview"),{stop:{kind:"overview",steps:i},notes:s,auto:!1};let u=r.getAttribute("focus")?.trim();if(u)return{stop:{kind:"focus",frame:l,focus:u,steps:i},notes:s,auto:a};let c=r.getAttribute("region");if(c!==null){let d=Ie(c);if(d)return{stop:{kind:"region",frame:l,region:d,steps:i},notes:s,auto:a};x(`region|${c}`,`[banger] <bang-stop region="${c}"> is not a valid region; showing the whole frame`)}return{stop:{kind:"frame",frame:l,steps:i},notes:s,auto:a}}var yt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},W=class extends y{constructor(){super(...arguments);this.gap="m";this.align="stretch"}static{this.styles=b`
117
+ `}render(){return h`<slot></slot>`}};p([u()],E.prototype,"frame",2),p([u({attribute:"focus"})],E.prototype,"focusId",2),p([u()],E.prototype,"region",2),p([u({type:Boolean})],E.prototype,"overview",2),p([u({type:Number})],E.prototype,"steps",2);v("bang-stop",E);function Qe(n,o=""){let e=[...n.children].filter(d=>d.localName==="bang-notes"),t=o.toLowerCase(),r=(t?e.find(d=>(d.getAttribute("lang")??"").toLowerCase()===t):void 0)??(t?e.find(d=>!d.getAttribute("lang")):void 0)??e[0],s=r?Je(r):"",i=!n.hasAttribute("steps"),a=H(n,"steps",0,Pt,0),l=n.getAttribute("frame")??void 0;if(n.hasAttribute("overview")||l===void 0)return n.hasAttribute("overview")||x("stop-no-frame","[banger] <bang-stop> has neither frame nor overview; treated as overview"),{stop:{kind:"overview",steps:a},notes:s,auto:!1};let m=n.getAttribute("focus")?.trim();if(m)return{stop:{kind:"focus",frame:l,focus:m,steps:a},notes:s,auto:i};let c=n.getAttribute("region");if(c!==null){let d=_e(c);if(d)return{stop:{kind:"region",frame:l,region:d,steps:a},notes:s,auto:i};x(`region|${c}`,`[banger] <bang-stop region="${c}"> is not a valid region; showing the whole frame`)}return{stop:{kind:"frame",frame:l,steps:a},notes:s,auto:i}}var kt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},U=class extends y{constructor(){super(...arguments);this.gap="m";this.align="stretch"}static{this.styles=b`
118
118
  :host {
119
119
  display: flex;
120
120
  flex-direction: column;
121
121
  flex: 0 1 auto;
122
122
  min-height: 0;
123
123
  }
124
- `}render(){let e=f(this,"gap",w,"m"),t=f(this,"align",["start","center","end","stretch"],"stretch");return m`<style>
125
- :host { gap: var(--bang-gap-${e}); align-items: ${yt[t]}; }
126
- </style><slot></slot>`}};p([h()],W.prototype,"gap",2),p([h()],W.prototype,"align",2);v("bang-stack",W);var C=class extends y{constructor(){super(...arguments);this.align="stretch";this.gap="m"}static{this.styles=b`
124
+ `}render(){let e=f(this,"gap",w,"m"),t=f(this,"align",["start","center","end","stretch"],"stretch");return h`<style>
125
+ :host { gap: var(--bang-gap-${e}); align-items: ${kt[t]}; }
126
+ </style><slot></slot>`}};p([u()],U.prototype,"gap",2),p([u()],U.prototype,"align",2);v("bang-stack",U);var L=class extends y{constructor(){super(...arguments);this.align="stretch";this.gap="m"}static{this.styles=b`
127
127
  :host {
128
128
  display: grid;
129
129
  flex: 0 1 auto;
@@ -131,9 +131,9 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
131
131
  /* The browser reads an align attribute as a legacy text-align hint, which would centre the text inside every column. */
132
132
  text-align: start;
133
133
  }
134
- `}render(){let e=f(this,"gap",w,"m"),t=f(this,"align",["stretch","start","center","end"],"stretch"),n=Math.max(this.children.length,1),s=this.getAttribute("ratio"),a=Array.from({length:n},()=>1);if(s!==null&&this.children.length>0){let l=be(s,this.children.length);l?a=l:x(`columns|${s}|${this.children.length}`,`[banger] <bang-columns ratio="${s}"> does not match ${this.children.length} children; using equal columns`)}let i=a.map(l=>`minmax(0, ${l}fr)`).join(" ");return m`<style>
135
- :host { grid-template-columns: ${i}; gap: var(--bang-gap-${e}); align-items: ${t}; }
136
- </style><slot @slotchange=${()=>this.requestUpdate()}></slot>`}};p([h()],C.prototype,"ratio",2),p([h()],C.prototype,"align",2),p([h()],C.prototype,"gap",2);v("bang-columns",C);var O=class extends y{constructor(){super(...arguments);this.kind="panel";this.grow=!1;this.valign="start"}static{this.styles=b`
134
+ `}render(){let e=f(this,"gap",w,"m"),t=f(this,"align",["stretch","start","center","end"],"stretch"),r=Math.max(this.children.length,1),s=this.getAttribute("ratio"),i=Array.from({length:r},()=>1);if(s!==null&&this.children.length>0){let l=ve(s,this.children.length);l?i=l:x(`columns|${s}|${this.children.length}`,`[banger] <bang-columns ratio="${s}"> does not match ${this.children.length} children; using equal columns`)}let a=i.map(l=>`minmax(0, ${l}fr)`).join(" ");return h`<style>
135
+ :host { grid-template-columns: ${a}; gap: var(--bang-gap-${e}); align-items: ${t}; }
136
+ </style><slot @slotchange=${()=>this.requestUpdate()}></slot>`}};p([u()],L.prototype,"ratio",2),p([u()],L.prototype,"align",2),p([u()],L.prototype,"gap",2);v("bang-columns",L);var N=class extends y{constructor(){super(...arguments);this.kind="panel";this.grow=!1;this.valign="start"}static{this.styles=b`
137
137
  :host {
138
138
  display: flex;
139
139
  flex-direction: column;
@@ -163,7 +163,7 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
163
163
  :host([grow]) {
164
164
  flex: 1 1 0;
165
165
  }
166
- `}render(){return f(this,"kind",["panel","band"],"panel"),f(this,"valign",["start","center","spread"],"start"),m`<slot></slot>`}};p([h()],O.prototype,"kind",2),p([h({type:Boolean})],O.prototype,"grow",2),p([h()],O.prototype,"valign",2);v("bang-card",O);var j=class extends y{constructor(){super(...arguments);this.size="l";this.tone="default"}static{this.styles=b`
166
+ `}render(){return f(this,"kind",["panel","band"],"panel"),f(this,"valign",["start","center","spread"],"start"),h`<slot></slot>`}};p([u()],N.prototype,"kind",2),p([u({type:Boolean})],N.prototype,"grow",2),p([u()],N.prototype,"valign",2);v("bang-card",N);var D=class extends y{constructor(){super(...arguments);this.size="l";this.tone="default"}static{this.styles=b`
167
167
  :host {
168
168
  display: block;
169
169
  /* Keeps a lone character off the last line, which narrow columns of Japanese text otherwise produce. */
@@ -172,9 +172,9 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
172
172
  font-weight: var(--bang-heading-weight, 800);
173
173
  letter-spacing: var(--bang-heading-tracking, -0.03em);
174
174
  }
175
- `}render(){let e=f(this,"size",w,"l"),t=f(this,"tone",$,"default");return m`<style>
175
+ `}render(){let e=f(this,"size",w,"l"),t=f(this,"tone",$,"default");return h`<style>
176
176
  :host { font-size: var(--bang-size-${e}); line-height: calc(var(--bang-leading-${e}) * var(--bang-heading-leading-scale, 1)); color: var(--bang-tone-${t}); }
177
- </style><slot></slot>`}};p([h()],j.prototype,"size",2),p([h()],j.prototype,"tone",2);v("bang-title",j);var q=class extends y{constructor(){super(...arguments);this.size="s";this.tone="default"}static{this.styles=b`
177
+ </style><slot></slot>`}};p([u()],D.prototype,"size",2),p([u()],D.prototype,"tone",2);v("bang-title",D);var W=class extends y{constructor(){super(...arguments);this.size="s";this.tone="default"}static{this.styles=b`
178
178
  :host {
179
179
  display: block;
180
180
  /* Keeps a lone character off the last line, which narrow columns of Japanese text otherwise produce. */
@@ -183,9 +183,9 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
183
183
  font-weight: var(--bang-text-weight, 400);
184
184
  letter-spacing: var(--bang-text-tracking, normal);
185
185
  }
186
- `}render(){let e=f(this,"size",w,"s"),t=f(this,"tone",$,"default");return m`<style>
186
+ `}render(){let e=f(this,"size",w,"s"),t=f(this,"tone",$,"default");return h`<style>
187
187
  :host { font-size: var(--bang-size-${e}); line-height: calc(var(--bang-leading-text-${e}) * var(--bang-text-leading-scale, 1)); color: var(--bang-tone-${t}); }
188
- </style><slot></slot>`}};p([h()],q.prototype,"size",2),p([h()],q.prototype,"tone",2);v("bang-text",q);var N=class N extends U{constructor(){super(...arguments);this.size="s";this.tone="default";this.ordered=!1}static{this.styles=b`
188
+ </style><slot></slot>`}};p([u()],W.prototype,"size",2),p([u()],W.prototype,"tone",2);v("bang-text",W);var I=class I extends j{constructor(){super(...arguments);this.size="s";this.tone="default";this.ordered=!1}static{this.styles=b`
189
189
  :host {
190
190
  display: block;
191
191
  text-wrap: pretty;
@@ -240,18 +240,18 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
240
240
  font-weight: 700;
241
241
  color: var(--bang-marker);
242
242
  }
243
- `}items(){return[...this.children].filter(e=>e.localName==="li"&&T(e))}firstStep(){return this.hasAttribute("step")&&H(this,"step",1,999,0)||void 0}nestedIn(){let e=this.parentElement;return e instanceof N?e:null}rootList(){let e=this;for(let t=e.nestedIn();t;t=e.nestedIn())e=t;return e}willUpdate(e){super.willUpdate(e),this.toggleAttribute("data-bang-nested",this.nestedIn()!==null),this.toggleAttribute("data-bang-grouped",[...this.children].some(t=>t.localName==="bang-list"))}get stepCount(){if(this.nestedIn())return 0;let e=this.firstStep();return e===void 0?0:e+this.items().length-1}updated(e){if(super.updated(e),this.nestedIn())return;let t=this.firstStep(),n=this.items(),s=t===void 0?n.length:Math.min(Math.max(this.frameStep-t+1,0),n.length);n.forEach((i,l)=>i.toggleAttribute("data-bang-hidden",l>=s));let a;for(let i of this.children)i.localName==="li"?T(i)&&(a=i):i.localName==="bang-list"&&i.toggleAttribute("data-bang-hidden",a?.hasAttribute("data-bang-hidden")??!1)}render(){let e=this.nestedIn()!==null,t=e?this.rootList():this,n=f(t,"size",w,"s"),s=e?f(this,"size",w,w[Math.max(w.indexOf(n)-1,0)]):n,a=f(t,"tone",$,"default");return e&&(this.hasAttribute("tone")||this.hasAttribute("step"))&&x("list|nested","[banger] <bang-list> next to its parent li takes its tone from the outermost list; its tone and step are ignored"),m`<style>
243
+ `}items(){return[...this.children].filter(e=>e.localName==="li"&&C(e))}firstStep(){return this.hasAttribute("step")&&H(this,"step",1,999,0)||void 0}nestedIn(){let e=this.parentElement;return e instanceof I?e:null}rootList(){let e=this;for(let t=e.nestedIn();t;t=e.nestedIn())e=t;return e}willUpdate(e){super.willUpdate(e),this.toggleAttribute("data-bang-nested",this.nestedIn()!==null),this.toggleAttribute("data-bang-grouped",[...this.children].some(t=>t.localName==="bang-list"))}get stepCount(){if(this.nestedIn())return 0;let e=this.firstStep();return e===void 0?0:e+this.items().length-1}updated(e){if(super.updated(e),this.nestedIn())return;let t=this.firstStep(),r=this.items(),s=t===void 0?r.length:Math.min(Math.max(this.frameStep-t+1,0),r.length);r.forEach((a,l)=>a.toggleAttribute("data-bang-hidden",l>=s));let i;for(let a of this.children)a.localName==="li"?C(a)&&(i=a):a.localName==="bang-list"&&a.toggleAttribute("data-bang-hidden",i?.hasAttribute("data-bang-hidden")??!1)}render(){let e=this.nestedIn()!==null,t=e?this.rootList():this,r=f(t,"size",w,"s"),s=e?f(this,"size",w,w[Math.max(w.indexOf(r)-1,0)]):r,i=f(t,"tone",$,"default");return e&&(this.hasAttribute("tone")||this.hasAttribute("step"))&&x("list|nested","[banger] <bang-list> next to its parent li takes its tone from the outermost list; its tone and step are ignored"),h`<style>
244
244
  :host {
245
245
  font-size: var(--bang-size-${s});
246
246
  line-height: calc(var(--bang-leading-text-${s}) * var(--bang-text-leading-scale, 1));
247
247
  --bang-lh: calc(var(--bang-leading-text-${s}) * var(--bang-text-leading-scale, 1));
248
- --bang-marker: var(--bang-tone-${a});
249
- color: var(--bang-tone-${a});
248
+ --bang-marker: var(--bang-tone-${i});
249
+ color: var(--bang-tone-${i});
250
250
  }
251
251
  ::slotted(bang-list) {
252
252
  margin-left: calc(var(--bang-size-${s}) * 1.2);
253
253
  }
254
- </style><ul><slot @slotchange=${()=>this.requestUpdate()}></slot></ul>`}};p([h()],N.prototype,"size",2),p([h()],N.prototype,"tone",2),p([h({type:Number})],N.prototype,"step",2),p([h({type:Boolean})],N.prototype,"ordered",2);var ne=N;v("bang-list",ne);var A=class extends y{constructor(){super(...arguments);this.labelSize="xs";this.size="xl";this.tone="default"}static{this.styles=b`
254
+ </style><ul><slot @slotchange=${()=>this.requestUpdate()}></slot></ul>`}};p([u()],I.prototype,"size",2),p([u()],I.prototype,"tone",2),p([u({type:Number})],I.prototype,"step",2),p([u({type:Boolean})],I.prototype,"ordered",2);var re=I;v("bang-list",re);var A=class extends y{constructor(){super(...arguments);this.labelSize="xs";this.size="xl";this.tone="default"}static{this.styles=b`
255
255
  :host {
256
256
  display: block;
257
257
  }
@@ -264,10 +264,10 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
264
264
  font-family: var(--bang-font-sans);
265
265
  color: var(--bang-tone-muted);
266
266
  }
267
- `}render(){let e=f(this,"size",w,"xl"),t=f(this,"tone",$,"default"),n=f(this,"label-size",w,"xs"),s=this.getAttribute("value");return s===null&&x("stat|value","[banger] <bang-stat> needs a value attribute"),m`<style>
267
+ `}render(){let e=f(this,"size",w,"xl"),t=f(this,"tone",$,"default"),r=f(this,"label-size",w,"xs"),s=this.getAttribute("value");return s===null&&x("stat|value","[banger] <bang-stat> needs a value attribute"),h`<style>
268
268
  .value { font-size: var(--bang-size-${e}); line-height: calc(var(--bang-leading-${e}) * var(--bang-heading-leading-scale, 1)); color: var(--bang-tone-${t}); }
269
- .label { font-size: var(--bang-size-${n}); line-height: var(--bang-leading-text-${n}); }
270
- </style><div class="value">${s??""}</div>${this.label?m`<div class="label">${this.label}</div>`:""}`}};p([h()],A.prototype,"value",2),p([h()],A.prototype,"label",2),p([h({attribute:"label-size"})],A.prototype,"labelSize",2),p([h()],A.prototype,"size",2),p([h()],A.prototype,"tone",2);v("bang-stat",A);var I=class extends y{constructor(){super(...arguments);this.alt="";this.fit="contain"}static{this.styles=b`
269
+ .label { font-size: var(--bang-size-${r}); line-height: var(--bang-leading-text-${r}); }
270
+ </style><div class="value">${s??""}</div>${this.label?h`<div class="label">${this.label}</div>`:""}`}};p([u()],A.prototype,"value",2),p([u()],A.prototype,"label",2),p([u({attribute:"label-size"})],A.prototype,"labelSize",2),p([u()],A.prototype,"size",2),p([u()],A.prototype,"tone",2);v("bang-stat",A);var _=class extends y{constructor(){super(...arguments);this.alt="";this.fit="contain"}static{this.styles=b`
271
271
  :host {
272
272
  display: block;
273
273
  flex: 1 1 0;
@@ -278,9 +278,9 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
278
278
  width: 100%;
279
279
  height: 100%;
280
280
  }
281
- `}updated(e){super.updated(e);let t=this.getAttribute("src"),n=this.renderRoot.querySelector("img"),s=!t||!n?Promise.reject(new Error("image has no src")):this.decode(n,t);s.catch(()=>{}),this.renderDone=s}async decode(e,t){try{await e.decode()}catch{throw new Error(`image failed to load: ${t}`)}}render(){let e=f(this,"fit",["contain","cover"],"contain"),t=this.getAttribute("src");return m`<style>
281
+ `}updated(e){super.updated(e);let t=this.getAttribute("src"),r=this.renderRoot.querySelector("img"),s=!t||!r?Promise.reject(new Error("image has no src")):this.decode(r,t);s.catch(()=>{}),this.renderDone=s}async decode(e,t){try{await e.decode()}catch{throw new Error(`image failed to load: ${t}`)}}render(){let e=f(this,"fit",["contain","cover"],"contain"),t=this.getAttribute("src");return h`<style>
282
282
  img { object-fit: ${e}; }
283
- </style>${t?m`<img src=${t} alt=${this.alt} />`:""}`}};p([h()],I.prototype,"src",2),p([h()],I.prototype,"alt",2),p([h()],I.prototype,"fit",2);v("bang-image",I);var K=class extends U{constructor(){super(...arguments);this.handle=null;this.lastKey=null;this.observer=null;this.parsed=null}static{this.styles=b`
283
+ </style>${t?h`<img src=${t} alt=${this.alt} />`:""}`}};p([u()],_.prototype,"src",2),p([u()],_.prototype,"alt",2),p([u()],_.prototype,"fit",2);v("bang-image",_);var q=class extends j{constructor(){super(...arguments);this.handle=null;this.lastKey=null;this.observer=null;this.parsed=null}static{this.styles=b`
284
284
  :host {
285
285
  display: block;
286
286
  position: relative;
@@ -291,7 +291,7 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
291
291
  position: absolute;
292
292
  inset: 0;
293
293
  }
294
- `}firstStep(){return this.hasAttribute("step")&&H(this,"step",1,999,0)||void 0}parse(){let t=this.querySelector(':scope > script[type="application/json"]')?.textContent??"";if(this.parsed?.text===t)return this.parsed.result;let n=null;try{let s=JSON.parse(t);typeof s=="object"&&s!==null&&!Array.isArray(s)&&(n={text:t,option:s})}catch{n=null}return this.parsed={text:t,result:n},n}seriesOf(e){let t=e.series;return t===void 0?[]:Array.isArray(t)?t:[t]}get visibleSeries(){let e=this.parse();if(!e)return 0;let t=this.seriesOf(e.option).length,n=this.firstStep();return n===void 0?t:Math.min(Math.max(this.frameStep-n+1,0),t)}get animationEnabled(){return!this.env().exportMode&&!this.env().reducedMotion}get stepCount(){let e=this.firstStep(),t=this.parse();return e===void 0||!t?0:e+this.seriesOf(t.option).length-1}env(){return{exportMode:this.closest("bang-root")?.getAttribute("data-mode")==="export",reducedMotion:window.matchMedia("(prefers-reduced-motion: reduce)").matches}}connectedCallback(){super.connectedCallback(),this.observer=new ResizeObserver(()=>{this.handle?.then(e=>e.resize())}),this.observer.observe(this),this.hasUpdated&&!this.handle&&this.requestUpdate()}disconnectedCallback(){super.disconnectedCallback(),this.observer?.disconnect(),this.observer=null,this.handle?.then(e=>e.dispose()),this.handle=null,this.lastKey=null}updated(e){super.updated(e);let t=this.parse(),n=t?`${this.visibleSeries}|${t.text}`:"invalid";if(n===this.lastKey)return;this.lastKey=n;let s=this.draw(t);s.catch(()=>{}),this.renderDone=s}async draw(e){if(!e)throw new Error("chart option JSON could not be parsed");let t=this.renderRoot.querySelector(".chart");if(!t)throw new Error("chart container is missing");let{createChart:n}=await import("./chunks/chart-impl-CMVBON4X.js");this.handle??=n(t,e.text);let s=await this.handle,a=structuredClone(e.option);this.firstStep()!==void 0&&(a.series=this.seriesOf(a).slice(0,this.visibleSeries)),await s.render(a,this.env())}render(){return m`<div class="chart"></div>`}};p([h({type:Number})],K.prototype,"step",2);v("bang-chart",K);var xt=["arrow-up","arrow-down","arrow-left","arrow-right","ok","ng"],re="0 0 64 32",Je="0 0 32 32",wt={"arrow-down":{viewBox:re,d:"M16 0H48V12H64L32 32L0 12H16Z",width:2},"arrow-up":{viewBox:re,d:"M16 32H48V20H64L32 0L0 20H16Z",width:2},"arrow-left":{viewBox:re,d:"M64 8H24V0L0 16L24 32V24H64Z",width:2},"arrow-right":{viewBox:re,d:"M0 8H40V0L64 16L40 32V24H0Z",width:2},ok:{viewBox:Je,d:"M16 0a16 16 0 1 0 0 32a16 16 0 1 0 0-32zM16 5a11 11 0 1 1 0 22a11 11 0 1 1 0-22z",width:1},ng:{viewBox:Je,d:"M6 0L16 10L26 0L32 6L22 16L32 26L26 32L16 22L6 32L0 26L10 16L0 6Z",width:1}},_=class extends y{constructor(){super(...arguments);this.kind="arrow-down";this.size="m";this.tone="default"}static{this.styles=b`
294
+ `}firstStep(){return this.hasAttribute("step")&&H(this,"step",1,999,0)||void 0}parse(){let t=this.querySelector(':scope > script[type="application/json"]')?.textContent??"";if(this.parsed?.text===t)return this.parsed.result;let r=null;try{let s=JSON.parse(t);typeof s=="object"&&s!==null&&!Array.isArray(s)&&(r={text:t,option:s})}catch{r=null}return this.parsed={text:t,result:r},r}seriesOf(e){let t=e.series;return t===void 0?[]:Array.isArray(t)?t:[t]}get visibleSeries(){let e=this.parse();if(!e)return 0;let t=this.seriesOf(e.option).length,r=this.firstStep();return r===void 0?t:Math.min(Math.max(this.frameStep-r+1,0),t)}get animationEnabled(){return!this.env().exportMode&&!this.env().reducedMotion}get stepCount(){let e=this.firstStep(),t=this.parse();return e===void 0||!t?0:e+this.seriesOf(t.option).length-1}env(){return{exportMode:this.closest("bang-root")?.getAttribute("data-mode")==="export",reducedMotion:window.matchMedia("(prefers-reduced-motion: reduce)").matches}}connectedCallback(){super.connectedCallback(),this.observer=new ResizeObserver(()=>{this.handle?.then(e=>e.resize())}),this.observer.observe(this),this.hasUpdated&&!this.handle&&this.requestUpdate()}disconnectedCallback(){super.disconnectedCallback(),this.observer?.disconnect(),this.observer=null,this.handle?.then(e=>e.dispose()),this.handle=null,this.lastKey=null}updated(e){super.updated(e);let t=this.parse(),r=t?`${this.visibleSeries}|${t.text}`:"invalid";if(r===this.lastKey)return;this.lastKey=r;let s=this.draw(t);s.catch(()=>{}),this.renderDone=s}async draw(e){if(!e)throw new Error("chart option JSON could not be parsed");let t=this.renderRoot.querySelector(".chart");if(!t)throw new Error("chart container is missing");let{createChart:r}=await import("./chunks/chart-impl-CMVBON4X.js");this.handle??=r(t,e.text);let s=await this.handle,i=structuredClone(e.option);this.firstStep()!==void 0&&(i.series=this.seriesOf(i).slice(0,this.visibleSeries)),await s.render(i,this.env())}render(){return h`<div class="chart"></div>`}};p([u({type:Number})],q.prototype,"step",2);v("bang-chart",q);var Et=["arrow-up","arrow-down","arrow-left","arrow-right","ok","ng"],se="0 0 64 32",Ye="0 0 32 32",At={"arrow-down":{viewBox:se,d:"M16 0H48V12H64L32 32L0 12H16Z",width:2},"arrow-up":{viewBox:se,d:"M16 32H48V20H64L32 0L0 20H16Z",width:2},"arrow-left":{viewBox:se,d:"M64 8H24V0L0 16L24 32V24H64Z",width:2},"arrow-right":{viewBox:se,d:"M0 8H40V0L64 16L40 32V24H0Z",width:2},ok:{viewBox:Ye,d:"M16 0a16 16 0 1 0 0 32a16 16 0 1 0 0-32zM16 5a11 11 0 1 1 0 22a11 11 0 1 1 0-22z",width:1},ng:{viewBox:Ye,d:"M6 0L16 10L26 0L32 6L22 16L32 26L26 32L16 22L6 32L0 26L10 16L0 6Z",width:1}},F=class extends y{constructor(){super(...arguments);this.kind="arrow-down";this.size="m";this.tone="default"}static{this.styles=b`
295
295
  :host {
296
296
  display: inline-block;
297
297
  flex: none;
@@ -303,11 +303,11 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
303
303
  height: 100%;
304
304
  fill: currentColor;
305
305
  }
306
- `}render(){let e=f(this,"kind",xt,"arrow-down"),t=f(this,"size",w,"m"),n=f(this,"tone",$,"default"),s=wt[e],a=e==="ok"||e==="ng",i=a?`var(--bang-tone-${n})`:`color-mix(in srgb, var(--bang-tone-${n}) 60%, transparent)`,l=m`<style>
307
- :host { height: var(--bang-size-${t}); width: calc(var(--bang-size-${t}) * ${s.width}); color: ${i}; }
308
- </style>`;return a?m`${l}<svg viewBox=${s.viewBox} role="img" aria-label=${e==="ok"?"OK":"NG"}>
306
+ `}render(){let e=f(this,"kind",Et,"arrow-down"),t=f(this,"size",w,"m"),r=f(this,"tone",$,"default"),s=At[e],i=e==="ok"||e==="ng",a=i?`var(--bang-tone-${r})`:`color-mix(in srgb, var(--bang-tone-${r}) 60%, transparent)`,l=h`<style>
307
+ :host { height: var(--bang-size-${t}); width: calc(var(--bang-size-${t}) * ${s.width}); color: ${a}; }
308
+ </style>`;return i?h`${l}<svg viewBox=${s.viewBox} role="img" aria-label=${e==="ok"?"OK":"NG"}>
309
309
  <path fill-rule="evenodd" d=${s.d}></path>
310
- </svg>`:m`${l}<svg viewBox=${s.viewBox} aria-hidden="true"><path d=${s.d}></path></svg>`}};p([h()],_.prototype,"kind",2),p([h()],_.prototype,"size",2),p([h()],_.prototype,"tone",2);v("bang-shape",_);var B=class extends y{constructor(){super(...arguments);this.overlay=!1}static{this.styles=b`
310
+ </svg>`:h`${l}<svg viewBox=${s.viewBox} aria-hidden="true"><path d=${s.d}></path></svg>`}};p([u()],F.prototype,"kind",2),p([u()],F.prototype,"size",2),p([u()],F.prototype,"tone",2);v("bang-shape",F);var K=class extends y{constructor(){super(...arguments);this.overlay=!1}static{this.styles=b`
311
311
  :host {
312
312
  display: grid;
313
313
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
@@ -324,23 +324,30 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
324
324
  flex: none;
325
325
  pointer-events: none;
326
326
  }
327
- `}firstUpdated(){this.scopeStyles()}get renderReady(){return this.updateComplete.then(()=>this.waitImages())}scopeStyles(){for(let e of this.children)if(!(e.localName!=="style"||e.hasAttribute("data-bang-scoped"))){if(!ke()){x("bang-free|scope","[banger] <bang-free>: this browser does not support CSS @scope; the rules in its <style> apply to the whole page");continue}e.textContent=Ee(e.textContent??""),e.setAttribute("data-bang-scoped","")}}async waitImages(){let e=[...this.querySelectorAll("img")].filter(t=>T(t));await Promise.all(e.map(async t=>{try{await t.decode()}catch{throw new Error(`image failed to load: ${t.getAttribute("src")??""}`)}}))}render(){return m`<slot @slotchange=${()=>this.scopeStyles()}></slot>`}};p([h({type:Boolean})],B.prototype,"overlay",2);v("bang-free",B);function Qe(r){return r.querySelector(':scope > bang-theme > script[type="application/json"]')?.textContent??null}var se=class extends y{static{this.styles=b`
327
+ `}firstUpdated(){this.scopeStyles()}get renderReady(){return this.updateComplete.then(()=>this.waitImages())}scopeStyles(){for(let e of this.children)if(!(e.localName!=="style"||e.hasAttribute("data-bang-scoped"))){if(!Ee()){x("bang-free|scope","[banger] <bang-free>: this browser does not support CSS @scope; the rules in its <style> apply to the whole page");continue}e.textContent=ke(e.textContent??""),e.setAttribute("data-bang-scoped","")}}async waitImages(){let e=[...this.querySelectorAll("img")].filter(t=>C(t));await Promise.all(e.map(async t=>{try{await t.decode()}catch{throw new Error(`image failed to load: ${t.getAttribute("src")??""}`)}}))}render(){return h`<slot @slotchange=${()=>this.scopeStyles()}></slot>`}};p([u({type:Boolean})],K.prototype,"overlay",2);v("bang-free",K);function et(n){return n.querySelector(':scope > bang-theme > script[type="application/json"]')?.textContent??null}var oe=class extends y{static{this.styles=b`
328
328
  :host {
329
329
  display: none;
330
330
  }
331
- `}render(){return null}};v("bang-theme",se);var me="0.2.2";var ge=r=>r.id?`frame "${r.id}"`:k(r);function nt(r){let o=new Map;for(let e of r.querySelectorAll("*")){let t=e.localName;if(!t.startsWith("bang-")||customElements.get(t))continue;let n=o.get(t);n?n.count+=1:o.set(t,{selector:k(e),count:1})}return[...o].map(([e,{selector:t,count:n}])=>`${t}: <${e}> is not a Banger element${n>1?` (${n} times)`:""}; check the tag name`)}function rt(r){let o=[];for(let e=0;e<r.length;e++)for(let t=e+1;t<r.length;t++){let n=r[e].rect,s=r[t].rect;n.x<s.x+s.w&&s.x<n.x+n.w&&n.y<s.y+s.h&&s.y<n.y+n.h&&o.push(`${ge(r[e].el)} and ${ge(r[t].el)} overlap on the canvas; give them different at values`)}return o}function Ye(r,o,e){let t={x:0,y:0,worst:null},n=0;for(let s of r.querySelectorAll("*")){if(s.localName==="script"||s.localName==="style"||s.closest("bang-free")||getComputedStyle(s).display==="inline")continue;let a=s.getBoundingClientRect();if(a.width===0&&a.height===0)continue;let i=Math.max(0,(o.left-a.left)/e,(a.right-o.right)/e),l=Math.max(0,(o.top-a.top)/e,(a.bottom-o.bottom)/e);t.x=Math.max(t.x,i),t.y=Math.max(t.y,l),Math.max(i,l)>n&&(n=Math.max(i,l),t.worst=s)}return t}var et=r=>r.worst?` (furthest: ${k(r.worst)})`:"",tt=(r,o)=>[r>ce?`${Math.round(r)}px horizontally`:"",o>ce?`${Math.round(o)}px vertically`:""].filter(Boolean);function st(r){let o=[];for(let{el:e}of r){let t=e.shadowRoot?.querySelector(".frame");if(!t||e.offsetWidth===0)continue;let n=e.getBoundingClientRect(),s=n.width/e.offsetWidth,a=getComputedStyle(t),i={left:n.left+parseFloat(a.paddingLeft)*s,top:n.top+parseFloat(a.paddingTop)*s,right:n.right-parseFloat(a.paddingRight)*s,bottom:n.bottom-parseFloat(a.paddingBottom)*s},l=Ye(e,i,s),u=tt(Math.max(l.x,t.scrollWidth-t.clientWidth),Math.max(l.y,t.scrollHeight-t.clientHeight));u.length>0&&o.push(`${ge(e)}: the content does not fit inside the frame margins by ${u.join(", ")}${et(l)}; what passes the frame edge is cut off, so shorten it or use smaller sizes`);for(let c of e.querySelectorAll("bang-card")){let d=Ye(c,c.getBoundingClientRect(),s),g=tt(d.x,d.y);g.length>0&&o.push(`${k(c)}: the content sticks out of the card by ${g.join(", ")}${et(d)}; shorten it or use smaller sizes`)}}return o}function ot(r,o){let e=[],t=a=>X(a.getAttribute("lang"),o),n=k;for(let a of r.querySelectorAll("bang-frame, bang-stop"))t(a)&&e.push(`${n(a)}: lang is ignored on <${a.localName}>; the frames and stops are the same in every language`);for(let a of r.querySelectorAll("bang-frame, bang-frame *, bang-path > bang-stop")){let i=new Map;for(let l of a.children){let u=t(l);if(u){let c=i.get(l.localName)??new Map;c.set(u,(c.get(u)??0)+1),i.set(l.localName,c)}else{let c=l.getAttribute("lang");c&&e.push(`${n(l)}: lang="${c}" is not in languages (${o.join(" ")}); shown in every language`)}}for(let[l,u]of i){let c=o.map(d=>u.get(d)??0);c.some(d=>d!==c[0])&&e.push(`${n(a)}: <${l}> differs by language (${o.map((d,g)=>`${d}: ${c[g]}`).join(", ")}); give every language the same number of <${l}>`)}if(a.localName==="bang-columns"&&[...a.children].some(l=>t(l))&&e.push(`${n(a)}: <bang-columns> makes a column of every child, so a child with lang adds a column in every language; put lang on the content inside each column`),a.localName==="bang-frame"&&a.getAttribute("valign")!=="spread"){let l=[...a.children],u=l.filter(c=>!(c.localName==="bang-free"&&c.hasAttribute("overlay")));l[0]?.localName==="bang-title"&&(t(l[0])||u.length>0&&t(u[u.length-1]))&&e.push(`${n(a)}: the title or the last child of this frame carries lang, so the layout moves between languages; write the title's languages with <span lang> and put the translated elements inside a bang-stack without lang`)}}let s=[...r.querySelectorAll("bang-frame")];for(let a of s)for(let i of["crumb","label"]){if(!a.getAttribute(i)?.trim())continue;let l=o.slice(1).filter(u=>!a.getAttribute(`${i}-${u.toLowerCase()}`)?.trim());l.length>0&&e.push(`${n(a)}: ${i} has no ${l.map(u=>`${i}-${u.toLowerCase()}`).join(", ")}; the ${o[0]} text is shown in ${l.join(", ")}`)}for(let a of r.querySelectorAll("bang-path > bang-stop[focus]")){let i=s.find(c=>c.id===a.getAttribute("frame")),l=a.getAttribute("focus")?.trim();if(!l)continue;let u=i?.querySelector(`#${CSS.escape(l)}`)??null;for(let c=u;c&&c!==i;c=c.parentElement){let d=t(c);if(d){e.push(`${n(a)}: focus="${l}" points into lang="${d}" content, which is hidden in the other languages; put the id on an element without lang`);break}}}return e}var oe=class{constructor(){this.id=Math.random().toString(36).slice(2);this.channel=new BroadcastChannel(`bang:${location.origin}${location.pathname}`)}send(o){let e={type:"state",stop:o.stop,step:o.step,sender:this.id};this.channel.postMessage(e)}sendLanguage(o){let e={type:"lang",lang:o,sender:this.id};this.channel.postMessage(e)}onRemoteLanguage(o){this.channel.addEventListener("message",e=>{let t=e.data;t?.type==="lang"&&t.sender!==this.id&&o(t.lang)})}onRemote(o){this.channel.addEventListener("message",e=>{let t=e.data;t?.type==="state"&&t.sender!==this.id&&o({stop:t.stop,step:t.step})})}close(){this.channel.close()}},at=r=>String(r).padStart(2,"0");function St(r){let o=Math.floor(r/1e3);return`${at(Math.floor(o/60))}:${at(o%60)}`}function it(r){return m`<div class="presenter">
331
+ `}render(){return null}};v("bang-theme",oe);var me="0.2.3";var ge=n=>n.id?`frame "${n.id}"`:k(n);function st(n){let o=new Map;for(let e of n.querySelectorAll("*")){let t=e.localName;if(!t.startsWith("bang-")||customElements.get(t))continue;let r=o.get(t);r?r.count+=1:o.set(t,{selector:k(e),count:1})}return[...o].map(([e,{selector:t,count:r}])=>`${t}: <${e}> is not a Banger element${r>1?` (${r} times)`:""}; check the tag name`)}function ot(n){let o=[];for(let e=0;e<n.length;e++)for(let t=e+1;t<n.length;t++){let r=n[e].rect,s=n[t].rect;r.x<s.x+s.w&&s.x<r.x+r.w&&r.y<s.y+s.h&&s.y<r.y+r.h&&o.push(`${ge(n[e].el)} and ${ge(n[t].el)} overlap on the canvas; give them different at values`)}return o}function tt(n,o,e){let t={x:0,y:0,worst:null},r=0;for(let s of n.querySelectorAll("*")){if(s.localName==="script"||s.localName==="style"||s.closest("bang-free")||getComputedStyle(s).display==="inline")continue;let i=s.getBoundingClientRect();if(i.width===0&&i.height===0)continue;let a=Math.max(0,(o.left-i.left)/e,(i.right-o.right)/e),l=Math.max(0,(o.top-i.top)/e,(i.bottom-o.bottom)/e);t.x=Math.max(t.x,a),t.y=Math.max(t.y,l),Math.max(a,l)>r&&(r=Math.max(a,l),t.worst=s)}return t}var nt=n=>n.worst?` (furthest: ${k(n.worst)})`:"",rt=(n,o)=>[n>pe?`${Math.round(n)}px horizontally`:"",o>pe?`${Math.round(o)}px vertically`:""].filter(Boolean);function it(n){let o=[];for(let{el:e}of n){let t=e.shadowRoot?.querySelector(".frame");if(!t||e.offsetWidth===0)continue;let r=e.getBoundingClientRect(),s=r.width/e.offsetWidth,i=getComputedStyle(t),a={left:r.left+parseFloat(i.paddingLeft)*s,top:r.top+parseFloat(i.paddingTop)*s,right:r.right-parseFloat(i.paddingRight)*s,bottom:r.bottom-parseFloat(i.paddingBottom)*s},l=tt(e,a,s),m=rt(Math.max(l.x,t.scrollWidth-t.clientWidth),Math.max(l.y,t.scrollHeight-t.clientHeight));m.length>0&&o.push(`${ge(e)}: the content does not fit inside the frame margins by ${m.join(", ")}${nt(l)}; what passes the frame edge is cut off, so shorten it or use smaller sizes`);for(let c of e.querySelectorAll("bang-card")){let d=tt(c,c.getBoundingClientRect(),s),g=rt(d.x,d.y);g.length>0&&o.push(`${k(c)}: the content sticks out of the card by ${g.join(", ")}${nt(d)}; shorten it or use smaller sizes`)}}return o}function at(n,o){let e=[],t=i=>X(i.getAttribute("lang"),o),r=k;for(let i of n.querySelectorAll("bang-frame, bang-stop"))t(i)&&e.push(`${r(i)}: lang is ignored on <${i.localName}>; the frames and stops are the same in every language`);for(let i of n.querySelectorAll("bang-frame, bang-frame *, bang-path > bang-stop")){let a=new Map;for(let l of i.children){let m=t(l);if(m){let c=a.get(l.localName)??new Map;c.set(m,(c.get(m)??0)+1),a.set(l.localName,c)}else{let c=l.getAttribute("lang");c&&e.push(`${r(l)}: lang="${c}" is not in languages (${o.join(" ")}); shown in every language`)}}for(let[l,m]of a){let c=o.map(d=>m.get(d)??0);c.some(d=>d!==c[0])&&e.push(`${r(i)}: <${l}> differs by language (${o.map((d,g)=>`${d}: ${c[g]}`).join(", ")}); give every language the same number of <${l}>`)}if(i.localName==="bang-columns"&&[...i.children].some(l=>t(l))&&e.push(`${r(i)}: <bang-columns> makes a column of every child, so a child with lang adds a column in every language; put lang on the content inside each column`),i.localName==="bang-frame"&&i.getAttribute("valign")!=="spread"){let l=[...i.children],m=l.filter(c=>!(c.localName==="bang-free"&&c.hasAttribute("overlay")));l[0]?.localName==="bang-title"&&(t(l[0])||m.length>0&&t(m[m.length-1]))&&e.push(`${r(i)}: the title or the last child of this frame carries lang, so the layout moves between languages; write the title's languages with <span lang> and put the translated elements inside a bang-stack without lang`)}}let s=[...n.querySelectorAll("bang-frame")];for(let i of s)for(let a of["crumb","label"]){if(!i.getAttribute(a)?.trim())continue;let l=o.slice(1).filter(m=>!i.getAttribute(`${a}-${m.toLowerCase()}`)?.trim());l.length>0&&e.push(`${r(i)}: ${a} has no ${l.map(m=>`${a}-${m.toLowerCase()}`).join(", ")}; the ${o[0]} text is shown in ${l.join(", ")}`)}for(let i of n.querySelectorAll("bang-path > bang-stop[focus]")){let a=s.find(c=>c.id===i.getAttribute("frame")),l=i.getAttribute("focus")?.trim();if(!l)continue;let m=a?.querySelector(`#${CSS.escape(l)}`)??null;for(let c=m;c&&c!==a;c=c.parentElement){let d=t(c);if(d){e.push(`${r(i)}: focus="${l}" points into lang="${d}" content, which is hidden in the other languages; put the id on an element without lang`);break}}}return e}var fe=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function lt(n,o){if(typeof n=="string")try{return o.includes(new URL(n).protocol)?n:void 0}catch{return}}function Rt(n){if(!fe(n))return null;let{state:o}=n;if(o==="logged_out"||o==="invalid"||o==="unavailable")return{state:o};if(o!=="logged_in"||typeof n.username!="string"||n.username==="")return null;let e=lt(n.avatarUrl,["https:"]);return{state:o,username:n.username,...typeof n.displayName=="string"&&n.displayName!==""?{displayName:n.displayName}:{},...e?{avatarUrl:e}:{}}}function Tt(n){if(!fe(n))return null;let{state:o}=n;if(o==="none")return{state:o};let e=lt(n.url,["http:","https:"]);if(o==="unpublished"||o==="missing"||o==="unverified")return{state:o,...e?{url:e}:{}};if(o!=="published")return null;let{visibility:t,version:r}=n;return t!=="public"&&t!=="unlisted"?null:{state:o,visibility:t,...typeof r=="number"&&Number.isInteger(r)&&r>=1?{version:r}:{},...e?{url:e}:{}}}function ct(n){if(!fe(n))return null;let o=Rt(n.account),e=Tt(n.deck);return o&&e?{account:o,deck:e}:null}function pt(n){let o=n.displayName||n.username;return Array.from(o)[0]?.toUpperCase()??"?"}var ie=class{constructor(){this.id=Math.random().toString(36).slice(2);this.channel=new BroadcastChannel(`bang:${location.origin}${location.pathname}`)}send(o){let e={type:"state",stop:o.stop,step:o.step,sender:this.id};this.channel.postMessage(e)}sendLanguage(o){let e={type:"lang",lang:o,sender:this.id};this.channel.postMessage(e)}onRemoteLanguage(o){this.channel.addEventListener("message",e=>{let t=e.data;t?.type==="lang"&&t.sender!==this.id&&o(t.lang)})}onRemote(o){this.channel.addEventListener("message",e=>{let t=e.data;t?.type==="state"&&t.sender!==this.id&&o({stop:t.stop,step:t.step})})}close(){this.channel.close()}},ut=n=>String(n).padStart(2,"0");function zt(n){let o=Math.floor(n/1e3);return`${ut(Math.floor(o/60))}:${ut(o%60)}`}var Ct={logged_out:"Not logged in to banger.page",invalid:"banger.page did not accept the token (run banger login)",unavailable:"banger.page is not reachable"};function Ot(n){return n.state!=="logged_in"?h`<span class="presenter-note">${Ct[n.state]}</span>`:h`<span class="presenter-avatar">${pt(n)}${n.avatarUrl?h`<img class="presenter-avatar-img" referrerpolicy="no-referrer" alt="" src=${n.avatarUrl} @error=${o=>o.target.hidden=!0} />`:""}</span>
332
+ <span class="presenter-user" title=${`@${n.username}`}>${n.displayName??`@${n.username}`}</span>`}function Lt(n){switch(n.state){case"none":return"";case"published":return h`<span class="presenter-visibility" data-visibility=${n.visibility}>${n.visibility==="unlisted"?"Unlisted (link only)":"Public"}</span>
333
+ ${n.version!==void 0?h`<span class="presenter-version">v${n.version}</span>`:""}
334
+ ${n.url?h`<span class="presenter-deck-url">${n.url}</span>`:""}`;case"unpublished":return h`<span class="presenter-deck-note">Unpublished${n.url?` ${n.url}`:""}</span>`;case"missing":return h`<span class="presenter-deck-note">Not found on banger.page (the local record is out of date)</span>`;case"unverified":return h`<span class="presenter-deck-note">Last published from this folder: ${n.url?`${n.url} `:""}(not verified)</span>`}}function ht(n){return h`<div class="presenter">
332
335
  <div class="presenter-head">
333
- <span class="presenter-stop">Stop ${r.stop+1} / ${r.stopCount}</span>
334
- <span class="presenter-step">Step ${r.step+1} / ${r.steps+1}</span>
335
- ${r.language!==void 0?m`<span class="presenter-language">${r.language}</span>`:""}
336
- <span class="presenter-elapsed">${St(r.elapsedMs)}</span>
336
+ <span class="presenter-stop">Stop ${n.stop+1} / ${n.stopCount}</span>
337
+ <span class="presenter-step">Step ${n.step+1} / ${n.steps+1}</span>
338
+ ${n.language!==void 0?h`<span class="presenter-language">${n.language}</span>`:""}
339
+ <span class="presenter-timer">
340
+ <span class="presenter-elapsed">${zt(n.elapsedMs)}</span>
341
+ <button type="button" class="presenter-reset" @click=${n.onResetTimer}>Reset</button>
342
+ </span>
337
343
  </div>
338
- <div class="presenter-notes">${r.notes}</div>
344
+ ${n.status?h`<div class="presenter-account">${Ot(n.status.account)}${Lt(n.status.deck)}</div>`:""}
345
+ <div class="presenter-notes">${n.notes}</div>
339
346
  <div class="presenter-buttons">
340
- <button type="button" @click=${r.onPrev}>Previous</button>
341
- <button type="button" @click=${r.onNext}>Next</button>
347
+ <button type="button" class="presenter-prev" @click=${n.onPrev}>Previous</button>
348
+ <button type="button" class="presenter-next" @click=${n.onNext}>Next</button>
342
349
  </div>
343
- </div>`}function lt(){if(typeof BroadcastChannel>"u")return null;let r=new URL(location.href);return r.searchParams.set("mode","presenter"),window.open(r.toString(),"bang-presenter","popup,width=1100,height=720")}var Mt=240,$t=720,Et=960,kt=320,Pt=.08,At=400;function Rt(r){return[["\u2192 Space Enter PageDown","Next step or stop"],["\u2190 Backspace PageUp","Previous step or stop"],["Home / End","First / last stop"],["o Esc","Overview; click a frame to go there"],["p","Presenter window with notes"],...r?[["l","Next language"]]:[],["f","Full screen"],["?","This help"]]}var zt=4e3,ae={w:1920,h:1080};function Tt(){let r=new URLSearchParams(location.search).get("mode");return r==="export"||r==="presenter"?r:"live"}var Lt=50,Ct=800,Ot=300,Nt=400,It=60,_t=3,Ft=500;function ct(r){return r instanceof HTMLElement?r.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(r.tagName):!1}var M=class extends y{constructor(){super(...arguments);this.theme="light";this.format="slides";this.ground=null;this.firstStop=new Map;this.spotted=[];this.stage=ae;this.statusText="";this.helpOpen=!1;this.elapsedMs=0;this.mode="live";this.path={stops:[]};this.notes=[];this.frames=[];this.frameMap={};this.current={stop:0,step:0};this.inOverview=!1;this.pose={cx:1920/2,cy:1080/2,zoom:1};this.tween=null;this.resolvePending=null;this.reducedMotion=!1;this.initialized=!1;this.sync=null;this.languageList=[];this.currentLanguage="";this.onFontsLoaded=()=>this.refreshPose();this.resizeObserver=null;this.startedAt=0;this.motionQuery=null;this.themeKey=null;this.themeVars=[];this.themeWarnings=[];this.onKeydown=e=>this.handleKey(e);this.swipeStart=null;this.swiped=!1;this.onPointerDown=e=>{!e.isPrimary||e.pointerType==="mouse"&&e.button!==0||ct(e.composedPath()[0]??e.target)||(this.swipeStart={id:e.pointerId,mouse:e.pointerType==="mouse",x:e.clientX,y:e.clientY,at:e.timeStamp})};this.onPointerUp=e=>{let t=this.swipeStart;if(!t||t.id!==e.pointerId)return;this.swipeStart=null;let n=e.clientX-t.x,s=e.clientY-t.y,a=e.timeStamp-t.at,i=t.mouse&&Math.abs(s)>Math.abs(n),l=i?s:n,u=i?n:s,[c,d]=t.mouse?[Nt,Ot]:[Ct,Lt];a>c||Math.abs(l)<d||Math.abs(l)<Math.abs(u)*1.5||(t.mouse&&(window.getSelection()?.removeAllRanges(),document.documentElement.setAttribute("data-bang-remote",""),this.setAttribute("data-bang-nocursor","")),this.swiped=!0,setTimeout(()=>this.swiped=!1),l<0?this.next():this.prev())};this.handMoves=[];this.onPointerMove=e=>{if(e.pointerType!=="mouse"||e.buttons!==0||!this.hasAttribute("data-bang-nocursor"))return;let t=Math.hypot(e.movementX,e.movementY);t===0||t>=It||(this.handMoves=[...this.handMoves.filter(n=>e.timeStamp-n<Ft),e.timeStamp],!(this.handMoves.length<_t)&&(this.handMoves=[],this.removeAttribute("data-bang-nocursor"),document.documentElement.removeAttribute("data-bang-remote")))};this.onStageClick=e=>{if(!this.inOverview||this.tween||this.swiped)return;let t=e.currentTarget.getBoundingClientRect(),n=Ge({x:e.clientX-t.left,y:e.clientY-t.top},this.pose,this.stageNow),s=this.frames.find(l=>qe(l.rect,n));if(!s)return;let a=this.path.stops[this.current.stop];if(a&&a.kind!=="overview"&&a.frame===s.id){this.overview(!1);return}let i=this.firstStop.get(s.id);i!==void 0&&this.goto(i,0)};this.onDragStart=e=>{e.target instanceof HTMLImageElement&&e.preventDefault()};this.onPointerCancel=()=>{this.swipeStart=null};this.onHashChange=()=>{let e=this.hashState();this.commit(e,{animate:!0,source:"hash",overview:!1})};this.onMotionChange=()=>this.applyMotionPreference();this.onSlotChange=()=>{this.applyTheme();for(let e of this.deckWarnings())x(`deck|${e}`,`[banger] ${e}`);this.initialized&&(this.buildPath(),this.current=E(this.current,this.path),this.commit(this.current,{animate:!1,source:"hash",overview:this.inOverview}))}}static{this.version=me}static{this.styles=[V(ve),b`
350
+ </div>`}function dt(){if(typeof BroadcastChannel>"u")return null;let n=new URL(location.href);return n.searchParams.set("mode","presenter"),window.open(n.toString(),"bang-presenter","popup,width=1100,height=720")}var mt=["smooth","swift","none"],Nt=240,It=720,_t=960,Ft=320,Ht=.08,Ut=400;function Dt(n){return[["\u2192 Space Enter PageDown","Next step or stop"],["\u2190 Backspace PageUp","Previous step or stop"],["Home / End","First / last stop"],["o Esc","Overview; click a frame to go there"],["p","Presenter window with notes"],...n?[["l","Next language"]]:[],["f","Full screen"],["?","This help"]]}var Wt=4e3,ae={w:1920,h:1080};function jt(){let n=new URLSearchParams(location.search).get("mode");return n==="export"||n==="presenter"?n:"live"}var qt=50,Kt=800,Vt=300,Bt=400,Gt=60,Xt=3,Zt=500;function gt(n){return n instanceof HTMLElement?n.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(n.tagName):!1}var S=class extends y{constructor(){super(...arguments);this.theme="light";this.format="slides";this.motion="smooth";this.ground=null;this.firstStop=new Map;this.spotted=[];this.stage=ae;this.statusText="";this.helpOpen=!1;this.elapsedMs=0;this.mode="live";this.path={stops:[]};this.notes=[];this.frames=[];this.frameMap={};this.current={stop:0,step:0};this.inOverview=!1;this.pose={cx:1920/2,cy:1080/2,zoom:1};this.tween=null;this.resolvePending=null;this.reducedMotion=!1;this.initialized=!1;this.sync=null;this.languageList=[];this.currentLanguage="";this.onFontsLoaded=()=>this.refreshPose();this.resizeObserver=null;this.startedAt=0;this.motionQuery=null;this.zeroedDurations=new Map;this.themeKey=null;this.themeVars=[];this.themeWarnings=[];this.onKeydown=e=>this.handleKey(e);this.swipeStart=null;this.swiped=!1;this.onPointerDown=e=>{!e.isPrimary||e.pointerType==="mouse"&&e.button!==0||gt(e.composedPath()[0]??e.target)||(this.swipeStart={id:e.pointerId,mouse:e.pointerType==="mouse",x:e.clientX,y:e.clientY,at:e.timeStamp})};this.onPointerUp=e=>{let t=this.swipeStart;if(!t||t.id!==e.pointerId)return;this.swipeStart=null;let r=e.clientX-t.x,s=e.clientY-t.y,i=e.timeStamp-t.at,a=t.mouse&&Math.abs(s)>Math.abs(r),l=a?s:r,m=a?r:s,[c,d]=t.mouse?[Bt,Vt]:[Kt,qt];i>c||Math.abs(l)<d||Math.abs(l)<Math.abs(m)*1.5||(t.mouse&&(window.getSelection()?.removeAllRanges(),document.documentElement.setAttribute("data-bang-remote",""),this.setAttribute("data-bang-nocursor","")),this.swiped=!0,setTimeout(()=>this.swiped=!1),l<0?this.next():this.prev())};this.handMoves=[];this.onPointerMove=e=>{if(e.pointerType!=="mouse"||e.buttons!==0||!this.hasAttribute("data-bang-nocursor"))return;let t=Math.hypot(e.movementX,e.movementY);t===0||t>=Gt||(this.handMoves=[...this.handMoves.filter(r=>e.timeStamp-r<Zt),e.timeStamp],!(this.handMoves.length<Xt)&&(this.handMoves=[],this.removeAttribute("data-bang-nocursor"),document.documentElement.removeAttribute("data-bang-remote")))};this.onStageClick=e=>{if(!this.inOverview||this.tween||this.swiped)return;let t=e.currentTarget.getBoundingClientRect(),r=Ze({x:e.clientX-t.left,y:e.clientY-t.top},this.pose,this.stageNow),s=this.frames.find(l=>je(l.rect,r));if(!s)return;let i=this.path.stops[this.current.stop];if(i&&i.kind!=="overview"&&i.frame===s.id){this.overview(!1);return}let a=this.firstStop.get(s.id);a!==void 0&&this.goto(a,0)};this.onDragStart=e=>{e.target instanceof HTMLImageElement&&e.preventDefault()};this.onPointerCancel=()=>{this.swipeStart=null};this.onHashChange=()=>{let e=this.hashState();this.commit(e,{animate:!0,source:"hash",overview:!1})};this.onMotionChange=()=>this.applyMotionPreference();this.onSlotChange=()=>{this.applyTheme();for(let e of this.deckWarnings())x(`deck|${e}`,`[banger] ${e}`);this.initialized&&(this.buildPath(),this.current=P(this.current,this.path),this.commit(this.current,{animate:!1,source:"hash",overview:this.inOverview}))}}static{this.version=me}static{this.styles=[V(ye),b`
344
351
  :host {
345
352
  display: block;
346
353
  position: fixed;
@@ -489,6 +496,55 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
489
496
  font-family: var(--bang-font-mono);
490
497
  font-size: 24px;
491
498
  }
499
+ .presenter-timer {
500
+ display: flex;
501
+ align-items: center;
502
+ gap: 12px;
503
+ }
504
+ .presenter-reset {
505
+ padding: 2px 10px;
506
+ font: inherit;
507
+ font-size: 16px;
508
+ cursor: pointer;
509
+ }
510
+ .presenter-account {
511
+ display: flex;
512
+ align-items: center;
513
+ gap: 12px;
514
+ font-size: 16px;
515
+ color: var(--bang-color-ink-muted);
516
+ }
517
+ .presenter-avatar {
518
+ position: relative;
519
+ display: inline-flex;
520
+ align-items: center;
521
+ justify-content: center;
522
+ width: 28px;
523
+ height: 28px;
524
+ border-radius: 50%;
525
+ overflow: hidden;
526
+ background: var(--bang-color-ink-muted);
527
+ color: var(--bang-color-paper);
528
+ font-size: 14px;
529
+ }
530
+ .presenter-avatar-img {
531
+ position: absolute;
532
+ inset: 0;
533
+ width: 100%;
534
+ height: 100%;
535
+ object-fit: cover;
536
+ }
537
+ .presenter-avatar-img[hidden] {
538
+ display: none;
539
+ }
540
+ .presenter-visibility {
541
+ padding: 0 8px;
542
+ border: 1px solid currentColor;
543
+ border-radius: 4px;
544
+ }
545
+ .presenter-visibility[data-visibility="unlisted"] {
546
+ border-style: dashed;
547
+ }
492
548
  .presenter-notes {
493
549
  flex: 1;
494
550
  overflow: auto;
@@ -507,8 +563,8 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
507
563
  font-size: 24px;
508
564
  cursor: pointer;
509
565
  }
510
- `]}get multilingual(){return this.languageList.length>1}connectedCallback(){super.connectedCallback(),this.mode=Tt(),this.setAttribute("data-mode",this.mode),this.initLanguage(),Re(this.mode),this.applyTheme(),this.motionQuery=window.matchMedia("(prefers-reduced-motion: reduce)"),this.motionQuery.addEventListener("change",this.onMotionChange),this.applyMotionPreference(),this.mode!=="export"&&(window.addEventListener("keydown",this.onKeydown),window.addEventListener("hashchange",this.onHashChange),window.addEventListener("pointerdown",this.onPointerDown),window.addEventListener("pointerup",this.onPointerUp),window.addEventListener("pointercancel",this.onPointerCancel),window.addEventListener("pointermove",this.onPointerMove),this.addEventListener("dragstart",this.onDragStart),typeof BroadcastChannel<"u"&&(this.sync=new oe,this.sync.onRemote(e=>{this.commit(E(e,this.path),{animate:!0,source:"remote",overview:!1})}),this.sync.onRemoteLanguage(e=>this.setLanguage(e,!1))),this.multilingual&&document.fonts?.addEventListener("loadingdone",this.onFontsLoaded)),this.mode==="presenter"&&(this.startedAt=Date.now(),this.clockTimer=setInterval(()=>{this.elapsedMs=Date.now()-this.startedAt},1e3))}initLanguage(){let{languages:e,invalid:t}=Se(this.getAttribute("languages"));for(let i of t)x(`languages|${i}`,`[banger] <bang-root languages> "${i}" is not a language tag such as "ja" or "en-US"; ignored`);if(this.languageList=e,e.length===0)return;let n=new URLSearchParams(location.search).get("lang"),{language:s,queryIgnored:a}=Me({languages:e,query:n,navigatorLanguages:navigator.languages??[navigator.language],useNavigator:this.mode!=="export"});a&&x(`lang|${n}`,`[banger] ?lang="${n}" is not one of the languages (${e.join(", ")}); ignored`),this.currentLanguage=s,Ae(e),this.setAttribute("lang",s),document.documentElement.lang=s}getLanguages(){return[...this.languageList]}getLanguage(){return this.currentLanguage}setLanguage(e,t){let n=X(e,this.languageList);if(!this.initialized||n===void 0||n===this.currentLanguage)return!1;this.currentLanguage=n,this.setAttribute("lang",n),document.documentElement.lang=n;for(let a of this.querySelectorAll("[step]"))a.requestUpdate?.();for(let a of this.frames)a.el.requestUpdate?.();this.buildPath(),this.commit(this.current,{animate:!1,source:"hash",overview:this.inOverview});let s=new URL(location.href);return s.searchParams.set("lang",n),history.replaceState(null,"",s.href),t&&this.sync?.sendLanguage(n),!0}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("hashchange",this.onHashChange),window.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerCancel),window.removeEventListener("pointermove",this.onPointerMove),this.motionQuery?.removeEventListener("change",this.onMotionChange),this.resizeObserver?.disconnect(),this.sync?.close(),this.sync=null,document.fonts?.removeEventListener("loadingdone",this.onFontsLoaded),clearInterval(this.clockTimer),clearTimeout(this.statusTimer),this.stopTween()}willUpdate(e){e.has("theme")&&this.applyTheme(),e.has("format")&&this.initialized&&(this.buildPath(),this.current=E(this.current,this.path),this.commit(this.current,{animate:!1,source:"hash",overview:this.inOverview}))}firstUpdated(e){this.buildPath(),this.mode!=="export"&&(this.resizeObserver=new ResizeObserver(()=>this.onResize()),this.resizeObserver.observe(this),this.onResize()),this.current=this.hashState(),this.initialized=!0,document.fonts?.ready.then(()=>this.refreshPose()),this.commit(this.current,{animate:!1,source:"hash",overview:!1})}render(){if(f(this,"theme",["light","dark","custom"],"light"),f(this,"format",["slides","map"],"slides"),this.mode==="presenter"){let e=this.path.stops[this.current.stop];return m`${it({stop:this.current.stop,stopCount:this.path.stops.length,step:this.current.step,steps:e?.steps??0,notes:this.notes[this.current.stop]??"",language:this.multilingual?this.currentLanguage:void 0,elapsedMs:this.elapsedMs,onPrev:()=>{this.prev()},onNext:()=>{this.next()}})}${this.renderHelp()}<div class="status" role="status">${this.statusText}</div>
511
- <div hidden><slot @slotchange=${this.onSlotChange}></slot></div>`}return m`<div class="viewport">
566
+ `]}get multilingual(){return this.languageList.length>1}connectedCallback(){super.connectedCallback(),this.mode=jt(),this.setAttribute("data-mode",this.mode),this.initLanguage(),Te(this.mode),this.applyTheme(),this.motionQuery=window.matchMedia("(prefers-reduced-motion: reduce)"),this.motionQuery.addEventListener("change",this.onMotionChange),this.applyMotionPreference(),this.mode!=="export"&&(window.addEventListener("keydown",this.onKeydown),window.addEventListener("hashchange",this.onHashChange),window.addEventListener("pointerdown",this.onPointerDown),window.addEventListener("pointerup",this.onPointerUp),window.addEventListener("pointercancel",this.onPointerCancel),window.addEventListener("pointermove",this.onPointerMove),this.addEventListener("dragstart",this.onDragStart),typeof BroadcastChannel<"u"&&(this.sync=new ie,this.sync.onRemote(e=>{this.commit(P(e,this.path),{animate:!0,source:"remote",overview:!1})}),this.sync.onRemoteLanguage(e=>this.setLanguage(e,!1))),this.multilingual&&document.fonts?.addEventListener("loadingdone",this.onFontsLoaded)),this.mode==="presenter"&&(this.startedAt=Date.now(),this.clockTimer=setInterval(()=>{this.elapsedMs=Date.now()-this.startedAt},1e3),this.loadPresenterStatus())}async loadPresenterStatus(){try{let e=await fetch("/__banger/status",{cache:"no-store"});if(!e.ok)return;let t=ct(await e.json());t&&(this.presenterStatus=t)}catch{}}resetTimer(){this.startedAt=Date.now(),this.elapsedMs=0}initLanguage(){let{languages:e,invalid:t}=Me(this.getAttribute("languages"));for(let a of t)x(`languages|${a}`,`[banger] <bang-root languages> "${a}" is not a language tag such as "ja" or "en-US"; ignored`);if(this.languageList=e,e.length===0)return;let r=new URLSearchParams(location.search).get("lang"),{language:s,queryIgnored:i}=$e({languages:e,query:r,navigatorLanguages:navigator.languages??[navigator.language],useNavigator:this.mode!=="export"});i&&x(`lang|${r}`,`[banger] ?lang="${r}" is not one of the languages (${e.join(", ")}); ignored`),this.currentLanguage=s,Re(e),this.setAttribute("lang",s),document.documentElement.lang=s}getLanguages(){return[...this.languageList]}getLanguage(){return this.currentLanguage}setLanguage(e,t){let r=X(e,this.languageList);if(!this.initialized||r===void 0||r===this.currentLanguage)return!1;this.currentLanguage=r,this.setAttribute("lang",r),document.documentElement.lang=r;for(let i of this.querySelectorAll("[step]"))i.requestUpdate?.();for(let i of this.frames)i.el.requestUpdate?.();this.buildPath(),this.commit(this.current,{animate:!1,source:"hash",overview:this.inOverview});let s=new URL(location.href);return s.searchParams.set("lang",r),history.replaceState(null,"",s.href),t&&this.sync?.sendLanguage(r),!0}disconnectedCallback(){super.disconnectedCallback(),window.removeEventListener("keydown",this.onKeydown),window.removeEventListener("hashchange",this.onHashChange),window.removeEventListener("pointerdown",this.onPointerDown),window.removeEventListener("pointerup",this.onPointerUp),window.removeEventListener("pointercancel",this.onPointerCancel),window.removeEventListener("pointermove",this.onPointerMove),this.motionQuery?.removeEventListener("change",this.onMotionChange),this.resizeObserver?.disconnect(),this.sync?.close(),this.sync=null,document.fonts?.removeEventListener("loadingdone",this.onFontsLoaded),clearInterval(this.clockTimer),clearTimeout(this.statusTimer),this.stopTween()}willUpdate(e){e.has("theme")&&this.applyTheme(),e.has("motion")&&this.applyMotionPreference(),e.has("format")&&this.initialized&&(this.buildPath(),this.current=P(this.current,this.path),this.commit(this.current,{animate:!1,source:"hash",overview:this.inOverview}))}firstUpdated(e){this.buildPath(),this.mode!=="export"&&(this.resizeObserver=new ResizeObserver(()=>this.onResize()),this.resizeObserver.observe(this),this.onResize()),this.current=this.hashState(),this.initialized=!0,document.fonts?.ready.then(()=>this.refreshPose()),this.commit(this.current,{animate:!1,source:"hash",overview:!1})}render(){if(f(this,"theme",["light","dark","custom"],"light"),f(this,"format",["slides","map"],"slides"),f(this,"motion",mt,"smooth"),this.mode==="presenter"){let e=this.path.stops[this.current.stop];return h`${ht({stop:this.current.stop,stopCount:this.path.stops.length,step:this.current.step,steps:e?.steps??0,notes:this.notes[this.current.stop]??"",language:this.multilingual?this.currentLanguage:void 0,elapsedMs:this.elapsedMs,status:this.presenterStatus,onPrev:()=>{this.prev()},onNext:()=>{this.next()},onResetTimer:()=>this.resetTimer()})}${this.renderHelp()}<div class="status" role="status">${this.statusText}</div>
567
+ <div hidden><slot @slotchange=${this.onSlotChange}></slot></div>`}return h`<div class="viewport">
512
568
  <div class="stage" style="width:${this.stage.w}px;height:${this.stage.h}px" @click=${this.onStageClick}>
513
569
  <div class="clip">
514
570
  <div class="canvas">${this.renderGround()}<slot @slotchange=${this.onSlotChange}></slot></div>
@@ -516,16 +572,16 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
516
572
  </div>
517
573
  </div>
518
574
  ${this.renderHelp()}
519
- <div class="status" role="status">${this.statusText}</div>`}renderHelp(){return this.helpOpen?m`<div class="help" @click=${()=>this.helpOpen=!1}>
575
+ <div class="status" role="status">${this.statusText}</div>`}renderHelp(){return this.helpOpen?h`<div class="help" @click=${()=>this.helpOpen=!1}>
520
576
  <div class="help-panel" role="dialog" aria-label="Keyboard shortcuts">
521
577
  <h2>Keyboard shortcuts</h2>
522
578
  <dl>
523
- ${Rt(this.multilingual).map(([e,t])=>m`<dt>${e}</dt><dd>${t}</dd>`)}
579
+ ${Dt(this.multilingual).map(([e,t])=>h`<dt>${e}</dt><dd>${t}</dd>`)}
524
580
  </dl>
525
581
  </div>
526
- </div>`:le}renderGround(){let e=this.ground;if(!e)return le;let{rect:t}=e;return m`<div class="ground" style="left:${t.x}px;top:${t.y}px;width:${t.w}px;height:${t.h}px">
582
+ </div>`:ce}renderGround(){let e=this.ground;if(!e)return ce;let{rect:t}=e;return h`<div class="ground" style="left:${t.x}px;top:${t.y}px;width:${t.w}px;height:${t.h}px">
527
583
  <svg class="roads" viewBox="${t.x} ${t.y} ${t.w} ${t.h}" aria-hidden="true">
528
- ${e.roads.map(n=>fe`<line class="road" x1=${n.x1} y1=${n.y1} x2=${n.x2} y2=${n.y2}></line><line class="road-center" x1=${n.x1} y1=${n.y1} x2=${n.x2} y2=${n.y2}></line>`)}
584
+ ${e.roads.map(r=>be`<line class="road" x1=${r.x1} y1=${r.y1} x2=${r.x2} y2=${r.y2}></line><line class="road-center" x1=${r.x1} y1=${r.y1} x2=${r.x2} y2=${r.y2}></line>`)}
529
585
  </svg>
530
- </div>`}applyTheme(){let e=Qe(this),t=()=>{for(let d of this.themeVars)this.style.removeProperty(d);this.themeVars=[]},n=d=>{this.themeWarnings=d;for(let g of d)x(`theme|${g}`,`[banger] ${g}`)},s=this.getAttribute("theme");if(s!=="custom"){t();let d=`\0ignored|${s}|${e===null?"none":"present"}`;if(d===this.themeKey)return;this.themeKey=d,this.applyFrameTones(D[s==="dark"?"dark":"light"]),n(e===null?[]:['theme: <bang-theme> is ignored unless theme="custom"']);return}let a=e??"\0none";if(a===this.themeKey)return;this.themeKey=a;let i=[],l={};if(e===null)i.push('theme: theme="custom" needs a <bang-theme> child with a JSON script; the light theme is used');else{let d=ye(e);i.push(...d.warnings),l=d.definition??{}}let u=xe(l);i.push(...u.warnings),t();let c={};for(let[d,g]of Object.entries(u.colors))c[`--bang-color-${d}`]=g;for(let[d,g]of Object.entries(u.fonts))c[`--bang-font-${d}`]=g;u.ground&&(c["--bang-ground"]=u.ground),Object.assign(c,u.vars);for(let[d,g]of Object.entries(c))this.style.setProperty(d,g);this.themeVars=Object.keys(c),this.applyFrameTones(u.colors),u.fontsRequest&&ze(u.fontsRequest),n(i)}languageWarnings(){return this.languageList.length===0||this.currentLanguage!==this.languageList[0]?[]:ot(this,this.languageList)}deckWarnings(){let e=[],t=n=>{let s=n?.getAttribute("tone");return s==="accent"||s==="inverse"?s:null};for(let n of this.querySelectorAll("bang-frame[ground=cover]")){let s=k(n),a=t(n);a?e.push(`${s}: ground="cover" is ignored because tone="${a}" is set; the tone ground is used`):this.style.getPropertyValue("--bang-cover-ground")===""&&e.push(`${s}: ground="cover" needs theme="custom" with a coverGradient; the normal ground is used`)}for(let n of this.querySelectorAll("bang-card[kind=band]")){let s=k(n),a=t(n.closest("bang-frame"));this.style.getPropertyValue("--bang-band-ground")===""?e.push(`${s}: kind="band" needs theme="custom" with a bandGradient; the surface color is used`):a&&e.push(`${s}: kind="band" inside a frame with tone="${a}" uses the surface color`)}return e}applyFrameTones(e){for(let t of G)for(let[n,s]of Object.entries(we(e,t)))this.style.setProperty(`--bang-frame-${t}-${n}`,s)}applyMotionPreference(){this.reducedMotion=this.motionQuery?.matches??!1,this.mode==="export"||this.reducedMotion?this.style.setProperty("--bang-duration-fast","0s"):this.style.removeProperty("--bang-duration-fast")}onResize(){if(this.mode==="export")return;let e=Be({w:this.clientWidth||1920,h:this.clientHeight||1080});e.w===this.stage.w&&e.h===this.stage.h||(this.stage=e,this.initialized&&(this.stopTween(),this.pose=this.targetPose(this.current,this.inOverview),this.applyPose(this.pose),this.applyClip()))}get stageNow(){return this.mode==="export"?ae:this.stage}get isMap(){return this.format==="map"}buildPath(){for(let c of this.spotted)c.removeAttribute("data-bang-dim");this.spotted=[];let e=[...this.querySelectorAll("bang-frame")],t=new Set,n=[];e.forEach((c,d)=>{let g=c.id;g&&t.has(g)&&(x(`dupframe|${g}`,`[banger] duplicate bang-frame id "${g}"; the first one is used`),g=""),g&&t.add(g),n.push({id:g||`\0${d}`,at:Fe(c.getAttribute("at")),span:He(c.getAttribute("span")),el:c})});let s=this.isMap,a=je(n,s?$t:Mt);this.frameMap=a,this.frames=n.map(c=>({el:c.el,id:c.id,rect:a[c.id]}));for(let c of this.frames)s?c.el.setAttribute("data-bang-format","map"):c.el.removeAttribute("data-bang-format"),c.el.style.setProperty("--bang-frame-x",`${c.rect.x}px`),c.el.style.setProperty("--bang-frame-y",`${c.rect.y}px`),c.el.style.setProperty("--bang-frame-w",`${c.rect.w}px`),c.el.style.setProperty("--bang-frame-h",`${c.rect.h}px`);this.ground=s?Ht(this.frames):null;let i=[],l=[],u=new Set;for(let c of this.querySelectorAll("bang-path > bang-stop")){let d=Ze(c,this.currentLanguage),g=d.stop;if(d.auto&&g.kind!=="overview"){let ie=this.frames.find(ht=>ht.id===g.frame);ie&&!u.has(ie.id)&&(g={...g,steps:pt(ie.el)})}g.kind!=="overview"&&g.frame&&u.add(g.frame),g.kind!=="overview"&&!(g.frame&&t.has(g.frame))&&(x(`stopframe|${g.frame}`,`[banger] <bang-stop frame="${g.frame}"> does not match any bang-frame; treated as overview`),g={kind:"overview",steps:g.steps}),i.push(g),l.push(d.notes)}this.path={stops:i},this.notes=l,this.firstStop=new Map,i.forEach((c,d)=>{c.kind!=="overview"&&c.frame&&!this.firstStop.has(c.frame)&&this.firstStop.set(c.frame,d)}),this.warnShortSteps()}warnShortSteps(){for(let e of this.frames){if(e.id.startsWith("\0"))continue;let t=this.path.stops.filter(a=>a.kind!=="overview"&&a.frame===e.id).map(a=>a.steps);if(t.length===0)continue;let n=Math.max(...t),s=pt(e.el);s>n&&x(`steps|${e.id}|${s}|${n}`,`[banger] frame "${e.id}" needs ${s} steps but its stops provide at most ${n}`)}}hashState(){let e=Le(location.hash,this.path),t=new URLSearchParams(location.hash.replace(/^#/,"")),n=t.get("stop"),s=t.get("step");return(n!==null&&n!==String(e.stop)||s!==null&&s!=="last"&&s!==String(e.step))&&x(`hash|${location.hash}`,`[banger] hash "${location.hash}" is out of range; using "${J(e)}"`),e}allRects(){return this.frames.map(e=>e.rect)}rectFor(e,t){let n=this.allRects(),s=n.length>0?Q(n):{x:0,y:0,w:1920,h:1080};this.isMap&&n.length>0&&(s=Y(s,kt));let a=this.path.stops[e.stop];if(t||!a||a.kind==="overview"||a.frame===void 0)return s;let i=this.frameMap[a.frame];if(!i)return null;if(a.kind==="focus"&&a.focus){let l=this.focusRect(a.frame,a.focus);return l?Ke(l,i,this.stageNow):i}return a.kind==="region"&&a.region?he(i,a.region):i}focusTarget(e,t){let n=this.frames.find(a=>a.id===e);if(!n)return null;let s=n.el.querySelector(`#${CSS.escape(t)}`);return s?{entry:n,target:s}:(x(`focus|${e}|${t}`,`[banger] <bang-stop focus="${t}"> does not match an element inside frame "${e}"; showing the whole frame`),null)}focusRect(e,t){let n=this.focusTarget(e,t);if(!n)return null;let{entry:s,target:a}=n,i=s.el.getBoundingClientRect(),l=a.getBoundingClientRect();if(i.width===0||l.width===0||l.height===0)return null;let u=i.width/s.rect.w,c={x:s.rect.x+(l.left-i.left)/u,y:s.rect.y+(l.top-i.top)/u,w:l.width/u,h:l.height/u};return Y(c,Math.max(c.w,c.h*(1920/1080))*Pt)}refreshPose(){if(!this.initialized||this.tween)return;let e=this.targetPose(this.current,this.inOverview),t=this.pose;Math.abs(e.cx-t.cx)<.5&&Math.abs(e.cy-t.cy)<.5&&Math.abs(e.zoom/t.zoom-1)<1e-4||(this.pose=e,this.applyPose(e),this.applyClip())}targetPose(e,t){let n=this.rectFor(e,t)??{x:0,y:0,w:1920,h:1080};return L(n,this.stageNow)}canvasEl(){return this.renderRoot.querySelector(".canvas")}applyPose(e){let t=this.canvasEl();t&&(t.style.transform=ue(e,this.stageNow,this.mode!=="export").css),this.applyNearness(e)}applyNearness(e){let t=this.stageNow;for(let n of this.frames){let a=Ue(n.rect,e,t).toFixed(3);n.el.style.getPropertyValue("--bang-near")!==a&&n.el.style.setProperty("--bang-near",a)}}applyClip(){let e=this.renderRoot.querySelector(".clip");if(!e)return;let t=this.mode==="export"&&!this.isMap?this.rectFor(this.current,this.inOverview):null;if(!t){e.style.clipPath="none";return}let n=L(t,ae),s=De(t,n,ae);e.style.clipPath=`inset(${s.top}px ${s.right}px ${s.bottom}px ${s.left}px)`}currentPose(){return this.tween?de(this.tween,performance.now()):this.pose}stopTween(){clearTimeout(this.tweenTimer),this.tweenFrame!==void 0&&cancelAnimationFrame(this.tweenFrame),this.tweenTimer=void 0,this.tweenFrame=void 0,this.tween=null;let e=this.canvasEl();e&&(e.style.willChange="")}settlePending(){let e=this.resolvePending;this.resolvePending=null,e?.()}moveCamera(e,t){let n=this.currentPose();if(this.stopTween(),this.settlePending(),!t||this.mode!=="live"||this.reducedMotion||!this.canvasEl())return this.pose=e,this.applyPose(e),Promise.resolve();let s=Ve(n,e,performance.now(),this.stageNow);return this.tween=s,this.canvasEl().style.willChange="transform",new Promise(a=>{this.resolvePending=a;let i=()=>{this.tween===s&&(this.stopTween(),this.pose=s.to,this.applyPose(s.to),this.settlePending(),this.refreshPose())};this.tweenTimer=setTimeout(i,s.duration+100);let l=()=>{if(this.tween!==s)return;let u=performance.now();if(u-s.start>=s.duration){i();return}this.applyPose(de(s,u)),this.tweenFrame=requestAnimationFrame(l)};this.tweenFrame=requestAnimationFrame(l)})}applySteps(){let e=this.isMap;for(let t of this.frames){t.el.toggleAttribute("data-bang-fog",e&&(this.firstStop.get(t.id)??-1)>this.current.stop);let n=Ne(t.id,this.current,this.path);t.el.currentStep=n;for(let s of t.el.querySelectorAll("[data-step]")){let a=Number(s.getAttribute("data-step"));Number.isFinite(a)&&s.toggleAttribute("data-bang-hidden",n<a)}for(let s of t.el.querySelectorAll("[step]"))"frameStep"in s&&(s.frameStep=n)}this.applySpotlight()}applySpotlight(){let e=this.spotted;this.spotted=[];let t=this.path.stops[this.current.stop],n=!this.inOverview&&t?.kind==="focus"&&t.frame&&t.focus?this.focusTarget(t.frame,t.focus):null;if(n){let{entry:a,target:i}=n;for(let l of this.frames)l!==a&&this.spotted.push(l.el);for(let l=i;l!==a.el&&l.parentElement;l=l.parentElement)for(let u of l.parentElement.children)u!==l&&this.spotted.push(u)}let s=new Set(this.spotted);for(let a of e)s.has(a)||(a.removeAttribute("data-bang-dim"),setTimeout(()=>{a.hasAttribute("data-bang-dim")||a.removeAttribute("data-bang-spot")},At));for(let a of this.spotted)a.setAttribute("data-bang-spot",""),a.setAttribute("data-bang-dim","")}applyInert(){if(this.mode==="export")return;let e=this.path.stops[this.current.stop],t=this.inOverview||!e||e.kind==="overview"?null:e.frame;for(let n of this.frames)n.el.inert=n.id!==t}commit(e,t){let n=E(e,this.path),s=this.rectFor(n,t.overview);if(!s)return console.warn("[banger] no target rectangle for the requested state; ignoring it"),Promise.resolve();this.current=n,this.inOverview=t.overview,this.toggleAttribute("data-bang-overview",t.overview),this.applySteps(),this.applyInert();let a=this.moveCamera(L(s,this.stageNow),t.animate);return this.applyClip(),t.source!=="hash"&&location.hash!==J(n)&&history.replaceState(null,"",J(n)),this.dispatchEvent(new CustomEvent("bang:statechange",{detail:{stop:n.stop,step:n.step,overview:t.overview},bubbles:!0,composed:!0})),t.source==="local"&&this.sync?.send(n),this.requestUpdate(),a}async whenInitialized(){this.initialized||await this.updateComplete}async goto(e,t=0){await this.whenInitialized();let n=this.path.stops[Math.min(Math.max(e,0),this.path.stops.length-1)]?.steps??0;return this.commit({stop:e,step:t==="last"?n:t},{animate:!0,source:"local",overview:!1})}async next(){return await this.whenInitialized(),this.commit(Ce(this.current,this.path),{animate:!0,source:"local",overview:!1})}async prev(){return await this.whenInitialized(),this.commit(Oe(this.current,this.path),{animate:!0,source:"local",overview:!1})}async overview(e){await this.whenInitialized();let t=e??!this.inOverview;return await this.commit(this.current,{animate:!0,source:"local",overview:t}),this.inOverview}getState(){return{...this.current}}getPath(){return this.path.stops.map((e,t)=>{let n=this.rectFor({stop:t,step:0},!1)??{x:0,y:0,w:1920,h:1080};return{index:t,kind:e.kind,frame:e.kind==="overview"?void 0:e.frame,steps:e.steps,notes:this.notes[t]??"",zoom:L(n,this.stageNow).zoom,rect:n}})}async ready(e){let t=await Pe(this,{...e,extraWarnings:[...this.themeWarnings,...this.deckWarnings(),...nt(this),...rt(this.frames),...this.languageWarnings()]});this.refreshPose();let n=new Set([...t.warnings,...st(this.frames)]);return{...t,warnings:[...n]}}showStatus(e){this.statusText=e,clearTimeout(this.statusTimer),this.statusTimer=setTimeout(()=>{this.statusText=""},zt)}handleKey(e){if(e.ctrlKey||e.metaKey||e.altKey||e.defaultPrevented||ct(e.composedPath()[0]??e.target))return;let t=this.path.stops.length-1;if(this.helpOpen&&(e.key==="Escape"||e.key==="?")){e.preventDefault(),this.helpOpen=!1;return}let n=null;switch(e.key){case"?":n=()=>this.helpOpen=!0;break;case"ArrowRight":case" ":case"PageDown":case"Enter":n=()=>this.next();break;case"ArrowLeft":case"Backspace":case"PageUp":n=()=>this.prev();break;case"Home":n=()=>this.goto(0,0);break;case"End":n=()=>this.goto(Math.max(t,0),"last");break;case"Escape":case"o":n=()=>this.overview();break;case"p":if(this.mode==="presenter")break;n=()=>{lt()||this.showStatus("Presenter view could not be opened (popup blocked or unsupported).")};break;case"l":if(!this.multilingual)break;n=()=>this.setLanguage($e(this.languageList,this.currentLanguage),!0);break;case"f":n=()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()).catch(()=>{})};break}n&&(e.preventDefault(),n())}};p([h()],M.prototype,"theme",2),p([h({reflect:!0})],M.prototype,"format",2),p([h()],M.prototype,"languages",2),p([F()],M.prototype,"ground",2),p([F()],M.prototype,"stage",2),p([F()],M.prototype,"statusText",2),p([F()],M.prototype,"helpOpen",2),p([F()],M.prototype,"elapsedMs",2);function Ht(r){if(r.length===0)return null;let o=Y(Q(r.map(s=>s.rect)),Et),e=new Map(r.map(s=>[s.id,s])),t=new Set,n=[];for(let s of r)for(let a of(s.el.getAttribute("link")??"").split(/\s+/).filter(Boolean)){let i=e.get(a);if(!i){x(`link|${s.id}|${a}`,`[banger] bang-frame "${s.id}" links to "${a}", which is not a bang-frame id; no road is drawn`);continue}if(i===s){x(`link|${s.id}|${a}`,`[banger] bang-frame "${s.id}" links to itself; no road is drawn`);continue}let l=[s.id,a].sort().join("\0");t.has(l)||(t.add(l),n.push({x1:s.rect.x+s.rect.w/2,y1:s.rect.y+s.rect.h/2,x2:i.rect.x+i.rect.w/2,y2:i.rect.y+i.rect.h/2}))}return{rect:o,roads:n}}function pt(r){let o=0;for(let e of r.querySelectorAll("*")){if(!T(e))continue;let t=Number(e.getAttribute("data-step"));e.hasAttribute("data-step")&&Number.isFinite(t)&&(o=Math.max(o,t));let n=e.stepCount;typeof n=="number"&&(o=Math.max(o,n))}return o}v("bang-root",M);export{O as BangCard,K as BangChart,C as BangColumns,y as BangElement,S as BangFrame,B as BangFree,I as BangImage,ne as BangList,te as BangNotes,ee as BangPath,M as BangRoot,_ as BangShape,W as BangStack,A as BangStat,P as BangStop,q as BangText,se as BangTheme,j as BangTitle,z as FRAME_HEIGHT,R as FRAME_WIDTH,U as StepAware,Q as boundsOf,E as clamp,De as clipFor,qe as contains,mt as durationFor,gt as ease,dt as frameRect,Ne as frameStep,Y as inflate,je as layoutFrames,Ue as nearness,Ce as next,Fe as parseAt,Le as parseHash,Ie as parseRegion,He as parseSpan,L as poseFor,Oe as prev,ft as pullBackFor,he as regionRect,Ve as retarget,de as sample,J as serializeHash,Be as stageSize,Ge as stageToCanvas,bt as startTween,jt as targetFor,ue as toTransform,me as version,Ke as viewInside};
586
+ </div>`}applyTheme(){let e=et(this),t=()=>{for(let d of this.themeVars)this.style.removeProperty(d);this.themeVars=[]},r=d=>{this.themeWarnings=d;for(let g of d)x(`theme|${g}`,`[banger] ${g}`)},s=this.getAttribute("theme");if(s!=="custom"){t();let d=`\0ignored|${s}|${e===null?"none":"present"}`;if(d===this.themeKey)return;this.themeKey=d,this.applyFrameTones(B[s==="dark"?"dark":"light"]),r(e===null?[]:['theme: <bang-theme> is ignored unless theme="custom"']);return}let i=e??"\0none";if(i===this.themeKey)return;this.themeKey=i;let a=[],l={};if(e===null)a.push('theme: theme="custom" needs a <bang-theme> child with a JSON script; the light theme is used');else{let d=xe(e);a.push(...d.warnings),l=d.definition??{}}let m=we(l);a.push(...m.warnings),t();let c={};for(let[d,g]of Object.entries(m.colors))c[`--bang-color-${d}`]=g;for(let[d,g]of Object.entries(m.fonts))c[`--bang-font-${d}`]=g;m.ground&&(c["--bang-ground"]=m.ground),Object.assign(c,m.vars);for(let[d,g]of Object.entries(c))this.style.setProperty(d,g);this.themeVars=Object.keys(c),this.applyFrameTones(m.colors),m.fontsRequest&&ze(m.fontsRequest),r(a)}languageWarnings(){return this.languageList.length===0||this.currentLanguage!==this.languageList[0]?[]:at(this,this.languageList)}deckWarnings(){let e=[],t=r=>{let s=r?.getAttribute("tone");return s==="accent"||s==="inverse"?s:null};for(let r of this.querySelectorAll("bang-frame[ground=cover]")){let s=k(r),i=t(r);i?e.push(`${s}: ground="cover" is ignored because tone="${i}" is set; the tone ground is used`):this.style.getPropertyValue("--bang-cover-ground")===""&&e.push(`${s}: ground="cover" needs theme="custom" with a coverGradient; the normal ground is used`)}for(let r of this.querySelectorAll("bang-card[kind=band]")){let s=k(r),i=t(r.closest("bang-frame"));this.style.getPropertyValue("--bang-band-ground")===""?e.push(`${s}: kind="band" needs theme="custom" with a bandGradient; the surface color is used`):i&&e.push(`${s}: kind="band" inside a frame with tone="${i}" uses the surface color`)}return e}applyFrameTones(e){for(let t of G)for(let[r,s]of Object.entries(Se(e,t)))this.style.setProperty(`--bang-frame-${t}-${r}`,s)}applyMotionPreference(){this.reducedMotion=this.motionQuery?.matches??!1;let e=this.mode==="live"&&this.authoredMotion()==="none";this.zeroDuration("--bang-duration-fast",this.mode==="export"||this.reducedMotion||e),this.zeroDuration("--bang-duration-slow",e)}zeroDuration(e,t){if(t){this.zeroedDurations.has(e)||(this.zeroedDurations.set(e,this.style.getPropertyValue(e)),this.style.setProperty(e,"0s"));return}let r=this.zeroedDurations.get(e);r!==void 0&&(this.zeroedDurations.delete(e),r?this.style.setProperty(e,r):this.style.removeProperty(e))}authoredMotion(){return mt.includes(this.motion)?this.motion:"smooth"}effectiveMotion(){return this.mode!=="live"||this.reducedMotion?"none":this.authoredMotion()}onResize(){if(this.mode==="export")return;let e=Ve({w:this.clientWidth||1920,h:this.clientHeight||1080});e.w===this.stage.w&&e.h===this.stage.h||(this.stage=e,this.initialized&&(this.stopTween(),this.settlePending(),this.pose=this.targetPose(this.current,this.inOverview),this.applyPose(this.pose),this.applyClip()))}get stageNow(){return this.mode==="export"?ae:this.stage}get isMap(){return this.format==="map"}buildPath(){for(let c of this.spotted)c.removeAttribute("data-bang-dim");this.spotted=[];let e=[...this.querySelectorAll("bang-frame")],t=new Set,r=[];e.forEach((c,d)=>{let g=c.id;g&&t.has(g)&&(x(`dupframe|${g}`,`[banger] duplicate bang-frame id "${g}"; the first one is used`),g=""),g&&t.add(g),r.push({id:g||`\0${d}`,at:He(c.getAttribute("at")),span:Ue(c.getAttribute("span")),el:c})});let s=this.isMap,i=We(r,s?It:Nt);this.frameMap=i,this.frames=r.map(c=>({el:c.el,id:c.id,rect:i[c.id]}));for(let c of this.frames)s?c.el.setAttribute("data-bang-format","map"):c.el.removeAttribute("data-bang-format"),c.el.style.setProperty("--bang-frame-x",`${c.rect.x}px`),c.el.style.setProperty("--bang-frame-y",`${c.rect.y}px`),c.el.style.setProperty("--bang-frame-w",`${c.rect.w}px`),c.el.style.setProperty("--bang-frame-h",`${c.rect.h}px`);this.ground=s?Jt(this.frames):null;let a=[],l=[],m=new Set;for(let c of this.querySelectorAll("bang-path > bang-stop")){let d=Qe(c,this.currentLanguage),g=d.stop;if(d.auto&&g.kind!=="overview"){let le=this.frames.find(bt=>bt.id===g.frame);le&&!m.has(le.id)&&(g={...g,steps:ft(le.el)})}g.kind!=="overview"&&g.frame&&m.add(g.frame),g.kind!=="overview"&&!(g.frame&&t.has(g.frame))&&(x(`stopframe|${g.frame}`,`[banger] <bang-stop frame="${g.frame}"> does not match any bang-frame; treated as overview`),g={kind:"overview",steps:g.steps}),a.push(g),l.push(d.notes)}this.path={stops:a},this.notes=l,this.firstStop=new Map,a.forEach((c,d)=>{c.kind!=="overview"&&c.frame&&!this.firstStop.has(c.frame)&&this.firstStop.set(c.frame,d)}),this.warnShortSteps()}warnShortSteps(){for(let e of this.frames){if(e.id.startsWith("\0"))continue;let t=this.path.stops.filter(i=>i.kind!=="overview"&&i.frame===e.id).map(i=>i.steps);if(t.length===0)continue;let r=Math.max(...t),s=ft(e.el);s>r&&x(`steps|${e.id}|${s}|${r}`,`[banger] frame "${e.id}" needs ${s} steps but its stops provide at most ${r}`)}}hashState(){let e=Oe(location.hash,this.path),t=new URLSearchParams(location.hash.replace(/^#/,"")),r=t.get("stop"),s=t.get("step");return(r!==null&&r!==String(e.stop)||s!==null&&s!=="last"&&s!==String(e.step))&&x(`hash|${location.hash}`,`[banger] hash "${location.hash}" is out of range; using "${J(e)}"`),e}allRects(){return this.frames.map(e=>e.rect)}rectFor(e,t){let r=this.allRects(),s=r.length>0?Y(r):{x:0,y:0,w:1920,h:1080};this.isMap&&r.length>0&&(s=ee(s,Ft));let i=this.path.stops[e.stop];if(t||!i||i.kind==="overview"||i.frame===void 0)return s;let a=this.frameMap[i.frame];if(!a)return null;if(i.kind==="focus"&&i.focus){let l=this.focusRect(i.frame,i.focus);return l?Ke(l,a,this.stageNow):a}return i.kind==="region"&&i.region?ue(a,i.region):a}focusTarget(e,t){let r=this.frames.find(i=>i.id===e);if(!r)return null;let s=r.el.querySelector(`#${CSS.escape(t)}`);return s?{entry:r,target:s}:(x(`focus|${e}|${t}`,`[banger] <bang-stop focus="${t}"> does not match an element inside frame "${e}"; showing the whole frame`),null)}focusRect(e,t){let r=this.focusTarget(e,t);if(!r)return null;let{entry:s,target:i}=r,a=s.el.getBoundingClientRect(),l=i.getBoundingClientRect();if(a.width===0||l.width===0||l.height===0)return null;let m=a.width/s.rect.w,c={x:s.rect.x+(l.left-a.left)/m,y:s.rect.y+(l.top-a.top)/m,w:l.width/m,h:l.height/m};return ee(c,Math.max(c.w,c.h*(1920/1080))*Ht)}refreshPose(){if(!this.initialized||this.tween)return;let e=this.targetPose(this.current,this.inOverview),t=this.pose;Math.abs(e.cx-t.cx)<.5&&Math.abs(e.cy-t.cy)<.5&&Math.abs(e.zoom/t.zoom-1)<1e-4||(this.pose=e,this.applyPose(e),this.applyClip())}targetPose(e,t){let r=this.rectFor(e,t)??{x:0,y:0,w:1920,h:1080};return O(r,this.stageNow)}canvasEl(){return this.renderRoot.querySelector(".canvas")}applyPose(e){let t=this.canvasEl();t&&(t.style.transform=de(e,this.stageNow,this.mode!=="export").css),this.applyNearness(e)}applyNearness(e){let t=this.stageNow;for(let r of this.frames){let i=qe(r.rect,e,t).toFixed(3);r.el.style.getPropertyValue("--bang-near")!==i&&r.el.style.setProperty("--bang-near",i)}}applyClip(){let e=this.renderRoot.querySelector(".clip");if(!e)return;let t=this.mode==="export"&&!this.isMap?this.rectFor(this.current,this.inOverview):null;if(!t){e.style.clipPath="none";return}let r=O(t,ae),s=Xe(t,r,ae);e.style.clipPath=`inset(${s.top}px ${s.right}px ${s.bottom}px ${s.left}px)`}currentPose(){return this.tween?he(this.tween,performance.now()):this.pose}stopTween(){clearTimeout(this.tweenTimer),this.tweenFrame!==void 0&&cancelAnimationFrame(this.tweenFrame),this.tweenTimer=void 0,this.tweenFrame=void 0,this.tween=null;let e=this.canvasEl();e&&(e.style.willChange="")}settlePending(){let e=this.resolvePending;this.resolvePending=null,e?.()}moveCamera(e,t,r){let s=this.effectiveMotion(),i=this.currentPose();if(this.stopTween(),this.settlePending(),!t||s==="none"||!this.canvasEl())return this.pose=e,this.applyPose(e),Promise.resolve();let a=Ge(i,e,performance.now(),this.stageNow,{...r,motion:s});return this.tween=a,this.canvasEl().style.willChange="transform",new Promise(l=>{this.resolvePending=l;let m=()=>{this.tween===a&&(this.stopTween(),this.pose=a.to,this.applyPose(a.to),this.settlePending(),this.refreshPose())};this.tweenTimer=setTimeout(m,a.duration+100);let c=()=>{if(this.tween!==a)return;let d=performance.now();if(d-a.start>=a.duration){m();return}this.applyPose(he(a,d)),this.tweenFrame=requestAnimationFrame(c)};this.tweenFrame=requestAnimationFrame(c)})}applySteps(){let e=this.isMap;for(let t of this.frames){t.el.toggleAttribute("data-bang-fog",e&&(this.firstStop.get(t.id)??-1)>this.current.stop);let r=Ie(t.id,this.current,this.path);t.el.currentStep=r;for(let s of t.el.querySelectorAll("[data-step]")){let i=Number(s.getAttribute("data-step"));Number.isFinite(i)&&s.toggleAttribute("data-bang-hidden",r<i)}for(let s of t.el.querySelectorAll("[step]"))"frameStep"in s&&(s.frameStep=r)}this.applySpotlight()}applySpotlight(){let e=this.spotted;this.spotted=[];let t=this.path.stops[this.current.stop],r=!this.inOverview&&t?.kind==="focus"&&t.frame&&t.focus?this.focusTarget(t.frame,t.focus):null;if(r){let{entry:i,target:a}=r;for(let l of this.frames)l!==i&&this.spotted.push(l.el);for(let l=a;l!==i.el&&l.parentElement;l=l.parentElement)for(let m of l.parentElement.children)m!==l&&this.spotted.push(m)}let s=new Set(this.spotted);for(let i of e)s.has(i)||(i.removeAttribute("data-bang-dim"),setTimeout(()=>{i.hasAttribute("data-bang-dim")||i.removeAttribute("data-bang-spot")},Ut));for(let i of this.spotted)i.setAttribute("data-bang-spot",""),i.setAttribute("data-bang-dim","")}applyInert(){if(this.mode==="export")return;let e=this.path.stops[this.current.stop],t=this.inOverview||!e||e.kind==="overview"?null:e.frame;for(let r of this.frames)r.el.inert=r.id!==t}commit(e,t){let r=P(e,this.path),s=this.rectFor(r,t.overview);if(!s)return console.warn("[banger] no target rectangle for the requested state; ignoring it"),Promise.resolve();this.current=r,this.inOverview=t.overview,this.toggleAttribute("data-bang-overview",t.overview),this.applySteps(),this.applyInert();let i=this.moveCamera(O(s,this.stageNow),t.animate);return this.applyClip(),t.source!=="hash"&&location.hash!==J(r)&&history.replaceState(null,"",J(r)),this.dispatchEvent(new CustomEvent("bang:statechange",{detail:{stop:r.stop,step:r.step,overview:t.overview},bubbles:!0,composed:!0})),t.source==="local"&&this.sync?.send(r),this.requestUpdate(),i}async whenInitialized(){this.initialized||await this.updateComplete}async goto(e,t=0){await this.whenInitialized();let r=this.path.stops[Math.min(Math.max(e,0),this.path.stops.length-1)]?.steps??0;return this.commit({stop:e,step:t==="last"?r:t},{animate:!0,source:"local",overview:!1})}async next(){return await this.whenInitialized(),this.commit(Le(this.current,this.path),{animate:!0,source:"local",overview:!1})}async prev(){return await this.whenInitialized(),this.commit(Ne(this.current,this.path),{animate:!0,source:"local",overview:!1})}async overview(e){await this.whenInitialized();let t=e??!this.inOverview;return await this.commit(this.current,{animate:!0,source:"local",overview:t}),this.inOverview}getState(){return{...this.current}}getPath(){return this.path.stops.map((e,t)=>{let r=this.rectFor({stop:t,step:0},!1)??{x:0,y:0,w:1920,h:1080};return{index:t,kind:e.kind,frame:e.kind==="overview"?void 0:e.frame,steps:e.steps,notes:this.notes[t]??"",zoom:O(r,this.stageNow).zoom,rect:r}})}async ready(e){let t=await Ae(this,{...e,extraWarnings:[...this.themeWarnings,...this.deckWarnings(),...st(this),...ot(this.frames),...this.languageWarnings()]});this.refreshPose();let r=new Set([...t.warnings,...it(this.frames)]);return{...t,warnings:[...r]}}showStatus(e){this.statusText=e,clearTimeout(this.statusTimer),this.statusTimer=setTimeout(()=>{this.statusText=""},Wt)}handleKey(e){if(e.ctrlKey||e.metaKey||e.altKey||e.defaultPrevented||gt(e.composedPath()[0]??e.target))return;let t=this.path.stops.length-1;if(this.helpOpen&&(e.key==="Escape"||e.key==="?")){e.preventDefault(),this.helpOpen=!1;return}let r=null;switch(e.key){case"?":r=()=>this.helpOpen=!0;break;case"ArrowRight":case" ":case"PageDown":case"Enter":r=()=>this.next();break;case"ArrowLeft":case"Backspace":case"PageUp":r=()=>this.prev();break;case"Home":r=()=>this.goto(0,0);break;case"End":r=()=>this.goto(Math.max(t,0),"last");break;case"Escape":case"o":r=()=>this.overview();break;case"p":if(this.mode==="presenter")break;r=()=>{dt()||this.showStatus("Presenter view could not be opened (popup blocked or unsupported).")};break;case"l":if(!this.multilingual)break;r=()=>this.setLanguage(Pe(this.languageList,this.currentLanguage),!0);break;case"f":r=()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()).catch(()=>{})};break}r&&(e.preventDefault(),r())}};p([u()],S.prototype,"theme",2),p([u({reflect:!0})],S.prototype,"format",2),p([u({reflect:!0})],S.prototype,"motion",2),p([u()],S.prototype,"languages",2),p([z()],S.prototype,"ground",2),p([z()],S.prototype,"stage",2),p([z()],S.prototype,"statusText",2),p([z()],S.prototype,"helpOpen",2),p([z()],S.prototype,"elapsedMs",2),p([z()],S.prototype,"presenterStatus",2);function Jt(n){if(n.length===0)return null;let o=ee(Y(n.map(s=>s.rect)),_t),e=new Map(n.map(s=>[s.id,s])),t=new Set,r=[];for(let s of n)for(let i of(s.el.getAttribute("link")??"").split(/\s+/).filter(Boolean)){let a=e.get(i);if(!a){x(`link|${s.id}|${i}`,`[banger] bang-frame "${s.id}" links to "${i}", which is not a bang-frame id; no road is drawn`);continue}if(a===s){x(`link|${s.id}|${i}`,`[banger] bang-frame "${s.id}" links to itself; no road is drawn`);continue}let l=[s.id,i].sort().join("\0");t.has(l)||(t.add(l),r.push({x1:s.rect.x+s.rect.w/2,y1:s.rect.y+s.rect.h/2,x2:a.rect.x+a.rect.w/2,y2:a.rect.y+a.rect.h/2}))}return{rect:o,roads:r}}function ft(n){let o=0;for(let e of n.querySelectorAll("*")){if(!C(e))continue;let t=Number(e.getAttribute("data-step"));e.hasAttribute("data-step")&&Number.isFinite(t)&&(o=Math.max(o,t));let r=e.stepCount;typeof r=="number"&&(o=Math.max(o,r))}return o}v("bang-root",S);export{N as BangCard,q as BangChart,L as BangColumns,y as BangElement,M as BangFrame,K as BangFree,_ as BangImage,re as BangList,ne as BangNotes,te as BangPath,S as BangRoot,F as BangShape,U as BangStack,A as BangStat,E as BangStop,W as BangText,oe as BangTheme,D as BangTitle,T as FRAME_HEIGHT,R as FRAME_WIDTH,j as StepAware,Y as boundsOf,P as clamp,Xe as clipFor,je as contains,xt as durationFor,wt as ease,St as easeOut,vt as frameRect,Ie as frameStep,ee as inflate,We as layoutFrames,qe as nearness,Le as next,He as parseAt,Oe as parseHash,_e as parseRegion,Ue as parseSpan,O as poseFor,Ne as prev,Mt as pullBackFor,ue as regionRect,Ge as retarget,he as sample,J as serializeHash,Ve as stageSize,Ze as stageToCanvas,$t as startTween,Yt as targetFor,de as toTransform,me as version,Ke as viewInside};
531
587
  //# sourceMappingURL=index.js.map