@orangelogic/design-system 2.114.0 → 2.115.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.
Files changed (50) hide show
  1. package/library/chunks/asset.CtPQLZOf.js +607 -0
  2. package/library/chunks/{color-swatch-group.5Mqr0rNP.js → color-swatch-group.DjjSIHSV.js} +1 -1
  3. package/library/chunks/{document-viewer.Cui5mV3v.js → document-viewer.BIC9iYpZ.js} +1232 -1228
  4. package/library/chunks/{endpoints.DBlquU2-.js → endpoints.CDX5PgQz.js} +251 -251
  5. package/library/chunks/{folder-select.Bc9x2hMO.js → folder-select.8xNjeJfp.js} +1 -1
  6. package/library/chunks/{list-editor.BBgFSBlF.js → list-editor.7zNWfBuW.js} +8 -8
  7. package/library/chunks/{table.DLrle5SR.js → table.BvbReIZh.js} +41 -40
  8. package/library/chunks/{time.BiQnh9wt.js → time.BSmpFe2G.js} +2 -2
  9. package/library/chunks/waveform.1U9U_0rd.js +60 -0
  10. package/library/components/asset-link-format.js +1 -1
  11. package/library/components/atoms.js +2 -2
  12. package/library/components/audio.js +131 -182
  13. package/library/components/color-swatch-group.js +2 -2
  14. package/library/components/document-viewer.js +1 -1
  15. package/library/components/folder-select.js +2 -2
  16. package/library/components/format-time.js +1 -1
  17. package/library/components/list-editor.js +2 -2
  18. package/library/components/molecules.js +2 -2
  19. package/library/components/organisms.js +1 -1
  20. package/library/components/table.js +6 -6
  21. package/library/components/types.js +25325 -25041
  22. package/library/package.json +1 -1
  23. package/library/packages/atoms/src/components/audio/audio.d.ts +36 -28
  24. package/library/packages/events/src/cx-facet-change.d.ts +16 -0
  25. package/library/packages/events/src/cx-faceted-filter-change.d.ts +6 -1
  26. package/library/packages/events/src/events.d.ts +1 -0
  27. package/library/packages/molecules/src/faceted-filter/components/facet-date-picker/facet-date-picker.d.ts +43 -0
  28. package/library/packages/molecules/src/faceted-filter/components/facet-date-picker/facet-date-picker.styles.d.ts +2 -0
  29. package/library/packages/molecules/src/faceted-filter/components/facet-date-range/facet-date-range.d.ts +51 -0
  30. package/library/packages/molecules/src/faceted-filter/components/facet-date-range/facet-date-range.styles.d.ts +2 -0
  31. package/library/packages/molecules/src/faceted-filter/facet-adapters.d.ts +12 -0
  32. package/library/packages/molecules/src/faceted-filter/faceted-filter.d.ts +14 -3
  33. package/library/packages/molecules/src/index.d.ts +3 -0
  34. package/library/packages/organisms/src/asset-transformation-dialog/asset-transformation-dialog.d.ts +1 -1
  35. package/library/packages/organisms/src/content-builder/components/gallery-config/gallery-config.d.ts +1 -0
  36. package/library/packages/organisms/src/content-builder/components/page-picker/page-picker.d.ts +1 -0
  37. package/library/packages/organisms/src/content-builder/configs/audio.d.ts +1 -1
  38. package/library/packages/organisms/src/content-builder/configs-controller.d.ts +2 -2
  39. package/library/packages/services/src/api/asset/asset.d.ts +3 -1
  40. package/library/packages/services/src/api/endpoints.d.ts +2 -0
  41. package/library/packages/tools/src/fetch-asset/fetch-asset.d.ts +6 -0
  42. package/library/packages/tools/src/fetch-image/fetch-image.d.ts +11 -4
  43. package/library/packages/types/src/faceted-filter.d.ts +71 -2
  44. package/library/packages/utils/src/image/index.d.ts +1 -0
  45. package/library/packages/utils/src/image/waveform.d.ts +29 -0
  46. package/library/react-web-component.d.ts +317 -194
  47. package/library/utils.js +174 -171
  48. package/package.json +1 -1
  49. package/library/chunks/asset.Drl4D1c7.js +0 -458
  50. package/library/chunks/wavesurfer.esm.Cwi1pz64.js +0 -1276
@@ -5,7 +5,7 @@ import oe from "../components/select.js";
5
5
  import ce from "../components/tag.js";
6
6
  import { C as g, a as ne } from "./tree.Btf2Q4YZ.js";
7
7
  import { n as r, C as U } from "./lib-cortex-element.CVMmyPMC.js";
8
- import { h as R, F as he, c as de } from "./endpoints.DBlquU2-.js";
8
+ import { h as R, F as he, c as de } from "./endpoints.CDX5PgQz.js";
9
9
  import { M as k } from "./asset-link-format.B0c92pSs.js";
10
10
  import { c as j } from "./component.styles.CRO4Odto.js";
11
11
  import { c as M } from "./custom-element.L4WJXn1j.js";
@@ -1,15 +1,15 @@
1
- import { C as _ } from "./button.DwJEeW2t.js";
1
+ import { C as k } from "./button.DwJEeW2t.js";
2
2
  import { C as O, D as q } from "./dialog.BYCWepBc.js";
3
3
  import G from "../components/grid.js";
4
4
  import R from "../components/grid-item.js";
5
- import { C as k } from "./input.CH4lKxPM.js";
5
+ import { C as _ } from "./input.CH4lKxPM.js";
6
6
  import j from "../components/line-clamp.js";
7
7
  import { C as P } from "./option.Bvh35v8S.js";
8
8
  import F from "../components/radio.js";
9
9
  import B from "../components/radio-group.js";
10
10
  import K from "../components/select.js";
11
11
  import S from "../components/space.js";
12
- import { C as U, H } from "./table.DLrle5SR.js";
12
+ import { C as U, H } from "./table.BvbReIZh.js";
13
13
  import { C as E } from "./typography.DJC_UXgs.js";
14
14
  import { n as o, C as T } from "./lib-cortex-element.CVMmyPMC.js";
15
15
  import V from "../components/dynamic-select.js";
@@ -30,7 +30,7 @@ import { n as N } from "./when.Dr1es41R.js";
30
30
  import { t as Q } from "./toString.CAY8lys2.js";
31
31
  import { C as ee } from "./icon-button.CQiBjznj.js";
32
32
  import { C as te } from "./image.cT-FziNS.js";
33
- import { a as ae } from "./asset.Drl4D1c7.js";
33
+ import { a as ae } from "./asset.CtPQLZOf.js";
34
34
  import { a as ie } from "./index.Cpamj0jB.js";
35
35
  import { A as g } from "./content-builder.OsUmm8Wu.js";
36
36
  import { b as ne, t as w } from "./string.DUgD4c9f.js";
@@ -931,10 +931,10 @@ let c = class extends T {
931
931
  };
932
932
  c.styles = [L, pe];
933
933
  c.dependencies = {
934
- "cx-button": _,
934
+ "cx-button": k,
935
935
  "cx-icon-button": ee,
936
936
  "cx-image": te,
937
- "cx-input": k,
937
+ "cx-input": _,
938
938
  "cx-space": S,
939
939
  "cx-typography": E
940
940
  };
@@ -1241,12 +1241,12 @@ let n = class extends T {
1241
1241
  n.styles = [L, ve];
1242
1242
  n.dependencies = {
1243
1243
  "cx-asset-picker": c,
1244
- "cx-button": _,
1244
+ "cx-button": k,
1245
1245
  "cx-dialog": O,
1246
1246
  "cx-dynamic-select": V,
1247
1247
  "cx-grid": G,
1248
1248
  "cx-grid-item": R,
1249
- "cx-input": k,
1249
+ "cx-input": _,
1250
1250
  "cx-line-clamp": j,
1251
1251
  "cx-option": P,
1252
1252
  "cx-radio": F,
@@ -19179,9 +19179,9 @@ v = C([
19179
19179
  Rt("cx-table")
19180
19180
  ], v);
19181
19181
  export {
19182
- is as $,
19182
+ ts as $,
19183
19183
  mi as A,
19184
- ji as B,
19184
+ Wi as B,
19185
19185
  v as C,
19186
19186
  Ti as D,
19187
19187
  Di as E,
@@ -19189,52 +19189,53 @@ export {
19189
19189
  Lo as G,
19190
19190
  at as H,
19191
19191
  Ai as I,
19192
- Gi as J,
19192
+ ji as J,
19193
19193
  Vi as K,
19194
- $i as L,
19194
+ Gi as L,
19195
19195
  P as M,
19196
- Ui as N,
19197
- Ki as O,
19196
+ $i as N,
19197
+ Ui as O,
19198
19198
  dd as P,
19199
- qi as Q,
19199
+ Ki as Q,
19200
19200
  bs as R,
19201
- Io as S,
19201
+ yh as S,
19202
19202
  it as T,
19203
- Xi as U,
19204
- Ji as V,
19205
- Yi as W,
19206
- Qi as X,
19207
- Zi as Y,
19208
- es as Z,
19209
- ts as _,
19203
+ qi as U,
19204
+ Xi as V,
19205
+ Ji as W,
19206
+ Yi as X,
19207
+ Qi as Y,
19208
+ Zi as Z,
19209
+ es as _,
19210
19210
  vh as a,
19211
- ss as a0,
19212
- os as a1,
19213
- st as a2,
19214
- ee as a3,
19211
+ is as a0,
19212
+ ss as a1,
19213
+ os as a2,
19214
+ st as a3,
19215
+ ee as a4,
19215
19216
  ms as b,
19216
19217
  xi as c,
19217
19218
  Fr as d,
19218
19219
  Ml as e,
19219
- pe as f,
19220
- Nt as g,
19221
- ri as h,
19222
- bi as i,
19223
- wi as j,
19224
- vi as k,
19225
- Ei as l,
19226
- Ri as m,
19227
- Si as n,
19228
- Mi as o,
19229
- Li as p,
19230
- qt as q,
19231
- Fi as r,
19232
- Oi as s,
19233
- _i as t,
19234
- Pi as u,
19235
- Hi as v,
19236
- Ni as w,
19237
- Ii as x,
19238
- Bi as y,
19239
- Wi as z
19220
+ Io as f,
19221
+ pe as g,
19222
+ Nt as h,
19223
+ ri as i,
19224
+ bi as j,
19225
+ wi as k,
19226
+ vi as l,
19227
+ Ei as m,
19228
+ Ri as n,
19229
+ Si as o,
19230
+ Mi as p,
19231
+ Li as q,
19232
+ qt as r,
19233
+ Fi as s,
19234
+ Oi as t,
19235
+ _i as u,
19236
+ Pi as v,
19237
+ Hi as w,
19238
+ Ni as x,
19239
+ Ii as y,
19240
+ Bi as z
19240
19241
  };
@@ -111,8 +111,8 @@ export {
111
111
  D as M,
112
112
  m as S,
113
113
  a as U,
114
- N as a,
114
+ w as a,
115
115
  H as c,
116
- w as f,
116
+ N as f,
117
117
  y as g
118
118
  };
@@ -0,0 +1,60 @@
1
+ function $(o, l, u, e, c, n) {
2
+ let r = -1, a = -1;
3
+ for (let t = e; t < c; t++)
4
+ for (let s = 0; s < u; s++) {
5
+ const i = (s * l + t) * 4;
6
+ (0.299 * o[i] + 0.587 * o[i + 1] + 0.114 * o[i + 2]) / 255 < n && o[i + 3] > 128 && (r === -1 && (r = s), a = s);
7
+ }
8
+ return r === -1 ? 0 : (a - r) / u;
9
+ }
10
+ async function p(o, l) {
11
+ const u = l?.threshold ?? 0.92;
12
+ try {
13
+ const e = new Image();
14
+ e.crossOrigin = "anonymous", e.src = o, await e.decode();
15
+ const { naturalHeight: c, naturalWidth: n } = e, r = l?.sampleCount ?? n, a = document.createElement("canvas");
16
+ a.width = n, a.height = c;
17
+ const t = a.getContext("2d");
18
+ if (!t)
19
+ return null;
20
+ let s;
21
+ try {
22
+ t.drawImage(e, 0, 0), s = t.getImageData(0, 0, n, c);
23
+ } catch {
24
+ return null;
25
+ }
26
+ const { data: i } = s, m = [];
27
+ for (let h = 0; h < r; h++) {
28
+ const f = Math.floor(h / r * n), x = Math.floor((h + 1) / r * n);
29
+ m.push($(i, n, c, f, x === f ? f + 1 : x, u));
30
+ }
31
+ const d = Math.max(...m), g = d > 0 ? m.map((h) => h / d) : m;
32
+ return { height: c, peaks: g, width: n };
33
+ } catch {
34
+ return null;
35
+ }
36
+ }
37
+ function F(o, l, u) {
38
+ if (o.length === 0)
39
+ return "";
40
+ const e = u / 2, c = u / 2, n = o.length, r = l / n, a = [`M0 ${(e - o[0] * c).toFixed(2)}`];
41
+ for (let t = 0; t < n - 1; t++)
42
+ a.push(
43
+ `H${((t + 1) * r).toFixed(2)}`,
44
+ `V${(e - o[t + 1] * c).toFixed(2)}`
45
+ );
46
+ a.push(
47
+ `H${l}`,
48
+ `V${(e + o[n - 1] * c).toFixed(2)}`
49
+ );
50
+ for (let t = n - 1; t > 0; t--)
51
+ a.push(
52
+ `H${(t * r).toFixed(2)}`,
53
+ `V${(e + o[t - 1] * c).toFixed(2)}`
54
+ );
55
+ return a.push("H0", "Z"), a.join(" ");
56
+ }
57
+ export {
58
+ F as b,
59
+ p as e
60
+ };
@@ -3,7 +3,7 @@ import { C as B } from "../chunks/button.DwJEeW2t.js";
3
3
  import _ from "./space.js";
4
4
  import { C as F } from "../chunks/typography.DJC_UXgs.js";
5
5
  import { n, C as W } from "../chunks/lib-cortex-element.CVMmyPMC.js";
6
- import { b as rt, c as ht } from "../chunks/asset.Drl4D1c7.js";
6
+ import { b as rt, c as ht } from "../chunks/asset.CtPQLZOf.js";
7
7
  import { c as E } from "../chunks/component.styles.CRO4Odto.js";
8
8
  import { U as a, T as l } from "../chunks/asset-link-format.B0c92pSs.js";
9
9
  import { c as N } from "../chunks/custom-element.L4WJXn1j.js";
@@ -19,7 +19,7 @@ import { default as K } from "./date-calendar.js";
19
19
  import { default as W } from "./details.js";
20
20
  import { C as Y } from "../chunks/dialog.BYCWepBc.js";
21
21
  import { default as _ } from "./divider.js";
22
- import { C as oe } from "../chunks/document-viewer.Cui5mV3v.js";
22
+ import { C as oe } from "../chunks/document-viewer.BIC9iYpZ.js";
23
23
  import { C as ae } from "../chunks/dot-pagination.C4l5vKor.js";
24
24
  import { default as xe } from "./dot-status.js";
25
25
  import { default as me } from "./drawer.js";
@@ -74,7 +74,7 @@ import { default as Uo } from "./stepper.js";
74
74
  import { default as Xo } from "./switch.js";
75
75
  import { default as Zo } from "./tab.js";
76
76
  import { C as et } from "../chunks/tab-group.DvMX02hY.js";
77
- import { C as tt } from "../chunks/table.DLrle5SR.js";
77
+ import { C as tt } from "../chunks/table.BvbReIZh.js";
78
78
  import { default as rt } from "./tab-panel.js";
79
79
  import { default as ft } from "./tag.js";
80
80
  import { default as st } from "./textarea.js";
@@ -1,45 +1,27 @@
1
- import { r as m, R as y } from "../chunks/resizable-component.styles.DpK0TTP5.js";
1
+ import { r as f, R as y } from "../chunks/resizable-component.styles.DpK0TTP5.js";
2
2
  import { c as v } from "../chunks/component.styles.CRO4Odto.js";
3
- import { c as g } from "../chunks/custom-element.L4WJXn1j.js";
3
+ import { U as u, g, f as x, D as w } from "../chunks/time.BSmpFe2G.js";
4
+ import { c as _ } from "../chunks/custom-element.L4WJXn1j.js";
4
5
  import { L as S } from "../chunks/i18n.CH-wak_P.js";
5
- import { w as f } from "../chunks/watch.CThbualB.js";
6
- import { i as w, x as p } from "../chunks/lit-element.jLBm65_O.js";
7
- import { n as c } from "../chunks/lib-cortex-element.CVMmyPMC.js";
8
- import { r as u } from "../chunks/state.CSDxrqLd.js";
9
- import { r as x } from "../chunks/query-async.CTgXGyQ5.js";
6
+ import { w as m } from "../chunks/watch.CThbualB.js";
7
+ import { e as b, b as P } from "../chunks/waveform.1U9U_0rd.js";
8
+ import { i as $, b as z, x as h } from "../chunks/lit-element.jLBm65_O.js";
9
+ import { n } from "../chunks/lib-cortex-element.CVMmyPMC.js";
10
+ import { r as s } from "../chunks/state.CSDxrqLd.js";
11
+ import { e as E } from "../chunks/query.BBf1UFkC.js";
10
12
  import { e as C } from "../chunks/class-map.BiVq-cVR.js";
11
13
  import { n as d } from "../chunks/when.Dr1es41R.js";
12
- import { C as b } from "../chunks/icon-button.CQiBjznj.js";
13
- import { C as W } from "../chunks/typography.DJC_UXgs.js";
14
- const _ = w`:host{background-color:var(--background-color,var(--cx-color-neutral-0));border-radius:var(--border-radius,0px);border:var(--border,0px);box-sizing:border-box;color:var(--text-color,var(--cx-color-neutral));height:var(--height,auto);width:var(--width,100%);border-style:solid;display:block;position:relative}.audio{border-radius:inherit;gap:var(--cx-spacing-x-small,4px);height:100%;padding:var(--cx-spacing-small,8px);flex-direction:column;justify-content:center;display:flex;overflow:hidden}.audio--empty{height:var(--height,200px);min-height:var(--min-height,100%);padding:0}.audio--empty:before{background-color:var(--cx-color-neutral-1000);color:var(--cx-color-neutral-0);content:attr(data-empty-label);font-family:var(--cx-font-sans);font-size:clamp(var(--cx-font-size-x-small), 4cqw, var(--cx-font-size-large));font-weight:var(--cx-font-weight-semibold);text-align:center;height:100%;text-shadow:.05em .05em .1em var(--cx-color-neutral-1000);justify-content:center;align-items:center;width:100%;line-height:1;display:flex}.audio__play-button{--cx-input-border-width:2px;--cx-input-border-color:var(--text-color,var(--cx-color-neutral))}.audio__play-button::part(base){width:50px;height:50px;color:var(--text-color,var(--cx-color-neutral))!important}.audio__player{align-items:center;gap:var(--cx-spacing-small,8px);display:flex}.audio__waveform{flex:1;min-width:0;overflow:hidden}.audio__footer{font-size:var(--cx-font-size-x-small,11px);color:var(--text-color,var(--cx-color-neutral));flex-direction:column;gap:0;padding-left:2px;display:flex}.audio__time{color:var(--text-color,var(--cx-color-neutral));font-variant-numeric:tabular-nums}.audio__filename{opacity:.75;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}`;
15
- var P = Object.defineProperty, z = Object.getOwnPropertyDescriptor, n = (e, t, r, o) => {
16
- for (var i = o > 1 ? void 0 : o ? z(t, r) : t, s = e.length - 1, l; s >= 0; s--)
17
- (l = e[s]) && (i = (o ? l(t, r, i) : l(i)) || i);
18
- return o && i && P(t, r, i), i;
14
+ import { C as k } from "../chunks/icon-button.CQiBjznj.js";
15
+ import { C as T } from "../chunks/typography.DJC_UXgs.js";
16
+ const A = $`audio{display:none}:host{background-color:var(--background-color,var(--cx-color-neutral-0));border-radius:var(--border-radius,0px);border:var(--border,0px);box-sizing:border-box;color:var(--text-color,var(--cx-color-neutral));height:var(--height,auto);width:var(--width,100%);border-style:solid;display:block;position:relative}.audio{border-radius:inherit;gap:var(--cx-spacing-x-small,4px);height:100%;padding:var(--cx-spacing-small,8px);flex-direction:column;justify-content:center;display:flex;overflow:hidden}.audio--empty{height:var(--height,200px);min-height:var(--min-height,100%);padding:0}.audio--empty:before{background-color:var(--cx-color-neutral-1000);color:var(--cx-color-neutral-0);content:attr(data-empty-label);font-family:var(--cx-font-sans);font-size:clamp(var(--cx-font-size-x-small), 4cqw, var(--cx-font-size-large));font-weight:var(--cx-font-weight-semibold);text-align:center;height:100%;text-shadow:.05em .05em .1em var(--cx-color-neutral-1000);justify-content:center;align-items:center;width:100%;line-height:1;display:flex}.audio__play-button{--cx-input-border-width:2px;--cx-input-border-color:var(--text-color,var(--cx-color-neutral))}.audio__play-button::part(base){width:50px;height:50px;color:var(--text-color,var(--cx-color-neutral))!important}.audio__player{align-items:center;gap:var(--cx-spacing-small,8px);height:148px;display:flex}.audio__waveform{flex:1;min-width:0;overflow:hidden}.audio__waveform-svg{cursor:pointer;flex:1;width:100%;min-width:0;height:100%;display:block;overflow:hidden}.audio__waveform-wave{fill:var(--waves-color,var(--cx-color-primary))}.audio__waveform-played{fill:var(--played-color,var(--cx-color-primary-700,var(--cx-color-primary)))}.audio__waveform-playhead{fill:var(--playhead-color,var(--cx-color-neutral-0));opacity:.9}.audio__footer{font-size:var(--cx-font-size-x-small,11px);color:var(--text-color,var(--cx-color-neutral));flex-direction:column;gap:0;padding-left:2px;display:flex}.audio__time{color:var(--text-color,var(--cx-color-neutral));font-variant-numeric:tabular-nums}.audio__filename{opacity:.75;text-overflow:ellipsis;white-space:nowrap;overflow:hidden}`;
17
+ var B = Object.defineProperty, W = Object.getOwnPropertyDescriptor, i = (t, a, o, r) => {
18
+ for (var l = r > 1 ? void 0 : r ? W(a, o) : a, c = t.length - 1, p; c >= 0; c--)
19
+ (p = t[c]) && (l = (r ? p(a, o, l) : p(l)) || l);
20
+ return r && l && B(a, o, l), l;
19
21
  };
20
- function $(e) {
21
- const t = "light-dark(";
22
- if (!e.startsWith(t) || !e.endsWith(")"))
23
- return null;
24
- const r = e.slice(t.length, -1);
25
- let o = 0, i = -1;
26
- for (let h = 0; h < r.length; h++)
27
- if (r[h] === "(")
28
- o++;
29
- else if (r[h] === ")")
30
- o--;
31
- else if (r[h] === "," && o === 0) {
32
- i = h;
33
- break;
34
- }
35
- if (i === -1)
36
- return null;
37
- const s = r.slice(0, i).trim(), l = r.slice(i + 1).trim();
38
- return !CSS.supports("color", s) || !CSS.supports("color", l) ? null : [s, l];
39
- }
40
- let a = class extends y {
22
+ let e = class extends y {
41
23
  constructor() {
42
- super(), this.localize = new S(this), this.waveSurfer = null, this.srcLoadVersion = 0, this.src = "", this.name = "", this.autoplay = !1, this.loop = !1, this.waveColor = ["", ""], this.isPlaying = !1, this.isLoaded = !1, this.isError = !1, this.currentTimeSeconds = 0, this.durationSeconds = 0, this.onWaveSurferReady = this.onWaveSurferReady.bind(this), this.onWaveSurferPlay = this.onWaveSurferPlay.bind(this), this.onWaveSurferPause = this.onWaveSurferPause.bind(this), this.onWaveSurferTimeUpdate = this.onWaveSurferTimeUpdate.bind(this), this.onWaveSurferFinish = this.onWaveSurferFinish.bind(this), this.onWaveSurferError = this.onWaveSurferError.bind(this);
24
+ super(...arguments), this.localize = new S(this), this.srcLoadVersion = 0, this.extractWaveformPeaks = b, this.src = "", this.name = "", this.autoplay = !1, this.loop = !1, this.waveformSrc = "", this.isPlaying = !1, this.isLoaded = !1, this.isError = !1, this.currentTimeSeconds = 0, this.durationSeconds = 0, this.waveformPath = "", this.waveformViewBoxWidth = 1e3, this.playedFraction = 0, this.audioSrc = "";
43
25
  }
44
26
  runConnectedCallback() {
45
27
  this.hasUpdated && this.requestUpdate("src");
@@ -50,188 +32,155 @@ let a = class extends y {
50
32
  async handleSrcChange() {
51
33
  await this.applySrc(this.src);
52
34
  }
53
- async applySrc(e) {
54
- const t = ++this.srcLoadVersion;
55
- if (this.isLoaded = !1, this.isPlaying = !1, !e) {
35
+ async applySrc(t) {
36
+ const a = ++this.srcLoadVersion;
37
+ if (this.isLoaded = !1, this.isPlaying = !1, !this.waveformSrc) {
56
38
  this.cleanUp();
57
39
  return;
58
40
  }
59
- await this.waveformContainerAsync, !(t !== this.srcLoadVersion || !this.isConnected) && await this.setupWaveSurfer(e, t);
41
+ await this.setupPngWaveform(t, a);
60
42
  }
61
- async handleWaveColorThemeChange() {
62
- this.src && this.waveSurfer && (await this.updateComplete, this.waveSurfer.setOptions(this.setupColors()));
43
+ updated(t) {
44
+ super.updated(t), (t.has("width") || t.has("height") || t.has("resizeSize")) && this.handleSizeChange();
63
45
  }
64
- updated(e) {
65
- super.updated(e), (e.has("width") || e.has("height") || e.has("resizeSize")) && this.handleSizeChange();
46
+ cleanUp() {
47
+ this.audioEl?.pause(), this.audioSrc = "", this.waveformPath = "", this.waveformViewBoxWidth = 1e3, this.playedFraction = 0, this.isLoaded = !1, this.isPlaying = !1, this.currentTimeSeconds = 0, this.durationSeconds = 0;
66
48
  }
67
- onWaveSurferReady() {
68
- this.isLoaded = !0, this.durationSeconds = this.waveSurfer.getDuration();
49
+ async setupPngWaveform(t, a) {
50
+ this.cleanUp();
51
+ const o = await this.extractWaveformPeaks(this.waveformSrc);
52
+ if (a !== this.srcLoadVersion || !this.isConnected)
53
+ return;
54
+ if (!o) {
55
+ this.isError = !0, this.emit("cx-error");
56
+ return;
57
+ }
58
+ const r = o.peaks.length;
59
+ this.waveformViewBoxWidth = r, this.waveformPath = P(o.peaks, r, 200), t && (this.audioSrc = t), this.isLoaded = !0, this.autoplay && t && (await this.updateComplete, this.audioEl?.play());
69
60
  }
70
- onWaveSurferPlay() {
61
+ handleAudioPlay() {
71
62
  this.isPlaying = !0, this.emit("cx-play");
72
63
  }
73
- onWaveSurferPause() {
64
+ handleAudioPause() {
74
65
  this.isPlaying = !1, this.emit("cx-pause");
75
66
  }
76
- onWaveSurferTimeUpdate(e) {
77
- this.currentTimeSeconds = e, this.emit("cx-time-update", {
78
- detail: {
79
- time: e
80
- }
81
- });
67
+ handleAudioTimeUpdate() {
68
+ if (!this.audioEl)
69
+ return;
70
+ const t = this.audioEl.duration ? this.audioEl.currentTime / this.audioEl.duration : 0;
71
+ this.playedFraction = t, this.style.setProperty("--played-fraction", String(t)), this.currentTimeSeconds = this.audioEl.currentTime, this.emit("cx-time-update", { detail: { time: this.audioEl.currentTime } });
72
+ }
73
+ handleAudioDurationChange() {
74
+ this.durationSeconds = this.audioEl?.duration || 0;
82
75
  }
83
- onWaveSurferFinish() {
76
+ handleAudioEnded() {
84
77
  this.isPlaying = !1, this.emit("cx-ended");
85
78
  }
86
- onWaveSurferError() {
87
- this.isError = !0, this.emit("cx-error");
88
- }
89
- resolveColorValue(e) {
90
- if (!e.startsWith("var("))
91
- return e;
92
- const t = e.match(/var\(\s*(--[\w-]+)/)?.[1];
93
- return t && getComputedStyle(this).getPropertyValue(t).trim() || e;
94
- }
95
- computeCursorColor(e) {
96
- const t = document.createElement("canvas");
97
- t.width = 1, t.height = 1;
98
- const r = t.getContext("2d");
99
- if (!r)
100
- return e;
101
- r.fillStyle = e, r.fillRect(0, 0, 1, 1);
102
- const [o, i, s] = r.getImageData(0, 0, 1, 1).data;
103
- return (0.299 * o + 0.587 * i + 0.114 * s) / 255 > 0.5 ? `rgb(${Math.round(o * 0.5)}, ${Math.round(i * 0.5)}, ${Math.round(s * 0.5)})` : `rgb(${Math.round(o + (255 - o) * 0.5)}, ${Math.round(i + (255 - i) * 0.5)}, ${Math.round(s + (255 - s) * 0.5)})`;
104
- }
105
- setupColors() {
106
- const t = getComputedStyle(this).getPropertyValue("--cx-color-primary").trim(), r = (this.theme === "dark" ? this.waveColor[1] : this.waveColor[0]) || t, o = this.resolveColorValue(r), i = this.resolveColorValue(
107
- this.theme === "dark" ? this.waveColor[1] : this.waveColor[0]
108
- ), s = this.computeCursorColor(o);
109
- return {
110
- cursorColor: s,
111
- progressColor: s,
112
- waveColor: i
113
- };
114
- }
115
- async setupWaveSurfer(e, t = this.srcLoadVersion) {
116
- this.cleanUp();
117
- const r = await this.waveformContainerAsync;
118
- if (t !== this.srcLoadVersion || !r || !e || !this.isConnected)
119
- return;
120
- const { default: o } = await import("../chunks/wavesurfer.esm.Cwi1pz64.js");
121
- t !== this.srcLoadVersion || !this.isConnected || (this.waveSurfer = o.create({
122
- barGap: 1,
123
- barRadius: 2,
124
- barWidth: 2,
125
- container: r,
126
- height: "auto",
127
- normalize: !0,
128
- url: e,
129
- ...this.setupColors()
130
- }), this.attachWaveSurferEvents(), this.autoplay && this.waveSurfer.play());
131
- }
132
- attachWaveSurferEvents() {
133
- this.waveSurfer && (this.waveSurfer.on("ready", this.onWaveSurferReady), this.waveSurfer.on("play", this.onWaveSurferPlay), this.waveSurfer.on("pause", this.onWaveSurferPause), this.waveSurfer.on("timeupdate", this.onWaveSurferTimeUpdate), this.waveSurfer.on("finish", this.onWaveSurferFinish), this.waveSurfer.on("error", this.onWaveSurferError));
134
- }
135
- cleanUp() {
136
- this.waveSurfer && (this.waveSurfer.destroy(), this.waveSurfer = null), this.isLoaded = !1, this.isPlaying = !1, this.currentTimeSeconds = 0, this.durationSeconds = 0;
79
+ handleAudioError() {
80
+ this.audioSrc && (this.isError = !0, this.emit("cx-error"));
137
81
  }
138
82
  handleSizeChange() {
139
- const e = this.isResizing ? `${this.resizeSize.width}px` : this.width, t = this.isResizing ? `${this.resizeSize.height}px` : this.height;
140
- this.width || this.isResizing ? this.style.setProperty("--width", e) : this.style.removeProperty("--width"), this.height || this.isResizing ? this.style.setProperty("--height", t) : this.style.removeProperty("--height");
83
+ const t = this.isResizing ? `${this.resizeSize.width}px` : this.width, a = this.isResizing ? `${this.resizeSize.height}px` : this.height;
84
+ this.width || this.isResizing ? this.style.setProperty("--width", t) : this.style.removeProperty("--width"), this.height || this.isResizing ? this.style.setProperty("--height", a) : this.style.removeProperty("--height");
141
85
  }
142
86
  /** Starts audio playback. */
143
87
  play() {
144
- this.waveSurfer?.play();
88
+ this.audioEl?.play();
145
89
  }
146
90
  /** Pauses audio playback. */
147
91
  pause() {
148
- this.waveSurfer?.pause();
92
+ this.audioEl?.pause();
149
93
  }
150
94
  /** Toggles between play and pause. */
151
95
  togglePlay() {
152
96
  this.isPlaying ? this.pause() : this.play();
153
97
  }
154
- formatTime(e) {
155
- const t = Math.floor(e / 60), r = Math.floor(e % 60);
156
- return `${t}:${r.toString().padStart(2, "0")}`;
98
+ formatTime(t) {
99
+ const o = this.durationSeconds >= 3600 ? u.HourMinuteSecond : u.MinuteSecond, r = g(t * 1e3, o);
100
+ return x(r, w.Digital);
101
+ }
102
+ handleWaveformClick(t) {
103
+ if (t.stopPropagation(), !this.audioEl || !this.durationSeconds)
104
+ return;
105
+ const o = t.currentTarget.getBoundingClientRect(), r = Math.max(0, Math.min(1, (t.clientX - o.left) / o.width));
106
+ this.audioEl.currentTime = r * this.durationSeconds;
157
107
  }
158
- handlePlayButtonKeyDown(e) {
159
- (e.key === "Enter" || e.key === " ") && (e.preventDefault(), this.togglePlay());
108
+ handlePlayButtonKeyDown(t) {
109
+ (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.togglePlay());
160
110
  }
161
111
  render() {
162
- const e = !this.src, t = this.formatTime(this.currentTimeSeconds), r = this.formatTime(this.durationSeconds);
163
- return p`<div part="base" class=${C({ audio: !0, "audio--empty": e })} data-empty-label=${this.localize.term("emptyAudio")} @click=${this.startResizing}>${d(
164
- !e,
165
- () => p`<div part="player" class="audio__player"><cx-icon-button part="play-button" class="audio__play-button" aria-pressed=${String(this.isPlaying)} circle label=${this.localize.term(this.isPlaying ? "pause" : "play")} name=${this.isPlaying ? "pause" : "play_arrow"} variant="filled" outline @click=${this.togglePlay} @keydown=${this.handlePlayButtonKeyDown}></cx-icon-button><div part="waveform" class="audio__waveform"></div></div><div part="footer" class="audio__footer"><cx-typography part="time" variant="small" class="audio__time">${t} / ${r}</cx-typography>${d(
112
+ const t = !this.src && !this.waveformSrc, a = this.formatTime(this.currentTimeSeconds), o = this.formatTime(this.durationSeconds);
113
+ return h`<audio src=${this.audioSrc} ?loop=${this.loop} @play=${this.handleAudioPlay} @pause=${this.handleAudioPause} @timeupdate=${this.handleAudioTimeUpdate} @durationchange=${this.handleAudioDurationChange} @ended=${this.handleAudioEnded} @error=${this.handleAudioError}></audio><div part="base" class=${C({ audio: !0, "audio--empty": t })} data-empty-label=${this.localize.term("emptyAudio")} @click=${this.startResizing}>${d(
114
+ !t,
115
+ () => h`<div part="player" class="audio__player"><cx-icon-button part="play-button" class="audio__play-button" aria-pressed=${String(this.isPlaying)} circle label=${this.localize.term(this.isPlaying ? "pause" : "play")} name=${this.isPlaying ? "pause" : "play_arrow"} variant="filled" outline @click=${this.togglePlay} @keydown=${this.handlePlayButtonKeyDown}></cx-icon-button>${d(
116
+ this.waveformPath,
117
+ () => z`<svg class="audio__waveform-svg" part="waveform-svg" viewBox="0 0 ${this.waveformViewBoxWidth} 200" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" @click=${this.handleWaveformClick}><path class="audio__waveform-wave" d=${this.waveformPath} /><svg x="0" y="0" width=${String(Math.round(this.playedFraction * this.waveformViewBoxWidth))} height="200" overflow="hidden"><path class="audio__waveform-played" d=${this.waveformPath} /></svg><rect class="audio__waveform-playhead" x=${String(Math.max(0, Math.round(this.playedFraction * this.waveformViewBoxWidth) - 1))} y="0" width="2" height="200"/></svg>`,
118
+ () => h`<div part="waveform" class="audio__waveform"></div>`
119
+ )}</div><div part="footer" class="audio__footer"><cx-typography part="time" variant="small" class="audio__time">${a} / ${o}</cx-typography>${d(
166
120
  this.name,
167
- () => p`<cx-typography part="filename" class="audio__filename">${this.name}</cx-typography>`
121
+ () => h`<cx-typography part="filename" class="audio__filename">${this.name}</cx-typography>`
168
122
  )}</div>`
169
123
  )}</div>${d(this.resizable && this.isResizeActive, () => this.renderResizer())}
170
124
  `;
171
125
  }
172
126
  };
173
- a.styles = [v, m, _];
174
- a.dependencies = {
175
- "cx-icon-button": b,
176
- "cx-typography": W
127
+ e.styles = [v, f, A];
128
+ e.dependencies = {
129
+ "cx-icon-button": k,
130
+ "cx-typography": T
177
131
  };
178
- n([
179
- x(".audio__waveform")
180
- ], a.prototype, "waveformContainerAsync", 2);
181
- n([
182
- c({ reflect: !0, type: String })
183
- ], a.prototype, "src", 2);
184
- n([
185
- c({ reflect: !0, type: String })
186
- ], a.prototype, "name", 2);
187
- n([
188
- c({ reflect: !0, type: Boolean })
189
- ], a.prototype, "autoplay", 2);
190
- n([
191
- c({ reflect: !0, type: Boolean })
192
- ], a.prototype, "loop", 2);
193
- n([
194
- c({
195
- attribute: "wave-color",
196
- converter: {
197
- fromAttribute(e) {
198
- if (!e)
199
- return ["", ""];
200
- const t = $(e);
201
- return t || (CSS.supports("color", e) ? [e, e] : ["", ""]);
202
- },
203
- toAttribute([e, t]) {
204
- return e === t ? e : `light-dark(${e}, ${t})`;
205
- }
206
- },
207
- reflect: !0
208
- })
209
- ], a.prototype, "waveColor", 2);
210
- n([
211
- u()
212
- ], a.prototype, "isPlaying", 2);
213
- n([
214
- u()
215
- ], a.prototype, "isLoaded", 2);
216
- n([
217
- u()
218
- ], a.prototype, "isError", 2);
219
- n([
220
- u()
221
- ], a.prototype, "currentTimeSeconds", 2);
222
- n([
223
- u()
224
- ], a.prototype, "durationSeconds", 2);
225
- n([
226
- f("src")
227
- ], a.prototype, "handleSrcChange", 1);
228
- n([
229
- f("theme", { waitUntilFirstUpdate: !0 }),
230
- f("waveColor", { waitUntilFirstUpdate: !0 })
231
- ], a.prototype, "handleWaveColorThemeChange", 1);
232
- a = n([
233
- g("cx-audio")
234
- ], a);
132
+ i([
133
+ E("audio")
134
+ ], e.prototype, "audioEl", 2);
135
+ i([
136
+ n({ reflect: !0, type: String })
137
+ ], e.prototype, "src", 2);
138
+ i([
139
+ n({ reflect: !0, type: String })
140
+ ], e.prototype, "name", 2);
141
+ i([
142
+ n({ reflect: !0, type: Boolean })
143
+ ], e.prototype, "autoplay", 2);
144
+ i([
145
+ n({ reflect: !0, type: Boolean })
146
+ ], e.prototype, "loop", 2);
147
+ i([
148
+ n({ attribute: "waveform-src", reflect: !0, type: String })
149
+ ], e.prototype, "waveformSrc", 2);
150
+ i([
151
+ s()
152
+ ], e.prototype, "isPlaying", 2);
153
+ i([
154
+ s()
155
+ ], e.prototype, "isLoaded", 2);
156
+ i([
157
+ s()
158
+ ], e.prototype, "isError", 2);
159
+ i([
160
+ s()
161
+ ], e.prototype, "currentTimeSeconds", 2);
162
+ i([
163
+ s()
164
+ ], e.prototype, "durationSeconds", 2);
165
+ i([
166
+ s()
167
+ ], e.prototype, "waveformPath", 2);
168
+ i([
169
+ s()
170
+ ], e.prototype, "waveformViewBoxWidth", 2);
171
+ i([
172
+ s()
173
+ ], e.prototype, "playedFraction", 2);
174
+ i([
175
+ s()
176
+ ], e.prototype, "audioSrc", 2);
177
+ i([
178
+ m("waveformSrc", { waitUntilFirstUpdate: !0 }),
179
+ m("src")
180
+ ], e.prototype, "handleSrcChange", 1);
181
+ e = i([
182
+ _("cx-audio")
183
+ ], e);
235
184
  export {
236
- a as default
185
+ e as default
237
186
  };