@magmamath/students-features 1.7.9 → 1.7.10-rc.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 (154) hide show
  1. package/dist/commonjs/features/voice/constants.js +39 -3
  2. package/dist/commonjs/features/voice/constants.js.map +1 -1
  3. package/dist/commonjs/features/voice/helpers.js +67 -1
  4. package/dist/commonjs/features/voice/helpers.js.map +1 -1
  5. package/dist/commonjs/features/voice/index.js +77 -0
  6. package/dist/commonjs/features/voice/index.js.map +1 -1
  7. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js +17 -9
  8. package/dist/commonjs/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -1
  9. package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js +4 -27
  10. package/dist/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -1
  11. package/dist/commonjs/features/voice/recording/components/VoiceRecordWithTranscript.js +49 -0
  12. package/dist/commonjs/features/voice/recording/components/VoiceRecordWithTranscript.js.map +1 -0
  13. package/dist/commonjs/features/voice/recording/components/VoiceTranscriptPanel.js +245 -0
  14. package/dist/commonjs/features/voice/recording/components/VoiceTranscriptPanel.js.map +1 -0
  15. package/dist/commonjs/features/voice/recording/components/VoiceWaveform.js +93 -0
  16. package/dist/commonjs/features/voice/recording/components/VoiceWaveform.js.map +1 -0
  17. package/dist/commonjs/features/voice/recording/hooks/useTranscriptPanelAnimation.js +42 -0
  18. package/dist/commonjs/features/voice/recording/hooks/useTranscriptPanelAnimation.js.map +1 -0
  19. package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorder.js +17 -2
  20. package/dist/commonjs/features/voice/recording/hooks/useVoiceRecorder.js.map +1 -1
  21. package/dist/commonjs/features/voice/recording/hooks/useVoiceWaveform.js +43 -0
  22. package/dist/commonjs/features/voice/recording/hooks/useVoiceWaveform.js.map +1 -0
  23. package/dist/commonjs/features/voice/recording/model/Recorder.model.js +3 -0
  24. package/dist/commonjs/features/voice/recording/model/Recorder.model.js.map +1 -1
  25. package/dist/commonjs/features/voice/recording/model/VoiceRecordWithTranscript.model.js +83 -0
  26. package/dist/commonjs/features/voice/recording/model/VoiceRecordWithTranscript.model.js.map +1 -0
  27. package/dist/commonjs/features/voice/recording/model/VoiceTranscriptPanel.model.js +65 -0
  28. package/dist/commonjs/features/voice/recording/model/VoiceTranscriptPanel.model.js.map +1 -0
  29. package/dist/commonjs/features/voice/transcript.helpers.js +36 -0
  30. package/dist/commonjs/features/voice/transcript.helpers.js.map +1 -0
  31. package/dist/commonjs/features/voice/types.js +11 -7
  32. package/dist/commonjs/features/voice/types.js.map +1 -1
  33. package/dist/module/features/voice/constants.js +38 -0
  34. package/dist/module/features/voice/constants.js.map +1 -1
  35. package/dist/module/features/voice/helpers.js +65 -1
  36. package/dist/module/features/voice/helpers.js.map +1 -1
  37. package/dist/module/features/voice/index.js +7 -0
  38. package/dist/module/features/voice/index.js.map +1 -1
  39. package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js +15 -9
  40. package/dist/module/features/voice/playing/components/VoiceTranscriptContent.js.map +1 -1
  41. package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js +4 -27
  42. package/dist/module/features/voice/playing/model/TranscriptionsDownloader.model.js.map +1 -1
  43. package/dist/module/features/voice/recording/components/VoiceRecordWithTranscript.js +43 -0
  44. package/dist/module/features/voice/recording/components/VoiceRecordWithTranscript.js.map +1 -0
  45. package/dist/module/features/voice/recording/components/VoiceTranscriptPanel.js +238 -0
  46. package/dist/module/features/voice/recording/components/VoiceTranscriptPanel.js.map +1 -0
  47. package/dist/module/features/voice/recording/components/VoiceWaveform.js +86 -0
  48. package/dist/module/features/voice/recording/components/VoiceWaveform.js.map +1 -0
  49. package/dist/module/features/voice/recording/hooks/useTranscriptPanelAnimation.js +37 -0
  50. package/dist/module/features/voice/recording/hooks/useTranscriptPanelAnimation.js.map +1 -0
  51. package/dist/module/features/voice/recording/hooks/useVoiceRecorder.js +20 -3
  52. package/dist/module/features/voice/recording/hooks/useVoiceRecorder.js.map +1 -1
  53. package/dist/module/features/voice/recording/hooks/useVoiceWaveform.js +38 -0
  54. package/dist/module/features/voice/recording/hooks/useVoiceWaveform.js.map +1 -0
  55. package/dist/module/features/voice/recording/model/Recorder.model.js +3 -0
  56. package/dist/module/features/voice/recording/model/Recorder.model.js.map +1 -1
  57. package/dist/module/features/voice/recording/model/VoiceRecordWithTranscript.model.js +78 -0
  58. package/dist/module/features/voice/recording/model/VoiceRecordWithTranscript.model.js.map +1 -0
  59. package/dist/module/features/voice/recording/model/VoiceTranscriptPanel.model.js +60 -0
  60. package/dist/module/features/voice/recording/model/VoiceTranscriptPanel.model.js.map +1 -0
  61. package/dist/module/features/voice/transcript.helpers.js +31 -0
  62. package/dist/module/features/voice/transcript.helpers.js.map +1 -0
  63. package/dist/module/features/voice/types.js +4 -6
  64. package/dist/module/features/voice/types.js.map +1 -1
  65. package/dist/typescript/commonjs/features/voice/__tests__/VoiceRecordWithTranscript.model.test.d.ts +2 -0
  66. package/dist/typescript/commonjs/features/voice/__tests__/VoiceRecordWithTranscript.model.test.d.ts.map +1 -0
  67. package/dist/typescript/commonjs/features/voice/__tests__/VoiceTranscriptPanel.model.test.d.ts +2 -0
  68. package/dist/typescript/commonjs/features/voice/__tests__/VoiceTranscriptPanel.model.test.d.ts.map +1 -0
  69. package/dist/typescript/commonjs/features/voice/constants.d.ts +32 -0
  70. package/dist/typescript/commonjs/features/voice/constants.d.ts.map +1 -1
  71. package/dist/typescript/commonjs/features/voice/helpers.d.ts +3 -0
  72. package/dist/typescript/commonjs/features/voice/helpers.d.ts.map +1 -1
  73. package/dist/typescript/commonjs/features/voice/index.d.ts +7 -0
  74. package/dist/typescript/commonjs/features/voice/index.d.ts.map +1 -1
  75. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts +2 -1
  76. package/dist/typescript/commonjs/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -1
  77. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +2 -7
  78. package/dist/typescript/commonjs/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -1
  79. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordWithTranscript.d.ts +13 -0
  80. package/dist/typescript/commonjs/features/voice/recording/components/VoiceRecordWithTranscript.d.ts.map +1 -0
  81. package/dist/typescript/commonjs/features/voice/recording/components/VoiceTranscriptPanel.d.ts +11 -0
  82. package/dist/typescript/commonjs/features/voice/recording/components/VoiceTranscriptPanel.d.ts.map +1 -0
  83. package/dist/typescript/commonjs/features/voice/recording/components/VoiceWaveform.d.ts +8 -0
  84. package/dist/typescript/commonjs/features/voice/recording/components/VoiceWaveform.d.ts.map +1 -0
  85. package/dist/typescript/commonjs/features/voice/recording/hooks/useTranscriptPanelAnimation.d.ts +18 -0
  86. package/dist/typescript/commonjs/features/voice/recording/hooks/useTranscriptPanelAnimation.d.ts.map +1 -0
  87. package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceRecorder.d.ts.map +1 -1
  88. package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceWaveform.d.ts +7 -0
  89. package/dist/typescript/commonjs/features/voice/recording/hooks/useVoiceWaveform.d.ts.map +1 -0
  90. package/dist/typescript/commonjs/features/voice/recording/model/Recorder.model.d.ts +2 -0
  91. package/dist/typescript/commonjs/features/voice/recording/model/Recorder.model.d.ts.map +1 -1
  92. package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecordWithTranscript.model.d.ts +16 -0
  93. package/dist/typescript/commonjs/features/voice/recording/model/VoiceRecordWithTranscript.model.d.ts.map +1 -0
  94. package/dist/typescript/commonjs/features/voice/recording/model/VoiceTranscriptPanel.model.d.ts +26 -0
  95. package/dist/typescript/commonjs/features/voice/recording/model/VoiceTranscriptPanel.model.d.ts.map +1 -0
  96. package/dist/typescript/commonjs/features/voice/transcript.helpers.d.ts +8 -0
  97. package/dist/typescript/commonjs/features/voice/transcript.helpers.d.ts.map +1 -0
  98. package/dist/typescript/commonjs/features/voice/types.d.ts +2 -5
  99. package/dist/typescript/commonjs/features/voice/types.d.ts.map +1 -1
  100. package/dist/typescript/module/features/voice/__tests__/VoiceRecordWithTranscript.model.test.d.ts +2 -0
  101. package/dist/typescript/module/features/voice/__tests__/VoiceRecordWithTranscript.model.test.d.ts.map +1 -0
  102. package/dist/typescript/module/features/voice/__tests__/VoiceTranscriptPanel.model.test.d.ts +2 -0
  103. package/dist/typescript/module/features/voice/__tests__/VoiceTranscriptPanel.model.test.d.ts.map +1 -0
  104. package/dist/typescript/module/features/voice/constants.d.ts +32 -0
  105. package/dist/typescript/module/features/voice/constants.d.ts.map +1 -1
  106. package/dist/typescript/module/features/voice/helpers.d.ts +3 -0
  107. package/dist/typescript/module/features/voice/helpers.d.ts.map +1 -1
  108. package/dist/typescript/module/features/voice/index.d.ts +7 -0
  109. package/dist/typescript/module/features/voice/index.d.ts.map +1 -1
  110. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts +2 -1
  111. package/dist/typescript/module/features/voice/playing/components/VoiceTranscriptContent.d.ts.map +1 -1
  112. package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts +2 -7
  113. package/dist/typescript/module/features/voice/playing/model/TranscriptionsDownloader.model.d.ts.map +1 -1
  114. package/dist/typescript/module/features/voice/recording/components/VoiceRecordWithTranscript.d.ts +13 -0
  115. package/dist/typescript/module/features/voice/recording/components/VoiceRecordWithTranscript.d.ts.map +1 -0
  116. package/dist/typescript/module/features/voice/recording/components/VoiceTranscriptPanel.d.ts +11 -0
  117. package/dist/typescript/module/features/voice/recording/components/VoiceTranscriptPanel.d.ts.map +1 -0
  118. package/dist/typescript/module/features/voice/recording/components/VoiceWaveform.d.ts +8 -0
  119. package/dist/typescript/module/features/voice/recording/components/VoiceWaveform.d.ts.map +1 -0
  120. package/dist/typescript/module/features/voice/recording/hooks/useTranscriptPanelAnimation.d.ts +18 -0
  121. package/dist/typescript/module/features/voice/recording/hooks/useTranscriptPanelAnimation.d.ts.map +1 -0
  122. package/dist/typescript/module/features/voice/recording/hooks/useVoiceRecorder.d.ts.map +1 -1
  123. package/dist/typescript/module/features/voice/recording/hooks/useVoiceWaveform.d.ts +7 -0
  124. package/dist/typescript/module/features/voice/recording/hooks/useVoiceWaveform.d.ts.map +1 -0
  125. package/dist/typescript/module/features/voice/recording/model/Recorder.model.d.ts +2 -0
  126. package/dist/typescript/module/features/voice/recording/model/Recorder.model.d.ts.map +1 -1
  127. package/dist/typescript/module/features/voice/recording/model/VoiceRecordWithTranscript.model.d.ts +16 -0
  128. package/dist/typescript/module/features/voice/recording/model/VoiceRecordWithTranscript.model.d.ts.map +1 -0
  129. package/dist/typescript/module/features/voice/recording/model/VoiceTranscriptPanel.model.d.ts +26 -0
  130. package/dist/typescript/module/features/voice/recording/model/VoiceTranscriptPanel.model.d.ts.map +1 -0
  131. package/dist/typescript/module/features/voice/transcript.helpers.d.ts +8 -0
  132. package/dist/typescript/module/features/voice/transcript.helpers.d.ts.map +1 -0
  133. package/dist/typescript/module/features/voice/types.d.ts +2 -5
  134. package/dist/typescript/module/features/voice/types.d.ts.map +1 -1
  135. package/package.json +1 -1
  136. package/src/features/voice/__tests__/VoiceRecordWithTranscript.model.test.ts +145 -0
  137. package/src/features/voice/__tests__/VoiceTranscriptPanel.model.test.ts +135 -0
  138. package/src/features/voice/constants.ts +40 -0
  139. package/src/features/voice/helpers.ts +85 -1
  140. package/src/features/voice/index.ts +7 -0
  141. package/src/features/voice/playing/components/VoiceTranscriptContent.tsx +16 -8
  142. package/src/features/voice/playing/model/TranscriptionsDownloader.model.ts +8 -30
  143. package/src/features/voice/recording/components/VoiceRecordWithTranscript.tsx +52 -0
  144. package/src/features/voice/recording/components/VoiceTranscriptPanel.tsx +285 -0
  145. package/src/features/voice/recording/components/VoiceWaveform.tsx +102 -0
  146. package/src/features/voice/recording/hooks/useTranscriptPanelAnimation.ts +49 -0
  147. package/src/features/voice/recording/hooks/useVoiceRecorder.ts +26 -3
  148. package/src/features/voice/recording/hooks/useVoiceWaveform.ts +46 -0
  149. package/src/features/voice/recording/model/Recorder.model.ts +3 -0
  150. package/src/features/voice/recording/model/VoiceRecordWithTranscript.model.ts +81 -0
  151. package/src/features/voice/recording/model/VoiceTranscriptPanel.model.ts +76 -0
  152. package/src/features/voice/transcript.helpers.ts +37 -0
  153. package/src/features/voice/types.ts +5 -6
  154. package/src/i18n/.generated/schema.json +6 -5
@@ -0,0 +1,245 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VoiceTranscriptPanel = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeUi = require("@magmamath/react-native-ui");
10
+ var _effectorReact = require("effector-react");
11
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
12
+ var _i18n = require("../../../../i18n/i18n.js");
13
+ var _constants = require("../../constants.js");
14
+ var _VoiceTranscriptContent = require("../../playing/components/VoiceTranscriptContent.js");
15
+ var _useTranscriptPanelAnimation = require("../hooks/useTranscriptPanelAnimation.js");
16
+ var _useVoiceWaveform = require("../hooks/useVoiceWaveform.js");
17
+ var _VoiceWaveform = require("./VoiceWaveform.js");
18
+ var _jsxRuntime = require("react/jsx-runtime");
19
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
20
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
21
+ const AnimatedTouchableOpacity = _reactNativeReanimated.default.createAnimatedComponent(_reactNative.TouchableOpacity);
22
+ const RECORDING_DOT_SIZE = 8;
23
+ const BLINK_DURATION_MS = 700;
24
+ const RECORDING_DOT_MIN_OPACITY = 0.2;
25
+ const CARET_SIZE = 22;
26
+ const PREVIEW_LINE_COUNT = 3;
27
+ // Cosmetic only (fade overlay height) — roughly the Typography h8 line height
28
+ const PREVIEW_LINE_HEIGHT = 19.6;
29
+ const PREVIEW_FADE_WIDTH = 72;
30
+ const PREVIEW_FADE_STRIPES_COUNT = 12;
31
+ // Rounding slack when comparing the two measured text heights
32
+ const PREVIEW_HEIGHT_TOLERANCE = 2;
33
+ const WAVEFORM_WIDTH = _constants.VOICE_TRANSCRIPT_PANEL.WIDTH - _reactNativeUi.SPACING[200] * 2 - RECORDING_DOT_SIZE - _reactNativeUi.SPACING[200];
34
+ const RecordingDot = () => {
35
+ const opacity = (0, _reactNativeReanimated.useSharedValue)(1);
36
+ (0, _react.useEffect)(() => {
37
+ opacity.value = (0, _reactNativeReanimated.withRepeat)((0, _reactNativeReanimated.withTiming)(RECORDING_DOT_MIN_OPACITY, {
38
+ duration: BLINK_DURATION_MS,
39
+ easing: _reactNativeReanimated.Easing.inOut(_reactNativeReanimated.Easing.ease)
40
+ }), -1, true);
41
+ }, [opacity]);
42
+
43
+ // Explicit deps: consumers compile this library without the Reanimated Babel plugin
44
+ const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
45
+ opacity: opacity.value
46
+ }), [opacity]);
47
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
48
+ style: [styles.recordingDot, animatedStyle]
49
+ });
50
+ };
51
+
52
+ // Stripes of the panel background with rising opacity imitate the text
53
+ // dissolving at the end of the last preview line (no gradient dependency)
54
+ const PreviewLineFade = () => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
55
+ style: styles.previewFade,
56
+ pointerEvents: "none",
57
+ children: Array.from({
58
+ length: PREVIEW_FADE_STRIPES_COUNT
59
+ }, (_, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
60
+ style: [styles.previewFadeStripe, {
61
+ opacity: (index + 1) / PREVIEW_FADE_STRIPES_COUNT
62
+ }]
63
+ }, index))
64
+ });
65
+ const VoiceTranscriptPanel = ({
66
+ model,
67
+ metering,
68
+ style
69
+ }) => {
70
+ const t = (0, _i18n.useText)();
71
+ const {
72
+ flags,
73
+ transcript,
74
+ hasError,
75
+ isExpanded
76
+ } = (0, _effectorReact.useUnit)({
77
+ flags: model.$flags,
78
+ transcript: model.$transcript,
79
+ hasError: model.$hasError,
80
+ isExpanded: model.dropdown.$isExpanded
81
+ });
82
+ const [fullTextHeight, setFullTextHeight] = (0, _react.useState)(0);
83
+ const [previewHeight, setPreviewHeight] = (0, _react.useState)(0);
84
+ const levels = (0, _useVoiceWaveform.useVoiceWaveform)({
85
+ metering,
86
+ isActive: flags.isRecording
87
+ });
88
+ const panelAnimation = (0, _useTranscriptPanelAnimation.useTranscriptPanelAnimation)(isExpanded);
89
+ if (!flags.isOpen) return null;
90
+ const transcriptText = hasError ? t('voice.transcriptNotAvailable') : transcript;
91
+
92
+ // Both heights are measured, so the comparison stays correct regardless of
93
+ // the text's font metrics or paddings
94
+ const isTruncated = fullTextHeight > 0 && previewHeight > 0 && fullTextHeight > previewHeight + PREVIEW_HEIGHT_TOLERANCE;
95
+ const measureFullText = event => {
96
+ const {
97
+ height
98
+ } = event.nativeEvent.layout;
99
+ if (height > 0) setFullTextHeight(height);
100
+ };
101
+ const measurePreview = event => {
102
+ const {
103
+ height
104
+ } = event.nativeEvent.layout;
105
+ // Expanded shows the full text — only the collapsed (3-line) layout counts
106
+ if (height > 0 && !isExpanded) setPreviewHeight(height);
107
+ };
108
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNativeReanimated.default.View, {
109
+ entering: _reactNativeReanimated.FadeIn,
110
+ style: [styles.container, panelAnimation.containerAnimatedStyle, style],
111
+ children: [flags.isRecording && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
112
+ style: styles.recordingRow,
113
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(RecordingDot, {}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_VoiceWaveform.VoiceWaveform, {
114
+ levels: levels,
115
+ width: WAVEFORM_WIDTH
116
+ })]
117
+ }), flags.isProcessing && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
118
+ style: styles.processing,
119
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeUi.Loader, {
120
+ size: _reactNativeUi.LoaderSize.SMALL,
121
+ color: _reactNativeUi.LoaderColor.BLUE
122
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeUi.Typography, {
123
+ variant: "h8",
124
+ style: styles.processingText,
125
+ children: `${t('voice.preparingTranscript')}...`
126
+ })]
127
+ }), flags.isDone && /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
128
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
129
+ style: [styles.contentCollapsed, styles.fullTextMeasure],
130
+ pointerEvents: "none",
131
+ onLayout: measureFullText,
132
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_VoiceTranscriptContent.VoiceTranscriptContent, {
133
+ text: transcriptText,
134
+ isLoading: false
135
+ })
136
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeUi.Typography, {
137
+ variant: "h5",
138
+ style: styles.title,
139
+ children: t('voice.transcriptions')
140
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
141
+ style: [styles.transcriptBody, panelAnimation.bodyAnimatedStyle],
142
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
143
+ style: [styles.transcriptBodyInner, isExpanded ? styles.contentExpanded : styles.contentCollapsed],
144
+ onLayout: panelAnimation.onContentLayout,
145
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeUi.ScrollableListScrollView, {
146
+ style: styles.transcriptScroll,
147
+ scrollbarWidth: _constants.VOICE_TRANSCRIPT_PANEL.SCROLLBAR_WIDTH,
148
+ scrollEnabled: isExpanded,
149
+ hideShadow: true,
150
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
151
+ onLayout: measurePreview,
152
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_VoiceTranscriptContent.VoiceTranscriptContent, {
153
+ text: transcriptText,
154
+ isLoading: false,
155
+ numberOfLines: isExpanded ? undefined : PREVIEW_LINE_COUNT
156
+ })
157
+ })
158
+ }), !isExpanded && isTruncated && /*#__PURE__*/(0, _jsxRuntime.jsx)(PreviewLineFade, {})]
159
+ })
160
+ }), isTruncated && /*#__PURE__*/(0, _jsxRuntime.jsx)(AnimatedTouchableOpacity, {
161
+ style: [styles.expandButton, panelAnimation.caretAnimatedStyle],
162
+ onPress: () => model.dropdown.toggleExpand(),
163
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeUi.CaretDownIcon, {
164
+ size: CARET_SIZE
165
+ })
166
+ })]
167
+ })]
168
+ });
169
+ };
170
+ exports.VoiceTranscriptPanel = VoiceTranscriptPanel;
171
+ const styles = _reactNative.StyleSheet.create({
172
+ container: {
173
+ padding: _reactNativeUi.SPACING[200],
174
+ borderRadius: _reactNativeUi.BORDER_RADIUS[300],
175
+ backgroundColor: _reactNativeUi.COLORS.NEUTRAL_1,
176
+ overflow: 'hidden',
177
+ ..._reactNativeUi.SHADOWS['4']
178
+ },
179
+ recordingRow: {
180
+ flexDirection: 'row',
181
+ alignItems: 'center',
182
+ gap: _reactNativeUi.SPACING[200]
183
+ },
184
+ recordingDot: {
185
+ width: RECORDING_DOT_SIZE,
186
+ height: RECORDING_DOT_SIZE,
187
+ borderRadius: RECORDING_DOT_SIZE / 2,
188
+ backgroundColor: _reactNativeUi.COLORS.PRIMARY_RED
189
+ },
190
+ title: {
191
+ color: _reactNativeUi.COLORS.NEUTRAL_10,
192
+ marginLeft: _reactNativeUi.SPACING[100]
193
+ },
194
+ transcriptBody: {
195
+ overflow: 'hidden'
196
+ },
197
+ // Absolute so its measured height stays the content's natural height,
198
+ // independent of the animated wrapper height around it
199
+ transcriptBodyInner: {
200
+ position: 'absolute',
201
+ top: 0,
202
+ left: 0
203
+ },
204
+ // Fixed per-state widths: the text snaps to its final layout once while the
205
+ // panel frame animates around it
206
+ contentCollapsed: {
207
+ width: _constants.VOICE_TRANSCRIPT_PANEL.WIDTH - _reactNativeUi.SPACING[200] * 2
208
+ },
209
+ fullTextMeasure: {
210
+ position: 'absolute',
211
+ opacity: 0
212
+ },
213
+ contentExpanded: {
214
+ width: _constants.VOICE_TRANSCRIPT_PANEL.WIDTH_DONE - _reactNativeUi.SPACING[200] * 2
215
+ },
216
+ transcriptScroll: {
217
+ maxHeight: _constants.VOICE_TRANSCRIPT_PANEL.TRANSCRIPT_MAX_HEIGHT
218
+ },
219
+ previewFade: {
220
+ position: 'absolute',
221
+ right: _reactNativeUi.SPACING[200],
222
+ bottom: _reactNativeUi.SPACING[100],
223
+ width: PREVIEW_FADE_WIDTH,
224
+ height: PREVIEW_LINE_HEIGHT,
225
+ flexDirection: 'row'
226
+ },
227
+ previewFadeStripe: {
228
+ flex: 1,
229
+ backgroundColor: _reactNativeUi.COLORS.NEUTRAL_1
230
+ },
231
+ expandButton: {
232
+ justifyContent: 'center',
233
+ alignItems: 'center'
234
+ },
235
+ processing: {
236
+ alignItems: 'center',
237
+ justifyContent: 'center',
238
+ gap: _reactNativeUi.SPACING[200],
239
+ paddingVertical: _reactNativeUi.SPACING[200]
240
+ },
241
+ processingText: {
242
+ color: _reactNativeUi.COLORS.NEUTRAL_7
243
+ }
244
+ });
245
+ //# sourceMappingURL=VoiceTranscriptPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeUi","_effectorReact","_reactNativeReanimated","_i18n","_constants","_VoiceTranscriptContent","_useTranscriptPanelAnimation","_useVoiceWaveform","_VoiceWaveform","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","AnimatedTouchableOpacity","Animated","createAnimatedComponent","TouchableOpacity","RECORDING_DOT_SIZE","BLINK_DURATION_MS","RECORDING_DOT_MIN_OPACITY","CARET_SIZE","PREVIEW_LINE_COUNT","PREVIEW_LINE_HEIGHT","PREVIEW_FADE_WIDTH","PREVIEW_FADE_STRIPES_COUNT","PREVIEW_HEIGHT_TOLERANCE","WAVEFORM_WIDTH","VOICE_TRANSCRIPT_PANEL","WIDTH","SPACING","RecordingDot","opacity","useSharedValue","useEffect","value","withRepeat","withTiming","duration","easing","Easing","inOut","ease","animatedStyle","useAnimatedStyle","jsx","View","style","styles","recordingDot","PreviewLineFade","previewFade","pointerEvents","children","Array","from","length","_","index","previewFadeStripe","VoiceTranscriptPanel","model","metering","useText","flags","transcript","hasError","isExpanded","useUnit","$flags","$transcript","$hasError","dropdown","$isExpanded","fullTextHeight","setFullTextHeight","useState","previewHeight","setPreviewHeight","levels","useVoiceWaveform","isActive","isRecording","panelAnimation","useTranscriptPanelAnimation","isOpen","transcriptText","isTruncated","measureFullText","event","height","nativeEvent","layout","measurePreview","jsxs","entering","FadeIn","container","containerAnimatedStyle","recordingRow","VoiceWaveform","width","isProcessing","processing","Loader","size","LoaderSize","SMALL","color","LoaderColor","BLUE","Typography","variant","processingText","isDone","contentCollapsed","fullTextMeasure","onLayout","VoiceTranscriptContent","text","isLoading","title","transcriptBody","bodyAnimatedStyle","transcriptBodyInner","contentExpanded","onContentLayout","ScrollableListScrollView","transcriptScroll","scrollbarWidth","SCROLLBAR_WIDTH","scrollEnabled","hideShadow","numberOfLines","undefined","expandButton","caretAnimatedStyle","onPress","toggleExpand","CaretDownIcon","exports","StyleSheet","create","padding","borderRadius","BORDER_RADIUS","backgroundColor","COLORS","NEUTRAL_1","overflow","SHADOWS","flexDirection","alignItems","gap","PRIMARY_RED","NEUTRAL_10","marginLeft","position","top","left","WIDTH_DONE","maxHeight","TRANSCRIPT_MAX_HEIGHT","right","bottom","flex","justifyContent","paddingVertical","NEUTRAL_7"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/components/VoiceTranscriptPanel.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AASA,IAAAE,cAAA,GAAAF,OAAA;AAYA,IAAAG,cAAA,GAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAL,uBAAA,CAAAC,OAAA;AASA,IAAAK,KAAA,GAAAL,OAAA;AACA,IAAAM,UAAA,GAAAN,OAAA;AACA,IAAAO,uBAAA,GAAAP,OAAA;AACA,IAAAQ,4BAAA,GAAAR,OAAA;AACA,IAAAS,iBAAA,GAAAT,OAAA;AAEA,IAAAU,cAAA,GAAAV,OAAA;AAA+C,IAAAW,WAAA,GAAAX,OAAA;AAAA,SAAAY,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAd,wBAAAc,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA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AAe,EAAEC,qBAAM,CAACC;EAC1B,CAAC;EACDb,YAAY,EAAE;IACZ+B,cAAc,EAAE,QAAQ;IACxBd,UAAU,EAAE;EACd,CAAC;EACDjD,UAAU,EAAE;IACViD,UAAU,EAAE,QAAQ;IACpBc,cAAc,EAAE,QAAQ;IACxBb,GAAG,EAAE3H,sBAAO,CAAC,GAAG,CAAC;IACjByI,eAAe,EAAEzI,sBAAO,CAAC,GAAG;EAC9B,CAAC;EACDmF,cAAc,EAAE;IACdL,KAAK,EAAEuC,qBAAM,CAACqB;EAChB;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,93 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VoiceWaveform = void 0;
7
+ var _react = _interopRequireWildcard(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _reactNativeUi = require("@magmamath/react-native-ui");
10
+ var _reactNativeReanimated = _interopRequireWildcard(require("react-native-reanimated"));
11
+ var _constants = require("../../constants.js");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ const BAR_STEP = _constants.VOICE_WAVEFORM.BAR_WIDTH + _constants.VOICE_WAVEFORM.BAR_GAP;
16
+ // One extra bar is rendered off-screen on the right and slides in as the row
17
+ // shifts — that is what makes the scroll continuous instead of stepping
18
+ const OFFSCREEN_BARS = 1;
19
+ const getVisibleBarsCount = width => {
20
+ const barsForWidth = Math.floor(width / BAR_STEP);
21
+ return Math.max(_constants.VOICE_WAVEFORM.MIN_BARS, barsForWidth);
22
+ };
23
+ const getBarHeight = level => Math.max(_constants.VOICE_WAVEFORM.MIN_BAR_HEIGHT, Math.round(level * (_constants.VOICE_WAVEFORM.HEIGHT - _constants.VOICE_WAVEFORM.AMPLITUDE_PADDING)));
24
+
25
+ // Older bars (toward the left) fade out, mirroring the dotted lead-in in the
26
+ // design. Opacity ramps from 0 up to full across the first FADE_RATIO of bars.
27
+ const getBarOpacity = (index, count) => {
28
+ const fadeBars = count * _constants.VOICE_WAVEFORM.FADE_RATIO;
29
+ return Math.min(1, index / fadeBars);
30
+ };
31
+ const VoiceWaveform = ({
32
+ levels,
33
+ width
34
+ }) => {
35
+ const count = getVisibleBarsCount(width);
36
+ const visibleLevels = levels.slice(-(count + OFFSCREEN_BARS));
37
+
38
+ // Conveyor-belt motion: each new sample shifts the buffer one slot left and
39
+ // snaps the row back, then the row glides left by one step until the next
40
+ // sample lands — the two cancel out into continuous movement.
41
+ const shift = (0, _reactNativeReanimated.useSharedValue)(0);
42
+ (0, _react.useEffect)(() => {
43
+ shift.value = 0;
44
+ shift.value = (0, _reactNativeReanimated.withTiming)(-BAR_STEP, {
45
+ duration: _constants.VOICE_WAVEFORM.SAMPLE_INTERVAL_MS,
46
+ easing: _reactNativeReanimated.Easing.linear
47
+ });
48
+ }, [levels, shift]);
49
+
50
+ // Explicit deps: consumers compile this library without the Reanimated Babel plugin
51
+ const rowAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
52
+ transform: [{
53
+ translateX: shift.value
54
+ }]
55
+ }), [shift]);
56
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
57
+ style: [styles.container, {
58
+ width
59
+ }],
60
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNativeReanimated.default.View, {
61
+ style: [styles.row, rowAnimatedStyle],
62
+ children: visibleLevels.map((level, index) => /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
63
+ style: [styles.bar, {
64
+ height: getBarHeight(level),
65
+ opacity: getBarOpacity(index, visibleLevels.length)
66
+ }]
67
+ }, index))
68
+ })
69
+ });
70
+ };
71
+ exports.VoiceWaveform = VoiceWaveform;
72
+ const styles = _reactNative.StyleSheet.create({
73
+ container: {
74
+ height: _constants.VOICE_WAVEFORM.HEIGHT,
75
+ overflow: 'hidden'
76
+ },
77
+ // Hangs one step past the right edge so the newest bar starts hidden
78
+ row: {
79
+ position: 'absolute',
80
+ top: 0,
81
+ bottom: 0,
82
+ right: -BAR_STEP,
83
+ flexDirection: 'row',
84
+ alignItems: 'center',
85
+ gap: _constants.VOICE_WAVEFORM.BAR_GAP
86
+ },
87
+ bar: {
88
+ width: _constants.VOICE_WAVEFORM.BAR_WIDTH,
89
+ borderRadius: _constants.VOICE_WAVEFORM.BAR_WIDTH / 2,
90
+ backgroundColor: _reactNativeUi.COLORS.NEUTRAL_7
91
+ }
92
+ });
93
+ //# sourceMappingURL=VoiceWaveform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_reactNativeUi","_reactNativeReanimated","_constants","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","BAR_STEP","VOICE_WAVEFORM","BAR_WIDTH","BAR_GAP","OFFSCREEN_BARS","getVisibleBarsCount","width","barsForWidth","Math","floor","max","MIN_BARS","getBarHeight","level","MIN_BAR_HEIGHT","round","HEIGHT","AMPLITUDE_PADDING","getBarOpacity","index","count","fadeBars","FADE_RATIO","min","VoiceWaveform","levels","visibleLevels","slice","shift","useSharedValue","useEffect","value","withTiming","duration","SAMPLE_INTERVAL_MS","easing","Easing","linear","rowAnimatedStyle","useAnimatedStyle","transform","translateX","jsx","View","style","styles","container","children","row","map","bar","height","opacity","length","exports","StyleSheet","create","overflow","position","top","bottom","right","flexDirection","alignItems","gap","borderRadius","backgroundColor","COLORS","NEUTRAL_7"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/components/VoiceWaveform.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAJ,uBAAA,CAAAC,OAAA;AAOA,IAAAI,UAAA,GAAAJ,OAAA;AAAgD,IAAAK,WAAA,GAAAL,OAAA;AAAA,SAAAM,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAR,wBAAAQ,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CA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X,CAAC;AAAAmC,OAAA,CAAA9B,aAAA,GAAAA,aAAA;AAED,MAAMqB,MAAM,GAAGU,uBAAU,CAACC,MAAM,CAAC;EAC/BV,SAAS,EAAE;IACTK,MAAM,EAAElD,yBAAc,CAACe,MAAM;IAC7ByC,QAAQ,EAAE;EACZ,CAAC;EACD;EACAT,GAAG,EAAE;IACHU,QAAQ,EAAE,UAAU;IACpBC,GAAG,EAAE,CAAC;IACNC,MAAM,EAAE,CAAC;IACTC,KAAK,EAAE,CAAC7D,QAAQ;IAChB8D,aAAa,EAAE,KAAK;IACpBC,UAAU,EAAE,QAAQ;IACpBC,GAAG,EAAE/D,yBAAc,CAACE;EACtB,CAAC;EACD+C,GAAG,EAAE;IACH5C,KAAK,EAAEL,yBAAc,CAACC,SAAS;IAC/B+D,YAAY,EAAEhE,yBAAc,CAACC,SAAS,GAAG,CAAC;IAC1CgE,eAAe,EAAEC,qBAAM,CAACC;EAC1B;AACF,CAAC,CAAC","ignoreList":[]}
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useTranscriptPanelAnimation = void 0;
7
+ var _reactNativeReanimated = require("react-native-reanimated");
8
+ var _constants = require("../../constants.js");
9
+ const TIMING = {
10
+ duration: 170
11
+ };
12
+
13
+ // Width and height are animated as explicit numbers instead of reanimated
14
+ // layout transitions: on web those run as FLIP animations that scale the
15
+ // subtree, visibly stretching the text while the panel resizes.
16
+ const useTranscriptPanelAnimation = isExpanded => {
17
+ const contentHeight = (0, _reactNativeReanimated.useSharedValue)(0);
18
+ const onContentLayout = event => {
19
+ const height = event.nativeEvent.layout.height;
20
+ if (height <= 0) return;
21
+ contentHeight.value = contentHeight.value === 0 ? height : (0, _reactNativeReanimated.withTiming)(height, TIMING);
22
+ };
23
+ const containerAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
24
+ width: (0, _reactNativeReanimated.withTiming)(isExpanded ? _constants.VOICE_TRANSCRIPT_PANEL.WIDTH_DONE : _constants.VOICE_TRANSCRIPT_PANEL.WIDTH, TIMING)
25
+ }), [isExpanded]);
26
+ const bodyAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => contentHeight.value === 0 ? {} : {
27
+ height: contentHeight.value
28
+ }, [contentHeight]);
29
+ const caretAnimatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => ({
30
+ transform: [{
31
+ rotate: (0, _reactNativeReanimated.withTiming)(isExpanded ? '180deg' : '0deg', TIMING)
32
+ }]
33
+ }), [isExpanded]);
34
+ return {
35
+ onContentLayout,
36
+ containerAnimatedStyle,
37
+ bodyAnimatedStyle,
38
+ caretAnimatedStyle
39
+ };
40
+ };
41
+ exports.useTranscriptPanelAnimation = useTranscriptPanelAnimation;
42
+ //# sourceMappingURL=useTranscriptPanelAnimation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_reactNativeReanimated","require","_constants","TIMING","duration","useTranscriptPanelAnimation","isExpanded","contentHeight","useSharedValue","onContentLayout","event","height","nativeEvent","layout","value","withTiming","containerAnimatedStyle","useAnimatedStyle","width","VOICE_TRANSCRIPT_PANEL","WIDTH_DONE","WIDTH","bodyAnimatedStyle","caretAnimatedStyle","transform","rotate","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/hooks/useTranscriptPanelAnimation.ts"],"mappings":";;;;;;AAEA,IAAAA,sBAAA,GAAAC,OAAA;AAMA,IAAAC,UAAA,GAAAD,OAAA;AAEA,MAAME,MAAM,GAAG;EAAEC,QAAQ,EAAE;AAAI,CAAU;;AAEzC;AACA;AACA;AACO,MAAMC,2BAA2B,GAAIC,UAAmB,IAAK;EAClE,MAAMC,aAAa,GAAG,IAAAC,qCAAc,EAAC,CAAC,CAAC;EAEvC,MAAMC,eAAe,GAAIC,KAAwB,IAAK;IACpD,MAAMC,MAAM,GAAGD,KAAK,CAACE,WAAW,CAACC,MAAM,CAACF,MAAM;IAC9C,IAAIA,MAAM,IAAI,CAAC,EAAE;IACjBJ,aAAa,CAACO,KAAK,GACjBP,aAAa,CAACO,KAAK,KAAK,CAAC,GAAGH,MAAM,GAAG,IAAAI,iCAAU,EAACJ,MAAM,EAAER,MAAM,CAAC;EACnE,CAAC;EAED,MAAMa,sBAAsB,GAAG,IAAAC,uCAAgB,EAC7C,OAAO;IACLC,KAAK,EAAE,IAAAH,iCAAU,EACfT,UAAU,GAAGa,iCAAsB,CAACC,UAAU,GAAGD,iCAAsB,CAACE,KAAK,EAC7ElB,MACF;EACF,CAAC,CAAC,EACF,CAACG,UAAU,CACb,CAAC;EAED,MAAMgB,iBAAiB,GAAG,IAAAL,uCAAgB,EACxC,MAAOV,aAAa,CAACO,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG;IAAEH,MAAM,EAAEJ,aAAa,CAACO;EAAM,CAAE,EACxE,CAACP,aAAa,CAChB,CAAC;EAED,MAAMgB,kBAAkB,GAAG,IAAAN,uCAAgB,EACzC,OAAO;IACLO,SAAS,EAAE,CAAC;MAAEC,MAAM,EAAE,IAAAV,iCAAU,EAACT,UAAU,GAAG,QAAQ,GAAG,MAAM,EAAEH,MAAM;IAAE,CAAC;EAC5E,CAAC,CAAC,EACF,CAACG,UAAU,CACb,CAAC;EAED,OAAO;IAAEG,eAAe;IAAEO,sBAAsB;IAAEM,iBAAiB;IAAEC;EAAmB,CAAC;AAC3F,CAAC;AAAAG,OAAA,CAAArB,2BAAA,GAAAA,2BAAA","ignoreList":[]}
@@ -9,9 +9,24 @@ var _react = require("react");
9
9
  var _reactNativeUi = require("@magmamath/react-native-ui");
10
10
  var _constants = require("../../constants.js");
11
11
  var _helpers = require("../../helpers.js");
12
+ // Metering powers the live recording waveform (recorderState.metering).
13
+ // Only native respects it — on web the level is measured by
14
+ // createWebMeteringMonitor instead.
15
+ const RECORDING_OPTIONS = {
16
+ ..._expoAudio.RecordingPresets.LOW_QUALITY,
17
+ isMeteringEnabled: true
18
+ };
12
19
  const useVoiceRecorder = model => {
13
- const recorder = (0, _expoAudio.useAudioRecorder)(_expoAudio.RecordingPresets.LOW_QUALITY, model.recordingStatusUpdate);
14
- const recorderState = (0, _expoAudio.useAudioRecorderState)(recorder);
20
+ const recorder = (0, _expoAudio.useAudioRecorder)(RECORDING_OPTIONS, model.recordingStatusUpdate);
21
+ const recorderState = (0, _expoAudio.useAudioRecorderState)(recorder, _constants.METERING_UPDATE_INTERVAL_MS);
22
+ (0, _react.useEffect)(() => {
23
+ if (_reactNativeUi.IS_WEB) return;
24
+ model.recorderModel.setMetering(recorderState.metering ?? null);
25
+ }, [recorderState.metering, model.recorderModel]);
26
+ (0, _react.useEffect)(() => {
27
+ if (!_reactNativeUi.IS_WEB || !recorderState.isRecording) return;
28
+ return (0, _helpers.createWebMeteringMonitor)(recorder, model.recorderModel.setMetering);
29
+ }, [recorderState.isRecording, recorder, model.recorderModel]);
15
30
  (0, _react.useEffect)(() => {
16
31
  if (recorderState.durationMillis >= _constants.VOICE_RECORDER_MAX_DURATION_MS && recorderState.isRecording) {
17
32
  model.recorderModel.stop();
@@ -1 +1 @@
1
- {"version":3,"names":["_expoAudio","require","_react","_reactNativeUi","_constants","_helpers","useVoiceRecorder","model","recorder","useAudioRecorder","RecordingPresets","LOW_QUALITY","recordingStatusUpdate","recorderState","useAudioRecorderState","useEffect","durationMillis","VOICE_RECORDER_MAX_DURATION_MS","isRecording","recorderModel","stop","setLastKnownDurationMs","IS_WEB","getAvailableInputs","then","inputs","setAvailableInputs","removeListener","addAudioInputsListenerWeb","devices","setVoiceRecordState","VoiceRecorderState","RECORDING","PAUSED","IDLE","reset","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/hooks/useVoiceRecorder.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;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AAE;MACpCT,KAAK,CAACY,aAAa,CAACW,mBAAmB,CAACC,6BAAkB,CAACE,MAAM,CAAC;MAClE;IACF;IACA1B,KAAK,CAACY,aAAa,CAACW,mBAAmB,CAACC,6BAAkB,CAACG,IAAI,CAAC;IAEhE,OAAO,MAAM;MACX3B,KAAK,CAACY,aAAa,CAACgB,KAAK,CAAC,CAAC;IAC7B,CAAC;EACH,CAAC,EAAE,CAACtB,aAAa,EAAEN,KAAK,CAACY,aAAa,CAAC,CAAC;EAExC,IAAAJ,gBAAS,EAAC,MAAM;IACdR,KAAK,CAACY,aAAa,CAACX,QAAQ,GAAGA,QAAQ;EACzC,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;EAEd,OAAO;IAAEK;EAAc,CAAC;AAC1B,CAAC;AAAAuB,OAAA,CAAA9B,gBAAA,GAAAA,gBAAA","ignoreList":[]}
1
+ {"version":3,"names":["_expoAudio","require","_react","_reactNativeUi","_constants","_helpers","RECORDING_OPTIONS","RecordingPresets","LOW_QUALITY","isMeteringEnabled","useVoiceRecorder","model","recorder","useAudioRecorder","recordingStatusUpdate","recorderState","useAudioRecorderState","METERING_UPDATE_INTERVAL_MS","useEffect","IS_WEB","recorderModel","setMetering","metering","isRecording","createWebMeteringMonitor","durationMillis","VOICE_RECORDER_MAX_DURATION_MS","stop","setLastKnownDurationMs","getAvailableInputs","then","inputs","setAvailableInputs","removeListener","addAudioInputsListenerWeb","devices","setVoiceRecordState","VoiceRecorderState","RECORDING","PAUSED","IDLE","reset","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/hooks/useVoiceRecorder.ts"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AAEA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,cAAA,GAAAF,OAAA;AACA,IAAAG,UAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AAOA;AACA;AACA;AACA,MAAMK,iBAAiB,GAAG;EACxB,GAAGC,2BAAg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AQ,CAAC,CAACkB,IAAI,CAAEC,MAAM,IAAK;QAC5CpB,KAAK,CAACS,aAAa,CAACY,kBAAkB,CAACD,MAAM,CAAC;MAChD,CAAC,CAAC;MACF;IACF;IAEA,MAAME,cAAc,GAAG,IAAAC,kCAAyB,EAAEC,OAAO,IAAK;MAC5DxB,KAAK,CAACS,aAAa,CAACY,kBAAkB,CAACG,OAAO,CAAC;IACjD,CAAC,CAAC;IAEF,OAAOF,cAAc;EACvB,CAAC,EAAE,CAACrB,QAAQ,EAAED,KAAK,CAACS,aAAa,CAAC,CAAC;EAEnC,IAAAF,gBAAS,EAAC,MAAM;IACd,IAAIH,aAAa,CAACQ,WAAW,EAAE;MAC7BZ,KAAK,CAACS,aAAa,CAACgB,mBAAmB,CAACC,6BAAkB,CAACC,SAAS,CAAC;MACrE;IACF;IACA,IAAIvB,aAAa,CAACU,cAAc,GAAG,CAAC,EAAE;MACpCd,KAAK,CAACS,aAAa,CAACgB,mBAAmB,CAACC,6BAAkB,CAACE,MAAM,CAAC;MAClE;IACF;IACA5B,KAAK,CAACS,aAAa,CAACgB,mBAAmB,CAACC,6BAAkB,CAACG,IAAI,CAAC;IAEhE,OAAO,MAAM;MACX7B,KAAK,CAACS,aAAa,CAACqB,KAAK,CAAC,CAAC;IAC7B,CAAC;EACH,CAAC,EAAE,CAAC1B,aAAa,EAAEJ,KAAK,CAACS,aAAa,CAAC,CAAC;EAExC,IAAAF,gBAAS,EAAC,MAAM;IACdP,KAAK,CAACS,aAAa,CAACR,QAAQ,GAAGA,QAAQ;EACzC,CAAC,EAAE,CAACA,QAAQ,CAAC,CAAC;EAEd,OAAO;IAAEG;EAAc,CAAC;AAC1B,CAAC;AAAA2B,OAAA,CAAAhC,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useVoiceWaveform = void 0;
7
+ var _react = require("react");
8
+ var _constants = require("../../constants.js");
9
+ var _helpers = require("../../helpers.js");
10
+ const createSilentBuffer = () => new Array(_constants.VOICE_WAVEFORM.BUFFER_SIZE).fill(_constants.VOICE_WAVEFORM.MIN_LEVEL);
11
+
12
+ // Keeps a rolling buffer of normalized levels that scrolls right-to-left while
13
+ // recording. We sample on a fixed interval (rather than on every metering
14
+ // update) so the scroll speed stays constant regardless of the recorder's
15
+ // status cadence. The latest metering value is read from a ref to avoid
16
+ // resubscribing the interval on each change. Levels are low-pass filtered so
17
+ // neighboring bars flow into each other instead of jumping.
18
+ const useVoiceWaveform = ({
19
+ metering,
20
+ isActive
21
+ }) => {
22
+ const meteringRef = (0, _react.useRef)(metering);
23
+ meteringRef.current = metering;
24
+ const smoothedLevelRef = (0, _react.useRef)(_constants.VOICE_WAVEFORM.MIN_LEVEL);
25
+ const [levels, setLevels] = (0, _react.useState)(createSilentBuffer);
26
+ (0, _react.useEffect)(() => {
27
+ if (!isActive) {
28
+ smoothedLevelRef.current = _constants.VOICE_WAVEFORM.MIN_LEVEL;
29
+ setLevels(createSilentBuffer());
30
+ return;
31
+ }
32
+ const intervalId = setInterval(() => {
33
+ const target = (0, _helpers.normalizeMetering)(meteringRef.current);
34
+ smoothedLevelRef.current += (target - smoothedLevelRef.current) * _constants.VOICE_WAVEFORM.LEVEL_SMOOTHING;
35
+ const level = Math.max(_constants.VOICE_WAVEFORM.MIN_LEVEL, smoothedLevelRef.current);
36
+ setLevels(prev => [...prev.slice(1), level]);
37
+ }, _constants.VOICE_WAVEFORM.SAMPLE_INTERVAL_MS);
38
+ return () => clearInterval(intervalId);
39
+ }, [isActive]);
40
+ return levels;
41
+ };
42
+ exports.useVoiceWaveform = useVoiceWaveform;
43
+ //# sourceMappingURL=useVoiceWaveform.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_react","require","_constants","_helpers","createSilentBuffer","Array","VOICE_WAVEFORM","BUFFER_SIZE","fill","MIN_LEVEL","useVoiceWaveform","metering","isActive","meteringRef","useRef","current","smoothedLevelRef","levels","setLevels","useState","useEffect","intervalId","setInterval","target","normalizeMetering","LEVEL_SMOOTHING","level","Math","max","prev","slice","SAMPLE_INTERVAL_MS","clearInterval","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/hooks/useVoiceWaveform.ts"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,OAAA;AAEA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAOA,MAAMG,kBAAkB,GAAGA,CAAA,KACzB,IAAIC,KAAK,CAASC,yBAAc,CAACC,WAAW,CAAC,CAACC,IAAI,CAACF,yBAAc,CAACG,SAAS,CAAC;;AAE9E;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC,QAAQ;EAAEC;AAAiC,CAAC,KAAK;EAClF,MAAMC,WAAW,GAAG,IAAAC,aAAM,EAACH,QAAQ,CAAC;EACpCE,WAAW,CAACE,OAAO,GAAGJ,QAAQ;EAE9B,MAAMK,gBAAgB,GAAG,IAAAF,aAAM,EAACR,yBAAc,CAACG,SAAS,CAAC;EACzD,MAAM,CAACQ,MAAM,EAAEC,SAAS,CAAC,GAAG,IAAAC,eAAQ,EAAWf,kBAAkB,CAAC;EAElE,IAAAgB,gBAAS,EAAC,MAAM;IACd,IAAI,CAACR,QAAQ,EAAE;MACbI,gBAAgB,CAACD,OAAO,GAAGT,yBAAc,CAACG,SAAS;MACnDS,SAAS,CAACd,kBAAkB,CAAC,CAAC,CAAC;MAC/B;IACF;IAEA,MAAMiB,UAAU,GAAGC,WAAW,CAAC,MAAM;MACnC,MAAMC,MAAM,GAAG,IAAAC,0BAAiB,EAACX,WAAW,CAACE,OAAO,CAAC;MACrDC,gBAAgB,CAACD,OAAO,IACtB,CAACQ,MAAM,GAAGP,gBAAgB,CAACD,OAAO,IAAIT,yBAAc,CAACmB,eAAe;MACtE,MAAMC,KAAK,GAAGC,IAAI,CAACC,GAAG,CAACtB,yBAAc,CAACG,SAAS,EAAEO,gBAAgB,CAACD,OAAO,CAAC;MAC1EG,SAAS,CAAEW,IAAI,IAAK,CAAC,GAAGA,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,EAAEJ,KAAK,CAAC,CAAC;IAChD,CAAC,EAAEpB,yBAAc,CAACyB,kBAAkB,CAAC;IAErC,OAAO,MAAMC,aAAa,CAACX,UAAU,CAAC;EACxC,CAAC,EAAE,CAACT,QAAQ,CAAC,CAAC;EAEd,OAAOK,MAAM;AACf,CAAC;AAAAgB,OAAA,CAAAvB,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -17,9 +17,12 @@ class RecorderModel {
17
17
  setVoiceRecordState = (0, _effector.createEvent)();
18
18
  setAvailableInputs = (0, _effector.createEvent)();
19
19
  setLastKnownDurationMs = (0, _effector.createEvent)();
20
+ setMetering = (0, _effector.createEvent)();
20
21
  $voiceRecordState = (0, _effector.restore)(this.setVoiceRecordState, _constants.VoiceRecorderState.IDLE).reset(this.reset);
21
22
  $availableInputs = (0, _effector.restore)(this.setAvailableInputs, []);
22
23
  $lastKnownDurationMs = (0, _effector.restore)(this.setLastKnownDurationMs, 0).reset(this.reset);
24
+ // Live input level in dBFS while recording (powers the waveform)
25
+ $metering = (0, _effector.restore)(this.setMetering, null).reset(this.reset);
23
26
  start = (0, _effector.createEffect)(async () => {
24
27
  try {
25
28
  await (0, _expoAudio.setAudioModeAsync)(AUDIO_MODE_CONFIG);
@@ -1 +1 @@
1
- {"version":3,"names":["_effector","require","_expoAudio","_constants","AUDIO_MODE_CONFIG","playsInSilentMode","allowsRecording","RecorderModel","stopResolver","reset","createEvent","setVoiceRecordState","setAvailableInputs","setLastKnownDurationMs","$voiceRecordState","restore","VoiceRecorderState","IDLE","$availableInputs","$lastKnownDurationMs","start","createEffect","setAudioModeAsync","recorder","prepareToRecordAsync","record","RECORDING","error","console","stop","getStatus","isRecording","stopAndAwaitResult","Promise","resolve","resolveRecord","result","clearStopResolver","exports"],"s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EACF,CAAC,CAAC;EAEcE,IAAI,GAAG,IAAAR,sBAAY,EAAC,MAAM;IACxC,IAAI,CAAC,IAAI,CAACE,QAAQ,CAACO,SAAS,CAAC,CAAC,CAACC,WAAW,EAAE;IAC5C,OAAO,IAAI,CAACR,QAAQ,CAACM,IAAI,CAAC,CAAC;EAC7B,CAAC,CAAC;EAEKG,kBAAkBA,CAAA,EAAe;IACtC,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;MAC9B,IAAI,CAAC1B,YAAY,GAAG0B,OAAO;MAC3B,IAAI,CAACX,QAAQ,CAACO,SAAS,CAAC,CAAC,CAACC,WAAW,IAAI,IAAI,CAACR,QAAQ,CAACM,IAAI,CAAC,CAAC;IAC/D,CAAC,CAAC;EACJ;EAEOM,aAAaA,CAACC,MAAS,EAAQ;IACpC,IAAI,IAAI,CAAC5B,YAAY,EAAE;MACrB,IAAI,CAACA,YAAY,CAAC4B,MAAM,CAAC;MACzB,IAAI,CAAC5B,YAAY,GAAG,IAAI;IAC1B;EACF;EAEO6B,iBAAiBA,CAAA,EAAS;IAC/B,IAAI,CAAC7B,YAAY,GAAG,IAAI;EAC1B;AACF;AAAC8B,OAAA,CAAA/B,aAAA,GAAAA,aAAA","ignoreList":[]}
1
+ {"version":3,"names":["_effector","require","_expoAudio","_constants","AUDIO_MODE_CONFIG","playsInSilentMode","allowsRecording","RecorderModel","stopResolver","reset","createEvent","setVoiceRecordState","setAvailableInputs","setLastKnownDurationMs","setMetering","$voiceRecordState","restore","VoiceRecorderState","IDLE","$availableInputs","$lastKnownDurationMs","$metering","start","createEffect","setAudioModeAsync","recorder","prepareToRecordAsync","record","RECORDING","error","console","stop","getStatus","isRecording","stopAndAwaitResult","Promise","resolve","resolveRecord","result","clearStopResolver","exports"],"sourceRoot":"../../../../../../src","sources":["features/voice/recording/model/Recorder.model.ts"],"mappings":";;;;;;AAAA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,UAAA,GAAAD,OAAA;AACA,IAAA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AEA,KAAK,CAAC;MACjD,MAAMA,KAAK;IACb;EACF,CAAC,CAAC;EAEcE,IAAI,GAAG,IAAAR,sBAAY,EAAC,MAAM;IACxC,IAAI,CAAC,IAAI,CAACE,QAAQ,CAACO,SAAS,CAAC,CAAC,CAACC,WAAW,EAAE;IAC5C,OAAO,IAAI,CAACR,QAAQ,CAACM,IAAI,CAAC,CAAC;EAC7B,CAAC,CAAC;EAEKG,kBAAkBA,CAAA,EAAe;IACtC,OAAO,IAAIC,OAAO,CAAEC,OAAO,IAAK;MAC9B,IAAI,CAAC5B,YAAY,GAAG4B,OAAO;MAC3B,IAAI,CAACX,QAAQ,CAACO,SAAS,CAAC,CAAC,CAACC,WAAW,IAAI,IAAI,CAACR,QAAQ,CAACM,IAAI,CAAC,CAAC;IAC/D,CAAC,CAAC;EACJ;EAEOM,aAAaA,CAACC,MAAS,EAAQ;IACpC,IAAI,IAAI,CAAC9B,YAAY,EAAE;MACrB,IAAI,CAACA,YAAY,CAAC8B,MAAM,CAAC;MACzB,IAAI,CAAC9B,YAAY,GAAG,IAAI;IAC1B;EACF;EAEO+B,iBAAiBA,CAAA,EAAS;IAC/B,IAAI,CAAC/B,YAAY,GAAG,IAAI;EAC1B;AACF;AAACgC,OAAA,CAAAjC,aAAA,GAAAA,aAAA","ignoreList":[]}
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.VoiceRecordWithTranscriptModel = void 0;
7
+ var _effector = require("effector");
8
+ var _constants = require("../../constants.js");
9
+ var _transcriptHelpers = require("../../transcript.helpers.js");
10
+ var _VoiceTranscriptPanelModel = require("./VoiceTranscriptPanel.model.js");
11
+ // Wires the existing recording flow to the transcript panel:
12
+ // recording starts → panel opens with the waveform; the recording is confirmed
13
+ // (upload kicks off) → panel shows the loader; the uploaded file's transcript
14
+ // arrives → panel shows the text. Deleting/discarding the record closes the panel.
15
+ class VoiceRecordWithTranscriptModel {
16
+ panel = new _VoiceTranscriptPanelModel.VoiceTranscriptPanelModel();
17
+ constructor({
18
+ recordModel,
19
+ getTranscript
20
+ }) {
21
+ this.record = recordModel;
22
+ this.resolveTranscriptFx = (0, _effector.createEffect)(async record => {
23
+ const upload = await record.audioUploadPromise;
24
+ if (!upload || !upload.id) throw new Error('Audio upload did not return a file id');
25
+ const {
26
+ text
27
+ } = await (0, _transcriptHelpers.fetchTranscriptWithRetry)(getTranscript, upload.id);
28
+ if (text === _constants.NO_AUDIO_BE_MESSAGE) throw new Error('Transcript is not available');
29
+ return text;
30
+ });
31
+ this.setupPanelLifecycle();
32
+ this.setupTranscriptPipeline();
33
+ }
34
+ setupPanelLifecycle() {
35
+ (0, _effector.sample)({
36
+ clock: this.record.recorderModel.$voiceRecordState,
37
+ filter: state => state === _constants.VoiceRecorderState.RECORDING,
38
+ target: this.panel.open
39
+ });
40
+ // startAudioUpload fires exactly when a recording was confirmed (the
41
+ // discard path never uploads), so it doubles as the panel's confirm clock.
42
+ (0, _effector.sample)({
43
+ clock: this.record.startAudioUpload,
44
+ target: this.panel.confirm
45
+ });
46
+ (0, _effector.sample)({
47
+ clock: [this.record.reset, this.record.stop.done],
48
+ target: this.panel.discard
49
+ });
50
+ }
51
+ setupTranscriptPipeline() {
52
+ // Identity guard: a fetch result only applies if the record it was fetched
53
+ // for is still the current one — late results from a discarded or
54
+ // re-recorded take are dropped.
55
+ const isFetchedRecordCurrent = (currentRecord, {
56
+ params
57
+ }) => currentRecord === params;
58
+ (0, _effector.sample)({
59
+ clock: this.record.$currentRecord.updates,
60
+ source: this.panel.$flags,
61
+ filter: (flags, record) => flags.isProcessing && Boolean(record?.audioUploadPromise),
62
+ fn: (_, record) => record,
63
+ target: this.resolveTranscriptFx
64
+ });
65
+ (0, _effector.sample)({
66
+ clock: this.resolveTranscriptFx.done,
67
+ source: this.record.$currentRecord,
68
+ filter: isFetchedRecordCurrent,
69
+ fn: (_, {
70
+ result
71
+ }) => result,
72
+ target: this.panel.complete
73
+ });
74
+ (0, _effector.sample)({
75
+ clock: this.resolveTranscriptFx.fail,
76
+ source: this.record.$currentRecord,
77
+ filter: isFetchedRecordCurrent,
78
+ target: this.panel.fail
79
+ });
80
+ }
81
+ }
82
+ exports.VoiceRecordWithTranscriptModel = VoiceRecordWithTranscriptModel;
83
+ //# sourceMappingURL=VoiceRecordWithTranscript.model.js.map