@alan-ai/alan-sdk-web 1.8.125 → 1.8.127

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/alan_lib.js CHANGED
@@ -374,16 +374,36 @@
374
374
  function isProjectIdValid(projectId) {
375
375
  return projectId.match(/^[A-Z0-9]{64}\/(prod|stage|testing)$/gi);
376
376
  }
377
+
378
+ function parseHostWithQueryString(host) {
379
+ var baseURL = config.baseURL;
380
+ var queryString = '';
381
+
382
+ if (host) {
383
+ var qIndex = host.indexOf('?');
384
+ if (qIndex >= 0) {
385
+ queryString = host.substring(qIndex);
386
+ baseURL = "wss://" + host.substring(0, qIndex);
387
+ } else {
388
+ baseURL = "wss://" + host;
389
+ }
390
+ } else if (config.baseURL.indexOf('?') >= 0) {
391
+ var qIndex = config.baseURL.indexOf('?');
392
+ queryString = config.baseURL.substring(qIndex);
393
+ baseURL = config.baseURL.substring(0, qIndex);
394
+ }
395
+
396
+ return { baseURL: baseURL, queryString: queryString };
397
+ }
377
398
 
378
399
  function connectProject(projectId, auth, host, mode, ext) {
379
400
  var connect = new ConnectionWrapper();
380
- if (host) {
381
- config.baseURL = "wss://" + host;
382
- }
401
+ var parsed = parseHostWithQueryString(host);
402
+
383
403
  connect._config.projectId = projectId;
384
404
  connect._config.codec = config.codec;
385
405
  connect._config.version = config.version;
386
- connect._config.url = config.baseURL + "/ws_project/" + projectId;
406
+ connect._config.url = parsed.baseURL + "/ws_project/" + projectId + parsed.queryString;
387
407
 
388
408
  if (!isProjectIdValid(projectId)) {
389
409
  throw new Error("Wrong projectId was provided: ", projectId);
@@ -422,13 +442,12 @@
422
442
 
423
443
  function connectProjectTest(projectId, auth, host, mode, ext) {
424
444
  var connect = new ConnectionWrapper();
425
- if (host) {
426
- config.baseURL = "wss://" + host;
427
- }
445
+ var parsed = parseHostWithQueryString(host);
446
+
428
447
  connect._config.projectId = projectId;
429
448
  connect._config.codec = config.codec;
430
449
  connect._config.version = config.version;
431
- connect._config.url = config.baseURL + "/ws_project/" + projectId;
450
+ connect._config.url = parsed.baseURL + "/ws_project/" + projectId + parsed.queryString;
432
451
 
433
452
  if (!isProjectIdValid(projectId)) {
434
453
  throw new Error("Wrong projectId was provided");
@@ -97644,15 +97663,37 @@
97644
97663
  `;
97645
97664
  const inlinedHtml = juice.inlineContent(rawHtml, css3);
97646
97665
  const blobHtml = new Blob([inlinedHtml], { type: "text/html" });
97647
- const blobText = new Blob([bubbleToCopy.innerText], { type: "text/plain" });
97666
+ const plainText = bubbleToCopy.innerText.replace(/[ \t]+/g, " ").replace(/\n{3,}/g, "\n\n").trim();
97667
+ const blobText = new Blob([plainText], { type: "text/plain" });
97648
97668
  const data4 = [new ClipboardItem({
97649
97669
  "text/html": blobHtml,
97650
97670
  "text/plain": blobText
97651
97671
  })];
97652
- try {
97653
- await navigator.clipboard.write(data4);
97654
- } catch (err) {
97655
- console.error("Failed to copy: ", err);
97672
+ if (navigator.clipboard && navigator.clipboard.write) {
97673
+ try {
97674
+ await navigator.clipboard.write(data4);
97675
+ } catch (err) {
97676
+ console.error("Failed to copy rich text: ", err);
97677
+ if (navigator.clipboard.writeText) {
97678
+ try {
97679
+ await navigator.clipboard.writeText(plainText);
97680
+ } catch (err2) {
97681
+ console.error("Failed to copy plain text: ", err2);
97682
+ copyTextToBuffer(plainText);
97683
+ }
97684
+ } else {
97685
+ copyTextToBuffer(plainText);
97686
+ }
97687
+ }
97688
+ } else if (navigator.clipboard && navigator.clipboard.writeText) {
97689
+ try {
97690
+ await navigator.clipboard.writeText(plainText);
97691
+ } catch (err) {
97692
+ console.error("Failed to copy plain text: ", err);
97693
+ copyTextToBuffer(plainText);
97694
+ }
97695
+ } else {
97696
+ copyTextToBuffer(plainText);
97656
97697
  }
97657
97698
  }
97658
97699
 
@@ -102316,19 +102357,21 @@ code.hljs {
102316
102357
  }
102317
102358
  return pathSegments.join(" > ");
102318
102359
  }
102319
- function collectScrollableElementStates() {
102320
- if (typeof document === "undefined") {
102360
+ function collectScrollableElementStates(doc2 = document) {
102361
+ if (typeof doc2 === "undefined") {
102321
102362
  return [];
102322
102363
  }
102364
+ const win = doc2.defaultView || window;
102365
+ const HTMLElementClass = win.HTMLElement;
102323
102366
  const elements = /* @__PURE__ */ new Set();
102324
- document.querySelectorAll("*").forEach((el) => elements.add(el));
102325
- if (document.body) elements.add(document.body);
102326
- if (document.documentElement) elements.add(document.documentElement);
102327
- if (document.scrollingElement) elements.add(document.scrollingElement);
102367
+ doc2.querySelectorAll("*").forEach((el) => elements.add(el));
102368
+ if (doc2.body) elements.add(doc2.body);
102369
+ if (doc2.documentElement) elements.add(doc2.documentElement);
102370
+ if (doc2.scrollingElement) elements.add(doc2.scrollingElement);
102328
102371
  const scrollableStates = [];
102329
102372
  const overflowRegex = /(auto|scroll|overlay)/i;
102330
102373
  elements.forEach((element) => {
102331
- if (!(element instanceof HTMLElement)) {
102374
+ if (!(element instanceof HTMLElementClass)) {
102332
102375
  return;
102333
102376
  }
102334
102377
  const scrollHeight = element.scrollHeight;
@@ -102338,10 +102381,10 @@ code.hljs {
102338
102381
  if (clientHeight === 0 && clientWidth === 0) {
102339
102382
  return;
102340
102383
  }
102341
- const computedStyle = window.getComputedStyle(element);
102384
+ const computedStyle = win.getComputedStyle(element);
102342
102385
  const overflowY = computedStyle.overflowY;
102343
102386
  const overflowX = computedStyle.overflowX;
102344
- const isRootElement = element === document.body || element === document.documentElement || element === document.scrollingElement;
102387
+ const isRootElement = element === doc2.body || element === doc2.documentElement || element === doc2.scrollingElement;
102345
102388
  const canScrollVertically = scrollHeight - clientHeight > 1;
102346
102389
  const canScrollHorizontally = scrollWidth - clientWidth > 1;
102347
102390
  const allowsVerticalScroll = isRootElement || overflowRegex.test(overflowY);
@@ -102357,17 +102400,41 @@ code.hljs {
102357
102400
  });
102358
102401
  return scrollableStates;
102359
102402
  }
102403
+ var CROSS_ORIGIN_IFRAME_CLASS = "alan-iframe-cross-origin";
102360
102404
  async function collectIframeContent() {
102361
102405
  const iframes = Array.from(document.querySelectorAll("iframe"));
102362
102406
  if (iframes.length === 0) {
102363
102407
  return [];
102364
102408
  }
102409
+ iframes.forEach((iframe, index3) => {
102410
+ if (!iframe.id) {
102411
+ iframe.id = `alan-iframe-${index3}`;
102412
+ }
102413
+ });
102414
+ const directResults = [];
102415
+ const crossOriginIframes = [];
102416
+ for (const iframe of iframes) {
102417
+ try {
102418
+ const doc2 = iframe.contentDocument;
102419
+ if (doc2 && doc2.documentElement) {
102420
+ const clone3 = doc2.documentElement.cloneNode(true);
102421
+ clone3.querySelectorAll("script").forEach((s) => s.remove());
102422
+ directResults.push({ id: iframe.id, html: clone3.outerHTML });
102423
+ } else {
102424
+ iframe.classList.add(CROSS_ORIGIN_IFRAME_CLASS);
102425
+ crossOriginIframes.push(iframe);
102426
+ }
102427
+ } catch (e) {
102428
+ iframe.classList.add(CROSS_ORIGIN_IFRAME_CLASS);
102429
+ crossOriginIframes.push(iframe);
102430
+ }
102431
+ }
102432
+ if (crossOriginIframes.length === 0) {
102433
+ return directResults;
102434
+ }
102365
102435
  return new Promise((resolve) => {
102366
102436
  const responses = /* @__PURE__ */ new Map();
102367
- const expectedIds = /* @__PURE__ */ new Set();
102368
- iframes.forEach((iframe, index3) => {
102369
- expectedIds.add(iframe.id);
102370
- });
102437
+ const expectedIds = new Set(crossOriginIframes.map((iframe) => iframe.id));
102371
102438
  const messageHandler = (event) => {
102372
102439
  if (event.data && event.data.source === "alan-chat-iframe" && event.data.type === "alan-iframe-content-response") {
102373
102440
  const { iframeId, html: html5 } = event.data;
@@ -102375,14 +102442,16 @@ code.hljs {
102375
102442
  responses.set(iframeId, html5);
102376
102443
  if (responses.size === expectedIds.size) {
102377
102444
  window.removeEventListener("message", messageHandler);
102378
- const result = Array.from(responses.entries()).map(([id, html6]) => ({ id, html: html6 }));
102379
- resolve(result);
102445
+ resolve([
102446
+ ...directResults,
102447
+ ...Array.from(responses.entries()).map(([id, html6]) => ({ id, html: html6, crossOrigin: true }))
102448
+ ]);
102380
102449
  }
102381
102450
  }
102382
102451
  }
102383
102452
  };
102384
102453
  window.addEventListener("message", messageHandler);
102385
- iframes.forEach((iframe) => {
102454
+ crossOriginIframes.forEach((iframe) => {
102386
102455
  try {
102387
102456
  if (iframe.contentWindow) {
102388
102457
  iframe.contentWindow.postMessage({
@@ -102397,23 +102466,32 @@ code.hljs {
102397
102466
  });
102398
102467
  setTimeout(() => {
102399
102468
  window.removeEventListener("message", messageHandler);
102400
- const result = Array.from(expectedIds).map((id) => ({
102401
- id,
102402
- html: responses.get(id) || ""
102403
- }));
102404
- resolve(result);
102469
+ resolve([
102470
+ ...directResults,
102471
+ ...Array.from(expectedIds).map((id) => ({
102472
+ id,
102473
+ html: responses.get(id) || "",
102474
+ crossOrigin: true
102475
+ }))
102476
+ ]);
102405
102477
  }, IFRAME_CONTENT_TIMEOUT_MS);
102406
102478
  });
102407
102479
  }
102408
102480
  function replaceIframesWithSrcDoc(page, iframeContents, visibilityMap) {
102409
- const contentMap = new Map(iframeContents.map((item) => [item.id, item.html]));
102410
- const iframes = page.querySelectorAll("iframe.act-embed");
102481
+ const contentMap = new Map(iframeContents.map((item) => [item.id, item]));
102482
+ const iframes = page.querySelectorAll("iframe");
102411
102483
  iframes.forEach((iframe) => {
102412
102484
  const iframeId = iframe.id;
102413
- const html5 = contentMap.get(iframeId);
102414
- if (html5 && visibilityMap.get(iframeId)) {
102485
+ const entry = contentMap.get(iframeId);
102486
+ if (!entry) {
102487
+ return;
102488
+ }
102489
+ if (entry.crossOrigin) {
102490
+ iframe.classList.add(CROSS_ORIGIN_IFRAME_CLASS);
102491
+ }
102492
+ if (entry.html && visibilityMap.get(iframeId)) {
102415
102493
  iframe.removeAttribute("src");
102416
- iframe.setAttribute("srcdoc", html5);
102494
+ iframe.setAttribute("srcdoc", entry.html);
102417
102495
  }
102418
102496
  });
102419
102497
  }
@@ -102424,6 +102502,14 @@ code.hljs {
102424
102502
  if (rect.bottom <= 0 || rect.top >= viewportHeight || rect.right <= 0 || rect.left >= viewportWidth) {
102425
102503
  return false;
102426
102504
  }
102505
+ let node = element;
102506
+ while (node) {
102507
+ const style = window.getComputedStyle(node);
102508
+ if (style.display === "none" || style.visibility === "hidden" || style.opacity === "0") {
102509
+ return false;
102510
+ }
102511
+ node = node.parentElement;
102512
+ }
102427
102513
  let parent3 = element.parentElement;
102428
102514
  while (parent3) {
102429
102515
  const style = window.getComputedStyle(parent3);
@@ -102520,6 +102606,7 @@ code.hljs {
102520
102606
  if (!document.getElementsByTagName("html")[0]) {
102521
102607
  throw new Error("HTML document not available");
102522
102608
  }
102609
+ const iframeContents = await collectIframeContent();
102523
102610
  const page = document.createElement("html");
102524
102611
  page.innerHTML = document.getElementsByTagName("html")[0].innerHTML;
102525
102612
  const scripts = page.getElementsByTagName("script");
@@ -102530,7 +102617,6 @@ code.hljs {
102530
102617
  }
102531
102618
  }
102532
102619
  const pageContent = page.outerHTML;
102533
- const iframeContents = await collectIframeContent();
102534
102620
  const liveIframes = Array.from(document.querySelectorAll("iframe"));
102535
102621
  const visibilityMap = /* @__PURE__ */ new Map();
102536
102622
  liveIframes.forEach((iframe) => {
@@ -102552,6 +102638,10 @@ code.hljs {
102552
102638
  if (!window.tutorProject) {
102553
102639
  return;
102554
102640
  }
102641
+ const animatedElements = page.querySelectorAll(".alan-btn__chat-response.animated, .alan-btn__chat-request.animated");
102642
+ animatedElements.forEach((el) => {
102643
+ el.classList.remove("animated");
102644
+ });
102555
102645
  const params = {
102556
102646
  html: page.outerHTML,
102557
102647
  url: window.location.href,
@@ -102569,11 +102659,29 @@ code.hljs {
102569
102659
  return;
102570
102660
  }
102571
102661
  if (uiState10.pageState?.screenshot?.enabled) {
102662
+ const iframeScrollStates = [];
102663
+ for (const iframe of liveIframes) {
102664
+ if (!visibilityMap.get(iframe.id)) continue;
102665
+ try {
102666
+ const iframeDoc = iframe.contentDocument;
102667
+ if (iframeDoc) {
102668
+ const states = collectScrollableElementStates(iframeDoc);
102669
+ states.forEach((s) => iframeScrollStates.push({
102670
+ ...s,
102671
+ path: `#${iframe.id} >> ${s.path}`
102672
+ }));
102673
+ }
102674
+ } catch (e) {
102675
+ }
102676
+ }
102572
102677
  params.screenshot_data = {
102573
102678
  baseHref: document.baseURI,
102574
102679
  width: window.innerWidth,
102575
102680
  height: window.innerHeight,
102576
- scrollStates: collectScrollableElementStates()
102681
+ scrollStates: [
102682
+ ...collectScrollableElementStates(),
102683
+ ...iframeScrollStates
102684
+ ]
102577
102685
  };
102578
102686
  }
102579
102687
  window.tutorProject.call("syncPageState", params);
@@ -109338,7 +109446,7 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
109338
109446
  return match ? match[0] : null;
109339
109447
  }
109340
109448
  function extractFunction(code2, functionName) {
109341
- const ast = parse11(code2, { ecmaVersion: 2020 });
109449
+ const ast = parse11(code2, { ecmaVersion: 2022 });
109342
109450
  for (const node of ast.body) {
109343
109451
  if (node.type === "FunctionDeclaration" && node.id.name === functionName) {
109344
109452
  return generate2(node);
@@ -109508,7 +109616,7 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
109508
109616
  let controlsDiv = document.createElement("div");
109509
109617
  controlsDiv.classList.add("alan-iframe-controls");
109510
109618
  let hiddenIframe = document.createElement("iframe");
109511
- hiddenIframe.srcdoc = `<!--${initHtmlContent}-->`;
109619
+ hiddenIframe.srcdoc = `<!--${htmlContent2}-->`;
109512
109620
  hiddenIframe.setAttribute("style", "display: none;");
109513
109621
  hiddenIframe.setAttribute("sandbox", "allow-scripts allow-same-origin allow-popups allow-downloads");
109514
109622
  controlsDiv.appendChild(hiddenIframe);
@@ -109525,6 +109633,54 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
109525
109633
  }
109526
109634
  } catch (error) {
109527
109635
  console.error(`Failed to fetch or process iframe from ${srcUrl}:`, error);
109636
+ const errorMessage = error?.message || error?.toString() || "Unknown error";
109637
+ const errorHtml = `
109638
+ <!DOCTYPE html>
109639
+ <html>
109640
+ <head>
109641
+ <meta charset="UTF-8">
109642
+ <style>
109643
+ body {
109644
+ font-family: Arial, sans-serif;
109645
+ padding: 20px;
109646
+ background-color: #fff3cd;
109647
+ color: #856404;
109648
+ margin: 0;
109649
+ }
109650
+ .error-container {
109651
+ border: 1px solid #ffc107;
109652
+ border-radius: 4px;
109653
+ padding: 15px;
109654
+ background-color: #fff;
109655
+ }
109656
+ .error-title {
109657
+ font-weight: bold;
109658
+ margin-bottom: 10px;
109659
+ font-size: 16px;
109660
+ }
109661
+ .error-details {
109662
+ font-size: 14px;
109663
+ word-break: break-word;
109664
+ }
109665
+ .error-url {
109666
+ margin-top: 10px;
109667
+ font-size: 12px;
109668
+ color: #666;
109669
+ }
109670
+ </style>
109671
+ </head>
109672
+ <body>
109673
+ <div class="error-container">
109674
+ <div class="error-title">\u26A0\uFE0F Failed to collect iframe content</div>
109675
+ <div class="error-details">${errorMessage.replace(/</g, "&lt;").replace(/>/g, "&gt;")}</div>
109676
+ <div class="error-url">Source: ${srcUrl}</div>
109677
+ </div>
109678
+ </body>
109679
+ </html>
109680
+ `;
109681
+ iframe.removeAttribute("src");
109682
+ iframe.setAttribute("srcdoc", errorHtml);
109683
+ iframe.setAttribute("sandbox", "allow-scripts allow-same-origin");
109528
109684
  }
109529
109685
  }));
109530
109686
  const iframeResizerCode = 'const v=()=>typeof window<"u",C=()=>{try{return window.self!==window.top}catch{return!0}},w=e=>e instanceof HTMLIFrameElement,z=e=>{"complete"===window.document.readyState?e():window.addEventListener("load",e,{once:!0})},B=(e,t)=>{t(),e.addEventListener("load",t,{once:!0})},k=(e,t)=>{const n="complete"===e.contentWindow?.document.readyState;return"about:blank"!==e.src&&"about:blank"!==e.contentWindow?.location.href&&n?t():e.addEventListener("load",t,{once:!0})},W=()=>({offsetSize:0,checkOrigin:!0,enableLegacyLibSupport:!1});async function A(e){try{return"about:blank"===e.contentDocument?.URL?new Promise((t=>{e.addEventListener("load",(()=>t(null!==e.contentDocument)),{once:!0})})):null!==e.contentDocument}catch{return!1}}const P=e=>{try{const t=new URL(e.src).origin;if("about:blank"!==t)return t}catch{}return null},H=e=>(Object.keys(e).forEach((t=>{void 0===e[t]&&delete e[t]})),e),I=e=>{const{height:t,width:n}=e.getBoundingClientRect();return{height:Math.ceil(t),width:Math.ceil(n)}},l=(e,t)=>e?t?e.querySelector(t):e.documentElement:null,O=(e,t)=>{e&&(t.bodyPadding&&(e.body.style.padding=t.bodyPadding),t.bodyMargin&&(e.body.style.margin=t.bodyMargin))},b=e=>e<=100?100:e<=120?1e3:1e4,x=()=>"[iFrameSizer]ID:0:false:false:32:true:true::auto:::0:false:child:auto:true:::true:::false";function F(e){if("string"!=typeof e.data||!e.data.startsWith("[iFrameSizer]")||!e.data.endsWith("mutationObserver")&&!e.data.endsWith("resizeObserver"))return null;const[t,n]=e.data.split(":"),i=+n;return i>0?i:null}const p=V();let m=[];const Z=async(e,t)=>{if(!v())return[];const n={...W(),...H(e??{})},i=N(t),r=U(n,i);return Promise.all(i.map((async e=>{const t={iframe:e,settings:n,interactionState:{isHovered:!1},initContext:{isInitialized:!1,retryAttempts:0}},{unsubscribe:i,resize:o}=await $(t,r);return m.push(t),{unsubscribe:()=>{i(),m=m.filter((t=>t.iframe!==e))},resize:o}})))};function N(e){return"string"==typeof e?Array.from(document.querySelectorAll(e)).filter(w):e?w(e)?[e]:[]:Array.from(document.getElementsByTagName("iframe"))}function U(e,t){if(Array.isArray(e.checkOrigin))return e.checkOrigin;if(!e.checkOrigin)return[];const n=[];for(const e of t){const t=P(e);t&&n.push(t)}return n}async function $(e,t){const n=await A(e.iframe),{unsubscribe:i,resize:r}=n?_(e):q(e,t),o=G(e);return{unsubscribe:()=>{i(),o()},resize:r}}function q(e,t){const{iframe:n,initContext:i,settings:{checkOrigin:r,enableLegacyLibSupport:o,targetElementSelector:s,bodyPadding:a,bodyMargin:c}}=e,d=i=>{const s="null"===i.origin,a=!r||s||t.includes(i.origin);if(n.contentWindow===i.source&&a){if("iframe-resized"===i.data?.type){const{height:t}=i.data;return void(t&&g({newHeight:t,registeredElement:e}))}if(o){const t=F(i);return void(null!==t&&g({newHeight:t,registeredElement:e}))}}};window.addEventListener("message",d);const u=o?x():{type:"iframe-child-init",targetElementSelector:s,bodyPadding:a,bodyMargin:c},l=()=>{B(n,(()=>n.contentWindow?.postMessage(u,"*"))),i.retryAttempts++,i.retryTimeoutId=window.setTimeout(l,b(i.retryAttempts))};return l(),{unsubscribe:()=>window.removeEventListener("message",d),resize:()=>{n.contentWindow?.postMessage({type:"iframe-get-child-dimensions"},"*")}}}function _(e){const{iframe:t,settings:n}=e,{targetElementSelector:i}=n;let r=0;const o=()=>{const e=l(t.contentDocument,i);if(!t.contentDocument||!e)return r++,setTimeout(o,b(r));O(t.contentDocument,n),p().observe(e)};return k(t,o),{unsubscribe:()=>{const e=l(t.contentDocument,i);e&&p().unobserve(e)},resize:()=>L(e)}}function G({iframe:e,interactionState:t,settings:n}){if(!n.onBeforeIframeResize&&!n.onIframeResize)return()=>{};const i=()=>{t.isHovered=!0},r=()=>{t.isHovered=!1};return e.addEventListener("mouseenter",i),e.addEventListener("mouseleave",r),()=>{e.removeEventListener("mouseenter",i),e.removeEventListener("mouseleave",r)}}function V(){let e=null;return()=>{if(!e){const t=({target:e})=>{const t=m.find((({iframe:t})=>t.contentDocument===e.ownerDocument));t&&L(t)};e=new ResizeObserver((e=>e.forEach(t)))}return e}}function L(e){const{iframe:t,settings:n}=e,i=l(t.contentDocument,n.targetElementSelector);if(!i)return;const{height:r}=I(i);r&&g({newHeight:r,registeredElement:e})}function g({registeredElement:e,newHeight:t}){const{iframe:n,settings:i,interactionState:r,initContext:o}=e;if(o.isInitialized||(o.isInitialized=!0,clearTimeout(o.retryTimeoutId)),!1===i.onBeforeIframeResize?.({iframe:n,interactionState:{...r},settings:{...i},observedHeight:t}))return;const s=n.getBoundingClientRect(),a=t+i.offsetSize;if(n.style.height=`${a}px`,!i.onIframeResize)return;const c={iframe:n,settings:{...i},interactionState:{...r},previousRenderState:{rect:s},nextRenderState:{rect:n.getBoundingClientRect()}};i.onIframeResize(c)}const J=X();let R,h=!1;function K(){!v()||!C()||window.addEventListener("message",(e=>"iframe-child-init"===e.data?.type?z((()=>S(e))):"iframe-get-child-dimensions"===e.data?.type?z((()=>Q(e))):void 0))}function S(e,t=0){const{targetElementSelector:n,bodyPadding:i,bodyMargin:r}=e.data,o=l(document,n);if(h||window.parent!==e.source)return;if(!o)return setTimeout((()=>S(e,t+1)),b(t));O(document,{bodyMargin:r,bodyPadding:i}),R=n;const s=J();s.disconnect(),s.observe(o),h=!0}function Q(e){const t=l(document,R);!h||window.parent!==e.source||!t||E(t)}function X(){let e=null;return()=>(e||(e=new ResizeObserver((e=>{e[0].target&&E(e[0].target)}))),e)}K();const E=e=>{const{width:t,height:n}=I(e),i={type:"iframe-resized",width:t,height:n};window.parent.postMessage(i,"*")},j=({previousRenderState:e,nextRenderState:t,iframe:n})=>{document.activeElement===n&&window.scrollBy(0,t.rect.bottom-e.rect.bottom)}; window.iframeResizer={initialize :Z ,initializeChildListener:K,updateParentScrollOnResize:j};';
@@ -110425,7 +110581,8 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
110425
110581
  console.error(`Failed to inline stylesheet from ${href}:`, error);
110426
110582
  }
110427
110583
  }));
110428
- const code = extractScriptContents(htmlContent);
110584
+ const htmlContentWithInlinedScripts = doc.documentElement.outerHTML;
110585
+ const code = extractScriptContents(htmlContentWithInlinedScripts);
110429
110586
  const initIframeFn = extractFunction(code, "initIframe");
110430
110587
  let allInitIframeResourcesInlined = false;
110431
110588
  if (initIframeFn) {
@@ -110804,7 +110961,7 @@ var hljs=function(){"use strict";function e(n){return n instanceof Map?n.clear=n
110804
110961
  // alan_btn/alan_btn.ts
110805
110962
  (function(ns) {
110806
110963
  const uiState10 = getUIState();
110807
- const version2 = "alan-version.1.8.125".replace("alan-version.", "");
110964
+ const version2 = "alan-version.1.8.127".replace("alan-version.", "");
110808
110965
  uiState10.lib.version = version2;
110809
110966
  window.alanLib = { version: version2 };
110810
110967
  if (window.alanBtn) {