import { At, Bt, xt, ye } from "./chunk-4SXJQ6MB.js"; import { S, f, m } from "./chunk-CLOCSTN3.js"; import { Pt, hi, ln, mn, ot, pi, qt, xf } from "./chunk-23V3HWTR.js"; // node_modules/.pnpm/@univerjs+sheets-hyper-link@0.5.5_@grpc+grpc-js@1.13.4_react@18.3.1_rxjs@7.8.1/node_modules/@univerjs/sheets-hyper-link/lib/es/facade.js var I = Object.defineProperty; var H = Object.getOwnPropertyDescriptor; var U = (o, e, i, r) => { for (var n = r > 1 ? void 0 : r ? H(e, i) : e, t = o.length - 1, s; t >= 0; t--) (s = o[t]) && (n = (r ? s(e, i, n) : s(n)) || n); return r && n && I(e, i, n), n; }; var R = (o, e) => (i, r) => e(i, r, o); var m2 = class { constructor(o, e) { this._workbook = o, this._parserService = e; } getRangeUrl(o) { return this._parserService.buildHyperLink(this._workbook.getId(), o.getSheetId(), o.getRange()), this; } }; m2 = U([ R(1, ot(ye)) ], m2); var E = class extends f { createSheetHyperlink(e, i) { return this._injector.get(ye).buildHyperLink(this.getId(), e, i); } /** * Parse the hyperlink string to get the hyperlink info. * @param {string} hyperlink the hyperlink string * @returns {ISheetHyperLinkInfo} the hyperlink info */ parseSheetHyperlink(e) { return this._injector.get(ye).parseHyperLink(e); } }; f.extend(E); var T = class extends m { getUrl() { return this._injector.get(ye).buildHyperLink(this._workbook.getUnitId(), this._worksheet.getSheetId()); } }; m.extend(T); var B = class extends S { // #region hyperlink setHyperLink(e, i) { const r = { unitId: this.getUnitId(), subUnitId: this._worksheet.getSheetId(), link: { row: this._range.startRow, column: this._range.startColumn, payload: e, display: i, id: qt() } }; return this._commandService.executeCommand(xt.id, r); } getHyperLinks() { var i, r, n; const e = this._worksheet.getCellRaw(this._range.startRow, this._range.startColumn); return e != null && e.p ? (n = (r = (i = e.p.body) == null ? void 0 : i.customRanges) == null ? void 0 : r.filter((t) => t.rangeType === mn.HYPERLINK).map((t) => { var s, h, c, p, l; return { id: `${t.rangeId}`, startIndex: t.startIndex, endIndex: t.endIndex, url: (h = (s = t.properties) == null ? void 0 : s.url) != null ? h : "", label: (l = (p = (c = e.p) == null ? void 0 : c.body) == null ? void 0 : p.dataStream.slice(t.startIndex, t.endIndex + 1).replaceAll(ln.CUSTOM_RANGE_START, "").replaceAll(ln.CUSTOM_RANGE_END, "")) != null ? l : "" }; })) != null ? n : [] : []; } updateHyperLink(e, i, r) { const n = { unitId: this.getUnitId(), subUnitId: this._worksheet.getSheetId(), row: this._range.startRow, column: this._range.startColumn, id: e, payload: { payload: i, display: r } }; return this._commandService.executeCommand(Bt.id, n); } cancelHyperLink(e) { const i = { unitId: this.getUnitId(), subUnitId: this._worksheet.getSheetId(), row: this._range.startRow, column: this._range.startColumn, id: e }; return this._commandService.syncExecuteCommand(At.id, i); } getUrl() { return this._injector.get(ye).buildHyperLink(this.getUnitId(), this.getSheetId(), this.getRange()); } // #endregion }; S.extend(B); var A = class { get BeforeSheetLinkAdd() { return "BeforeSheetLinkAdd"; } get BeforeSheetLinkCancel() { return "BeforeSheetLinkCancel"; } get BeforeSheetLinkUpdate() { return "BeforeSheetLinkUpdate"; } }; hi.extend(A); var F = class extends pi { _initialize(e) { const i = e.get(Pt); this.disposeWithMe( i.beforeCommandExecuted((r) => { if (r.id === xt.id) { if (!this._eventListend(this.Event.BeforeSheetLinkAdd)) return; const n = this.getCommandSheetTarget(r); if (!n) return; const t = r.params, s = { workbook: n.workbook, worksheet: n.worksheet, row: t.link.row, col: t.link.column, link: t.link }; if (this.fireEvent(this.Event.BeforeSheetLinkAdd, s), s.cancel) throw new xf(); } if (r.id === Bt.id) { const n = this.getCommandSheetTarget(r); if (!n) return; const t = r.params, s = { workbook: n.workbook, worksheet: n.worksheet, row: t.row, column: t.column, id: t.id, payload: t.payload }; if (this.fireEvent(this.Event.BeforeSheetLinkUpdate, s), s.cancel) throw new xf(); } if (r.id === At.id) { const n = this.getCommandSheetTarget(r); if (!n) return; const t = r.params, s = { workbook: n.workbook, worksheet: n.worksheet, row: t.row, column: t.column, id: t.id }; if (this.fireEvent(this.Event.BeforeSheetLinkCancel, s), s.cancel) throw new xf(); } }) ); } }; pi.extend(F); export { E }; //# sourceMappingURL=chunk-SJCG2OJH.js.map