dytools-capture-engine 1.5.2 → 2.0.0

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/dist/index.cjs CHANGED
@@ -34,6 +34,8 @@ var CapturePublicEventType = {
34
34
  // This is a call that happens when either resize or moved.
35
35
  ZoneNameChanged: "zone:name_changed",
36
36
  ZoneFilterRegexChanged: "zone:filter_regex_changed",
37
+ ZoneApplyFilterRegexToWholeLinesChanged: "zone:apply_filter_regex_to_whole_lines_changed",
38
+ ZoneIsFilterRegexNegatedChanged: "zone:is_filter_regex_negated_changed",
37
39
  ZoneExampleChanged: "zone:example_changed",
38
40
  ZoneHiddenChanged: "zone:hidden_changed",
39
41
  ZoneChanged: "zone:changed",
@@ -77,15 +79,22 @@ var CaptureZoneEventType = {
77
79
  ZoneExampleChanged: "zone_internal:example_changed",
78
80
  ZoneHiddenChanged: "zone_internal:hidden_changed",
79
81
  ZoneFilterRegexChanged: "zone_internal:filter_regex_changed",
82
+ ZoneApplyFilterRegexToWholeLinesChanged: "zone_internal:apply_filter_regex_to_whole_lines_changed",
83
+ ZoneIsFilterRegexNegatedChanged: "zone_internal:is_filter_regex_negated_changed",
80
84
  ZoneOutputRegexChanged: "zone_internal:output_regex_changed",
81
85
  ZoneOutputReplacementChanged: "zone_internal:output_replacement_changed",
86
+ ZoneOutputFunctionChanged: "zone_internal:output_function_changed",
82
87
  ZoneRequiredChanged: "zone_internal:required_changed",
83
88
  ZoneDataTypeChanged: "zone_internal:data_type_changed",
84
89
  ZoneExcludeFromOutputChanged: "zone_internal:exclude_from_output_changed",
85
90
  ZoneDefaultValueIfEmptyChanged: "zone_internal:default_value_if_empty_changed",
91
+ ZoneFeatureFlagsChanged: "zone_internal:feature_flags_changed",
86
92
  ZoneOcrMatchesChanged: "zone_internal:ocr_matches_changed",
87
93
  ZoneGroupChildrenChanged: "zone_internal:group_children_changed",
88
- ZoneAnchorLocationChanged: "zone_internal:anchor_location_changed"
94
+ ZoneAnchorLocationChanged: "zone_internal:anchor_location_changed",
95
+ ZoneHasColumnHeadersChanged: "zone_internal:has_column_headers_changed",
96
+ ZoneExcludeColumnHeadersChanged: "zone_internal:exclude_column_headers_changed",
97
+ ZoneIsAnchorPerLineChanged: "zone_internal:is_anchor_per_line_changed"
89
98
  // These are events based on the state of the zone that is handled by the engine.
90
99
  // ZoneSelected: "zone:selected",
91
100
  // ZoneDeselected: "zone:deselected",
@@ -118,8 +127,11 @@ var CaptureToEngineEventType = {
118
127
  // This is a call that happens when either resize or moved.
119
128
  ZoneNameChanged: "zone:name_changed",
120
129
  ZoneFilterRegexChanged: "zone:filter_regex_changed",
130
+ ZoneApplyFilterRegexToWholeLinesChanged: "zone:apply_filter_regex_to_whole_lines_changed",
131
+ ZoneIsFilterRegexNegatedChanged: "zone:is_filter_regex_negated_changed",
121
132
  ZoneOutputRegexChanged: "zone:output_regex_changed",
122
133
  ZoneOutputReplacementChanged: "zone:output_replacement_changed",
134
+ ZoneOutputFunctionChanged: "zone:output_function_changed",
123
135
  ZoneRequiredChanged: "zone:required_changed",
124
136
  ZoneDataTypeChanged: "zone:data_type_changed",
125
137
  ZoneExcludeFromOutputChanged: "zone:exclude_from_output_changed",
@@ -130,6 +142,10 @@ var CaptureToEngineEventType = {
130
142
  // This happens on all the above events.
131
143
  ZoneAnchorLocationChanged: "zone:anchor_location_changed",
132
144
  ZoneGroupChildrenChanged: "zone:group_children_changed",
145
+ ZoneHasColumnHeadersChanged: "zone:has_column_headers_changed",
146
+ ZoneExcludeColumnHeadersChanged: "zone:exclude_column_headers_changed",
147
+ ZoneIsAnchorPerLineChanged: "zone:is_anchor_per_line_changed",
148
+ ZoneFeatureFlagsChanged: "zone:feature_flags_changed",
133
149
  ZoneChildZoneAdded: "zone:child_zone_added",
134
150
  ZoneChildZoneRemoved: "zone:child_zone_removed",
135
151
  ZoneChildZonesChanged: "zone:child_zone_changed",
@@ -143,7 +159,7 @@ var CaptureToEngineEventType = {
143
159
  // ObjectDeselected: "object:deselected",
144
160
  };
145
161
  var CaptureZoneBase = class {
146
- constructor(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, opts = {}) {
162
+ constructor(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, featureFlags, opts = {}) {
147
163
  this._example = null;
148
164
  this.needsAnchorReposition = false;
149
165
  // This is true when the zone needs to be repositioned to the parent's anchor point when the anchor is moved.
@@ -156,12 +172,16 @@ var CaptureZoneBase = class {
156
172
  this._rect = rect;
157
173
  this._hidden = hidden;
158
174
  this._filterRegex = filterRegex;
175
+ this._applyFilterRegexToWholeLines = applyFilterRegexToWholeLines;
176
+ this._isFilterRegexNegated = isFilterRegexNegated;
159
177
  this._outputRegex = outputRegex;
160
178
  this._outputReplacement = outputReplacement;
179
+ this._outputFunction = outputFunction;
161
180
  this._required = required;
162
181
  this._dataType = dataType;
163
182
  this._excludeFromOutput = excludeFromOutput;
164
183
  this._defaultValueIfEmpty = defaultValueIfEmpty;
184
+ this._featureFlags = featureFlags;
165
185
  }
166
186
  get defaultOptions() {
167
187
  return {
@@ -237,6 +257,28 @@ var CaptureZoneBase = class {
237
257
  });
238
258
  propertiesChanged.push("filterRegex");
239
259
  }
260
+ if (type === CaptureZoneEventType.ZoneApplyFilterRegexToWholeLinesChanged) {
261
+ const zoneApplyFilterRegexToWholeLinesChangedPayload = payload;
262
+ const oldApplyFilterRegexToWholeLines = zoneApplyFilterRegexToWholeLinesChangedPayload.oldApplyFilterRegexToWholeLines;
263
+ const newApplyFilterRegexToWholeLines = zoneApplyFilterRegexToWholeLinesChangedPayload.newApplyFilterRegexToWholeLines;
264
+ this.emitToEngine(CaptureToEngineEventType.ZoneApplyFilterRegexToWholeLinesChanged, {
265
+ zone: this,
266
+ oldApplyFilterRegexToWholeLines,
267
+ newApplyFilterRegexToWholeLines
268
+ });
269
+ propertiesChanged.push("applyFilterRegexToWholeLines");
270
+ }
271
+ if (type === CaptureZoneEventType.ZoneIsFilterRegexNegatedChanged) {
272
+ const zoneIsFilterRegexNegatedChangedPayload = payload;
273
+ const oldIsFilterRegexNegated = zoneIsFilterRegexNegatedChangedPayload.oldIsFilterRegexNegated;
274
+ const newIsFilterRegexNegated = zoneIsFilterRegexNegatedChangedPayload.newIsFilterRegexNegated;
275
+ this.emitToEngine(CaptureToEngineEventType.ZoneIsFilterRegexNegatedChanged, {
276
+ zone: this,
277
+ oldIsFilterRegexNegated,
278
+ newIsFilterRegexNegated
279
+ });
280
+ propertiesChanged.push("isFilterRegexNegated");
281
+ }
240
282
  if (type === CaptureZoneEventType.ZoneOutputRegexChanged) {
241
283
  const zoneOutputRegexChangedPayload = payload;
242
284
  const oldOutputRegex = zoneOutputRegexChangedPayload.oldOutputRegex;
@@ -259,6 +301,17 @@ var CaptureZoneBase = class {
259
301
  });
260
302
  propertiesChanged.push("outputReplacement");
261
303
  }
304
+ if (type === CaptureZoneEventType.ZoneOutputFunctionChanged) {
305
+ const zoneOutputFunctionChangedPayload = payload;
306
+ const oldOutputFunction = zoneOutputFunctionChangedPayload.oldOutputFunction;
307
+ const newOutputFunction = zoneOutputFunctionChangedPayload.newOutputFunction;
308
+ this.emitToEngine(CaptureToEngineEventType.ZoneOutputFunctionChanged, {
309
+ zone: this,
310
+ oldOutputFunction,
311
+ newOutputFunction
312
+ });
313
+ propertiesChanged.push("outputFunction");
314
+ }
262
315
  if (type === CaptureZoneEventType.ZoneRequiredChanged) {
263
316
  const zoneRequiredChangedPayload = payload;
264
317
  const oldRequired = zoneRequiredChangedPayload.oldRequired;
@@ -303,6 +356,17 @@ var CaptureZoneBase = class {
303
356
  });
304
357
  propertiesChanged.push("defaultValueIfEmpty");
305
358
  }
359
+ if (type === CaptureZoneEventType.ZoneFeatureFlagsChanged) {
360
+ const zoneFeatureFlagsChangedPayload = payload;
361
+ const oldFeatureFlags = zoneFeatureFlagsChangedPayload.oldFeatureFlags;
362
+ const newFeatureFlags = zoneFeatureFlagsChangedPayload.newFeatureFlags;
363
+ this.emitToEngine(CaptureToEngineEventType.ZoneFeatureFlagsChanged, {
364
+ zone: this,
365
+ oldFeatureFlags,
366
+ newFeatureFlags
367
+ });
368
+ propertiesChanged.push("featureFlags");
369
+ }
306
370
  if (propertiesChanged.length > 0) {
307
371
  this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged });
308
372
  }
@@ -372,6 +436,24 @@ var CaptureZoneBase = class {
372
436
  this._filterRegex = value;
373
437
  this.emitZoneEvent(CaptureZoneEventType.ZoneFilterRegexChanged, { oldFilterRegex, newFilterRegex: value });
374
438
  }
439
+ get applyFilterRegexToWholeLines() {
440
+ return this._applyFilterRegexToWholeLines;
441
+ }
442
+ set applyFilterRegexToWholeLines(value) {
443
+ if (value === this._applyFilterRegexToWholeLines) return;
444
+ const oldApplyFilterRegexToWholeLines = this._applyFilterRegexToWholeLines;
445
+ this._applyFilterRegexToWholeLines = value;
446
+ this.emitZoneEvent(CaptureZoneEventType.ZoneApplyFilterRegexToWholeLinesChanged, { oldApplyFilterRegexToWholeLines, newApplyFilterRegexToWholeLines: value });
447
+ }
448
+ get isFilterRegexNegated() {
449
+ return this._isFilterRegexNegated;
450
+ }
451
+ set isFilterRegexNegated(value) {
452
+ if (value === this._isFilterRegexNegated) return;
453
+ const oldIsFilterRegexNegated = this._isFilterRegexNegated;
454
+ this._isFilterRegexNegated = value;
455
+ this.emitZoneEvent(CaptureZoneEventType.ZoneIsFilterRegexNegatedChanged, { oldIsFilterRegexNegated, newIsFilterRegexNegated: value });
456
+ }
375
457
  get outputRegex() {
376
458
  return this._outputRegex ?? null;
377
459
  }
@@ -392,6 +474,15 @@ var CaptureZoneBase = class {
392
474
  this._outputReplacement = value;
393
475
  this.emitZoneEvent(CaptureZoneEventType.ZoneOutputReplacementChanged, { oldOutputReplacement, newOutputReplacement: value });
394
476
  }
477
+ get outputFunction() {
478
+ return this._outputFunction ?? null;
479
+ }
480
+ set outputFunction(value) {
481
+ if (value === this._outputFunction) return;
482
+ const oldOutputFunction = this._outputFunction;
483
+ this._outputFunction = value;
484
+ this.emitZoneEvent(CaptureZoneEventType.ZoneOutputFunctionChanged, { oldOutputFunction, newOutputFunction: value });
485
+ }
395
486
  get required() {
396
487
  return this._required;
397
488
  }
@@ -430,6 +521,28 @@ var CaptureZoneBase = class {
430
521
  this._defaultValueIfEmpty = value;
431
522
  this.emitZoneEvent(CaptureZoneEventType.ZoneDefaultValueIfEmptyChanged, { oldDefaultValueIfEmpty, newDefaultValueIfEmpty: value });
432
523
  }
524
+ get featureFlags() {
525
+ return this._featureFlags ?? null;
526
+ }
527
+ set featureFlags(value) {
528
+ if (value === this._featureFlags) return;
529
+ if ((value === void 0 || value === null || value.length == 0) && (this._featureFlags === void 0 || this._featureFlags === null || this._featureFlags.length == 0)) return;
530
+ if (value && this._featureFlags && this.sameStrings(value, this._featureFlags)) return;
531
+ const oldFeatureFlags = this._featureFlags;
532
+ this._featureFlags = value;
533
+ this.emitZoneEvent(CaptureZoneEventType.ZoneFeatureFlagsChanged, { oldFeatureFlags, newFeatureFlags: value });
534
+ }
535
+ sameStrings(a, b) {
536
+ if (a.length !== b.length) return false;
537
+ const map = /* @__PURE__ */ new Map();
538
+ for (const s of a) map.set(s, (map.get(s) ?? 0) + 1);
539
+ for (const s of b) {
540
+ const count = map.get(s);
541
+ if (!count) return false;
542
+ count === 1 ? map.delete(s) : map.set(s, count - 1);
543
+ }
544
+ return map.size === 0;
545
+ }
433
546
  /* EVENT HANDLING METHODS */
434
547
  setEngineEventSink(callback) {
435
548
  this.engineEventSink = callback;
@@ -479,9 +592,51 @@ var CaptureZoneBase = class {
479
592
  }
480
593
  }
481
594
  };
595
+ var StaticZone = class extends CaptureZoneBase {
596
+ constructor(name, dataType = null, value = null, featureFlags, opts = {}) {
597
+ super(name, new import_dytools_geometry.Rectangle(0, 0, 10, 10), true, null, false, false, null, null, null, false, dataType, false, value, featureFlags, opts);
598
+ this.type = "static";
599
+ }
600
+ get defaultOptions() {
601
+ return {
602
+ ...super.defaultOptions
603
+ };
604
+ }
605
+ handleInternalZoneEvent(type, payload) {
606
+ super.handleInternalZoneEvent(type, payload);
607
+ if (this.canvasManager === null) {
608
+ this.emitToEngine(CaptureToEngineEventType.ZoneError, { zone: this, message: "Missing CanvasManager" });
609
+ return;
610
+ }
611
+ if (type === CaptureZoneEventType.ZoneCanvasManagerSet) {
612
+ this.primaryCanvasRectangleId = this.canvasManager.addRectangle(this.rect, this.name, this.options.zoneColor ?? "black", true, true);
613
+ }
614
+ }
615
+ handleEvent(id, type, payload) {
616
+ if (this.id !== id) {
617
+ return;
618
+ }
619
+ }
620
+ toExternal(docWidth, docHeight) {
621
+ return {
622
+ TemplateZoneId: this.id,
623
+ Name: this.name,
624
+ Type: "TemplateStaticZone",
625
+ DataType: this.dataType,
626
+ Value: this.defaultValueIfEmpty,
627
+ FeatureFlags: this.featureFlags ?? void 0
628
+ };
629
+ }
630
+ get value() {
631
+ return this.defaultValueIfEmpty;
632
+ }
633
+ set value(value) {
634
+ this.defaultValueIfEmpty = value;
635
+ }
636
+ };
482
637
  var SimpleZone = class extends CaptureZoneBase {
483
- constructor(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, opts = {}) {
484
- super(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required, dataType, excludeFromOutput, defaultValueIfEmpty, opts);
638
+ constructor(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, featureFlags, opts = {}) {
639
+ super(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required, dataType, excludeFromOutput, defaultValueIfEmpty, featureFlags, opts);
485
640
  this.type = "simple";
486
641
  this.ocrOverlayIds = [];
487
642
  this.lastMatchHash = "";
@@ -556,12 +711,16 @@ var SimpleZone = class extends CaptureZoneBase {
556
711
  WidthAbsolute: this.rect.size.width,
557
712
  HeightAbsolute: this.rect.size.height,
558
713
  RegExFilter: this.filterRegex,
714
+ ApplyRegExFilterToWholeLines: this.applyFilterRegexToWholeLines,
715
+ IsRegExFilterNegated: this.isFilterRegexNegated,
559
716
  RegExOutput: this.outputRegex,
560
717
  RegExReplacement: this.outputReplacement,
718
+ OutputFunction: this.outputFunction,
561
719
  Required: this.required,
562
720
  DataType: this.dataType,
563
721
  ExcludeFromOutput: this.excludeFromOutput,
564
- DefaultValueIfEmpty: this.defaultValueIfEmpty
722
+ DefaultValueIfEmpty: this.defaultValueIfEmpty,
723
+ FeatureFlags: this.featureFlags ?? void 0
565
724
  };
566
725
  }
567
726
  };
@@ -588,14 +747,15 @@ var AnchorChildZone = class extends SimpleZone {
588
747
  }
589
748
  };
590
749
  var AnchorZone = class extends CaptureZoneBase {
591
- constructor(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, opts = {}) {
592
- super(name, rect, hidden, filterRegex, outputRegex, outputReplacement, required, dataType, excludeFromOutput, defaultValueIfEmpty, opts);
750
+ constructor(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required = false, dataType = null, excludeFromOutput = false, defaultValueIfEmpty = null, featureFlags, opts = {}) {
751
+ super(name, rect, hidden, filterRegex, applyFilterRegexToWholeLines, isFilterRegexNegated, outputRegex, outputReplacement, outputFunction, required, dataType, excludeFromOutput, defaultValueIfEmpty, featureFlags, opts);
593
752
  this.type = "anchor";
594
- //private primaryCanvasRectangleId: string | null = null;
595
753
  this._anchorLocation = "MiddleLeft";
596
754
  this._groupChildren = true;
755
+ this._hasColumnHeaders = false;
756
+ this._excludeColumnHeaders = false;
757
+ this._isAnchorPerLine = false;
597
758
  this.children = [];
598
- //canvasEngineIds: string[] = [];
599
759
  this.ocrOverlayIds = [];
600
760
  this.lastMatchHash = "";
601
761
  this.currentAnchorPoint = null;
@@ -692,6 +852,33 @@ var AnchorZone = class extends CaptureZoneBase {
692
852
  this._groupChildren = value;
693
853
  this.emitZoneEvent(CaptureZoneEventType.ZoneGroupChildrenChanged, { oldGroupChildren, newGroupChildren: value });
694
854
  }
855
+ get hasColumnHeaders() {
856
+ return this._hasColumnHeaders;
857
+ }
858
+ set hasColumnHeaders(value) {
859
+ if (value === this._hasColumnHeaders) return;
860
+ const oldHasColumnHeaders = this._hasColumnHeaders;
861
+ this._hasColumnHeaders = value;
862
+ this.emitZoneEvent(CaptureZoneEventType.ZoneHasColumnHeadersChanged, { oldHasColumnHeaders, newHasColumnHeaders: value });
863
+ }
864
+ get excludeColumnHeaders() {
865
+ return this._excludeColumnHeaders;
866
+ }
867
+ set excludeColumnHeaders(value) {
868
+ if (value === this._excludeColumnHeaders) return;
869
+ const oldExcludeColumnHeaders = this._excludeColumnHeaders;
870
+ this._excludeColumnHeaders = value;
871
+ this.emitZoneEvent(CaptureZoneEventType.ZoneExcludeColumnHeadersChanged, { oldExcludeColumnHeaders, newExcludeColumnHeaders: value });
872
+ }
873
+ get isAnchorPerLine() {
874
+ return this._isAnchorPerLine;
875
+ }
876
+ set isAnchorPerLine(value) {
877
+ if (value === this._isAnchorPerLine) return;
878
+ const oldIsAnchorPerLine = this._isAnchorPerLine;
879
+ this._isAnchorPerLine = value;
880
+ this.emitZoneEvent(CaptureZoneEventType.ZoneIsAnchorPerLineChanged, { oldIsAnchorPerLine, newIsAnchorPerLine: value });
881
+ }
695
882
  handleInternalZoneEvent(type, payload) {
696
883
  super.handleInternalZoneEvent(type, payload);
697
884
  if (this.canvasManager === null) {
@@ -723,6 +910,39 @@ var AnchorZone = class extends CaptureZoneBase {
723
910
  });
724
911
  this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["groupChildren"] });
725
912
  }
913
+ if (type === CaptureZoneEventType.ZoneHasColumnHeadersChanged) {
914
+ const zoneHasColumnHeadersChangedPayload = payload;
915
+ const oldHasColumnHeaders = zoneHasColumnHeadersChangedPayload.oldHasColumnHeaders;
916
+ const newHasColumnHeaders = zoneHasColumnHeadersChangedPayload.newHasColumnHeaders;
917
+ this.emitToEngine(CaptureToEngineEventType.ZoneHasColumnHeadersChanged, {
918
+ zone: this,
919
+ oldHasColumnHeaders,
920
+ newHasColumnHeaders
921
+ });
922
+ this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["hasColumnHeaders"] });
923
+ }
924
+ if (type === CaptureZoneEventType.ZoneExcludeColumnHeadersChanged) {
925
+ const zoneExcludeColumnHeadersChangedPayload = payload;
926
+ const oldExcludeColumnHeaders = zoneExcludeColumnHeadersChangedPayload.oldExcludeColumnHeaders;
927
+ const newExcludeColumnHeaders = zoneExcludeColumnHeadersChangedPayload.newExcludeColumnHeaders;
928
+ this.emitToEngine(CaptureToEngineEventType.ZoneExcludeColumnHeadersChanged, {
929
+ zone: this,
930
+ oldExcludeColumnHeaders,
931
+ newExcludeColumnHeaders
932
+ });
933
+ this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["excludeColumnHeaders"] });
934
+ }
935
+ if (type === CaptureZoneEventType.ZoneIsAnchorPerLineChanged) {
936
+ const zoneIsAnchorPerLineChangedPayload = payload;
937
+ const oldIsAnchorPerLine = zoneIsAnchorPerLineChangedPayload.oldIsAnchorPerLine;
938
+ const newIsAnchorPerLine = zoneIsAnchorPerLineChangedPayload.newIsAnchorPerLine;
939
+ this.emitToEngine(CaptureToEngineEventType.ZoneIsAnchorPerLineChanged, {
940
+ zone: this,
941
+ oldIsAnchorPerLine,
942
+ newIsAnchorPerLine
943
+ });
944
+ this.emitToEngine(CaptureToEngineEventType.ZoneChanged, { zone: this, propertiesChanged: ["isAnchorPerLine"] });
945
+ }
726
946
  if (type === CaptureZoneEventType.ZoneHiddenChanged) {
727
947
  const zoneHiddenChangedPayload = payload;
728
948
  this.ocrOverlayIds.forEach((id) => this.canvasManager?.setVisibility(id, !zoneHiddenChangedPayload.newHidden));
@@ -818,8 +1038,11 @@ var AnchorZone = class extends CaptureZoneBase {
818
1038
  WidthAbsolute: this.rect.size.width,
819
1039
  HeightAbsolute: this.rect.size.height,
820
1040
  RegExFilter: this.filterRegex,
1041
+ ApplyRegExFilterToWholeLines: this.applyFilterRegexToWholeLines,
1042
+ IsRegExFilterNegated: this.isFilterRegexNegated,
821
1043
  RegExOutput: this.outputRegex,
822
1044
  RegExReplacement: this.outputReplacement,
1045
+ OutputFunction: this.outputFunction,
823
1046
  Required: this.required,
824
1047
  DataType: this.dataType,
825
1048
  ExcludeFromOutput: this.excludeFromOutput,
@@ -828,6 +1051,10 @@ var AnchorZone = class extends CaptureZoneBase {
828
1051
  AnchorLocationXAbsoluteHint: this.currentAnchorPoint?.x,
829
1052
  AnchorLocationYAbsoluteHint: this.currentAnchorPoint?.y,
830
1053
  GroupChildrenInSubRecord: this.groupChildren,
1054
+ HasColumnHeaders: this.hasColumnHeaders,
1055
+ ExcludeColumnHeaders: this.excludeColumnHeaders,
1056
+ IsAnchorPerLine: this.isAnchorPerLine,
1057
+ FeatureFlags: this.featureFlags ?? void 0,
831
1058
  ChildZones: this.children.map((e) => e instanceof AnchorChildZone ? e.toExternalChild(docWidth, docHeight, this.currentAnchorPoint || this.rect.origin) ?? null : e.toExternal(docWidth, docHeight) ?? null).filter((e) => e !== null)
832
1059
  };
833
1060
  }
@@ -1094,7 +1321,6 @@ var CaptureEngine = class {
1094
1321
  });
1095
1322
  this.engine.on(import_dytools_canvas_engine.EngineEventType.EngineRenderStarted, () => {
1096
1323
  this.emitExternal(CapturePublicEventType.CaptureRenderStarted, {});
1097
- this.doRender();
1098
1324
  });
1099
1325
  this.engine.on(import_dytools_canvas_engine.EngineEventType.EngineRenderCompleted, () => {
1100
1326
  this.emitExternal(CapturePublicEventType.CaptureRenderCompleted, {});
@@ -1179,6 +1405,18 @@ var CaptureEngine = class {
1179
1405
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1180
1406
  this.refreshMatches();
1181
1407
  }
1408
+ if (type === CaptureToEngineEventType.ZoneApplyFilterRegexToWholeLinesChanged) {
1409
+ const zoneApplyFilterRegexToWholeLinesChangedPayload = payload;
1410
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneApplyFilterRegexToWholeLinesChangedPayload.zone, propertiesChanged: ["applyFilterRegexToWholeLines"] });
1411
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1412
+ this.refreshMatches();
1413
+ }
1414
+ if (type === CaptureToEngineEventType.ZoneIsFilterRegexNegatedChanged) {
1415
+ const zoneIsFilterRegexNegatedChangedPayload = payload;
1416
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneIsFilterRegexNegatedChangedPayload.zone, propertiesChanged: ["isFilterRegexNegated"] });
1417
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1418
+ this.refreshMatches();
1419
+ }
1182
1420
  if (type === CaptureToEngineEventType.ZoneOutputRegexChanged) {
1183
1421
  const zoneOutputRegexChangedPayload = payload;
1184
1422
  this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneOutputRegexChangedPayload.zone, propertiesChanged: ["outputRegex"] });
@@ -1191,6 +1429,12 @@ var CaptureEngine = class {
1191
1429
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1192
1430
  this.refreshMatches();
1193
1431
  }
1432
+ if (type === CaptureToEngineEventType.ZoneOutputFunctionChanged) {
1433
+ const zoneOutputFunctionChangedPayload = payload;
1434
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneOutputFunctionChangedPayload.zone, propertiesChanged: ["outputFunction"] });
1435
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1436
+ this.refreshMatches();
1437
+ }
1194
1438
  if (type === CaptureToEngineEventType.ZoneRequiredChanged) {
1195
1439
  const zoneRequiredChangedPayload = payload;
1196
1440
  this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneRequiredChangedPayload.zone, propertiesChanged: ["required"] });
@@ -1223,6 +1467,30 @@ var CaptureEngine = class {
1223
1467
  this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1224
1468
  this.refreshMatches();
1225
1469
  }
1470
+ if (type === CaptureToEngineEventType.ZoneFeatureFlagsChanged) {
1471
+ const zoneFeatureFlagsChangedPayload = payload;
1472
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneFeatureFlagsChangedPayload.zone, propertiesChanged: ["featureFlags"] });
1473
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1474
+ this.refreshMatches();
1475
+ }
1476
+ if (type === CaptureToEngineEventType.ZoneHasColumnHeadersChanged) {
1477
+ const zoneHasColumnHeadersChangedPayload = payload;
1478
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneHasColumnHeadersChangedPayload.zone, propertiesChanged: ["hasColumnHeaders"] });
1479
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1480
+ this.refreshMatches();
1481
+ }
1482
+ if (type === CaptureToEngineEventType.ZoneExcludeColumnHeadersChanged) {
1483
+ const zoneExcludeColumnHeadersChangedPayload = payload;
1484
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneExcludeColumnHeadersChangedPayload.zone, propertiesChanged: ["excludeColumnHeaders"] });
1485
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1486
+ this.refreshMatches();
1487
+ }
1488
+ if (type === CaptureToEngineEventType.ZoneIsAnchorPerLineChanged) {
1489
+ const zoneIsAnchorPerLineChangedPayload = payload;
1490
+ this.emitExternal(CapturePublicEventType.ZoneChanged, { zone: zoneIsAnchorPerLineChangedPayload.zone, propertiesChanged: ["isAnchorPerLine"] });
1491
+ this.emitExternal(CapturePublicEventType.TemplateChanged, {});
1492
+ this.refreshMatches();
1493
+ }
1226
1494
  }
1227
1495
  onZoneAdded(zone, parentZone, excludeOcrMatches = false) {
1228
1496
  zone.setEngineEventSink?.(
@@ -1254,10 +1522,6 @@ var CaptureEngine = class {
1254
1522
  const zoneId = parts[0];
1255
1523
  return this.allZonesFlattened.find((z) => z.id === zoneId);
1256
1524
  }
1257
- doRender() {
1258
- for (const zone of this.allZonesFlattened) {
1259
- }
1260
- }
1261
1525
  // ---- metered wrapper ----
1262
1526
  createMeteredFn(fn, minIntervalMs = 1e3) {
1263
1527
  let lastExec = 0;
@@ -1330,10 +1594,10 @@ var CaptureEngine = class {
1330
1594
  // --- in CaptureEngine.ts (or a new file) ---
1331
1595
  rectFromExternal(z, docW, docH) {
1332
1596
  return new import_dytools_geometry.Rectangle(
1333
- z.X * docW,
1334
- z.Y * docH,
1335
- z.Width * docW,
1336
- z.Height * docH
1597
+ (z.X ?? 0) * docW,
1598
+ (z.Y ?? 0) * docH,
1599
+ (z.Width ?? 10) * docW,
1600
+ (z.Height ?? 10) * docH
1337
1601
  );
1338
1602
  }
1339
1603
  zoneFromExternal(z, docW, docH, parentAnchorAbs) {
@@ -1343,12 +1607,16 @@ var CaptureEngine = class {
1343
1607
  this.rectFromExternal(z, docW, docH),
1344
1608
  false,
1345
1609
  z.RegExFilter ?? null,
1610
+ z.ApplyRegExFilterToWholeLines ?? true,
1611
+ z.IsRegExFilterNegated ?? false,
1346
1612
  z.RegExOutput ?? null,
1347
1613
  z.RegExReplacement ?? null,
1614
+ z.OutputFunction ?? null,
1348
1615
  z.Required ?? false,
1349
1616
  z.DataType ?? null,
1350
1617
  z.ExcludeFromOutput ?? false,
1351
1618
  z.DefaultValueIfEmpty ?? null,
1619
+ z.FeatureFlags ?? null,
1352
1620
  {
1353
1621
  zoneColor: this.options.anchorZoneColor,
1354
1622
  ocrMatchColor: this.options.anchorZoneOcrMatchColor,
@@ -1358,6 +1626,9 @@ var CaptureEngine = class {
1358
1626
  );
1359
1627
  if (z.AnchorLocation) anchor.anchorLocation = z.AnchorLocation;
1360
1628
  if (z.GroupChildrenInSubRecord !== void 0) anchor.groupChildren = z.GroupChildrenInSubRecord;
1629
+ if (z.HasColumnHeaders) anchor.hasColumnHeaders = z.HasColumnHeaders;
1630
+ if (z.ExcludeColumnHeaders) anchor.excludeColumnHeaders = z.ExcludeColumnHeaders;
1631
+ if (z.IsAnchorPerLine) anchor.isAnchorPerLine = z.IsAnchorPerLine;
1361
1632
  const anchorPoint = anchor.rect.origin;
1362
1633
  for (const childDto of z.ChildZones ?? []) {
1363
1634
  const child = this.zoneFromExternal(childDto, docW, docH, anchorPoint);
@@ -1367,42 +1638,65 @@ var CaptureEngine = class {
1367
1638
  return anchor;
1368
1639
  }
1369
1640
  if (parentAnchorAbs) {
1370
- const absX = parentAnchorAbs.x / docW + z.X;
1371
- const absY = parentAnchorAbs.y / docH + z.Y;
1641
+ const absX = parentAnchorAbs.x / docW + (z.X ?? 0);
1642
+ const absY = parentAnchorAbs.y / docH + (z.Y ?? 0);
1372
1643
  const childRect = new import_dytools_geometry.Rectangle(
1373
1644
  absX * docW,
1374
1645
  absY * docH,
1375
- z.Width * docW,
1376
- z.Height * docH
1646
+ (z.Width ?? 10) * docW,
1647
+ (z.Height ?? 10) * docH
1377
1648
  );
1378
1649
  return new AnchorChildZone(
1379
1650
  z.Name,
1380
1651
  childRect,
1381
1652
  false,
1382
1653
  z.RegExFilter ?? null,
1654
+ z.ApplyRegExFilterToWholeLines ?? true,
1655
+ z.IsRegExFilterNegated ?? false,
1383
1656
  z.RegExOutput ?? null,
1384
1657
  z.RegExReplacement ?? null,
1658
+ z.OutputFunction ?? null,
1385
1659
  z.Required ?? false,
1386
1660
  z.DataType ?? null,
1387
1661
  z.ExcludeFromOutput ?? false,
1388
1662
  z.DefaultValueIfEmpty ?? null,
1663
+ z.FeatureFlags ?? null,
1389
1664
  {
1390
1665
  zoneColor: this.options.anchorChildZoneColor,
1391
1666
  ocrMatchColor: this.options.anchorChildZoneOcrMatchColor
1392
1667
  }
1393
1668
  );
1394
1669
  }
1670
+ if (z.Type === "TemplateStaticZone") {
1671
+ const staticZone = new StaticZone(
1672
+ z.Name,
1673
+ z.DataType ?? null,
1674
+ z.Value ?? null,
1675
+ z.FeatureFlags ?? null,
1676
+ {
1677
+ zoneColor: this.options.anchorZoneColor,
1678
+ ocrMatchColor: this.options.anchorZoneOcrMatchColor,
1679
+ anchorPointColor: this.options.anchorZoneAnchorPointColor,
1680
+ zoneAdditionalChildrenColor: this.options.anchorZoneAdditionalChildrenColor
1681
+ }
1682
+ );
1683
+ return staticZone;
1684
+ }
1395
1685
  return new SimpleZone(
1396
1686
  z.Name,
1397
1687
  this.rectFromExternal(z, docW, docH),
1398
1688
  false,
1399
1689
  z.RegExFilter ?? null,
1690
+ z.ApplyRegExFilterToWholeLines ?? false,
1691
+ z.IsRegExFilterNegated ?? false,
1400
1692
  z.RegExOutput ?? null,
1401
1693
  z.RegExReplacement ?? null,
1694
+ z.OutputFunction ?? null,
1402
1695
  z.Required ?? false,
1403
1696
  z.DataType ?? null,
1404
1697
  z.ExcludeFromOutput ?? false,
1405
1698
  z.DefaultValueIfEmpty ?? null,
1699
+ z.FeatureFlags ?? null,
1406
1700
  {
1407
1701
  zoneColor: this.options.simpleZoneColor,
1408
1702
  ocrMatchColor: this.options.simpleZoneOcrMatchColor
@@ -1424,12 +1718,26 @@ var CaptureEngine = class {
1424
1718
  getZoneById(id) {
1425
1719
  return this.allZonesFlattened.find((z) => z.id === id);
1426
1720
  }
1721
+ /**
1722
+ * Add a new static zone
1723
+ */
1724
+ addStaticZone(makeCurrentSelected = false) {
1725
+ let newZone = new StaticZone(`Static ${this.zoneCounter++}`, null, null, null, {
1726
+ zoneColor: this.options.simpleZoneColor,
1727
+ ocrMatchColor: this.options.simpleZoneOcrMatchColor
1728
+ });
1729
+ this.zones.push(newZone);
1730
+ if (makeCurrentSelected) {
1731
+ this.setSelectedZones([newZone]);
1732
+ }
1733
+ return newZone;
1734
+ }
1427
1735
  /**
1428
1736
  * Add a new simple zone
1429
1737
  * @param bounds Rectangle
1430
1738
  */
1431
1739
  addSimpleZone(bounds, makeCurrentSelected = false) {
1432
- let newZone = new SimpleZone("Test1", bounds, false, null, null, null, false, null, false, null, {
1740
+ let newZone = new SimpleZone(`Simple ${this.zoneCounter++}`, bounds, false, null, true, false, null, null, null, false, null, false, null, null, {
1433
1741
  zoneColor: this.options.simpleZoneColor,
1434
1742
  ocrMatchColor: this.options.simpleZoneOcrMatchColor
1435
1743
  });
@@ -1444,7 +1752,7 @@ var CaptureEngine = class {
1444
1752
  * @param bounds Rectangle
1445
1753
  */
1446
1754
  addAnchorZone(bounds, makeCurrentSelected = false) {
1447
- let newZone = new AnchorZone(`Anchor ${this.zoneCounter++}`, bounds, false, null, null, null, false, null, false, null, {
1755
+ let newZone = new AnchorZone(`Anchor ${this.zoneCounter++}`, bounds, false, null, true, false, null, null, null, false, null, false, null, null, {
1448
1756
  zoneColor: this.options.anchorZoneColor,
1449
1757
  ocrMatchColor: this.options.anchorZoneOcrMatchColor,
1450
1758
  anchorPointColor: this.options.anchorZoneAnchorPointColor,
@@ -1466,7 +1774,7 @@ var CaptureEngine = class {
1466
1774
  if (!anchorZone) {
1467
1775
  throw new Error(`Anchor zone with id ${anchorId} not found`);
1468
1776
  }
1469
- let newZone = new AnchorChildZone(`Child ${this.zoneCounter++}`, bounds, false, null, null, null, false, null, false, null, {
1777
+ let newZone = new AnchorChildZone(`Child ${this.zoneCounter++}`, bounds, false, null, true, false, null, null, null, false, null, false, null, null, {
1470
1778
  zoneColor: this.options.anchorChildZoneColor,
1471
1779
  ocrMatchColor: this.options.anchorChildZoneOcrMatchColor
1472
1780
  });
@@ -1535,18 +1843,39 @@ var CaptureEngine = class {
1535
1843
  if (patch.filterRegex !== void 0) {
1536
1844
  zone.filterRegex = patch.filterRegex;
1537
1845
  }
1846
+ if (patch.applyFilterRegexToWholeLines !== void 0) {
1847
+ zone.applyFilterRegexToWholeLines = patch.applyFilterRegexToWholeLines;
1848
+ }
1849
+ if (patch.isFilterRegexNegated !== void 0) {
1850
+ zone.isFilterRegexNegated = patch.isFilterRegexNegated;
1851
+ }
1538
1852
  if (patch.outputRegex !== void 0) {
1539
1853
  zone.outputRegex = patch.outputRegex;
1540
1854
  }
1541
1855
  if (patch.outputReplacement !== void 0) {
1542
1856
  zone.outputReplacement = patch.outputReplacement;
1543
1857
  }
1858
+ if (patch.outputFunction !== void 0) {
1859
+ zone.outputFunction = patch.outputFunction;
1860
+ }
1544
1861
  if (patch.anchorLocation !== void 0) {
1545
1862
  zone.anchorLocation = patch.anchorLocation;
1546
1863
  }
1547
1864
  if (patch.groupChildren !== void 0) {
1548
1865
  zone.groupChildren = patch.groupChildren;
1549
1866
  }
1867
+ if (patch.featureFlags !== void 0) {
1868
+ zone.featureFlags = patch.featureFlags;
1869
+ }
1870
+ if (patch.hasColumnHeaders !== void 0) {
1871
+ zone.hasColumnHeaders = patch.hasColumnHeaders;
1872
+ }
1873
+ if (patch.excludeColumnHeaders !== void 0) {
1874
+ zone.excludeColumnHeaders = patch.excludeColumnHeaders;
1875
+ }
1876
+ if (patch.isAnchorPerLine !== void 0) {
1877
+ zone.isAnchorPerLine = patch.isAnchorPerLine;
1878
+ }
1550
1879
  if (patch.rect) {
1551
1880
  const b = patch.rect;
1552
1881
  if (b instanceof import_dytools_geometry.Rectangle) {