@bangerpage/core 0.1.1 → 0.2.0-rc.1

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.
@@ -12,3 +12,8 @@ export declare function overlapWarnings(frames: readonly CheckedFrame[]): string
12
12
  * and content that sticks out of a `bang-card`, which does not clip and lets it run over what is below.
13
13
  */
14
14
  export declare function frameOverflowWarnings(frames: readonly CheckedFrame[]): string[];
15
+ /**
16
+ * Mistakes in how a multilingual deck is written, independent of which language is shown: untranslated siblings,
17
+ * `lang` in places that cannot vary, layouts that move between languages, and `crumb`/`label` without a translation.
18
+ */
19
+ export declare function translationWarnings(root: Element, languages: readonly string[]): string[];
package/dist/frame.d.ts CHANGED
@@ -28,12 +28,16 @@ export declare class BangFrame extends BangElement {
28
28
  * `coverGradient` the normal ground stays.
29
29
  */
30
30
  ground: "default" | "cover";
31
- /** A bold heading-size line (36px) at the top left, inside the top margin. It does not move the content and is cut to one line. */
31
+ /**
32
+ * A bold heading-size line (36px) at the top left, inside the top margin. It does not move the content and is cut to one line.
33
+ * In a deck with `languages`, write `crumb-<language>` (for example `crumb-en`) for each other language; a language without one shows `crumb`.
34
+ */
32
35
  crumb?: string;
33
36
  /**
34
37
  * A large name shown over the frame when the camera is far away (the overview, or a stop on another frame), with the
35
38
  * content faded behind it. It fades out as the camera comes close. Use it to name a place on a map or a chapter.
36
39
  * Experimental, made for `format="map"`; it may change in any release.
40
+ * In a deck with `languages`, write `label-<language>` (for example `label-en`) for each other language; a language without one shows `label`.
37
41
  */
38
42
  label?: string;
39
43
  /**
@@ -43,5 +47,7 @@ export declare class BangFrame extends BangElement {
43
47
  valign: "center" | "spread";
44
48
  /** The step shown in this frame. Set by `bang-root`. */
45
49
  currentStep: number;
50
+ /** The text for `crumb` or `label` in the root's current language: `crumb-<language>` when set, else the plain attribute. */
51
+ private frameText;
46
52
  render(): import("lit").TemplateResult<1>;
47
53
  }
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{g as be,i as ve,j as q,k as xe}from"./chunks/chunk-ZPKJQ62D.js";import{a as V,b as f,c as d,d as me,e as ie,f as p,g as _,h as g,i as R,j as b,k as j,l as w,m as k,n as y,o as m,p as H,q as fe,r as ae,s as ye,t as we,u as Se,v as Me,w as ke}from"./chunks/chunk-YW2TRY4C.js";import{b as c,c as ge,e as D}from"./chunks/chunk-ISQU3ATQ.js";var Ee=/^-?\d+$/;function G(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),G(o,e));return{stop:e,step:t}}function Pe(r,o){let e=new URLSearchParams(r.startsWith("#")?r.slice(1):r),t=e.get("stop"),n=e.get("step"),s=t!==null&&Ee.test(t)?Number(t):0,i=E({stop:s,step:0},o).stop,a=0;return n==="last"?a=G(o,i):n!==null&&Ee.test(n)&&(a=Number(n)),E({stop:i,step:a},o)}function X(r){return`#stop=${r.stop}&step=${r.step}`}function $e(r,o){let e=E(r,o);return e.step<G(o,e.stop)?{stop:e.stop,step:e.step+1}:e.stop<o.stops.length-1?{stop:e.stop+1,step:0}:e}function Re(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:G(o,e.stop-1)}:e}function Ae(r,o,e){let t=E(o,e),n=0;for(let i=0;i<t.stop;i++){let a=e.stops[i];a.kind!=="overview"&&a.frame===r&&(n=Math.max(n,a.steps))}let s=e.stops[t.stop];return s&&s.kind!=="overview"&&s.frame===r&&(n=Math.max(n,t.step)),n}function ze(r){if(r===null)return null;let o=r.split(",");if(o.length!==4||o.some(i=>i.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 Te(r,o,e){if(r===null)return e;let t=r.split(",").map(i=>i.trim());if(t.length!==2||!t.every(i=>/^\d+$/.test(i)))return e;let[n,s]=t.map(Number);return n>=o&&s>=o?[n,s]:e}function Ce(r){return Te(r,0,[0,0])}function Oe(r){return Te(r,1,[1,1])}var A=1920,z=1080;var le=r=>Math.min(Math.max(r,0),1);function ot(r,o,e){let[t,n]=r,[s,i]=o;return{x:t*(1920+e),y:n*(1080+e),w:s*1920+(s-1)*e,h:i*1080+(i-1)*e}}function Ie(r,o){return Object.fromEntries(r.map(e=>[e.id,ot(e.at,e.span,o)]))}function ce(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 Z(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 J(r,o){return{x:r.x-o,y:r.y-o,w:r.w+2*o,h:r.h+2*o}}function Le(r,o){return o.x>=r.x&&o.x<=r.x+r.w&&o.y>=r.y&&o.y<=r.y+r.h}function T(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 Nt(r,o,e){let t=r.kind==="overview"||r.frame===void 0?void 0:o[r.frame];return T(t?r.kind==="region"&&r.region?ce(t,r.region):t:Z(Object.values(o)),e)}var Ne=.5,it=.8;function _e(r,o,e){let t=Math.max(r.w*o.zoom/e.w,r.h*o.zoom/e.h),n=le((t-Ne)/(it-Ne));return n*n*(3-2*n)}function He(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 i=Math.min(Math.max(r.x+r.w/2-n/2,o.x),o.x+o.w-n),a=Math.min(Math.max(r.y+r.h/2-s/2,o.y),o.y+o.h-s);return{x:i,y:a,w:n,h:s}}function Fe(r){let o=Math.min(r.w/1920,r.h/1080);return{w:1920*o,h:1080*o}}function at(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 lt(r){let o=le(r);return o<.5?4*o*o*o:1-Math.pow(-2*o+2,3)/2}function ct(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),i=Math.abs(o.cy-r.cy);if(Math.hypot(s/t,i/n)<1.5)return 0;let a=Math.min(e.w/(s+t),e.h/(i+n)),l=(Math.log(r.zoom)+Math.log(o.zoom))/2;return Math.min(0,Math.log(a)-l)}function pt(r,o,e,t){let n=ct(r,o,t),s=Math.min(at(r,o,t)-250*n,1300);return{from:r,to:o,start:e,duration:s,pullBack:n}}function pe(r,o){let e=le((o-r.start)/r.duration);if(e<=0)return{...r.from};if(e>=1)return{...r.to};let t=lt(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 We(r,o,e,t){return pt(r,o,e,t)}function Ue(r,o,e){let t=(i,a)=>{let l=(i-a*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 je(r,o,e){let{tx:t,ty:n,scale:s}=he(o,e);return{x:(r.x-t)/s,y:(r.y-n)/s}}function he(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 b{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=f`
1
+ import{g as ye,i as xe,j as G,k as we}from"./chunks/chunk-ZPKJQ62D.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`
2
2
  :host {
3
3
  position: absolute;
4
4
  display: block;
@@ -16,7 +16,7 @@ import{g as be,i as ve,j as q,k as xe}from"./chunks/chunk-ZPKJQ62D.js";import{a
16
16
  --bang-band-ground: initial;
17
17
  --bang-band-border: initial;
18
18
  }
19
- ${V(q.map(e=>`:host([tone="${e}"]) {
19
+ ${V(G.map(e=>`:host([tone="${e}"]) {
20
20
  ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});`).join(`
21
21
  `)}
22
22
  }`).join(`
@@ -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
- `}render(){m(this,"tone",["default","accent","inverse"],"default"),m(this,"ground",["default","cover"],"default"),m(this,"valign",["center","spread"],"center");let e=this.crumb?.trim(),t=this.label?.trim();return d`<div class="frame">${e?d`<div class="crumb">${e}</div>`:""}<slot></slot>${t?d`<div class="label" aria-hidden="true">${t}</div>`:""}<div class="fog" aria-hidden="true"></div></div>`}};c([p()],S.prototype,"at",2),c([p()],S.prototype,"span",2),c([p()],S.prototype,"tone",2),c([p()],S.prototype,"ground",2),c([p()],S.prototype,"crumb",2),c([p()],S.prototype,"label",2),c([p()],S.prototype,"valign",2),c([p({attribute:!1})],S.prototype,"currentStep",2);g("bang-frame",S);var Q=class extends b{static{this.styles=f`
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`
104
104
  :host {
105
105
  display: none;
106
106
  }
107
- `}render(){return d`<slot></slot>`}};g("bang-path",Q);function Ke(r){let o=(r.textContent??"").split(`
107
+ `}render(){return m`<slot></slot>`}};v("bang-path",ee);function Xe(r){let o=(r.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 Y=class extends b{static{this.styles=f`
109
+ `)}var te=class extends y{static{this.styles=b`
110
110
  :host {
111
111
  display: none;
112
112
  }
113
- `}};g("bang-notes",Y);var ht=999,P=class extends b{constructor(){super(...arguments);this.overview=!1}static{this.styles=f`
113
+ `}};v("bang-notes",te);var vt=999,P=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 d`<slot></slot>`}};c([p()],P.prototype,"frame",2),c([p({attribute:"focus"})],P.prototype,"focusId",2),c([p()],P.prototype,"region",2),c([p({type:Boolean})],P.prototype,"overview",2),c([p({type:Number})],P.prototype,"steps",2);g("bang-stop",P);function Be(r){let o=[...r.children].find(l=>l.localName==="bang-notes"),e=o?Ke(o):"",t=!r.hasAttribute("steps"),n=H(r,"steps",0,ht,0),s=r.getAttribute("frame")??void 0;if(r.hasAttribute("overview")||s===void 0)return r.hasAttribute("overview")||y("stop-no-frame","[banger] <bang-stop> has neither frame nor overview; treated as overview"),{stop:{kind:"overview",steps:n},notes:e,auto:!1};let i=r.getAttribute("focus")?.trim();if(i)return{stop:{kind:"focus",frame:s,focus:i,steps:n},notes:e,auto:t};let a=r.getAttribute("region");if(a!==null){let l=ze(a);if(l)return{stop:{kind:"region",frame:s,region:l,steps:n},notes:e,auto:t};y(`region|${a}`,`[banger] <bang-stop region="${a}"> is not a valid region; showing the whole frame`)}return{stop:{kind:"frame",frame:s,steps:n},notes:e,auto:t}}var dt={start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"},F=class extends b{constructor(){super(...arguments);this.gap="m";this.align="stretch"}static{this.styles=f`
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`
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=m(this,"gap",w,"m"),t=m(this,"align",["start","center","end","stretch"],"stretch");return d`<style>
125
- :host { gap: var(--bang-gap-${e}); align-items: ${dt[t]}; }
126
- </style><slot></slot>`}};c([p()],F.prototype,"gap",2),c([p()],F.prototype,"align",2);g("bang-stack",F);var C=class extends b{constructor(){super(...arguments);this.align="stretch";this.gap="m"}static{this.styles=f`
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`
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=m(this,"gap",w,"m"),t=m(this,"align",["stretch","start","center","end"],"stretch"),n=Math.max(this.children.length,1),s=this.getAttribute("ratio"),i=Array.from({length:n},()=>1);if(s!==null&&this.children.length>0){let l=fe(s,this.children.length);l?i=l:y(`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 d`<style>
135
- :host { grid-template-columns: ${a}; gap: var(--bang-gap-${e}); align-items: ${t}; }
136
- </style><slot @slotchange=${()=>this.requestUpdate()}></slot>`}};c([p()],C.prototype,"ratio",2),c([p()],C.prototype,"align",2),c([p()],C.prototype,"gap",2);g("bang-columns",C);var O=class extends b{constructor(){super(...arguments);this.kind="panel";this.grow=!1;this.valign="start"}static{this.styles=f`
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`
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 m(this,"kind",["panel","band"],"panel"),m(this,"valign",["start","center","spread"],"start"),d`<slot></slot>`}};c([p()],O.prototype,"kind",2),c([p({type:Boolean})],O.prototype,"grow",2),c([p()],O.prototype,"valign",2);g("bang-card",O);var W=class extends b{constructor(){super(...arguments);this.size="l";this.tone="default"}static{this.styles=f`
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`
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=m(this,"size",w,"l"),t=m(this,"tone",k,"default");return d`<style>
175
+ `}render(){let e=f(this,"size",w,"l"),t=f(this,"tone",$,"default");return m`<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>`}};c([p()],W.prototype,"size",2),c([p()],W.prototype,"tone",2);g("bang-title",W);var U=class extends b{constructor(){super(...arguments);this.size="s";this.tone="default"}static{this.styles=f`
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`
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=m(this,"size",w,"s"),t=m(this,"tone",k,"default");return d`<style>
186
+ `}render(){let e=f(this,"size",w,"s"),t=f(this,"tone",$,"default");return m`<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>`}};c([p()],U.prototype,"size",2),c([p()],U.prototype,"tone",2);g("bang-text",U);var N=class N extends j{constructor(){super(...arguments);this.size="s";this.tone="default";this.ordered=!1}static{this.styles=f`
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`
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")}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((a,l)=>a.toggleAttribute("data-bang-hidden",l>=s));let i;for(let a of this.children)a.localName==="li"?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,n=m(t,"size",w,"s"),s=e?m(this,"size",w,w[Math.max(w.indexOf(n)-1,0)]):n,i=m(t,"tone",k,"default");return e&&(this.hasAttribute("tone")||this.hasAttribute("step"))&&y("list|nested","[banger] <bang-list> next to its parent li takes its tone from the outermost list; its tone and step are ignored"),d`<style>
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>
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-${i});
249
- color: var(--bang-tone-${i});
248
+ --bang-marker: var(--bang-tone-${a});
249
+ color: var(--bang-tone-${a});
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>`}};c([p()],N.prototype,"size",2),c([p()],N.prototype,"tone",2),c([p({type:Number})],N.prototype,"step",2),c([p({type:Boolean})],N.prototype,"ordered",2);var ee=N;g("bang-list",ee);var $=class extends b{constructor(){super(...arguments);this.labelSize="xs";this.size="xl";this.tone="default"}static{this.styles=f`
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`
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=m(this,"size",w,"xl"),t=m(this,"tone",k,"default"),n=m(this,"label-size",w,"xs"),s=this.getAttribute("value");return s===null&&y("stat|value","[banger] <bang-stat> needs a value attribute"),d`<style>
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>
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
269
  .label { font-size: var(--bang-size-${n}); line-height: var(--bang-leading-text-${n}); }
270
- </style><div class="value">${s??""}</div>${this.label?d`<div class="label">${this.label}</div>`:""}`}};c([p()],$.prototype,"value",2),c([p()],$.prototype,"label",2),c([p({attribute:"label-size"})],$.prototype,"labelSize",2),c([p()],$.prototype,"size",2),c([p()],$.prototype,"tone",2);g("bang-stat",$);var I=class extends b{constructor(){super(...arguments);this.alt="";this.fit="contain"}static{this.styles=f`
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`
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=m(this,"fit",["contain","cover"],"contain"),t=this.getAttribute("src");return d`<style>
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>
282
282
  img { object-fit: ${e}; }
283
- </style>${t?d`<img src=${t} alt=${this.alt} />`:""}`}};c([p()],I.prototype,"src",2),c([p()],I.prototype,"alt",2),c([p()],I.prototype,"fit",2);g("bang-image",I);var K=class extends j{constructor(){super(...arguments);this.handle=null;this.lastKey=null;this.observer=null;this.parsed=null}static{this.styles=f`
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`
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-4XQPQZ4J.js");this.handle??=n(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 d`<div class="chart"></div>`}};c([p({type:Number})],K.prototype,"step",2);g("bang-chart",K);var ut=["arrow-up","arrow-down","arrow-left","arrow-right","ok","ng"],te="0 0 64 32",Ve="0 0 32 32",mt={"arrow-down":{viewBox:te,d:"M16 0H48V12H64L32 32L0 12H16Z",width:2},"arrow-up":{viewBox:te,d:"M16 32H48V20H64L32 0L0 20H16Z",width:2},"arrow-left":{viewBox:te,d:"M64 8H24V0L0 16L24 32V24H64Z",width:2},"arrow-right":{viewBox:te,d:"M0 8H40V0L64 16L40 32V24H0Z",width:2},ok:{viewBox:Ve,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:Ve,d:"M6 0L16 10L26 0L32 6L22 16L32 26L26 32L16 22L6 32L0 26L10 16L0 6Z",width:1}},L=class extends b{constructor(){super(...arguments);this.kind="arrow-down";this.size="m";this.tone="default"}static{this.styles=f`
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`
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=m(this,"kind",ut,"arrow-down"),t=m(this,"size",w,"m"),n=m(this,"tone",k,"default"),s=mt[e],i=e==="ok"||e==="ng",a=i?`var(--bang-tone-${n})`:`color-mix(in srgb, var(--bang-tone-${n}) 60%, transparent)`,l=d`<style>
307
- :host { height: var(--bang-size-${t}); width: calc(var(--bang-size-${t}) * ${s.width}); color: ${a}; }
308
- </style>`;return i?d`${l}<svg viewBox=${s.viewBox} role="img" aria-label=${e==="ok"?"OK":"NG"}>
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"}>
309
309
  <path fill-rule="evenodd" d=${s.d}></path>
310
- </svg>`:d`${l}<svg viewBox=${s.viewBox} aria-hidden="true"><path d=${s.d}></path></svg>`}};c([p()],L.prototype,"kind",2),c([p()],L.prototype,"size",2),c([p()],L.prototype,"tone",2);g("bang-shape",L);var B=class extends b{constructor(){super(...arguments);this.overlay=!1}static{this.styles=f`
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`
311
311
  :host {
312
312
  display: grid;
313
313
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
@@ -324,22 +324,23 @@ ${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(!we()){y("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=ye(e.textContent??""),e.setAttribute("data-bang-scoped","")}}async waitImages(){let e=[...this.querySelectorAll("img")];await Promise.all(e.map(async t=>{try{await t.decode()}catch{throw new Error(`image failed to load: ${t.getAttribute("src")??""}`)}}))}render(){return d`<slot @slotchange=${()=>this.scopeStyles()}></slot>`}};c([p({type:Boolean})],B.prototype,"overlay",2);g("bang-free",B);function De(r){return r.querySelector(':scope > bang-theme > script[type="application/json"]')?.textContent??null}var ne=class extends b{static{this.styles=f`
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`
328
328
  :host {
329
329
  display: none;
330
330
  }
331
- `}render(){return null}};g("bang-theme",ne);var de="0.1.1";var ue=r=>r.id?`frame "${r.id}"`:R(r);function Ze(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:R(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 Je(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(`${ue(r[e].el)} and ${ue(r[t].el)} overlap on the canvas; give them different at values`)}return o}function qe(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 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)>n&&(n=Math.max(a,l),t.worst=s)}return t}var Ge=r=>r.worst?` (furthest: ${R(r.worst)})`:"",Xe=(r,o)=>[r>ae?`${Math.round(r)}px horizontally`:"",o>ae?`${Math.round(o)}px vertically`:""].filter(Boolean);function Qe(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,i=getComputedStyle(t),a={left:n.left+parseFloat(i.paddingLeft)*s,top:n.top+parseFloat(i.paddingTop)*s,right:n.right-parseFloat(i.paddingRight)*s,bottom:n.bottom-parseFloat(i.paddingBottom)*s},l=qe(e,a,s),x=Xe(Math.max(l.x,t.scrollWidth-t.clientWidth),Math.max(l.y,t.scrollHeight-t.clientHeight));x.length>0&&o.push(`${ue(e)}: the content does not fit inside the frame margins by ${x.join(", ")}${Ge(l)}; what passes the frame edge is cut off, so shorten it or use smaller sizes`);for(let h of e.querySelectorAll("bang-card")){let v=qe(h,h.getBoundingClientRect(),s),u=Xe(v.x,v.y);u.length>0&&o.push(`${R(h)}: the content sticks out of the card by ${u.join(", ")}${Ge(v)}; shorten it or use smaller sizes`)}}return o}var re=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)}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()}},Ye=r=>String(r).padStart(2,"0");function ft(r){let o=Math.floor(r/1e3);return`${Ye(Math.floor(o/60))}:${Ye(o%60)}`}function et(r){return d`<div class="presenter">
331
+ `}render(){return null}};v("bang-theme",se);var me="0.2.0-rc.1";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">
332
332
  <div class="presenter-head">
333
333
  <span class="presenter-stop">Stop ${r.stop+1} / ${r.stopCount}</span>
334
334
  <span class="presenter-step">Step ${r.step+1} / ${r.steps+1}</span>
335
- <span class="presenter-elapsed">${ft(r.elapsedMs)}</span>
335
+ ${r.language!==void 0?m`<span class="presenter-language">${r.language}</span>`:""}
336
+ <span class="presenter-elapsed">${St(r.elapsedMs)}</span>
336
337
  </div>
337
338
  <div class="presenter-notes">${r.notes}</div>
338
339
  <div class="presenter-buttons">
339
340
  <button type="button" @click=${r.onPrev}>Previous</button>
340
341
  <button type="button" @click=${r.onNext}>Next</button>
341
342
  </div>
342
- </div>`}function tt(){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 gt=240,bt=720,vt=960,xt=320,yt=.08,wt=400,St=[["\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"],["f","Full screen"],["?","This help"]],Mt=4e3,se={w:1920,h:1080};function kt(){let r=new URLSearchParams(location.search).get("mode");return r==="export"||r==="presenter"?r:"live"}var Et=50,Pt=800,$t=300,Rt=400,At=60,zt=3,Tt=500;function nt(r){return r instanceof HTMLElement?r.isContentEditable||["INPUT","TEXTAREA","SELECT"].includes(r.tagName):!1}var M=class extends b{constructor(){super(...arguments);this.theme="light";this.format="slides";this.ground=null;this.firstStop=new Map;this.spotted=[];this.stage=se;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.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||nt(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,i=e.timeStamp-t.at,a=t.mouse&&Math.abs(s)>Math.abs(n),l=a?s:n,x=a?n:s,[h,v]=t.mouse?[Rt,$t]:[Pt,Et];i>h||Math.abs(l)<v||Math.abs(l)<Math.abs(x)*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>=At||(this.handMoves=[...this.handMoves.filter(n=>e.timeStamp-n<Tt),e.timeStamp],!(this.handMoves.length<zt)&&(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=je({x:e.clientX-t.left,y:e.clientY-t.top},this.pose,this.stageNow),s=this.frames.find(l=>Le(l.rect,n));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())y(`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=de}static{this.styles=[V(ge),f`
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`
343
344
  :host {
344
345
  display: block;
345
346
  position: fixed;
@@ -506,8 +507,8 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
506
507
  font-size: 24px;
507
508
  cursor: pointer;
508
509
  }
509
- `]}connectedCallback(){super.connectedCallback(),this.mode=kt(),this.setAttribute("data-mode",this.mode),Me(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 re,this.sync.onRemote(e=>{this.commit(E(e,this.path),{animate:!0,source:"remote",overview:!1})}))),this.mode==="presenter"&&(this.startedAt=Date.now(),this.clockTimer=setInterval(()=>{this.elapsedMs=Date.now()-this.startedAt},1e3))}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,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(m(this,"theme",["light","dark","custom"],"light"),m(this,"format",["slides","map"],"slides"),this.mode==="presenter"){let e=this.path.stops[this.current.stop];return d`${et({stop:this.current.stop,stopCount:this.path.stops.length,step:this.current.step,steps:e?.steps??0,notes:this.notes[this.current.stop]??"",elapsedMs:this.elapsedMs,onPrev:()=>{this.prev()},onNext:()=>{this.next()}})}${this.renderHelp()}<div class="status" role="status">${this.statusText}</div>
510
- <div hidden><slot @slotchange=${this.onSlotChange}></slot></div>`}return d`<div class="viewport">
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">
511
512
  <div class="stage" style="width:${this.stage.w}px;height:${this.stage.h}px" @click=${this.onStageClick}>
512
513
  <div class="clip">
513
514
  <div class="canvas">${this.renderGround()}<slot @slotchange=${this.onSlotChange}></slot></div>
@@ -515,16 +516,16 @@ ${Object.keys(D.light).map(t=>` --bang-color-${t}: var(--bang-frame-${e}-${t});
515
516
  </div>
516
517
  </div>
517
518
  ${this.renderHelp()}
518
- <div class="status" role="status">${this.statusText}</div>`}renderHelp(){return this.helpOpen?d`<div class="help" @click=${()=>this.helpOpen=!1}>
519
+ <div class="status" role="status">${this.statusText}</div>`}renderHelp(){return this.helpOpen?m`<div class="help" @click=${()=>this.helpOpen=!1}>
519
520
  <div class="help-panel" role="dialog" aria-label="Keyboard shortcuts">
520
521
  <h2>Keyboard shortcuts</h2>
521
522
  <dl>
522
- ${St.map(([e,t])=>d`<dt>${e}</dt><dd>${t}</dd>`)}
523
+ ${Rt(this.multilingual).map(([e,t])=>m`<dt>${e}</dt><dd>${t}</dd>`)}
523
524
  </dl>
524
525
  </div>
525
- </div>`:ie}renderGround(){let e=this.ground;if(!e)return ie;let{rect:t}=e;return d`<div class="ground" style="left:${t.x}px;top:${t.y}px;width:${t.w}px;height:${t.h}px">
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">
526
527
  <svg class="roads" viewBox="${t.x} ${t.y} ${t.w} ${t.h}" aria-hidden="true">
527
- ${e.roads.map(n=>me`<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>`)}
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>`)}
528
529
  </svg>
529
- </div>`}applyTheme(){let e=De(this),t=()=>{for(let v of this.themeVars)this.style.removeProperty(v);this.themeVars=[]},n=v=>{this.themeWarnings=v;for(let u of v)y(`theme|${u}`,`[banger] ${u}`)},s=this.getAttribute("theme");if(s!=="custom"){t();let v=`\0ignored|${s}|${e===null?"none":"present"}`;if(v===this.themeKey)return;this.themeKey=v,this.applyFrameTones(D[s==="dark"?"dark":"light"]),n(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 v=be(e);a.push(...v.warnings),l=v.definition??{}}let x=ve(l);a.push(...x.warnings),t();let h={};for(let[v,u]of Object.entries(x.colors))h[`--bang-color-${v}`]=u;for(let[v,u]of Object.entries(x.fonts))h[`--bang-font-${v}`]=u;x.ground&&(h["--bang-ground"]=x.ground),Object.assign(h,x.vars);for(let[v,u]of Object.entries(h))this.style.setProperty(v,u);this.themeVars=Object.keys(h),this.applyFrameTones(x.colors),x.fontsRequest&&ke(x.fontsRequest),n(a)}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=R(n),i=t(n);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 n of this.querySelectorAll("bang-card[kind=band]")){let s=R(n),i=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`):i&&e.push(`${s}: kind="band" inside a frame with tone="${i}" uses the surface color`)}return e}applyFrameTones(e){for(let t of q)for(let[n,s]of Object.entries(xe(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=Fe({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"?se:this.stage}get isMap(){return this.format==="map"}buildPath(){for(let h of this.spotted)h.removeAttribute("data-bang-dim");this.spotted=[];let e=[...this.querySelectorAll("bang-frame")],t=new Set,n=[];e.forEach((h,v)=>{let u=h.id;u&&t.has(u)&&(y(`dupframe|${u}`,`[banger] duplicate bang-frame id "${u}"; the first one is used`),u=""),u&&t.add(u),n.push({id:u||`\0${v}`,at:Ce(h.getAttribute("at")),span:Oe(h.getAttribute("span")),el:h})});let s=this.isMap,i=Ie(n,s?bt:gt);this.frameMap=i,this.frames=n.map(h=>({el:h.el,id:h.id,rect:i[h.id]}));for(let h of this.frames)s?h.el.setAttribute("data-bang-format","map"):h.el.removeAttribute("data-bang-format"),h.el.style.setProperty("--bang-frame-x",`${h.rect.x}px`),h.el.style.setProperty("--bang-frame-y",`${h.rect.y}px`),h.el.style.setProperty("--bang-frame-w",`${h.rect.w}px`),h.el.style.setProperty("--bang-frame-h",`${h.rect.h}px`);this.ground=s?Ct(this.frames):null;let a=[],l=[],x=new Set;for(let h of this.querySelectorAll("bang-path > bang-stop")){let v=Be(h),u=v.stop;if(v.auto&&u.kind!=="overview"){let oe=this.frames.find(st=>st.id===u.frame);oe&&!x.has(oe.id)&&(u={...u,steps:rt(oe.el)})}u.kind!=="overview"&&u.frame&&x.add(u.frame),u.kind!=="overview"&&!(u.frame&&t.has(u.frame))&&(y(`stopframe|${u.frame}`,`[banger] <bang-stop frame="${u.frame}"> does not match any bang-frame; treated as overview`),u={kind:"overview",steps:u.steps}),a.push(u),l.push(v.notes)}this.path={stops:a},this.notes=l,this.firstStop=new Map,a.forEach((h,v)=>{h.kind!=="overview"&&h.frame&&!this.firstStop.has(h.frame)&&this.firstStop.set(h.frame,v)}),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 n=Math.max(...t),s=rt(e.el);s>n&&y(`steps|${e.id}|${s}|${n}`,`[banger] frame "${e.id}" needs ${s} steps but its stops provide at most ${n}`)}}hashState(){let e=Pe(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))&&y(`hash|${location.hash}`,`[banger] hash "${location.hash}" is out of range; using "${X(e)}"`),e}allRects(){return this.frames.map(e=>e.rect)}rectFor(e,t){let n=this.allRects(),s=n.length>0?Z(n):{x:0,y:0,w:1920,h:1080};this.isMap&&n.length>0&&(s=J(s,xt));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?He(l,a,this.stageNow):a}return i.kind==="region"&&i.region?ce(a,i.region):a}focusTarget(e,t){let n=this.frames.find(i=>i.id===e);if(!n)return null;let s=n.el.querySelector(`#${CSS.escape(t)}`);return s?{entry:n,target:s}:(y(`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:i}=n,a=s.el.getBoundingClientRect(),l=i.getBoundingClientRect();if(a.width===0||l.width===0||l.height===0)return null;let x=a.width/s.rect.w,h={x:s.rect.x+(l.left-a.left)/x,y:s.rect.y+(l.top-a.top)/x,w:l.width/x,h:l.height/x};return J(h,Math.max(h.w,h.h*(1920/1080))*yt)}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 T(n,this.stageNow)}canvasEl(){return this.renderRoot.querySelector(".canvas")}applyPose(e){let t=this.canvasEl();t&&(t.style.transform=he(e,this.stageNow,this.mode!=="export").css),this.applyNearness(e)}applyNearness(e){let t=this.stageNow;for(let n of this.frames){let i=_e(n.rect,e,t).toFixed(3);n.el.style.getPropertyValue("--bang-near")!==i&&n.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 n=T(t,se),s=Ue(t,n,se);e.style.clipPath=`inset(${s.top}px ${s.right}px ${s.bottom}px ${s.left}px)`}currentPose(){return this.tween?pe(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=We(n,e,performance.now(),this.stageNow);return this.tween=s,this.canvasEl().style.willChange="transform",new Promise(i=>{this.resolvePending=i;let a=()=>{this.tween===s&&(this.stopTween(),this.pose=s.to,this.applyPose(s.to),this.settlePending(),this.refreshPose())};this.tweenTimer=setTimeout(a,s.duration+100);let l=()=>{if(this.tween!==s)return;let x=performance.now();if(x-s.start>=s.duration){a();return}this.applyPose(pe(s,x)),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=Ae(t.id,this.current,this.path);t.el.currentStep=n;for(let s of t.el.querySelectorAll("[data-step]")){let i=Number(s.getAttribute("data-step"));Number.isFinite(i)&&s.toggleAttribute("data-bang-hidden",n<i)}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:i,target:a}=n;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 x of l.parentElement.children)x!==l&&this.spotted.push(x)}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")},wt));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 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 i=this.moveCamera(T(s,this.stageNow),t.animate);return this.applyClip(),t.source!=="hash"&&location.hash!==X(n)&&history.replaceState(null,"",X(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(),i}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($e(this.current,this.path),{animate:!0,source:"local",overview:!1})}async prev(){return await this.whenInitialized(),this.commit(Re(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:T(n,this.stageNow).zoom,rect:n}})}async ready(e){let t=await Se(this,{...e,extraWarnings:[...this.themeWarnings,...this.deckWarnings(),...Ze(this),...Je(this.frames)]});this.refreshPose();let n=new Set([...t.warnings,...Qe(this.frames)]);return{...t,warnings:[...n]}}showStatus(e){this.statusText=e,clearTimeout(this.statusTimer),this.statusTimer=setTimeout(()=>{this.statusText=""},Mt)}handleKey(e){if(e.ctrlKey||e.metaKey||e.altKey||e.defaultPrevented||nt(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=()=>{tt()||this.showStatus("Presenter view could not be opened (popup blocked or unsupported).")};break;case"f":n=()=>{(document.fullscreenElement?document.exitFullscreen():document.documentElement.requestFullscreen()).catch(()=>{})};break}n&&(e.preventDefault(),n())}};c([p()],M.prototype,"theme",2),c([p({reflect:!0})],M.prototype,"format",2),c([_()],M.prototype,"ground",2),c([_()],M.prototype,"stage",2),c([_()],M.prototype,"statusText",2),c([_()],M.prototype,"helpOpen",2),c([_()],M.prototype,"elapsedMs",2);function Ct(r){if(r.length===0)return null;let o=J(Z(r.map(s=>s.rect)),vt),e=new Map(r.map(s=>[s.id,s])),t=new Set,n=[];for(let s of r)for(let i of(s.el.getAttribute("link")??"").split(/\s+/).filter(Boolean)){let a=e.get(i);if(!a){y(`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){y(`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),n.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:n}}function rt(r){let o=0;for(let e of r.querySelectorAll("*")){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}g("bang-root",M);export{O as BangCard,K as BangChart,C as BangColumns,b as BangElement,S as BangFrame,B as BangFree,I as BangImage,ee as BangList,Y as BangNotes,Q as BangPath,M as BangRoot,L as BangShape,F as BangStack,$ as BangStat,P as BangStop,U as BangText,ne as BangTheme,W as BangTitle,z as FRAME_HEIGHT,A as FRAME_WIDTH,j as StepAware,Z as boundsOf,E as clamp,Ue as clipFor,Le as contains,at as durationFor,lt as ease,ot as frameRect,Ae as frameStep,J as inflate,Ie as layoutFrames,_e as nearness,$e as next,Ce as parseAt,Pe as parseHash,ze as parseRegion,Oe as parseSpan,T as poseFor,Re as prev,ct as pullBackFor,ce as regionRect,We as retarget,pe as sample,X as serializeHash,Fe as stageSize,je as stageToCanvas,pt as startTween,Nt as targetFor,he as toTransform,de as version,He as viewInside};
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};
530
531
  //# sourceMappingURL=index.js.map