meticulous-ui 3.12.0 → 3.12.2

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.
@@ -1,28 +1,31 @@
1
- import { jsx as a, jsxs as u } from "react/jsx-runtime";
1
+ import { jsx as d, jsxs as h } from "react/jsx-runtime";
2
2
  import { useState as v } from "react";
3
- import r from "prop-types";
4
- import t, { keyframes as w } from "styled-components";
3
+ import n from "prop-types";
4
+ import i, { keyframes as w } from "styled-components";
5
5
  import c from "../../colors/grey.js";
6
6
  import { black as l } from "../../colors/black.js";
7
7
  import B from "../Icons/ChevronDown.js";
8
8
  const O = w`
9
9
  from { opacity: 0; transform: translateY(-6px); }
10
10
  to { opacity: 1; transform: translateY(0); }
11
- `, S = t.div`
11
+ `, S = i.div`
12
12
  width: 100%;
13
13
  display: flex;
14
14
  flex-direction: column;
15
15
  gap: 12px;
16
- `, T = t.div`
16
+ `, T = i.div`
17
17
  border: 1.5px solid
18
- ${({ $isOpen: o, $activeBackground: n, $itemBorderColor: s }) => o && n ? "transparent" : s || c.m200};
18
+ ${({ $isOpen: o, $activeBackground: e, $itemBorderColor: s }) => o && e ? "transparent" : s || c.m200};
19
19
  border-radius: 12px;
20
20
  overflow: hidden;
21
- background: ${({ $isOpen: o, $activeBackground: n, $itemBackground: s }) => o && n ? n : s};
21
+ background: ${({ $isOpen: o, $activeBackground: e, $itemBackground: s }) => o && e ? e : s};
22
22
  transition:
23
23
  background 0.22s ease,
24
24
  border-color 0.22s ease;
25
- `, I = t.button`
25
+ `, I = i.h3`
26
+ margin: 0;
27
+ font: inherit;
28
+ `, R = i.button`
26
29
  width: 100%;
27
30
  display: flex;
28
31
  align-items: center;
@@ -38,32 +41,32 @@ const O = w`
38
41
  outline-offset: -2px;
39
42
  border-radius: 12px;
40
43
  }
41
- `, R = t.div`
44
+ `, j = i.div`
42
45
  flex-shrink: 0;
43
46
  width: 40px;
44
47
  height: 40px;
45
48
  border: 1.5px solid
46
- ${({ $iconBackground: o, $borderColor: n }) => o ? "transparent" : n || c.m200};
49
+ ${({ $iconBackground: o, $borderColor: e }) => o ? "transparent" : e || c.m200};
47
50
  border-radius: 10px;
48
51
  display: flex;
49
52
  align-items: center;
50
53
  justify-content: center;
51
54
  color: ${({ $iconColor: o }) => o};
52
55
  background: ${({ $iconBackground: o }) => o || "none"};
53
- `, j = t.span`
56
+ `, q = i.span`
54
57
  flex: 1;
55
58
  font-size: 15px;
56
59
  font-weight: 600;
57
60
  color: ${({ $titleColor: o }) => o || l.m700};
58
61
  line-height: 1.4;
59
- `, q = t.div`
62
+ `, z = i.div`
60
63
  flex-shrink: 0;
61
64
  display: flex;
62
65
  align-items: center;
63
66
  color: ${({ $chevronColor: o }) => o || c.m600};
64
67
  transform: rotate(${({ $isOpen: o }) => o ? "180deg" : "0deg"});
65
68
  transition: transform 0.22s ease;
66
- `, z = t.div`
69
+ `, A = i.div`
67
70
  padding: 0 20px 18px calc(20px + 40px + 16px);
68
71
  font-size: 14px;
69
72
  line-height: 1.65;
@@ -74,109 +77,110 @@ const O = w`
74
77
  color: ${({ $bodyColor: o }) => o || l.m700};
75
78
  text-decoration: underline;
76
79
  }
77
- `, A = l.m700, D = ({
80
+ `, D = l.m700, H = ({
78
81
  items: o = [],
79
- allowMultiple: n = !1,
82
+ allowMultiple: e = !1,
80
83
  activeBackground: s,
81
- iconColor: h,
84
+ iconColor: u,
82
85
  iconBackground: m,
83
86
  itemBackground: $ = "#fff",
84
87
  itemBorderColor: p,
85
88
  titleColor: g,
86
89
  bodyColor: b
87
90
  }) => {
88
- const [y, k] = v(/* @__PURE__ */ new Set()), C = (e) => {
89
- k((i) => {
90
- const d = n ? new Set(i) : /* @__PURE__ */ new Set();
91
- return i.has(e) ? d.delete(e) : d.add(e), d;
91
+ const [y, k] = v(/* @__PURE__ */ new Set()), C = (r) => {
92
+ k((t) => {
93
+ const a = e ? new Set(t) : /* @__PURE__ */ new Set();
94
+ return t.has(r) ? a.delete(r) : a.add(r), a;
92
95
  });
93
96
  };
94
- return /* @__PURE__ */ a(S, { children: o.map((e) => {
95
- var d, f, x;
96
- const i = y.has(e.id);
97
- return /* @__PURE__ */ u(
97
+ return /* @__PURE__ */ d(S, { children: o.map((r) => {
98
+ var a, f, x;
99
+ const t = y.has(r.id);
100
+ return /* @__PURE__ */ h(
98
101
  T,
99
102
  {
100
- $isOpen: i,
103
+ $isOpen: t,
101
104
  $activeBackground: s,
102
105
  $itemBackground: $,
103
106
  $itemBorderColor: p,
104
107
  children: [
105
- /* @__PURE__ */ u(
106
- I,
108
+ /* @__PURE__ */ d(I, { children: /* @__PURE__ */ h(
109
+ R,
107
110
  {
108
111
  type: "button",
109
- "aria-expanded": i,
110
- "aria-controls": `accordion-body-${e.id}`,
111
- id: `accordion-header-${e.id}`,
112
- onClick: () => C(e.id),
112
+ "aria-expanded": t,
113
+ "aria-controls": `accordion-body-${r.id}`,
114
+ id: `accordion-header-${r.id}`,
115
+ onClick: () => C(r.id),
113
116
  children: [
114
- e.icon && /* @__PURE__ */ a(
115
- R,
117
+ r.icon && /* @__PURE__ */ d(
118
+ j,
116
119
  {
117
120
  "aria-hidden": "true",
118
- $iconColor: (f = (d = e.iconColor) != null ? d : h) != null ? f : A,
119
- $iconBackground: (x = e.iconBackground) != null ? x : m,
121
+ $iconColor: (f = (a = r.iconColor) != null ? a : u) != null ? f : D,
122
+ $iconBackground: (x = r.iconBackground) != null ? x : m,
120
123
  $borderColor: p,
121
- children: e.icon
124
+ children: r.icon
122
125
  }
123
126
  ),
124
- /* @__PURE__ */ a(j, { $titleColor: g, children: e.title }),
125
- /* @__PURE__ */ a(q, { "aria-hidden": "true", $isOpen: i, $chevronColor: g, children: /* @__PURE__ */ a(B, { size: 18 }) })
127
+ /* @__PURE__ */ d(q, { $titleColor: g, children: r.title }),
128
+ /* @__PURE__ */ d(z, { "aria-hidden": "true", $isOpen: t, $chevronColor: g, children: /* @__PURE__ */ d(B, { size: 18 }) })
126
129
  ]
127
130
  }
128
- ),
129
- i && /* @__PURE__ */ a(
130
- z,
131
+ ) }),
132
+ /* @__PURE__ */ d(
133
+ A,
131
134
  {
132
- id: `accordion-body-${e.id}`,
135
+ id: `accordion-body-${r.id}`,
133
136
  role: "region",
134
- "aria-labelledby": `accordion-header-${e.id}`,
137
+ "aria-labelledby": `accordion-header-${r.id}`,
138
+ hidden: !t,
135
139
  $bodyColor: b,
136
- children: e.content
140
+ children: r.content
137
141
  }
138
142
  )
139
143
  ]
140
144
  },
141
- e.id
145
+ r.id
142
146
  );
143
147
  }) });
144
148
  };
145
- D.propTypes = {
149
+ H.propTypes = {
146
150
  /** Array of accordion items */
147
- items: r.arrayOf(
148
- r.shape({
151
+ items: n.arrayOf(
152
+ n.shape({
149
153
  /** Unique identifier for the item */
150
- id: r.oneOfType([r.string, r.number]).isRequired,
154
+ id: n.oneOfType([n.string, n.number]).isRequired,
151
155
  /** Question / heading text */
152
- title: r.node.isRequired,
156
+ title: n.node.isRequired,
153
157
  /** Answer / expanded content (string or JSX) */
154
- content: r.node.isRequired,
158
+ content: n.node.isRequired,
155
159
  /** Optional icon node rendered in the icon box */
156
- icon: r.node,
160
+ icon: n.node,
157
161
  /** Color applied to the icon — defaults to black.m700 */
158
- iconColor: r.string,
162
+ iconColor: n.string,
159
163
  /** Background color of the icon box for this item — overrides accordion-level iconBackground */
160
- iconBackground: r.string
164
+ iconBackground: n.string
161
165
  })
162
166
  ),
163
167
  /** When true, multiple items can be open simultaneously */
164
- allowMultiple: r.bool,
168
+ allowMultiple: n.bool,
165
169
  /** Background color applied to the expanded item — use a token from the colors palette e.g. blue.m50 */
166
- activeBackground: r.string,
170
+ activeBackground: n.string,
167
171
  /** Default icon color for all items — overridden per-item via item.iconColor. Defaults to black.m700 */
168
- iconColor: r.string,
172
+ iconColor: n.string,
169
173
  /** Default icon box background for all items — overridden per-item via item.iconBackground */
170
- iconBackground: r.string,
174
+ iconBackground: n.string,
171
175
  /** Background color for resting (closed) items. Defaults to '#fff' — use a palette token e.g. blueGray.m800 for dark mode */
172
- itemBackground: r.string,
176
+ itemBackground: n.string,
173
177
  /** Border color for all items — use a palette token e.g. blueGray.m600 for dark mode */
174
- itemBorderColor: r.string,
178
+ itemBorderColor: n.string,
175
179
  /** Title and chevron text color — use a light palette token e.g. blueGray.m100 for dark mode */
176
- titleColor: r.string,
180
+ titleColor: n.string,
177
181
  /** Body content text color — use a muted light token e.g. blueGray.m300 for dark mode */
178
- bodyColor: r.string
182
+ bodyColor: n.string
179
183
  };
180
184
  export {
181
- D as default
185
+ H as default
182
186
  };
@@ -1,9 +1,9 @@
1
1
  import { jsxs as H, jsx as i } from "react/jsx-runtime";
2
2
  import { useState as K, useRef as Q } from "react";
3
3
  import U from "../../../colors/white.js";
4
- import s from "../../../colors/grey.js";
4
+ import m from "../../../colors/grey.js";
5
5
  import B from "./SvgIcon.js";
6
- import n, { css as c } from "styled-components";
6
+ import n, { css as a } from "styled-components";
7
7
  import { black as L } from "../../../colors/black.js";
8
8
  import v from "../../../colors/red.js";
9
9
  import { blue as V } from "../../../colors/blue.js";
@@ -21,15 +21,15 @@ const ie = {
21
21
  yellow: Y.m500,
22
22
  orange: Z.m500,
23
23
  black: L.m500,
24
- grey: s.m500,
24
+ grey: m.m500,
25
25
  violet: ee.m500,
26
26
  teal: oe.m500,
27
27
  purple: re.m500,
28
28
  pink: te.m500
29
29
  }, ne = (e) => {
30
30
  var o;
31
- return (o = ie[e]) != null ? o : s.m500;
32
- }, x = ({ $hasError: e, $shade: o, $isFocused: r, value: a, $onlyPh: d }) => e ? typeof a == "string" && !a && !r ? s.m500 : v.m400 : r && !d ? o : s.m500, se = n.textarea`
31
+ return (o = ie[e]) != null ? o : m.m500;
32
+ }, x = ({ $hasError: e, $shade: o, $isFocused: r, value: s, $onlyPh: d }) => e ? typeof s == "string" && !s && !r ? m.m500 : v.m400 : r && !d ? o : m.m500, se = n.textarea`
33
33
  border-radius: 0.64rem;
34
34
  font-size: 2.24rem;
35
35
  border: 2px solid ${({ $hasError: e }) => e ? v.m400 : L.m200};
@@ -40,11 +40,19 @@ const ie = {
40
40
  min-height: 2.24rem;
41
41
  min-width: 4.8rem;
42
42
 
43
- ${({ $isResizeNone: e }) => e && c`
43
+ ${({ $hasLeftIcon: e }) => e && a`
44
+ padding-left: 3.52rem;
45
+ `}
46
+
47
+ ${({ $hasRightIcon: e }) => e && a`
48
+ padding-right: 3.52rem;
49
+ `}
50
+
51
+ ${({ $isResizeNone: e }) => e && a`
44
52
  resize: none;
45
53
  `}
46
54
 
47
- ${({ $isDynamic: e }) => e && c`
55
+ ${({ $isDynamic: e }) => e && a`
48
56
  resize: none;
49
57
  `}
50
58
 
@@ -58,7 +66,7 @@ const ie = {
58
66
  }
59
67
 
60
68
  &::placeholder {
61
- color: ${s.m500};
69
+ color: ${m.m500};
62
70
  font-weight: 300;
63
71
  font-size: 2.24rem;
64
72
  background-color: ${({ $background: e }) => e};
@@ -97,14 +105,14 @@ const ie = {
97
105
  max-width: -webkit-fill-available; /* Chrome, Safari, Edge */
98
106
  max-width: stretch; /* Modern Standard */
99
107
 
100
- ${({ $isFocused: e, $value: o, $onlyPh: r }) => !r && (e || o) ? c`
108
+ ${({ $isFocused: e, $value: o, $onlyPh: r }) => !r && (e || o) ? a`
101
109
  top: -0.64rem;
102
110
  left: 0.8rem;
103
111
  padding: 0 0.64rem;
104
112
  margin: 0;
105
- ` : c`
113
+ ` : a`
106
114
  top: 1.28rem;
107
- left: 0.8rem;
115
+ left: ${({ $hasLeftIcon: s }) => s ? "3.52rem" : "0.8rem"};
108
116
  font-size: 2.24rem;
109
117
  `}
110
118
  `, ce = n.div`
@@ -121,7 +129,7 @@ const ie = {
121
129
  label: e,
122
130
  onChange: o,
123
131
  value: r,
124
- type: a,
132
+ type: s,
125
133
  hasError: d,
126
134
  name: k = "textarea",
127
135
  color: j = "blue",
@@ -137,7 +145,7 @@ const ie = {
137
145
  placeholder: u,
138
146
  ...W
139
147
  }) => {
140
- const [m, C] = K(!1), g = ne(j), b = Q(null), M = (t) => {
148
+ const [l, C] = K(!1), g = ne(j), b = Q(null), M = (t) => {
141
149
  t.style.height = "";
142
150
  const R = t.scrollHeight - t.clientHeight;
143
151
  if (R > 0) {
@@ -146,16 +154,16 @@ const ie = {
146
154
  }
147
155
  }, T = () => C(!0), _ = () => C(!1), D = (t) => {
148
156
  z && b.current && M(b.current), o(t);
149
- }, S = { color: s.m500, size: 20 }, w = !!f, F = !!h, l = d, N = z, q = y, G = { rows: O }, $ = `textarea-${k}`, I = p ? `${$}-helper` : void 0;
157
+ }, S = { color: m.m500, size: 20 }, w = !!f, F = !!h, c = d, N = z, q = y, G = { rows: O }, $ = `textarea-${k}`, I = p ? `${$}-helper` : void 0;
150
158
  return /* @__PURE__ */ H(me, { children: [
151
159
  /* @__PURE__ */ i(
152
160
  se,
153
161
  {
154
- type: a,
162
+ type: s,
155
163
  name: k,
156
- $hasError: l,
164
+ $hasError: c,
157
165
  value: r,
158
- $isFocused: m,
166
+ $isFocused: l,
159
167
  $shade: g,
160
168
  $isDynamic: N,
161
169
  $background: q,
@@ -165,7 +173,7 @@ const ie = {
165
173
  $isResizeNone: E,
166
174
  ...G,
167
175
  id: $,
168
- "aria-invalid": l ? !0 : void 0,
176
+ "aria-invalid": c ? !0 : void 0,
169
177
  "aria-describedby": I,
170
178
  ref: b,
171
179
  onFocus: T,
@@ -182,18 +190,18 @@ const ie = {
182
190
  {
183
191
  as: "label",
184
192
  htmlFor: $,
185
- $hasError: l,
186
- $isFocused: m,
193
+ $hasError: c,
194
+ $isFocused: l,
187
195
  $shade: g,
188
196
  $value: r,
189
- $outerBackground: m || r ? A : y,
197
+ $outerBackground: l || r ? A : y,
190
198
  $hasLeftIcon: w,
191
199
  $hasRightIcon: F,
192
200
  $onlyPh: u && !e,
193
201
  children: e || u
194
202
  }
195
203
  ),
196
- p && /* @__PURE__ */ i(ae, { id: I, $hasError: l, $isFocused: m, $shade: g, $hasLeftIcon: w, children: p })
204
+ p && /* @__PURE__ */ i(ae, { id: I, $hasError: c, $isFocused: l, $shade: g, $hasLeftIcon: w, children: p })
197
205
  ] })
198
206
  ] });
199
207
  };
package/index.d.ts CHANGED
@@ -1488,28 +1488,32 @@ export declare function getQrAsJsonContent(source: QrSource): Promise<QrJsonResu
1488
1488
 
1489
1489
  export interface RecognizeImageResult {
1490
1490
  success: boolean;
1491
- /** Whether the TextDetector API is available in this browser. */
1492
- supported?: boolean;
1493
1491
  /** BCP-47 code of the primary language used for recognition. */
1494
1492
  detectedLanguage?: string;
1495
- /** Full extracted text, newline-separated by detected region. */
1493
+ /** Full extracted text from OCR, newline-separated by detected region. */
1496
1494
  text?: string;
1497
- /** OCR confidence score 0–100, or null when not available. */
1495
+ /** OCR confidence score 0–100. */
1498
1496
  confidence?: number | null;
1499
- /** Raw per-region data including bounding boxes and corner points. */
1500
- rawJson?: Array<{
1501
- rawValue: string;
1502
- boundingBox: { x: number; y: number; width: number; height: number };
1503
- cornerPoints: Array<{ x: number; y: number }>;
1504
- }>;
1497
+ /**
1498
+ * All readable lines from the OCR output as a key-value object.
1499
+ * Lines matching `ALL-CAPS KEY : value` use the label as the key.
1500
+ * Lines without a recognisable label are assigned generic keys (`param_1`, `param_2`, …).
1501
+ * Continuation lines (e.g. a wrapped address) are appended to the previous key.
1502
+ */
1503
+ fields?: Record<string, string>;
1504
+ /** Raw Tesseract output including per-word bounding boxes and metadata. */
1505
+ rawJson?: object;
1505
1506
  /** Human-readable error when success is false. */
1506
1507
  error?: string;
1507
1508
  }
1508
1509
 
1509
1510
  /**
1510
- * Detect text in a base64 image using the browser-native TextDetector API.
1511
- * No external dependencies or network requests.
1512
- * Supported in Chrome 70+ and Edge 79+; returns supported:false on other browsers.
1511
+ * Runs OCR on a base64 image in all browsers with no npm dependency.
1512
+ * Powered by Tesseract.js loaded on demand from a CDN (fetched once, then
1513
+ * browser-cached). Preprocesses the image (grayscale + upscale + contrast
1514
+ * boost) before recognition for higher accuracy. Returns structured `fields`
1515
+ * with extracted key-value pairs alongside the raw `text`, `confidence` score,
1516
+ * and `rawJson` with full word-level bounding-box metadata.
1513
1517
  */
1514
1518
  export declare function recognizeImageContent(
1515
1519
  base64Image: string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "meticulous-ui",
3
- "version": "3.12.0",
3
+ "version": "3.12.2",
4
4
  "license": "ISC",
5
5
  "description": "A comprehensive React UI component library with a wide range of customizable components, icons, colors, and utilities for building modern web applications.",
6
6
  "types": "./index.d.ts",
@@ -1,4 +1,62 @@
1
- const l = {
1
+ const b = (l) => new Promise((n, s) => {
2
+ const o = new Image();
3
+ o.onload = () => {
4
+ const r = document.createElement("canvas");
5
+ r.width = o.width * 2, r.height = o.height * 2;
6
+ const e = r.getContext("2d");
7
+ e.filter = "grayscale(1) contrast(1.8)", e.drawImage(o, 0, 0, r.width, r.height), n(r.toDataURL("image/png"));
8
+ }, o.onerror = s, o.src = l;
9
+ }), u = (l) => {
10
+ var r;
11
+ const n = ((r = l.words) != null ? r : []).map((e) => {
12
+ var t;
13
+ return { text: (t = e.text) == null ? void 0 : t.trim(), bbox: e.bbox };
14
+ }).filter((e) => e.text && e.bbox);
15
+ if (!n.length) return [];
16
+ const s = [];
17
+ for (const e of n) {
18
+ const t = (e.bbox.y0 + e.bbox.y1) / 2, c = (e.bbox.y1 - e.bbox.y0) / 2;
19
+ let a = s.find((m) => Math.abs(m.cy - t) < c);
20
+ a || (a = { cy: t, words: [] }, s.push(a)), a.words.push(e);
21
+ }
22
+ const o = [];
23
+ for (const e of s) {
24
+ const t = e.words.slice().sort((i, x) => i.bbox.x0 - x.bbox.x0), c = t.slice(1).map((i, x) => i.bbox.x0 - t[x].bbox.x1), a = c.length ? c.reduce((i, x) => i + x, 0) / c.length : 0, m = Math.max(a * 3, (t[0].bbox.y1 - t[0].bbox.y0) * 1.5);
25
+ let d = [t[0]];
26
+ for (let i = 1; i < t.length; i++)
27
+ t[i].bbox.x0 - t[i - 1].bbox.x1 > m && (o.push({
28
+ text: d.map((x) => x.text).join(" "),
29
+ y: e.cy,
30
+ x: d[0].bbox.x0
31
+ }), d = []), d.push(t[i]);
32
+ o.push({
33
+ text: d.map((i) => i.text).join(" "),
34
+ y: e.cy,
35
+ x: d[0].bbox.x0
36
+ });
37
+ }
38
+ return o.sort((e, t) => e.y - t.y || e.x - t.x), o.map((e) => e.text);
39
+ }, h = (l) => {
40
+ const n = {};
41
+ let s = null, o = 0;
42
+ const r = (e) => {
43
+ let t = e.replace(/^[^A-Za-z0-9"'(]+/, "").trim();
44
+ return t = t.replace(/[^A-Za-z0-9"')]+$/, "").trim(), t = t.replace(/^[A-Za-z]{1,3}\s+(?=\d)/, ""), t;
45
+ };
46
+ for (const e of l) {
47
+ const t = r(e.trim());
48
+ if (!t) {
49
+ s = null;
50
+ continue;
51
+ }
52
+ const c = t.match(/\b([A-Z][A-Z.]{0,}(?:\s+[A-Z.]+){0,2})\s*[:©]\s*(.+)/);
53
+ if (c) {
54
+ const a = c[1].trim();
55
+ n[a] = c[2].trim(), s = a;
56
+ } else s && /^[A-Z0-9][A-Z0-9\s.,'\-]+$/.test(t) ? (n[s] += " " + t, s = null) : (/\w{3,}/.test(t) && (n[`param_${++o}`] = t), s = null);
57
+ }
58
+ return n;
59
+ }, g = {
2
60
  en: "eng",
3
61
  hi: "hin",
4
62
  fr: "fra",
@@ -17,37 +75,40 @@ const l = {
17
75
  vi: "vie",
18
76
  th: "tha",
19
77
  id: "ind"
20
- }, d = (t) => t.map((r) => {
21
- var e;
22
- return (e = l[r]) != null ? e : r;
78
+ }, f = (l) => l.map((n) => {
79
+ var s;
80
+ return (s = g[n]) != null ? s : n;
23
81
  }).join("+");
24
- let s = null;
25
- const u = () => (s || (s = import(
82
+ let p = null;
83
+ const y = () => (p || (p = import(
26
84
  /* webpackIgnore: true */
27
85
  /* @vite-ignore */
28
86
  "https://esm.sh/tesseract.js@5"
29
- )), s), p = async (t, r = "en") => {
30
- var e;
87
+ )), p), w = async (l, n = "en") => {
88
+ var s;
31
89
  try {
32
- const a = t.startsWith("data:") ? t : `data:image/png;base64,${t}`, o = r.split("+").filter(Boolean), { createWorker: i } = await u(), c = await i(d(o));
90
+ const o = l.startsWith("data:") ? l : `data:image/png;base64,${l}`, r = n.split("+").filter(Boolean), e = await b(o), { createWorker: t } = await y(), c = await t(f(r));
33
91
  try {
34
- const { data: n } = await c.recognize(a);
92
+ await c.setParameters({ tessedit_pageseg_mode: "3" });
93
+ const { data: a } = await c.recognize(e), m = a.text.trim();
35
94
  return {
36
95
  success: !0,
37
- detectedLanguage: (e = o[0]) != null ? e : "en",
38
- text: n.text.trim(),
39
- confidence: n.confidence,
96
+ detectedLanguage: (s = r[0]) != null ? s : "en",
97
+ text: m,
98
+ confidence: a.confidence,
40
99
  // 0–100
41
- rawJson: n
100
+ fields: h(u(a)),
101
+ // structured key-value extraction, split on bbox gaps
102
+ rawJson: a
42
103
  // full metadata: words, blocks, bounding boxes
43
104
  };
44
105
  } finally {
45
106
  await c.terminate();
46
107
  }
47
- } catch (a) {
48
- return { success: !1, error: a.message };
108
+ } catch (o) {
109
+ return { success: !1, error: o.message };
49
110
  }
50
111
  };
51
112
  export {
52
- p as default
113
+ w as default
53
114
  };