@m3e/toc 1.0.6 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -20,33 +20,30 @@ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
20
20
  LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21
21
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
22
22
  PERFORMANCE OF THIS SOFTWARE.
23
- ***************************************************************************** */
24
- /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
25
-
26
-
27
- function __decorate(decorators, target, key, desc) {
28
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
29
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
30
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31
- return c > 3 && r && Object.defineProperty(target, key, r), r;
32
- }
33
-
34
- function __classPrivateFieldGet(receiver, state, kind, f) {
35
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
36
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
37
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
38
- }
39
-
40
- function __classPrivateFieldSet(receiver, state, value, kind, f) {
41
- if (kind === "m") throw new TypeError("Private method is not writable");
42
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
43
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
44
- return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
45
- }
46
-
47
- typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
48
- var e = new Error(message);
49
- return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
23
+ ***************************************************************************** */
24
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
25
+
26
+ function __decorate(decorators, target, key, desc) {
27
+ var c = arguments.length,
28
+ r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
29
+ d;
30
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
31
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
32
+ }
33
+ function __classPrivateFieldGet(receiver, state, kind, f) {
34
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
35
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
36
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
37
+ }
38
+ function __classPrivateFieldSet(receiver, state, value, kind, f) {
39
+ if (kind === "m") throw new TypeError("Private method is not writable");
40
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
41
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
42
+ return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
43
+ }
44
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
45
+ var e = new Error(message);
46
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
50
47
  };
51
48
 
52
49
  /**
@@ -54,45 +51,408 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
54
51
  * Copyright 2017 Google LLC
55
52
  * SPDX-License-Identifier: BSD-3-Clause
56
53
  */
57
- const t$1=t=>(e,o)=>{ void 0!==o?o.addInitializer((()=>{customElements.define(t,e);})):customElements.define(t,e);};
54
+ const t$1 = t => (e, o) => {
55
+ void 0 !== o ? o.addInitializer(() => {
56
+ customElements.define(t, e);
57
+ }) : customElements.define(t, e);
58
+ };
58
59
 
59
60
  /**
60
61
  * @license
61
62
  * Copyright 2019 Google LLC
62
63
  * SPDX-License-Identifier: BSD-3-Clause
63
64
  */
64
- const t=globalThis,e$3=t.ShadowRoot&&(void 0===t.ShadyCSS||t.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,s=Symbol(),o$2=new WeakMap;let n$2 = class n{constructor(t,e,o){if(this._$cssResult$=true,o!==s)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e;}get styleSheet(){let t=this.o;const s=this.t;if(e$3&&void 0===t){const e=void 0!==s&&1===s.length;e&&(t=o$2.get(s)),void 0===t&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),e&&o$2.set(s,t));}return t}toString(){return this.cssText}};const r$3=t=>new n$2("string"==typeof t?t:t+"",void 0,s),S=(s,o)=>{if(e$3)s.adoptedStyleSheets=o.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet));else for(const e of o){const o=document.createElement("style"),n=t.litNonce;void 0!==n&&o.setAttribute("nonce",n),o.textContent=e.cssText,s.appendChild(o);}},c$1=e$3?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return r$3(e)})(t):t;
65
+ const t = globalThis,
66
+ e$3 = t.ShadowRoot && (void 0 === t.ShadyCSS || t.ShadyCSS.nativeShadow) && "adoptedStyleSheets" in Document.prototype && "replace" in CSSStyleSheet.prototype,
67
+ s = Symbol(),
68
+ o$2 = new WeakMap();
69
+ let n$2 = class n {
70
+ constructor(t, e, o) {
71
+ if (this._$cssResult$ = true, o !== s) throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");
72
+ this.cssText = t, this.t = e;
73
+ }
74
+ get styleSheet() {
75
+ let t = this.o;
76
+ const s = this.t;
77
+ if (e$3 && void 0 === t) {
78
+ const e = void 0 !== s && 1 === s.length;
79
+ e && (t = o$2.get(s)), void 0 === t && ((this.o = t = new CSSStyleSheet()).replaceSync(this.cssText), e && o$2.set(s, t));
80
+ }
81
+ return t;
82
+ }
83
+ toString() {
84
+ return this.cssText;
85
+ }
86
+ };
87
+ const r$3 = t => new n$2("string" == typeof t ? t : t + "", void 0, s),
88
+ S = (s, o) => {
89
+ if (e$3) s.adoptedStyleSheets = o.map(t => t instanceof CSSStyleSheet ? t : t.styleSheet);else for (const e of o) {
90
+ const o = document.createElement("style"),
91
+ n = t.litNonce;
92
+ void 0 !== n && o.setAttribute("nonce", n), o.textContent = e.cssText, s.appendChild(o);
93
+ }
94
+ },
95
+ c$1 = e$3 ? t => t : t => t instanceof CSSStyleSheet ? (t => {
96
+ let e = "";
97
+ for (const s of t.cssRules) e += s.cssText;
98
+ return r$3(e);
99
+ })(t) : t;
65
100
 
66
101
  /**
67
102
  * @license
68
103
  * Copyright 2017 Google LLC
69
104
  * SPDX-License-Identifier: BSD-3-Clause
70
- */const{is:i,defineProperty:e$2,getOwnPropertyDescriptor:h,getOwnPropertyNames:r$2,getOwnPropertySymbols:o$1,getPrototypeOf:n$1}=Object,a=globalThis,c=a.trustedTypes,l=c?c.emptyScript:"",p=a.reactiveElementPolyfillSupport,d=(t,s)=>t,u={toAttribute(t,s){switch(s){case Boolean:t=t?l:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,s){let i=t;switch(s){case Boolean:i=null!==t;break;case Number:i=null===t?null:Number(t);break;case Object:case Array:try{i=JSON.parse(t);}catch(t){i=null;}}return i}},f=(t,s)=>!i(t,s),b={attribute:true,type:String,converter:u,reflect:false,useDefault:false,hasChanged:f};Symbol.metadata??=Symbol("metadata"),a.litPropertyMetadata??=new WeakMap;class y extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??=[]).push(t);}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,s=b){if(s.state&&(s.attribute=false),this._$Ei(),this.prototype.hasOwnProperty(t)&&((s=Object.create(s)).wrapped=true),this.elementProperties.set(t,s),!s.noAccessor){const i=Symbol(),h=this.getPropertyDescriptor(t,i,s);void 0!==h&&e$2(this.prototype,t,h);}}static getPropertyDescriptor(t,s,i){const{get:e,set:r}=h(this.prototype,t)??{get(){return this[s]},set(t){this[s]=t;}};return {get:e,set(s){const h=e?.call(this);r?.call(this,s),this.requestUpdate(t,h,i);},configurable:true,enumerable:true}}static getPropertyOptions(t){return this.elementProperties.get(t)??b}static _$Ei(){if(this.hasOwnProperty(d("elementProperties")))return;const t=n$1(this);t.finalize(),void 0!==t.l&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties);}static finalize(){if(this.hasOwnProperty(d("finalized")))return;if(this.finalized=true,this._$Ei(),this.hasOwnProperty(d("properties"))){const t=this.properties,s=[...r$2(t),...o$1(t)];for(const i of s)this.createProperty(i,t[i]);}const t=this[Symbol.metadata];if(null!==t){const s=litPropertyMetadata.get(t);if(void 0!==s)for(const[t,i]of s)this.elementProperties.set(t,i);}this._$Eh=new Map;for(const[t,s]of this.elementProperties){const i=this._$Eu(t,s);void 0!==i&&this._$Eh.set(i,t);}this.elementStyles=this.finalizeStyles(this.styles);}static finalizeStyles(s){const i=[];if(Array.isArray(s)){const e=new Set(s.flat(1/0).reverse());for(const s of e)i.unshift(c$1(s));}else void 0!==s&&i.push(c$1(s));return i}static _$Eu(t,s){const i=s.attribute;return false===i?void 0:"string"==typeof i?i:"string"==typeof t?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=false,this.hasUpdated=false,this._$Em=null,this._$Ev();}_$Ev(){this._$ES=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((t=>t(this)));}addController(t){(this._$EO??=new Set).add(t),void 0!==this.renderRoot&&this.isConnected&&t.hostConnected?.();}removeController(t){this._$EO?.delete(t);}_$E_(){const t=new Map,s=this.constructor.elementProperties;for(const i of s.keys())this.hasOwnProperty(i)&&(t.set(i,this[i]),delete this[i]);t.size>0&&(this._$Ep=t);}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return S(t,this.constructor.elementStyles),t}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(true),this._$EO?.forEach((t=>t.hostConnected?.()));}enableUpdating(t){}disconnectedCallback(){this._$EO?.forEach((t=>t.hostDisconnected?.()));}attributeChangedCallback(t,s,i){this._$AK(t,i);}_$ET(t,s){const i=this.constructor.elementProperties.get(t),e=this.constructor._$Eu(t,i);if(void 0!==e&&true===i.reflect){const h=(void 0!==i.converter?.toAttribute?i.converter:u).toAttribute(s,i.type);this._$Em=t,null==h?this.removeAttribute(e):this.setAttribute(e,h),this._$Em=null;}}_$AK(t,s){const i=this.constructor,e=i._$Eh.get(t);if(void 0!==e&&this._$Em!==e){const t=i.getPropertyOptions(e),h="function"==typeof t.converter?{fromAttribute:t.converter}:void 0!==t.converter?.fromAttribute?t.converter:u;this._$Em=e;const r=h.fromAttribute(s,t.type);this[e]=r??this._$Ej?.get(e)??r,this._$Em=null;}}requestUpdate(t,s,i){if(void 0!==t){const e=this.constructor,h=this[t];if(i??=e.getPropertyOptions(t),!((i.hasChanged??f)(h,s)||i.useDefault&&i.reflect&&h===this._$Ej?.get(t)&&!this.hasAttribute(e._$Eu(t,i))))return;this.C(t,s,i);} false===this.isUpdatePending&&(this._$ES=this._$EP());}C(t,s,{useDefault:i,reflect:e,wrapped:h},r){i&&!(this._$Ej??=new Map).has(t)&&(this._$Ej.set(t,r??s??this[t]),true!==h||void 0!==r)||(this._$AL.has(t)||(this.hasUpdated||i||(s=void 0),this._$AL.set(t,s)),true===e&&this._$Em!==t&&(this._$Eq??=new Set).add(t));}async _$EP(){this.isUpdatePending=true;try{await this._$ES;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[t,s]of this._$Ep)this[t]=s;this._$Ep=void 0;}const t=this.constructor.elementProperties;if(t.size>0)for(const[s,i]of t){const{wrapped:t}=i,e=this[s];true!==t||this._$AL.has(s)||void 0===e||this.C(s,void 0,i,e);}}let t=false;const s=this._$AL;try{t=this.shouldUpdate(s),t?(this.willUpdate(s),this._$EO?.forEach((t=>t.hostUpdate?.())),this.update(s)):this._$EM();}catch(s){throw t=false,this._$EM(),s}t&&this._$AE(s);}willUpdate(t){}_$AE(t){this._$EO?.forEach((t=>t.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=true,this.firstUpdated(t)),this.updated(t);}_$EM(){this._$AL=new Map,this.isUpdatePending=false;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return true}update(t){this._$Eq&&=this._$Eq.forEach((t=>this._$ET(t,this[t]))),this._$EM();}updated(t){}firstUpdated(t){}}y.elementStyles=[],y.shadowRootOptions={mode:"open"},y[d("elementProperties")]=new Map,y[d("finalized")]=new Map,p?.({ReactiveElement:y}),(a.reactiveElementVersions??=[]).push("2.1.1");
105
+ */
106
+ const {
107
+ is: i,
108
+ defineProperty: e$2,
109
+ getOwnPropertyDescriptor: h,
110
+ getOwnPropertyNames: r$2,
111
+ getOwnPropertySymbols: o$1,
112
+ getPrototypeOf: n$1
113
+ } = Object,
114
+ a = globalThis,
115
+ c = a.trustedTypes,
116
+ l = c ? c.emptyScript : "",
117
+ p = a.reactiveElementPolyfillSupport,
118
+ d = (t, s) => t,
119
+ u = {
120
+ toAttribute(t, s) {
121
+ switch (s) {
122
+ case Boolean:
123
+ t = t ? l : null;
124
+ break;
125
+ case Object:
126
+ case Array:
127
+ t = null == t ? t : JSON.stringify(t);
128
+ }
129
+ return t;
130
+ },
131
+ fromAttribute(t, s) {
132
+ let i = t;
133
+ switch (s) {
134
+ case Boolean:
135
+ i = null !== t;
136
+ break;
137
+ case Number:
138
+ i = null === t ? null : Number(t);
139
+ break;
140
+ case Object:
141
+ case Array:
142
+ try {
143
+ i = JSON.parse(t);
144
+ } catch (t) {
145
+ i = null;
146
+ }
147
+ }
148
+ return i;
149
+ }
150
+ },
151
+ f = (t, s) => !i(t, s),
152
+ b = {
153
+ attribute: true,
154
+ type: String,
155
+ converter: u,
156
+ reflect: false,
157
+ useDefault: false,
158
+ hasChanged: f
159
+ };
160
+ Symbol.metadata ??= Symbol("metadata"), a.litPropertyMetadata ??= new WeakMap();
161
+ class y extends HTMLElement {
162
+ static addInitializer(t) {
163
+ this._$Ei(), (this.l ??= []).push(t);
164
+ }
165
+ static get observedAttributes() {
166
+ return this.finalize(), this._$Eh && [...this._$Eh.keys()];
167
+ }
168
+ static createProperty(t, s = b) {
169
+ if (s.state && (s.attribute = false), this._$Ei(), this.prototype.hasOwnProperty(t) && ((s = Object.create(s)).wrapped = true), this.elementProperties.set(t, s), !s.noAccessor) {
170
+ const i = Symbol(),
171
+ h = this.getPropertyDescriptor(t, i, s);
172
+ void 0 !== h && e$2(this.prototype, t, h);
173
+ }
174
+ }
175
+ static getPropertyDescriptor(t, s, i) {
176
+ const {
177
+ get: e,
178
+ set: r
179
+ } = h(this.prototype, t) ?? {
180
+ get() {
181
+ return this[s];
182
+ },
183
+ set(t) {
184
+ this[s] = t;
185
+ }
186
+ };
187
+ return {
188
+ get: e,
189
+ set(s) {
190
+ const h = e?.call(this);
191
+ r?.call(this, s), this.requestUpdate(t, h, i);
192
+ },
193
+ configurable: true,
194
+ enumerable: true
195
+ };
196
+ }
197
+ static getPropertyOptions(t) {
198
+ return this.elementProperties.get(t) ?? b;
199
+ }
200
+ static _$Ei() {
201
+ if (this.hasOwnProperty(d("elementProperties"))) return;
202
+ const t = n$1(this);
203
+ t.finalize(), void 0 !== t.l && (this.l = [...t.l]), this.elementProperties = new Map(t.elementProperties);
204
+ }
205
+ static finalize() {
206
+ if (this.hasOwnProperty(d("finalized"))) return;
207
+ if (this.finalized = true, this._$Ei(), this.hasOwnProperty(d("properties"))) {
208
+ const t = this.properties,
209
+ s = [...r$2(t), ...o$1(t)];
210
+ for (const i of s) this.createProperty(i, t[i]);
211
+ }
212
+ const t = this[Symbol.metadata];
213
+ if (null !== t) {
214
+ const s = litPropertyMetadata.get(t);
215
+ if (void 0 !== s) for (const [t, i] of s) this.elementProperties.set(t, i);
216
+ }
217
+ this._$Eh = new Map();
218
+ for (const [t, s] of this.elementProperties) {
219
+ const i = this._$Eu(t, s);
220
+ void 0 !== i && this._$Eh.set(i, t);
221
+ }
222
+ this.elementStyles = this.finalizeStyles(this.styles);
223
+ }
224
+ static finalizeStyles(s) {
225
+ const i = [];
226
+ if (Array.isArray(s)) {
227
+ const e = new Set(s.flat(1 / 0).reverse());
228
+ for (const s of e) i.unshift(c$1(s));
229
+ } else void 0 !== s && i.push(c$1(s));
230
+ return i;
231
+ }
232
+ static _$Eu(t, s) {
233
+ const i = s.attribute;
234
+ return false === i ? void 0 : "string" == typeof i ? i : "string" == typeof t ? t.toLowerCase() : void 0;
235
+ }
236
+ constructor() {
237
+ super(), this._$Ep = void 0, this.isUpdatePending = false, this.hasUpdated = false, this._$Em = null, this._$Ev();
238
+ }
239
+ _$Ev() {
240
+ this._$ES = new Promise(t => this.enableUpdating = t), this._$AL = new Map(), this._$E_(), this.requestUpdate(), this.constructor.l?.forEach(t => t(this));
241
+ }
242
+ addController(t) {
243
+ (this._$EO ??= new Set()).add(t), void 0 !== this.renderRoot && this.isConnected && t.hostConnected?.();
244
+ }
245
+ removeController(t) {
246
+ this._$EO?.delete(t);
247
+ }
248
+ _$E_() {
249
+ const t = new Map(),
250
+ s = this.constructor.elementProperties;
251
+ for (const i of s.keys()) this.hasOwnProperty(i) && (t.set(i, this[i]), delete this[i]);
252
+ t.size > 0 && (this._$Ep = t);
253
+ }
254
+ createRenderRoot() {
255
+ const t = this.shadowRoot ?? this.attachShadow(this.constructor.shadowRootOptions);
256
+ return S(t, this.constructor.elementStyles), t;
257
+ }
258
+ connectedCallback() {
259
+ this.renderRoot ??= this.createRenderRoot(), this.enableUpdating(true), this._$EO?.forEach(t => t.hostConnected?.());
260
+ }
261
+ enableUpdating(t) {}
262
+ disconnectedCallback() {
263
+ this._$EO?.forEach(t => t.hostDisconnected?.());
264
+ }
265
+ attributeChangedCallback(t, s, i) {
266
+ this._$AK(t, i);
267
+ }
268
+ _$ET(t, s) {
269
+ const i = this.constructor.elementProperties.get(t),
270
+ e = this.constructor._$Eu(t, i);
271
+ if (void 0 !== e && true === i.reflect) {
272
+ const h = (void 0 !== i.converter?.toAttribute ? i.converter : u).toAttribute(s, i.type);
273
+ this._$Em = t, null == h ? this.removeAttribute(e) : this.setAttribute(e, h), this._$Em = null;
274
+ }
275
+ }
276
+ _$AK(t, s) {
277
+ const i = this.constructor,
278
+ e = i._$Eh.get(t);
279
+ if (void 0 !== e && this._$Em !== e) {
280
+ const t = i.getPropertyOptions(e),
281
+ h = "function" == typeof t.converter ? {
282
+ fromAttribute: t.converter
283
+ } : void 0 !== t.converter?.fromAttribute ? t.converter : u;
284
+ this._$Em = e;
285
+ const r = h.fromAttribute(s, t.type);
286
+ this[e] = r ?? this._$Ej?.get(e) ?? r, this._$Em = null;
287
+ }
288
+ }
289
+ requestUpdate(t, s, i) {
290
+ if (void 0 !== t) {
291
+ const e = this.constructor,
292
+ h = this[t];
293
+ if (i ??= e.getPropertyOptions(t), !((i.hasChanged ?? f)(h, s) || i.useDefault && i.reflect && h === this._$Ej?.get(t) && !this.hasAttribute(e._$Eu(t, i)))) return;
294
+ this.C(t, s, i);
295
+ }
296
+ false === this.isUpdatePending && (this._$ES = this._$EP());
297
+ }
298
+ C(t, s, {
299
+ useDefault: i,
300
+ reflect: e,
301
+ wrapped: h
302
+ }, r) {
303
+ i && !(this._$Ej ??= new Map()).has(t) && (this._$Ej.set(t, r ?? s ?? this[t]), true !== h || void 0 !== r) || (this._$AL.has(t) || (this.hasUpdated || i || (s = void 0), this._$AL.set(t, s)), true === e && this._$Em !== t && (this._$Eq ??= new Set()).add(t));
304
+ }
305
+ async _$EP() {
306
+ this.isUpdatePending = true;
307
+ try {
308
+ await this._$ES;
309
+ } catch (t) {
310
+ Promise.reject(t);
311
+ }
312
+ const t = this.scheduleUpdate();
313
+ return null != t && (await t), !this.isUpdatePending;
314
+ }
315
+ scheduleUpdate() {
316
+ return this.performUpdate();
317
+ }
318
+ performUpdate() {
319
+ if (!this.isUpdatePending) return;
320
+ if (!this.hasUpdated) {
321
+ if (this.renderRoot ??= this.createRenderRoot(), this._$Ep) {
322
+ for (const [t, s] of this._$Ep) this[t] = s;
323
+ this._$Ep = void 0;
324
+ }
325
+ const t = this.constructor.elementProperties;
326
+ if (t.size > 0) for (const [s, i] of t) {
327
+ const {
328
+ wrapped: t
329
+ } = i,
330
+ e = this[s];
331
+ true !== t || this._$AL.has(s) || void 0 === e || this.C(s, void 0, i, e);
332
+ }
333
+ }
334
+ let t = false;
335
+ const s = this._$AL;
336
+ try {
337
+ t = this.shouldUpdate(s), t ? (this.willUpdate(s), this._$EO?.forEach(t => t.hostUpdate?.()), this.update(s)) : this._$EM();
338
+ } catch (s) {
339
+ throw t = false, this._$EM(), s;
340
+ }
341
+ t && this._$AE(s);
342
+ }
343
+ willUpdate(t) {}
344
+ _$AE(t) {
345
+ this._$EO?.forEach(t => t.hostUpdated?.()), this.hasUpdated || (this.hasUpdated = true, this.firstUpdated(t)), this.updated(t);
346
+ }
347
+ _$EM() {
348
+ this._$AL = new Map(), this.isUpdatePending = false;
349
+ }
350
+ get updateComplete() {
351
+ return this.getUpdateComplete();
352
+ }
353
+ getUpdateComplete() {
354
+ return this._$ES;
355
+ }
356
+ shouldUpdate(t) {
357
+ return true;
358
+ }
359
+ update(t) {
360
+ this._$Eq &&= this._$Eq.forEach(t => this._$ET(t, this[t])), this._$EM();
361
+ }
362
+ updated(t) {}
363
+ firstUpdated(t) {}
364
+ }
365
+ y.elementStyles = [], y.shadowRootOptions = {
366
+ mode: "open"
367
+ }, y[d("elementProperties")] = new Map(), y[d("finalized")] = new Map(), p?.({
368
+ ReactiveElement: y
369
+ }), (a.reactiveElementVersions ??= []).push("2.1.1");
71
370
 
72
371
  /**
73
372
  * @license
74
373
  * Copyright 2017 Google LLC
75
374
  * SPDX-License-Identifier: BSD-3-Clause
76
- */const o={attribute:true,type:String,converter:u,reflect:false,hasChanged:f},r$1=(t=o,e,r)=>{const{kind:n,metadata:i}=r;let s=globalThis.litPropertyMetadata.get(i);if(void 0===s&&globalThis.litPropertyMetadata.set(i,s=new Map),"setter"===n&&((t=Object.create(t)).wrapped=true),s.set(r.name,t),"accessor"===n){const{name:o}=r;return {set(r){const n=e.get.call(this);e.set.call(this,r),this.requestUpdate(o,n,t);},init(e){return void 0!==e&&this.C(o,void 0,t,e),e}}}if("setter"===n){const{name:o}=r;return function(r){const n=this[o];e.call(this,r),this.requestUpdate(o,n,t);}}throw Error("Unsupported decorator location: "+n)};function n(t){return (e,o)=>"object"==typeof o?r$1(t,e,o):((t,e,o)=>{const r=e.hasOwnProperty(o);return e.constructor.createProperty(o,t),r?Object.getOwnPropertyDescriptor(e,o):void 0})(t,e,o)}
375
+ */
376
+ const o = {
377
+ attribute: true,
378
+ type: String,
379
+ converter: u,
380
+ reflect: false,
381
+ hasChanged: f
382
+ },
383
+ r$1 = (t = o, e, r) => {
384
+ const {
385
+ kind: n,
386
+ metadata: i
387
+ } = r;
388
+ let s = globalThis.litPropertyMetadata.get(i);
389
+ if (void 0 === s && globalThis.litPropertyMetadata.set(i, s = new Map()), "setter" === n && ((t = Object.create(t)).wrapped = true), s.set(r.name, t), "accessor" === n) {
390
+ const {
391
+ name: o
392
+ } = r;
393
+ return {
394
+ set(r) {
395
+ const n = e.get.call(this);
396
+ e.set.call(this, r), this.requestUpdate(o, n, t);
397
+ },
398
+ init(e) {
399
+ return void 0 !== e && this.C(o, void 0, t, e), e;
400
+ }
401
+ };
402
+ }
403
+ if ("setter" === n) {
404
+ const {
405
+ name: o
406
+ } = r;
407
+ return function (r) {
408
+ const n = this[o];
409
+ e.call(this, r), this.requestUpdate(o, n, t);
410
+ };
411
+ }
412
+ throw Error("Unsupported decorator location: " + n);
413
+ };
414
+ function n(t) {
415
+ return (e, o) => "object" == typeof o ? r$1(t, e, o) : ((t, e, o) => {
416
+ const r = e.hasOwnProperty(o);
417
+ return e.constructor.createProperty(o, t), r ? Object.getOwnPropertyDescriptor(e, o) : void 0;
418
+ })(t, e, o);
419
+ }
77
420
 
78
421
  /**
79
422
  * @license
80
423
  * Copyright 2017 Google LLC
81
424
  * SPDX-License-Identifier: BSD-3-Clause
82
- */function r(r){return n({...r,state:true,attribute:false})}
425
+ */
426
+ function r(r) {
427
+ return n({
428
+ ...r,
429
+ state: true,
430
+ attribute: false
431
+ });
432
+ }
83
433
 
84
434
  /**
85
435
  * @license
86
436
  * Copyright 2017 Google LLC
87
437
  * SPDX-License-Identifier: BSD-3-Clause
88
438
  */
89
- const e$1=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"object"!=typeof t&&Object.defineProperty(e,t,c),c);
439
+ const e$1 = (e, t, c) => (c.configurable = true, c.enumerable = true, Reflect.decorate && "object" != typeof t && Object.defineProperty(e, t, c), c);
90
440
 
91
441
  /**
92
442
  * @license
93
443
  * Copyright 2017 Google LLC
94
444
  * SPDX-License-Identifier: BSD-3-Clause
95
- */function e(e,r){return (n,s,i)=>{const o=t=>t.renderRoot?.querySelector(e)??null;return e$1(n,s,{get(){return o(this)}})}}
445
+ */
446
+ function e(e, r) {
447
+ return (n, s, i) => {
448
+ const o = t => t.renderRoot?.querySelector(e) ?? null;
449
+ return e$1(n, s, {
450
+ get() {
451
+ return o(this);
452
+ }
453
+ });
454
+ };
455
+ }
96
456
 
97
457
  /**
98
458
  * An item in a table of contents.
@@ -121,141 +481,82 @@ const e$1=(e,t,c)=>(c.configurable=true,c.enumerable=true,Reflect.decorate&&"obj
121
481
  * @cssprop --m3e-toc-item-selected-color - Text color for selected items.
122
482
  */
123
483
  let M3eTocItemElement = class M3eTocItemElement extends Selected(Disabled(AttachInternals(Role(LitElement, "link")))) {
124
- /** @internal */
125
- update(changedProperties) {
126
- super.update(changedProperties);
127
- if (changedProperties.has("selected")) {
128
- this.ariaSelected = null;
129
- this.ariaCurrent = this.selected ? "true" : null;
130
- }
131
- if (changedProperties.has("node")) {
132
- if (this.node) {
133
- this._base?.style.setProperty("--_level", `${this.node.level - 1}`);
134
- }
135
- else {
136
- this._base?.style.removeProperty("--_level");
137
- }
138
- }
139
- }
140
- /** @inheritdoc */
141
- firstUpdated(_changedProperties) {
142
- super.firstUpdated(_changedProperties);
143
- this._stateLayer?.attach(this);
484
+ /** @internal */
485
+ update(changedProperties) {
486
+ super.update(changedProperties);
487
+ if (changedProperties.has("selected")) {
488
+ this.ariaSelected = null;
489
+ this.ariaCurrent = this.selected ? "true" : null;
144
490
  }
145
- /** @inheritdoc */
146
- render() {
147
- return html `<m3e-state-layer class="state-layer"></m3e-state-layer>
148
- <div class="base"><slot></slot></div>`;
491
+ if (changedProperties.has("node")) {
492
+ if (this.node) {
493
+ this._base?.style.setProperty("--_level", `${this.node.level - 1}`);
494
+ } else {
495
+ this._base?.style.removeProperty("--_level");
496
+ }
149
497
  }
498
+ }
499
+ /** @inheritdoc */
500
+ firstUpdated(_changedProperties) {
501
+ super.firstUpdated(_changedProperties);
502
+ this._stateLayer?.attach(this);
503
+ }
504
+ /** @inheritdoc */
505
+ render() {
506
+ return html`<m3e-state-layer class="state-layer"></m3e-state-layer><div class="base"><slot></slot></div>`;
507
+ }
150
508
  };
151
509
  /** The styles of the element. */
152
- M3eTocItemElement.styles = css `
153
- :host {
154
- display: inline-block;
155
- position: relative;
156
- user-select: none;
157
- outline: none;
158
- border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased});
159
- padding-block: var(--m3e-toc-item-padding-block, 0.5rem);
160
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
161
- }
162
- :host(:not(:disabled)) {
163
- cursor: pointer;
164
- }
165
- .base {
166
- padding-inline-start: calc(
167
- var(--m3e-toc-item-padding, 1rem) + calc(var(--m3e-toc-item-inset, 0.75rem) * var(--_level, 0))
168
- );
169
- padding-inline-end: var(--m3e-toc-item-padding, 1rem);
170
- transition: ${unsafeCSS(`color var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1}) ${DesignToken.motion.easing.standard}`)};
171
- }
172
- :host(:not([selected])) {
173
- font-size: var(--m3e-toc-item-font-size, ${DesignToken.typescale.standard.body.large.fontSize});
174
- font-weight: var(--m3e-toc-item-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight});
175
- line-height: var(--m3e-toc-item-line-height, ${DesignToken.typescale.standard.body.large.lineHeight});
176
- letter-spacing: var(--m3e-toc-item-tracking, ${DesignToken.typescale.standard.body.large.tracking});
177
- color: var(--m3e-toc-item-color, ${DesignToken.color.onSurfaceVariant});
178
- }
179
- :host([selected]) {
180
- font-size: var(--m3e-toc-item-selected-font-size, ${DesignToken.typescale.emphasized.body.large.fontSize});
181
- font-weight: var(--m3e-toc-item-selected-font-weight, ${DesignToken.typescale.emphasized.body.large.fontWeight});
182
- line-height: var(--m3e-toc-item-selected-line-height, ${DesignToken.typescale.emphasized.body.large.lineHeight});
183
- letter-spacing: var(--m3e-toc-item-selected-tracking, ${DesignToken.typescale.emphasized.body.large.tracking});
184
- color: var(--m3e-toc-item-selected-color, ${DesignToken.color.onSecondaryContainer});
185
- }
186
- .base {
187
- justify-content: unset;
188
- }
189
- .state-layer {
190
- --m3e-state-layer-focus-opacity: 0;
191
- }
192
- @media (prefers-reduced-motion) {
193
- .base {
194
- transition: none;
195
- }
196
- }
197
- `;
198
- __decorate([
199
- e(".base")
200
- ], M3eTocItemElement.prototype, "_base", void 0);
201
- __decorate([
202
- e(".state-layer")
203
- ], M3eTocItemElement.prototype, "_stateLayer", void 0);
204
- __decorate([
205
- r()
206
- ], M3eTocItemElement.prototype, "node", void 0);
207
- M3eTocItemElement = __decorate([
208
- t$1("m3e-toc-item")
209
- ], M3eTocItemElement);
510
+ M3eTocItemElement.styles = css`:host { display: inline-block; position: relative; user-select: none; outline: none; border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased}); padding-block: var(--m3e-toc-item-padding-block, 0.5rem); -webkit-tap-highlight-color: rgba(0, 0, 0, 0); } :host(:not(:disabled)) { cursor: pointer; } .base { padding-inline-start: calc( var(--m3e-toc-item-padding, 1rem) + calc(var(--m3e-toc-item-inset, 0.75rem) * var(--_level, 0)) ); padding-inline-end: var(--m3e-toc-item-padding, 1rem); transition: ${unsafeCSS(`color var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1}) ${DesignToken.motion.easing.standard}`)}; } :host(:not([selected])) { font-size: var(--m3e-toc-item-font-size, ${DesignToken.typescale.standard.body.large.fontSize}); font-weight: var(--m3e-toc-item-font-weight, ${DesignToken.typescale.standard.body.large.fontWeight}); line-height: var(--m3e-toc-item-line-height, ${DesignToken.typescale.standard.body.large.lineHeight}); letter-spacing: var(--m3e-toc-item-tracking, ${DesignToken.typescale.standard.body.large.tracking}); color: var(--m3e-toc-item-color, ${DesignToken.color.onSurfaceVariant}); } :host([selected]) { font-size: var(--m3e-toc-item-selected-font-size, ${DesignToken.typescale.emphasized.body.large.fontSize}); font-weight: var(--m3e-toc-item-selected-font-weight, ${DesignToken.typescale.emphasized.body.large.fontWeight}); line-height: var(--m3e-toc-item-selected-line-height, ${DesignToken.typescale.emphasized.body.large.lineHeight}); letter-spacing: var(--m3e-toc-item-selected-tracking, ${DesignToken.typescale.emphasized.body.large.tracking}); color: var(--m3e-toc-item-selected-color, ${DesignToken.color.onSecondaryContainer}); } .base { justify-content: unset; } .state-layer { --m3e-state-layer-focus-opacity: 0; } @media (prefers-reduced-motion) { .base { transition: none; } }`;
511
+ __decorate([e(".base")], M3eTocItemElement.prototype, "_base", void 0);
512
+ __decorate([e(".state-layer")], M3eTocItemElement.prototype, "_stateLayer", void 0);
513
+ __decorate([r()], M3eTocItemElement.prototype, "node", void 0);
514
+ M3eTocItemElement = __decorate([t$1("m3e-toc-item")], M3eTocItemElement);
210
515
 
211
516
  var _a, _TocGenerator_getHeaderLevel;
212
517
  /** Provides functionality used to generate a table of contents used for in-page navigation. */
213
518
  class TocGenerator {
214
- /**
215
- * Generates nodes from which to construct a table of contents for in-page navigation.
216
- * @param {HTMLElement} element The element for which to generate a table of contents.
217
- * @param {number} [maxDepth=6] The maximum depth of the table of contents.
218
- * @returns {Array<TocNode>} The top-level nodes of the table of contents.
219
- */
220
- static generate(element, maxDepth = 6) {
221
- const maxLevel = 6;
222
- let topLevel = maxLevel;
223
- const nodes = new Array();
224
- element
225
- .querySelectorAll("h1:not([m3e-toc-ignore]),h2:not([m3e-toc-ignore]),h3:not([m3e-toc-ignore]),h4:not([m3e-toc-ignore]),h5:not([m3e-toc-ignore]),h6:not([m3e-toc-ignore]),m3e-heading[level]:not([m3e-toc-ignore])")
226
- .forEach((element) => {
227
- const level = __classPrivateFieldGet(_a, _a, "m", _TocGenerator_getHeaderLevel).call(_a, element);
228
- topLevel = Math.min(level, topLevel);
229
- nodes.push({
230
- id: element.id || guid(),
231
- element,
232
- level,
233
- label: getTextContent(element, true),
234
- nodes: new Array(),
235
- });
236
- });
237
- for (let level = topLevel + maxDepth - 1; level > topLevel; level--) {
238
- for (let i = 0; i < nodes.length; i++) {
239
- const node = nodes[i];
240
- if (node.level === level) {
241
- for (let j = i; j >= 0; j--) {
242
- const prev = nodes[j];
243
- if (prev.level < level) {
244
- prev.nodes.push(node);
245
- break;
246
- }
247
- }
248
- }
519
+ /**
520
+ * Generates nodes from which to construct a table of contents for in-page navigation.
521
+ * @param {HTMLElement} element The element for which to generate a table of contents.
522
+ * @param {number} [maxDepth=6] The maximum depth of the table of contents.
523
+ * @returns {Array<TocNode>} The top-level nodes of the table of contents.
524
+ */
525
+ static generate(element, maxDepth = 6) {
526
+ const maxLevel = 6;
527
+ let topLevel = maxLevel;
528
+ const nodes = new Array();
529
+ element.querySelectorAll("h1:not([m3e-toc-ignore]),h2:not([m3e-toc-ignore]),h3:not([m3e-toc-ignore]),h4:not([m3e-toc-ignore]),h5:not([m3e-toc-ignore]),h6:not([m3e-toc-ignore]),m3e-heading[level]:not([m3e-toc-ignore])").forEach(element => {
530
+ const level = __classPrivateFieldGet(_a, _a, "m", _TocGenerator_getHeaderLevel).call(_a, element);
531
+ topLevel = Math.min(level, topLevel);
532
+ nodes.push({
533
+ id: element.id || guid(),
534
+ element,
535
+ level,
536
+ label: getTextContent(element, true),
537
+ nodes: new Array()
538
+ });
539
+ });
540
+ for (let level = topLevel + maxDepth - 1; level > topLevel; level--) {
541
+ for (let i = 0; i < nodes.length; i++) {
542
+ const node = nodes[i];
543
+ if (node.level === level) {
544
+ for (let j = i; j >= 0; j--) {
545
+ const prev = nodes[j];
546
+ if (prev.level < level) {
547
+ prev.nodes.push(node);
548
+ break;
249
549
  }
550
+ }
250
551
  }
251
- nodes.forEach((x) => (x.level -= topLevel - 1));
252
- return nodes.filter((x) => x.level === 1);
552
+ }
253
553
  }
554
+ nodes.forEach(x => x.level -= topLevel - 1);
555
+ return nodes.filter(x => x.level === 1);
556
+ }
254
557
  }
255
558
  _a = TocGenerator, _TocGenerator_getHeaderLevel = function _TocGenerator_getHeaderLevel(element) {
256
- return element.tagName.startsWith("H")
257
- ? parseInt(element.tagName.substring(1))
258
- : parseInt(element.getAttribute("level") ?? "0");
559
+ return element.tagName.startsWith("H") ? parseInt(element.tagName.substring(1)) : parseInt(element.getAttribute("level") ?? "0");
259
560
  };
260
561
 
261
562
  var _M3eTocElement_instances, _M3eTocElement_ignoreScroll, _M3eTocElement_selectionManager, _M3eTocElement_intersectionController, _M3eTocElement_scrollController, _M3eTocElement_mutationController, _M3eTocElement_renderNode, _M3eTocElement_handleOverlineSlotChange, _M3eTocElement_handleTitleSlotChange, _M3eTocElement_handleClick, _M3eTocElement_generateToc;
@@ -313,150 +614,136 @@ var _M3eTocElement_instances, _M3eTocElement_ignoreScroll, _M3eTocElement_select
313
614
  * @cssprop --m3e-toc-title-color - Text color for the title slot.
314
615
  */
315
616
  let M3eTocElement = class M3eTocElement extends HtmlFor(AttachInternals(Role(LitElement, "navigation"))) {
316
- constructor() {
317
- super(...arguments);
318
- _M3eTocElement_instances.add(this);
319
- /** @private */ this._toc = [];
320
- /** @private */ _M3eTocElement_ignoreScroll.set(this, false);
321
- /** @private */ _M3eTocElement_selectionManager.set(this, new SelectionManager()
322
- .withHomeAndEnd()
323
- .withVerticalOrientation()
324
- .disableRovingTabIndex()
325
- .onSelectedItemsChange(() => {
326
- if (this._activeIndicator) {
327
- const item = __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").selectedItems[0];
328
- if (!item) {
329
- this.classList.toggle("-no-animate", true);
330
- this._activeIndicator.style.top = `0px`;
331
- this._activeIndicator.style.height = `0px`;
332
- this._activeIndicator.style.visibility = "hidden";
333
- }
334
- else {
335
- scrollIntoViewIfNeeded(item, this, { block: "nearest", behavior: "smooth" });
336
- this._activeIndicator.style.top = `${item.offsetTop}px`;
337
- this._activeIndicator.style.height = `${item.clientHeight}px`;
338
- this._activeIndicator.style.visibility = item.clientHeight == 0 ? "hidden" : "";
339
- if (this.classList.contains("-no-animate")) {
340
- setTimeout(() => this.classList.toggle("-no-animate", false), 40);
341
- }
342
- }
343
- }
344
- }));
345
- /** @private */
346
- _M3eTocElement_intersectionController.set(this, new IntersectionController(this, {
347
- target: null,
348
- callback: (entries) => {
349
- if (!this.control || __classPrivateFieldGet(this, _M3eTocElement_ignoreScroll, "f"))
350
- return;
351
- const targetOffset = this.control.scrollTop;
352
- let closestElement = null;
353
- let closestDistance = Number.POSITIVE_INFINITY;
354
- entries
355
- .filter((x) => x.isIntersecting)
356
- .map((x) => x.target)
357
- .forEach((item) => {
358
- const offsetTop = item.offsetTop;
359
- const distance = Math.abs(offsetTop - targetOffset);
360
- if (distance < closestDistance) {
361
- closestDistance = distance;
362
- closestElement = item;
363
- }
364
- });
365
- if (closestElement) {
366
- const item = __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").items.find((x) => x.node?.element === closestElement);
367
- if (item) {
368
- __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").select(item);
369
- }
370
- }
371
- },
372
- }));
373
- /** @private */
374
- _M3eTocElement_scrollController.set(this, new ScrollController(this, {
375
- target: null,
376
- callback: () => (__classPrivateFieldSet(this, _M3eTocElement_ignoreScroll, false, "f")),
377
- debounce: true,
378
- }));
379
- /** @private */
380
- _M3eTocElement_mutationController.set(this, new MutationController(this, {
381
- target: null,
382
- config: {
383
- childList: true,
384
- subtree: true,
385
- },
386
- callback: () => this._updateToc(),
387
- }));
388
- /**
389
- * The maximum depth of the table of contents.
390
- * @default 2
391
- */
392
- this.maxDepth = 2;
393
- }
394
- /** @inheritdoc */
395
- attach(control) {
396
- super.attach(control);
397
- __classPrivateFieldGet(this, _M3eTocElement_mutationController, "f").observe(control);
398
- __classPrivateFieldGet(this, _M3eTocElement_scrollController, "f").observe(control);
399
- __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_generateToc).call(this);
400
- }
401
- /** @inheritdoc */
402
- detach() {
403
- if (this.control) {
404
- __classPrivateFieldGet(this, _M3eTocElement_mutationController, "f").unobserve(this.control);
405
- __classPrivateFieldGet(this, _M3eTocElement_scrollController, "f").unobserve(this.control);
406
- }
407
- super.detach();
408
- __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_generateToc).call(this);
409
- }
410
- /** @inheritdoc */
411
- update(changedProperties) {
412
- super.update(changedProperties);
413
- if (changedProperties.has("maxDepth")) {
414
- __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_generateToc).call(this);
617
+ constructor() {
618
+ super(...arguments);
619
+ _M3eTocElement_instances.add(this);
620
+ /** @private */
621
+ this._toc = [];
622
+ /** @private */
623
+ _M3eTocElement_ignoreScroll.set(this, false);
624
+ /** @private */
625
+ _M3eTocElement_selectionManager.set(this, new SelectionManager().withHomeAndEnd().withVerticalOrientation().disableRovingTabIndex().onSelectedItemsChange(() => {
626
+ if (this._activeIndicator) {
627
+ const item = __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").selectedItems[0];
628
+ if (!item) {
629
+ this.classList.toggle("-no-animate", true);
630
+ this._activeIndicator.style.top = `0px`;
631
+ this._activeIndicator.style.height = `0px`;
632
+ this._activeIndicator.style.visibility = "hidden";
633
+ } else {
634
+ scrollIntoViewIfNeeded(item, this, {
635
+ block: "nearest",
636
+ behavior: "smooth"
637
+ });
638
+ this._activeIndicator.style.top = `${item.offsetTop}px`;
639
+ this._activeIndicator.style.height = `${item.clientHeight}px`;
640
+ this._activeIndicator.style.visibility = item.clientHeight == 0 ? "hidden" : "";
641
+ if (this.classList.contains("-no-animate")) {
642
+ setTimeout(() => this.classList.toggle("-no-animate", false), 40);
643
+ }
415
644
  }
416
- }
417
- /** @inheritdoc */
418
- updated(_changedProperties) {
419
- super.updated(_changedProperties);
420
- if (_changedProperties.has("_toc")) {
421
- const { added, removed } = __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").setItems([
422
- ...(this.shadowRoot?.querySelectorAll("m3e-toc-item") ?? []),
423
- ]);
424
- if (!__classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").activeItem) {
425
- this.classList.toggle("-no-animate", true);
426
- __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").updateActiveItem(added.find((x) => !x.disabled));
427
- }
428
- for (const item of added) {
429
- if (item.node) {
430
- __classPrivateFieldGet(this, _M3eTocElement_intersectionController, "f").observe(item.node.element);
431
- }
432
- }
433
- for (const item of removed) {
434
- if (item.node) {
435
- __classPrivateFieldGet(this, _M3eTocElement_intersectionController, "f").unobserve(item.node.element);
436
- }
437
- }
645
+ }
646
+ }));
647
+ /** @private */
648
+ _M3eTocElement_intersectionController.set(this, new IntersectionController(this, {
649
+ target: null,
650
+ callback: entries => {
651
+ if (!this.control || __classPrivateFieldGet(this, _M3eTocElement_ignoreScroll, "f")) return;
652
+ const targetOffset = this.control.scrollTop;
653
+ let closestElement = null;
654
+ let closestDistance = Number.POSITIVE_INFINITY;
655
+ entries.filter(x => x.isIntersecting).map(x => x.target).forEach(item => {
656
+ const offsetTop = item.offsetTop;
657
+ const distance = Math.abs(offsetTop - targetOffset);
658
+ if (distance < closestDistance) {
659
+ closestDistance = distance;
660
+ closestElement = item;
661
+ }
662
+ });
663
+ if (closestElement) {
664
+ const item = __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").items.find(x => x.node?.element === closestElement);
665
+ if (item) {
666
+ __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").select(item);
667
+ }
438
668
  }
669
+ }
670
+ }));
671
+ /** @private */
672
+ _M3eTocElement_scrollController.set(this, new ScrollController(this, {
673
+ target: null,
674
+ callback: () => __classPrivateFieldSet(this, _M3eTocElement_ignoreScroll, false, "f"),
675
+ debounce: true
676
+ }));
677
+ /** @private */
678
+ _M3eTocElement_mutationController.set(this, new MutationController(this, {
679
+ target: null,
680
+ config: {
681
+ childList: true,
682
+ subtree: true
683
+ },
684
+ callback: () => this._updateToc()
685
+ }));
686
+ /**
687
+ * The maximum depth of the table of contents.
688
+ * @default 2
689
+ */
690
+ this.maxDepth = 2;
691
+ }
692
+ /** @inheritdoc */
693
+ attach(control) {
694
+ super.attach(control);
695
+ __classPrivateFieldGet(this, _M3eTocElement_mutationController, "f").observe(control);
696
+ __classPrivateFieldGet(this, _M3eTocElement_scrollController, "f").observe(control);
697
+ __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_generateToc).call(this);
698
+ }
699
+ /** @inheritdoc */
700
+ detach() {
701
+ if (this.control) {
702
+ __classPrivateFieldGet(this, _M3eTocElement_mutationController, "f").unobserve(this.control);
703
+ __classPrivateFieldGet(this, _M3eTocElement_scrollController, "f").unobserve(this.control);
439
704
  }
440
- /** @inheritdoc */
441
- render() {
442
- return html `<div class="header">
443
- <div class="overline">
444
- <slot name="overline" @slotchange="${__classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_handleOverlineSlotChange)}"></slot>
445
- </div>
446
- <div class="title">
447
- <slot name="title" @slotchange="${__classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_handleTitleSlotChange)}"></slot>
448
- </div>
449
- </div>
450
- <slot></slot>
451
- <ul class="list">
452
- ${this._toc.map((x) => __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_renderNode).call(this, x))}
453
- </ul>
454
- <div class="active-indicator" aria-hidden="true"></div>`;
705
+ super.detach();
706
+ __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_generateToc).call(this);
707
+ }
708
+ /** @inheritdoc */
709
+ update(changedProperties) {
710
+ super.update(changedProperties);
711
+ if (changedProperties.has("maxDepth")) {
712
+ __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_generateToc).call(this);
455
713
  }
456
- /** @private */
457
- _updateToc() {
458
- __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_generateToc).call(this);
714
+ }
715
+ /** @inheritdoc */
716
+ updated(_changedProperties) {
717
+ super.updated(_changedProperties);
718
+ if (_changedProperties.has("_toc")) {
719
+ const {
720
+ added,
721
+ removed
722
+ } = __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").setItems([...(this.shadowRoot?.querySelectorAll("m3e-toc-item") ?? [])]);
723
+ if (!__classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").activeItem) {
724
+ this.classList.toggle("-no-animate", true);
725
+ __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").updateActiveItem(added.find(x => !x.disabled));
726
+ }
727
+ for (const item of added) {
728
+ if (item.node) {
729
+ __classPrivateFieldGet(this, _M3eTocElement_intersectionController, "f").observe(item.node.element);
730
+ }
731
+ }
732
+ for (const item of removed) {
733
+ if (item.node) {
734
+ __classPrivateFieldGet(this, _M3eTocElement_intersectionController, "f").unobserve(item.node.element);
735
+ }
736
+ }
459
737
  }
738
+ }
739
+ /** @inheritdoc */
740
+ render() {
741
+ return html`<div class="header"><div class="overline"><slot name="overline" @slotchange="${__classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_handleOverlineSlotChange)}"></slot></div><div class="title"><slot name="title" @slotchange="${__classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_handleTitleSlotChange)}"></slot></div></div><slot></slot><ul class="list">${this._toc.map(x => __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_renderNode).call(this, x))}</ul><div class="active-indicator" aria-hidden="true"></div>`;
742
+ }
743
+ /** @private */
744
+ _updateToc() {
745
+ __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_generateToc).call(this);
746
+ }
460
747
  };
461
748
  _M3eTocElement_ignoreScroll = new WeakMap();
462
749
  _M3eTocElement_selectionManager = new WeakMap();
@@ -465,137 +752,45 @@ _M3eTocElement_scrollController = new WeakMap();
465
752
  _M3eTocElement_mutationController = new WeakMap();
466
753
  _M3eTocElement_instances = new WeakSet();
467
754
  _M3eTocElement_renderNode = function _M3eTocElement_renderNode(node) {
468
- return html `<li>
469
- <m3e-toc-item tabindex="-1" .node="${node}" @click="${__classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_handleClick)}">${node.label}</m3e-toc-item>
470
- ${node.nodes.length == 0
471
- ? nothing
472
- : html `<ul>
473
- ${node.nodes.map((x) => __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_renderNode).call(this, x))}
474
- </ul>`}
475
- </li>`;
755
+ return html`<li><m3e-toc-item tabindex="-1" .node="${node}" @click="${__classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_handleClick)}">${node.label}</m3e-toc-item>${node.nodes.length == 0 ? nothing : html`<ul>${node.nodes.map(x => __classPrivateFieldGet(this, _M3eTocElement_instances, "m", _M3eTocElement_renderNode).call(this, x))}</ul>`}</li>`;
476
756
  };
477
757
  _M3eTocElement_handleOverlineSlotChange = function _M3eTocElement_handleOverlineSlotChange(e) {
478
- this.classList.toggle("-with-overline", hasAssignedNodes(e.target));
758
+ this.classList.toggle("-with-overline", hasAssignedNodes(e.target));
479
759
  };
480
760
  _M3eTocElement_handleTitleSlotChange = function _M3eTocElement_handleTitleSlotChange(e) {
481
- this.classList.toggle("-with-title", hasAssignedNodes(e.target));
761
+ this.classList.toggle("-with-title", hasAssignedNodes(e.target));
482
762
  };
483
763
  _M3eTocElement_handleClick = function _M3eTocElement_handleClick(e) {
484
- if (e.target instanceof M3eTocItemElement && !e.target.disabled && e.target.node?.element) {
485
- __classPrivateFieldSet(this, _M3eTocElement_ignoreScroll, true, "f");
486
- e.target.node.element.scrollIntoView({ block: "start", inline: "start", behavior: "smooth" });
487
- __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").updateActiveItem(e.target);
488
- __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").select(e.target);
489
- }
764
+ if (e.target instanceof M3eTocItemElement && !e.target.disabled && e.target.node?.element) {
765
+ __classPrivateFieldSet(this, _M3eTocElement_ignoreScroll, true, "f");
766
+ e.target.node.element.scrollIntoView({
767
+ block: "start",
768
+ inline: "start",
769
+ behavior: "smooth"
770
+ });
771
+ __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").updateActiveItem(e.target);
772
+ __classPrivateFieldGet(this, _M3eTocElement_selectionManager, "f").select(e.target);
773
+ }
490
774
  };
491
775
  _M3eTocElement_generateToc = function _M3eTocElement_generateToc() {
492
- this._toc = this.control ? TocGenerator.generate(this.control, Math.max(1, Math.min(this.maxDepth, 6))) : [];
493
- this.requestUpdate();
776
+ this._toc = this.control ? TocGenerator.generate(this.control, Math.max(1, Math.min(this.maxDepth, 6))) : [];
777
+ this.requestUpdate();
494
778
  };
495
779
  /** The styles of the element. */
496
- M3eTocElement.styles = css `
497
- :host {
498
- display: inline-block;
499
- position: relative;
500
- overflow-y: auto;
501
- scrollbar-width: ${DesignToken.scrollbar.thinWidth};
502
- scrollbar-color: ${DesignToken.scrollbar.color};
503
- width: var(--m3e-toc-width, 9.75rem);
504
- }
505
- ul {
506
- list-style: none;
507
- padding-inline-start: unset;
508
- margin-block-start: unset;
509
- margin-block-end: unset;
510
- }
511
- ul,
512
- li {
513
- display: flex;
514
- flex-direction: column;
515
- align-items: stretch;
516
- }
517
- m3e-toc-item {
518
- flex: none;
519
- }
520
- .active-indicator {
521
- position: absolute;
522
- pointer-events: none;
523
- box-sizing: border-box;
524
- left: 0;
525
- right: 0;
526
-
527
- border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased});
528
- border: 1px solid var(--m3e-toc-active-indicator-color, ${DesignToken.color.outline});
529
- transition: ${unsafeCSS(`visibility var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})
530
- ${DesignToken.motion.easing.standard},
531
- height var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})
532
- ${DesignToken.motion.easing.standard},
533
- top var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})
534
- ${DesignToken.motion.easing.standard}`)};
535
- }
536
- .header {
537
- display: flex;
538
- flex-direction: column;
539
- align-items: stretch;
540
- padding-inline-start: var(--m3e-toc-item-padding, 1rem);
541
- padding-block-end: var(--m3e-toc-header-space, 0.5rem);
542
- row-gap: var(--m3e-toc-header-space, 0.5rem);
543
- }
544
- .overline {
545
- white-space: nowrap;
546
- overflow: hidden;
547
- text-overflow: ellipsis;
548
- }
549
- .title {
550
- display: -webkit-box;
551
- -webkit-line-clamp: 2;
552
- -webkit-box-orient: vertical;
553
- overflow: hidden;
554
- line-clamp: 2;
555
- }
556
- :host(:not(.-with-overline)) .overline,
557
- :host(:not(.-with-title)) .title,
558
- :host(:not(.-with-overline):not(.-with-title)) .header {
559
- display: none;
560
- }
561
- ::slotted([slot="overline"]) {
562
- font-size: var(--m3e-toc-overline-font-size, ${DesignToken.typescale.standard.label.small.fontSize});
563
- font-weight: var(--m3e-toc-overline-font-weight, ${DesignToken.typescale.standard.label.small.fontWeight});
564
- line-height: var(--m3e-toc-overline-line-height, ${DesignToken.typescale.standard.label.small.lineHeight});
565
- letter-spacing: var(--m3e-toc-overline-tracking, ${DesignToken.typescale.standard.label.small.tracking});
566
- color: var(--m3e-toc-overline-color, ${DesignToken.color.onSurfaceVariant});
567
- }
568
- ::slotted([slot="title"]) {
569
- font-size: var(--m3e-toc-title-font-size, ${DesignToken.typescale.standard.headline.small.fontSize});
570
- font-weight: var(--m3e-toc-title-font-weight, ${DesignToken.typescale.standard.headline.small.fontWeight});
571
- line-height: var(--m3e-toc-title-line-height, ${DesignToken.typescale.standard.headline.small.lineHeight});
572
- letter-spacing: var(--m3e-toc-title-tracking, ${DesignToken.typescale.standard.headline.small.tracking});
573
- color: var(--m3e-toc-title-color, ${DesignToken.color.onSurface});
574
- }
575
- :host(.-no-animate) .active-indicator {
576
- transition: none;
577
- }
578
- @media (prefers-reduced-motion) {
579
- .active-indicator {
580
- transition: none;
581
- }
582
- }
583
- `;
584
- __decorate([
585
- r()
586
- ], M3eTocElement.prototype, "_toc", void 0);
587
- __decorate([
588
- e(".active-indicator")
589
- ], M3eTocElement.prototype, "_activeIndicator", void 0);
590
- __decorate([
591
- n({ attribute: "max-depth", type: Number })
592
- ], M3eTocElement.prototype, "maxDepth", void 0);
593
- __decorate([
594
- debounce(40)
595
- ], M3eTocElement.prototype, "_updateToc", null);
596
- M3eTocElement = __decorate([
597
- t$1("m3e-toc")
598
- ], M3eTocElement);
780
+ M3eTocElement.styles = css`:host { display: inline-block; position: relative; overflow-y: auto; scrollbar-width: ${DesignToken.scrollbar.thinWidth}; scrollbar-color: ${DesignToken.scrollbar.color}; width: var(--m3e-toc-width, 9.75rem); } ul { list-style: none; padding-inline-start: unset; margin-block-start: unset; margin-block-end: unset; } ul, li { display: flex; flex-direction: column; align-items: stretch; } m3e-toc-item { flex: none; } .active-indicator { position: absolute; pointer-events: none; box-sizing: border-box; left: 0; right: 0; border-radius: var(--m3e-toc-item-shape, ${DesignToken.shape.corner.largeIncreased}); border: 1px solid var(--m3e-toc-active-indicator-color, ${DesignToken.color.outline}); transition: ${unsafeCSS(`visibility var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})
781
+ ${DesignToken.motion.easing.standard},
782
+ height var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})
783
+ ${DesignToken.motion.easing.standard},
784
+ top var(--m3e-toc-active-indicator-animation-duration, ${DesignToken.motion.duration.long1})
785
+ ${DesignToken.motion.easing.standard}`)}; } .header { display: flex; flex-direction: column; align-items: stretch; padding-inline-start: var(--m3e-toc-item-padding, 1rem); padding-block-end: var(--m3e-toc-header-space, 0.5rem); row-gap: var(--m3e-toc-header-space, 0.5rem); } .overline { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .title { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; line-clamp: 2; } :host(:not(.-with-overline)) .overline, :host(:not(.-with-title)) .title, :host(:not(.-with-overline):not(.-with-title)) .header { display: none; } ::slotted([slot="overline"]) { font-size: var(--m3e-toc-overline-font-size, ${DesignToken.typescale.standard.label.small.fontSize}); font-weight: var(--m3e-toc-overline-font-weight, ${DesignToken.typescale.standard.label.small.fontWeight}); line-height: var(--m3e-toc-overline-line-height, ${DesignToken.typescale.standard.label.small.lineHeight}); letter-spacing: var(--m3e-toc-overline-tracking, ${DesignToken.typescale.standard.label.small.tracking}); color: var(--m3e-toc-overline-color, ${DesignToken.color.onSurfaceVariant}); } ::slotted([slot="title"]) { font-size: var(--m3e-toc-title-font-size, ${DesignToken.typescale.standard.headline.small.fontSize}); font-weight: var(--m3e-toc-title-font-weight, ${DesignToken.typescale.standard.headline.small.fontWeight}); line-height: var(--m3e-toc-title-line-height, ${DesignToken.typescale.standard.headline.small.lineHeight}); letter-spacing: var(--m3e-toc-title-tracking, ${DesignToken.typescale.standard.headline.small.tracking}); color: var(--m3e-toc-title-color, ${DesignToken.color.onSurface}); } :host(.-no-animate) .active-indicator { transition: none; } @media (prefers-reduced-motion) { .active-indicator { transition: none; } }`;
786
+ __decorate([r()], M3eTocElement.prototype, "_toc", void 0);
787
+ __decorate([e(".active-indicator")], M3eTocElement.prototype, "_activeIndicator", void 0);
788
+ __decorate([n({
789
+ attribute: "max-depth",
790
+ type: Number
791
+ })], M3eTocElement.prototype, "maxDepth", void 0);
792
+ __decorate([debounce(40)], M3eTocElement.prototype, "_updateToc", null);
793
+ M3eTocElement = __decorate([t$1("m3e-toc")], M3eTocElement);
599
794
 
600
795
  export { M3eTocElement, M3eTocItemElement, TocGenerator };
601
796
  //# sourceMappingURL=index.js.map