@mlightcad/common 1.2.5 → 1.2.7

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.
@@ -0,0 +1,198 @@
1
+ import { AcCmColorMethod } from './AcCmColorMethod';
2
+ /**
3
+ * Represents an AutoCAD-like entity color object.
4
+ *
5
+ * This class mimics ObjectARX `AcCmEntityColor`. It stores:
6
+ * - A color method (`AcCmColorMethod`)
7
+ * - A single numeric `value` that represents:
8
+ * - RGB (packed R/G/B)
9
+ * - ACI index
10
+ * - Layer index
11
+ *
12
+ * It uses lazy decoding/encoding to expose convenient getters/setters.
13
+ */
14
+ var AcCmEntityColor = /** @class */ (function () {
15
+ /**
16
+ * Constructs a new `AcCmEntityColor`.
17
+ *
18
+ * @param method Initial color method (defaults to `ByColor`)
19
+ * @param value Internal packed value (defaults to `0`)
20
+ */
21
+ function AcCmEntityColor(method, value) {
22
+ if (method === void 0) { method = AcCmColorMethod.ByColor; }
23
+ if (value === void 0) { value = 0; }
24
+ this._colorMethod = method;
25
+ this._value = value;
26
+ }
27
+ Object.defineProperty(AcCmEntityColor.prototype, "colorMethd", {
28
+ /**
29
+ * Gets the method used to determine the final color.
30
+ */
31
+ get: function () {
32
+ return this._colorMethod;
33
+ },
34
+ enumerable: false,
35
+ configurable: true
36
+ });
37
+ Object.defineProperty(AcCmEntityColor.prototype, "red", {
38
+ // ---------------------------------------------------------------------
39
+ // RGB accessors
40
+ // ---------------------------------------------------------------------
41
+ /**
42
+ * Gets the red component (0–255). Only valid when colorMethod = ByColor.
43
+ */
44
+ get: function () {
45
+ return (this._value >> 16) & 0xff;
46
+ },
47
+ /**
48
+ * Sets the red component and updates the packed RGB value.
49
+ */
50
+ set: function (v) {
51
+ this._colorMethod = AcCmColorMethod.ByColor;
52
+ this._value = (this._value & 0x00ffff) | ((v & 0xff) << 16);
53
+ },
54
+ enumerable: false,
55
+ configurable: true
56
+ });
57
+ Object.defineProperty(AcCmEntityColor.prototype, "green", {
58
+ /**
59
+ * Gets the green component (0–255). Only valid when colorMethod = ByColor.
60
+ */
61
+ get: function () {
62
+ return (this._value >> 8) & 0xff;
63
+ },
64
+ /**
65
+ * Sets the green component and updates the packed RGB value.
66
+ */
67
+ set: function (v) {
68
+ this._colorMethod = AcCmColorMethod.ByColor;
69
+ this._value = (this._value & 0xff00ff) | ((v & 0xff) << 8);
70
+ },
71
+ enumerable: false,
72
+ configurable: true
73
+ });
74
+ Object.defineProperty(AcCmEntityColor.prototype, "blue", {
75
+ /**
76
+ * Gets the blue component (0–255). Only valid when colorMethod = ByColor.
77
+ */
78
+ get: function () {
79
+ return this._value & 0xff;
80
+ },
81
+ /**
82
+ * Sets the blue component and updates the packed RGB value.
83
+ */
84
+ set: function (v) {
85
+ this._colorMethod = AcCmColorMethod.ByColor;
86
+ this._value = (this._value & 0xffff00) | (v & 0xff);
87
+ },
88
+ enumerable: false,
89
+ configurable: true
90
+ });
91
+ /**
92
+ * Sets all RGB components.
93
+ *
94
+ * @param r Red (0–255)
95
+ * @param g Green (0–255)
96
+ * @param b Blue (0–255)
97
+ */
98
+ AcCmEntityColor.prototype.setRGB = function (r, g, b) {
99
+ this._colorMethod = AcCmColorMethod.ByColor;
100
+ this._value = ((r & 0xff) << 16) | ((g & 0xff) << 8) | (b & 0xff);
101
+ };
102
+ Object.defineProperty(AcCmEntityColor.prototype, "colorIndex", {
103
+ // ---------------------------------------------------------------------
104
+ // ACI accessors
105
+ // ---------------------------------------------------------------------
106
+ /**
107
+ * Gets the AutoCAD Color Index (ACI). Only valid when colorMethod = ByACI.
108
+ */
109
+ get: function () {
110
+ return this._value;
111
+ },
112
+ /**
113
+ * Sets the AutoCAD Color Index (ACI).
114
+ */
115
+ set: function (index) {
116
+ this._colorMethod = AcCmColorMethod.ByACI;
117
+ this._value = index;
118
+ },
119
+ enumerable: false,
120
+ configurable: true
121
+ });
122
+ Object.defineProperty(AcCmEntityColor.prototype, "layerIndex", {
123
+ // ---------------------------------------------------------------------
124
+ // Layer index accessors
125
+ // ---------------------------------------------------------------------
126
+ /**
127
+ * Gets the referenced layer index. Only valid when colorMethod = ByLayer.
128
+ */
129
+ get: function () {
130
+ return this._value;
131
+ },
132
+ /**
133
+ * Sets the layer index for ByLayer color mode.
134
+ */
135
+ set: function (index) {
136
+ this._colorMethod = AcCmColorMethod.ByLayer;
137
+ this._value = index;
138
+ },
139
+ enumerable: false,
140
+ configurable: true
141
+ });
142
+ // ---------------------------------------------------------------------
143
+ // Utility methods
144
+ // ---------------------------------------------------------------------
145
+ /**
146
+ * Returns true if the color method is ByColor (explicit RGB).
147
+ */
148
+ AcCmEntityColor.prototype.isByColor = function () {
149
+ return this._colorMethod === AcCmColorMethod.ByColor;
150
+ };
151
+ /**
152
+ * Returns true if the color method is ByLayer.
153
+ */
154
+ AcCmEntityColor.prototype.isByLayer = function () {
155
+ return this._colorMethod === AcCmColorMethod.ByLayer;
156
+ };
157
+ /**
158
+ * Returns true if the color method is ByBlock.
159
+ */
160
+ AcCmEntityColor.prototype.isByBlock = function () {
161
+ return this._colorMethod === AcCmColorMethod.ByBlock;
162
+ };
163
+ /**
164
+ * Returns true if the color method is ByACI.
165
+ */
166
+ AcCmEntityColor.prototype.isByACI = function () {
167
+ return this._colorMethod === AcCmColorMethod.ByACI;
168
+ };
169
+ /**
170
+ * Returns true if color is uninitialized or invalid.
171
+ */
172
+ AcCmEntityColor.prototype.isNone = function () {
173
+ return this._colorMethod === AcCmColorMethod.None;
174
+ };
175
+ Object.defineProperty(AcCmEntityColor.prototype, "rawValue", {
176
+ /**
177
+ * Gets the packed internal value.
178
+ *
179
+ * - RGB → packed 24-bit integer
180
+ * - ACI → index
181
+ * - Layer → index
182
+ */
183
+ get: function () {
184
+ return this._value;
185
+ },
186
+ /**
187
+ * Sets a raw internal value. The meaning depends on `colorMethod`.
188
+ */
189
+ set: function (v) {
190
+ this._value = v;
191
+ },
192
+ enumerable: false,
193
+ configurable: true
194
+ });
195
+ return AcCmEntityColor;
196
+ }());
197
+ export { AcCmEntityColor };
198
+ //# sourceMappingURL=AcCmEntityColor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcCmEntityColor.js","sourceRoot":"","sources":["../src/AcCmEntityColor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD;;;;;;;;;;;GAWG;AACH;IAeE;;;;;OAKG;IACH,yBACE,MAAiD,EACjD,KAAiB;QADjB,uBAAA,EAAA,SAA0B,eAAe,CAAC,OAAO;QACjD,sBAAA,EAAA,SAAiB;QAEjB,IAAI,CAAC,YAAY,GAAG,MAAM,CAAA;QAC1B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAKD,sBAAI,uCAAU;QAHd;;WAEG;aACH;YACE,OAAO,IAAI,CAAC,YAAY,CAAA;QAC1B,CAAC;;;OAAA;IASD,sBAAI,gCAAG;QAPP,wEAAwE;QACxE,gBAAgB;QAChB,wEAAwE;QAExE;;WAEG;aACH;YACE,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;QACnC,CAAC;QAED;;WAEG;aACH,UAAQ,CAAS;YACf,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,OAAO,CAAA;YAC3C,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,CAAA;QAC7D,CAAC;;;OARA;IAaD,sBAAI,kCAAK;QAHT;;WAEG;aACH;YACE,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,GAAG,IAAI,CAAA;QAClC,CAAC;QAED;;WAEG;aACH,UAAU,CAAS;YACjB,IAAI,CAAC,YAAY,GAAG,eAAe,CAAC,OAAO,CAAA;YAC3C,IAAI,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC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CAAC,MAAM,GAAG,KAAK,CAAA;QACrB,CAAC;;;OARA;IAUD,wEAAwE;IACxE,kBAAkB;IAClB,wEAAwE;IAExE;;OAEG;IACH,mCAAS,GAAT;QACE,OAAO,IAAI,CAAC,YAAY,KAAK,eAAe,CAAC,OAAO,CAAA;IACtD,CAAC;IAED;;OAEG;IACH,mCAAS,GAAT;QACE,OAAO,IAAI,CAAC,YAAY,KAAK,eAAe,CAAC,OAAO,CAAA;IACtD,CAAC;IAED;;OAEG;IACH,mCAAS,GAAT;QACE,OAAO,IAAI,CAAC,YAAY,KAAK,eAAe,CAAC,OAAO,CAAA;IACtD,CAAC;IAED;;OAEG;IACH,iCAAO,GAAP;QACE,OAAO,IAAI,CAAC,YAAY,KAAK,eAAe,CAAC,KAAK,CAAA;IACpD,CAAC;IAED;;OAEG;IACH,gCAAM,GAAN;QACE,OAAO,IAAI,CAAC,YAAY,KAAK,eAAe,CAAC,IAAI,CAAA;IACnD,CAAC;IASD,sBAAI,qCAAQ;QAPZ;;;;;;WAMG;aACH;YACE,OAAO,IAAI,CAAC,MAAM,CAAA;QACpB,CAAC;QAED;;WAEG;aACH,UAAa,CAAS;YACpB,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA;QACjB,CAAC;;;OAPA;IAQH,sBAAC;AAAD,CAAC,AA/LD,IA+LC"}
@@ -37,6 +37,12 @@
37
37
  * ```
38
38
  */
39
39
  export declare function clone<T>(obj: T): T;
40
+ /**
41
+ * Deeply clones a value (object, array, Date, RegExp, or primitive)
42
+ * @param value The value to deep clone
43
+ * @returns A deep copy of the input value
44
+ */
45
+ export declare function deepClone<T>(value: T): T;
40
46
  /**
41
47
  * Assigns own enumerable properties of source objects to the destination object
42
48
  * for all destination properties that resolve to undefined.
@@ -1 +1 @@
1
- {"version":3,"file":"AcCmLodashUtils.d.ts","sourceRoot":"","sources":["../src/AcCmLodashUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH;;;GAGG;AAEH;;;;;;;;;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,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAczB;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAEvE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAkB/C;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAwD/D"}
@@ -92,6 +92,37 @@ export function clone(obj) {
92
92
  }
93
93
  return __assign({}, obj);
94
94
  }
95
+ /**
96
+ * Deeply clones a value (object, array, Date, RegExp, or primitive)
97
+ * @param value The value to deep clone
98
+ * @returns A deep copy of the input value
99
+ */
100
+ export function deepClone(value) {
101
+ // Handle primitives (string, number, boolean, null, undefined, symbol, bigint)
102
+ if (value === null || typeof value !== 'object') {
103
+ return value;
104
+ }
105
+ // Handle Date
106
+ if (value instanceof Date) {
107
+ return new Date(value.getTime());
108
+ }
109
+ // Handle RegExp
110
+ if (value instanceof RegExp) {
111
+ return new RegExp(value.source, value.flags);
112
+ }
113
+ // Handle Array
114
+ if (Array.isArray(value)) {
115
+ return value.map(deepClone);
116
+ }
117
+ // Handle plain objects
118
+ var clonedObj = {};
119
+ for (var key in value) {
120
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
121
+ clonedObj[key] = deepClone(value[key]);
122
+ }
123
+ }
124
+ return clonedObj;
125
+ }
95
126
  /**
96
127
  * Assigns own enumerable properties of source objects to the destination object
97
128
  * for all destination properties that resolve to undefined.
@@ -1 +1 @@
1
- {"version":3,"file":"AcCmLodashUtils.js","sourceRoot":"","sources":["../src/AcCmLodashUtils.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;;;;;;;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,CAAC;IAED,IAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAgC,CAAC,CAAA;IAC/D,IAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAgC,CAAC,CAAA;IAE/D,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,CAAC,MAAM,EAAE,CAAC;QAC1C,OAAO,KAAK,CAAA;IACd,CAAC;;QAED,KAAkB,IAAA,cAAA,SAAA,SAAS,CAAA,oCAAA,2DAAE,CAAC;YAAzB,IAAM,GAAG,sBAAA;YACZ,IACE,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,CAAC,IAAI,CACnC,KAAgC,EAChC,GAAG,CACJ;gBACD,CAAC,OAAO,CACL,KAAiC,CAAC,GAAG,CAAC,EACtC,KAAiC,CAAC,GAAG,CAAC,CACxC,EACD,CAAC;gBACD,OAAO,KAAK,CAAA;YACd,CAAC;QACH,CAAC;;;;;;;;;IAED,OAAO,IAAI,CAAA;AACb,CAAC"}
@@ -0,0 +1,201 @@
1
+ import { AcCmTransparencyMethod } from './AcCmTransparencyMethod';
2
+ /**
3
+ * Class representing transparency similar to AutoCAD’s `AcCmTransparency`.
4
+ *
5
+ * Stores both method and alpha information.
6
+ */
7
+ export declare class AcCmTransparency {
8
+ /** The transparency interpretation method. */
9
+ private _method;
10
+ /**
11
+ * Alpha value in range 0–255 where:
12
+ * - 0 is fully transparent
13
+ * - 255 is fully opaque
14
+ *
15
+ * Only valid when the method is `ByAlpha`.
16
+ */
17
+ private _alpha;
18
+ /**
19
+ * Creates a new transparency object.
20
+ *
21
+ * @param alpha
22
+ * When provided, constructs with `ByAlpha` method and sets alpha.
23
+ * Must be between 0 and 255.
24
+ */
25
+ constructor(alpha?: number);
26
+ /** Gets the current transparency method */
27
+ get method(): AcCmTransparencyMethod;
28
+ /**
29
+ * Sets the transparency method.
30
+ * If setting to ByAlpha with no prior alpha, alpha stays 255 (opaque).
31
+ *
32
+ * @param method The new transparency method
33
+ */
34
+ set method(method: AcCmTransparencyMethod);
35
+ /**
36
+ * Gets the alpha value.
37
+ * Only meaningful if `method === ByAlpha`.
38
+ */
39
+ get alpha(): number;
40
+ /**
41
+ * Sets the alpha value and force the method to `ByAlpha`.
42
+ *
43
+ * @param alpha 0–255 alpha, clamped internally if out of range
44
+ */
45
+ set alpha(alpha: number);
46
+ /**
47
+ * Gets the AutoCAD-style transparency percentage.
48
+ *
49
+ * Mapping rules:
50
+ * - 0% = fully opaque (alpha = 255)
51
+ * - 100% = fully transparent (alpha = 0)
52
+ *
53
+ * This matches how AutoCAD displays and stores transparency
54
+ * values in UI and DXF files.
55
+ *
56
+ * If the transparency method is not `ByAlpha`,
57
+ * this method returns `undefined`, because AutoCAD
58
+ * does not define a percentage for ByLayer or ByBlock.
59
+ *
60
+ * @returns Transparency percentage (0–100), or undefined
61
+ */
62
+ get percentage(): number | undefined;
63
+ /**
64
+ * Sets the transparency using an AutoCAD-style percentage.
65
+ *
66
+ * Mapping rules (AutoCAD compatible):
67
+ * - 0% → fully opaque (alpha = 255)
68
+ * - 100% → fully transparent (alpha = 0)
69
+ *
70
+ * Internally, the alpha value is calculated as:
71
+ * alpha = round(255 × (1 − percentage / 100))
72
+ *
73
+ * This method:
74
+ * - Forces the transparency method to `ByAlpha`
75
+ * - Clamps the percentage to the range 0–100
76
+ * - Preserves ObjectARX value semantics
77
+ *
78
+ * @param percentage Transparency percentage (0–100)
79
+ * @returns This instance (for fluent chaining)
80
+ *
81
+ * @example
82
+ * const t = new AcCmTransparency();
83
+ * t.setPercentage(50); // ≈ alpha 128
84
+ *
85
+ * t.setPercentage(0); // alpha = 255 (opaque)
86
+ * t.setPercentage(100); // alpha = 0 (clear)
87
+ */
88
+ set percentage(percentage: number);
89
+ /**
90
+ * Ensures alpha always stays within 0–255.
91
+ */
92
+ private static clampAlpha;
93
+ /**
94
+ * True if the method is `ByAlpha`.
95
+ */
96
+ get isByAlpha(): boolean;
97
+ /**
98
+ * True if the method is `ByBlock`.
99
+ */
100
+ get isByBlock(): boolean;
101
+ /**
102
+ * True if the method is `ByLayer`.
103
+ */
104
+ get isByLayer(): boolean;
105
+ /**
106
+ * True if transparency is exactly clear (alpha==0 and ByAlpha).
107
+ */
108
+ get isClear(): boolean;
109
+ /**
110
+ * True if transparency is solid (alpha==255 and ByAlpha).
111
+ */
112
+ get isSolid(): boolean;
113
+ /**
114
+ * True if current state is invalid (ErrorValue).
115
+ */
116
+ get isInvalid(): boolean;
117
+ /**
118
+ * Convert this transparency to an integer suitable for storage.
119
+ * Uses a simple bit-encoding: high­bits for method and low­bits for alpha.
120
+ *
121
+ * 31 24 23 8 7 0
122
+ * +-------------+--------------+------------+
123
+ * | flags | reserved | alpha |
124
+ * +-------------+--------------+------------+
125
+ */
126
+ serialize(): number;
127
+ /**
128
+ * Creates a deep copy of this transparency object.
129
+ *
130
+ * This mirrors the value-semantics of ObjectARX `AcCmTransparency`,
131
+ * where copying results in an independent object with the same
132
+ * transparency method and alpha value.
133
+ *
134
+ * @returns A new `AcCmTransparency` instance with identical state.
135
+ */
136
+ clone(): AcCmTransparency;
137
+ /**
138
+ * Compares this transparency with another one for equality.
139
+ *
140
+ * Two `AcCmTransparency` objects are considered equal if:
141
+ * - Their transparency methods are identical
142
+ * - Their alpha values are identical
143
+ *
144
+ * This mirrors the value semantics of ObjectARX
145
+ * `AcCmTransparency`.
146
+ *
147
+ * @param other The transparency to compare with
148
+ * @returns True if both represent the same transparency
149
+ *
150
+ * @example
151
+ * const a = new AcCmTransparency(128);
152
+ * const b = new AcCmTransparency(128);
153
+ * a.equals(b); // true
154
+ */
155
+ equals(other: AcCmTransparency): boolean;
156
+ /**
157
+ * Returns a human-readable string representation of the transparency.
158
+ *
159
+ * Behavior:
160
+ * - `"ByLayer"` if transparency is inherited from layer
161
+ * - `"ByBlock"` if transparency is inherited from block
162
+ * - Numeric alpha value (`"0"`–`"255"`) if method is `ByAlpha`
163
+ *
164
+ * This format is intentionally simple and mirrors common
165
+ * AutoCAD UI and DXF text usage.
166
+ *
167
+ * @returns String representation of the transparency
168
+ *
169
+ * @example
170
+ * new AcCmTransparency().toString(); // "ByLayer"
171
+ * new AcCmTransparency(128).toString(); // "128"
172
+ */
173
+ toString(): string;
174
+ /**
175
+ * Creates an `AcCmTransparency` instance from a string representation.
176
+ *
177
+ * Accepted formats:
178
+ * - `"ByLayer"` (case-insensitive)
179
+ * - `"ByBlock"` (case-insensitive)
180
+ * - Numeric alpha value `"0"`–`"255"`
181
+ *
182
+ * Invalid or out-of-range values will produce an
183
+ * `ErrorValue` transparency.
184
+ *
185
+ * @param value String to parse
186
+ * @returns Parsed `AcCmTransparency` instance
187
+ *
188
+ * @example
189
+ * AcCmTransparency.fromString("ByLayer");
190
+ * AcCmTransparency.fromString("128");
191
+ * AcCmTransparency.fromString("ByBlock");
192
+ */
193
+ static fromString(value: string): AcCmTransparency;
194
+ /**
195
+ * Deserialize an integer back into a transparency object.
196
+ *
197
+ * @param value 32-bit stored transparency representation
198
+ */
199
+ static deserialize(value: number): AcCmTransparency;
200
+ }
201
+ //# sourceMappingURL=AcCmTransparency.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AcCmTransparency.d.ts","sourceRoot":"","sources":["../src/AcCmTransparency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAA;AAEjE;;;;GAIG;AACH,qBAAa,gBAAgB;IAC3B,8CAA8C;IAC9C,OAAO,CAAC,OAAO,CAAwB;IAEvC;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAQ;IAEtB;;;;;;OAMG;gBACS,KAAK,CAAC,EAAE,MAAM;IAU1B,2CAA2C;IAC3C,IAAI,MAAM,IAAI,sBAAsB,CAEnC;IAED;;;;;OAKG;IACH,IAAI,MAAM,CAAC,MAAM,EAAE,sBAAsB,EAExC;IAED;;;OAGG;IACH,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;;OAIG;IACH,IAAI,KAAK,CAAC,KAAK,EAAE,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