@markupai/sidebar-adapter 1.5.1 → 2.0.0

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/main.js CHANGED
@@ -10,18 +10,16 @@ var oe = /* @__PURE__ */ (function(e) {
10
10
  integrationVersion: "unknown",
11
11
  integrationId: "markupai-sidebar-app",
12
12
  hideBanner: !1,
13
- dialogClosingScript: void 0,
14
- useCheckPreviewDialog: !1,
15
13
  supportCheckSelection: !0,
16
14
  multiAgent: !1,
17
15
  multiDocument: !1
18
16
  }, ce = (e) => typeof e != "object" || e === null ? !1 : Array.isArray(e.fields), de = (e) => {
19
17
  if (typeof e != "object" || e === null) return !1;
20
18
  const t = e;
21
- return typeof t.id != "string" || t.id.length === 0 || typeof t.label != "string" ? !1 : t.type === "boolean" ? typeof t.default == "boolean" : t.type === "enum" ? typeof t.default != "string" || !Array.isArray(t.options) || t.options.length === 0 ? !1 : t.options.every((i) => {
22
- if (typeof i != "object" || i === null) return !1;
23
- const n = i;
24
- return typeof n.value == "string" && typeof n.label == "string";
19
+ return typeof t.id != "string" || t.id.length === 0 || typeof t.label != "string" ? !1 : t.type === "boolean" ? typeof t.default == "boolean" : t.type === "enum" ? typeof t.default != "string" || !Array.isArray(t.options) || t.options.length === 0 ? !1 : t.options.every((n) => {
20
+ if (typeof n != "object" || n === null) return !1;
21
+ const r = n;
22
+ return typeof r.value == "string" && typeof r.label == "string";
25
23
  }) : !1;
26
24
  }, O = class T extends Error {
27
25
  name = "TextLookupError";
@@ -34,20 +32,20 @@ function ge(e) {
34
32
  }
35
33
  var P = { TextLookupError: (e) => new O(e) };
36
34
  function U(e) {
37
- const t = e.message ?? "", i = e.name, n = typeof i == "string" && i in P ? P[i] : void 0;
38
- return n ? n(t, e) : Object.assign(new Error(t), i ? { name: i } : {});
35
+ const t = e.message ?? "", n = e.name, r = typeof n == "string" && n in P ? P[n] : void 0;
36
+ return r ? r(t, e) : Object.assign(new Error(t), n ? { name: n } : {});
39
37
  }
40
- var D = ":", x = /^[a-z][a-z0-9-]*$/;
38
+ var x = ":", D = /^[a-z][a-z0-9-]*$/;
41
39
  function pe(e) {
42
- const t = e.indexOf(D);
43
- return t <= 0 || t === e.length - 1 ? !1 : x.test(e.slice(0, t));
40
+ const t = e.indexOf(x);
41
+ return t <= 0 || t === e.length - 1 ? !1 : D.test(e.slice(0, t));
44
42
  }
45
43
  function ue(e, t) {
46
- const i = e.trim().toLowerCase(), n = t.trim();
47
- if (!x.test(i)) throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);
48
- if (n.length === 0) throw new Error("Invalid document reference: the document id is empty.");
49
- const r = `${i}${D}`;
50
- return n.startsWith(r) ? n : `${r}${n}`;
44
+ const n = e.trim().toLowerCase(), r = t.trim();
45
+ if (!D.test(n)) throw new Error(`Invalid document reference prefix ${JSON.stringify(e)}: expected a lowercase name like "word".`);
46
+ if (r.length === 0) throw new Error("Invalid document reference: the document id is empty.");
47
+ const i = `${n}${x}`;
48
+ return r.startsWith(i) ? r : `${i}${r}`;
51
49
  }
52
50
  var H = class extends Promise {
53
51
  static get [Symbol.species]() {
@@ -57,15 +55,15 @@ var H = class extends Promise {
57
55
  reject;
58
56
  constructor(e = () => {
59
57
  }) {
60
- let t, i;
61
- super((n, r) => {
62
- t = n, i = r, e(n, r);
63
- }), this.resolve = t, this.reject = i;
58
+ let t, n;
59
+ super((r, i) => {
60
+ t = r, n = i, e(r, i);
61
+ }), this.resolve = t, this.reject = n;
64
62
  }
65
63
  }, $ = { timeout: 1e4 };
66
64
  function j(e) {
67
- const t = JSON.stringify(e, Object.getOwnPropertyNames(e)), i = JSON.parse(t);
68
- return i.message === void 0 || i.message === "" ? JSON.stringify({
65
+ const t = JSON.stringify(e, Object.getOwnPropertyNames(e)), n = JSON.parse(t);
66
+ return n.message === void 0 || n.message === "" ? JSON.stringify({
69
67
  message: e instanceof Error ? e.message : String(e),
70
68
  name: e instanceof Error ? e.name : void 0
71
69
  }) : t;
@@ -91,24 +89,24 @@ var L = class {
91
89
  call(e, ...t) {
92
90
  return this.callWithOptions(e, {}, ...t);
93
91
  }
94
- callWithOptions(e, t, ...i) {
95
- const n = this.currentID++, r = new H(), a = t.timeout ?? this.config.timeout, o = setTimeout(() => {
96
- if (n in this.promisesByID) {
92
+ callWithOptions(e, t, ...n) {
93
+ const r = this.currentID++, i = new H(), a = t.timeout ?? this.config.timeout, o = setTimeout(() => {
94
+ if (r in this.promisesByID) {
97
95
  const l = /* @__PURE__ */ new Error(`IPC call timeout: "${e}" did not respond within ${String(a)}ms`);
98
- r.reject(l), Reflect.deleteProperty(this.promisesByID, n);
96
+ i.reject(l), Reflect.deleteProperty(this.promisesByID, r);
99
97
  }
100
98
  }, a);
101
- this.promisesByID[n] = {
102
- promise: r,
99
+ this.promisesByID[r] = {
100
+ promise: i,
103
101
  timeoutId: o
104
102
  };
105
103
  const s = {
106
104
  type: "call",
107
- id: n,
105
+ id: r,
108
106
  name: e,
109
- data: i
107
+ data: n
110
108
  };
111
- return this.postMessage(s), r;
109
+ return this.postMessage(s), i;
112
110
  }
113
111
  receive(e, t) {
114
112
  this.receiversByName[e] = t;
@@ -131,27 +129,27 @@ var L = class {
131
129
  }
132
130
  }
133
131
  async handleCall(e) {
134
- const { id: t, name: i, data: n } = e;
135
- if (!(i in this.receiversByName)) {
136
- const a = /* @__PURE__ */ new Error(`No receiver registered for: ${i}`), o = JSON.stringify({
132
+ const { id: t, name: n, data: r } = e;
133
+ if (!(n in this.receiversByName)) {
134
+ const a = /* @__PURE__ */ new Error(`No receiver registered for: ${n}`), o = JSON.stringify({
137
135
  message: a.message,
138
136
  name: a.name
139
137
  });
140
138
  this.postMessage({
141
139
  type: "error",
142
140
  id: t,
143
- name: i,
141
+ name: n,
144
142
  errorJSON: o
145
143
  });
146
144
  return;
147
145
  }
148
- const r = this.receiversByName[i];
146
+ const i = this.receiversByName[n];
149
147
  try {
150
- if (!Array.isArray(n)) throw new TypeError(`IPC: Expected array of arguments but got ${typeof n}`);
151
- const a = await r(...n), o = {
148
+ if (!Array.isArray(r)) throw new TypeError(`IPC: Expected array of arguments but got ${typeof r}`);
149
+ const a = await i(...r), o = {
152
150
  type: "response",
153
151
  id: t,
154
- name: i,
152
+ name: n,
155
153
  data: a
156
154
  };
157
155
  this.postMessage(o);
@@ -159,7 +157,7 @@ var L = class {
159
157
  const o = {
160
158
  type: "error",
161
159
  id: t,
162
- name: i,
160
+ name: n,
163
161
  errorJSON: j(a)
164
162
  };
165
163
  this.postMessage(o);
@@ -168,20 +166,20 @@ var L = class {
168
166
  handleResponse(e) {
169
167
  const { id: t } = e;
170
168
  if (t in this.promisesByID) {
171
- const { promise: i, timeoutId: n } = this.promisesByID[t];
172
- clearTimeout(n), i.resolve(e.data), Reflect.deleteProperty(this.promisesByID, t);
169
+ const { promise: n, timeoutId: r } = this.promisesByID[t];
170
+ clearTimeout(r), n.resolve(e.data), Reflect.deleteProperty(this.promisesByID, t);
173
171
  }
174
172
  }
175
173
  handleError(e) {
176
- const { id: t, errorJSON: i } = e;
174
+ const { id: t, errorJSON: n } = e;
177
175
  if (t in this.promisesByID) {
178
- const { promise: n, timeoutId: r } = this.promisesByID[t];
179
- clearTimeout(r);
176
+ const { promise: r, timeoutId: i } = this.promisesByID[t];
177
+ clearTimeout(i);
180
178
  try {
181
- const a = U(JSON.parse(i));
182
- n.reject(a);
179
+ const a = JSON.parse(n), o = U(a);
180
+ r.reject(o);
183
181
  } catch {
184
- n.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
182
+ r.reject(/* @__PURE__ */ new Error("Failed to parse error from IPC"));
185
183
  }
186
184
  Reflect.deleteProperty(this.promisesByID, t);
187
185
  }
@@ -195,26 +193,26 @@ var L = class {
195
193
  ipc;
196
194
  sidebar;
197
195
  targetOrigin;
198
- constructor(e, t, i = "*") {
199
- this.sidebar = e || {}, this.targetOrigin = i, this.ipc = new L((n) => {
200
- window.parent.postMessage(n, this.targetOrigin);
196
+ constructor(e, t, n = "*") {
197
+ this.sidebar = e || {}, this.targetOrigin = n, this.ipc = new L((r) => {
198
+ window.parent.postMessage(r, this.targetOrigin);
201
199
  }, t), window.addEventListener("message", this.handleMessage), this.registerReceivers();
202
200
  }
203
201
  handleMessage = (e) => {
204
- const t = globalThis.window.location.origin, i = this.targetOrigin;
205
- e.origin !== t && (i !== "*" && e.origin !== i || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
202
+ const t = globalThis.window.location.origin, n = this.targetOrigin;
203
+ e.origin !== t && (n !== "*" && e.origin !== n || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
206
204
  };
207
205
  registerReceivers() {
208
206
  if (this.sidebar.onPluginStatusChange) {
209
207
  const e = this.sidebar.onPluginStatusChange;
210
- this.ipc.receive("onPluginStatusChange", async (t, i) => {
211
- await e(t, i);
208
+ this.ipc.receive("onPluginStatusChange", async (t, n) => {
209
+ await e(t, n);
212
210
  });
213
211
  }
214
212
  if (this.sidebar.activateAgenticIssue) {
215
213
  const e = this.sidebar.activateAgenticIssue;
216
- this.ipc.receive("activateAgenticIssue", async (t, i) => {
217
- await e(t, typeof i == "string" ? i : null);
214
+ this.ipc.receive("activateAgenticIssue", async (t, n) => {
215
+ await e(t, typeof n == "string" ? n : null);
218
216
  });
219
217
  }
220
218
  if (this.sidebar.invalidateAgenticIssue) {
@@ -261,29 +259,26 @@ var L = class {
261
259
  async getSelectedContent(e) {
262
260
  return this.ipc.callWithOptions("getSelectedContent", e ?? {});
263
261
  }
264
- async replaceContent(e, t, i = null) {
265
- await this.ipc.call("replaceContent", e, t, i);
262
+ async replaceContent(e, t, n = null) {
263
+ await this.ipc.call("replaceContent", e, t, n);
266
264
  }
267
265
  async selectContent(e, t = null) {
268
266
  await this.ipc.call("selectContent", e, t);
269
267
  }
270
- async showDialog(e, t, i, n) {
271
- await this.ipc.call("showDialog", e, t, i, n);
272
- }
273
- async closeDialog() {
274
- await this.ipc.call("closeDialog");
275
- }
276
268
  async replaceMultipleContents(e) {
277
269
  await this.ipc.call("replaceMultipleContents", e);
278
270
  }
279
- async onAgenticAgentResults(e, t, i = null) {
280
- await this.ipc.call("onAgenticAgentResults", e, t, i);
271
+ async onAgenticAgentResults(e, t, n = null) {
272
+ await this.ipc.call("onAgenticAgentResults", e, t, n);
281
273
  }
282
274
  async onAgenticStreamComplete(e = null) {
283
275
  await this.ipc.call("onAgenticStreamComplete", e);
284
276
  }
285
- async onAgenticIssueStatusChanged(e, t, i) {
286
- await this.ipc.call("onAgenticIssueStatusChanged", e, t, i);
277
+ async onAgenticIssueStatusChanged(e, t, n) {
278
+ await this.ipc.call("onAgenticIssueStatusChanged", e, t, n);
279
+ }
280
+ async onAgenticIssuesCleared(e = null) {
281
+ await this.ipc.call("onAgenticIssuesCleared", e);
287
282
  }
288
283
  async openAuthUrl(e) {
289
284
  await this.ipc.call("openAuthUrl", e);
@@ -315,8 +310,8 @@ var L = class {
315
310
  }
316
311
  }, he = class {
317
312
  ipcAdapter;
318
- constructor(e, t, i) {
319
- this.ipcAdapter = new F(e, t, i);
313
+ constructor(e, t, n) {
314
+ this.ipcAdapter = new F(e, t, n);
320
315
  }
321
316
  destroy() {
322
317
  this.ipcAdapter.destroy();
@@ -330,29 +325,26 @@ var L = class {
330
325
  async getSelectedContent(e) {
331
326
  return await this.ipcAdapter.getSelectedContent(e);
332
327
  }
333
- async replaceContent(e, t, i = null) {
334
- await this.ipcAdapter.replaceContent(e, t, i);
328
+ async replaceContent(e, t, n = null) {
329
+ await this.ipcAdapter.replaceContent(e, t, n);
335
330
  }
336
331
  async selectContent(e, t = null) {
337
332
  await this.ipcAdapter.selectContent(e, t);
338
333
  }
339
- async showDialog(e, t, i, n) {
340
- await this.ipcAdapter.showDialog(e, t, i, n);
341
- }
342
- async closeDialog() {
343
- await this.ipcAdapter.closeDialog();
344
- }
345
334
  async replaceMultipleContents(e) {
346
335
  await this.ipcAdapter.replaceMultipleContents(e);
347
336
  }
348
- onAgenticAgentResults(e, t, i = null) {
349
- return this.ipcAdapter.onAgenticAgentResults(e, t, i);
337
+ onAgenticAgentResults(e, t, n = null) {
338
+ return this.ipcAdapter.onAgenticAgentResults(e, t, n);
350
339
  }
351
340
  onAgenticStreamComplete(e = null) {
352
341
  return this.ipcAdapter.onAgenticStreamComplete(e);
353
342
  }
354
- onAgenticIssueStatusChanged(e, t, i) {
355
- return this.ipcAdapter.onAgenticIssueStatusChanged(e, t, i);
343
+ onAgenticIssueStatusChanged(e, t, n) {
344
+ return this.ipcAdapter.onAgenticIssueStatusChanged(e, t, n);
345
+ }
346
+ onAgenticIssuesCleared(e = null) {
347
+ return this.ipcAdapter.onAgenticIssuesCleared(e);
356
348
  }
357
349
  openAuthUrl(e) {
358
350
  return this.ipcAdapter.openAuthUrl(e);
@@ -378,41 +370,42 @@ var L = class {
378
370
  iframe;
379
371
  window;
380
372
  targetOrigin;
381
- constructor(e, t, i, n, r = "*") {
382
- this.plugin = e, this.iframe = t, this.window = i ?? window, this.targetOrigin = r, this.ipc = new L((a) => {
373
+ constructor(e, t, n, r, i = "*") {
374
+ this.plugin = e, this.iframe = t, this.window = n ?? window, this.targetOrigin = i, this.ipc = new L((a) => {
383
375
  this.iframe.contentWindow?.postMessage(a, this.targetOrigin);
384
- }, n), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
376
+ }, r), this.window.addEventListener("message", this.handleMessage, !1), this.registerReceivers();
385
377
  }
386
378
  handleMessage = (e) => {
387
- const t = this.window.location.origin, i = this.targetOrigin;
388
- e.origin !== t && (i !== "*" && e.origin !== i || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
379
+ const t = this.window.location.origin, n = this.targetOrigin;
380
+ e.origin !== t && (n !== "*" && e.origin !== n || e.data && typeof e.data == "object" && this.ipc.handleMessage(e.data));
389
381
  };
390
382
  registerReceivers() {
391
- if (this.ipc.receive("getInitConfig", async () => await this.plugin.getInitConfig()), this.ipc.receive("getContent", async () => await this.plugin.getContent()), this.ipc.receive("getSelectedContent", async () => await this.plugin.getSelectedContent()), this.ipc.receive("replaceContent", async (e, t, i) => {
392
- await this.plugin.replaceContent(e, t, typeof i == "string" ? i : null);
383
+ if (this.ipc.receive("getInitConfig", async () => await this.plugin.getInitConfig()), this.ipc.receive("getContent", async () => await this.plugin.getContent()), this.ipc.receive("getSelectedContent", async () => await this.plugin.getSelectedContent()), this.ipc.receive("replaceContent", async (e, t, n) => {
384
+ await this.plugin.replaceContent(e, t, typeof n == "string" ? n : null);
393
385
  }), this.ipc.receive("selectContent", async (e, t) => {
394
386
  await this.plugin.selectContent(e, typeof t == "string" ? t : null);
395
- }), this.ipc.receive("showDialog", async (e, t, i, n) => {
396
- if (!this.plugin.showDialog) throw new Error("SidebarIPCAdapter: host does not implement showDialog");
397
- await this.plugin.showDialog(e, t, i, n);
398
- }), this.ipc.receive("closeDialog", async () => {
399
- if (!this.plugin.closeDialog) throw new Error("SidebarIPCAdapter: host does not implement closeDialog");
400
- await this.plugin.closeDialog();
401
387
  }), this.ipc.receive("replaceMultipleContents", async (e) => {
402
388
  await this.plugin.replaceMultipleContents(e);
403
- }), this.ipc.receive("onAgenticAgentResults", async (e, t, i) => {
389
+ }), this.ipc.receive("onAgenticAgentResults", async (e, t, n) => {
404
390
  if (!Array.isArray(t))
405
391
  return;
406
- const n = this.plugin.onAgenticAgentResults;
407
- n && await n(e, t, typeof i == "string" ? i : null);
392
+ const r = this.plugin.onAgenticAgentResults;
393
+ r && await r(e, t, typeof n == "string" ? n : null);
408
394
  }), this.ipc.receive("onAgenticStreamComplete", async (e) => {
409
395
  const t = this.plugin.onAgenticStreamComplete;
410
396
  t && await t(typeof e == "string" ? e : null);
411
- }), this.ipc.receive("onAgenticIssueStatusChanged", async (e, t, i) => {
412
- const n = this.plugin.onAgenticIssueStatusChanged;
413
- if (n && !(t !== "active" && t !== "resolved" && t !== "dismissed" || i !== "user" && i !== "host"))
397
+ }), this.ipc.receive("onAgenticIssueStatusChanged", async (e, t, n) => {
398
+ const r = this.plugin.onAgenticIssueStatusChanged;
399
+ if (r && !(t !== "active" && t !== "resolved" && t !== "dismissed" || n !== "user" && n !== "host"))
400
+ try {
401
+ await r(e, t, n);
402
+ } catch {
403
+ }
404
+ }), this.ipc.receive("onAgenticIssuesCleared", async (e) => {
405
+ const t = this.plugin.onAgenticIssuesCleared;
406
+ if (t)
414
407
  try {
415
- await n(e, t, i);
408
+ await t(typeof e == "string" ? e : null);
416
409
  } catch {
417
410
  }
418
411
  }), this.plugin.openAuthUrl) {
@@ -429,8 +422,8 @@ var L = class {
429
422
  }
430
423
  if (this.plugin.onIntegrationSettingsChange) {
431
424
  const e = this.plugin.onIntegrationSettingsChange;
432
- this.ipc.receive("onIntegrationSettingsChange", async (t, i) => {
433
- await e(t, i);
425
+ this.ipc.receive("onIntegrationSettingsChange", async (t, n) => {
426
+ await e(t, n);
434
427
  });
435
428
  }
436
429
  }
@@ -466,8 +459,8 @@ var L = class {
466
459
  }
467
460
  }, W = class {
468
461
  ipcAdapter;
469
- constructor(e, t, i) {
470
- this.ipcAdapter = new z(e, t, i?.win, i?.config, i?.targetOrigin);
462
+ constructor(e, t, n) {
463
+ this.ipcAdapter = new z(e, t, n?.win, n?.config, n?.targetOrigin);
471
464
  }
472
465
  destroy() {
473
466
  this.ipcAdapter.destroy();
@@ -624,18 +617,18 @@ var L = class {
624
617
  `, V = (e) => {
625
618
  const t = e ?? document;
626
619
  if (t.getElementById(E)) return;
627
- const i = t.createElement("style");
628
- i.id = E, i.textContent = Y, t.head.appendChild(i);
629
- }, X = 8e3, K = 12e3, q = (e, t, i = {}) => {
620
+ const n = t.createElement("style");
621
+ n.id = E, n.textContent = Y, t.head.appendChild(n);
622
+ }, X = 8e3, K = 12e3, q = (e, t, n = {}) => {
630
623
  V(e.ownerDocument);
631
- const { sidebarUrl: n, targetOrigin: r, timeoutMs: a = X, retryIntervalMs: o = K, messageListenWindow: s } = i, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => n ?? t.src, N = () => {
632
- if (r) return r;
624
+ const { sidebarUrl: r, targetOrigin: i, timeoutMs: a = X, retryIntervalMs: o = K, messageListenWindow: s } = n, l = s ?? (typeof globalThis.window < "u" ? globalThis.window : globalThis), p = () => r ?? t.src, N = () => {
625
+ if (i) return i;
633
626
  try {
634
627
  return new URL(p()).origin;
635
628
  } catch {
636
629
  return "*";
637
630
  }
638
- }, { overlay: y, button: v } = J();
631
+ }, { overlay: y, button: I } = J();
639
632
  e.appendChild(y);
640
633
  let u = !1, h, d;
641
634
  const g = (c) => {
@@ -644,13 +637,13 @@ var L = class {
644
637
  g(!1);
645
638
  const f = () => {
646
639
  h && (globalThis.clearTimeout(h), h = void 0);
647
- }, I = () => {
640
+ }, v = () => {
648
641
  f(), h = globalThis.setTimeout(() => {
649
642
  u || g(!0);
650
643
  }, a);
651
644
  }, A = (c) => {
652
645
  const m = c?.preserveOverlay ?? !0;
653
- u = !1, m || g(!1), t.src = p(), I();
646
+ u = !1, m || g(!1), t.src = p(), v();
654
647
  }, B = () => {
655
648
  d || o <= 0 || (d = globalThis.setInterval(() => {
656
649
  u || A({ preserveOverlay: !0 });
@@ -661,13 +654,13 @@ var L = class {
661
654
  if (!t.contentWindow || c.source !== t.contentWindow) return;
662
655
  const m = N();
663
656
  m !== "*" && c.origin !== m || (u = !0, f(), C(), g(!1));
664
- }, w = () => {
665
- f(), g(!0);
666
657
  }, S = () => {
658
+ f(), g(!0);
659
+ }, w = () => {
667
660
  A();
668
661
  };
669
- return v.addEventListener("click", S), t.addEventListener("error", w), l.addEventListener("message", b), I(), B(), () => {
670
- f(), C(), t.removeEventListener("error", w), l.removeEventListener("message", b), v.removeEventListener("click", S), y.remove();
662
+ return I.addEventListener("click", w), t.addEventListener("error", S), l.addEventListener("message", b), v(), B(), () => {
663
+ f(), C(), t.removeEventListener("error", S), l.removeEventListener("message", b), I.removeEventListener("click", w), y.remove();
671
664
  };
672
665
  }, Z = "Markup AI Sidebar", Q = "clipboard-read; clipboard-write", fe = "markupai.sidebarNextGen.overrideUrl", me = "https://sidebar.markup.ai/";
673
666
  function ye(e) {
@@ -678,38 +671,38 @@ function ye(e) {
678
671
  }
679
672
  }
680
673
  var ee = "markupai.sidebarNextGen.authOverride";
681
- function ve(e, t) {
674
+ function Ie(e, t) {
682
675
  if (!t) return e;
683
676
  try {
684
677
  if (!("localStorage" in globalThis)) return e;
685
- const i = globalThis.localStorage.getItem(ee)?.trim();
686
- if (!i) return e;
687
- const n = JSON.parse(i);
688
- return n !== null && typeof n == "object" && "type" in n && (n.type === "mediation" || n.type === "popup") ? n : e;
678
+ const n = globalThis.localStorage.getItem(ee)?.trim();
679
+ if (!n) return e;
680
+ const r = JSON.parse(n);
681
+ return r !== null && typeof r == "object" && "type" in r && (r.type === "mediation" || r.type === "popup") ? r : e;
689
682
  } catch {
690
683
  return e;
691
684
  }
692
685
  }
693
- function Ie(e, t) {
686
+ function ve(e, t) {
694
687
  try {
695
688
  return new URL(e).origin;
696
- } catch (i) {
697
- return t?.onInvalidUrl?.(e, i), "*";
689
+ } catch (n) {
690
+ return t?.onInvalidUrl?.(e, n), "*";
698
691
  }
699
692
  }
700
693
  function Ae(e, t = "Expected SidebarAdapter from createSidebarHost") {
701
694
  if (e.adapter === null) throw new Error(t);
702
695
  }
703
696
  function te(e) {
704
- const { iframe: t, iframeMount: i } = e;
705
- if (t !== void 0 && i !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
697
+ const { iframe: t, iframeMount: n } = e;
698
+ if (t !== void 0 && n !== void 0) throw new Error("createSidebarHost: pass only one of `iframe` or `iframeMount`");
706
699
  if (t !== void 0) return {
707
700
  iframe: t,
708
701
  removeMountedIframe: null
709
702
  };
710
- if (i === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
711
- const { container: n, src: r, allow: a = Q } = i, o = document.createElement("iframe");
712
- return o.title = Z, o.src = r, a && o.setAttribute("allow", a), n.appendChild(o), {
703
+ if (n === void 0) throw new Error("createSidebarHost: pass either `iframe` or `iframeMount`");
704
+ const { container: r, src: i, allow: a = Q } = n, o = document.createElement("iframe");
705
+ return o.title = Z, o.src = i, a && o.setAttribute("allow", a), r.appendChild(o), {
713
706
  iframe: o,
714
707
  removeMountedIframe: () => {
715
708
  o.remove();
@@ -717,9 +710,9 @@ function te(e) {
717
710
  };
718
711
  }
719
712
  function Ce(e) {
720
- const { plugin: t, loadOverlayContainer: i, loadOverlayOptions: n, adapterOptions: r } = e, { iframe: a, removeMountedIframe: o } = te(e), s = i !== void 0 ? q(i, a, n ?? {}) : null;
713
+ const { plugin: t, loadOverlayContainer: n, loadOverlayOptions: r, adapterOptions: i } = e, { iframe: a, removeMountedIframe: o } = te(e), s = n !== void 0 ? q(n, a, r ?? {}) : null;
721
714
  if (t !== void 0) {
722
- const l = new W(t, a, r);
715
+ const l = new W(t, a, i);
723
716
  return {
724
717
  iframe: a,
725
718
  adapter: l,
@@ -769,33 +762,33 @@ body {
769
762
  `.trim();
770
763
  }
771
764
  var be = k();
772
- function ie(e) {
765
+ function ne(e) {
773
766
  return e instanceof Document ? e : e.ownerDocument;
774
767
  }
775
- function ne(e, t, i) {
768
+ function re(e, t, n) {
776
769
  if (!t || e.getElementById(R)) return;
777
- const n = e.createElement("style");
778
- n.id = R, n.textContent = k(i), e.head.appendChild(n);
770
+ const r = e.createElement("style");
771
+ r.id = R, r.textContent = k(n), e.head.appendChild(r);
779
772
  }
780
- function we(e) {
781
- const { root: t = typeof document < "u" ? document : void 0, containerId: i = M, includeDefaultStyles: n = !0 } = e ?? {};
773
+ function Se(e) {
774
+ const { root: t = typeof document < "u" ? document : void 0, containerId: n = M, includeDefaultStyles: r = !0 } = e ?? {};
782
775
  if (t === void 0) throw new Error("ensureSidebarHostShell: no document — pass `root` in non-browser environments");
783
- const r = ie(t);
784
- ne(r, n, i);
785
- const a = t instanceof Document ? r.getElementById(i) : t.querySelector(`#${_(i)}`);
776
+ const i = ne(t);
777
+ re(i, r, n);
778
+ const a = t instanceof Document ? i.getElementById(n) : t.querySelector(`#${_(n)}`);
786
779
  if (a instanceof HTMLElement && (t instanceof Document || t.contains(a))) return a;
787
780
  if (!(t instanceof Document)) {
788
- const s = r.createElement("div");
789
- return s.id = i, t.appendChild(s), s;
781
+ const s = i.createElement("div");
782
+ return s.id = n, t.appendChild(s), s;
790
783
  }
791
- const o = r.createElement("div");
792
- return o.id = i, r.body.appendChild(o), o;
784
+ const o = i.createElement("div");
785
+ return o.id = n, i.body.appendChild(o), o;
793
786
  }
794
- function re() {
787
+ function ie() {
795
788
  return ' <meta name="viewport" content="width=device-width, initial-scale=1.0" />';
796
789
  }
797
- function Se(e) {
798
- const { title: t = "Markup AI Sidebar", headInnerHtml: i = "", includePluginHostHead: n = !1, bodyScriptsHtml: r, htmlLang: a = "en", htmlAttrs: o = `lang="${a}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [n ? re() : "", i].filter((p) => p.trim().length > 0).join(`
790
+ function we(e) {
791
+ const { title: t = "Markup AI Sidebar", headInnerHtml: n = "", includePluginHostHead: r = !1, bodyScriptsHtml: i, htmlLang: a = "en", htmlAttrs: o = `lang="${a}" style="height:100%"`, bodyAttrs: s = 'style="height:100%;margin:0"' } = e, l = [r ? ie() : "", n].filter((p) => p.trim().length > 0).join(`
799
792
  `);
800
793
  return `<!DOCTYPE html>
801
794
  <html ${o}>
@@ -806,7 +799,7 @@ function Se(e) {
806
799
  ${l}` : ""}
807
800
  </head>
808
801
  <body ${s}>
809
- ${r}
802
+ ${i}
810
803
  </body>
811
804
  </html>
812
805
  `;
@@ -835,12 +828,12 @@ export {
835
828
  O as TextLookupError,
836
829
  Ae as assertSidebarHostAdapter,
837
830
  ue as buildDocumentReference,
838
- Se as buildSidebarHostHtmlDocument,
831
+ we as buildSidebarHostHtmlDocument,
839
832
  k as buildSidebarHostShellCss,
840
- re as buildSidebarPluginHostHeadInnerHtml,
833
+ ie as buildSidebarPluginHostHeadInnerHtml,
841
834
  Ce as createSidebarHost,
842
- we as ensureSidebarHostShell,
843
- ve as getAuthConfigWithOverride,
835
+ Se as ensureSidebarHostShell,
836
+ Ie as getAuthConfigWithOverride,
844
837
  ye as getSidebarBaseUrlWithOverride,
845
838
  P as ipcErrorReconstructors,
846
839
  pe as isDocumentReference,
@@ -849,5 +842,5 @@ export {
849
842
  ge as isTextLookupError,
850
843
  U as reconstructError,
851
844
  q as setupSidebarLoadOverlay,
852
- Ie as sidebarPostMessageTargetOrigin
845
+ ve as sidebarPostMessageTargetOrigin
853
846
  };