import { $e, Gl, L1, Le, Li, bi, f1, h3, it, l1, m1, n1, o3, rt, wt } from "./chunk-POAJ2YNP.js"; import "./chunk-GBYP4PB2.js"; import "./chunk-2MK3Q52E.js"; import "./chunk-BSDDCPAW.js"; import { B0, Fi, Ot, Pt, ar, ci, di, ot, pi, re } from "./chunk-23V3HWTR.js"; import "./chunk-GNR2UJZM.js"; import "./chunk-2LSFTFF7.js"; // node_modules/.pnpm/@univerjs+ui@0.5.5_@grpc+grpc-js@1.13.4_react-dom@18.3.1_react@18.3.1_rxjs@7.8.1_typescript@5.4.5/node_modules/@univerjs/ui/lib/es/facade.js var x = Object.defineProperty; var U = (n, e, t) => e in n ? x(n, e, { enumerable: true, configurable: true, writable: true, value: t }) : n[e] = t; var o = (n, e, t) => U(n, typeof e != "symbol" ? e + "" : e, t); var L = Object.defineProperty; var A = Object.getOwnPropertyDescriptor; var E = (n, e, t, r) => { for (var i = r > 1 ? void 0 : r ? A(e, t) : e, s = n.length - 1, c; s >= 0; s--) (c = n[s]) && (i = (r ? c(e, t, i) : c(i)) || i); return r && i && L(e, t, i), i; }; var h = (n, e) => (t, r) => e(t, r, n); var a; var S = (a = class extends Fi { constructor(e, t, r, i) { super(); o(this, "_commandToRegister", /* @__PURE__ */ new Map()); o(this, "_buildingSchema"); this._item = e, this._injector = t, this._commandService = r, this._menuManagerService = i; const s = typeof e.action == "string" ? e.action : re.generateRandomId(12); s !== e.action && this._commandToRegister.set(s, e.action), this._buildingSchema = { // eslint-disable-next-line ts/explicit-function-return-type menuItemFactory: () => ({ id: e.id, type: $e.BUTTON, // we only support button for now icon: e.icon, title: e.title, tooltip: e.tooltip, commandId: s }) }, typeof e.order < "u" && (this._buildingSchema.order = e.order); } /** @ignore */ __getSchema() { return this._commandToRegister.forEach((e, t) => { this._commandService.hasCommand(t) || this._commandService.registerCommand({ id: t, type: ar.COMMAND, handler: e }); }), { [this._item.id]: this._buildingSchema }; } /** * Append the menu to any menu position on Univer UI. * @param path Some predefined path to append the menu. */ appendTo(e) { const t = this.__getSchema(); this._menuManagerService.mergeMenu({ [e]: t }); } }, o(a, "RibbonStartGroup", l1), o(a, "RibbonPosition", L1), o(a, "MenuManagerPosition", wt), a); S = E([ h(1, ot(Ot)), h(2, Pt), h(3, m1) ], S); var _ = class extends Fi { constructor(e, t, r) { super(); o(this, "_menuByGroups", []); o(this, "_submenus", []); o(this, "_buildingSchema"); this._item = e, this._injector = t, this._menuManagerService = r, this._buildingSchema = { // eslint-disable-next-line ts/explicit-function-return-type menuItemFactory: () => ({ id: e.id, type: $e.SUBITEMS, icon: e.icon, title: e.title, tooltip: e.tooltip }) }, typeof e.order < "u" && (this._buildingSchema.order = e.order); } /** * Add a menu to the submenu. It can be a {@link FMenu} or a {@link FSubmenu}. * @param submenu Menu to add to the submenu. * @returns The FSubmenu itself for chaining calls. */ addSubmenu(e) { return this._submenus.push(e), this; } /** * Add a separator to the submenu. * @returns The FSubmenu itself for chaining calls. */ addSeparator() { return this._menuByGroups.push(this._submenus), this._submenus = [], this; } /** * Append the menu to any menu position on Univer UI. * @param path Some predefined path to append the menu. */ appendTo(e) { const t = this.__getSchema(); this._menuManagerService.mergeMenu({ [e]: t }); } /** @ignore */ __getSchema() { const e = {}; return this.addSeparator(), this._menuByGroups.forEach((t, r) => { const i = {}; t.forEach((s) => { Object.assign(i, s.__getSchema()); }), e[`${this._item.id}-group-${r}`] = i; }), { [this._item.id]: Object.assign(this._buildingSchema, e) }; } }; _ = E([ h(1, ot(Ot)), h(2, m1) ], _); var K = Object.defineProperty; var W = Object.getOwnPropertyDescriptor; var q = (n, e, t, r) => { for (var i = r > 1 ? void 0 : r ? W(e, t) : e, s = n.length - 1, c; s >= 0; s--) (c = n[s]) && (i = (r ? c(e, t, i) : c(i)) || i); return r && i && K(e, t, i), i; }; var I = (n, e) => (t, r) => e(t, r, n); var g = class extends Fi { constructor(e, t) { super(); o(this, "_forceEscapeDisposable", null); this._injector = e, this._shortcutService = t; } enableShortcut() { var e; (e = this._forceEscapeDisposable) == null || e.dispose(), this._forceEscapeDisposable = null; } disableShortcut() { this._forceEscapeDisposable || (this._forceEscapeDisposable = this._shortcutService.forceEscape()); } dispatchShortcutEvent(e) { return this._shortcutService.dispatch(e); } }; g = q([ I(0, ot(Ot)), I(1, it) ], g); var z = class extends pi { getURL() { return new URL(window.location.href); } getShortcut() { return this._injector.createInstance(g); } copy() { return this._commandService.syncExecuteCommand(bi.id); } paste() { return this._commandService.syncExecuteCommand(Li.id); } createMenu(e) { return this._injector.createInstance(S, e); } createSubmenu(e) { return this._injector.createInstance(_, e); } openSiderbar(e) { return this._injector.get(rt).open(e); } openSidebar(e) { return this.openSiderbar(e); } openDialog(e) { const r = this._injector.get(h3).open({ ...e, onClose: () => { r.dispose(); } }); return r; } getComponentManager() { return this._injector.get(n1); } showMessage(e) { return this._injector.get(o3).show(e), this; } setUIVisible(e, t) { return this._injector.get(f1).setUIVisible(e, t), this; } isUIVisible(e) { return this._injector.get(f1).isUIVisible(e); } registerUIPart(e, t) { return this._injector.get(f1).registerComponent(e, () => B0(t, this._injector)); } registerComponent(e, t, r) { const i = this._injector.get(n1); return this.disposeWithMe(i.register(e, t, r)); } }; pi.extend(z); var J = class extends di { onBeforeCopy(e) { return this._injector.get(Pt).beforeCommandExecuted((r) => { r.id === bi.id && e(); }); } onCopy(e) { return this._injector.get(Pt).onCommandExecuted((r) => { r.id === bi.id && e(); }); } onBeforePaste(e) { return this._injector.get(Pt).beforeCommandExecuted((r) => { r.id === Li.id && e(); }); } onPaste(e) { return this._injector.get(Pt).onCommandExecuted((r) => { (r.id === Li.id || r.id === Gl) && e(); }); } }; di.extend(J); var Q = class extends ci { get BuiltInUIPart() { return Le; } }; ci.extend(Q); //# sourceMappingURL=@univerjs_ui_facade.js.map