@pickaxeproject/react 6.22.0 → 6.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/cjs/common/responseArtifactSnapshot.js +1 -0
  2. package/dist/cjs/common/responseArtifactStyles.js +1 -0
  3. package/dist/cjs/common/responseArtifactSvg.js +101 -0
  4. package/dist/cjs/common/responseArtifactWordImages.js +1 -0
  5. package/dist/cjs/common/responseDownload.js +1 -0
  6. package/dist/cjs/common/responseDownloadArtifacts.js +1 -0
  7. package/dist/cjs/common/responseDownloadDocx.js +1 -0
  8. package/dist/cjs/common/responseDownloadHtml.js +1 -0
  9. package/dist/cjs/common/responseInteractiveArtifactHtml.js +1 -0
  10. package/dist/cjs/common/responseMermaid.js +1 -0
  11. package/dist/cjs/common/responseStandaloneSvg.js +1 -0
  12. package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
  13. package/dist/cjs/components/Pickaxe/Form/index.js +1 -1
  14. package/dist/cjs/components/Pickaxe/Provider.js +1 -1
  15. package/dist/cjs/components/Pickaxe/common/PickaxeDownloadButton.js +1 -0
  16. package/dist/cjs/components/Pickaxe/common/PickaxeEmbedHead.js +1 -1
  17. package/dist/cjs/components/Pickaxe/common/PickaxeMCPButton.js +1 -1
  18. package/dist/cjs/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
  19. package/dist/cjs/src/common/responseArtifactSnapshot.d.ts +1 -0
  20. package/dist/cjs/src/common/responseArtifactStyles.d.ts +4 -0
  21. package/dist/cjs/src/common/responseArtifactSvg.d.ts +2 -0
  22. package/dist/cjs/src/common/responseArtifactWordImages.d.ts +2 -0
  23. package/dist/cjs/src/common/responseDownload.d.ts +6 -0
  24. package/dist/cjs/src/common/responseDownloadArtifacts.d.ts +8 -0
  25. package/dist/cjs/src/common/responseDownloadDocx.d.ts +6 -0
  26. package/dist/cjs/src/common/responseDownloadHtml.d.ts +11 -0
  27. package/dist/cjs/src/common/responseInteractiveArtifactHtml.d.ts +11 -0
  28. package/dist/cjs/src/common/responseMermaid.d.ts +2 -0
  29. package/dist/cjs/src/common/responseStandaloneSvg.d.ts +5 -0
  30. package/dist/cjs/src/components/Pickaxe/Provider.d.ts +4 -1
  31. package/dist/cjs/src/components/Pickaxe/common/PickaxeDownloadButton.d.ts +8 -0
  32. package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
  33. package/dist/esm/common/responseArtifactSnapshot.js +1 -0
  34. package/dist/esm/common/responseArtifactStyles.js +1 -0
  35. package/dist/esm/common/responseArtifactSvg.js +101 -0
  36. package/dist/esm/common/responseArtifactWordImages.js +1 -0
  37. package/dist/esm/common/responseDownload.js +1 -0
  38. package/dist/esm/common/responseDownloadArtifacts.js +1 -0
  39. package/dist/esm/common/responseDownloadDocx.js +1 -0
  40. package/dist/esm/common/responseDownloadHtml.js +1 -0
  41. package/dist/esm/common/responseInteractiveArtifactHtml.js +1 -0
  42. package/dist/esm/common/responseMermaid.js +1 -0
  43. package/dist/esm/common/responseStandaloneSvg.js +1 -0
  44. package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
  45. package/dist/esm/components/Pickaxe/Form/index.js +1 -1
  46. package/dist/esm/components/Pickaxe/Provider.js +1 -1
  47. package/dist/esm/components/Pickaxe/common/PickaxeDownloadButton.js +1 -0
  48. package/dist/esm/components/Pickaxe/common/PickaxeEmbedHead.js +1 -1
  49. package/dist/esm/components/Pickaxe/common/PickaxeMCPButton.js +1 -1
  50. package/dist/esm/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
  51. package/dist/esm/src/common/responseArtifactSnapshot.d.ts +1 -0
  52. package/dist/esm/src/common/responseArtifactStyles.d.ts +4 -0
  53. package/dist/esm/src/common/responseArtifactSvg.d.ts +2 -0
  54. package/dist/esm/src/common/responseArtifactWordImages.d.ts +2 -0
  55. package/dist/esm/src/common/responseDownload.d.ts +6 -0
  56. package/dist/esm/src/common/responseDownloadArtifacts.d.ts +8 -0
  57. package/dist/esm/src/common/responseDownloadDocx.d.ts +6 -0
  58. package/dist/esm/src/common/responseDownloadHtml.d.ts +11 -0
  59. package/dist/esm/src/common/responseInteractiveArtifactHtml.d.ts +11 -0
  60. package/dist/esm/src/common/responseMermaid.d.ts +2 -0
  61. package/dist/esm/src/common/responseStandaloneSvg.d.ts +5 -0
  62. package/dist/esm/src/components/Pickaxe/Provider.d.ts +4 -1
  63. package/dist/esm/src/components/Pickaxe/common/PickaxeDownloadButton.d.ts +8 -0
  64. package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
  65. package/package.json +4 -2
@@ -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";
@@ -111,6 +112,7 @@ type PickaxeContextType = {
111
112
  isRtl: boolean;
112
113
  isEmbed: boolean;
113
114
  mcpEnabled: boolean;
115
+ mcpGuestId?: string;
114
116
  isDropShadow: boolean;
115
117
  allowGuestUsage: boolean;
116
118
  persistActiveConversation: boolean;
@@ -164,6 +166,7 @@ export interface IPickaxeProviderProps {
164
166
  isRtl?: boolean;
165
167
  isEmbed?: boolean;
166
168
  mcpEnabled?: boolean;
169
+ mcpGuestId?: string;
167
170
  studioSessionToken?: string | null;
168
171
  isDropShadow?: boolean;
169
172
  allowGuestUsage?: boolean;
@@ -174,5 +177,5 @@ export interface IPickaxeProviderProps {
174
177
  onSessionIdChange?: (sessionId: string) => void;
175
178
  }
176
179
  export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
177
- export declare const PickaxeProvider: ({ children, origin, sender: _sender, senderType: _senderType, deploymentId, portalId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, artifact, responsiveBy, locale, opacity, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, isEmbed, mcpEnabled, studioSessionToken, isDropShadow, allowGuestUsage, persistActiveConversation, preventInitialSessionId, onUpgrade, onGenerateComplete, onSessionIdChange, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
180
+ export declare const PickaxeProvider: ({ children, origin, sender: _sender, senderType: _senderType, deploymentId, portalId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, artifact, responsiveBy, locale, opacity, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, isEmbed, mcpEnabled, mcpGuestId, studioSessionToken, isDropShadow, allowGuestUsage, persistActiveConversation, preventInitialSessionId, onUpgrade, onGenerateComplete, onSessionIdChange, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
178
181
  export {};
@@ -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;
@@ -38,6 +38,7 @@ export declare const usePickaxeContext: () => {
38
38
  isRtl: boolean;
39
39
  isEmbed: boolean;
40
40
  mcpEnabled: boolean;
41
+ mcpGuestId?: string | undefined;
41
42
  isDropShadow: boolean;
42
43
  allowGuestUsage: boolean;
43
44
  persistActiveConversation: boolean;
@@ -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', () => { failed = true; }, true);\n window.addEventListener('unhandledrejection', () => { failed = true; });\n observer = new MutationObserver(() => {\n if (!paintReady) return;\n clearTimeout(timer);\n timer = setTimeout(finish, 1000);\n });\n observer.observe(document.documentElement, { subtree: true, childList: true, characterData: true, attributes: true });\n // Start the capture window only after the artifact has had a chance to paint.\n // If frames are suspended (for example in a background tab), the parent's\n // timeout rejects instead of silently exporting an uninitialized chart.\n requestAnimationFrame(() => requestAnimationFrame(() => {\n paintReady = true;\n timer = setTimeout(finish, 1000);\n // Live counters/animations may never settle. Capture their rendered state\n // after a bounded wait, rather than requiring permanent DOM inactivity.\n deadline = setTimeout(finish, 3000);\n }));\n})();\n<\/script>`,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}))),h=()=>{void 0!==u&&(null==l||l.clearInterval(u)),u=void 0},g=()=>{p=!0,window.clearTimeout(w),window.clearInterval(b),h(),m.forEach((({target:e,document:t})=>{e.removeEventListener("message",v),e.removeEventListener("focus",y),t.removeEventListener("visibilitychange",y)})),null==d||d.remove()},f=e=>{p||(g(),s(new Error(e)))},v=e=>{var t;!p&&d&&e.source===d.contentWindow&&e.origin===r&&(null===(t=e.data)||void 0===t?void 0:t.token)===c&&("PXE_RESPONSE_SNAPSHOT_STARTED"!==e.data.type?"PXE_RESPONSE_SNAPSHOT"===e.data.type&&(g(),e.data.error||"string"!=typeof e.data.html||e.data.html.length>1e7?s(new Error("Unable to capture the complete artifact.")):a(e.data.html)):h())},y=()=>{var e;if(p)return;if(null==i?void 0:i.closed)return void f("The response print window was closed.");const a=!document.hidden&&document.hasFocus()?window:i&&!i.document.hidden?i:document.hidden&&null!==(e=null!=l?l:i)&&void 0!==e?e:window;if(a===l)return;h(),null==d||d.remove(),l=a;const s=a.document.createElement("iframe");d=s,s.src=`${r}/html`,s.setAttribute("sandbox","allow-scripts allow-same-origin"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.style.cssText="position:fixed;left:0;top:0;width:900px;height:600px;border:0;opacity:0;pointer-events:none;",s.onload=()=>{p||d!==s||(h(),u=a.setInterval((()=>{var e;return null===(e=s.contentWindow)||void 0===e?void 0:e.postMessage({type:"HTML_CODE",content:o(c,n)+t},r)}),250))},s.onerror=()=>{d===s&&f("Unable to load the artifact renderer.")},a.document.body.appendChild(s)},w=window.setTimeout((()=>f("Artifact rendering timed out.")),15e3),b=i?window.setInterval((()=>{i.closed&&f("The response print window was closed.")}),250):void 0;m.forEach((({target:e,document:t})=>{e.addEventListener("message",v),e.addEventListener("focus",y),t.addEventListener("visibilitychange",y)})),y()}));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";const o=(o,r)=>t(void 0,void 0,void 0,(function*(){const t=e(`<div class="pxe-export-artifact">${o}</div>`,!0),n=(new DOMParser).parseFromString(t,"text/html");for(const t of n.querySelectorAll("img"))if(!/^data:image\/(png|jpeg|gif);base64,/i.test(t.getAttribute("src")||""))throw new Error("Word artifact pictures require self-contained images.");const i=document.createElement("iframe");i.setAttribute("sandbox","allow-same-origin"),i.setAttribute("aria-hidden","true"),i.tabIndex=-1,i.style.cssText="position:fixed;left:-10000px;top:0;width:720px;height:600px;border:0;pointer-events:none";try{yield new Promise(((e,o)=>{const r=setTimeout((()=>o(new Error("Word snapshot timed out."))),5e3);i.onload=()=>{clearTimeout(r),e()},i.onerror=()=>{clearTimeout(r),o(new Error("Word snapshot failed."))},i.srcdoc=t,document.body.appendChild(i)}));const e=i.contentDocument,o=i.contentWindow,n=null==e?void 0:e.querySelector("main");if(!e||!o||!n)throw new Error("Word snapshot unavailable.");const a=e.createElement("style");a.textContent="main{width:720px;max-width:none;padding:0;margin:0}\n.pxe-export-artifact{overflow:visible}\n.pxe-export-artifact:has(tr > :nth-child(6)) > div{min-width:0}\ntable{width:100%;table-layout:fixed} pre{white-space:pre-wrap;overflow-wrap:anywhere}\n*{animation:none!important;transition:none!important}",e.head.appendChild(a),e.querySelectorAll("details").forEach((t=>{t.open=!0}));const l=Math.ceil(Math.max(n.scrollWidth,n.getBoundingClientRect().width)),c=Math.ceil(n.getBoundingClientRect().height);if(l>1440||!c||c>16e3)throw new Error("Artifact is too large for a readable Word picture.");const s=n.cloneNode(!0),d=[n,...n.querySelectorAll("*")],h=[s,...s.querySelectorAll("*")];d.forEach(((t,e)=>{const r=h[e],n=o.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 p=(new XMLSerializer).serializeToString(s);if(p.length>1e7)throw new Error("Word snapshot is too large.");const m=n.getBoundingClientRect().top,g=[],w=e.createTreeWalker(n,NodeFilter.SHOW_TEXT);for(;w.nextNode();){const t=e.createRange();t.selectNodeContents(w.currentNode);for(const e of Array.from(t.getClientRects()))e.height&&g.push({top:e.top-m,bottom:e.bottom-m})}n.querySelectorAll("tr,img").forEach((t=>{const e=t.getBoundingClientRect();e.height<=800&&g.push({top:e.top-m,bottom:e.bottom-m})}));const f=[];let u=0;for(let t=0;t<c;){let o=Math.min(c,t+800);if(o<c)for(let e=0;e<g.length;e++){const e=g.find((t=>t.top+1<o&&t.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 n=`<svg xmlns="http://www.w3.org/2000/svg" width="${l}" height="${o-t}" viewBox="0 ${t} ${l} ${o-t}"><foreignObject x="0" y="0" width="${l}" height="${c}">${p}</foreignObject></svg>`,i=new Image;yield new Promise(((t,e)=>{const o=setTimeout((()=>r(!1)),5e3),r=r=>{clearTimeout(o),i.onload=i.onerror=null,r?t():e(new Error("Unable to draw Word artifact picture."))};i.onload=()=>r(!0),i.onerror=()=>r(!1),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(n)}`}));const a=document.createElement("canvas");a.width=2*l,a.height=2*(o-t);const s=a.getContext("2d");if(!s)throw new Error("Word image capture unavailable.");s.fillStyle="white",s.fillRect(0,0,a.width,a.height),s.drawImage(i,0,0,a.width,a.height);const d=a.toDataURL("image/png");if(u+=d.length,u>1e7)throw new Error("Word artifact pictures are too large.");const h=e.createElement("img");h.src=d,h.width=l,h.height=o-t,h.alt=r;const m=e.createElement("p");m.appendChild(h),f.push(m.outerHTML),a.width=a.height=0,i.removeAttribute("src"),t=o}return f.join("")}finally{i.remove()}}));export{o 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,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;"),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 g,WidthType as m,Table as h,LevelFormat as p,AlignmentType as b}from"docx";import{createResponseDownloadHtml as f}from"./responseDownloadHtml.js";const w=720,A=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DD","DETAILS","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SUMMARY","TABLE","UL"]),N=e=>{if(e&&/^(https?:|mailto:|tel:)/i.test(e.trim()))try{return new URL(e.trim()).href}catch(e){return}},O=(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},E=(E,I)=>e(void 0,void 0,void 0,(function*(){const e=document.createElement("template");e.innerHTML=null!=I?I:f(E);const y=e.content.querySelector("main");if(!y)throw new Error("Unable to prepare the response document.");const T=new Map;for(const e of y.querySelectorAll('.pxe-export-artifact img[src^="data:image/png;base64,"]')){const t=e.getAttribute("src")||"";if(t.length>1e7)throw new Error("Artifact image too large.");const r=Uint8Array.from(atob(t.slice(22)),(e=>e.charCodeAt(0))),n=new DataView(r.buffer);if(r.length<24||2303741511!==n.getUint32(0)||218765834!==n.getUint32(4)||1229472850!==n.getUint32(12))throw new Error("Invalid artifact image.");const 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;T.set(e,{data:r,width:i*o,height:a*o})}const j=[],v=(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=O(a,t);if("BR"===a.tagName)return[new i(Object.assign(Object.assign({},t),{break:1}))];if("IMG"===a.tagName){const e=T.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=N(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?N(a.getAttribute("href")):void 0,u=v(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})),S=(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))},D=(e,t)=>{var r;const n="OL"===e.tagName;let i="",a=!1;const s=e=>{i=`response-list-${j.length}`,a=0===e,j.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(...k([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}}}}),g=k(l.childNodes,c);(null===(r=c.marker)||void 0===r?void 0:r.used)||g.unshift(S([],c)),u.push(...g)}return u},H=(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=k(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 g(Object.assign({children:o,columnSpan:n,rowSpan:i,width:{size:a,type:m.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?[...k(c,{indent:0,width:t,run:{}}),new h({rows:l,width:{size:t,type:m.DXA},columnWidths:o})]:k(e.childNodes,{indent:0,width:t,run:{}})},k=(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(S(v(n,t.run,t.width-t.indent),t)),n=[]};for(const c of Array.from(e)){if(1!==c.nodeType||!A.has(c.tagName)){1===c.nodeType&&Array.from(c.children).some((e=>A.has(e.tagName)))?(l(),r.push(...k(c.childNodes,Object.assign(Object.assign({},t),{run:O(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(S([],t)),r.push(...D(e,t));else if("TABLE"===d)t.marker&&!t.marker.used&&r.push(S([],t)),r.push(...H(e,t.width));else if("PRE"===d){const n=(e.textContent||"").replace(/\r\n?/g,"\n").split("\n");r.push(S(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(S(v(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(S([],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=k(e.childNodes,n);r.push(...i),i.length||"P"!==d||r.push(S([],n))}}return l(),r},L=k(y.childNodes,{indent:0,width:10800,run:{}}),M=new t({title:"Pickaxe",creator:"Pickaxe",styles:{default:{document:{run:{font:"Arial",size:22,color:"202020"}}}},numbering:{config:j},sections:[{properties:{page:{size:{width:12240,height:15840},margin:{top:w,bottom:w,left:w,right:w}}},children:L.length?L:[new r("")]}]});return n.toBlob(M)}));export{E 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 d(a)},d=(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>`},c=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 h(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}})),h=(t,r)=>new Promise(((o,n)=>{const i=window.setTimeout((()=>p(new Error("Response print images did not finish loading."))),15e3),a=window.setInterval((()=>{t.closed&&p(new Error("The response print window was closed."))}),100);let l=!1;function p(e){l||(l=!0,window.clearTimeout(i),window.clearInterval(a),e?n(e):o())}Promise.all([...Array.from(r.images,(t=>e(void 0,void 0,void 0,(function*(){if(yield t.decode(),!t.complete||!t.naturalWidth||!t.naturalHeight)throw new Error("Unable to load a response print image.")})))),r.fonts.ready]).then((()=>p()),(()=>p(new Error("Unable to load the response print resources."))))}));export{d as createResponseDownloadDocument,p as createResponseDownloadHtml,s as printResponseDownloadDocument,c as printResponseDownloadHtml};
@@ -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{jsxs as t,jsx as o,Fragment as i}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as s,useCallback as a}from"react";import{usePickaxeContext as l}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as c}from"../Addons/Auth/hooks/useAuthContext.js";import{useDimensionContext as d}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as m}from"../Addons/Document/hooks/useDocument.js";import{useScrollContext as u}from"../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as p}from"../../../hooks/studio/useStyleFontSize.js";import f from"../../../hooks/core/useScrollToBottomVisibility.js";import h from"./History/index.js";import v from"./Input.js";import g from"../../Icons/attach-vertical.svg.js";import x from"../../../common/cn.js";import{pickaxeApi2 as b}from"../../../common/api/pickaxe.js";import{v4 as j}from"uuid";import{StudioTip as k}from"../../Core/StudioTip.js";import y from"../common/ScrollToBottomButton.js";import I from"../common/PickaxeMCPButton.js";import{useResponseContext as w}from"../../../hooks/pickaxe/useResponseContext.js";import{NavPill as D,EditableNavPill as C,HistoryPill as N}from"../Addons/Navbar/NavPill.js";import S from"../../Icons/history.svg.js";const T=()=>{var T,A;const{deploymentType:F,isNewChat:O,setIsNewChat:P,sessionId:H,setSessionId:z,setLastSessionId:B,pickaxeId:E,sender:R,pickaxe:L,styles:G,isEmbed:M,mcpEnabled:V,translations:_}=l(),{isSent:q,isLoggedIn:U}=c(),{width:W,height:J,setDimension:K}=d(),{setDocuments:Q,onFileUpload:X}=m(),{scrollContainerRef:Y,hasScrolledRef:Z,isLocked:$,setIsLocked:ee}=u(),{isGenerating:te,messages:oe}=w(),ie=p(),[ne,re]=n(0),[se,ae]=n(!1),[le,ce]=n(!1),de=r(null),me=r(null),ue=r(0),[pe,fe]=n(null),[he,ve]=n(!1),ge=(null==_?void 0:_["new-chat"])||"New chat",xe="chat-input"===F&&O&&!q,be=null!==(A=null===(T=null==L?void 0:L.documentuploadtype)||void 0===T?void 0:T.startsWith("enduserupload"))&&void 0!==A&&A,{hasScrollableContent:je,isNearBottom:ke}=f(Y);s((()=>()=>{Q([])}),[]);const ye=a((()=>{if(!E||!R)return;const t=(o=0)=>e(void 0,void 0,void 0,(function*(){var e;try{const t=yield b.post("/conversation/title",{sessionId:H,userId:R});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void we(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}o<20&&setTimeout((()=>t(o+1)),3e3)}));t()}),[E,R,H]);s((()=>{te||O||!H||ye()}),[te,O,H,ye]),s((()=>{if(!de.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;K(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(de.current),()=>{e.disconnect()}}),[K]);const[Ie,we]=n(ge),De=(null==L?void 0:L.formtitle)||"Pickaxe",Ce=(null==L?void 0:L.coverphoto)||void 0,[Ne,Se]=n(!1);s((()=>{const e=!xe&&!M&&G.portalTheme&&(oe.filter((e=>"user"===e.role)).length>0||se||!O);Se(null!=e&&e)}),[xe,M,se,O,oe,G.portalTheme]);const Te=a((()=>{Z.current=!1,ee(!0),requestAnimationFrame((()=>{const e=Y.current;e&&e.scrollTo({top:Math.max(0,e.scrollHeight-e.clientHeight),behavior:"smooth"})}))}),[Z,Y,ee]);return t("div",Object.assign({ref:de,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),be&&(ue.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&ce(!0))},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),be&&(ue.current-=1,0===ue.current&&ce(!1))},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e(void 0,void 0,void 0,(function*(){if(t.preventDefault(),t.stopPropagation(),ce(!1),ue.current=0,!be)return;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(P(!1),yield X(e))}))},{children:[le&&t("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[o("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:o(g,{className:"h-10 w-10"})})),o("h3",Object.assign({className:x(ie.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==_?void 0:_["drop-files-to-upload"])||"Drop files to upload"})),o("p",Object.assign({className:x(ie.b2,"mt-2 opacity-60 text-black")},{children:(null==_?void 0:_["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),!M&&V&&U?o("div",Object.assign({className:"pointer-events-none absolute left-1/2 top-4 z-40 flex w-full max-w-[800px] -translate-x-1/2 justify-end px-4"},{children:o("div",Object.assign({className:"pointer-events-auto"},{children:o(I,{})}))})):null,xe?o(v,{}):t(i,{children:[Ne&&t("div",Object.assign({className:x("direct-link"===F?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===G.portalTheme?"glass-dark ":"")},{children:[o(D,{text:De,icon:Ce}),O||Ie===ge?o(D,{text:Ie}):o(C,{text:Ie,sessionId:H,onRename:t=>e(void 0,void 0,void 0,(function*(){if(H)try{yield b.patch("/conversation/title",{sessionId:H,name:t,userId:R}),we(t)}catch(e){console.error("Error renaming chat:",e),alert((null==_?void 0:_["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e(void 0,void 0,void 0,(function*(){if(H&&window.confirm((null==_?void 0:_["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield b.delete("/conversation",{data:{sessionId:H,userId:R}}),P(!0),z(j()),we(ge)}catch(e){console.error("Error deleting chat:",e),alert((null==_?void 0:_["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===G.portalTheme}),o(k,Object.assign({content:_["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:o(N,{icon:o(S,{}),onClick:()=>{z(""),B(H)}})}))]})),o(h,{additionalScrollHeight:ne,isForceHideInfo:J<=545||W<=350||se,isInputFocused:se,onSubmit:t=>e(void 0,void 0,void 0,(function*(){me.current&&me.current.onSubmit(t)})),smitheryAuthData:pe,resubmitPrompt:()=>{fe(null),ve(!0)}}),o(y,{isVisible:je&&!$&&!ke,bottom:ne+65,onClick:Te}),o(v,{ref:me,onFocus:()=>ae(!0),onBlur:()=>ae(!1),onInputHeightChange:re,initSmitheryAuthData:e=>fe(e),resubmitPrompt:he})]})]}))};export{T as default};
1
+ import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as i}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as s,useCallback as a}from"react";import{usePickaxeContext as l}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as c}from"../Addons/Auth/hooks/useAuthContext.js";import{useDimensionContext as d}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as m}from"../Addons/Document/hooks/useDocument.js";import{useScrollContext as u}from"../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as p}from"../../../hooks/studio/useStyleFontSize.js";import f from"../../../hooks/core/useScrollToBottomVisibility.js";import h from"./History/index.js";import v from"./Input.js";import x from"../../Icons/attach-vertical.svg.js";import g from"../../../common/cn.js";import{pickaxeApi2 as b}from"../../../common/api/pickaxe.js";import{v4 as j}from"uuid";import{StudioTip as k}from"../../Core/StudioTip.js";import y from"../common/ScrollToBottomButton.js";import w from"../common/PickaxeMCPButton.js";import{useResponseContext as I}from"../../../hooks/pickaxe/useResponseContext.js";import{NavPill as D,EditableNavPill as C,HistoryPill as N}from"../Addons/Navbar/NavPill.js";import S from"../../Icons/history.svg.js";const T=()=>{var T,A;const{deploymentType:F,isNewChat:O,setIsNewChat:P,sessionId:H,setSessionId:z,setLastSessionId:B,pickaxeId:E,sender:R,pickaxe:L,styles:G,isEmbed:M,mcpEnabled:V,translations:_}=l(),{isSent:q}=c(),{width:U,height:W,setDimension:J}=d(),{setDocuments:K,onFileUpload:Q}=m(),{scrollContainerRef:X,hasScrolledRef:Y,isLocked:Z,setIsLocked:$}=u(),{isGenerating:ee,messages:te}=I(),oe=p(),[ie,ne]=n(0),[re,se]=n(!1),[ae,le]=n(!1),ce=r(null),de=r(null),me=r(0),[ue,pe]=n(null),[fe,he]=n(!1),ve=(null==_?void 0:_["new-chat"])||"New chat",xe="chat-input"===F&&O&&!q,ge=null!==(A=null===(T=null==L?void 0:L.documentuploadtype)||void 0===T?void 0:T.startsWith("enduserupload"))&&void 0!==A&&A,{hasScrollableContent:be,isNearBottom:je}=f(X);s((()=>()=>{K([])}),[]);const ke=a((()=>{if(!E||!R)return;const t=(o=0)=>e(void 0,void 0,void 0,(function*(){var e;try{const t=yield b.post("/conversation/title",{sessionId:H,userId:R});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void we(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}o<20&&setTimeout((()=>t(o+1)),3e3)}));t()}),[E,R,H]);s((()=>{ee||O||!H||ke()}),[ee,O,H,ke]),s((()=>{if(!ce.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;J(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(ce.current),()=>{e.disconnect()}}),[J]);const[ye,we]=n(ve),Ie=(null==L?void 0:L.formtitle)||"Pickaxe",De=(null==L?void 0:L.coverphoto)||void 0,[Ce,Ne]=n(!1);s((()=>{const e=!xe&&!M&&G.portalTheme&&(te.filter((e=>"user"===e.role)).length>0||re||!O);Ne(null!=e&&e)}),[xe,M,re,O,te,G.portalTheme]);const Se=a((()=>{Y.current=!1,$(!0),requestAnimationFrame((()=>{const e=X.current;e&&e.scrollTo({top:Math.max(0,e.scrollHeight-e.clientHeight),behavior:"smooth"})}))}),[Y,X,$]);return t("div",Object.assign({ref:ce,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),ge&&(me.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&le(!0))},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),ge&&(me.current-=1,0===me.current&&le(!1))},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e(void 0,void 0,void 0,(function*(){if(t.preventDefault(),t.stopPropagation(),le(!1),me.current=0,!ge)return;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(P(!1),yield Q(e))}))},{children:[ae&&t("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[o("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:o(x,{className:"h-10 w-10"})})),o("h3",Object.assign({className:g(oe.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==_?void 0:_["drop-files-to-upload"])||"Drop files to upload"})),o("p",Object.assign({className:g(oe.b2,"mt-2 opacity-60 text-black")},{children:(null==_?void 0:_["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),!M&&V?o("div",Object.assign({className:"pointer-events-none absolute left-1/2 top-4 z-40 flex w-full max-w-[800px] -translate-x-1/2 justify-end px-4"},{children:o("div",Object.assign({className:"pointer-events-auto"},{children:o(w,{})}))})):null,xe?o(v,{}):t(i,{children:[Ce&&t("div",Object.assign({className:g("direct-link"===F?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===G.portalTheme?"glass-dark ":"")},{children:[o(D,{text:Ie,icon:De}),O||ye===ve?o(D,{text:ye}):o(C,{text:ye,sessionId:H,onRename:t=>e(void 0,void 0,void 0,(function*(){if(H)try{yield b.patch("/conversation/title",{sessionId:H,name:t,userId:R}),we(t)}catch(e){console.error("Error renaming chat:",e),alert((null==_?void 0:_["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e(void 0,void 0,void 0,(function*(){if(H&&window.confirm((null==_?void 0:_["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield b.delete("/conversation",{data:{sessionId:H,userId:R}}),P(!0),z(j()),we(ve)}catch(e){console.error("Error deleting chat:",e),alert((null==_?void 0:_["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===G.portalTheme}),o(k,Object.assign({content:_["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:o(N,{icon:o(S,{}),onClick:()=>{z(""),B(H)}})}))]})),o(h,{additionalScrollHeight:ie,isForceHideInfo:W<=545||U<=350||re,isInputFocused:re,onSubmit:t=>e(void 0,void 0,void 0,(function*(){de.current&&de.current.onSubmit(t)})),smitheryAuthData:ue,resubmitPrompt:()=>{pe(null),he(!0)}}),o(y,{isVisible:be&&!Z&&!je,bottom:ie+65,onClick:Se}),o(v,{ref:de,onFocus:()=>se(!0),onBlur:()=>se(!1),onInputHeightChange:ne,initSmitheryAuthData:e=>pe(e),resubmitPrompt:fe})]})]}))};export{T as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import{useRef as l,useState as s,useEffect as i,useCallback as n}from"react";import{usePickaxeContext as r}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as a}from"../Addons/Auth/hooks/useAuthContext.js";import c from"../../../hooks/core/useScrollToBottomVisibility.js";import{useStyleFontSize as m}from"../../../hooks/studio/useStyleFontSize.js";import d from"../common/PickaxeHead.js";import f from"../common/PickaxeEmbedHead.js";import u from"../common/PickaxeMCPButton.js";import p from"../common/ScrollToBottomButton.js";import x from"./History/index.js";import v from"./NewChat.js";import h from"./Questions/index.js";import b from"../../../common/cn.js";import{NavPill as g}from"../Addons/Navbar/NavPill.js";const j=()=>{const{lastSessionId:j,pickaxe:w,responsiveBy:y,translations:k,isEmbed:N,mcpEnabled:O,deploymentType:E,styles:L,setLastSessionId:C,setSessionId:B}=r(),{isLoggedIn:S}=a(),P=(null==w?void 0:w.formtitle)||"Pickaxe",H=(null==w?void 0:w.coverphoto)||void 0,T=m(),M=l(null),z=l(null),[I,A]=s(!0),R=N&&(null==w?void 0:w.chatflag),{hasScrollableContent:D,isNearBottom:V}=c(M,{targetRef:z,activeOffset:48},[Boolean(null==w?void 0:w.chatflag)]);i((()=>{V&&A(!0)}),[V]),i((()=>{const e=M.current;if(!e)return;const t=()=>{A(!1)};return e.addEventListener("mousedown",t),e.addEventListener("touchmove",t,{passive:!0}),e.addEventListener("wheel",t,{passive:!0}),e.addEventListener("DOMMouseScroll",t),e.addEventListener("mousewheel",t),()=>{e.removeEventListener("mousedown",t),e.removeEventListener("touchmove",t),e.removeEventListener("wheel",t),e.removeEventListener("DOMMouseScroll",t),e.removeEventListener("mousewheel",t)}}),[]);const F=n((()=>{if(!M.current||!z.current)return;const e=M.current.getBoundingClientRect(),t=z.current.getBoundingClientRect().bottom-e.top+M.current.scrollTop;A(!0),M.current.scrollTo({top:Math.max(0,t-M.current.clientHeight),behavior:"smooth"})}),[]),Q=n((()=>{A(!1)}),[]);return e("div",Object.assign({className:b("relative flex h-full w-full flex-col items-center overflow-hidden")},{children:[e("div",Object.assign({ref:M,className:b("flex h-full w-full flex-col items-center overflow-y-auto","pt-0","viewport"===y?"min-[767px]:pb-10":"@[767px]/pickaxe-root:pb-10")},{children:[!N&&t("div",Object.assign({className:b("direct-link"===E?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===L.portalTheme?"glass-dark ":"")},{children:t(g,{text:P,icon:H,onClick:()=>{B(j),C("")}})})),!N&&O&&S?t("div",Object.assign({className:"pointer-events-none absolute left-1/2 top-4 z-40 flex w-full max-w-[700px] -translate-x-1/2 justify-end"},{children:t("div",Object.assign({className:"pointer-events-auto"},{children:t(u,{})}))})):null,R?e(o,{children:[t(f,{className:"sticky top-0 z-10 w-full",historyBtnTip:(null==k?void 0:k["exit-chat-history"])||"Exit Chat History",onHistoryClick:()=>B(j)}),t("div",Object.assign({className:"relative flex min-h-[56px] w-full justify-end rounded-tl-lg rounded-tr-lg border-y p-4"},{children:t("p",Object.assign({className:b(T.b1,"absolute left-1/2 -translate-x-1/2 select-none text-center")},{children:(null==k?void 0:k["chat-history"])||"Chat History"}))}))]}):e("div",Object.assign({className:"flex w-full max-w-[700px] flex-col"},{children:[N&&O&&S?t("div",Object.assign({className:"flex w-full justify-end"},{children:t("div",Object.assign({className:b("mr-3 flex","popup"===E&&"pr-10")},{children:t(u,{})}))})):null,t(d,{})]})),t("div",Object.assign({className:b("flex w-full min-h-0 flex-col items-center",R?"px-4":"px-6")},{children:t("div",Object.assign({className:"flex h-full w-full max-w-[700px] flex-col"},{children:e("div",Object.assign({className:b("flex h-full flex-col gap-y-8","viewport"===y?"min-[767px]:mt-4":"@[767px]/pickaxe-root:mt-4")},{children:[t("div",Object.assign({ref:z,className:"flex flex-col"},{children:(null==w?void 0:w.chatflag)?t(v,{}):t(h,{onLongInputPaste:Q})})),t(x,{})]}))}))}))]})),t(p,{bottom:30,isVisible:D&&!I&&!V,onClick:F})]}))};export{j as default};
1
+ import{jsxs as e,jsx as t,Fragment as o}from"react/jsx-runtime";import{useRef as l,useState as i,useEffect as s,useCallback as n}from"react";import{usePickaxeContext as r}from"../../../hooks/pickaxe/usePickaxeContext.js";import a from"../../../hooks/core/useScrollToBottomVisibility.js";import{useStyleFontSize as c}from"../../../hooks/studio/useStyleFontSize.js";import m from"../common/PickaxeHead.js";import d from"../common/PickaxeEmbedHead.js";import f from"../common/PickaxeMCPButton.js";import u from"../common/ScrollToBottomButton.js";import p from"./History/index.js";import x from"./NewChat.js";import v from"./Questions/index.js";import h from"../../../common/cn.js";import{NavPill as b}from"../Addons/Navbar/NavPill.js";const j=()=>{const{lastSessionId:j,pickaxe:g,responsiveBy:w,translations:y,isEmbed:k,mcpEnabled:N,deploymentType:O,styles:E,setLastSessionId:L,setSessionId:C}=r(),B=(null==g?void 0:g.formtitle)||"Pickaxe",S=(null==g?void 0:g.coverphoto)||void 0,P=c(),H=l(null),T=l(null),[M,z]=i(!0),I=k&&(null==g?void 0:g.chatflag),{hasScrollableContent:R,isNearBottom:D}=a(H,{targetRef:T,activeOffset:48},[Boolean(null==g?void 0:g.chatflag)]);s((()=>{D&&z(!0)}),[D]),s((()=>{const e=H.current;if(!e)return;const t=()=>{z(!1)};return e.addEventListener("mousedown",t),e.addEventListener("touchmove",t,{passive:!0}),e.addEventListener("wheel",t,{passive:!0}),e.addEventListener("DOMMouseScroll",t),e.addEventListener("mousewheel",t),()=>{e.removeEventListener("mousedown",t),e.removeEventListener("touchmove",t),e.removeEventListener("wheel",t),e.removeEventListener("DOMMouseScroll",t),e.removeEventListener("mousewheel",t)}}),[]);const V=n((()=>{if(!H.current||!T.current)return;const e=H.current.getBoundingClientRect(),t=T.current.getBoundingClientRect().bottom-e.top+H.current.scrollTop;z(!0),H.current.scrollTo({top:Math.max(0,t-H.current.clientHeight),behavior:"smooth"})}),[]),A=n((()=>{z(!1)}),[]);return e("div",Object.assign({className:h("relative flex h-full w-full flex-col items-center overflow-hidden")},{children:[e("div",Object.assign({ref:H,className:h("flex h-full w-full flex-col items-center overflow-y-auto","pt-0","viewport"===w?"min-[767px]:pb-10":"@[767px]/pickaxe-root:pb-10")},{children:[!k&&t("div",Object.assign({className:h("direct-link"===O?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===E.portalTheme?"glass-dark ":"")},{children:t(b,{text:B,icon:S,onClick:()=>{C(j),L("")}})})),!k&&N?t("div",Object.assign({className:"pointer-events-none absolute left-1/2 top-4 z-40 flex w-full max-w-[700px] -translate-x-1/2 justify-end"},{children:t("div",Object.assign({className:"pointer-events-auto"},{children:t(f,{})}))})):null,I?e(o,{children:[t(d,{className:"sticky top-0 z-10 w-full",historyBtnTip:(null==y?void 0:y["exit-chat-history"])||"Exit Chat History",onHistoryClick:()=>C(j)}),t("div",Object.assign({className:"relative flex min-h-[56px] w-full justify-end rounded-tl-lg rounded-tr-lg border-y p-4"},{children:t("p",Object.assign({className:h(P.b1,"absolute left-1/2 -translate-x-1/2 select-none text-center")},{children:(null==y?void 0:y["chat-history"])||"Chat History"}))}))]}):e("div",Object.assign({className:"flex w-full max-w-[700px] flex-col"},{children:[k&&N?t("div",Object.assign({className:"flex w-full justify-end"},{children:t("div",Object.assign({className:h("mr-3 flex","popup"===O&&"pr-10")},{children:t(f,{})}))})):null,t(m,{})]})),t("div",Object.assign({className:h("flex w-full min-h-0 flex-col items-center",I?"px-4":"px-6")},{children:t("div",Object.assign({className:"flex h-full w-full max-w-[700px] flex-col"},{children:e("div",Object.assign({className:h("flex h-full flex-col gap-y-8","viewport"===w?"min-[767px]:mt-4":"@[767px]/pickaxe-root:mt-4")},{children:[t("div",Object.assign({ref:T,className:"flex flex-col"},{children:(null==g?void 0:g.chatflag)?t(x,{}):t(v,{onLongInputPaste:A})})),t(p,{})]}))}))}))]})),t(u,{bottom:30,isVisible:R&&!M&&!D,onClick:V})]}))};export{j as default};
@@ -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,studioSessionToken:j,isDropShadow:E=!1,allowGuestUsage:L=!0,persistActiveConversation:G=!1,preventInitialSessionId:H=!1,onUpgrade:W,onGenerateComplete:B,onSessionIdChange:N})=>{const[V,Y]=o(""),[X,J]=o(""),[_,z]=o(""),[Q,K]=o(""),[Z,$]=o(u),[ee,te]=o(null),[ie,oe]=o(m),[ne,ae]=o("loading"),[se,re]=o([]),[le,de]=o(null),[ce,pe]=o(null),[ue,me]=o(null),[ge,fe]=o(null),[he,ye]=o("");n((()=>ye("")),[X]);const[ve,be]=o(!1),[we,ke]=o(!0),[Se,Ce]=o(!0),[Ie,Pe]=o(!1);return n((()=>{be(!1)}),[null==b?void 0:b.font]),n((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&q&&!ve&&(null==b?void 0:b.font)&&"Real Head Pro"!==b.font)try{(yield import("webfontloader")).default.load({google:{families:[b.font]},active:()=>{be(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),be(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),be(!0)}}))}),[q,ve,null==b?void 0:b.font]),n((()=>{$(u)}),[u]),t(c.Provider,Object.assign({value:Object.assign(Object.assign({origin:p,contextId:V,pickaxeId:X,sessionId:_,lastSessionId:Q,sender:Z,senderType:ie,portalId:f,deploymentId:g,deploymentType:h,validationStatus:ne,validationUpgradeGroups:se,validationUpgradeUrl:le,deploymentDimensions:y,deploymentMisc:v,accessGroup:ee,pickaxe:ge,selectedModel:he,setSelectedModel:ye,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:ve,isNewChat:we,isShowIceBreaker:Se,isShowFeedbackMessage:Ie,isRtl:R,isEmbed:O,mcpEnabled:M,isDropShadow:E,allowGuestUsage:L,persistActiveConversation:G,clientSecret:ue,stripeAccountId:ce,preventInitialSessionId:H,setClientSecret:me,setStripeAccountId:pe,setContextId:Y,setValidationStatus:ae,setValidationUpgradeGroups:re,setValidationUpgradeUrl:de,setPickaxeId:J,setSessionId:e=>{z((t=>{const i="function"==typeof e?e(t):e;return null==N||N(i),i}))},setLastSessionId:K,setSender:$,setSenderType:oe,setAccessGroup:te,setPickaxe:fe,setIsFontLoaded:be,setIsNewChat:ke,setIsShowIceBreaker:Ce,setIsShowFeedbackMessage:Pe},W&&{onUpgrade:W}),B&&{onGenerateComplete:B})},{children:t(d,Object.assign({initialToken:j},{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{printResponseDownloadDocument as c,printResponseDownloadHtml as u,createResponseDownloadHtml as m}from"../../../common/responseDownloadHtml.js";import{findResponseArtifacts as p,prepareResponseArtifactDownload as f}from"../../../common/responseDownloadArtifacts.js";import{renderResponseArtifactHtml as v}from"../../../common/responseArtifactSnapshot.js";import{useArtifactContext as x}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useArtifactData as h}from"../Addons/Artifact/hooks/useArtifactData.js";import{useAuthContext as y}from"../Addons/Auth/hooks/useAuthContext.js";import{usePickaxeContext as b}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useOutsideAlerter as w}from"../../../hooks/core/useOutsideAlerter.js";import g from"../../Icons/download.svg.js";import k from"../../Core/Menu/index.js";import j from"../../Core/Menu/List.js";const A=[{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:D=!1})=>{const{translations:O,colors:S,styles:P,isRtl:M,sender:N,senderType:I,pickaxe:$}=b(),{artifacts:B=[]}=x(),{token:E}=y(),F=h(),[L,_]=n(""),[H,K]=n(!1),[R,U]=n(),[X,W]=n(!1),q=r(!1),z=r(null),G=r(null),J=r([]),Q=r(0),V=(null==O?void 0:O.download)||"Download",Y=D||X||!C.trim();i((()=>{_(`response-download-${l()}`)}),[]),i((()=>{Y&&K(!1)}),[Y]),i((()=>{H&&z.current&&U(getComputedStyle(z.current).fontFamily)}),[H,P.font]),w({ref:[z,G],callback:()=>K(!1)});const Z=()=>{var e;K(!1),null===(e=z.current)||void 0===e||e.focus({preventScroll:!0})},ee=e=>{var o;if(!Y)if("Escape"===e.key&&H)e.preventDefault(),e.stopPropagation(),Z();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();const t=J.current.indexOf(e.currentTarget),n="ArrowDown"===e.key?1:-1,r=A.length,i=-1===t?1===n?0:r-1:(t+n+r)%r;Q.current=i,K(!0),null===(o=J.current[i])||void 0===o||o.focus({preventScroll:!0})}else"Tab"===e.key&&K(!1)},oe=e=>{e.relatedTarget===z.current||J.current.some((o=>o===e.relatedTarget))||K(!1)};return o(k,Object.assign({id:L,className:"h-4 w-4 shrink-0",isOpen:H&&!Y,onChange:K,closeOnSelect:!1,closeOnClickOutside:!1},{children:[t("button",Object.assign({ref:z,id:L||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:V,"aria-label":V,"aria-haspopup":"menu","aria-busy":X,"aria-expanded":H&&!Y,"aria-controls":H&&!Y?`${L}-menu`:void 0,disabled:Y,onClick:e=>{e.stopPropagation(),Q.current=0,K((e=>!e))},onKeyDown:ee,onBlur:oe},{children:t(g,{className:"h-4 w-4 shrink-0","aria-hidden":"true"})})),L&&!Y&&s(t("div",Object.assign({ref:G,style:{fontFamily:R},dir:M?"rtl":"ltr"},{children:t(j,Object.assign({id:`${L}-menu`,role:"menu",align:"right",width:"auto",className:"p-1 text-sm",style:{backgroundColor:S.primary,color:S.text,maxWidth:"calc(100vw - 32px)"},imperativeModeOnly:!0,afterShow:()=>{var e;return null===(e=J.current[Q.current])||void 0===e?void 0:e.focus({preventScroll:!0})}},{children:A.map(((o,n)=>t("button",Object.assign({ref:e=>{J.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(),Y||q.current)return;let r;Z();try{const o=p(C);let i;if(o.length){if(q.current=!0,W(!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==O?void 0:O.loading)||"Loading...",e.setAttribute("role","status"),e.style.cssText="margin:32px;font:16px system-ui,sans-serif",r.document.body.appendChild(e)}i=yield f(C,o,(o=>e(void 0,void 0,void 0,(function*(){const e=B.find((e=>e.id===o.id&&e.version===o.version));return null!=e?e:F.mutateAsync({artifactId:o.id,version:o.version,studioId:null==$?void 0:$.studioid,senderType:I,sender:N||void 0,studioSessionToken:E||void 0})}))),t.extension,(e=>v(e,"pdf"===t.extension||"docx"===t.extension,r)))}if("docx"===t.extension){q.current=!0,W(!0);const e=yield d(C,i);return void a(e,"response.docx")}if("pdf"===t.extension)return q.current=!0,W(!0),void(i?yield c(i,r):yield u(C));const s=null!=i?i:"html"===t.extension?m(C):C,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==O?void 0:O["something-went-wrong"])||"Something went wrong.")}finally{q.current=!1,W(!1)}}))})(t,o)},onKeyDown:ee,onBlur:oe},{children:o.label}),o.extension)))}))})),document.body)]}))};export{T as default};
@@ -1 +1 @@
1
- import{jsxs as o,jsx as i}from"react/jsx-runtime";import{useMemo as t}from"react";import{usePickaxeContext as e}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as s}from"../Addons/Auth/hooks/useAuthContext.js";import{useStyleFontSize as r}from"../../../hooks/studio/useStyleFontSize.js";import l from"./PickaxeIcon.js";import n from"./PickaxeHistoryButton.js";import c from"./PickaxeLogoutButton.js";import a from"./PickaxeMCPButton.js";import m from"../../../common/cn.js";const p=({className:p,iconClassName:u,historyBtnTip:d,onIconClick:f,onHistoryClick:x})=>{const{deploymentType:h,pickaxe:g,misc:k,colors:j,translations:b,mcpEnabled:y}=e(),{isLoggedIn:v}=s(),C=y&&v,P=r(),N=t((()=>({title:(null==g?void 0:g.formtitle)||"",description:(null==g?void 0:g.formdescription)||""})),[g]);return k.isTitle||k.isDescription||!k.isWhiteLabel||C?o("div",Object.assign({className:m("flex min-h-[56px] items-center justify-between gap-4 px-4",p),style:{backgroundColor:j.secondary,color:j.secondaryText}},{children:[o("div",Object.assign({className:"flex items-center gap-4"},{children:[k.isProfileImage&&i(l,Object.assign({src:null==g?void 0:g.coverphoto,alt:`${null==g?void 0:g.formtitle}'s Profile Picture`,width:32,height:32,className:m("h-[32px] w-[32px] shrink-0 rounded-full",u,!!f&&"cursor-pointer")},f&&{onClick:f})),k.isTitle&&i("p",Object.assign({className:m(P.b1)},{children:N.title}))]})),x||C?o("div",Object.assign({className:m("popup"===h&&"pr-10","flex items-center gap-1")},{children:[C?i(a,{}):null,x?i(n,{tip:d,onClick:x}):null,v&&x&&i(c,{tip:(null==b?void 0:b["log-out"])||"Log Out"})]})):null]})):null};export{p as default};
1
+ import{jsxs as o,jsx as i}from"react/jsx-runtime";import{useMemo as t}from"react";import{usePickaxeContext as e}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as s}from"../Addons/Auth/hooks/useAuthContext.js";import{useStyleFontSize as r}from"../../../hooks/studio/useStyleFontSize.js";import l from"./PickaxeIcon.js";import n from"./PickaxeHistoryButton.js";import c from"./PickaxeLogoutButton.js";import a from"./PickaxeMCPButton.js";import m from"../../../common/cn.js";const p=({className:p,iconClassName:u,historyBtnTip:d,onIconClick:f,onHistoryClick:x})=>{const{deploymentType:h,pickaxe:g,misc:k,colors:j,translations:b,mcpEnabled:y}=e(),{isLoggedIn:v}=s(),C=y,P=r(),N=t((()=>({title:(null==g?void 0:g.formtitle)||"",description:(null==g?void 0:g.formdescription)||""})),[g]);return k.isTitle||k.isDescription||!k.isWhiteLabel||C?o("div",Object.assign({className:m("flex min-h-[56px] items-center justify-between gap-4 px-4",p),style:{backgroundColor:j.secondary,color:j.secondaryText}},{children:[o("div",Object.assign({className:"flex items-center gap-4"},{children:[k.isProfileImage&&i(l,Object.assign({src:null==g?void 0:g.coverphoto,alt:`${null==g?void 0:g.formtitle}'s Profile Picture`,width:32,height:32,className:m("h-[32px] w-[32px] shrink-0 rounded-full",u,!!f&&"cursor-pointer")},f&&{onClick:f})),k.isTitle&&i("p",Object.assign({className:m(P.b1)},{children:N.title}))]})),x||C?o("div",Object.assign({className:m("popup"===h&&"pr-10","flex items-center gap-1")},{children:[C?i(a,{}):null,x?i(n,{tip:d,onClick:x}):null,v&&x&&i(c,{tip:(null==b?void 0:b["log-out"])||"Log Out"})]})):null]})):null};export{p as default};
@@ -1 +1 @@
1
- import{jsxs as e,Fragment as o,jsx as r}from"react/jsx-runtime";import{useState as t,useMemo as a}from"react";import s from"copy-to-clipboard";import{AnimatePresence as n,motion as i}from"framer-motion";import c from"../../Icons/terminal.svg.js";import l from"../../Icons/copy.svg.js";import p from"../../Icons/check.svg.js";import d from"../../Icons/chevron-down.svg.js";import m from"../../Core/Modal/index.js";import u from"../../Core/Modal/Body.js";import h from"../../Core/Modal/CloseButton.js";import{usePickaxeContext as b}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as g}from"../../../hooks/studio/useStyleFontSize.js";import{useAuthContext as f}from"../Addons/Auth/hooks/useAuthContext.js";import y from"./PickaxeSimpleButton.js";const x={codex:"Codex",claude:"Claude Code",cursor:"Cursor",vscode:"VS Code",other:"Other"},v=()=>{const{colors:v,styles:j,deploymentId:C,mcpEnabled:O,translations:w}=b(),{token:k}=f(),N=g(),[$,I]=t(!1),[R,S]=t(!1),[A,P]=t(!1),[U,_]=t("codex"),M=(e,o)=>{var r;return null!==(r=null==w?void 0:w[e])&&void 0!==r?r:o},z=a((()=>{if(!C)return"";const e=process.env.NEXT_PUBLIC_API_MCP_URL||"https://mcp.pickaxe.co",o=new URL(e),r=o.pathname.replace(/\/+$/,"");return o.pathname=r.endsWith("/deployment")?r:`${r}/deployment`,o.searchParams.set("id",C),o.toString()}),[C]),T=a((()=>{const e=`Bearer ${null!=k?k:"YOUR_STUDIO_SESSION_TOKEN"}`;return"codex"===U?`[mcp_servers.pickaxe]\nurl = "${z}"\nhttp_headers = { Authorization = "${e}" }`:"claude"===U?`claude mcp add --transport http --scope user pickaxe "${z}" --header "Authorization: ${e}"`:"vscode"===U?JSON.stringify({servers:{pickaxe:{type:"http",url:z,headers:{Authorization:e}}}},null,2):"cursor"===U?JSON.stringify({mcpServers:{pickaxe:{url:z,headers:{Authorization:e}}}},null,2):`URL: ${z}\nAuthorization: ${e}`}),[U,z,k]);if(!O||!C||!k)return null;return e(o,{children:[e("div",Object.assign({className:"relative"},{children:[e(y,Object.assign({className:"h-8 w-8 shrink-0 justify-center rounded-full",color:v.accent,onClick:()=>I(!0),onMouseEnter:()=>S(!0),onMouseLeave:()=>S(!1)},{children:[r(c,{className:"h-5 w-5"}),r("span",Object.assign({className:"sr-only"},{children:M("mcp-use-with-ai-app","Use with an AI app")}))]})),r(n,{children:R?r(i.div,Object.assign({className:"absolute right-0 top-10 z-20 w-max rounded px-3 py-2 text-xs font-medium",style:{background:v.accent,color:v.accentText},initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8}},{children:M("mcp-use-with-ai-app","Use with an AI app")})):null})]})),r(m,Object.assign({isOpen:$,onChange:I},{children:r(u,Object.assign({portalClassName:"dark"===j.theme?"dark":void 0,wrapperClassName:"mx-4 w-[min(92vw,560px)]",className:"w-full overflow-hidden p-0",style:Object.assign({backgroundColor:v.secondary,borderColor:`${v.accent}40`,borderRadius:j.cornerRadius,color:v.secondaryText},"Real Head Pro"!==j.font&&{fontFamily:j.font})},{children:e("div",Object.assign({className:"flex flex-col gap-5 p-6"},{children:[e("div",Object.assign({className:"flex items-start justify-between gap-4"},{children:[e("div",{children:[r("h2",Object.assign({className:`${N.h4} font-semibold`},{children:M("mcp-use-agent-in-ai-app","Use this agent in your AI app")})),r("p",Object.assign({className:`${N.b3} mt-1 opacity-70`},{children:M("mcp-connect-description","Connect through MCP. Requests will be sent as your signed-in Studio user.")}))]}),r(h,{className:"shrink-0"})]})),e("label",Object.assign({className:`${N.l2} flex flex-col gap-2 font-medium`},{children:[M("mcp-ai-app","AI app"),e("div",Object.assign({className:"relative"},{children:[r("select",Object.assign({className:"w-full appearance-none border py-2 pl-3 pr-10 outline-none",style:{backgroundColor:v.primary,borderColor:`${v.accent}40`,borderRadius:j.cornerRadius,color:v.text},value:U,onChange:e=>_(e.target.value)},{children:Object.entries(x).map((([e,o])=>r("option",Object.assign({value:e},{children:"other"===e?M("other","Other"):o}),e)))})),r(d,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2",style:{color:v.text}})]}))]})),e("div",Object.assign({className:"relative min-w-0"},{children:[r("pre",Object.assign({className:"max-h-64 w-full overflow-auto whitespace-pre-wrap break-all border p-4 pr-12 text-xs",style:{backgroundColor:v.primary,borderColor:`${v.accent}40`,borderRadius:j.cornerRadius,color:v.text}},{children:T})),r("button",Object.assign({type:"button",className:"absolute right-3 top-3 border p-2 transition-opacity hover:opacity-70",style:{backgroundColor:v.accent,borderColor:v.accent,borderRadius:j.cornerRadius,color:v.accentText},"aria-label":M("mcp-copy-configuration","Copy MCP configuration"),onClick:()=>{s(T),P(!0),window.setTimeout((()=>P(!1)),1800)}},{children:r(A?p:l,{className:"h-4 w-4"})}))]})),r("p",Object.assign({className:`${N.b4} opacity-60`},{children:M("mcp-private-configuration-note","Keep this configuration private. It contains your Studio session token and stops working when that session expires.")}))]}))}))}))]})};export{v as default};
1
+ import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,Fragment as r,jsx as t}from"react/jsx-runtime";import{useState as a,useMemo as s}from"react";import n from"copy-to-clipboard";import{AnimatePresence as i,motion as c}from"framer-motion";import l from"../../Icons/terminal.svg.js";import p from"../../Icons/copy.svg.js";import d from"../../Icons/check.svg.js";import u from"../../Icons/chevron-down.svg.js";import m from"../../../common/api/utils.js";import{initializeEmbedUserId as h}from"../../../common/utils.js";import b from"../../Core/Modal/index.js";import g from"../../Core/Modal/Body.js";import f from"../../Core/Modal/CloseButton.js";import{usePickaxeContext as y}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as v}from"../../../hooks/studio/useStyleFontSize.js";import{useAuthContext as x}from"../Addons/Auth/hooks/useAuthContext.js";import j from"./PickaxeSimpleButton.js";const C={codex:"Codex",claude:"Claude Code",cursor:"Cursor",vscode:"VS Code",other:"Other"},k=()=>{const{colors:k,styles:w,deploymentId:N,mcpEnabled:O,mcpGuestId:$,sender:R,translations:I}=y(),{token:A}=x(),P=v(),[M,S]=a(!1),[_,z]=a(!1),[U,T]=a(!1),[B,L]=a(null),[E,q]=a(!1),[F,G]=a(!1),[J,H]=a("codex"),K=(e,o)=>{var r;return null!==(r=null==I?void 0:I[e])&&void 0!==r?r:o},V=s((()=>{if(!N)return"";const e=process.env.NEXT_PUBLIC_API_MCP_URL||"https://mcp.pickaxe.co",o=new URL(e),r=o.pathname.replace(/\/+$/,"");return o.pathname=r.endsWith("/deployment")?r:`${r}/deployment`,o.searchParams.set("id",N),o.toString()}),[N]),W=A||B,X=s((()=>{if(!W)return"";const e=`Bearer ${W}`;return"codex"===J?`[mcp_servers.pickaxe]\nurl = "${V}"\nhttp_headers = { Authorization = "${e}" }`:"claude"===J?`claude mcp add --transport http --scope user pickaxe "${V}" --header "Authorization: ${e}"`:"vscode"===J?JSON.stringify({servers:{pickaxe:{type:"http",url:V,headers:{Authorization:e}}}},null,2):"cursor"===J?JSON.stringify({mcpServers:{pickaxe:{url:V,headers:{Authorization:e}}}},null,2):`URL: ${V}\nAuthorization: ${e}`}),[J,V,W]);if(!O||!N)return null;return o(r,{children:[o("div",Object.assign({className:"relative"},{children:[o(j,Object.assign({className:"h-8 w-8 shrink-0 justify-center rounded-full",color:k.accent,onClick:()=>e(void 0,void 0,void 0,(function*(){if(S(!0),!W&&!E){q(!0),G(!1);try{const e=$||R||h(),o=yield m.post("/pickaxe/mcp-session",{deploymentId:N,guestId:e});if(!o.data.success||!o.data.token)throw new Error("Guest MCP session was not created");L(o.data.token)}catch(e){console.error("[pxe] failed to prepare MCP configuration",e),G(!0)}finally{q(!1)}}})),onMouseEnter:()=>z(!0),onMouseLeave:()=>z(!1)},{children:[t(l,{className:"h-5 w-5"}),t("span",Object.assign({className:"sr-only"},{children:K("mcp-use-with-ai-app","Use with an AI app")}))]})),t(i,{children:_?t(c.div,Object.assign({className:"absolute right-0 top-10 z-20 w-max rounded px-3 py-2 text-xs font-medium",style:{background:k.accent,color:k.accentText},initial:{opacity:0,y:-8},animate:{opacity:1,y:0},exit:{opacity:0,y:-8}},{children:K("mcp-use-with-ai-app","Use with an AI app")})):null})]})),t(b,Object.assign({isOpen:M,onChange:S},{children:t(g,Object.assign({portalClassName:"dark"===w.theme?"dark":void 0,wrapperClassName:"mx-4 w-[min(92vw,560px)]",className:"w-full overflow-hidden p-0",style:Object.assign({backgroundColor:k.secondary,borderColor:`${k.accent}40`,borderRadius:w.cornerRadius,color:k.secondaryText},"Real Head Pro"!==w.font&&{fontFamily:w.font})},{children:o("div",Object.assign({className:"flex flex-col gap-5 p-6"},{children:[o("div",Object.assign({className:"flex items-start justify-between gap-4"},{children:[o("div",{children:[t("h2",Object.assign({className:`${P.h4} font-semibold`},{children:K("mcp-use-agent-in-ai-app","Use this agent in your AI app")})),t("p",Object.assign({className:`${P.b3} mt-1 opacity-70`},{children:K(A?"mcp-connect-description":"mcp-connect-description-guest",A?"Connect through MCP. Requests will be sent as your signed-in Studio user.":"Connect through MCP. Requests will be sent as this visitor.")}))]}),t(f,{className:"shrink-0"})]})),o("label",Object.assign({className:`${P.l2} flex flex-col gap-2 font-medium`},{children:[K("mcp-ai-app","AI app"),o("div",Object.assign({className:"relative"},{children:[t("select",Object.assign({className:"w-full appearance-none border py-2 pl-3 pr-10 outline-none",style:{backgroundColor:k.primary,borderColor:`${k.accent}40`,borderRadius:w.cornerRadius,color:k.text},value:J,onChange:e=>H(e.target.value)},{children:Object.entries(C).map((([e,o])=>t("option",Object.assign({value:e},{children:"other"===e?K("other","Other"):o}),e)))})),t(u,{className:"pointer-events-none absolute right-3 top-1/2 h-4 w-4 -translate-y-1/2",style:{color:k.text}})]}))]})),E?t("div",Object.assign({className:"min-h-24 animate-pulse border p-4",role:"status",style:{backgroundColor:k.primary,borderColor:`${k.accent}40`,borderRadius:w.cornerRadius}},{children:t("span",Object.assign({className:"sr-only"},{children:K("mcp-preparing-configuration","Preparing your private configuration…")}))})):F?t("p",Object.assign({className:`${P.b3} border p-4`,style:{backgroundColor:k.primary,borderColor:`${k.accent}40`,borderRadius:w.cornerRadius,color:k.text}},{children:K("mcp-configuration-unavailable","This private configuration is unavailable. Close and try again.")})):X?o("div",Object.assign({className:"relative min-w-0"},{children:[t("pre",Object.assign({className:"max-h-64 w-full overflow-auto whitespace-pre-wrap break-all border p-4 pr-12 text-xs",style:{backgroundColor:k.primary,borderColor:`${k.accent}40`,borderRadius:w.cornerRadius,color:k.text}},{children:X})),t("button",Object.assign({type:"button",className:"absolute right-3 top-3 border p-2 transition-opacity hover:opacity-70",style:{backgroundColor:k.accent,borderColor:k.accent,borderRadius:w.cornerRadius,color:k.accentText},"aria-label":K("mcp-copy-configuration","Copy MCP configuration"),onClick:()=>{X&&(n(X),T(!0),window.setTimeout((()=>T(!1)),1800))}},{children:t(U?d:p,{className:"h-4 w-4"})}))]})):null,t("p",Object.assign({className:`${P.b4} opacity-60`},{children:K("mcp-private-configuration-note","Keep this configuration private. It contains your Studio session token and stops working when that session expires.")}))]}))}))}))]})};export{k 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 o}from"../../../hooks/pickaxe/useFeedback.js";import{AnimatePresence as n,motion as l}from"framer-motion";import c from"../../Icons/message-square-notes.svg.js";import r from"../../Icons/thumbs-down.svg.js";import m from"../../Icons/speaker.svg.js";import p from"../../Icons/stop.svg.js";import d from"../../Icons/spinner-lines.svg.js";import u from"../../Icons/thumbs-up.svg.js";import b from"./PickaxeSimpleButton.js";import h from"./PickaxeCopyButton.js";import f from"./PickaxeFeedbackThumbsDownReasons.js";import g from"../../../common/cn.js";const x=({content:x,sessionId:v,index:k=0,messagesCount:y,isHideFeedback:j,isReadOut:O,isReadOutLoading:w,isReading:N,onOpenChat:T,onReadOut:C})=>{var I,D,R,S;const{colors:z,translations:F,pickaxe:U,setIsShowFeedbackMessage:P}=a(),B=t(),{toggleThumb:H,submitThumbsDown:W,submitThumbsUp:q,isThumbsUpSelected:L,isThumbsDownSelected:M,showThumbsDownOptions:A,showThumbsUpOptions:E,showSuccess:G}=o({content:x,index:k,sessionId:v,successDuration:2e3,promptRate:1,onThumbsDownReasonOpen:()=>P(!0),onThumbsDownReasonClose:()=>P(!1)}),J="function"==typeof T&&((null==U?void 0:U.chatflag)||!!(null==U?void 0:U.enablechatresponses))&&void 0!==v&&void 0!==y,K=Boolean(((null==U?void 0:U.chatflag)||(null==U?void 0:U.enablechatresponses))&&!T||!(null==U?void 0:U.chatflag)&&!(null==U?void 0:U.enablechatresponses))&&!j;return e("div",Object.assign({className:"flex w-full flex-col gap-4"},{children:[e("div",Object.assign({className:"flex h-4 items-center gap-3"},{children:[J&&e(b,Object.assign({color:z.accent,onClick:T},{children:[s(c,{className:"h-4 w-4 shrink-0"}),s("p",Object.assign({className:g(B.b3,"font-semibold")},{children:y}))]})),s(h,{color:z.accent,text:x}),K&&e(i,{children:[s(b,Object.assign({color:z.accent,onClick:()=>H("like"),className:"transition-all active:rotate-12 active:scale-90"},{children:s(u,{className:"size-4",style:{fill:z.text,fillOpacity:L?.3:0}})})),s(b,Object.assign({color:z.accent,onClick:()=>H("dislike"),className:"transition-all active:-rotate-12 active:scale-90"},{children:s(r,{className:"size-4",style:{fill:z.text,fillOpacity:M?.3:0}})})),O&&C&&s(b,Object.assign({color:z.accent,onClick:()=>C(),className:"transition-all active:-rotate-12 active:scale-90"},{children:w?s(d,{className:"size-4 animate-spin"}):N?s(p,{className:"size-4 rounded-full border p-[1.5px]",style:{borderColor:z.accent}}):s(m,{className:"size-4"})})),s(n,{children:G&&s(l.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:g(B.b4,z.secondary,"opacity-75")},{children:null!==(I=null==F?void 0:F["feedback-thanks"])&&void 0!==I?I:"Thanks for the feedback!"}))}))})]})]})),s(n,{children:(A||E)&&e(l.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:g(B.b3,z.text)},{children:E?null!==(D=null==F?void 0:F["feedback-like-title"])&&void 0!==D?D:"What went right?":null!==(R=null==F?void 0:F["feedback-dislike-title"])&&void 0!==R?R:"What went wrong?"})),s("p",Object.assign({className:g(B.b3,z.secondary,"opacity-75")},{children:null!==(S=null==F?void 0:F["feedback-dislike-message"])&&void 0!==S?S:"Help us improve our answers"}))]})),s(l.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(f,{isUp:E,submitThumbsDown:W,submitThumbsUp:q})}))]}))})]}))};export{x as default};
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,2 @@
1
+ /** Executed only inside the isolated artifact renderer. Keep this self-contained. */
2
+ export declare const artifactSvgSnapshotScript: string;
@@ -0,0 +1,2 @@
1
+ /** Rasterize only the sanitized static snapshot, never the original artifact script. */
2
+ export declare const createResponseArtifactWordImages: (snapshot: string, title: string) => Promise<string>;
@@ -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. No response scripts, remote image fetches,
4
+ * live chat DOM, or existing artifact-export code are used.
5
+ */
6
+ export declare const createResponseDownloadDocx: (text: string, preparedHtml?: string) => Promise<Blob>;