@smileid/web-components 1.5.1 → 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.
Files changed (80) hide show
  1. package/package.json +58 -48
  2. package/{components → src/components}/combobox/src/Combobox.js +4 -1
  3. package/{components → src/components}/document/src/DocumentCaptureScreens.js +409 -409
  4. package/{components → src/components}/document/src/document-capture/DocumentCapture.js +760 -760
  5. package/{components → src/components}/end-user-consent/src/EndUserConsent.js +4 -1
  6. package/{components → src/components}/navigation/src/Navigation.js +4 -1
  7. package/{components → src/components}/selfie/src/SelfieCaptureScreens.js +282 -290
  8. package/{components → src/components}/selfie/src/selfie-capture/SelfieCapture.js +1010 -1011
  9. package/{components → src/components}/selfie/src/selfie-capture/SelfieCapture.stories.js +36 -36
  10. package/{components → src/components}/signature-pad/package.json +30 -30
  11. package/{components → src/components}/signature-pad/src/SignaturePad.js +4 -1
  12. package/{components → src/components}/smart-camera-web/src/SmartCameraWeb.js +1 -1
  13. package/{components → src/components}/totp-consent/src/TotpConsent.js +1 -1
  14. package/.eslintrc.cjs +0 -72
  15. package/cypress/e2e/smart-camera-web-agent-mode.cy.js +0 -144
  16. package/cypress/e2e/smart-camera-web-attribution.cy.js +0 -249
  17. package/cypress/e2e/smart-camera-web-back-press.cy.js +0 -481
  18. package/cypress/e2e/smart-camera-web-complete-flow.cy.js +0 -221
  19. package/cypress/e2e/smart-camera-web-hide-back-to-host.cy.js +0 -61
  20. package/cypress/e2e/smart-camera-web-hide-instructions.cy.js +0 -334
  21. package/cypress/e2e/smart-camera-web.cy.js +0 -309
  22. package/cypress/fixtures/example.json +0 -5
  23. package/cypress/pages/capture-back-of-id-hide-attribution.html +0 -44
  24. package/cypress/pages/capture-back-of-id-navigation.html +0 -72
  25. package/cypress/pages/smart-camera-web-agent-mode.html +0 -36
  26. package/cypress/pages/smart-camera-web-complete-flow.html +0 -42
  27. package/cypress/pages/smart-camera-web-hide-instructions.html +0 -38
  28. package/cypress/pages/smart-camera-web.html +0 -38
  29. package/cypress/support/commands.js +0 -144
  30. package/cypress/support/e2e.js +0 -20
  31. package/cypress.config.js +0 -11
  32. package/esbuild.js +0 -119
  33. /package/{components → src/components}/README.md +0 -0
  34. /package/{components → src/components}/attribution/PoweredBySmileId.js +0 -0
  35. /package/{components → src/components}/camera-permission/CameraPermission.js +0 -0
  36. /package/{components → src/components}/camera-permission/CameraPermission.stories.js +0 -0
  37. /package/{components → src/components}/combobox/src/index.js +0 -0
  38. /package/{components → src/components}/document/src/DocumentCaptureScreens.stories.js +0 -0
  39. /package/{components → src/components}/document/src/README.md +0 -0
  40. /package/{components → src/components}/document/src/document-capture/DocumentCapture.stories.js +0 -0
  41. /package/{components → src/components}/document/src/document-capture/README.md +0 -0
  42. /package/{components → src/components}/document/src/document-capture/index.js +0 -0
  43. /package/{components → src/components}/document/src/document-capture-instructions/DocumentCaptureInstructions.js +0 -0
  44. /package/{components → src/components}/document/src/document-capture-instructions/DocumentCaptureInstructions.stories.js +0 -0
  45. /package/{components → src/components}/document/src/document-capture-instructions/README.md +0 -0
  46. /package/{components → src/components}/document/src/document-capture-instructions/index.js +0 -0
  47. /package/{components → src/components}/document/src/document-capture-review/DocumentCaptureReview.js +0 -0
  48. /package/{components → src/components}/document/src/document-capture-review/DocumentCaptureReview.stories.js +0 -0
  49. /package/{components → src/components}/document/src/document-capture-review/README.md +0 -0
  50. /package/{components → src/components}/document/src/document-capture-review/index.js +0 -0
  51. /package/{components → src/components}/document/src/index.js +0 -0
  52. /package/{components → src/components}/end-user-consent/src/EndUserConsent.stories.js +0 -0
  53. /package/{components → src/components}/end-user-consent/src/index.js +0 -0
  54. /package/{components → src/components}/navigation/src/Navigation.stories.js +0 -0
  55. /package/{components → src/components}/navigation/src/index.js +0 -0
  56. /package/{components → src/components}/selfie/README.md +0 -0
  57. /package/{components → src/components}/selfie/src/SelfieCaptureScreens.stories.js +0 -0
  58. /package/{components → src/components}/selfie/src/index.js +0 -0
  59. /package/{components → src/components}/selfie/src/selfie-capture/index.js +0 -0
  60. /package/{components → src/components}/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.js +0 -0
  61. /package/{components → src/components}/selfie/src/selfie-capture-instructions/SelfieCaptureInstructions.stories.js +0 -0
  62. /package/{components → src/components}/selfie/src/selfie-capture-instructions/index.js +0 -0
  63. /package/{components → src/components}/selfie/src/selfie-capture-review/SelfieCaptureReview.js +0 -0
  64. /package/{components → src/components}/selfie/src/selfie-capture-review/SelfieCaptureReview.stories.js +0 -0
  65. /package/{components → src/components}/selfie/src/selfie-capture-review/index.js +0 -0
  66. /package/{components → src/components}/signature-pad/package-lock.json +0 -0
  67. /package/{components → src/components}/signature-pad/src/SignaturePad.stories.js +0 -0
  68. /package/{components → src/components}/signature-pad/src/index.js +0 -0
  69. /package/{components → src/components}/smart-camera-web/src/README.md +0 -0
  70. /package/{components → src/components}/smart-camera-web/src/SmartCameraWeb.stories.js +0 -0
  71. /package/{components → src/components}/totp-consent/src/index.js +0 -0
  72. /package/{domain → src/domain}/camera/src/README.md +0 -0
  73. /package/{domain → src/domain}/camera/src/SmartCamera.js +0 -0
  74. /package/{domain → src/domain}/constants/src/Constants.js +0 -0
  75. /package/{domain → src/domain}/file-upload/README.md +0 -0
  76. /package/{domain → src/domain}/file-upload/src/SmartFileUpload.js +0 -0
  77. /package/{index.js → src/index.js} +0 -0
  78. /package/{styles → src/styles}/README.md +0 -0
  79. /package/{styles → src/styles}/src/styles.js +0 -0
  80. /package/{styles → src/styles}/src/typography.js +0 -0
@@ -782,7 +782,10 @@ class EndUserConsent extends HTMLElement {
782
782
  }
783
783
  }
784
784
 
785
- if ('customElements' in window) {
785
+ if (
786
+ 'customElements' in window &&
787
+ !window.customElements.get('end-user-consent')
788
+ ) {
786
789
  window.customElements.define('end-user-consent', EndUserConsent);
787
790
  }
788
791
 
@@ -161,7 +161,10 @@ button[data-type="icon"] {
161
161
  }
162
162
  }
163
163
 
164
- if ('customElements' in window) {
164
+ if (
165
+ 'customElements' in window &&
166
+ !window.customElements.get('smileid-navigation')
167
+ ) {
165
168
  window.customElements.define('smileid-navigation', Navigation);
166
169
  }
167
170
 
@@ -1,290 +1,282 @@
1
- import './selfie-capture';
2
- import './selfie-capture-instructions';
3
- import './selfie-capture-review';
4
- import SmartCamera from '../../../domain/camera/src/SmartCamera';
5
- import styles from '../../../styles/src/styles';
6
- import packageJson from '../../../package.json';
7
-
8
- const COMPONENTS_VERSION = packageJson.version;
9
-
10
- const smartCameraWeb = document.querySelector('smart-camera-web');
11
-
12
- async function getPermissions(captureScreen, facingMode = 'user') {
13
- try {
14
- const stream = await SmartCamera.getMedia({
15
- audio: false,
16
- video: { facingMode },
17
- });
18
- const devices = await navigator.mediaDevices.enumerateDevices();
19
- const videoDevice = devices.find(
20
- (device) =>
21
- device.kind === 'videoinput' &&
22
- stream.getVideoTracks()[0].getSettings().deviceId === device.deviceId,
23
- );
24
- smartCameraWeb?.dispatchEvent(
25
- new CustomEvent('metadata.camera-name', {
26
- detail: { cameraName: videoDevice?.label },
27
- }),
28
- );
29
- captureScreen.removeAttribute('data-camera-error');
30
- captureScreen.setAttribute('data-camera-ready', true);
31
- } catch (error) {
32
- captureScreen.removeAttribute('data-camera-ready');
33
- captureScreen.setAttribute(
34
- 'data-camera-error',
35
- SmartCamera.handleCameraError(error),
36
- );
37
- }
38
- }
39
-
40
- class SelfieCaptureScreens extends HTMLElement {
41
- constructor() {
42
- super();
43
- this.activeScreen = null;
44
- smartCameraWeb?.dispatchEvent(new CustomEvent('metadata.initialize'));
45
- }
46
-
47
- connectedCallback() {
48
- this.innerHTML = `
49
- ${styles(this.themeColor)}
50
- <div>
51
- <selfie-capture-instructions theme-color='${this.themeColor}' ${this.showNavigation} ${this.hideAttribution} ${this.hideBack} hidden></selfie-capture-instructions>
52
- <selfie-capture theme-color='${this.themeColor}' ${this.showNavigation} ${this.allowAgentMode} ${this.allowAgentModeTests} ${this.hideAttribution} ${this.disableImageTests} hidden></selfie-capture>
53
- <selfie-capture-review theme-color='${this.themeColor}' ${this.showNavigation} ${this.hideAttribution} hidden></selfie-capture-review>
54
- </div>
55
- `;
56
-
57
- this._data = {
58
- images: [],
59
- meta: {
60
- libraryVersion: COMPONENTS_VERSION,
61
- },
62
- };
63
-
64
- this.selfieInstruction = this.querySelector('selfie-capture-instructions');
65
- this.selfieCapture = this.querySelector('selfie-capture');
66
- this.selfieReview = this.querySelector('selfie-capture-review');
67
-
68
- if (this.hideInstructions && !this.hasAttribute('hidden')) {
69
- getPermissions(this.selfieCapture, this.getAgentMode());
70
- }
71
-
72
- // If the initial screen is selfie-capture, we need to get permissions
73
- if (this.getAttribute('initial-screen') === 'selfie-capture') {
74
- getPermissions(this.selfieCapture, this.getAgentMode()).then(() =>
75
- this.setActiveScreen(this.selfieCapture),
76
- );
77
- } else if (this.hideInstructions) {
78
- this.setActiveScreen(this.selfieCapture);
79
- } else {
80
- this.setActiveScreen(this.selfieInstruction);
81
- }
82
-
83
- this.setUpEventListeners();
84
- }
85
-
86
- getAgentMode() {
87
- return this.inAgentMode ? 'environment' : 'user';
88
- }
89
-
90
- disconnectedCallback() {
91
- SmartCamera.stopMedia();
92
- if (this.activeScreen) {
93
- this.activeScreen.removeAttribute('hidden');
94
- }
95
- this.activeScreen = null;
96
- this.innerHTML = '';
97
- }
98
-
99
- setUpEventListeners() {
100
- this.selfieInstruction.addEventListener(
101
- 'selfie-capture-instructions.capture',
102
- async () => {
103
- await getPermissions(this.selfieCapture, this.getAgentMode()).then(() =>
104
- this.setActiveScreen(this.selfieCapture),
105
- );
106
- smartCameraWeb?.dispatchEvent(
107
- new CustomEvent('metadata.selfie-capture-start'),
108
- );
109
- smartCameraWeb?.dispatchEvent(
110
- new CustomEvent('metadata.selfie-origin', {
111
- detail: {
112
- imageOrigin: {
113
- environment: 'back_camera',
114
- user: 'front_camera',
115
- }[this.getAgentMode()],
116
- },
117
- }),
118
- );
119
- },
120
- );
121
- this.selfieInstruction.addEventListener(
122
- 'selfie-capture-instructions.cancelled',
123
- () => {
124
- this.handleBackEvents();
125
- },
126
- );
127
-
128
- this.selfieCapture.addEventListener('selfie-capture.cancelled', () => {
129
- if (this.hideInstructions) {
130
- this.dispatchEvent(new CustomEvent('selfie-capture-screens.cancelled'));
131
- } else {
132
- this.setActiveScreen(this.selfieInstruction);
133
- }
134
- });
135
-
136
- this.selfieCapture.addEventListener('selfie-capture.publish', (event) => {
137
- smartCameraWeb?.dispatchEvent(
138
- new CustomEvent('metadata.selfie-capture-end'),
139
- );
140
- this.selfieReview.setAttribute('data-image', event.detail.referenceImage);
141
- this._data.images = event.detail.images;
142
- SmartCamera.stopMedia();
143
- this.setActiveScreen(this.selfieReview);
144
- });
145
-
146
- this.selfieCapture.addEventListener('selfie-capture.cancelled', () => {
147
- this.selfieCapture.reset();
148
- SmartCamera.stopMedia();
149
- if (this.hideInstructions) {
150
- this.handleBackEvents();
151
- return;
152
- }
153
-
154
- this.setActiveScreen(this.selfieInstruction);
155
- });
156
-
157
- this.selfieReview.addEventListener(
158
- 'selfie-capture-review.rejected',
159
- async () => {
160
- smartCameraWeb?.dispatchEvent(
161
- new CustomEvent('metadata.selfie-capture-retry'),
162
- );
163
- this.selfieReview.removeAttribute('data-image');
164
- this._data.images = [];
165
- if (this.hideInstructions) {
166
- this.setActiveScreen(this.selfieCapture);
167
- await getPermissions(this.selfieCapture, this.getAgentMode());
168
- } else {
169
- this.setActiveScreen(this.selfieInstruction);
170
- }
171
- },
172
- );
173
-
174
- this.selfieReview.addEventListener(
175
- 'selfie-capture-review.accepted',
176
- async () => {
177
- this._publishSelectedImages();
178
- },
179
- );
180
-
181
- [this.selfieInstruction, this.selfieCapture, this.selfieReview].forEach(
182
- (screen) => {
183
- screen.addEventListener(
184
- `${screen.nodeName.toLowerCase()}.close`,
185
- () => {
186
- this.handleCloseEvent();
187
- },
188
- );
189
- },
190
- );
191
- }
192
-
193
- _publishSelectedImages() {
194
- this.dispatchEvent(
195
- new CustomEvent('selfie-capture-screens.publish', { detail: this._data }),
196
- );
197
- }
198
-
199
- get hideInstructions() {
200
- return this.hasAttribute('hide-instructions');
201
- }
202
-
203
- get hideAttribution() {
204
- return this.hasAttribute('hide-attribution') ? 'hide-attribution' : '';
205
- }
206
-
207
- get hideBackOfId() {
208
- return this.hasAttribute('hide-back-of-id');
209
- }
210
-
211
- get showNavigation() {
212
- return this.hasAttribute('show-navigation') ? 'show-navigation' : '';
213
- }
214
-
215
- get inAgentMode() {
216
- return this.getAttribute('allow-agent-mode') === 'true';
217
- }
218
-
219
- get allowAgentMode() {
220
- return this.inAgentMode ? "allow-agent-mode='true'" : '';
221
- }
222
-
223
- get allowAgentModeTests() {
224
- return this.hasAttribute('show-agent-mode-for-tests')
225
- ? 'show-agent-mode-for-tests'
226
- : '';
227
- }
228
-
229
- get hideBack() {
230
- return this.hasAttribute('hide-back-to-host') ||
231
- this.hasAttribute('hide-back')
232
- ? 'hide-back'
233
- : '';
234
- }
235
-
236
- get disableImageTests() {
237
- return this.hasAttribute('disable-image-tests')
238
- ? 'disable-image-tests'
239
- : '';
240
- }
241
-
242
- get themeColor() {
243
- return this.getAttribute('theme-color') || '#001096';
244
- }
245
-
246
- setActiveScreen(screen) {
247
- this.activeScreen?.setAttribute('hidden', '');
248
- screen.removeAttribute('hidden');
249
- this.activeScreen = screen;
250
- }
251
-
252
- handleBackEvents() {
253
- this.dispatchEvent(new CustomEvent('selfie-capture-screens.cancelled'));
254
- }
255
-
256
- handleCloseEvent() {
257
- this.dispatchEvent(new CustomEvent('selfie-capture-screens.close'));
258
- }
259
-
260
- static get observedAttributes() {
261
- return [
262
- 'title',
263
- 'hidden',
264
- 'show-navigation',
265
- 'hide-back-to-host',
266
- 'initial-screen',
267
- ];
268
- }
269
-
270
- attributeChangedCallback(name) {
271
- switch (name) {
272
- case 'title':
273
- case 'hidden':
274
- case 'initial-screen':
275
- this.connectedCallback();
276
- break;
277
- default:
278
- break;
279
- }
280
- }
281
- }
282
-
283
- if (
284
- 'customElements' in window &&
285
- !customElements.get('selfie-capture-screens')
286
- ) {
287
- customElements.define('selfie-capture-screens', SelfieCaptureScreens);
288
- }
289
-
290
- export default SelfieCaptureScreens;
1
+ import './selfie-capture';
2
+ import './selfie-capture-instructions';
3
+ import './selfie-capture-review';
4
+ import SmartCamera from '../../../domain/camera/src/SmartCamera';
5
+ import styles from '../../../styles/src/styles';
6
+ import packageJson from '../../../../package.json';
7
+
8
+ const COMPONENTS_VERSION = packageJson.version;
9
+
10
+ const smartCameraWeb = document.querySelector('smart-camera-web');
11
+
12
+ async function getPermissions(captureScreen, facingMode = 'user') {
13
+ try {
14
+ const stream = await SmartCamera.getMedia({
15
+ audio: false,
16
+ video: { facingMode },
17
+ });
18
+ const devices = await navigator.mediaDevices.enumerateDevices();
19
+ const videoDevice = devices.find(
20
+ (device) =>
21
+ device.kind === 'videoinput' &&
22
+ stream.getVideoTracks()[0].getSettings().deviceId === device.deviceId,
23
+ );
24
+ smartCameraWeb?.dispatchEvent(
25
+ new CustomEvent('metadata.camera-name', {
26
+ detail: { cameraName: videoDevice?.label },
27
+ }),
28
+ );
29
+ captureScreen.removeAttribute('data-camera-error');
30
+ captureScreen.setAttribute('data-camera-ready', true);
31
+ } catch (error) {
32
+ captureScreen.removeAttribute('data-camera-ready');
33
+ captureScreen.setAttribute(
34
+ 'data-camera-error',
35
+ SmartCamera.handleCameraError(error),
36
+ );
37
+ }
38
+ }
39
+
40
+ class SelfieCaptureScreens extends HTMLElement {
41
+ constructor() {
42
+ super();
43
+ this.activeScreen = null;
44
+ smartCameraWeb?.dispatchEvent(new CustomEvent('metadata.initialize'));
45
+ }
46
+
47
+ connectedCallback() {
48
+ this.innerHTML = `
49
+ ${styles(this.themeColor)}
50
+ <div>
51
+ <selfie-capture-instructions theme-color='${this.themeColor}' ${this.showNavigation} ${this.hideAttribution} ${this.hideBack} hidden></selfie-capture-instructions>
52
+ <selfie-capture theme-color='${this.themeColor}' ${this.showNavigation} ${this.allowAgentMode} ${this.allowAgentModeTests} ${this.hideAttribution} ${this.disableImageTests} hidden></selfie-capture>
53
+ <selfie-capture-review theme-color='${this.themeColor}' ${this.showNavigation} ${this.hideAttribution} hidden></selfie-capture-review>
54
+ </div>
55
+ `;
56
+
57
+ this._data = {
58
+ images: [],
59
+ meta: {
60
+ libraryVersion: COMPONENTS_VERSION,
61
+ },
62
+ };
63
+
64
+ this.selfieInstruction = this.querySelector('selfie-capture-instructions');
65
+ this.selfieCapture = this.querySelector('selfie-capture');
66
+ this.selfieReview = this.querySelector('selfie-capture-review');
67
+
68
+ if (this.hideInstructions && !this.hasAttribute('hidden')) {
69
+ getPermissions(this.selfieCapture, this.getAgentMode());
70
+ }
71
+
72
+ // If the initial screen is selfie-capture, we need to get permissions
73
+ if (this.getAttribute('initial-screen') === 'selfie-capture') {
74
+ getPermissions(this.selfieCapture, this.getAgentMode()).then(() =>
75
+ this.setActiveScreen(this.selfieCapture),
76
+ );
77
+ } else if (this.hideInstructions) {
78
+ this.setActiveScreen(this.selfieCapture);
79
+ } else {
80
+ this.setActiveScreen(this.selfieInstruction);
81
+ }
82
+
83
+ this.setUpEventListeners();
84
+ }
85
+
86
+ getAgentMode() {
87
+ return this.inAgentMode ? 'environment' : 'user';
88
+ }
89
+
90
+ disconnectedCallback() {
91
+ SmartCamera.stopMedia();
92
+ if (this.activeScreen) {
93
+ this.activeScreen.removeAttribute('hidden');
94
+ }
95
+ this.activeScreen = null;
96
+ this.innerHTML = '';
97
+ }
98
+
99
+ setUpEventListeners() {
100
+ this.selfieInstruction.addEventListener(
101
+ 'selfie-capture-instructions.capture',
102
+ async () => {
103
+ await getPermissions(this.selfieCapture, this.getAgentMode()).then(() =>
104
+ this.setActiveScreen(this.selfieCapture),
105
+ );
106
+ smartCameraWeb?.dispatchEvent(
107
+ new CustomEvent('metadata.selfie-capture-start'),
108
+ );
109
+ smartCameraWeb?.dispatchEvent(
110
+ new CustomEvent('metadata.selfie-origin', {
111
+ detail: {
112
+ imageOrigin: {
113
+ environment: 'back_camera',
114
+ user: 'front_camera',
115
+ }[this.getAgentMode()],
116
+ },
117
+ }),
118
+ );
119
+ },
120
+ );
121
+ this.selfieInstruction.addEventListener(
122
+ 'selfie-capture-instructions.cancelled',
123
+ () => {
124
+ this.handleBackEvents();
125
+ },
126
+ );
127
+
128
+ this.selfieCapture.addEventListener('selfie-capture.cancelled', () => {
129
+ this.selfieCapture.reset();
130
+ SmartCamera.stopMedia();
131
+ if (this.hideInstructions) {
132
+ this.handleBackEvents();
133
+ return;
134
+ }
135
+
136
+ this.setActiveScreen(this.selfieInstruction);
137
+ });
138
+
139
+ this.selfieCapture.addEventListener('selfie-capture.publish', (event) => {
140
+ smartCameraWeb?.dispatchEvent(
141
+ new CustomEvent('metadata.selfie-capture-end'),
142
+ );
143
+ this.selfieReview.setAttribute('data-image', event.detail.referenceImage);
144
+ this._data.images = event.detail.images;
145
+ SmartCamera.stopMedia();
146
+ this.setActiveScreen(this.selfieReview);
147
+ });
148
+
149
+ this.selfieReview.addEventListener(
150
+ 'selfie-capture-review.rejected',
151
+ async () => {
152
+ smartCameraWeb?.dispatchEvent(
153
+ new CustomEvent('metadata.selfie-capture-retry'),
154
+ );
155
+ this.selfieReview.removeAttribute('data-image');
156
+ this._data.images = [];
157
+ if (this.hideInstructions) {
158
+ this.setActiveScreen(this.selfieCapture);
159
+ await getPermissions(this.selfieCapture, this.getAgentMode());
160
+ } else {
161
+ this.setActiveScreen(this.selfieInstruction);
162
+ }
163
+ },
164
+ );
165
+
166
+ this.selfieReview.addEventListener(
167
+ 'selfie-capture-review.accepted',
168
+ async () => {
169
+ this._publishSelectedImages();
170
+ },
171
+ );
172
+
173
+ [this.selfieInstruction, this.selfieCapture, this.selfieReview].forEach(
174
+ (screen) => {
175
+ screen.addEventListener(
176
+ `${screen.nodeName.toLowerCase()}.close`,
177
+ () => {
178
+ this.handleCloseEvent();
179
+ },
180
+ );
181
+ },
182
+ );
183
+ }
184
+
185
+ _publishSelectedImages() {
186
+ this.dispatchEvent(
187
+ new CustomEvent('selfie-capture-screens.publish', { detail: this._data }),
188
+ );
189
+ }
190
+
191
+ get hideInstructions() {
192
+ return this.hasAttribute('hide-instructions');
193
+ }
194
+
195
+ get hideAttribution() {
196
+ return this.hasAttribute('hide-attribution') ? 'hide-attribution' : '';
197
+ }
198
+
199
+ get hideBackOfId() {
200
+ return this.hasAttribute('hide-back-of-id');
201
+ }
202
+
203
+ get showNavigation() {
204
+ return this.hasAttribute('show-navigation') ? 'show-navigation' : '';
205
+ }
206
+
207
+ get inAgentMode() {
208
+ return this.getAttribute('allow-agent-mode') === 'true';
209
+ }
210
+
211
+ get allowAgentMode() {
212
+ return this.inAgentMode ? "allow-agent-mode='true'" : '';
213
+ }
214
+
215
+ get allowAgentModeTests() {
216
+ return this.hasAttribute('show-agent-mode-for-tests')
217
+ ? 'show-agent-mode-for-tests'
218
+ : '';
219
+ }
220
+
221
+ get hideBack() {
222
+ return this.hasAttribute('hide-back-to-host') ||
223
+ this.hasAttribute('hide-back')
224
+ ? 'hide-back'
225
+ : '';
226
+ }
227
+
228
+ get disableImageTests() {
229
+ return this.hasAttribute('disable-image-tests')
230
+ ? 'disable-image-tests'
231
+ : '';
232
+ }
233
+
234
+ get themeColor() {
235
+ return this.getAttribute('theme-color') || '#001096';
236
+ }
237
+
238
+ setActiveScreen(screen) {
239
+ this.activeScreen?.setAttribute('hidden', '');
240
+ screen.removeAttribute('hidden');
241
+ this.activeScreen = screen;
242
+ }
243
+
244
+ handleBackEvents() {
245
+ this.dispatchEvent(new CustomEvent('selfie-capture-screens.cancelled'));
246
+ }
247
+
248
+ handleCloseEvent() {
249
+ this.dispatchEvent(new CustomEvent('selfie-capture-screens.close'));
250
+ }
251
+
252
+ static get observedAttributes() {
253
+ return [
254
+ 'title',
255
+ 'hidden',
256
+ 'show-navigation',
257
+ 'hide-back-to-host',
258
+ 'initial-screen',
259
+ ];
260
+ }
261
+
262
+ attributeChangedCallback(name) {
263
+ switch (name) {
264
+ case 'title':
265
+ case 'hidden':
266
+ case 'initial-screen':
267
+ this.connectedCallback();
268
+ break;
269
+ default:
270
+ break;
271
+ }
272
+ }
273
+ }
274
+
275
+ if (
276
+ 'customElements' in window &&
277
+ !customElements.get('selfie-capture-screens')
278
+ ) {
279
+ customElements.define('selfie-capture-screens', SelfieCaptureScreens);
280
+ }
281
+
282
+ export default SelfieCaptureScreens;