@pickaxeproject/react 6.22.1 → 6.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/responseArtifactSnapshot.js +1 -0
- package/dist/cjs/common/responseArtifactStyles.js +1 -0
- package/dist/cjs/common/responseArtifactSvg.js +101 -0
- package/dist/cjs/common/responseArtifactWordImages.js +1 -0
- package/dist/cjs/common/responseDownload.js +1 -0
- package/dist/cjs/common/responseDownloadArtifacts.js +1 -0
- package/dist/cjs/common/responseDownloadDocx.js +1 -0
- package/dist/cjs/common/responseDownloadHtml.js +1 -0
- package/dist/cjs/common/responseDownloadImages.js +1 -0
- package/dist/cjs/common/responseInteractiveArtifactHtml.js +1 -0
- package/dist/cjs/common/responseMermaid.js +1 -0
- package/dist/cjs/common/responseStandaloneSvg.js +1 -0
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeDownloadButton.js +1 -0
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
- package/dist/cjs/src/common/responseArtifactSnapshot.d.ts +1 -0
- package/dist/cjs/src/common/responseArtifactStyles.d.ts +4 -0
- package/dist/cjs/src/common/responseArtifactSvg.d.ts +2 -0
- package/dist/cjs/src/common/responseArtifactWordImages.d.ts +2 -0
- package/dist/cjs/src/common/responseDownload.d.ts +6 -0
- package/dist/cjs/src/common/responseDownloadArtifacts.d.ts +8 -0
- package/dist/cjs/src/common/responseDownloadDocx.d.ts +6 -0
- package/dist/cjs/src/common/responseDownloadHtml.d.ts +11 -0
- package/dist/cjs/src/common/responseDownloadImages.d.ts +3 -0
- package/dist/cjs/src/common/responseInteractiveArtifactHtml.d.ts +11 -0
- package/dist/cjs/src/common/responseMermaid.d.ts +2 -0
- package/dist/cjs/src/common/responseStandaloneSvg.d.ts +5 -0
- package/dist/cjs/src/components/Pickaxe/Provider.d.ts +1 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeDownloadButton.d.ts +8 -0
- package/dist/esm/common/responseArtifactSnapshot.js +1 -0
- package/dist/esm/common/responseArtifactStyles.js +1 -0
- package/dist/esm/common/responseArtifactSvg.js +101 -0
- package/dist/esm/common/responseArtifactWordImages.js +1 -0
- package/dist/esm/common/responseDownload.js +1 -0
- package/dist/esm/common/responseDownloadArtifacts.js +1 -0
- package/dist/esm/common/responseDownloadDocx.js +1 -0
- package/dist/esm/common/responseDownloadHtml.js +1 -0
- package/dist/esm/common/responseDownloadImages.js +1 -0
- package/dist/esm/common/responseInteractiveArtifactHtml.js +1 -0
- package/dist/esm/common/responseMermaid.js +1 -0
- package/dist/esm/common/responseStandaloneSvg.js +1 -0
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeDownloadButton.js +1 -0
- package/dist/esm/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
- package/dist/esm/src/common/responseArtifactSnapshot.d.ts +1 -0
- package/dist/esm/src/common/responseArtifactStyles.d.ts +4 -0
- package/dist/esm/src/common/responseArtifactSvg.d.ts +2 -0
- package/dist/esm/src/common/responseArtifactWordImages.d.ts +2 -0
- package/dist/esm/src/common/responseDownload.d.ts +6 -0
- package/dist/esm/src/common/responseDownloadArtifacts.d.ts +8 -0
- package/dist/esm/src/common/responseDownloadDocx.d.ts +6 -0
- package/dist/esm/src/common/responseDownloadHtml.d.ts +11 -0
- package/dist/esm/src/common/responseDownloadImages.d.ts +3 -0
- package/dist/esm/src/common/responseInteractiveArtifactHtml.d.ts +11 -0
- package/dist/esm/src/common/responseMermaid.d.ts +2 -0
- package/dist/esm/src/common/responseStandaloneSvg.d.ts +5 -0
- package/dist/esm/src/components/Pickaxe/Provider.d.ts +1 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeDownloadButton.d.ts +8 -0
- package/package.json +4 -2
|
@@ -0,0 +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', 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()}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=["color","background-color","background-image","font-family","font-size","font-weight","font-style","line-height","letter-spacing","text-align","text-decoration-line","text-decoration-color","text-transform","vertical-align","border-top","border-right","border-bottom","border-left","border-radius","border-collapse","border-spacing","box-shadow","box-sizing","padding-top","padding-right","padding-bottom","padding-left","margin-top","margin-right","margin-bottom","margin-left","display","flex-direction","flex-wrap","align-items","justify-content","gap","list-style-type","list-style-position"];exports.artifactStyleProperties=t,exports.filterArtifactStyles=e=>{e.querySelectorAll("[style]").forEach((e=>{const r=e.style,o=document.createElement("span").style;for(const e of t){const t=r.getPropertyValue(e);t&&!/url\s*\(|image-set\s*\(|var\s*\(|expression\s*\(|[\\<>@]/i.test(t)&&(e.startsWith("margin")&&/-\d/.test(t)||o.setProperty(e,t))}e.removeAttribute("style"),o.cssText&&e.setAttribute("style",o.cssText)}))};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=String.raw`async (source) => {
|
|
2
|
+
const bounds = source.getBoundingClientRect();
|
|
3
|
+
const width = Math.ceil(bounds.width);
|
|
4
|
+
const height = Math.ceil(bounds.height);
|
|
5
|
+
if (!width || !height) return null;
|
|
6
|
+
if (width * height * 4 > 16000000) throw new Error('SVG is too large');
|
|
7
|
+
const copy = source.cloneNode(true);
|
|
8
|
+
const sources = [source, ...source.querySelectorAll('*')];
|
|
9
|
+
const targets = [copy, ...copy.querySelectorAll('*')];
|
|
10
|
+
const ids = new Set(sources.map(node => node.id).filter(Boolean));
|
|
11
|
+
const localReference = (value) => {
|
|
12
|
+
const url = new URL(value, document.baseURI);
|
|
13
|
+
const current = new URL(document.URL);
|
|
14
|
+
const hash = url.hash;
|
|
15
|
+
url.hash = current.hash = '';
|
|
16
|
+
if (!hash || url.href !== current.href || !ids.has(decodeURIComponent(hash.slice(1))))
|
|
17
|
+
throw new Error('SVG requires an external resource');
|
|
18
|
+
return hash;
|
|
19
|
+
};
|
|
20
|
+
const safeValue = (value) => value.replace(/url\(\s*['"]?([^'"\)]+)['"]?\s*\)/gi,
|
|
21
|
+
(_, ref) => 'url("' + localReference(ref.trim()) + '")');
|
|
22
|
+
const properties = [
|
|
23
|
+
'color', 'fill', 'fill-opacity', 'fill-rule', 'stroke', 'stroke-width',
|
|
24
|
+
'stroke-opacity', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit',
|
|
25
|
+
'stroke-dasharray', 'stroke-dashoffset', 'opacity', 'visibility', 'display',
|
|
26
|
+
'font-family', 'font-size', 'font-weight', 'font-style', 'letter-spacing',
|
|
27
|
+
'text-anchor', 'dominant-baseline', 'white-space', 'paint-order',
|
|
28
|
+
'stop-color', 'stop-opacity', 'flood-color', 'flood-opacity', 'lighting-color',
|
|
29
|
+
'clip-path', 'clip-rule', 'mask', 'filter', 'marker-start', 'marker-mid',
|
|
30
|
+
'marker-end', 'vector-effect', 'shape-rendering', 'text-rendering',
|
|
31
|
+
'transform', 'transform-origin', 'transform-box',
|
|
32
|
+
'x', 'y', 'cx', 'cy', 'r', 'rx', 'ry', 'd'
|
|
33
|
+
];
|
|
34
|
+
sources.forEach((node, index) => {
|
|
35
|
+
const target = targets[index];
|
|
36
|
+
const tag = node.localName.toLowerCase();
|
|
37
|
+
if (['script', 'style', 'animate', 'animatemotion', 'animatetransform', 'set'].includes(tag)) {
|
|
38
|
+
target.remove();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (tag === 'foreignobject') throw new Error('SVG embedded HTML cannot be captured');
|
|
42
|
+
// Referenced symbols inherit styles through a browser-created shadow tree.
|
|
43
|
+
// Do not silently flatten them with the wrong colors or missing geometry.
|
|
44
|
+
if (tag === 'use') throw new Error('SVG symbol instances cannot be captured');
|
|
45
|
+
for (const attr of Array.from(target.attributes)) {
|
|
46
|
+
if (/^on/i.test(attr.name) || attr.name === 'style') target.removeAttributeNode(attr);
|
|
47
|
+
else if (attr.localName === 'href') {
|
|
48
|
+
// Links are inert in the picture. Resource references must be self-contained.
|
|
49
|
+
if (tag === 'a') target.removeAttributeNode(attr);
|
|
50
|
+
else if (tag === 'image' && /^data:image\/(png|jpeg|gif);base64,/i.test(attr.value)) continue;
|
|
51
|
+
else attr.value = localReference(attr.value);
|
|
52
|
+
} else attr.value = safeValue(attr.value);
|
|
53
|
+
}
|
|
54
|
+
const computed = getComputedStyle(node);
|
|
55
|
+
for (const property of properties) {
|
|
56
|
+
const value = computed.getPropertyValue(property);
|
|
57
|
+
if (value) target.style.setProperty(property, safeValue(value));
|
|
58
|
+
}
|
|
59
|
+
// Root sizing comes from the visible viewport, not outer-page positioning.
|
|
60
|
+
if (node === source) {
|
|
61
|
+
target.style.removeProperty('transform');
|
|
62
|
+
target.style.removeProperty('transform-origin');
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
copy.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
|
66
|
+
copy.setAttribute('width', String(width));
|
|
67
|
+
copy.setAttribute('height', String(height));
|
|
68
|
+
const xml = new XMLSerializer().serializeToString(copy);
|
|
69
|
+
if (xml.length > 10000000) throw new Error('SVG source is too large');
|
|
70
|
+
const image = new Image();
|
|
71
|
+
const canvas = document.createElement('canvas');
|
|
72
|
+
try {
|
|
73
|
+
await new Promise((resolve, reject) => {
|
|
74
|
+
const done = (ok) => {
|
|
75
|
+
clearTimeout(timeout);
|
|
76
|
+
image.onload = image.onerror = null;
|
|
77
|
+
if (ok) resolve(); else reject(new Error('Unable to capture SVG'));
|
|
78
|
+
};
|
|
79
|
+
const timeout = setTimeout(() => done(false), 5000);
|
|
80
|
+
image.onload = () => done(true);
|
|
81
|
+
image.onerror = () => done(false);
|
|
82
|
+
image.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(xml);
|
|
83
|
+
});
|
|
84
|
+
canvas.width = width * 2;
|
|
85
|
+
canvas.height = height * 2;
|
|
86
|
+
const context = canvas.getContext('2d');
|
|
87
|
+
if (!context) throw new Error('SVG capture unavailable');
|
|
88
|
+
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
89
|
+
const png = canvas.toDataURL('image/png');
|
|
90
|
+
if (png.length > 10000000) throw new Error('SVG picture is too large');
|
|
91
|
+
const picture = document.createElement('img');
|
|
92
|
+
picture.src = png;
|
|
93
|
+
picture.width = width;
|
|
94
|
+
picture.height = height;
|
|
95
|
+
picture.alt = source.getAttribute('aria-label') || source.textContent || '';
|
|
96
|
+
return picture;
|
|
97
|
+
} finally {
|
|
98
|
+
image.removeAttribute('src');
|
|
99
|
+
canvas.width = canvas.height = 0;
|
|
100
|
+
}
|
|
101
|
+
}`;exports.artifactSvgSnapshotScript=e;
|
|
@@ -0,0 +1 @@
|
|
|
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()}}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.prepareResponseDownloadText=e=>{if(!/<action-(caption|finished|error)\b/.test(e))return e;let n="\0pickaxe-download-code:";for(;e.includes(n);)n+=":";const t=[],s=new RegExp([/^(?:[ \t]*> ?)*[ \t]*(?:[-+*] |\d+[.)] )?(`{3,}|~{3,})[^\r\n]*(?:\r?\n|$)/,/(`+)/,/<(pre|code|script|style|textarea)\b(?:[^>"']|"[^"]*"|'[^']*')*>/,/<!--[\s\S]*?(?:-->|(?![\s\S]))/,/<\/?(?!action-(?:caption|finished|error)\b)[a-z][\w:-]*(?:[^>"']|"[^"]*"|'[^']*')*>/,/^(?: {4}|\t)[^\r\n]*/].map((e=>e.source)).join("|"),"gim");let i,r="",l=0;for(;null!==(i=s.exec(e));){let o=s.lastIndex;if(i[1]){const n=i[1],t=new RegExp(`^(?:[ \\t]*> ?)*[ \\t]*${n[0]}{${n.length},}[ \\t]*(?:\\r?\\n|$)`,"gm");t.lastIndex=o;o=t.exec(e)?t.lastIndex:e.length}else if(i[2]){const n=/`+/g;let t;for(n.lastIndex=o;null!==(t=n.exec(e))&&t[0].length!==i[2].length;);if(!t)continue;o=n.lastIndex}else if(i[3]){const n=new RegExp(`</${i[3]}\\s*>`,"gi");n.lastIndex=o;o=n.exec(e)?n.lastIndex:e.length}r+=e.slice(l,i.index),r+=`${n}${t.length}\0`,t.push(e.slice(i.index,o)),l=o,s.lastIndex=o}return r+=e.slice(l),(e=>e.replace(/<action-caption\b[^>]*>([\s\S]*?)<\/action-caption>/g,"$1").replace(/<action-finished\b[^>]*>[\s\S]*?<\/action-finished>/g,"").replace(/<action-error\b[^>]*>[\s\S]*?<\/action-error>/g,""))(r).replace(new RegExp(`${n}(\\d+)\0`,"g"),((e,n)=>t[Number(n)]))};
|
|
@@ -0,0 +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("uuid"),s=require("./responseArtifactWordImages.js"),c=require("./responseStandaloneSvg.js"),l=require("./responseMermaid.js"),d=require("./responseInteractiveArtifactHtml.js"),p=require("./responseDownloadHtml.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=u(n),m=u(o),v=u(a);const h=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),g=e=>{var t,r;const n=document.createElement("template");return n.innerHTML=p.createResponseDownloadHtml(e),null!==(r=null===(t=n.content.querySelector("main"))||void 0===t?void 0:t.innerHTML)&&void 0!==r?r:""},b=(e,t)=>{const r=[];let n=[],o="",a=!1;for(let i=0;i<e.length;i++){const s=e[i];'"'===s?a&&'"'===e[i+1]?(o+='"',i++):a=!a:a||s!==t&&"\n"!==s&&"\r"!==s?o+=s:(n.push(o),o="",s!==t&&(r.push(n),n=[],"\r"===s&&"\n"===e[i+1]&&i++))}if(a)throw new Error("Incomplete artifact table.");return(o||n.length)&&r.push([...n,o]),`<table>${r.map(((e,t)=>`<tr>${e.map((e=>{const r=t?"td":"th";return`<${r}>${h(e).replace(/\n/g,"<br>")}</${r}>`})).join("")}</tr>`)).join("")}</table>`};exports.findResponseArtifacts=e=>{if(!/<artifact\b/i.test(e))return[];const n=[];return r.renderToStaticMarkup(t.createElement(f.default,{remarkPlugins:[m.default],rehypePlugins:[v.default],components:{artifact:({node:e})=>{var t,r,o,a;const i=null===(t=e.position)||void 0===t?void 0:t.start.offset,s=null===(r=e.position)||void 0===r?void 0:r.end.offset,c=String(null!==(o=e.properties.dataId)&&void 0!==o?o:""),l=Number(null!==(a=e.properties.dataVersion)&&void 0!==a?a:1);if(null==i||null==s||!c||!Number.isInteger(l)||l<1)throw new Error("Invalid response artifact reference.");return n.push({id:c,version:l,start:i,end:s}),null}}},e)),n.sort(((e,t)=>e.start-t.start))},exports.prepareResponseArtifactDownload=(t,r,n,o,a)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e="txt"===o||"md"===o,u=[],f=[];let m=0;for(const d of r){const r=yield n(d);if(r.id!==d.id||r.version!==d.version||r.status&&"finished"!==r.status)throw new Error("Response artifact is not ready.");const p=t.slice(m,d.start);if(u.push(e?p:g(p)),e){const e="`".repeat(Math.max(3,...Array.from(r.content.matchAll(/`+/g),(e=>e[0].length+1))));u.push(`\n\n${r.title}\n\n${"md"===o&&"text/markdown"!==r.type?`${e}\n${r.content}\n${e}`:r.content}\n\n`)}else{let e;switch(r.type){case"text/markdown":e=g(r.content);break;case"text/csv":e=b(r.content,",");break;case"text/tab-separated-values":e=b(r.content,"\t");break;case"application/vnd.pxe.mermaid":e=yield l.createResponseMermaidImage(r.content,r.title);break;case"image/svg+xml":e=yield c.createResponseSvgImage(r.content,r.title);break;case"text/html":if("html"===o){const t=`artifact-${i.v4()}`;f.push({placeholder:t,title:r.title,content:r.content}),e=`<div id="${t}"></div>`;break}e=yield a(r.content),"docx"===o&&(e=yield s.createResponseArtifactWordImages(e,r.title));break;case"application/pdf":e=yield a(r.content);break;case"application/vnd.pxe.code":e=`<pre><code>${h(r.content)}</code></pre>`;break;default:throw new Error(`Artifact export is not supported for ${r.type}.`)}u.push(`<section><h2>${h(r.title)}</h2><div class="pxe-export-artifact">${e}</div></section>`)}m=d.end}return u.push(e?t.slice(m):g(t.slice(m))),e?u.join(""):d.embedInteractiveArtifacts(p.createResponseDownloadDocument(u.join("\n"),"html"===o||"pdf"===o),f)}));
|
|
@@ -0,0 +1 @@
|
|
|
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)}));
|
|
@@ -0,0 +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 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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.embedInteractiveArtifacts=(e,t)=>{var r;if(!t.length)return e;const n=(new DOMParser).parseFromString(e,"text/html"),i=n.querySelector('meta[http-equiv="Content-Security-Policy"]');if(!i)throw new Error("Missing response document policy.");i.setAttribute("content",i.getAttribute("content").replace("script-src 'none'","script-src 'unsafe-inline'"));const o=n.createElement("style");o.textContent="\nmain { max-width: 1200px; }\nmain > * { max-width: 900px; margin-left: auto; margin-right: auto; }\nmain > .pxe-interactive-section { max-width: none; }\n@media (max-width: 600px) { main { padding: 12px; } }\n",n.head.appendChild(o);for(const e of t){const t=n.getElementById(e.placeholder);if(!t)throw new Error("Missing response artifact placeholder.");null===(r=t.closest("section"))||void 0===r||r.classList.add("pxe-interactive-section");const i=n.createElement("iframe");i.setAttribute("sandbox","allow-scripts"),i.setAttribute("referrerpolicy","no-referrer"),i.title=e.title,i.style.cssText="display:block;width:100%;height:85vh;min-height:360px;border:0;resize:vertical;overflow:auto;",i.srcdoc=e.content,t.replaceWith(i)}return`<!doctype html>\n${n.documentElement.outerHTML}`};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("../node_modules/.pnpm/mermaid@11.7.0/node_modules/mermaid/dist/mermaid.core.mjs.js"),r=require("uuid"),s=require("./responseStandaloneSvg.js");exports.createResponseMermaidImage=(i,n)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=i.trim();if(!e||e.length>5e4||/^---/.test(e)||/%%\s*\{/.test(e)||/<\/?[a-z!]|\burl\s*\(|\bimg\s*:|\\/i.test(e)||/@|(?:https?|data):|\/\/|image-set\s*\(/i.test(e))throw new Error("Unsupported Mermaid export content.");if("strict"!==t.default.mermaidAPI.getSiteConfig().securityLevel)throw new Error("Mermaid export requires strict rendering.");const o=`pxe-export-mermaid-${r.v4()}`,a=document.createElement("div");a.setAttribute("aria-hidden","true"),a.style.cssText="position:fixed;left:-10000px;top:0;width:1200px;visibility:hidden;pointer-events:none;",document.body.appendChild(a);try{const r=yield t.default.render(o,"---\nconfig:\n htmlLabels: false\n flowchart:\n htmlLabels: false\n suppressErrorRendering: true\n---\n"+e,a),i=(new DOMParser).parseFromString(r.svg,"image/svg+xml");for(const e of i.querySelectorAll("style")){const t=new CSSStyleSheet;t.replaceSync(e.textContent||"");const r=[];for(const e of Array.from(t.cssRules))if(e.type===CSSRule.STYLE_RULE)r.push(e.cssText);else if(e.type!==CSSRule.KEYFRAMES_RULE)throw new Error("Unsupported Mermaid stylesheet.");e.textContent=r.join("\n")}return yield s.createResponseSvgImage((new XMLSerializer).serializeToString(i),n)}finally{a.remove()}}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js");exports.createResponseSvgImage=(t,r)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(t.length>1e7||/<!DOCTYPE|<!ENTITY/i.test(t))throw new Error("Unsupported SVG document.");const o=(new DOMParser).parseFromString(t,"image/svg+xml"),i=o.documentElement;if(o.querySelector("parsererror")||"svg"!==i.localName||i.namespaceURI&&"http://www.w3.org/2000/svg"!==i.namespaceURI)throw new Error("Invalid SVG artifact.");const n=e=>{const t=e.startsWith("#")?e.slice(1):"";if(!t||!o.getElementById(t))throw new Error("SVG requires an external or missing resource.")},a=e=>{if(/[\\@]/.test(e))throw new Error("Unsupported SVG stylesheet.");for(const t of e.matchAll(/url\(\s*["']?([^"')]+)["']?\s*\)/gi))n(t[1].trim())};for(const e of[i,...i.querySelectorAll("*")]){const t=e.localName.toLowerCase();if("script"!==t){if("foreignobject"===t||e.namespaceURI&&"http://www.w3.org/2000/svg"!==e.namespaceURI)throw new Error("Unsupported embedded SVG content.");"style"===t&&a(e.textContent||"");for(const r of Array.from(e.attributes))if(/^on/i.test(r.name))e.removeAttributeNode(r);else{if("xml:base"===r.name)throw new Error("SVG base URLs are unsupported.");if("href"===r.localName)if("a"===t)e.removeAttributeNode(r);else{if("image"===t&&/^data:image\/(png|jpeg|gif);base64,/i.test(r.value))continue;n(r.value)}else("style"===r.name||/url\s*\(/i.test(r.value))&&a(r.value)}}else e.remove()}const s=(i.getAttribute("viewBox")||"").trim().split(/[\s,]+/).map(Number),l=4===s.length&&s.every(Number.isFinite)&&s[2]>0&&s[3]>0,c=(e,t)=>{const r=i.getAttribute(e);if(!r||r.endsWith("%"))return t;if(!/^\d+(?:\.\d+)?(?:px)?$/.test(r))throw new Error("Unsupported SVG dimensions.");return parseFloat(r)},m=Math.ceil(c("width",l?s[2]:300)),u=Math.ceil(c("height",l?s[3]:150));if(!m||!u||m>4096||u>4096||m*u*4>16e6)throw new Error("SVG image is too large.");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width",String(m)),i.setAttribute("height",String(u));const g=new Image,w=document.createElement("canvas");try{yield new Promise(((e,t)=>{const r=r=>{clearTimeout(o),g.onload=g.onerror=null,r?e():t(new Error("Unable to read SVG artifact."))},o=setTimeout((()=>r(!1)),5e3);g.onload=()=>r(!0),g.onerror=()=>r(!1),g.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(i))})),w.width=2*m,w.height=2*u;const t=w.getContext("2d");if(!t)throw new Error("SVG image capture unavailable.");t.drawImage(g,0,0,w.width,w.height);const o=w.toDataURL("image/png");if(o.length>1e7)throw new Error("SVG picture is too large.");const n=document.createElement("img");return n.src=o,n.width=m,n.height=u,n.alt=i.getAttribute("aria-label")||(null===(e=i.querySelector("title"))||void 0===e?void 0:e.textContent)||r,n.outerHTML}finally{g.removeAttribute("src"),w.width=w.height=0}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),o=require("./Addons/Artifact/Provider.js"),n=require("./DimensionProvider.js"),a=require("./ResponseProvider.js"),s=require("./Addons/Document/Provider.js"),r=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:p,senderType:f,deploymentId:g,portalId:m,deploymentType:h,deploymentDimensions:y,deploymentMisc:v,styles:b,colors:w,limits:S={},misc:k={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:C={popupType:"auto"},responsiveBy:x="viewport",locale:I="en",opacity:F=1,forceMobile:A=!1,disableHtml:q=!1,disableJs:T=!1,disableCss:j=!1,loadFont:D=!0,isRtl:O=!1,isEmbed:U=!1,mcpEnabled:E=!1,mcpGuestId:M,studioSessionToken:R,isDropShadow:L=!1,allowGuestUsage:G=!0,persistActiveConversation:H=!1,preventInitialSessionId:W=!1,onUpgrade:_,onGenerateComplete:B,onSessionIdChange:N})=>{const[V,Y]=i.useState(""),[X,z]=i.useState(""),[J,Q]=i.useState(""),[K,Z]=i.useState(""),[$,ee]=i.useState(p),[te,ie]=i.useState(null),[oe,ne]=i.useState(f),[ae,se]=i.useState("loading"),[re,le]=i.useState([]),[de,ce]=i.useState(null),[ue,pe]=i.useState(null),[fe,ge]=i.useState(null),[me,he]=i.useState(null),[ye,ve]=i.useState("");i.useEffect((()=>ve("")),[X]);const[be,we]=i.useState(!1),[Se,ke]=i.useState(!0),[Pe,Ce]=i.useState(!0),[xe,Ie]=i.useState(!1);return i.useEffect((()=>{we(!1)}),[null==b?void 0:b.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&D&&!be&&(null==b?void 0:b.font)&&"Real Head Pro"!==b.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[b.font]},active:()=>{we(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),we(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),we(!0)}}))}),[D,be,null==b?void 0:b.font]),i.useEffect((()=>{ee(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign(Object.assign({origin:u,contextId:V,pickaxeId:X,sessionId:J,lastSessionId:K,sender:$,senderType:oe,portalId:m,deploymentId:g,deploymentType:h,validationStatus:ae,validationUpgradeGroups:re,validationUpgradeUrl:de,deploymentDimensions:y,deploymentMisc:v,accessGroup:te,pickaxe:me,selectedModel:ye,setSelectedModel:ve,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},b),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},w),misc:k,translations:Object.assign({"form-next":"Next","form-progress":"Form progress","form-page-progress":"Question {current} of {total}","action-confirmation-needed":"Confirmation needed","action-confirmation-unavailable":"Confirmation unavailable","action-approved":"Approved","action-declined":"Declined","action-expired":"Expired","action-not-run":"Not run","action-label":"Action: {name}","action-confirmation-description":"Review this action before it runs. Your decision applies only to this call.","action-inputs":"Action inputs","decline-action":"Decline","approve-action":"Approve action","action-confirmation-resolved":"This confirmation has expired or already been resolved.","action-decision-failed":"Could not save your decision. Please try again.","ai-model":"AI model","default-ai-model":"Default ({model})","attach-files":"Attach files","new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.","something-wrong-occured":"Something wrong occurred",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","enter-verification-code":"Or enter the 6-digit code from the email","verification-code-session-missing":"Your login request could not be found. Please resend the email.","verification-code-invalid":"Invalid verification code.",verifying:"Verifying...",verify:"Verify","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","mcp-use-with-ai-app":"Use with an AI app","mcp-use-agent-in-ai-app":"Use this agent in your AI app","mcp-connect-description":"Connect through MCP. Requests will be sent as your signed-in Studio user.","mcp-ai-app":"AI app","mcp-copy-configuration":"Copy MCP configuration","mcp-private-configuration-note":"Keep this configuration private. It contains your Studio session token and stops working when that session expires.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.","queue-message":"Queue message","stop-response":"Stop response",steer:"Steer","steer-with":"Steer with",steering:"Steering...",starting:"Starting...","remove-queued-message":"Remove queued message","edit-message":"Edit message","more-options":"More options","failed-to-interrupt-current-response":"Failed to interrupt the current response.","current-response-still-stopping":"The current response is still stopping. Please send your message again in a moment.","queued-message-waiting":"A queued message is waiting for the previous response to finish.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, GIF, or M4A files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},P),artifact:C,responsiveBy:x,locale:I,opacity:F,forceMobile:A,loadFont:D,disableHtml:q,disableJs:T,disableCss:j,isFontLoaded:be,isNewChat:Se,isShowIceBreaker:Pe,isShowFeedbackMessage:xe,isRtl:O,isEmbed:U,mcpEnabled:E,mcpGuestId:M,isDropShadow:L,allowGuestUsage:G,persistActiveConversation:H,clientSecret:fe,stripeAccountId:ue,preventInitialSessionId:W,setClientSecret:ge,setStripeAccountId:pe,setContextId:Y,setValidationStatus:se,setValidationUpgradeGroups:le,setValidationUpgradeUrl:ce,setPickaxeId:z,setSessionId:e=>{Q((t=>{const i="function"==typeof e?e(t):e;return null==N||N(i),i}))},setLastSessionId:Z,setSender:ee,setSenderType:ne,setAccessGroup:ie,setPickaxe:he,setIsFontLoaded:we,setIsNewChat:ke,setIsShowIceBreaker:Ce,setIsShowFeedbackMessage:Ie},_&&{onUpgrade:_}),B&&{onGenerateComplete:B})},{children:t.jsx(r.default,Object.assign({initialToken:R},{children:t.jsx(n.default,{children:t.jsx(a.default,Object.assign({limits:S},{children:t.jsx(s.default,{children:t.jsx(o.ArtifactProvider,Object.assign({},C,{children:c}))})}))})}))}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),o=require("./Addons/Artifact/Provider.js"),n=require("./DimensionProvider.js"),a=require("./ResponseProvider.js"),s=require("./Addons/Document/Provider.js"),r=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:p,senderType:f,deploymentId:g,portalId:m,deploymentType:h,deploymentDimensions:y,deploymentMisc:v,styles:b,colors:w,limits:S={},misc:k={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0,isResponseDownload:!1},translations:P,artifact:C={popupType:"auto"},responsiveBy:x="viewport",locale:I="en",opacity:F=1,forceMobile:A=!1,disableHtml:q=!1,disableJs:T=!1,disableCss:j=!1,loadFont:D=!0,isRtl:O=!1,isEmbed:U=!1,mcpEnabled:E=!1,mcpGuestId:R,studioSessionToken:M,isDropShadow:L=!1,allowGuestUsage:G=!0,persistActiveConversation:H=!1,preventInitialSessionId:W=!1,onUpgrade:_,onGenerateComplete:B,onSessionIdChange:N})=>{const[V,Y]=i.useState(""),[X,z]=i.useState(""),[J,Q]=i.useState(""),[K,Z]=i.useState(""),[$,ee]=i.useState(p),[te,ie]=i.useState(null),[oe,ne]=i.useState(f),[ae,se]=i.useState("loading"),[re,le]=i.useState([]),[de,ce]=i.useState(null),[ue,pe]=i.useState(null),[fe,ge]=i.useState(null),[me,he]=i.useState(null),[ye,ve]=i.useState("");i.useEffect((()=>ve("")),[X]);const[be,we]=i.useState(!1),[Se,ke]=i.useState(!0),[Pe,Ce]=i.useState(!0),[xe,Ie]=i.useState(!1);return i.useEffect((()=>{we(!1)}),[null==b?void 0:b.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&D&&!be&&(null==b?void 0:b.font)&&"Real Head Pro"!==b.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[b.font]},active:()=>{we(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),we(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),we(!0)}}))}),[D,be,null==b?void 0:b.font]),i.useEffect((()=>{ee(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign(Object.assign({origin:u,contextId:V,pickaxeId:X,sessionId:J,lastSessionId:K,sender:$,senderType:oe,portalId:m,deploymentId:g,deploymentType:h,validationStatus:ae,validationUpgradeGroups:re,validationUpgradeUrl:de,deploymentDimensions:y,deploymentMisc:v,accessGroup:te,pickaxe:me,selectedModel:ye,setSelectedModel:ve,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},b),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},w),misc:k,translations:Object.assign({"form-next":"Next","form-progress":"Form progress","form-page-progress":"Question {current} of {total}","action-confirmation-needed":"Confirmation needed","action-confirmation-unavailable":"Confirmation unavailable","action-approved":"Approved","action-declined":"Declined","action-expired":"Expired","action-not-run":"Not run","action-label":"Action: {name}","action-confirmation-description":"Review this action before it runs. Your decision applies only to this call.","action-inputs":"Action inputs","decline-action":"Decline","approve-action":"Approve action","action-confirmation-resolved":"This confirmation has expired or already been resolved.","action-decision-failed":"Could not save your decision. Please try again.","ai-model":"AI model","default-ai-model":"Default ({model})","attach-files":"Attach files","new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.","something-wrong-occured":"Something wrong occurred",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","enter-verification-code":"Or enter the 6-digit code from the email","verification-code-session-missing":"Your login request could not be found. Please resend the email.","verification-code-invalid":"Invalid verification code.",verifying:"Verifying...",verify:"Verify","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","mcp-use-with-ai-app":"Use with an AI app","mcp-use-agent-in-ai-app":"Use this agent in your AI app","mcp-connect-description":"Connect through MCP. Requests will be sent as your signed-in Studio user.","mcp-ai-app":"AI app","mcp-copy-configuration":"Copy MCP configuration","mcp-private-configuration-note":"Keep this configuration private. It contains your Studio session token and stops working when that session expires.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.","queue-message":"Queue message","stop-response":"Stop response",steer:"Steer","steer-with":"Steer with",steering:"Steering...",starting:"Starting...","remove-queued-message":"Remove queued message","edit-message":"Edit message","more-options":"More options","failed-to-interrupt-current-response":"Failed to interrupt the current response.","current-response-still-stopping":"The current response is still stopping. Please send your message again in a moment.","queued-message-waiting":"A queued message is waiting for the previous response to finish.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, GIF, or M4A files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},P),artifact:C,responsiveBy:x,locale:I,opacity:F,forceMobile:A,loadFont:D,disableHtml:q,disableJs:T,disableCss:j,isFontLoaded:be,isNewChat:Se,isShowIceBreaker:Pe,isShowFeedbackMessage:xe,isRtl:O,isEmbed:U,mcpEnabled:E,mcpGuestId:R,isDropShadow:L,allowGuestUsage:G,persistActiveConversation:H,clientSecret:fe,stripeAccountId:ue,preventInitialSessionId:W,setClientSecret:ge,setStripeAccountId:pe,setContextId:Y,setValidationStatus:se,setValidationUpgradeGroups:le,setValidationUpgradeUrl:ce,setPickaxeId:z,setSessionId:e=>{Q((t=>{const i="function"==typeof e?e(t):e;return null==N||N(i),i}))},setLastSessionId:Z,setSender:ee,setSenderType:ne,setAccessGroup:ie,setPickaxe:he,setIsFontLoaded:we,setIsNewChat:ke,setIsShowIceBreaker:Ce,setIsShowFeedbackMessage:Ie},_&&{onUpgrade:_}),B&&{onGenerateComplete:B})},{children:t.jsx(r.default,Object.assign({initialToken:M},{children:t.jsx(n.default,{children:t.jsx(a.default,Object.assign({limits:S},{children:t.jsx(s.default,{children:t.jsx(o.ArtifactProvider,Object.assign({},C,{children:c}))})}))})}))}))};
|
|
@@ -0,0 +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/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("react/jsx-runtime"),s=require("../../../hooks/studio/useStyleFontSize.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../hooks/pickaxe/useFeedback.js"),n=require("framer-motion"),l=require("../../Icons/message-square-notes.svg.js"),o=require("../../Icons/thumbs-down.svg.js"),c=require("../../Icons/speaker.svg.js"),r=require("../../Icons/stop.svg.js"),u=require("../../Icons/spinner-lines.svg.js"),d=require("../../Icons/thumbs-up.svg.js"),p=require("./PickaxeSimpleButton.js"),x=require("./PickaxeCopyButton.js"),m=require("./PickaxeDownloadButton.js"),b=require("./PickaxeFeedbackThumbsDownReasons.js"),j=require("../../../common/responseDownload.js"),f=require("../../../common/cn.js");exports.default=({content:h,sessionId:g,index:v=0,messagesCount:k,isHideFeedback:y,isReadOut:w,isReadOutLoading:O,isReading:q,onOpenChat:N,onReadOut:T})=>{var D,C,R,I;const{colors:P,translations:S,pickaxe:F,misc:z,setIsShowFeedbackMessage:U}=a.usePickaxeContext(),B=i.useStyleFontSize(),M=!0===z.isResponseDownload,A=s.useMemo((()=>M?j.prepareResponseDownloadText(h):""),[h,M]),{toggleThumb:H,submitThumbsDown:W,submitThumbsUp:_,isThumbsUpSelected:L,isThumbsDownSelected:E,showThumbsDownOptions:G,showThumbsUpOptions:J,showSuccess:K}=t.useFeedback({content:h,index:v,sessionId:g,successDuration:2e3,promptRate:1,onThumbsDownReasonOpen:()=>U(!0),onThumbsDownReasonClose:()=>U(!1)}),Q="function"==typeof N&&((null==F?void 0:F.chatflag)||!!(null==F?void 0:F.enablechatresponses))&&void 0!==g&&void 0!==k,V=Boolean(((null==F?void 0:F.chatflag)||(null==F?void 0:F.enablechatresponses))&&!N||!(null==F?void 0:F.chatflag)&&!(null==F?void 0:F.enablechatresponses))&&!y;return e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-4"},{children:[e.jsxs("div",Object.assign({className:f.default("flex items-center gap-3",M?"min-h-4 flex-wrap":"h-4")},{children:[Q&&e.jsxs(p.default,Object.assign({color:P.accent,onClick:N},{children:[e.jsx(l.default,{className:"h-4 w-4 shrink-0"}),e.jsx("p",Object.assign({className:f.default(B.b3,"font-semibold")},{children:k}))]})),e.jsx(x.default,{color:P.accent,text:h}),M&&e.jsx(m.default,{color:P.accent,text:A}),V&&e.jsxs(e.Fragment,{children:[e.jsx(p.default,Object.assign({color:P.accent,onClick:()=>H("like"),className:"transition-all active:rotate-12 active:scale-90"},{children:e.jsx(d.default,{className:"size-4",style:{fill:P.text,fillOpacity:L?.3:0}})})),e.jsx(p.default,Object.assign({color:P.accent,onClick:()=>H("dislike"),className:"transition-all active:-rotate-12 active:scale-90"},{children:e.jsx(o.default,{className:"size-4",style:{fill:P.text,fillOpacity:E?.3:0}})})),w&&T&&e.jsx(p.default,Object.assign({color:P.accent,onClick:()=>T(),className:"transition-all active:-rotate-12 active:scale-90"},{children:O?e.jsx(u.default,{className:"size-4 animate-spin"}):q?e.jsx(r.default,{className:"size-4 rounded-full border p-[1.5px]",style:{borderColor:P.accent}}):e.jsx(c.default,{className:"size-4"})})),e.jsx(n.AnimatePresence,{children:K&&e.jsx(n.motion.div,Object.assign({initial:{opacity:0,x:-8,filter:"blur(4px)"},animate:{opacity:1,x:0,filter:"blur(0px)"},exit:{opacity:0,x:8,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.6}},{children:e.jsx("p",Object.assign({className:f.default(B.b4,P.secondary,"opacity-75")},{children:null!==(D=null==S?void 0:S["feedback-thanks"])&&void 0!==D?D:"Thanks for the feedback!"}))}))})]})]})),e.jsx(n.AnimatePresence,{children:(G||J)&&e.jsxs(n.motion.div,Object.assign({initial:{opacity:0,y:-4,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},exit:{opacity:0,y:-2,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.25},className:"flex flex-col gap-4"},{children:[e.jsxs("div",Object.assign({className:"space-y-0.5"},{children:[e.jsx("p",Object.assign({className:f.default(B.b3,P.text)},{children:J?null!==(C=null==S?void 0:S["feedback-like-title"])&&void 0!==C?C:"What went right?":null!==(R=null==S?void 0:S["feedback-dislike-title"])&&void 0!==R?R:"What went wrong?"})),e.jsx("p",Object.assign({className:f.default(B.b3,P.secondary,"opacity-75")},{children:null!==(I=null==S?void 0:S["feedback-dislike-message"])&&void 0!==I?I:"Help us improve our answers"}))]})),e.jsx(n.motion.div,Object.assign({initial:{opacity:0,y:-8,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{type:"spring",bounce:0,duration:.5,delay:.175},className:"flex flex-wrap items-center gap-2"},{children:e.jsx(b.default,{isUp:J,submitThumbsDown:W,submitThumbsUp:_})}))]}))})]}))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const renderResponseArtifactHtml: (content: string, captureCanvas?: boolean, printWindow?: Window) => Promise<string>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Presentation only: no positioning, clipping, fixed dimensions or network URLs. */
|
|
2
|
+
export declare const artifactStyleProperties: readonly ["color", "background-color", "background-image", "font-family", "font-size", "font-weight", "font-style", "line-height", "letter-spacing", "text-align", "text-decoration-line", "text-decoration-color", "text-transform", "vertical-align", "border-top", "border-right", "border-bottom", "border-left", "border-radius", "border-collapse", "border-spacing", "box-shadow", "box-sizing", "padding-top", "padding-right", "padding-bottom", "padding-left", "margin-top", "margin-right", "margin-bottom", "margin-left", "display", "flex-direction", "flex-wrap", "align-items", "justify-content", "gap", "list-style-type", "list-style-position"];
|
|
3
|
+
/** Revalidate even computed styles: the renderer's message is not trusted. */
|
|
4
|
+
export declare const filterArtifactStyles: (root: ParentNode) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies Copy's action-marker cleanup to visible response text only.
|
|
3
|
+
* Markdown and HTML remain source text, not rendered or converted plain text.
|
|
4
|
+
* This does not fetch linked content or modify the original message.
|
|
5
|
+
*/
|
|
6
|
+
export declare const prepareResponseDownloadText: (text: string) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ArtifactData } from "../types/artifact";
|
|
2
|
+
export type ResponseArtifact = Pick<ArtifactData, "id" | "version"> & {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
};
|
|
6
|
+
/** Use the same Markdown parser as chat so quoted/code examples stay literal. */
|
|
7
|
+
export declare const findResponseArtifacts: (text: string) => ResponseArtifact[];
|
|
8
|
+
export declare const prepareResponseArtifactDownload: (text: string, references: ResponseArtifact[], resolve: (reference: ResponseArtifact) => Promise<ArtifactData>, format: "txt" | "md" | "html" | "pdf" | "docx", renderHtml: (content: string) => Promise<string>) => Promise<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exports the same sanitized response used by HTML/PDF as editable Word content.
|
|
3
|
+
* Parsing stays in an inert template. Images are copied with bounded anonymous
|
|
4
|
+
* requests; response scripts and the live chat DOM are never used.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createResponseDownloadDocx: (text: string, preparedHtml?: string) => Promise<Blob>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts prepared response text into a standalone, static HTML document.
|
|
3
|
+
* Does not mount the chat renderer, run response scripts, or fetch linked content.
|
|
4
|
+
* Code fences stay literal; only the export gets these stricter HTML rules.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createResponseDownloadHtml: (text: string) => string;
|
|
7
|
+
/** All assembled content, including artifact snapshots, crosses this boundary. */
|
|
8
|
+
export declare const createResponseDownloadDocument: (rendered: string, preserveArtifactStyles?: boolean) => string;
|
|
9
|
+
/** Opens a print copy from the user's click without changing the live response. */
|
|
10
|
+
export declare const printResponseDownloadHtml: (text: string) => Promise<void>;
|
|
11
|
+
export declare const printResponseDownloadDocument: (html: string, reservedWindow?: Window) => Promise<void>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Only modifies an inert export copy. Never reads or changes live chat images. */
|
|
2
|
+
export declare const embedResponseDownloadImages: (root: ParentNode, format: "docx" | "html") => Promise<Set<Element>>;
|
|
3
|
+
export declare const embedResponseDownloadHtmlImages: (html: string) => Promise<string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type InteractiveArtifactFrame = {
|
|
2
|
+
placeholder: string;
|
|
3
|
+
title: string;
|
|
4
|
+
content: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* HTML downloads only. Assemble frames AFTER sanitizing the outer message, so
|
|
8
|
+
* response markup cannot create frames or executable code in the parent page.
|
|
9
|
+
* srcdoc is serialized as an attribute, never interpolated into raw HTML.
|
|
10
|
+
*/
|
|
11
|
+
export declare const embedInteractiveArtifacts: (sanitizedDocument: string, artifacts: InteractiveArtifactFrame[]) => string;
|
|
@@ -35,6 +35,7 @@ export type PickaxeMisc = {
|
|
|
35
35
|
isTitle: boolean;
|
|
36
36
|
isDescription: boolean;
|
|
37
37
|
isHistory?: boolean;
|
|
38
|
+
isResponseDownload?: boolean;
|
|
38
39
|
};
|
|
39
40
|
type ValidationStatus = "loading" | "success" | "login_required" | "upgrade_required" | "access_denied" | "stripe_checkout";
|
|
40
41
|
export type PickaxeDeploymentEmbedType = "inline" | "fab" | "popup" | "chat-input" | "direct-link";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface PickaxeDownloadButtonProps {
|
|
2
|
+
color: string;
|
|
3
|
+
/** Prepared response text; Markdown and HTML source are preserved. */
|
|
4
|
+
text: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const PickaxeDownloadButton: ({ color, text, disabled, }: PickaxeDownloadButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default PickaxeDownloadButton;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{v4 as e}from"uuid";import{artifactStyleProperties as t}from"./responseArtifactStyles.js";import{artifactSvgSnapshotScript as n}from"./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};\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)};\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>`,i=(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();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()}));export{i as renderResponseArtifactHtml};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=["color","background-color","background-image","font-family","font-size","font-weight","font-style","line-height","letter-spacing","text-align","text-decoration-line","text-decoration-color","text-transform","vertical-align","border-top","border-right","border-bottom","border-left","border-radius","border-collapse","border-spacing","box-shadow","box-sizing","padding-top","padding-right","padding-bottom","padding-left","margin-top","margin-right","margin-bottom","margin-left","display","flex-direction","flex-wrap","align-items","justify-content","gap","list-style-type","list-style-position"],e=e=>{e.querySelectorAll("[style]").forEach((e=>{const o=e.style,r=document.createElement("span").style;for(const e of t){const t=o.getPropertyValue(e);t&&!/url\s*\(|image-set\s*\(|var\s*\(|expression\s*\(|[\\<>@]/i.test(t)&&(e.startsWith("margin")&&/-\d/.test(t)||r.setProperty(e,t))}e.removeAttribute("style"),r.cssText&&e.setAttribute("style",r.cssText)}))};export{t as artifactStyleProperties,e as filterArtifactStyles};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
const e=String.raw`async (source) => {
|
|
2
|
+
const bounds = source.getBoundingClientRect();
|
|
3
|
+
const width = Math.ceil(bounds.width);
|
|
4
|
+
const height = Math.ceil(bounds.height);
|
|
5
|
+
if (!width || !height) return null;
|
|
6
|
+
if (width * height * 4 > 16000000) throw new Error('SVG is too large');
|
|
7
|
+
const copy = source.cloneNode(true);
|
|
8
|
+
const sources = [source, ...source.querySelectorAll('*')];
|
|
9
|
+
const targets = [copy, ...copy.querySelectorAll('*')];
|
|
10
|
+
const ids = new Set(sources.map(node => node.id).filter(Boolean));
|
|
11
|
+
const localReference = (value) => {
|
|
12
|
+
const url = new URL(value, document.baseURI);
|
|
13
|
+
const current = new URL(document.URL);
|
|
14
|
+
const hash = url.hash;
|
|
15
|
+
url.hash = current.hash = '';
|
|
16
|
+
if (!hash || url.href !== current.href || !ids.has(decodeURIComponent(hash.slice(1))))
|
|
17
|
+
throw new Error('SVG requires an external resource');
|
|
18
|
+
return hash;
|
|
19
|
+
};
|
|
20
|
+
const safeValue = (value) => value.replace(/url\(\s*['"]?([^'"\)]+)['"]?\s*\)/gi,
|
|
21
|
+
(_, ref) => 'url("' + localReference(ref.trim()) + '")');
|
|
22
|
+
const properties = [
|
|
23
|
+
'color', 'fill', 'fill-opacity', 'fill-rule', 'stroke', 'stroke-width',
|
|
24
|
+
'stroke-opacity', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit',
|
|
25
|
+
'stroke-dasharray', 'stroke-dashoffset', 'opacity', 'visibility', 'display',
|
|
26
|
+
'font-family', 'font-size', 'font-weight', 'font-style', 'letter-spacing',
|
|
27
|
+
'text-anchor', 'dominant-baseline', 'white-space', 'paint-order',
|
|
28
|
+
'stop-color', 'stop-opacity', 'flood-color', 'flood-opacity', 'lighting-color',
|
|
29
|
+
'clip-path', 'clip-rule', 'mask', 'filter', 'marker-start', 'marker-mid',
|
|
30
|
+
'marker-end', 'vector-effect', 'shape-rendering', 'text-rendering',
|
|
31
|
+
'transform', 'transform-origin', 'transform-box',
|
|
32
|
+
'x', 'y', 'cx', 'cy', 'r', 'rx', 'ry', 'd'
|
|
33
|
+
];
|
|
34
|
+
sources.forEach((node, index) => {
|
|
35
|
+
const target = targets[index];
|
|
36
|
+
const tag = node.localName.toLowerCase();
|
|
37
|
+
if (['script', 'style', 'animate', 'animatemotion', 'animatetransform', 'set'].includes(tag)) {
|
|
38
|
+
target.remove();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (tag === 'foreignobject') throw new Error('SVG embedded HTML cannot be captured');
|
|
42
|
+
// Referenced symbols inherit styles through a browser-created shadow tree.
|
|
43
|
+
// Do not silently flatten them with the wrong colors or missing geometry.
|
|
44
|
+
if (tag === 'use') throw new Error('SVG symbol instances cannot be captured');
|
|
45
|
+
for (const attr of Array.from(target.attributes)) {
|
|
46
|
+
if (/^on/i.test(attr.name) || attr.name === 'style') target.removeAttributeNode(attr);
|
|
47
|
+
else if (attr.localName === 'href') {
|
|
48
|
+
// Links are inert in the picture. Resource references must be self-contained.
|
|
49
|
+
if (tag === 'a') target.removeAttributeNode(attr);
|
|
50
|
+
else if (tag === 'image' && /^data:image\/(png|jpeg|gif);base64,/i.test(attr.value)) continue;
|
|
51
|
+
else attr.value = localReference(attr.value);
|
|
52
|
+
} else attr.value = safeValue(attr.value);
|
|
53
|
+
}
|
|
54
|
+
const computed = getComputedStyle(node);
|
|
55
|
+
for (const property of properties) {
|
|
56
|
+
const value = computed.getPropertyValue(property);
|
|
57
|
+
if (value) target.style.setProperty(property, safeValue(value));
|
|
58
|
+
}
|
|
59
|
+
// Root sizing comes from the visible viewport, not outer-page positioning.
|
|
60
|
+
if (node === source) {
|
|
61
|
+
target.style.removeProperty('transform');
|
|
62
|
+
target.style.removeProperty('transform-origin');
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
copy.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
|
66
|
+
copy.setAttribute('width', String(width));
|
|
67
|
+
copy.setAttribute('height', String(height));
|
|
68
|
+
const xml = new XMLSerializer().serializeToString(copy);
|
|
69
|
+
if (xml.length > 10000000) throw new Error('SVG source is too large');
|
|
70
|
+
const image = new Image();
|
|
71
|
+
const canvas = document.createElement('canvas');
|
|
72
|
+
try {
|
|
73
|
+
await new Promise((resolve, reject) => {
|
|
74
|
+
const done = (ok) => {
|
|
75
|
+
clearTimeout(timeout);
|
|
76
|
+
image.onload = image.onerror = null;
|
|
77
|
+
if (ok) resolve(); else reject(new Error('Unable to capture SVG'));
|
|
78
|
+
};
|
|
79
|
+
const timeout = setTimeout(() => done(false), 5000);
|
|
80
|
+
image.onload = () => done(true);
|
|
81
|
+
image.onerror = () => done(false);
|
|
82
|
+
image.src = 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(xml);
|
|
83
|
+
});
|
|
84
|
+
canvas.width = width * 2;
|
|
85
|
+
canvas.height = height * 2;
|
|
86
|
+
const context = canvas.getContext('2d');
|
|
87
|
+
if (!context) throw new Error('SVG capture unavailable');
|
|
88
|
+
context.drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
89
|
+
const png = canvas.toDataURL('image/png');
|
|
90
|
+
if (png.length > 10000000) throw new Error('SVG picture is too large');
|
|
91
|
+
const picture = document.createElement('img');
|
|
92
|
+
picture.src = png;
|
|
93
|
+
picture.width = width;
|
|
94
|
+
picture.height = height;
|
|
95
|
+
picture.alt = source.getAttribute('aria-label') || source.textContent || '';
|
|
96
|
+
return picture;
|
|
97
|
+
} finally {
|
|
98
|
+
image.removeAttribute('src');
|
|
99
|
+
canvas.width = canvas.height = 0;
|
|
100
|
+
}
|
|
101
|
+
}`;export{e as artifactSvgSnapshotScript};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as t}from"../_virtual/_tslib.js";import{createResponseDownloadDocument as e}from"./responseDownloadHtml.js";import{embedResponseDownloadImages as o}from"./responseDownloadImages.js";const r=(r,n)=>t(void 0,void 0,void 0,(function*(){var t;let i=e(`<div class="pxe-export-artifact">${r}</div>`,!0);const a=document.createElement("template");a.innerHTML=i;const l=yield o(a.content,"docx");for(const e of a.content.querySelectorAll("img")){if(l.has(e))continue;const o=document.createElement("span");o.textContent=`⚠ ${(null===(t=e.getAttribute("alt"))||void 0===t?void 0:t.trim())||"[…]"}`,e.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(((t,e)=>{const o=setTimeout((()=>e(new Error("Word snapshot timed out."))),5e3);c.onload=()=>{clearTimeout(o),t()},c.onerror=()=>{clearTimeout(o),e(new Error("Word snapshot failed."))},c.srcdoc=i,document.body.appendChild(c)}));const t=c.contentDocument,e=c.contentWindow,o=null==t?void 0:t.querySelector("main");if(!t||!e||!o)throw new Error("Word snapshot unavailable.");const r=t.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}",t.head.appendChild(r),t.querySelectorAll("details").forEach((t=>{t.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(((t,o)=>{const r=h[o],n=e.getComputedStyle(t);r.removeAttribute("style");for(const t of Array.from(n))r.style.setProperty(t,n.getPropertyValue(t))})),s.setAttribute("xmlns","http://www.w3.org/1999/xhtml");const m=(new XMLSerializer).serializeToString(s);if(m.length>1e7)throw new Error("Word snapshot is too large.");const p=o.getBoundingClientRect().top,w=[],g=t.createTreeWalker(o,NodeFilter.SHOW_TEXT);for(;g.nextNode();){const e=t.createRange();e.selectNodeContents(g.currentNode);for(const t of Array.from(e.getClientRects()))t.height&&w.push({top:t.top-p,bottom:t.bottom-p})}o.querySelectorAll("tr,img").forEach((t=>{const e=t.getBoundingClientRect();e.height<=800&&w.push({top:e.top-p,bottom:e.bottom-p})}));const u=[];let f=0;for(let e=0;e<l;){let o=Math.min(l,e+800);if(o<l)for(let t=0;t<w.length;t++){const t=w.find((t=>t.top+1<o&&t.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 r=`<svg xmlns="http://www.w3.org/2000/svg" width="${a}" height="${o-e}" viewBox="0 ${e} ${a} ${o-e}"><foreignObject x="0" y="0" width="${a}" height="${l}">${m}</foreignObject></svg>`,i=new Image;yield new Promise(((t,e)=>{const o=setTimeout((()=>n(!1)),5e3),n=r=>{clearTimeout(o),i.onload=i.onerror=null,r?t():e(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-e);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=t.createElement("img");h.src=d,h.width=a,h.height=o-e,h.alt=n;const p=t.createElement("p");p.appendChild(h),u.push(p.outerHTML),c.width=c.height=0,i.removeAttribute("src"),e=o}return u.join("")}finally{c.remove()}}));export{r as createResponseArtifactWordImages};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=e=>{if(!/<action-(caption|finished|error)\b/.test(e))return e;let n="\0pickaxe-download-code:";for(;e.includes(n);)n+=":";const t=[],i=new RegExp([/^(?:[ \t]*> ?)*[ \t]*(?:[-+*] |\d+[.)] )?(`{3,}|~{3,})[^\r\n]*(?:\r?\n|$)/,/(`+)/,/<(pre|code|script|style|textarea)\b(?:[^>"']|"[^"]*"|'[^']*')*>/,/<!--[\s\S]*?(?:-->|(?![\s\S]))/,/<\/?(?!action-(?:caption|finished|error)\b)[a-z][\w:-]*(?:[^>"']|"[^"]*"|'[^']*')*>/,/^(?: {4}|\t)[^\r\n]*/].map((e=>e.source)).join("|"),"gim");let c,l="",s=0;for(;null!==(c=i.exec(e));){let r=i.lastIndex;if(c[1]){const n=c[1],t=new RegExp(`^(?:[ \\t]*> ?)*[ \\t]*${n[0]}{${n.length},}[ \\t]*(?:\\r?\\n|$)`,"gm");t.lastIndex=r;r=t.exec(e)?t.lastIndex:e.length}else if(c[2]){const n=/`+/g;let t;for(n.lastIndex=r;null!==(t=n.exec(e))&&t[0].length!==c[2].length;);if(!t)continue;r=n.lastIndex}else if(c[3]){const n=new RegExp(`</${c[3]}\\s*>`,"gi");n.lastIndex=r;r=n.exec(e)?n.lastIndex:e.length}l+=e.slice(s,c.index),l+=`${n}${t.length}\0`,t.push(e.slice(c.index,r)),s=r,i.lastIndex=r}return l+=e.slice(s),(e=>e.replace(/<action-caption\b[^>]*>([\s\S]*?)<\/action-caption>/g,"$1").replace(/<action-finished\b[^>]*>[\s\S]*?<\/action-finished>/g,"").replace(/<action-error\b[^>]*>[\s\S]*?<\/action-error>/g,""))(l).replace(new RegExp(`${n}(\\d+)\0`,"g"),((e,n)=>t[Number(n)]))};export{e as prepareResponseDownloadText};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as t}from"../_virtual/_tslib.js";import{createElement as e}from"react";import{renderToStaticMarkup as r}from"react-dom/server";import n from"react-markdown";import o from"remark-gfm";import i from"rehype-raw";import{v4 as a}from"uuid";import{createResponseArtifactWordImages as s}from"./responseArtifactWordImages.js";import{createResponseSvgImage as c}from"./responseStandaloneSvg.js";import{createResponseMermaidImage as l}from"./responseMermaid.js";import{embedInteractiveArtifacts as p}from"./responseInteractiveArtifactHtml.js";import{createResponseDownloadDocument as d,createResponseDownloadHtml as m}from"./responseDownloadHtml.js";const f=t=>{if(!/<artifact\b/i.test(t))return[];const a=[];return r(e(n,{remarkPlugins:[o],rehypePlugins:[i],components:{artifact:({node:t})=>{var e,r,n,o;const i=null===(e=t.position)||void 0===e?void 0:e.start.offset,s=null===(r=t.position)||void 0===r?void 0:r.end.offset,c=String(null!==(n=t.properties.dataId)&&void 0!==n?n:""),l=Number(null!==(o=t.properties.dataVersion)&&void 0!==o?o:1);if(null==i||null==s||!c||!Number.isInteger(l)||l<1)throw new Error("Invalid response artifact reference.");return a.push({id:c,version:l,start:i,end:s}),null}}},t)),a.sort(((t,e)=>t.start-e.start))},u=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),v=t=>{var e,r;const n=document.createElement("template");return n.innerHTML=m(t),null!==(r=null===(e=n.content.querySelector("main"))||void 0===e?void 0:e.innerHTML)&&void 0!==r?r:""},h=(t,e)=>{const r=[];let n=[],o="",i=!1;for(let a=0;a<t.length;a++){const s=t[a];'"'===s?i&&'"'===t[a+1]?(o+='"',a++):i=!i:i||s!==e&&"\n"!==s&&"\r"!==s?o+=s:(n.push(o),o="",s!==e&&(r.push(n),n=[],"\r"===s&&"\n"===t[a+1]&&a++))}if(i)throw new Error("Incomplete artifact table.");return(o||n.length)&&r.push([...n,o]),`<table>${r.map(((t,e)=>`<tr>${t.map((t=>{const r=e?"td":"th";return`<${r}>${u(t).replace(/\n/g,"<br>")}</${r}>`})).join("")}</tr>`)).join("")}</table>`},g=(e,r,n,o,i)=>t(void 0,void 0,void 0,(function*(){const t="txt"===o||"md"===o,m=[],f=[];let g=0;for(const p of r){const r=yield n(p);if(r.id!==p.id||r.version!==p.version||r.status&&"finished"!==r.status)throw new Error("Response artifact is not ready.");const d=e.slice(g,p.start);if(m.push(t?d:v(d)),t){const t="`".repeat(Math.max(3,...Array.from(r.content.matchAll(/`+/g),(t=>t[0].length+1))));m.push(`\n\n${r.title}\n\n${"md"===o&&"text/markdown"!==r.type?`${t}\n${r.content}\n${t}`:r.content}\n\n`)}else{let t;switch(r.type){case"text/markdown":t=v(r.content);break;case"text/csv":t=h(r.content,",");break;case"text/tab-separated-values":t=h(r.content,"\t");break;case"application/vnd.pxe.mermaid":t=yield l(r.content,r.title);break;case"image/svg+xml":t=yield c(r.content,r.title);break;case"text/html":if("html"===o){const e=`artifact-${a()}`;f.push({placeholder:e,title:r.title,content:r.content}),t=`<div id="${e}"></div>`;break}t=yield i(r.content),"docx"===o&&(t=yield s(t,r.title));break;case"application/pdf":t=yield i(r.content);break;case"application/vnd.pxe.code":t=`<pre><code>${u(r.content)}</code></pre>`;break;default:throw new Error(`Artifact export is not supported for ${r.type}.`)}m.push(`<section><h2>${u(r.title)}</h2><div class="pxe-export-artifact">${t}</div></section>`)}g=p.end}return m.push(t?e.slice(g):v(e.slice(g))),t?m.join(""):p(d(m.join("\n"),"html"===o||"pdf"===o),f)}));export{f as findResponseArtifacts,g as prepareResponseArtifactDownload};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as e}from"../_virtual/_tslib.js";import{Document as t,Paragraph as r,Packer as n,TextRun as i,Tab as a,HeadingLevel as s,BorderStyle as o,UnderlineType as l,ImageRun as c,ExternalHyperlink as d,TableRow as u,TableCell as m,WidthType as g,Table as h,LevelFormat as p,AlignmentType as b}from"docx";import{createResponseDownloadHtml as f}from"./responseDownloadHtml.js";import{embedResponseDownloadImages as w}from"./responseDownloadImages.js";const A=720,N=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"]),O=e=>{if(e&&/^(https?:|mailto:|tel:)/i.test(e.trim()))try{return new URL(e.trim()).href}catch(e){return}},E=(e,t)=>{const r=Object.assign({},t);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:l.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},I=(I,j)=>e(void 0,void 0,void 0,(function*(){const e=document.createElement("template");e.innerHTML=null!=j?j:f(I);const y=e.content.querySelector("main");if(!y)throw new Error("Unable to prepare the response document.");const T=yield w(y,"docx"),v=new Map;for(const e of T){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 i=n.getUint32(16),a=n.getUint32(20);if(!i||!a||i*a>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===i&&n.naturalHeight===a),n.onerror=()=>s(!1),n.src=t}));const s=Number(e.getAttribute("width")),o=s>0?Math.min(1,s/i):1;v.set(e,{data:r,width:i*o,height:a*o})}const D=[],S=(e,t,r)=>Array.from(e).flatMap((e=>{var n;if(3===e.nodeType){const r=e.textContent||"";return[new i(Object.assign(Object.assign({},t),{text:(null===(n=e.parentElement)||void 0===n?void 0:n.closest("code"))?r:r.replace(/[\t\n\r ]+/g," ")}))]}if(1!==e.nodeType)return[];const a=e,s=E(a,t);if("BR"===a.tagName)return[new i(Object.assign(Object.assign({},t),{break:1}))];if("IMG"===a.tagName){const e=v.get(a);if(e){const t=Math.min(1,Math.max(1,r/15)/e.width,900/e.height);return[new c(Object.assign(Object.assign({type:"png",data:e.data},a.getAttribute("alt")?{altText:{name:a.getAttribute("alt")||""}}:{}),{transformation:{width:e.width*t,height:e.height*t}}))]}const n=O(a.getAttribute("src")),s=a.getAttribute("alt")||n||"[…]",o=[new i(Object.assign(Object.assign({},t),{text:s}))];return n&&!a.closest("a")?[new d({link:n,children:o})]:o}const o="A"===a.tagName?O(a.getAttribute("href")):void 0,u=S(a.childNodes,o?Object.assign(Object.assign({},s),{color:"174EA6",underline:{type:l.SINGLE}}):s,r);return o?[new d({link:o,children:u})]:u})),H=(e,t,n={})=>{const i=t.marker&&!t.marker.used?t.marker:void 0;return i&&(i.used=!0),new r(Object.assign(Object.assign(Object.assign({children:e,spacing:{after:160},widowControl:!0},t.indent?{indent:Object.assign({left:t.indent},i?{hanging:360}:{})}:{}),null==i?void 0:i.properties),n))},k=(e,t)=>{var r;const n="OL"===e.tagName;let i="",a=!1;const s=e=>{i=`response-list-${D.length}`,a=0===e,D.push({reference:i,levels:[{level:0,format:p.DECIMAL,text:a?"0.":"%1.",start:a?1:e,alignment:b.LEFT}]})},o=e.hasAttribute("reversed"),l=Array.from(e.children).filter((e=>"LI"===e.tagName)),c=Number.parseInt(e.getAttribute("start")||"",10);let d=Number.isFinite(c)?c:o?l.length:1;n&&s(d);const u=[];for(const l of Array.from(e.children)){if("LI"!==l.tagName){u.push(...M([l],t));continue}const e=Number.parseInt(l.getAttribute("value")||"",10);n&&Number.isFinite(e)&&(d=e),n&&(o||a||0===d||Number.isFinite(e))&&s(d),d+=o?-1:1;const c=Object.assign(Object.assign({},t),{indent:Math.min(t.indent+720,5760),marker:{used:!1,properties:n?{numbering:{reference:i,level:0}}:{bullet:{level:0}}}}),m=M(l.childNodes,c);(null===(r=c.marker)||void 0===r?void 0:r.used)||m.unshift(H([],c)),u.push(...m)}return u},L=(e,t)=>{const n=[];let i=0;const a=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 a=t=>Math.min(100,Math.max(1,parseInt(e.getAttribute(t)||"1",10)||1)),s=a("colspan"),o=a("rowspan"),l=r;for(let e=0;e<s;e++)n[r++]=t+o;return i=Math.max(i,r),{cell:e,start:l,columnSpan:s,rowSpan:o}}))}})),s=e=>Math.floor(e*t/i),o=Array.from({length:i},((e,t)=>s(t+1)-s(t))),l=a.flatMap((({row:e,cells:t})=>{var n;return t.length?[new u({tableHeader:"THEAD"===(null===(n=e.parentElement)||void 0===n?void 0:n.tagName)||t.every((({cell:e})=>"TH"===e.tagName)),children:t.map((({cell:e,start:t,columnSpan:n,rowSpan:i})=>{const a=s(t+n)-s(t),o=M(e.childNodes,{indent:0,width:Math.max(1,a-200),run:{bold:"TH"===e.tagName}});return o[o.length-1]instanceof r||o.push(new r("")),new m(Object.assign({children:o,columnSpan:n,rowSpan:i,width:{size:a,type:g.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?[...M(c,{indent:0,width:t,run:{}}),new h({rows:l,width:{size:t,type:g.DXA},columnWidths:o})]:M(e.childNodes,{indent:0,width:t,run:{}})},M=(e,t)=>{const r=[];let n=[];const l=()=>{n.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(H(S(n,t.run,t.width-t.indent),t)),n=[]};for(const c of Array.from(e)){if(1!==c.nodeType||!N.has(c.tagName)){1===c.nodeType&&Array.from(c.children).some((e=>N.has(e.tagName)))?(l(),r.push(...M(c.childNodes,Object.assign(Object.assign({},t),{run:E(c,t.run)})))):n.push(c);continue}l();const e=c,d=e.tagName;if("UL"===d||"OL"===d)t.marker&&!t.marker.used&&r.push(H([],t)),r.push(...k(e,t));else if("TABLE"===d)t.marker&&!t.marker.used&&r.push(H([],t)),r.push(...L(e,t.width));else if("PRE"===d){const n=(e.textContent||"").replace(/\r\n?/g,"\n").split("\n");r.push(H(n.map(((e,r)=>new i(Object.assign(Object.assign(Object.assign({},t.run),{children:e.split("\t").flatMap(((e,t)=>t?[new a,e]:[e])),font:"Courier New",size:20}),r?{break:1}:{})))),t,{shading:{fill:"F4F4F4"},spacing:{before:120,after:160}}))}else if(/^H[1-6]$/.test(d)){const n=[s.HEADING_1,s.HEADING_2,s.HEADING_3,s.HEADING_4,s.HEADING_5,s.HEADING_6];r.push(H(S(e.childNodes,Object.assign(Object.assign({},t.run),{bold:!0,color:"202020"}),t.width-t.indent),t,{heading:n[Number(d[1])-1],keepNext:!0}))}else if("HR"===d)r.push(H([],t,{border:{bottom:{style:o.SINGLE,color:"CCCCCC",size:4}}}));else{const n="BLOCKQUOTE"===d?Object.assign(Object.assign({},t),{indent:t.indent+360}):t,i=M(e.childNodes,n);r.push(...i),i.length||"P"!==d||r.push(H([],n))}}return l(),r},C=M(y.childNodes,{indent:0,width:10800,run:{}}),U=new t({title:"Pickaxe",creator:"Pickaxe",styles:{default:{document:{run:{font:"Arial",size:22,color:"202020"}}}},numbering:{config:D},sections:[{properties:{page:{size:{width:12240,height:15840},margin:{top:A,bottom:A,left:A,right:A}}},children:C.length?C:[new r("")]}]});return n.toBlob(U)}));export{I as createResponseDownloadDocx};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as e}from"../_virtual/_tslib.js";import{createElement as t}from"react";import{renderToStaticMarkup as r}from"react-dom/server";import o from"react-markdown";import n from"remark-gfm";import i from"rehype-raw";import a from"isomorphic-dompurify";import{filterArtifactStyles as l}from"./responseArtifactStyles.js";const p=e=>{const a=r(t(o,{remarkPlugins:[n],rehypePlugins:[i],components:{input:({type:e,checked:r})=>"checkbox"===(null==e?void 0:e.toLowerCase())?t("span",null,r?"☑":"☐"):null}},e));return c(a)},c=(e,t=!1)=>{let r=a.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(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>`},d=e=>s(p(e)),s=(t,r)=>e(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 o=r.createElement("style");if(o.media="print",o.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(o),r.querySelectorAll("details").forEach((e=>{e.open=!0})),r.querySelectorAll("img").forEach((e=>{e.loading="eager"})),r.close(),e.focus(),yield m(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}})),m=(t,r)=>new Promise(((o,n)=>{const i=new Set(Array.from(r.images)),a=e=>{if(c)return;i.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((()=>{i.forEach(a),d()}),15e3),p=window.setInterval((()=>{t.closed&&d(new Error("The response print window was closed."))}),100);let c=!1;function d(e){c||(c=!0,window.clearTimeout(l),window.clearInterval(p),e?n(e):o())}Promise.all([...Array.from(i,(t=>e(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.");i.delete(t)}catch(e){a(t)}})))),r.fonts.ready]).then((()=>d()),(()=>d(new Error("Unable to load the response print resources."))))}));export{c as createResponseDownloadDocument,p as createResponseDownloadHtml,s as printResponseDownloadDocument,d as printResponseDownloadHtml};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as e}from"../_virtual/_tslib.js";const t=75e5,r=25e6,n=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){}},o=(e,t)=>new Promise(((r,n)=>{const o=new Image,i=e=>{o.onload=o.onerror=null,t.removeEventListener("abort",l),e&&o.naturalWidth&&o.naturalHeight?r(o):(o.removeAttribute("src"),n(new Error("Image unavailable.")))},l=()=>i(!1);if(t.aborted)return l();t.addEventListener("abort",l,{once:!0}),o.referrerPolicy="no-referrer",o.onload=()=>i(!0),o.onerror=()=>i(!1),o.src=e})),i=(i,l)=>e(void 0,void 0,void 0,(function*(){const a=Array.from(i.querySelectorAll("img")),c=new Set,s=new AbortController,d=setTimeout((()=>s.abort()),15e3),u=new Map;let m=0,g=0;const h=n=>e(void 0,void 0,void 0,(function*(){let i,a;try{if(s.signal.aborted)return;const c=yield((r,n)=>e(void 0,void 0,void 0,(function*(){var e;const o=yield fetch(r,{signal:n,credentials:"omit",referrerPolicy:"no-referrer"});if(!o.ok||!o.body)throw new Error("Image unavailable.");const i=null===(e=o.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(o.headers.get("content-length"))>t)throw yield o.body.cancel(),new Error("Unsupported image.");const l=o.body.getReader(),a=[];let c=0;try{for(;;){const{done:e,value:r}=yield l.read();if(e)break;if(c+=r.byteLength,c>t)throw new Error("Image too large.");a.push(r)}}finally{yield l.cancel()}return new Blob(a,{type:i})})))(n,s.signal);if(m+=c.size,m>r)return;if(i=URL.createObjectURL(c),a=yield o(i,s.signal),a.naturalWidth*a.naturalHeight>16e6)return;if("docx"===l||"image/svg+xml"===c.type){const e=document.createElement("canvas");try{e.width=a.naturalWidth,e.height=a.naturalHeight;const t=e.getContext("2d");if(!t)return;t.drawImage(a,0,0);const n=e.toDataURL("image/png");if(m+=n.length,n.length>1e7||m>r)return;return n}finally{e.width=e.height=0}}const d=new Uint8Array(yield c.arrayBuffer());let u="";for(let e=0;e<d.length;e+=8192)u+=String.fromCharCode(...d.subarray(e,e+8192));return`data:${c.type};base64,${btoa(u)}`}catch(e){return}finally{null==a||a.removeAttribute("src"),i&&URL.revokeObjectURL(i)}}));try{yield Promise.all(Array.from({length:Math.min(4,a.length)},(()=>e(void 0,void 0,void 0,(function*(){for(var e,t;g<a.length;){const r=a[g++],i=n(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)c.add(r),r.setAttribute("src",d),r.removeAttribute("srcset");else if("html"===l&&(null==i?void 0:i.startsWith("https:")))try{(yield o(i,s.signal)).removeAttribute("src");continue}catch(t){const n=document.createElement("span");n.textContent=`⚠ ${(null===(e=r.getAttribute("alt"))||void 0===e?void 0:e.trim())||"[…]"}`,r.replaceWith(n)}else if("html"===l){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),s.abort()}return c})),l=t=>e(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}`}));export{l as embedResponseDownloadHtmlImages,i as embedResponseDownloadImages};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=(e,t)=>{var n;if(!t.length)return e;const r=(new DOMParser).parseFromString(e,"text/html"),i=r.querySelector('meta[http-equiv="Content-Security-Policy"]');if(!i)throw new Error("Missing response document policy.");i.setAttribute("content",i.getAttribute("content").replace("script-src 'none'","script-src 'unsafe-inline'"));const o=r.createElement("style");o.textContent="\nmain { max-width: 1200px; }\nmain > * { max-width: 900px; margin-left: auto; margin-right: auto; }\nmain > .pxe-interactive-section { max-width: none; }\n@media (max-width: 600px) { main { padding: 12px; } }\n",r.head.appendChild(o);for(const e of t){const t=r.getElementById(e.placeholder);if(!t)throw new Error("Missing response artifact placeholder.");null===(n=t.closest("section"))||void 0===n||n.classList.add("pxe-interactive-section");const i=r.createElement("iframe");i.setAttribute("sandbox","allow-scripts"),i.setAttribute("referrerpolicy","no-referrer"),i.title=e.title,i.style.cssText="display:block;width:100%;height:85vh;min-height:360px;border:0;resize:vertical;overflow:auto;",i.srcdoc=e.content,t.replaceWith(i)}return`<!doctype html>\n${r.documentElement.outerHTML}`};export{e as embedInteractiveArtifacts};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as e}from"../_virtual/_tslib.js";import t from"../node_modules/.pnpm/mermaid@11.7.0/node_modules/mermaid/dist/mermaid.core.mjs.js";import{v4 as r}from"uuid";import{createResponseSvgImage as i}from"./responseStandaloneSvg.js";const o=(o,n)=>e(void 0,void 0,void 0,(function*(){const e=o.trim();if(!e||e.length>5e4||/^---/.test(e)||/%%\s*\{/.test(e)||/<\/?[a-z!]|\burl\s*\(|\bimg\s*:|\\/i.test(e)||/@|(?:https?|data):|\/\/|image-set\s*\(/i.test(e))throw new Error("Unsupported Mermaid export content.");if("strict"!==t.mermaidAPI.getSiteConfig().securityLevel)throw new Error("Mermaid export requires strict rendering.");const s=`pxe-export-mermaid-${r()}`,d=document.createElement("div");d.setAttribute("aria-hidden","true"),d.style.cssText="position:fixed;left:-10000px;top:0;width:1200px;visibility:hidden;pointer-events:none;",document.body.appendChild(d);try{const r=yield t.render(s,"---\nconfig:\n htmlLabels: false\n flowchart:\n htmlLabels: false\n suppressErrorRendering: true\n---\n"+e,d),o=(new DOMParser).parseFromString(r.svg,"image/svg+xml");for(const e of o.querySelectorAll("style")){const t=new CSSStyleSheet;t.replaceSync(e.textContent||"");const r=[];for(const e of Array.from(t.cssRules))if(e.type===CSSRule.STYLE_RULE)r.push(e.cssText);else if(e.type!==CSSRule.KEYFRAMES_RULE)throw new Error("Unsupported Mermaid stylesheet.");e.textContent=r.join("\n")}return yield i((new XMLSerializer).serializeToString(o),n)}finally{d.remove()}}));export{o as createResponseMermaidImage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as e}from"../_virtual/_tslib.js";const t=(t,r)=>e(void 0,void 0,void 0,(function*(){var e;if(t.length>1e7||/<!DOCTYPE|<!ENTITY/i.test(t))throw new Error("Unsupported SVG document.");const o=(new DOMParser).parseFromString(t,"image/svg+xml"),i=o.documentElement;if(o.querySelector("parsererror")||"svg"!==i.localName||i.namespaceURI&&"http://www.w3.org/2000/svg"!==i.namespaceURI)throw new Error("Invalid SVG artifact.");const n=e=>{const t=e.startsWith("#")?e.slice(1):"";if(!t||!o.getElementById(t))throw new Error("SVG requires an external or missing resource.")},a=e=>{if(/[\\@]/.test(e))throw new Error("Unsupported SVG stylesheet.");for(const t of e.matchAll(/url\(\s*["']?([^"')]+)["']?\s*\)/gi))n(t[1].trim())};for(const e of[i,...i.querySelectorAll("*")]){const t=e.localName.toLowerCase();if("script"!==t){if("foreignobject"===t||e.namespaceURI&&"http://www.w3.org/2000/svg"!==e.namespaceURI)throw new Error("Unsupported embedded SVG content.");"style"===t&&a(e.textContent||"");for(const r of Array.from(e.attributes))if(/^on/i.test(r.name))e.removeAttributeNode(r);else{if("xml:base"===r.name)throw new Error("SVG base URLs are unsupported.");if("href"===r.localName)if("a"===t)e.removeAttributeNode(r);else{if("image"===t&&/^data:image\/(png|jpeg|gif);base64,/i.test(r.value))continue;n(r.value)}else("style"===r.name||/url\s*\(/i.test(r.value))&&a(r.value)}}else e.remove()}const s=(i.getAttribute("viewBox")||"").trim().split(/[\s,]+/).map(Number),l=4===s.length&&s.every(Number.isFinite)&&s[2]>0&&s[3]>0,m=(e,t)=>{const r=i.getAttribute(e);if(!r||r.endsWith("%"))return t;if(!/^\d+(?:\.\d+)?(?:px)?$/.test(r))throw new Error("Unsupported SVG dimensions.");return parseFloat(r)},c=Math.ceil(m("width",l?s[2]:300)),u=Math.ceil(m("height",l?s[3]:150));if(!c||!u||c>4096||u>4096||c*u*4>16e6)throw new Error("SVG image is too large.");i.setAttribute("xmlns","http://www.w3.org/2000/svg"),i.setAttribute("width",String(c)),i.setAttribute("height",String(u));const g=new Image,w=document.createElement("canvas");try{yield new Promise(((e,t)=>{const r=r=>{clearTimeout(o),g.onload=g.onerror=null,r?e():t(new Error("Unable to read SVG artifact."))},o=setTimeout((()=>r(!1)),5e3);g.onload=()=>r(!0),g.onerror=()=>r(!1),g.src="data:image/svg+xml;charset=utf-8,"+encodeURIComponent((new XMLSerializer).serializeToString(i))})),w.width=2*c,w.height=2*u;const t=w.getContext("2d");if(!t)throw new Error("SVG image capture unavailable.");t.drawImage(g,0,0,w.width,w.height);const o=w.toDataURL("image/png");if(o.length>1e7)throw new Error("SVG picture is too large.");const n=document.createElement("img");return n.src=o,n.width=c,n.height=u,n.alt=i.getAttribute("aria-label")||(null===(e=i.querySelector("title"))||void 0===e?void 0:e.textContent)||r,n.outerHTML}finally{g.removeAttribute("src"),w.width=w.height=0}}));export{t as createResponseSvgImage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import{createContext as i,useState as o,useEffect as n}from"react";import{ArtifactProvider as a}from"./Addons/Artifact/Provider.js";import s from"./DimensionProvider.js";import r from"./ResponseProvider.js";import l from"./Addons/Document/Provider.js";import d from"./Addons/Auth/Provider.js";const c=i({}),p=({children:i,origin:p,sender:u,senderType:m,deploymentId:g,portalId:f,deploymentType:h,deploymentDimensions:y,deploymentMisc:v,styles:b,colors:w,limits:k={},misc:S={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:C,artifact:I={popupType:"auto"},responsiveBy:P="viewport",locale:F="en",opacity:A=1,forceMobile:x=!1,disableHtml:T=!1,disableJs:D=!1,disableCss:U=!1,loadFont:q=!0,isRtl:R=!1,isEmbed:O=!1,mcpEnabled:M=!1,mcpGuestId:j,studioSessionToken:E,isDropShadow:L=!1,allowGuestUsage:G=!0,persistActiveConversation:H=!1,preventInitialSessionId:W=!1,onUpgrade:B,onGenerateComplete:N,onSessionIdChange:V})=>{const[Y,X]=o(""),[J,_]=o(""),[z,Q]=o(""),[K,Z]=o(""),[$,ee]=o(u),[te,ie]=o(null),[oe,ne]=o(m),[ae,se]=o("loading"),[re,le]=o([]),[de,ce]=o(null),[pe,ue]=o(null),[me,ge]=o(null),[fe,he]=o(null),[ye,ve]=o("");n((()=>ve("")),[J]);const[be,we]=o(!1),[ke,Se]=o(!0),[Ce,Ie]=o(!0),[Pe,Fe]=o(!1);return n((()=>{we(!1)}),[null==b?void 0:b.font]),n((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&q&&!be&&(null==b?void 0:b.font)&&"Real Head Pro"!==b.font)try{(yield import("webfontloader")).default.load({google:{families:[b.font]},active:()=>{we(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),we(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),we(!0)}}))}),[q,be,null==b?void 0:b.font]),n((()=>{ee(u)}),[u]),t(c.Provider,Object.assign({value:Object.assign(Object.assign({origin:p,contextId:Y,pickaxeId:J,sessionId:z,lastSessionId:K,sender:$,senderType:oe,portalId:f,deploymentId:g,deploymentType:h,validationStatus:ae,validationUpgradeGroups:re,validationUpgradeUrl:de,deploymentDimensions:y,deploymentMisc:v,accessGroup:te,pickaxe:fe,selectedModel:ye,setSelectedModel:ve,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},b),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},w),misc:S,translations:Object.assign({"form-next":"Next","form-progress":"Form progress","form-page-progress":"Question {current} of {total}","action-confirmation-needed":"Confirmation needed","action-confirmation-unavailable":"Confirmation unavailable","action-approved":"Approved","action-declined":"Declined","action-expired":"Expired","action-not-run":"Not run","action-label":"Action: {name}","action-confirmation-description":"Review this action before it runs. Your decision applies only to this call.","action-inputs":"Action inputs","decline-action":"Decline","approve-action":"Approve action","action-confirmation-resolved":"This confirmation has expired or already been resolved.","action-decision-failed":"Could not save your decision. Please try again.","ai-model":"AI model","default-ai-model":"Default ({model})","attach-files":"Attach files","new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.","something-wrong-occured":"Something wrong occurred",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","enter-verification-code":"Or enter the 6-digit code from the email","verification-code-session-missing":"Your login request could not be found. Please resend the email.","verification-code-invalid":"Invalid verification code.",verifying:"Verifying...",verify:"Verify","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","mcp-use-with-ai-app":"Use with an AI app","mcp-use-agent-in-ai-app":"Use this agent in your AI app","mcp-connect-description":"Connect through MCP. Requests will be sent as your signed-in Studio user.","mcp-ai-app":"AI app","mcp-copy-configuration":"Copy MCP configuration","mcp-private-configuration-note":"Keep this configuration private. It contains your Studio session token and stops working when that session expires.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.","queue-message":"Queue message","stop-response":"Stop response",steer:"Steer","steer-with":"Steer with",steering:"Steering...",starting:"Starting...","remove-queued-message":"Remove queued message","edit-message":"Edit message","more-options":"More options","failed-to-interrupt-current-response":"Failed to interrupt the current response.","current-response-still-stopping":"The current response is still stopping. Please send your message again in a moment.","queued-message-waiting":"A queued message is waiting for the previous response to finish.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, GIF, or M4A files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},C),artifact:I,responsiveBy:P,locale:F,opacity:A,forceMobile:x,loadFont:q,disableHtml:T,disableJs:D,disableCss:U,isFontLoaded:be,isNewChat:ke,isShowIceBreaker:Ce,isShowFeedbackMessage:Pe,isRtl:R,isEmbed:O,mcpEnabled:M,mcpGuestId:j,isDropShadow:L,allowGuestUsage:G,persistActiveConversation:H,clientSecret:me,stripeAccountId:pe,preventInitialSessionId:W,setClientSecret:ge,setStripeAccountId:ue,setContextId:X,setValidationStatus:se,setValidationUpgradeGroups:le,setValidationUpgradeUrl:ce,setPickaxeId:_,setSessionId:e=>{Q((t=>{const i="function"==typeof e?e(t):e;return null==V||V(i),i}))},setLastSessionId:Z,setSender:ee,setSenderType:ne,setAccessGroup:ie,setPickaxe:he,setIsFontLoaded:we,setIsNewChat:Se,setIsShowIceBreaker:Ie,setIsShowFeedbackMessage:Fe},B&&{onUpgrade:B}),N&&{onGenerateComplete:N})},{children:t(d,Object.assign({initialToken:E},{children:t(s,{children:t(r,Object.assign({limits:k},{children:t(l,{children:t(a,Object.assign({},I,{children:i}))})}))})}))}))};export{c as PickaxeContext,p as PickaxeProvider};
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import{createContext as i,useState as o,useEffect as n}from"react";import{ArtifactProvider as a}from"./Addons/Artifact/Provider.js";import s from"./DimensionProvider.js";import r from"./ResponseProvider.js";import l from"./Addons/Document/Provider.js";import d from"./Addons/Auth/Provider.js";const c=i({}),p=({children:i,origin:p,sender:u,senderType:m,deploymentId:g,portalId:f,deploymentType:h,deploymentDimensions:y,deploymentMisc:v,styles:b,colors:w,limits:k={},misc:S={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0,isResponseDownload:!1},translations:C,artifact:I={popupType:"auto"},responsiveBy:P="viewport",locale:F="en",opacity:A=1,forceMobile:x=!1,disableHtml:T=!1,disableJs:D=!1,disableCss:U=!1,loadFont:q=!0,isRtl:R=!1,isEmbed:O=!1,mcpEnabled:M=!1,mcpGuestId:j,studioSessionToken:E,isDropShadow:L=!1,allowGuestUsage:G=!0,persistActiveConversation:H=!1,preventInitialSessionId:W=!1,onUpgrade:B,onGenerateComplete:N,onSessionIdChange:V})=>{const[Y,X]=o(""),[J,_]=o(""),[z,Q]=o(""),[K,Z]=o(""),[$,ee]=o(u),[te,ie]=o(null),[oe,ne]=o(m),[ae,se]=o("loading"),[re,le]=o([]),[de,ce]=o(null),[pe,ue]=o(null),[me,ge]=o(null),[fe,he]=o(null),[ye,ve]=o("");n((()=>ve("")),[J]);const[be,we]=o(!1),[ke,Se]=o(!0),[Ce,Ie]=o(!0),[Pe,Fe]=o(!1);return n((()=>{we(!1)}),[null==b?void 0:b.font]),n((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&q&&!be&&(null==b?void 0:b.font)&&"Real Head Pro"!==b.font)try{(yield import("webfontloader")).default.load({google:{families:[b.font]},active:()=>{we(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),we(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),we(!0)}}))}),[q,be,null==b?void 0:b.font]),n((()=>{ee(u)}),[u]),t(c.Provider,Object.assign({value:Object.assign(Object.assign({origin:p,contextId:Y,pickaxeId:J,sessionId:z,lastSessionId:K,sender:$,senderType:oe,portalId:f,deploymentId:g,deploymentType:h,validationStatus:ae,validationUpgradeGroups:re,validationUpgradeUrl:de,deploymentDimensions:y,deploymentMisc:v,accessGroup:te,pickaxe:fe,selectedModel:ye,setSelectedModel:ve,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},b),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},w),misc:S,translations:Object.assign({"form-next":"Next","form-progress":"Form progress","form-page-progress":"Question {current} of {total}","action-confirmation-needed":"Confirmation needed","action-confirmation-unavailable":"Confirmation unavailable","action-approved":"Approved","action-declined":"Declined","action-expired":"Expired","action-not-run":"Not run","action-label":"Action: {name}","action-confirmation-description":"Review this action before it runs. Your decision applies only to this call.","action-inputs":"Action inputs","decline-action":"Decline","approve-action":"Approve action","action-confirmation-resolved":"This confirmation has expired or already been resolved.","action-decision-failed":"Could not save your decision. Please try again.","ai-model":"AI model","default-ai-model":"Default ({model})","attach-files":"Attach files","new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.","something-wrong-occured":"Something wrong occurred",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","enter-verification-code":"Or enter the 6-digit code from the email","verification-code-session-missing":"Your login request could not be found. Please resend the email.","verification-code-invalid":"Invalid verification code.",verifying:"Verifying...",verify:"Verify","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","mcp-use-with-ai-app":"Use with an AI app","mcp-use-agent-in-ai-app":"Use this agent in your AI app","mcp-connect-description":"Connect through MCP. Requests will be sent as your signed-in Studio user.","mcp-ai-app":"AI app","mcp-copy-configuration":"Copy MCP configuration","mcp-private-configuration-note":"Keep this configuration private. It contains your Studio session token and stops working when that session expires.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.","queue-message":"Queue message","stop-response":"Stop response",steer:"Steer","steer-with":"Steer with",steering:"Steering...",starting:"Starting...","remove-queued-message":"Remove queued message","edit-message":"Edit message","more-options":"More options","failed-to-interrupt-current-response":"Failed to interrupt the current response.","current-response-still-stopping":"The current response is still stopping. Please send your message again in a moment.","queued-message-waiting":"A queued message is waiting for the previous response to finish.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, GIF, or M4A files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},C),artifact:I,responsiveBy:P,locale:F,opacity:A,forceMobile:x,loadFont:q,disableHtml:T,disableJs:D,disableCss:U,isFontLoaded:be,isNewChat:ke,isShowIceBreaker:Ce,isShowFeedbackMessage:Pe,isRtl:R,isEmbed:O,mcpEnabled:M,mcpGuestId:j,isDropShadow:L,allowGuestUsage:G,persistActiveConversation:H,clientSecret:me,stripeAccountId:pe,preventInitialSessionId:W,setClientSecret:ge,setStripeAccountId:ue,setContextId:X,setValidationStatus:se,setValidationUpgradeGroups:le,setValidationUpgradeUrl:ce,setPickaxeId:_,setSessionId:e=>{Q((t=>{const i="function"==typeof e?e(t):e;return null==V||V(i),i}))},setLastSessionId:Z,setSender:ee,setSenderType:ne,setAccessGroup:ie,setPickaxe:he,setIsFontLoaded:we,setIsNewChat:Se,setIsShowIceBreaker:Ie,setIsShowFeedbackMessage:Fe},B&&{onUpgrade:B}),N&&{onGenerateComplete:N})},{children:t(d,Object.assign({initialToken:E},{children:t(s,{children:t(r,Object.assign({limits:k},{children:t(l,{children:t(a,Object.assign({},I,{children:i}))})}))})}))}))};export{c as PickaxeContext,p as PickaxeProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as i}from"react";import{createPortal as s}from"react-dom";import{v4 as l}from"uuid";import a from"file-saver";import{createResponseDownloadDocx as d}from"../../../common/responseDownloadDocx.js";import{embedResponseDownloadHtmlImages as c}from"../../../common/responseDownloadImages.js";import{printResponseDownloadDocument as u,printResponseDownloadHtml as m,createResponseDownloadHtml as p}from"../../../common/responseDownloadHtml.js";import{findResponseArtifacts as f,prepareResponseArtifactDownload as x}from"../../../common/responseDownloadArtifacts.js";import{renderResponseArtifactHtml as v}from"../../../common/responseArtifactSnapshot.js";import{useArtifactContext as h}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useArtifactData as y}from"../Addons/Artifact/hooks/useArtifactData.js";import{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import{usePickaxeContext as w}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useOutsideAlerter as g}from"../../../hooks/core/useOutsideAlerter.js";import k from"../../Icons/download.svg.js";import j from"../../Core/Menu/index.js";import A from"../../Core/Menu/List.js";const D=[{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"}],T=({color:T,text:C,disabled:O=!1})=>{const{translations:S,colors:P,styles:I,isRtl:M,sender:N,senderType:$,pickaxe:B}=w(),{artifacts:E=[]}=h(),{token:F}=b(),L=y(),[_,H]=n(""),[K,R]=n(!1),[U,X]=n(),[W,q]=n(!1),z=r(!1),G=r(null),J=r(null),Q=r([]),V=r(0),Y=(null==S?void 0:S.download)||"Download",Z=O||W||!C.trim();i((()=>{H(`response-download-${l()}`)}),[]),i((()=>{Z&&R(!1)}),[Z]),i((()=>{K&&G.current&&X(getComputedStyle(G.current).fontFamily)}),[K,I.font]),g({ref:[G,J],callback:()=>R(!1)});const ee=()=>{var e;R(!1),null===(e=G.current)||void 0===e||e.focus({preventScroll:!0})},oe=e=>{var o;if(!Z)if("Escape"===e.key&&K)e.preventDefault(),e.stopPropagation(),ee();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();const t=Q.current.indexOf(e.currentTarget),n="ArrowDown"===e.key?1:-1,r=D.length,i=-1===t?1===n?0:r-1:(t+n+r)%r;V.current=i,R(!0),null===(o=Q.current[i])||void 0===o||o.focus({preventScroll:!0})}else"Tab"===e.key&&R(!1)},te=e=>{e.relatedTarget===G.current||Q.current.some((o=>o===e.relatedTarget))||R(!1)};return o(j,Object.assign({id:_,className:"h-4 w-4 shrink-0",isOpen:K&&!Z,onChange:R,closeOnSelect:!1,closeOnClickOutside:!1},{children:[t("button",Object.assign({ref:G,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:T},title:Y,"aria-label":Y,"aria-haspopup":"menu","aria-busy":W,"aria-expanded":K&&!Z,"aria-controls":K&&!Z?`${_}-menu`:void 0,disabled:Z,onClick:e=>{e.stopPropagation(),V.current=0,R((e=>!e))},onKeyDown:oe,onBlur:te},{children:t(k,{className:"h-4 w-4 shrink-0","aria-hidden":"true"})})),_&&!Z&&s(t("div",Object.assign({ref:J,style:{fontFamily:U},dir:M?"rtl":"ltr"},{children:t(A,Object.assign({id:`${_}-menu`,role:"menu",align:"right",width:"auto",className:"p-1 text-sm",style:{backgroundColor:P.primary,color:P.text,maxWidth:"calc(100vw - 32px)"},imperativeModeOnly:!0,afterShow:()=>{var e;return null===(e=Q.current[V.current])||void 0===e?void 0:e.focus({preventScroll:!0})}},{children:D.map(((o,n)=>t("button",Object.assign({ref:e=>{Q.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=>{((o,t)=>{e(void 0,void 0,void 0,(function*(){var n;if(o.stopPropagation(),Z||z.current)return;let r;ee();try{const o=f(C);let i;if(o.length){if(z.current=!0,q(!0),"pdf"===t.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==S?void 0:S.loading)||"Loading...",e.setAttribute("role","status"),e.style.cssText="margin:32px;font:16px system-ui,sans-serif",r.document.body.appendChild(e)}i=yield x(C,o,(o=>e(void 0,void 0,void 0,(function*(){const e=E.find((e=>e.id===o.id&&e.version===o.version));return null!=e?e:L.mutateAsync({artifactId:o.id,version:o.version,studioId:null==B?void 0:B.studioid,senderType:$,sender:N||void 0,studioSessionToken:F||void 0})}))),t.extension,(e=>v(e,"pdf"===t.extension||"docx"===t.extension,r)))}if("docx"===t.extension){z.current=!0,q(!0);const e=yield d(C,i);return void a(e,"response.docx")}if("pdf"===t.extension)return z.current=!0,q(!0),void(i?yield u(i,r):yield m(C));let s=null!=i?i:"html"===t.extension?p(C):C;"html"===t.extension&&(z.current=!0,q(!0),s=yield c(s));const l=new Blob([s],{type:t.mimeType});a(l,`response.${t.extension}`)}catch(e){console.error("Response download failed",{format:t.extension,error:e}),null==r||r.close(),window.alert((null==S?void 0:S["something-went-wrong"])||"Something went wrong.")}finally{z.current=!1,q(!1)}}))})(t,o)},onKeyDown:oe,onBlur:te},{children:o.label}),o.extension)))}))})),document.body)]}))};export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useStyleFontSize as t}from"../../../hooks/studio/useStyleFontSize.js";import{usePickaxeContext as a}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useFeedback as
|
|
1
|
+
import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as o}from"react";import{useStyleFontSize as t}from"../../../hooks/studio/useStyleFontSize.js";import{usePickaxeContext as a}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useFeedback as n}from"../../../hooks/pickaxe/useFeedback.js";import{AnimatePresence as l,motion as c}from"framer-motion";import r from"../../Icons/message-square-notes.svg.js";import m from"../../Icons/thumbs-down.svg.js";import p from"../../Icons/speaker.svg.js";import d from"../../Icons/stop.svg.js";import u from"../../Icons/spinner-lines.svg.js";import b from"../../Icons/thumbs-up.svg.js";import h from"./PickaxeSimpleButton.js";import f from"./PickaxeCopyButton.js";import g from"./PickaxeDownloadButton.js";import x from"./PickaxeFeedbackThumbsDownReasons.js";import{prepareResponseDownloadText as v}from"../../../common/responseDownload.js";import k from"../../../common/cn.js";const j=({content:j,sessionId:y,index:w=0,messagesCount:O,isHideFeedback:N,isReadOut:T,isReadOutLoading:D,isReading:C,onOpenChat:I,onReadOut:R})=>{var S,z,F,P;const{colors:U,translations:B,pickaxe:H,misc:W,setIsShowFeedbackMessage:q}=a(),L=t(),M=!0===W.isResponseDownload,A=o((()=>M?v(j):""),[j,M]),{toggleThumb:E,submitThumbsDown:G,submitThumbsUp:J,isThumbsUpSelected:K,isThumbsDownSelected:Q,showThumbsDownOptions:V,showThumbsUpOptions:X,showSuccess:Y}=n({content:j,index:w,sessionId:y,successDuration:2e3,promptRate:1,onThumbsDownReasonOpen:()=>q(!0),onThumbsDownReasonClose:()=>q(!1)}),Z="function"==typeof I&&((null==H?void 0:H.chatflag)||!!(null==H?void 0:H.enablechatresponses))&&void 0!==y&&void 0!==O,$=Boolean(((null==H?void 0:H.chatflag)||(null==H?void 0:H.enablechatresponses))&&!I||!(null==H?void 0:H.chatflag)&&!(null==H?void 0:H.enablechatresponses))&&!N;return e("div",Object.assign({className:"flex w-full flex-col gap-4"},{children:[e("div",Object.assign({className:k("flex items-center gap-3",M?"min-h-4 flex-wrap":"h-4")},{children:[Z&&e(h,Object.assign({color:U.accent,onClick:I},{children:[s(r,{className:"h-4 w-4 shrink-0"}),s("p",Object.assign({className:k(L.b3,"font-semibold")},{children:O}))]})),s(f,{color:U.accent,text:j}),M&&s(g,{color:U.accent,text:A}),$&&e(i,{children:[s(h,Object.assign({color:U.accent,onClick:()=>E("like"),className:"transition-all active:rotate-12 active:scale-90"},{children:s(b,{className:"size-4",style:{fill:U.text,fillOpacity:K?.3:0}})})),s(h,Object.assign({color:U.accent,onClick:()=>E("dislike"),className:"transition-all active:-rotate-12 active:scale-90"},{children:s(m,{className:"size-4",style:{fill:U.text,fillOpacity:Q?.3:0}})})),T&&R&&s(h,Object.assign({color:U.accent,onClick:()=>R(),className:"transition-all active:-rotate-12 active:scale-90"},{children:D?s(u,{className:"size-4 animate-spin"}):C?s(d,{className:"size-4 rounded-full border p-[1.5px]",style:{borderColor:U.accent}}):s(p,{className:"size-4"})})),s(l,{children:Y&&s(c.div,Object.assign({initial:{opacity:0,x:-8,filter:"blur(4px)"},animate:{opacity:1,x:0,filter:"blur(0px)"},exit:{opacity:0,x:8,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.6}},{children:s("p",Object.assign({className:k(L.b4,U.secondary,"opacity-75")},{children:null!==(S=null==B?void 0:B["feedback-thanks"])&&void 0!==S?S:"Thanks for the feedback!"}))}))})]})]})),s(l,{children:(V||X)&&e(c.div,Object.assign({initial:{opacity:0,y:-4,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},exit:{opacity:0,y:-2,filter:"blur(4px)"},transition:{type:"spring",bounce:0,duration:.25},className:"flex flex-col gap-4"},{children:[e("div",Object.assign({className:"space-y-0.5"},{children:[s("p",Object.assign({className:k(L.b3,U.text)},{children:X?null!==(z=null==B?void 0:B["feedback-like-title"])&&void 0!==z?z:"What went right?":null!==(F=null==B?void 0:B["feedback-dislike-title"])&&void 0!==F?F:"What went wrong?"})),s("p",Object.assign({className:k(L.b3,U.secondary,"opacity-75")},{children:null!==(P=null==B?void 0:B["feedback-dislike-message"])&&void 0!==P?P:"Help us improve our answers"}))]})),s(c.div,Object.assign({initial:{opacity:0,y:-8,filter:"blur(4px)"},animate:{opacity:1,y:0,filter:"blur(0px)"},transition:{type:"spring",bounce:0,duration:.5,delay:.175},className:"flex flex-wrap items-center gap-2"},{children:s(x,{isUp:X,submitThumbsDown:G,submitThumbsUp:J})}))]}))})]}))};export{j as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const renderResponseArtifactHtml: (content: string, captureCanvas?: boolean, printWindow?: Window) => Promise<string>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** Presentation only: no positioning, clipping, fixed dimensions or network URLs. */
|
|
2
|
+
export declare const artifactStyleProperties: readonly ["color", "background-color", "background-image", "font-family", "font-size", "font-weight", "font-style", "line-height", "letter-spacing", "text-align", "text-decoration-line", "text-decoration-color", "text-transform", "vertical-align", "border-top", "border-right", "border-bottom", "border-left", "border-radius", "border-collapse", "border-spacing", "box-shadow", "box-sizing", "padding-top", "padding-right", "padding-bottom", "padding-left", "margin-top", "margin-right", "margin-bottom", "margin-left", "display", "flex-direction", "flex-wrap", "align-items", "justify-content", "gap", "list-style-type", "list-style-position"];
|
|
3
|
+
/** Revalidate even computed styles: the renderer's message is not trusted. */
|
|
4
|
+
export declare const filterArtifactStyles: (root: ParentNode) => void;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies Copy's action-marker cleanup to visible response text only.
|
|
3
|
+
* Markdown and HTML remain source text, not rendered or converted plain text.
|
|
4
|
+
* This does not fetch linked content or modify the original message.
|
|
5
|
+
*/
|
|
6
|
+
export declare const prepareResponseDownloadText: (text: string) => string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ArtifactData } from "../types/artifact";
|
|
2
|
+
export type ResponseArtifact = Pick<ArtifactData, "id" | "version"> & {
|
|
3
|
+
start: number;
|
|
4
|
+
end: number;
|
|
5
|
+
};
|
|
6
|
+
/** Use the same Markdown parser as chat so quoted/code examples stay literal. */
|
|
7
|
+
export declare const findResponseArtifacts: (text: string) => ResponseArtifact[];
|
|
8
|
+
export declare const prepareResponseArtifactDownload: (text: string, references: ResponseArtifact[], resolve: (reference: ResponseArtifact) => Promise<ArtifactData>, format: "txt" | "md" | "html" | "pdf" | "docx", renderHtml: (content: string) => Promise<string>) => Promise<string>;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exports the same sanitized response used by HTML/PDF as editable Word content.
|
|
3
|
+
* Parsing stays in an inert template. Images are copied with bounded anonymous
|
|
4
|
+
* requests; response scripts and the live chat DOM are never used.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createResponseDownloadDocx: (text: string, preparedHtml?: string) => Promise<Blob>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts prepared response text into a standalone, static HTML document.
|
|
3
|
+
* Does not mount the chat renderer, run response scripts, or fetch linked content.
|
|
4
|
+
* Code fences stay literal; only the export gets these stricter HTML rules.
|
|
5
|
+
*/
|
|
6
|
+
export declare const createResponseDownloadHtml: (text: string) => string;
|
|
7
|
+
/** All assembled content, including artifact snapshots, crosses this boundary. */
|
|
8
|
+
export declare const createResponseDownloadDocument: (rendered: string, preserveArtifactStyles?: boolean) => string;
|
|
9
|
+
/** Opens a print copy from the user's click without changing the live response. */
|
|
10
|
+
export declare const printResponseDownloadHtml: (text: string) => Promise<void>;
|
|
11
|
+
export declare const printResponseDownloadDocument: (html: string, reservedWindow?: Window) => Promise<void>;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/** Only modifies an inert export copy. Never reads or changes live chat images. */
|
|
2
|
+
export declare const embedResponseDownloadImages: (root: ParentNode, format: "docx" | "html") => Promise<Set<Element>>;
|
|
3
|
+
export declare const embedResponseDownloadHtmlImages: (html: string) => Promise<string>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export type InteractiveArtifactFrame = {
|
|
2
|
+
placeholder: string;
|
|
3
|
+
title: string;
|
|
4
|
+
content: string;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* HTML downloads only. Assemble frames AFTER sanitizing the outer message, so
|
|
8
|
+
* response markup cannot create frames or executable code in the parent page.
|
|
9
|
+
* srcdoc is serialized as an attribute, never interpolated into raw HTML.
|
|
10
|
+
*/
|
|
11
|
+
export declare const embedInteractiveArtifacts: (sanitizedDocument: string, artifacts: InteractiveArtifactFrame[]) => string;
|
|
@@ -35,6 +35,7 @@ export type PickaxeMisc = {
|
|
|
35
35
|
isTitle: boolean;
|
|
36
36
|
isDescription: boolean;
|
|
37
37
|
isHistory?: boolean;
|
|
38
|
+
isResponseDownload?: boolean;
|
|
38
39
|
};
|
|
39
40
|
type ValidationStatus = "loading" | "success" | "login_required" | "upgrade_required" | "access_denied" | "stripe_checkout";
|
|
40
41
|
export type PickaxeDeploymentEmbedType = "inline" | "fab" | "popup" | "chat-input" | "direct-link";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
interface PickaxeDownloadButtonProps {
|
|
2
|
+
color: string;
|
|
3
|
+
/** Prepared response text; Markdown and HTML source are preserved. */
|
|
4
|
+
text: string;
|
|
5
|
+
disabled?: boolean;
|
|
6
|
+
}
|
|
7
|
+
declare const PickaxeDownloadButton: ({ color, text, disabled, }: PickaxeDownloadButtonProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export default PickaxeDownloadButton;
|
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pickaxeproject/react",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.23.1",
|
|
4
4
|
"description": "Client utility library for Pickaxe",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/pickaxeproject/v2-pickaxe-react.git"
|
|
8
8
|
},
|
|
9
|
-
"sideEffects":
|
|
9
|
+
"sideEffects": [
|
|
10
|
+
"./dist/**/node_modules/**/vscode-jsonrpc/lib/common/events.js"
|
|
11
|
+
],
|
|
10
12
|
"exports": {
|
|
11
13
|
".": {
|
|
12
14
|
"import": "./dist/esm/index.js",
|