embetter 2.0.0 → 2.0.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.
package/README.md CHANGED
@@ -52,7 +52,7 @@ For the best experience, include an `<a><img>` inside the element. This serves a
52
52
  <!-- YouTube -->
53
53
  <embetter-media youtube-id="l9XdkPsaynk">
54
54
  <a href="https://www.youtube.com/watch?v=l9XdkPsaynk">
55
- <img src="http://img.youtube.com/vi/l9XdkPsaynk/0.jpg" />
55
+ <img src="https://img.youtube.com/vi/l9XdkPsaynk/maxresdefault.jpg" />
56
56
  </a>
57
57
  </embetter-media>
58
58
 
@@ -45,12 +45,11 @@ let m = (
45
45
  }
46
46
 
47
47
  :host([youtube-id]) {
48
- padding-bottom: 56.25%;
49
- height: 0;
48
+ aspect-ratio: 16 / 9;
49
+ }
50
50
 
51
- img {
52
- margin: -9.4% 0;
53
- }
51
+ :host([youtube-id]) img[src$="/0.jpg"] {
52
+ margin: -9.4% 0;
54
53
  }
55
54
 
56
55
  :host([soundcloud-id]),
@@ -149,7 +148,7 @@ class p {
149
148
  return `<iframe class="video" enablejsapi="1" width="${t.w}" height="${t.h}" src="https://www.youtube.com/embed/${t.id}?rel=0&suggestedQuality=hd720&enablejsapi=1${i}${e}" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowfullscreen allow=autoplay></iframe>`;
150
149
  }
151
150
  static thumbnail(t) {
152
- return "http://img.youtube.com/vi/" + t + "/0.jpg";
151
+ return "https://img.youtube.com/vi/" + t + "/maxresdefault.jpg";
153
152
  }
154
153
  static link(t) {
155
154
  return "https://www.youtube.com/watch?v=" + t;
@@ -157,8 +156,8 @@ class p {
157
156
  static buildFromText(t, i) {
158
157
  const e = t.match(this.regex)[1];
159
158
  if (e != null) {
160
- const a = this.link(e), s = this.thumbnail(e);
161
- i(e, a, s);
159
+ const s = this.link(e), a = this.thumbnail(e);
160
+ i(e, s, a);
162
161
  }
163
162
  }
164
163
  }
@@ -179,21 +178,21 @@ class b {
179
178
  }
180
179
  static getData(t) {
181
180
  return new Promise((i, e) => {
182
- const a = `https://vimeo.com/api/v2/video/${t}.json`;
183
- fetch(a).then((s) => s.json()).then((s) => i(s[0].thumbnail_large)).catch(() => i(""));
181
+ const s = `https://vimeo.com/api/v2/video/${t}.json`;
182
+ fetch(s).then((a) => a.json()).then((a) => i(a[0].thumbnail_large)).catch(() => i(""));
184
183
  });
185
184
  }
186
185
  static buildFromText(t, i) {
187
186
  const e = t.match(this.regex);
188
187
  if (e && e[1]) {
189
- const a = e[1], s = this.link(a);
190
- this.getData(a).then((r) => {
191
- i(a, s, r);
188
+ const s = e[1], a = this.link(s);
189
+ this.getData(s).then((r) => {
190
+ i(s, a, r);
192
191
  });
193
192
  }
194
193
  }
195
194
  }
196
- class g {
195
+ class A {
197
196
  static type = "soundcloud";
198
197
  static dataAttribute = "soundcloud-id";
199
198
  static regex = /(?:https?:\/\/)?(?:w{3}\.)?(?:soundcloud\.com|snd\.sc)\/([a-zA-Z0-9_-]*(?:\/sets)?(?:\/groups)?\/[a-zA-Z0-9_-]*)/;
@@ -214,41 +213,14 @@ class g {
214
213
  static buildFromText(t, i) {
215
214
  const e = t.match(this.regex);
216
215
  if (e && e[1]) {
217
- const a = e[1], s = this.link(a);
218
- this.getData(s).then((r) => {
219
- i(a, s, r);
216
+ const s = e[1], a = this.link(s);
217
+ this.getData(a).then((r) => {
218
+ i(s, a, r);
220
219
  });
221
220
  }
222
221
  }
223
222
  }
224
- class A {
225
- static type = "instagram";
226
- static dataAttribute = "instagram-id";
227
- static regex = /(?:https?:\/\/)?(?:w{3}\.)?(?:instagram\.com|instagr\.am)\/(p|reel|tv)\/([a-zA-Z0-9-_]+)/i;
228
- static normalizePath(t) {
229
- if (!t) return "p/";
230
- const i = String(t).replace(/^\/+|\/+$/g, "");
231
- return /^(p|reel|tv)\/[a-zA-Z0-9-_]+$/i.test(i) ? i : `p/${i}`;
232
- }
233
- static embed(t) {
234
- const i = this.normalizePath(t.id), e = t.captioned === !1 ? "" : "captioned/";
235
- return `<iframe width="100%" height="100%" scrolling="no" frameborder="0" src="https://www.instagram.com/${i}/embed/${e}?cr=1&v=14" allowfullscreen></iframe>`;
236
- }
237
- static thumbnail(t) {
238
- return "";
239
- }
240
- static link(t) {
241
- return `https://www.instagram.com/${this.normalizePath(t)}/`;
242
- }
243
- static buildFromText(t, i) {
244
- const e = t.match(this.regex);
245
- if (e && e[2]) {
246
- const a = `${e[1]}/${e[2]}`, s = this.link(a);
247
- i(a, s, "");
248
- }
249
- }
250
- }
251
- class f {
223
+ class g {
252
224
  static type = "dailymotion";
253
225
  static dataAttribute = "dailymotion-id";
254
226
  static regex = /(?:https?:\/\/)?(?:w{3}\.)?dailymotion\.com\/video\/([a-zA-Z0-9-_]*)/;
@@ -266,12 +238,12 @@ class f {
266
238
  t = t.split("_")[0];
267
239
  const e = t.match(this.regex);
268
240
  if (e && e[1]) {
269
- const a = e[1], s = this.link(a), r = this.thumbnail(a);
270
- i(a, s, r);
241
+ const s = e[1], a = this.link(s), r = this.thumbnail(s);
242
+ i(s, a, r);
271
243
  }
272
244
  }
273
245
  }
274
- class y {
246
+ class f {
275
247
  static type = "mixcloud";
276
248
  static dataAttribute = "mixcloud-id";
277
249
  static regex = /(?:https?:\/\/)?(?:w{3}\.)?(?:mixcloud\.com)\/(.*\/.*)/;
@@ -292,20 +264,20 @@ class y {
292
264
  static buildFromText(t, i) {
293
265
  const e = t.match(this.regex);
294
266
  if (e && e[1]) {
295
- const a = e[1], s = this.link(a);
296
- this.getData(s).then((r) => {
297
- i(a, s, r);
267
+ const s = e[1], a = this.link(s);
268
+ this.getData(a).then((r) => {
269
+ i(s, a, r);
298
270
  });
299
271
  }
300
272
  }
301
273
  }
302
- class w {
274
+ class y {
303
275
  static type = "codepen";
304
276
  static dataAttribute = "codepen-id";
305
277
  static regex = /(?:https?:\/\/)?(?:w{3}\.)?(?:codepen\.io)\/([a-zA-Z0-9_\-%]*\/[a-zA-Z0-9_\-%]*\/[a-zA-Z0-9_\-%]*)/;
306
278
  static embed(t) {
307
- const i = t.id.replace("/pen/", "/embed/"), e = i.split("/")[0], a = i.split("/")[2];
308
- return `<iframe src="https://codepen.io/${i}?height=${t.h}&theme-id=0&slug-hash=${a}&default-tab=result&user=${e}" frameborder="0" scrolling="no" allowtransparency="true" allowfullscreen allow=autoplay></iframe>`;
279
+ const i = t.id.replace("/pen/", "/embed/"), e = i.split("/")[0], s = i.split("/")[2];
280
+ return `<iframe src="https://codepen.io/${i}?height=${t.h}&theme-id=0&slug-hash=${s}&default-tab=result&user=${e}" frameborder="0" scrolling="no" allowtransparency="true" allowfullscreen allow=autoplay></iframe>`;
309
281
  }
310
282
  static thumbnail(t) {
311
283
  return `https://codepen.io/${t}/image/large.png`;
@@ -316,13 +288,13 @@ class w {
316
288
  static buildFromText(t, i) {
317
289
  const e = t.match(this.regex);
318
290
  if (e && e[1]) {
319
- let a = e[1].replace("/embed/", "/pen/");
320
- const s = this.link(a), r = this.thumbnail(a);
321
- i(a, s, r);
291
+ let s = e[1].replace("/embed/", "/pen/");
292
+ const a = this.link(s), r = this.thumbnail(s);
293
+ i(s, a, r);
322
294
  }
323
295
  }
324
296
  }
325
- class v {
297
+ class w {
326
298
  static type = "bandcamp";
327
299
  static dataAttribute = "bandcamp-id";
328
300
  static regex = /(?:https?:\/\/)?(?:w{3}\.)?([a-zA-Z0-9_\-]*\.bandcamp\.com\/(?:album|track)\/[a-zA-Z0-9_\-%]*)/;
@@ -341,14 +313,14 @@ class v {
341
313
  static buildFromText(t, i) {
342
314
  const e = t.match(this.regex);
343
315
  if (e && e[1]) {
344
- const s = `https://${e[1]}`;
345
- this.getData(s).then((r) => {
346
- r.id && i(r.id, s, r.thumbnail || "");
316
+ const a = `https://${e[1]}`;
317
+ this.getData(a).then((r) => {
318
+ r.id && i(r.id, a, r.thumbnail || "");
347
319
  });
348
320
  }
349
321
  }
350
322
  }
351
- class $ {
323
+ class v {
352
324
  static type = "giphy";
353
325
  static dataAttribute = "giphy-id";
354
326
  static regex = /(?:https?:\/\/)?(?:w{3}\.)?giphy\.com\/gifs\/([a-zA-Z0-9_\-%]*)/;
@@ -362,10 +334,10 @@ class $ {
362
334
  return `https://giphy.com/gifs/${t}`;
363
335
  }
364
336
  static buildFromText(t, i) {
365
- const e = t.split("/"), a = e[e.length - 1], s = a.split("-"), r = s[s.length - 1];
337
+ const e = t.split("/"), s = e[e.length - 1], a = s.split("-"), r = a[a.length - 1];
366
338
  if (r) {
367
- const o = this.link(a), l = this.thumbnail(r);
368
- i(r, o, l);
339
+ const o = this.link(s), n = this.thumbnail(r);
340
+ i(r, o, n);
369
341
  }
370
342
  }
371
343
  }
@@ -374,8 +346,8 @@ class k {
374
346
  static dataAttribute = "video-url";
375
347
  static regex = /(?:https?:\/\/)?(?:w{3}\.)?(.+\.(?:mp4|mov|m4v))(?:\/|$|\s|\?|#)/;
376
348
  static embed(t) {
377
- const i = t.autoplay === !0 ? ' autoplay="true"' : "", e = t.loops === !0 ? ' loop="true"' : "", a = t.muted === !0 ? " muted" : "";
378
- return `<video src="${t.id}" width="${t.w}" height="${t.h}"${i}${e}${a} controls playsinline webkitallowfullscreen mozallowfullscreen allowfullscreen></video>`;
349
+ const i = t.autoplay === !0 ? ' autoplay="true"' : "", e = t.loops === !0 ? ' loop="true"' : "", s = t.muted === !0 ? " muted" : "";
350
+ return `<video src="${t.id}" width="${t.w}" height="${t.h}"${i}${e}${s} controls playsinline webkitallowfullscreen mozallowfullscreen allowfullscreen></video>`;
379
351
  }
380
352
  static thumbnail(t) {
381
353
  return t.replace(".mp4", "-poster.jpg").replace(".mov", "-poster.jpg").replace(".m4v", "-poster.jpg");
@@ -386,12 +358,12 @@ class k {
386
358
  static buildFromText(t, i) {
387
359
  const e = t.match(this.regex);
388
360
  if (e && e[1]) {
389
- const a = e[1], s = this.thumbnail(a);
390
- i(a, a, s);
361
+ const s = e[1], a = this.thumbnail(s);
362
+ i(s, s, a);
391
363
  }
392
364
  }
393
365
  }
394
- class x {
366
+ class $ {
395
367
  static type = "gif";
396
368
  static dataAttribute = "gif-url";
397
369
  static regex = /(?:https?:\/\/)?(?:w{3}\.)?(.+\.gif)(?:\/|$|\s|\?|#)/;
@@ -407,31 +379,17 @@ class x {
407
379
  static buildFromText(t, i) {
408
380
  const e = t.match(this.regex);
409
381
  if (e && e[1]) {
410
- const a = e[1], s = this.thumbnail(a);
411
- i(a, a, s);
382
+ const s = e[1], a = this.thumbnail(s);
383
+ i(s, s, a);
412
384
  }
413
385
  }
414
386
  }
415
- const d = [
416
- p,
417
- b,
418
- g,
419
- A,
420
- f,
421
- y,
422
- w,
423
- v,
424
- $,
425
- // Shadertoy,
426
- // Kuula,
427
- k,
428
- x
429
- ];
387
+ const d = [k, $, p, b, A, g, f, y, w, v];
430
388
  class c extends HTMLElement {
431
389
  defaultThumbnail = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArwAAAGcAQMAAAABMOGrAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAADUExURQAAAKd6PdoAAAA6SURBVHja7cGBAAAAAMOg+VPf4ARVAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAN488AAGP4e1mAAAAAElFTkSuQmCC";
432
390
  static EMBETTER_ACTIVATED = "embetter-activated";
433
391
  connectedCallback() {
434
- this.shadow = this.attachShadow({ mode: "open" }), this.el = this.shadow, this.initComponent(), this.render(), this.checkThumbnail(), this.addListeners(), this.setupMobileObserver();
392
+ this.shadow = this.attachShadow({ mode: "open" }), this.el = this.shadow ?? this, this.initComponent(), this.render(), this.checkThumbnail(), this.addListeners();
435
393
  }
436
394
  disconnectedCallback() {
437
395
  this.unembedMedia(), this.removeAttribute("ready"), this.playButton && this.playButton.removeEventListener("click", this.clickListener), document.removeEventListener(c.EMBETTER_ACTIVATED, this.embedListener), this.observer && (this.observer.disconnect(), this.observer = null);
@@ -460,9 +418,9 @@ class c extends HTMLElement {
460
418
  this.service = t, this.serviceType = t.type, this.serviceId = this.getAttribute(i);
461
419
  let e = this.posterURL || t.thumbnail(this.serviceId);
462
420
  if (this.markup = this.playerHTML(t.link(this.serviceId), e), t.getData) {
463
- const a = t.link(this.serviceId);
464
- t.getData(a).then((s) => {
465
- const r = typeof s == "string" ? s : s?.thumbnail;
421
+ const s = t.link(this.serviceId);
422
+ t.getData(s).then((a) => {
423
+ const r = typeof a == "string" ? a : a?.thumbnail;
466
424
  !e && !this.posterURL && r && this.thumbnail && (this.thumbnail.src = r);
467
425
  });
468
426
  }
@@ -474,6 +432,10 @@ class c extends HTMLElement {
474
432
  this.thumbnail && (this.setAttribute("loading", ""), this.thumbnail.onload = () => {
475
433
  this.removeAttribute("loading"), this.setAttribute("ready", "");
476
434
  }, this.thumbnail.onerror = () => {
435
+ if (this.thumbnail.src.includes("/maxresdefault.jpg")) {
436
+ this.thumbnail.src = this.thumbnail.src.replace("/maxresdefault.jpg", "/0.jpg");
437
+ return;
438
+ }
477
439
  this.thumbnail.src = this.defaultThumbnail, this.removeAttribute("loading"), this.setAttribute("ready", "");
478
440
  }, setTimeout(() => {
479
441
  this.thumbnail.height < 50 && (this.thumbnail.src = this.defaultThumbnail), this.removeAttribute("loading"), this.setAttribute("ready", "");
@@ -518,13 +480,13 @@ class c extends HTMLElement {
518
480
  var i = document.createElement("div");
519
481
  return i.innerHTML = t, i.firstChild;
520
482
  }
521
- static componentHTML(t, i, e = null, a = null) {
522
- let s = "";
523
- if (a || e) {
524
- const r = a || "#", o = e ? `<img src="${e}">` : "";
525
- s = `<a href="${r}">${o}</a>`;
483
+ static componentHTML(t, i, e = null, s = null) {
484
+ let a = "";
485
+ if (s || e) {
486
+ const r = s || "#", o = e ? `<img src="${e}">` : "";
487
+ a = `<a href="${r}">${o}</a>`;
526
488
  }
527
- return `<embetter-media ${t}="${i}">${s}</embetter-media>`;
489
+ return `<embetter-media ${t}="${i}">${a}</embetter-media>`;
528
490
  }
529
491
  playerHTML(t, i) {
530
492
  return (
@@ -555,13 +517,13 @@ class c extends HTMLElement {
555
517
  }
556
518
  static upgradeLegacyEmbeds(t = document) {
557
519
  t.querySelectorAll(".embetter").forEach((e) => {
558
- for (const a of d) {
559
- const s = `data-${a.dataAttribute}`;
560
- if (e.hasAttribute(s)) {
561
- const r = e.getAttribute(s), o = document.createElement("embetter-media");
562
- o.setAttribute(a.dataAttribute, r);
563
- const l = e.querySelector("a");
564
- l && o.appendChild(l.cloneNode(!0)), e.hasAttribute("data-loops") && o.setAttribute("loops", ""), e.hasAttribute("data-muted") && o.setAttribute("muted", ""), e.replaceWith(o);
520
+ for (const s of d) {
521
+ const a = `data-${s.dataAttribute}`;
522
+ if (e.hasAttribute(a)) {
523
+ const r = e.getAttribute(a), o = document.createElement("embetter-media");
524
+ o.setAttribute(s.dataAttribute, r);
525
+ const n = e.querySelector("a");
526
+ n && o.appendChild(n.cloneNode(!0)), e.hasAttribute("data-loops") && o.setAttribute("loops", ""), e.hasAttribute("data-muted") && o.setAttribute("muted", ""), e.replaceWith(o);
565
527
  break;
566
528
  }
567
529
  }
@@ -569,26 +531,26 @@ class c extends HTMLElement {
569
531
  }
570
532
  static componentMarkupFromURL(t, i) {
571
533
  for (let e = 0; e < d.length; e++) {
572
- const a = d[e];
573
- if (t.match(a.regex) != null) {
574
- a.buildFromText(t, (s, r, o) => {
575
- const l = (h) => {
534
+ const s = d[e];
535
+ if (t.match(s.regex) != null) {
536
+ s.buildFromText(t, (a, r, o) => {
537
+ const n = (h) => {
576
538
  let u = c.componentHTML(
577
- a.dataAttribute,
578
- s,
539
+ s.dataAttribute,
540
+ a,
579
541
  h,
580
542
  r
581
543
  );
582
- i(u, a);
544
+ i(u, s);
583
545
  };
584
- if (!o && a.getData && r) {
585
- a.getData(r).then((h) => {
546
+ if (!o && s.getData && r) {
547
+ s.getData(r).then((h) => {
586
548
  const u = typeof h == "string" ? h : h?.thumbnail;
587
- l(u || o);
588
- }).catch(() => l(o));
549
+ n(u || o);
550
+ }).catch(() => n(o));
589
551
  return;
590
552
  }
591
- l(o);
553
+ n(o);
592
554
  });
593
555
  break;
594
556
  }
@@ -43,12 +43,11 @@
43
43
  }
44
44
 
45
45
  :host([youtube-id]) {
46
- padding-bottom: 56.25%;
47
- height: 0;
46
+ aspect-ratio: 16 / 9;
47
+ }
48
48
 
49
- img {
50
- margin: -9.4% 0;
51
- }
49
+ :host([youtube-id]) img[src$="/0.jpg"] {
50
+ margin: -9.4% 0;
52
51
  }
53
52
 
54
53
  :host([soundcloud-id]),
@@ -136,7 +135,7 @@
136
135
  to { transform: rotate(360deg); }
137
136
  }
138
137
 
139
- `;class d{static type="youtube";static dataAttribute="youtube-id";static regex=/(?:.+?)?(?:youtube\.com\/v\/|watch\/|\?v=|\&v=|youtu\.be\/|\/v=|^youtu\.be\/)([a-zA-Z0-9_-]{11})+/;static embed(t){const i=t.autoplay===!0?"&autoplay=1":"",e=t.loops===!0?`&loop=1&playlist=${t.id}`:"";return`<iframe class="video" enablejsapi="1" width="${t.w}" height="${t.h}" src="https://www.youtube.com/embed/${t.id}?rel=0&suggestedQuality=hd720&enablejsapi=1${i}${e}" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowfullscreen allow=autoplay></iframe>`}static thumbnail(t){return"http://img.youtube.com/vi/"+t+"/0.jpg"}static link(t){return"https://www.youtube.com/watch?v="+t}static buildFromText(t,i){const e=t.match(this.regex)[1];if(e!=null){const a=this.link(e),s=this.thumbnail(e);i(e,a,s)}}}class b{static type="vimeo";static dataAttribute="vimeo-id";static regex=/(?:vimeo\.com\/(?:video\/)?|player\.vimeo\.com\/video\/)(\d+)/i;static embed(t){const i=t.autoplay===!0?"&autoplay=1":"",e=t.loops===!0?"&loop=1":"";return`<iframe id="${t.id}" src="https://player.vimeo.com/video/${t.id}?title=0&byline=0&portrait=0&color=ffffff&api=1&player_id=${t.id}${i}${e}" width="${t.w}" height="${t.h}" frameborder="0" scrolling="no" webkitallowfullscreen mozallowfullscreen allowfullscreen allow=autoplay></iframe>`}static thumbnail(t){return""}static link(t){return"https://vimeo.com/"+t}static getData(t){return new Promise((i,e)=>{const a=`https://vimeo.com/api/v2/video/${t}.json`;fetch(a).then(s=>s.json()).then(s=>i(s[0].thumbnail_large)).catch(()=>i(""))})}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){const a=e[1],s=this.link(a);this.getData(a).then(r=>{i(a,s,r)})}}}class g{static type="soundcloud";static dataAttribute="soundcloud-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?(?:soundcloud\.com|snd\.sc)\/([a-zA-Z0-9_-]*(?:\/sets)?(?:\/groups)?\/[a-zA-Z0-9_-]*)/;static embed(t){const i=t.autoplay===!0?"&auto_play=true":"";return`<iframe width="100%" height="600" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=${encodeURIComponent(`https://soundcloud.com/${t.id}`)}${i}&hide_related=false&color=373737&show_comments=false&show_user=true&show_reposts=false&visual=true" allow="autoplay"></iframe>`}static thumbnail(t){return""}static link(t){return`https://soundcloud.com/${t}`}static getData(t){const i=`/api/soundcloud?url=${encodeURIComponent(t)}&format=json`;return fetch(i).then(e=>e.json()).then(e=>e.thumbnail_url||"").catch(()=>"")}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){const a=e[1],s=this.link(a);this.getData(s).then(r=>{i(a,s,r)})}}}class A{static type="instagram";static dataAttribute="instagram-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?(?:instagram\.com|instagr\.am)\/(p|reel|tv)\/([a-zA-Z0-9-_]+)/i;static normalizePath(t){if(!t)return"p/";const i=String(t).replace(/^\/+|\/+$/g,"");return/^(p|reel|tv)\/[a-zA-Z0-9-_]+$/i.test(i)?i:`p/${i}`}static embed(t){const i=this.normalizePath(t.id),e=t.captioned===!1?"":"captioned/";return`<iframe width="100%" height="100%" scrolling="no" frameborder="0" src="https://www.instagram.com/${i}/embed/${e}?cr=1&v=14" allowfullscreen></iframe>`}static thumbnail(t){return""}static link(t){return`https://www.instagram.com/${this.normalizePath(t)}/`}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[2]){const a=`${e[1]}/${e[2]}`,s=this.link(a);i(a,s,"")}}}class f{static type="dailymotion";static dataAttribute="dailymotion-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?dailymotion\.com\/video\/([a-zA-Z0-9-_]*)/;static embed(t){const i=t.autoplay===!0?"?autoPlay=1":"";return`<iframe class="video" width="${t.w}" height="${t.h}" src="https://www.dailymotion.com/embed/video/${t.id}${i}" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowfullscreen allow=autoplay></iframe>`}static thumbnail(t){return`https://www.dailymotion.com/thumbnail/video/${t}`}static link(t){return`https://www.dailymotion.com/video/${t}`}static buildFromText(t,i){t=t.split("_")[0];const e=t.match(this.regex);if(e&&e[1]){const a=e[1],s=this.link(a),r=this.thumbnail(a);i(a,s,r)}}}class y{static type="mixcloud";static dataAttribute="mixcloud-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?(?:mixcloud\.com)\/(.*\/.*)/;static embed(t){const i=t.autoplay===!0?"&autoplay=true":"";return`<iframe width="660" height="180" src="https://www.mixcloud.com/widget/iframe/?feed=${encodeURIComponent("https://www.mixcloud.com/"+t.id)}&replace=0&hide_cover=1&stylecolor=ffffff&embed_type=widget_standard${i}" frameborder="0" scrolling="no"></iframe>`}static thumbnail(t){return""}static link(t){return`https://www.mixcloud.com/${t}`}static getData(t){const i=`/api/mixcloud/?url=${encodeURIComponent(t)}&format=json`;return fetch(i).then(e=>e.json()).then(e=>e.image||"").catch(()=>"")}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){const a=e[1],s=this.link(a);this.getData(s).then(r=>{i(a,s,r)})}}}class w{static type="codepen";static dataAttribute="codepen-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?(?:codepen\.io)\/([a-zA-Z0-9_\-%]*\/[a-zA-Z0-9_\-%]*\/[a-zA-Z0-9_\-%]*)/;static embed(t){const i=t.id.replace("/pen/","/embed/"),e=i.split("/")[0],a=i.split("/")[2];return`<iframe src="https://codepen.io/${i}?height=${t.h}&theme-id=0&slug-hash=${a}&default-tab=result&user=${e}" frameborder="0" scrolling="no" allowtransparency="true" allowfullscreen allow=autoplay></iframe>`}static thumbnail(t){return`https://codepen.io/${t}/image/large.png`}static link(t){return`https://codepen.io/${t.replace("/embed/","/pen/")}`}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){let a=e[1].replace("/embed/","/pen/");const s=this.link(a),r=this.thumbnail(a);i(a,s,r)}}}class v{static type="bandcamp";static dataAttribute="bandcamp-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?([a-zA-Z0-9_\-]*\.bandcamp\.com\/(?:album|track)\/[a-zA-Z0-9_\-%]*)/;static embed(t){return`<iframe src="https://bandcamp.com/EmbeddedPlayer/${t.id}/size=large/bgcol=ffffff/linkcol=333333/tracklist=true/artwork=small/transparent=true/" frameborder="0" scrolling="no" allowtransparency="true" allowfullscreen seamless></iframe>`}static thumbnail(t){return""}static link(t){return t.match(/^(album|track)=/)?"":`https://${t}`}static getData(t){return fetch(`/api/bandcamp?url=${encodeURIComponent(t)}`).then(i=>i.json()).catch(()=>({id:null,thumbnail:null}))}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){const s=`https://${e[1]}`;this.getData(s).then(r=>{r.id&&i(r.id,s,r.thumbnail||"")})}}}class ${static type="giphy";static dataAttribute="giphy-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?giphy\.com\/gifs\/([a-zA-Z0-9_\-%]*)/;static embed(t){return`<iframe width="${t.w}" height="${t.h}" src="https://giphy.com/embed/${t.id}/twitter/iframe" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowfullscreen allow=autoplay></iframe>`}static thumbnail(t){return`https://media.giphy.com/media/${t}/giphy_s.gif`}static link(t){return`https://giphy.com/gifs/${t}`}static buildFromText(t,i){const e=t.split("/"),a=e[e.length-1],s=a.split("-"),r=s[s.length-1];if(r){const o=this.link(a),c=this.thumbnail(r);i(r,o,c)}}}class k{static type="video";static dataAttribute="video-url";static regex=/(?:https?:\/\/)?(?:w{3}\.)?(.+\.(?:mp4|mov|m4v))(?:\/|$|\s|\?|#)/;static embed(t){const i=t.autoplay===!0?' autoplay="true"':"",e=t.loops===!0?' loop="true"':"",a=t.muted===!0?" muted":"";return`<video src="${t.id}" width="${t.w}" height="${t.h}"${i}${e}${a} controls playsinline webkitallowfullscreen mozallowfullscreen allowfullscreen></video>`}static thumbnail(t){return t.replace(".mp4","-poster.jpg").replace(".mov","-poster.jpg").replace(".m4v","-poster.jpg")}static link(t){return t}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){const a=e[1],s=this.thumbnail(a);i(a,a,s)}}}class x{static type="gif";static dataAttribute="gif-url";static regex=/(?:https?:\/\/)?(?:w{3}\.)?(.+\.gif)(?:\/|$|\s|\?|#)/;static embed(t){return`<img class="gif" src="${t.id}" width="${t.w}" height="${t.h}">`}static thumbnail(t){return t.replace(".gif","-poster.jpg")}static link(t){return t}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){const a=e[1],s=this.thumbnail(a);i(a,a,s)}}}const m=[d,b,g,A,f,y,w,v,$,k,x];class l extends HTMLElement{defaultThumbnail="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArwAAAGcAQMAAAABMOGrAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAADUExURQAAAKd6PdoAAAA6SURBVHja7cGBAAAAAMOg+VPf4ARVAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAN488AAGP4e1mAAAAAElFTkSuQmCC";static EMBETTER_ACTIVATED="embetter-activated";connectedCallback(){this.shadow=this.attachShadow({mode:"open"}),this.el=this.shadow,this.initComponent(),this.render(),this.checkThumbnail(),this.addListeners(),this.setupMobileObserver()}disconnectedCallback(){this.unembedMedia(),this.removeAttribute("ready"),this.playButton&&this.playButton.removeEventListener("click",this.clickListener),document.removeEventListener(l.EMBETTER_ACTIVATED,this.embedListener),this.observer&&(this.observer.disconnect(),this.observer=null)}initComponent(){this.markup="embetter-media component not initialized properly.",this.loops=this.hasAttribute("loops"),this.muted=this.hasAttribute("muted"),this.posterURL=null;const t=this.querySelector("img");t&&t.src&&(this.posterURL=t.src),this.innerHTML="",this.findAndActivateService()}getElements(){this.thumbnail=this.el.querySelector("img")}addListeners(){this.clickListener=this.onClick.bind(this),this.playButton=this.el.querySelector(".embetter-play-button"),this.playButton&&this.playButton.addEventListener("click",this.clickListener),this.embedListener=this.onEmbedActivated.bind(this),document.addEventListener(l.EMBETTER_ACTIVATED,this.embedListener)}onClick(t){t.preventDefault(),this.embedMedia()}onEmbedActivated(t){t.detail!==this&&this.unembedMedia()}findAndActivateService(){for(let t of m){let i=t.dataAttribute;if(this.hasAttribute(i)){this.service=t,this.serviceType=t.type,this.serviceId=this.getAttribute(i);let e=this.posterURL||t.thumbnail(this.serviceId);if(this.markup=this.playerHTML(t.link(this.serviceId),e),t.getData){const a=t.link(this.serviceId);t.getData(a).then(s=>{const r=typeof s=="string"?s:s?.thumbnail;!e&&!this.posterURL&&r&&this.thumbnail&&(this.thumbnail.src=r)})}break}}}checkThumbnail(){this.thumbnail&&(this.setAttribute("loading",""),this.thumbnail.onload=()=>{this.removeAttribute("loading"),this.setAttribute("ready","")},this.thumbnail.onerror=()=>{this.thumbnail.src=this.defaultThumbnail,this.removeAttribute("loading"),this.setAttribute("ready","")},setTimeout(()=>{this.thumbnail.height<50&&(this.thumbnail.src=this.defaultThumbnail),this.removeAttribute("loading"),this.setAttribute("ready","")},4e3))}setupMobileObserver(){this.isMobile()&&(this.observer=new IntersectionObserver(t=>{t.forEach(i=>{i.isIntersecting?this.embedMedia(!1):this.unembedMedia()})},{threshold:.3}),this.observer.observe(this))}embedMedia(t){if(document.dispatchEvent(new CustomEvent(l.EMBETTER_ACTIVATED,{bubbles:!0,composed:!0,detail:this})),this.hasAttribute("playing"))return;t===void 0&&(t=this.hasAttribute("autoplay")?this.getAttribute("autoplay")!=="false":!0);let i=this.service.embed({id:this.serviceId,w:this.thumbnail&&this.thumbnail.width||"100%",h:this.thumbnail&&this.thumbnail.height||"100%",autoplay:t,loops:this.loops,muted:this.muted||t});this.playerEl=l.stringToDomElement(i),this.el.appendChild(this.playerEl),this.setAttribute("playing","")}unembedMedia(){this.playerEl!=null&&this.playerEl.parentNode!=null&&this.playerEl.parentNode.removeChild(this.playerEl),this.removeAttribute("playing")}isMobile(){return/iphone|ipad|ipod|android/i.test(navigator.userAgent)}static stringToDomElement(t){var i=document.createElement("div");return i.innerHTML=t,i.firstChild}static componentHTML(t,i,e=null,a=null){let s="";if(a||e){const r=a||"#",o=e?`<img src="${e}">`:"";s=`<a href="${r}">${o}</a>`}return`<embetter-media ${t}="${i}">${s}</embetter-media>`}playerHTML(t,i){return`
138
+ `;class d{static type="youtube";static dataAttribute="youtube-id";static regex=/(?:.+?)?(?:youtube\.com\/v\/|watch\/|\?v=|\&v=|youtu\.be\/|\/v=|^youtu\.be\/)([a-zA-Z0-9_-]{11})+/;static embed(t){const i=t.autoplay===!0?"&autoplay=1":"",e=t.loops===!0?`&loop=1&playlist=${t.id}`:"";return`<iframe class="video" enablejsapi="1" width="${t.w}" height="${t.h}" src="https://www.youtube.com/embed/${t.id}?rel=0&suggestedQuality=hd720&enablejsapi=1${i}${e}" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowfullscreen allow=autoplay></iframe>`}static thumbnail(t){return"https://img.youtube.com/vi/"+t+"/maxresdefault.jpg"}static link(t){return"https://www.youtube.com/watch?v="+t}static buildFromText(t,i){const e=t.match(this.regex)[1];if(e!=null){const s=this.link(e),a=this.thumbnail(e);i(e,s,a)}}}class b{static type="vimeo";static dataAttribute="vimeo-id";static regex=/(?:vimeo\.com\/(?:video\/)?|player\.vimeo\.com\/video\/)(\d+)/i;static embed(t){const i=t.autoplay===!0?"&autoplay=1":"",e=t.loops===!0?"&loop=1":"";return`<iframe id="${t.id}" src="https://player.vimeo.com/video/${t.id}?title=0&byline=0&portrait=0&color=ffffff&api=1&player_id=${t.id}${i}${e}" width="${t.w}" height="${t.h}" frameborder="0" scrolling="no" webkitallowfullscreen mozallowfullscreen allowfullscreen allow=autoplay></iframe>`}static thumbnail(t){return""}static link(t){return"https://vimeo.com/"+t}static getData(t){return new Promise((i,e)=>{const s=`https://vimeo.com/api/v2/video/${t}.json`;fetch(s).then(a=>a.json()).then(a=>i(a[0].thumbnail_large)).catch(()=>i(""))})}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){const s=e[1],a=this.link(s);this.getData(s).then(r=>{i(s,a,r)})}}}class A{static type="soundcloud";static dataAttribute="soundcloud-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?(?:soundcloud\.com|snd\.sc)\/([a-zA-Z0-9_-]*(?:\/sets)?(?:\/groups)?\/[a-zA-Z0-9_-]*)/;static embed(t){const i=t.autoplay===!0?"&auto_play=true":"";return`<iframe width="100%" height="600" scrolling="no" frameborder="no" src="https://w.soundcloud.com/player/?url=${encodeURIComponent(`https://soundcloud.com/${t.id}`)}${i}&hide_related=false&color=373737&show_comments=false&show_user=true&show_reposts=false&visual=true" allow="autoplay"></iframe>`}static thumbnail(t){return""}static link(t){return`https://soundcloud.com/${t}`}static getData(t){const i=`/api/soundcloud?url=${encodeURIComponent(t)}&format=json`;return fetch(i).then(e=>e.json()).then(e=>e.thumbnail_url||"").catch(()=>"")}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){const s=e[1],a=this.link(s);this.getData(a).then(r=>{i(s,a,r)})}}}class f{static type="dailymotion";static dataAttribute="dailymotion-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?dailymotion\.com\/video\/([a-zA-Z0-9-_]*)/;static embed(t){const i=t.autoplay===!0?"?autoPlay=1":"";return`<iframe class="video" width="${t.w}" height="${t.h}" src="https://www.dailymotion.com/embed/video/${t.id}${i}" frameborder="0" scrolling="no" webkitAllowFullScreen mozallowfullscreen allowfullscreen allow=autoplay></iframe>`}static thumbnail(t){return`https://www.dailymotion.com/thumbnail/video/${t}`}static link(t){return`https://www.dailymotion.com/video/${t}`}static buildFromText(t,i){t=t.split("_")[0];const e=t.match(this.regex);if(e&&e[1]){const s=e[1],a=this.link(s),r=this.thumbnail(s);i(s,a,r)}}}class g{static type="mixcloud";static dataAttribute="mixcloud-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?(?:mixcloud\.com)\/(.*\/.*)/;static embed(t){const i=t.autoplay===!0?"&autoplay=true":"";return`<iframe width="660" height="180" src="https://www.mixcloud.com/widget/iframe/?feed=${encodeURIComponent("https://www.mixcloud.com/"+t.id)}&replace=0&hide_cover=1&stylecolor=ffffff&embed_type=widget_standard${i}" frameborder="0" scrolling="no"></iframe>`}static thumbnail(t){return""}static link(t){return`https://www.mixcloud.com/${t}`}static getData(t){const i=`/api/mixcloud/?url=${encodeURIComponent(t)}&format=json`;return fetch(i).then(e=>e.json()).then(e=>e.image||"").catch(()=>"")}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){const s=e[1],a=this.link(s);this.getData(a).then(r=>{i(s,a,r)})}}}class y{static type="codepen";static dataAttribute="codepen-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?(?:codepen\.io)\/([a-zA-Z0-9_\-%]*\/[a-zA-Z0-9_\-%]*\/[a-zA-Z0-9_\-%]*)/;static embed(t){const i=t.id.replace("/pen/","/embed/"),e=i.split("/")[0],s=i.split("/")[2];return`<iframe src="https://codepen.io/${i}?height=${t.h}&theme-id=0&slug-hash=${s}&default-tab=result&user=${e}" frameborder="0" scrolling="no" allowtransparency="true" allowfullscreen allow=autoplay></iframe>`}static thumbnail(t){return`https://codepen.io/${t}/image/large.png`}static link(t){return`https://codepen.io/${t.replace("/embed/","/pen/")}`}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){let s=e[1].replace("/embed/","/pen/");const a=this.link(s),r=this.thumbnail(s);i(s,a,r)}}}class w{static type="bandcamp";static dataAttribute="bandcamp-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?([a-zA-Z0-9_\-]*\.bandcamp\.com\/(?:album|track)\/[a-zA-Z0-9_\-%]*)/;static embed(t){return`<iframe src="https://bandcamp.com/EmbeddedPlayer/${t.id}/size=large/bgcol=ffffff/linkcol=333333/tracklist=true/artwork=small/transparent=true/" frameborder="0" scrolling="no" allowtransparency="true" allowfullscreen seamless></iframe>`}static thumbnail(t){return""}static link(t){return t.match(/^(album|track)=/)?"":`https://${t}`}static getData(t){return fetch(`/api/bandcamp?url=${encodeURIComponent(t)}`).then(i=>i.json()).catch(()=>({id:null,thumbnail:null}))}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){const a=`https://${e[1]}`;this.getData(a).then(r=>{r.id&&i(r.id,a,r.thumbnail||"")})}}}class v{static type="giphy";static dataAttribute="giphy-id";static regex=/(?:https?:\/\/)?(?:w{3}\.)?giphy\.com\/gifs\/([a-zA-Z0-9_\-%]*)/;static embed(t){return`<iframe width="${t.w}" height="${t.h}" src="https://giphy.com/embed/${t.id}/twitter/iframe" frameborder="0" webkitAllowFullScreen mozallowfullscreen allowfullscreen allow=autoplay></iframe>`}static thumbnail(t){return`https://media.giphy.com/media/${t}/giphy_s.gif`}static link(t){return`https://giphy.com/gifs/${t}`}static buildFromText(t,i){const e=t.split("/"),s=e[e.length-1],a=s.split("-"),r=a[a.length-1];if(r){const o=this.link(s),c=this.thumbnail(r);i(r,o,c)}}}class k{static type="video";static dataAttribute="video-url";static regex=/(?:https?:\/\/)?(?:w{3}\.)?(.+\.(?:mp4|mov|m4v))(?:\/|$|\s|\?|#)/;static embed(t){const i=t.autoplay===!0?' autoplay="true"':"",e=t.loops===!0?' loop="true"':"",s=t.muted===!0?" muted":"";return`<video src="${t.id}" width="${t.w}" height="${t.h}"${i}${e}${s} controls playsinline webkitallowfullscreen mozallowfullscreen allowfullscreen></video>`}static thumbnail(t){return t.replace(".mp4","-poster.jpg").replace(".mov","-poster.jpg").replace(".m4v","-poster.jpg")}static link(t){return t}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){const s=e[1],a=this.thumbnail(s);i(s,s,a)}}}class ${static type="gif";static dataAttribute="gif-url";static regex=/(?:https?:\/\/)?(?:w{3}\.)?(.+\.gif)(?:\/|$|\s|\?|#)/;static embed(t){return`<img class="gif" src="${t.id}" width="${t.w}" height="${t.h}">`}static thumbnail(t){return t.replace(".gif","-poster.jpg")}static link(t){return t}static buildFromText(t,i){const e=t.match(this.regex);if(e&&e[1]){const s=e[1],a=this.thumbnail(s);i(s,s,a)}}}const m=[k,$,d,b,A,f,g,y,w,v];class l extends HTMLElement{defaultThumbnail="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAArwAAAGcAQMAAAABMOGrAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAADUExURQAAAKd6PdoAAAA6SURBVHja7cGBAAAAAMOg+VPf4ARVAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADAN488AAGP4e1mAAAAAElFTkSuQmCC";static EMBETTER_ACTIVATED="embetter-activated";connectedCallback(){this.shadow=this.attachShadow({mode:"open"}),this.el=this.shadow??this,this.initComponent(),this.render(),this.checkThumbnail(),this.addListeners()}disconnectedCallback(){this.unembedMedia(),this.removeAttribute("ready"),this.playButton&&this.playButton.removeEventListener("click",this.clickListener),document.removeEventListener(l.EMBETTER_ACTIVATED,this.embedListener),this.observer&&(this.observer.disconnect(),this.observer=null)}initComponent(){this.markup="embetter-media component not initialized properly.",this.loops=this.hasAttribute("loops"),this.muted=this.hasAttribute("muted"),this.posterURL=null;const t=this.querySelector("img");t&&t.src&&(this.posterURL=t.src),this.innerHTML="",this.findAndActivateService()}getElements(){this.thumbnail=this.el.querySelector("img")}addListeners(){this.clickListener=this.onClick.bind(this),this.playButton=this.el.querySelector(".embetter-play-button"),this.playButton&&this.playButton.addEventListener("click",this.clickListener),this.embedListener=this.onEmbedActivated.bind(this),document.addEventListener(l.EMBETTER_ACTIVATED,this.embedListener)}onClick(t){t.preventDefault(),this.embedMedia()}onEmbedActivated(t){t.detail!==this&&this.unembedMedia()}findAndActivateService(){for(let t of m){let i=t.dataAttribute;if(this.hasAttribute(i)){this.service=t,this.serviceType=t.type,this.serviceId=this.getAttribute(i);let e=this.posterURL||t.thumbnail(this.serviceId);if(this.markup=this.playerHTML(t.link(this.serviceId),e),t.getData){const s=t.link(this.serviceId);t.getData(s).then(a=>{const r=typeof a=="string"?a:a?.thumbnail;!e&&!this.posterURL&&r&&this.thumbnail&&(this.thumbnail.src=r)})}break}}}checkThumbnail(){this.thumbnail&&(this.setAttribute("loading",""),this.thumbnail.onload=()=>{this.removeAttribute("loading"),this.setAttribute("ready","")},this.thumbnail.onerror=()=>{if(this.thumbnail.src.includes("/maxresdefault.jpg")){this.thumbnail.src=this.thumbnail.src.replace("/maxresdefault.jpg","/0.jpg");return}this.thumbnail.src=this.defaultThumbnail,this.removeAttribute("loading"),this.setAttribute("ready","")},setTimeout(()=>{this.thumbnail.height<50&&(this.thumbnail.src=this.defaultThumbnail),this.removeAttribute("loading"),this.setAttribute("ready","")},4e3))}setupMobileObserver(){this.isMobile()&&(this.observer=new IntersectionObserver(t=>{t.forEach(i=>{i.isIntersecting?this.embedMedia(!1):this.unembedMedia()})},{threshold:.3}),this.observer.observe(this))}embedMedia(t){if(document.dispatchEvent(new CustomEvent(l.EMBETTER_ACTIVATED,{bubbles:!0,composed:!0,detail:this})),this.hasAttribute("playing"))return;t===void 0&&(t=this.hasAttribute("autoplay")?this.getAttribute("autoplay")!=="false":!0);let i=this.service.embed({id:this.serviceId,w:this.thumbnail&&this.thumbnail.width||"100%",h:this.thumbnail&&this.thumbnail.height||"100%",autoplay:t,loops:this.loops,muted:this.muted||t});this.playerEl=l.stringToDomElement(i),this.el.appendChild(this.playerEl),this.setAttribute("playing","")}unembedMedia(){this.playerEl!=null&&this.playerEl.parentNode!=null&&this.playerEl.parentNode.removeChild(this.playerEl),this.removeAttribute("playing")}isMobile(){return/iphone|ipad|ipod|android/i.test(navigator.userAgent)}static stringToDomElement(t){var i=document.createElement("div");return i.innerHTML=t,i.firstChild}static componentHTML(t,i,e=null,s=null){let a="";if(s||e){const r=s||"#",o=e?`<img src="${e}">`:"";a=`<a href="${r}">${o}</a>`}return`<embetter-media ${t}="${i}">${a}</embetter-media>`}playerHTML(t,i){return`
140
139
  <a href="${t}">
141
140
  <img src="${i}" />
142
141
  <div class="embetter-loading"></div>
@@ -145,4 +144,4 @@
145
144
  `}css(){return h}html(){return this.markup}render(){this.el.innerHTML=`
146
145
  ${this.html()}
147
146
  <style>${this.css()}</style>
148
- `,this.getElements()}static register(){customElements.define("embetter-media",l)}static upgradeLegacyEmbeds(t=document){t.querySelectorAll(".embetter").forEach(e=>{for(const a of m){const s=`data-${a.dataAttribute}`;if(e.hasAttribute(s)){const r=e.getAttribute(s),o=document.createElement("embetter-media");o.setAttribute(a.dataAttribute,r);const c=e.querySelector("a");c&&o.appendChild(c.cloneNode(!0)),e.hasAttribute("data-loops")&&o.setAttribute("loops",""),e.hasAttribute("data-muted")&&o.setAttribute("muted",""),e.replaceWith(o);break}}})}static componentMarkupFromURL(t,i){for(let e=0;e<m.length;e++){const a=m[e];if(t.match(a.regex)!=null){a.buildFromText(t,(s,r,o)=>{const c=u=>{let p=l.componentHTML(a.dataAttribute,s,u,r);i(p,a)};if(!o&&a.getData&&r){a.getData(r).then(u=>{const p=typeof u=="string"?u:u?.thumbnail;c(p||o)}).catch(()=>c(o));return}c(o)});break}}}}return l.register(),l}));
147
+ `,this.getElements()}static register(){customElements.define("embetter-media",l)}static upgradeLegacyEmbeds(t=document){t.querySelectorAll(".embetter").forEach(e=>{for(const s of m){const a=`data-${s.dataAttribute}`;if(e.hasAttribute(a)){const r=e.getAttribute(a),o=document.createElement("embetter-media");o.setAttribute(s.dataAttribute,r);const c=e.querySelector("a");c&&o.appendChild(c.cloneNode(!0)),e.hasAttribute("data-loops")&&o.setAttribute("loops",""),e.hasAttribute("data-muted")&&o.setAttribute("muted",""),e.replaceWith(o);break}}})}static componentMarkupFromURL(t,i){for(let e=0;e<m.length;e++){const s=m[e];if(t.match(s.regex)!=null){s.buildFromText(t,(a,r,o)=>{const c=u=>{let p=l.componentHTML(s.dataAttribute,a,u,r);i(p,s)};if(!o&&s.getData&&r){s.getData(r).then(u=>{const p=typeof u=="string"?u:u?.thumbnail;c(p||o)}).catch(()=>c(o));return}c(o)});break}}}}return l.register(),l}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "embetter",
3
- "version": "2.0.0",
3
+ "version": "2.0.1",
4
4
  "type": "module",
5
5
  "description": "Lazy-loading iframe embed web component",
6
6
  "main": "dist/embetter-media.umd.js",