@rhc-office/sdk 6.6.363 → 6.6.381

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/index.js CHANGED
@@ -1,11 +1,11 @@
1
- var W = /* @__PURE__ */ ((t) => (t.DEFAULT = "default", t.COMPACT = "compact", t.HIDE = "none", t))(W || {});
2
- const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGITAL_SIGN_ENVIRONMENT__", y = {
1
+ var Y = /* @__PURE__ */ ((t) => (t.DEFAULT = "default", t.COMPACT = "compact", t.HIDE = "none", t))(Y || {});
2
+ const U = "RIGHT_CENTER", N = "REGULAR_ESM", B = "auto", k = "__RHC_OFFICE_DIGITAL_SIGN_ENVIRONMENT__", E = {
3
3
  defaults: {
4
4
  bjca: {
5
5
  pin: ""
6
6
  },
7
7
  deviceType: "client",
8
- edgePosition: F,
8
+ edgePosition: U,
9
9
  kol: {
10
10
  appId: "",
11
11
  appName: "",
@@ -17,8 +17,8 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
17
17
  pin: "",
18
18
  usbKeyType: 14
19
19
  },
20
- rsaMode: N,
21
- signatureType: U
20
+ rsaMode: B,
21
+ signatureType: N
22
22
  },
23
23
  signServer: {
24
24
  authSource: "Password",
@@ -38,7 +38,7 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
38
38
  usbKeyType: 14
39
39
  }
40
40
  }
41
- }, B = (t) => ({
41
+ }, x = (t) => ({
42
42
  bjca: {
43
43
  pin: t.bjca.pin
44
44
  },
@@ -57,7 +57,7 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
57
57
  },
58
58
  rsaMode: t.rsaMode,
59
59
  signatureType: t.signatureType
60
- }), x = (t) => ({
60
+ }), K = (t) => ({
61
61
  authSource: t.authSource,
62
62
  defaultLogin: t.defaultLogin,
63
63
  defaultPassword: t.defaultPassword,
@@ -74,10 +74,10 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
74
74
  checkCertificateBinding: t.usbKey.checkCertificateBinding,
75
75
  usbKeyType: t.usbKey.usbKeyType
76
76
  }
77
- }), m = (t) => ({
78
- defaults: B(t.defaults),
79
- signServer: x(t.signServer)
80
- }), V = (t) => ({
77
+ }), g = (t) => ({
78
+ defaults: x(t.defaults),
79
+ signServer: K(t.signServer)
80
+ }), y = (t) => ({
81
81
  defaults: t.defaults ? {
82
82
  ...t.defaults,
83
83
  bjca: t.defaults.bjca ? { ...t.defaults.bjca } : void 0,
@@ -89,7 +89,7 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
89
89
  kol: t.signServer.kol ? { ...t.signServer.kol } : void 0,
90
90
  usbKey: t.signServer.usbKey ? { ...t.signServer.usbKey } : void 0
91
91
  } : void 0
92
- }), $ = (t, n) => n ? {
92
+ }), W = (t, n) => n ? {
93
93
  bjca: {
94
94
  pin: n.bjca?.pin ?? t.bjca.pin
95
95
  },
@@ -108,7 +108,7 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
108
108
  },
109
109
  rsaMode: n.rsaMode ?? t.rsaMode,
110
110
  signatureType: n.signatureType ?? t.signatureType
111
- } : B(t), j = (t, n) => n ? {
111
+ } : x(t), $ = (t, n) => n ? {
112
112
  authSource: n.authSource ?? t.authSource,
113
113
  defaultLogin: n.defaultLogin ?? t.defaultLogin,
114
114
  defaultPassword: n.defaultPassword ?? t.defaultPassword,
@@ -125,62 +125,72 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
125
125
  checkCertificateBinding: n.usbKey?.checkCertificateBinding ?? t.usbKey.checkCertificateBinding,
126
126
  usbKeyType: n.usbKey?.usbKeyType ?? t.usbKey.usbKeyType
127
127
  }
128
- } : x(t), K = (t, n) => ({
129
- defaults: $(t.defaults, n.defaults),
130
- signServer: j(t.signServer, n.signServer)
131
- }), X = (t, n) => ({
132
- defaults: t.defaults || n.defaults ? {
133
- ...t.defaults,
134
- ...n.defaults,
135
- bjca: {
136
- ...t.defaults?.bjca ?? {},
137
- ...n.defaults?.bjca ?? {}
138
- },
139
- kol: {
140
- ...t.defaults?.kol ?? {},
141
- ...n.defaults?.kol ?? {}
142
- },
143
- plugin: {
144
- ...t.defaults?.plugin ?? {},
145
- ...n.defaults?.plugin ?? {}
146
- }
147
- } : void 0,
148
- signServer: t.signServer || n.signServer ? {
149
- ...t.signServer,
150
- ...n.signServer,
151
- kol: {
152
- ...t.signServer?.kol ?? {},
153
- ...n.signServer?.kol ?? {}
154
- },
155
- usbKey: {
156
- ...t.signServer?.usbKey ?? {},
157
- ...n.signServer?.usbKey ?? {}
158
- }
159
- } : void 0
160
- }), J = () => globalThis, b = () => {
128
+ } : K(t), V = (t, n) => ({
129
+ defaults: W(t.defaults, n.defaults),
130
+ signServer: $(t.signServer, n.signServer)
131
+ }), X = (t, n) => {
132
+ const e = t.defaults?.bjca || n.defaults?.bjca ? {
133
+ ...t.defaults?.bjca,
134
+ ...n.defaults?.bjca
135
+ } : void 0, i = t.defaults?.kol || n.defaults?.kol ? {
136
+ ...t.defaults?.kol,
137
+ ...n.defaults?.kol
138
+ } : void 0, r = t.defaults?.plugin || n.defaults?.plugin ? {
139
+ ...t.defaults?.plugin,
140
+ ...n.defaults?.plugin
141
+ } : void 0, a = t.signServer?.kol || n.signServer?.kol ? {
142
+ ...t.signServer?.kol,
143
+ ...n.signServer?.kol
144
+ } : void 0, s = t.signServer?.usbKey || n.signServer?.usbKey ? {
145
+ ...t.signServer?.usbKey,
146
+ ...n.signServer?.usbKey
147
+ } : void 0;
148
+ return {
149
+ defaults: t.defaults || n.defaults ? {
150
+ ...t.defaults,
151
+ ...n.defaults,
152
+ ...e ? { bjca: e } : {},
153
+ ...i ? { kol: i } : {},
154
+ ...r ? { plugin: r } : {}
155
+ } : void 0,
156
+ signServer: t.signServer || n.signServer ? {
157
+ ...t.signServer,
158
+ ...n.signServer,
159
+ ...a ? { kol: a } : {},
160
+ ...s ? { usbKey: s } : {}
161
+ } : void 0
162
+ };
163
+ }, J = () => globalThis, p = () => {
161
164
  const t = J();
162
165
  return t[k] || (t[k] = {
163
- current: m(y),
164
- defaults: m(y),
166
+ current: g(E),
167
+ defaults: g(E),
165
168
  overrides: {}
166
169
  }), t[k];
167
- }, lt = () => b().current, ct = (t) => {
168
- const n = b();
169
- return n.defaults = m(t), n.current = K(n.defaults, n.overrides), n.current;
170
- }, ht = (t) => {
171
- const n = b();
172
- return n.current = m(t), n.overrides = V(t), n.current;
170
+ }, ct = () => p().current, ht = () => {
171
+ const t = p();
172
+ return {
173
+ current: g(t.current),
174
+ defaults: g(t.defaults),
175
+ overrides: y(t.overrides)
176
+ };
173
177
  }, gt = (t) => {
174
- const n = b();
175
- return n.overrides = X(n.overrides, V(t)), n.current = K(n.current, t), n.current;
178
+ const n = p();
179
+ return n.defaults = g(t), n.current = V(n.defaults, n.overrides), n.current;
176
180
  }, mt = (t) => {
177
- const n = b();
178
- return t && (n.defaults = m(t)), n.overrides = {}, n.current = m(n.defaults), n.current;
179
- }, pt = {
180
- EDGE_POSITION: F,
181
- RSA_MODE: N,
182
- SIGNATURE_TYPE: U
183
- }, R = (t) => {
181
+ const n = p();
182
+ return n.current = g(t), n.overrides = y(t), n.current;
183
+ }, pt = (t) => {
184
+ const n = p();
185
+ return n.overrides = X(n.overrides, y(t)), n.current = V(n.current, t), n.current;
186
+ }, bt = (t) => {
187
+ const n = p();
188
+ return t && (n.defaults = g(t)), n.overrides = {}, n.current = g(n.defaults), n.current;
189
+ }, St = {
190
+ EDGE_POSITION: U,
191
+ RSA_MODE: B,
192
+ SIGNATURE_TYPE: N
193
+ }, f = (t) => {
184
194
  if (t.length !== 0)
185
195
  return t.length === 1 ? t[0] : t;
186
196
  }, d = (t, n, e) => new Proxy(
@@ -201,16 +211,16 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
201
211
  return a.state?.(e.state.snapshot(), s);
202
212
  const o = a.adapterMethod ?? r;
203
213
  if (a.kind === "query")
204
- return e.bridge.request(t, o, R(s));
214
+ return e.bridge.request(t, o, f(s));
205
215
  if (a.kind === "callbackQuery") {
206
216
  const c = s.find((h) => typeof h == "function"), l = s.filter((h) => typeof h != "function");
207
- e.bridge.request(t, o, R(l)).then((h) => {
208
- const Y = a.mapCallbackResult?.(h) ?? [h];
209
- c?.(...Y);
217
+ e.bridge.request(t, o, f(l)).then((h) => {
218
+ const j = a.mapCallbackResult?.(h) ?? [h];
219
+ c?.(...j);
210
220
  }).catch(e.onAsyncError);
211
221
  return;
212
222
  }
213
- const u = e.bridge.request(t, o, R(s)).catch((c) => {
223
+ const u = e.bridge.request(t, o, f(s)).catch((c) => {
214
224
  e.onAsyncError(c);
215
225
  });
216
226
  if (a.returnsResult)
@@ -221,7 +231,7 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
221
231
  };
222
232
  }
223
233
  }
224
- ), Z = (t) => typeof t == "object" && t !== null && !Array.isArray(t) && "id" in t, E = (t) => t.annotations?.filter(Z).map((n) => ({ ...n })) ?? [], ee = (t) => {
234
+ ), Z = (t) => typeof t == "object" && t !== null && !Array.isArray(t) && "id" in t, P = (t) => t.annotations?.filter(Z).map((n) => ({ ...n })) ?? [], ee = (t) => {
225
235
  switch (t) {
226
236
  case "select":
227
237
  case "pen":
@@ -259,11 +269,11 @@ const F = "RIGHT_CENTER", U = "REGULAR_ESM", N = "auto", k = "__RHC_OFFICE_DIGIT
259
269
  },
260
270
  getAnnotations: {
261
271
  kind: "stateGetter",
262
- state: (t) => E(t)
272
+ state: (t) => P(t)
263
273
  },
264
274
  getAnnotationsCount: {
265
275
  kind: "stateGetter",
266
- state: (t) => E(t).length
276
+ state: (t) => P(t).length
267
277
  },
268
278
  openAnnotationView: { kind: "command" },
269
279
  closeAnnotationView: { kind: "command" },
@@ -300,7 +310,7 @@ class re {
300
310
  this.configSecurityProvider = (e) => this.adapter.configSecurityProvider(e), this.getSecurityProviders = () => this.adapter.getSecurityProviders(), this.adapter = d("crypto", ie, n);
301
311
  }
302
312
  }
303
- const P = (t) => t.digitalSignatures ? [...t.digitalSignatures] : [], ae = {
313
+ const C = (t) => t.digitalSignatures ? [...t.digitalSignatures] : [], ae = {
304
314
  addDigitalSignatureRetrieveCallback: {
305
315
  kind: "callbackRegister",
306
316
  callback: (t, n) => {
@@ -337,11 +347,11 @@ const P = (t) => t.digitalSignatures ? [...t.digitalSignatures] : [], ae = {
337
347
  listDigitalSignatures: { kind: "callbackQuery" },
338
348
  getDigitalSignatures: {
339
349
  kind: "stateGetter",
340
- state: (t) => P(t)
350
+ state: (t) => C(t)
341
351
  },
342
352
  getDigitalSignaturesCount: {
343
353
  kind: "stateGetter",
344
- state: (t) => P(t).length
354
+ state: (t) => C(t).length
345
355
  },
346
356
  enableDigitalSignatureInfoView: { kind: "command" },
347
357
  enableDigitalSignatureRevocation: { kind: "command" }
@@ -355,7 +365,7 @@ class se {
355
365
  );
356
366
  }
357
367
  }
358
- const oe = "rhc-office.editor-adapter", de = 1, ue = "__RHC_OFFICE_EDITOR_ADAPTER__", C = "rhcOfficeAdapterReady", A = "rhcOfficeAdapterEvent", G = "data-rhc-office-reader-id", le = {
368
+ const oe = "rhc-office.editor-adapter", de = 1, ue = "__RHC_OFFICE_EDITOR_ADAPTER__", D = "rhcOfficeAdapterReady", A = "rhcOfficeAdapterEvent", G = "data-rhc-office-reader-id", le = {
359
369
  addDocumentOpenedCallback: {
360
370
  kind: "callbackRegister",
361
371
  callback: (t, n) => {
@@ -475,7 +485,7 @@ class ke {
475
485
  );
476
486
  }
477
487
  }
478
- const Re = (t) => ({
488
+ const fe = (t) => ({
479
489
  addPageChangeCallback: {
480
490
  kind: "callbackRegister",
481
491
  callback: (n, e) => {
@@ -525,11 +535,11 @@ const Re = (t) => ({
525
535
  gotoPreviousPage: { kind: "command" },
526
536
  rotatePage: { kind: "command" }
527
537
  });
528
- class fe {
538
+ class Re {
529
539
  constructor(n) {
530
540
  this.addPageChangeCallback = (e) => this.adapter.addPageChangeCallback(e), this.addPageModeChangeCallback = (e) => this.adapter.addPageModeChangeCallback(e), this.getPageCount = (e) => this.adapter.getPageCount(e), this.getPageIndex = (e) => this.adapter.getPageIndex(e), this.setSinglePageViewMode = () => this.adapter.setSinglePageViewMode(), this.setTwoPagesViewMode = () => this.adapter.setTwoPagesViewMode(), this.setPageScrollVertical = () => this.adapter.setPageScrollVertical(), this.setPageScrollHorizontal = () => this.adapter.setPageScrollHorizontal(), this.setPageCursorPanDrag = () => this.adapter.setPageCursorPanDrag(), this.setPageCursorTextSelect = () => this.adapter.setPageCursorTextSelect(), this.rotateCW = () => this.adapter.rotateCW(), this.rotateCCW = () => this.adapter.rotateCCW(), this.autoFitPage = () => this.adapter.autoFitPage(), this.fitPageSize = () => this.adapter.fitPageSize(), this.fitPageWidth = () => this.adapter.fitPageWidth(), this.fitPageHeight = () => this.adapter.fitPageHeight(), this.increasePageScale = () => this.adapter.increasePageScale(), this.decreasePageScale = () => this.adapter.decreasePageScale(), this.setPageScale = (e) => this.adapter.setPageScale(e), this.setPageBlendColor = (e, i, r, a) => this.adapter.setPageBlendColor(e, i, r, a), this.gotoPage = (e, i, r) => this.adapter.gotoPage(e, i, r), this.gotoNextPage = () => this.adapter.gotoNextPage(), this.gotoPreviousPage = () => this.adapter.gotoPreviousPage(), this.rotatePage = (e) => this.adapter.rotatePage(e), this.adapter = d(
531
541
  "page",
532
- Re(n),
542
+ fe(n),
533
543
  n
534
544
  );
535
545
  }
@@ -560,19 +570,19 @@ class ve {
560
570
  );
561
571
  }
562
572
  }
563
- const ye = /\s*,\s*/, Ee = /\s*-\s*/, f = (t) => {
573
+ const ye = /\s*,\s*/, Ee = /\s*-\s*/, R = (t) => {
564
574
  const n = Number.parseInt(t.trim(), 10);
565
575
  return !Number.isFinite(n) || n <= 0 ? null : n;
566
576
  }, Pe = (t) => {
567
577
  const n = t.split(Ee);
568
578
  if (n.length === 1) {
569
- const r = f(n[0] ?? "");
579
+ const r = R(n[0] ?? "");
570
580
  return r ? [r] : [];
571
581
  }
572
- const e = f(n[0] ?? ""), i = f(n[1] ?? "");
582
+ const e = R(n[0] ?? ""), i = R(n[1] ?? "");
573
583
  return !e || !i || i < e ? [] : Array.from({ length: i - e + 1 }, (r, a) => e + a);
574
584
  }, Ce = (t) => t ? t.split(ye).flatMap((e) => Pe(e)).filter((e, i, r) => r.indexOf(e) === i) : [];
575
- class Ae {
585
+ class De {
576
586
  constructor(n, e, i) {
577
587
  this.setFieldName = (r) => {
578
588
  this.key = r;
@@ -583,7 +593,7 @@ class Ae {
583
593
  }, this.key = n, this.value = e, this.description = i;
584
594
  }
585
595
  }
586
- class De {
596
+ class Ae {
587
597
  constructor() {
588
598
  this.fields = [], this.keywordTextFixedPositions = void 0, this.keywordOffsetX = 0, this.keywordOffsetY = 0, this.bookmarkOffsetX = 0, this.bookmarkOffsetY = 0, this.printMargin = 0, this.grayscaleSealImage = !1, this.signType = 0, this.sealPosition = 0, this.getSignType = () => this.signType, this.setSignType = (n) => {
589
599
  this.signType = n;
@@ -613,7 +623,7 @@ const Me = {
613
623
  setSecuritySettings: { kind: "query" },
614
624
  openSecuritySettingsDialog: { kind: "command" }
615
625
  };
616
- class we {
626
+ class Ie {
617
627
  constructor(n) {
618
628
  this.getSecuritySettings = () => this.adapter.getSecuritySettings(), this.setSecuritySettings = (e) => this.adapter.setSecuritySettings(e), this.isSecuritySettingsLocalEditable = () => this.adapter.isSecuritySettingsLocalEditable(), this.setSecuritySettingsLocalEditable = (e) => this.adapter.setSecuritySettingsLocalEditable(e), this.openSecuritySettingsDialog = () => this.adapter.openSecuritySettingsDialog(), this.adapter = d(
619
629
  "security",
@@ -622,7 +632,7 @@ class we {
622
632
  );
623
633
  }
624
634
  }
625
- const Ie = {
635
+ const we = {
626
636
  setSignServer: { kind: "command" },
627
637
  addSignServerAuthCallback: {
628
638
  kind: "callbackRegister",
@@ -646,7 +656,7 @@ class _e {
646
656
  constructor(n) {
647
657
  this.setSignServer = (e) => this.adapter.setSignServer(e), this.addSignServerAuthCallback = (e) => this.adapter.addSignServerAuthCallback(e), this.setSignServerDefaultLogin = (e) => this.adapter.setSignServerDefaultLogin(e), this.setDefaultSignServerLogin = (e) => this.adapter.setDefaultSignServerLogin(e), this.setSignServerDefaultPassword = (e) => this.adapter.setSignServerDefaultPassword(e), this.setDefaultSignServerPassword = (e) => this.adapter.setDefaultSignServerPassword(e), this.loginNTKOSignServer = (e, i, r) => this.adapter.loginNTKOSignServer(e, i, r), this.loginSignServer = (e, i, r, a) => this.adapter.loginSignServer(e, i, r, a), this.signOutSignServer = () => this.adapter.signOutSignServer(), this.isAuthenticatedOnSignServer = () => this.adapter.isAuthenticatedOnSignServer(), this.setSignServerLoginFromUSBKey = (e, i) => this.adapter.setSignServerLoginFromUSBKey(e, i), this.setUserAuthSource = (e) => this.adapter.setUserAuthSource(e), this.adapter = d(
648
658
  "signServer",
649
- Ie,
659
+ we,
650
660
  n
651
661
  );
652
662
  }
@@ -738,7 +748,7 @@ class xe {
738
748
  console.warn(`[RHC Office SDK] ui.${n} is deprecated. Use ui.${e} instead.`);
739
749
  }
740
750
  }
741
- const Ve = (t) => {
751
+ const Ke = (t) => {
742
752
  if (!t)
743
753
  return;
744
754
  const n = t.trim().toLowerCase();
@@ -749,21 +759,21 @@ const Ve = (t) => {
749
759
  }, q = (t) => {
750
760
  const n = new URL(t, globalThis.location?.href ?? "http://localhost/");
751
761
  return n.hash = "", n.pathname.endsWith("/") || (n.pathname = `${n.pathname}/`), n.toString();
752
- }, Ke = (t) => new URL("editors.bootstrap.js", t).toString(), Ge = (t, n) => {
762
+ }, Ve = (t) => new URL("editors.bootstrap.js", t).toString(), Ge = (t, n) => {
753
763
  const e = q(t);
754
764
  return {
755
765
  ...n,
756
766
  appUrl: e,
757
- theme: Ve(n.theme)
767
+ theme: Ke(n.theme)
758
768
  };
759
- }, g = "rhc-office-editor", T = "__RHC_OFFICE_SDK_READER_LOADER__", H = () => {
769
+ }, m = "rhc-office-editor", T = "__RHC_OFFICE_SDK_READER_LOADER__", H = () => {
760
770
  const t = globalThis;
761
771
  return t[T] || (t[T] = {
762
772
  activeAppUrl: null,
763
773
  loadPromises: /* @__PURE__ */ new Map()
764
774
  }), t[T];
765
775
  }, qe = (t) => Array.from(document.querySelectorAll("script")).find((n) => n.src === t) ?? null;
766
- class D extends Error {
776
+ class M extends Error {
767
777
  constructor(n) {
768
778
  super(`Failed to load reader bootstrap script: ${n}`), this.name = "ReaderScriptLoadError";
769
779
  }
@@ -771,7 +781,7 @@ class D extends Error {
771
781
  class He extends Error {
772
782
  constructor(n, e) {
773
783
  super(
774
- `Reader Web Component "${g}" is already bound to ${n} and cannot be reloaded from ${e}.`
784
+ `Reader Web Component "${m}" is already bound to ${n} and cannot be reloaded from ${e}.`
775
785
  ), this.name = "ReaderSourceConflictError";
776
786
  }
777
787
  }
@@ -785,29 +795,29 @@ const z = (t) => {
785
795
  const e = n.loadPromises.get(t);
786
796
  if (e)
787
797
  return e;
788
- if (globalThis.customElements?.get(g)) {
798
+ if (globalThis.customElements?.get(m)) {
789
799
  n.activeAppUrl = t;
790
800
  const s = Promise.resolve();
791
801
  return n.loadPromises.set(t, s), s;
792
802
  }
793
- const i = Ke(t), r = qe(i);
803
+ const i = Ve(t), r = qe(i);
794
804
  n.activeAppUrl = t;
795
805
  const a = new Promise((s, o) => {
796
806
  const u = (h) => {
797
- h?.remove(), o(new D(i));
807
+ h?.remove(), o(new M(i));
798
808
  }, c = () => {
799
- globalThis.customElements.whenDefined(g).then(() => {
809
+ globalThis.customElements.whenDefined(m).then(() => {
800
810
  s();
801
811
  }).catch(o);
802
812
  };
803
813
  if (r) {
804
- if (globalThis.customElements?.get(g)) {
814
+ if (globalThis.customElements?.get(m)) {
805
815
  s();
806
816
  return;
807
817
  }
808
818
  r.addEventListener(
809
819
  "error",
810
- () => o(new D(i)),
820
+ () => o(new M(i)),
811
821
  {
812
822
  once: !0
813
823
  }
@@ -817,21 +827,21 @@ const z = (t) => {
817
827
  const l = document.createElement("script");
818
828
  l.src = i, l.async = !0, l.dataset.rhcOfficeSdkReader = t, l.addEventListener("load", c, { once: !0 }), l.addEventListener("error", () => u(l), { once: !0 }), document.head.appendChild(l);
819
829
  }).catch((s) => {
820
- throw n.loadPromises.delete(t), !globalThis.customElements?.get(g) && n.activeAppUrl === t && (n.activeAppUrl = null), s;
830
+ throw n.loadPromises.delete(t), !globalThis.customElements?.get(m) && n.activeAppUrl === t && (n.activeAppUrl = null), s;
821
831
  });
822
832
  return n.loadPromises.set(t, a), a;
823
- }, Qe = 5e3, Ye = 5e3, We = () => {
833
+ }, Qe = 5e3, je = 5e3, Ye = () => {
824
834
  const t = globalThis.crypto;
825
835
  return typeof t?.randomUUID == "function" ? t.randomUUID() : `adapter-${Date.now()}-${Math.random().toString(36).slice(2)}`;
826
- }, p = () => globalThis[ue];
827
- class $e extends Error {
836
+ }, b = () => globalThis[ue];
837
+ class We extends Error {
828
838
  constructor(n, e, i) {
829
839
  super(e), this.name = "ReaderBridgeError", this.code = n, this.details = i;
830
840
  }
831
841
  }
832
- class je {
842
+ class $e {
833
843
  constructor(n) {
834
- this.readerId = null, this.readyTimeoutMs = n?.readyTimeoutMs ?? Ye, this.requestTimeoutMs = n?.requestTimeoutMs ?? Qe;
844
+ this.readerId = null, this.readyTimeoutMs = n?.readyTimeoutMs ?? je, this.requestTimeoutMs = n?.requestTimeoutMs ?? Qe;
835
845
  }
836
846
  configureTimeouts(n) {
837
847
  this.readyTimeoutMs = n?.readyTimeoutMs ?? this.readyTimeoutMs, this.requestTimeoutMs = n?.requestTimeoutMs ?? this.requestTimeoutMs;
@@ -846,7 +856,7 @@ class je {
846
856
  const a = await this.requestRaw(n, e, i, r);
847
857
  if (a.ok)
848
858
  return a.result;
849
- throw new $e(
859
+ throw new We(
850
860
  a.error.code,
851
861
  a.error.message,
852
862
  a.error.details
@@ -875,7 +885,7 @@ class je {
875
885
  const s = {
876
886
  protocol: oe,
877
887
  version: de,
878
- requestId: We(),
888
+ requestId: Ye(),
879
889
  readerId: this.readerId,
880
890
  tool: n,
881
891
  method: e,
@@ -888,25 +898,25 @@ class je {
888
898
  );
889
899
  }
890
900
  getCapabilities() {
891
- return this.readerId ? p()?.getCapabilities(this.readerId) ?? null : null;
901
+ return this.readerId ? b()?.getCapabilities(this.readerId) ?? null : null;
892
902
  }
893
903
  async waitForReady(n) {
894
904
  return this.readerId ? !!await this.waitForAdapter(this.readerId, n?.timeoutMs) : !1;
895
905
  }
896
906
  async waitForAdapter(n, e = this.readyTimeoutMs) {
897
- const i = p();
907
+ const i = b();
898
908
  return i?.getCapabilities(n) ? i : new Promise((r) => {
899
909
  let a;
900
910
  const s = () => {
901
- a && clearTimeout(a), globalThis.removeEventListener(C, o);
911
+ a && clearTimeout(a), globalThis.removeEventListener(D, o);
902
912
  }, o = (u) => {
903
913
  if ((u instanceof CustomEvent ? u.detail : void 0)?.readerId !== n)
904
914
  return;
905
- const l = p();
915
+ const l = b();
906
916
  s(), r(l ?? null);
907
917
  };
908
- globalThis.addEventListener(C, o), a = setTimeout(() => {
909
- s(), r(p()?.getCapabilities(n) ? p() : null);
918
+ globalThis.addEventListener(D, o), a = setTimeout(() => {
919
+ s(), r(b()?.getCapabilities(n) ? b() : null);
910
920
  }, e);
911
921
  });
912
922
  }
@@ -937,7 +947,7 @@ class je {
937
947
  });
938
948
  }
939
949
  }
940
- const M = {
950
+ const I = {
941
951
  annotationEnabled: !1,
942
952
  documentModified: !1,
943
953
  documentOpened: !1,
@@ -948,10 +958,10 @@ const M = {
948
958
  };
949
959
  class Xe {
950
960
  constructor() {
951
- this.state = { ...M };
961
+ this.state = { ...I };
952
962
  }
953
963
  reset() {
954
- this.state = { ...M };
964
+ this.state = { ...I };
955
965
  }
956
966
  update(n) {
957
967
  n && (this.state = {
@@ -1072,11 +1082,22 @@ const S = "__RHC_OFFICE_READER_RUNTIME__", tt = "__rhcOfficeReaderRuntimeConfig"
1072
1082
  "documentLoaded",
1073
1083
  "documentStateChange",
1074
1084
  "documentError"
1075
- ], it = "readerReady", rt = "readerUnload", v = "readerError", at = () => typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : `rhc-reader-${Date.now()}-${Math.random().toString(36).slice(2)}`, I = (t, n) => ({
1085
+ ], it = "readerReady", rt = "readerUnload", v = "readerError", at = () => typeof globalThis.crypto?.randomUUID == "function" ? globalThis.crypto.randomUUID() : `rhc-reader-${Date.now()}-${Math.random().toString(36).slice(2)}`, _ = (t, n) => ({
1076
1086
  appUrl: n?.appUrl ?? null,
1077
1087
  configuration: n,
1078
1088
  element: t
1079
- }), st = (t) => {
1089
+ }), st = (t, n) => {
1090
+ if (!t)
1091
+ return;
1092
+ const e = typeof t == "string" ? t.trim() : t.userName.trim();
1093
+ if (!e)
1094
+ return;
1095
+ const i = n == null ? "" : String(n).trim(), r = typeof t == "string" || t.userId === void 0 || t.userId === null ? "" : String(t.userId).trim(), a = i || r;
1096
+ return {
1097
+ sessionUser: e,
1098
+ ...a ? { sessionUserId: a } : {}
1099
+ };
1100
+ }, ot = (t) => {
1080
1101
  if (typeof t == "string") {
1081
1102
  const n = document.getElementById(t);
1082
1103
  if (!n)
@@ -1088,52 +1109,52 @@ const S = "__RHC_OFFICE_READER_RUNTIME__", tt = "__rhcOfficeReaderRuntimeConfig"
1088
1109
  if (!(t instanceof HTMLDivElement))
1089
1110
  throw new Error("Reader container must be a div element.");
1090
1111
  return t;
1091
- }, ot = () => {
1112
+ }, dt = () => {
1092
1113
  const t = typeof globalThis.matchMedia == "function";
1093
1114
  return (t ? globalThis.matchMedia("(prefers-contrast: more)").matches : !1) ? "high-contrast" : (t ? globalThis.matchMedia("(prefers-color-scheme: dark)").matches : !1) ? "dark" : "light";
1094
- }, _ = (t, n) => {
1115
+ }, O = (t, n) => {
1095
1116
  const e = t;
1096
1117
  if (typeof e.addEventListener == "function") {
1097
1118
  e.addEventListener("change", n);
1098
1119
  return;
1099
1120
  }
1100
1121
  typeof e.addListener == "function" && e.addListener(n);
1101
- }, O = (t, n) => {
1122
+ }, L = (t, n) => {
1102
1123
  const e = t;
1103
1124
  if (typeof e.removeEventListener == "function") {
1104
1125
  e.removeEventListener("change", n);
1105
1126
  return;
1106
1127
  }
1107
1128
  typeof e.removeListener == "function" && e.removeListener(n);
1108
- }, dt = (t) => {
1129
+ }, ut = (t) => {
1109
1130
  t.style.display || (t.style.display = "block"), t.style.width || (t.style.width = "100%"), t.style.height || (t.style.height = "100%");
1110
- }, L = (t, n) => {
1131
+ }, F = (t, n) => {
1111
1132
  const e = n;
1112
1133
  if (!e)
1113
1134
  return t.removeAttribute("theme"), null;
1114
1135
  if (e !== "auto")
1115
1136
  return t.setAttribute("theme", e), null;
1116
1137
  const i = () => {
1117
- t.setAttribute("theme", ot());
1138
+ t.setAttribute("theme", dt());
1118
1139
  };
1119
1140
  if (i(), typeof globalThis.matchMedia != "function")
1120
1141
  return null;
1121
1142
  const r = globalThis.matchMedia("(prefers-color-scheme: dark)"), a = globalThis.matchMedia("(prefers-contrast: more)"), s = () => {
1122
1143
  i();
1123
1144
  };
1124
- return _(r, s), _(a, s), () => {
1125
- O(r, s), O(a, s);
1145
+ return O(r, s), O(a, s), () => {
1146
+ L(r, s), L(a, s);
1126
1147
  };
1127
1148
  };
1128
- class ut {
1149
+ class lt {
1129
1150
  constructor(n) {
1130
- this.bridge = new je(), this.callbacks = new et(), this.readerState = new Xe(), this.bridgeToolContext = {
1151
+ this.bridge = new $e(), this.callbacks = new et(), this.readerState = new Xe(), this.bridgeToolContext = {
1131
1152
  bridge: this.bridge,
1132
1153
  callbacks: this.callbacks,
1133
1154
  debug: () => this.debugEnabled,
1134
1155
  onAsyncError: (e) => this.reportAdapterError(e),
1135
1156
  state: this.readerState
1136
- }, this.documentTool = new ce(this.bridgeToolContext), this.uiTool = new xe(this.bridgeToolContext), this.pageTool = new fe(this.bridgeToolContext), this.pageArrangeTool = new ke(this.bridgeToolContext), this.findTool = new ge(this.bridgeToolContext), this.signServerTool = new _e(this.bridgeToolContext), this.digitalSignTool = new se(this.bridgeToolContext), this.symbologyTool = new Le(this.bridgeToolContext), this.annotationTool = new ne(this.bridgeToolContext), this.templateSignTool = new Ue(this.bridgeToolContext), this.pdfFormFiller = new ve(this.bridgeToolContext), this.networkingTool = new pe(this.bridgeToolContext), this.cryptoTool = new re(this.bridgeToolContext), this.securityTool = new we(this.bridgeToolContext), this.readyCallbacks = [], this.unloadCallbacks = [], this.debugEnabled = !1, this.isReady = !1, this.removed = !1, this.mountToken = 0, this.hostContainer = null, this.readerElement = null, this.readerId = null, this.normalizedConfiguration = null, this.runtimeRestoreState = null, this.nativeEventCleanupCallbacks = [], this.themeCleanup = null, this.enableDebug = (e) => {
1157
+ }, this.documentTool = new ce(this.bridgeToolContext), this.uiTool = new xe(this.bridgeToolContext), this.pageTool = new Re(this.bridgeToolContext), this.pageArrangeTool = new ke(this.bridgeToolContext), this.findTool = new ge(this.bridgeToolContext), this.signServerTool = new _e(this.bridgeToolContext), this.digitalSignTool = new se(this.bridgeToolContext), this.symbologyTool = new Le(this.bridgeToolContext), this.annotationTool = new ne(this.bridgeToolContext), this.templateSignTool = new Ue(this.bridgeToolContext), this.pdfFormFiller = new ve(this.bridgeToolContext), this.networkingTool = new pe(this.bridgeToolContext), this.cryptoTool = new re(this.bridgeToolContext), this.securityTool = new Ie(this.bridgeToolContext), this.readyCallbacks = [], this.unloadCallbacks = [], this.debugEnabled = !1, this.isReady = !1, this.removed = !1, this.mountToken = 0, this.hostContainer = null, this.readerElement = null, this.readerId = null, this.normalizedConfiguration = null, this.runtimeRestoreState = null, this.nativeEventCleanupCallbacks = [], this.themeCleanup = null, this.enableDebug = (e) => {
1137
1158
  this.debugEnabled = e;
1138
1159
  }, this.changeLanguage = (e) => {
1139
1160
  this.readerElement && this.readerElement.setAttribute("language", e);
@@ -1141,21 +1162,11 @@ class ut {
1141
1162
  this.themeCleanup?.(), this.themeCleanup = null, this.normalizedConfiguration = this.normalizedConfiguration ? {
1142
1163
  ...this.normalizedConfiguration,
1143
1164
  theme: e
1144
- } : null, this.readerElement && (this.themeCleanup = L(this.readerElement, e));
1165
+ } : null, this.readerElement && (this.themeCleanup = F(this.readerElement, e));
1145
1166
  }, this.setSessionUser = (e) => {
1146
1167
  this.sessionUser = e;
1147
1168
  }, this.setSessionUserId = (e) => {
1148
- if (typeof this.sessionUser == "string" || !this.sessionUser) {
1149
- this.sessionUser = {
1150
- userName: typeof this.sessionUser == "string" ? this.sessionUser : "",
1151
- userId: e
1152
- };
1153
- return;
1154
- }
1155
- this.sessionUser = {
1156
- ...this.sessionUser,
1157
- userId: e
1158
- };
1169
+ this.sessionUserId = e;
1159
1170
  }, this.setSessionData = (e) => {
1160
1171
  this.sessionData = e;
1161
1172
  }, this.isReaderReady = () => this.isReady, this.isReaderDestroyed = () => this.removed && !this.isReady, this.addReaderReadyCallback = (e) => {
@@ -1165,7 +1176,7 @@ class ut {
1165
1176
  }, this.setReaderEventListener = (e) => {
1166
1177
  this.readerEventListener = e;
1167
1178
  }, this.embedReader = (e, i, r) => {
1168
- const a = st(e), s = q(i);
1179
+ const a = ot(e), s = q(i);
1169
1180
  z(s);
1170
1181
  const o = Ge(s, r), u = this.mountToken + 1;
1171
1182
  this.removeReader(), this.mountToken = u, this.removed = !1, this.hostContainer = a, this.normalizedConfiguration = o, this.mountReader(a, o, u);
@@ -1173,16 +1184,19 @@ class ut {
1173
1184
  const e = !!(this.readerElement || this.hostContainer);
1174
1185
  if (this.mountToken += 1, this.cleanupNativeEventForwarders(), this.cleanupThemeBinding(), this.restoreReaderRuntimeConfig(), this.readerElement?.parentNode && this.readerElement.parentNode.removeChild(this.readerElement), this.readerElement = null, this.readerId = null, this.bridge.setReaderId(null), this.readerState.reset(), this.hostContainer = null, this.normalizedConfiguration = null, this.isReady = !1, this.removed = !0, !e)
1175
1186
  return;
1176
- const i = I(null, null);
1187
+ const i = _(null, null);
1177
1188
  this.emitReaderEvent(rt, i), this.unloadCallbacks.forEach((r) => r());
1178
- }, this.getDocumentTool = () => this.documentTool, this.getUITool = () => this.uiTool, this.getPageTool = () => this.pageTool, this.getPageArrangeTool = () => this.pageArrangeTool, this.getFindTool = () => this.findTool, this.getSignServerTool = () => this.signServerTool, this.getDigitalSignTool = () => this.digitalSignTool, this.getSymbologyTool = () => this.symbologyTool, this.getAnnotationTool = () => this.annotationTool, this.getTemplateSignTool = () => this.templateSignTool, this.getPdfFormFiller = () => this.pdfFormFiller, this.getNetworkingTool = () => this.networkingTool, this.getCryptoTool = () => this.cryptoTool, this.getSecurityTool = () => this.securityTool, this.createDigitalSignOptions = () => new De(), this.createKVField = (e, i, r) => new Ae(e, i, r), this.mountReader = async (e, i, r) => {
1189
+ }, this.getDocumentTool = () => this.documentTool, this.getUITool = () => this.uiTool, this.getPageTool = () => this.pageTool, this.getPageArrangeTool = () => this.pageArrangeTool, this.getFindTool = () => this.findTool, this.getSignServerTool = () => this.signServerTool, this.getDigitalSignTool = () => this.digitalSignTool, this.getSymbologyTool = () => this.symbologyTool, this.getAnnotationTool = () => this.annotationTool, this.getTemplateSignTool = () => this.templateSignTool, this.getPdfFormFiller = () => this.pdfFormFiller, this.getNetworkingTool = () => this.networkingTool, this.getCryptoTool = () => this.cryptoTool, this.getSecurityTool = () => this.securityTool, this.createDigitalSignOptions = () => new Ae(), this.createKVField = (e, i, r) => new De(e, i, r), this.mountReader = async (e, i, r) => {
1179
1190
  try {
1180
1191
  if (await ze(i.appUrl), this.mountToken !== r)
1181
1192
  return;
1182
- const a = document.createElement(g), s = at();
1183
- a.setAttribute(G, s), this.readerId = s, this.bridge.setReaderId(s), dt(a), this.applyReaderRuntimeConfig(a, i);
1193
+ const a = document.createElement(m), s = at();
1194
+ a.setAttribute(G, s), this.readerId = s, this.bridge.setReaderId(s), ut(a), this.applyReaderRuntimeConfig(a, i);
1184
1195
  const o = i.compactViewer === !0 && i.keepPCMenu !== !0;
1185
- if (a.toggleAttribute("data-sdk-compact-mode", o), a.setAttribute("language", i.language ?? "zh_CN"), this.themeCleanup = L(a, i.theme), this.bindNativeReaderEvents(a), e.replaceChildren(a), this.readerElement = a, await Promise.resolve(), this.mountToken !== r)
1196
+ if (a.toggleAttribute("data-sdk-compact-mode", o), a.toggleAttribute("data-sdk-ribbon-hidden", i.ribbonMenu === !1), a.toggleAttribute(
1197
+ "data-sdk-ribbon-title-hidden",
1198
+ i.ribbonTitle === !1
1199
+ ), a.setAttribute("language", i.language ?? "zh_CN"), this.themeCleanup = F(a, i.theme), this.bindNativeReaderEvents(a), e.replaceChildren(a), this.readerElement = a, await Promise.resolve(), this.mountToken !== r)
1186
1200
  return;
1187
1201
  const u = await this.bridge.waitForReady();
1188
1202
  if (this.mountToken !== r)
@@ -1190,7 +1204,7 @@ class ut {
1190
1204
  if (!u)
1191
1205
  throw new Error("Editor adapter is not available.");
1192
1206
  this.isReady = !0;
1193
- const c = I(a, i);
1207
+ const c = _(a, i);
1194
1208
  this.emitReaderEvent(it, c), this.readyCallbacks.forEach((l) => l());
1195
1209
  } catch (a) {
1196
1210
  if (this.mountToken !== r)
@@ -1234,18 +1248,19 @@ class ut {
1234
1248
  }
1235
1249
  applyReaderRuntimeConfig(n, e) {
1236
1250
  this.restoreReaderRuntimeConfig();
1237
- const i = {
1251
+ const i = st(this.sessionUser, this.sessionUserId), r = {
1238
1252
  hostKind: "server",
1239
1253
  server: {
1240
1254
  baseUrl: e.appUrl
1241
- }
1242
- }, r = n;
1243
- r[tt] = i;
1244
- const a = globalThis, s = a[S];
1255
+ },
1256
+ ...i ? { identity: i } : {}
1257
+ }, a = n;
1258
+ a[tt] = r;
1259
+ const s = globalThis, o = s[S];
1245
1260
  this.runtimeRestoreState = {
1246
- hadPreviousRuntime: s !== void 0,
1247
- ...s !== void 0 ? { previousRuntime: s } : {}
1248
- }, a[S] = i;
1261
+ hadPreviousRuntime: o !== void 0,
1262
+ ...o !== void 0 ? { previousRuntime: o } : {}
1263
+ }, s[S] = r;
1249
1264
  }
1250
1265
  restoreReaderRuntimeConfig() {
1251
1266
  if (!this.runtimeRestoreState)
@@ -1254,32 +1269,33 @@ class ut {
1254
1269
  this.runtimeRestoreState.hadPreviousRuntime ? n[S] = this.runtimeRestoreState.previousRuntime : Reflect.deleteProperty(n, S), this.runtimeRestoreState = null;
1255
1270
  }
1256
1271
  }
1257
- const bt = (t) => new ut(t);
1272
+ const kt = (t) => new lt(t);
1258
1273
  export {
1259
1274
  ne as AnnotationToolImpl,
1260
1275
  re as CryptoToolImpl,
1261
- pt as DIGITAL_SIGN_DEFAULTS,
1262
- De as DigitalSignOptions,
1276
+ St as DIGITAL_SIGN_DEFAULTS,
1277
+ Ae as DigitalSignOptions,
1263
1278
  se as DigitalSignToolImpl,
1264
- ut as DocumentSDK,
1279
+ lt as DocumentSDK,
1265
1280
  ce as DocumentToolImpl,
1266
1281
  ge as FindToolImpl,
1267
- Ae as KVField,
1282
+ De as KVField,
1268
1283
  pe as NetworkingToolImpl,
1269
1284
  ke as PageArrangeToolImpl,
1270
- fe as PageToolImpl,
1285
+ Re as PageToolImpl,
1271
1286
  ve as PdfFormFillerImpl,
1272
- we as SecurityToolImpl,
1287
+ Ie as SecurityToolImpl,
1273
1288
  _e as SignServerToolImpl,
1274
1289
  Le as SymbologyToolImpl,
1275
1290
  Ue as TemplateSignToolImpl,
1276
1291
  xe as UIToolImpl,
1277
- W as WatermarkDisplay,
1278
- bt as createNewDocumentSdk,
1279
- lt as getDigitalSignEnvironment,
1280
- ct as initializeDigitalSignEnvironment,
1281
- gt as patchDigitalSignEnvironment,
1282
- mt as resetDigitalSignEnvironment,
1283
- ht as setDigitalSignEnvironment
1292
+ Y as WatermarkDisplay,
1293
+ kt as createNewDocumentSdk,
1294
+ ct as getDigitalSignEnvironment,
1295
+ ht as getDigitalSignEnvironmentSource,
1296
+ gt as initializeDigitalSignEnvironment,
1297
+ pt as patchDigitalSignEnvironment,
1298
+ bt as resetDigitalSignEnvironment,
1299
+ mt as setDigitalSignEnvironment
1284
1300
  };
1285
1301
  //# sourceMappingURL=index.js.map