@pickaxeproject/react 6.23.4 → 6.23.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/embedAuthEvents.js +1 -0
- package/dist/cjs/common/responseArtifactSvg.js +33 -1
- package/dist/cjs/common/responseArtifactWordImages.js +1 -1
- package/dist/cjs/common/responseDownloadArtifacts.js +1 -1
- package/dist/cjs/common/responseDownloadDocx.js +1 -1
- package/dist/cjs/common/responseDownloadHtml.js +1 -1
- package/dist/cjs/common/responseInteractiveArtifactHtml.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Auth/VerificationCodeForm.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuthBootstrap.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeLogoutButton.js +1 -1
- package/dist/cjs/src/common/embedAuthEvents.d.ts +26 -0
- package/dist/cjs/src/common/responseDownloadHtml.d.ts +1 -1
- package/dist/cjs/src/components/Pickaxe/Addons/Auth/hooks/useAuthVerify.d.ts +2 -0
- package/dist/esm/common/embedAuthEvents.js +1 -0
- package/dist/esm/common/responseArtifactSvg.js +33 -1
- package/dist/esm/common/responseArtifactWordImages.js +1 -1
- package/dist/esm/common/responseDownloadArtifacts.js +1 -1
- package/dist/esm/common/responseDownloadDocx.js +1 -1
- package/dist/esm/common/responseDownloadHtml.js +1 -1
- package/dist/esm/common/responseInteractiveArtifactHtml.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Auth/VerificationCodeForm.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuthBootstrap.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeLogoutButton.js +1 -1
- package/dist/esm/src/common/embedAuthEvents.d.ts +26 -0
- package/dist/esm/src/common/responseDownloadHtml.d.ts +1 -1
- package/dist/esm/src/components/Pickaxe/Addons/Auth/hooks/useAuthVerify.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=new Map,t=new Set,o=({deploymentId:e,pickaxeId:t,studioId:o})=>[o,t,e||""].map((e=>encodeURIComponent(e))).join(":"),n=e=>`PXE-pending-auth-${e}`,r=e=>`PXE-emitted-auth-${e}`,d=(e,t)=>{if("undefined"==typeof window)return;const o=`pickaxe:${e.event}`,n=Object.assign(Object.assign({},e),t);window.parent===window?window.dispatchEvent(new CustomEvent(o,{detail:n})):window.parent.postMessage({type:o,detail:n},(()=>{if("undefined"==typeof document||!document.referrer)return"";try{return new URL(document.referrer).origin}catch(e){return""}})()||"*")};exports.emitEmbedLogout=i=>{const a=o(i);e.delete(a),t.clear();try{window.localStorage.removeItem(n(a)),window.localStorage.removeItem(r(a))}catch(e){}d({event:"logout"},i)},exports.emitPendingEmbedAuthOutcome=({token:i,outcome:a,context:c})=>{if("undefined"==typeof window||!a)return;const w=o(c),m=`${w}:${i}`;let s=e.get(w);try{const e=n(w);if(s=window.localStorage.getItem(e)||s,s!==i)return;window.localStorage.removeItem(e),window.localStorage.setItem(r(w),i)}catch(e){}s!==i||t.has(m)||(e.delete(w),t.add(m),d({event:a,method:"email"},c))},exports.rememberPendingEmbedAuth=(t,r)=>{if("undefined"==typeof window)return;const d=o(t);e.set(d,r);try{window.localStorage.setItem(n(d),r)}catch(e){}};
|
|
@@ -31,6 +31,19 @@
|
|
|
31
31
|
'transform', 'transform-origin', 'transform-box',
|
|
32
32
|
'x', 'y', 'cx', 'cy', 'r', 'rx', 'ry', 'd'
|
|
33
33
|
];
|
|
34
|
+
// Mermaid HTML labels are static text inside foreignObject. Preserve their
|
|
35
|
+
// measured layout, but never serialize active elements or external resources.
|
|
36
|
+
const labelTags = new Set(['div', 'span', 'p', 'br', 'b', 'strong', 'i', 'em', 'u', 's', 'small', 'sub', 'sup', 'a']);
|
|
37
|
+
const labelProperties = [
|
|
38
|
+
'display', 'visibility', 'opacity', 'box-sizing', 'width', 'height',
|
|
39
|
+
'min-width', 'max-width', 'min-height', 'max-height',
|
|
40
|
+
'margin-top', 'margin-right', 'margin-bottom', 'margin-left',
|
|
41
|
+
'padding-top', 'padding-right', 'padding-bottom', 'padding-left',
|
|
42
|
+
'color', 'background-color', 'font-family', 'font-size', 'font-weight',
|
|
43
|
+
'font-style', 'line-height', 'letter-spacing', 'word-spacing',
|
|
44
|
+
'white-space', 'text-align', 'text-decoration', 'text-transform',
|
|
45
|
+
'vertical-align', 'overflow-wrap', 'word-break', 'direction'
|
|
46
|
+
];
|
|
34
47
|
sources.forEach((node, index) => {
|
|
35
48
|
const target = targets[index];
|
|
36
49
|
const tag = node.localName.toLowerCase();
|
|
@@ -38,7 +51,26 @@
|
|
|
38
51
|
target.remove();
|
|
39
52
|
return;
|
|
40
53
|
}
|
|
41
|
-
if (
|
|
54
|
+
if (node.namespaceURI === 'http://www.w3.org/1999/xhtml') {
|
|
55
|
+
if (!node.closest('foreignObject') || !labelTags.has(tag))
|
|
56
|
+
throw new Error('Unsupported SVG HTML label');
|
|
57
|
+
const computed = getComputedStyle(node);
|
|
58
|
+
if (computed.backgroundImage !== 'none')
|
|
59
|
+
throw new Error('SVG HTML label requires an external resource');
|
|
60
|
+
for (const pseudo of ['::before', '::after']) {
|
|
61
|
+
const content = getComputedStyle(node, pseudo).content;
|
|
62
|
+
if (content && content !== 'none' && content !== 'normal' && content !== '""')
|
|
63
|
+
throw new Error('Unsupported SVG HTML label decoration');
|
|
64
|
+
}
|
|
65
|
+
for (const attr of Array.from(target.attributes)) target.removeAttributeNode(attr);
|
|
66
|
+
labelProperties.forEach(property => {
|
|
67
|
+
const value = computed.getPropertyValue(property);
|
|
68
|
+
if (value) target.style.setProperty(property, safeValue(value));
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (node.namespaceURI !== 'http://www.w3.org/2000/svg')
|
|
73
|
+
throw new Error('Unsupported SVG namespace');
|
|
42
74
|
// Referenced symbols inherit styles through a browser-created shadow tree.
|
|
43
75
|
// Do not silently flatten them with the wrong colors or missing geometry.
|
|
44
76
|
if (tag === 'use') throw new Error('SVG symbol instances cannot be captured');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("./responseDownloadHtml.js"),o=require("./responseDownloadImages.js");exports.createResponseArtifactWordImages=(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("./responseDownloadHtml.js"),o=require("./responseDownloadImages.js"),r=require("./responseArtifactStyles.js");exports.createResponseArtifactWordImages=(n,i)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;let a=t.createResponseDownloadDocument(`<div class="pxe-export-artifact">${n}</div>`,!0);const l=document.createElement("template");l.innerHTML=a;const s=yield o.embedResponseDownloadImages(l.content,"docx");for(const t of l.content.querySelectorAll("img")){if(s.has(t))continue;const o=document.createElement("span");o.textContent=`⚠ ${(null===(e=t.getAttribute("alt"))||void 0===e?void 0:e.trim())||"[…]"}`,t.replaceWith(o)}a=`<!doctype html>\n${l.innerHTML}`;const c=document.createElement("iframe");c.setAttribute("sandbox","allow-same-origin"),c.setAttribute("aria-hidden","true"),c.tabIndex=-1,c.style.cssText="position:fixed;left:-10000px;top:0;width:720px;height:600px;border:0;pointer-events:none";try{yield new Promise(((e,t)=>{const o=setTimeout((()=>t(new Error("Word snapshot timed out."))),5e3);c.onload=()=>{clearTimeout(o),e()},c.onerror=()=>{clearTimeout(o),t(new Error("Word snapshot failed."))},c.srcdoc=a,document.body.appendChild(c)}));const e=c.contentDocument,t=c.contentWindow,o=null==e?void 0:e.querySelector("main");if(!e||!t||!o)throw new Error("Word snapshot unavailable.");const n=e.createElement("style");n.textContent="body > main{display:flow-root;width:720px;max-width:none;padding:0;margin:0}\n.pxe-export-artifact{overflow:visible}\n.pxe-export-artifact:has(tr > :nth-child(6)) > div{min-width:0}\ntable{width:100%;table-layout:fixed} pre{white-space:pre-wrap;overflow-wrap:anywhere}\n*{animation:none!important;transition:none!important}",e.head.appendChild(n),e.querySelectorAll("details").forEach((e=>{e.open=!0}));const l=o.cloneNode(!0),s=[o,...o.querySelectorAll("*")],d=[l,...l.querySelectorAll("*")];s.forEach(((e,o)=>{const n=d[o],i=t.getComputedStyle(e);n.removeAttribute("style");for(const e of[...r.artifactStyleProperties,"direction","unicode-bidi","white-space","overflow-wrap","table-layout"])n.style.setProperty(e,i.getPropertyValue(e));"TABLE"===e.tagName&&(n.style.width="100%"),"IMG"===e.tagName&&(n.style.maxWidth="100%",n.style.height="auto")})),l.style.width="720px",o.replaceWith(l),e.querySelectorAll("style").forEach((e=>e.remove())),e.body.style.margin="0",yield Promise.all(Array.from(l.querySelectorAll("img"),(e=>e.decode())));const h=Math.ceil(Math.max(l.scrollWidth,l.getBoundingClientRect().width)),p=Math.ceil(l.getBoundingClientRect().height);if(h>1440||!p||p>16e3)throw new Error("Artifact is too large for a readable Word picture.");l.setAttribute("xmlns","http://www.w3.org/1999/xhtml");const m=(new XMLSerializer).serializeToString(l);if(m.length>1e7)throw new Error("Word snapshot is too large.");const u=l.getBoundingClientRect().top,w=[],g=e.createTreeWalker(l,NodeFilter.SHOW_TEXT);for(;g.nextNode();){const t=e.createRange();t.selectNodeContents(g.currentNode);for(const e of Array.from(t.getClientRects()))e.height&&w.push({top:e.top-u,bottom:e.bottom-u})}l.querySelectorAll("tr,img").forEach((e=>{const t=e.getBoundingClientRect();t.height<=800&&w.push({top:t.top-u,bottom:t.bottom-u})}));const f=[];let y=0;for(let t=0;t<p;){let o=Math.min(p,t+800);if(o<p)for(let e=0;e<w.length;e++){const e=w.find((e=>e.top+1<o&&e.bottom-1>o));if(!e||e.top<=t)break;o=Math.ceil(e.top)}if(o<=t)throw new Error("Unable to paginate artifact picture.");const r=`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${o-t}" viewBox="0 ${t} ${h} ${o-t}"><foreignObject x="0" y="0" width="${h}" height="${p}">${m}</foreignObject></svg>`,n=new Image;yield new Promise(((e,t)=>{const o=setTimeout((()=>i(!1)),5e3),i=r=>{clearTimeout(o),n.onload=n.onerror=null,r?e():t(new Error("Unable to draw Word artifact picture."))};n.onload=()=>i(!0),n.onerror=()=>i(!1),n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`}));const a=document.createElement("canvas");a.width=2*h,a.height=2*(o-t);const l=a.getContext("2d");if(!l)throw new Error("Word image capture unavailable.");l.fillStyle="white",l.fillRect(0,0,a.width,a.height),l.drawImage(n,0,0,a.width,a.height);const s=a.toDataURL("image/png");if(y+=s.length,y>1e7)throw new Error("Word artifact pictures are too large.");const c=e.createElement("img");c.src=s,c.width=h,c.height=o-t,c.alt=i;const d=e.createElement("p");d.appendChild(c),f.push(d.outerHTML),a.width=a.height=0,n.removeAttribute("src"),t=o}return f.join("")}finally{c.remove()}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("react"),r=require("react-dom/server"),n=require("react-markdown"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("react"),r=require("react-dom/server"),n=require("react-markdown"),a=require("remark-gfm"),i=require("rehype-raw"),o=require("uuid"),s=require("./responseArtifactWordImages.js"),l=require("./responseStandaloneSvg.js"),c=require("./responseMermaid.js"),d=require("./responseInteractiveArtifactHtml.js"),p=require("./responseDownloadHtml.js");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=u(n),m=u(a),v=u(i);const h=(e,t)=>{var r;const n=/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<\/?([a-z][\w:-]*)(?:[^>"']|"[^"]*"|'[^']*')*>/gi;n.lastIndex=t;let a,i=0;for(;null!==(a=n.exec(e));){const t=null===(r=a[1])||void 0===r?void 0:r.toLowerCase();if(!t)continue;const o=a[0].startsWith("</");if("artifact"===t){if(o?i--:/\/\s*>$/.test(a[0])||i++,0===i)return n.lastIndex}else if(!o&&/^(script|style|textarea|title|xmp|iframe|noembed|noframes)$/.test(t)){const r=new RegExp(`</${t}\\s*>`,"gi");if(r.lastIndex=n.lastIndex,!r.exec(e))break;n.lastIndex=r.lastIndex}}return e.length},x=e=>e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),g=t=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,r;const n=document.createElement("template");return n.innerHTML=yield p.createResponseDownloadHtml(t),null!==(r=null===(e=n.content.querySelector("main"))||void 0===e?void 0:e.innerHTML)&&void 0!==r?r:""})),b=(e,t)=>{const r=[];let n=[],a="",i=!1;for(let o=0;o<e.length;o++){const s=e[o];'"'===s?i&&'"'===e[o+1]?(a+='"',o++):i=!i:i||s!==t&&"\n"!==s&&"\r"!==s?a+=s:(n.push(a),a="",s!==t&&(r.push(n),n=[],"\r"===s&&"\n"===e[o+1]&&o++))}if(i)throw new Error("Incomplete artifact table.");return(a||n.length)&&r.push([...n,a]),`<table>${r.map(((e,t)=>`<tr>${e.map((e=>{const r=t?"td":"th";return`<${r}>${x(e).replace(/\n/g,"<br>")}</${r}>`})).join("")}</tr>`)).join("")}</table>`};exports.findResponseArtifacts=e=>{if(!/<artifact\b/i.test(e))return[];const n=[];r.renderToStaticMarkup(t.createElement(f.default,{remarkPlugins:[m.default],rehypePlugins:[v.default],components:{artifact:({node:t})=>{var r,a,i;const o=null===(r=t.position)||void 0===r?void 0:r.start.offset,s=String(null!==(a=t.properties.dataId)&&void 0!==a?a:""),l=Number(null!==(i=t.properties.dataVersion)&&void 0!==i?i:1);if(null==o||!s||!Number.isInteger(l)||l<1)throw new Error("Invalid response artifact reference.");return n.push({id:s,version:l,start:o,end:h(e,o)}),null}}},e));let a=0;return n.sort(((e,t)=>e.start-t.start)).filter((e=>!(e.start<a)&&(a=e.end,!0)))},exports.prepareResponseArtifactDownload=(t,r,n,a,i)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e="txt"===a||"md"===a,u=[],f=[];let m=0;for(const d of r){const r=yield n(d);if(r.id!==d.id||r.version!==d.version||r.status&&"finished"!==r.status)throw new Error("Response artifact is not ready.");const p=t.slice(m,d.start);if(u.push(e?p:yield g(p)),e){const e="`".repeat(Math.max(3,...Array.from(r.content.matchAll(/`+/g),(e=>e[0].length+1))));u.push(`\n\n${r.title}\n\n${"md"===a&&"text/markdown"!==r.type?`${e}\n${r.content}\n${e}`:r.content}\n\n`)}else{let e;switch(r.type){case"text/markdown":e=yield g(r.content);break;case"text/csv":e=b(r.content,",");break;case"text/tab-separated-values":e=b(r.content,"\t");break;case"application/vnd.pxe.mermaid":e=yield c.createResponseMermaidImage(r.content,r.title);break;case"image/svg+xml":e=yield l.createResponseSvgImage(r.content,r.title);break;case"text/html":if("html"===a){const t=`artifact-${o.v4()}`;f.push({placeholder:t,title:r.title,content:r.content}),e=`<div id="${t}"></div>`;break}e=yield i(r.content),"docx"===a&&(e=yield s.createResponseArtifactWordImages(e,r.title));break;case"application/pdf":e=yield i(r.content);break;case"application/vnd.pxe.code":e=`<pre><code>${x(r.content)}</code></pre>`;break;default:throw new Error(`Artifact export is not supported for ${r.type}.`)}u.push(`<section><h2>${x(r.title)}</h2><div class="pxe-export-artifact">${e}</div></section>`)}m=d.end}return u.push(e?t.slice(m):yield g(t.slice(m))),e?u.join(""):d.embedInteractiveArtifacts(p.createResponseDownloadDocument(u.join("\n"),"html"===a||"pdf"===a),f)}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("docx"),n=require("./responseDownloadHtml.js"),r=require("./responseDownloadImages.js");const a=720,i=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DD","DETAILS","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SUMMARY","TABLE","UL"]),s=e=>{if(e&&/^(https?:|mailto:|tel:)/i.test(e.trim()))try{return new URL(e.trim()).href}catch(e){return}},o=(e,n)=>{const r=Object.assign({},n);switch(e.tagName){case"STRONG":case"B":r.bold=!0;break;case"EM":case"I":r.italics=!0;break;case"DEL":case"S":case"STRIKE":r.strike=!0;break;case"U":r.underline={type:t.UnderlineType.SINGLE};break;case"CODE":case"KBD":case"SAMP":r.font="Courier New";break;case"SUP":r.superScript=!0;break;case"SUB":r.subScript=!0}return r};exports.createResponseDownloadDocx=(l,c)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=document.createElement("template");e.innerHTML=null!=c?c:n.createResponseDownloadHtml(l);const d=e.content.querySelector("main");if(!d)throw new Error("Unable to prepare the response document.");const u=yield r.embedResponseDownloadImages(d,"docx"),g=new Map;for(const e of u){const t=e.getAttribute("src")||"";if(t.length>1e7)throw new Error("Artifact image too large.");const n=Uint8Array.from(atob(t.slice(22)),(e=>e.charCodeAt(0))),r=new DataView(n.buffer);if(n.length<24||2303741511!==r.getUint32(0)||218765834!==r.getUint32(4)||1229472850!==r.getUint32(12))throw new Error("Invalid artifact image.");const a=r.getUint32(16),i=r.getUint32(20);if(!a||!i||a*i>16e6)throw new Error("Artifact image dimensions are unsupported.");yield new Promise(((e,n)=>{const r=new Image,s=t=>{clearTimeout(o),r.onload=r.onerror=null,r.removeAttribute("src"),t?e():n(new Error("Unable to read artifact image."))},o=setTimeout((()=>s(!1)),5e3);r.onload=()=>s(r.naturalWidth===a&&r.naturalHeight===i),r.onerror=()=>s(!1),r.src=t}));const s=Number(e.getAttribute("width")),o=s>0?Math.min(1,s/a):1;g.set(e,{data:n,width:a*o,height:i*o})}const h=[],m=(e,n,r)=>Array.from(e).flatMap((e=>{var a;if(3===e.nodeType){const r=e.textContent||"";return[new t.TextRun(Object.assign(Object.assign({},n),{text:(null===(a=e.parentElement)||void 0===a?void 0:a.closest("code"))?r:r.replace(/[\t\n\r ]+/g," ")}))]}if(1!==e.nodeType)return[];const i=e,l=o(i,n);if("BR"===i.tagName)return[new t.TextRun(Object.assign(Object.assign({},n),{break:1}))];if("IMG"===i.tagName){const e=g.get(i);if(e){const n=Math.min(1,Math.max(1,r/15)/e.width,900/e.height);return[new t.ImageRun(Object.assign(Object.assign({type:"png",data:e.data},i.getAttribute("alt")?{altText:{name:i.getAttribute("alt")||""}}:{}),{transformation:{width:e.width*n,height:e.height*n}}))]}const a=s(i.getAttribute("src")),o=i.getAttribute("alt")||a||"[…]",l=[new t.TextRun(Object.assign(Object.assign({},n),{text:o}))];return a&&!i.closest("a")?[new t.ExternalHyperlink({link:a,children:l})]:l}const c="A"===i.tagName?s(i.getAttribute("href")):void 0,d=m(i.childNodes,c?Object.assign(Object.assign({},l),{color:"174EA6",underline:{type:t.UnderlineType.SINGLE}}):l,r);return c?[new t.ExternalHyperlink({link:c,children:d})]:d})),p=(e,n,r={})=>{const a=n.marker&&!n.marker.used?n.marker:void 0;return a&&(a.used=!0),new t.Paragraph(Object.assign(Object.assign(Object.assign({children:e,spacing:{after:160},widowControl:!0},n.indent?{indent:Object.assign({left:n.indent},a?{hanging:360}:{})}:{}),null==a?void 0:a.properties),r))},b=(e,n)=>{var r;const a="OL"===e.tagName;let i="",s=!1;const o=e=>{i=`response-list-${h.length}`,s=0===e,h.push({reference:i,levels:[{level:0,format:t.LevelFormat.DECIMAL,text:s?"0.":"%1.",start:s?1:e,alignment:t.AlignmentType.LEFT}]})},l=e.hasAttribute("reversed"),c=Array.from(e.children).filter((e=>"LI"===e.tagName)),d=Number.parseInt(e.getAttribute("start")||"",10);let u=Number.isFinite(d)?d:l?c.length:1;a&&o(u);const g=[];for(const t of Array.from(e.children)){if("LI"!==t.tagName){g.push(...w([t],n));continue}const e=Number.parseInt(t.getAttribute("value")||"",10);a&&Number.isFinite(e)&&(u=e),a&&(l||s||0===u||Number.isFinite(e))&&o(u),u+=l?-1:1;const c=Object.assign(Object.assign({},n),{indent:Math.min(n.indent+720,5760),marker:{used:!1,properties:a?{numbering:{reference:i,level:0}}:{bullet:{level:0}}}}),d=w(t.childNodes,c);(null===(r=c.marker)||void 0===r?void 0:r.used)||d.unshift(p([],c)),g.push(...d)}return g},f=(e,n)=>{const r=[];let a=0;const i=Array.from(e.querySelectorAll("tr")).filter((t=>t.closest("table")===e)).map(((e,t)=>{let n=0;return{row:e,cells:Array.from(e.children).filter((e=>"TD"===e.tagName||"TH"===e.tagName)).map((e=>{for(;r[n]>t;)n++;const i=t=>Math.min(100,Math.max(1,parseInt(e.getAttribute(t)||"1",10)||1)),s=i("colspan"),o=i("rowspan"),l=n;for(let e=0;e<s;e++)r[n++]=t+o;return a=Math.max(a,n),{cell:e,start:l,columnSpan:s,rowSpan:o}}))}})),s=e=>Math.floor(e*n/a),o=Array.from({length:a},((e,t)=>s(t+1)-s(t))),l=i.flatMap((({row:e,cells:n})=>{var r;return n.length?[new t.TableRow({tableHeader:"THEAD"===(null===(r=e.parentElement)||void 0===r?void 0:r.tagName)||n.every((({cell:e})=>"TH"===e.tagName)),children:n.map((({cell:e,start:n,columnSpan:r,rowSpan:a})=>{const i=s(n+r)-s(n),o=w(e.childNodes,{indent:0,width:Math.max(1,i-200),run:{bold:"TH"===e.tagName}});return o[o.length-1]instanceof t.Paragraph||o.push(new t.Paragraph("")),new t.TableCell(Object.assign({children:o,columnSpan:r,rowSpan:a,width:{size:i,type:t.WidthType.DXA},margins:{top:80,bottom:80,left:100,right:100}},"TH"===e.tagName?{shading:{fill:"F0F0F0"}}:{}))}))})]:[]})),c=Array.from(e.children).filter((e=>"CAPTION"===e.tagName));return l.length?[...w(c,{indent:0,width:n,run:{}}),new t.Table({rows:l,width:{size:n,type:t.WidthType.DXA},columnWidths:o})]:w(e.childNodes,{indent:0,width:n,run:{}})},w=(e,n)=>{const r=[];let a=[];const s=()=>{a.some((e=>{var t;return(null===(t=e.textContent)||void 0===t?void 0:t.trim())||1===e.nodeType&&/^(BR|IMG)$/.test(e.tagName)||1===e.nodeType&&e.querySelector("br,img")}))&&r.push(p(m(a,n.run,n.width-n.indent),n)),a=[]};for(const l of Array.from(e)){if(1!==l.nodeType||!i.has(l.tagName)){1===l.nodeType&&Array.from(l.children).some((e=>i.has(e.tagName)))?(s(),r.push(...w(l.childNodes,Object.assign(Object.assign({},n),{run:o(l,n.run)})))):a.push(l);continue}s();const e=l,c=e.tagName;if("UL"===c||"OL"===c)n.marker&&!n.marker.used&&r.push(p([],n)),r.push(...b(e,n));else if("TABLE"===c)n.marker&&!n.marker.used&&r.push(p([],n)),r.push(...f(e,n.width));else if("PRE"===c){const a=(e.textContent||"").replace(/\r\n?/g,"\n").split("\n");r.push(p(a.map(((e,r)=>new t.TextRun(Object.assign(Object.assign(Object.assign({},n.run),{children:e.split("\t").flatMap(((e,n)=>n?[new t.Tab,e]:[e])),font:"Courier New",size:20}),r?{break:1}:{})))),n,{shading:{fill:"F4F4F4"},spacing:{before:120,after:160}}))}else if(/^H[1-6]$/.test(c)){const a=[t.HeadingLevel.HEADING_1,t.HeadingLevel.HEADING_2,t.HeadingLevel.HEADING_3,t.HeadingLevel.HEADING_4,t.HeadingLevel.HEADING_5,t.HeadingLevel.HEADING_6];r.push(p(m(e.childNodes,Object.assign(Object.assign({},n.run),{bold:!0,color:"202020"}),n.width-n.indent),n,{heading:a[Number(c[1])-1],keepNext:!0}))}else if("HR"===c)r.push(p([],n,{border:{bottom:{style:t.BorderStyle.SINGLE,color:"CCCCCC",size:4}}}));else{const t="BLOCKQUOTE"===c?Object.assign(Object.assign({},n),{indent:n.indent+360}):n,a=w(e.childNodes,t);r.push(...a),a.length||"P"!==c||r.push(p([],t))}}return s(),r},A=w(d.childNodes,{indent:0,width:10800,run:{}}),N=new t.Document({title:"Pickaxe",creator:"Pickaxe",styles:{default:{document:{run:{font:"Arial",size:22,color:"202020"}}}},numbering:{config:h},sections:[{properties:{page:{size:{width:12240,height:15840},margin:{top:a,bottom:a,left:a,right:a}}},children:A.length?A:[new t.Paragraph("")]}]});return t.Packer.toBlob(N)}));
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("docx"),n=require("./responseDownloadHtml.js"),r=require("./responseDownloadImages.js");const a=720,i=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DD","DETAILS","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SUMMARY","TABLE","UL"]),s=e=>{if(e&&/^(https?:|mailto:|tel:)/i.test(e.trim()))try{return new URL(e.trim()).href}catch(e){return}},o=(e,n)=>{const r=Object.assign({},n);switch(e.tagName){case"STRONG":case"B":r.bold=!0;break;case"EM":case"I":r.italics=!0;break;case"DEL":case"S":case"STRIKE":r.strike=!0;break;case"U":r.underline={type:t.UnderlineType.SINGLE};break;case"CODE":case"KBD":case"SAMP":r.font="Courier New";break;case"SUP":r.superScript=!0;break;case"SUB":r.subScript=!0}return r};exports.createResponseDownloadDocx=(l,c)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=document.createElement("template");e.innerHTML=null!=c?c:yield n.createResponseDownloadHtml(l);const d=e.content.querySelector("main");if(!d)throw new Error("Unable to prepare the response document.");const u=yield r.embedResponseDownloadImages(d,"docx"),g=new Map;for(const e of u){const t=e.getAttribute("src")||"";if(t.length>1e7)throw new Error("Artifact image too large.");const n=Uint8Array.from(atob(t.slice(22)),(e=>e.charCodeAt(0))),r=new DataView(n.buffer);if(n.length<24||2303741511!==r.getUint32(0)||218765834!==r.getUint32(4)||1229472850!==r.getUint32(12))throw new Error("Invalid artifact image.");const a=r.getUint32(16),i=r.getUint32(20);if(!a||!i||a*i>16e6)throw new Error("Artifact image dimensions are unsupported.");yield new Promise(((e,n)=>{const r=new Image,s=t=>{clearTimeout(o),r.onload=r.onerror=null,r.removeAttribute("src"),t?e():n(new Error("Unable to read artifact image."))},o=setTimeout((()=>s(!1)),5e3);r.onload=()=>s(r.naturalWidth===a&&r.naturalHeight===i),r.onerror=()=>s(!1),r.src=t}));const s=Number(e.getAttribute("width")),o=s>0?Math.min(1,s/a):1;g.set(e,{data:n,width:a*o,height:i*o})}const h=[],m=(e,n,r)=>Array.from(e).flatMap((e=>{var a;if(3===e.nodeType){const r=e.textContent||"";return[new t.TextRun(Object.assign(Object.assign({},n),{text:(null===(a=e.parentElement)||void 0===a?void 0:a.closest("code"))?r:r.replace(/[\t\n\r ]+/g," ")}))]}if(1!==e.nodeType)return[];const i=e,l=o(i,n);if("BR"===i.tagName)return[new t.TextRun(Object.assign(Object.assign({},n),{break:1}))];if("IMG"===i.tagName){const e=g.get(i);if(e){const n=Math.min(1,Math.max(1,r/15)/e.width,900/e.height);return[new t.ImageRun(Object.assign(Object.assign({type:"png",data:e.data},i.getAttribute("alt")?{altText:{name:i.getAttribute("alt")||""}}:{}),{transformation:{width:e.width*n,height:e.height*n}}))]}const a=s(i.getAttribute("src")),o=i.getAttribute("alt")||a||"[…]",l=[new t.TextRun(Object.assign(Object.assign({},n),{text:o}))];return a&&!i.closest("a")?[new t.ExternalHyperlink({link:a,children:l})]:l}const c="A"===i.tagName?s(i.getAttribute("href")):void 0,d=m(i.childNodes,c?Object.assign(Object.assign({},l),{color:"174EA6",underline:{type:t.UnderlineType.SINGLE}}):l,r);return c?[new t.ExternalHyperlink({link:c,children:d})]:d})),p=(e,n,r={})=>{const a=n.marker&&!n.marker.used?n.marker:void 0;return a&&(a.used=!0),new t.Paragraph(Object.assign(Object.assign(Object.assign({children:e,spacing:{after:160},widowControl:!0},n.indent?{indent:Object.assign({left:n.indent},a?{hanging:360}:{})}:{}),null==a?void 0:a.properties),r))},b=(e,n)=>{var r;const a="OL"===e.tagName;let i="",s=!1;const o=e=>{i=`response-list-${h.length}`,s=0===e,h.push({reference:i,levels:[{level:0,format:t.LevelFormat.DECIMAL,text:s?"0.":"%1.",start:s?1:e,alignment:t.AlignmentType.LEFT}]})},l=e.hasAttribute("reversed"),c=Array.from(e.children).filter((e=>"LI"===e.tagName)),d=Number.parseInt(e.getAttribute("start")||"",10);let u=Number.isFinite(d)?d:l?c.length:1;a&&o(u);const g=[];for(const t of Array.from(e.children)){if("LI"!==t.tagName){g.push(...w([t],n));continue}const e=Number.parseInt(t.getAttribute("value")||"",10);a&&Number.isFinite(e)&&(u=e),a&&(l||s||0===u||Number.isFinite(e))&&o(u),u+=l?-1:1;const c=Object.assign(Object.assign({},n),{indent:Math.min(n.indent+720,5760),marker:{used:!1,properties:a?{numbering:{reference:i,level:0}}:{bullet:{level:0}}}}),d=w(t.childNodes,c);(null===(r=c.marker)||void 0===r?void 0:r.used)||d.unshift(p([],c)),g.push(...d)}return g},f=(e,n)=>{const r=[];let a=0;const i=Array.from(e.querySelectorAll("tr")).filter((t=>t.closest("table")===e)).map(((e,t)=>{let n=0;return{row:e,cells:Array.from(e.children).filter((e=>"TD"===e.tagName||"TH"===e.tagName)).map((e=>{for(;r[n]>t;)n++;const i=t=>Math.min(100,Math.max(1,parseInt(e.getAttribute(t)||"1",10)||1)),s=i("colspan"),o=i("rowspan"),l=n;for(let e=0;e<s;e++)r[n++]=t+o;return a=Math.max(a,n),{cell:e,start:l,columnSpan:s,rowSpan:o}}))}})),s=e=>Math.floor(e*n/a),o=Array.from({length:a},((e,t)=>s(t+1)-s(t))),l=i.flatMap((({row:e,cells:n})=>{var r;return n.length?[new t.TableRow({tableHeader:"THEAD"===(null===(r=e.parentElement)||void 0===r?void 0:r.tagName)||n.every((({cell:e})=>"TH"===e.tagName)),children:n.map((({cell:e,start:n,columnSpan:r,rowSpan:a})=>{const i=s(n+r)-s(n),o=w(e.childNodes,{indent:0,width:Math.max(1,i-200),run:{bold:"TH"===e.tagName}});return o[o.length-1]instanceof t.Paragraph||o.push(new t.Paragraph("")),new t.TableCell(Object.assign({children:o,columnSpan:r,rowSpan:a,width:{size:i,type:t.WidthType.DXA},margins:{top:80,bottom:80,left:100,right:100}},"TH"===e.tagName?{shading:{fill:"F0F0F0"}}:{}))}))})]:[]})),c=Array.from(e.children).filter((e=>"CAPTION"===e.tagName));return l.length?[...w(c,{indent:0,width:n,run:{}}),new t.Table({rows:l,width:{size:n,type:t.WidthType.DXA},columnWidths:o})]:w(e.childNodes,{indent:0,width:n,run:{}})},w=(e,n)=>{const r=[];let a=[];const s=()=>{a.some((e=>{var t;return(null===(t=e.textContent)||void 0===t?void 0:t.trim())||1===e.nodeType&&/^(BR|IMG)$/.test(e.tagName)||1===e.nodeType&&e.querySelector("br,img")}))&&r.push(p(m(a,n.run,n.width-n.indent),n)),a=[]};for(const l of Array.from(e)){if(1!==l.nodeType||!i.has(l.tagName)){1===l.nodeType&&Array.from(l.children).some((e=>i.has(e.tagName)))?(s(),r.push(...w(l.childNodes,Object.assign(Object.assign({},n),{run:o(l,n.run)})))):a.push(l);continue}s();const e=l,c=e.tagName;if("UL"===c||"OL"===c)n.marker&&!n.marker.used&&r.push(p([],n)),r.push(...b(e,n));else if("TABLE"===c)n.marker&&!n.marker.used&&r.push(p([],n)),r.push(...f(e,n.width));else if("PRE"===c){const a=(e.textContent||"").replace(/\r\n?/g,"\n").split("\n");r.push(p(a.map(((e,r)=>new t.TextRun(Object.assign(Object.assign(Object.assign({},n.run),{children:e.split("\t").flatMap(((e,n)=>n?[new t.Tab,e]:[e])),font:"Courier New",size:20}),r?{break:1}:{})))),n,{shading:{fill:"F4F4F4"},spacing:{before:120,after:160}}))}else if(/^H[1-6]$/.test(c)){const a=[t.HeadingLevel.HEADING_1,t.HeadingLevel.HEADING_2,t.HeadingLevel.HEADING_3,t.HeadingLevel.HEADING_4,t.HeadingLevel.HEADING_5,t.HeadingLevel.HEADING_6];r.push(p(m(e.childNodes,Object.assign(Object.assign({},n.run),{bold:!0,color:"202020"}),n.width-n.indent),n,{heading:a[Number(c[1])-1],keepNext:!0}))}else if("HR"===c)r.push(p([],n,{border:{bottom:{style:t.BorderStyle.SINGLE,color:"CCCCCC",size:4}}}));else{const t="BLOCKQUOTE"===c?Object.assign(Object.assign({},n),{indent:n.indent+360}):n,a=w(e.childNodes,t);r.push(...a),a.length||"P"!==c||r.push(p([],t))}}return s(),r},A=w(d.childNodes,{indent:0,width:10800,run:{}}),N=new t.Document({title:"Pickaxe",creator:"Pickaxe",styles:{default:{document:{run:{font:"Arial",size:22,color:"202020"}}}},numbering:{config:h},sections:[{properties:{page:{size:{width:12240,height:15840},margin:{top:a,bottom:a,left:a,right:a}}},children:A.length?A:[new t.Paragraph("")]}]});return t.Packer.toBlob(N)}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("react"),r=require("react-dom/server"),n=require("react-markdown"),o=require("remark-gfm"),a=require("rehype-raw"),i=require("isomorphic-dompurify"),l=require("./responseArtifactStyles.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js"),t=require("react"),r=require("react-dom/server"),n=require("react-markdown"),o=require("remark-gfm"),a=require("rehype-raw"),i=require("isomorphic-dompurify"),l=require("./responseArtifactStyles.js"),c=require("./responseStandaloneSvg.js");function d(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=d(n),p=d(o),h=d(a),m=d(i);const u=n=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,o,a;const i=r.renderToStaticMarkup(t.createElement(s.default,{remarkPlugins:[p.default],rehypePlugins:[h.default],components:{input:({type:e,checked:r})=>"checkbox"===(null==e?void 0:e.toLowerCase())?t.createElement("span",null,r?"☑":"☐"):null}},n)),l=document.createElement("template");l.innerHTML=i;const d=(e=>{var t;let r=!1;const n=new Set(Array.from(e.querySelectorAll("img[src]"),(e=>e.getAttribute("src"))));for(const o of e.querySelectorAll("a[href]"))if(!o.closest("pre,code")&&!o.querySelector("img"))try{const e=new URL(o.getAttribute("href")||""),a=decodeURIComponent(e.pathname.split("/").pop()||"");if("https:"!==e.protocol||e.username||e.password||!e.pathname.includes("/action_generated_files/")||!/\.(png|jpe?g|gif|webp|svg)$/i.test(a)||n.has(e.href))continue;n.add(e.href);const i=document.createElement("img");i.src=e.href,i.alt=(null===(t=o.textContent)||void 0===t?void 0:t.trim())||a;const l=document.createElement("span");o.replaceWith(l),l.append(o,document.createElement("br"),i),r=!0}catch(e){}return r})(l.content),m=Array.from(l.content.querySelectorAll("svg")).filter((e=>{var t;return!(null===(t=e.parentElement)||void 0===t?void 0:t.closest("svg"))}));if(!m.length&&!d)return w(i);for(const t of m)try{const e=yield c.createResponseSvgImage(t.outerHTML,""),r=document.createElement("template");r.innerHTML=e,t.replaceWith(r.content)}catch(r){const n=document.createElement("span");n.textContent=`⚠ ${(null===(e=t.getAttribute("aria-label"))||void 0===e?void 0:e.trim())||(null===(a=null===(o=t.querySelector("title"))||void 0===o?void 0:o.textContent)||void 0===a?void 0:a.trim())||"[…]"}`,t.replaceWith(n)}return w(l.innerHTML)})),w=(e,t=!1)=>{let r=m.default.sanitize(e,{USE_PROFILES:{html:!0},FORBID_TAGS:["script","style","iframe","form","input","button","select","textarea","object","embed","link","meta","base","audio","video","source","track"],FORBID_ATTR:["srcset","ping","background",...t?[]:["style"]],ALLOW_DATA_ATTR:!1});if(t){const e=document.createElement("template");e.innerHTML=r,l.filterArtifactStyles(e.content),e.content.querySelectorAll("label").forEach((e=>{var t;(null===(t=e.textContent)||void 0===t?void 0:t.trim())||e.children.length||e.remove()})),r=e.innerHTML}return`<!doctype html>\n<html>\n<head>\n<meta charset="utf-8">\n<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'none'; style-src 'unsafe-inline'; img-src https: data:; base-uri 'none'; form-action 'none'">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<title>Pickaxe</title>\n<style>\nbody { margin: 0; background: white; color: #202020; font: 16px/1.6 system-ui, sans-serif; }\nmain { max-width: 900px; margin: 0 auto; padding: 24px; overflow-wrap: anywhere; }\nh1, h2, h3, h4, h5, h6 { line-height: 1.25; }\na { color: #174ea6; }\npre, code { font-family: ui-monospace, monospace; }\npre { padding: 16px; background: #f4f4f4; overflow-x: auto; white-space: pre; }\nblockquote { margin-left: 0; padding-left: 16px; border-left: 3px solid #ccc; }\ntable { border-collapse: collapse; max-width: 100%; }\nth, td { border: 1px solid #ccc; padding: 8px; text-align: start; }\nimg { max-width: 100%; height: auto; }\nsummary { cursor: pointer; }\n${t?"\n.pxe-export-artifact { max-width: 100%; overflow-x: auto; }\n.pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 720px; }\n.pxe-export-artifact table { width: 100%; max-width: 100%; }\n.pxe-export-artifact th, .pxe-export-artifact td { overflow-wrap: anywhere; }\n@media print {\n .pxe-export-artifact { overflow: visible; }\n .pxe-export-artifact:has(tr > :nth-child(6)) > div { min-width: 0; }\n .pxe-export-artifact table { width: 100%; min-width: 0; max-width: 100%; table-layout: fixed; }\n .pxe-export-artifact th, .pxe-export-artifact td { padding: 5px !important; font-size: 10px !important; overflow-wrap: anywhere; }\n .pxe-export-artifact, .pxe-export-artifact * { print-color-adjust: exact; -webkit-print-color-adjust: exact; }\n}\n":""}</style>\n</head>\n<body><main dir="auto">${r}</main></body>\n</html>`},f=(t,r)=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=null!=r?r:window.open("","_blank");if(!e||e.closed)throw new Error("Unable to open the response print window.");try{e.opener=null;const r=e.document;r.open(),r.write(t);const n=r.createElement("style");if(n.media="print",n.textContent="\n@page { margin: 12mm; }\nmain { max-width: none; padding: 0; }\npre { overflow: visible; }\npre, pre code { white-space: pre-wrap; overflow-wrap: anywhere; }\ntable { width: 100%; table-layout: fixed; }\nth, td { white-space: normal; overflow-wrap: anywhere; }\nthead { display: table-header-group; }\ntr, img { break-inside: avoid; }\nh1, h2, h3, h4, h5, h6 { break-after: avoid; }\np, li { orphans: 3; widows: 3; }\n",r.head.appendChild(n),r.querySelectorAll("details").forEach((e=>{e.open=!0})),r.querySelectorAll("img").forEach((e=>{e.loading="eager"})),r.close(),e.focus(),yield x(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}})),x=(t,r)=>new Promise(((n,o)=>{const a=new Set(Array.from(r.images)),i=e=>{if(d)return;a.delete(e);const t=r.createElement("span");t.textContent=`⚠ ${e.alt.trim()||"[…]"}`,t.style.cssText="display:inline-block;border:1px solid #999;padding:4px;white-space:normal;overflow-wrap:anywhere;",e.removeAttribute("src"),e.removeAttribute("srcset"),e.replaceWith(t)},l=window.setTimeout((()=>{a.forEach(i),s()}),15e3),c=window.setInterval((()=>{t.closed&&s(new Error("The response print window was closed."))}),100);let d=!1;function s(e){d||(d=!0,window.clearTimeout(l),window.clearInterval(c),e?o(e):n())}Promise.all([...Array.from(a,(t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(yield t.decode(),!t.complete||!t.naturalWidth||!t.naturalHeight)throw new Error("Unable to load a response print image.");a.delete(t)}catch(e){i(t)}})))),r.fonts.ready]).then((()=>s()),(()=>s(new Error("Unable to load the response print resources."))))}));exports.createResponseDownloadDocument=w,exports.createResponseDownloadHtml=u,exports.printResponseDownloadDocument=f,exports.printResponseDownloadHtml=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=window.open("","_blank");if(!e)throw new Error("Unable to open the response print window.");e.opener=null;try{yield f(yield u(t),e)}catch(t){throw e.close(),t}}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.embedInteractiveArtifacts=(e,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=t=>{var e;const n=new Set;for(const r of t){const t=document.createElement("template");t.innerHTML=r.content;for(const r of t.content.querySelectorAll("script[src]"))try{const t=new URL(null!==(e=r.getAttribute("src"))&&void 0!==e?e:"");t.username||t.password||!/^https:\/\/[a-z0-9.-]+(?::\d+)?$/i.test(t.origin)||n.add(t.origin)}catch(t){}}return[...n]};exports.embedInteractiveArtifacts=(e,n)=>{var r;if(!n.length)return e;const i=(new DOMParser).parseFromString(e,"text/html"),o=i.querySelector('meta[http-equiv="Content-Security-Policy"]');if(!o)throw new Error("Missing response document policy.");const s=["'unsafe-inline'",...t(n)].join(" ");o.setAttribute("content",o.getAttribute("content").replace("script-src 'none'",`script-src ${s}`));const c=i.createElement("style");c.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",i.head.appendChild(c);for(const t of n){const e=i.getElementById(t.placeholder);if(!e)throw new Error("Missing response artifact placeholder.");null===(r=e.closest("section"))||void 0===r||r.classList.add("pxe-interactive-section");const n=i.createElement("iframe");n.setAttribute("sandbox","allow-scripts"),n.setAttribute("referrerpolicy","no-referrer"),n.title=t.title,n.style.cssText="display:block;width:100%;height:85vh;min-height:360px;border:0;resize:vertical;overflow:auto;",n.srcdoc=t.content,e.replaceWith(n)}return`<!doctype html>\n${i.documentElement.outerHTML}`};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),t=require("react"),o=require("../../../../common/cn.js"),r=require("../../../../common/error.js"),n=require("../../../../common/api/pickaxe.js"),a=require("../../../../common/utils.js"),s=require("../../../Core/ErrorAlert.js"),c=require("../../../../hooks/pickaxe/usePickaxeContext.js"),d=require("../../../../hooks/pickaxe/useResponseContext.js"),l=require("../../common/PickaxeButton.js"),u=require("../../common/PickaxeInput.js"),m=require("./hooks/useAuthContext.js"),v=require("../../../../common/embedAuthEvents.js");const f=new Set(["Invalid verification code","Too many incorrect verification code attempts","Your token has expired, please try again","Your token is invalid or has already been used"]);exports.default=({compact:x=!1})=>{const{deploymentId:h,isEmbed:p,pickaxe:g,translations:j,setSender:k,setSenderType:b}=c.usePickaxeContext(),{setLimitData:y}=d.useResponseContext(),{isPricingAuth:q,setToken:I,setIsPricingAuth:A}=m.useAuthContext(),[C,O]=t.useState(""),[P,S]=t.useState(""),[w,E]=t.useState(!1),T=(null==g?void 0:g.studioid)||"",_=(e,i)=>{var t;return null!==(t=null==j?void 0:j[e])&&void 0!==t?t:i};return i.jsxs("form",Object.assign({className:o.default("flex w-full flex-col items-center gap-2",x&&"max-w-[328px]"),onSubmit:i=>e.__awaiter(void 0,void 0,void 0,(function*(){if(i.preventDefault(),6!==C.length||w||!T)return;const e=a.getAuthToken(T);if(e){S(""),E(!0);try{const i=yield n.pickaxeApi2.post("/auth/verify",{token:e,code:C});if(!i.data.success)throw new Error(i.data.error||_("verification-code-invalid","Invalid verification code."));a.setAuthToken(`PXE-token-${T}`,e),I(e),k(void 0),b("STUDIO_USER"),p&&v.emitPendingEmbedAuthOutcome({token:e,outcome:i.data.authOutcome,context:{deploymentId:h,pickaxeId:(null==g?void 0:g.formid)||"",studioId:T}}),q&&(A(!1),y(null))}catch(e){const i=r.default(e);S(f.has(i)?_("verification-code-invalid","Invalid verification code."):i||_("verification-code-invalid","Invalid verification code."))}finally{E(!1)}}else S(_("verification-code-session-missing","Your login request could not be found. Please resend the email."))}))},{children:[i.jsx("label",Object.assign({htmlFor:"email-verification-code",className:"font-semilight"},{children:_("enter-verification-code","Or enter the 6-digit code from the email")})),i.jsxs("div",Object.assign({className:"flex w-full items-center gap-2"},{children:[i.jsx(u.default,{id:"email-verification-code",name:"verificationCode",type:"text",inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,className:"min-w-0 flex-1 text-center text-lg tracking-[0.3em]",placeholder:"000000",value:C,"aria-invalid":!!P,"aria-describedby":P?"email-verification-code-error":void 0,onChange:e=>{O(e.target.value.replace(/\D/g,"").slice(0,6)),S("")}}),i.jsx(l.default,Object.assign({className:o.default("shrink-0",x&&"min-h-[44px]"),loadingText:_("verifying","Verifying..."),isLoading:w,isDisabled:6!==C.length},{children:_("verify","Verify")}))]})),i.jsx("div",Object.assign({id:"email-verification-code-error","aria-live":"polite"},{children:i.jsx(s.default,{error:P})}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("./useAuthContext.js"),s=require("../../../../../common/utils.js"),r=require("../../../../../common/api/pickaxe.js"),o=require("../../../../../common/error.js");exports.useAuth=()=>{const{deploymentId:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("./useAuthContext.js"),s=require("../../../../../common/utils.js"),r=require("../../../../../common/api/pickaxe.js"),o=require("../../../../../common/error.js"),n=require("../../../../../common/embedAuthEvents.js");exports.useAuth=()=>{const{deploymentId:d,isEmbed:a,pickaxe:u,translations:l,setValidationStatus:c}=i.usePickaxeContext(),{emailInput:m,redirectUrl:p,isSending:f,setIsSending:h,setIsSent:k,setIsResendDisabled:v,setIsPricingAuth:x}=t.useAuthContext();return{onSend:i=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!u)return;if(f)return;const e=m.trim().toLowerCase();if(!e)throw new Error((null==l?void 0:l["email-address-cannot-be-empty"])||"Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error((null==l?void 0:l["please-enter-valid-email-address"])||"Please enter a valid email address.");if(!u.studioid)throw new Error(`Studio ID is missing for ${u.formid}. Please contact support.`);h(!0),i&&v(!0);const t=(yield r.pickaxeApi2.post("/auth/email",Object.assign(Object.assign({pickaxeId:u.formid,studioId:u.studioid,email:e},d&&{deploymentId:d}),{redirectUrl:p}))).data;if(!t.success)throw new Error(t.error||(null==l?void 0:l["failed-to-send-sign-in-link"])||"Failed to send sign-in link.");h(!1),k(!0),i&&(yield new Promise((e=>setTimeout(e,3e4))),v(!1)),s.setAuthToken(`PXE-token-${u.studioid}`,t.token),a&&n.rememberPendingEmbedAuth({deploymentId:d,pickaxeId:u.formid,studioId:u.studioid},t.token),x(!0)}catch(e){const i=o.default(e);if(a&&"You must be invited to use this tool"===i)return void c("access_denied");alert(i)}finally{h(!1)}}))}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../../common/utils.js"),i=require("./useAuthContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../../common/utils.js"),i=require("./useAuthContext.js"),u=require("./useAuthVerify.js"),n=require("../../../../../common/embedSession.js"),r=require("../../../../../common/embedAuthEvents.js");exports.useAuthBootstrap=()=>{const{deploymentId:d,isEmbed:c,pickaxe:a,setSender:l,setSenderType:m}=t.usePickaxeContext(),{setLimitData:k}=s.useResponseContext(),{token:h,isLoggedOut:p,isPricingAuth:f,setToken:g,setIsLoggingIn:x,setIsPricingAuth:A,setIsAuthBootstrapComplete:I}=i.useAuthContext(),v=(null==a?void 0:a.studioid)||"",E=v?`PXE-token-${v}`:"",b=o.getAuthToken(v)||"",j=u.useAuthVerify({token:b,enabled:p&&!!b,setIsLoggingIn:x});e.useEffect((()=>{v&&I(!1)}),[I,v]);const q=e.useCallback((e=>{o.setAuthToken(E,e),g(e),l(void 0),m("STUDIO_USER"),f&&(A(!1),k(null))}),[E,f,A,k,l,m,g]);e.useEffect((()=>{if(!E)return;if(!j.data)return;const{success:e,token:t,authOutcome:s,error:i}=j.data;if(!e||i)return d&&(null==a?void 0:a.formid)&&b&&n.clearAuthenticatedEmbedSession({deploymentId:d,pickaxeId:a.formid,authToken:b}),o.deleteAuthToken(E),A(!1),void I(!0);t&&(q(t),c&&r.emitPendingEmbedAuthOutcome({token:t,outcome:s,context:{deploymentId:d,pickaxeId:(null==a?void 0:a.formid)||"",studioId:v}}),I(!0))}),[q,E,j.data,d,c,null==a?void 0:a.formid,I,A,b,v]),e.useEffect((()=>{var e;v&&(h?I(!0):b?j.isLoading||j.isFetching||(j.isError||j.isSuccess&&!(null===(e=j.data)||void 0===e?void 0:e.token))&&I(!0):I(!0))}),[j.data,j.isError,j.isFetching,j.isLoading,j.isSuccess,I,b,v,h])};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),s=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../Addons/Auth/hooks/useAuthContext.js"),n=require("../../../hooks/pickaxe/useDimensionContext.js"),r=require("../Addons/Document/hooks/useDocument.js"),a=require("../Addons/Scroll/hooks/useScrollContext.js"),l=require("../../../hooks/studio/useStyleFontSize.js"),u=require("../../../hooks/core/useScrollToBottomVisibility.js"),c=require("./History/index.js"),d=require("./Input.js"),f=require("../../Icons/attach-vertical.svg.js"),h=require("../../../common/cn.js"),m=require("../../../common/api/pickaxe.js"),p=require("uuid"),x=require("../../Core/StudioTip.js"),v=require("../common/ScrollToBottomButton.js"),j=require("../common/PickaxeMCPButton.js"),g=require("../../../hooks/pickaxe/useResponseContext.js"),b=require("../Addons/Navbar/NavPill.js"),k=require("../../Icons/history.svg.js");exports.default=()=>{var y,S;const{deploymentType:w,isNewChat:C,setIsNewChat:q,sessionId:I,setSessionId:D,setLastSessionId:N,pickaxeId:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),s=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../Addons/Auth/hooks/useAuthContext.js"),n=require("../../../hooks/pickaxe/useDimensionContext.js"),r=require("../Addons/Document/hooks/useDocument.js"),a=require("../Addons/Scroll/hooks/useScrollContext.js"),l=require("../../../hooks/studio/useStyleFontSize.js"),u=require("../../../hooks/core/useScrollToBottomVisibility.js"),c=require("./History/index.js"),d=require("./Input.js"),f=require("../../Icons/attach-vertical.svg.js"),h=require("../../../common/cn.js"),m=require("../../../common/api/pickaxe.js"),p=require("uuid"),x=require("../../Core/StudioTip.js"),v=require("../common/ScrollToBottomButton.js"),j=require("../common/PickaxeMCPButton.js"),g=require("../../../hooks/pickaxe/useResponseContext.js"),b=require("../Addons/Navbar/NavPill.js"),k=require("../../Icons/history.svg.js");exports.default=()=>{var y,S;const{deploymentType:w,isNewChat:C,setIsNewChat:q,sessionId:I,setSessionId:D,setLastSessionId:N,pickaxeId:T,sender:P,pickaxe:A,styles:O,isEmbed:_,mcpEnabled:F,translations:E}=s.usePickaxeContext(),{isSent:R,token:H}=i.useAuthContext(),{width:z,height:B,setDimension:L}=n.useDimensionContext(),{setDocuments:M,onFileUpload:G}=r.useDocument(),{scrollContainerRef:V,hasScrolledRef:U,isLocked:W,setIsLocked:J}=a.useScrollContext(),{isGenerating:K,messages:Q}=g.useResponseContext(),X=l.useStyleFontSize(),[Y,Z]=o.useState(0),[$,ee]=o.useState(!1),[te,oe]=o.useState(!1),se=o.useRef(null),ie=o.useRef(null),ne=o.useRef(0),[re,ae]=o.useState(null),[le,ue]=o.useState(!1),ce=(null==E?void 0:E["new-chat"])||"New chat",de="chat-input"===w&&C&&!R,fe=null!==(S=null===(y=null==A?void 0:A.documentuploadtype)||void 0===y?void 0:y.startsWith("enduserupload"))&&void 0!==S&&S,{hasScrollableContent:he,isNearBottom:me}=u.default(V);o.useEffect((()=>()=>{M([])}),[]);const pe=o.useCallback((()=>{if(!T||!P&&!H)return;const t=(o=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield m.pickaxeApi2.post("/conversation/title",Object.assign({sessionId:I},H?{studioSessionToken:H}:P?{userId:P}:{}));if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void ve(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()}),[T,P,I,H]);o.useEffect((()=>{K||C||!I||pe()}),[K,C,I,pe]),o.useEffect((()=>{if(!se.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;L(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(se.current),()=>{e.disconnect()}}),[L]);const[xe,ve]=o.useState(ce),je=(null==A?void 0:A.formtitle)||"Pickaxe",ge=(null==A?void 0:A.coverphoto)||void 0,[be,ke]=o.useState(!1);o.useEffect((()=>{const e=!de&&!_&&O.portalTheme&&(Q.filter((e=>"user"===e.role)).length>0||$||!C);ke(null!=e&&e)}),[de,_,$,C,Q,O.portalTheme]);const ye=o.useCallback((()=>{U.current=!1,J(!0),requestAnimationFrame((()=>{const e=V.current;e&&e.scrollTo({top:Math.max(0,e.scrollHeight-e.clientHeight),behavior:"smooth"})}))}),[U,V,J]);return t.jsxs("div",Object.assign({ref:se,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),fe&&(ne.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&oe(!0))},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),fe&&(ne.current-=1,0===ne.current&&oe(!1))},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(t.preventDefault(),t.stopPropagation(),oe(!1),ne.current=0,!fe)return;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(q(!1),yield G(e))}))},{children:[te&&t.jsxs("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:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(f.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:h.default(X.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==E?void 0:E["drop-files-to-upload"])||"Drop files to upload"})),t.jsx("p",Object.assign({className:h.default(X.b2,"mt-2 opacity-60 text-black")},{children:(null==E?void 0:E["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),!_&&F?t.jsx("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:t.jsx("div",Object.assign({className:"pointer-events-auto"},{children:t.jsx(j.default,{})}))})):null,de?t.jsx(d.default,{}):t.jsxs(t.Fragment,{children:[be&&t.jsxs("div",Object.assign({className:h.default("direct-link"===w?"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"===O.portalTheme?"glass-dark ":"")},{children:[t.jsx(b.NavPill,{text:je,icon:ge}),C||xe===ce?t.jsx(b.NavPill,{text:xe}):t.jsx(b.EditableNavPill,{text:xe,sessionId:I,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(I)try{yield m.pickaxeApi2.patch("/conversation/title",Object.assign({sessionId:I,name:t},H?{studioSessionToken:H}:P?{userId:P}:{})),ve(t)}catch(e){console.error("Error renaming chat:",e),alert((null==E?void 0:E["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(I&&window.confirm((null==E?void 0:E["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield m.pickaxeApi2.delete("/conversation",{data:Object.assign({sessionId:I},H?{studioSessionToken:H}:P?{userId:P}:{})}),q(!0),D(p.v4()),ve(ce)}catch(e){console.error("Error deleting chat:",e),alert((null==E?void 0:E["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===O.portalTheme}),t.jsx(x.StudioTip,Object.assign({content:E["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:t.jsx(b.HistoryPill,{icon:t.jsx(k.default,{}),onClick:()=>{D(""),N(I)}})}))]})),t.jsx(c.default,{additionalScrollHeight:Y,isForceHideInfo:B<=545||z<=350||$,isInputFocused:$,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){ie.current&&ie.current.onSubmit(t)})),smitheryAuthData:re,resubmitPrompt:()=>{ae(null),ue(!0)}}),t.jsx(v.default,{isVisible:he&&!W&&!me,bottom:Y+65,onClick:ye}),t.jsx(d.default,{ref:ie,onFocus:()=>ee(!0),onBlur:()=>ee(!1),onInputHeightChange:Z,initSmitheryAuthData:e=>ae(e),resubmitPrompt:le})]})]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../Addons/Document/hooks/useDocument.js"),i=require("../../../../common/api/pickaxe.js"),l=require("../../../../common/date.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../Addons/Document/hooks/useDocument.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),r=require("../../../../common/api/pickaxe.js"),l=require("../../../../common/date.js"),c=require("lucide-react"),d=require("../../../Icons/trash-2.svg.js"),u=require("../../../Icons/chat.svg.js"),m=require("../../../Icons/copy.svg.js"),p=require("../../../Icons/copied.svg.js"),x=require("../../../Icons/expand.svg.js"),h=require("../../../Icons/collapse.svg.js"),v=require("../../common/PickaxeMarkdown/index.js"),g=require("../../common/PickaxeMarkdown/Renderer.js"),b=require("../../common/PickaxeMessageParts/index.js"),j=require("../../../../common/cn.js");exports.default=({item:f,onDelete:y})=>{const{pickaxe:k,sender:w,colors:N,translations:C,styles:O,isRtl:_,disableCss:q,disableHtml:P,disableJs:M,setSessionId:I,setIsNewChat:R}=n.usePickaxeContext(),{token:S}=i.useAuthContext(),{setMessages:T}=a.useResponseContext(),{setDocuments:A}=o.useDocument(),[E,D]=t.useState(!1),[F,H]=t.useState(!1),[$,z]=t.useState(!1),[J,L]=t.useState(!1),[U,B]=t.useState(!1),K=t.useRef(null),[X,G]=t.useState(f.shortSummary||f.summary||(null==C?void 0:C["conversation-name"])||"Conversation name"),[Q,V]=t.useState("");t.useEffect((()=>{G(f.shortSummary||f.summary||(null==C?void 0:C["conversation-name"])||"Conversation name")}),[f.shortSummary,f.summary,C]),t.useEffect((()=>{const e=e=>{K.current&&!K.current.contains(e.target)&&D(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const W=t.useMemo((()=>f?"FORM"===f.pickaxeType?f.question?0===f.messages.length?f.question.responseParts?f.question.responseParts.length:0:f.messages.length:0:f.messages.length:0),[f]),Y=l.formatLocalDateTime(f.updatedAt,"MMM dd, yyyy hh:mm a"),Z=t.useMemo((()=>{var e,s;const t=(null==C?void 0:C["not-available"])||"n/a";if("FORM"===f.pickaxeType){if(f.messages&&0!==f.messages.length){const e=f.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const n=null!==(s=null===(e=f.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[];return U?n.map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 600; opacity: 0.9;">${e.question}</p>\n <p style="opacity: 0.8;">${e.answer||t}</p>\n</div>`)).join(""):n.map((e=>`${e.question}: ${e.answer||t}`)).join(" | ")}const n=f.messages.find((e=>"user"===e.role));return n?n.parts[0].content:""}),[f,U,C]),ee=t.useMemo((()=>{var e,s,t,n,a,o;return"FORM"===f.pickaxeType?f.messages&&0!==f.messages.length?null!==(s=null===(e=f.messages.find((e=>"assistant"===e.role)))||void 0===e?void 0:e.parts)&&void 0!==s?s:[]:null!==(n=null===(t=f.question)||void 0===t?void 0:t.responseParts)&&void 0!==n?n:[]:null!==(o=null===(a=f.messages.find((e=>"assistant"===e.role)))||void 0===a?void 0:a.parts)&&void 0!==o?o:[]}),[f]),se=t.useMemo((()=>ee.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")),[ee]),te=t.useMemo((()=>b.getSuppressedRichPreviewUrls(ee)),[ee]),ne=()=>{H(!1),V("")},ae=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(Q.trim()){z(!0);try{yield r.pickaxeApi2.patch("/conversation/title",Object.assign({sessionId:f.sessionId,name:Q},S?{studioSessionToken:S}:w?{userId:w}:{})),G(Q),H(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==C?void 0:C["failed-update-name"])||"Failed to update name.")}finally{z(!1)}}}));return s.jsxs("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:N.secondary,borderRadius:O.cornerRadius}},{children:[s.jsx("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:N.primary,color:N.text}},{children:F?s.jsxs("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[s.jsx("input",{autoFocus:!0,type:"text",value:Q,onChange:e=>V(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ae(),"Escape"===e.key&&ne()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:N.primary,borderColor:N.secondary}}),s.jsx("button",Object.assign({onClick:ae,disabled:$,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==C?void 0:C.save)||"Save"},{children:s.jsx(c.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:ne,disabled:$,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==C?void 0:C.cancel)||"Cancel"},{children:s.jsx(c.X,{className:"h-4 w-4"})}))]})):s.jsxs(s.Fragment,{children:[s.jsx("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:X})),s.jsxs("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),B(!U)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:U?(null==C?void 0:C.collapse)||"Collapse":(null==C?void 0:C.expand)||"Expand"},{children:U?s.jsx(h.default,{className:"h-4 w-4"}):s.jsx(x.default,{className:"h-4 w-4"})})),s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),D(!E)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:s.jsx(c.MoreHorizontal,{className:"h-6 w-6"})})),E&&s.jsxs("div",Object.assign({ref:K,className:"absolute right-0 top-8 w-48 rounded-xl shadow-xl z-40 border overflow-hidden animate-in fade-in zoom-in-95 duration-100",style:{backgroundColor:N.secondary,color:N.secondaryText,borderColor:N.primary}},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),V(X),H(!0),D(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:N.primary}},{children:[s.jsx(c.Pencil,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==C?void 0:C["rename-chat"])||"Rename chat"}))]})),s.jsxs("button",Object.assign({onClick:s=>{s.stopPropagation(),e.__awaiter(void 0,void 0,void 0,(function*(){if(window.confirm((null==C?void 0:C["delete-confirm"])||"Are you sure you want to delete this conversation?")){D(!1);try{yield r.pickaxeApi2.delete("/conversation",{data:Object.assign({sessionId:f.sessionId},S?{studioSessionToken:S}:w?{userId:w}:{})}),y&&y(f.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==C?void 0:C["failed-delete-conversation"])||"Failed to delete conversation.")}}}))},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95"},{children:[s.jsx(d.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==C?void 0:C["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s.jsxs("div",Object.assign({className:j.default("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",U?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:N.secondary,color:N.secondaryText}},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsx("div",Object.assign({className:j.default("w-full",U?"mb-0":"mb-2")},{children:s.jsx(v.PickaxeMarkdown,Object.assign({theme:O.theme,colors:N},_&&{rtl:!0},P&&{disableHtml:!0},M&&{disableJs:!0},q&&{disableCss:!0},{children:s.jsx(g.PickaxeMarkdownRenderer,{style:{display:"block"},className:j.default("w-full",!U&&["[&_*]:!font-semibold mb-0.5 h-5 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],U&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:Z})}))})),s.jsx("div",Object.assign({className:"w-full"},{children:s.jsx(v.PickaxeMarkdown,Object.assign({theme:O.theme,colors:N},_&&{rtl:!0},P&&{disableHtml:!0},M&&{disableJs:!0},q&&{disableCss:!0},{children:s.jsx(g.PickaxeMarkdownRenderer,{style:{display:"block"},className:j.default("w-full text-sm",!U&&["font-normal h-5 opacity-80 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],U&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:se,suppressedRichPreviewUrls:te})}))}))]})),s.jsxs("div",Object.assign({className:"flex items-center justify-between mt-4 pt-2 border-t border-transparent"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-4"},{children:[((null==k?void 0:k.chatflag)||!(null==k?void 0:k.chatflag)&&(null==k?void 0:k.enablechatresponses))&&s.jsxs("div",Object.assign({className:"flex items-center gap-1.5 opacity-70 hover:opacity-100 cursor-pointer transition-opacity",onClick:e=>{var s;e.stopPropagation(),s=f.sessionId,A([]),T([]),R(!1),I(s)},title:(null==C?void 0:C["open-chat"])||"Open Chat"},{children:[s.jsx(u.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"text-sm font-medium"},{children:W}))]})),s.jsx("button",Object.assign({className:"transition-colors "+(J?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(se),L(!0),setTimeout((()=>{L(!1)}),2e3)},title:J?(null==C?void 0:C.copied)||"Copied!":(null==C?void 0:C["copy-assistant-message"])||"Copy assistant message"},{children:J?s.jsx(p.default,{className:"h-4 w-4",style:{color:N.accent},fill:N.accent}):s.jsx(m.default,{className:"h-4 w-4"})}))]})),s.jsx("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:Y}))]}))]}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),n=require("react-dom"),r=require("uuid"),s=require("file-saver"),i=require("../../../common/responseDownloadDocx.js"),l=require("../../../common/responseDownloadImages.js"),a=require("../../../common/responseDownloadHtml.js"),u=require("../../../common/responseDownloadArtifacts.js"),d=require("../../../common/responseArtifactSnapshot.js"),c=require("../Addons/Artifact/hooks/useArtifactContext.js"),f=require("../Addons/Artifact/hooks/useArtifactData.js"),p=require("../Addons/Auth/hooks/useAuthContext.js"),m=require("../../../hooks/pickaxe/usePickaxeContext.js"),x=require("../../../hooks/core/useOutsideAlerter.js"),v=require("../../Icons/download.svg.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),n=require("react-dom"),r=require("uuid"),s=require("file-saver"),i=require("../../../common/responseDownloadDocx.js"),l=require("../../../common/responseDownloadImages.js"),a=require("../../../common/responseDownloadHtml.js"),u=require("../../../common/responseDownloadArtifacts.js"),d=require("../../../common/responseArtifactSnapshot.js"),c=require("../Addons/Artifact/hooks/useArtifactContext.js"),f=require("../Addons/Artifact/hooks/useArtifactData.js"),p=require("../Addons/Auth/hooks/useAuthContext.js"),m=require("../../../hooks/pickaxe/usePickaxeContext.js"),x=require("../../../hooks/core/useOutsideAlerter.js"),v=require("../../Icons/download.svg.js"),y=require("../../Core/Menu/index.js"),h=require("../../Core/Menu/List.js");function w(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=w(s);const g=[{extension:"txt",label:"TXT",mimeType:"text/plain;charset=utf-8"},{extension:"md",label:"Markdown (.md)",mimeType:"text/markdown;charset=utf-8"},{extension:"html",label:"HTML (.html)",mimeType:"text/html;charset=utf-8"},{extension:"pdf",label:"PDF"},{extension:"docx",label:"DOCX"}];exports.default=({color:s,text:w,disabled:j=!1})=>{const{translations:k,colors:A,styles:D,isRtl:q,sender:C,senderType:O,pickaxe:R}=m.usePickaxeContext(),{artifacts:T=[]}=c.useArtifactContext(),{token:S}=p.useAuthContext(),P=f.useArtifactData(),[_,E]=o.useState(""),[H,I]=o.useState(!1),[M,N]=o.useState(),[$,B]=o.useState(!1),F=o.useRef(!1),L=o.useRef(null),K=o.useRef(null),U=o.useRef([]),X=o.useRef(0),W=(null==k?void 0:k.download)||"Download",z=j||$||!w.trim();o.useEffect((()=>{E(`response-download-${r.v4()}`)}),[]),o.useEffect((()=>{z&&I(!1)}),[z]),o.useEffect((()=>{H&&L.current&&N(getComputedStyle(L.current).fontFamily)}),[H,D.font]),x.useOutsideAlerter({ref:[L,K],callback:()=>I(!1)});const G=()=>{var e;I(!1),null===(e=L.current)||void 0===e||e.focus({preventScroll:!0})},J=e=>{var t;if(!z)if("Escape"===e.key&&H)e.preventDefault(),e.stopPropagation(),G();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();const o=U.current.indexOf(e.currentTarget),n="ArrowDown"===e.key?1:-1,r=g.length,s=-1===o?1===n?0:r-1:(o+n+r)%r;X.current=s,I(!0),null===(t=U.current[s])||void 0===t||t.focus({preventScroll:!0})}else"Tab"===e.key&&I(!1)},Q=e=>{e.relatedTarget===L.current||U.current.some((t=>t===e.relatedTarget))||I(!1)};return t.jsxs(y.default,Object.assign({id:_,className:"h-4 w-4 shrink-0",isOpen:H&&!z,onChange:I,closeOnSelect:!1,closeOnClickOutside:!1},{children:[t.jsx("button",Object.assign({ref:L,id:_||void 0,type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-30",style:{color:s},title:W,"aria-label":W,"aria-haspopup":"menu","aria-busy":$,"aria-expanded":H&&!z,"aria-controls":H&&!z?`${_}-menu`:void 0,disabled:z,onClick:e=>{e.stopPropagation(),X.current=0,I((e=>!e))},onKeyDown:J,onBlur:Q},{children:t.jsx(v.default,{className:"h-4 w-4 shrink-0","aria-hidden":"true"})})),_&&!z&&n.createPortal(t.jsx("div",Object.assign({ref:K,style:{fontFamily:M},dir:q?"rtl":"ltr"},{children:t.jsx(h.default,Object.assign({id:`${_}-menu`,role:"menu",align:"right",width:"auto",className:"p-1 text-sm",style:{backgroundColor:A.primary,color:A.text,maxWidth:"calc(100vw - 32px)"},imperativeModeOnly:!0,afterShow:()=>{var e;return null===(e=U.current[X.current])||void 0===e?void 0:e.focus({preventScroll:!0})}},{children:g.map(((o,n)=>t.jsx("button",Object.assign({ref:e=>{U.current[n]=e},type:"button",role:"menuitem",tabIndex:-1,className:"rounded-sm px-3 py-2 text-left hover:bg-black/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px]",onClick:t=>{((t,o)=>{e.__awaiter(void 0,void 0,void 0,(function*(){var n;if(t.stopPropagation(),z||F.current)return;let r;G();try{const t=u.findResponseArtifacts(w);let s;if(t.length){if(F.current=!0,B(!0),"pdf"===o.extension){if(r=null!==(n=window.open("","_blank"))&&void 0!==n?n:void 0,!r)throw new Error("Unable to open the print window.");r.opener=null;const e=r.document.createElement("p");e.textContent=(null==k?void 0:k.loading)||"Loading...",e.setAttribute("role","status"),e.style.cssText="margin:32px;font:16px system-ui,sans-serif",r.document.body.appendChild(e)}s=yield u.prepareResponseArtifactDownload(w,t,(t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=T.find((e=>e.id===t.id&&e.version===t.version));return null!=e?e:P.mutateAsync({artifactId:t.id,version:t.version,studioId:null==R?void 0:R.studioid,senderType:O,sender:C||void 0,studioSessionToken:S||void 0})}))),o.extension,(e=>d.renderResponseArtifactHtml(e,"pdf"===o.extension||"docx"===o.extension,r)))}if("docx"===o.extension){F.current=!0,B(!0);const e=yield i.createResponseDownloadDocx(w,s);return void b.default(e,"response.docx")}if("pdf"===o.extension)return F.current=!0,B(!0),void(s?yield a.printResponseDownloadDocument(s,r):yield a.printResponseDownloadHtml(w));"html"===o.extension&&(F.current=!0,B(!0));let c=null!=s?s:"html"===o.extension?yield a.createResponseDownloadHtml(w):w;"html"===o.extension&&(F.current=!0,B(!0),c=yield l.embedResponseDownloadHtmlImages(c));const f=new Blob([c],{type:o.mimeType});b.default(f,`response.${o.extension}`)}catch(e){console.error("Response download failed",{format:o.extension,error:e}),null==r||r.close(),window.alert((null==k?void 0:k["something-went-wrong"])||"Something went wrong.")}finally{F.current=!1,B(!1)}}))})(t,o)},onKeyDown:J,onBlur:Q},{children:o.label}),o.extension)))}))})),document.body)]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("../../../hooks/core/useHover.js"),s=require("../../../hooks/core/usePressed.js"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("framer-motion"),n=require("../../../common/utils.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("../../../hooks/core/useHover.js"),s=require("../../../hooks/core/usePressed.js"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("framer-motion"),n=require("../../../common/utils.js"),d=require("../../../common/embedSession.js"),a=require("../Addons/Auth/hooks/useAuthContext.js"),u=require("../../Icons/logout.svg.js"),c=require("./PickaxeSimpleButton.js"),l=require("../../../common/embedAuthEvents.js");exports.default=({tip:m})=>{const{colors:x,styles:j,pickaxe:k,deploymentId:v,isEmbed:h}=i.usePickaxeContext(),{token:p}=a.useAuthContext(),b=o.useHover(),{isHover:g}=b,y=e.__rest(b,["isHover"]),f=s.usePressed(),{isActive:q}=f,I=e.__rest(f,["isActive"]);return t.jsxs("div",Object.assign({className:"relative"},{children:[t.jsx(c.default,Object.assign({className:"h-8 w-8 shrink-0 items-center justify-center rounded-full duration-300 ease-in-out",color:x.accent,style:{backgroundColor:q?x.accent+"30":g?x.accent+"10":void 0},onClick:()=>{p&&v&&(null==k?void 0:k.formid)&&d.clearAuthenticatedEmbedSession({deploymentId:v,pickaxeId:k.formid,authToken:p});const e=`PXE-token-${null==k?void 0:k.studioid}`;localStorage.getItem(e)?localStorage.removeItem(`PXE-token-${null==k?void 0:k.studioid}`):n.deleteCookie(e),h&&(null==k?void 0:k.studioid)&&k.formid&&l.emitEmbedLogout({deploymentId:v,pickaxeId:k.formid,studioId:k.studioid}),location.reload()},reversed:!0},y,I,{children:t.jsx(u.default,{className:"h-5 w-5 shrink-0"})})),t.jsx(r.AnimatePresence,{children:g&&!!m&&t.jsx(r.motion.div,Object.assign({className:"absolute right-0 top-10 z-10 w-max rounded text-xs font-semibold",style:{background:x.accent,color:x.accentText,padding:"0.5rem 0.75rem",fontWeight:500,borderRadius:j.cornerRadius},initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2,ease:"easeInOut"}},{children:m}))})]}))};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type EmbedAuthOutcome = "signup" | "login";
|
|
2
|
+
export type EmbedAuthMethod = "email" | "sso";
|
|
3
|
+
export type EmbedAuthEvent = {
|
|
4
|
+
event: EmbedAuthOutcome;
|
|
5
|
+
method: EmbedAuthMethod;
|
|
6
|
+
} | {
|
|
7
|
+
event: "logout";
|
|
8
|
+
};
|
|
9
|
+
type EmbedAuthEventContext = {
|
|
10
|
+
deploymentId?: string;
|
|
11
|
+
pickaxeId: string;
|
|
12
|
+
studioId: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const rememberPendingEmbedAuth: (context: EmbedAuthEventContext, token: string) => void;
|
|
15
|
+
export declare const emitPendingEmbedAuthOutcome: ({ token, outcome, context, }: {
|
|
16
|
+
token: string;
|
|
17
|
+
outcome?: EmbedAuthOutcome | undefined;
|
|
18
|
+
context: EmbedAuthEventContext;
|
|
19
|
+
}) => void;
|
|
20
|
+
export declare const emitSsoEmbedAuthOutcome: ({ token, outcome, context, }: {
|
|
21
|
+
token: string;
|
|
22
|
+
outcome?: EmbedAuthOutcome | undefined;
|
|
23
|
+
context: EmbedAuthEventContext;
|
|
24
|
+
}) => void;
|
|
25
|
+
export declare const emitEmbedLogout: (context: EmbedAuthEventContext) => void;
|
|
26
|
+
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Does not mount the chat renderer, run response scripts, or fetch linked content.
|
|
4
4
|
* Code fences stay literal; only the export gets these stricter HTML rules.
|
|
5
5
|
*/
|
|
6
|
-
export declare const createResponseDownloadHtml: (text: string) => string
|
|
6
|
+
export declare const createResponseDownloadHtml: (text: string) => Promise<string>;
|
|
7
7
|
/** All assembled content, including artifact snapshots, crosses this boundary. */
|
|
8
8
|
export declare const createResponseDownloadDocument: (rendered: string, preserveArtifactStyles?: boolean) => string;
|
|
9
9
|
/** Opens a print copy from the user's click without changing the live response. */
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { SetState } from "../../../../../types/common";
|
|
2
2
|
import { UseQueryResult } from "@tanstack/react-query";
|
|
3
|
+
import type { EmbedAuthOutcome } from "../../../../../common/embedAuthEvents";
|
|
3
4
|
type QueryResponse = {
|
|
4
5
|
success: boolean;
|
|
5
6
|
token: string;
|
|
7
|
+
authOutcome?: EmbedAuthOutcome;
|
|
6
8
|
error?: string;
|
|
7
9
|
};
|
|
8
10
|
interface UseAuthVerifyQueryProps {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=new Map,t=new Set,n=({deploymentId:e,pickaxeId:t,studioId:n})=>[n,t,e||""].map((e=>encodeURIComponent(e))).join(":"),o=e=>`PXE-pending-auth-${e}`,d=e=>`PXE-emitted-auth-${e}`,r=(e,t)=>{if("undefined"==typeof window)return;const n=`pickaxe:${e.event}`,o=Object.assign(Object.assign({},e),t);window.parent===window?window.dispatchEvent(new CustomEvent(n,{detail:o})):window.parent.postMessage({type:n,detail:o},(()=>{if("undefined"==typeof document||!document.referrer)return"";try{return new URL(document.referrer).origin}catch(e){return""}})()||"*")},i=(t,d)=>{if("undefined"==typeof window)return;const r=n(t);e.set(r,d);try{window.localStorage.setItem(o(r),d)}catch(e){}},a=({token:i,outcome:a,context:c})=>{if("undefined"==typeof window||!a)return;const w=n(c),l=`${w}:${i}`;let m=e.get(w);try{const e=o(w);if(m=window.localStorage.getItem(e)||m,m!==i)return;window.localStorage.removeItem(e),window.localStorage.setItem(d(w),i)}catch(e){}m!==i||t.has(l)||(e.delete(w),t.add(l),r({event:a,method:"email"},c))},c=i=>{const a=n(i);e.delete(a),t.clear();try{window.localStorage.removeItem(o(a)),window.localStorage.removeItem(d(a))}catch(e){}r({event:"logout"},i)};export{c as emitEmbedLogout,a as emitPendingEmbedAuthOutcome,i as rememberPendingEmbedAuth};
|
|
@@ -31,6 +31,19 @@ const e=String.raw`async (source) => {
|
|
|
31
31
|
'transform', 'transform-origin', 'transform-box',
|
|
32
32
|
'x', 'y', 'cx', 'cy', 'r', 'rx', 'ry', 'd'
|
|
33
33
|
];
|
|
34
|
+
// Mermaid HTML labels are static text inside foreignObject. Preserve their
|
|
35
|
+
// measured layout, but never serialize active elements or external resources.
|
|
36
|
+
const labelTags = new Set(['div', 'span', 'p', 'br', 'b', 'strong', 'i', 'em', 'u', 's', 'small', 'sub', 'sup', 'a']);
|
|
37
|
+
const labelProperties = [
|
|
38
|
+
'display', 'visibility', 'opacity', 'box-sizing', 'width', 'height',
|
|
39
|
+
'min-width', 'max-width', 'min-height', 'max-height',
|
|
40
|
+
'margin-top', 'margin-right', 'margin-bottom', 'margin-left',
|
|
41
|
+
'padding-top', 'padding-right', 'padding-bottom', 'padding-left',
|
|
42
|
+
'color', 'background-color', 'font-family', 'font-size', 'font-weight',
|
|
43
|
+
'font-style', 'line-height', 'letter-spacing', 'word-spacing',
|
|
44
|
+
'white-space', 'text-align', 'text-decoration', 'text-transform',
|
|
45
|
+
'vertical-align', 'overflow-wrap', 'word-break', 'direction'
|
|
46
|
+
];
|
|
34
47
|
sources.forEach((node, index) => {
|
|
35
48
|
const target = targets[index];
|
|
36
49
|
const tag = node.localName.toLowerCase();
|
|
@@ -38,7 +51,26 @@ const e=String.raw`async (source) => {
|
|
|
38
51
|
target.remove();
|
|
39
52
|
return;
|
|
40
53
|
}
|
|
41
|
-
if (
|
|
54
|
+
if (node.namespaceURI === 'http://www.w3.org/1999/xhtml') {
|
|
55
|
+
if (!node.closest('foreignObject') || !labelTags.has(tag))
|
|
56
|
+
throw new Error('Unsupported SVG HTML label');
|
|
57
|
+
const computed = getComputedStyle(node);
|
|
58
|
+
if (computed.backgroundImage !== 'none')
|
|
59
|
+
throw new Error('SVG HTML label requires an external resource');
|
|
60
|
+
for (const pseudo of ['::before', '::after']) {
|
|
61
|
+
const content = getComputedStyle(node, pseudo).content;
|
|
62
|
+
if (content && content !== 'none' && content !== 'normal' && content !== '""')
|
|
63
|
+
throw new Error('Unsupported SVG HTML label decoration');
|
|
64
|
+
}
|
|
65
|
+
for (const attr of Array.from(target.attributes)) target.removeAttributeNode(attr);
|
|
66
|
+
labelProperties.forEach(property => {
|
|
67
|
+
const value = computed.getPropertyValue(property);
|
|
68
|
+
if (value) target.style.setProperty(property, safeValue(value));
|
|
69
|
+
});
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
if (node.namespaceURI !== 'http://www.w3.org/2000/svg')
|
|
73
|
+
throw new Error('Unsupported SVG namespace');
|
|
42
74
|
// Referenced symbols inherit styles through a browser-created shadow tree.
|
|
43
75
|
// Do not silently flatten them with the wrong colors or missing geometry.
|
|
44
76
|
if (tag === 'use') throw new Error('SVG symbol instances cannot be captured');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t}from"../_virtual/_tslib.js";import{createResponseDownloadDocument as e}from"./responseDownloadHtml.js";import{embedResponseDownloadImages as o}from"./responseDownloadImages.js";const
|
|
1
|
+
import{__awaiter as t}from"../_virtual/_tslib.js";import{createResponseDownloadDocument as e}from"./responseDownloadHtml.js";import{embedResponseDownloadImages as o}from"./responseDownloadImages.js";import{artifactStyleProperties as r}from"./responseArtifactStyles.js";const n=(n,i)=>t(void 0,void 0,void 0,(function*(){var t;let a=e(`<div class="pxe-export-artifact">${n}</div>`,!0);const l=document.createElement("template");l.innerHTML=a;const c=yield o(l.content,"docx");for(const e of l.content.querySelectorAll("img")){if(c.has(e))continue;const o=document.createElement("span");o.textContent=`⚠ ${(null===(t=e.getAttribute("alt"))||void 0===t?void 0:t.trim())||"[…]"}`,e.replaceWith(o)}a=`<!doctype html>\n${l.innerHTML}`;const s=document.createElement("iframe");s.setAttribute("sandbox","allow-same-origin"),s.setAttribute("aria-hidden","true"),s.tabIndex=-1,s.style.cssText="position:fixed;left:-10000px;top:0;width:720px;height:600px;border:0;pointer-events:none";try{yield new Promise(((t,e)=>{const o=setTimeout((()=>e(new Error("Word snapshot timed out."))),5e3);s.onload=()=>{clearTimeout(o),t()},s.onerror=()=>{clearTimeout(o),e(new Error("Word snapshot failed."))},s.srcdoc=a,document.body.appendChild(s)}));const t=s.contentDocument,e=s.contentWindow,o=null==t?void 0:t.querySelector("main");if(!t||!e||!o)throw new Error("Word snapshot unavailable.");const n=t.createElement("style");n.textContent="body > main{display:flow-root;width:720px;max-width:none;padding:0;margin:0}\n.pxe-export-artifact{overflow:visible}\n.pxe-export-artifact:has(tr > :nth-child(6)) > div{min-width:0}\ntable{width:100%;table-layout:fixed} pre{white-space:pre-wrap;overflow-wrap:anywhere}\n*{animation:none!important;transition:none!important}",t.head.appendChild(n),t.querySelectorAll("details").forEach((t=>{t.open=!0}));const l=o.cloneNode(!0),c=[o,...o.querySelectorAll("*")],d=[l,...l.querySelectorAll("*")];c.forEach(((t,o)=>{const n=d[o],i=e.getComputedStyle(t);n.removeAttribute("style");for(const t of[...r,"direction","unicode-bidi","white-space","overflow-wrap","table-layout"])n.style.setProperty(t,i.getPropertyValue(t));"TABLE"===t.tagName&&(n.style.width="100%"),"IMG"===t.tagName&&(n.style.maxWidth="100%",n.style.height="auto")})),l.style.width="720px",o.replaceWith(l),t.querySelectorAll("style").forEach((t=>t.remove())),t.body.style.margin="0",yield Promise.all(Array.from(l.querySelectorAll("img"),(t=>t.decode())));const h=Math.ceil(Math.max(l.scrollWidth,l.getBoundingClientRect().width)),m=Math.ceil(l.getBoundingClientRect().height);if(h>1440||!m||m>16e3)throw new Error("Artifact is too large for a readable Word picture.");l.setAttribute("xmlns","http://www.w3.org/1999/xhtml");const p=(new XMLSerializer).serializeToString(l);if(p.length>1e7)throw new Error("Word snapshot is too large.");const w=l.getBoundingClientRect().top,g=[],u=t.createTreeWalker(l,NodeFilter.SHOW_TEXT);for(;u.nextNode();){const e=t.createRange();e.selectNodeContents(u.currentNode);for(const t of Array.from(e.getClientRects()))t.height&&g.push({top:t.top-w,bottom:t.bottom-w})}l.querySelectorAll("tr,img").forEach((t=>{const e=t.getBoundingClientRect();e.height<=800&&g.push({top:e.top-w,bottom:e.bottom-w})}));const f=[];let y=0;for(let e=0;e<m;){let o=Math.min(m,e+800);if(o<m)for(let t=0;t<g.length;t++){const t=g.find((t=>t.top+1<o&&t.bottom-1>o));if(!t||t.top<=e)break;o=Math.ceil(t.top)}if(o<=e)throw new Error("Unable to paginate artifact picture.");const r=`<svg xmlns="http://www.w3.org/2000/svg" width="${h}" height="${o-e}" viewBox="0 ${e} ${h} ${o-e}"><foreignObject x="0" y="0" width="${h}" height="${m}">${p}</foreignObject></svg>`,n=new Image;yield new Promise(((t,e)=>{const o=setTimeout((()=>i(!1)),5e3),i=r=>{clearTimeout(o),n.onload=n.onerror=null,r?t():e(new Error("Unable to draw Word artifact picture."))};n.onload=()=>i(!0),n.onerror=()=>i(!1),n.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(r)}`}));const a=document.createElement("canvas");a.width=2*h,a.height=2*(o-e);const l=a.getContext("2d");if(!l)throw new Error("Word image capture unavailable.");l.fillStyle="white",l.fillRect(0,0,a.width,a.height),l.drawImage(n,0,0,a.width,a.height);const c=a.toDataURL("image/png");if(y+=c.length,y>1e7)throw new Error("Word artifact pictures are too large.");const s=t.createElement("img");s.src=c,s.width=h,s.height=o-e,s.alt=i;const d=t.createElement("p");d.appendChild(s),f.push(d.outerHTML),a.width=a.height=0,n.removeAttribute("src"),e=o}return f.join("")}finally{s.remove()}}));export{n as createResponseArtifactWordImages};
|
|
@@ -1 +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
|
|
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 l}from"./responseStandaloneSvg.js";import{createResponseMermaidImage as c}from"./responseMermaid.js";import{embedInteractiveArtifacts as d}from"./responseInteractiveArtifactHtml.js";import{createResponseDownloadDocument as p,createResponseDownloadHtml as m}from"./responseDownloadHtml.js";const f=(t,e)=>{var r;const n=/<!--[\s\S]*?(?:-->|$)|<!\[CDATA\[[\s\S]*?(?:\]\]>|$)|<\/?([a-z][\w:-]*)(?:[^>"']|"[^"]*"|'[^']*')*>/gi;n.lastIndex=e;let o,i=0;for(;null!==(o=n.exec(t));){const e=null===(r=o[1])||void 0===r?void 0:r.toLowerCase();if(!e)continue;const a=o[0].startsWith("</");if("artifact"===e){if(a?i--:/\/\s*>$/.test(o[0])||i++,0===i)return n.lastIndex}else if(!a&&/^(script|style|textarea|title|xmp|iframe|noembed|noframes)$/.test(e)){const r=new RegExp(`</${e}\\s*>`,"gi");if(r.lastIndex=n.lastIndex,!r.exec(t))break;n.lastIndex=r.lastIndex}}return t.length},u=t=>{if(!/<artifact\b/i.test(t))return[];const a=[];r(e(n,{remarkPlugins:[o],rehypePlugins:[i],components:{artifact:({node:e})=>{var r,n,o;const i=null===(r=e.position)||void 0===r?void 0:r.start.offset,s=String(null!==(n=e.properties.dataId)&&void 0!==n?n:""),l=Number(null!==(o=e.properties.dataVersion)&&void 0!==o?o:1);if(null==i||!s||!Number.isInteger(l)||l<1)throw new Error("Invalid response artifact reference.");return a.push({id:s,version:l,start:i,end:f(t,i)}),null}}},t));let s=0;return a.sort(((t,e)=>t.start-e.start)).filter((t=>!(t.start<s)&&(s=t.end,!0)))},v=t=>t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,"""),h=e=>t(void 0,void 0,void 0,(function*(){var t,r;const n=document.createElement("template");return n.innerHTML=yield m(e),null!==(r=null===(t=n.content.querySelector("main"))||void 0===t?void 0:t.innerHTML)&&void 0!==r?r:""})),x=(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}>${v(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 u=0;for(const d of r){const r=yield n(d);if(r.id!==d.id||r.version!==d.version||r.status&&"finished"!==r.status)throw new Error("Response artifact is not ready.");const p=e.slice(u,d.start);if(m.push(t?p:yield h(p)),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=yield h(r.content);break;case"text/csv":t=x(r.content,",");break;case"text/tab-separated-values":t=x(r.content,"\t");break;case"application/vnd.pxe.mermaid":t=yield c(r.content,r.title);break;case"image/svg+xml":t=yield l(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>${v(r.content)}</code></pre>`;break;default:throw new Error(`Artifact export is not supported for ${r.type}.`)}m.push(`<section><h2>${v(r.title)}</h2><div class="pxe-export-artifact">${t}</div></section>`)}u=d.end}return m.push(t?e.slice(u):yield h(e.slice(u))),t?m.join(""):d(p(m.join("\n"),"html"===o||"pdf"===o),f)}));export{u as findResponseArtifacts,g as prepareResponseArtifactDownload};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../_virtual/_tslib.js";import{Document as t,Paragraph as r,Packer as n,TextRun as i,Tab as a,HeadingLevel as s,BorderStyle as o,UnderlineType as l,ImageRun as c,ExternalHyperlink as d,TableRow as u,TableCell as m,WidthType as g,Table as h,LevelFormat as p,AlignmentType as b}from"docx";import{createResponseDownloadHtml as f}from"./responseDownloadHtml.js";import{embedResponseDownloadImages as w}from"./responseDownloadImages.js";const A=720,N=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DD","DETAILS","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SUMMARY","TABLE","UL"]),O=e=>{if(e&&/^(https?:|mailto:|tel:)/i.test(e.trim()))try{return new URL(e.trim()).href}catch(e){return}},E=(e,t)=>{const r=Object.assign({},t);switch(e.tagName){case"STRONG":case"B":r.bold=!0;break;case"EM":case"I":r.italics=!0;break;case"DEL":case"S":case"STRIKE":r.strike=!0;break;case"U":r.underline={type:l.SINGLE};break;case"CODE":case"KBD":case"SAMP":r.font="Courier New";break;case"SUP":r.superScript=!0;break;case"SUB":r.subScript=!0}return r},I=(I,
|
|
1
|
+
import{__awaiter as e}from"../_virtual/_tslib.js";import{Document as t,Paragraph as r,Packer as n,TextRun as i,Tab as a,HeadingLevel as s,BorderStyle as o,UnderlineType as l,ImageRun as c,ExternalHyperlink as d,TableRow as u,TableCell as m,WidthType as g,Table as h,LevelFormat as p,AlignmentType as b}from"docx";import{createResponseDownloadHtml as f}from"./responseDownloadHtml.js";import{embedResponseDownloadImages as w}from"./responseDownloadImages.js";const A=720,N=new Set(["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DD","DETAILS","DIV","DL","DT","FIGCAPTION","FIGURE","FOOTER","H1","H2","H3","H4","H5","H6","HEADER","HR","LI","MAIN","NAV","OL","P","PRE","SECTION","SUMMARY","TABLE","UL"]),O=e=>{if(e&&/^(https?:|mailto:|tel:)/i.test(e.trim()))try{return new URL(e.trim()).href}catch(e){return}},E=(e,t)=>{const r=Object.assign({},t);switch(e.tagName){case"STRONG":case"B":r.bold=!0;break;case"EM":case"I":r.italics=!0;break;case"DEL":case"S":case"STRIKE":r.strike=!0;break;case"U":r.underline={type:l.SINGLE};break;case"CODE":case"KBD":case"SAMP":r.font="Courier New";break;case"SUP":r.superScript=!0;break;case"SUB":r.subScript=!0}return r},I=(I,y)=>e(void 0,void 0,void 0,(function*(){const e=document.createElement("template");e.innerHTML=null!=y?y:yield f(I);const j=e.content.querySelector("main");if(!j)throw new Error("Unable to prepare the response document.");const T=yield w(j,"docx"),v=new Map;for(const e of T){const t=e.getAttribute("src")||"";if(t.length>1e7)throw new Error("Artifact image too large.");const r=Uint8Array.from(atob(t.slice(22)),(e=>e.charCodeAt(0))),n=new DataView(r.buffer);if(r.length<24||2303741511!==n.getUint32(0)||218765834!==n.getUint32(4)||1229472850!==n.getUint32(12))throw new Error("Invalid artifact image.");const i=n.getUint32(16),a=n.getUint32(20);if(!i||!a||i*a>16e6)throw new Error("Artifact image dimensions are unsupported.");yield new Promise(((e,r)=>{const n=new Image,s=t=>{clearTimeout(o),n.onload=n.onerror=null,n.removeAttribute("src"),t?e():r(new Error("Unable to read artifact image."))},o=setTimeout((()=>s(!1)),5e3);n.onload=()=>s(n.naturalWidth===i&&n.naturalHeight===a),n.onerror=()=>s(!1),n.src=t}));const s=Number(e.getAttribute("width")),o=s>0?Math.min(1,s/i):1;v.set(e,{data:r,width:i*o,height:a*o})}const D=[],S=(e,t,r)=>Array.from(e).flatMap((e=>{var n;if(3===e.nodeType){const r=e.textContent||"";return[new i(Object.assign(Object.assign({},t),{text:(null===(n=e.parentElement)||void 0===n?void 0:n.closest("code"))?r:r.replace(/[\t\n\r ]+/g," ")}))]}if(1!==e.nodeType)return[];const a=e,s=E(a,t);if("BR"===a.tagName)return[new i(Object.assign(Object.assign({},t),{break:1}))];if("IMG"===a.tagName){const e=v.get(a);if(e){const t=Math.min(1,Math.max(1,r/15)/e.width,900/e.height);return[new c(Object.assign(Object.assign({type:"png",data:e.data},a.getAttribute("alt")?{altText:{name:a.getAttribute("alt")||""}}:{}),{transformation:{width:e.width*t,height:e.height*t}}))]}const n=O(a.getAttribute("src")),s=a.getAttribute("alt")||n||"[…]",o=[new i(Object.assign(Object.assign({},t),{text:s}))];return n&&!a.closest("a")?[new d({link:n,children:o})]:o}const o="A"===a.tagName?O(a.getAttribute("href")):void 0,u=S(a.childNodes,o?Object.assign(Object.assign({},s),{color:"174EA6",underline:{type:l.SINGLE}}):s,r);return o?[new d({link:o,children:u})]:u})),H=(e,t,n={})=>{const i=t.marker&&!t.marker.used?t.marker:void 0;return i&&(i.used=!0),new r(Object.assign(Object.assign(Object.assign({children:e,spacing:{after:160},widowControl:!0},t.indent?{indent:Object.assign({left:t.indent},i?{hanging:360}:{})}:{}),null==i?void 0:i.properties),n))},k=(e,t)=>{var r;const n="OL"===e.tagName;let i="",a=!1;const s=e=>{i=`response-list-${D.length}`,a=0===e,D.push({reference:i,levels:[{level:0,format:p.DECIMAL,text:a?"0.":"%1.",start:a?1:e,alignment:b.LEFT}]})},o=e.hasAttribute("reversed"),l=Array.from(e.children).filter((e=>"LI"===e.tagName)),c=Number.parseInt(e.getAttribute("start")||"",10);let d=Number.isFinite(c)?c:o?l.length:1;n&&s(d);const u=[];for(const l of Array.from(e.children)){if("LI"!==l.tagName){u.push(...M([l],t));continue}const e=Number.parseInt(l.getAttribute("value")||"",10);n&&Number.isFinite(e)&&(d=e),n&&(o||a||0===d||Number.isFinite(e))&&s(d),d+=o?-1:1;const c=Object.assign(Object.assign({},t),{indent:Math.min(t.indent+720,5760),marker:{used:!1,properties:n?{numbering:{reference:i,level:0}}:{bullet:{level:0}}}}),m=M(l.childNodes,c);(null===(r=c.marker)||void 0===r?void 0:r.used)||m.unshift(H([],c)),u.push(...m)}return u},L=(e,t)=>{const n=[];let i=0;const a=Array.from(e.querySelectorAll("tr")).filter((t=>t.closest("table")===e)).map(((e,t)=>{let r=0;return{row:e,cells:Array.from(e.children).filter((e=>"TD"===e.tagName||"TH"===e.tagName)).map((e=>{for(;n[r]>t;)r++;const a=t=>Math.min(100,Math.max(1,parseInt(e.getAttribute(t)||"1",10)||1)),s=a("colspan"),o=a("rowspan"),l=r;for(let e=0;e<s;e++)n[r++]=t+o;return i=Math.max(i,r),{cell:e,start:l,columnSpan:s,rowSpan:o}}))}})),s=e=>Math.floor(e*t/i),o=Array.from({length:i},((e,t)=>s(t+1)-s(t))),l=a.flatMap((({row:e,cells:t})=>{var n;return t.length?[new u({tableHeader:"THEAD"===(null===(n=e.parentElement)||void 0===n?void 0:n.tagName)||t.every((({cell:e})=>"TH"===e.tagName)),children:t.map((({cell:e,start:t,columnSpan:n,rowSpan:i})=>{const a=s(t+n)-s(t),o=M(e.childNodes,{indent:0,width:Math.max(1,a-200),run:{bold:"TH"===e.tagName}});return o[o.length-1]instanceof r||o.push(new r("")),new m(Object.assign({children:o,columnSpan:n,rowSpan:i,width:{size:a,type:g.DXA},margins:{top:80,bottom:80,left:100,right:100}},"TH"===e.tagName?{shading:{fill:"F0F0F0"}}:{}))}))})]:[]})),c=Array.from(e.children).filter((e=>"CAPTION"===e.tagName));return l.length?[...M(c,{indent:0,width:t,run:{}}),new h({rows:l,width:{size:t,type:g.DXA},columnWidths:o})]:M(e.childNodes,{indent:0,width:t,run:{}})},M=(e,t)=>{const r=[];let n=[];const l=()=>{n.some((e=>{var t;return(null===(t=e.textContent)||void 0===t?void 0:t.trim())||1===e.nodeType&&/^(BR|IMG)$/.test(e.tagName)||1===e.nodeType&&e.querySelector("br,img")}))&&r.push(H(S(n,t.run,t.width-t.indent),t)),n=[]};for(const c of Array.from(e)){if(1!==c.nodeType||!N.has(c.tagName)){1===c.nodeType&&Array.from(c.children).some((e=>N.has(e.tagName)))?(l(),r.push(...M(c.childNodes,Object.assign(Object.assign({},t),{run:E(c,t.run)})))):n.push(c);continue}l();const e=c,d=e.tagName;if("UL"===d||"OL"===d)t.marker&&!t.marker.used&&r.push(H([],t)),r.push(...k(e,t));else if("TABLE"===d)t.marker&&!t.marker.used&&r.push(H([],t)),r.push(...L(e,t.width));else if("PRE"===d){const n=(e.textContent||"").replace(/\r\n?/g,"\n").split("\n");r.push(H(n.map(((e,r)=>new i(Object.assign(Object.assign(Object.assign({},t.run),{children:e.split("\t").flatMap(((e,t)=>t?[new a,e]:[e])),font:"Courier New",size:20}),r?{break:1}:{})))),t,{shading:{fill:"F4F4F4"},spacing:{before:120,after:160}}))}else if(/^H[1-6]$/.test(d)){const n=[s.HEADING_1,s.HEADING_2,s.HEADING_3,s.HEADING_4,s.HEADING_5,s.HEADING_6];r.push(H(S(e.childNodes,Object.assign(Object.assign({},t.run),{bold:!0,color:"202020"}),t.width-t.indent),t,{heading:n[Number(d[1])-1],keepNext:!0}))}else if("HR"===d)r.push(H([],t,{border:{bottom:{style:o.SINGLE,color:"CCCCCC",size:4}}}));else{const n="BLOCKQUOTE"===d?Object.assign(Object.assign({},t),{indent:t.indent+360}):t,i=M(e.childNodes,n);r.push(...i),i.length||"P"!==d||r.push(H([],n))}}return l(),r},C=M(j.childNodes,{indent:0,width:10800,run:{}}),U=new t({title:"Pickaxe",creator:"Pickaxe",styles:{default:{document:{run:{font:"Arial",size:22,color:"202020"}}}},numbering:{config:D},sections:[{properties:{page:{size:{width:12240,height:15840},margin:{top:A,bottom:A,left:A,right:A}}},children:C.length?C:[new r("")]}]});return n.toBlob(U)}));export{I as createResponseDownloadDocx};
|
|
@@ -1 +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
|
|
1
|
+
import{__awaiter as e}from"../_virtual/_tslib.js";import{createElement as t}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 a from"isomorphic-dompurify";import{filterArtifactStyles as l}from"./responseArtifactStyles.js";import{createResponseSvgImage as c}from"./responseStandaloneSvg.js";const d=a=>e(void 0,void 0,void 0,(function*(){var e,l,d;const s=r(t(n,{remarkPlugins:[o],rehypePlugins:[i],components:{input:({type:e,checked:r})=>"checkbox"===(null==e?void 0:e.toLowerCase())?t("span",null,r?"☑":"☐"):null}},a)),m=document.createElement("template");m.innerHTML=s;const h=(e=>{var t;let r=!1;const n=new Set(Array.from(e.querySelectorAll("img[src]"),(e=>e.getAttribute("src"))));for(const o of e.querySelectorAll("a[href]"))if(!o.closest("pre,code")&&!o.querySelector("img"))try{const e=new URL(o.getAttribute("href")||""),i=decodeURIComponent(e.pathname.split("/").pop()||"");if("https:"!==e.protocol||e.username||e.password||!e.pathname.includes("/action_generated_files/")||!/\.(png|jpe?g|gif|webp|svg)$/i.test(i)||n.has(e.href))continue;n.add(e.href);const a=document.createElement("img");a.src=e.href,a.alt=(null===(t=o.textContent)||void 0===t?void 0:t.trim())||i;const l=document.createElement("span");o.replaceWith(l),l.append(o,document.createElement("br"),a),r=!0}catch(e){}return r})(m.content),f=Array.from(m.content.querySelectorAll("svg")).filter((e=>{var t;return!(null===(t=e.parentElement)||void 0===t?void 0:t.closest("svg"))}));if(!f.length&&!h)return p(s);for(const t of f)try{const e=yield c(t.outerHTML,""),r=document.createElement("template");r.innerHTML=e,t.replaceWith(r.content)}catch(r){const n=document.createElement("span");n.textContent=`⚠ ${(null===(e=t.getAttribute("aria-label"))||void 0===e?void 0:e.trim())||(null===(d=null===(l=t.querySelector("title"))||void 0===l?void 0:l.textContent)||void 0===d?void 0:d.trim())||"[…]"}`,t.replaceWith(n)}return p(m.innerHTML)})),p=(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>`},s=t=>e(void 0,void 0,void 0,(function*(){const e=window.open("","_blank");if(!e)throw new Error("Unable to open the response print window.");e.opener=null;try{yield m(yield d(t),e)}catch(t){throw e.close(),t}})),m=(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 n=r.createElement("style");if(n.media="print",n.textContent="\n@page { margin: 12mm; }\nmain { max-width: none; padding: 0; }\npre { overflow: visible; }\npre, pre code { white-space: pre-wrap; overflow-wrap: anywhere; }\ntable { width: 100%; table-layout: fixed; }\nth, td { white-space: normal; overflow-wrap: anywhere; }\nthead { display: table-header-group; }\ntr, img { break-inside: avoid; }\nh1, h2, h3, h4, h5, h6 { break-after: avoid; }\np, li { orphans: 3; widows: 3; }\n",r.head.appendChild(n),r.querySelectorAll("details").forEach((e=>{e.open=!0})),r.querySelectorAll("img").forEach((e=>{e.loading="eager"})),r.close(),e.focus(),yield 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(((n,o)=>{const i=new Set(Array.from(r.images)),a=e=>{if(d)return;i.delete(e);const t=r.createElement("span");t.textContent=`⚠ ${e.alt.trim()||"[…]"}`,t.style.cssText="display:inline-block;border:1px solid #999;padding:4px;white-space:normal;overflow-wrap:anywhere;",e.removeAttribute("src"),e.removeAttribute("srcset"),e.replaceWith(t)},l=window.setTimeout((()=>{i.forEach(a),p()}),15e3),c=window.setInterval((()=>{t.closed&&p(new Error("The response print window was closed."))}),100);let d=!1;function p(e){d||(d=!0,window.clearTimeout(l),window.clearInterval(c),e?o(e):n())}Promise.all([...Array.from(i,(t=>e(void 0,void 0,void 0,(function*(){try{if(yield t.decode(),!t.complete||!t.naturalWidth||!t.naturalHeight)throw new Error("Unable to load a response print image.");i.delete(t)}catch(e){a(t)}})))),r.fonts.ready]).then((()=>p()),(()=>p(new Error("Unable to load the response print resources."))))}));export{p as createResponseDownloadDocument,d as createResponseDownloadHtml,m as printResponseDownloadDocument,s as printResponseDownloadHtml};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=(e
|
|
1
|
+
const t=t=>{var e;const n=new Set;for(const r of t){const t=document.createElement("template");t.innerHTML=r.content;for(const r of t.content.querySelectorAll("script[src]"))try{const t=new URL(null!==(e=r.getAttribute("src"))&&void 0!==e?e:"");t.username||t.password||!/^https:\/\/[a-z0-9.-]+(?::\d+)?$/i.test(t.origin)||n.add(t.origin)}catch(t){}}return[...n]},e=(e,n)=>{var r;if(!n.length)return e;const o=(new DOMParser).parseFromString(e,"text/html"),i=o.querySelector('meta[http-equiv="Content-Security-Policy"]');if(!i)throw new Error("Missing response document policy.");const c=["'unsafe-inline'",...t(n)].join(" ");i.setAttribute("content",i.getAttribute("content").replace("script-src 'none'",`script-src ${c}`));const s=o.createElement("style");s.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",o.head.appendChild(s);for(const t of n){const e=o.getElementById(t.placeholder);if(!e)throw new Error("Missing response artifact placeholder.");null===(r=e.closest("section"))||void 0===r||r.classList.add("pxe-interactive-section");const n=o.createElement("iframe");n.setAttribute("sandbox","allow-scripts"),n.setAttribute("referrerpolicy","no-referrer"),n.title=t.title,n.style.cssText="display:block;width:100%;height:85vh;min-height:360px;border:0;resize:vertical;overflow:auto;",n.srcdoc=t.content,e.replaceWith(n)}return`<!doctype html>\n${o.documentElement.outerHTML}`};export{e as embedInteractiveArtifacts};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as i,jsx as o}from"react/jsx-runtime";import{useState as t}from"react";import r from"../../../../common/cn.js";import n from"../../../../common/error.js";import{pickaxeApi2 as a}from"../../../../common/api/pickaxe.js";import{getAuthToken as c,setAuthToken as s}from"../../../../common/utils.js";import
|
|
1
|
+
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as i,jsx as o}from"react/jsx-runtime";import{useState as t}from"react";import r from"../../../../common/cn.js";import n from"../../../../common/error.js";import{pickaxeApi2 as a}from"../../../../common/api/pickaxe.js";import{getAuthToken as c,setAuthToken as s}from"../../../../common/utils.js";import m from"../../../Core/ErrorAlert.js";import{usePickaxeContext as l}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as d}from"../../../../hooks/pickaxe/useResponseContext.js";import f from"../../common/PickaxeButton.js";import u from"../../common/PickaxeInput.js";import{useAuthContext as v}from"./hooks/useAuthContext.js";import{emitPendingEmbedAuthOutcome as p}from"../../../../common/embedAuthEvents.js";const h=new Set(["Invalid verification code","Too many incorrect verification code attempts","Your token has expired, please try again","Your token is invalid or has already been used"]),x=({compact:x=!1})=>{const{deploymentId:g,isEmbed:k,pickaxe:j,translations:y,setSender:b,setSenderType:I}=l(),{setLimitData:O}=d(),{isPricingAuth:w,setToken:C,setIsPricingAuth:P}=v(),[E,S]=t(""),[A,D]=t(""),[N,T]=t(!1),L=(null==j?void 0:j.studioid)||"",Y=(e,i)=>{var o;return null!==(o=null==y?void 0:y[e])&&void 0!==o?o:i};return i("form",Object.assign({className:r("flex w-full flex-col items-center gap-2",x&&"max-w-[328px]"),onSubmit:i=>e(void 0,void 0,void 0,(function*(){if(i.preventDefault(),6!==E.length||N||!L)return;const e=c(L);if(e){D(""),T(!0);try{const i=yield a.post("/auth/verify",{token:e,code:E});if(!i.data.success)throw new Error(i.data.error||Y("verification-code-invalid","Invalid verification code."));s(`PXE-token-${L}`,e),C(e),b(void 0),I("STUDIO_USER"),k&&p({token:e,outcome:i.data.authOutcome,context:{deploymentId:g,pickaxeId:(null==j?void 0:j.formid)||"",studioId:L}}),w&&(P(!1),O(null))}catch(e){const i=n(e);D(h.has(i)?Y("verification-code-invalid","Invalid verification code."):i||Y("verification-code-invalid","Invalid verification code."))}finally{T(!1)}}else D(Y("verification-code-session-missing","Your login request could not be found. Please resend the email."))}))},{children:[o("label",Object.assign({htmlFor:"email-verification-code",className:"font-semilight"},{children:Y("enter-verification-code","Or enter the 6-digit code from the email")})),i("div",Object.assign({className:"flex w-full items-center gap-2"},{children:[o(u,{id:"email-verification-code",name:"verificationCode",type:"text",inputMode:"numeric",autoComplete:"one-time-code",pattern:"[0-9]{6}",maxLength:6,className:"min-w-0 flex-1 text-center text-lg tracking-[0.3em]",placeholder:"000000",value:E,"aria-invalid":!!A,"aria-describedby":A?"email-verification-code-error":void 0,onChange:e=>{S(e.target.value.replace(/\D/g,"").slice(0,6)),D("")}}),o(f,Object.assign({className:r("shrink-0",x&&"min-h-[44px]"),loadingText:Y("verifying","Verifying..."),isLoading:N,isDisabled:6!==E.length},{children:Y("verify","Verify")}))]})),o("div",Object.assign({id:"email-verification-code-error","aria-live":"polite"},{children:o(m,{error:A})}))]}))};export{x as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{usePickaxeContext as i}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as t}from"./useAuthContext.js";import{setAuthToken as o}from"../../../../../common/utils.js";import{pickaxeApi2 as s}from"../../../../../common/api/pickaxe.js";import r from"../../../../../common/error.js";const
|
|
1
|
+
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{usePickaxeContext as i}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as t}from"./useAuthContext.js";import{setAuthToken as o}from"../../../../../common/utils.js";import{pickaxeApi2 as s}from"../../../../../common/api/pickaxe.js";import r from"../../../../../common/error.js";import{rememberPendingEmbedAuth as n}from"../../../../../common/embedAuthEvents.js";const d=()=>{const{deploymentId:d,isEmbed:a,pickaxe:m,translations:l,setValidationStatus:c}=i(),{emailInput:u,redirectUrl:p,isSending:f,setIsSending:I,setIsSent:k,setIsResendDisabled:v,setIsPricingAuth:h}=t();return{onSend:i=>e(void 0,void 0,void 0,(function*(){try{if(!m)return;if(f)return;const e=u.trim().toLowerCase();if(!e)throw new Error((null==l?void 0:l["email-address-cannot-be-empty"])||"Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error((null==l?void 0:l["please-enter-valid-email-address"])||"Please enter a valid email address.");if(!m.studioid)throw new Error(`Studio ID is missing for ${m.formid}. Please contact support.`);I(!0),i&&v(!0);const t=(yield s.post("/auth/email",Object.assign(Object.assign({pickaxeId:m.formid,studioId:m.studioid,email:e},d&&{deploymentId:d}),{redirectUrl:p}))).data;if(!t.success)throw new Error(t.error||(null==l?void 0:l["failed-to-send-sign-in-link"])||"Failed to send sign-in link.");I(!1),k(!0),i&&(yield new Promise((e=>setTimeout(e,3e4))),v(!1)),o(`PXE-token-${m.studioid}`,t.token),a&&n({deploymentId:d,pickaxeId:m.formid,studioId:m.studioid},t.token),h(!0)}catch(e){const i=r(e);if(a&&"You must be invited to use this tool"===i)return void c("access_denied");alert(i)}finally{I(!1)}}))}};export{d as useAuth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{useEffect as o,useCallback as e}from"react";import{usePickaxeContext as t}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../../hooks/pickaxe/useResponseContext.js";import{getAuthToken as s,setAuthToken as n,deleteAuthToken as r}from"../../../../../common/utils.js";import{useAuthContext as d}from"./useAuthContext.js";import{useAuthVerify as m}from"./useAuthVerify.js";import{clearAuthenticatedEmbedSession as
|
|
1
|
+
import{useEffect as o,useCallback as e}from"react";import{usePickaxeContext as t}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../../hooks/pickaxe/useResponseContext.js";import{getAuthToken as s,setAuthToken as n,deleteAuthToken as r}from"../../../../../common/utils.js";import{useAuthContext as d}from"./useAuthContext.js";import{useAuthVerify as m}from"./useAuthVerify.js";import{clearAuthenticatedEmbedSession as u}from"../../../../../common/embedSession.js";import{emitPendingEmbedAuthOutcome as c}from"../../../../../common/embedAuthEvents.js";const a=()=>{const{deploymentId:a,isEmbed:p,pickaxe:l,setSender:f,setSenderType:k}=t(),{setLimitData:g}=i(),{token:I,isLoggedOut:h,isPricingAuth:x,setToken:v,setIsLoggingIn:j,setIsPricingAuth:S,setIsAuthBootstrapComplete:A}=d(),E=(null==l?void 0:l.studioid)||"",L=E?`PXE-token-${E}`:"",y=s(E)||"",b=m({token:y,enabled:h&&!!y,setIsLoggingIn:j});o((()=>{E&&A(!1)}),[A,E]);const C=e((o=>{n(L,o),v(o),f(void 0),k("STUDIO_USER"),x&&(S(!1),g(null))}),[L,x,S,g,f,k,v]);o((()=>{if(!L)return;if(!b.data)return;const{success:o,token:e,authOutcome:t,error:i}=b.data;if(!o||i)return a&&(null==l?void 0:l.formid)&&y&&u({deploymentId:a,pickaxeId:l.formid,authToken:y}),r(L),S(!1),void A(!0);e&&(C(e),p&&c({token:e,outcome:t,context:{deploymentId:a,pickaxeId:(null==l?void 0:l.formid)||"",studioId:E}}),A(!0))}),[C,L,b.data,a,p,null==l?void 0:l.formid,A,S,y,E]),o((()=>{var o;E&&(I?A(!0):y?b.isLoading||b.isFetching||(b.isError||b.isSuccess&&!(null===(o=b.data)||void 0===o?void 0:o.token))&&A(!0):A(!0))}),[b.data,b.isError,b.isFetching,b.isLoading,b.isSuccess,A,y,E,I])};export{a as useAuthBootstrap};
|
|
@@ -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
|
|
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 s,useEffect as r,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 w from"../common/PickaxeMCPButton.js";import{useResponseContext as I}from"../../../hooks/pickaxe/useResponseContext.js";import{NavPill as S,EditableNavPill as D,HistoryPill as C}from"../Addons/Navbar/NavPill.js";import T from"../../Icons/history.svg.js";const N=()=>{var N,O;const{deploymentType:A,isNewChat:F,setIsNewChat:P,sessionId:H,setSessionId:z,setLastSessionId:B,pickaxeId:E,sender:R,pickaxe:L,styles:G,isEmbed:M,mcpEnabled:V,translations:_}=l(),{isSent:q,token: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}=I(),ie=p(),[ne,se]=n(0),[re,ae]=n(!1),[le,ce]=n(!1),de=s(null),me=s(null),ue=s(0),[pe,fe]=n(null),[he,ve]=n(!1),ge=(null==_?void 0:_["new-chat"])||"New chat",xe="chat-input"===A&&F&&!q,be=null!==(O=null===(N=null==L?void 0:L.documentuploadtype)||void 0===N?void 0:N.startsWith("enduserupload"))&&void 0!==O&&O,{hasScrollableContent:je,isNearBottom:ke}=f(Y);r((()=>()=>{Q([])}),[]);const ye=a((()=>{if(!E||!R&&!U)return;const t=(o=0)=>e(void 0,void 0,void 0,(function*(){var e;try{const t=yield b.post("/conversation/title",Object.assign({sessionId:H},U?{studioSessionToken:U}:R?{userId:R}:{}));if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void Ie(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,U]);r((()=>{te||F||!H||ye()}),[te,F,H,ye]),r((()=>{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[we,Ie]=n(ge),Se=(null==L?void 0:L.formtitle)||"Pickaxe",De=(null==L?void 0:L.coverphoto)||void 0,[Ce,Te]=n(!1);r((()=>{const e=!xe&&!M&&G.portalTheme&&(oe.filter((e=>"user"===e.role)).length>0||re||!F);Te(null!=e&&e)}),[xe,M,re,F,oe,G.portalTheme]);const Ne=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?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:x("direct-link"===A?"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(S,{text:Se,icon:De}),F||we===ge?o(S,{text:we}):o(D,{text:we,sessionId:H,onRename:t=>e(void 0,void 0,void 0,(function*(){if(H)try{yield b.patch("/conversation/title",Object.assign({sessionId:H,name:t},U?{studioSessionToken:U}:R?{userId:R}:{})),Ie(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:Object.assign({sessionId:H},U?{studioSessionToken:U}:R?{userId:R}:{})}),P(!0),z(j()),Ie(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(C,{icon:o(T,{}),onClick:()=>{z(""),B(H)}})}))]})),o(h,{additionalScrollHeight:ne,isForceHideInfo:J<=545||W<=350||re,isInputFocused:re,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:Ne}),o(v,{ref:me,onFocus:()=>ae(!0),onBlur:()=>ae(!1),onInputHeightChange:se,initSmitheryAuthData:e=>fe(e),resubmitPrompt:he})]})]}))};export{N as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as s,jsx as o,Fragment as t}from"react/jsx-runtime";import{useState as n,useRef as a,useEffect as i,useMemo as l}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{
|
|
1
|
+
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as s,jsx as o,Fragment as t}from"react/jsx-runtime";import{useState as n,useRef as a,useEffect as i,useMemo as l}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{useAuthContext as m}from"../../Addons/Auth/hooks/useAuthContext.js";import{pickaxeApi2 as p}from"../../../../common/api/pickaxe.js";import{formatLocalDateTime as u}from"../../../../common/date.js";import{Check as h,X as b,MoreHorizontal as g,Pencil as v}from"lucide-react";import f from"../../../Icons/trash-2.svg.js";import y from"../../../Icons/chat.svg.js";import x from"../../../Icons/copy.svg.js";import j from"../../../Icons/copied.svg.js";import k from"../../../Icons/expand.svg.js";import w from"../../../Icons/collapse.svg.js";import{PickaxeMarkdown as N}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as O}from"../../common/PickaxeMarkdown/Renderer.js";import{getSuppressedRichPreviewUrls as C}from"../../common/PickaxeMessageParts/index.js";import _ from"../../../../common/cn.js";const I=({item:I,onDelete:P})=>{const{pickaxe:M,sender:R,colors:T,translations:q,styles:E,isRtl:S,disableCss:A,disableHtml:D,disableJs:F,setSessionId:$,setIsNewChat:H}=r(),{token:J}=m(),{setMessages:z}=c(),{setDocuments:L}=d(),[B,K]=n(!1),[U,G]=n(!1),[Q,V]=n(!1),[W,X]=n(!1),[Y,Z]=n(!1),ee=a(null),[se,oe]=n(I.shortSummary||I.summary||(null==q?void 0:q["conversation-name"])||"Conversation name"),[te,ne]=n("");i((()=>{oe(I.shortSummary||I.summary||(null==q?void 0:q["conversation-name"])||"Conversation name")}),[I.shortSummary,I.summary,q]),i((()=>{const e=e=>{ee.current&&!ee.current.contains(e.target)&&K(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const ae=l((()=>I?"FORM"===I.pickaxeType?I.question?0===I.messages.length?I.question.responseParts?I.question.responseParts.length:0:I.messages.length:0:I.messages.length:0),[I]),ie=u(I.updatedAt,"MMM dd, yyyy hh:mm a"),le=l((()=>{var e,s;const o=(null==q?void 0:q["not-available"])||"n/a";if("FORM"===I.pickaxeType){if(I.messages&&0!==I.messages.length){const e=I.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const t=null!==(s=null===(e=I.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[];return Y?t.map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 600; opacity: 0.9;">${e.question}</p>\n <p style="opacity: 0.8;">${e.answer||o}</p>\n</div>`)).join(""):t.map((e=>`${e.question}: ${e.answer||o}`)).join(" | ")}const t=I.messages.find((e=>"user"===e.role));return t?t.parts[0].content:""}),[I,Y,q]),re=l((()=>{var e,s,o,t,n,a;return"FORM"===I.pickaxeType?I.messages&&0!==I.messages.length?null!==(s=null===(e=I.messages.find((e=>"assistant"===e.role)))||void 0===e?void 0:e.parts)&&void 0!==s?s:[]:null!==(t=null===(o=I.question)||void 0===o?void 0:o.responseParts)&&void 0!==t?t:[]:null!==(a=null===(n=I.messages.find((e=>"assistant"===e.role)))||void 0===n?void 0:n.parts)&&void 0!==a?a:[]}),[I]),ce=l((()=>re.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")),[re]),de=l((()=>C(re)),[re]),me=()=>{G(!1),ne("")},pe=()=>e(void 0,void 0,void 0,(function*(){if(te.trim()){V(!0);try{yield p.patch("/conversation/title",Object.assign({sessionId:I.sessionId,name:te},J?{studioSessionToken:J}:R?{userId:R}:{})),oe(te),G(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==q?void 0:q["failed-update-name"])||"Failed to update name.")}finally{V(!1)}}}));return s("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:T.secondary,borderRadius:E.cornerRadius}},{children:[o("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:T.primary,color:T.text}},{children:U?s("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[o("input",{autoFocus:!0,type:"text",value:te,onChange:e=>ne(e.target.value),onKeyDown:e=>{"Enter"===e.key&&pe(),"Escape"===e.key&&me()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:T.primary,borderColor:T.secondary}}),o("button",Object.assign({onClick:pe,disabled:Q,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==q?void 0:q.save)||"Save"},{children:o(h,{className:"h-4 w-4"})})),o("button",Object.assign({onClick:me,disabled:Q,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==q?void 0:q.cancel)||"Cancel"},{children:o(b,{className:"h-4 w-4"})}))]})):s(t,{children:[o("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:se})),s("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[o("button",Object.assign({onClick:e=>{e.stopPropagation(),Z(!Y)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:Y?(null==q?void 0:q.collapse)||"Collapse":(null==q?void 0:q.expand)||"Expand"},{children:o(Y?w:k,{className:"h-4 w-4"})})),s("div",Object.assign({className:"relative"},{children:[o("button",Object.assign({onClick:e=>{e.stopPropagation(),K(!B)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:o(g,{className:"h-6 w-6"})})),B&&s("div",Object.assign({ref:ee,className:"absolute right-0 top-8 w-48 rounded-xl shadow-xl z-40 border overflow-hidden animate-in fade-in zoom-in-95 duration-100",style:{backgroundColor:T.secondary,color:T.secondaryText,borderColor:T.primary}},{children:[s("button",Object.assign({onClick:e=>{e.stopPropagation(),ne(se),G(!0),K(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:T.primary}},{children:[o(v,{className:"h-4 w-4"}),o("span",Object.assign({className:"font-medium text-sm"},{children:(null==q?void 0:q["rename-chat"])||"Rename chat"}))]})),s("button",Object.assign({onClick:s=>{s.stopPropagation(),e(void 0,void 0,void 0,(function*(){if(window.confirm((null==q?void 0:q["delete-confirm"])||"Are you sure you want to delete this conversation?")){K(!1);try{yield p.delete("/conversation",{data:Object.assign({sessionId:I.sessionId},J?{studioSessionToken:J}:R?{userId:R}:{})}),P&&P(I.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==q?void 0:q["failed-delete-conversation"])||"Failed to delete conversation.")}}}))},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95"},{children:[o(f,{className:"h-4 w-4"}),o("span",Object.assign({className:"font-medium text-sm"},{children:(null==q?void 0:q["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s("div",Object.assign({className:_("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",Y?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:T.secondary,color:T.secondaryText}},{children:[s("div",Object.assign({className:"flex flex-col"},{children:[o("div",Object.assign({className:_("w-full",Y?"mb-0":"mb-2")},{children:o(N,Object.assign({theme:E.theme,colors:T},S&&{rtl:!0},D&&{disableHtml:!0},F&&{disableJs:!0},A&&{disableCss:!0},{children:o(O,{style:{display:"block"},className:_("w-full",!Y&&["[&_*]:!font-semibold mb-0.5 h-5 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],Y&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:le})}))})),o("div",Object.assign({className:"w-full"},{children:o(N,Object.assign({theme:E.theme,colors:T},S&&{rtl:!0},D&&{disableHtml:!0},F&&{disableJs:!0},A&&{disableCss:!0},{children:o(O,{style:{display:"block"},className:_("w-full text-sm",!Y&&["font-normal h-5 opacity-80 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],Y&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:ce,suppressedRichPreviewUrls:de})}))}))]})),s("div",Object.assign({className:"flex items-center justify-between mt-4 pt-2 border-t border-transparent"},{children:[s("div",Object.assign({className:"flex items-center gap-4"},{children:[((null==M?void 0:M.chatflag)||!(null==M?void 0:M.chatflag)&&(null==M?void 0:M.enablechatresponses))&&s("div",Object.assign({className:"flex items-center gap-1.5 opacity-70 hover:opacity-100 cursor-pointer transition-opacity",onClick:e=>{var s;e.stopPropagation(),s=I.sessionId,L([]),z([]),H(!1),$(s)},title:(null==q?void 0:q["open-chat"])||"Open Chat"},{children:[o(y,{className:"h-4 w-4"}),o("span",Object.assign({className:"text-sm font-medium"},{children:ae}))]})),o("button",Object.assign({className:"transition-colors "+(W?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(ce),X(!0),setTimeout((()=>{X(!1)}),2e3)},title:W?(null==q?void 0:q.copied)||"Copied!":(null==q?void 0:q["copy-assistant-message"])||"Copy assistant message"},{children:W?o(j,{className:"h-4 w-4",style:{color:T.accent},fill:T.accent}):o(x,{className:"h-4 w-4"})}))]})),o("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:ie}))]}))]}))]}))};export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as i}from"react";import{createPortal as s}from"react-dom";import{v4 as l}from"uuid";import a from"file-saver";import{createResponseDownloadDocx as d}from"../../../common/responseDownloadDocx.js";import{embedResponseDownloadHtmlImages as c}from"../../../common/responseDownloadImages.js";import{printResponseDownloadDocument as u,printResponseDownloadHtml as m,createResponseDownloadHtml as p}from"../../../common/responseDownloadHtml.js";import{findResponseArtifacts as f,prepareResponseArtifactDownload as x}from"../../../common/responseDownloadArtifacts.js";import{renderResponseArtifactHtml as v}from"../../../common/responseArtifactSnapshot.js";import{useArtifactContext as h}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useArtifactData as y}from"../Addons/Artifact/hooks/useArtifactData.js";import{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import{usePickaxeContext as w}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useOutsideAlerter as g}from"../../../hooks/core/useOutsideAlerter.js";import k from"../../Icons/download.svg.js";import j from"../../Core/Menu/index.js";import A from"../../Core/Menu/List.js";const D=[{extension:"txt",label:"TXT",mimeType:"text/plain;charset=utf-8"},{extension:"md",label:"Markdown (.md)",mimeType:"text/markdown;charset=utf-8"},{extension:"html",label:"HTML (.html)",mimeType:"text/html;charset=utf-8"},{extension:"pdf",label:"PDF"},{extension:"docx",label:"DOCX"}],T=({color:T,text:C,disabled:O=!1})=>{const{translations:S,colors:P,styles:I,isRtl:M,sender:N,senderType:$,pickaxe:B}=w(),{artifacts:E=[]}=h(),{token:F}=b(),L=y(),[_,H]=n(""),[K,R]=n(!1),[U,X]=n(),[W,q]=n(!1),z=r(!1),G=r(null),J=r(null),Q=r([]),V=r(0),Y=(null==S?void 0:S.download)||"Download",Z=O||W||!C.trim();i((()=>{H(`response-download-${l()}`)}),[]),i((()=>{Z&&R(!1)}),[Z]),i((()=>{K&&G.current&&X(getComputedStyle(G.current).fontFamily)}),[K,I.font]),g({ref:[G,J],callback:()=>R(!1)});const ee=()=>{var e;R(!1),null===(e=G.current)||void 0===e||e.focus({preventScroll:!0})},oe=e=>{var o;if(!Z)if("Escape"===e.key&&K)e.preventDefault(),e.stopPropagation(),ee();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();const t=Q.current.indexOf(e.currentTarget),n="ArrowDown"===e.key?1:-1,r=D.length,i=-1===t?1===n?0:r-1:(t+n+r)%r;V.current=i,R(!0),null===(o=Q.current[i])||void 0===o||o.focus({preventScroll:!0})}else"Tab"===e.key&&R(!1)},te=e=>{e.relatedTarget===G.current||Q.current.some((o=>o===e.relatedTarget))||R(!1)};return o(j,Object.assign({id:_,className:"h-4 w-4 shrink-0",isOpen:K&&!Z,onChange:R,closeOnSelect:!1,closeOnClickOutside:!1},{children:[t("button",Object.assign({ref:G,id:_||void 0,type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-30",style:{color:T},title:Y,"aria-label":Y,"aria-haspopup":"menu","aria-busy":W,"aria-expanded":K&&!Z,"aria-controls":K&&!Z?`${_}-menu`:void 0,disabled:Z,onClick:e=>{e.stopPropagation(),V.current=0,R((e=>!e))},onKeyDown:oe,onBlur:te},{children:t(k,{className:"h-4 w-4 shrink-0","aria-hidden":"true"})})),_&&!Z&&s(t("div",Object.assign({ref:J,style:{fontFamily:U},dir:M?"rtl":"ltr"},{children:t(A,Object.assign({id:`${_}-menu`,role:"menu",align:"right",width:"auto",className:"p-1 text-sm",style:{backgroundColor:P.primary,color:P.text,maxWidth:"calc(100vw - 32px)"},imperativeModeOnly:!0,afterShow:()=>{var e;return null===(e=Q.current[V.current])||void 0===e?void 0:e.focus({preventScroll:!0})}},{children:D.map(((o,n)=>t("button",Object.assign({ref:e=>{Q.current[n]=e},type:"button",role:"menuitem",tabIndex:-1,className:"rounded-sm px-3 py-2 text-left hover:bg-black/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px]",onClick:t=>{((o,t)=>{e(void 0,void 0,void 0,(function*(){var n;if(o.stopPropagation(),Z||z.current)return;let r;ee();try{const o=f(C);let i;if(o.length){if(z.current=!0,q(!0),"pdf"===t.extension){if(r=null!==(n=window.open("","_blank"))&&void 0!==n?n:void 0,!r)throw new Error("Unable to open the print window.");r.opener=null;const e=r.document.createElement("p");e.textContent=(null==S?void 0:S.loading)||"Loading...",e.setAttribute("role","status"),e.style.cssText="margin:32px;font:16px system-ui,sans-serif",r.document.body.appendChild(e)}i=yield x(C,o,(o=>e(void 0,void 0,void 0,(function*(){const e=E.find((e=>e.id===o.id&&e.version===o.version));return null!=e?e:L.mutateAsync({artifactId:o.id,version:o.version,studioId:null==B?void 0:B.studioid,senderType:$,sender:N||void 0,studioSessionToken:F||void 0})}))),t.extension,(e=>v(e,"pdf"===t.extension||"docx"===t.extension,r)))}if("docx"===t.extension){z.current=!0,q(!0);const e=yield d(C,i);return void a(e,"response.docx")}if("pdf"===t.extension)return z.current=!0,q(!0),void(i?yield u(i,r):yield m(C));let s=null!=i?i:"html"===t.extension?p(C):C;"html"===t.extension&&(z.current=!0,q(!0),s=yield c(s));const l=new Blob([s],{type:t.mimeType});a(l,`response.${t.extension}`)}catch(e){console.error("Response download failed",{format:t.extension,error:e}),null==r||r.close(),window.alert((null==S?void 0:S["something-went-wrong"])||"Something went wrong.")}finally{z.current=!1,q(!1)}}))})(t,o)},onKeyDown:oe,onBlur:te},{children:o.label}),o.extension)))}))})),document.body)]}))};export{T as default};
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as i}from"react";import{createPortal as s}from"react-dom";import{v4 as l}from"uuid";import a from"file-saver";import{createResponseDownloadDocx as d}from"../../../common/responseDownloadDocx.js";import{embedResponseDownloadHtmlImages as c}from"../../../common/responseDownloadImages.js";import{printResponseDownloadDocument as u,printResponseDownloadHtml as m,createResponseDownloadHtml as p}from"../../../common/responseDownloadHtml.js";import{findResponseArtifacts as f,prepareResponseArtifactDownload as x}from"../../../common/responseDownloadArtifacts.js";import{renderResponseArtifactHtml as v}from"../../../common/responseArtifactSnapshot.js";import{useArtifactContext as h}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useArtifactData as y}from"../Addons/Artifact/hooks/useArtifactData.js";import{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import{usePickaxeContext as w}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useOutsideAlerter as g}from"../../../hooks/core/useOutsideAlerter.js";import k from"../../Icons/download.svg.js";import j from"../../Core/Menu/index.js";import A from"../../Core/Menu/List.js";const D=[{extension:"txt",label:"TXT",mimeType:"text/plain;charset=utf-8"},{extension:"md",label:"Markdown (.md)",mimeType:"text/markdown;charset=utf-8"},{extension:"html",label:"HTML (.html)",mimeType:"text/html;charset=utf-8"},{extension:"pdf",label:"PDF"},{extension:"docx",label:"DOCX"}],T=({color:T,text:C,disabled:O=!1})=>{const{translations:S,colors:P,styles:I,isRtl:M,sender:N,senderType:$,pickaxe:B}=w(),{artifacts:E=[]}=h(),{token:F}=b(),L=y(),[_,H]=n(""),[K,R]=n(!1),[U,X]=n(),[W,q]=n(!1),z=r(!1),G=r(null),J=r(null),Q=r([]),V=r(0),Y=(null==S?void 0:S.download)||"Download",Z=O||W||!C.trim();i((()=>{H(`response-download-${l()}`)}),[]),i((()=>{Z&&R(!1)}),[Z]),i((()=>{K&&G.current&&X(getComputedStyle(G.current).fontFamily)}),[K,I.font]),g({ref:[G,J],callback:()=>R(!1)});const ee=()=>{var e;R(!1),null===(e=G.current)||void 0===e||e.focus({preventScroll:!0})},oe=e=>{var o;if(!Z)if("Escape"===e.key&&K)e.preventDefault(),e.stopPropagation(),ee();else if("ArrowDown"===e.key||"ArrowUp"===e.key){e.preventDefault(),e.stopPropagation();const t=Q.current.indexOf(e.currentTarget),n="ArrowDown"===e.key?1:-1,r=D.length,i=-1===t?1===n?0:r-1:(t+n+r)%r;V.current=i,R(!0),null===(o=Q.current[i])||void 0===o||o.focus({preventScroll:!0})}else"Tab"===e.key&&R(!1)},te=e=>{e.relatedTarget===G.current||Q.current.some((o=>o===e.relatedTarget))||R(!1)};return o(j,Object.assign({id:_,className:"h-4 w-4 shrink-0",isOpen:K&&!Z,onChange:R,closeOnSelect:!1,closeOnClickOutside:!1},{children:[t("button",Object.assign({ref:G,id:_||void 0,type:"button",className:"flex h-4 w-4 shrink-0 items-center justify-center rounded-sm opacity-70 transition-opacity hover:opacity-100 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-30",style:{color:T},title:Y,"aria-label":Y,"aria-haspopup":"menu","aria-busy":W,"aria-expanded":K&&!Z,"aria-controls":K&&!Z?`${_}-menu`:void 0,disabled:Z,onClick:e=>{e.stopPropagation(),V.current=0,R((e=>!e))},onKeyDown:oe,onBlur:te},{children:t(k,{className:"h-4 w-4 shrink-0","aria-hidden":"true"})})),_&&!Z&&s(t("div",Object.assign({ref:J,style:{fontFamily:U},dir:M?"rtl":"ltr"},{children:t(A,Object.assign({id:`${_}-menu`,role:"menu",align:"right",width:"auto",className:"p-1 text-sm",style:{backgroundColor:P.primary,color:P.text,maxWidth:"calc(100vw - 32px)"},imperativeModeOnly:!0,afterShow:()=>{var e;return null===(e=Q.current[V.current])||void 0===e?void 0:e.focus({preventScroll:!0})}},{children:D.map(((o,n)=>t("button",Object.assign({ref:e=>{Q.current[n]=e},type:"button",role:"menuitem",tabIndex:-1,className:"rounded-sm px-3 py-2 text-left hover:bg-black/10 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-[-2px]",onClick:t=>{((o,t)=>{e(void 0,void 0,void 0,(function*(){var n;if(o.stopPropagation(),Z||z.current)return;let r;ee();try{const o=f(C);let i;if(o.length){if(z.current=!0,q(!0),"pdf"===t.extension){if(r=null!==(n=window.open("","_blank"))&&void 0!==n?n:void 0,!r)throw new Error("Unable to open the print window.");r.opener=null;const e=r.document.createElement("p");e.textContent=(null==S?void 0:S.loading)||"Loading...",e.setAttribute("role","status"),e.style.cssText="margin:32px;font:16px system-ui,sans-serif",r.document.body.appendChild(e)}i=yield x(C,o,(o=>e(void 0,void 0,void 0,(function*(){const e=E.find((e=>e.id===o.id&&e.version===o.version));return null!=e?e:L.mutateAsync({artifactId:o.id,version:o.version,studioId:null==B?void 0:B.studioid,senderType:$,sender:N||void 0,studioSessionToken:F||void 0})}))),t.extension,(e=>v(e,"pdf"===t.extension||"docx"===t.extension,r)))}if("docx"===t.extension){z.current=!0,q(!0);const e=yield d(C,i);return void a(e,"response.docx")}if("pdf"===t.extension)return z.current=!0,q(!0),void(i?yield u(i,r):yield m(C));"html"===t.extension&&(z.current=!0,q(!0));let s=null!=i?i:"html"===t.extension?yield p(C):C;"html"===t.extension&&(z.current=!0,q(!0),s=yield c(s));const l=new Blob([s],{type:t.mimeType});a(l,`response.${t.extension}`)}catch(e){console.error("Response download failed",{format:t.extension,error:e}),null==r||r.close(),window.alert((null==S?void 0:S["something-went-wrong"])||"Something went wrong.")}finally{z.current=!1,q(!1)}}))})(t,o)},onKeyDown:oe,onBlur:te},{children:o.label}),o.extension)))}))})),document.body)]}))};export{T as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as o}from"../../../_virtual/_tslib.js";import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useHover as i}from"../../../hooks/core/useHover.js";import{usePressed as
|
|
1
|
+
import{__rest as o}from"../../../_virtual/_tslib.js";import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useHover as i}from"../../../hooks/core/useHover.js";import{usePressed as s}from"../../../hooks/core/usePressed.js";import{usePickaxeContext as r}from"../../../hooks/pickaxe/usePickaxeContext.js";import{AnimatePresence as n,motion as m}from"framer-motion";import{deleteCookie as d}from"../../../common/utils.js";import{clearAuthenticatedEmbedSession as a}from"../../../common/embedSession.js";import{useAuthContext as c}from"../Addons/Auth/hooks/useAuthContext.js";import l from"../../Icons/logout.svg.js";import u from"./PickaxeSimpleButton.js";import{emitEmbedLogout as p}from"../../../common/embedAuthEvents.js";const f=({tip:f})=>{const{colors:k,styles:h,pickaxe:v,deploymentId:j,isEmbed:x}=r(),{token:g}=c(),y=i(),{isHover:b}=y,I=o(y,["isHover"]),A=s(),{isActive:P}=A,C=o(A,["isActive"]);return e("div",Object.assign({className:"relative"},{children:[t(u,Object.assign({className:"h-8 w-8 shrink-0 items-center justify-center rounded-full duration-300 ease-in-out",color:k.accent,style:{backgroundColor:P?k.accent+"30":b?k.accent+"10":void 0},onClick:()=>{g&&j&&(null==v?void 0:v.formid)&&a({deploymentId:j,pickaxeId:v.formid,authToken:g});const o=`PXE-token-${null==v?void 0:v.studioid}`;localStorage.getItem(o)?localStorage.removeItem(`PXE-token-${null==v?void 0:v.studioid}`):d(o),x&&(null==v?void 0:v.studioid)&&v.formid&&p({deploymentId:j,pickaxeId:v.formid,studioId:v.studioid}),location.reload()},reversed:!0},I,C,{children:t(l,{className:"h-5 w-5 shrink-0"})})),t(n,{children:b&&!!f&&t(m.div,Object.assign({className:"absolute right-0 top-10 z-10 w-max rounded text-xs font-semibold",style:{background:k.accent,color:k.accentText,padding:"0.5rem 0.75rem",fontWeight:500,borderRadius:h.cornerRadius},initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2,ease:"easeInOut"}},{children:f}))})]}))};export{f as default};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type EmbedAuthOutcome = "signup" | "login";
|
|
2
|
+
export type EmbedAuthMethod = "email" | "sso";
|
|
3
|
+
export type EmbedAuthEvent = {
|
|
4
|
+
event: EmbedAuthOutcome;
|
|
5
|
+
method: EmbedAuthMethod;
|
|
6
|
+
} | {
|
|
7
|
+
event: "logout";
|
|
8
|
+
};
|
|
9
|
+
type EmbedAuthEventContext = {
|
|
10
|
+
deploymentId?: string;
|
|
11
|
+
pickaxeId: string;
|
|
12
|
+
studioId: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const rememberPendingEmbedAuth: (context: EmbedAuthEventContext, token: string) => void;
|
|
15
|
+
export declare const emitPendingEmbedAuthOutcome: ({ token, outcome, context, }: {
|
|
16
|
+
token: string;
|
|
17
|
+
outcome?: EmbedAuthOutcome | undefined;
|
|
18
|
+
context: EmbedAuthEventContext;
|
|
19
|
+
}) => void;
|
|
20
|
+
export declare const emitSsoEmbedAuthOutcome: ({ token, outcome, context, }: {
|
|
21
|
+
token: string;
|
|
22
|
+
outcome?: EmbedAuthOutcome | undefined;
|
|
23
|
+
context: EmbedAuthEventContext;
|
|
24
|
+
}) => void;
|
|
25
|
+
export declare const emitEmbedLogout: (context: EmbedAuthEventContext) => void;
|
|
26
|
+
export {};
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Does not mount the chat renderer, run response scripts, or fetch linked content.
|
|
4
4
|
* Code fences stay literal; only the export gets these stricter HTML rules.
|
|
5
5
|
*/
|
|
6
|
-
export declare const createResponseDownloadHtml: (text: string) => string
|
|
6
|
+
export declare const createResponseDownloadHtml: (text: string) => Promise<string>;
|
|
7
7
|
/** All assembled content, including artifact snapshots, crosses this boundary. */
|
|
8
8
|
export declare const createResponseDownloadDocument: (rendered: string, preserveArtifactStyles?: boolean) => string;
|
|
9
9
|
/** Opens a print copy from the user's click without changing the live response. */
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import type { SetState } from "../../../../../types/common";
|
|
2
2
|
import { UseQueryResult } from "@tanstack/react-query";
|
|
3
|
+
import type { EmbedAuthOutcome } from "../../../../../common/embedAuthEvents";
|
|
3
4
|
type QueryResponse = {
|
|
4
5
|
success: boolean;
|
|
5
6
|
token: string;
|
|
7
|
+
authOutcome?: EmbedAuthOutcome;
|
|
6
8
|
error?: string;
|
|
7
9
|
};
|
|
8
10
|
interface UseAuthVerifyQueryProps {
|