@vouchfor/embeds 0.0.0-experiment.f80a91a → 0.0.0-experiment.f90d920

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 (67) hide show
  1. package/dist/es/embeds.js +1142 -9
  2. package/dist/es/embeds.js.map +1 -1
  3. package/dist/es/src/components/DialogEmbed/DialogOverlay.d.ts +2 -1
  4. package/dist/es/src/components/DialogEmbed/DialogPortal.d.ts +2 -1
  5. package/dist/es/src/components/DialogEmbed/index.d.ts +4 -1
  6. package/dist/es/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +1 -1
  7. package/dist/es/src/components/PlayerEmbed/index.d.ts +75 -0
  8. package/dist/es/src/components/PlayerEmbed/tests/data.d.ts +3 -2
  9. package/dist/es/src/components/PlayerEmbed/tests/media-data.d.ts +19 -0
  10. package/dist/iife/dialog-embed/embed.iife.js +2732 -411
  11. package/dist/iife/dialog-embed/embed.iife.js.map +1 -1
  12. package/dist/iife/embeds.iife.js +2732 -411
  13. package/dist/iife/embeds.iife.js.map +1 -1
  14. package/dist/iife/player-embed/embed.iife.js +2706 -387
  15. package/dist/iife/player-embed/embed.iife.js.map +1 -1
  16. package/package.json +36 -31
  17. package/src/components/DialogEmbed/Dialog.stories.ts +12 -0
  18. package/src/components/DialogEmbed/DialogOverlay.ts +2 -1
  19. package/src/components/DialogEmbed/DialogPortal.ts +22 -10
  20. package/src/components/DialogEmbed/index.ts +5 -1
  21. package/src/components/PlayerEmbed/MultiEmbed.stories.ts +135 -0
  22. package/src/components/PlayerEmbed/PlayerEmbed.stories.ts +15 -1
  23. package/src/components/PlayerEmbed/controllers/tracking/index.ts +7 -7
  24. package/src/components/PlayerEmbed/controllers/tracking/utils.ts +1 -1
  25. package/src/components/PlayerEmbed/index.ts +120 -7
  26. package/src/components/PlayerEmbed/tests/PlayerEmbed.spec.ts +14 -7
  27. package/src/components/PlayerEmbed/tests/data.ts +121 -77
  28. package/src/components/PlayerEmbed/tests/media-data.ts +22 -0
  29. package/dist/es/browser-07a8b7dc.js +0 -433
  30. package/dist/es/browser-07a8b7dc.js.map +0 -1
  31. package/dist/es/index-0c298932.js +0 -10473
  32. package/dist/es/index-0c298932.js.map +0 -1
  33. package/dist/iife/dialog-embed/browser-450a324f.js +0 -433
  34. package/dist/iife/dialog-embed/browser-450a324f.js.map +0 -1
  35. package/dist/iife/dialog-embed/embed.js +0 -5
  36. package/dist/iife/dialog-embed/embed.js.map +0 -1
  37. package/dist/iife/dialog-embed/index-62750303.js +0 -32932
  38. package/dist/iife/dialog-embed/index-62750303.js.map +0 -1
  39. package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogOverlay.d.ts +0 -19
  40. package/dist/iife/dialog-embed/src/components/DialogEmbed/DialogPortal.d.ts +0 -35
  41. package/dist/iife/dialog-embed/src/components/DialogEmbed/index.d.ts +0 -35
  42. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +0 -15
  43. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +0 -14
  44. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +0 -36
  45. package/dist/iife/dialog-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +0 -17
  46. package/dist/iife/dialog-embed/src/components/PlayerEmbed/tests/data.d.ts +0 -3
  47. package/dist/iife/dialog-embed/src/index.d.ts +0 -2
  48. package/dist/iife/dialog-embed/src/utils/env.d.ts +0 -12
  49. package/dist/iife/dialog-embed/src/utils/events.d.ts +0 -2
  50. package/dist/iife/player-embed/browser-c51cdddb.js +0 -433
  51. package/dist/iife/player-embed/browser-c51cdddb.js.map +0 -1
  52. package/dist/iife/player-embed/embed.js +0 -5
  53. package/dist/iife/player-embed/embed.js.map +0 -1
  54. package/dist/iife/player-embed/index-0d71c577.js +0 -32489
  55. package/dist/iife/player-embed/index-0d71c577.js.map +0 -1
  56. package/dist/iife/player-embed/src/components/DialogEmbed/DialogOverlay.d.ts +0 -19
  57. package/dist/iife/player-embed/src/components/DialogEmbed/DialogPortal.d.ts +0 -35
  58. package/dist/iife/player-embed/src/components/DialogEmbed/index.d.ts +0 -35
  59. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/event-forwarder.d.ts +0 -15
  60. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/fetcher.d.ts +0 -14
  61. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/index.d.ts +0 -36
  62. package/dist/iife/player-embed/src/components/PlayerEmbed/controllers/tracking/utils.d.ts +0 -17
  63. package/dist/iife/player-embed/src/components/PlayerEmbed/tests/data.d.ts +0 -3
  64. package/dist/iife/player-embed/src/index.d.ts +0 -2
  65. package/dist/iife/player-embed/src/utils/env.d.ts +0 -12
  66. package/dist/iife/player-embed/src/utils/events.d.ts +0 -2
  67. package/src/mixins/media-player-proxy.ts +0 -116
@@ -1,19 +0,0 @@
1
- import { LitElement } from 'lit';
2
- import type { DialogEmbedProps } from '.';
3
- declare class DialogOverlay extends LitElement {
4
- static styles: import("lit").CSSResult[];
5
- open: boolean;
6
- aspectRatio: DialogEmbedProps['aspectRatio'];
7
- render(): import("lit").TemplateResult<1>;
8
- }
9
- declare global {
10
- interface HTMLElementTagNameMap {
11
- 'vouch-embed-dialog-overlay': DialogOverlay;
12
- }
13
- namespace JSX {
14
- interface IntrinsicElements {
15
- 'vouch-embed-dialog-overlay': DialogOverlay;
16
- }
17
- }
18
- }
19
- export { DialogOverlay };
@@ -1,35 +0,0 @@
1
- import { LitElement } from 'lit';
2
- import type { DialogEmbedProps } from '.';
3
- declare class DialogPortal extends LitElement {
4
- vouchId: DialogEmbedProps['vouchId'];
5
- templateId: DialogEmbedProps['templateId'];
6
- questions: DialogEmbedProps['questions'];
7
- env: DialogEmbedProps['env'];
8
- apiKey: DialogEmbedProps['apiKey'];
9
- disableTracking: DialogEmbedProps['disableTracking'];
10
- trackingSource: DialogEmbedProps['trackingSource'];
11
- controls: DialogEmbedProps['controls'];
12
- preload: DialogEmbedProps['preload'];
13
- disableAutoplay: DialogEmbedProps['disableAutoplay'];
14
- aspectRatio: DialogEmbedProps['aspectRatio'];
15
- private _mediaPlayerRef;
16
- open: boolean;
17
- private _handleToggle;
18
- private _handleClose;
19
- private _handleDocumentKeyUp;
20
- connectedCallback(): void;
21
- disconnectedCallback(): void;
22
- protected createRenderRoot(): HTMLElement | DocumentFragment;
23
- render(): import("lit").TemplateResult<1>;
24
- }
25
- declare global {
26
- interface HTMLElementTagNameMap {
27
- 'vouch-embed-dialog-portal': DialogPortal;
28
- }
29
- namespace JSX {
30
- interface IntrinsicElements {
31
- 'vouch-embed-dialog-portal': DialogPortal;
32
- }
33
- }
34
- }
35
- export { DialogPortal };
@@ -1,35 +0,0 @@
1
- import { LitElement } from 'lit';
2
- import type { PlayerEmbedProps } from '../PlayerEmbed';
3
- type DialogEmbedProps = Omit<PlayerEmbedProps, 'data'> & {
4
- disableAutoplay?: boolean;
5
- };
6
- declare class DialogEmbed extends LitElement {
7
- static styles: import("lit").CSSResult[];
8
- vouchId: DialogEmbedProps['vouchId'];
9
- templateId: DialogEmbedProps['templateId'];
10
- questions: DialogEmbedProps['questions'];
11
- env: DialogEmbedProps['env'];
12
- apiKey: DialogEmbedProps['apiKey'];
13
- disableTracking: DialogEmbedProps['disableTracking'];
14
- trackingSource: DialogEmbedProps['trackingSource'];
15
- controls: DialogEmbedProps['controls'];
16
- preload: DialogEmbedProps['preload'];
17
- disableAutoplay: DialogEmbedProps['disableAutoplay'];
18
- aspectRatio: DialogEmbedProps['aspectRatio'];
19
- private _handleRootClick;
20
- connectedCallback(): void;
21
- disconnectedCallback(): void;
22
- render(): import("lit").TemplateResult<1>;
23
- }
24
- declare global {
25
- interface HTMLElementTagNameMap {
26
- 'vouch-embed-dialog': DialogEmbed;
27
- }
28
- namespace JSX {
29
- interface IntrinsicElements {
30
- 'vouch-embed-dialog': DialogEmbed;
31
- }
32
- }
33
- }
34
- export { DialogEmbed };
35
- export type { DialogEmbedProps };
@@ -1,15 +0,0 @@
1
- import type { PlayerEmbed } from '..';
2
- import type { ReactiveController, ReactiveControllerHost } from 'lit';
3
- import type { DirectiveResult } from 'lit/directive.js';
4
- type PlayerEmbedHost = ReactiveControllerHost & PlayerEmbed;
5
- declare class EventForwardController implements ReactiveController {
6
- host: PlayerEmbedHost;
7
- private _events;
8
- private _cleanup;
9
- private _forwardElementRef;
10
- constructor(host: PlayerEmbedHost, events: string[]);
11
- register(): DirectiveResult;
12
- hostConnected(): void;
13
- hostDisconnected(): void;
14
- }
15
- export { EventForwardController };
@@ -1,14 +0,0 @@
1
- import type { PlayerEmbed } from '..';
2
- import type { ReactiveControllerHost } from 'lit';
3
- type PlayerEmbedHost = ReactiveControllerHost & PlayerEmbed;
4
- declare class FetcherController {
5
- host: PlayerEmbedHost;
6
- private _fetching;
7
- private _vouch;
8
- set fetching(value: boolean);
9
- get fetching(): boolean;
10
- private getVouch;
11
- private getTemplate;
12
- constructor(host: PlayerEmbedHost);
13
- }
14
- export { FetcherController };
@@ -1,36 +0,0 @@
1
- import type { PlayerEmbed } from '../..';
2
- import type { ReactiveController, ReactiveControllerHost } from 'lit';
3
- type PlayerEmbedHost = ReactiveControllerHost & PlayerEmbed;
4
- type TrackingEvent = 'VOUCH_LOADED' | 'VOUCH_RESPONSE_VIEWED' | 'VIDEO_PLAYED' | 'VIDEO_STREAMED';
5
- type TrackingPayload = {
6
- vouchId?: string;
7
- answerId?: string;
8
- streamStart?: number;
9
- streamEnd?: number;
10
- };
11
- declare class TrackingController implements ReactiveController {
12
- host: PlayerEmbedHost;
13
- private _batchedEvents;
14
- private _hasPlayed;
15
- private _hasLoaded;
16
- private _answersViewed;
17
- private _streamStartTime;
18
- private _streamLatestTime;
19
- private _currentlyPlayingVideo;
20
- constructor(host: PlayerEmbedHost);
21
- private _createTrackingEvent;
22
- private _sendTrackingEvent;
23
- private _streamEnded;
24
- private _handleVouchLoaded;
25
- private _handlePlay;
26
- private _handleVideoPlay;
27
- private _handleVideoTimeUpdate;
28
- private _handleVideoPause;
29
- private _pageUnloading;
30
- private _handleVisibilityChange;
31
- private _handlePageHide;
32
- hostConnected(): void;
33
- hostDisconnected(): void;
34
- }
35
- export { TrackingController };
36
- export type { TrackingEvent, TrackingPayload };
@@ -1,17 +0,0 @@
1
- import type { TrackingPayload } from '.';
2
- import type { Vouch } from '@vouchfor/media-player';
3
- import type { Environment } from '../../../../utils/env';
4
- declare function getUids(env: Environment): {
5
- client: null;
6
- tab: null;
7
- request: string;
8
- visitor?: undefined;
9
- } | {
10
- client: string;
11
- tab: string;
12
- request: string;
13
- visitor: string;
14
- };
15
- declare function findVouchId(payload?: TrackingPayload, vouch?: Vouch): string | null | undefined;
16
- declare function getReportingMetadata(source?: string): any;
17
- export { getUids, findVouchId, getReportingMetadata };
@@ -1,3 +0,0 @@
1
- import type { Vouch } from '@vouchfor/media-player';
2
- declare const data: Vouch;
3
- export { data };
@@ -1,2 +0,0 @@
1
- export { PlayerEmbed } from './components/PlayerEmbed';
2
- export { DialogEmbed } from './components/DialogEmbed';
@@ -1,12 +0,0 @@
1
- type Environment = 'local' | 'dev' | 'staging' | 'prod';
2
- type GetEnvUrlsReturn = {
3
- videoUrl: string;
4
- publicApiUrl: string;
5
- embedApiUrl: string;
6
- };
7
- declare const devEmbedApiUrl = "https://embed-dev.vouchfor.com/v2";
8
- declare const stagingEmbedApiUrl = "https://embed-staging.vouchfor.com/v2";
9
- declare const prodEmbedApiUrl = "https://embed.vouchfor.com/v2";
10
- declare function getEnvUrls(env: Environment): GetEnvUrlsReturn;
11
- export { devEmbedApiUrl, stagingEmbedApiUrl, prodEmbedApiUrl, getEnvUrls };
12
- export type { Environment };
@@ -1,2 +0,0 @@
1
- declare function forwardEvent(type: string, fromElement: HTMLElement, toElement: HTMLElement): () => void;
2
- export { forwardEvent };
@@ -1,433 +0,0 @@
1
- var I = Object.defineProperty;
2
- var q = (o, e, t) => e in o ? I(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var U = (o, e, t) => (q(o, typeof e != "symbol" ? e + "" : e, t), t);
4
- import { c as G, g as H } from "./index-0d71c577.js";
5
- function J(o, e) {
6
- for (var t = 0; t < e.length; t++) {
7
- const r = e[t];
8
- if (typeof r != "string" && !Array.isArray(r)) {
9
- for (const n in r)
10
- if (n !== "default" && !(n in o)) {
11
- const i = Object.getOwnPropertyDescriptor(r, n);
12
- i && Object.defineProperty(o, n, i.get ? i : {
13
- enumerable: !0,
14
- get: () => r[n]
15
- });
16
- }
17
- }
18
- }
19
- return Object.freeze(Object.defineProperty(o, Symbol.toStringTag, { value: "Module" }));
20
- }
21
- function h(o) {
22
- if (typeof o != "string")
23
- throw new TypeError("Path must be a string. Received " + JSON.stringify(o));
24
- }
25
- function L(o, e) {
26
- for (var t = "", r = 0, n = -1, i = 0, a, s = 0; s <= o.length; ++s) {
27
- if (s < o.length)
28
- a = o.charCodeAt(s);
29
- else {
30
- if (a === 47)
31
- break;
32
- a = 47;
33
- }
34
- if (a === 47) {
35
- if (!(n === s - 1 || i === 1))
36
- if (n !== s - 1 && i === 2) {
37
- if (t.length < 2 || r !== 2 || t.charCodeAt(t.length - 1) !== 46 || t.charCodeAt(t.length - 2) !== 46) {
38
- if (t.length > 2) {
39
- var l = t.lastIndexOf("/");
40
- if (l !== t.length - 1) {
41
- l === -1 ? (t = "", r = 0) : (t = t.slice(0, l), r = t.length - 1 - t.lastIndexOf("/")), n = s, i = 0;
42
- continue;
43
- }
44
- } else if (t.length === 2 || t.length === 1) {
45
- t = "", r = 0, n = s, i = 0;
46
- continue;
47
- }
48
- }
49
- e && (t.length > 0 ? t += "/.." : t = "..", r = 2);
50
- } else
51
- t.length > 0 ? t += "/" + o.slice(n + 1, s) : t = o.slice(n + 1, s), r = s - n - 1;
52
- n = s, i = 0;
53
- } else
54
- a === 46 && i !== -1 ? ++i : i = -1;
55
- }
56
- return t;
57
- }
58
- function V(o, e) {
59
- var t = e.dir || e.root, r = e.base || (e.name || "") + (e.ext || "");
60
- return t ? t === e.root ? t + r : t + o + r : r;
61
- }
62
- var p = {
63
- // path.resolve([from ...], to)
64
- resolve: function() {
65
- for (var e = "", t = !1, r, n = arguments.length - 1; n >= -1 && !t; n--) {
66
- var i;
67
- n >= 0 ? i = arguments[n] : (r === void 0 && (r = process.cwd()), i = r), h(i), i.length !== 0 && (e = i + "/" + e, t = i.charCodeAt(0) === 47);
68
- }
69
- return e = L(e, !t), t ? e.length > 0 ? "/" + e : "/" : e.length > 0 ? e : ".";
70
- },
71
- normalize: function(e) {
72
- if (h(e), e.length === 0)
73
- return ".";
74
- var t = e.charCodeAt(0) === 47, r = e.charCodeAt(e.length - 1) === 47;
75
- return e = L(e, !t), e.length === 0 && !t && (e = "."), e.length > 0 && r && (e += "/"), t ? "/" + e : e;
76
- },
77
- isAbsolute: function(e) {
78
- return h(e), e.length > 0 && e.charCodeAt(0) === 47;
79
- },
80
- join: function() {
81
- if (arguments.length === 0)
82
- return ".";
83
- for (var e, t = 0; t < arguments.length; ++t) {
84
- var r = arguments[t];
85
- h(r), r.length > 0 && (e === void 0 ? e = r : e += "/" + r);
86
- }
87
- return e === void 0 ? "." : p.normalize(e);
88
- },
89
- relative: function(e, t) {
90
- if (h(e), h(t), e === t || (e = p.resolve(e), t = p.resolve(t), e === t))
91
- return "";
92
- for (var r = 1; r < e.length && e.charCodeAt(r) === 47; ++r)
93
- ;
94
- for (var n = e.length, i = n - r, a = 1; a < t.length && t.charCodeAt(a) === 47; ++a)
95
- ;
96
- for (var s = t.length, l = s - a, u = i < l ? i : l, c = -1, f = 0; f <= u; ++f) {
97
- if (f === u) {
98
- if (l > u) {
99
- if (t.charCodeAt(a + f) === 47)
100
- return t.slice(a + f + 1);
101
- if (f === 0)
102
- return t.slice(a + f);
103
- } else
104
- i > u && (e.charCodeAt(r + f) === 47 ? c = f : f === 0 && (c = 0));
105
- break;
106
- }
107
- var g = e.charCodeAt(r + f), v = t.charCodeAt(a + f);
108
- if (g !== v)
109
- break;
110
- g === 47 && (c = f);
111
- }
112
- var d = "";
113
- for (f = r + c + 1; f <= n; ++f)
114
- (f === n || e.charCodeAt(f) === 47) && (d.length === 0 ? d += ".." : d += "/..");
115
- return d.length > 0 ? d + t.slice(a + c) : (a += c, t.charCodeAt(a) === 47 && ++a, t.slice(a));
116
- },
117
- _makeLong: function(e) {
118
- return e;
119
- },
120
- dirname: function(e) {
121
- if (h(e), e.length === 0)
122
- return ".";
123
- for (var t = e.charCodeAt(0), r = t === 47, n = -1, i = !0, a = e.length - 1; a >= 1; --a)
124
- if (t = e.charCodeAt(a), t === 47) {
125
- if (!i) {
126
- n = a;
127
- break;
128
- }
129
- } else
130
- i = !1;
131
- return n === -1 ? r ? "/" : "." : r && n === 1 ? "//" : e.slice(0, n);
132
- },
133
- basename: function(e, t) {
134
- if (t !== void 0 && typeof t != "string")
135
- throw new TypeError('"ext" argument must be a string');
136
- h(e);
137
- var r = 0, n = -1, i = !0, a;
138
- if (t !== void 0 && t.length > 0 && t.length <= e.length) {
139
- if (t.length === e.length && t === e)
140
- return "";
141
- var s = t.length - 1, l = -1;
142
- for (a = e.length - 1; a >= 0; --a) {
143
- var u = e.charCodeAt(a);
144
- if (u === 47) {
145
- if (!i) {
146
- r = a + 1;
147
- break;
148
- }
149
- } else
150
- l === -1 && (i = !1, l = a + 1), s >= 0 && (u === t.charCodeAt(s) ? --s === -1 && (n = a) : (s = -1, n = l));
151
- }
152
- return r === n ? n = l : n === -1 && (n = e.length), e.slice(r, n);
153
- } else {
154
- for (a = e.length - 1; a >= 0; --a)
155
- if (e.charCodeAt(a) === 47) {
156
- if (!i) {
157
- r = a + 1;
158
- break;
159
- }
160
- } else
161
- n === -1 && (i = !1, n = a + 1);
162
- return n === -1 ? "" : e.slice(r, n);
163
- }
164
- },
165
- extname: function(e) {
166
- h(e);
167
- for (var t = -1, r = 0, n = -1, i = !0, a = 0, s = e.length - 1; s >= 0; --s) {
168
- var l = e.charCodeAt(s);
169
- if (l === 47) {
170
- if (!i) {
171
- r = s + 1;
172
- break;
173
- }
174
- continue;
175
- }
176
- n === -1 && (i = !1, n = s + 1), l === 46 ? t === -1 ? t = s : a !== 1 && (a = 1) : t !== -1 && (a = -1);
177
- }
178
- return t === -1 || n === -1 || // We saw a non-dot character immediately before the dot
179
- a === 0 || // The (right-most) trimmed path component is exactly '..'
180
- a === 1 && t === n - 1 && t === r + 1 ? "" : e.slice(t, n);
181
- },
182
- format: function(e) {
183
- if (e === null || typeof e != "object")
184
- throw new TypeError('The "pathObject" argument must be of type Object. Received type ' + typeof e);
185
- return V("/", e);
186
- },
187
- parse: function(e) {
188
- h(e);
189
- var t = { root: "", dir: "", base: "", ext: "", name: "" };
190
- if (e.length === 0)
191
- return t;
192
- var r = e.charCodeAt(0), n = r === 47, i;
193
- n ? (t.root = "/", i = 1) : i = 0;
194
- for (var a = -1, s = 0, l = -1, u = !0, c = e.length - 1, f = 0; c >= i; --c) {
195
- if (r = e.charCodeAt(c), r === 47) {
196
- if (!u) {
197
- s = c + 1;
198
- break;
199
- }
200
- continue;
201
- }
202
- l === -1 && (u = !1, l = c + 1), r === 46 ? a === -1 ? a = c : f !== 1 && (f = 1) : a !== -1 && (f = -1);
203
- }
204
- return a === -1 || l === -1 || // We saw a non-dot character immediately before the dot
205
- f === 0 || // The (right-most) trimmed path component is exactly '..'
206
- f === 1 && a === l - 1 && a === s + 1 ? l !== -1 && (s === 0 && n ? t.base = t.name = e.slice(1, l) : t.base = t.name = e.slice(s, l)) : (s === 0 && n ? (t.name = e.slice(1, a), t.base = e.slice(1, l)) : (t.name = e.slice(s, a), t.base = e.slice(s, l)), t.ext = e.slice(a, l)), s > 0 ? t.dir = e.slice(0, s - 1) : n && (t.dir = "/"), t;
207
- },
208
- sep: "/",
209
- delimiter: ":",
210
- win32: null,
211
- posix: null
212
- };
213
- p.posix = p;
214
- var W = p;
215
- const { basename: B, extname: Y } = W;
216
- class Z {
217
- constructor() {
218
- let e = (() => typeof G > "u")(), t = "image/png", r = "image/jpeg", n = "image/jpeg", i = "image/webp", a = "application/pdf", s = "image/svg+xml";
219
- Object.assign(this, {
220
- toMime: this.toMime.bind(this),
221
- fromMime: this.fromMime.bind(this),
222
- expected: e ? '"png", "jpg", or "webp"' : '"png", "jpg", "pdf", or "svg"',
223
- formats: e ? { png: t, jpg: r, jpeg: n, webp: i } : { png: t, jpg: r, jpeg: n, pdf: a, svg: s },
224
- mimes: e ? { [t]: "png", [r]: "jpg", [i]: "webp" } : { [t]: "png", [r]: "jpg", [a]: "pdf", [s]: "svg" }
225
- });
226
- }
227
- toMime(e) {
228
- return this.formats[(e || "").replace(/^\./, "").toLowerCase()];
229
- }
230
- fromMime(e) {
231
- return this.mimes[e];
232
- }
233
- }
234
- function K(o, { filename: e = "", extension: t = "", format: m, page: n, quality: i, matte: a, density: s, outline: l, archive: v } = {}) {
235
- var { fromMime: c, toMime: f, expected: g } = new Z(), v = v || "canvas", d = m || t.replace(/@\d+x$/i, "") || Y(e), m = c(f(d) || d), y = f(m), b = o.length;
236
- if (!d)
237
- throw new Error("Cannot determine image format (use a filename extension or 'format' argument)");
238
- if (!m)
239
- throw new Error(`Unsupported file format "${d}" (expected ${g})`);
240
- if (!b)
241
- throw new RangeError("Canvas has no associated contexts (try calling getContext or newPage first)");
242
- let C, E, z = e.replace(/{(\d*)}/g, (D, A) => (E = !0, A = parseInt(A, 10), C = isFinite(A) ? A : isFinite(C) ? C : -1, "{}")), w = n > 0 ? n - 1 : n < 0 ? b + n : void 0;
243
- if (isFinite(w) && w < 0 || w >= b)
244
- throw new RangeError(
245
- b == 1 ? `Canvas only has a ‘page 1’ (${w} is out of bounds)` : `Canvas has pages 1–${b} (${w} is out of bounds)`
246
- );
247
- if (o = isFinite(w) ? [o[w]] : E || m == "pdf" ? o : o.slice(-1), i === void 0)
248
- i = 0.92;
249
- else if (typeof i != "number" || !isFinite(i) || i < 0 || i > 1)
250
- throw new TypeError("The quality option must be an number in the 0.0–1.0 range");
251
- if (s === void 0) {
252
- let D = (t || B(e, d)).match(/@(\d+)x$/i);
253
- s = D ? parseInt(D[1], 10) : 1;
254
- } else if (typeof s != "number" || !Number.isInteger(s) || s < 1)
255
- throw new TypeError("The density option must be a non-negative integer");
256
- return l === void 0 ? l = !0 : m == "svg" && (l = !!l), { filename: e, pattern: z, format: m, mime: y, pages: o, padding: C, quality: i, matte: a, density: s, outline: l, archive: v };
257
- }
258
- class j {
259
- static for(e) {
260
- return new j().append(e).get();
261
- }
262
- constructor() {
263
- this.crc = -1;
264
- }
265
- get() {
266
- return ~this.crc;
267
- }
268
- append(e) {
269
- for (var t = this.crc | 0, r = this.table, n = 0, i = e.length | 0; n < i; n++)
270
- t = t >>> 8 ^ r[(t ^ e[n]) & 255];
271
- return this.crc = t, this;
272
- }
273
- }
274
- j.prototype.table = (() => {
275
- var o, e, t, r = [];
276
- for (o = 0; o < 256; o++) {
277
- for (t = o, e = 0; e < 8; e++)
278
- t = t & 1 ? t >>> 1 ^ 3988292384 : t >>> 1;
279
- r[o] = t;
280
- }
281
- return r;
282
- })();
283
- function S(o) {
284
- let e = new Uint8Array(o), t = new DataView(e.buffer), r = {
285
- array: e,
286
- view: t,
287
- size: o,
288
- set8(n, i) {
289
- return t.setUint8(n, i), r;
290
- },
291
- set16(n, i) {
292
- return t.setUint16(n, i, !0), r;
293
- },
294
- set32(n, i) {
295
- return t.setUint32(n, i, !0), r;
296
- },
297
- bytes(n, i) {
298
- return e.set(i, n), r;
299
- }
300
- };
301
- return r;
302
- }
303
- const x = class x {
304
- constructor(e) {
305
- let t = /* @__PURE__ */ new Date();
306
- Object.assign(this, {
307
- directory: e,
308
- offset: 0,
309
- files: [],
310
- time: (t.getHours() << 6 | t.getMinutes()) << 5 | t.getSeconds() / 2,
311
- date: (t.getFullYear() - 1980 << 4 | t.getMonth() + 1) << 5 | t.getDate()
312
- }), this.add(e);
313
- }
314
- async add(e, t) {
315
- let r = !t, n = x.encoder.encode(`${this.directory}/${r ? "" : e}`), i = new Uint8Array(r ? 0 : await t.arrayBuffer()), a = 30 + n.length, s = a + i.length, l = 16, { offset: u } = this, c = S(26).set32(0, 134742036).set16(6, this.time).set16(8, this.date).set32(10, j.for(i)).set32(14, i.length).set32(18, i.length).set16(22, n.length);
316
- u += a;
317
- let f = S(a + i.length + l).set32(0, 67324752).bytes(4, c.array).bytes(30, n).bytes(a, i);
318
- u += i.length, f.set32(s, 134695760).bytes(s + 4, c.array.slice(10, 22)), u += l, this.files.push({ offset: u, folder: r, name: n, header: c, payload: f }), this.offset = u;
319
- }
320
- toBuffer() {
321
- let e = this.files.reduce((f, { name: g }) => 46 + g.length + f, 0), t = S(e + 22), r = 0;
322
- for (var { offset: n, name: i, header: a, folder: s } of this.files)
323
- t.set32(r, 33639248).set16(r + 4, 20).bytes(r + 6, a.array).set8(r + 38, s ? 16 : 0).set32(r + 42, n).bytes(r + 46, i), r += 46 + i.length;
324
- t.set32(r, 101010256).set16(r + 8, this.files.length).set16(r + 10, this.files.length).set32(r + 12, e).set32(r + 16, this.offset);
325
- let l = new Uint8Array(this.offset + t.size), u = 0;
326
- for (var { payload: c } of this.files)
327
- l.set(c.array, u), u += c.size;
328
- return l.set(t.array, u), l;
329
- }
330
- get blob() {
331
- return new Blob([this.toBuffer()], { type: "application/zip" });
332
- }
333
- };
334
- U(x, "encoder", new TextEncoder());
335
- let k = x;
336
- const $ = (o, e, t, r) => {
337
- if (r) {
338
- let { width: n, height: i } = o, a = Object.assign(document.createElement("canvas"), { width: n, height: i }), s = a.getContext("2d");
339
- s.fillStyle = r, s.fillRect(0, 0, n, i), s.drawImage(o, 0, 0), o = a;
340
- }
341
- return new Promise((n, i) => o.toBlob(n, e, t));
342
- }, N = (...o) => $(...o).then((e) => e.arrayBuffer()), Q = async (o, e, t, r, n) => {
343
- T(n, await $(o, e, t, r));
344
- }, X = async (o, e, t, r, n, i, a) => {
345
- let s = (c) => i.replace("{}", String(c + 1).padStart(a, "0")), l = B(n, ".zip") || "archive", u = new k(l);
346
- await Promise.all(o.map(async (c, f) => {
347
- let g = s(f);
348
- await u.add(g, await $(c, e, t, r));
349
- })), T(`${l}.zip`, u.blob);
350
- }, T = (o, e) => {
351
- const t = window.URL.createObjectURL(e), r = document.createElement("a");
352
- r.style.display = "none", r.href = t, r.setAttribute("download", o), typeof r.download > "u" && r.setAttribute("target", "_blank"), document.body.appendChild(r), r.click(), document.body.removeChild(r), setTimeout(() => window.URL.revokeObjectURL(t), 100);
353
- }, ee = (o, e, t) => o.map((r) => {
354
- if (e == 1 && !t)
355
- return r.canvas;
356
- let n = document.createElement("canvas"), i = n.getContext("2d"), a = r.canvas ? r.canvas : r;
357
- return n.width = a.width * e, n.height = a.height * e, t && (i.fillStyle = t, i.fillRect(0, 0, n.width, n.height)), i.scale(e, e), i.drawImage(a, 0, 0), n;
358
- });
359
- var te = { asBuffer: N, asDownload: Q, asZipDownload: X, atScale: ee, options: K };
360
- const { asBuffer: P, asDownload: re, asZipDownload: ne, atScale: O, options: R } = te, M = Symbol.for("toDataURL"), ie = (o) => {
361
- let e = Object.assign(new F(), { crossOrigin: "Anonymous", src: o });
362
- return e.decode().then(() => e);
363
- };
364
- class ae {
365
- constructor(e, t) {
366
- let r = document.createElement("canvas"), n = [];
367
- Object.defineProperty(r, "async", { value: !0, writable: !1, enumerable: !0 });
368
- for (var [i, a] of Object.entries({
369
- png: () => P(r, "image/png"),
370
- jpg: () => P(r, "image/jpeg"),
371
- pages: () => n.concat(r).map((s) => s.getContext("2d"))
372
- }))
373
- Object.defineProperty(r, i, { get: a });
374
- return Object.assign(r, {
375
- width: e,
376
- height: t,
377
- newPage(...s) {
378
- var { width: u, height: c } = r, l = Object.assign(document.createElement("canvas"), { width: u, height: c });
379
- l.getContext("2d").drawImage(r, 0, 0), n.push(l);
380
- var [u, c] = s.length ? s : [u, c];
381
- return Object.assign(r, { width: u, height: c }).getContext("2d");
382
- },
383
- saveAs(s, l) {
384
- l = typeof l == "number" ? { quality: l } : l;
385
- let u = R(this.pages, { filename: s, ...l }), { pattern: c, padding: f, mime: g, quality: v, matte: d, density: m, archive: y } = u, b = O(u.pages, m);
386
- return f == null ? re(b[0], g, v, d, s) : ne(b, g, v, d, y, c, f);
387
- },
388
- toBuffer(s = "png", l = {}) {
389
- l = typeof l == "number" ? { quality: l } : l;
390
- let u = R(this.pages, { extension: s, ...l }), { mime: c, quality: f, matte: g, pages: v, density: d } = u, m = O(v, d, g)[0];
391
- return P(m, c, f, g);
392
- },
393
- [M]: r.toDataURL.bind(r),
394
- toDataURL(s = "png", l = {}) {
395
- l = typeof l == "number" ? { quality: l } : l;
396
- let u = R(this.pages, { extension: s, ...l }), { mime: c, quality: f, matte: g, pages: v, density: d } = u, m = O(v, d, g)[0], y = m[m === r ? M : "toDataURL"](c, f);
397
- return Promise.resolve(y);
398
- }
399
- });
400
- }
401
- }
402
- const {
403
- CanvasRenderingContext2D: se,
404
- CanvasGradient: oe,
405
- CanvasPattern: le,
406
- Image: F,
407
- ImageData: fe,
408
- Path2D: ce,
409
- DOMMatrix: ue,
410
- DOMRect: de,
411
- DOMPoint: ge
412
- } = window;
413
- var _ = {
414
- Canvas: ae,
415
- loadImage: ie,
416
- CanvasRenderingContext2D: se,
417
- CanvasGradient: oe,
418
- CanvasPattern: le,
419
- Image: F,
420
- ImageData: fe,
421
- Path2D: ce,
422
- DOMMatrix: ue,
423
- DOMRect: de,
424
- DOMPoint: ge
425
- };
426
- const me = /* @__PURE__ */ H(_), be = /* @__PURE__ */ J({
427
- __proto__: null,
428
- default: me
429
- }, [_]);
430
- export {
431
- be as b
432
- };
433
- //# sourceMappingURL=browser-c51cdddb.js.map