@pickaxeproject/react 6.23.0 → 6.23.2

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.
Files changed (31) hide show
  1. package/dist/cjs/common/responseArtifactSnapshot.js +1 -1
  2. package/dist/cjs/common/responseArtifactWordImages.js +1 -1
  3. package/dist/cjs/common/responseDownloadDocx.js +1 -1
  4. package/dist/cjs/common/responseDownloadHtml.js +1 -1
  5. package/dist/cjs/common/responseDownloadImages.js +1 -0
  6. package/dist/cjs/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
  7. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  8. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.js +1 -1
  9. package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  10. package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  11. package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  12. package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  13. package/dist/cjs/src/common/responseDownloadDocx.d.ts +2 -2
  14. package/dist/cjs/src/common/responseDownloadImages.d.ts +3 -0
  15. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.d.ts +7 -0
  16. package/dist/esm/common/responseArtifactSnapshot.js +1 -1
  17. package/dist/esm/common/responseArtifactWordImages.js +1 -1
  18. package/dist/esm/common/responseDownloadDocx.js +1 -1
  19. package/dist/esm/common/responseDownloadHtml.js +1 -1
  20. package/dist/esm/common/responseDownloadImages.js +1 -0
  21. package/dist/esm/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
  22. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  23. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.js +1 -1
  24. package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  25. package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  26. package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  27. package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  28. package/dist/esm/src/common/responseDownloadDocx.d.ts +2 -2
  29. package/dist/esm/src/common/responseDownloadImages.d.ts +3 -0
  30. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/utils/custom-plugins.d.ts +7 -0
  31. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("uuid"),t=require("./responseArtifactStyles.js"),n=require("./responseArtifactSvg.js");const r="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co",o=(e,r)=>`<script>\n(() => {\n const token = ${JSON.stringify(e)};\n const send = parent.postMessage.bind(parent);\n send({ type: 'PXE_RESPONSE_SNAPSHOT_STARTED', token }, '*');\n let failed = false;\n let captureStarted = false;\n let timer;\n let deadline;\n let observer;\n let paintReady = false;\n const captureSvg = ${n.artifactSvgSnapshotScript};\n const finish = async () => {\n // The quiet timer and deadline can become ready together. Capture once,\n // including while asynchronous SVG/image conversion is still in progress.\n if (captureStarted) return;\n captureStarted = true;\n clearTimeout(timer);\n clearTimeout(deadline);\n observer?.disconnect();\n if (failed || document.querySelector('${r?"iframe, object, embed":"canvas, iframe, object, embed"}')) {\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n return;\n }\n try {\n const copy = document.createElement('div');\n copy.innerHTML = document.body.innerHTML;\n const sources = [document.body, ...document.body.querySelectorAll('*')];\n const targets = [copy, ...copy.querySelectorAll('*')];\n const properties = ${JSON.stringify(t.artifactStyleProperties)};\n sources.forEach((source, index) => {\n const target = targets[index];\n if (!target || !target.style) return;\n const computed = getComputedStyle(source);\n target.removeAttribute('style');\n properties.forEach(property => target.style.setProperty(property, computed.getPropertyValue(property)));\n // Static snapshots cannot retain clipped gradient text safely without\n // its full CSS. Keep the heading readable instead of copying transparency.\n if (computed.backgroundClip === 'text' || computed.webkitBackgroundClip === 'text') {\n target.style.setProperty('background-image', 'none');\n let ancestor = source.parentElement;\n let color = 'rgb(32, 32, 32)';\n while (ancestor) {\n const candidate = getComputedStyle(ancestor).color;\n if (candidate !== 'transparent' && candidate !== 'rgba(0, 0, 0, 0)') { color = candidate; break; }\n ancestor = ancestor.parentElement;\n }\n target.style.setProperty('color', color);\n }\n // A screen-reader-only caption must not become a new visible table cell\n // when its absolute positioning and clipping are deliberately discarded.\n if (computed.position === 'absolute' && computed.clip !== 'auto' && source.getBoundingClientRect().width <= 1) {\n target.hidden = true;\n target.style.setProperty('display', 'none');\n }\n });\n // Canvas pixels are not included in innerHTML. Freeze them as inert images.\n sources.forEach((source, index) => {\n if (!(source instanceof HTMLCanvasElement)) return;\n const target = targets[index];\n if (!source.width || !source.height) { target.remove(); return; }\n if (source.width * source.height > 16000000) throw new Error('Canvas too large');\n const pixels = document.createElement('canvas');\n pixels.width = source.width;\n pixels.height = source.height;\n const context = pixels.getContext('2d');\n if (!context) throw new Error('Canvas capture unavailable');\n context.drawImage(source, 0, 0);\n // Do not turn an empty decorative overlay into a large blank PDF section.\n if (source.getAttribute('aria-hidden') === 'true') {\n const data = context.getImageData(0, 0, pixels.width, pixels.height).data;\n let visible = false;\n for (let i = 3; i < data.length; i += 4) {\n if (data[i]) { visible = true; break; }\n }\n if (!visible) { target.remove(); return; }\n }\n const image = document.createElement('img');\n image.src = pixels.toDataURL('image/png');\n image.alt = source.getAttribute('aria-label') || source.textContent || '';\n image.style.cssText = target.style.cssText;\n const bounds = source.getBoundingClientRect();\n image.width = Math.max(1, Math.round(bounds.width || source.width));\n image.height = Math.max(1, Math.round(bounds.height || source.height));\n target.replaceWith(image);\n });\n // Preserve SVG charts as inert PNGs before the export's HTML-only sanitizer.\n // Capture outer SVGs once; their nested SVGs/defs are part of the same image.\n for (let index = 0; index < sources.length; index++) {\n const source = sources[index];\n if (!(source instanceof SVGSVGElement) || source.parentElement?.closest('svg')) continue;\n const picture = await captureSvg(source);\n if (picture) {\n picture.style.cssText = targets[index].style.cssText;\n targets[index].replaceWith(picture);\n } else targets[index].remove();\n }\n copy.querySelectorAll('script, style, link, meta, noscript').forEach(node => node.remove());\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, html: copy.outerHTML }, '*');\n } catch {\n // A tainted/unreadable canvas must fail, not produce an incomplete export.\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n }\n };\n window.addEventListener('error', () => { failed = true; }, true);\n window.addEventListener('unhandledrejection', () => { failed = true; });\n observer = new MutationObserver(() => {\n if (!paintReady) return;\n clearTimeout(timer);\n timer = setTimeout(finish, 1000);\n });\n observer.observe(document.documentElement, { subtree: true, childList: true, characterData: true, attributes: true });\n // Start the capture window only after the artifact has had a chance to paint.\n // If frames are suspended (for example in a background tab), the parent's\n // timeout rejects instead of silently exporting an uninitialized chart.\n requestAnimationFrame(() => requestAnimationFrame(() => {\n paintReady = true;\n timer = setTimeout(finish, 1000);\n // Live counters/animations may never settle. Capture their rendered state\n // after a bounded wait, rather than requiring permanent DOM inactivity.\n deadline = setTimeout(finish, 3000);\n }));\n})();\n<\/script>`;exports.renderResponseArtifactHtml=(t,n=!1,i)=>t.trimStart().startsWith("%PDF")?Promise.reject(new Error("Binary PDF artifacts cannot be rendered as HTML.")):window.location.origin===r?Promise.reject(new Error("Artifact rendering requires a separate origin.")):(null==i?void 0:i.closed)?Promise.reject(new Error("The response print window was closed.")):new Promise(((a,s)=>{const c=e.v4();let d,l,u,p=!1;const m=(i?[window,i]:[window]).map((e=>({target:e,document:e.document}))),h=()=>{void 0!==u&&(null==l||l.clearInterval(u)),u=void 0},g=()=>{p=!0,window.clearTimeout(w),window.clearInterval(b),h(),m.forEach((({target:e,document:t})=>{e.removeEventListener("message",v),e.removeEventListener("focus",y),t.removeEventListener("visibilitychange",y)})),null==d||d.remove()},f=e=>{p||(g(),s(new Error(e)))},v=e=>{var t;!p&&d&&e.source===d.contentWindow&&e.origin===r&&(null===(t=e.data)||void 0===t?void 0:t.token)===c&&("PXE_RESPONSE_SNAPSHOT_STARTED"!==e.data.type?"PXE_RESPONSE_SNAPSHOT"===e.data.type&&(g(),e.data.error||"string"!=typeof e.data.html||e.data.html.length>1e7?s(new Error("Unable to capture the complete artifact.")):a(e.data.html)):h())},y=()=>{var e;if(p)return;if(null==i?void 0:i.closed)return void f("The response print window was closed.");const a=!document.hidden&&document.hasFocus()?window:i&&!i.document.hidden?i:document.hidden&&null!==(e=null!=l?l:i)&&void 0!==e?e:window;if(a===l)return;h(),null==d||d.remove(),l=a;const s=a.document.createElement("iframe");d=s,s.src=`${r}/html`,s.setAttribute("sandbox","allow-scripts allow-same-origin"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.style.cssText="position:fixed;left:0;top:0;width:900px;height:600px;border:0;opacity:0;pointer-events:none;",s.onload=()=>{p||d!==s||(h(),u=a.setInterval((()=>{var e;return null===(e=s.contentWindow)||void 0===e?void 0:e.postMessage({type:"HTML_CODE",content:o(c,n)+t},r)}),250))},s.onerror=()=>{d===s&&f("Unable to load the artifact renderer.")},a.document.body.appendChild(s)},w=window.setTimeout((()=>f("Artifact rendering timed out.")),15e3),b=i?window.setInterval((()=>{i.closed&&f("The response print window was closed.")}),250):void 0;m.forEach((({target:e,document:t})=>{e.addEventListener("message",v),e.addEventListener("focus",y),t.addEventListener("visibilitychange",y)})),y()}));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("uuid"),t=require("./responseArtifactStyles.js"),n=require("./responseArtifactSvg.js");const r="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co",o=(e,r)=>`<script>\n(() => {\n const token = ${JSON.stringify(e)};\n const send = parent.postMessage.bind(parent);\n send({ type: 'PXE_RESPONSE_SNAPSHOT_STARTED', token }, '*');\n let failed = false;\n let captureStarted = false;\n let timer;\n let deadline;\n let observer;\n let paintReady = false;\n const captureSvg = ${n.artifactSvgSnapshotScript};\n const finish = async () => {\n // The quiet timer and deadline can become ready together. Capture once,\n // including while asynchronous SVG/image conversion is still in progress.\n if (captureStarted) return;\n captureStarted = true;\n clearTimeout(timer);\n clearTimeout(deadline);\n observer?.disconnect();\n if (failed || document.querySelector('${r?"iframe, object, embed":"canvas, iframe, object, embed"}')) {\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n return;\n }\n try {\n const copy = document.createElement('div');\n copy.innerHTML = document.body.innerHTML;\n const sources = [document.body, ...document.body.querySelectorAll('*')];\n const targets = [copy, ...copy.querySelectorAll('*')];\n const properties = ${JSON.stringify(t.artifactStyleProperties)};\n sources.forEach((source, index) => {\n const target = targets[index];\n if (!target || !target.style) return;\n const computed = getComputedStyle(source);\n target.removeAttribute('style');\n properties.forEach(property => target.style.setProperty(property, computed.getPropertyValue(property)));\n // Static snapshots cannot retain clipped gradient text safely without\n // its full CSS. Keep the heading readable instead of copying transparency.\n if (computed.backgroundClip === 'text' || computed.webkitBackgroundClip === 'text') {\n target.style.setProperty('background-image', 'none');\n let ancestor = source.parentElement;\n let color = 'rgb(32, 32, 32)';\n while (ancestor) {\n const candidate = getComputedStyle(ancestor).color;\n if (candidate !== 'transparent' && candidate !== 'rgba(0, 0, 0, 0)') { color = candidate; break; }\n ancestor = ancestor.parentElement;\n }\n target.style.setProperty('color', color);\n }\n // A screen-reader-only caption must not become a new visible table cell\n // when its absolute positioning and clipping are deliberately discarded.\n if (computed.position === 'absolute' && computed.clip !== 'auto' && source.getBoundingClientRect().width <= 1) {\n target.hidden = true;\n target.style.setProperty('display', 'none');\n }\n });\n // Canvas pixels are not included in innerHTML. Freeze them as inert images.\n sources.forEach((source, index) => {\n if (!(source instanceof HTMLCanvasElement)) return;\n const target = targets[index];\n if (!source.width || !source.height) { target.remove(); return; }\n if (source.width * source.height > 16000000) throw new Error('Canvas too large');\n const pixels = document.createElement('canvas');\n pixels.width = source.width;\n pixels.height = source.height;\n const context = pixels.getContext('2d');\n if (!context) throw new Error('Canvas capture unavailable');\n context.drawImage(source, 0, 0);\n // Do not turn an empty decorative overlay into a large blank PDF section.\n if (source.getAttribute('aria-hidden') === 'true') {\n const data = context.getImageData(0, 0, pixels.width, pixels.height).data;\n let visible = false;\n for (let i = 3; i < data.length; i += 4) {\n if (data[i]) { visible = true; break; }\n }\n if (!visible) { target.remove(); return; }\n }\n const image = document.createElement('img');\n image.src = pixels.toDataURL('image/png');\n image.alt = source.getAttribute('aria-label') || source.textContent || '';\n image.style.cssText = target.style.cssText;\n const bounds = source.getBoundingClientRect();\n image.width = Math.max(1, Math.round(bounds.width || source.width));\n image.height = Math.max(1, Math.round(bounds.height || source.height));\n target.replaceWith(image);\n });\n // Preserve SVG charts as inert PNGs before the export's HTML-only sanitizer.\n // Capture outer SVGs once; their nested SVGs/defs are part of the same image.\n for (let index = 0; index < sources.length; index++) {\n const source = sources[index];\n if (!(source instanceof SVGSVGElement) || source.parentElement?.closest('svg')) continue;\n const picture = await captureSvg(source);\n if (picture) {\n picture.style.cssText = targets[index].style.cssText;\n targets[index].replaceWith(picture);\n } else targets[index].remove();\n }\n copy.querySelectorAll('script, style, link, meta, noscript').forEach(node => node.remove());\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, html: copy.outerHTML }, '*');\n } catch {\n // A tainted/unreadable canvas must fail, not produce an incomplete export.\n send({ type: 'PXE_RESPONSE_SNAPSHOT', token, error: true }, '*');\n }\n };\n window.addEventListener('error', event => {\n // Missing images use the export's image fallback, not a fatal capture error.\n // Script errors (including errors thrown by image handlers) still fail.\n if (event.target instanceof HTMLImageElement) return;\n failed = true;\n }, true);\n window.addEventListener('unhandledrejection', () => { failed = true; });\n observer = new MutationObserver(() => {\n if (!paintReady) return;\n clearTimeout(timer);\n timer = setTimeout(finish, 1000);\n });\n observer.observe(document.documentElement, { subtree: true, childList: true, characterData: true, attributes: true });\n // Start the capture window only after the artifact has had a chance to paint.\n // If frames are suspended (for example in a background tab), the parent's\n // timeout rejects instead of silently exporting an uninitialized chart.\n requestAnimationFrame(() => requestAnimationFrame(() => {\n paintReady = true;\n timer = setTimeout(finish, 1000);\n // Live counters/animations may never settle. Capture their rendered state\n // after a bounded wait, rather than requiring permanent DOM inactivity.\n deadline = setTimeout(finish, 3000);\n }));\n})();\n<\/script>`;exports.renderResponseArtifactHtml=(t,n=!1,i)=>t.trimStart().startsWith("%PDF")?Promise.reject(new Error("Binary PDF artifacts cannot be rendered as HTML.")):window.location.origin===r?Promise.reject(new Error("Artifact rendering requires a separate origin.")):(null==i?void 0:i.closed)?Promise.reject(new Error("The response print window was closed.")):new Promise(((a,s)=>{const c=e.v4();let d,l,u,p=!1;const m=(i?[window,i]:[window]).map((e=>({target:e,document:e.document}))),g=()=>{void 0!==u&&(null==l||l.clearInterval(u)),u=void 0},h=()=>{p=!0,window.clearTimeout(w),window.clearInterval(b),g(),m.forEach((({target:e,document:t})=>{e.removeEventListener("message",v),e.removeEventListener("focus",y),t.removeEventListener("visibilitychange",y)})),null==d||d.remove()},f=e=>{p||(h(),s(new Error(e)))},v=e=>{var t;!p&&d&&e.source===d.contentWindow&&e.origin===r&&(null===(t=e.data)||void 0===t?void 0:t.token)===c&&("PXE_RESPONSE_SNAPSHOT_STARTED"!==e.data.type?"PXE_RESPONSE_SNAPSHOT"===e.data.type&&(h(),e.data.error||"string"!=typeof e.data.html||e.data.html.length>1e7?s(new Error("Unable to capture the complete artifact.")):a(e.data.html)):g())},y=()=>{var e;if(p)return;if(null==i?void 0:i.closed)return void f("The response print window was closed.");const a=!document.hidden&&document.hasFocus()?window:i&&!i.document.hidden?i:document.hidden&&null!==(e=null!=l?l:i)&&void 0!==e?e:window;if(a===l)return;g(),null==d||d.remove(),l=a;const s=a.document.createElement("iframe");d=s,s.src=`${r}/html`,s.setAttribute("sandbox","allow-scripts allow-same-origin"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.style.cssText="position:fixed;left:0;top:0;width:900px;height:600px;border:0;opacity:0;pointer-events:none;",s.onload=()=>{p||d!==s||(g(),u=a.setInterval((()=>{var e;return null===(e=s.contentWindow)||void 0===e?void 0:e.postMessage({type:"HTML_CODE",content:o(c,n)+t},r)}),250))},s.onerror=()=>{d===s&&f("Unable to load the artifact renderer.")},a.document.body.appendChild(s)},w=window.setTimeout((()=>f("Artifact rendering timed out.")),15e3),b=i?window.setInterval((()=>{i.closed&&f("The response print window was closed.")}),250):void 0;m.forEach((({target:e,document:t})=>{e.addEventListener("message",v),e.addEventListener("focus",y),t.addEventListener("visibilitychange",y)})),y()}));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("./responseDownloadHtml.js");exports.createResponseArtifactWordImages=(o,r)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=t.createResponseDownloadDocument(`<div class="pxe-export-artifact">${o}</div>`,!0),n=(new DOMParser).parseFromString(e,"text/html");for(const e of n.querySelectorAll("img"))if(!/^data:image\/(png|jpeg|gif);base64,/i.test(e.getAttribute("src")||""))throw new Error("Word artifact pictures require self-contained images.");const i=document.createElement("iframe");i.setAttribute("sandbox","allow-same-origin"),i.setAttribute("aria-hidden","true"),i.tabIndex=-1,i.style.cssText="position:fixed;left:-10000px;top:0;width:720px;height:600px;border:0;pointer-events:none";try{yield new Promise(((t,o)=>{const r=setTimeout((()=>o(new Error("Word snapshot timed out."))),5e3);i.onload=()=>{clearTimeout(r),t()},i.onerror=()=>{clearTimeout(r),o(new Error("Word snapshot failed."))},i.srcdoc=e,document.body.appendChild(i)}));const t=i.contentDocument,o=i.contentWindow,n=null==t?void 0:t.querySelector("main");if(!t||!o||!n)throw new Error("Word snapshot unavailable.");const a=t.createElement("style");a.textContent="main{width:720px;max-width:none;padding:0;margin:0}\n.pxe-export-artifact{overflow:visible}\n.pxe-export-artifact:has(tr > :nth-child(6)) > div{min-width:0}\ntable{width:100%;table-layout:fixed} pre{white-space:pre-wrap;overflow-wrap:anywhere}\n*{animation:none!important;transition:none!important}",t.head.appendChild(a),t.querySelectorAll("details").forEach((e=>{e.open=!0}));const l=Math.ceil(Math.max(n.scrollWidth,n.getBoundingClientRect().width)),s=Math.ceil(n.getBoundingClientRect().height);if(l>1440||!s||s>16e3)throw new Error("Artifact is too large for a readable Word picture.");const c=n.cloneNode(!0),d=[n,...n.querySelectorAll("*")],h=[c,...c.querySelectorAll("*")];d.forEach(((e,t)=>{const r=h[t],n=o.getComputedStyle(e);r.removeAttribute("style");for(const e of Array.from(n))r.style.setProperty(e,n.getPropertyValue(e))})),c.setAttribute("xmlns","http://www.w3.org/1999/xhtml");const p=(new XMLSerializer).serializeToString(c);if(p.length>1e7)throw new Error("Word snapshot is too large.");const g=n.getBoundingClientRect().top,m=[],w=t.createTreeWalker(n,NodeFilter.SHOW_TEXT);for(;w.nextNode();){const e=t.createRange();e.selectNodeContents(w.currentNode);for(const t of Array.from(e.getClientRects()))t.height&&m.push({top:t.top-g,bottom:t.bottom-g})}n.querySelectorAll("tr,img").forEach((e=>{const t=e.getBoundingClientRect();t.height<=800&&m.push({top:t.top-g,bottom:t.bottom-g})}));const u=[];let f=0;for(let e=0;e<s;){let o=Math.min(s,e+800);if(o<s)for(let t=0;t<m.length;t++){const t=m.find((e=>e.top+1<o&&e.bottom-1>o));if(!t||t.top<=e)break;o=Math.ceil(t.top)}if(o<=e)throw new Error("Unable to paginate artifact picture.");const n=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${o-e}" viewBox="0 ${e} ${l} ${o-e}"><foreignObject x="0" y="0" width="${l}" height="${s}">${p}</foreignObject></svg>`,i=new Image;yield new Promise(((e,t)=>{const o=setTimeout((()=>r(!1)),5e3),r=r=>{clearTimeout(o),i.onload=i.onerror=null,r?e():t(new Error("Unable to draw Word artifact picture."))};i.onload=()=>r(!0),i.onerror=()=>r(!1),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}));const a=document.createElement("canvas");a.width=2*l,a.height=2*(o-e);const c=a.getContext("2d");if(!c)throw new Error("Word image capture unavailable.");c.fillStyle="white",c.fillRect(0,0,a.width,a.height),c.drawImage(i,0,0,a.width,a.height);const d=a.toDataURL("image/png");if(f+=d.length,f>1e7)throw new Error("Word artifact pictures are too large.");const h=t.createElement("img");h.src=d,h.width=l,h.height=o-e,h.alt=r;const g=t.createElement("p");g.appendChild(h),u.push(g.outerHTML),a.width=a.height=0,i.removeAttribute("src"),e=o}return u.join("")}finally{i.remove()}}));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("./responseDownloadHtml.js"),o=require("./responseDownloadImages.js");exports.createResponseArtifactWordImages=(r,n)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;let i=t.createResponseDownloadDocument(`<div class="pxe-export-artifact">${r}</div>`,!0);const a=document.createElement("template");a.innerHTML=i;const l=yield o.embedResponseDownloadImages(a.content,"docx");for(const t of a.content.querySelectorAll("img")){if(l.has(t))continue;const o=document.createElement("span");o.textContent=`⚠ ${(null===(e=t.getAttribute("alt"))||void 0===e?void 0:e.trim())||"[…]"}`,t.replaceWith(o)}i=`<!doctype html>\n${a.innerHTML}`;const c=document.createElement("iframe");c.setAttribute("sandbox","allow-same-origin"),c.setAttribute("aria-hidden","true"),c.tabIndex=-1,c.style.cssText="position:fixed;left:-10000px;top:0;width:720px;height:600px;border:0;pointer-events:none";try{yield new Promise(((e,t)=>{const o=setTimeout((()=>t(new Error("Word snapshot timed out."))),5e3);c.onload=()=>{clearTimeout(o),e()},c.onerror=()=>{clearTimeout(o),t(new Error("Word snapshot failed."))},c.srcdoc=i,document.body.appendChild(c)}));const e=c.contentDocument,t=c.contentWindow,o=null==e?void 0:e.querySelector("main");if(!e||!t||!o)throw new Error("Word snapshot unavailable.");const r=e.createElement("style");r.textContent="main{display:flow-root;width:720px;max-width:none;padding:0;margin:0}\n.pxe-export-artifact{overflow:visible}\n.pxe-export-artifact:has(tr > :nth-child(6)) > div{min-width:0}\ntable{width:100%;table-layout:fixed} pre{white-space:pre-wrap;overflow-wrap:anywhere}\n*{animation:none!important;transition:none!important}",e.head.appendChild(r),e.querySelectorAll("details").forEach((e=>{e.open=!0}));const a=Math.ceil(Math.max(o.scrollWidth,o.getBoundingClientRect().width)),l=Math.ceil(o.getBoundingClientRect().height);if(a>1440||!l||l>16e3)throw new Error("Artifact is too large for a readable Word picture.");const s=o.cloneNode(!0),d=[o,...o.querySelectorAll("*")],h=[s,...s.querySelectorAll("*")];d.forEach(((e,o)=>{const r=h[o],n=t.getComputedStyle(e);r.removeAttribute("style");for(const e of Array.from(n))r.style.setProperty(e,n.getPropertyValue(e))})),s.setAttribute("xmlns","http://www.w3.org/1999/xhtml");const p=(new XMLSerializer).serializeToString(s);if(p.length>1e7)throw new Error("Word snapshot is too large.");const m=o.getBoundingClientRect().top,u=[],w=e.createTreeWalker(o,NodeFilter.SHOW_TEXT);for(;w.nextNode();){const t=e.createRange();t.selectNodeContents(w.currentNode);for(const e of Array.from(t.getClientRects()))e.height&&u.push({top:e.top-m,bottom:e.bottom-m})}o.querySelectorAll("tr,img").forEach((e=>{const t=e.getBoundingClientRect();t.height<=800&&u.push({top:t.top-m,bottom:t.bottom-m})}));const g=[];let f=0;for(let t=0;t<l;){let o=Math.min(l,t+800);if(o<l)for(let e=0;e<u.length;e++){const e=u.find((e=>e.top+1<o&&e.bottom-1>o));if(!e||e.top<=t)break;o=Math.ceil(e.top)}if(o<=t)throw new Error("Unable to paginate artifact picture.");const r=`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${o-t}" viewBox="0 ${t} ${a} ${o-t}"><foreignObject x="0" y="0" width="${a}" height="${l}">${p}</foreignObject></svg>`,i=new Image;yield new Promise(((e,t)=>{const o=setTimeout((()=>n(!1)),5e3),n=r=>{clearTimeout(o),i.onload=i.onerror=null,r?e():t(new Error("Unable to draw Word artifact picture."))};i.onload=()=>n(!0),i.onerror=()=>n(!1),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`}));const c=document.createElement("canvas");c.width=2*a,c.height=2*(o-t);const s=c.getContext("2d");if(!s)throw new Error("Word image capture unavailable.");s.fillStyle="white",s.fillRect(0,0,c.width,c.height),s.drawImage(i,0,0,c.width,c.height);const d=c.toDataURL("image/png");if(f+=d.length,f>1e7)throw new Error("Word artifact pictures are too large.");const h=e.createElement("img");h.src=d,h.width=a,h.height=o-t,h.alt=n;const m=e.createElement("p");m.appendChild(h),g.push(m.outerHTML),c.width=c.height=0,i.removeAttribute("src"),t=o}return g.join("")}finally{c.remove()}}));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("docx"),r=require("./responseDownloadHtml.js");const n=720,a=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DD","DETAILS","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SUMMARY","TABLE","UL"]),i=e=>{if(e&&/^(https?:|mailto:|tel:)/i.test(e.trim()))try{return new URL(e.trim()).href}catch(e){return}},s=(e,r)=>{const n=Object.assign({},r);switch(e.tagName){case"STRONG":case"B":n.bold=!0;break;case"EM":case"I":n.italics=!0;break;case"DEL":case"S":case"STRIKE":n.strike=!0;break;case"U":n.underline={type:t.UnderlineType.SINGLE};break;case"CODE":case"KBD":case"SAMP":n.font="Courier New";break;case"SUP":n.superScript=!0;break;case"SUB":n.subScript=!0}return n};exports.createResponseDownloadDocx=(o,l)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=document.createElement("template");e.innerHTML=null!=l?l:r.createResponseDownloadHtml(o);const c=e.content.querySelector("main");if(!c)throw new Error("Unable to prepare the response document.");const d=new Map;for(const e of c.querySelectorAll('.pxe-export-artifact img[src^="data:image/png;base64,"]')){const t=e.getAttribute("src")||"";if(t.length>1e7)throw new Error("Artifact image too large.");const r=Uint8Array.from(atob(t.slice(22)),(e=>e.charCodeAt(0))),n=new DataView(r.buffer);if(r.length<24||2303741511!==n.getUint32(0)||218765834!==n.getUint32(4)||1229472850!==n.getUint32(12))throw new Error("Invalid artifact image.");const a=n.getUint32(16),i=n.getUint32(20);if(!a||!i||a*i>16e6)throw new Error("Artifact image dimensions are unsupported.");yield new Promise(((e,r)=>{const n=new Image,s=t=>{clearTimeout(o),n.onload=n.onerror=null,n.removeAttribute("src"),t?e():r(new Error("Unable to read artifact image."))},o=setTimeout((()=>s(!1)),5e3);n.onload=()=>s(n.naturalWidth===a&&n.naturalHeight===i),n.onerror=()=>s(!1),n.src=t}));const s=Number(e.getAttribute("width")),o=s>0?Math.min(1,s/a):1;d.set(e,{data:r,width:a*o,height:i*o})}const u=[],g=(e,r,n)=>Array.from(e).flatMap((e=>{var a;if(3===e.nodeType){const n=e.textContent||"";return[new t.TextRun(Object.assign(Object.assign({},r),{text:(null===(a=e.parentElement)||void 0===a?void 0:a.closest("code"))?n:n.replace(/[\t\n\r ]+/g," ")}))]}if(1!==e.nodeType)return[];const o=e,l=s(o,r);if("BR"===o.tagName)return[new t.TextRun(Object.assign(Object.assign({},r),{break:1}))];if("IMG"===o.tagName){const e=d.get(o);if(e){const r=Math.min(1,Math.max(1,n/15)/e.width,900/e.height);return[new t.ImageRun(Object.assign(Object.assign({type:"png",data:e.data},o.getAttribute("alt")?{altText:{name:o.getAttribute("alt")||""}}:{}),{transformation:{width:e.width*r,height:e.height*r}}))]}const a=i(o.getAttribute("src")),s=o.getAttribute("alt")||a||"[…]",l=[new t.TextRun(Object.assign(Object.assign({},r),{text:s}))];return a&&!o.closest("a")?[new t.ExternalHyperlink({link:a,children:l})]:l}const c="A"===o.tagName?i(o.getAttribute("href")):void 0,u=g(o.childNodes,c?Object.assign(Object.assign({},l),{color:"174EA6",underline:{type:t.UnderlineType.SINGLE}}):l,n);return c?[new t.ExternalHyperlink({link:c,children:u})]:u})),h=(e,r,n={})=>{const a=r.marker&&!r.marker.used?r.marker:void 0;return a&&(a.used=!0),new t.Paragraph(Object.assign(Object.assign(Object.assign({children:e,spacing:{after:160},widowControl:!0},r.indent?{indent:Object.assign({left:r.indent},a?{hanging:360}:{})}:{}),null==a?void 0:a.properties),n))},m=(e,r)=>{var n;const a="OL"===e.tagName;let i="",s=!1;const o=e=>{i=`response-list-${u.length}`,s=0===e,u.push({reference:i,levels:[{level:0,format:t.LevelFormat.DECIMAL,text:s?"0.":"%1.",start:s?1:e,alignment:t.AlignmentType.LEFT}]})},l=e.hasAttribute("reversed"),c=Array.from(e.children).filter((e=>"LI"===e.tagName)),d=Number.parseInt(e.getAttribute("start")||"",10);let g=Number.isFinite(d)?d:l?c.length:1;a&&o(g);const m=[];for(const t of Array.from(e.children)){if("LI"!==t.tagName){m.push(...b([t],r));continue}const e=Number.parseInt(t.getAttribute("value")||"",10);a&&Number.isFinite(e)&&(g=e),a&&(l||s||0===g||Number.isFinite(e))&&o(g),g+=l?-1:1;const c=Object.assign(Object.assign({},r),{indent:Math.min(r.indent+720,5760),marker:{used:!1,properties:a?{numbering:{reference:i,level:0}}:{bullet:{level:0}}}}),d=b(t.childNodes,c);(null===(n=c.marker)||void 0===n?void 0:n.used)||d.unshift(h([],c)),m.push(...d)}return m},p=(e,r)=>{const n=[];let a=0;const i=Array.from(e.querySelectorAll("tr")).filter((t=>t.closest("table")===e)).map(((e,t)=>{let r=0;return{row:e,cells:Array.from(e.children).filter((e=>"TD"===e.tagName||"TH"===e.tagName)).map((e=>{for(;n[r]>t;)r++;const i=t=>Math.min(100,Math.max(1,parseInt(e.getAttribute(t)||"1",10)||1)),s=i("colspan"),o=i("rowspan"),l=r;for(let e=0;e<s;e++)n[r++]=t+o;return a=Math.max(a,r),{cell:e,start:l,columnSpan:s,rowSpan:o}}))}})),s=e=>Math.floor(e*r/a),o=Array.from({length:a},((e,t)=>s(t+1)-s(t))),l=i.flatMap((({row:e,cells:r})=>{var n;return r.length?[new t.TableRow({tableHeader:"THEAD"===(null===(n=e.parentElement)||void 0===n?void 0:n.tagName)||r.every((({cell:e})=>"TH"===e.tagName)),children:r.map((({cell:e,start:r,columnSpan:n,rowSpan:a})=>{const i=s(r+n)-s(r),o=b(e.childNodes,{indent:0,width:Math.max(1,i-200),run:{bold:"TH"===e.tagName}});return o[o.length-1]instanceof t.Paragraph||o.push(new t.Paragraph("")),new t.TableCell(Object.assign({children:o,columnSpan:n,rowSpan:a,width:{size:i,type:t.WidthType.DXA},margins:{top:80,bottom:80,left:100,right:100}},"TH"===e.tagName?{shading:{fill:"F0F0F0"}}:{}))}))})]:[]})),c=Array.from(e.children).filter((e=>"CAPTION"===e.tagName));return l.length?[...b(c,{indent:0,width:r,run:{}}),new t.Table({rows:l,width:{size:r,type:t.WidthType.DXA},columnWidths:o})]:b(e.childNodes,{indent:0,width:r,run:{}})},b=(e,r)=>{const n=[];let i=[];const o=()=>{i.some((e=>{var t;return(null===(t=e.textContent)||void 0===t?void 0:t.trim())||1===e.nodeType&&/^(BR|IMG)$/.test(e.tagName)||1===e.nodeType&&e.querySelector("br,img")}))&&n.push(h(g(i,r.run,r.width-r.indent),r)),i=[]};for(const l of Array.from(e)){if(1!==l.nodeType||!a.has(l.tagName)){1===l.nodeType&&Array.from(l.children).some((e=>a.has(e.tagName)))?(o(),n.push(...b(l.childNodes,Object.assign(Object.assign({},r),{run:s(l,r.run)})))):i.push(l);continue}o();const e=l,c=e.tagName;if("UL"===c||"OL"===c)r.marker&&!r.marker.used&&n.push(h([],r)),n.push(...m(e,r));else if("TABLE"===c)r.marker&&!r.marker.used&&n.push(h([],r)),n.push(...p(e,r.width));else if("PRE"===c){const a=(e.textContent||"").replace(/\r\n?/g,"\n").split("\n");n.push(h(a.map(((e,n)=>new t.TextRun(Object.assign(Object.assign(Object.assign({},r.run),{children:e.split("\t").flatMap(((e,r)=>r?[new t.Tab,e]:[e])),font:"Courier New",size:20}),n?{break:1}:{})))),r,{shading:{fill:"F4F4F4"},spacing:{before:120,after:160}}))}else if(/^H[1-6]$/.test(c)){const a=[t.HeadingLevel.HEADING_1,t.HeadingLevel.HEADING_2,t.HeadingLevel.HEADING_3,t.HeadingLevel.HEADING_4,t.HeadingLevel.HEADING_5,t.HeadingLevel.HEADING_6];n.push(h(g(e.childNodes,Object.assign(Object.assign({},r.run),{bold:!0,color:"202020"}),r.width-r.indent),r,{heading:a[Number(c[1])-1],keepNext:!0}))}else if("HR"===c)n.push(h([],r,{border:{bottom:{style:t.BorderStyle.SINGLE,color:"CCCCCC",size:4}}}));else{const t="BLOCKQUOTE"===c?Object.assign(Object.assign({},r),{indent:r.indent+360}):r,a=b(e.childNodes,t);n.push(...a),a.length||"P"!==c||n.push(h([],t))}}return o(),n},f=b(c.childNodes,{indent:0,width:10800,run:{}}),w=new t.Document({title:"Pickaxe",creator:"Pickaxe",styles:{default:{document:{run:{font:"Arial",size:22,color:"202020"}}}},numbering:{config:u},sections:[{properties:{page:{size:{width:12240,height:15840},margin:{top:n,bottom:n,left:n,right:n}}},children:f.length?f:[new t.Paragraph("")]}]});return t.Packer.toBlob(w)}));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("docx"),n=require("./responseDownloadHtml.js"),r=require("./responseDownloadImages.js");const a=720,i=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DD","DETAILS","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SUMMARY","TABLE","UL"]),s=e=>{if(e&&/^(https?:|mailto:|tel:)/i.test(e.trim()))try{return new URL(e.trim()).href}catch(e){return}},o=(e,n)=>{const r=Object.assign({},n);switch(e.tagName){case"STRONG":case"B":r.bold=!0;break;case"EM":case"I":r.italics=!0;break;case"DEL":case"S":case"STRIKE":r.strike=!0;break;case"U":r.underline={type:t.UnderlineType.SINGLE};break;case"CODE":case"KBD":case"SAMP":r.font="Courier New";break;case"SUP":r.superScript=!0;break;case"SUB":r.subScript=!0}return r};exports.createResponseDownloadDocx=(l,c)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=document.createElement("template");e.innerHTML=null!=c?c:n.createResponseDownloadHtml(l);const d=e.content.querySelector("main");if(!d)throw new Error("Unable to prepare the response document.");const u=yield r.embedResponseDownloadImages(d,"docx"),g=new Map;for(const e of u){const t=e.getAttribute("src")||"";if(t.length>1e7)throw new Error("Artifact image too large.");const n=Uint8Array.from(atob(t.slice(22)),(e=>e.charCodeAt(0))),r=new DataView(n.buffer);if(n.length<24||2303741511!==r.getUint32(0)||218765834!==r.getUint32(4)||1229472850!==r.getUint32(12))throw new Error("Invalid artifact image.");const a=r.getUint32(16),i=r.getUint32(20);if(!a||!i||a*i>16e6)throw new Error("Artifact image dimensions are unsupported.");yield new Promise(((e,n)=>{const r=new Image,s=t=>{clearTimeout(o),r.onload=r.onerror=null,r.removeAttribute("src"),t?e():n(new Error("Unable to read artifact image."))},o=setTimeout((()=>s(!1)),5e3);r.onload=()=>s(r.naturalWidth===a&&r.naturalHeight===i),r.onerror=()=>s(!1),r.src=t}));const s=Number(e.getAttribute("width")),o=s>0?Math.min(1,s/a):1;g.set(e,{data:n,width:a*o,height:i*o})}const h=[],m=(e,n,r)=>Array.from(e).flatMap((e=>{var a;if(3===e.nodeType){const r=e.textContent||"";return[new t.TextRun(Object.assign(Object.assign({},n),{text:(null===(a=e.parentElement)||void 0===a?void 0:a.closest("code"))?r:r.replace(/[\t\n\r ]+/g," ")}))]}if(1!==e.nodeType)return[];const i=e,l=o(i,n);if("BR"===i.tagName)return[new t.TextRun(Object.assign(Object.assign({},n),{break:1}))];if("IMG"===i.tagName){const e=g.get(i);if(e){const n=Math.min(1,Math.max(1,r/15)/e.width,900/e.height);return[new t.ImageRun(Object.assign(Object.assign({type:"png",data:e.data},i.getAttribute("alt")?{altText:{name:i.getAttribute("alt")||""}}:{}),{transformation:{width:e.width*n,height:e.height*n}}))]}const a=s(i.getAttribute("src")),o=i.getAttribute("alt")||a||"[…]",l=[new t.TextRun(Object.assign(Object.assign({},n),{text:o}))];return a&&!i.closest("a")?[new t.ExternalHyperlink({link:a,children:l})]:l}const c="A"===i.tagName?s(i.getAttribute("href")):void 0,d=m(i.childNodes,c?Object.assign(Object.assign({},l),{color:"174EA6",underline:{type:t.UnderlineType.SINGLE}}):l,r);return c?[new t.ExternalHyperlink({link:c,children:d})]:d})),p=(e,n,r={})=>{const a=n.marker&&!n.marker.used?n.marker:void 0;return a&&(a.used=!0),new t.Paragraph(Object.assign(Object.assign(Object.assign({children:e,spacing:{after:160},widowControl:!0},n.indent?{indent:Object.assign({left:n.indent},a?{hanging:360}:{})}:{}),null==a?void 0:a.properties),r))},b=(e,n)=>{var r;const a="OL"===e.tagName;let i="",s=!1;const o=e=>{i=`response-list-${h.length}`,s=0===e,h.push({reference:i,levels:[{level:0,format:t.LevelFormat.DECIMAL,text:s?"0.":"%1.",start:s?1:e,alignment:t.AlignmentType.LEFT}]})},l=e.hasAttribute("reversed"),c=Array.from(e.children).filter((e=>"LI"===e.tagName)),d=Number.parseInt(e.getAttribute("start")||"",10);let u=Number.isFinite(d)?d:l?c.length:1;a&&o(u);const g=[];for(const t of Array.from(e.children)){if("LI"!==t.tagName){g.push(...w([t],n));continue}const e=Number.parseInt(t.getAttribute("value")||"",10);a&&Number.isFinite(e)&&(u=e),a&&(l||s||0===u||Number.isFinite(e))&&o(u),u+=l?-1:1;const c=Object.assign(Object.assign({},n),{indent:Math.min(n.indent+720,5760),marker:{used:!1,properties:a?{numbering:{reference:i,level:0}}:{bullet:{level:0}}}}),d=w(t.childNodes,c);(null===(r=c.marker)||void 0===r?void 0:r.used)||d.unshift(p([],c)),g.push(...d)}return g},f=(e,n)=>{const r=[];let a=0;const i=Array.from(e.querySelectorAll("tr")).filter((t=>t.closest("table")===e)).map(((e,t)=>{let n=0;return{row:e,cells:Array.from(e.children).filter((e=>"TD"===e.tagName||"TH"===e.tagName)).map((e=>{for(;r[n]>t;)n++;const i=t=>Math.min(100,Math.max(1,parseInt(e.getAttribute(t)||"1",10)||1)),s=i("colspan"),o=i("rowspan"),l=n;for(let e=0;e<s;e++)r[n++]=t+o;return a=Math.max(a,n),{cell:e,start:l,columnSpan:s,rowSpan:o}}))}})),s=e=>Math.floor(e*n/a),o=Array.from({length:a},((e,t)=>s(t+1)-s(t))),l=i.flatMap((({row:e,cells:n})=>{var r;return n.length?[new t.TableRow({tableHeader:"THEAD"===(null===(r=e.parentElement)||void 0===r?void 0:r.tagName)||n.every((({cell:e})=>"TH"===e.tagName)),children:n.map((({cell:e,start:n,columnSpan:r,rowSpan:a})=>{const i=s(n+r)-s(n),o=w(e.childNodes,{indent:0,width:Math.max(1,i-200),run:{bold:"TH"===e.tagName}});return o[o.length-1]instanceof t.Paragraph||o.push(new t.Paragraph("")),new t.TableCell(Object.assign({children:o,columnSpan:r,rowSpan:a,width:{size:i,type:t.WidthType.DXA},margins:{top:80,bottom:80,left:100,right:100}},"TH"===e.tagName?{shading:{fill:"F0F0F0"}}:{}))}))})]:[]})),c=Array.from(e.children).filter((e=>"CAPTION"===e.tagName));return l.length?[...w(c,{indent:0,width:n,run:{}}),new t.Table({rows:l,width:{size:n,type:t.WidthType.DXA},columnWidths:o})]:w(e.childNodes,{indent:0,width:n,run:{}})},w=(e,n)=>{const r=[];let a=[];const s=()=>{a.some((e=>{var t;return(null===(t=e.textContent)||void 0===t?void 0:t.trim())||1===e.nodeType&&/^(BR|IMG)$/.test(e.tagName)||1===e.nodeType&&e.querySelector("br,img")}))&&r.push(p(m(a,n.run,n.width-n.indent),n)),a=[]};for(const l of Array.from(e)){if(1!==l.nodeType||!i.has(l.tagName)){1===l.nodeType&&Array.from(l.children).some((e=>i.has(e.tagName)))?(s(),r.push(...w(l.childNodes,Object.assign(Object.assign({},n),{run:o(l,n.run)})))):a.push(l);continue}s();const e=l,c=e.tagName;if("UL"===c||"OL"===c)n.marker&&!n.marker.used&&r.push(p([],n)),r.push(...b(e,n));else if("TABLE"===c)n.marker&&!n.marker.used&&r.push(p([],n)),r.push(...f(e,n.width));else if("PRE"===c){const a=(e.textContent||"").replace(/\r\n?/g,"\n").split("\n");r.push(p(a.map(((e,r)=>new t.TextRun(Object.assign(Object.assign(Object.assign({},n.run),{children:e.split("\t").flatMap(((e,n)=>n?[new t.Tab,e]:[e])),font:"Courier New",size:20}),r?{break:1}:{})))),n,{shading:{fill:"F4F4F4"},spacing:{before:120,after:160}}))}else if(/^H[1-6]$/.test(c)){const a=[t.HeadingLevel.HEADING_1,t.HeadingLevel.HEADING_2,t.HeadingLevel.HEADING_3,t.HeadingLevel.HEADING_4,t.HeadingLevel.HEADING_5,t.HeadingLevel.HEADING_6];r.push(p(m(e.childNodes,Object.assign(Object.assign({},n.run),{bold:!0,color:"202020"}),n.width-n.indent),n,{heading:a[Number(c[1])-1],keepNext:!0}))}else if("HR"===c)r.push(p([],n,{border:{bottom:{style:t.BorderStyle.SINGLE,color:"CCCCCC",size:4}}}));else{const t="BLOCKQUOTE"===c?Object.assign(Object.assign({},n),{indent:n.indent+360}):n,a=w(e.childNodes,t);r.push(...a),a.length||"P"!==c||r.push(p([],t))}}return s(),r},A=w(d.childNodes,{indent:0,width:10800,run:{}}),N=new t.Document({title:"Pickaxe",creator:"Pickaxe",styles:{default:{document:{run:{font:"Arial",size:22,color:"202020"}}}},numbering:{config:h},sections:[{properties:{page:{size:{width:12240,height:15840},margin:{top:a,bottom:a,left:a,right:a}}},children:A.length?A:[new t.Paragraph("")]}]});return t.Packer.toBlob(N)}));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("react"),r=require("react-dom/server"),n=require("react-markdown"),o=require("remark-gfm"),a=require("rehype-raw"),i=require("isomorphic-dompurify"),l=require("./responseArtifactStyles.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=d(n),s=d(o),c=d(a),h=d(i);const w=e=>{const n=r.renderToStaticMarkup(t.createElement(p.default,{remarkPlugins:[s.default],rehypePlugins:[c.default],components:{input:({type:e,checked:r})=>"checkbox"===(null==e?void 0:e.toLowerCase())?t.createElement("span",null,r?"☑":"☐"):null}},e));return m(n)},m=(e,t=!1)=>{let r=h.default.sanitize(e,{USE_PROFILES:{html:!0},FORBID_TAGS:["script","style","iframe","form","input","button","select","textarea","object","embed","link","meta","base","audio","video","source","track"],FORBID_ATTR:["srcset","ping","background",...t?[]:["style"]],ALLOW_DATA_ATTR:!1});if(t){const e=document.createElement("template");e.innerHTML=r,l.filterArtifactStyles(e.content),e.content.querySelectorAll("label").forEach((e=>{var t;(null===(t=e.textContent)||void 0===t?void 0:t.trim())||e.children.length||e.remove()})),r=e.innerHTML}return`<!doctype html>\n<html>\n<head>\n<meta charset="utf-8">\n<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src https: data:; base-uri 'none'; form-action 'none'">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<title>Pickaxe</title>\n<style>\nbody { margin: 0; background: white; color: #202020; font: 16px/1.6 system-ui, sans-serif; }\nmain { max-width: 900px; margin: 0 auto; padding: 24px; overflow-wrap: anywhere; }\nh1, h2, h3, h4, h5, h6 { line-height: 1.25; }\na { color: #174ea6; }\npre, code { font-family: ui-monospace, monospace; }\npre { padding: 16px; background: #f4f4f4; overflow-x: auto; white-space: pre; }\nblockquote { margin-left: 0; padding-left: 16px; border-left: 3px solid #ccc; }\ntable { border-collapse: collapse; max-width: 100%; }\nth, td { border: 1px solid #ccc; padding: 8px; text-align: start; }\nimg { max-width: 100%; height: auto; }\nsummary { cursor: pointer; }\n${t?"\n.pxe-export-artifact { max-width: 100%; overflow-x: auto; }\n.pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 720px; }\n.pxe-export-artifact table { width: 100%; max-width: 100%; }\n.pxe-export-artifact th, .pxe-export-artifact td { overflow-wrap: anywhere; }\n@media print {\n .pxe-export-artifact { overflow: visible; }\n .pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 0; }\n .pxe-export-artifact table { width: 100%; min-width: 0; max-width: 100%; table-layout: fixed; }\n .pxe-export-artifact th, .pxe-export-artifact td { padding: 5px !important; font-size: 10px !important; overflow-wrap: anywhere; }\n .pxe-export-artifact, .pxe-export-artifact * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }\n}\n":""}</style>\n</head>\n<body><main dir="auto">${r}</main></body>\n</html>`},u=(t,r)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=null!=r?r:window.open("","_blank");if(!e||e.closed)throw new Error("Unable to open the response print window.");try{e.opener=null;const r=e.document;r.open(),r.write(t);const n=r.createElement("style");if(n.media="print",n.textContent="\n@page { margin: 12mm; }\nmain { max-width: none; padding: 0; }\npre { overflow: visible; }\npre, pre code { white-space: pre-wrap; overflow-wrap: anywhere; }\ntable { width: 100%; table-layout: fixed; }\nth, td { white-space: normal; overflow-wrap: anywhere; }\nthead { display: table-header-group; }\ntr, img { break-inside: avoid; }\nh1, h2, h3, h4, h5, h6 { break-after: avoid; }\np, li { orphans: 3; widows: 3; }\n",r.head.appendChild(n),r.querySelectorAll("details").forEach((e=>{e.open=!0})),r.querySelectorAll("img").forEach((e=>{e.loading="eager"})),r.close(),e.focus(),yield f(e,r),e.closed)throw new Error("The response print window was closed.");r.body.offsetHeight,e.focus(),e.print()}catch(t){throw e.close(),t}})),f=(t,r)=>new Promise(((n,o)=>{const a=window.setTimeout((()=>d(new Error("Response print images did not finish loading."))),15e3),i=window.setInterval((()=>{t.closed&&d(new Error("The response print window was closed."))}),100);let l=!1;function d(e){l||(l=!0,window.clearTimeout(a),window.clearInterval(i),e?o(e):n())}Promise.all([...Array.from(r.images,(t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(yield t.decode(),!t.complete||!t.naturalWidth||!t.naturalHeight)throw new Error("Unable to load a response print image.")})))),r.fonts.ready]).then((()=>d()),(()=>d(new Error("Unable to load the response print resources."))))}));exports.createResponseDownloadDocument=m,exports.createResponseDownloadHtml=w,exports.printResponseDownloadDocument=u,exports.printResponseDownloadHtml=e=>u(w(e));
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("react"),r=require("react-dom/server"),n=require("react-markdown"),o=require("remark-gfm"),a=require("rehype-raw"),i=require("isomorphic-dompurify"),l=require("./responseArtifactStyles.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var c=d(n),p=d(o),s=d(a),h=d(i);const w=e=>{const n=r.renderToStaticMarkup(t.createElement(c.default,{remarkPlugins:[p.default],rehypePlugins:[s.default],components:{input:({type:e,checked:r})=>"checkbox"===(null==e?void 0:e.toLowerCase())?t.createElement("span",null,r?"☑":"☐"):null}},e));return m(n)},m=(e,t=!1)=>{let r=h.default.sanitize(e,{USE_PROFILES:{html:!0},FORBID_TAGS:["script","style","iframe","form","input","button","select","textarea","object","embed","link","meta","base","audio","video","source","track"],FORBID_ATTR:["srcset","ping","background",...t?[]:["style"]],ALLOW_DATA_ATTR:!1});if(t){const e=document.createElement("template");e.innerHTML=r,l.filterArtifactStyles(e.content),e.content.querySelectorAll("label").forEach((e=>{var t;(null===(t=e.textContent)||void 0===t?void 0:t.trim())||e.children.length||e.remove()})),r=e.innerHTML}return`<!doctype html>\n<html>\n<head>\n<meta charset="utf-8">\n<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src https: data:; base-uri 'none'; form-action 'none'">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<title>Pickaxe</title>\n<style>\nbody { margin: 0; background: white; color: #202020; font: 16px/1.6 system-ui, sans-serif; }\nmain { max-width: 900px; margin: 0 auto; padding: 24px; overflow-wrap: anywhere; }\nh1, h2, h3, h4, h5, h6 { line-height: 1.25; }\na { color: #174ea6; }\npre, code { font-family: ui-monospace, monospace; }\npre { padding: 16px; background: #f4f4f4; overflow-x: auto; white-space: pre; }\nblockquote { margin-left: 0; padding-left: 16px; border-left: 3px solid #ccc; }\ntable { border-collapse: collapse; max-width: 100%; }\nth, td { border: 1px solid #ccc; padding: 8px; text-align: start; }\nimg { max-width: 100%; height: auto; }\nsummary { cursor: pointer; }\n${t?"\n.pxe-export-artifact { max-width: 100%; overflow-x: auto; }\n.pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 720px; }\n.pxe-export-artifact table { width: 100%; max-width: 100%; }\n.pxe-export-artifact th, .pxe-export-artifact td { overflow-wrap: anywhere; }\n@media print {\n .pxe-export-artifact { overflow: visible; }\n .pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 0; }\n .pxe-export-artifact table { width: 100%; min-width: 0; max-width: 100%; table-layout: fixed; }\n .pxe-export-artifact th, .pxe-export-artifact td { padding: 5px !important; font-size: 10px !important; overflow-wrap: anywhere; }\n .pxe-export-artifact, .pxe-export-artifact * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }\n}\n":""}</style>\n</head>\n<body><main dir="auto">${r}</main></body>\n</html>`},u=(t,r)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=null!=r?r:window.open("","_blank");if(!e||e.closed)throw new Error("Unable to open the response print window.");try{e.opener=null;const r=e.document;r.open(),r.write(t);const n=r.createElement("style");if(n.media="print",n.textContent="\n@page { margin: 12mm; }\nmain { max-width: none; padding: 0; }\npre { overflow: visible; }\npre, pre code { white-space: pre-wrap; overflow-wrap: anywhere; }\ntable { width: 100%; table-layout: fixed; }\nth, td { white-space: normal; overflow-wrap: anywhere; }\nthead { display: table-header-group; }\ntr, img { break-inside: avoid; }\nh1, h2, h3, h4, h5, h6 { break-after: avoid; }\np, li { orphans: 3; widows: 3; }\n",r.head.appendChild(n),r.querySelectorAll("details").forEach((e=>{e.open=!0})),r.querySelectorAll("img").forEach((e=>{e.loading="eager"})),r.close(),e.focus(),yield f(e,r),e.closed)throw new Error("The response print window was closed.");r.body.offsetHeight,e.focus(),e.print()}catch(t){throw e.close(),t}})),f=(t,r)=>new Promise(((n,o)=>{const a=new Set(Array.from(r.images)),i=e=>{if(c)return;a.delete(e);const t=r.createElement("span");t.textContent=`⚠ ${e.alt.trim()||"[…]"}`,t.style.cssText="display:inline-block;border:1px solid #999;padding:4px;white-space:normal;overflow-wrap:anywhere;",e.removeAttribute("src"),e.removeAttribute("srcset"),e.replaceWith(t)},l=window.setTimeout((()=>{a.forEach(i),p()}),15e3),d=window.setInterval((()=>{t.closed&&p(new Error("The response print window was closed."))}),100);let c=!1;function p(e){c||(c=!0,window.clearTimeout(l),window.clearInterval(d),e?o(e):n())}Promise.all([...Array.from(a,(t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(yield t.decode(),!t.complete||!t.naturalWidth||!t.naturalHeight)throw new Error("Unable to load a response print image.");a.delete(t)}catch(e){i(t)}})))),r.fonts.ready]).then((()=>p()),(()=>p(new Error("Unable to load the response print resources."))))}));exports.createResponseDownloadDocument=m,exports.createResponseDownloadHtml=w,exports.printResponseDownloadDocument=u,exports.printResponseDownloadHtml=e=>u(w(e));
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js");const t=75e5,r=25e6,o=e=>{if(/^data:image\/(png|jpeg|gif|webp);base64,/i.test(e))return e.length<=105e5?e:void 0;try{const t=new URL(e);if(!t.username&&!t.password&&("https:"===t.protocol||"http:"===t.protocol&&t.origin===location.origin))return t.href}catch(e){}},n=(e,t)=>new Promise(((r,o)=>{const n=new Image,i=e=>{n.onload=n.onerror=null,t.removeEventListener("abort",a),e&&n.naturalWidth&&n.naturalHeight?r(n):(n.removeAttribute("src"),o(new Error("Image unavailable.")))},a=()=>i(!1);if(t.aborted)return a();t.addEventListener("abort",a,{once:!0}),n.referrerPolicy="no-referrer",n.onload=()=>i(!0),n.onerror=()=>i(!1),n.src=e})),i=(i,a)=>e.__awaiter(void 0,void 0,void 0,(function*(){const l=Array.from(i.querySelectorAll("img")),s=new Set,c=new AbortController,d=setTimeout((()=>c.abort()),15e3),u=new Map;let m=0,g=0;const h=o=>e.__awaiter(void 0,void 0,void 0,(function*(){let i,l;try{if(c.signal.aborted)return;const s=yield((r,o)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;const n=yield fetch(r,{signal:o,credentials:"omit",referrerPolicy:"no-referrer"});if(!n.ok||!n.body)throw new Error("Image unavailable.");const i=null===(e=n.headers.get("content-type"))||void 0===e?void 0:e.split(";")[0].trim();if(!i||!/^image\/(png|jpeg|gif|webp|svg\+xml)$/i.test(i)||Number(n.headers.get("content-length"))>t)throw yield n.body.cancel(),new Error("Unsupported image.");const a=n.body.getReader(),l=[];let s=0;try{for(;;){const{done:e,value:r}=yield a.read();if(e)break;if(s+=r.byteLength,s>t)throw new Error("Image too large.");l.push(r)}}finally{yield a.cancel()}return new Blob(l,{type:i})})))(o,c.signal);if(m+=s.size,m>r)return;if(i=URL.createObjectURL(s),l=yield n(i,c.signal),l.naturalWidth*l.naturalHeight>16e6)return;if("docx"===a||"image/svg+xml"===s.type){const e=document.createElement("canvas");try{e.width=l.naturalWidth,e.height=l.naturalHeight;const t=e.getContext("2d");if(!t)return;t.drawImage(l,0,0);const o=e.toDataURL("image/png");if(m+=o.length,o.length>1e7||m>r)return;return o}finally{e.width=e.height=0}}const d=new Uint8Array(yield s.arrayBuffer());let u="";for(let e=0;e<d.length;e+=8192)u+=String.fromCharCode(...d.subarray(e,e+8192));return`data:${s.type};base64,${btoa(u)}`}catch(e){return}finally{null==l||l.removeAttribute("src"),i&&URL.revokeObjectURL(i)}}));try{yield Promise.all(Array.from({length:Math.min(4,l.length)},(()=>e.__awaiter(void 0,void 0,void 0,(function*(){for(var e,t;g<l.length;){const r=l[g++],i=o(r.getAttribute("src")||"");let d;if(i&&(u.has(i)||u.size<50)&&(u.has(i)||u.set(i,h(i)),d=yield u.get(i)),d)s.add(r),r.setAttribute("src",d),r.removeAttribute("srcset");else if("html"===a&&(null==i?void 0:i.startsWith("https:")))try{(yield n(i,c.signal)).removeAttribute("src");continue}catch(t){const o=document.createElement("span");o.textContent=`⚠ ${(null===(e=r.getAttribute("alt"))||void 0===e?void 0:e.trim())||"[…]"}`,r.replaceWith(o)}else if("html"===a){const e=document.createElement("span");e.textContent=`⚠ ${(null===(t=r.getAttribute("alt"))||void 0===t?void 0:t.trim())||"[…]"}`,r.replaceWith(e)}}})))))}finally{clearTimeout(d),c.abort()}return s}));exports.embedResponseDownloadHtmlImages=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=(new DOMParser).parseFromString(t,"text/html");yield i(e,"html");for(const t of e.querySelectorAll("iframe[srcdoc]")){const e=t.getAttribute("srcdoc");if(e){const r=(new DOMParser).parseFromString(e,"text/html");yield i(r,"html"),t.setAttribute("srcdoc",`<!doctype html>\n${r.documentElement.outerHTML}`)}}return`<!doctype html>\n${e.documentElement.outerHTML}`})),exports.embedResponseDownloadImages=i;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),n=require("react-dom"),r=require("uuid"),s=require("file-saver"),i=require("../../../common/responseDownloadDocx.js"),l=require("../../../common/responseDownloadHtml.js"),a=require("../../../common/responseDownloadArtifacts.js"),u=require("../../../common/responseArtifactSnapshot.js"),d=require("../Addons/Artifact/hooks/useArtifactContext.js"),c=require("../Addons/Artifact/hooks/useArtifactData.js"),f=require("../Addons/Auth/hooks/useAuthContext.js"),p=require("../../../hooks/pickaxe/usePickaxeContext.js"),m=require("../../../hooks/core/useOutsideAlerter.js"),x=require("../../Icons/download.svg.js"),v=require("../../Core/Menu/index.js"),y=require("../../Core/Menu/List.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var w=h(s);const b=[{extension:"txt",label:"TXT",mimeType:"text/plain;charset=utf-8"},{extension:"md",label:"Markdown (.md)",mimeType:"text/markdown;charset=utf-8"},{extension:"html",label:"HTML (.html)",mimeType:"text/html;charset=utf-8"},{extension:"pdf",label:"PDF"},{extension:"docx",label:"DOCX"}];exports.default=({color:s,text:h,disabled:g=!1})=>{const{translations:j,colors:k,styles:A,isRtl:D,sender:q,senderType:C,pickaxe:O}=p.usePickaxeContext(),{artifacts:T=[]}=d.useArtifactContext(),{token:R}=f.useAuthContext(),S=c.useArtifactData(),[P,_]=o.useState(""),[E,M]=o.useState(!1),[H,N]=o.useState(),[I,$]=o.useState(!1),B=o.useRef(!1),F=o.useRef(null),L=o.useRef(null),K=o.useRef([]),U=o.useRef(0),X=(null==j?void 0:j.download)||"Download",W=g||I||!h.trim();o.useEffect((()=>{_(`response-download-${r.v4()}`)}),[]),o.useEffect((()=>{W&&M(!1)}),[W]),o.useEffect((()=>{E&&F.current&&N(getComputedStyle(F.current).fontFamily)}),[E,A.font]),m.useOutsideAlerter({ref:[F,L],callback:()=>M(!1)});const z=()=>{var e;M(!1),null===(e=F.current)||void 0===e||e.focus({preventScroll:!0})},G=e=>{var t;if(!W)if("Escape"===e.key&&E)e.preventDefault(),e.stopPropagation(),z();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();const o=K.current.indexOf(e.currentTarget),n="ArrowDown"===e.key?1:-1,r=b.length,s=-1===o?1===n?0:r-1:(o+n+r)%r;U.current=s,M(!0),null===(t=K.current[s])||void 0===t||t.focus({preventScroll:!0})}else"Tab"===e.key&&M(!1)},J=e=>{e.relatedTarget===F.current||K.current.some((t=>t===e.relatedTarget))||M(!1)};return t.jsxs(v.default,Object.assign({id:P,className:"h-4 w-4 shrink-0",isOpen:E&&!W,onChange:M,closeOnSelect:!1,closeOnClickOutside:!1},{children:[t.jsx("button",Object.assign({ref:F,id:P||void 0,type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-30",style:{color:s},title:X,"aria-label":X,"aria-haspopup":"menu","aria-busy":I,"aria-expanded":E&&!W,"aria-controls":E&&!W?`${P}-menu`:void 0,disabled:W,onClick:e=>{e.stopPropagation(),U.current=0,M((e=>!e))},onKeyDown:G,onBlur:J},{children:t.jsx(x.default,{className:"h-4 w-4 shrink-0","aria-hidden":"true"})})),P&&!W&&n.createPortal(t.jsx("div",Object.assign({ref:L,style:{fontFamily:H},dir:D?"rtl":"ltr"},{children:t.jsx(y.default,Object.assign({id:`${P}-menu`,role:"menu",align:"right",width:"auto",className:"p-1 text-sm",style:{backgroundColor:k.primary,color:k.text,maxWidth:"calc(100vw - 32px)"},imperativeModeOnly:!0,afterShow:()=>{var e;return null===(e=K.current[U.current])||void 0===e?void 0:e.focus({preventScroll:!0})}},{children:b.map(((o,n)=>t.jsx("button",Object.assign({ref:e=>{K.current[n]=e},type:"button",role:"menuitem",tabIndex:-1,className:"rounded-sm px-3 py-2 text-left hover:bg-black/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px]",onClick:t=>{((t,o)=>{e.__awaiter(void 0,void 0,void 0,(function*(){var n;if(t.stopPropagation(),W||B.current)return;let r;z();try{const t=a.findResponseArtifacts(h);let s;if(t.length){if(B.current=!0,$(!0),"pdf"===o.extension){if(r=null!==(n=window.open("","_blank"))&&void 0!==n?n:void 0,!r)throw new Error("Unable to open the print window.");r.opener=null;const e=r.document.createElement("p");e.textContent=(null==j?void 0:j.loading)||"Loading...",e.setAttribute("role","status"),e.style.cssText="margin:32px;font:16px system-ui,sans-serif",r.document.body.appendChild(e)}s=yield a.prepareResponseArtifactDownload(h,t,(t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=T.find((e=>e.id===t.id&&e.version===t.version));return null!=e?e:S.mutateAsync({artifactId:t.id,version:t.version,studioId:null==O?void 0:O.studioid,senderType:C,sender:q||void 0,studioSessionToken:R||void 0})}))),o.extension,(e=>u.renderResponseArtifactHtml(e,"pdf"===o.extension||"docx"===o.extension,r)))}if("docx"===o.extension){B.current=!0,$(!0);const e=yield i.createResponseDownloadDocx(h,s);return void w.default(e,"response.docx")}if("pdf"===o.extension)return B.current=!0,$(!0),void(s?yield l.printResponseDownloadDocument(s,r):yield l.printResponseDownloadHtml(h));const d=null!=s?s:"html"===o.extension?l.createResponseDownloadHtml(h):h,c=new Blob([d],{type:o.mimeType});w.default(c,`response.${o.extension}`)}catch(e){console.error("Response download failed",{format:o.extension,error:e}),null==r||r.close(),window.alert((null==j?void 0:j["something-went-wrong"])||"Something went wrong.")}finally{B.current=!1,$(!1)}}))})(t,o)},onKeyDown:G,onBlur:J},{children:o.label}),o.extension)))}))})),document.body)]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),n=require("react-dom"),r=require("uuid"),s=require("file-saver"),i=require("../../../common/responseDownloadDocx.js"),l=require("../../../common/responseDownloadImages.js"),a=require("../../../common/responseDownloadHtml.js"),u=require("../../../common/responseDownloadArtifacts.js"),d=require("../../../common/responseArtifactSnapshot.js"),c=require("../Addons/Artifact/hooks/useArtifactContext.js"),f=require("../Addons/Artifact/hooks/useArtifactData.js"),p=require("../Addons/Auth/hooks/useAuthContext.js"),m=require("../../../hooks/pickaxe/usePickaxeContext.js"),x=require("../../../hooks/core/useOutsideAlerter.js"),v=require("../../Icons/download.svg.js"),w=require("../../Core/Menu/index.js"),y=require("../../Core/Menu/List.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=h(s);const g=[{extension:"txt",label:"TXT",mimeType:"text/plain;charset=utf-8"},{extension:"md",label:"Markdown (.md)",mimeType:"text/markdown;charset=utf-8"},{extension:"html",label:"HTML (.html)",mimeType:"text/html;charset=utf-8"},{extension:"pdf",label:"PDF"},{extension:"docx",label:"DOCX"}];exports.default=({color:s,text:h,disabled:j=!1})=>{const{translations:k,colors:A,styles:D,isRtl:q,sender:C,senderType:O,pickaxe:R}=m.usePickaxeContext(),{artifacts:T=[]}=c.useArtifactContext(),{token:S}=p.useAuthContext(),P=f.useArtifactData(),[_,E]=o.useState(""),[H,I]=o.useState(!1),[M,N]=o.useState(),[$,B]=o.useState(!1),F=o.useRef(!1),L=o.useRef(null),K=o.useRef(null),U=o.useRef([]),X=o.useRef(0),W=(null==k?void 0:k.download)||"Download",z=j||$||!h.trim();o.useEffect((()=>{E(`response-download-${r.v4()}`)}),[]),o.useEffect((()=>{z&&I(!1)}),[z]),o.useEffect((()=>{H&&L.current&&N(getComputedStyle(L.current).fontFamily)}),[H,D.font]),x.useOutsideAlerter({ref:[L,K],callback:()=>I(!1)});const G=()=>{var e;I(!1),null===(e=L.current)||void 0===e||e.focus({preventScroll:!0})},J=e=>{var t;if(!z)if("Escape"===e.key&&H)e.preventDefault(),e.stopPropagation(),G();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();const o=U.current.indexOf(e.currentTarget),n="ArrowDown"===e.key?1:-1,r=g.length,s=-1===o?1===n?0:r-1:(o+n+r)%r;X.current=s,I(!0),null===(t=U.current[s])||void 0===t||t.focus({preventScroll:!0})}else"Tab"===e.key&&I(!1)},Q=e=>{e.relatedTarget===L.current||U.current.some((t=>t===e.relatedTarget))||I(!1)};return t.jsxs(w.default,Object.assign({id:_,className:"h-4 w-4 shrink-0",isOpen:H&&!z,onChange:I,closeOnSelect:!1,closeOnClickOutside:!1},{children:[t.jsx("button",Object.assign({ref:L,id:_||void 0,type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-30",style:{color:s},title:W,"aria-label":W,"aria-haspopup":"menu","aria-busy":$,"aria-expanded":H&&!z,"aria-controls":H&&!z?`${_}-menu`:void 0,disabled:z,onClick:e=>{e.stopPropagation(),X.current=0,I((e=>!e))},onKeyDown:J,onBlur:Q},{children:t.jsx(v.default,{className:"h-4 w-4 shrink-0","aria-hidden":"true"})})),_&&!z&&n.createPortal(t.jsx("div",Object.assign({ref:K,style:{fontFamily:M},dir:q?"rtl":"ltr"},{children:t.jsx(y.default,Object.assign({id:`${_}-menu`,role:"menu",align:"right",width:"auto",className:"p-1 text-sm",style:{backgroundColor:A.primary,color:A.text,maxWidth:"calc(100vw - 32px)"},imperativeModeOnly:!0,afterShow:()=>{var e;return null===(e=U.current[X.current])||void 0===e?void 0:e.focus({preventScroll:!0})}},{children:g.map(((o,n)=>t.jsx("button",Object.assign({ref:e=>{U.current[n]=e},type:"button",role:"menuitem",tabIndex:-1,className:"rounded-sm px-3 py-2 text-left hover:bg-black/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px]",onClick:t=>{((t,o)=>{e.__awaiter(void 0,void 0,void 0,(function*(){var n;if(t.stopPropagation(),z||F.current)return;let r;G();try{const t=u.findResponseArtifacts(h);let s;if(t.length){if(F.current=!0,B(!0),"pdf"===o.extension){if(r=null!==(n=window.open("","_blank"))&&void 0!==n?n:void 0,!r)throw new Error("Unable to open the print window.");r.opener=null;const e=r.document.createElement("p");e.textContent=(null==k?void 0:k.loading)||"Loading...",e.setAttribute("role","status"),e.style.cssText="margin:32px;font:16px system-ui,sans-serif",r.document.body.appendChild(e)}s=yield u.prepareResponseArtifactDownload(h,t,(t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=T.find((e=>e.id===t.id&&e.version===t.version));return null!=e?e:P.mutateAsync({artifactId:t.id,version:t.version,studioId:null==R?void 0:R.studioid,senderType:O,sender:C||void 0,studioSessionToken:S||void 0})}))),o.extension,(e=>d.renderResponseArtifactHtml(e,"pdf"===o.extension||"docx"===o.extension,r)))}if("docx"===o.extension){F.current=!0,B(!0);const e=yield i.createResponseDownloadDocx(h,s);return void b.default(e,"response.docx")}if("pdf"===o.extension)return F.current=!0,B(!0),void(s?yield a.printResponseDownloadDocument(s,r):yield a.printResponseDownloadHtml(h));let c=null!=s?s:"html"===o.extension?a.createResponseDownloadHtml(h):h;"html"===o.extension&&(F.current=!0,B(!0),c=yield l.embedResponseDownloadHtmlImages(c));const f=new Blob([c],{type:o.mimeType});b.default(f,`response.${o.extension}`)}catch(e){console.error("Response download failed",{format:o.extension,error:e}),null==r||r.close(),window.alert((null==k?void 0:k["something-went-wrong"])||"Something went wrong.")}finally{F.current=!1,B(!1)}}))})(t,o)},onKeyDown:J,onBlur:Q},{children:o.label}),o.extension)))}))})),document.body)]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),s=require("react"),n=require("./hooks/usePickaxeMarkdownContext.js"),i=require("./utils/custom-plugins.js"),t=require("react-markdown"),o=require("remark-gfm"),a=require("remark-math"),l=require("rehype-katex"),c=require("rehype-raw"),u=require("./Components/A/index.js"),d=require("./Components/A/FilePreview.js"),p=require("./Components/P/index.js"),f=require("./Components/Img/index.js"),h=require("./Components/Iframe/index.js"),m=require("./Components/Code/index.js"),x=require("./Components/Headings/index.js"),g=require("./Components/List/index.js"),j=require("./Components/Table/index.js"),w=require("./Components/Others/index.js"),v=require("./Components/Action/index.js"),b=require("./Components/Artifact/index.js"),k=require("./Components/Others/Think.js"),C=require("../../../../common/cn.js");function q(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var P=q(t),R=q(o),y=q(a),S=q(l),O=q(c);exports.PickaxeMarkdownRenderer=({className:t,style:o,children:a,value:l,maxLines:c,maxChars:q,multiLineBreaks:$,onExpandClick:A,filePreviewSeenRef:U,suppressedRichPreviewUrls:H})=>{const{colors:M,rtl:T,disableHtml:E,disableJs:I,disableCss:_}=n.usePickaxeMarkdownContext(),[N,F]=s.useState({width:0,height:0}),[L,B]=s.useState(null),z=s.useRef(null),J=s.useMemo((()=>{if(!l)return"";if(E)return l;let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),$&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,$,E]);s.useEffect((()=>{if(q)return void B(J.length>q?J.slice(0,q)+'<span class="pxe-expand-btn">...</span>':null);if(!c)return void B(null);if(!z.current||!J||L)return;const e=z.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),s=c*r;if(!(N.height>s))return;const n=Math.floor(N.width/8),i=Math.floor(n*c);B(J.slice(0,i)+'<span class="pxe-expand-btn">...</span>')}),[J,c,q,N,L]);const W=s.useRef(new Set);U||(W.current=new Set);const D=null!=U?U:W,Q=s.useRef({colors:M,onExpandClick:A,filePreviewSeenRef:D,suppressedRichPreviewUrls:H});Q.current={colors:M,onExpandClick:A,filePreviewSeenRef:D,suppressedRichPreviewUrls:H};const G=s.useMemo((()=>({h1:x.H1,h2:x.H2,h3:x.H3,h4:x.H4,h5:x.H5,p:e=>r.jsx(p.P,Object.assign({},e,{suppressedRichPreviewUrls:Q.current.suppressedRichPreviewUrls})),a:e=>r.jsx(u.A,Object.assign({},e,{filePreviewSeenRef:Q.current.filePreviewSeenRef,suppressedRichPreviewUrls:Q.current.suppressedRichPreviewUrls})),img:e=>{const{colors:s,filePreviewSeenRef:n,suppressedRichPreviewUrls:i}=Q.current,t="string"==typeof e.src?e.src:"",o=d.getFilePreviewInfo(t);return o&&!d.shouldSuppressRichPreviewForUrl(o.url,i)?d.shouldRenderFilePreview(o,n)?r.jsx(d.default,{fileInfo:o,displayName:"string"==typeof e.alt?e.alt:void 0}):r.jsx("a",Object.assign({href:o.url,target:"_blank",rel:"noopener noreferrer",style:{color:s.accent}},{children:e.alt||o.fileName})):r.jsx(f.Img,Object.assign({},e))},iframe:h.Iframe,code:m.Code,ol:g.Ol,ul:g.Ul,li:g.Li,table:j.Table,th:j.Th,tr:j.Tr,td:j.Td,hr:w.Hr,br:w.Br,blockquote:w.Blockquote,span:s=>{var{children:n}=s,i=e.__rest(s,["children"]);const{colors:t,onExpandClick:o}=Q.current;return"pxe-expand-btn"===i.className?r.jsx("span",Object.assign({},i,{style:Object.assign({display:"inline",fontWeight:500,color:t.accent,marginLeft:".25rem",userSelect:"none"},o&&{cursor:"pointer"})},o&&{onClick:o},{children:n})):r.jsx("span",Object.assign({},i,{children:n}))},"action-caption":v.ActionCaption,"action-finished":v.ActionFinished,"action-error":v.ActionError,artifact:b.Artifact,"artifact-error":b.ArtifactError,think:k.Think})),[]);s.useEffect((()=>{if(!z.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:s}=r.contentRect;F({width:e,height:s})}}));return e.observe(z.current),()=>{e.disconnect()}}),[]);const K=L||J;return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:z,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},o)},T&&{dir:"rtl"},{children:[r.jsx(P.default,Object.assign({className:C.default("pxe-prose",t),components:G,remarkPlugins:[R.default,[y.default,{singleDollarTextMath:!1}],i.remarkSmartQuotes],rehypePlugins:[i.rehypeCode,S.default,...E?[]:[O.default],[i.rehypeSanitize,{disableJs:I,disableCss:_}]]},{children:K})),a]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),s=require("react"),n=require("./hooks/usePickaxeMarkdownContext.js"),i=require("./utils/custom-plugins.js"),t=require("react-markdown"),o=require("remark-gfm"),a=require("remark-math"),l=require("rehype-katex"),c=require("rehype-raw"),u=require("./Components/A/index.js"),d=require("./Components/A/FilePreview.js"),p=require("./Components/P/index.js"),f=require("./Components/Img/index.js"),h=require("./Components/Iframe/index.js"),m=require("./Components/Code/index.js"),x=require("./Components/Headings/index.js"),g=require("./Components/List/index.js"),j=require("./Components/Table/index.js"),w=require("./Components/Others/index.js"),b=require("./Components/Action/index.js"),v=require("./Components/Artifact/index.js"),C=require("./Components/Others/Think.js"),k=require("../../../../common/cn.js");function q(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var P=q(t),R=q(o),y=q(a),S=q(l),O=q(c);exports.PickaxeMarkdownRenderer=({className:t,style:o,children:a,value:l,maxLines:c,maxChars:q,multiLineBreaks:$,onExpandClick:A,filePreviewSeenRef:U,suppressedRichPreviewUrls:H})=>{const{colors:M,rtl:T,disableHtml:E,disableJs:I,disableCss:_}=n.usePickaxeMarkdownContext(),[N,F]=s.useState({width:0,height:0}),[L,B]=s.useState(null),z=s.useRef(null),D=s.useMemo((()=>{if(!l)return"";if(E)return l;let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),$&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,$,E]);s.useEffect((()=>{if(q)return void B(D.length>q?D.slice(0,q)+'<span class="pxe-expand-btn">...</span>':null);if(!c)return void B(null);if(!z.current||!D||L)return;const e=z.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),s=c*r;if(!(N.height>s))return;const n=Math.floor(N.width/8),i=Math.floor(n*c);B(D.slice(0,i)+'<span class="pxe-expand-btn">...</span>')}),[D,c,q,N,L]);const J=s.useRef(new Set);U||(J.current=new Set);const W=null!=U?U:J,Q=s.useRef({colors:M,onExpandClick:A,filePreviewSeenRef:W,suppressedRichPreviewUrls:H});Q.current={colors:M,onExpandClick:A,filePreviewSeenRef:W,suppressedRichPreviewUrls:H};const G=s.useMemo((()=>({h1:x.H1,h2:x.H2,h3:x.H3,h4:x.H4,h5:x.H5,p:e=>r.jsx(p.P,Object.assign({},e,{suppressedRichPreviewUrls:Q.current.suppressedRichPreviewUrls})),a:e=>r.jsx(u.A,Object.assign({},e,{filePreviewSeenRef:Q.current.filePreviewSeenRef,suppressedRichPreviewUrls:Q.current.suppressedRichPreviewUrls})),img:e=>{const{colors:s,filePreviewSeenRef:n,suppressedRichPreviewUrls:i}=Q.current,t="string"==typeof e.src?e.src:"",o=d.getFilePreviewInfo(t);return o&&!d.shouldSuppressRichPreviewForUrl(o.url,i)?d.shouldRenderFilePreview(o,n)?r.jsx(d.default,{fileInfo:o,displayName:"string"==typeof e.alt?e.alt:void 0}):r.jsx("a",Object.assign({href:o.url,target:"_blank",rel:"noopener noreferrer",style:{color:s.accent}},{children:e.alt||o.fileName})):r.jsx(f.Img,Object.assign({},e))},iframe:h.Iframe,code:m.Code,ol:g.Ol,ul:g.Ul,li:g.Li,table:j.Table,th:j.Th,tr:j.Tr,td:j.Td,hr:w.Hr,br:w.Br,blockquote:w.Blockquote,span:s=>{var{children:n}=s,i=e.__rest(s,["children"]);const{colors:t,onExpandClick:o}=Q.current;return"pxe-expand-btn"===i.className?r.jsx("span",Object.assign({},i,{style:Object.assign({display:"inline",fontWeight:500,color:t.accent,marginLeft:".25rem",userSelect:"none"},o&&{cursor:"pointer"})},o&&{onClick:o},{children:n})):r.jsx("span",Object.assign({},i,{children:n}))},"action-caption":b.ActionCaption,"action-finished":b.ActionFinished,"action-error":b.ActionError,artifact:v.Artifact,"artifact-error":v.ArtifactError,think:C.Think})),[]);s.useEffect((()=>{if(!z.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:s}=r.contentRect;F({width:e,height:s})}}));return e.observe(z.current),()=>{e.disconnect()}}),[]);const K=L||D;return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:z,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},o)},T&&{dir:"rtl"},{children:[r.jsx(P.default,Object.assign({className:k.default("pxe-prose",t),components:G,remarkPlugins:[R.default,[y.default,{singleDollarTextMath:!1}],[i.remarkDocumentCssAsCode,{disableCss:_}],i.remarkSmartQuotes],rehypePlugins:[i.rehypeCode,S.default,...E?[]:[O.default],[i.rehypeSanitize,{disableJs:I,disableCss:_}]]},{children:K})),a]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("unist-util-visit");const t=new Set(["blockquote","break","delete","footnoteDefinition","heading","html","list","listItem","paragraph","root","table","tableCell","tableRow","thematicBreak","yaml"]),r=new Set(["code","html","inlineCode","inlineMath","math","mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression"]),o=/[\s([{<]/,i=/[:;—–-]/,s=(e,l)=>{if(e.type&&r.has(e.type))return;if("text"===e.type&&"string"==typeof e.value)return void(e.value=((e,t)=>{let r="";for(let n=0;n<e.length;n+=1){const a=e[n];if('"'!==a)r+=a,t.previousChar=a;else{const a=(s=t.previousChar,l=e[n+1],!s||o.test(s)||l&&!/\s/.test(l)&&i.test(s)?"“":"”");r+=a,t.previousChar=a}}var s,l;return r})(e.value,l));if(!e.children)return;const n=e.type&&t.has(e.type)?{previousChar:""}:l;e.children.forEach((e=>{s(e,n)}))};exports.rehypeCode=()=>t=>{e.visit(t,"code",(e=>{var t;e.lang=null!==(t=e.lang)&&void 0!==t?t:"plaintext"}))},exports.rehypeSanitize=(t={})=>r=>{e.visit(r,"element",((r,o,i)=>{if(t.disableJs){if("script"===r.tagName&&i&&"number"==typeof o)return i.children.splice(o,1),[e.SKIP,o];if(r.properties){["onclick","onload","onerror","onmouseover","onmouseout","onfocus","onblur"].forEach((e=>{r.properties[e]&&delete r.properties[e]})),r.properties.href&&"string"==typeof r.properties.href&&r.properties.href.toLowerCase().startsWith("javascript:")&&delete r.properties.href}}if(t.disableCss&&"style"===r.tagName&&i&&"number"==typeof o)return i.children.splice(o,1),[e.SKIP,o]}))},exports.remarkSmartQuotes=()=>e=>{s(e,{previousChar:""})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("unist-util-visit");const t=new Set(["blockquote","break","delete","footnoteDefinition","heading","html","list","listItem","paragraph","root","table","tableCell","tableRow","thematicBreak","yaml"]),r=new Set(["code","html","inlineCode","inlineMath","math","mdxFlowExpression","mdxJsxFlowElement","mdxJsxTextElement","mdxTextExpression"]),s=/[\s([{<]/,i=/[:;—–-]/,o=(e,l)=>{if(e.type&&r.has(e.type))return;if("text"===e.type&&"string"==typeof e.value)return void(e.value=((e,t)=>{let r="";for(let a=0;a<e.length;a+=1){const n=e[a];if('"'!==n)r+=n,t.previousChar=n;else{const n=(o=t.previousChar,l=e[a+1],!o||s.test(o)||l&&!/\s/.test(l)&&i.test(o)?"“":"”");r+=n,t.previousChar=n}}var o,l;return r})(e.value,l));if(!e.children)return;const a=e.type&&t.has(e.type)?{previousChar:""}:l;e.children.forEach((e=>{o(e,a)}))};exports.rehypeCode=()=>t=>{e.visit(t,"code",(e=>{var t;e.lang=null!==(t=e.lang)&&void 0!==t?t:"plaintext"}))},exports.rehypeSanitize=(t={})=>r=>{e.visit(r,"element",((r,s,i)=>{if(("style"===r.tagName||(e=>{var t;if("link"!==e.tagName)return!1;const r=null===(t=e.properties)||void 0===t?void 0:t.rel;return(Array.isArray(r)?r:[r]).some((e=>"string"==typeof e&&e.toLowerCase().split(/\s+/).includes("stylesheet")))})(r))&&i&&"number"==typeof s)return i.children.splice(s,1),[e.SKIP,s];if(t.disableJs){if("script"===r.tagName&&i&&"number"==typeof s)return i.children.splice(s,1),[e.SKIP,s];if(r.properties){["onclick","onload","onerror","onmouseover","onmouseout","onfocus","onblur"].forEach((e=>{r.properties[e]&&delete r.properties[e]})),r.properties.href&&"string"==typeof r.properties.href&&r.properties.href.toLowerCase().startsWith("javascript:")&&delete r.properties.href}}}))},exports.remarkDocumentCssAsCode=(t={})=>r=>{t.disableCss||e.visit(r,"html",((t,r,s)=>{var i;if("string"==typeof t.value&&(/<style(?:\s|>)/i.test(t.value)||(i=t.value,/<link\b[^>]*\brel\s*=\s*(?:["'][^"']*\bstylesheet\b[^"']*["']|[^\s>]*\bstylesheet\b[^\s>]*)[^>]*>/i.test(i)))&&(s&&"number"==typeof r))return s.children[r]={type:"paragraph"===s.type?"inlineCode":"code",lang:"paragraph"===s.type?void 0:"html",value:t.value},[e.SKIP,r]}))},exports.remarkSmartQuotes=()=>e=>{o(e,{previousChar:""})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("../../../../../_virtual/_commonjsHelpers.js"),r=require("../../../../../_virtual/cose-base.js"),i=require("../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js");r.__module.exports,exports.__require=function(){return t||(t=1,o=r.__module,r.__module.exports,e.commonjsGlobal,n=function(t){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(e,r){e.exports=t},function(t,e,r){var i=r(0).FDLayoutConstants;function o(){}for(var n in i)o[n]=i[n];o.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,o.DEFAULT_RADIAL_SEPARATION=i.DEFAULT_EDGE_LENGTH,o.DEFAULT_COMPONENT_SEPERATION=60,o.TILE=!0,o.TILING_PADDING_VERTICAL=10,o.TILING_PADDING_HORIZONTAL=10,o.TREE_REDUCTION_ON_INCREMENTAL=!1,t.exports=o},function(t,e,r){var i=r(0).FDLayoutEdge;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraph;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraphManager;function o(t){i.call(this,t)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).FDLayoutNode,o=r(0).IMath;function n(t,e,r,o){i.call(this,t,e,r,o)}for(var a in n.prototype=Object.create(i.prototype),i)n[a]=i[a];n.prototype.move=function(){var t=this.graphManager.getLayout();this.displacementX=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementX=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementX)),Math.abs(this.displacementY)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementY=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementY)),null==this.child||0==this.child.getNodes().length?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),t.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},n.prototype.propogateDisplacementToChildren=function(t,e){for(var r,i=this.getChild().getNodes(),o=0;o<i.length;o++)null==(r=i[o]).getChild()?(r.moveBy(t,e),r.displacementX+=t,r.displacementY+=e):r.propogateDisplacementToChildren(t,e)},n.prototype.setPred1=function(t){this.pred1=t},n.prototype.getPred1=function(){return pred1},n.prototype.getPred2=function(){return pred2},n.prototype.setNext=function(t){this.next=t},n.prototype.getNext=function(){return next},n.prototype.setProcessed=function(t){this.processed=t},n.prototype.isProcessed=function(){return processed},t.exports=n},function(t,e,r){var i=r(0).FDLayout,o=r(4),n=r(3),a=r(5),s=r(2),h=r(1),d=r(0).FDLayoutConstants,g=r(0).LayoutConstants,l=r(0).Point,p=r(0).PointD,c=r(0).Layout,u=r(0).Integer,f=r(0).IGeometry,v=r(0).LGraph,T=r(0).Transform;function E(){i.call(this),this.toBeTiled={}}for(var m in E.prototype=Object.create(i.prototype),i)E[m]=i[m];E.prototype.newGraphManager=function(){var t=new o(this);return this.graphManager=t,t},E.prototype.newGraph=function(t){return new n(null,this.graphManager,t)},E.prototype.newNode=function(t){return new a(this.graphManager,t)},E.prototype.newEdge=function(t){return new s(null,null,t)},E.prototype.initParameters=function(){i.prototype.initParameters.call(this,arguments),this.isSubLayout||(h.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=h.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=h.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=d.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=d.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=d.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},E.prototype.layout=function(){return g.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},E.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)h.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)})),this.graphManager.setAllNodesToApplyGravitation(r));else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)}));this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},E.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter((function(e){return t.has(e)}));this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var r=!this.isTreeGrowing&&!this.isGrowthFinished,i=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(r,i),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},E.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},r=0;r<t.length;r++){var i=t[r].rect,o=t[r].id;e[o]={id:o,x:i.getCenterX(),y:i.getCenterY(),w:i.width,h:i.height}}return e},E.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if("during"===d.ANIMATE)this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},E.prototype.calculateNodesToApplyGravitationTo=function(){var t,e,r=[],i=this.graphManager.getGraphs(),o=i.length;for(e=0;e<o;e++)(t=i[e]).updateConnected(),t.isConnected||(r=r.concat(t.getNodes()));return r},E.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e,r=new Set;for(e=0;e<t.length;e++){var i=t[e];if(!r.has(i)){var o=i.getSource(),n=i.getTarget();if(o==n)i.getBendpoints().push(new p),i.getBendpoints().push(new p),this.createDummyNodesForBendpoints(i),r.add(i);else{var a=[];if(a=(a=a.concat(o.getEdgeListToNode(n))).concat(n.getEdgeListToNode(o)),!r.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var h=a[s];h.getBendpoints().push(new p),this.createDummyNodesForBendpoints(h)}a.forEach((function(t){r.add(t)}))}}}if(r.size==t.length)break}},E.prototype.positionNodesRadially=function(t){for(var e=new l(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,n=0,a=new p(0,0),s=0;s<t.length;s++){s%r==0&&(n=0,o=i,0!=s&&(o+=h.DEFAULT_COMPONENT_SEPERATION),i=0);var d=t[s],u=c.findCenterOfTree(d);e.x=n,e.y=o,(a=E.radialLayout(d,u,e)).y>i&&(i=Math.floor(a.y)),n=Math.floor(a.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(g.WORLD_CENTER_X-a.x/2,g.WORLD_CENTER_Y-a.y/2))},E.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),h.DEFAULT_RADIAL_SEPARATION);E.branchRadialLayout(e,null,0,359,0,i);var o=v.calculateBounds(t),n=new T;n.setDeviceOrgX(o.getMinX()),n.setDeviceOrgY(o.getMinY()),n.setWorldOrgX(r.x),n.setWorldOrgY(r.y);for(var a=0;a<t.length;a++)t[a].transform(n);var s=new p(o.getMaxX(),o.getMaxY());return n.inverseTransformPoint(s)},E.branchRadialLayout=function(t,e,r,i,o,n){var a=(i-r+1)/2;a<0&&(a+=180);var s=(a+r)%360*f.TWO_PI/360,h=o*Math.cos(s),d=o*Math.sin(s);t.setCenter(h,d);var g=[],l=(g=g.concat(t.getEdges())).length;null!=e&&l--;for(var p,c=0,u=g.length,v=t.getEdgesBetween(e);v.length>1;){var T=v[0];v.splice(0,1);var m=g.indexOf(T);m>=0&&g.splice(m,1),u--,l--}p=null!=e?(g.indexOf(v[0])+1)%u:0;for(var y=Math.abs(i-r)/l,N=p;c!=l;N=++N%u){var w=g[N].getOtherEnd(t);if(w!=e){var A=(r+c*y)%360,C=(A+y)%360;E.branchRadialLayout(w,t,A,C,o+n,n),c++}}},E.maxDiagonalInTree=function(t){for(var e=u.MIN_VALUE,r=0;r<t.length;r++){var i=t[r].getDiagonal();i>e&&(e=i)}return e},E.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},E.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var r=[],i=this.graphManager.getAllNodes(),o=0;o<i.length;o++){var n=(s=i[o]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=n.id&&this.getToBeTiled(n)||r.push(s)}for(o=0;o<r.length;o++){var s,h=(s=r[o]).getParent().id;void 0===e[h]&&(e[h]=[]),e[h]=e[h].concat(s)}Object.keys(e).forEach((function(r){if(e[r].length>1){var i="DummyCompound_"+r;t.memberGroups[i]=e[r];var o=e[r][0].getParent(),n=new a(t.graphManager);n.id=i,n.paddingLeft=o.paddingLeft||0,n.paddingRight=o.paddingRight||0,n.paddingBottom=o.paddingBottom||0,n.paddingTop=o.paddingTop||0,t.idToDummyNode[i]=n;var s=t.getGraphManager().add(t.newGraph(),n),h=o.getChild();h.add(n);for(var d=0;d<e[r].length;d++){var g=e[r][d];h.remove(g),s.add(g)}}}))},E.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var r=0;r<this.compoundOrder.length;r++)e[this.compoundOrder[r].id]=this.compoundOrder[r],t[this.compoundOrder[r].id]=[].concat(this.compoundOrder[r].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[r].getChild()),this.compoundOrder[r].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},E.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach((function(r){var i=t.idToDummyNode[r];e[r]=t.tileNodes(t.memberGroups[r],i.paddingLeft+i.paddingRight),i.rect.width=e[r].width,i.rect.height=e[r].height}))},E.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],r=e.id,i=e.paddingLeft,o=e.paddingTop;this.adjustLocations(this.tiledMemberPack[r],e.rect.x,e.rect.y,i,o)}},E.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach((function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,n=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,n)}))},E.prototype.getToBeTiled=function(t){var e=t.id;if(null!=this.toBeTiled[e])return this.toBeTiled[e];var r=t.getChild();if(null==r)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var n=i[o];if(this.getNodeDegree(n)>0)return this.toBeTiled[e]=!1,!1;if(null!=n.getChild()){if(!this.getToBeTiled(n))return this.toBeTiled[e]=!1,!1}else this.toBeTiled[n.id]=!1}return this.toBeTiled[e]=!0,!0},E.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),r=0,i=0;i<e.length;i++){var o=e[i];o.getSource().id!==o.getTarget().id&&(r+=1)}return r},E.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(null==t.getChild())return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},E.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},E.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];null!=r.getChild()&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},E.prototype.adjustLocations=function(t,e,r,i,o){r+=o;for(var n=e+=i,a=0;a<t.rows.length;a++){var s=t.rows[a];e=n;for(var h=0,d=0;d<s.length;d++){var g=s[d];g.rect.x=e,g.rect.y=r,e+=g.rect.width+t.horizontalPadding,g.rect.height>h&&(h=g.rect.height)}r+=h+t.verticalPadding}},E.prototype.tileCompoundMembers=function(t,e){var r=this;this.tiledMemberPack=[],Object.keys(t).forEach((function(i){var o=e[i];r.tiledMemberPack[i]=r.tileNodes(t[i],o.paddingLeft+o.paddingRight),o.rect.width=r.tiledMemberPack[i].width,o.rect.height=r.tiledMemberPack[i].height}))},E.prototype.tileNodes=function(t,e){var r={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:h.TILING_PADDING_VERTICAL,horizontalPadding:h.TILING_PADDING_HORIZONTAL};t.sort((function(t,e){return t.rect.width*t.rect.height>e.rect.width*e.rect.height?-1:t.rect.width*t.rect.height<e.rect.width*e.rect.height?1:0}));for(var i=0;i<t.length;i++){var o=t[i];0==r.rows.length?this.insertNodeToRow(r,o,0,e):this.canAddHorizontal(r,o.rect.width,o.rect.height)?this.insertNodeToRow(r,o,this.getShortestRowIndex(r),e):this.insertNodeToRow(r,o,r.rows.length,e),this.shiftToLastRow(r)}return r},E.prototype.insertNodeToRow=function(t,e,r,i){var o=i;r==t.rows.length&&(t.rows.push([]),t.rowWidth.push(o),t.rowHeight.push(0));var n=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(n+=t.horizontalPadding),t.rowWidth[r]=n,t.width<n&&(t.width=n);var a=e.rect.height;r>0&&(a+=t.verticalPadding);var s=0;a>t.rowHeight[r]&&(s=t.rowHeight[r],t.rowHeight[r]=a,s=t.rowHeight[r]-s),t.height+=s,t.rows[r].push(e)},E.prototype.getShortestRowIndex=function(t){for(var e=-1,r=Number.MAX_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]<r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.getLongestRowIndex=function(t){for(var e=-1,r=Number.MIN_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]>r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.canAddHorizontal=function(t,e,r){var i=this.getShortestRowIndex(t);if(i<0)return!0;var o=t.rowWidth[i];if(o+t.horizontalPadding+e<=t.width)return!0;var n,a,s=0;return t.rowHeight[i]<r&&i>0&&(s=r+t.verticalPadding-t.rowHeight[i]),n=t.width-o>=e+t.horizontalPadding?(t.height+s)/(o+e+t.horizontalPadding):(t.height+s)/t.width,s=r+t.verticalPadding,(a=t.width<e?(t.height+s)/e:(t.height+s)/t.width)<1&&(a=1/a),n<1&&(n=1/n),n<a},E.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],n=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>n&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-n,t.rowWidth[r]=t.rowWidth[r]+n,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var a=Number.MIN_VALUE,s=0;s<i.length;s++)i[s].height>a&&(a=i[s].height);e>0&&(a+=t.verticalPadding);var h=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=a,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var d=t.rowHeight[e]+t.rowHeight[r];t.height+=d-h,this.shiftToLastRow(t)}},E.prototype.tilingPreLayout=function(){h.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},E.prototype.tilingPostLayout=function(){h.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},E.prototype.reduceTrees=function(){for(var t,e=[],r=!0;r;){var i=this.graphManager.getAllNodes(),o=[];r=!1;for(var n=0;n<i.length;n++)1!=(t=i[n]).getEdges().length||t.getEdges()[0].isInterGraph||null!=t.getChild()||(o.push([t,t.getEdges()[0],t.getOwner()]),r=!0);if(1==r){for(var a=[],s=0;s<o.length;s++)1==o[s][0].getEdges().length&&(a.push(o[s]),o[s][0].getOwner().remove(o[s][0]));e.push(a),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=e},E.prototype.growTree=function(t){for(var e,r=t[t.length-1],i=0;i<r.length;i++)e=r[i],this.findPlaceforPrunedNode(e),e[2].add(e[0]),e[2].add(e[1],e[1].source,e[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},E.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0],o=(r=i==t[1].source?t[1].target:t[1].source).startX,n=r.finishX,a=r.startY,s=r.finishY,h=[0,0,0,0];if(a>0)for(var g=o;g<=n;g++)h[0]+=this.grid[g][a-1].length+this.grid[g][a].length-1;if(n<this.grid.length-1)for(g=a;g<=s;g++)h[1]+=this.grid[n+1][g].length+this.grid[n][g].length-1;if(s<this.grid[0].length-1)for(g=o;g<=n;g++)h[2]+=this.grid[g][s+1].length+this.grid[g][s].length-1;if(o>0)for(g=a;g<=s;g++)h[3]+=this.grid[o-1][g].length+this.grid[o][g].length-1;for(var l,p,c=u.MAX_VALUE,f=0;f<h.length;f++)h[f]<c?(c=h[f],l=1,p=f):h[f]==c&&l++;if(3==l&&0==c)0==h[0]&&0==h[1]&&0==h[2]?e=1:0==h[0]&&0==h[1]&&0==h[3]?e=0:0==h[0]&&0==h[2]&&0==h[3]?e=3:0==h[1]&&0==h[2]&&0==h[3]&&(e=2);else if(2==l&&0==c){var v=Math.floor(2*Math.random());e=0==h[0]&&0==h[1]?0==v?0:1:0==h[0]&&0==h[2]?0==v?0:2:0==h[0]&&0==h[3]?0==v?0:3:0==h[1]&&0==h[2]?0==v?1:2:0==h[1]&&0==h[3]?0==v?1:3:0==v?2:3}else e=4==l&&0==c?v=Math.floor(4*Math.random()):p;0==e?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-d.DEFAULT_EDGE_LENGTH-i.getHeight()/2):1==e?i.setCenter(r.getCenterX()+r.getWidth()/2+d.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):2==e?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+d.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-d.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},t.exports=E},function(t,e,r){var i={};i.layoutBase=r(0),i.CoSEConstants=r(1),i.CoSEEdge=r(2),i.CoSEGraph=r(3),i.CoSEGraphManager=r(4),i.CoSELayout=r(6),i.CoSENode=r(5),t.exports=i}])},o.exports=n(i.__require())),r.__module.exports;var o,n};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("../../../../../_virtual/_commonjsHelpers.js"),r=require("../../../../../_virtual/cose-base2.js"),i=require("../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js");r.__module.exports,exports.__require=function(){return t||(t=1,o=r.__module,r.__module.exports,e.commonjsGlobal,n=function(t){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(e,r){e.exports=t},function(t,e,r){var i=r(0).FDLayoutConstants;function o(){}for(var n in i)o[n]=i[n];o.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,o.DEFAULT_RADIAL_SEPARATION=i.DEFAULT_EDGE_LENGTH,o.DEFAULT_COMPONENT_SEPERATION=60,o.TILE=!0,o.TILING_PADDING_VERTICAL=10,o.TILING_PADDING_HORIZONTAL=10,o.TREE_REDUCTION_ON_INCREMENTAL=!1,t.exports=o},function(t,e,r){var i=r(0).FDLayoutEdge;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraph;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraphManager;function o(t){i.call(this,t)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).FDLayoutNode,o=r(0).IMath;function n(t,e,r,o){i.call(this,t,e,r,o)}for(var a in n.prototype=Object.create(i.prototype),i)n[a]=i[a];n.prototype.move=function(){var t=this.graphManager.getLayout();this.displacementX=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementX=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementX)),Math.abs(this.displacementY)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementY=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementY)),null==this.child||0==this.child.getNodes().length?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),t.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},n.prototype.propogateDisplacementToChildren=function(t,e){for(var r,i=this.getChild().getNodes(),o=0;o<i.length;o++)null==(r=i[o]).getChild()?(r.moveBy(t,e),r.displacementX+=t,r.displacementY+=e):r.propogateDisplacementToChildren(t,e)},n.prototype.setPred1=function(t){this.pred1=t},n.prototype.getPred1=function(){return pred1},n.prototype.getPred2=function(){return pred2},n.prototype.setNext=function(t){this.next=t},n.prototype.getNext=function(){return next},n.prototype.setProcessed=function(t){this.processed=t},n.prototype.isProcessed=function(){return processed},t.exports=n},function(t,e,r){var i=r(0).FDLayout,o=r(4),n=r(3),a=r(5),s=r(2),h=r(1),d=r(0).FDLayoutConstants,g=r(0).LayoutConstants,l=r(0).Point,p=r(0).PointD,c=r(0).Layout,u=r(0).Integer,f=r(0).IGeometry,v=r(0).LGraph,T=r(0).Transform;function E(){i.call(this),this.toBeTiled={}}for(var m in E.prototype=Object.create(i.prototype),i)E[m]=i[m];E.prototype.newGraphManager=function(){var t=new o(this);return this.graphManager=t,t},E.prototype.newGraph=function(t){return new n(null,this.graphManager,t)},E.prototype.newNode=function(t){return new a(this.graphManager,t)},E.prototype.newEdge=function(t){return new s(null,null,t)},E.prototype.initParameters=function(){i.prototype.initParameters.call(this,arguments),this.isSubLayout||(h.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=h.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=h.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=d.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=d.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=d.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},E.prototype.layout=function(){return g.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},E.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)h.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)})),this.graphManager.setAllNodesToApplyGravitation(r));else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)}));this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},E.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter((function(e){return t.has(e)}));this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var r=!this.isTreeGrowing&&!this.isGrowthFinished,i=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(r,i),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},E.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},r=0;r<t.length;r++){var i=t[r].rect,o=t[r].id;e[o]={id:o,x:i.getCenterX(),y:i.getCenterY(),w:i.width,h:i.height}}return e},E.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if("during"===d.ANIMATE)this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},E.prototype.calculateNodesToApplyGravitationTo=function(){var t,e,r=[],i=this.graphManager.getGraphs(),o=i.length;for(e=0;e<o;e++)(t=i[e]).updateConnected(),t.isConnected||(r=r.concat(t.getNodes()));return r},E.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e,r=new Set;for(e=0;e<t.length;e++){var i=t[e];if(!r.has(i)){var o=i.getSource(),n=i.getTarget();if(o==n)i.getBendpoints().push(new p),i.getBendpoints().push(new p),this.createDummyNodesForBendpoints(i),r.add(i);else{var a=[];if(a=(a=a.concat(o.getEdgeListToNode(n))).concat(n.getEdgeListToNode(o)),!r.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var h=a[s];h.getBendpoints().push(new p),this.createDummyNodesForBendpoints(h)}a.forEach((function(t){r.add(t)}))}}}if(r.size==t.length)break}},E.prototype.positionNodesRadially=function(t){for(var e=new l(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,n=0,a=new p(0,0),s=0;s<t.length;s++){s%r==0&&(n=0,o=i,0!=s&&(o+=h.DEFAULT_COMPONENT_SEPERATION),i=0);var d=t[s],u=c.findCenterOfTree(d);e.x=n,e.y=o,(a=E.radialLayout(d,u,e)).y>i&&(i=Math.floor(a.y)),n=Math.floor(a.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(g.WORLD_CENTER_X-a.x/2,g.WORLD_CENTER_Y-a.y/2))},E.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),h.DEFAULT_RADIAL_SEPARATION);E.branchRadialLayout(e,null,0,359,0,i);var o=v.calculateBounds(t),n=new T;n.setDeviceOrgX(o.getMinX()),n.setDeviceOrgY(o.getMinY()),n.setWorldOrgX(r.x),n.setWorldOrgY(r.y);for(var a=0;a<t.length;a++)t[a].transform(n);var s=new p(o.getMaxX(),o.getMaxY());return n.inverseTransformPoint(s)},E.branchRadialLayout=function(t,e,r,i,o,n){var a=(i-r+1)/2;a<0&&(a+=180);var s=(a+r)%360*f.TWO_PI/360,h=o*Math.cos(s),d=o*Math.sin(s);t.setCenter(h,d);var g=[],l=(g=g.concat(t.getEdges())).length;null!=e&&l--;for(var p,c=0,u=g.length,v=t.getEdgesBetween(e);v.length>1;){var T=v[0];v.splice(0,1);var m=g.indexOf(T);m>=0&&g.splice(m,1),u--,l--}p=null!=e?(g.indexOf(v[0])+1)%u:0;for(var y=Math.abs(i-r)/l,N=p;c!=l;N=++N%u){var w=g[N].getOtherEnd(t);if(w!=e){var A=(r+c*y)%360,C=(A+y)%360;E.branchRadialLayout(w,t,A,C,o+n,n),c++}}},E.maxDiagonalInTree=function(t){for(var e=u.MIN_VALUE,r=0;r<t.length;r++){var i=t[r].getDiagonal();i>e&&(e=i)}return e},E.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},E.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var r=[],i=this.graphManager.getAllNodes(),o=0;o<i.length;o++){var n=(s=i[o]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=n.id&&this.getToBeTiled(n)||r.push(s)}for(o=0;o<r.length;o++){var s,h=(s=r[o]).getParent().id;void 0===e[h]&&(e[h]=[]),e[h]=e[h].concat(s)}Object.keys(e).forEach((function(r){if(e[r].length>1){var i="DummyCompound_"+r;t.memberGroups[i]=e[r];var o=e[r][0].getParent(),n=new a(t.graphManager);n.id=i,n.paddingLeft=o.paddingLeft||0,n.paddingRight=o.paddingRight||0,n.paddingBottom=o.paddingBottom||0,n.paddingTop=o.paddingTop||0,t.idToDummyNode[i]=n;var s=t.getGraphManager().add(t.newGraph(),n),h=o.getChild();h.add(n);for(var d=0;d<e[r].length;d++){var g=e[r][d];h.remove(g),s.add(g)}}}))},E.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var r=0;r<this.compoundOrder.length;r++)e[this.compoundOrder[r].id]=this.compoundOrder[r],t[this.compoundOrder[r].id]=[].concat(this.compoundOrder[r].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[r].getChild()),this.compoundOrder[r].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},E.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach((function(r){var i=t.idToDummyNode[r];e[r]=t.tileNodes(t.memberGroups[r],i.paddingLeft+i.paddingRight),i.rect.width=e[r].width,i.rect.height=e[r].height}))},E.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],r=e.id,i=e.paddingLeft,o=e.paddingTop;this.adjustLocations(this.tiledMemberPack[r],e.rect.x,e.rect.y,i,o)}},E.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach((function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,n=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,n)}))},E.prototype.getToBeTiled=function(t){var e=t.id;if(null!=this.toBeTiled[e])return this.toBeTiled[e];var r=t.getChild();if(null==r)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var n=i[o];if(this.getNodeDegree(n)>0)return this.toBeTiled[e]=!1,!1;if(null!=n.getChild()){if(!this.getToBeTiled(n))return this.toBeTiled[e]=!1,!1}else this.toBeTiled[n.id]=!1}return this.toBeTiled[e]=!0,!0},E.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),r=0,i=0;i<e.length;i++){var o=e[i];o.getSource().id!==o.getTarget().id&&(r+=1)}return r},E.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(null==t.getChild())return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},E.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},E.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];null!=r.getChild()&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},E.prototype.adjustLocations=function(t,e,r,i,o){r+=o;for(var n=e+=i,a=0;a<t.rows.length;a++){var s=t.rows[a];e=n;for(var h=0,d=0;d<s.length;d++){var g=s[d];g.rect.x=e,g.rect.y=r,e+=g.rect.width+t.horizontalPadding,g.rect.height>h&&(h=g.rect.height)}r+=h+t.verticalPadding}},E.prototype.tileCompoundMembers=function(t,e){var r=this;this.tiledMemberPack=[],Object.keys(t).forEach((function(i){var o=e[i];r.tiledMemberPack[i]=r.tileNodes(t[i],o.paddingLeft+o.paddingRight),o.rect.width=r.tiledMemberPack[i].width,o.rect.height=r.tiledMemberPack[i].height}))},E.prototype.tileNodes=function(t,e){var r={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:h.TILING_PADDING_VERTICAL,horizontalPadding:h.TILING_PADDING_HORIZONTAL};t.sort((function(t,e){return t.rect.width*t.rect.height>e.rect.width*e.rect.height?-1:t.rect.width*t.rect.height<e.rect.width*e.rect.height?1:0}));for(var i=0;i<t.length;i++){var o=t[i];0==r.rows.length?this.insertNodeToRow(r,o,0,e):this.canAddHorizontal(r,o.rect.width,o.rect.height)?this.insertNodeToRow(r,o,this.getShortestRowIndex(r),e):this.insertNodeToRow(r,o,r.rows.length,e),this.shiftToLastRow(r)}return r},E.prototype.insertNodeToRow=function(t,e,r,i){var o=i;r==t.rows.length&&(t.rows.push([]),t.rowWidth.push(o),t.rowHeight.push(0));var n=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(n+=t.horizontalPadding),t.rowWidth[r]=n,t.width<n&&(t.width=n);var a=e.rect.height;r>0&&(a+=t.verticalPadding);var s=0;a>t.rowHeight[r]&&(s=t.rowHeight[r],t.rowHeight[r]=a,s=t.rowHeight[r]-s),t.height+=s,t.rows[r].push(e)},E.prototype.getShortestRowIndex=function(t){for(var e=-1,r=Number.MAX_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]<r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.getLongestRowIndex=function(t){for(var e=-1,r=Number.MIN_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]>r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.canAddHorizontal=function(t,e,r){var i=this.getShortestRowIndex(t);if(i<0)return!0;var o=t.rowWidth[i];if(o+t.horizontalPadding+e<=t.width)return!0;var n,a,s=0;return t.rowHeight[i]<r&&i>0&&(s=r+t.verticalPadding-t.rowHeight[i]),n=t.width-o>=e+t.horizontalPadding?(t.height+s)/(o+e+t.horizontalPadding):(t.height+s)/t.width,s=r+t.verticalPadding,(a=t.width<e?(t.height+s)/e:(t.height+s)/t.width)<1&&(a=1/a),n<1&&(n=1/n),n<a},E.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],n=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>n&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-n,t.rowWidth[r]=t.rowWidth[r]+n,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var a=Number.MIN_VALUE,s=0;s<i.length;s++)i[s].height>a&&(a=i[s].height);e>0&&(a+=t.verticalPadding);var h=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=a,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var d=t.rowHeight[e]+t.rowHeight[r];t.height+=d-h,this.shiftToLastRow(t)}},E.prototype.tilingPreLayout=function(){h.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},E.prototype.tilingPostLayout=function(){h.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},E.prototype.reduceTrees=function(){for(var t,e=[],r=!0;r;){var i=this.graphManager.getAllNodes(),o=[];r=!1;for(var n=0;n<i.length;n++)1!=(t=i[n]).getEdges().length||t.getEdges()[0].isInterGraph||null!=t.getChild()||(o.push([t,t.getEdges()[0],t.getOwner()]),r=!0);if(1==r){for(var a=[],s=0;s<o.length;s++)1==o[s][0].getEdges().length&&(a.push(o[s]),o[s][0].getOwner().remove(o[s][0]));e.push(a),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=e},E.prototype.growTree=function(t){for(var e,r=t[t.length-1],i=0;i<r.length;i++)e=r[i],this.findPlaceforPrunedNode(e),e[2].add(e[0]),e[2].add(e[1],e[1].source,e[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},E.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0],o=(r=i==t[1].source?t[1].target:t[1].source).startX,n=r.finishX,a=r.startY,s=r.finishY,h=[0,0,0,0];if(a>0)for(var g=o;g<=n;g++)h[0]+=this.grid[g][a-1].length+this.grid[g][a].length-1;if(n<this.grid.length-1)for(g=a;g<=s;g++)h[1]+=this.grid[n+1][g].length+this.grid[n][g].length-1;if(s<this.grid[0].length-1)for(g=o;g<=n;g++)h[2]+=this.grid[g][s+1].length+this.grid[g][s].length-1;if(o>0)for(g=a;g<=s;g++)h[3]+=this.grid[o-1][g].length+this.grid[o][g].length-1;for(var l,p,c=u.MAX_VALUE,f=0;f<h.length;f++)h[f]<c?(c=h[f],l=1,p=f):h[f]==c&&l++;if(3==l&&0==c)0==h[0]&&0==h[1]&&0==h[2]?e=1:0==h[0]&&0==h[1]&&0==h[3]?e=0:0==h[0]&&0==h[2]&&0==h[3]?e=3:0==h[1]&&0==h[2]&&0==h[3]&&(e=2);else if(2==l&&0==c){var v=Math.floor(2*Math.random());e=0==h[0]&&0==h[1]?0==v?0:1:0==h[0]&&0==h[2]?0==v?0:2:0==h[0]&&0==h[3]?0==v?0:3:0==h[1]&&0==h[2]?0==v?1:2:0==h[1]&&0==h[3]?0==v?1:3:0==v?2:3}else e=4==l&&0==c?v=Math.floor(4*Math.random()):p;0==e?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-d.DEFAULT_EDGE_LENGTH-i.getHeight()/2):1==e?i.setCenter(r.getCenterX()+r.getWidth()/2+d.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):2==e?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+d.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-d.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},t.exports=E},function(t,e,r){var i={};i.layoutBase=r(0),i.CoSEConstants=r(1),i.CoSEEdge=r(2),i.CoSEGraph=r(3),i.CoSEGraphManager=r(4),i.CoSELayout=r(6),i.CoSENode=r(5),t.exports=i}])},o.exports=n(i.__require())),r.__module.exports;var o,n};