veryfi-lens-wasm 3.3.2 → 3.3.4

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
@@ -17,7 +17,7 @@ Veryfi Lens for Web is a browser SDK that gives your web app document capture su
17
17
  | `credit_card` | Credit card scanning (name, number, date, CVV) |
18
18
  | `caps` | Bottle cap capture with circular guide overlay |
19
19
  | `code_strips` | Code strip capture with rectangular guide overlay |
20
- | `prescription_label` | Prescription label video capture with pill bottle overlay, zips video and submits to anydocs |
20
+ | `prescription_label` | Prescription label capture, submits to anydocs. Switch overlays during capture: bottle overlay records video, box overlay captures a still image |
21
21
  | `upload` | File upload with crop and submit (no camera) |
22
22
 
23
23
  ## Installation
@@ -207,6 +207,8 @@ VeryfiLens.onFailure((error) => { /* error occurred */ });
207
207
  | `anydocShowFlipMessage` | `boolean` | `false` | Show flip document message between pages |
208
208
  | `anydocFlipMessageText` | `string` | `"Please flip the document..."` | Flip message text |
209
209
  | `anydocFlipContinueText` | `string` | `"Continue"` | Continue button text |
210
+ | `anydocShowGuide` | `boolean` | `false` | Show a dismissible on-screen text guide explaining how to capture. Auto-hides after each page capture and reappears when the camera restarts for the next page |
211
+ | `anydocGuideText` | `string` | `"Position the document within the frame..."` | Guide text shown for anydocs capture. Use `\n` for line breaks |
210
212
 
211
213
  ### Bottle Cap Settings (`caps` flavor)
212
214
 
@@ -236,7 +238,16 @@ VeryfiLens.onFailure((error) => { /* error occurred */ });
236
238
  | `prescriptionLabelSquareHeightRatio` | `number` | `0.5` | Square overlay height (0-1 relative to viewport) |
237
239
  | `prescriptionLabelShowGuide` | `boolean` | `false` | Show a semi-transparent guide explaining how to record the label. Auto-hides when recording starts and reappears on retake |
238
240
  | `prescriptionLabelGuideText` | `string` | `"Position the bottle within the outline.\n\nPress the capture button to start recording, slowly rotate the bottle to capture the entire label and press the capture button again to stop recording."` | Guide text shown when the bottle outline overlay is active. Use `\n` for line breaks |
239
- | `prescriptionLabelSquareGuideText` | `string` | `"Position the prescription label within the square.\n\nPress the capture button to start recording, press again to stop."` | Guide text shown when the square overlay is active. Use `\n` for line breaks |
241
+ | `prescriptionLabelSquareGuideText` | `string` | `"Position the prescription label within the square.\n\nPress the capture button to take a photo of the label."` | Guide text shown when the box overlay is active. Use `\n` for line breaks |
242
+ | `prescriptionLabelShowOverlayToggle` | `boolean` | `true` | Show a toggle that lets the user switch between the bottle and box overlays during capture. The **bottle** overlay records a video; the **box** overlay captures a still image |
243
+ | `prescriptionLabelBottleLabel` | `string` | `"Bottle"` | Label for the bottle (video) segment of the overlay toggle |
244
+ | `prescriptionLabelBoxLabel` | `string` | `"Box"` | Label for the box (image) segment of the overlay toggle |
245
+ | `prescriptionLabelBoxMultiSide` | `boolean` | `true` | When capturing with the box overlay, prompt after each capture to add another side of the same box. All captured sides are submitted as a single document (requires `packageMode: true` to group into one document) |
246
+ | `prescriptionLabelBoxMaxSides` | `number` | `4` | Maximum number of sides that can be captured for a single box. Once reached, the capture is submitted automatically instead of prompting for another side |
247
+ | `prescriptionLabelBoxSideMessage` | `string` | `"Capture another side of the box?"` | Message shown in the "another side" prompt for box captures |
248
+ | `prescriptionLabelBoxSideAddText` | `string` | `"Capture another side"` | Text for the button that captures another side of the box |
249
+ | `prescriptionLabelBoxSideSubmitText` | `string` | `"Submit"` | Text for the button that submits the captured box sides as one document |
250
+ | `prescriptionLabelMaxVideoDuration` | `number` | `12` | Maximum length, in seconds, of a bottle (video) capture. When reached, recording stops automatically. An on-screen countdown is shown while recording. Set to `0` to disable the limit |
240
251
 
241
252
  ### Upload Settings (`upload` flavor)
242
253
 
@@ -1,4 +1,5 @@
1
1
  import { createGallery } from './gallery.js';
2
+ import { LIQUID_GLASS } from './liquid-glass.js';
2
3
 
3
4
  export const createAnydocPageControls = (container, onAddPage, onSubmit, removeOverlay, options = {}) => {
4
5
  const wrapper = document.createElement('div');
@@ -88,14 +89,16 @@ export const createAnydocPageControls = (container, onAddPage, onSubmit, removeO
88
89
  addButton.style.padding = `var(--anydoc-add-button-padding, ${defaultStyles.addButtonPadding})`;
89
90
  addButton.style.backgroundColor = `var(--anydoc-add-button-background-color, ${defaultStyles.addButtonBackgroundColor})`;
90
91
  addButton.style.color = `var(--anydoc-add-button-color, ${defaultStyles.addButtonColor})`;
91
- addButton.style.border = 'none';
92
+ addButton.style.border = `var(--anydoc-add-button-border, ${LIQUID_GLASS.border})`;
92
93
  addButton.style.borderRadius = `var(--anydoc-add-button-border-radius, ${defaultStyles.addButtonBorderRadius})`;
93
94
  addButton.style.cursor = 'pointer';
94
95
  addButton.style.fontSize = `var(--anydoc-add-button-font-size, ${defaultStyles.addButtonFontSize})`;
95
96
  addButton.style.fontFamily = `var(--anydoc-add-button-font-family, ${defaultStyles.addButtonFontFamily})`;
96
97
  addButton.style.fontWeight = `var(--anydoc-add-button-font-weight, 600)`;
97
98
  addButton.style.transition = 'all 0.2s ease';
98
- addButton.style.boxShadow = `var(--anydoc-add-button-box-shadow, 0 2px 8px rgba(0,0,0,0.15))`;
99
+ addButton.style.backdropFilter = LIQUID_GLASS.blur;
100
+ addButton.style.webkitBackdropFilter = LIQUID_GLASS.blur;
101
+ addButton.style.boxShadow = `var(--anydoc-add-button-box-shadow, ${LIQUID_GLASS.boxShadow})`;
99
102
  addButton.style.letterSpacing = '0.3px';
100
103
  addButton.style.whiteSpace = 'nowrap';
101
104
 
@@ -105,14 +108,16 @@ export const createAnydocPageControls = (container, onAddPage, onSubmit, removeO
105
108
  submitButton.style.padding = `var(--anydoc-submit-button-padding, ${defaultStyles.submitButtonPadding})`;
106
109
  submitButton.style.backgroundColor = `var(--anydoc-submit-button-background-color, ${defaultStyles.submitButtonBackgroundColor})`;
107
110
  submitButton.style.color = `var(--anydoc-submit-button-color, ${defaultStyles.submitButtonColor})`;
108
- submitButton.style.border = 'none';
111
+ submitButton.style.border = `var(--anydoc-submit-button-border, ${LIQUID_GLASS.border})`;
109
112
  submitButton.style.borderRadius = `var(--anydoc-submit-button-border-radius, ${defaultStyles.submitButtonBorderRadius})`;
110
113
  submitButton.style.cursor = 'pointer';
111
114
  submitButton.style.fontSize = `var(--anydoc-submit-button-font-size, ${defaultStyles.submitButtonFontSize})`;
112
115
  submitButton.style.fontFamily = `var(--anydoc-submit-button-font-family, ${defaultStyles.submitButtonFontFamily})`;
113
116
  submitButton.style.fontWeight = `var(--anydoc-submit-button-font-weight, 600)`;
114
117
  submitButton.style.transition = 'all 0.2s ease';
115
- submitButton.style.boxShadow = `var(--anydoc-submit-button-box-shadow, 0 2px 8px rgba(0,0,0,0.15))`;
118
+ submitButton.style.backdropFilter = LIQUID_GLASS.blur;
119
+ submitButton.style.webkitBackdropFilter = LIQUID_GLASS.blur;
120
+ submitButton.style.boxShadow = `var(--anydoc-submit-button-box-shadow, ${LIQUID_GLASS.boxShadow})`;
116
121
  submitButton.style.letterSpacing = '0.3px';
117
122
  submitButton.style.whiteSpace = 'nowrap';
118
123
 
@@ -143,23 +148,26 @@ export const createAnydocPageControls = (container, onAddPage, onSubmit, removeO
143
148
  exitButton.style.minWidth = '40px';
144
149
  exitButton.style.minHeight = '40px';
145
150
  exitButton.style.padding = '0';
146
- exitButton.style.backgroundColor = 'rgba(107, 114, 128, 0.5)';
151
+ exitButton.style.backgroundColor = LIQUID_GLASS.backgroundColor;
147
152
  exitButton.style.color = 'white';
148
153
  exitButton.style.fontWeight = 'bold';
149
154
  exitButton.style.fontFamily = 'sans-serif';
150
- exitButton.style.border = 'none';
155
+ exitButton.style.border = LIQUID_GLASS.border;
151
156
  exitButton.style.borderRadius = '50%';
152
157
  exitButton.style.cursor = 'pointer';
153
158
  exitButton.style.display = 'flex';
154
159
  exitButton.style.alignItems = 'center';
155
160
  exitButton.style.justifyContent = 'center';
156
- exitButton.style.transition = 'background-color 0.3s ease';
161
+ exitButton.style.transition = 'background-color 0.3s ease, box-shadow 0.3s ease';
157
162
  exitButton.style.boxSizing = 'border-box';
163
+ exitButton.style.backdropFilter = LIQUID_GLASS.blur;
164
+ exitButton.style.webkitBackdropFilter = LIQUID_GLASS.blur;
165
+ exitButton.style.boxShadow = LIQUID_GLASS.boxShadow;
158
166
  exitButton.addEventListener('mouseenter', () => {
159
- exitButton.style.backgroundColor = 'rgba(55, 65, 81, 0.8)';
167
+ exitButton.style.backgroundColor = LIQUID_GLASS.hoverBackgroundColor;
160
168
  });
161
169
  exitButton.addEventListener('mouseleave', () => {
162
- exitButton.style.backgroundColor = 'rgba(107, 114, 128, 0.5)';
170
+ exitButton.style.backgroundColor = LIQUID_GLASS.backgroundColor;
163
171
  });
164
172
  exitButton.addEventListener('click', (e) => {
165
173
  e.preventDefault();
@@ -1,3 +1,5 @@
1
+ import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
2
+
1
3
  export const createCaptureButton = (container, onCapture, onStopStitching) => {
2
4
  const button = document.createElement('button');
3
5
  button.id = 'veryfi-capture-button';
@@ -10,17 +12,14 @@ export const createCaptureButton = (container, onCapture, onStopStitching) => {
10
12
  width: '4rem',
11
13
  height: '4rem',
12
14
  borderRadius: '50%',
13
- border: '3px solid rgba(255, 255, 255, 0.4)',
14
- backgroundColor: 'rgba(255, 255, 255, 0.15)',
15
15
  cursor: 'pointer',
16
16
  zIndex: '1000',
17
- transition: 'background-color 0.3s ease',
17
+ transition: 'background-color 0.3s ease, box-shadow 0.3s ease',
18
18
  padding: '0',
19
19
  outline: 'none',
20
20
  pointerEvents: 'auto',
21
- backdropFilter: 'blur(2px)',
22
- WebkitBackdropFilter: 'blur(2px)',
23
21
  boxSizing: 'border-box',
22
+ ...liquidGlassStyles({ border: '3px solid rgba(255, 255, 255, 0.55)' }),
24
23
  };
25
24
 
26
25
  Object.entries(defaultStyles).forEach(([key, value]) => {
@@ -47,11 +46,11 @@ export const createCaptureButton = (container, onCapture, onStopStitching) => {
47
46
 
48
47
  // Add hover effect
49
48
  button.addEventListener('mouseenter', () => {
50
- button.style.backgroundColor = 'var(--capture-button-hover-background-color, rgba(255, 255, 255, 0.25))';
49
+ button.style.backgroundColor = `var(--capture-button-hover-background-color, ${LIQUID_GLASS.hoverBackgroundColor})`;
51
50
  });
52
51
 
53
52
  button.addEventListener('mouseleave', () => {
54
- button.style.backgroundColor = 'var(--capture-button-background-color, rgba(255, 255, 255, 0.15))';
53
+ button.style.backgroundColor = `var(--capture-button-background-color, ${LIQUID_GLASS.backgroundColor})`;
55
54
  });
56
55
 
57
56
  let isStitching = false;
@@ -1,3 +1,5 @@
1
+ import { LIQUID_GLASS } from './liquid-glass.js';
2
+
1
3
  const WIDE_VIEWPORT_THRESHOLD = 900;
2
4
  const MODAL_ID = 'veryfi-desktop-mode-modal';
3
5
  const STYLE_ID = 'veryfi-desktop-mode-modal-styles';
@@ -61,11 +63,13 @@ const ensureStyles = () => {
61
63
  position: relative;
62
64
  width: 100%;
63
65
  max-width: 420px;
64
- background: #1e293b;
66
+ background: ${LIQUID_GLASS.darkPanelBackground};
67
+ backdrop-filter: ${LIQUID_GLASS.blur};
68
+ -webkit-backdrop-filter: ${LIQUID_GLASS.blur};
65
69
  color: #ffffff;
66
- border-radius: 16px;
67
- border: 1px solid #334155;
68
- box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
70
+ border-radius: 20px;
71
+ border: ${LIQUID_GLASS.darkBorder};
72
+ box-shadow: ${LIQUID_GLASS.darkPanelBoxShadow};
69
73
  padding: 24px;
70
74
  box-sizing: border-box;
71
75
  }
@@ -118,12 +122,13 @@ const ensureStyles = () => {
118
122
  #${MODAL_ID} .veryfi-dm-reload {
119
123
  width: 100%;
120
124
  padding: 12px 16px;
121
- border-radius: 8px;
125
+ border-radius: 12px;
122
126
  background: #10b981;
123
127
  color: #0f172a;
124
128
  font-weight: 600;
125
129
  font-size: 14px;
126
- border: none;
130
+ border: 1px solid rgba(255, 255, 255, 0.3);
131
+ box-shadow: 0 6px 20px rgba(16, 185, 129, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.5);
127
132
  cursor: pointer;
128
133
  transition: background-color 0.15s;
129
134
  }
@@ -1,3 +1,5 @@
1
+ import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
2
+
1
3
  export const createExitButton = (container, options, removeOverlay) => {
2
4
  const { setter, redirectUrl, lensFlavor } = options;
3
5
 
@@ -9,14 +11,13 @@ export const createExitButton = (container, options, removeOverlay) => {
9
11
  position: 'absolute',
10
12
  bottom: '50px',
11
13
  left: '115px',
12
- backgroundColor: 'rgba(255, 255, 255, 0.15)',
13
14
  color: 'white',
14
15
  fontWeight: 'bold',
15
16
  borderRadius: '50%',
16
17
  textDecoration: 'none',
17
18
  zIndex: '1000',
18
19
  cursor: 'pointer',
19
- transition: 'background-color 0.3s ease',
20
+ transition: 'background-color 0.3s ease, box-shadow 0.3s ease',
20
21
  width: '40px',
21
22
  height: '40px',
22
23
  display: 'flex',
@@ -24,7 +25,6 @@ export const createExitButton = (container, options, removeOverlay) => {
24
25
  alignItems: 'center',
25
26
  justifyContent: 'center',
26
27
  pointerEvents: 'auto',
27
- border: '1px solid rgba(255, 255, 255, 0.4)',
28
28
  outline: 'none',
29
29
  boxSizing: 'border-box',
30
30
  margin: '0',
@@ -33,8 +33,7 @@ export const createExitButton = (container, options, removeOverlay) => {
33
33
  minHeight: '40px',
34
34
  maxWidth: '40px',
35
35
  maxHeight: '40px',
36
- backdropFilter: 'blur(8px)',
37
- WebkitBackdropFilter: 'blur(8px)',
36
+ ...liquidGlassStyles(),
38
37
  };
39
38
 
40
39
  Object.entries(defaultStyles).forEach(([key, value]) => {
@@ -70,11 +69,11 @@ export const createExitButton = (container, options, removeOverlay) => {
70
69
  }
71
70
 
72
71
  button.addEventListener('mouseenter', () => {
73
- button.style.backgroundColor = 'rgba(255, 255, 255, 0.25)';
72
+ button.style.backgroundColor = LIQUID_GLASS.hoverBackgroundColor;
74
73
  });
75
74
 
76
75
  button.addEventListener('mouseleave', () => {
77
- button.style.backgroundColor = 'rgba(255, 255, 255, 0.15)';
76
+ button.style.backgroundColor = LIQUID_GLASS.backgroundColor;
78
77
  });
79
78
 
80
79
  button.addEventListener('click', (e) => {
@@ -0,0 +1,38 @@
1
+ // Shared "liquid glass" design tokens for every glassy surface in the SDK
2
+ // (on-camera control buttons, segmented toggles and modal panels). Centralized
3
+ // so the look stays consistent and can be tuned from a single place.
4
+
5
+ export const LIQUID_GLASS = {
6
+ // Translucent fill for dark-on-camera controls (idle / hover / active).
7
+ backgroundColor: 'rgba(255, 255, 255, 0.12)',
8
+ hoverBackgroundColor: 'rgba(255, 255, 255, 0.24)',
9
+ activeBackgroundColor: 'rgba(255, 255, 255, 0.34)',
10
+ // Frosted panel fill for light modals (dark content sits on top).
11
+ panelBackground: 'rgba(250, 250, 252, 0.72)',
12
+ // Dark frosted panel fill for warning / system modals.
13
+ darkPanelBackground: 'rgba(30, 41, 59, 0.72)',
14
+ // Heavy blur + saturation is what produces the "liquid" refraction.
15
+ blur: 'blur(18px) saturate(180%)',
16
+ // Bright hairline edge.
17
+ border: '1px solid rgba(255, 255, 255, 0.5)',
18
+ darkBorder: '1px solid rgba(255, 255, 255, 0.14)',
19
+ // Outer float shadow + inner specular highlights (bright top, soft bottom).
20
+ boxShadow:
21
+ '0 8px 32px rgba(0, 0, 0, 0.18), inset 0 1px 1px rgba(255, 255, 255, 0.65), inset 0 -2px 6px rgba(255, 255, 255, 0.12)',
22
+ panelBoxShadow:
23
+ '0 16px 48px rgba(0, 0, 0, 0.28), inset 0 1px 1px rgba(255, 255, 255, 0.85), inset 0 -2px 8px rgba(255, 255, 255, 0.22)',
24
+ darkPanelBoxShadow:
25
+ '0 16px 48px rgba(0, 0, 0, 0.45), inset 0 1px 1px rgba(255, 255, 255, 0.22), inset 0 -2px 8px rgba(0, 0, 0, 0.25)',
26
+ };
27
+
28
+ // Inline-style fragment for on-camera glass controls (buttons, toggles).
29
+ // Spread into a component's defaultStyles; pass overrides (e.g. a thicker
30
+ // border for the capture ring) to customize per control.
31
+ export const liquidGlassStyles = (overrides = {}) => ({
32
+ backgroundColor: LIQUID_GLASS.backgroundColor,
33
+ backdropFilter: LIQUID_GLASS.blur,
34
+ WebkitBackdropFilter: LIQUID_GLASS.blur,
35
+ border: LIQUID_GLASS.border,
36
+ boxShadow: LIQUID_GLASS.boxShadow,
37
+ ...overrides,
38
+ });
@@ -1,3 +1,5 @@
1
+ import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
2
+
1
3
  export const createMirrorButton = (container, toggleCallback) => {
2
4
  const button = document.createElement('button');
3
5
  button.id = 'veryfi-mirror-button';
@@ -5,7 +7,6 @@ export const createMirrorButton = (container, toggleCallback) => {
5
7
  const defaultStyles = {
6
8
  width: '40px',
7
9
  height: '40px',
8
- backgroundColor: 'rgba(255, 255, 255, 0.15)',
9
10
  color: '#FFFFFF',
10
11
  borderRadius: '50%',
11
12
  position: 'absolute',
@@ -18,7 +19,6 @@ export const createMirrorButton = (container, toggleCallback) => {
18
19
  padding: '0',
19
20
  cursor: 'pointer',
20
21
  pointerEvents: 'auto',
21
- border: '1px solid rgba(255, 255, 255, 0.4)',
22
22
  outline: 'none',
23
23
  boxSizing: 'border-box',
24
24
  margin: '0',
@@ -26,8 +26,8 @@ export const createMirrorButton = (container, toggleCallback) => {
26
26
  minHeight: '40px',
27
27
  maxWidth: '40px',
28
28
  maxHeight: '40px',
29
- backdropFilter: 'blur(8px)',
30
- WebkitBackdropFilter: 'blur(8px)',
29
+ transition: 'background-color 0.3s ease, box-shadow 0.3s ease',
30
+ ...liquidGlassStyles(),
31
31
  };
32
32
 
33
33
  Object.entries(defaultStyles).forEach(([key, value]) => {
@@ -35,10 +35,10 @@ export const createMirrorButton = (container, toggleCallback) => {
35
35
  });
36
36
 
37
37
  button.addEventListener('mouseover', () => {
38
- button.style.backgroundColor = 'rgba(255, 255, 255, 0.25)';
38
+ button.style.backgroundColor = LIQUID_GLASS.hoverBackgroundColor;
39
39
  });
40
40
  button.addEventListener('mouseout', () => {
41
- button.style.backgroundColor = 'rgba(255, 255, 255, 0.15)';
41
+ button.style.backgroundColor = LIQUID_GLASS.backgroundColor;
42
42
  });
43
43
 
44
44
  button.addEventListener('click', toggleCallback);
@@ -1,3 +1,5 @@
1
+ import { LIQUID_GLASS } from './liquid-glass.js';
2
+
1
3
  const DEFAULT_STYLES = {
2
4
  position: 'fixed',
3
5
  width: '300px',
@@ -6,8 +8,8 @@ const DEFAULT_STYLES = {
6
8
  justifyContent: 'center',
7
9
  alignItems: 'center',
8
10
  zIndex: '1000',
9
- backgroundColor: 'white',
10
- borderRadius: '16px',
11
+ backgroundColor: LIQUID_GLASS.panelBackground,
12
+ borderRadius: '20px',
11
13
  padding: '24px 28px',
12
14
  maxWidth: '300px',
13
15
  textColor: '#1e293b',
@@ -21,9 +23,13 @@ const DEFAULT_STYLES = {
21
23
  buttonFontWeight: '700',
22
24
  primaryButtonBackground: '#00AA00',
23
25
  primaryButtonColor: 'white',
24
- secondaryButtonBackground: 'transparent',
25
- secondaryButtonBorder: '1px solid #333',
26
- secondaryButtonColor: '#333'
26
+ primaryButtonBoxShadow: LIQUID_GLASS.boxShadow,
27
+ secondaryButtonBackground: 'rgba(255, 255, 255, 0.45)',
28
+ secondaryButtonBorder: '1px solid rgba(0, 0, 0, 0.12)',
29
+ secondaryButtonColor: '#1e293b',
30
+ panelBackdropFilter: LIQUID_GLASS.blur,
31
+ panelBorder: '1px solid rgba(255, 255, 255, 0.6)',
32
+ panelBoxShadow: LIQUID_GLASS.panelBoxShadow,
27
33
  };
28
34
 
29
35
  export const createModal = (container, {
@@ -86,6 +92,13 @@ export const createModal = (container, {
86
92
  modal.style.transform = `var(--modal-transform, ${s.transform})`;
87
93
  }
88
94
 
95
+ const glassPanelStyle = `
96
+ backdrop-filter: var(--${cssPrefix}-panel-backdrop-filter, ${s.panelBackdropFilter});
97
+ -webkit-backdrop-filter: var(--${cssPrefix}-panel-backdrop-filter, ${s.panelBackdropFilter});
98
+ border: var(--${cssPrefix}-panel-border, ${s.panelBorder});
99
+ box-shadow: var(--${cssPrefix}-panel-box-shadow, ${s.panelBoxShadow});
100
+ `;
101
+
89
102
  const contentStyle = useBackdrop ? `
90
103
  background-color: var(--${cssPrefix}-background-color, ${s.backgroundColor});
91
104
  border-radius: var(--${cssPrefix}-border-radius, ${s.borderRadius});
@@ -97,13 +110,14 @@ export const createModal = (container, {
97
110
  display: flex;
98
111
  flex-direction: column;
99
112
  align-items: stretch;
100
- box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
113
+ ${glassPanelStyle}
101
114
  ` : `
102
115
  background-color: var(--${cssPrefix}-background-color, ${s.backgroundColor});
103
116
  border-radius: var(--${cssPrefix}-border-radius, ${s.borderRadius});
104
117
  padding: var(--${cssPrefix}-padding, ${s.padding});
105
118
  width: var(--${cssPrefix}-width, ${s.width});
106
119
  max-width: var(--${cssPrefix}-max-width, ${s.maxWidth});
120
+ ${glassPanelStyle}
107
121
  `;
108
122
 
109
123
  const btnWidth = useBackdrop ? 'width: 100%;' : `width: var(--${cssPrefix}-button-width, ${s.buttonWidth});`;
@@ -130,7 +144,8 @@ export const createModal = (container, {
130
144
  border-radius: var(--${cssPrefix}-button-border-radius, ${s.buttonBorderRadius});
131
145
  background-color: var(--${cssPrefix}-primary-button-background, ${s.primaryButtonBackground});
132
146
  color: var(--${cssPrefix}-primary-button-color, ${s.primaryButtonColor});
133
- border: none;
147
+ border: var(--${cssPrefix}-primary-button-border, ${LIQUID_GLASS.border});
148
+ box-shadow: var(--${cssPrefix}-primary-button-box-shadow, ${s.primaryButtonBoxShadow});
134
149
  cursor: pointer;
135
150
  font-weight: var(--${cssPrefix}-button-font-weight, ${s.buttonFontWeight});
136
151
  font-family: var(--${cssPrefix}-button-font-family, ${s.buttonFontFamily});
@@ -149,6 +164,8 @@ export const createModal = (container, {
149
164
  background-color: var(--${cssPrefix}-secondary-button-background, ${s.secondaryButtonBackground});
150
165
  color: var(--${cssPrefix}-secondary-button-color, ${s.secondaryButtonColor});
151
166
  border: var(--${cssPrefix}-secondary-button-border, ${s.secondaryButtonBorder});
167
+ backdrop-filter: blur(8px);
168
+ -webkit-backdrop-filter: blur(8px);
152
169
  cursor: pointer;
153
170
  font-weight: var(--${cssPrefix}-button-font-weight, ${s.buttonFontWeight});
154
171
  font-family: var(--${cssPrefix}-button-font-family, ${s.buttonFontFamily});
@@ -1,8 +1,9 @@
1
1
  export const createPrescriptionLabelGuide = (container, options = {}) => {
2
2
  const text = options.text || '';
3
+ const id = options.id || 'veryfi-prescription-label-guide';
3
4
 
4
5
  const guide = document.createElement('div');
5
- guide.id = 'veryfi-prescription-label-guide';
6
+ guide.id = id;
6
7
 
7
8
  Object.assign(guide.style, {
8
9
  position: 'absolute',
@@ -33,7 +34,7 @@ export const createPrescriptionLabelGuide = (container, options = {}) => {
33
34
  guide.appendChild(textEl);
34
35
 
35
36
  const closeButton = document.createElement('button');
36
- closeButton.id = 'veryfi-prescription-label-guide-close';
37
+ closeButton.id = `${id}-close`;
37
38
  closeButton.setAttribute('aria-label', 'Close guide');
38
39
  closeButton.textContent = '\u00D7';
39
40
  Object.assign(closeButton.style, {
@@ -67,6 +68,7 @@ export const createPrescriptionLabelGuide = (container, options = {}) => {
67
68
 
68
69
  return {
69
70
  element: guide,
71
+ setText: (newText) => { textEl.textContent = newText || ''; },
70
72
  show: () => { guide.style.display = 'block'; },
71
73
  hide: () => { guide.style.display = 'none'; },
72
74
  remove: () => {
@@ -0,0 +1,78 @@
1
+ import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
2
+
3
+ export const createPrescriptionOverlayToggleButton = (container, options = {}) => {
4
+ const bottleLabel = options.bottleLabel || 'Bottle';
5
+ const boxLabel = options.boxLabel || 'Box';
6
+ let active = options.initial === 'box' ? 'box' : 'bottle';
7
+ const onToggle = typeof options.onToggle === 'function' ? options.onToggle : () => {};
8
+
9
+ const wrapper = document.createElement('div');
10
+ wrapper.id = 'veryfi-prescription-overlay-toggle';
11
+ Object.assign(wrapper.style, {
12
+ position: 'absolute',
13
+ top: '20px',
14
+ left: '50%',
15
+ transform: 'translateX(-50%)',
16
+ display: 'flex',
17
+ gap: '4px',
18
+ padding: '4px',
19
+ borderRadius: '25px',
20
+ zIndex: '1004',
21
+ pointerEvents: 'auto',
22
+ ...liquidGlassStyles(),
23
+ });
24
+
25
+ const makeSegment = (label, type) => {
26
+ const btn = document.createElement('button');
27
+ btn.type = 'button';
28
+ btn.textContent = label;
29
+ btn.dataset.type = type;
30
+ Object.assign(btn.style, {
31
+ border: 'none',
32
+ outline: 'none',
33
+ cursor: 'pointer',
34
+ borderRadius: '20px',
35
+ padding: '8px 18px',
36
+ fontSize: '14px',
37
+ fontWeight: '600',
38
+ fontFamily: "system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif",
39
+ color: 'white',
40
+ backgroundColor: 'transparent',
41
+ transition: 'background-color 0.2s ease, box-shadow 0.2s ease',
42
+ });
43
+ btn.addEventListener('click', () => {
44
+ if (active === type) return;
45
+ active = type;
46
+ updateSegments();
47
+ onToggle(active);
48
+ });
49
+ return btn;
50
+ };
51
+
52
+ const bottleBtn = makeSegment(bottleLabel, 'bottle');
53
+ const boxBtn = makeSegment(boxLabel, 'box');
54
+
55
+ const updateSegments = () => {
56
+ [[bottleBtn, 'bottle'], [boxBtn, 'box']].forEach(([btn, type]) => {
57
+ const isActive = active === type;
58
+ btn.style.backgroundColor = isActive ? LIQUID_GLASS.activeBackgroundColor : 'transparent';
59
+ btn.style.boxShadow = isActive
60
+ ? 'inset 0 1px 1px rgba(255, 255, 255, 0.6), 0 2px 8px rgba(0, 0, 0, 0.12)'
61
+ : 'none';
62
+ });
63
+ };
64
+
65
+ wrapper.appendChild(bottleBtn);
66
+ wrapper.appendChild(boxBtn);
67
+ updateSegments();
68
+ container.appendChild(wrapper);
69
+
70
+ return {
71
+ element: wrapper,
72
+ getActive: () => active,
73
+ setActive: (type) => { active = type === 'box' ? 'box' : 'bottle'; updateSegments(); },
74
+ show: () => { wrapper.style.display = 'flex'; },
75
+ hide: () => { wrapper.style.display = 'none'; },
76
+ remove: () => { if (wrapper.parentNode) wrapper.parentNode.removeChild(wrapper); },
77
+ };
78
+ };
@@ -1,3 +1,5 @@
1
+ import { liquidGlassStyles } from './liquid-glass.js';
2
+
1
3
  export const createSubmitButton = (container, onSubmit, removeOverlay, options = {}) => {
2
4
  const button = document.createElement('button');
3
5
  button.id = 'veryfi-submit-button';
@@ -8,9 +10,7 @@ export const createSubmitButton = (container, onSubmit, removeOverlay, options =
8
10
  bottom: '50px',
9
11
  transform: 'translateX(-50%)',
10
12
  padding: '12px 28px',
11
- backgroundColor: '#00AA00',
12
13
  color: 'white',
13
- border: 'none',
14
14
  borderRadius: '25px',
15
15
  cursor: 'pointer',
16
16
  fontSize: '14px',
@@ -18,7 +18,7 @@ export const createSubmitButton = (container, onSubmit, removeOverlay, options =
18
18
  fontWeight: '600',
19
19
  letterSpacing: '0.3px',
20
20
  transition: 'all 0.2s ease',
21
- boxShadow: '0 2px 8px rgba(0,0,0,0.15)',
21
+ ...liquidGlassStyles({ backgroundColor: '#00AA00' }),
22
22
  zIndex: '1000',
23
23
  display: 'none',
24
24
  pointerEvents: 'auto',
@@ -1,3 +1,5 @@
1
+ import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
2
+
1
3
  export const createSwitchCameraButton = (container, toggleCallback) => {
2
4
  const button = document.createElement('button');
3
5
  button.id = 'veryfi-switch-camera-button';
@@ -5,7 +7,6 @@ export const createSwitchCameraButton = (container, toggleCallback) => {
5
7
  const defaultStyles = {
6
8
  width: '40px',
7
9
  height: '40px',
8
- backgroundColor: 'rgba(255, 255, 255, 0.15)',
9
10
  color: '#FFFFFF',
10
11
  borderRadius: '50%',
11
12
  position: 'absolute',
@@ -18,7 +19,6 @@ export const createSwitchCameraButton = (container, toggleCallback) => {
18
19
  padding: '0',
19
20
  cursor: 'pointer',
20
21
  pointerEvents: 'auto',
21
- border: '1px solid rgba(255, 255, 255, 0.4)',
22
22
  outline: 'none',
23
23
  boxSizing: 'border-box',
24
24
  margin: '0',
@@ -26,8 +26,8 @@ export const createSwitchCameraButton = (container, toggleCallback) => {
26
26
  minHeight: '40px',
27
27
  maxWidth: '40px',
28
28
  maxHeight: '40px',
29
- backdropFilter: 'blur(8px)',
30
- WebkitBackdropFilter: 'blur(8px)',
29
+ transition: 'background-color 0.3s ease, box-shadow 0.3s ease',
30
+ ...liquidGlassStyles(),
31
31
  };
32
32
 
33
33
  Object.entries(defaultStyles).forEach(([key, value]) => {
@@ -35,10 +35,10 @@ export const createSwitchCameraButton = (container, toggleCallback) => {
35
35
  });
36
36
 
37
37
  button.addEventListener('mouseover', () => {
38
- button.style.backgroundColor = 'rgba(255, 255, 255, 0.25)';
38
+ button.style.backgroundColor = LIQUID_GLASS.hoverBackgroundColor;
39
39
  });
40
40
  button.addEventListener('mouseout', () => {
41
- button.style.backgroundColor = 'rgba(255, 255, 255, 0.15)';
41
+ button.style.backgroundColor = LIQUID_GLASS.backgroundColor;
42
42
  });
43
43
 
44
44
  button.addEventListener('click', toggleCallback);
@@ -1,3 +1,5 @@
1
+ import { LIQUID_GLASS, liquidGlassStyles } from './liquid-glass.js';
2
+
1
3
  export const createTorchButton = (container, toggleCallback, lensFlavor) => {
2
4
  const button = document.createElement("button");
3
5
  button.id = "veryfi-torch-button";
@@ -5,7 +7,6 @@ export const createTorchButton = (container, toggleCallback, lensFlavor) => {
5
7
  const defaultStyles = {
6
8
  width: '40px',
7
9
  height: '40px',
8
- backgroundColor: 'rgba(255, 255, 255, 0.15)',
9
10
  color: '#FFFFFF',
10
11
  borderRadius: '50%',
11
12
  position: 'absolute',
@@ -18,7 +19,6 @@ export const createTorchButton = (container, toggleCallback, lensFlavor) => {
18
19
  padding: '0',
19
20
  cursor: 'pointer',
20
21
  pointerEvents: 'auto',
21
- border: '1px solid rgba(255, 255, 255, 0.4)',
22
22
  outline: 'none',
23
23
  boxSizing: 'border-box',
24
24
  margin: '0',
@@ -26,8 +26,8 @@ export const createTorchButton = (container, toggleCallback, lensFlavor) => {
26
26
  minHeight: '40px',
27
27
  maxWidth: '40px',
28
28
  maxHeight: '40px',
29
- backdropFilter: 'blur(8px)',
30
- WebkitBackdropFilter: 'blur(8px)',
29
+ transition: 'background-color 0.3s ease, box-shadow 0.3s ease',
30
+ ...liquidGlassStyles(),
31
31
  };
32
32
 
33
33
 
@@ -59,10 +59,10 @@ export const createTorchButton = (container, toggleCallback, lensFlavor) => {
59
59
  }
60
60
 
61
61
  button.addEventListener('mouseover', () => {
62
- button.style.backgroundColor = 'rgba(255, 255, 255, 0.25)';
62
+ button.style.backgroundColor = LIQUID_GLASS.hoverBackgroundColor;
63
63
  });
64
64
  button.addEventListener('mouseout', () => {
65
- button.style.backgroundColor = 'rgba(255, 255, 255, 0.15)';
65
+ button.style.backgroundColor = LIQUID_GLASS.backgroundColor;
66
66
  });
67
67
 
68
68
  button.addEventListener('click', toggleCallback);
@@ -76,6 +76,8 @@ export const handleAnydocPageCapture = () => {
76
76
  state.exitButtonRef.hide();
77
77
  }
78
78
 
79
+ state.anydocGuide?.hide?.();
80
+
79
81
  state.blurStatus = false;
80
82
  state.lcdStatus = false;
81
83
 
@@ -1,9 +1,12 @@
1
1
  import { state } from '../state.js';
2
- import { handleSubmit, addPackageScan, ensurePackageUploaded } from '../api.js';
2
+ import { handleSubmit, addPackageScan, ensurePackageUploaded, docReady } from '../api.js';
3
3
  import { hideVideoOverlay, showVideoOverlay } from '../overlay-controls.js';
4
4
  import { removeOverlay, newStartLens } from '../lifecycle.js';
5
5
  import { promptForAnotherCapture } from '../multi-submission.js';
6
6
  import { createSubmitButton } from '../../components/submitButton.js';
7
+ import { createMultiCaptureModal } from '../../components/multiCaptureModal.js';
8
+ import { liquidGlassStyles } from '../../components/liquid-glass.js';
9
+ import { DEFAULTS } from '../constants.js';
7
10
 
8
11
  let previewRecorder = null;
9
12
  let previewChunks = [];
@@ -19,6 +22,9 @@ let lastVideoBlob = null;
19
22
  let cropCanvas = null;
20
23
  let cropAnimationFrameId = null;
21
24
  let recordingStartTime = 0;
25
+ let boxSideCount = 0;
26
+ let maxDurationTimeoutId = null;
27
+ let countdownIntervalId = null;
22
28
 
23
29
  const ensurePulseKeyframes = () => {
24
30
  if (pulseStyleEl) return;
@@ -85,6 +91,7 @@ const updateRecordingUI = (recording) => {
85
91
  });
86
92
 
87
93
  const text = document.createElement('span');
94
+ text.id = 'veryfi-recording-countdown';
88
95
  Object.assign(text.style, {
89
96
  color: 'white',
90
97
  fontSize: '14px',
@@ -134,7 +141,7 @@ const getRecorderMimeType = () => {
134
141
  };
135
142
 
136
143
  const computeOverlayCropRect = (vw, vh) => {
137
- if (state.prescriptionLabelShowSquareOverlay) {
144
+ if (state.prescriptionLabelActiveOverlay === 'box') {
138
145
  const w = vw * state.prescriptionLabelSquareWidthRatio;
139
146
  const h = vh * state.prescriptionLabelSquareHeightRatio;
140
147
  const cx = vw / 2;
@@ -142,15 +149,11 @@ const computeOverlayCropRect = (vw, vh) => {
142
149
  return { x: cx - w / 2, y: cy - h / 2, width: w, height: h };
143
150
  }
144
151
 
145
- if (state.prescriptionLabelShowOverlay) {
146
- const bodyW = vw * state.prescriptionLabelWidthRatio;
147
- const totalH = vh * state.prescriptionLabelHeightRatio;
148
- const cx = vw / 2;
149
- const cy = vh * 0.46;
150
- return { x: cx - bodyW / 2, y: cy - totalH / 2, width: bodyW, height: totalH };
151
- }
152
-
153
- return null;
152
+ const bodyW = vw * state.prescriptionLabelWidthRatio;
153
+ const totalH = vh * state.prescriptionLabelHeightRatio;
154
+ const cx = vw / 2;
155
+ const cy = vh * 0.46;
156
+ return { x: cx - bodyW / 2, y: cy - totalH / 2, width: bodyW, height: totalH };
154
157
  };
155
158
 
156
159
  const computeSourceCropRegion = (videoElement) => {
@@ -220,6 +223,45 @@ const stopCroppedDrawLoop = () => {
220
223
  cropCanvas = null;
221
224
  };
222
225
 
226
+ const formatCountdown = (totalSeconds) => {
227
+ const s = Math.max(0, Math.floor(totalSeconds));
228
+ const mins = Math.floor(s / 60);
229
+ const secs = s % 60;
230
+ return `${mins}:${String(secs).padStart(2, '0')}`;
231
+ };
232
+
233
+ const startRecordingCountdown = (maxDuration) => {
234
+ stopRecordingCountdown();
235
+ let remaining = maxDuration;
236
+ const render = () => {
237
+ const el = document.getElementById('veryfi-recording-countdown');
238
+ if (el) el.textContent = `REC ${formatCountdown(remaining)}`;
239
+ };
240
+ render();
241
+ countdownIntervalId = setInterval(() => {
242
+ remaining -= 1;
243
+ render();
244
+ if (remaining <= 0) {
245
+ stopRecordingCountdown();
246
+ }
247
+ }, 1000);
248
+ };
249
+
250
+ const stopRecordingCountdown = () => {
251
+ if (countdownIntervalId !== null) {
252
+ clearInterval(countdownIntervalId);
253
+ countdownIntervalId = null;
254
+ }
255
+ };
256
+
257
+ const clearRecordingTimers = () => {
258
+ if (maxDurationTimeoutId !== null) {
259
+ clearTimeout(maxDurationTimeoutId);
260
+ maxDurationTimeoutId = null;
261
+ }
262
+ stopRecordingCountdown();
263
+ };
264
+
223
265
  const startRecording = () => {
224
266
  const stream = state.videoRef?.srcObject;
225
267
  if (!stream) {
@@ -273,8 +315,20 @@ const startRecording = () => {
273
315
  isRecording = true;
274
316
  updateRecordingUI(true);
275
317
  state.prescriptionLabelGuide?.hide?.();
318
+ state.prescriptionOverlayToggleButton?.hide?.();
276
319
  state.updateHandler?.({ status: 'recording_started' });
277
320
  state.debug_mode && console.log('[EVENT] prescription label recording started');
321
+
322
+ // Optional hard cap on recording length with an on-screen countdown. When the
323
+ // limit is reached the recording auto-stops through the normal capture path.
324
+ const maxDuration = state.prescriptionLabelMaxVideoDuration;
325
+ if (maxDuration && maxDuration > 0) {
326
+ startRecordingCountdown(maxDuration);
327
+ maxDurationTimeoutId = setTimeout(() => {
328
+ maxDurationTimeoutId = null;
329
+ if (isRecording) capturePrescriptionLabel();
330
+ }, maxDuration * 1000);
331
+ }
278
332
  };
279
333
 
280
334
  const stopRecording = () => {
@@ -286,6 +340,8 @@ const stopRecording = () => {
286
340
 
287
341
  let previewBlob = null;
288
342
  let submissionBlob = null;
343
+ clearRecordingTimers();
344
+
289
345
  const finalize = () => {
290
346
  if (!previewBlob || !submissionBlob) return;
291
347
  const durationSec = (performance.now() - recordingStartTime) / 1000;
@@ -395,15 +451,14 @@ const showVideoPreview = (videoBlob) => {
395
451
  width: '60px',
396
452
  height: '60px',
397
453
  borderRadius: '50%',
398
- border: 'none',
399
- backgroundColor: 'rgba(0,0,0,0.5)',
400
454
  cursor: 'pointer',
401
455
  zIndex: '950',
402
456
  pointerEvents: 'auto',
403
457
  display: 'flex',
404
458
  alignItems: 'center',
405
459
  justifyContent: 'center',
406
- transition: 'opacity 0.2s',
460
+ transition: 'opacity 0.2s, box-shadow 0.3s ease',
461
+ ...liquidGlassStyles(),
407
462
  });
408
463
 
409
464
  playPauseButtonEl.addEventListener('click', () => {
@@ -432,9 +487,7 @@ const showVideoPreview = (videoBlob) => {
432
487
  transform: 'translateX(calc(-100% - 8px))',
433
488
  width: '140px',
434
489
  padding: '12px 0',
435
- backgroundColor: 'rgba(255,255,255,0.15)',
436
490
  color: 'white',
437
- border: '1px solid rgba(255,255,255,0.4)',
438
491
  borderRadius: '25px',
439
492
  cursor: 'pointer',
440
493
  fontSize: '14px',
@@ -443,6 +496,7 @@ const showVideoPreview = (videoBlob) => {
443
496
  textAlign: 'center',
444
497
  zIndex: '1000',
445
498
  pointerEvents: 'auto',
499
+ ...liquidGlassStyles(),
446
500
  });
447
501
  retakeButtonEl.addEventListener('click', async () => {
448
502
  cleanupPreview();
@@ -457,6 +511,7 @@ const showVideoPreview = (videoBlob) => {
457
511
  }
458
512
  showVideoOverlay();
459
513
  state.prescriptionLabelGuide?.show?.();
514
+ state.prescriptionOverlayToggleButton?.show?.();
460
515
  await newStartLens();
461
516
  });
462
517
  containerEl.appendChild(retakeButtonEl);
@@ -497,7 +552,208 @@ const submitVideoBlob = async (videoBlob) => {
497
552
  return submitResult;
498
553
  };
499
554
 
555
+ const submitPrescriptionImage = async (imageBase64) => {
556
+ state.updateHandler?.({ status: 'processing_started' });
557
+ state.updateHandler?.({ status: 'processing_completed' });
558
+
559
+ let submitResult;
560
+ if (typeof state.customSubmitHandler === 'function') {
561
+ const packageInfo = await ensurePackageUploaded();
562
+ state.customSubmitHandler(imageBase64, packageInfo);
563
+ submitResult = imageBase64;
564
+ } else {
565
+ submitResult = await handleSubmit(imageBase64);
566
+ }
567
+
568
+ state.updateHandler?.({ status: 'capture_completed' });
569
+ return submitResult;
570
+ };
571
+
572
+ const capturePrescriptionImage = async () => {
573
+ try {
574
+ state.debug_mode && console.log('[EVENT] capture prescription label image');
575
+ state.updateHandler?.({ status: 'capture_started' });
576
+
577
+ const videoElement = state.videoRef;
578
+ if (!videoElement) {
579
+ throw new Error('Video reference not initialized');
580
+ }
581
+
582
+ const region = computeSourceCropRegion(videoElement);
583
+ if (!region) {
584
+ throw new Error('Failed to compute prescription label crop region');
585
+ }
586
+
587
+ const cropImgRef = state.cropImgRef;
588
+ if (!cropImgRef) {
589
+ throw new Error('Crop image reference not initialized');
590
+ }
591
+
592
+ cropImgRef.width = Math.max(2, Math.round(region.srcW));
593
+ cropImgRef.height = Math.max(2, Math.round(region.srcH));
594
+ const ctx = cropImgRef.getContext('2d');
595
+ ctx.clearRect(0, 0, cropImgRef.width, cropImgRef.height);
596
+ ctx.drawImage(
597
+ videoElement,
598
+ region.srcX, region.srcY, region.srcW, region.srcH,
599
+ 0, 0, cropImgRef.width, cropImgRef.height
600
+ );
601
+
602
+ state.finalImage = cropImgRef.toDataURL('image/jpeg', DEFAULTS.IMAGE_QUALITY).split(',')[1];
603
+ if (!state.finalImage) {
604
+ throw new Error('Failed to capture prescription label image');
605
+ }
606
+
607
+ state.isDocument = true;
608
+ hideVideoOverlay();
609
+ state.prescriptionSquareOverlay?.hide?.();
610
+ state.prescriptionLabelOverlay?.hide?.();
611
+ state.prescriptionOverlayToggleButton?.hide?.();
612
+ state.prescriptionLabelGuide?.hide?.();
613
+ state.exitButtonRef?.hide?.();
614
+ state.videoRef?.srcObject?.getTracks?.().forEach((track) => track.stop());
615
+
616
+ state.cropImgRef?.setRectangleDisplay?.();
617
+ state.cropImgRef?.showSuccessBorder?.();
618
+
619
+ // Accumulate this side. Upload is deferred to submit so multiple box sides
620
+ // land in a single document via the package flow (parity with anydocs
621
+ // multi-page). In packageMode: true each side is added to state.packageScans
622
+ // and uploaded once on submit; in packageMode: false each side POSTs to
623
+ // /rest/send-cropped as its own document.
624
+ state.updateHandler?.({ status: 'processing_started' });
625
+ state.docReadyResult = await docReady();
626
+ state.updateHandler?.({ status: 'processing_completed' });
627
+
628
+ boxSideCount += 1;
629
+
630
+ const clearCropPreview = () => {
631
+ if (state.cropImgRef) {
632
+ const previewImg = state.cropImgRef.previewImg;
633
+ if (previewImg) {
634
+ previewImg.style.display = 'none';
635
+ previewImg.src = '';
636
+ }
637
+ state.cropImgRef.hideBorder?.();
638
+ const cctx = state.cropImgRef.getContext('2d');
639
+ cctx?.clearRect(0, 0, state.cropImgRef.width, state.cropImgRef.height);
640
+ }
641
+ };
642
+
643
+ // Re-open the box camera to capture another side of the SAME box. Keeps the
644
+ // accumulated package scans and locks to the box overlay (toggle hidden).
645
+ const captureAnotherSide = async () => {
646
+ clearCropPreview();
647
+ showVideoOverlay();
648
+ state.prescriptionLabelOverlay?.hide?.();
649
+ state.prescriptionSquareOverlay?.show?.();
650
+ state.prescriptionLabelGuide?.show?.();
651
+ state.prescriptionOverlayToggleButton?.hide?.();
652
+ await newStartLens();
653
+ };
654
+
655
+ // Restart for a brand new document (multi-submission "capture another").
656
+ const restartPrescription = async () => {
657
+ clearCropPreview();
658
+ showVideoOverlay();
659
+ state.prescriptionSquareOverlay?.show?.();
660
+ state.prescriptionLabelGuide?.show?.();
661
+ state.prescriptionOverlayToggleButton?.show?.();
662
+ await newStartLens();
663
+ };
664
+
665
+ const finalizeBoxDocument = async () => {
666
+ boxSideCount = 0;
667
+
668
+ if (state.packageMode && !state.enableSubmit && typeof state.customSubmitHandler !== 'function') {
669
+ const packageInfo = await ensurePackageUploaded();
670
+ state.resultSetter?.({ ...(packageInfo || {}), image: state.finalImage });
671
+ removeOverlay();
672
+ return;
673
+ }
674
+
675
+ const result = await submitPrescriptionImage(state.finalImage);
676
+ if (state.multiSubmission && result) {
677
+ promptForAnotherCapture(restartPrescription);
678
+ } else {
679
+ removeOverlay();
680
+ }
681
+ };
682
+
683
+ // Multi-side box capture: after each side, ask whether to capture another
684
+ // side of the same box (accumulated into one document) or submit now.
685
+ if (state.prescriptionLabelBoxMultiSide) {
686
+ state.resultSetter?.(state.finalImage);
687
+
688
+ // Cap the number of sides per box; once reached, submit automatically
689
+ // instead of prompting for another side.
690
+ const maxSides = state.prescriptionLabelBoxMaxSides;
691
+ if (maxSides && boxSideCount >= maxSides) {
692
+ await finalizeBoxDocument();
693
+ state.updateHandler?.({ status: 'capture_completed' });
694
+ return state.finalImage;
695
+ }
696
+
697
+ const sideModal = createMultiCaptureModal(
698
+ state.container,
699
+ async () => {
700
+ sideModal.remove();
701
+ await captureAnotherSide();
702
+ },
703
+ async () => {
704
+ sideModal.remove();
705
+ await finalizeBoxDocument();
706
+ },
707
+ {
708
+ message: state.prescriptionLabelBoxSideMessage,
709
+ yesButtonText: state.prescriptionLabelBoxSideAddText,
710
+ noButtonText: state.prescriptionLabelBoxSideSubmitText,
711
+ }
712
+ );
713
+ sideModal.show();
714
+
715
+ state.updateHandler?.({ status: 'capture_completed' });
716
+ return state.finalImage;
717
+ }
718
+
719
+ state.submitButton = createSubmitButton(
720
+ state.container,
721
+ async () => {
722
+ const result = await submitPrescriptionImage(state.finalImage);
723
+ if (state.multiSubmission && result) {
724
+ state.submitButton?.hide?.();
725
+ promptForAnotherCapture(restartPrescription);
726
+ } else {
727
+ removeOverlay();
728
+ }
729
+ },
730
+ () => {},
731
+ { autoClose: false }
732
+ );
733
+ state.submitButton.show();
734
+
735
+ if (state.packageMode && !state.enableSubmit) {
736
+ const packageInfo = await ensurePackageUploaded();
737
+ state.resultSetter?.({ ...(packageInfo || {}), image: state.finalImage });
738
+ } else {
739
+ state.resultSetter?.(state.finalImage);
740
+ }
741
+
742
+ state.updateHandler?.({ status: 'capture_completed' });
743
+ return state.finalImage;
744
+ } catch (error) {
745
+ console.error('Prescription label image capture failed:', error.message);
746
+ state.failureHandler?.(error);
747
+ state.updateHandler?.({ status: 'capture_failed' });
748
+ return null;
749
+ }
750
+ };
751
+
500
752
  export const capturePrescriptionLabel = async () => {
753
+ if (state.prescriptionLabelActiveOverlay === 'box') {
754
+ return capturePrescriptionImage();
755
+ }
756
+
501
757
  try {
502
758
  if (!isRecording) {
503
759
  state.debug_mode && console.log('[EVENT] starting prescription label recording');
@@ -539,6 +795,7 @@ export const capturePrescriptionLabel = async () => {
539
795
  cleanupPreview();
540
796
  showVideoOverlay();
541
797
  state.prescriptionLabelGuide?.show?.();
798
+ state.prescriptionOverlayToggleButton?.show?.();
542
799
  await newStartLens();
543
800
  };
544
801
 
@@ -596,6 +853,8 @@ export const cleanupPrescriptionLabelRecording = () => {
596
853
  previewChunks = [];
597
854
  submissionChunks = [];
598
855
  isRecording = false;
856
+ boxSideCount = 0;
857
+ clearRecordingTimers();
599
858
  updateRecordingUI(false);
600
859
  stopCroppedDrawLoop();
601
860
  cleanupPreview();
package/core/constants.js CHANGED
@@ -86,18 +86,24 @@ export const MESSAGES = {
86
86
  BOTTLE_CAP: 'Position bottle cap in circle',
87
87
  PRESCRIPTION_LABEL: 'Position prescription label in outline',
88
88
  PRESCRIPTION_LABEL_GUIDE: 'Position the bottle within the outline.\n\nPress the capture button to start recording, slowly rotate the bottle to capture the entire label and press the capture button again to stop recording.',
89
- PRESCRIPTION_SQUARE_GUIDE: 'Position the prescription label within the square.\n\nPress the capture button to start recording, press again to stop.',
89
+ PRESCRIPTION_SQUARE_GUIDE: 'Position the prescription label within the square.\n\nPress the capture button to take a photo of the label.',
90
+ PRESCRIPTION_TOGGLE_BOTTLE: 'Bottle',
91
+ PRESCRIPTION_TOGGLE_BOX: 'Box',
92
+ PRESCRIPTION_BOX_SIDE: 'Capture another side of the box?',
93
+ PRESCRIPTION_BOX_SIDE_ADD: 'Capture another side',
94
+ PRESCRIPTION_BOX_SIDE_SUBMIT: 'Submit',
90
95
  CODE_STRIPS: 'Position code strip in rectangle',
91
96
  CHECK_POSITION: 'We could not detect a check, hope this will make it easier',
92
97
  ANYDOC_ADD_PAGE: 'Add Page',
93
98
  ANYDOC_SUBMIT: 'Submit',
94
99
  ANYDOC_FLIP: 'Please flip the document and capture the other side',
95
100
  ANYDOC_FLIP_CONTINUE: 'Continue',
101
+ ANYDOC_GUIDE: 'Position the document within the frame.\n\nPress the capture button to scan a page. Use "Add Page" to capture multiple pages, then press "Submit" when done.',
96
102
  MULTI_CAPTURE_PROMPT: 'Do you need to capture another document?',
97
103
  MULTI_CAPTURE_YES: 'Capture another',
98
104
  MULTI_CAPTURE_NO: "No, I'm done",
99
105
  BATCH_FINISHING: 'Completing batch...',
100
- BATCH_FINISH_FAILED: 'Failed to notify your system. Would you like to try again?',
106
+ BATCH_FINISH_FAILED: 'Failed to submit the batch. Would you like to try again?',
101
107
  BATCH_FINISH_RETRY: 'Retry',
102
108
  BATCH_FINISH_CANCEL: 'Close without notifying',
103
109
  AUTH_FAILED: 'Authorization failed, please provide correct client-id or contact customer support at support@veryfi.com',
package/core/lifecycle.js CHANGED
@@ -185,6 +185,7 @@ export const restartCameraForNextCapture = async () => {
185
185
  }
186
186
  }
187
187
  showVideoOverlay();
188
+ state.anydocGuide?.show?.();
188
189
  await newStartLens();
189
190
  };
190
191
 
package/core/state.js CHANGED
@@ -143,6 +143,9 @@ export const state = {
143
143
  anydocShowFlipMessage: false,
144
144
  anydocFlipMessageText: MESSAGES.ANYDOC_FLIP,
145
145
  anydocFlipContinueText: MESSAGES.ANYDOC_FLIP_CONTINUE,
146
+ anydocShowGuide: false,
147
+ anydocGuideText: MESSAGES.ANYDOC_GUIDE,
148
+ anydocGuide: null,
146
149
  capCircleRadius: DEFAULTS.CAP_CIRCLE_RADIUS,
147
150
  bottleCapText: MESSAGES.BOTTLE_CAP,
148
151
 
@@ -214,6 +217,17 @@ export const state = {
214
217
  prescriptionLabelGuideText: MESSAGES.PRESCRIPTION_LABEL_GUIDE,
215
218
  prescriptionLabelSquareGuideText: MESSAGES.PRESCRIPTION_SQUARE_GUIDE,
216
219
  prescriptionLabelGuide: null,
220
+ prescriptionLabelActiveOverlay: null,
221
+ prescriptionLabelShowOverlayToggle: true,
222
+ prescriptionLabelBottleLabel: MESSAGES.PRESCRIPTION_TOGGLE_BOTTLE,
223
+ prescriptionLabelBoxLabel: MESSAGES.PRESCRIPTION_TOGGLE_BOX,
224
+ prescriptionOverlayToggleButton: null,
225
+ prescriptionLabelBoxMultiSide: true,
226
+ prescriptionLabelBoxMaxSides: 4,
227
+ prescriptionLabelBoxSideMessage: MESSAGES.PRESCRIPTION_BOX_SIDE,
228
+ prescriptionLabelBoxSideAddText: MESSAGES.PRESCRIPTION_BOX_SIDE_ADD,
229
+ prescriptionLabelBoxSideSubmitText: MESSAGES.PRESCRIPTION_BOX_SIDE_SUBMIT,
230
+ prescriptionLabelMaxVideoDuration: 12,
217
231
  preferredVideoFormat: null,
218
232
 
219
233
  codeStripsOverlay: null,
@@ -333,6 +347,8 @@ export const resetState = () => {
333
347
  state.prescriptionLabelOverlay = null;
334
348
  state.prescriptionSquareOverlay = null;
335
349
  state.prescriptionLabelGuide = null;
350
+ state.prescriptionLabelActiveOverlay = null;
351
+ state.prescriptionOverlayToggleButton = null;
336
352
  state.codeStripsOverlay = null;
337
353
  state.checkOverlay = null;
338
354
  state.isManualCheckCapture = false;
@@ -343,6 +359,7 @@ export const resetState = () => {
343
359
  state.blueprintsData = null;
344
360
  state.anydocPages = [];
345
361
  state.anydocPageControls = null;
362
+ state.anydocGuide = null;
346
363
  state.packageScans = [];
347
364
  state.packageFilename = null;
348
365
  state.packageUploadId = null;
@@ -20,6 +20,7 @@ import { createCodeStripsOverlay } from '../components/codeStripsOverlay.js';
20
20
  import { createPrescriptionLabelOverlay } from '../components/prescriptionLabelOverlay.js';
21
21
  import { createPrescriptionSquareOverlay } from '../components/prescriptionSquareOverlay.js';
22
22
  import { createPrescriptionLabelGuide } from '../components/prescriptionLabelGuide.js';
23
+ import { createPrescriptionOverlayToggleButton } from '../components/prescriptionOverlayToggleButton.js';
23
24
  import { createMirrorButton } from '../components/mirrorButton.js';
24
25
  import { createSwitchCameraButton } from '../components/switchCameraButton.js';
25
26
 
@@ -69,19 +70,22 @@ const setupVideoOverlayControls = (captureAction) => {
69
70
  renderWatermarkIfNeeded();
70
71
  };
71
72
 
72
- const createSpecialtyOverlayOnReady = (overlayKey, createFn, options) => {
73
+ const createSpecialtyOverlayOnReady = (overlayKey, createFn, options, onReady) => {
73
74
  const videoElement = document.getElementById("veryfi-video-ref");
74
75
  if (!videoElement) return;
75
76
 
76
- if (videoElement.readyState >= 2) {
77
+ const create = () => {
77
78
  if (!state[overlayKey]) {
78
79
  state[overlayKey] = createFn(state.container, options);
79
80
  }
81
+ onReady?.();
82
+ };
83
+
84
+ if (videoElement.readyState >= 2) {
85
+ create();
80
86
  } else {
81
87
  const handleVideoLoad = () => {
82
- if (!state[overlayKey]) {
83
- state[overlayKey] = createFn(state.container, options);
84
- }
88
+ create();
85
89
  videoElement.removeEventListener('loadeddata', handleVideoLoad);
86
90
  };
87
91
  videoElement.addEventListener('loadeddata', handleVideoLoad);
@@ -159,6 +163,13 @@ export const renderVideoOverlayIfNeeded = () => {
159
163
  });
160
164
  }
161
165
 
166
+ if (state.lensFlavor === 'anydocs' && state.anydocShowGuide && !state.anydocGuide) {
167
+ state.anydocGuide = createPrescriptionLabelGuide(
168
+ state.videoOverlay?.overlay || state.container,
169
+ { text: state.anydocGuideText, id: 'veryfi-anydoc-guide' }
170
+ );
171
+ }
172
+
162
173
  renderWatermarkIfNeeded();
163
174
  };
164
175
 
@@ -293,23 +304,47 @@ export const renderPrescriptionLabelOverlayIfNeeded = () => {
293
304
  state.debug_mode && console.log("Rendering prescription label overlay");
294
305
  setupVideoOverlayControls(() => actions.capturePrescriptionLabel());
295
306
 
296
- if (state.prescriptionLabelShowOverlay) {
307
+ const toggleEnabled = state.prescriptionLabelShowOverlayToggle;
308
+ // When the toggle is enabled both overlays must be switchable regardless of
309
+ // the individual show flags; otherwise fall back to the legacy per-flag show.
310
+ const bottleEnabled = toggleEnabled || state.prescriptionLabelShowOverlay;
311
+ const boxEnabled = toggleEnabled || state.prescriptionLabelShowSquareOverlay;
312
+
313
+ if (!state.prescriptionLabelActiveOverlay) {
314
+ state.prescriptionLabelActiveOverlay =
315
+ (state.prescriptionLabelShowSquareOverlay && !state.prescriptionLabelShowOverlay) ? 'box' : 'bottle';
316
+ }
317
+
318
+ const applyOverlayVisibility = () => {
319
+ if (state.prescriptionLabelOverlay) {
320
+ state.prescriptionLabelActiveOverlay === 'bottle'
321
+ ? state.prescriptionLabelOverlay.show()
322
+ : state.prescriptionLabelOverlay.hide();
323
+ }
324
+ if (state.prescriptionSquareOverlay) {
325
+ state.prescriptionLabelActiveOverlay === 'box'
326
+ ? state.prescriptionSquareOverlay.show()
327
+ : state.prescriptionSquareOverlay.hide();
328
+ }
329
+ };
330
+
331
+ if (bottleEnabled) {
297
332
  createSpecialtyOverlayOnReady('prescriptionLabelOverlay', createPrescriptionLabelOverlay, {
298
333
  bottleWidthRatio: state.prescriptionLabelWidthRatio,
299
334
  bottleHeightRatio: state.prescriptionLabelHeightRatio,
300
335
  instructionText: state.prescriptionLabelText
301
- });
336
+ }, applyOverlayVisibility);
302
337
  }
303
338
 
304
- if (state.prescriptionLabelShowSquareOverlay) {
339
+ if (boxEnabled) {
305
340
  createSpecialtyOverlayOnReady('prescriptionSquareOverlay', createPrescriptionSquareOverlay, {
306
341
  squareWidthRatio: state.prescriptionLabelSquareWidthRatio,
307
342
  squareHeightRatio: state.prescriptionLabelSquareHeightRatio,
308
- });
343
+ }, applyOverlayVisibility);
309
344
  }
310
345
 
311
346
  if (state.prescriptionLabelShowGuide && !state.prescriptionLabelGuide) {
312
- const guideText = state.prescriptionLabelShowSquareOverlay
347
+ const guideText = state.prescriptionLabelActiveOverlay === 'box'
313
348
  ? state.prescriptionLabelSquareGuideText
314
349
  : state.prescriptionLabelGuideText;
315
350
  state.prescriptionLabelGuide = createPrescriptionLabelGuide(
@@ -317,6 +352,25 @@ export const renderPrescriptionLabelOverlayIfNeeded = () => {
317
352
  { text: guideText }
318
353
  );
319
354
  }
355
+
356
+ if (toggleEnabled && bottleEnabled && boxEnabled && !state.prescriptionOverlayToggleButton) {
357
+ state.prescriptionOverlayToggleButton = createPrescriptionOverlayToggleButton(
358
+ state.videoOverlay?.overlay || state.container,
359
+ {
360
+ initial: state.prescriptionLabelActiveOverlay,
361
+ bottleLabel: state.prescriptionLabelBottleLabel,
362
+ boxLabel: state.prescriptionLabelBoxLabel,
363
+ onToggle: (type) => {
364
+ state.prescriptionLabelActiveOverlay = type;
365
+ applyOverlayVisibility();
366
+ const text = type === 'box'
367
+ ? state.prescriptionLabelSquareGuideText
368
+ : state.prescriptionLabelGuideText;
369
+ state.prescriptionLabelGuide?.setText?.(text);
370
+ },
371
+ }
372
+ );
373
+ }
320
374
  };
321
375
 
322
376
  export const renderCodeStripsOverlayIfNeeded = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "veryfi-lens-wasm",
3
- "version": "3.3.2",
3
+ "version": "3.3.4",
4
4
  "description": "Lens For Web SDK with WASM",
5
5
  "main": "veryfi-lens.js",
6
6
  "type": "module",