@mlightcad/cad-simple-viewer 1.4.12 → 1.4.13

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 (160) hide show
  1. package/dist/index.js +15901 -10590
  2. package/dist/index.umd.cjs +55 -48
  3. package/dist/libredwg-parser-worker.js +4724 -4762
  4. package/lib/app/AcApDocManager.d.ts +60 -4
  5. package/lib/app/AcApDocManager.d.ts.map +1 -1
  6. package/lib/app/AcApDocManager.js +160 -33
  7. package/lib/app/AcApDocManager.js.map +1 -1
  8. package/lib/command/AcApArcCmd.d.ts.map +1 -1
  9. package/lib/command/AcApArcCmd.js +1 -1
  10. package/lib/command/AcApArcCmd.js.map +1 -1
  11. package/lib/command/AcApCircleCmd.d.ts +59 -0
  12. package/lib/command/AcApCircleCmd.d.ts.map +1 -1
  13. package/lib/command/AcApCircleCmd.js +489 -18
  14. package/lib/command/AcApCircleCmd.js.map +1 -1
  15. package/lib/command/AcApConvertToPngCmd.d.ts +35 -0
  16. package/lib/command/AcApConvertToPngCmd.d.ts.map +1 -0
  17. package/lib/command/{AcApZoomToBoxCmd.js → AcApConvertToPngCmd.js} +50 -26
  18. package/lib/command/AcApConvertToPngCmd.js.map +1 -0
  19. package/lib/command/AcApEllipseCmd.d.ts +87 -0
  20. package/lib/command/AcApEllipseCmd.d.ts.map +1 -0
  21. package/lib/command/AcApEllipseCmd.js +583 -0
  22. package/lib/command/AcApEllipseCmd.js.map +1 -0
  23. package/lib/command/AcApHatchCmd.d.ts +210 -0
  24. package/lib/command/AcApHatchCmd.d.ts.map +1 -0
  25. package/lib/command/AcApHatchCmd.js +808 -0
  26. package/lib/command/AcApHatchCmd.js.map +1 -0
  27. package/lib/command/AcApLayerCmd.d.ts +217 -0
  28. package/lib/command/AcApLayerCmd.d.ts.map +1 -0
  29. package/lib/command/AcApLayerCmd.js +768 -0
  30. package/lib/command/AcApLayerCmd.js.map +1 -0
  31. package/lib/command/AcApLineCmd.d.ts +36 -1
  32. package/lib/command/AcApLineCmd.d.ts.map +1 -1
  33. package/lib/command/AcApLineCmd.js +157 -20
  34. package/lib/command/AcApLineCmd.js.map +1 -1
  35. package/lib/command/AcApMeasureAreaCmd.d.ts.map +1 -1
  36. package/lib/command/AcApMeasureAreaCmd.js +3 -0
  37. package/lib/command/AcApMeasureAreaCmd.js.map +1 -1
  38. package/lib/command/AcApMoveCmd.d.ts +16 -0
  39. package/lib/command/AcApMoveCmd.d.ts.map +1 -0
  40. package/lib/command/AcApMoveCmd.js +278 -0
  41. package/lib/command/AcApMoveCmd.js.map +1 -0
  42. package/lib/command/AcApPngConvertor.d.ts +95 -0
  43. package/lib/command/AcApPngConvertor.d.ts.map +1 -0
  44. package/lib/command/AcApPngConvertor.js +205 -0
  45. package/lib/command/AcApPngConvertor.js.map +1 -0
  46. package/lib/command/AcApPolygonCmd.d.ts +69 -0
  47. package/lib/command/AcApPolygonCmd.d.ts.map +1 -0
  48. package/lib/command/AcApPolygonCmd.js +422 -0
  49. package/lib/command/AcApPolygonCmd.js.map +1 -0
  50. package/lib/command/AcApRectCmd.d.ts +149 -4
  51. package/lib/command/AcApRectCmd.d.ts.map +1 -1
  52. package/lib/command/AcApRectCmd.js +716 -34
  53. package/lib/command/AcApRectCmd.js.map +1 -1
  54. package/lib/command/AcApRevCircleCmd.d.ts +8 -0
  55. package/lib/command/AcApRevCircleCmd.d.ts.map +1 -1
  56. package/lib/command/AcApRevCircleCmd.js +30 -6
  57. package/lib/command/AcApRevCircleCmd.js.map +1 -1
  58. package/lib/command/AcApRevRectCmd.d.ts +8 -0
  59. package/lib/command/AcApRevRectCmd.d.ts.map +1 -1
  60. package/lib/command/AcApRevRectCmd.js +78 -6
  61. package/lib/command/AcApRevRectCmd.js.map +1 -1
  62. package/lib/command/AcApSplineCmd.d.ts +66 -1
  63. package/lib/command/AcApSplineCmd.d.ts.map +1 -1
  64. package/lib/command/AcApSplineCmd.js +466 -59
  65. package/lib/command/AcApSplineCmd.js.map +1 -1
  66. package/lib/command/AcApZoomCmd.d.ts +91 -20
  67. package/lib/command/AcApZoomCmd.d.ts.map +1 -1
  68. package/lib/command/AcApZoomCmd.js +288 -23
  69. package/lib/command/AcApZoomCmd.js.map +1 -1
  70. package/lib/command/index.d.ts +7 -1
  71. package/lib/command/index.d.ts.map +1 -1
  72. package/lib/command/index.js +7 -1
  73. package/lib/command/index.js.map +1 -1
  74. package/lib/editor/command/AcEdCommandStack.d.ts +54 -1
  75. package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -1
  76. package/lib/editor/command/AcEdCommandStack.js +207 -25
  77. package/lib/editor/command/AcEdCommandStack.js.map +1 -1
  78. package/lib/editor/input/AcEdSelectionFilter.d.ts +79 -0
  79. package/lib/editor/input/AcEdSelectionFilter.d.ts.map +1 -0
  80. package/lib/editor/input/AcEdSelectionFilter.js +231 -0
  81. package/lib/editor/input/AcEdSelectionFilter.js.map +1 -0
  82. package/lib/editor/input/AcEditor.d.ts +20 -2
  83. package/lib/editor/input/AcEditor.d.ts.map +1 -1
  84. package/lib/editor/input/AcEditor.js +66 -0
  85. package/lib/editor/input/AcEditor.js.map +1 -1
  86. package/lib/editor/input/index.d.ts +1 -0
  87. package/lib/editor/input/index.d.ts.map +1 -1
  88. package/lib/editor/input/index.js +1 -0
  89. package/lib/editor/input/index.js.map +1 -1
  90. package/lib/editor/input/prompt/AcEdKeywordCollection.d.ts +47 -0
  91. package/lib/editor/input/prompt/AcEdKeywordCollection.d.ts.map +1 -1
  92. package/lib/editor/input/prompt/AcEdKeywordCollection.js +19 -0
  93. package/lib/editor/input/prompt/AcEdKeywordCollection.js.map +1 -1
  94. package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts +7 -0
  95. package/lib/editor/input/prompt/AcEdPromptAngleOptions.d.ts.map +1 -1
  96. package/lib/editor/input/prompt/AcEdPromptAngleOptions.js +17 -0
  97. package/lib/editor/input/prompt/AcEdPromptAngleOptions.js.map +1 -1
  98. package/lib/editor/input/prompt/AcEdPromptEntityOptions.d.ts +17 -0
  99. package/lib/editor/input/prompt/AcEdPromptEntityOptions.d.ts.map +1 -1
  100. package/lib/editor/input/prompt/AcEdPromptEntityOptions.js +30 -3
  101. package/lib/editor/input/prompt/AcEdPromptEntityOptions.js.map +1 -1
  102. package/lib/editor/input/prompt/AcEdPromptOptions.d.ts +6 -1
  103. package/lib/editor/input/prompt/AcEdPromptOptions.d.ts.map +1 -1
  104. package/lib/editor/input/prompt/AcEdPromptOptions.js +7 -0
  105. package/lib/editor/input/prompt/AcEdPromptOptions.js.map +1 -1
  106. package/lib/editor/input/session/AcEdKeywordSession.d.ts +65 -0
  107. package/lib/editor/input/session/AcEdKeywordSession.d.ts.map +1 -1
  108. package/lib/editor/input/session/AcEdKeywordSession.js +71 -0
  109. package/lib/editor/input/session/AcEdKeywordSession.js.map +1 -1
  110. package/lib/editor/input/ui/AcEdCommandLine.d.ts +23 -0
  111. package/lib/editor/input/ui/AcEdCommandLine.d.ts.map +1 -1
  112. package/lib/editor/input/ui/AcEdCommandLine.js +42 -6
  113. package/lib/editor/input/ui/AcEdCommandLine.js.map +1 -1
  114. package/lib/editor/input/ui/AcEdFloatingInput.d.ts +1 -0
  115. package/lib/editor/input/ui/AcEdFloatingInput.d.ts.map +1 -1
  116. package/lib/editor/input/ui/AcEdFloatingInput.js +8 -2
  117. package/lib/editor/input/ui/AcEdFloatingInput.js.map +1 -1
  118. package/lib/editor/input/ui/AcEdFloatingInputBoxes.d.ts +23 -1
  119. package/lib/editor/input/ui/AcEdFloatingInputBoxes.d.ts.map +1 -1
  120. package/lib/editor/input/ui/AcEdFloatingInputBoxes.js +32 -9
  121. package/lib/editor/input/ui/AcEdFloatingInputBoxes.js.map +1 -1
  122. package/lib/editor/input/ui/AcEdFloatingInputTypes.d.ts +28 -0
  123. package/lib/editor/input/ui/AcEdFloatingInputTypes.d.ts.map +1 -1
  124. package/lib/editor/input/ui/AcEdInputManager.d.ts +356 -16
  125. package/lib/editor/input/ui/AcEdInputManager.d.ts.map +1 -1
  126. package/lib/editor/input/ui/AcEdInputManager.js +964 -529
  127. package/lib/editor/input/ui/AcEdInputManager.js.map +1 -1
  128. package/lib/editor/input/ui/AcEdRubberBand.d.ts +15 -1
  129. package/lib/editor/input/ui/AcEdRubberBand.d.ts.map +1 -1
  130. package/lib/editor/input/ui/AcEdRubberBand.js +42 -10
  131. package/lib/editor/input/ui/AcEdRubberBand.js.map +1 -1
  132. package/lib/i18n/en/command.d.ts +21 -3
  133. package/lib/i18n/en/command.d.ts.map +1 -1
  134. package/lib/i18n/en/command.js +21 -3
  135. package/lib/i18n/en/command.js.map +1 -1
  136. package/lib/i18n/en/jig.d.ts +443 -0
  137. package/lib/i18n/en/jig.d.ts.map +1 -1
  138. package/lib/i18n/en/jig.js +452 -9
  139. package/lib/i18n/en/jig.js.map +1 -1
  140. package/lib/i18n/zh/command.d.ts +21 -3
  141. package/lib/i18n/zh/command.d.ts.map +1 -1
  142. package/lib/i18n/zh/command.js +21 -3
  143. package/lib/i18n/zh/command.js.map +1 -1
  144. package/lib/i18n/zh/jig.d.ts +443 -0
  145. package/lib/i18n/zh/jig.d.ts.map +1 -1
  146. package/lib/i18n/zh/jig.js +452 -9
  147. package/lib/i18n/zh/jig.js.map +1 -1
  148. package/lib/plugin/AcApPluginManager.d.ts.map +1 -1
  149. package/lib/plugin/AcApPluginManager.js.map +1 -1
  150. package/lib/view/AcTrLayer.d.ts.map +1 -1
  151. package/lib/view/AcTrLayer.js +5 -3
  152. package/lib/view/AcTrLayer.js.map +1 -1
  153. package/lib/view/AcTrView2d.d.ts +0 -1
  154. package/lib/view/AcTrView2d.d.ts.map +1 -1
  155. package/lib/view/AcTrView2d.js +17 -4
  156. package/lib/view/AcTrView2d.js.map +1 -1
  157. package/package.json +11 -9
  158. package/lib/command/AcApZoomToBoxCmd.d.ts +0 -29
  159. package/lib/command/AcApZoomToBoxCmd.d.ts.map +0 -1
  160. package/lib/command/AcApZoomToBoxCmd.js.map +0 -1
@@ -85,8 +85,8 @@ var __values = (this && this.__values) || function(o) {
85
85
  };
86
86
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
87
87
  };
88
- import { AcGeBox2d } from '@mlightcad/data-model';
89
- import { AcApSettingManager } from '../../../app';
88
+ import { acdbHostApplicationServices, AcDbSystemVariables, AcDbSysVarManager, AcGeBox2d } from '@mlightcad/data-model';
89
+ import { AcApDocManager, AcApSettingManager } from '../../../app';
90
90
  import { AcApI18n } from '../../../i18n';
91
91
  import { AcEdSelectionSet } from '../AcEdSelectionSet';
92
92
  import { AcEdAngleHandler, AcEdDistanceHandler, AcEdDoubleHandler, AcEdIntegerHandler, AcEdPointHandler, AcEdStringHandler } from '../handler';
@@ -95,8 +95,20 @@ import { AcEdPromptBoxResult, AcEdPromptDoubleResult, AcEdPromptEntityResult, Ac
95
95
  import { AcEdCommandLine } from './AcEdCommandLine';
96
96
  import { AcEdFloatingInput } from './AcEdFloatingInput';
97
97
  import { AcEdFloatingMessage } from './AcEdFloatingMessage';
98
+ /**
99
+ * Internal control-flow error used to propagate keyword picks out of
100
+ * floating-input loops.
101
+ *
102
+ * This error is intentionally caught by prompt wrappers and converted into
103
+ * `AcEdPromptStatus.Keyword` results.
104
+ */
98
105
  var AcEdKeywordInputError = /** @class */ (function (_super) {
99
106
  __extends(AcEdKeywordInputError, _super);
107
+ /**
108
+ * Creates a keyword control-flow error.
109
+ *
110
+ * @param keyword - Canonical keyword token to bubble to prompt callers.
111
+ */
100
112
  function AcEdKeywordInputError(keyword) {
101
113
  var _this = _super.call(this, 'keyword') || this;
102
114
  _this.keyword = keyword;
@@ -104,6 +116,16 @@ var AcEdKeywordInputError = /** @class */ (function (_super) {
104
116
  }
105
117
  return AcEdKeywordInputError;
106
118
  }(Error));
119
+ /**
120
+ * Internal control-flow error used to represent Enter/RightClick None input.
121
+ */
122
+ var AcEdNoneInputError = /** @class */ (function (_super) {
123
+ __extends(AcEdNoneInputError, _super);
124
+ function AcEdNoneInputError() {
125
+ return _super.call(this, 'none') || this;
126
+ }
127
+ return AcEdNoneInputError;
128
+ }(Error));
107
129
  /**
108
130
  * A fully type-safe TypeScript class providing CAD-style interactive user input
109
131
  * using floating HTML input boxes and mouse events. Supports collecting points,
@@ -244,11 +266,35 @@ var AcEdInputManager = /** @class */ (function () {
244
266
  return value.toFixed(3);
245
267
  }
246
268
  };
269
+ /**
270
+ * Returns whether the supplied prompt defines any keywords.
271
+ *
272
+ * Keyword-aware prompts need extra command-line wiring so textual input can
273
+ * be interpreted as keyword picks instead of free-form values. This helper
274
+ * centralizes the check and gracefully handles prompts that expose no keyword
275
+ * collection.
276
+ *
277
+ * @param options - Prompt options to inspect
278
+ * @returns `true` when at least one keyword is registered on the prompt
279
+ */
247
280
  AcEdInputManager.prototype.hasKeywords = function (options) {
248
281
  var _a, _b;
249
282
  var keywords = (_b = (_a = options.keywords) === null || _a === void 0 ? void 0 : _a.toArray()) !== null && _b !== void 0 ? _b : [];
250
283
  return keywords.length > 0;
251
284
  };
285
+ /**
286
+ * Builds a keyword-only prompt options object from a general prompt.
287
+ *
288
+ * Several input flows support optional keywords in parallel with their main
289
+ * acquisition mode. Rather than duplicating keyword definitions manually, the
290
+ * original prompt's keyword metadata is cloned into a dedicated
291
+ * `AcEdPromptKeywordOptions` instance that can be passed to the command-line
292
+ * keyword session.
293
+ *
294
+ * @typeParam T - Value type produced by the source prompt
295
+ * @param options - Source prompt whose keyword definitions should be copied
296
+ * @returns A keyword prompt configured with the same message and keyword set
297
+ */
252
298
  AcEdInputManager.prototype.buildKeywordOptions = function (options) {
253
299
  var _a, _b;
254
300
  var keywordOptions = new AcEdPromptKeywordOptions(options.message);
@@ -262,6 +308,16 @@ var AcEdInputManager = /** @class */ (function () {
262
308
  });
263
309
  return keywordOptions;
264
310
  };
311
+ /**
312
+ * Copies keyword definitions from one prompt options object to another.
313
+ *
314
+ * This is primarily used by composite prompts such as `getBox()`, which break
315
+ * a higher-level workflow into multiple sub-prompts while preserving the same
316
+ * keyword vocabulary and default keyword behavior across each stage.
317
+ *
318
+ * @param source - Prompt options providing the keyword definitions
319
+ * @param target - Prompt options receiving the cloned keyword definitions
320
+ */
265
321
  AcEdInputManager.prototype.copyKeywords = function (source, target) {
266
322
  var _a, _b;
267
323
  target.appendKeywordsToMessage = source.appendKeywordsToMessage;
@@ -273,6 +329,95 @@ var AcEdInputManager = /** @class */ (function () {
273
329
  }
274
330
  });
275
331
  };
332
+ /**
333
+ * Resolves a picked object id back to its database entity instance.
334
+ *
335
+ * View-level picking only returns lightweight hit-test data such as object
336
+ * ids and bounding information. Prompt validation, however, needs access to
337
+ * the backing `AcDbEntity` so it can inspect runtime metadata like the entity
338
+ * type and layer.
339
+ *
340
+ * @param objectId - Object id returned by the spatial pick query
341
+ * @returns The matching database entity, or `undefined` if it can no longer be found
342
+ */
343
+ AcEdInputManager.prototype.getEntityById = function (objectId) {
344
+ return AcApDocManager.instance.curDocument.database.tables.blockTable.getEntityById(objectId);
345
+ };
346
+ /**
347
+ * Returns whether the specified entity belongs to a locked layer.
348
+ *
349
+ * The entity itself only stores its layer name, so this helper resolves the
350
+ * layer record from the current drawing database and inspects its lock state.
351
+ * Missing layer records are treated as unlocked to avoid rejecting input due
352
+ * to incomplete metadata.
353
+ *
354
+ * @param entity - Entity being evaluated for prompt selection
355
+ * @returns `true` if the entity's layer exists and is locked; otherwise `false`
356
+ */
357
+ AcEdInputManager.prototype.isEntityOnLockedLayer = function (entity) {
358
+ var _a;
359
+ var layerName = entity.layer;
360
+ if (!layerName) {
361
+ return false;
362
+ }
363
+ return !!((_a = AcApDocManager.instance.curDocument.database.tables.layerTable.getAt(layerName)) === null || _a === void 0 ? void 0 : _a.isLocked);
364
+ };
365
+ /**
366
+ * Checks whether a picked entity satisfies the prompt's allowed-class filter.
367
+ *
368
+ * Different parts of the stack expose the entity type in slightly different
369
+ * forms. The data-model layer provides a short CAD type name through
370
+ * `entity.type` (for example `Line`), while runtime inspection exposes the
371
+ * TypeScript constructor name (for example `AcDbLine`). To maximize
372
+ * compatibility with existing caller expectations, both forms are tested
373
+ * against the prompt's allow-list.
374
+ *
375
+ * @param entity - Picked entity being validated
376
+ * @param options - Prompt options containing the configured allowed classes
377
+ * @returns `true` when the entity matches at least one allowed class, or when
378
+ * no class restriction has been configured
379
+ */
380
+ AcEdInputManager.prototype.isEntityClassAllowed = function (entity, options) {
381
+ var e_1, _a;
382
+ var _b;
383
+ var candidates = new Set();
384
+ if (entity.type) {
385
+ candidates.add(entity.type);
386
+ }
387
+ var constructorName = (_b = entity.constructor) === null || _b === void 0 ? void 0 : _b.name;
388
+ if (constructorName) {
389
+ candidates.add(constructorName);
390
+ }
391
+ try {
392
+ for (var candidates_1 = __values(candidates), candidates_1_1 = candidates_1.next(); !candidates_1_1.done; candidates_1_1 = candidates_1.next()) {
393
+ var candidate = candidates_1_1.value;
394
+ if (options.isClassAllowed(candidate)) {
395
+ return true;
396
+ }
397
+ }
398
+ }
399
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
400
+ finally {
401
+ try {
402
+ if (candidates_1_1 && !candidates_1_1.done && (_a = candidates_1.return)) _a.call(candidates_1);
403
+ }
404
+ finally { if (e_1) throw e_1.error; }
405
+ }
406
+ return false;
407
+ };
408
+ /**
409
+ * Starts a command-line keyword session for the given prompt when needed.
410
+ *
411
+ * Many interactive prompts accept both mouse-driven input and typed keywords
412
+ * at the same time. This helper lazily creates the command-line keyword
413
+ * session only when keywords are actually configured, and returns a small
414
+ * control object that lets callers await or cancel that session.
415
+ *
416
+ * @param options - Prompt options that may define keywords
417
+ * @param allowTyping - Whether arbitrary typing is allowed alongside keyword completion
418
+ * @returns An object containing the keyword promise and cancel callback, or
419
+ * `undefined` when the prompt has no keywords
420
+ */
276
421
  AcEdInputManager.prototype.startKeywordSession = function (options, allowTyping) {
277
422
  var _this = this;
278
423
  if (!this.hasKeywords(options))
@@ -283,33 +428,97 @@ var AcEdInputManager = /** @class */ (function () {
283
428
  cancel: function () { return _this._commandLine.cancelActiveSession(); }
284
429
  };
285
430
  };
431
+ /**
432
+ * Narrows an unknown error value to the internal keyword control-flow error.
433
+ *
434
+ * Prompt implementations use {@link AcEdKeywordInputError} as a private
435
+ * mechanism for bubbling a keyword pick out of deeply nested async UI flows.
436
+ * This type guard keeps the outer prompt wrappers readable while preserving
437
+ * strong typing for the extracted keyword token.
438
+ *
439
+ * @param error - Unknown error value thrown from an input workflow
440
+ * @returns `true` if the error represents a keyword selection
441
+ */
286
442
  AcEdInputManager.prototype.isPromptKeyword = function (error) {
287
443
  return error instanceof AcEdKeywordInputError;
288
444
  };
289
445
  /**
290
- * Public point input API.
446
+ * Converts internal prompt control-flow errors to typed prompt results.
447
+ *
448
+ * @typeParam T - Prompt result type to construct
449
+ * @param error - Unknown error thrown from prompt workflow
450
+ * @param handlers - Result factories for mapped prompt statuses
451
+ * @returns Mapped prompt result when recognized; otherwise `undefined`
291
452
  */
292
- AcEdInputManager.prototype.getPoint = function (options) {
453
+ AcEdInputManager.prototype.mapPromptError = function (error, handlers) {
454
+ if (handlers.none && this.isPromptNone(error)) {
455
+ return handlers.none();
456
+ }
457
+ if (handlers.cancel && this.isPromptCancelled(error)) {
458
+ return handlers.cancel();
459
+ }
460
+ if (handlers.keyword && this.isPromptKeyword(error)) {
461
+ return handlers.keyword(error.keyword);
462
+ }
463
+ return undefined;
464
+ };
465
+ /**
466
+ * Attaches keyword text to a prompt result and returns it.
467
+ */
468
+ AcEdInputManager.prototype.withKeywordResult = function (result, keyword) {
469
+ result.stringResult = keyword;
470
+ return result;
471
+ };
472
+ /**
473
+ * Maps internal control-flow errors to prompt results by status constructor.
474
+ *
475
+ * @typeParam T - Prompt result type
476
+ * @param error - Unknown error thrown from prompt workflow
477
+ * @param create - Factory creating a result from target status
478
+ * @param options - Toggles for supported mapped statuses
479
+ */
480
+ AcEdInputManager.prototype.mapPromptErrorToResult = function (error, create, options) {
481
+ var _this = this;
482
+ var _a, _b, _c;
483
+ var includeNone = (_a = options === null || options === void 0 ? void 0 : options.none) !== null && _a !== void 0 ? _a : true;
484
+ var includeCancel = (_b = options === null || options === void 0 ? void 0 : options.cancel) !== null && _b !== void 0 ? _b : true;
485
+ var includeKeyword = (_c = options === null || options === void 0 ? void 0 : options.keyword) !== null && _c !== void 0 ? _c : true;
486
+ return this.mapPromptError(error, {
487
+ none: includeNone ? function () { return create(AcEdPromptStatus.None); } : undefined,
488
+ cancel: includeCancel ? function () { return create(AcEdPromptStatus.Cancel); } : undefined,
489
+ keyword: includeKeyword
490
+ ? function (keyword) {
491
+ return _this.withKeywordResult(create(AcEdPromptStatus.Keyword), keyword);
492
+ }
493
+ : undefined
494
+ });
495
+ };
496
+ /**
497
+ * Executes prompt workflow with centralized try/catch mapping.
498
+ *
499
+ * @typeParam T - Raw successful value from prompt workflow
500
+ * @typeParam R - Prompt result type
501
+ * @param run - Async prompt workflow that may throw control-flow errors
502
+ * @param onOk - Maps successful workflow value to result object
503
+ * @param create - Creates a result object from mapped prompt status
504
+ * @param options - Toggles for supported mapped statuses
505
+ */
506
+ AcEdInputManager.prototype.executePrompt = function (run, onOk, create, options) {
293
507
  return __awaiter(this, void 0, void 0, function () {
294
- var value, error_1, result;
508
+ var value, error_1, mapped;
295
509
  return __generator(this, function (_a) {
296
510
  switch (_a.label) {
297
511
  case 0:
298
512
  _a.trys.push([0, 2, , 3]);
299
- return [4 /*yield*/, this.getPointInternal(options)];
513
+ return [4 /*yield*/, run()];
300
514
  case 1:
301
515
  value = _a.sent();
302
- return [2 /*return*/, new AcEdPromptPointResult(AcEdPromptStatus.OK, value)];
516
+ return [2 /*return*/, onOk(value)];
303
517
  case 2:
304
518
  error_1 = _a.sent();
305
- if (this.isPromptCancelled(error_1)) {
306
- return [2 /*return*/, new AcEdPromptPointResult(AcEdPromptStatus.Cancel)];
307
- }
308
- if (this.isPromptKeyword(error_1)) {
309
- result = new AcEdPromptPointResult(AcEdPromptStatus.Keyword);
310
- result.stringResult = error_1.keyword;
311
- return [2 /*return*/, result];
312
- }
519
+ mapped = this.mapPromptErrorToResult(error_1, create, options);
520
+ if (mapped)
521
+ return [2 /*return*/, mapped];
313
522
  throw error_1;
314
523
  case 3: return [2 /*return*/];
315
524
  }
@@ -317,9 +526,49 @@ var AcEdInputManager = /** @class */ (function () {
317
526
  });
318
527
  };
319
528
  /**
320
- * Prompt the user to type a numeric value. If integerOnly is true, integers
321
- * are enforced. The input is validated and the box will be marked invalid if
322
- * the typed value does not conform, allowing the user to retype.
529
+ * Extracts default-value behavior from prompt options when supported.
530
+ */
531
+ AcEdInputManager.prototype.resolvePromptDefaultValue = function (promptOptions) {
532
+ if ('useDefaultValue' in promptOptions &&
533
+ 'defaultValue' in promptOptions &&
534
+ promptOptions.useDefaultValue) {
535
+ return {
536
+ useDefaultValue: true,
537
+ defaultValue: promptOptions.defaultValue
538
+ };
539
+ }
540
+ return { useDefaultValue: false };
541
+ };
542
+ /**
543
+ * Prompts the user to specify a point.
544
+ *
545
+ * The point may be supplied by clicking in the view, typing coordinates into
546
+ * the floating input, or consuming a queued scripted input token. Keywords are
547
+ * also supported when configured on the prompt options.
548
+ *
549
+ * @param options - Point prompt options controlling messaging, base-point
550
+ * behavior, jig integration, and keywords
551
+ * @returns A prompt result containing the picked point, cancel status, or keyword
552
+ */
553
+ AcEdInputManager.prototype.getPoint = function (options) {
554
+ return __awaiter(this, void 0, void 0, function () {
555
+ var _this = this;
556
+ return __generator(this, function (_a) {
557
+ return [2 /*return*/, this.executePrompt(function () { return _this.getPointInternal(options); }, function (value) { return new AcEdPromptPointResult(AcEdPromptStatus.OK, value); }, function (status) { return new AcEdPromptPointResult(status); })];
558
+ });
559
+ });
560
+ };
561
+ /**
562
+ * Prompts the user for a purely typed numeric value through floating input.
563
+ *
564
+ * This helper is shared by distance, angle, double, and integer prompts when
565
+ * no mouse-driven geometric reference is needed. Validation is delegated to
566
+ * the supplied handler so the floating UI can mark invalid values and keep
567
+ * the prompt alive until the user enters an acceptable number.
568
+ *
569
+ * @param options - Numeric prompt options describing the message and keyword set
570
+ * @param handler - Parser/validator responsible for converting raw text into a number
571
+ * @returns A promise that resolves to the parsed numeric value
323
572
  */
324
573
  AcEdInputManager.prototype.getNumberTyped = function (options, handler) {
325
574
  var getDynamicValue = function () {
@@ -335,249 +584,238 @@ var AcEdInputManager = /** @class */ (function () {
335
584
  getDynamicValue: getDynamicValue
336
585
  });
337
586
  };
338
- /** Request a distance (number) from the user. */
587
+ /**
588
+ * Prompts the user to specify a distance value.
589
+ *
590
+ * When a base point is available, the floating input previews the live
591
+ * distance from that reference point to the current cursor. Otherwise, the
592
+ * method falls back to typed numeric entry only. Scripted inputs and keywords
593
+ * are supported as well.
594
+ *
595
+ * @param options - Distance prompt options controlling base-point behavior and messaging
596
+ * @returns A prompt result containing the resolved distance, cancel status, or keyword
597
+ */
339
598
  AcEdInputManager.prototype.getDistance = function (options) {
340
599
  return __awaiter(this, void 0, void 0, function () {
341
- var handler, scriptedValue, value_1, getDynamicValue, value, error_2, result;
600
+ var handler, scriptedValue;
342
601
  var _this = this;
343
602
  return __generator(this, function (_a) {
344
- switch (_a.label) {
345
- case 0:
346
- handler = new AcEdDistanceHandler(options);
347
- scriptedValue = this.tryGetScriptedNumber(handler);
348
- if (scriptedValue != null) {
349
- return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, scriptedValue)];
350
- }
351
- _a.label = 1;
352
- case 1:
353
- _a.trys.push([1, 5, , 6]);
354
- if (!!this.lastPoint) return [3 /*break*/, 3];
355
- return [4 /*yield*/, this.getNumberTyped(options, handler)];
356
- case 2:
357
- value_1 = _a.sent();
358
- return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, value_1)];
359
- case 3:
360
- getDynamicValue = function (pos) {
361
- var dx = pos.x - _this.lastPoint.x;
362
- var dy = pos.y - _this.lastPoint.y;
363
- var dist = Math.sqrt(dx * dx + dy * dy);
364
- return {
365
- value: dist,
366
- raw: { x: _this.formatNumber(dist, 'distance') }
367
- };
368
- };
369
- return [4 /*yield*/, this.makeFloatingInputPromise({
370
- inputCount: 1,
371
- promptOptions: options,
372
- handler: handler,
373
- getDynamicValue: getDynamicValue
374
- })];
375
- case 4:
376
- value = _a.sent();
377
- return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, value)];
378
- case 5:
379
- error_2 = _a.sent();
380
- if (this.isPromptCancelled(error_2)) {
381
- return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.Cancel)];
382
- }
383
- if (this.isPromptKeyword(error_2)) {
384
- result = new AcEdPromptDoubleResult(AcEdPromptStatus.Keyword);
385
- result.stringResult = error_2.keyword;
386
- return [2 /*return*/, result];
387
- }
388
- throw error_2;
389
- case 6: return [2 /*return*/];
603
+ handler = new AcEdDistanceHandler(options);
604
+ scriptedValue = this.tryGetScriptedNumber(handler);
605
+ if (scriptedValue != null) {
606
+ return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, scriptedValue)];
390
607
  }
608
+ return [2 /*return*/, this.executePrompt(function () { return __awaiter(_this, void 0, void 0, function () {
609
+ var getDynamicValue;
610
+ var _this = this;
611
+ return __generator(this, function (_a) {
612
+ switch (_a.label) {
613
+ case 0:
614
+ if (!!this.lastPoint) return [3 /*break*/, 2];
615
+ return [4 /*yield*/, this.getNumberTyped(options, handler)];
616
+ case 1: return [2 /*return*/, _a.sent()];
617
+ case 2:
618
+ getDynamicValue = function (pos) {
619
+ var dx = pos.x - _this.lastPoint.x;
620
+ var dy = pos.y - _this.lastPoint.y;
621
+ var dist = Math.sqrt(dx * dx + dy * dy);
622
+ return {
623
+ value: dist,
624
+ raw: { x: _this.formatNumber(dist, 'distance') }
625
+ };
626
+ };
627
+ return [4 /*yield*/, this.makeFloatingInputPromise({
628
+ inputCount: 1,
629
+ promptOptions: options,
630
+ handler: handler,
631
+ getDynamicValue: getDynamicValue
632
+ })];
633
+ case 3: return [2 /*return*/, _a.sent()];
634
+ }
635
+ });
636
+ }); }, function (value) { return new AcEdPromptDoubleResult(AcEdPromptStatus.OK, value); }, function (status) { return new AcEdPromptDoubleResult(status); })];
391
637
  });
392
638
  });
393
639
  };
394
- /** Request an angle in degrees from the user. */
640
+ /**
641
+ * Prompts the user to specify an angle in degrees.
642
+ *
643
+ * If a base point is available, the cursor position is converted into a live
644
+ * angular preview relative to that point and the optional prompt base angle.
645
+ * Without a geometric reference, the method accepts typed numeric input only.
646
+ *
647
+ * @param options - Angle prompt options controlling base point, base angle, and messaging
648
+ * @returns A prompt result containing the resolved angle, cancel status, or keyword
649
+ */
395
650
  AcEdInputManager.prototype.getAngle = function (options) {
396
651
  return __awaiter(this, void 0, void 0, function () {
397
- var handler, scriptedValue, getDynamicValue, value, error_3, result;
652
+ var handler, scriptedValue, basePoint, getDynamicValue;
398
653
  var _this = this;
399
654
  return __generator(this, function (_a) {
400
- switch (_a.label) {
401
- case 0:
402
- handler = new AcEdAngleHandler(options);
403
- scriptedValue = this.tryGetScriptedNumber(handler);
404
- if (scriptedValue != null) {
405
- return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, scriptedValue)];
406
- }
407
- getDynamicValue = function (pos) {
408
- var dx = pos.x - _this.lastPoint.x;
409
- var dy = pos.y - _this.lastPoint.y;
410
- var angleRad = Math.atan2(dy, dx);
411
- var angleDeg = (angleRad * 180) / Math.PI;
412
- return {
413
- value: angleDeg,
414
- raw: { x: _this.formatNumber(angleDeg, 'angle') }
415
- };
416
- };
417
- _a.label = 1;
418
- case 1:
419
- _a.trys.push([1, 3, , 4]);
420
- return [4 /*yield*/, this.makeFloatingInputPromise({
421
- inputCount: 1,
422
- promptOptions: options,
423
- handler: handler,
424
- getDynamicValue: getDynamicValue
425
- })];
426
- case 2:
427
- value = _a.sent();
428
- return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, value)];
429
- case 3:
430
- error_3 = _a.sent();
431
- if (this.isPromptCancelled(error_3)) {
432
- return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.Cancel)];
433
- }
434
- if (this.isPromptKeyword(error_3)) {
435
- result = new AcEdPromptDoubleResult(AcEdPromptStatus.Keyword);
436
- result.stringResult = error_3.keyword;
437
- return [2 /*return*/, result];
438
- }
439
- throw error_3;
440
- case 4: return [2 /*return*/];
655
+ handler = new AcEdAngleHandler(options);
656
+ scriptedValue = this.tryGetScriptedNumber(handler);
657
+ if (scriptedValue != null) {
658
+ return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, scriptedValue)];
441
659
  }
660
+ basePoint = options.useBasePoint && options.basePoint
661
+ ? options.basePoint
662
+ : this.lastPoint;
663
+ // No reference point available: fallback to typed angle input only.
664
+ if (!basePoint) {
665
+ return [2 /*return*/, this.executePrompt(function () { return _this.getNumberTyped(options, handler); }, function (value) { return new AcEdPromptDoubleResult(AcEdPromptStatus.OK, value); }, function (status) { return new AcEdPromptDoubleResult(status); })];
666
+ }
667
+ getDynamicValue = function (pos) {
668
+ var dx = pos.x - basePoint.x;
669
+ var dy = pos.y - basePoint.y;
670
+ var rawAngleRad = Math.atan2(dy, dx);
671
+ var baseAngleRad = (options.baseAngle * Math.PI) / 180;
672
+ var angleRad = rawAngleRad - baseAngleRad;
673
+ while (angleRad <= -Math.PI)
674
+ angleRad += Math.PI * 2;
675
+ while (angleRad > Math.PI)
676
+ angleRad -= Math.PI * 2;
677
+ var angleDeg = (angleRad * 180) / Math.PI;
678
+ return {
679
+ value: angleDeg,
680
+ raw: { x: _this.formatNumber(angleDeg, 'angle') }
681
+ };
682
+ };
683
+ return [2 /*return*/, this.executePrompt(function () {
684
+ return _this.makeFloatingInputPromise({
685
+ inputCount: 1,
686
+ promptOptions: options,
687
+ handler: handler,
688
+ getDynamicValue: getDynamicValue
689
+ });
690
+ }, function (value) { return new AcEdPromptDoubleResult(AcEdPromptStatus.OK, value); }, function (status) { return new AcEdPromptDoubleResult(status); })];
442
691
  });
443
692
  });
444
693
  };
445
- /** Request a double/float from the user. */
694
+ /**
695
+ * Prompts the user for a floating-point number.
696
+ *
697
+ * This is the generic free-form numeric entry path used when no geometric
698
+ * interpretation such as distance or angle is required.
699
+ *
700
+ * @param options - Double prompt options controlling validation and messaging
701
+ * @returns A prompt result containing the parsed number, cancel status, or keyword
702
+ */
446
703
  AcEdInputManager.prototype.getDouble = function (options) {
447
704
  return __awaiter(this, void 0, void 0, function () {
448
- var handler, scriptedValue, value, error_4, result;
705
+ var handler, scriptedValue;
706
+ var _this = this;
449
707
  return __generator(this, function (_a) {
450
- switch (_a.label) {
451
- case 0:
452
- handler = new AcEdDoubleHandler(options);
453
- scriptedValue = this.tryGetScriptedNumber(handler);
454
- if (scriptedValue != null) {
455
- return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, scriptedValue)];
456
- }
457
- _a.label = 1;
458
- case 1:
459
- _a.trys.push([1, 3, , 4]);
460
- return [4 /*yield*/, this.getNumberTyped(options, handler)];
461
- case 2:
462
- value = _a.sent();
463
- return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, value)];
464
- case 3:
465
- error_4 = _a.sent();
466
- if (this.isPromptCancelled(error_4)) {
467
- return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.Cancel)];
468
- }
469
- if (this.isPromptKeyword(error_4)) {
470
- result = new AcEdPromptDoubleResult(AcEdPromptStatus.Keyword);
471
- result.stringResult = error_4.keyword;
472
- return [2 /*return*/, result];
473
- }
474
- throw error_4;
475
- case 4: return [2 /*return*/];
708
+ handler = new AcEdDoubleHandler(options);
709
+ scriptedValue = this.tryGetScriptedNumber(handler);
710
+ if (scriptedValue != null) {
711
+ return [2 /*return*/, new AcEdPromptDoubleResult(AcEdPromptStatus.OK, scriptedValue)];
476
712
  }
713
+ return [2 /*return*/, this.executePrompt(function () { return _this.getNumberTyped(options, handler); }, function (value) { return new AcEdPromptDoubleResult(AcEdPromptStatus.OK, value); }, function (status) { return new AcEdPromptDoubleResult(status); })];
477
714
  });
478
715
  });
479
716
  };
480
- /** Request an integer from the user. */
717
+ /**
718
+ * Prompts the user for an integer value.
719
+ *
720
+ * The supplied integer handler enforces integer-only parsing for both typed
721
+ * input and scripted command input.
722
+ *
723
+ * @param options - Integer prompt options controlling validation and messaging
724
+ * @returns A prompt result containing the parsed integer, cancel status, or keyword
725
+ */
481
726
  AcEdInputManager.prototype.getInteger = function (options) {
482
727
  return __awaiter(this, void 0, void 0, function () {
483
- var scriptedValue, value, error_5, result;
728
+ var scriptedValue;
729
+ var _this = this;
484
730
  return __generator(this, function (_a) {
485
- switch (_a.label) {
486
- case 0:
487
- scriptedValue = this.tryGetScriptedNumber(new AcEdIntegerHandler(options));
488
- if (scriptedValue != null) {
489
- return [2 /*return*/, new AcEdPromptIntegerResult(AcEdPromptStatus.OK, scriptedValue)];
490
- }
491
- _a.label = 1;
492
- case 1:
493
- _a.trys.push([1, 3, , 4]);
494
- return [4 /*yield*/, this.getNumberTyped(options, new AcEdIntegerHandler(options))];
495
- case 2:
496
- value = _a.sent();
497
- return [2 /*return*/, new AcEdPromptIntegerResult(AcEdPromptStatus.OK, value)];
498
- case 3:
499
- error_5 = _a.sent();
500
- if (this.isPromptCancelled(error_5)) {
501
- return [2 /*return*/, new AcEdPromptIntegerResult(AcEdPromptStatus.Cancel)];
502
- }
503
- if (this.isPromptKeyword(error_5)) {
504
- result = new AcEdPromptIntegerResult(AcEdPromptStatus.Keyword);
505
- result.stringResult = error_5.keyword;
506
- return [2 /*return*/, result];
507
- }
508
- throw error_5;
509
- case 4: return [2 /*return*/];
731
+ scriptedValue = this.tryGetScriptedNumber(new AcEdIntegerHandler(options));
732
+ if (scriptedValue != null) {
733
+ return [2 /*return*/, new AcEdPromptIntegerResult(AcEdPromptStatus.OK, scriptedValue)];
510
734
  }
735
+ return [2 /*return*/, this.executePrompt(function () { return _this.getNumberTyped(options, new AcEdIntegerHandler(options)); }, function (value) { return new AcEdPromptIntegerResult(AcEdPromptStatus.OK, value); }, function (status) { return new AcEdPromptIntegerResult(status); })];
511
736
  });
512
737
  });
513
738
  };
514
739
  /**
515
- * Prompt the user to type an arbitrary string. Resolved when Enter is pressed.
740
+ * Prompts the user to type an arbitrary string.
741
+ *
742
+ * The value is collected through the shared floating-input pipeline so it can
743
+ * participate in the same cancellation, keyword, and scripted-input behavior
744
+ * as the other prompt types.
745
+ *
746
+ * @param options - String prompt options controlling the prompt message and keywords
747
+ * @returns A prompt result containing the entered string, cancel status, or keyword
516
748
  */
517
749
  AcEdInputManager.prototype.getString = function (options) {
518
750
  return __awaiter(this, void 0, void 0, function () {
519
- var scriptedValue, getDynamicValue, handler, value, error_6;
751
+ var scriptedValue;
752
+ var _this = this;
520
753
  return __generator(this, function (_a) {
521
- switch (_a.label) {
522
- case 0:
523
- scriptedValue = this.tryGetScriptedValue(new AcEdStringHandler(options));
524
- if (scriptedValue != null) {
525
- return [2 /*return*/, new AcEdPromptResult(AcEdPromptStatus.OK, scriptedValue)];
526
- }
527
- _a.label = 1;
528
- case 1:
529
- _a.trys.push([1, 3, , 4]);
530
- getDynamicValue = function () {
531
- return {
532
- value: '',
533
- raw: { x: '' }
534
- };
535
- };
536
- handler = new AcEdStringHandler(options);
537
- return [4 /*yield*/, this.makeFloatingInputPromise({
538
- inputCount: 1,
539
- promptOptions: options,
540
- handler: handler,
541
- getDynamicValue: getDynamicValue
542
- })];
543
- case 2:
544
- value = _a.sent();
545
- return [2 /*return*/, new AcEdPromptResult(AcEdPromptStatus.OK, value)];
546
- case 3:
547
- error_6 = _a.sent();
548
- if (this.isPromptCancelled(error_6)) {
549
- return [2 /*return*/, new AcEdPromptResult(AcEdPromptStatus.Cancel)];
550
- }
551
- if (this.isPromptKeyword(error_6)) {
552
- return [2 /*return*/, new AcEdPromptResult(AcEdPromptStatus.Keyword, error_6.keyword)];
553
- }
554
- throw error_6;
555
- case 4: return [2 /*return*/];
754
+ scriptedValue = this.tryGetScriptedValue(new AcEdStringHandler(options));
755
+ if (scriptedValue != null) {
756
+ return [2 /*return*/, new AcEdPromptResult(AcEdPromptStatus.OK, scriptedValue)];
556
757
  }
758
+ return [2 /*return*/, this.executePrompt(function () { return __awaiter(_this, void 0, void 0, function () {
759
+ var getDynamicValue, handler;
760
+ return __generator(this, function (_a) {
761
+ switch (_a.label) {
762
+ case 0:
763
+ getDynamicValue = function () {
764
+ return {
765
+ value: '',
766
+ raw: { x: '' }
767
+ };
768
+ };
769
+ handler = new AcEdStringHandler(options);
770
+ return [4 /*yield*/, this.makeFloatingInputPromise({
771
+ inputCount: 1,
772
+ promptOptions: options,
773
+ handler: handler,
774
+ getDynamicValue: getDynamicValue
775
+ })];
776
+ case 1: return [2 /*return*/, _a.sent()];
777
+ }
778
+ });
779
+ }); }, function (value) { return new AcEdPromptResult(AcEdPromptStatus.OK, value); }, function (status) { return new AcEdPromptResult(status); })];
557
780
  });
558
781
  });
559
782
  };
560
783
  /**
561
- * Prompt the user to type a keyword. Resolved when Enter is pressed.
784
+ * Prompts the user to enter one of the configured keywords.
785
+ *
786
+ * Unlike the mixed-mode keyword sessions used by other prompt types, this
787
+ * method runs a dedicated keyword prompt and returns the chosen keyword as the
788
+ * result value.
789
+ *
790
+ * @param options - Keyword prompt options describing the allowed keywords
791
+ * @returns A prompt result containing the chosen keyword or cancel status
562
792
  */
563
793
  AcEdInputManager.prototype.getKeywords = function (options) {
564
794
  return __awaiter(this, void 0, void 0, function () {
565
- var scriptedValue, result;
795
+ var scriptedValue;
796
+ var _this = this;
566
797
  return __generator(this, function (_a) {
567
- switch (_a.label) {
568
- case 0:
569
- scriptedValue = this.tryGetScriptedValue(new AcEdKeywordHandler(options));
570
- if (scriptedValue != null) {
571
- return [2 /*return*/, Promise.resolve(scriptedValue)];
572
- }
573
- return [4 /*yield*/, this._commandLine.getKeywords(options, true)];
574
- case 1:
575
- result = _a.sent();
576
- if (!result) {
577
- throw new Error('cancelled');
578
- }
579
- return [2 /*return*/, result];
798
+ scriptedValue = this.tryGetScriptedValue(new AcEdKeywordHandler(options));
799
+ if (scriptedValue != null) {
800
+ return [2 /*return*/, new AcEdPromptResult(AcEdPromptStatus.OK, scriptedValue)];
580
801
  }
802
+ return [2 /*return*/, this.executePrompt(function () { return __awaiter(_this, void 0, void 0, function () {
803
+ var result;
804
+ return __generator(this, function (_a) {
805
+ switch (_a.label) {
806
+ case 0: return [4 /*yield*/, this._commandLine.getKeywords(options, true)];
807
+ case 1:
808
+ result = _a.sent();
809
+ if (!result) {
810
+ if (options.allowNone) {
811
+ throw new AcEdNoneInputError();
812
+ }
813
+ throw new Error('cancelled');
814
+ }
815
+ return [2 /*return*/, result];
816
+ }
817
+ });
818
+ }); }, function (value) { return new AcEdPromptResult(AcEdPromptStatus.OK, value); }, function (status) { return new AcEdPromptResult(status); }, { keyword: false })];
581
819
  });
582
820
  });
583
821
  };
@@ -611,281 +849,304 @@ var AcEdInputManager = /** @class */ (function () {
611
849
  */
612
850
  AcEdInputManager.prototype.getSelection = function (options) {
613
851
  return __awaiter(this, void 0, void 0, function () {
614
- var value, error_7;
615
852
  var _this = this;
616
853
  return __generator(this, function (_a) {
617
- switch (_a.label) {
618
- case 0:
619
- _a.trys.push([0, 2, , 3]);
620
- return [4 /*yield*/, new Promise(function (resolve, reject) {
621
- _this.active = true;
622
- _this.entitySelectionActive = true;
623
- var keywordSession = _this.startKeywordSession(options, true);
624
- if (!keywordSession) {
625
- _this._commandLine.setPrompt(options.message);
854
+ return [2 /*return*/, this.executePrompt(function () {
855
+ return new Promise(function (resolve, reject) {
856
+ _this.active = true;
857
+ _this.entitySelectionActive = true;
858
+ var keywordSession = _this.startKeywordSession(options, true);
859
+ if (!keywordSession) {
860
+ _this._commandLine.setPrompt(options.message);
861
+ }
862
+ var floatingMessage = new AcEdFloatingMessage(_this.view, {
863
+ parent: _this.view.canvas,
864
+ message: options.message
865
+ });
866
+ var selected = new Set();
867
+ var startWcs = null;
868
+ var startCanvas = null;
869
+ var previewEl = null;
870
+ var settled = false;
871
+ var cleanup = function () {
872
+ if (settled)
873
+ return;
874
+ settled = true;
875
+ _this.active = false;
876
+ _this.entitySelectionActive = false;
877
+ floatingMessage === null || floatingMessage === void 0 ? void 0 : floatingMessage.dispose();
878
+ previewEl === null || previewEl === void 0 ? void 0 : previewEl.remove();
879
+ keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.cancel();
880
+ _this._commandLine.clear();
881
+ document.removeEventListener('keydown', keyHandler);
882
+ _this.view.canvas.removeEventListener('mousedown', mouseDown);
883
+ _this.view.canvas.removeEventListener('mousemove', mouseMove);
884
+ _this.view.canvas.removeEventListener('mouseup', mouseUp);
885
+ _this.view.canvas.removeEventListener('contextmenu', contextMenuHandler);
886
+ };
887
+ keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.promise.then(function (keyword) {
888
+ if (settled)
889
+ return;
890
+ if (!keyword) {
891
+ cleanup();
892
+ reject(new Error('cancelled'));
893
+ return;
626
894
  }
627
- var floatingMessage = new AcEdFloatingMessage(_this.view, {
628
- parent: _this.view.canvas,
629
- message: options.message
630
- });
631
- var selected = new Set();
632
- var startWcs = null;
633
- var startCanvas = null;
634
- var previewEl = null;
635
- var settled = false;
636
- var cleanup = function () {
637
- if (settled)
638
- return;
639
- settled = true;
640
- _this.active = false;
641
- _this.entitySelectionActive = false;
642
- floatingMessage === null || floatingMessage === void 0 ? void 0 : floatingMessage.dispose();
643
- previewEl === null || previewEl === void 0 ? void 0 : previewEl.remove();
644
- keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.cancel();
645
- _this._commandLine.clear();
646
- document.removeEventListener('keydown', keyHandler);
647
- _this.view.canvas.removeEventListener('mousedown', mouseDown);
648
- _this.view.canvas.removeEventListener('mousemove', mouseMove);
649
- _this.view.canvas.removeEventListener('mouseup', mouseUp);
650
- };
651
- keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.promise.then(function (keyword) {
652
- if (settled)
653
- return;
654
- if (!keyword) {
655
- cleanup();
656
- reject(new Error('cancelled'));
657
- return;
658
- }
895
+ cleanup();
896
+ reject(new AcEdKeywordInputError(keyword));
897
+ });
898
+ /** ---------- Keyboard ---------- */
899
+ var keyHandler = function (e) {
900
+ if (e.key === 'Escape') {
659
901
  cleanup();
660
- reject(new AcEdKeywordInputError(keyword));
661
- });
662
- /** ---------- Keyboard ---------- */
663
- var keyHandler = function (e) {
664
- if (e.key === 'Escape') {
665
- cleanup();
666
- reject(new Error('cancelled'));
667
- return;
668
- }
669
- if (e.key === 'Enter') {
902
+ reject(new Error('cancelled'));
903
+ return;
904
+ }
905
+ if (e.key === 'Enter') {
906
+ cleanup();
907
+ resolve(__spreadArray([], __read(selected), false));
908
+ }
909
+ };
910
+ /** ---------- Mouse ---------- */
911
+ var contextMenuHandler = function (e) {
912
+ if (_this.shouldUseRightClickEnter()) {
913
+ e.preventDefault();
914
+ }
915
+ };
916
+ var mouseDown = function (e) {
917
+ if (e.button === 2) {
918
+ if (_this.shouldUseRightClickEnter()) {
919
+ e.preventDefault();
670
920
  cleanup();
671
921
  resolve(__spreadArray([], __read(selected), false));
672
922
  }
673
- };
674
- /** ---------- Mouse ---------- */
675
- var mouseDown = function (e) {
676
- startCanvas = _this.view.viewportToCanvas({
677
- x: e.clientX,
678
- y: e.clientY
679
- });
680
- startWcs = _this.view.screenToWorld(startCanvas);
681
- previewEl = document.createElement('div');
682
- previewEl.className = 'ml-jig-preview-rect';
683
- _this.view.container.appendChild(previewEl);
684
- };
685
- var mouseMove = function (e) {
686
- if (!startWcs || !previewEl || !startCanvas)
687
- return;
688
- var curWcs = _this.view.screenToWorld(_this.view.viewportToCanvas({ x: e.clientX, y: e.clientY }));
689
- var curCanvas = _this.view.viewportToCanvas({
690
- x: e.clientX,
691
- y: e.clientY
692
- });
693
- var p1 = _this.view.worldToScreen(startWcs);
694
- var p2 = _this.view.worldToScreen(curWcs);
695
- var left = Math.min(p1.x, p2.x);
696
- var top = Math.min(p1.y, p2.y);
697
- var width = Math.abs(p1.x - p2.x);
698
- var height = Math.abs(p1.y - p2.y);
699
- var mode = _this.view.getSelectionMode(startCanvas, curCanvas);
700
- var action = _this.view.getSelectionActionFromEvent(e, 'add');
701
- var style = _this.view.getSelectionPreviewStyle(mode, action);
702
- Object.assign(previewEl.style, {
703
- left: "".concat(left, "px"),
704
- top: "".concat(top, "px"),
705
- width: "".concat(width, "px"),
706
- height: "".concat(height, "px"),
707
- borderStyle: style.borderStyle,
708
- background: style.background
709
- });
710
- previewEl.style.setProperty('--line-color', style.lineColor);
711
- };
712
- var mouseUp = function (e) {
713
- var e_1, _a;
714
- if (!startWcs || !startCanvas)
715
- return;
716
- var endWcs = _this.view.screenToWorld(_this.view.viewportToCanvas({ x: e.clientX, y: e.clientY }));
717
- var endCanvas = _this.view.viewportToCanvas({
718
- x: e.clientX,
719
- y: e.clientY
720
- });
721
- previewEl === null || previewEl === void 0 ? void 0 : previewEl.remove();
722
- previewEl = null;
723
- // Click selection
724
- var action = _this.view.getSelectionActionFromEvent(e, 'add');
725
- if (_this.view.isSelectionClick(startCanvas, endCanvas)) {
726
- var picked = _this.view.pick(endWcs);
727
- if (picked.length > 0) {
728
- _this.view.applySelection([picked[0].id], action);
729
- }
730
- else if (action === 'replace') {
731
- _this.view.selectionSet.clear();
732
- }
923
+ return;
924
+ }
925
+ if (e.button !== 0)
926
+ return;
927
+ startCanvas = _this.view.viewportToCanvas({
928
+ x: e.clientX,
929
+ y: e.clientY
930
+ });
931
+ startWcs = _this.view.screenToWorld(startCanvas);
932
+ previewEl = document.createElement('div');
933
+ previewEl.className = 'ml-jig-preview-rect';
934
+ _this.view.container.appendChild(previewEl);
935
+ };
936
+ var mouseMove = function (e) {
937
+ if (e.buttons !== 1)
938
+ return;
939
+ if (!startWcs || !previewEl || !startCanvas)
940
+ return;
941
+ var curWcs = _this.view.screenToWorld(_this.view.viewportToCanvas({ x: e.clientX, y: e.clientY }));
942
+ var curCanvas = _this.view.viewportToCanvas({
943
+ x: e.clientX,
944
+ y: e.clientY
945
+ });
946
+ var p1 = _this.view.worldToScreen(startWcs);
947
+ var p2 = _this.view.worldToScreen(curWcs);
948
+ var left = Math.min(p1.x, p2.x);
949
+ var top = Math.min(p1.y, p2.y);
950
+ var width = Math.abs(p1.x - p2.x);
951
+ var height = Math.abs(p1.y - p2.y);
952
+ var mode = _this.view.getSelectionMode(startCanvas, curCanvas);
953
+ var action = _this.view.getSelectionActionFromEvent(e, 'add');
954
+ var style = _this.view.getSelectionPreviewStyle(mode, action);
955
+ Object.assign(previewEl.style, {
956
+ left: "".concat(left, "px"),
957
+ top: "".concat(top, "px"),
958
+ width: "".concat(width, "px"),
959
+ height: "".concat(height, "px"),
960
+ borderStyle: style.borderStyle,
961
+ background: style.background
962
+ });
963
+ previewEl.style.setProperty('--line-color', style.lineColor);
964
+ };
965
+ var mouseUp = function (e) {
966
+ var e_2, _a;
967
+ if (e.button !== 0)
968
+ return;
969
+ if (!startWcs || !startCanvas)
970
+ return;
971
+ var endWcs = _this.view.screenToWorld(_this.view.viewportToCanvas({ x: e.clientX, y: e.clientY }));
972
+ var endCanvas = _this.view.viewportToCanvas({
973
+ x: e.clientX,
974
+ y: e.clientY
975
+ });
976
+ previewEl === null || previewEl === void 0 ? void 0 : previewEl.remove();
977
+ previewEl = null;
978
+ // Click selection
979
+ var action = _this.view.getSelectionActionFromEvent(e, 'add');
980
+ if (_this.view.isSelectionClick(startCanvas, endCanvas)) {
981
+ var picked = _this.view.pick(endWcs);
982
+ if (picked.length > 0) {
983
+ _this.view.applySelection([picked[0].id], action);
733
984
  }
734
- else {
735
- // Box selection
736
- var box = new AcGeBox2d()
737
- .expandByPoint(startWcs)
738
- .expandByPoint(endWcs);
739
- var mode = _this.view.getSelectionMode(startCanvas, endCanvas);
740
- _this.view.selectByBoxWithMode(box, mode, action);
985
+ else if (action === 'replace') {
986
+ _this.view.selectionSet.clear();
741
987
  }
742
- selected.clear();
743
- try {
744
- for (var _b = __values(_this.view.selectionSet.ids), _c = _b.next(); !_c.done; _c = _b.next()) {
745
- var id = _c.value;
746
- selected.add(id);
747
- }
988
+ }
989
+ else {
990
+ // Box selection
991
+ var box = new AcGeBox2d()
992
+ .expandByPoint(startWcs)
993
+ .expandByPoint(endWcs);
994
+ var mode = _this.view.getSelectionMode(startCanvas, endCanvas);
995
+ _this.view.selectByBoxWithMode(box, mode, action);
996
+ }
997
+ selected.clear();
998
+ try {
999
+ for (var _b = __values(_this.view.selectionSet.ids), _c = _b.next(); !_c.done; _c = _b.next()) {
1000
+ var id = _c.value;
1001
+ selected.add(id);
748
1002
  }
749
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
750
- finally {
751
- try {
752
- if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
753
- }
754
- finally { if (e_1) throw e_1.error; }
1003
+ }
1004
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
1005
+ finally {
1006
+ try {
1007
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
755
1008
  }
756
- if (options.singleOnly && action !== 'remove') {
757
- if (selected.size > 0) {
758
- cleanup();
759
- resolve(__spreadArray([], __read(selected), false));
760
- }
1009
+ finally { if (e_2) throw e_2.error; }
1010
+ }
1011
+ if (options.singleOnly && action !== 'remove') {
1012
+ if (selected.size > 0) {
1013
+ cleanup();
1014
+ resolve(__spreadArray([], __read(selected), false));
761
1015
  }
762
- startWcs = null;
763
- startCanvas = null;
764
- };
765
- document.addEventListener('keydown', keyHandler);
766
- _this.view.canvas.addEventListener('mousedown', mouseDown);
767
- _this.view.canvas.addEventListener('mousemove', mouseMove);
768
- _this.view.canvas.addEventListener('mouseup', mouseUp);
769
- })];
770
- case 1:
771
- value = _a.sent();
772
- return [2 /*return*/, new AcEdPromptSelectionResult(AcEdPromptStatus.OK, new AcEdSelectionSet(value))];
773
- case 2:
774
- error_7 = _a.sent();
775
- if (this.isPromptCancelled(error_7)) {
776
- return [2 /*return*/, new AcEdPromptSelectionResult(AcEdPromptStatus.Cancel)];
777
- }
778
- if (this.isPromptKeyword(error_7)) {
779
- return [2 /*return*/, new AcEdPromptSelectionResult(AcEdPromptStatus.Keyword, undefined, error_7.keyword)];
780
- }
781
- throw error_7;
782
- case 3: return [2 /*return*/];
783
- }
1016
+ }
1017
+ startWcs = null;
1018
+ startCanvas = null;
1019
+ };
1020
+ document.addEventListener('keydown', keyHandler);
1021
+ _this.view.canvas.addEventListener('mousedown', mouseDown);
1022
+ _this.view.canvas.addEventListener('mousemove', mouseMove);
1023
+ _this.view.canvas.addEventListener('mouseup', mouseUp);
1024
+ _this.view.canvas.addEventListener('contextmenu', contextMenuHandler);
1025
+ });
1026
+ }, function (value) {
1027
+ return new AcEdPromptSelectionResult(AcEdPromptStatus.OK, new AcEdSelectionSet(value));
1028
+ }, function (status) { return new AcEdPromptSelectionResult(status); }, { none: false })];
784
1029
  });
785
1030
  });
786
1031
  };
787
1032
  /**
788
1033
  * Prompts the user to select a single entity.
789
- * Similar to Editor.GetEntity() in AutoCAD.
1034
+ *
1035
+ * Selection is performed by clicking in the view and validating the first
1036
+ * hit-tested entity under the cursor. The picked entity may be rejected when
1037
+ * it belongs to a locked layer or does not satisfy the prompt's allowed-class
1038
+ * filter, in which case the rejection message is shown and the prompt remains
1039
+ * active. Keywords and `AllowNone` behavior are also supported.
1040
+ *
1041
+ * @param options - Entity prompt options controlling filtering, messaging, and keywords
1042
+ * @returns A prompt result containing the selected entity id, picked point,
1043
+ * cancel status, or keyword
790
1044
  */
791
1045
  AcEdInputManager.prototype.getEntity = function (options) {
792
1046
  return __awaiter(this, void 0, void 0, function () {
793
- var value, error_8, result;
1047
+ var pickedPoint;
794
1048
  var _this = this;
795
1049
  return __generator(this, function (_a) {
796
- switch (_a.label) {
797
- case 0:
798
- _a.trys.push([0, 2, , 3]);
799
- return [4 /*yield*/, new Promise(function (resolve, reject) {
800
- _this.active = true;
801
- _this.entitySelectionActive = true;
802
- var keywordSession = _this.startKeywordSession(options, true);
803
- var floatingMessage = new AcEdFloatingMessage(_this.view, {
804
- parent: _this.view.canvas,
805
- message: options.message
806
- });
807
- if (!keywordSession) {
808
- _this._commandLine.setPrompt(options.message);
1050
+ return [2 /*return*/, this.executePrompt(function () {
1051
+ return new Promise(function (resolve, reject) {
1052
+ _this.active = true;
1053
+ _this.entitySelectionActive = true;
1054
+ var keywordSession = _this.startKeywordSession(options, true);
1055
+ var floatingMessage = new AcEdFloatingMessage(_this.view, {
1056
+ parent: _this.view.canvas,
1057
+ message: options.message
1058
+ });
1059
+ if (!keywordSession) {
1060
+ _this._commandLine.setPrompt(options.message);
1061
+ }
1062
+ var settled = false;
1063
+ var cleanup = function () {
1064
+ var _a;
1065
+ if (settled)
1066
+ return;
1067
+ settled = true;
1068
+ _this.active = false;
1069
+ _this.entitySelectionActive = false;
1070
+ (_a = options.jig) === null || _a === void 0 ? void 0 : _a.end();
1071
+ document.removeEventListener('keydown', keyHandler);
1072
+ _this.view.canvas.removeEventListener('mousedown', clickHandler);
1073
+ _this.view.canvas.removeEventListener('contextmenu', contextMenuHandler);
1074
+ floatingMessage === null || floatingMessage === void 0 ? void 0 : floatingMessage.dispose();
1075
+ keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.cancel();
1076
+ _this._commandLine.clear();
1077
+ };
1078
+ keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.promise.then(function (keyword) {
1079
+ if (settled)
1080
+ return;
1081
+ if (!keyword) {
1082
+ cleanup();
1083
+ reject(new Error('cancelled'));
1084
+ return;
809
1085
  }
810
- var settled = false;
811
- var cleanup = function () {
812
- var _a;
813
- if (settled)
814
- return;
815
- settled = true;
816
- _this.active = false;
817
- _this.entitySelectionActive = false;
818
- (_a = options.jig) === null || _a === void 0 ? void 0 : _a.end();
819
- document.removeEventListener('keydown', keyHandler);
820
- _this.view.canvas.removeEventListener('mousedown', clickHandler);
821
- floatingMessage === null || floatingMessage === void 0 ? void 0 : floatingMessage.dispose();
822
- keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.cancel();
823
- _this._commandLine.clear();
824
- };
825
- keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.promise.then(function (keyword) {
826
- if (settled)
827
- return;
828
- if (!keyword) {
1086
+ cleanup();
1087
+ reject(new AcEdKeywordInputError(keyword));
1088
+ });
1089
+ /** Mouse click → try select entity */
1090
+ var clickHandler = function (e) {
1091
+ if (e.button === 2) {
1092
+ if (_this.shouldUseRightClickEnter() && options.allowNone) {
1093
+ e.preventDefault();
829
1094
  cleanup();
830
- reject(new Error('cancelled'));
831
- return;
1095
+ resolve(null);
832
1096
  }
1097
+ return;
1098
+ }
1099
+ if (e.button !== 0)
1100
+ return;
1101
+ var pos = _this.view.screenToWorld(_this.view.viewportToCanvas({ x: e.clientX, y: e.clientY }));
1102
+ var picked = _this.view.pick(pos, undefined, true);
1103
+ // Clicked empty space
1104
+ if (picked.length == 0) {
1105
+ _this._commandLine.showError(options.rejectMessage);
1106
+ return;
1107
+ }
1108
+ var entity = _this.getEntityById(picked[0].id);
1109
+ if (!entity) {
1110
+ _this._commandLine.showError(options.rejectMessage);
1111
+ return;
1112
+ }
1113
+ if (!options.allowObjectOnLockedLayer &&
1114
+ _this.isEntityOnLockedLayer(entity)) {
1115
+ _this._commandLine.showError(options.rejectMessage);
1116
+ return;
1117
+ }
1118
+ if (!_this.isEntityClassAllowed(entity, options)) {
1119
+ _this._commandLine.showError(options.rejectMessage);
1120
+ return;
1121
+ }
1122
+ pickedPoint = { x: pos.x, y: pos.y, z: 0 };
1123
+ cleanup();
1124
+ resolve(picked[0].id);
1125
+ };
1126
+ /** Keyboard handling */
1127
+ var keyHandler = function (e) {
1128
+ if (e.key === 'Escape') {
833
1129
  cleanup();
834
- reject(new AcEdKeywordInputError(keyword));
835
- });
836
- /** Mouse click → try select entity */
837
- var clickHandler = function (e) {
838
- var pos = _this.view.screenToWorld(_this.view.viewportToCanvas({ x: e.clientX, y: e.clientY }));
839
- var picked = _this.view.pick(pos);
840
- // Clicked empty space
841
- if (picked.length == 0) {
842
- // this.view.showMessage(options.rejectMessage)
843
- return;
844
- }
845
- // Locked layer
846
- // if (picked.locked && !options.allowObjectOnLockedLayer) {
847
- // this.view.showMessage(options.rejectMessage)
848
- // return
849
- // }
850
- // Class filter
851
- // if (!options.isClassAllowed(picked.className)) {
852
- // this.view.showMessage(options.rejectMessage)
853
- // return
854
- // }
1130
+ reject(new Error('cancelled'));
1131
+ return;
1132
+ }
1133
+ if (e.key === 'Enter' && options.allowNone) {
855
1134
  cleanup();
856
- resolve(picked[0].id);
857
- };
858
- /** Keyboard handling */
859
- var keyHandler = function (e) {
860
- if (e.key === 'Escape') {
861
- cleanup();
862
- reject(new Error('cancelled'));
863
- return;
864
- }
865
- if (e.key === 'Enter' && options.allowNone) {
866
- cleanup();
867
- resolve(null);
868
- }
869
- };
870
- document.addEventListener('keydown', keyHandler);
871
- _this.view.canvas.addEventListener('mousedown', clickHandler);
872
- })];
873
- case 1:
874
- value = _a.sent();
875
- return [2 /*return*/, new AcEdPromptEntityResult(AcEdPromptStatus.OK, value || undefined)];
876
- case 2:
877
- error_8 = _a.sent();
878
- if (this.isPromptCancelled(error_8)) {
879
- return [2 /*return*/, new AcEdPromptEntityResult(AcEdPromptStatus.Cancel)];
880
- }
881
- if (this.isPromptKeyword(error_8)) {
882
- result = new AcEdPromptEntityResult(AcEdPromptStatus.Keyword);
883
- result.stringResult = error_8.keyword;
884
- return [2 /*return*/, result];
885
- }
886
- throw error_8;
887
- case 3: return [2 /*return*/];
888
- }
1135
+ resolve(null);
1136
+ }
1137
+ };
1138
+ var contextMenuHandler = function (e) {
1139
+ if (_this.shouldUseRightClickEnter()) {
1140
+ e.preventDefault();
1141
+ }
1142
+ };
1143
+ document.addEventListener('keydown', keyHandler);
1144
+ _this.view.canvas.addEventListener('mousedown', clickHandler);
1145
+ _this.view.canvas.addEventListener('contextmenu', contextMenuHandler);
1146
+ });
1147
+ }, function (value) {
1148
+ return new AcEdPromptEntityResult(AcEdPromptStatus.OK, value || undefined, pickedPoint);
1149
+ }, function (status) { return new AcEdPromptEntityResult(status); }, { none: false })];
889
1150
  });
890
1151
  });
891
1152
  };
@@ -893,76 +1154,86 @@ var AcEdInputManager = /** @class */ (function () {
893
1154
  * Prompt the user to specify a rectangular box by selecting two corners.
894
1155
  * Each corner may be specified by clicking on the canvas or typing "x,y".
895
1156
  * A live HTML overlay rectangle previews the box as the user moves the mouse.
1157
+ *
1158
+ * The box prompt is implemented as two chained point prompts. Keywords from
1159
+ * the original box prompt are copied into each corner prompt so the caller
1160
+ * sees a consistent interaction model across both stages.
1161
+ *
1162
+ * @param options - Box prompt options controlling corner messages, preview behavior, and keywords
1163
+ * @returns A prompt result containing the final 2D box, cancel status, or keyword
896
1164
  */
897
1165
  AcEdInputManager.prototype.getBox = function (options) {
898
1166
  return __awaiter(this, void 0, void 0, function () {
899
- var message1, options1, p1Result, p1, cwcsP1_1, previewEl_1, cleanup, drawPreview, message2, options2, p2, box, error_9;
900
1167
  var _this = this;
901
1168
  return __generator(this, function (_a) {
902
- switch (_a.label) {
903
- case 0:
904
- _a.trys.push([0, 3, , 4]);
905
- message1 = options.firstCornerMessage ||
906
- AcApI18n.t('main.inputManager.firstCorner');
907
- options1 = new AcEdPromptPointOptions(message1);
908
- this.copyKeywords(options, options1);
909
- options1.useDashedLine = options.useDashedLine;
910
- options1.useBasePoint = options.useBasePoint;
911
- return [4 /*yield*/, this.getPoint(options1)];
912
- case 1:
913
- p1Result = _a.sent();
914
- if (p1Result.status !== AcEdPromptStatus.OK) {
915
- return [2 /*return*/, new AcEdPromptBoxResult(p1Result.status, undefined, p1Result.stringResult)];
916
- }
917
- p1 = p1Result.value;
918
- cwcsP1_1 = this.view.worldToScreen(p1);
919
- previewEl_1 = document.createElement('div');
920
- previewEl_1.className = 'ml-jig-preview-rect';
921
- this.view.container.appendChild(previewEl_1);
922
- cleanup = function () {
923
- previewEl_1.remove();
924
- };
925
- drawPreview = function (pos) {
926
- var cwcsP2 = _this.view.worldToScreen(pos);
927
- var left = Math.min(cwcsP2.x, cwcsP1_1.x);
928
- var top = Math.min(cwcsP2.y, cwcsP1_1.y);
929
- var width = Math.abs(cwcsP2.x - cwcsP1_1.x);
930
- var height = Math.abs(cwcsP2.y - cwcsP1_1.y);
931
- Object.assign(previewEl_1.style, {
932
- left: "".concat(left, "px"),
933
- top: "".concat(top, "px"),
934
- width: "".concat(width, "px"),
935
- height: "".concat(height, "px")
936
- });
937
- };
938
- message2 = options.secondCornerMessage ||
939
- AcApI18n.t('main.inputManager.secondCorner');
940
- options2 = new AcEdPromptPointOptions(message2);
941
- this.copyKeywords(options, options2);
942
- options2.useDashedLine = options.useDashedLine;
943
- options2.useBasePoint = options.useBasePoint;
944
- return [4 /*yield*/, this.getPointInternal(options2, cleanup, drawPreview)];
945
- case 2:
946
- p2 = _a.sent();
947
- box = new AcGeBox2d().expandByPoint(p1).expandByPoint(p2);
948
- return [2 /*return*/, new AcEdPromptBoxResult(AcEdPromptStatus.OK, box)];
949
- case 3:
950
- error_9 = _a.sent();
951
- if (this.isPromptCancelled(error_9)) {
952
- return [2 /*return*/, new AcEdPromptBoxResult(AcEdPromptStatus.Cancel)];
953
- }
954
- if (this.isPromptKeyword(error_9)) {
955
- return [2 /*return*/, new AcEdPromptBoxResult(AcEdPromptStatus.Keyword, undefined, error_9.keyword)];
956
- }
957
- throw error_9;
958
- case 4: return [2 /*return*/];
959
- }
1169
+ return [2 /*return*/, this.executePrompt(function () { return __awaiter(_this, void 0, void 0, function () {
1170
+ var message1, options1, p1Result, p1, cwcsP1, previewEl, cleanup, drawPreview, message2, options2, p2, box;
1171
+ var _this = this;
1172
+ return __generator(this, function (_a) {
1173
+ switch (_a.label) {
1174
+ case 0:
1175
+ message1 = options.firstCornerMessage ||
1176
+ AcApI18n.t('main.inputManager.firstCorner');
1177
+ options1 = new AcEdPromptPointOptions(message1);
1178
+ this.copyKeywords(options, options1);
1179
+ options1.useDashedLine = options.useDashedLine;
1180
+ options1.useBasePoint = options.useBasePoint;
1181
+ return [4 /*yield*/, this.getPoint(options1)];
1182
+ case 1:
1183
+ p1Result = _a.sent();
1184
+ if (p1Result.status !== AcEdPromptStatus.OK) {
1185
+ return [2 /*return*/, new AcEdPromptBoxResult(p1Result.status, undefined, p1Result.stringResult)];
1186
+ }
1187
+ p1 = p1Result.value;
1188
+ cwcsP1 = this.view.worldToScreen(p1);
1189
+ previewEl = document.createElement('div');
1190
+ previewEl.className = 'ml-jig-preview-rect';
1191
+ this.view.container.appendChild(previewEl);
1192
+ cleanup = function () {
1193
+ previewEl.remove();
1194
+ };
1195
+ drawPreview = function (pos) {
1196
+ var cwcsP2 = _this.view.worldToScreen(pos);
1197
+ var left = Math.min(cwcsP2.x, cwcsP1.x);
1198
+ var top = Math.min(cwcsP2.y, cwcsP1.y);
1199
+ var width = Math.abs(cwcsP2.x - cwcsP1.x);
1200
+ var height = Math.abs(cwcsP2.y - cwcsP1.y);
1201
+ Object.assign(previewEl.style, {
1202
+ left: "".concat(left, "px"),
1203
+ top: "".concat(top, "px"),
1204
+ width: "".concat(width, "px"),
1205
+ height: "".concat(height, "px")
1206
+ });
1207
+ };
1208
+ message2 = options.secondCornerMessage ||
1209
+ AcApI18n.t('main.inputManager.secondCorner');
1210
+ options2 = new AcEdPromptPointOptions(message2);
1211
+ this.copyKeywords(options, options2);
1212
+ options2.useDashedLine = options.useDashedLine;
1213
+ options2.useBasePoint = options.useBasePoint;
1214
+ return [4 /*yield*/, this.getPointInternal(options2, cleanup, drawPreview)];
1215
+ case 2:
1216
+ p2 = _a.sent();
1217
+ box = new AcGeBox2d().expandByPoint(p1).expandByPoint(p2);
1218
+ return [2 /*return*/, new AcEdPromptBoxResult(AcEdPromptStatus.OK, box)];
1219
+ }
1220
+ });
1221
+ }); }, function (value) { return value; }, function (status) { return new AcEdPromptBoxResult(status); })];
960
1222
  });
961
1223
  });
962
1224
  };
963
1225
  /**
964
1226
  * Shared point input logic used by getPoint() and getBox(). Accepts "x,y"
965
1227
  * typed input OR mouse click.
1228
+ *
1229
+ * This helper optionally wires extra cleanup and preview callbacks so
1230
+ * higher-level workflows can overlay additional temporary graphics while
1231
+ * reusing the same point acquisition behavior.
1232
+ *
1233
+ * @param options - Point prompt options controlling the interaction
1234
+ * @param cleanup - Optional callback invoked when the point prompt ends
1235
+ * @param drawPreview - Optional callback invoked as the cursor moves for live preview rendering
1236
+ * @returns A promise that resolves to the chosen point
966
1237
  */
967
1238
  AcEdInputManager.prototype.getPointInternal = function (options, cleanup, drawPreview) {
968
1239
  return __awaiter(this, void 0, void 0, function () {
@@ -998,11 +1269,27 @@ var AcEdInputManager = /** @class */ (function () {
998
1269
  /**
999
1270
  * Attempts to consume one scripted input and parse it as a point.
1000
1271
  * Supported forms: "x,y", "x,y,z", or "x y".
1272
+ *
1273
+ * Successful scripted points also update `lastPoint` so subsequent prompts
1274
+ * that rely on prior geometric context behave the same way as with manual
1275
+ * point picking.
1276
+ *
1277
+ * @param options - Point prompt options used to validate the scripted coordinates
1278
+ * @returns Parsed point value, or `undefined` when no scripted token is queued
1279
+ * @throws Error if a queued scripted token cannot be parsed as a valid point
1001
1280
  */
1002
1281
  AcEdInputManager.prototype.tryGetScriptedPoint = function (options) {
1003
1282
  var token = this.dequeueScriptInput();
1004
1283
  if (token === undefined)
1005
1284
  return undefined;
1285
+ var trimmed = token.trim();
1286
+ if (!trimmed && options.allowNone) {
1287
+ throw new AcEdNoneInputError();
1288
+ }
1289
+ var keyword = options.keywords.findByName(trimmed);
1290
+ if (keyword) {
1291
+ throw new AcEdKeywordInputError(keyword.globalName);
1292
+ }
1006
1293
  var parsed = this.splitScriptedPoint(token);
1007
1294
  if (!parsed) {
1008
1295
  throw new Error("Invalid point input '".concat(token, "'"));
@@ -1016,6 +1303,16 @@ var AcEdInputManager = /** @class */ (function () {
1016
1303
  };
1017
1304
  /**
1018
1305
  * Attempts to consume one scripted input and parse it with the supplied handler.
1306
+ *
1307
+ * Scripted input is used to emulate command-line entry in automated or
1308
+ * replayed workflows. This helper keeps the parsing path consistent with
1309
+ * interactive input by delegating to the same handler implementation used by
1310
+ * the floating-input UI.
1311
+ *
1312
+ * @typeParam T - Parsed value type
1313
+ * @param handler - Input handler used to parse the queued token
1314
+ * @returns Parsed value, or `undefined` when no scripted token is available
1315
+ * @throws Error if a queued token exists but fails validation
1019
1316
  */
1020
1317
  AcEdInputManager.prototype.tryGetScriptedValue = function (handler) {
1021
1318
  var token = this.dequeueScriptInput();
@@ -1027,14 +1324,39 @@ var AcEdInputManager = /** @class */ (function () {
1027
1324
  }
1028
1325
  return value;
1029
1326
  };
1327
+ /**
1328
+ * Attempts to consume one scripted numeric token.
1329
+ *
1330
+ * This is a thin specialization of {@link tryGetScriptedValue} that narrows
1331
+ * the accepted handler types to those used by numeric-style prompts.
1332
+ *
1333
+ * @param handler - Numeric handler used to parse the queued token
1334
+ * @returns Parsed numeric value, or `undefined` when no scripted token is queued
1335
+ */
1030
1336
  AcEdInputManager.prototype.tryGetScriptedNumber = function (handler) {
1031
1337
  return this.tryGetScriptedValue(handler);
1032
1338
  };
1339
+ /**
1340
+ * Removes and returns the next queued scripted input token.
1341
+ *
1342
+ * @returns The next scripted token, or `undefined` when the queue is empty
1343
+ */
1033
1344
  AcEdInputManager.prototype.dequeueScriptInput = function () {
1034
1345
  if (!this._scriptInputs.length)
1035
1346
  return undefined;
1036
1347
  return this._scriptInputs.shift();
1037
1348
  };
1349
+ /**
1350
+ * Splits a scripted point token into x/y coordinate components.
1351
+ *
1352
+ * The accepted formats intentionally mirror common CAD command-line point
1353
+ * entry conventions, including comma-separated coordinates and whitespace-
1354
+ * separated coordinates. An optional third `z` component is tolerated for
1355
+ * compatibility, but only the `x` and `y` values are used by 2D prompts.
1356
+ *
1357
+ * @param token - Raw scripted point token
1358
+ * @returns Extracted x/y string pair, or `undefined` if the token is malformed
1359
+ */
1038
1360
  AcEdInputManager.prototype.splitScriptedPoint = function (token) {
1039
1361
  var trimmed = token.trim();
1040
1362
  if (!trimmed)
@@ -1052,9 +1374,70 @@ var AcEdInputManager = /** @class */ (function () {
1052
1374
  return undefined;
1053
1375
  return { x: parts[0], y: parts[1] };
1054
1376
  };
1377
+ /**
1378
+ * Returns whether an unknown error value represents prompt cancellation.
1379
+ *
1380
+ * Prompt flows normalize cancellation to a regular `Error` with the message
1381
+ * `'cancelled'`. This helper keeps the outer result-conversion code concise
1382
+ * and consistent across prompt types.
1383
+ *
1384
+ * @param error - Unknown error value thrown from an input workflow
1385
+ * @returns `true` if the error represents prompt cancellation
1386
+ */
1055
1387
  AcEdInputManager.prototype.isPromptCancelled = function (error) {
1056
1388
  return error instanceof Error && error.message === 'cancelled';
1057
1389
  };
1390
+ /**
1391
+ * Returns whether an unknown error value represents PromptStatus.None.
1392
+ *
1393
+ * @param error - Unknown error value thrown from an input workflow
1394
+ * @returns `true` if the error represents "no input" confirmation
1395
+ */
1396
+ AcEdInputManager.prototype.isPromptNone = function (error) {
1397
+ return error instanceof AcEdNoneInputError;
1398
+ };
1399
+ /**
1400
+ * Reads SHORTCUTMENU value from current working database.
1401
+ *
1402
+ * @returns Normalized 0..3 shortcut-menu mode
1403
+ */
1404
+ AcEdInputManager.prototype.getShortcutMenuMode = function () {
1405
+ var db = acdbHostApplicationServices().workingDatabase;
1406
+ var raw = AcDbSysVarManager.instance().getVar(AcDbSystemVariables.SHORTCUTMENU, db);
1407
+ var value = Math.trunc(Number(raw));
1408
+ if (Number.isNaN(value))
1409
+ return 0;
1410
+ var normalized = value & 0x3;
1411
+ return normalized;
1412
+ };
1413
+ /**
1414
+ * Resolves right-click behavior for current prompt session.
1415
+ *
1416
+ * SHORTCUTMENU:
1417
+ * 0 => always Enter
1418
+ * 1 => Enter in command, menu when idle
1419
+ * 2 => menu in command
1420
+ * 3 => always menu
1421
+ */
1422
+ AcEdInputManager.prototype.shouldUseRightClickEnter = function () {
1423
+ var mode = this.getShortcutMenuMode();
1424
+ if (mode === 0)
1425
+ return true;
1426
+ if (mode === 1)
1427
+ return this.active;
1428
+ return false;
1429
+ };
1430
+ /**
1431
+ * Synchronizes the stored modifier-key snapshot with a DOM keyboard event.
1432
+ *
1433
+ * Floating preview rendering depends on modifier state for behaviors such as
1434
+ * temporary mode switches. This helper updates the cached modifier snapshot
1435
+ * and reports whether anything actually changed so callers can avoid
1436
+ * unnecessary preview refreshes.
1437
+ *
1438
+ * @param e - Keyboard-like event carrying modifier-key flags
1439
+ * @returns `true` if any modifier flag changed; otherwise `false`
1440
+ */
1058
1441
  AcEdInputManager.prototype.updateModifierStateFromEvent = function (e) {
1059
1442
  var next = {
1060
1443
  ctrlKey: !!e.ctrlKey,
@@ -1072,6 +1455,16 @@ var AcEdInputManager = /** @class */ (function () {
1072
1455
  }
1073
1456
  return changed;
1074
1457
  };
1458
+ /**
1459
+ * Handles the sticky Ctrl toggle used by certain jig interactions.
1460
+ *
1461
+ * Instead of tracking Ctrl as a purely held modifier, some commands treat a
1462
+ * Ctrl key press as a persistent toggle. This helper flips that toggle on the
1463
+ * first non-repeating keydown event for the Control key.
1464
+ *
1465
+ * @param e - Keyboard event to inspect
1466
+ * @returns `true` if the toggle state changed and previews should refresh
1467
+ */
1075
1468
  AcEdInputManager.prototype.handleCtrlToggleKey = function (e) {
1076
1469
  if (e.key !== 'Control' || e.repeat)
1077
1470
  return false;
@@ -1081,29 +1474,51 @@ var AcEdInputManager = /** @class */ (function () {
1081
1474
  return true;
1082
1475
  };
1083
1476
  /**
1084
- * Creates a promise for floating input that will be resolved or rejected by user input.
1477
+ * Extracts cross-prompt defaults from a prompt options object.
1085
1478
  *
1086
- * This method centralizes the lifecycle of an interactive input operation,
1087
- * including handling the Escape key to cancel, resolving with user-provided
1088
- * values, and guaranteeing cleanup of UI elements and event handlers.
1479
+ * Not every prompt type exposes the same optional properties, but the
1480
+ * floating-input pipeline needs a normalized shape for values such as base
1481
+ * point, dashed-baseline behavior, jig, and base angle. This helper performs
1482
+ * those property-existence checks in one place.
1483
+ *
1484
+ * @typeParam T - Value type produced by the prompt
1485
+ * @param options - Prompt options to normalize
1486
+ * @returns A normalized object containing only the floating-input defaults it understands
1089
1487
  */
1090
1488
  AcEdInputManager.prototype.resolvePromptDefaults = function (options) {
1091
1489
  var hasBasePoint = 'basePoint' in options;
1092
1490
  var hasUseBasePoint = 'useBasePoint' in options;
1093
1491
  var hasUseDashedLine = 'useDashedLine' in options;
1492
+ var hasBaseAngle = 'baseAngle' in options;
1094
1493
  var basePoint = hasBasePoint && options.basePoint
1095
1494
  ? options.basePoint
1096
1495
  : undefined;
1097
1496
  var useBasePoint = hasUseBasePoint ? options.useBasePoint : false;
1098
1497
  var showBaseLineOnly = hasUseDashedLine ? !options.useDashedLine : false;
1498
+ var baseAngle = hasBaseAngle ? options.baseAngle : undefined;
1099
1499
  return {
1100
1500
  message: options.message,
1101
1501
  jig: options.jig,
1102
1502
  basePoint: basePoint,
1103
1503
  useBasePoint: useBasePoint,
1104
- showBaseLineOnly: showBaseLineOnly
1504
+ showBaseLineOnly: showBaseLineOnly,
1505
+ baseAngle: baseAngle
1105
1506
  };
1106
1507
  };
1508
+ /**
1509
+ * Runs a floating-input prompt and resolves it to a parsed value.
1510
+ *
1511
+ * This is the core interaction primitive used by most non-selection prompts.
1512
+ * It wires together command-line keyword handling, floating input creation,
1513
+ * validation, preview refreshes, jig updates, cancellation handling, and
1514
+ * cleanup. The method guarantees that temporary UI and event listeners are
1515
+ * torn down no matter how the prompt completes.
1516
+ *
1517
+ * @typeParam T - Value type produced by the prompt
1518
+ * @param options - Configuration describing how the floating prompt should parse,
1519
+ * validate, preview, and commit its value
1520
+ * @returns A promise that resolves with the committed value or rejects on cancel/keyword
1521
+ */
1107
1522
  AcEdInputManager.prototype.makeFloatingInputPromise = function (options) {
1108
1523
  return __awaiter(this, void 0, void 0, function () {
1109
1524
  var _this = this;
@@ -1134,6 +1549,10 @@ var AcEdInputManager = /** @class */ (function () {
1134
1549
  if (!keywordSession) {
1135
1550
  _this._commandLine.setPrompt(commandLineMessage);
1136
1551
  }
1552
+ var allowNone = 'allowNone' in options.promptOptions
1553
+ ? options.promptOptions.allowNone
1554
+ : false;
1555
+ var defaultBehavior = _this.resolvePromptDefaultValue(options.promptOptions);
1137
1556
  var floatingInput = new AcEdFloatingInput(_this.view, {
1138
1557
  parent: _this.view.canvas,
1139
1558
  inputCount: options.inputCount,
@@ -1141,7 +1560,11 @@ var AcEdInputManager = /** @class */ (function () {
1141
1560
  disableOSnap: options.disableOSnap,
1142
1561
  showBaseLineOnly: promptDefaults.showBaseLineOnly,
1143
1562
  basePoint: basePoint,
1563
+ baseAngle: promptDefaults.baseAngle,
1144
1564
  allowPrompt: options.allowPrompt !== false,
1565
+ allowNone: allowNone,
1566
+ useDefaultValue: defaultBehavior.useDefaultValue,
1567
+ defaultValue: defaultBehavior.defaultValue,
1145
1568
  validate: validate,
1146
1569
  getDynamicValue: options.getDynamicValue,
1147
1570
  drawPreview: function (pos) {
@@ -1167,7 +1590,8 @@ var AcEdInputManager = /** @class */ (function () {
1167
1590
  }
1168
1591
  return result;
1169
1592
  },
1170
- onCancel: function () { return rejector(); }
1593
+ onCancel: function () { return rejector(); },
1594
+ onNone: function () { return noneRejector(); }
1171
1595
  });
1172
1596
  var cleanup = function () {
1173
1597
  var _a, _b;
@@ -1181,6 +1605,7 @@ var AcEdInputManager = /** @class */ (function () {
1181
1605
  document.removeEventListener('keydown', escHandler);
1182
1606
  document.removeEventListener('keydown', modifierHandler);
1183
1607
  document.removeEventListener('keyup', modifierHandler);
1608
+ _this.view.canvas.removeEventListener('contextmenu', contextMenuHandler);
1184
1609
  floatingInput.dispose();
1185
1610
  keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.cancel();
1186
1611
  _this._commandLine.clear();
@@ -1193,6 +1618,9 @@ var AcEdInputManager = /** @class */ (function () {
1193
1618
  cleanup();
1194
1619
  reject(err !== null && err !== void 0 ? err : new Error('cancelled'));
1195
1620
  };
1621
+ var noneRejector = function () {
1622
+ rejector(new AcEdNoneInputError());
1623
+ };
1196
1624
  var keywordRejector = function (keyword) {
1197
1625
  rejector(new AcEdKeywordInputError(keyword));
1198
1626
  };
@@ -1208,9 +1636,16 @@ var AcEdInputManager = /** @class */ (function () {
1208
1636
  floatingInput.requestPreviewRefresh();
1209
1637
  }
1210
1638
  };
1639
+ var contextMenuHandler = function (e) {
1640
+ if (!_this.shouldUseRightClickEnter())
1641
+ return;
1642
+ e.preventDefault();
1643
+ noneRejector();
1644
+ };
1211
1645
  document.addEventListener('keydown', escHandler);
1212
1646
  document.addEventListener('keydown', modifierHandler);
1213
1647
  document.addEventListener('keyup', modifierHandler);
1648
+ _this.view.canvas.addEventListener('contextmenu', contextMenuHandler);
1214
1649
  // showAt() expects viewport coordinates; curMousePos is canvas-local.
1215
1650
  floatingInput.showAt(_this.view.canvasToViewport(_this.view.curMousePos));
1216
1651
  keywordSession === null || keywordSession === void 0 ? void 0 : keywordSession.promise.then(function (keyword) {