@mlightcad/cad-simple-viewer 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/__vite-browser-external-l0sNRNKZ-l0sNRNKZ.js +1 -0
- package/dist/index.js +40205 -0
- package/dist/index.umd.cjs +333 -0
- package/dist/libredwg-parser-worker.js +15458 -0
- package/dist/mtext-renderer-worker.js +29930 -0
- package/lib/app/AcApContext.d.ts +57 -0
- package/lib/app/AcApContext.d.ts.map +1 -0
- package/lib/app/AcApContext.js +106 -0
- package/lib/app/AcApContext.js.map +1 -0
- package/lib/app/AcApDocManager.d.ts +291 -0
- package/lib/app/AcApDocManager.d.ts.map +1 -0
- package/lib/app/AcApDocManager.js +498 -0
- package/lib/app/AcApDocManager.js.map +1 -0
- package/lib/app/AcApDocument.d.ts +101 -0
- package/lib/app/AcApDocument.d.ts.map +1 -0
- package/lib/app/AcApDocument.js +237 -0
- package/lib/app/AcApDocument.js.map +1 -0
- package/lib/app/AcApFontLoader.d.ts +54 -0
- package/lib/app/AcApFontLoader.d.ts.map +1 -0
- package/lib/app/AcApFontLoader.js +151 -0
- package/lib/app/AcApFontLoader.js.map +1 -0
- package/lib/app/AcApGlobalFunc.d.ts +26 -0
- package/lib/app/AcApGlobalFunc.d.ts.map +1 -0
- package/lib/app/AcApGlobalFunc.js +66 -0
- package/lib/app/AcApGlobalFunc.js.map +1 -0
- package/lib/app/AcApSettingManager.d.ts +232 -0
- package/lib/app/AcApSettingManager.d.ts.map +1 -0
- package/lib/app/AcApSettingManager.js +283 -0
- package/lib/app/AcApSettingManager.js.map +1 -0
- package/lib/app/index.d.ts +6 -0
- package/lib/app/index.d.ts.map +1 -0
- package/lib/app/index.js +6 -0
- package/lib/app/index.js.map +1 -0
- package/lib/command/AcApConvertToSvgCmd.d.ts +32 -0
- package/lib/command/AcApConvertToSvgCmd.d.ts.map +1 -0
- package/lib/command/AcApConvertToSvgCmd.js +56 -0
- package/lib/command/AcApConvertToSvgCmd.js.map +1 -0
- package/lib/command/AcApOpenCmd.d.ts +37 -0
- package/lib/command/AcApOpenCmd.d.ts.map +1 -0
- package/lib/command/AcApOpenCmd.js +60 -0
- package/lib/command/AcApOpenCmd.js.map +1 -0
- package/lib/command/AcApPanCmd.d.ts +31 -0
- package/lib/command/AcApPanCmd.d.ts.map +1 -0
- package/lib/command/AcApPanCmd.js +55 -0
- package/lib/command/AcApPanCmd.js.map +1 -0
- package/lib/command/AcApQNewCmd.d.ts +32 -0
- package/lib/command/AcApQNewCmd.d.ts.map +1 -0
- package/lib/command/AcApQNewCmd.js +56 -0
- package/lib/command/AcApQNewCmd.js.map +1 -0
- package/lib/command/AcApRegenCmd.d.ts +21 -0
- package/lib/command/AcApRegenCmd.d.ts.map +1 -0
- package/lib/command/AcApRegenCmd.js +45 -0
- package/lib/command/AcApRegenCmd.js.map +1 -0
- package/lib/command/AcApSelectCmd.d.ts +32 -0
- package/lib/command/AcApSelectCmd.d.ts.map +1 -0
- package/lib/command/AcApSelectCmd.js +56 -0
- package/lib/command/AcApSelectCmd.js.map +1 -0
- package/lib/command/AcApSvgConvertor.d.ts +53 -0
- package/lib/command/AcApSvgConvertor.d.ts.map +1 -0
- package/lib/command/AcApSvgConvertor.js +103 -0
- package/lib/command/AcApSvgConvertor.js.map +1 -0
- package/lib/command/AcApZoomCmd.d.ts +35 -0
- package/lib/command/AcApZoomCmd.d.ts.map +1 -0
- package/lib/command/AcApZoomCmd.js +57 -0
- package/lib/command/AcApZoomCmd.js.map +1 -0
- package/lib/command/AcApZoomToBoxCmd.d.ts +68 -0
- package/lib/command/AcApZoomToBoxCmd.d.ts.map +1 -0
- package/lib/command/AcApZoomToBoxCmd.js +158 -0
- package/lib/command/AcApZoomToBoxCmd.js.map +1 -0
- package/lib/command/index.d.ts +11 -0
- package/lib/command/index.d.ts.map +1 -0
- package/lib/command/index.js +11 -0
- package/lib/command/index.js.map +1 -0
- package/lib/editor/command/AcEdCommand.d.ts +151 -0
- package/lib/editor/command/AcEdCommand.d.ts.map +1 -0
- package/lib/editor/command/AcEdCommand.js +164 -0
- package/lib/editor/command/AcEdCommand.js.map +1 -0
- package/lib/editor/command/AcEdCommandIterator.d.ts +36 -0
- package/lib/editor/command/AcEdCommandIterator.d.ts.map +1 -0
- package/lib/editor/command/AcEdCommandIterator.js +65 -0
- package/lib/editor/command/AcEdCommandIterator.js.map +1 -0
- package/lib/editor/command/AcEdCommandStack.d.ts +120 -0
- package/lib/editor/command/AcEdCommandStack.d.ts.map +1 -0
- package/lib/editor/command/AcEdCommandStack.js +235 -0
- package/lib/editor/command/AcEdCommandStack.js.map +1 -0
- package/lib/editor/command/index.d.ts +3 -0
- package/lib/editor/command/index.d.ts.map +1 -0
- package/lib/editor/command/index.js +3 -0
- package/lib/editor/command/index.js.map +1 -0
- package/lib/editor/global/AcEdConditionWaiter.d.ts +51 -0
- package/lib/editor/global/AcEdConditionWaiter.d.ts.map +1 -0
- package/lib/editor/global/AcEdConditionWaiter.js +87 -0
- package/lib/editor/global/AcEdConditionWaiter.js.map +1 -0
- package/lib/editor/global/AcEdGlobalFunc.d.ts +8 -0
- package/lib/editor/global/AcEdGlobalFunc.d.ts.map +1 -0
- package/lib/editor/global/AcEdGlobalFunc.js +14 -0
- package/lib/editor/global/AcEdGlobalFunc.js.map +1 -0
- package/lib/editor/global/AcEdMessage.d.ts +5 -0
- package/lib/editor/global/AcEdMessage.d.ts.map +1 -0
- package/lib/editor/global/AcEdMessage.js +6 -0
- package/lib/editor/global/AcEdMessage.js.map +1 -0
- package/lib/editor/global/eventBus.d.ts +103 -0
- package/lib/editor/global/eventBus.d.ts.map +1 -0
- package/lib/editor/global/eventBus.js +41 -0
- package/lib/editor/global/eventBus.js.map +1 -0
- package/lib/editor/global/index.d.ts +4 -0
- package/lib/editor/global/index.d.ts.map +1 -0
- package/lib/editor/global/index.js +4 -0
- package/lib/editor/global/index.js.map +1 -0
- package/lib/editor/index.d.ts +5 -0
- package/lib/editor/index.d.ts.map +1 -0
- package/lib/editor/index.js +5 -0
- package/lib/editor/index.js.map +1 -0
- package/lib/editor/input/AcEdBaseInput.d.ts +89 -0
- package/lib/editor/input/AcEdBaseInput.d.ts.map +1 -0
- package/lib/editor/input/AcEdBaseInput.js +166 -0
- package/lib/editor/input/AcEdBaseInput.js.map +1 -0
- package/lib/editor/input/AcEdBoxSelector.d.ts +108 -0
- package/lib/editor/input/AcEdBoxSelector.d.ts.map +1 -0
- package/lib/editor/input/AcEdBoxSelector.js +220 -0
- package/lib/editor/input/AcEdBoxSelector.js.map +1 -0
- package/lib/editor/input/AcEdCursorManager.d.ts +130 -0
- package/lib/editor/input/AcEdCursorManager.d.ts.map +1 -0
- package/lib/editor/input/AcEdCursorManager.js +155 -0
- package/lib/editor/input/AcEdCursorManager.js.map +1 -0
- package/lib/editor/input/AcEdInputPoint.d.ts +51 -0
- package/lib/editor/input/AcEdInputPoint.d.ts.map +1 -0
- package/lib/editor/input/AcEdInputPoint.js +78 -0
- package/lib/editor/input/AcEdInputPoint.js.map +1 -0
- package/lib/editor/input/AcEdJig.d.ts +180 -0
- package/lib/editor/input/AcEdJig.d.ts.map +1 -0
- package/lib/editor/input/AcEdJig.js +256 -0
- package/lib/editor/input/AcEdJig.js.map +1 -0
- package/lib/editor/input/AcEdJigLoop.d.ts +63 -0
- package/lib/editor/input/AcEdJigLoop.d.ts.map +1 -0
- package/lib/editor/input/AcEdJigLoop.js +91 -0
- package/lib/editor/input/AcEdJigLoop.js.map +1 -0
- package/lib/editor/input/AcEdSelectionSet.d.ts +146 -0
- package/lib/editor/input/AcEdSelectionSet.d.ts.map +1 -0
- package/lib/editor/input/AcEdSelectionSet.js +179 -0
- package/lib/editor/input/AcEdSelectionSet.js.map +1 -0
- package/lib/editor/input/AcEditor.d.ts +111 -0
- package/lib/editor/input/AcEditor.d.ts.map +1 -0
- package/lib/editor/input/AcEditor.js +183 -0
- package/lib/editor/input/AcEditor.js.map +1 -0
- package/lib/editor/input/index.d.ts +5 -0
- package/lib/editor/input/index.d.ts.map +1 -0
- package/lib/editor/input/index.js +5 -0
- package/lib/editor/input/index.js.map +1 -0
- package/lib/editor/view/AcEdBaseView.d.ts +457 -0
- package/lib/editor/view/AcEdBaseView.d.ts.map +1 -0
- package/lib/editor/view/AcEdBaseView.js +349 -0
- package/lib/editor/view/AcEdBaseView.js.map +1 -0
- package/lib/editor/view/AcEdLayerInfo.d.ts +21 -0
- package/lib/editor/view/AcEdLayerInfo.d.ts.map +1 -0
- package/lib/editor/view/AcEdLayerInfo.js +2 -0
- package/lib/editor/view/AcEdLayerInfo.js.map +1 -0
- package/lib/editor/view/index.d.ts +3 -0
- package/lib/editor/view/index.d.ts.map +1 -0
- package/lib/editor/view/index.js +3 -0
- package/lib/editor/view/index.js.map +1 -0
- package/lib/index.d.ts +5 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +5 -0
- package/lib/index.js.map +1 -0
- package/lib/util/AcTrGeometryUtil.d.ts +92 -0
- package/lib/util/AcTrGeometryUtil.d.ts.map +1 -0
- package/lib/util/AcTrGeometryUtil.js +109 -0
- package/lib/util/AcTrGeometryUtil.js.map +1 -0
- package/lib/util/index.d.ts +2 -0
- package/lib/util/index.d.ts.map +1 -0
- package/lib/util/index.js +2 -0
- package/lib/util/index.js.map +1 -0
- package/lib/view/AcTrLayer.d.ts +132 -0
- package/lib/view/AcTrLayer.d.ts.map +1 -0
- package/lib/view/AcTrLayer.js +199 -0
- package/lib/view/AcTrLayer.js.map +1 -0
- package/lib/view/AcTrLayout.d.ts +218 -0
- package/lib/view/AcTrLayout.d.ts.map +1 -0
- package/lib/view/AcTrLayout.js +437 -0
- package/lib/view/AcTrLayout.js.map +1 -0
- package/lib/view/AcTrLayoutView.d.ts +115 -0
- package/lib/view/AcTrLayoutView.d.ts.map +1 -0
- package/lib/view/AcTrLayoutView.js +200 -0
- package/lib/view/AcTrLayoutView.js.map +1 -0
- package/lib/view/AcTrLayoutViewManager.d.ts +89 -0
- package/lib/view/AcTrLayoutViewManager.d.ts.map +1 -0
- package/lib/view/AcTrLayoutViewManager.js +118 -0
- package/lib/view/AcTrLayoutViewManager.js.map +1 -0
- package/lib/view/AcTrScene.d.ts +162 -0
- package/lib/view/AcTrScene.d.ts.map +1 -0
- package/lib/view/AcTrScene.js +370 -0
- package/lib/view/AcTrScene.js.map +1 -0
- package/lib/view/AcTrView2d.d.ts +262 -0
- package/lib/view/AcTrView2d.d.ts.map +1 -0
- package/lib/view/AcTrView2d.js +772 -0
- package/lib/view/AcTrView2d.js.map +1 -0
- package/lib/view/index.d.ts +2 -0
- package/lib/view/index.d.ts.map +1 -0
- package/lib/view/index.js +2 -0
- package/lib/view/index.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,498 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import { AcCmEventManager, acdbHostApplicationServices, AcGeBox2d } from '@mlightcad/data-model';
|
|
38
|
+
import { AcTrMTextRenderer } from '@mlightcad/three-renderer';
|
|
39
|
+
import { AcApConvertToSvgCmd, AcApOpenCmd, AcApPanCmd, AcApQNewCmd, AcApRegenCmd, AcApSelectCmd, AcApZoomCmd, AcApZoomToBoxCmd, AcEdCommandStack } from '../command';
|
|
40
|
+
import { eventBus } from '../editor';
|
|
41
|
+
import { AcTrView2d } from '../view';
|
|
42
|
+
import { AcApContext } from './AcApContext';
|
|
43
|
+
import { AcApDocument } from './AcApDocument';
|
|
44
|
+
import { AcApFontLoader } from './AcApFontLoader';
|
|
45
|
+
var DEFAULT_BASE_URL = 'https://mlightcad.gitlab.io/cad-data/';
|
|
46
|
+
/**
|
|
47
|
+
* Document manager that handles CAD document lifecycle and provides the main entry point for the CAD viewer.
|
|
48
|
+
*
|
|
49
|
+
* This singleton class manages:
|
|
50
|
+
* - Document creation and opening (from URLs or file content)
|
|
51
|
+
* - View and context management
|
|
52
|
+
* - Command registration and execution
|
|
53
|
+
* - Font loading for text rendering
|
|
54
|
+
* - Event handling for document lifecycle
|
|
55
|
+
*
|
|
56
|
+
* The manager follows a singleton pattern to ensure only one instance manages the application state.
|
|
57
|
+
*/
|
|
58
|
+
var AcApDocManager = /** @class */ (function () {
|
|
59
|
+
/**
|
|
60
|
+
* Private constructor for singleton pattern.
|
|
61
|
+
*
|
|
62
|
+
* Creates an empty document with a 2D view and sets up the application context.
|
|
63
|
+
* Registers default commands and creates an example document.
|
|
64
|
+
*
|
|
65
|
+
* @param options -Options for creating AcApDocManager instance
|
|
66
|
+
* @private
|
|
67
|
+
*/
|
|
68
|
+
function AcApDocManager(options) {
|
|
69
|
+
if (options === void 0) { options = {}; }
|
|
70
|
+
var _a;
|
|
71
|
+
/** Events fired during document lifecycle */
|
|
72
|
+
this.events = {
|
|
73
|
+
/** Fired when a new document is created */
|
|
74
|
+
documentCreated: new AcCmEventManager(),
|
|
75
|
+
/** Fired when a document becomes active */
|
|
76
|
+
documentActivated: new AcCmEventManager()
|
|
77
|
+
};
|
|
78
|
+
this._baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : DEFAULT_BASE_URL;
|
|
79
|
+
if (options.useMainThreadDraw) {
|
|
80
|
+
AcTrMTextRenderer.getInstance().setRenderMode('main');
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
AcTrMTextRenderer.getInstance().setRenderMode('worker');
|
|
84
|
+
}
|
|
85
|
+
// Create one empty drawing
|
|
86
|
+
var doc = new AcApDocument();
|
|
87
|
+
doc.database.events.openProgress.addEventListener(function (args) {
|
|
88
|
+
eventBus.emit('open-file-progress', {
|
|
89
|
+
database: doc.database,
|
|
90
|
+
percentage: args.percentage,
|
|
91
|
+
stage: args.stage,
|
|
92
|
+
subStage: args.subStage,
|
|
93
|
+
subStageStatus: args.subStageStatus,
|
|
94
|
+
data: args.data
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
var callback = function () {
|
|
98
|
+
return {
|
|
99
|
+
width: window.innerWidth,
|
|
100
|
+
height: window.innerHeight - 30
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
var view = new AcTrView2d({
|
|
104
|
+
canvas: options.canvas,
|
|
105
|
+
calculateSizeCallback: callback
|
|
106
|
+
});
|
|
107
|
+
this._context = new AcApContext(view, doc);
|
|
108
|
+
this._fontLoader = new AcApFontLoader();
|
|
109
|
+
this._fontLoader.baseUrl = this._baseUrl + 'fonts/';
|
|
110
|
+
acdbHostApplicationServices().workingDatabase = doc.database;
|
|
111
|
+
this.registerCommands();
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Creates the singleton instance with an optional canvas element.
|
|
115
|
+
*
|
|
116
|
+
* This method should be called before accessing the `instance` property
|
|
117
|
+
* if you want to provide a specific canvas element.
|
|
118
|
+
*
|
|
119
|
+
* @param options -Options for creating AcApDocManager instance
|
|
120
|
+
* @returns The singleton instance
|
|
121
|
+
*/
|
|
122
|
+
AcApDocManager.createInstance = function (options) {
|
|
123
|
+
if (options === void 0) { options = {}; }
|
|
124
|
+
if (AcApDocManager._instance == null) {
|
|
125
|
+
AcApDocManager._instance = new AcApDocManager(options);
|
|
126
|
+
}
|
|
127
|
+
return this._instance;
|
|
128
|
+
};
|
|
129
|
+
Object.defineProperty(AcApDocManager, "instance", {
|
|
130
|
+
/**
|
|
131
|
+
* Gets the singleton instance of the document manager.
|
|
132
|
+
*
|
|
133
|
+
* Creates a new instance if one doesn't exist yet.
|
|
134
|
+
*
|
|
135
|
+
* @returns The singleton document manager instance
|
|
136
|
+
*/
|
|
137
|
+
get: function () {
|
|
138
|
+
if (!AcApDocManager._instance) {
|
|
139
|
+
AcApDocManager._instance = new AcApDocManager();
|
|
140
|
+
}
|
|
141
|
+
return AcApDocManager._instance;
|
|
142
|
+
},
|
|
143
|
+
enumerable: false,
|
|
144
|
+
configurable: true
|
|
145
|
+
});
|
|
146
|
+
Object.defineProperty(AcApDocManager.prototype, "context", {
|
|
147
|
+
/**
|
|
148
|
+
* Gets the current application context.
|
|
149
|
+
*
|
|
150
|
+
* The context binds the current document with its associated view.
|
|
151
|
+
*
|
|
152
|
+
* @returns The current application context
|
|
153
|
+
*/
|
|
154
|
+
get: function () {
|
|
155
|
+
return this._context;
|
|
156
|
+
},
|
|
157
|
+
enumerable: false,
|
|
158
|
+
configurable: true
|
|
159
|
+
});
|
|
160
|
+
Object.defineProperty(AcApDocManager.prototype, "curDocument", {
|
|
161
|
+
/**
|
|
162
|
+
* Gets the currently open CAD document.
|
|
163
|
+
*
|
|
164
|
+
* @returns The current document instance
|
|
165
|
+
*/
|
|
166
|
+
get: function () {
|
|
167
|
+
return this._context.doc;
|
|
168
|
+
},
|
|
169
|
+
enumerable: false,
|
|
170
|
+
configurable: true
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(AcApDocManager.prototype, "mdiActiveDocument", {
|
|
173
|
+
/**
|
|
174
|
+
* Gets the currently active document.
|
|
175
|
+
*
|
|
176
|
+
* For now, this is the same as `curDocument` since only one document
|
|
177
|
+
* can be active at a time.
|
|
178
|
+
*
|
|
179
|
+
* @returns The current active document
|
|
180
|
+
*/
|
|
181
|
+
get: function () {
|
|
182
|
+
return this._context.doc;
|
|
183
|
+
},
|
|
184
|
+
enumerable: false,
|
|
185
|
+
configurable: true
|
|
186
|
+
});
|
|
187
|
+
Object.defineProperty(AcApDocManager.prototype, "curView", {
|
|
188
|
+
/**
|
|
189
|
+
* Gets the current 2D view used to display the drawing.
|
|
190
|
+
*
|
|
191
|
+
* @returns The current 2D view instance
|
|
192
|
+
*/
|
|
193
|
+
get: function () {
|
|
194
|
+
return this._context.view;
|
|
195
|
+
},
|
|
196
|
+
enumerable: false,
|
|
197
|
+
configurable: true
|
|
198
|
+
});
|
|
199
|
+
Object.defineProperty(AcApDocManager.prototype, "editor", {
|
|
200
|
+
/**
|
|
201
|
+
* Gets the editor instance for handling user input.
|
|
202
|
+
*
|
|
203
|
+
* @returns The current editor instance
|
|
204
|
+
*/
|
|
205
|
+
get: function () {
|
|
206
|
+
return this._context.view.editor;
|
|
207
|
+
},
|
|
208
|
+
enumerable: false,
|
|
209
|
+
configurable: true
|
|
210
|
+
});
|
|
211
|
+
Object.defineProperty(AcApDocManager.prototype, "baseUrl", {
|
|
212
|
+
/**
|
|
213
|
+
* Base URL to load fonts
|
|
214
|
+
*/
|
|
215
|
+
get: function () {
|
|
216
|
+
return this._baseUrl;
|
|
217
|
+
},
|
|
218
|
+
enumerable: false,
|
|
219
|
+
configurable: true
|
|
220
|
+
});
|
|
221
|
+
Object.defineProperty(AcApDocManager.prototype, "avaiableFonts", {
|
|
222
|
+
/**
|
|
223
|
+
* Gets the list of available fonts that can be loaded.
|
|
224
|
+
*
|
|
225
|
+
* Note: These fonts are available for loading but may not be loaded yet.
|
|
226
|
+
*
|
|
227
|
+
* @returns Array of available font names
|
|
228
|
+
*/
|
|
229
|
+
get: function () {
|
|
230
|
+
return this._fontLoader.avaiableFonts;
|
|
231
|
+
},
|
|
232
|
+
enumerable: false,
|
|
233
|
+
configurable: true
|
|
234
|
+
});
|
|
235
|
+
/**
|
|
236
|
+
* Loads the specified fonts for text rendering.
|
|
237
|
+
*
|
|
238
|
+
* @param fonts - Array of font names to load
|
|
239
|
+
* @returns Promise that resolves when fonts are loaded
|
|
240
|
+
*
|
|
241
|
+
* @example
|
|
242
|
+
* ```typescript
|
|
243
|
+
* await docManager.loadFonts(['Arial', 'Times New Roman']);
|
|
244
|
+
* ```
|
|
245
|
+
*/
|
|
246
|
+
AcApDocManager.prototype.loadFonts = function (fonts) {
|
|
247
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
248
|
+
return __generator(this, function (_a) {
|
|
249
|
+
switch (_a.label) {
|
|
250
|
+
case 0: return [4 /*yield*/, this._fontLoader.load(fonts)];
|
|
251
|
+
case 1:
|
|
252
|
+
_a.sent();
|
|
253
|
+
return [2 /*return*/];
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
/**
|
|
259
|
+
* Loads default fonts for CAD text rendering.
|
|
260
|
+
*
|
|
261
|
+
* This method loads either the specified fonts or falls back to default Chinese fonts
|
|
262
|
+
* (specifically 'simkai') if no fonts are provided. The loaded fonts are used for
|
|
263
|
+
* rendering CAD text entities like MText and Text in the viewer.
|
|
264
|
+
*
|
|
265
|
+
* It is better to load default fonts when viewer is initialized so that the viewer can
|
|
266
|
+
* render text correctly if fonts used in the document are not available.
|
|
267
|
+
*
|
|
268
|
+
* @param fonts - Optional array of font names to load. If not provided or null,
|
|
269
|
+
* defaults to ['simkai'] for Chinese text support
|
|
270
|
+
* @returns Promise that resolves when all specified fonts are loaded
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* // Load default fonts (simkai)
|
|
275
|
+
* await docManager.loadDefaultFonts();
|
|
276
|
+
*
|
|
277
|
+
* // Load specific fonts
|
|
278
|
+
* await docManager.loadDefaultFonts(['Arial', 'SimSun']);
|
|
279
|
+
*
|
|
280
|
+
* // Load no fonts (empty array)
|
|
281
|
+
* await docManager.loadDefaultFonts([]);
|
|
282
|
+
* ```
|
|
283
|
+
*
|
|
284
|
+
* @see {@link AcApFontLoader.load} - The underlying font loading implementation
|
|
285
|
+
* @see {@link createExampleDoc} - Method that uses this for example document creation
|
|
286
|
+
*/
|
|
287
|
+
AcApDocManager.prototype.loadDefaultFonts = function (fonts) {
|
|
288
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
289
|
+
return __generator(this, function (_a) {
|
|
290
|
+
switch (_a.label) {
|
|
291
|
+
case 0:
|
|
292
|
+
if (!(fonts == null)) return [3 /*break*/, 2];
|
|
293
|
+
return [4 /*yield*/, this._fontLoader.load(['simkai'])];
|
|
294
|
+
case 1:
|
|
295
|
+
_a.sent();
|
|
296
|
+
return [3 /*break*/, 4];
|
|
297
|
+
case 2: return [4 /*yield*/, this._fontLoader.load(fonts)];
|
|
298
|
+
case 3:
|
|
299
|
+
_a.sent();
|
|
300
|
+
_a.label = 4;
|
|
301
|
+
case 4: return [2 /*return*/];
|
|
302
|
+
}
|
|
303
|
+
});
|
|
304
|
+
});
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Opens a CAD document from a URL.
|
|
308
|
+
*
|
|
309
|
+
* This method loads a document from the specified URL and replaces the current document.
|
|
310
|
+
* It handles the complete document lifecycle including before/after open events.
|
|
311
|
+
*
|
|
312
|
+
* @param url - The URL of the CAD file to open
|
|
313
|
+
* @param options - Optional database opening options. If not provided, default options with font loader will be used
|
|
314
|
+
* @returns Promise that resolves to true if the document was successfully opened, false otherwise
|
|
315
|
+
*
|
|
316
|
+
* @example
|
|
317
|
+
* ```typescript
|
|
318
|
+
* const success = await docManager.openUrl('https://example.com/drawing.dwg');
|
|
319
|
+
* if (success) {
|
|
320
|
+
* console.log('Document opened successfully');
|
|
321
|
+
* }
|
|
322
|
+
* ```
|
|
323
|
+
*/
|
|
324
|
+
AcApDocManager.prototype.openUrl = function (url, options) {
|
|
325
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
326
|
+
var isSuccess;
|
|
327
|
+
return __generator(this, function (_a) {
|
|
328
|
+
switch (_a.label) {
|
|
329
|
+
case 0:
|
|
330
|
+
this.onBeforeOpenDocument();
|
|
331
|
+
options = this.setOptions(options);
|
|
332
|
+
return [4 /*yield*/, this.context.doc.openUri(url, options)];
|
|
333
|
+
case 1:
|
|
334
|
+
isSuccess = _a.sent();
|
|
335
|
+
this.onAfterOpenDocument(isSuccess);
|
|
336
|
+
return [2 /*return*/, isSuccess];
|
|
337
|
+
}
|
|
338
|
+
});
|
|
339
|
+
});
|
|
340
|
+
};
|
|
341
|
+
/**
|
|
342
|
+
* Opens a CAD document from file content.
|
|
343
|
+
*
|
|
344
|
+
* This method loads a document from the provided file content (binary data)
|
|
345
|
+
* and replaces the current document. It handles the complete document lifecycle
|
|
346
|
+
* including before/after open events.
|
|
347
|
+
*
|
|
348
|
+
* @param fileName - The name of the file being opened (used for format detection)
|
|
349
|
+
* @param content - The file content
|
|
350
|
+
* @param options - Database opening options including font loader settings
|
|
351
|
+
* @returns Promise that resolves to true if the document was successfully opened, false otherwise
|
|
352
|
+
*
|
|
353
|
+
* @example
|
|
354
|
+
* ```typescript
|
|
355
|
+
* const fileContent = await file.arrayBuffer();
|
|
356
|
+
* const success = await docManager.openDocument('drawing.dwg', fileContent, options);
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
AcApDocManager.prototype.openDocument = function (fileName, content, options) {
|
|
360
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
361
|
+
var isSuccess;
|
|
362
|
+
return __generator(this, function (_a) {
|
|
363
|
+
switch (_a.label) {
|
|
364
|
+
case 0:
|
|
365
|
+
this.onBeforeOpenDocument();
|
|
366
|
+
options = this.setOptions(options);
|
|
367
|
+
return [4 /*yield*/, this.context.doc.openDocument(fileName, content, options)];
|
|
368
|
+
case 1:
|
|
369
|
+
isSuccess = _a.sent();
|
|
370
|
+
this.onAfterOpenDocument(isSuccess);
|
|
371
|
+
return [2 /*return*/, isSuccess];
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
});
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
* Redraws the current view. Currently it is used once you modified font mapping
|
|
378
|
+
* for missed fonts so that the drawing can apply new fonts.
|
|
379
|
+
*/
|
|
380
|
+
AcApDocManager.prototype.regen = function () {
|
|
381
|
+
this.curView.clear();
|
|
382
|
+
this.context.doc.database.regen();
|
|
383
|
+
};
|
|
384
|
+
/**
|
|
385
|
+
* Registers all default commands available in the CAD viewer.
|
|
386
|
+
*
|
|
387
|
+
* This method sets up the command system by registering built-in commands including:
|
|
388
|
+
* - pan: Pan/move the view
|
|
389
|
+
* - select: Select entities
|
|
390
|
+
* - zoom: Zoom in/out
|
|
391
|
+
* - zoomw: Zoom to window/box
|
|
392
|
+
* - csvg: Convert to SVG
|
|
393
|
+
* - qnew: Quick new document
|
|
394
|
+
* - open: Open document
|
|
395
|
+
*
|
|
396
|
+
* All commands are registered under the system command group.
|
|
397
|
+
*/
|
|
398
|
+
AcApDocManager.prototype.registerCommands = function () {
|
|
399
|
+
var register = AcEdCommandStack.instance;
|
|
400
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'pan', 'pan', new AcApPanCmd());
|
|
401
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'regen', 'regen', new AcApRegenCmd());
|
|
402
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'select', 'select', new AcApSelectCmd());
|
|
403
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'zoom', 'zoom', new AcApZoomCmd());
|
|
404
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'zoomw', 'zoomw', new AcApZoomToBoxCmd());
|
|
405
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'csvg', 'csvg', new AcApConvertToSvgCmd());
|
|
406
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'qnew', 'qnew', new AcApQNewCmd());
|
|
407
|
+
register.addCommand(AcEdCommandStack.SYSTEMT_COMMAND_GROUP_NAME, 'open', 'open', new AcApOpenCmd());
|
|
408
|
+
};
|
|
409
|
+
/**
|
|
410
|
+
* Executes a command by its string name.
|
|
411
|
+
*
|
|
412
|
+
* This method looks up a registered command by name and executes it with the current context.
|
|
413
|
+
* If the command is not found, no action is taken.
|
|
414
|
+
*
|
|
415
|
+
* @param cmdStr - The command string to execute (e.g., 'pan', 'zoom', 'select')
|
|
416
|
+
*
|
|
417
|
+
* @example
|
|
418
|
+
* ```typescript
|
|
419
|
+
* docManager.sendStringToExecute('zoom');
|
|
420
|
+
* docManager.sendStringToExecute('pan');
|
|
421
|
+
* ```
|
|
422
|
+
*/
|
|
423
|
+
AcApDocManager.prototype.sendStringToExecute = function (cmdStr) {
|
|
424
|
+
var register = AcEdCommandStack.instance;
|
|
425
|
+
var cmd = register.lookupGlobalCmd(cmdStr);
|
|
426
|
+
cmd === null || cmd === void 0 ? void 0 : cmd.execute(this.context);
|
|
427
|
+
};
|
|
428
|
+
/**
|
|
429
|
+
* Configures layout information for the current view.
|
|
430
|
+
*
|
|
431
|
+
* Sets up the active layout block table record ID and model space block table
|
|
432
|
+
* record ID based on the current document's space configuration.
|
|
433
|
+
*/
|
|
434
|
+
AcApDocManager.prototype.setActiveLayout = function () {
|
|
435
|
+
var currentView = this.curView;
|
|
436
|
+
currentView.activeLayoutBtrId = this.curDocument.database.currentSpaceId;
|
|
437
|
+
currentView.modelSpaceBtrId = this.curDocument.database.currentSpaceId;
|
|
438
|
+
};
|
|
439
|
+
/**
|
|
440
|
+
* Performs cleanup operations before opening a new document.
|
|
441
|
+
*
|
|
442
|
+
* This protected method is called automatically before any document opening operation.
|
|
443
|
+
* It clears the current view to prepare for the new document content.
|
|
444
|
+
*
|
|
445
|
+
* @protected
|
|
446
|
+
*/
|
|
447
|
+
AcApDocManager.prototype.onBeforeOpenDocument = function () {
|
|
448
|
+
this.curView.clear();
|
|
449
|
+
};
|
|
450
|
+
/**
|
|
451
|
+
* Performs setup operations after a document opening attempt.
|
|
452
|
+
*
|
|
453
|
+
* This protected method is called automatically after any document opening operation.
|
|
454
|
+
* If the document was successfully opened, it dispatches the documentActivated event,
|
|
455
|
+
* sets up layout information, and zooms the view to fit the content.
|
|
456
|
+
*
|
|
457
|
+
* @param isSuccess - Whether the document was successfully opened
|
|
458
|
+
* @protected
|
|
459
|
+
*/
|
|
460
|
+
AcApDocManager.prototype.onAfterOpenDocument = function (isSuccess) {
|
|
461
|
+
if (isSuccess) {
|
|
462
|
+
var doc = this.context.doc;
|
|
463
|
+
this.events.documentActivated.dispatch({ doc: doc });
|
|
464
|
+
this.setActiveLayout();
|
|
465
|
+
var db = doc.database;
|
|
466
|
+
// The extents of drawing database may be empty. Espically dxf files.
|
|
467
|
+
if (db.extents.isEmpty()) {
|
|
468
|
+
this.curView.zoomToFit();
|
|
469
|
+
}
|
|
470
|
+
else {
|
|
471
|
+
this.curView.zoomTo(new AcGeBox2d(db.extmin, db.extmax));
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
/**
|
|
476
|
+
* Sets up or validates database opening options.
|
|
477
|
+
*
|
|
478
|
+
* This private method ensures that the options object has a font loader configured.
|
|
479
|
+
* If no options are provided, creates new options with the font loader.
|
|
480
|
+
* If options are provided but missing a font loader, adds the font loader.
|
|
481
|
+
*
|
|
482
|
+
* @param options - Optional database opening options to validate/modify
|
|
483
|
+
* @returns The validated options object with font loader configured
|
|
484
|
+
* @private
|
|
485
|
+
*/
|
|
486
|
+
AcApDocManager.prototype.setOptions = function (options) {
|
|
487
|
+
if (options == null) {
|
|
488
|
+
options = { fontLoader: this._fontLoader };
|
|
489
|
+
}
|
|
490
|
+
else if (options.fontLoader == null) {
|
|
491
|
+
options.fontLoader = this._fontLoader;
|
|
492
|
+
}
|
|
493
|
+
return options;
|
|
494
|
+
};
|
|
495
|
+
return AcApDocManager;
|
|
496
|
+
}());
|
|
497
|
+
export { AcApDocManager };
|
|
498
|
+
//# sourceMappingURL=AcApDocManager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApDocManager.js","sourceR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GAAG,EAAE,UAAU,EAAE,IAAI,CAAC,WAAW,EAAE,CAAA;QAC5C,CAAC;aAAM,IAAI,OAAO,CAAC,UAAU,IAAI,IAAI,EAAE,CAAC;YACtC,OAAO,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAA;QACvC,CAAC;QACD,OAAO,OAAO,CAAA;IAChB,CAAC;IACH,qBAAC;AAAD,CAAC,AAzbD,IAybC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { AcDbDatabase, AcDbOpenDatabaseOptions } from '@mlightcad/data-model';
|
|
2
|
+
/**
|
|
3
|
+
* Represents a CAD document that manages a drawing database and associated metadata.
|
|
4
|
+
*
|
|
5
|
+
* This class handles:
|
|
6
|
+
* - Opening CAD files from URIs or file content (DWG/DXF formats)
|
|
7
|
+
* - Managing document properties (title, read-only state)
|
|
8
|
+
* - Providing access to the underlying database
|
|
9
|
+
* - Handling file loading errors through event emission
|
|
10
|
+
*/
|
|
11
|
+
export declare class AcApDocument {
|
|
12
|
+
/** The URI of the opened document, if opened from a URI */
|
|
13
|
+
private _uri?;
|
|
14
|
+
/** The underlying CAD database containing all drawing data */
|
|
15
|
+
private _database;
|
|
16
|
+
/** The file name of the document */
|
|
17
|
+
private _fileName;
|
|
18
|
+
/** The display title of the document */
|
|
19
|
+
private _docTitle;
|
|
20
|
+
/** Whether the document is opened in read-only mode */
|
|
21
|
+
private _isReadOnly;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new document instance with an empty database.
|
|
24
|
+
*
|
|
25
|
+
* The document is initialized with an "Untitled" title and read-only mode enabled.
|
|
26
|
+
*/
|
|
27
|
+
constructor();
|
|
28
|
+
/**
|
|
29
|
+
* Opens a CAD document from a URI.
|
|
30
|
+
*
|
|
31
|
+
* @param uri - The URI of the CAD file to open
|
|
32
|
+
* @param options - Options for opening the database, including read-only mode
|
|
33
|
+
* @returns Promise resolving to true if successful, false if failed
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const success = await document.openUri('https://example.com/drawing.dwg', {
|
|
38
|
+
* readOnly: true
|
|
39
|
+
* });
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
openUri(uri: string, options: AcDbOpenDatabaseOptions): Promise<boolean>;
|
|
43
|
+
/**
|
|
44
|
+
* Opens a CAD document from file content.
|
|
45
|
+
*
|
|
46
|
+
* @param fileName - The name of the file (used to determine file type from extension)
|
|
47
|
+
* @param content - The file content as string or ArrayBuffer
|
|
48
|
+
* @param options - Options for opening the database, including read-only mode
|
|
49
|
+
* @returns Promise resolving to true if successful, false if failed
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* ```typescript
|
|
53
|
+
* const fileContent = await fetch('drawing.dwg').then(r => r.arrayBuffer());
|
|
54
|
+
* const success = await document.openDocument('drawing.dwg', fileContent, {
|
|
55
|
+
* readOnly: false
|
|
56
|
+
* });
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
openDocument(fileName: string, content: ArrayBuffer, options: AcDbOpenDatabaseOptions): Promise<boolean>;
|
|
60
|
+
/**
|
|
61
|
+
* Gets the URI of the document if opened from a URI.
|
|
62
|
+
*
|
|
63
|
+
* @returns The document URI, or undefined if not opened from URI
|
|
64
|
+
*/
|
|
65
|
+
get uri(): string | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* Gets the database object containing all drawing data.
|
|
68
|
+
*
|
|
69
|
+
* @returns The underlying CAD database instance
|
|
70
|
+
*/
|
|
71
|
+
get database(): AcDbDatabase;
|
|
72
|
+
/**
|
|
73
|
+
* Gets the display title of the document.
|
|
74
|
+
*
|
|
75
|
+
* @returns The document title displayed in the window/tab
|
|
76
|
+
*/
|
|
77
|
+
get docTitle(): string;
|
|
78
|
+
/**
|
|
79
|
+
* Sets the display title of the document.
|
|
80
|
+
*
|
|
81
|
+
* Also updates the browser tab title if running in a browser environment.
|
|
82
|
+
*
|
|
83
|
+
* @param value - The new document title
|
|
84
|
+
*/
|
|
85
|
+
set docTitle(value: string);
|
|
86
|
+
/**
|
|
87
|
+
* Gets whether the document is opened in read-only mode.
|
|
88
|
+
*
|
|
89
|
+
* @returns True if the document is read-only, false if editable
|
|
90
|
+
*/
|
|
91
|
+
get isReadOnly(): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Extracts the file name from a URI.
|
|
94
|
+
*
|
|
95
|
+
* @param uri - The URI to extract the file name from
|
|
96
|
+
* @returns The extracted file name, or empty string if extraction fails
|
|
97
|
+
* @private
|
|
98
|
+
*/
|
|
99
|
+
private getFileNameFromUri;
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=AcApDocument.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AcApDocument.d.ts","sourceRoot":"","sources":["../../src/app/AcApDocument.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EAEZ,uBAAuB,EACxB,MAAM,uBAAuB,CAAA;AAI9B;;;;;;;;GAQG;AACH,qBAAa,YAAY;IACvB,2DAA2D;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAQ;IACrB,8DAA8D;IAC9D,OAAO,CAAC,SAAS,CAAc;IAC/B,oCAAoC;IACpC,OAAO,CAAC,SAAS,CAAa;IAC9B,wCAAwC;IACxC,OAAO,CAAC,SAAS,CAAa;IAC9B,uDAAuD;IACvD,OAAO,CAAC,WAAW,CAAgB;IAEnC;;;;OAIG;;IAMH;;;;;;;;;;;;;OAaG;IACG,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,uBAAuB;IAe3D;;;;;;;;;;;;;;;OAeG;IACG,YAAY,CAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,WAAW,EACpB,OAAO,EAAE,uBAAuB;IAoBlC;;;;OAIG;IACH,IAAI,GAAG,uBAEN;IAED;;;;OAIG;IACH,IAAI,QAAQ,iBAEX;IAED;;;;OAIG;IACH,IAAI,QAAQ,IAWQ,MAAM,CATzB;IAED;;;;;;OAMG;IACH,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAMzB;IAED;;;;OAIG;IACH,IAAI,UAAU,YAEb;IAED;;;;;;OAMG;IACH,OAAO,CAAC,kBAAkB;CAa3B"}
|