@mlightcad/cad-simple-viewer 1.7.3 → 1.7.5

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 (235) hide show
  1. package/README.md +5 -0
  2. package/dist/cad-simple-viewer.js +10348 -8246
  3. package/dist/cad-simple-viewer.umd.cjs +431 -87
  4. package/dist/mtext-renderer-worker.js +2191 -2124
  5. package/lib/app/AcApDocManager.d.ts +57 -0
  6. package/lib/app/AcApDocManager.d.ts.map +1 -1
  7. package/lib/app/AcApDocManager.js +171 -9
  8. package/lib/app/AcApDocManager.js.map +1 -1
  9. package/lib/app/AcApOpenDatabaseOptions.d.ts +34 -8
  10. package/lib/app/AcApOpenDatabaseOptions.d.ts.map +1 -1
  11. package/lib/app/AcApOpenFileDialog.d.ts +1 -1
  12. package/lib/app/AcApOpenFileDialog.d.ts.map +1 -1
  13. package/lib/app/AcApOpenFileDialog.js +22 -92
  14. package/lib/app/AcApOpenFileDialog.js.map +1 -1
  15. package/lib/app/AcApOpenFileProfiler.d.ts +14 -0
  16. package/lib/app/AcApOpenFileProfiler.d.ts.map +1 -1
  17. package/lib/app/AcApOpenFileProfiler.js +25 -3
  18. package/lib/app/AcApOpenFileProfiler.js.map +1 -1
  19. package/lib/app/dataSource/AcApDataSource.d.ts +97 -0
  20. package/lib/app/dataSource/AcApDataSource.d.ts.map +1 -0
  21. package/lib/app/dataSource/AcApDataSource.js +2 -0
  22. package/lib/app/dataSource/AcApDataSource.js.map +1 -0
  23. package/lib/app/dataSource/AcApDataSourceManager.d.ts +70 -0
  24. package/lib/app/dataSource/AcApDataSourceManager.d.ts.map +1 -0
  25. package/lib/app/dataSource/AcApDataSourceManager.js +84 -0
  26. package/lib/app/dataSource/AcApDataSourceManager.js.map +1 -0
  27. package/lib/app/dataSource/AcApLocalDataSource.d.ts +25 -0
  28. package/lib/app/dataSource/AcApLocalDataSource.d.ts.map +1 -0
  29. package/lib/app/dataSource/AcApLocalDataSource.js +153 -0
  30. package/lib/app/dataSource/AcApLocalDataSource.js.map +1 -0
  31. package/lib/app/dataSource/AcApUrlDataSource.d.ts +17 -0
  32. package/lib/app/dataSource/AcApUrlDataSource.d.ts.map +1 -0
  33. package/lib/app/dataSource/AcApUrlDataSource.js +214 -0
  34. package/lib/app/dataSource/AcApUrlDataSource.js.map +1 -0
  35. package/lib/app/dataSource/acapBuildDataSourceMenu.d.ts +42 -0
  36. package/lib/app/dataSource/acapBuildDataSourceMenu.d.ts.map +1 -0
  37. package/lib/app/dataSource/acapBuildDataSourceMenu.js +121 -0
  38. package/lib/app/dataSource/acapBuildDataSourceMenu.js.map +1 -0
  39. package/lib/app/dataSource/acapInvokeDataSourceMenuAction.d.ts +17 -0
  40. package/lib/app/dataSource/acapInvokeDataSourceMenuAction.d.ts.map +1 -0
  41. package/lib/app/dataSource/acapInvokeDataSourceMenuAction.js +74 -0
  42. package/lib/app/dataSource/acapInvokeDataSourceMenuAction.js.map +1 -0
  43. package/lib/app/dataSource/acapOpenCenteredPopup.d.ts +13 -0
  44. package/lib/app/dataSource/acapOpenCenteredPopup.d.ts.map +1 -0
  45. package/lib/app/dataSource/acapOpenCenteredPopup.js +35 -0
  46. package/lib/app/dataSource/acapOpenCenteredPopup.js.map +1 -0
  47. package/lib/app/dataSource/acapOpenDataSourceResult.d.ts +13 -0
  48. package/lib/app/dataSource/acapOpenDataSourceResult.d.ts.map +1 -0
  49. package/lib/app/dataSource/acapOpenDataSourceResult.js +90 -0
  50. package/lib/app/dataSource/acapOpenDataSourceResult.js.map +1 -0
  51. package/lib/app/dataSource/acapRunDataSourceMenuAction.d.ts +15 -0
  52. package/lib/app/dataSource/acapRunDataSourceMenuAction.d.ts.map +1 -0
  53. package/lib/app/dataSource/acapRunDataSourceMenuAction.js +74 -0
  54. package/lib/app/dataSource/acapRunDataSourceMenuAction.js.map +1 -0
  55. package/lib/app/dataSource/acapWithDataSourceBusy.d.ts +12 -0
  56. package/lib/app/dataSource/acapWithDataSourceBusy.d.ts.map +1 -0
  57. package/lib/app/dataSource/acapWithDataSourceBusy.js +88 -0
  58. package/lib/app/dataSource/acapWithDataSourceBusy.js.map +1 -0
  59. package/lib/app/dataSource/index.d.ts +11 -0
  60. package/lib/app/dataSource/index.d.ts.map +1 -0
  61. package/lib/app/dataSource/index.js +10 -0
  62. package/lib/app/dataSource/index.js.map +1 -0
  63. package/lib/app/index.d.ts +1 -0
  64. package/lib/app/index.d.ts.map +1 -1
  65. package/lib/app/index.js +1 -0
  66. package/lib/app/index.js.map +1 -1
  67. package/lib/command/AcApZoomCmd.d.ts +3 -0
  68. package/lib/command/AcApZoomCmd.d.ts.map +1 -1
  69. package/lib/command/AcApZoomCmd.js +20 -6
  70. package/lib/command/AcApZoomCmd.js.map +1 -1
  71. package/lib/command/convert/AcApConvertToRasterImageCmd.d.ts +4 -2
  72. package/lib/command/convert/AcApConvertToRasterImageCmd.d.ts.map +1 -1
  73. package/lib/command/convert/AcApConvertToRasterImageCmd.js +33 -17
  74. package/lib/command/convert/AcApConvertToRasterImageCmd.js.map +1 -1
  75. package/lib/command/markup/AcApMarkupCalloutCmd.d.ts.map +1 -1
  76. package/lib/command/markup/AcApMarkupCalloutCmd.js +8 -4
  77. package/lib/command/markup/AcApMarkupCalloutCmd.js.map +1 -1
  78. package/lib/command/markup/AcApMarkupShapeCallout.d.ts.map +1 -1
  79. package/lib/command/markup/AcApMarkupShapeCallout.js +8 -4
  80. package/lib/command/markup/AcApMarkupShapeCallout.js.map +1 -1
  81. package/lib/command/markup/AcApMarkupUtil.d.ts.map +1 -1
  82. package/lib/command/markup/AcApMarkupUtil.js +6 -4
  83. package/lib/command/markup/AcApMarkupUtil.js.map +1 -1
  84. package/lib/command/measure/AcApMeasureAngleArc.d.ts +9 -2
  85. package/lib/command/measure/AcApMeasureAngleArc.d.ts.map +1 -1
  86. package/lib/command/measure/AcApMeasureAngleArc.js +9 -2
  87. package/lib/command/measure/AcApMeasureAngleArc.js.map +1 -1
  88. package/lib/command/measure/AcApMeasureAngleCmd.d.ts.map +1 -1
  89. package/lib/command/measure/AcApMeasureAngleCmd.js +17 -4
  90. package/lib/command/measure/AcApMeasureAngleCmd.js.map +1 -1
  91. package/lib/command/measure/AcApMeasureArcCmd.d.ts.map +1 -1
  92. package/lib/command/measure/AcApMeasureArcCmd.js +12 -8
  93. package/lib/command/measure/AcApMeasureArcCmd.js.map +1 -1
  94. package/lib/command/measure/AcApMeasureAreaCmd.d.ts.map +1 -1
  95. package/lib/command/measure/AcApMeasureAreaCmd.js +17 -4
  96. package/lib/command/measure/AcApMeasureAreaCmd.js.map +1 -1
  97. package/lib/command/measure/AcApMeasureContinuousCmd.d.ts.map +1 -1
  98. package/lib/command/measure/AcApMeasureContinuousCmd.js +36 -6
  99. package/lib/command/measure/AcApMeasureContinuousCmd.js.map +1 -1
  100. package/lib/command/measure/AcApMeasureDistanceCmd.d.ts.map +1 -1
  101. package/lib/command/measure/AcApMeasureDistanceCmd.js +28 -8
  102. package/lib/command/measure/AcApMeasureDistanceCmd.js.map +1 -1
  103. package/lib/command/measure/AcApMeasurementStore.d.ts.map +1 -1
  104. package/lib/command/measure/AcApMeasurementStore.js +44 -28
  105. package/lib/command/measure/AcApMeasurementStore.js.map +1 -1
  106. package/lib/command/measure/entity/AcApMeasureAngleEntity.d.ts.map +1 -1
  107. package/lib/command/measure/entity/AcApMeasureAngleEntity.js +43 -7
  108. package/lib/command/measure/entity/AcApMeasureAngleEntity.js.map +1 -1
  109. package/lib/command/measure/entity/AcApMeasureArcEntity.d.ts.map +1 -1
  110. package/lib/command/measure/entity/AcApMeasureArcEntity.js +46 -8
  111. package/lib/command/measure/entity/AcApMeasureArcEntity.js.map +1 -1
  112. package/lib/command/measure/entity/AcApMeasureAreaEntity.d.ts.map +1 -1
  113. package/lib/command/measure/entity/AcApMeasureAreaEntity.js +43 -7
  114. package/lib/command/measure/entity/AcApMeasureAreaEntity.js.map +1 -1
  115. package/lib/command/measure/entity/AcApMeasureDistanceEntity.d.ts.map +1 -1
  116. package/lib/command/measure/entity/AcApMeasureDistanceEntity.js +56 -8
  117. package/lib/command/measure/entity/AcApMeasureDistanceEntity.js.map +1 -1
  118. package/lib/command/measure/entity/AcApMeasureEntity.d.ts +8 -0
  119. package/lib/command/measure/entity/AcApMeasureEntity.d.ts.map +1 -1
  120. package/lib/command/measure/entity/AcApMeasureEntity.js +16 -1
  121. package/lib/command/measure/entity/AcApMeasureEntity.js.map +1 -1
  122. package/lib/command/measure/entity/AcApMeasureEntityGrips.d.ts.map +1 -1
  123. package/lib/command/measure/entity/AcApMeasureEntityGrips.js +2 -1
  124. package/lib/command/measure/entity/AcApMeasureEntityGrips.js.map +1 -1
  125. package/lib/command/overlay/AcApHtmlLivePreview.d.ts +6 -0
  126. package/lib/command/overlay/AcApHtmlLivePreview.d.ts.map +1 -1
  127. package/lib/command/overlay/AcApHtmlLivePreview.js +9 -2
  128. package/lib/command/overlay/AcApHtmlLivePreview.js.map +1 -1
  129. package/lib/command/overlay/AcApOverlayDrawUtil.d.ts +5 -0
  130. package/lib/command/overlay/AcApOverlayDrawUtil.d.ts.map +1 -1
  131. package/lib/command/overlay/AcApOverlayDrawUtil.js +54 -23
  132. package/lib/command/overlay/AcApOverlayDrawUtil.js.map +1 -1
  133. package/lib/editor/global/AcEdConditionWaiter.d.ts +3 -0
  134. package/lib/editor/global/AcEdConditionWaiter.d.ts.map +1 -1
  135. package/lib/editor/global/AcEdConditionWaiter.js +9 -2
  136. package/lib/editor/global/AcEdConditionWaiter.js.map +1 -1
  137. package/lib/editor/global/AcEdUiTheme.d.ts +10 -1
  138. package/lib/editor/global/AcEdUiTheme.d.ts.map +1 -1
  139. package/lib/editor/global/AcEdUiTheme.js +35 -2
  140. package/lib/editor/global/AcEdUiTheme.js.map +1 -1
  141. package/lib/editor/input/ui/AcEdCommandLine.d.ts.map +1 -1
  142. package/lib/editor/input/ui/AcEdCommandLine.js +7 -7
  143. package/lib/editor/input/ui/AcEdCommandLine.js.map +1 -1
  144. package/lib/editor/view/AcEdBaseView.d.ts +14 -1
  145. package/lib/editor/view/AcEdBaseView.d.ts.map +1 -1
  146. package/lib/editor/view/AcEdBaseView.js.map +1 -1
  147. package/lib/i18n/ar/main.d.ts +28 -0
  148. package/lib/i18n/ar/main.d.ts.map +1 -1
  149. package/lib/i18n/ar/main.js +28 -0
  150. package/lib/i18n/ar/main.js.map +1 -1
  151. package/lib/i18n/cs/main.d.ts +28 -0
  152. package/lib/i18n/cs/main.d.ts.map +1 -1
  153. package/lib/i18n/cs/main.js +28 -0
  154. package/lib/i18n/cs/main.js.map +1 -1
  155. package/lib/i18n/en/main.d.ts +28 -0
  156. package/lib/i18n/en/main.d.ts.map +1 -1
  157. package/lib/i18n/en/main.js +28 -0
  158. package/lib/i18n/en/main.js.map +1 -1
  159. package/lib/i18n/tr/main.d.ts +28 -0
  160. package/lib/i18n/tr/main.d.ts.map +1 -1
  161. package/lib/i18n/tr/main.js +28 -0
  162. package/lib/i18n/tr/main.js.map +1 -1
  163. package/lib/i18n/zh/main.d.ts +28 -0
  164. package/lib/i18n/zh/main.d.ts.map +1 -1
  165. package/lib/i18n/zh/main.js +28 -0
  166. package/lib/i18n/zh/main.js.map +1 -1
  167. package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.d.ts +11 -0
  168. package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.d.ts.map +1 -1
  169. package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js +92 -0
  170. package/lib/spatialIndex/AcTrHierarchicalSpatialIndex.js.map +1 -1
  171. package/lib/ui/AcUiFileOpenPanel.d.ts +156 -0
  172. package/lib/ui/AcUiFileOpenPanel.d.ts.map +1 -0
  173. package/lib/ui/AcUiFileOpenPanel.js +695 -0
  174. package/lib/ui/AcUiFileOpenPanel.js.map +1 -0
  175. package/lib/ui/icons.d.ts +4 -0
  176. package/lib/ui/icons.d.ts.map +1 -1
  177. package/lib/ui/icons.js +4 -0
  178. package/lib/ui/icons.js.map +1 -1
  179. package/lib/ui/index.d.ts +1 -0
  180. package/lib/ui/index.d.ts.map +1 -1
  181. package/lib/ui/index.js +1 -0
  182. package/lib/ui/index.js.map +1 -1
  183. package/lib/util/AcApDrawingExtents.d.ts +29 -0
  184. package/lib/util/AcApDrawingExtents.d.ts.map +1 -0
  185. package/lib/util/AcApDrawingExtents.js +34 -0
  186. package/lib/util/AcApDrawingExtents.js.map +1 -0
  187. package/lib/util/AcApFontUtil.d.ts +18 -0
  188. package/lib/util/AcApFontUtil.d.ts.map +1 -1
  189. package/lib/util/AcApFontUtil.js +126 -0
  190. package/lib/util/AcApFontUtil.js.map +1 -1
  191. package/lib/util/AcApMeasureBadgeFont.d.ts +99 -0
  192. package/lib/util/AcApMeasureBadgeFont.d.ts.map +1 -0
  193. package/lib/util/AcApMeasureBadgeFont.js +207 -0
  194. package/lib/util/AcApMeasureBadgeFont.js.map +1 -0
  195. package/lib/util/AcApMeasurementUnits.d.ts.map +1 -1
  196. package/lib/util/AcApMeasurementUnits.js +41 -2
  197. package/lib/util/AcApMeasurementUnits.js.map +1 -1
  198. package/lib/util/AcApTextStyleFontPreload.d.ts +42 -0
  199. package/lib/util/AcApTextStyleFontPreload.d.ts.map +1 -0
  200. package/lib/util/AcApTextStyleFontPreload.js +149 -0
  201. package/lib/util/AcApTextStyleFontPreload.js.map +1 -0
  202. package/lib/util/index.d.ts +3 -0
  203. package/lib/util/index.d.ts.map +1 -1
  204. package/lib/util/index.js +3 -0
  205. package/lib/util/index.js.map +1 -1
  206. package/lib/view/AcTrExtentCluster.d.ts +10 -0
  207. package/lib/view/AcTrExtentCluster.d.ts.map +1 -1
  208. package/lib/view/AcTrExtentCluster.js +76 -0
  209. package/lib/view/AcTrExtentCluster.js.map +1 -1
  210. package/lib/view/AcTrIntelligentExtents.d.ts +8 -0
  211. package/lib/view/AcTrIntelligentExtents.d.ts.map +1 -1
  212. package/lib/view/AcTrIntelligentExtents.js +247 -10
  213. package/lib/view/AcTrIntelligentExtents.js.map +1 -1
  214. package/lib/view/AcTrLayer.d.ts +4 -0
  215. package/lib/view/AcTrLayer.d.ts.map +1 -1
  216. package/lib/view/AcTrLayer.js +6 -0
  217. package/lib/view/AcTrLayer.js.map +1 -1
  218. package/lib/view/AcTrLayout.d.ts +41 -0
  219. package/lib/view/AcTrLayout.d.ts.map +1 -1
  220. package/lib/view/AcTrLayout.js +132 -0
  221. package/lib/view/AcTrLayout.js.map +1 -1
  222. package/lib/view/AcTrScene.d.ts +11 -0
  223. package/lib/view/AcTrScene.d.ts.map +1 -1
  224. package/lib/view/AcTrScene.js +84 -48
  225. package/lib/view/AcTrScene.js.map +1 -1
  226. package/lib/view/AcTrView2d.d.ts +79 -6
  227. package/lib/view/AcTrView2d.d.ts.map +1 -1
  228. package/lib/view/AcTrView2d.js +411 -113
  229. package/lib/view/AcTrView2d.js.map +1 -1
  230. package/lib/view/AcTrWorkSlice.d.ts +23 -0
  231. package/lib/view/AcTrWorkSlice.d.ts.map +1 -0
  232. package/lib/view/AcTrWorkSlice.js +92 -0
  233. package/lib/view/AcTrWorkSlice.js.map +1 -0
  234. package/package.json +8 -8
  235. package/src/ui/icons.ts +9 -0
@@ -0,0 +1,695 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __values = (this && this.__values) || function(o) {
13
+ var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
14
+ if (m) return m.call(o);
15
+ if (o && typeof o.length === "number") return {
16
+ next: function () {
17
+ if (o && i >= o.length) o = void 0;
18
+ return { value: o && o[i++], done: !o };
19
+ }
20
+ };
21
+ throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
22
+ };
23
+ var __read = (this && this.__read) || function (o, n) {
24
+ var m = typeof Symbol === "function" && o[Symbol.iterator];
25
+ if (!m) return o;
26
+ var i = m.call(o), r, ar = [], e;
27
+ try {
28
+ while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
29
+ }
30
+ catch (error) { e = { error: error }; }
31
+ finally {
32
+ try {
33
+ if (r && !r.done && (m = i["return"])) m.call(i);
34
+ }
35
+ finally { if (e) throw e.error; }
36
+ }
37
+ return ar;
38
+ };
39
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
40
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
41
+ if (ar || !(i in from)) {
42
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
43
+ ar[i] = from[i];
44
+ }
45
+ }
46
+ return to.concat(ar || Array.prototype.slice.call(from));
47
+ };
48
+ import { AcApDocManager } from '../app/AcApDocManager';
49
+ import { acapBuildDataSourceMenu } from '../app/dataSource/acapBuildDataSourceMenu';
50
+ import { ACAP_LOCAL_DATA_SOURCE_ID } from '../app/dataSource/AcApLocalDataSource';
51
+ import { ACAP_URL_DATA_SOURCE_ID } from '../app/dataSource/AcApUrlDataSource';
52
+ import { acedApplyUiTheme, acedSubscribeUiTheme, resolveUiTheme } from '../editor/global/AcEdUiTheme';
53
+ import { AcApI18n } from '../i18n/AcApI18n';
54
+ var SUPPORTED_EXTENSIONS = ['.dxf', '.dwg'];
55
+ var VIEW_LOCAL = 'local';
56
+ var VIEW_URL = 'url';
57
+ var DEFAULT_CARD_WIDTH = '100%';
58
+ var DEFAULT_CARD_HEIGHT = '150px';
59
+ function toCssSize(value, fallback) {
60
+ if (value == null)
61
+ return fallback;
62
+ return typeof value === 'number' ? "".concat(value, "px") : value;
63
+ }
64
+ /**
65
+ * Framework-free landing panel for opening CAD files.
66
+ *
67
+ * Card body swaps by source; bottom chevron opens a source menu.
68
+ * Pass {@link AcUiFileOpenPanelOptions.theme} for an isolated light/dark
69
+ * palette, and {@link AcUiFileOpenPanelOptions.cardSize} for width/height.
70
+ */
71
+ var AcUiFileOpenPanel = /** @class */ (function () {
72
+ function AcUiFileOpenPanel(options) {
73
+ var e_1, _a;
74
+ var _this = this;
75
+ var _b, _c;
76
+ this.activeView = VIEW_LOCAL;
77
+ this.menuOpen = false;
78
+ this.disposed = false;
79
+ this.unsubManager = null;
80
+ this.unsubTheme = null;
81
+ this.onDocPointerDown = null;
82
+ this.options = __assign(__assign({}, options), { cardSize: __assign({}, ((_b = options.cardSize) !== null && _b !== void 0 ? _b : {})) });
83
+ AcUiFileOpenPanel.ensureStyles();
84
+ this.root = document.createElement('div');
85
+ this.root.className = 'ml-ui-file-open';
86
+ this.root.setAttribute('data-ml-ui-file-open', '1');
87
+ this.applyTheme();
88
+ if (options.title || options.subtitle) {
89
+ var header = document.createElement('div');
90
+ header.className = 'ml-ui-file-open-header';
91
+ if (options.title) {
92
+ var title = document.createElement('h2');
93
+ title.className = 'ml-ui-file-open-title';
94
+ title.textContent = options.title;
95
+ header.appendChild(title);
96
+ }
97
+ if (options.subtitle) {
98
+ var subtitle = document.createElement('p');
99
+ subtitle.className = 'ml-ui-file-open-subtitle';
100
+ subtitle.textContent = options.subtitle;
101
+ header.appendChild(subtitle);
102
+ }
103
+ this.root.appendChild(header);
104
+ }
105
+ if (options.showNewDrawing) {
106
+ var newBtn = document.createElement('button');
107
+ newBtn.type = 'button';
108
+ newBtn.className = 'ml-ui-file-open-primary';
109
+ newBtn.textContent = AcApI18n.t('main.dataSource.newDrawing');
110
+ newBtn.addEventListener('click', function () { return _this.emit({ kind: 'new-drawing' }); });
111
+ this.root.appendChild(newBtn);
112
+ this.root.appendChild(this.createDivider());
113
+ }
114
+ this.card = document.createElement('div');
115
+ this.card.className = 'ml-ui-file-open-card';
116
+ this.applyCardSize();
117
+ this.root.appendChild(this.card);
118
+ this.fileInput = document.createElement('input');
119
+ this.fileInput.type = 'file';
120
+ this.fileInput.accept = (_c = options.accept) !== null && _c !== void 0 ? _c : SUPPORTED_EXTENSIONS.join(',');
121
+ this.fileInput.className = 'ml-ui-file-open-input-hidden';
122
+ this.fileInput.addEventListener('change', function () {
123
+ var _a;
124
+ var file = (_a = _this.fileInput.files) === null || _a === void 0 ? void 0 : _a[0];
125
+ _this.fileInput.value = '';
126
+ if (file && _this.isSupportedFileName(file.name)) {
127
+ _this.emitLocal(file);
128
+ }
129
+ });
130
+ this.card.appendChild(this.fileInput);
131
+ this.contentEl = document.createElement('div');
132
+ this.contentEl.className = 'ml-ui-file-open-body';
133
+ this.card.appendChild(this.contentEl);
134
+ this.dropzone = document.createElement('div');
135
+ this.dropzone.className = 'ml-ui-file-open-dropzone';
136
+ this.dropzone.tabIndex = 0;
137
+ this.dropzone.setAttribute('role', 'button');
138
+ this.dropzone.setAttribute('aria-label', AcApI18n.t('main.dataSource.dropOrBrowse'));
139
+ var dropTitle = document.createElement('p');
140
+ dropTitle.className = 'ml-ui-file-open-drop-title';
141
+ dropTitle.append(document.createTextNode("".concat(AcApI18n.t('main.dataSource.dropFile'), " ")));
142
+ var dropLink = document.createElement('span');
143
+ dropLink.className = 'ml-ui-file-open-drop-link';
144
+ dropLink.textContent = AcApI18n.t('main.dataSource.browse');
145
+ dropTitle.appendChild(dropLink);
146
+ var tags = document.createElement('div');
147
+ tags.className = 'ml-ui-file-open-tags';
148
+ try {
149
+ for (var _d = __values(['DWG', 'DXF']), _e = _d.next(); !_e.done; _e = _d.next()) {
150
+ var tag = _e.value;
151
+ var span = document.createElement('span');
152
+ span.className = 'ml-ui-file-open-tag';
153
+ span.textContent = tag;
154
+ tags.appendChild(span);
155
+ }
156
+ }
157
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
158
+ finally {
159
+ try {
160
+ if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
161
+ }
162
+ finally { if (e_1) throw e_1.error; }
163
+ }
164
+ this.dropzone.appendChild(dropTitle);
165
+ this.dropzone.appendChild(tags);
166
+ this.dropzone.addEventListener('click', function () { return _this.fileInput.click(); });
167
+ this.dropzone.addEventListener('keydown', function (e) {
168
+ if (e.key === 'Enter' || e.key === ' ') {
169
+ e.preventDefault();
170
+ _this.fileInput.click();
171
+ }
172
+ });
173
+ this.dropzone.addEventListener('dragenter', function (e) { return _this.onDrag(e, true); });
174
+ this.dropzone.addEventListener('dragover', function (e) { return _this.onDrag(e, true); });
175
+ this.dropzone.addEventListener('dragleave', function (e) { return _this.onDrag(e, false); });
176
+ this.dropzone.addEventListener('drop', function (e) { return _this.onDrop(e); });
177
+ this.urlRow = document.createElement('div');
178
+ this.urlRow.className = 'ml-ui-file-open-url-row';
179
+ this.urlInput = document.createElement('input');
180
+ this.urlInput.type = 'url';
181
+ this.urlInput.className = 'ml-ui-file-open-url-input';
182
+ this.urlInput.placeholder = AcApI18n.t('main.dataSource.urlPlaceholder');
183
+ this.urlInput.autocomplete = 'off';
184
+ this.urlInput.spellcheck = false;
185
+ this.urlInput.addEventListener('keydown', function (e) {
186
+ if (e.key === 'Enter') {
187
+ e.preventDefault();
188
+ _this.submitUrl();
189
+ }
190
+ });
191
+ var urlBtn = document.createElement('button');
192
+ urlBtn.type = 'button';
193
+ urlBtn.className = 'ml-ui-file-open-secondary';
194
+ urlBtn.textContent = AcApI18n.t('main.dataSource.open');
195
+ urlBtn.addEventListener('click', function () { return _this.submitUrl(); });
196
+ this.urlRow.appendChild(this.urlInput);
197
+ this.urlRow.appendChild(urlBtn);
198
+ this.sourceActionsEl = document.createElement('div');
199
+ this.sourceActionsEl.className = 'ml-ui-file-open-sources';
200
+ var footer = document.createElement('div');
201
+ footer.className = 'ml-ui-file-open-footer';
202
+ this.footerBtn = document.createElement('button');
203
+ this.footerBtn.type = 'button';
204
+ this.footerBtn.className = 'ml-ui-file-open-footer-btn';
205
+ this.footerBtn.setAttribute('aria-label', AcApI18n.t('main.dataSource.source'));
206
+ this.footerBtn.setAttribute('aria-haspopup', 'listbox');
207
+ this.footerBtn.setAttribute('aria-expanded', 'false');
208
+ this.footerLabel = document.createElement('span');
209
+ this.footerLabel.className = 'ml-ui-file-open-footer-label';
210
+ this.footerChevron = document.createElement('span');
211
+ this.footerChevron.className = 'ml-ui-file-open-footer-chevron';
212
+ this.footerChevron.setAttribute('aria-hidden', 'true');
213
+ this.footerChevron.textContent = '▾';
214
+ this.footerBtn.appendChild(this.footerLabel);
215
+ this.footerBtn.appendChild(this.footerChevron);
216
+ this.footerBtn.addEventListener('click', function (e) {
217
+ e.stopPropagation();
218
+ _this.toggleMenu();
219
+ });
220
+ footer.appendChild(this.footerBtn);
221
+ this.card.appendChild(footer);
222
+ this.menuEl = document.createElement('div');
223
+ this.menuEl.className = 'ml-ui-file-open-menu';
224
+ this.menuEl.hidden = true;
225
+ this.menuEl.setAttribute('role', 'listbox');
226
+ this.card.appendChild(this.menuEl);
227
+ this.onDocPointerDown = function (event) {
228
+ if (!_this.menuOpen)
229
+ return;
230
+ var target = event.target;
231
+ if (!(target instanceof Node))
232
+ return;
233
+ if (_this.card.contains(target))
234
+ return;
235
+ _this.closeMenu();
236
+ };
237
+ document.addEventListener('pointerdown', this.onDocPointerDown);
238
+ this.unsubTheme = acedSubscribeUiTheme(function () {
239
+ if (_this.options.theme)
240
+ return;
241
+ _this.applyTheme();
242
+ });
243
+ options.host.appendChild(this.root);
244
+ this.bindManagerEvents();
245
+ this.refreshSourceButtons();
246
+ }
247
+ Object.defineProperty(AcUiFileOpenPanel.prototype, "element", {
248
+ /** Root element of the panel. */
249
+ get: function () {
250
+ return this.root;
251
+ },
252
+ enumerable: false,
253
+ configurable: true
254
+ });
255
+ /** Rebuilds the source menu and active body content. */
256
+ AcUiFileOpenPanel.prototype.refreshSourceButtons = function () {
257
+ if (this.disposed)
258
+ return;
259
+ this.bindManagerEvents();
260
+ this.applyTheme();
261
+ this.applyCardSize();
262
+ this.syncSourceChrome();
263
+ this.renderActiveView();
264
+ };
265
+ /**
266
+ * Sets an isolated card theme, or `undefined` to follow the host app theme.
267
+ *
268
+ * @param theme - `light`, `dark`, or `undefined` to track {@link resolveUiTheme}
269
+ */
270
+ AcUiFileOpenPanel.prototype.setTheme = function (theme) {
271
+ if (this.disposed)
272
+ return;
273
+ this.options.theme = theme;
274
+ this.applyTheme();
275
+ };
276
+ /**
277
+ * Updates the source card width and/or height.
278
+ *
279
+ * @param size - Partial size; omitted sides keep their current option value
280
+ */
281
+ AcUiFileOpenPanel.prototype.setCardSize = function (size) {
282
+ if (this.disposed)
283
+ return;
284
+ this.options.cardSize = __assign(__assign({}, this.options.cardSize), size);
285
+ this.applyCardSize();
286
+ };
287
+ /** Removes the panel from the host and unsubscribes. */
288
+ AcUiFileOpenPanel.prototype.dispose = function () {
289
+ var _a, _b;
290
+ if (this.disposed)
291
+ return;
292
+ this.disposed = true;
293
+ (_a = this.unsubManager) === null || _a === void 0 ? void 0 : _a.call(this);
294
+ this.unsubManager = null;
295
+ (_b = this.unsubTheme) === null || _b === void 0 ? void 0 : _b.call(this);
296
+ this.unsubTheme = null;
297
+ if (this.onDocPointerDown) {
298
+ document.removeEventListener('pointerdown', this.onDocPointerDown);
299
+ this.onDocPointerDown = null;
300
+ }
301
+ this.root.remove();
302
+ };
303
+ AcUiFileOpenPanel.prototype.applyTheme = function () {
304
+ var _a;
305
+ var isolated = this.options.theme != null;
306
+ var theme = (_a = this.options.theme) !== null && _a !== void 0 ? _a : resolveUiTheme(this.options.host);
307
+ acedApplyUiTheme(theme, this.root, { isolated: isolated });
308
+ };
309
+ AcUiFileOpenPanel.prototype.applyCardSize = function () {
310
+ var size = this.options.cardSize;
311
+ this.card.style.width = toCssSize(size === null || size === void 0 ? void 0 : size.width, DEFAULT_CARD_WIDTH);
312
+ this.card.style.height = toCssSize(size === null || size === void 0 ? void 0 : size.height, DEFAULT_CARD_HEIGHT);
313
+ };
314
+ AcUiFileOpenPanel.prototype.syncSourceChrome = function () {
315
+ var e_2, _a;
316
+ var _this = this;
317
+ var _b, _c;
318
+ var options = this.resolveSourceOptions();
319
+ var values = new Set(options.map(function (o) { return o.value; }));
320
+ if (!values.has(this.activeView)) {
321
+ this.activeView = VIEW_LOCAL;
322
+ this.closeMenu();
323
+ }
324
+ var current = (_b = options.find(function (o) { return o.value === _this.activeView; })) !== null && _b !== void 0 ? _b : options[0];
325
+ this.footerLabel.textContent = (_c = current === null || current === void 0 ? void 0 : current.label) !== null && _c !== void 0 ? _c : '';
326
+ var multi = options.length > 1;
327
+ this.footerBtn.disabled = !multi;
328
+ this.footerBtn.classList.toggle('is-single', !multi);
329
+ this.footerChevron.hidden = !multi;
330
+ if (!multi)
331
+ this.closeMenu();
332
+ this.menuEl.replaceChildren();
333
+ var _loop_1 = function (opt) {
334
+ var item = document.createElement('button');
335
+ item.type = 'button';
336
+ item.className = 'ml-ui-file-open-menu-item';
337
+ item.setAttribute('role', 'option');
338
+ item.setAttribute('aria-selected', opt.value === this_1.activeView ? 'true' : 'false');
339
+ if (opt.value === this_1.activeView) {
340
+ item.classList.add('is-active');
341
+ }
342
+ item.textContent = opt.label;
343
+ item.addEventListener('click', function (e) {
344
+ e.stopPropagation();
345
+ _this.selectSource(opt.value);
346
+ });
347
+ this_1.menuEl.appendChild(item);
348
+ };
349
+ var this_1 = this;
350
+ try {
351
+ for (var options_1 = __values(options), options_1_1 = options_1.next(); !options_1_1.done; options_1_1 = options_1.next()) {
352
+ var opt = options_1_1.value;
353
+ _loop_1(opt);
354
+ }
355
+ }
356
+ catch (e_2_1) { e_2 = { error: e_2_1 }; }
357
+ finally {
358
+ try {
359
+ if (options_1_1 && !options_1_1.done && (_a = options_1.return)) _a.call(options_1);
360
+ }
361
+ finally { if (e_2) throw e_2.error; }
362
+ }
363
+ };
364
+ AcUiFileOpenPanel.prototype.selectSource = function (value) {
365
+ this.activeView = value;
366
+ this.closeMenu();
367
+ this.syncSourceChrome();
368
+ this.renderActiveView();
369
+ this.maybeAutoSignIn(value);
370
+ };
371
+ /**
372
+ * When switching to an auth-required cloud source, start sign-in immediately
373
+ * (separate from pick, so the File Picker popup is not blocked).
374
+ */
375
+ AcUiFileOpenPanel.prototype.maybeAutoSignIn = function (sourceId) {
376
+ var _this = this;
377
+ if (sourceId === VIEW_LOCAL || sourceId === VIEW_URL)
378
+ return;
379
+ var source = this.resolveSources().find(function (s) { return s.id === sourceId; });
380
+ if (source) {
381
+ if (source.requiresAuth && source.getAuthState() === 'signed-out') {
382
+ void source
383
+ .signIn()
384
+ .catch(function () { return undefined; })
385
+ .finally(function () { return _this.refreshSourceButtons(); });
386
+ }
387
+ return;
388
+ }
389
+ var signInItem = this.resolveExtraMenuItems().find(function (i) { return i.sourceId === sourceId && i.action === 'sign-in'; });
390
+ if (signInItem) {
391
+ this.emit({ kind: 'data-source', item: signInItem });
392
+ }
393
+ };
394
+ AcUiFileOpenPanel.prototype.toggleMenu = function () {
395
+ if (this.footerBtn.disabled)
396
+ return;
397
+ if (this.menuOpen)
398
+ this.closeMenu();
399
+ else
400
+ this.openMenu();
401
+ };
402
+ AcUiFileOpenPanel.prototype.openMenu = function () {
403
+ this.menuOpen = true;
404
+ this.menuEl.hidden = false;
405
+ this.footerBtn.setAttribute('aria-expanded', 'true');
406
+ this.footerBtn.classList.add('is-open');
407
+ this.footerChevron.textContent = '▴';
408
+ };
409
+ AcUiFileOpenPanel.prototype.closeMenu = function () {
410
+ this.menuOpen = false;
411
+ this.menuEl.hidden = true;
412
+ this.footerBtn.setAttribute('aria-expanded', 'false');
413
+ this.footerBtn.classList.remove('is-open');
414
+ this.footerChevron.textContent = '▾';
415
+ };
416
+ AcUiFileOpenPanel.prototype.resolveSourceOptions = function () {
417
+ var e_3, _a;
418
+ var options = [
419
+ {
420
+ value: VIEW_LOCAL,
421
+ label: AcApI18n.t('main.dataSource.local')
422
+ }
423
+ ];
424
+ if (this.options.showUrl !== false) {
425
+ options.push({
426
+ value: VIEW_URL,
427
+ label: AcApI18n.t('main.dataSource.url')
428
+ });
429
+ }
430
+ var seen = new Set();
431
+ try {
432
+ for (var _b = __values(this.resolveMenuItems()), _c = _b.next(); !_c.done; _c = _b.next()) {
433
+ var item = _c.value;
434
+ if (seen.has(item.sourceId))
435
+ continue;
436
+ seen.add(item.sourceId);
437
+ options.push({
438
+ value: item.sourceId,
439
+ label: this.resolveSourceLabel(item.sourceId)
440
+ });
441
+ }
442
+ }
443
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
444
+ finally {
445
+ try {
446
+ if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
447
+ }
448
+ finally { if (e_3) throw e_3.error; }
449
+ }
450
+ return options;
451
+ };
452
+ AcUiFileOpenPanel.prototype.resolveSourceLabel = function (sourceId) {
453
+ var _a;
454
+ var source = this.resolveSources().find(function (s) { return s.id === sourceId; });
455
+ if (source) {
456
+ return AcApI18n.t(source.labelKey);
457
+ }
458
+ var extra = this.resolveExtraMenuItems().find(function (i) { return i.sourceId === sourceId; });
459
+ if ((_a = extra === null || extra === void 0 ? void 0 : extra.labelParams) === null || _a === void 0 ? void 0 : _a.name) {
460
+ return extra.labelParams.name;
461
+ }
462
+ return sourceId;
463
+ };
464
+ AcUiFileOpenPanel.prototype.renderActiveView = function () {
465
+ var _this = this;
466
+ this.contentEl.replaceChildren();
467
+ if (this.activeView === VIEW_LOCAL) {
468
+ this.contentEl.appendChild(this.dropzone);
469
+ return;
470
+ }
471
+ if (this.activeView === VIEW_URL) {
472
+ this.contentEl.appendChild(this.urlRow);
473
+ requestAnimationFrame(function () { return _this.urlInput.focus(); });
474
+ return;
475
+ }
476
+ this.renderSourceActions(this.activeView);
477
+ this.contentEl.appendChild(this.sourceActionsEl);
478
+ };
479
+ AcUiFileOpenPanel.prototype.canPickSource = function (sourceId) {
480
+ var source = this.resolveSources().find(function (s) { return s.id === sourceId; });
481
+ if (source) {
482
+ if (!source.requiresAuth)
483
+ return true;
484
+ return source.getAuthState() === 'signed-in';
485
+ }
486
+ // Landing page before registration: host exposes a pick item after sign-in.
487
+ return this.resolveExtraMenuItems().some(function (i) { return i.sourceId === sourceId && i.action === 'pick'; });
488
+ };
489
+ AcUiFileOpenPanel.prototype.buildPickMenuItem = function (sourceId) {
490
+ var name = this.resolveSourceLabel(sourceId);
491
+ var labelTemplate = AcApI18n.t('main.dataSource.openFrom');
492
+ return {
493
+ id: "".concat(sourceId, ":pick"),
494
+ sourceId: sourceId,
495
+ action: 'pick',
496
+ labelKey: 'main.dataSource.openFrom',
497
+ labelParams: { name: name },
498
+ label: labelTemplate.includes('{name}')
499
+ ? labelTemplate.split('{name}').join(name)
500
+ : AcApI18n.t('main.dataSource.selectFile')
501
+ };
502
+ };
503
+ AcUiFileOpenPanel.prototype.resolveAccountProfile = function (sourceId) {
504
+ var _a, _b, _c, _d;
505
+ var fromHost = (_b = (_a = this.options).getAccountProfile) === null || _b === void 0 ? void 0 : _b.call(_a, sourceId);
506
+ if (fromHost === null || fromHost === void 0 ? void 0 : fromHost.displayName)
507
+ return fromHost;
508
+ var source = this.resolveSources().find(function (s) { return s.id === sourceId; });
509
+ if (!source || source.getAuthState() !== 'signed-in')
510
+ return undefined;
511
+ var profile = (_c = source.getAccountProfile) === null || _c === void 0 ? void 0 : _c.call(source);
512
+ if (profile === null || profile === void 0 ? void 0 : profile.displayName)
513
+ return profile;
514
+ var label = (_d = source.getAccountLabel) === null || _d === void 0 ? void 0 : _d.call(source);
515
+ if (label)
516
+ return { displayName: label };
517
+ return undefined;
518
+ };
519
+ AcUiFileOpenPanel.prototype.initialsFromName = function (name) {
520
+ var _a, _b;
521
+ var parts = name.trim().split(/\s+/).filter(Boolean);
522
+ if (parts.length === 0)
523
+ return '?';
524
+ if (parts.length === 1)
525
+ return parts[0].slice(0, 2).toUpperCase();
526
+ return "".concat((_a = parts[0][0]) !== null && _a !== void 0 ? _a : '').concat((_b = parts[1][0]) !== null && _b !== void 0 ? _b : '').toUpperCase();
527
+ };
528
+ AcUiFileOpenPanel.prototype.renderSourceActions = function (sourceId) {
529
+ var _this = this;
530
+ this.sourceActionsEl.replaceChildren();
531
+ var profile = this.resolveAccountProfile(sourceId);
532
+ if (profile) {
533
+ var accountRow = document.createElement('div');
534
+ accountRow.className = 'ml-ui-file-open-account';
535
+ var avatar = document.createElement('div');
536
+ avatar.className = 'ml-ui-file-open-avatar';
537
+ if (profile.avatarUrl) {
538
+ var img = document.createElement('img');
539
+ img.className = 'ml-ui-file-open-avatar-img';
540
+ img.src = profile.avatarUrl;
541
+ img.alt = '';
542
+ img.referrerPolicy = 'no-referrer';
543
+ avatar.appendChild(img);
544
+ }
545
+ else {
546
+ var initials = document.createElement('span');
547
+ initials.className = 'ml-ui-file-open-avatar-initials';
548
+ initials.textContent = this.initialsFromName(profile.displayName);
549
+ avatar.appendChild(initials);
550
+ }
551
+ var textCol = document.createElement('div');
552
+ textCol.className = 'ml-ui-file-open-account-text';
553
+ var nameEl = document.createElement('div');
554
+ nameEl.className = 'ml-ui-file-open-account-name';
555
+ nameEl.textContent = profile.displayName;
556
+ textCol.appendChild(nameEl);
557
+ if (profile.email && profile.email !== profile.displayName) {
558
+ var emailEl = document.createElement('div');
559
+ emailEl.className = 'ml-ui-file-open-account-email';
560
+ emailEl.textContent = profile.email;
561
+ textCol.appendChild(emailEl);
562
+ }
563
+ accountRow.appendChild(avatar);
564
+ accountRow.appendChild(textCol);
565
+ this.sourceActionsEl.appendChild(accountRow);
566
+ }
567
+ var pickBtn = document.createElement('button');
568
+ pickBtn.type = 'button';
569
+ pickBtn.className =
570
+ 'ml-ui-file-open-source-btn ml-ui-file-open-source-btn--primary';
571
+ pickBtn.textContent = AcApI18n.t('main.dataSource.selectFile');
572
+ var canPick = this.canPickSource(sourceId);
573
+ pickBtn.disabled = !canPick;
574
+ if (!canPick) {
575
+ pickBtn.title = AcApI18n.t('main.dataSource.signInRequired');
576
+ }
577
+ pickBtn.addEventListener('click', function () {
578
+ if (!_this.canPickSource(sourceId))
579
+ return;
580
+ _this.emit({
581
+ kind: 'data-source',
582
+ item: _this.buildPickMenuItem(sourceId)
583
+ });
584
+ });
585
+ this.sourceActionsEl.appendChild(pickBtn);
586
+ };
587
+ AcUiFileOpenPanel.prototype.resolveMenuItems = function () {
588
+ var sources = this.resolveSources().filter(function (s) {
589
+ return s.id !== ACAP_LOCAL_DATA_SOURCE_ID && s.id !== ACAP_URL_DATA_SOURCE_ID;
590
+ });
591
+ var fromManager = acapBuildDataSourceMenu(sources);
592
+ var extra = this.resolveExtraMenuItems();
593
+ var known = new Set(fromManager.map(function (i) { return i.sourceId; }));
594
+ var pending = extra.filter(function (i) { return !known.has(i.sourceId); });
595
+ return __spreadArray(__spreadArray([], __read(fromManager), false), __read(pending), false);
596
+ };
597
+ AcUiFileOpenPanel.prototype.resolveSources = function () {
598
+ var _a, _b;
599
+ if (this.options.getSources) {
600
+ return this.options.getSources();
601
+ }
602
+ return (_b = (_a = AcApDocManager.tryGetInstance()) === null || _a === void 0 ? void 0 : _a.dataSourceManager.list()) !== null && _b !== void 0 ? _b : [];
603
+ };
604
+ AcUiFileOpenPanel.prototype.resolveExtraMenuItems = function () {
605
+ var extra = this.options.extraMenuItems;
606
+ if (!extra)
607
+ return [];
608
+ return typeof extra === 'function' ? extra() : extra;
609
+ };
610
+ AcUiFileOpenPanel.prototype.bindManagerEvents = function () {
611
+ var _this = this;
612
+ var _a;
613
+ if (this.unsubManager)
614
+ return;
615
+ var dsm = (_a = AcApDocManager.tryGetInstance()) === null || _a === void 0 ? void 0 : _a.dataSourceManager;
616
+ if (!dsm)
617
+ return;
618
+ var refresh = function () { return _this.refreshSourceButtons(); };
619
+ dsm.on('changed', refresh);
620
+ dsm.on('auth-changed', refresh);
621
+ this.unsubManager = function () {
622
+ dsm.off('changed', refresh);
623
+ dsm.off('auth-changed', refresh);
624
+ };
625
+ };
626
+ AcUiFileOpenPanel.prototype.submitUrl = function () {
627
+ var url = this.urlInput.value.trim();
628
+ if (!url) {
629
+ this.urlInput.focus();
630
+ return;
631
+ }
632
+ this.emit({ kind: 'url', url: url });
633
+ };
634
+ AcUiFileOpenPanel.prototype.onDrag = function (event, active) {
635
+ event.preventDefault();
636
+ event.stopPropagation();
637
+ this.dropzone.classList.toggle('is-dragover', active);
638
+ };
639
+ AcUiFileOpenPanel.prototype.onDrop = function (event) {
640
+ var _a, _b;
641
+ this.onDrag(event, false);
642
+ var file = (_b = (_a = event.dataTransfer) === null || _a === void 0 ? void 0 : _a.files) === null || _b === void 0 ? void 0 : _b[0];
643
+ if (file && this.isSupportedFileName(file.name)) {
644
+ this.emitLocal(file);
645
+ }
646
+ };
647
+ AcUiFileOpenPanel.prototype.isSupportedFileName = function (name) {
648
+ var lower = name.toLowerCase();
649
+ return SUPPORTED_EXTENSIONS.some(function (ext) { return lower.endsWith(ext); });
650
+ };
651
+ AcUiFileOpenPanel.prototype.emitLocal = function (file) {
652
+ this.emit({ kind: 'local', file: file });
653
+ };
654
+ AcUiFileOpenPanel.prototype.emit = function (result) {
655
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
656
+ (_b = (_a = this.options).onResult) === null || _b === void 0 ? void 0 : _b.call(_a, result);
657
+ switch (result.kind) {
658
+ case 'local':
659
+ (_d = (_c = this.options).onLocalFile) === null || _d === void 0 ? void 0 : _d.call(_c, result.file);
660
+ break;
661
+ case 'url':
662
+ (_f = (_e = this.options).onUrl) === null || _f === void 0 ? void 0 : _f.call(_e, result.url);
663
+ break;
664
+ case 'data-source':
665
+ (_h = (_g = this.options).onDataSourceAction) === null || _h === void 0 ? void 0 : _h.call(_g, result.item);
666
+ break;
667
+ case 'new-drawing':
668
+ (_k = (_j = this.options).onNewDrawing) === null || _k === void 0 ? void 0 : _k.call(_j);
669
+ break;
670
+ }
671
+ };
672
+ AcUiFileOpenPanel.prototype.createDivider = function () {
673
+ var el = document.createElement('p');
674
+ el.className = 'ml-ui-file-open-divider';
675
+ el.setAttribute('aria-hidden', 'true');
676
+ var span = document.createElement('span');
677
+ span.textContent = AcApI18n.t('main.dataSource.or');
678
+ el.appendChild(span);
679
+ return el;
680
+ };
681
+ AcUiFileOpenPanel.ensureStyles = function () {
682
+ if (typeof document === 'undefined')
683
+ return;
684
+ if (document.getElementById(AcUiFileOpenPanel.styleId))
685
+ return;
686
+ var style = document.createElement('style');
687
+ style.id = AcUiFileOpenPanel.styleId;
688
+ style.textContent = "\n.ml-ui-file-open {\n display: flex;\n flex-direction: column;\n gap: 0;\n width: 100%;\n box-sizing: border-box;\n font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, Helvetica, Arial, sans-serif;\n color: var(--ml-ui-text, #303133);\n}\n.ml-ui-file-open-header { margin-bottom: 12px; }\n.ml-ui-file-open-title {\n margin: 0 0 4px;\n font-size: 18px;\n font-weight: 700;\n line-height: 1.3;\n}\n.ml-ui-file-open-subtitle {\n margin: 0;\n font-size: 13px;\n line-height: 1.4;\n color: var(--ml-ui-text-muted, #606266);\n}\n.ml-ui-file-open-primary {\n display: block;\n width: 100%;\n padding: 10px 14px;\n border: none;\n border-radius: 10px;\n background: var(--ml-ui-accent, #409eff);\n color: #fff;\n font-size: 13px;\n font-weight: 700;\n cursor: pointer;\n}\n.ml-ui-file-open-primary:hover { filter: brightness(1.05); }\n.ml-ui-file-open-secondary {\n flex: 0 0 auto;\n padding: 8px 14px;\n border: none;\n border-radius: 8px;\n background: var(--ml-ui-accent, #409eff);\n color: #fff;\n font-size: 13px;\n font-weight: 600;\n cursor: pointer;\n white-space: nowrap;\n}\n.ml-ui-file-open-divider {\n display: flex;\n align-items: center;\n gap: 10px;\n margin: 12px 0;\n font-size: 11px;\n font-weight: 600;\n color: var(--ml-ui-text-muted, #94a3b8);\n text-transform: uppercase;\n letter-spacing: 0.06em;\n}\n.ml-ui-file-open-divider::before,\n.ml-ui-file-open-divider::after {\n content: '';\n flex: 1;\n height: 1px;\n background: var(--ml-ui-border, #e2e8f0);\n}\n.ml-ui-file-open-card {\n position: relative;\n display: flex;\n flex-direction: column;\n width: 100%;\n height: 150px;\n max-width: 100%;\n box-sizing: border-box;\n border: 1px solid var(--ml-ui-border, #dcdfe6);\n border-radius: 12px;\n background: var(--ml-ui-bg, #fff);\n box-shadow: var(--ml-ui-shadow, 0 2px 6px rgba(0, 0, 0, 0.12));\n overflow: hidden;\n}\n.ml-ui-file-open-body {\n flex: 1 1 auto;\n min-height: 0;\n display: flex;\n flex-direction: column;\n}\n.ml-ui-file-open-input-hidden { display: none; }\n.ml-ui-file-open-dropzone {\n flex: 1;\n display: flex;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n gap: 10px;\n padding: 16px;\n box-sizing: border-box;\n border: 1.5px dashed transparent;\n border-radius: 0;\n background: transparent;\n cursor: pointer;\n outline: none;\n transition: border-color 0.15s ease, background 0.15s ease;\n}\n.ml-ui-file-open-dropzone:hover,\n.ml-ui-file-open-dropzone:focus-visible,\n.ml-ui-file-open-dropzone.is-dragover {\n border-color: var(--ml-ui-accent, #409eff);\n background: color-mix(in srgb, var(--ml-ui-accent, #409eff) 8%, transparent);\n}\n.ml-ui-file-open-drop-title {\n margin: 0;\n font-size: 14px;\n text-align: center;\n color: var(--ml-ui-text-muted, #606266);\n}\n.ml-ui-file-open-drop-link {\n color: var(--ml-ui-accent, #409eff);\n font-weight: 600;\n}\n.ml-ui-file-open-tags { display: flex; gap: 6px; }\n.ml-ui-file-open-tag {\n padding: 2px 8px;\n border-radius: 999px;\n border: 1px solid var(--ml-ui-border, #dcdfe6);\n font-size: 11px;\n font-weight: 600;\n color: var(--ml-ui-text-muted, #606266);\n}\n.ml-ui-file-open-url-row {\n flex: 1;\n display: flex;\n gap: 8px;\n align-items: center;\n padding: 16px;\n box-sizing: border-box;\n}\n.ml-ui-file-open-url-input {\n flex: 1;\n min-width: 0;\n padding: 8px 10px;\n border: 1px solid var(--ml-ui-border, #c0c4cc);\n border-radius: 8px;\n background: var(--ml-ui-bg, #fff);\n color: inherit;\n font-size: 13px;\n box-sizing: border-box;\n}\n.ml-ui-file-open-url-input:focus {\n outline: 2px solid var(--ml-ui-accent, #409eff);\n outline-offset: 1px;\n}\n.ml-ui-file-open-sources {\n flex: 1;\n display: flex;\n flex-direction: column;\n gap: 8px;\n justify-content: center;\n padding: 16px;\n box-sizing: border-box;\n}\n.ml-ui-file-open-empty {\n margin: 0;\n text-align: center;\n font-size: 13px;\n color: var(--ml-ui-text-muted, #606266);\n}\n.ml-ui-file-open-account {\n display: flex;\n align-items: center;\n gap: 10px;\n width: 100%;\n margin: 0 0 4px;\n min-width: 0;\n}\n.ml-ui-file-open-avatar {\n flex: 0 0 auto;\n width: 36px;\n height: 36px;\n border-radius: 999px;\n overflow: hidden;\n display: flex;\n align-items: center;\n justify-content: center;\n background: color-mix(in srgb, var(--ml-ui-accent, #409eff) 22%, transparent);\n border: 1px solid var(--ml-ui-border, #dcdfe6);\n}\n.ml-ui-file-open-avatar-img {\n width: 100%;\n height: 100%;\n object-fit: cover;\n display: block;\n}\n.ml-ui-file-open-avatar-initials {\n font-size: 12px;\n font-weight: 700;\n color: var(--ml-ui-accent, #409eff);\n line-height: 1;\n}\n.ml-ui-file-open-account-text {\n flex: 1;\n min-width: 0;\n}\n.ml-ui-file-open-account-name {\n font-size: 13px;\n font-weight: 600;\n color: var(--ml-ui-text, #303133);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.ml-ui-file-open-account-email {\n margin-top: 2px;\n font-size: 11px;\n color: var(--ml-ui-text-muted, #606266);\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.ml-ui-file-open-source-btn {\n width: 100%;\n padding: 10px 14px;\n border: 1px solid var(--ml-ui-border, #e2e8f0);\n border-radius: 8px;\n background: var(--ml-ui-bg, #fff);\n color: var(--ml-ui-text, #334155);\n font-size: 13px;\n cursor: pointer;\n text-align: center;\n}\n.ml-ui-file-open-source-btn:disabled {\n opacity: 0.55;\n cursor: not-allowed;\n}\n.ml-ui-file-open-source-btn--primary {\n border: none;\n background: var(--ml-ui-accent, #409eff);\n color: #fff;\n font-weight: 600;\n}\n.ml-ui-file-open-source-btn--primary:hover:not(:disabled) { filter: brightness(1.05); }\n.ml-ui-file-open-source-btn--muted:hover {\n border-color: var(--ml-ui-accent, #409eff);\n color: var(--ml-ui-accent, #409eff);\n}\n.ml-ui-file-open-footer {\n flex: 0 0 auto;\n border-top: 1px solid var(--ml-ui-border, #dcdfe6);\n background: color-mix(in srgb, var(--ml-ui-bg, #fff) 92%, var(--ml-ui-text, #303133) 8%);\n}\n.ml-ui-file-open-footer-btn {\n display: flex;\n align-items: center;\n justify-content: space-between;\n gap: 8px;\n width: 100%;\n padding: 10px 14px;\n border: none;\n background: transparent;\n color: var(--ml-ui-text, #303133);\n font-size: 13px;\n font-weight: 600;\n cursor: pointer;\n text-align: left;\n box-sizing: border-box;\n}\n.ml-ui-file-open-footer-btn:hover:not(:disabled),\n.ml-ui-file-open-footer-btn.is-open {\n background: color-mix(in srgb, var(--ml-ui-accent, #409eff) 10%, transparent);\n}\n.ml-ui-file-open-footer-btn:disabled,\n.ml-ui-file-open-footer-btn.is-single {\n cursor: default;\n}\n.ml-ui-file-open-footer-label {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.ml-ui-file-open-footer-chevron {\n flex: 0 0 auto;\n color: var(--ml-ui-text-muted, #606266);\n font-size: 12px;\n line-height: 1;\n}\n.ml-ui-file-open-menu {\n position: absolute;\n left: 8px;\n right: 8px;\n bottom: 44px;\n z-index: 5;\n display: flex;\n flex-direction: column;\n padding: 4px;\n border: 1px solid var(--ml-ui-border, #dcdfe6);\n border-radius: 10px;\n background: var(--ml-ui-bg, #fff);\n box-shadow: var(--ml-ui-shadow, 0 6px 18px rgba(0, 0, 0, 0.18));\n max-height: 148px;\n overflow: auto;\n}\n.ml-ui-file-open-menu[hidden] { display: none; }\n.ml-ui-file-open-menu-item {\n display: block;\n width: 100%;\n padding: 9px 12px;\n border: none;\n border-radius: 7px;\n background: transparent;\n color: var(--ml-ui-text, #303133);\n font-size: 13px;\n text-align: left;\n cursor: pointer;\n}\n.ml-ui-file-open-menu-item:hover {\n background: color-mix(in srgb, var(--ml-ui-accent, #409eff) 12%, transparent);\n}\n.ml-ui-file-open-menu-item.is-active {\n color: var(--ml-ui-accent, #409eff);\n font-weight: 600;\n}\n";
689
+ document.head.appendChild(style);
690
+ };
691
+ AcUiFileOpenPanel.styleId = 'ml-ui-file-open-panel-styles-v3';
692
+ return AcUiFileOpenPanel;
693
+ }());
694
+ export { AcUiFileOpenPanel };
695
+ //# sourceMappingURL=AcUiFileOpenPanel.js.map