import { Ut, on } from "./chunk-QG2HZMYH.js"; import { Bi, Ct, Fe, Mf, Ot, Ra, SE, _n, nt, nu, ot } from "./chunk-23V3HWTR.js"; // node_modules/.pnpm/@univerjs+docs-drawing@0.5.5_@grpc+grpc-js@1.13.4_react@18.3.1_rxjs@7.8.1/node_modules/@univerjs/docs-drawing/lib/es/index.js var w = Object.defineProperty; var S = (t, r, e) => r in t ? w(t, r, { enumerable: true, configurable: true, writable: true, value: e }) : t[r] = e; var D = (t, r, e) => S(t, typeof r != "symbol" ? r + "" : r, e); var G = "docs-drawing.config"; var d = {}; var v = class extends on { }; var h = Ct("univer.doc.plugin.doc-drawing.service"); var F = Object.defineProperty; var J = Object.getOwnPropertyDescriptor; var y = (t, r, e, n) => { for (var i = n > 1 ? void 0 : n ? J(r, e) : r, a = t.length - 1, s; a >= 0; a--) (s = t[a]) && (i = (n ? s(r, e, i) : s(i)) || i); return n && i && F(r, e, i), i; }; var o = (t, r) => (e, n) => r(e, n, t); var l = "DOC_DRAWING_PLUGIN"; var _ = class extends nt { constructor(t, r, e, n) { super(), this._docDrawingService = t, this._drawingManagerService = r, this._resourceManagerService = e, this._univerInstanceService = n, this._init(); } _init() { this._initSnapshot(); } _initSnapshot() { const t = (e) => { const n = this._univerInstanceService.getUnit(e, Fe.UNIVER_DOC); if (n) { const i = n.getSnapshot().drawings, a = n.getSnapshot().drawingsOrder, s = { data: i != null ? i : {}, order: a != null ? a : [] }; return JSON.stringify(s); } return ""; }, r = (e) => { if (!e) return { data: {}, order: [] }; try { return JSON.parse(e); } catch { return { data: {}, order: [] }; } }; this.disposeWithMe( this._resourceManagerService.registerPluginResource({ pluginName: l, businesses: [Fe.UNIVER_DOC], toJson: (e) => t(e), parseJson: (e) => r(e), onUnLoad: (e) => { this._setDrawingDataForUnit(e, { data: {}, order: [] }); }, onLoad: (e, n) => { var i, a; this._setDrawingDataForUnit(e, { data: (i = n.data) != null ? i : {}, order: (a = n.order) != null ? a : [] }); } }) ); } _setDrawingDataForUnit(t, r) { const e = this._univerInstanceService.getUnit(t); e != null && (e.resetDrawing(r.data, r.order), this.loadDrawingDataForUnit(t)); } loadDrawingDataForUnit(t) { const r = this._univerInstanceService.getUnit(t, Fe.UNIVER_DOC); if (!r) return false; const e = t, n = r.getDrawings(), i = r.getDrawingsOrder(); if (!n || !i) return false; Object.keys(n).forEach((s) => { const p = n[s]; n[s] = { ...p }; }); const a = { [e]: { unitId: t, subUnitId: e, data: n, order: i } }; return this._docDrawingService.registerDrawingData(t, a), this._drawingManagerService.registerDrawingData(t, a), true; } }; _ = y([ o(0, h), o(1, Ut), o(2, Bi), o(3, _n) ], _); var L = Object.defineProperty; var x = Object.getOwnPropertyDescriptor; var V = (t, r, e, n) => { for (var i = n > 1 ? void 0 : n ? x(r, e) : r, a = t.length - 1, s; a >= 0; a--) (s = t[a]) && (i = (n ? s(r, e, i) : s(i)) || i); return n && i && L(r, e, i), i; }; var u = (t, r) => (e, n) => r(e, n, t); var c; var f = (c = class extends Ra { constructor(t = d, r, e) { super(), this._config = t, this._injector = r, this._configService = e; const { ...n } = nu( {}, d, this._config ); this._configService.setConfig(G, n); } onStarting() { [ [_], [v], [h, { useClass: v }] ].forEach((t) => this._injector.add(t)), Mf(this._injector, [ [_] ]); } }, D(c, "pluginName", l), D(c, "type", Fe.UNIVER_DOC), c); f = V([ u(1, ot(Ot)), u(2, SE) ], f); export { v, h, l, _, f }; //# sourceMappingURL=chunk-23GLNZMH.js.map