@pickaxeproject/react 6.6.0 → 6.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/dist/cjs/components/Pickaxe/Form/History/Item.js +1 -1
  2. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/A/FilePreview.js +1 -1
  3. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/A/index.js +1 -1
  4. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/P/index.js +1 -1
  5. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  6. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
  7. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Components/A/FilePreview.d.ts +6 -0
  8. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Components/A/index.d.ts +3 -2
  9. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Components/P/index.d.ts +6 -1
  10. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Renderer.d.ts +3 -2
  11. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/index.d.ts +2 -0
  12. package/dist/cjs/src/types/history.d.ts +1 -1
  13. package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
  14. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/A/FilePreview.js +1 -1
  15. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/A/index.js +1 -1
  16. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/P/index.js +1 -1
  17. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
  18. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
  19. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Components/A/FilePreview.d.ts +6 -0
  20. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Components/A/index.d.ts +3 -2
  21. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Components/P/index.d.ts +6 -1
  22. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Renderer.d.ts +3 -2
  23. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/index.d.ts +2 -0
  24. package/dist/esm/src/types/history.d.ts +1 -1
  25. package/package.json +1 -1
@@ -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("date-fns"),r=require("../../../../common/api/pickaxe.js"),l=require("lucide-react"),c=require("../../../Icons/trash-2.svg.js"),d=require("../../../Icons/chat.svg.js"),u=require("../../../Icons/copy.svg.js"),m=require("../../../Icons/copied.svg.js"),p=require("../../../Icons/expand.svg.js"),x=require("../../../Icons/collapse.svg.js"),h=require("../../common/PickaxeMarkdown/index.js"),b=require("../../common/PickaxeMarkdown/Renderer.js"),f=require("../../../../common/cn.js");exports.default=({item:g,onDelete:j})=>{const{pickaxe:v,sender:y,colors:k,translations:w,styles:N,isRtl:_,disableCss:C,disableHtml:O,disableJs:q,setSessionId:P,setIsNewChat:M}=n.usePickaxeContext(),{setMessages:I}=a.useResponseContext(),{setDocuments:R}=o.useDocument(),[S,E]=t.useState(!1),[D,F]=t.useState(!1),[T,H]=t.useState(!1),[$,z]=t.useState(!1),[A,J]=t.useState(!1),L=t.useRef(null),[B,K]=t.useState(g.shortSummary||g.summary||(null==w?void 0:w["conversation-name"])||"Conversation name"),[X,G]=t.useState("");t.useEffect((()=>{K(g.shortSummary||g.summary||(null==w?void 0:w["conversation-name"])||"Conversation name")}),[g.shortSummary,g.summary,w]),t.useEffect((()=>{const e=e=>{L.current&&!L.current.contains(e.target)&&E(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const Q=t.useMemo((()=>g?"FORM"===g.pickaxeType&&0===g.messages.length?g.question.responseParts?g.question.responseParts.length:0:g.messages.length:0),[g]),U=t.useMemo((()=>i.format(new Date(g.updatedAt),"MMM dd, yyy hh:mm a")),[g]),V=t.useMemo((()=>{var e;const s=(null==w?void 0:w["not-available"])||"n/a";if("FORM"===g.pickaxeType){if(g.messages&&0!==g.messages.length){const e=g.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const t=null!==(e=g.question.inputs)&&void 0!==e?e:[];return A?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||s}</p>\n</div>`)).join(""):t.map((e=>`${e.question}: ${e.answer||s}`)).join(" | ")}const t=g.messages.find((e=>"user"===e.role));return t?t.parts[0].content:""}),[g,A,w]),W=t.useMemo((()=>{if("FORM"===g.pickaxeType){if(g.messages&&0!==g.messages.length){const e=g.messages.find((e=>"assistant"===e.role));return e?e.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" "):""}return g.question.responseParts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")}const e=g.messages.find((e=>"assistant"===e.role));return e?e.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" "):""}),[g]),Y=()=>{F(!1),G("")},Z=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(X.trim()){H(!0);try{yield r.default.post("/edit_conversation_name",{sessionId:g.sessionId,name:X,userId:y}),K(X),F(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==w?void 0:w["failed-update-name"])||"Failed to update name.")}finally{H(!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:k.secondary,borderRadius:N.cornerRadius}},{children:[s.jsx("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:k.primary,color:k.text}},{children:D?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:X,onChange:e=>G(e.target.value),onKeyDown:e=>{"Enter"===e.key&&Z(),"Escape"===e.key&&Y()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:k.primary,borderColor:k.secondary}}),s.jsx("button",Object.assign({onClick:Z,disabled:T,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==w?void 0:w.save)||"Save"},{children:s.jsx(l.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:Y,disabled:T,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==w?void 0:w.cancel)||"Cancel"},{children:s.jsx(l.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:B})),s.jsxs("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),J(!A)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:A?(null==w?void 0:w.collapse)||"Collapse":(null==w?void 0:w.expand)||"Expand"},{children:A?s.jsx(x.default,{className:"h-4 w-4"}):s.jsx(p.default,{className:"h-4 w-4"})})),s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),E(!S)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:s.jsx(l.MoreHorizontal,{className:"h-6 w-6"})})),S&&s.jsxs("div",Object.assign({ref:L,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:k.secondary,color:k.secondaryText,borderColor:k.primary}},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),G(B),F(!0),E(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:k.primary}},{children:[s.jsx(l.Pencil,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==w?void 0:w["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==w?void 0:w["delete-confirm"])||"Are you sure you want to delete this conversation?")){E(!1);try{yield r.default.post("/delete_pickaxe_conversation",{sessionId:g.sessionId,userId:y}),j&&j(g.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==w?void 0:w["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(c.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==w?void 0:w["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s.jsxs("div",Object.assign({className:f.default("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",A?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsx("div",Object.assign({className:f.default("w-full",A?"mb-0":"mb-2")},{children:s.jsx(h.PickaxeMarkdown,Object.assign({theme:N.theme,colors:k},_&&{rtl:!0},O&&{disableHtml:!0},q&&{disableJs:!0},C&&{disableCss:!0},{children:s.jsx(b.PickaxeMarkdownRenderer,{style:{display:"block"},className:f.default("w-full",!A&&["[&_*]:!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"],A&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:V})}))})),s.jsx("div",Object.assign({className:"w-full"},{children:s.jsx(h.PickaxeMarkdown,Object.assign({theme:N.theme,colors:k},_&&{rtl:!0},O&&{disableHtml:!0},q&&{disableJs:!0},C&&{disableCss:!0},{children:s.jsx(b.PickaxeMarkdownRenderer,{style:{display:"block"},className:f.default("w-full text-sm",!A&&["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"],A&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:W})}))}))]})),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==v?void 0:v.chatflag)||!(null==v?void 0:v.chatflag)&&(null==v?void 0:v.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=g.sessionId,R([]),I([]),M(!1),P(s)},title:(null==w?void 0:w["open-chat"])||"Open Chat"},{children:[s.jsx(d.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"text-sm font-medium"},{children:Q}))]})),s.jsx("button",Object.assign({className:"transition-colors "+($?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(W),z(!0),setTimeout((()=>{z(!1)}),2e3)},title:$?(null==w?void 0:w.copied)||"Copied!":(null==w?void 0:w["copy-assistant-message"])||"Copy assistant message"},{children:$?s.jsx(m.default,{className:"h-4 w-4",style:{color:k.accent},fill:k.accent}):s.jsx(u.default,{className:"h-4 w-4"})}))]})),s.jsx("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:U}))]}))]}))]}))};
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("date-fns"),r=require("../../../../common/api/pickaxe.js"),l=require("lucide-react"),c=require("../../../Icons/trash-2.svg.js"),d=require("../../../Icons/chat.svg.js"),u=require("../../../Icons/copy.svg.js"),m=require("../../../Icons/copied.svg.js"),p=require("../../../Icons/expand.svg.js"),x=require("../../../Icons/collapse.svg.js"),h=require("../../common/PickaxeMarkdown/index.js"),b=require("../../common/PickaxeMarkdown/Renderer.js"),g=require("../../common/PickaxeMessageParts/index.js"),v=require("../../../../common/cn.js");exports.default=({item:j,onDelete:f})=>{const{pickaxe:y,sender:w,colors:k,translations:N,styles:_,isRtl:C,disableCss:O,disableHtml:q,disableJs:P,setSessionId:M,setIsNewChat:I}=n.usePickaxeContext(),{setMessages:R}=a.useResponseContext(),{setDocuments:S}=o.useDocument(),[E,D]=t.useState(!1),[F,T]=t.useState(!1),[H,$]=t.useState(!1),[z,A]=t.useState(!1),[J,L]=t.useState(!1),U=t.useRef(null),[B,K]=t.useState(j.shortSummary||j.summary||(null==N?void 0:N["conversation-name"])||"Conversation name"),[X,G]=t.useState("");t.useEffect((()=>{K(j.shortSummary||j.summary||(null==N?void 0:N["conversation-name"])||"Conversation name")}),[j.shortSummary,j.summary,N]),t.useEffect((()=>{const e=e=>{U.current&&!U.current.contains(e.target)&&D(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const Q=t.useMemo((()=>j?"FORM"===j.pickaxeType&&0===j.messages.length?j.question.responseParts?j.question.responseParts.length:0:j.messages.length:0),[j]),V=t.useMemo((()=>i.format(new Date(j.updatedAt),"MMM dd, yyy hh:mm a")),[j]),W=t.useMemo((()=>{var e;const s=(null==N?void 0:N["not-available"])||"n/a";if("FORM"===j.pickaxeType){if(j.messages&&0!==j.messages.length){const e=j.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const t=null!==(e=j.question.inputs)&&void 0!==e?e:[];return J?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||s}</p>\n</div>`)).join(""):t.map((e=>`${e.question}: ${e.answer||s}`)).join(" | ")}const t=j.messages.find((e=>"user"===e.role));return t?t.parts[0].content:""}),[j,J,N]),Y=t.useMemo((()=>{var e,s,t,n;return"FORM"===j.pickaxeType?j.messages&&0!==j.messages.length?null!==(s=null===(e=j.messages.find((e=>"assistant"===e.role)))||void 0===e?void 0:e.parts)&&void 0!==s?s:[]:j.question.responseParts:null!==(n=null===(t=j.messages.find((e=>"assistant"===e.role)))||void 0===t?void 0:t.parts)&&void 0!==n?n:[]}),[j]),Z=t.useMemo((()=>Y.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")),[Y]),ee=t.useMemo((()=>g.getSuppressedRichPreviewUrls(Y)),[Y]),se=()=>{T(!1),G("")},te=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(X.trim()){$(!0);try{yield r.default.post("/edit_conversation_name",{sessionId:j.sessionId,name:X,userId:w}),K(X),T(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==N?void 0:N["failed-update-name"])||"Failed to update name.")}finally{$(!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:k.secondary,borderRadius:_.cornerRadius}},{children:[s.jsx("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:k.primary,color:k.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:X,onChange:e=>G(e.target.value),onKeyDown:e=>{"Enter"===e.key&&te(),"Escape"===e.key&&se()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:k.primary,borderColor:k.secondary}}),s.jsx("button",Object.assign({onClick:te,disabled:H,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==N?void 0:N.save)||"Save"},{children:s.jsx(l.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:se,disabled:H,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==N?void 0:N.cancel)||"Cancel"},{children:s.jsx(l.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:B})),s.jsxs("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),L(!J)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:J?(null==N?void 0:N.collapse)||"Collapse":(null==N?void 0:N.expand)||"Expand"},{children:J?s.jsx(x.default,{className:"h-4 w-4"}):s.jsx(p.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(l.MoreHorizontal,{className:"h-6 w-6"})})),E&&s.jsxs("div",Object.assign({ref:U,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:k.secondary,color:k.secondaryText,borderColor:k.primary}},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),G(B),T(!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:k.primary}},{children:[s.jsx(l.Pencil,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==N?void 0:N["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==N?void 0:N["delete-confirm"])||"Are you sure you want to delete this conversation?")){D(!1);try{yield r.default.post("/delete_pickaxe_conversation",{sessionId:j.sessionId,userId:w}),f&&f(j.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==N?void 0:N["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(c.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==N?void 0:N["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s.jsxs("div",Object.assign({className:v.default("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",J?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsx("div",Object.assign({className:v.default("w-full",J?"mb-0":"mb-2")},{children:s.jsx(h.PickaxeMarkdown,Object.assign({theme:_.theme,colors:k},C&&{rtl:!0},q&&{disableHtml:!0},P&&{disableJs:!0},O&&{disableCss:!0},{children:s.jsx(b.PickaxeMarkdownRenderer,{style:{display:"block"},className:v.default("w-full",!J&&["[&_*]:!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"],J&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:W})}))})),s.jsx("div",Object.assign({className:"w-full"},{children:s.jsx(h.PickaxeMarkdown,Object.assign({theme:_.theme,colors:k},C&&{rtl:!0},q&&{disableHtml:!0},P&&{disableJs:!0},O&&{disableCss:!0},{children:s.jsx(b.PickaxeMarkdownRenderer,{style:{display:"block"},className:v.default("w-full text-sm",!J&&["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"],J&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:Z,suppressedRichPreviewUrls:ee})}))}))]})),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==y?void 0:y.chatflag)||!(null==y?void 0:y.chatflag)&&(null==y?void 0:y.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=j.sessionId,S([]),R([]),I(!1),M(s)},title:(null==N?void 0:N["open-chat"])||"Open Chat"},{children:[s.jsx(d.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"text-sm font-medium"},{children:Q}))]})),s.jsx("button",Object.assign({className:"transition-colors "+(z?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(Z),A(!0),setTimeout((()=>{A(!1)}),2e3)},title:z?(null==N?void 0:N.copied)||"Copied!":(null==N?void 0:N["copy-assistant-message"])||"Copy assistant message"},{children:z?s.jsx(m.default,{className:"h-4 w-4",style:{color:k.accent},fill:k.accent}):s.jsx(u.default,{className:"h-4 w-4"})}))]})),s.jsx("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:V}))]}))]}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),o=require("../../../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../Addons/Auth/hooks/useAuthContext.js"),i=require("../../../../../../hooks/pickaxe/useSubmitDocument.js"),l=require("../../hooks/usePickaxeMarkdownContext.js"),n=require("../../../../../Icons/download.svg.js"),r=require("../../../../../Icons/copy.svg.js"),c=require("../../../../../Icons/copied.svg.js"),d=require("../../../../../Icons/file.svg.js"),u=require("../../../../../Icons/upload-cloud.svg.js"),p=require("copy-to-clipboard"),m=require("../../../../../../common/error.js");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=f(p);const b=new Set(["jpeg","jpg","gif","bmp","webp","svg","tiff","avif","png","jfif","pjpeg","pjp"]),g=new Set(["mp3","wav","ogg","flac","aac","wma","alac","m4a","aiff","ape","au","mid","midi","opus"]),v=new Set(["mp4","webm","mov","avi","mkv","m4v"]),h=new Set(["csv","tsv","txt","json","xml","md","log","yaml","yml"]),w=new Set(["doc","docx","xls","xlsx","ppt","pptx"]),j=e=>b.has(e)?"image":g.has(e)?"audio":v.has(e)?"video":"pdf"===e?"pdf":"html"===e||"htm"===e?"html":h.has(e)?"text":w.has(e)?"office":"file",k=e=>{const t=(e=>{let t=e.trim();for(;/[),.;!?]$/.test(t);)t=t.slice(0,-1);return t})(e);return t.startsWith("http://")?`https://${t.slice(7)}`:t.startsWith("www.")?`https://${t}`:t};exports.default=({fileInfo:p,displayName:f})=>{const{theme:b,colors:g,disableHtml:v,disableJs:h}=l.usePickaxeMarkdownContext(),{contextId:w,pickaxeId:j,pickaxe:k,translations:y}=o.usePickaxeContext(),{isLoggedIn:N,token:C}=a.useAuthContext(),O=i.useSubmitDocument(),[S,I]=s.useState(!1),[q,F]=s.useState(!1),[D,$]=s.useState(!1),_=(e,t)=>{var s;return null!==(s=null==y?void 0:y[e])&&void 0!==s?s:t},P="dark"===b?"#30363D":"#D0D7DE",R="dark"===b?"#0D1117":"#F6F8FA",T="dark"===b?"#161B22":"#FFFFFF",U=(null==f?void 0:f.trim())||p.fileName,A=U!==p.fileName,B={display:"inline-flex",width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:4,color:g.accentText,backgroundColor:g.accent,opacity:.88,flexShrink:0},E=(e,s,o)=>t.jsx("div",Object.assign({className:"flex w-full p-4"},{children:t.jsxs("div",Object.assign({className:"relative w-full overflow-hidden rounded-md shadow-sm",style:{aspectRatio:"8.5 / 11",backgroundColor:T,border:`1px solid ${P}`}},{children:[t.jsx("iframe",Object.assign({src:e,title:s},o,{className:"h-full w-full",scrolling:"no",tabIndex:-1,style:{border:"none",pointerEvents:"none"}})),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10",style:{background:"dark"===b?"linear-gradient(to top, rgba(22,27,34,0.95), rgba(22,27,34,0))":"linear-gradient(to top, rgba(255,255,255,0.95), rgba(255,255,255,0))"}})]}))}));return t.jsxs("div",Object.assign({className:"my-2 w-full overflow-hidden rounded-lg",style:{border:`1px solid ${P}`,backgroundColor:R,color:g.secondaryText}},{children:[t.jsxs("div",Object.assign({className:"flex items-center justify-between gap-3 border-b px-3 py-2",style:{borderColor:P}},{children:[t.jsx("a",Object.assign({href:p.url,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 flex-1 truncate text-sm font-semibold hover:underline",style:{color:g.secondaryText},title:A?`${U} (${p.fileName})`:U},{children:U})),t.jsxs("div",Object.assign({className:"flex shrink-0 items-center gap-1.5"},{children:[t.jsx("button",Object.assign({type:"button",onClick:()=>{const e=document.createElement("a");e.href=p.url,e.download=p.fileName,e.target="_blank",e.rel="noopener noreferrer",e.click()},title:_("download","Download"),"aria-label":_("download","Download"),style:B},{children:t.jsx(n.default,{className:"h-[18px] w-[18px]"})})),t.jsx("button",Object.assign({type:"button",onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){try{I(!0),x.default(p.url),yield new Promise((e=>setTimeout(e,1500)))}finally{I(!1)}}))},title:S?_("copied","Copied"):_("copy-link","Copy link"),"aria-label":S?_("copied","Copied"):_("copy-link","Copy link"),style:Object.assign(Object.assign({},B),{opacity:S?1:B.opacity})},{children:S?t.jsx(c.default,{className:"h-[18px] w-[18px]"}):t.jsx(r.default,{className:"h-[18px] w-[18px]"})})),N&&C&&t.jsx("button",Object.assign({type:"button",disabled:q||D,onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if(C&&!q){F(!0),$(!1);try{const e=yield fetch(p.url);if(!e.ok)throw new Error("Failed to download generated file.");const t=yield e.blob(),s=new File([t],p.fileName,{type:t.type||"application/octet-stream"});yield O.document(Object.assign(Object.assign({contextId:w,pickaxeId:j,file:s},(null==k?void 0:k.workspaceid)&&{workspaceId:k.workspaceid}),{studioSessionToken:C,isUserDocument:!0})),$(!0),yield new Promise((e=>setTimeout(e,1500)))}catch(e){alert(m.default(e))}finally{F(!1),$(!1)}}}))},title:q?_("saving","Saving..."):D?_("saved","Saved"):_("save-to-knowledge-base","Save to Knowledge Base"),"aria-label":q?_("saving","Saving..."):D?_("saved","Saved"):_("save-to-knowledge-base","Save to Knowledge Base"),style:Object.assign(Object.assign({},B),{opacity:q||D?.55:B.opacity,cursor:q||D?"not-allowed":"pointer"})},{children:t.jsx(u.default,{className:"h-[18px] w-[18px]"})}))]}))]})),t.jsx("div",{children:(()=>{if("image"===p.kind)return t.jsx("img",{src:p.url,alt:p.fileName,className:"block max-h-[420px] w-full object-contain"});if("audio"===p.kind)return t.jsx("div",Object.assign({className:"flex min-h-[72px] items-center p-4"},{children:t.jsx("audio",{className:"w-full",controls:!0,src:p.url})}));if("video"===p.kind)return t.jsx("video",{className:"block max-h-[420px] w-full bg-black",controls:!0,preload:"metadata",src:p.url});if("pdf"===p.kind||"text"===p.kind){const e="pdf"===p.kind?`${p.url}#page=1&toolbar=0&navpanes=0&scrollbar=0&view=FitH`:p.url;return E(e,p.fileName)}if("html"===p.kind&&!v){const e=["allow-same-origin","allow-forms","allow-popups","allow-downloads","allow-modals",h?"":"allow-scripts"].filter(Boolean).join(" ");return E(p.url,p.fileName,{sandbox:e})}return"office"===p.kind?E(`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(p.url)}`,p.fileName):t.jsxs("div",Object.assign({className:"flex min-h-[120px] items-center justify-center gap-3 p-6 text-sm"},{children:[t.jsx(d.default,{className:"h-8 w-8 shrink-0"}),t.jsx("span",Object.assign({className:"break-all"},{children:p.extension.toUpperCase()}))]}))})()})]}))},exports.getFilePreviewInfo=e=>{var t,s;try{const o=k(e),a=new URL(o);if("https:"!==a.protocol&&"http:"!==a.protocol)return null;const i=a.pathname.split("/").filter(Boolean).pop();if(!i)return null;const l=decodeURIComponent(i),n=null===(s=null===(t=l.match(/\.([a-z0-9]{1,10})$/i))||void 0===t?void 0:t[1])||void 0===s?void 0:s.toLowerCase();return n?{url:o,fileName:l,extension:n,kind:j(n)}:null}catch(e){return null}},exports.normalizeMarkdownUrl=k,exports.shouldRenderFilePreview=(e,t)=>!!e&&(!t||!t.current.has(e.url)&&(t.current.add(e.url),!0));
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"),r=require("../../../../../../hooks/pickaxe/useSubmitDocument.js"),l=require("../../hooks/usePickaxeMarkdownContext.js"),n=require("../../../../../Icons/download.svg.js"),a=require("../../../../../Icons/copy.svg.js"),c=require("../../../../../Icons/copied.svg.js"),d=require("../../../../../Icons/file.svg.js"),u=require("../../../../../Icons/upload-cloud.svg.js"),p=require("copy-to-clipboard"),m=require("../../../../../../common/error.js");function f(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var x=f(p);const h=/(?:https?:\/\/|www\.)[^\s<>"']+/gi,v=new Set(["jpeg","jpg","gif","bmp","webp","svg","tiff","avif","png","jfif","pjpeg","pjp"]),w=new Set(["mp3","wav","ogg","flac","aac","wma","alac","m4a","aiff","ape","au","mid","midi","opus"]),b=new Set(["mp4","webm","mov","avi","mkv","m4v"]),g=new Set(["csv","tsv","txt","json","xml","md","log","yaml","yml"]),j=new Set(["doc","docx","xls","xlsx","ppt","pptx"]),k=new Set(["pdf","html","htm",...g,...j]),y=e=>v.has(e)?"image":w.has(e)?"audio":b.has(e)?"video":"pdf"===e?"pdf":"html"===e||"htm"===e?"html":g.has(e)?"text":j.has(e)?"office":"file",N=e=>{const t=(e=>{let t=e.trim();for(;/[),.;!?]$/.test(t);)t=t.slice(0,-1);return t})(e);return t.startsWith("http://")?`https://${t.slice(7)}`:t.startsWith("www.")?`https://${t}`:t},C=e=>{try{return new URL(N(e)).pathname.includes("/action_generated_files/")}catch(e){return!1}},S=e=>{try{return new URL(N(e)).pathname.includes("/documentinterrogation/")}catch(e){return!1}},O=e=>{const t=N(e);if(C(t))return!1;if(S(t))return!0;if((e=>{const t=N(e);return/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i.test(t)||/loom\.com\/(?:share|embed)\/([\w-]+)/i.test(t)||/vimeo\.com\/(?:video\/)?(\d+)/i.test(t)||/streamable\.com\/([\w-]+)/i.test(t)})(t))return!0;const o=(e=>{var t,o,s,i;try{const r=new URL(N(e));return"https:"!==r.protocol&&"http:"!==r.protocol?null:null!==(i=null===(s=null===(o=null===(t=r.pathname.split("/").filter(Boolean).pop())||void 0===t?void 0:t.match(/\.([a-z0-9]{1,10})$/i))||void 0===o?void 0:o[1])||void 0===s?void 0:s.toLowerCase())&&void 0!==i?i:null}catch(e){return null}})(t);return!!o&&k.has(o)},I=(e,t)=>{const o=N(e);return O(o)||(null==t?void 0:t.has(o))};exports.default=({fileInfo:p,displayName:f})=>{const{theme:h,colors:v,disableHtml:w,disableJs:b}=l.usePickaxeMarkdownContext(),{contextId:g,pickaxeId:j,pickaxe:k,translations:y}=s.usePickaxeContext(),{isLoggedIn:N,token:C}=i.useAuthContext(),S=r.useSubmitDocument(),[O,I]=o.useState(!1),[F,q]=o.useState(!1),[U,P]=o.useState(!1),R=(e,t)=>{var o;return null!==(o=null==y?void 0:y[e])&&void 0!==o?o:t},_="dark"===h?"#30363D":"#D0D7DE",D="dark"===h?"#0D1117":"#F6F8FA",$="dark"===h?"#161B22":"#FFFFFF",L=(null==f?void 0:f.trim())||p.fileName,T=L!==p.fileName,A={display:"inline-flex",width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:4,color:v.accentText,backgroundColor:v.accent,opacity:.88,flexShrink:0},B=(e,o,s)=>t.jsx("div",Object.assign({className:"flex w-full p-4"},{children:t.jsxs("div",Object.assign({className:"relative w-full overflow-hidden rounded-md shadow-sm",style:{aspectRatio:"8.5 / 11",backgroundColor:$,border:`1px solid ${_}`}},{children:[t.jsx("iframe",Object.assign({src:e,title:o},s,{className:"h-full w-full",scrolling:"no",tabIndex:-1,style:{border:"none",pointerEvents:"none"}})),t.jsx("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10",style:{background:"dark"===h?"linear-gradient(to top, rgba(22,27,34,0.95), rgba(22,27,34,0))":"linear-gradient(to top, rgba(255,255,255,0.95), rgba(255,255,255,0))"}})]}))}));return t.jsxs("div",Object.assign({className:"my-2 w-full overflow-hidden rounded-lg",style:{border:`1px solid ${_}`,backgroundColor:D,color:v.secondaryText}},{children:[t.jsxs("div",Object.assign({className:"flex items-center justify-between gap-3 border-b px-3 py-2",style:{borderColor:_}},{children:[t.jsx("a",Object.assign({href:p.url,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 flex-1 truncate text-sm font-semibold hover:underline",style:{color:v.secondaryText},title:T?`${L} (${p.fileName})`:L},{children:L})),t.jsxs("div",Object.assign({className:"flex shrink-0 items-center gap-1.5"},{children:[t.jsx("button",Object.assign({type:"button",onClick:()=>{const e=document.createElement("a");e.href=p.url,e.download=p.fileName,e.target="_blank",e.rel="noopener noreferrer",e.click()},title:R("download","Download"),"aria-label":R("download","Download"),style:A},{children:t.jsx(n.default,{className:"h-[18px] w-[18px]"})})),t.jsx("button",Object.assign({type:"button",onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){try{I(!0),x.default(p.url),yield new Promise((e=>setTimeout(e,1500)))}finally{I(!1)}}))},title:O?R("copied","Copied"):R("copy-link","Copy link"),"aria-label":O?R("copied","Copied"):R("copy-link","Copy link"),style:Object.assign(Object.assign({},A),{opacity:O?1:A.opacity})},{children:O?t.jsx(c.default,{className:"h-[18px] w-[18px]"}):t.jsx(a.default,{className:"h-[18px] w-[18px]"})})),N&&C&&t.jsx("button",Object.assign({type:"button",disabled:F||U,onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if(C&&!F){q(!0),P(!1);try{const e=yield fetch(p.url);if(!e.ok)throw new Error("Failed to download generated file.");const t=yield e.blob(),o=new File([t],p.fileName,{type:t.type||"application/octet-stream"});yield S.document(Object.assign(Object.assign({contextId:g,pickaxeId:j,file:o},(null==k?void 0:k.workspaceid)&&{workspaceId:k.workspaceid}),{studioSessionToken:C,isUserDocument:!0})),P(!0),yield new Promise((e=>setTimeout(e,1500)))}catch(e){alert(m.default(e))}finally{q(!1),P(!1)}}}))},title:F?R("saving","Saving..."):U?R("saved","Saved"):R("save-to-knowledge-base","Save to Knowledge Base"),"aria-label":F?R("saving","Saving..."):U?R("saved","Saved"):R("save-to-knowledge-base","Save to Knowledge Base"),style:Object.assign(Object.assign({},A),{opacity:F||U?.55:A.opacity,cursor:F||U?"not-allowed":"pointer"})},{children:t.jsx(u.default,{className:"h-[18px] w-[18px]"})}))]}))]})),t.jsx("div",{children:(()=>{if("image"===p.kind)return t.jsx("img",{src:p.url,alt:p.fileName,className:"block max-h-[420px] w-full object-contain"});if("audio"===p.kind)return t.jsx("div",Object.assign({className:"flex min-h-[72px] items-center p-4"},{children:t.jsx("audio",{className:"w-full",controls:!0,src:p.url})}));if("video"===p.kind)return t.jsx("video",{className:"block max-h-[420px] w-full bg-black",controls:!0,preload:"metadata",src:p.url});if("pdf"===p.kind||"text"===p.kind){const e="pdf"===p.kind?`${p.url}#page=1&toolbar=0&navpanes=0&scrollbar=0&view=FitH`:p.url;return B(e,p.fileName)}if("html"===p.kind&&!w){const e=["allow-same-origin","allow-forms","allow-popups","allow-downloads","allow-modals",b?"":"allow-scripts"].filter(Boolean).join(" ");return B(p.url,p.fileName,{sandbox:e})}return"office"===p.kind?B(`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(p.url)}`,p.fileName):t.jsxs("div",Object.assign({className:"flex min-h-[120px] items-center justify-center gap-3 p-6 text-sm"},{children:[t.jsx(d.default,{className:"h-8 w-8 shrink-0"}),t.jsx("span",Object.assign({className:"break-all"},{children:p.extension.toUpperCase()}))]}))})()})]}))},exports.getFilePreviewInfo=e=>{var t,o;try{const s=N(e),i=new URL(s);if("https:"!==i.protocol&&"http:"!==i.protocol)return null;const r=i.pathname.split("/").filter(Boolean).pop();if(!r)return null;const l=decodeURIComponent(r),n=null===(o=null===(t=l.match(/\.([a-z0-9]{1,10})$/i))||void 0===t?void 0:t[1])||void 0===o?void 0:o.toLowerCase();return n?{url:s,fileName:l,extension:n,kind:y(n)}:null}catch(e){return null}},exports.isDocumentSourceUrl=S,exports.isGeneratedFileUrl=C,exports.isSourceLikeRichPreviewUrl=O,exports.normalizeMarkdownUrl=N,exports.shouldRenderFilePreview=(e,t)=>!!e&&(!t||!t.current.has(e.url)&&(t.current.add(e.url),!0)),exports.shouldSuppressRichPreviewForUrl=I,exports.shouldSuppressRichPreviewInText=(e,t)=>{for(const o of e.matchAll(h))if(I(o[0],t))return!0;return!1};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../hooks/usePickaxeMarkdownContext.js"),o=require("../common/IframeVideo.js"),i=require("./FilePreview.js");const s=e=>{let t="";return r.Children.forEach(e,(e=>{"string"!=typeof e&&"number"!=typeof e?r.isValidElement(e)&&(t+=s(e.props.children)):t+=e})),t.trim().replace(/\s+/g," ")};exports.A=({href:l="",children:n,filePreviewSeenRef:c})=>{const{colors:m}=t.usePickaxeMarkdownContext(),a=r.useMemo((()=>l?i.normalizeMarkdownUrl(l):""),[l]),u=r.useMemo((()=>i.getFilePreviewInfo(a)),[a]),d=r.useMemo((()=>((e,r)=>{const t=s(e);if(t&&t!==r&&i.normalizeMarkdownUrl(t)!==r)return t})(n,a)),[n,a]),f=r.useMemo((()=>{if(u)return null;const e=a.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const r=a.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(r)return{title:"loom-embed",src:`https://www.loom.com/embed/${r[1]}`};const t=a.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(t)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${t[1]}`};const o=a.match(/streamable\.com\/([\w-]+)/i);return o?{title:"streamable-embed",src:`https://streamable.com/e/${o[1]}`}:null}),[u,a]);return f?e.jsx(o.default,{title:f.title,src:f.src}):u&&i.shouldRenderFilePreview(u,c)?e.jsx(i.default,{fileInfo:u,displayName:d}):e.jsx("a",Object.assign({href:a,target:"_blank",rel:"noopener noreferrer",style:{color:m.accent}},{children:n}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),r=require("react"),t=require("../../hooks/usePickaxeMarkdownContext.js"),o=require("../common/IframeVideo.js"),s=require("./FilePreview.js");const i=e=>{let t="";return r.Children.forEach(e,(e=>{"string"!=typeof e&&"number"!=typeof e?r.isValidElement(e)&&(t+=i(e.props.children)):t+=e})),t.trim().replace(/\s+/g," ")};exports.A=({href:l="",children:n,filePreviewSeenRef:c,suppressedRichPreviewUrls:m})=>{const{colors:u}=t.usePickaxeMarkdownContext(),a=r.useMemo((()=>l?s.normalizeMarkdownUrl(l):""),[l]),d=r.useMemo((()=>s.shouldSuppressRichPreviewForUrl(a,m)),[a,m]),h=r.useMemo((()=>s.getFilePreviewInfo(a)),[a]),f=r.useMemo((()=>((e,r)=>{const t=i(e);if(t&&t!==r&&s.normalizeMarkdownUrl(t)!==r)return t})(n,a)),[n,a]),w=r.useMemo((()=>{if(d)return null;if(h)return null;const e=a.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const r=a.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(r)return{title:"loom-embed",src:`https://www.loom.com/embed/${r[1]}`};const t=a.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(t)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${t[1]}`};const o=a.match(/streamable\.com\/([\w-]+)/i);return o?{title:"streamable-embed",src:`https://streamable.com/e/${o[1]}`}:null}),[h,a,d]);return w?e.jsx(o.default,{title:w.title,src:w.src}):h&&!d&&s.shouldRenderFilePreview(h,c)?e.jsx(s.default,{fileInfo:h,displayName:f}):e.jsx("a",Object.assign({href:a,target:"_blank",rel:"noopener noreferrer",style:{color:u.accent}},{children:n}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../common/IframeVideo.js");exports.P=({children:o})=>{const m=t.useMemo((()=>{if("string"!=typeof o)return null;const e=o.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const t=o.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(t)return{title:"loom-embed",src:`https://www.loom.com/embed/${t[1]}`};const r=o.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(r)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${r[1]}`};const m=o.match(/streamable\.com\/([\w-]+)/i);return m?{title:"streamable-embed",src:`https://streamable.com/e/${m[1]}`}:null}),[o]);return m?e.jsx(r.default,{title:m.title,src:m.src}):e.jsx("p",{children:o})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../common/IframeVideo.js"),o=require("../A/FilePreview.js");exports.P=({children:s,suppressedRichPreviewUrls:i})=>{const c=t.useMemo((()=>{if("string"!=typeof s)return null;if(o.shouldSuppressRichPreviewInText(s,i))return null;const e=s.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const t=s.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(t)return{title:"loom-embed",src:`https://www.loom.com/embed/${t[1]}`};const r=s.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(r)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${r[1]}`};const c=s.match(/streamable\.com\/([\w-]+)/i);return c?{title:"streamable-embed",src:`https://streamable.com/e/${c[1]}`}:null}),[s,i]);return c?e.jsx(r.default,{title:c.title,src:c.src}):e.jsx("p",{children:s})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),i=require("./utils/custom-plugins.js"),s=require("react-markdown"),a=require("remark-gfm"),o=require("remark-math"),l=require("rehype-katex"),c=require("rehype-raw"),u=require("./Components/A/index.js"),d=require("./Components/A/FilePreview.js"),p=require("./Components/P/index.js"),f=require("./Components/Img/index.js"),h=require("./Components/Iframe/index.js"),m=require("./Components/Code/index.js"),x=require("./Components/Headings/index.js"),g=require("./Components/List/index.js"),j=require("./Components/Table/index.js"),b=require("./Components/Others/index.js"),k=require("./Components/Action/index.js"),q=require("./Components/Artifact/index.js"),C=require("./Components/Others/Think.js"),w=require("../../../../common/cn.js");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=v(s),O=v(a),$=v(o),P=v(l),S=v(c);exports.PickaxeMarkdownRenderer=({className:s,style:a,children:o,value:l,maxLines:c,maxChars:v,multiLineBreaks:A,onExpandClick:H,filePreviewSeenRef:T})=>{const{colors:M,rtl:R,disableHtml:I,disableJs:_,disableCss:N}=t.usePickaxeMarkdownContext(),[E,L]=n.useState({width:0,height:0}),[B,F]=n.useState(null),z=n.useRef(null),J=n.useMemo((()=>{if(!l)return"";let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),A&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,A]);n.useEffect((()=>{if(v)return void F(J.length>v?J.slice(0,v)+'<span class="pxe-expand-btn">...</span>':null);if(!c)return void F(null);if(!z.current||!J||B)return;const e=z.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=c*r;if(!(E.height>n))return;const t=Math.floor(E.width/8),i=Math.floor(t*c);F(J.slice(0,i)+'<span class="pxe-expand-btn">...</span>')}),[J,c,v,E,B]);const W=n.useRef(new Set);T||(W.current=new Set);const D=null!=T?T:W,Q={h1:x.H1,h2:x.H2,h3:x.H3,h4:x.H4,h5:x.H5,p:p.P,a:e=>r.jsx(u.A,Object.assign({},e,{filePreviewSeenRef:D})),img:e=>{const n="string"==typeof e.src?e.src:"",t=d.getFilePreviewInfo(n);return t?d.shouldRenderFilePreview(t,D)?r.jsx(d.default,{fileInfo:t,displayName:"string"==typeof e.alt?e.alt:void 0}):r.jsx("a",Object.assign({href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:M.accent}},{children:e.alt||t.fileName})):r.jsx(f.Img,Object.assign({},e))},iframe:h.Iframe,code:m.Code,ol:g.Ol,ul:g.Ul,li:g.Li,table:j.Table,th:j.Th,tr:j.Tr,td:j.Td,hr:b.Hr,br:b.Br,blockquote:b.Blockquote,span:n=>{var{children:t}=n,i=e.__rest(n,["children"]);return"pxe-expand-btn"===i.className?r.jsx("span",Object.assign({},i,{style:Object.assign({display:"inline",fontWeight:500,color:M.accent,marginLeft:".25rem",userSelect:"none"},H&&{cursor:"pointer"})},H&&{onClick:H},{children:t})):r.jsx("span",Object.assign({},i,{children:t}))},"action-caption":k.ActionCaption,"action-finished":k.ActionFinished,"action-error":k.ActionError,artifact:q.Artifact,"artifact-error":q.ArtifactError,think:C.Think};n.useEffect((()=>{if(!z.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;L({width:e,height:n})}}));return e.observe(z.current),()=>{e.disconnect()}}),[]);const U=B||J;return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:z,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},a)},R&&{dir:"rtl"},{children:[r.jsx(y.default,Object.assign({className:w.default("pxe-prose",s),components:Q,remarkPlugins:[O.default,[$.default,{singleDollarTextMath:!1}],i.remarkSmartQuotes],rehypePlugins:[i.rehypeCode,P.default,...I?[]:[S.default],[i.rehypeSanitize,{disableJs:_,disableCss:N}]]},{children:U})),o]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),s=require("./utils/custom-plugins.js"),i=require("react-markdown"),a=require("remark-gfm"),o=require("remark-math"),l=require("rehype-katex"),c=require("rehype-raw"),u=require("./Components/A/index.js"),d=require("./Components/A/FilePreview.js"),p=require("./Components/P/index.js"),h=require("./Components/Img/index.js"),f=require("./Components/Iframe/index.js"),m=require("./Components/Code/index.js"),x=require("./Components/Headings/index.js"),g=require("./Components/List/index.js"),j=require("./Components/Table/index.js"),b=require("./Components/Others/index.js"),w=require("./Components/Action/index.js"),k=require("./Components/Artifact/index.js"),q=require("./Components/Others/Think.js"),C=require("../../../../common/cn.js");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var y=v(i),P=v(a),O=v(o),$=v(l),S=v(c);exports.PickaxeMarkdownRenderer=({className:i,style:a,children:o,value:l,maxLines:c,maxChars:v,multiLineBreaks:R,onExpandClick:A,filePreviewSeenRef:H,suppressedRichPreviewUrls:T})=>{const{colors:M,rtl:I,disableHtml:_,disableJs:N,disableCss:E}=t.usePickaxeMarkdownContext(),[F,L]=n.useState({width:0,height:0}),[U,B]=n.useState(null),z=n.useRef(null),J=n.useMemo((()=>{if(!l)return"";let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),R&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,R]);n.useEffect((()=>{if(v)return void B(J.length>v?J.slice(0,v)+'<span class="pxe-expand-btn">...</span>':null);if(!c)return void B(null);if(!z.current||!J||U)return;const e=z.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=c*r;if(!(F.height>n))return;const t=Math.floor(F.width/8),s=Math.floor(t*c);B(J.slice(0,s)+'<span class="pxe-expand-btn">...</span>')}),[J,c,v,F,U]);const W=n.useRef(new Set);H||(W.current=new Set);const D=null!=H?H:W,Q={h1:x.H1,h2:x.H2,h3:x.H3,h4:x.H4,h5:x.H5,p:e=>r.jsx(p.P,Object.assign({},e,{suppressedRichPreviewUrls:T})),a:e=>r.jsx(u.A,Object.assign({},e,{filePreviewSeenRef:D,suppressedRichPreviewUrls:T})),img:e=>{const n="string"==typeof e.src?e.src:"",t=d.getFilePreviewInfo(n);return t&&!d.shouldSuppressRichPreviewForUrl(t.url,T)?d.shouldRenderFilePreview(t,D)?r.jsx(d.default,{fileInfo:t,displayName:"string"==typeof e.alt?e.alt:void 0}):r.jsx("a",Object.assign({href:t.url,target:"_blank",rel:"noopener noreferrer",style:{color:M.accent}},{children:e.alt||t.fileName})):r.jsx(h.Img,Object.assign({},e))},iframe:f.Iframe,code:m.Code,ol:g.Ol,ul:g.Ul,li:g.Li,table:j.Table,th:j.Th,tr:j.Tr,td:j.Td,hr:b.Hr,br:b.Br,blockquote:b.Blockquote,span:n=>{var{children:t}=n,s=e.__rest(n,["children"]);return"pxe-expand-btn"===s.className?r.jsx("span",Object.assign({},s,{style:Object.assign({display:"inline",fontWeight:500,color:M.accent,marginLeft:".25rem",userSelect:"none"},A&&{cursor:"pointer"})},A&&{onClick:A},{children:t})):r.jsx("span",Object.assign({},s,{children:t}))},"action-caption":w.ActionCaption,"action-finished":w.ActionFinished,"action-error":w.ActionError,artifact:k.Artifact,"artifact-error":k.ArtifactError,think:q.Think};n.useEffect((()=>{if(!z.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;L({width:e,height:n})}}));return e.observe(z.current),()=>{e.disconnect()}}),[]);const G=U||J;return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:z,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},a)},I&&{dir:"rtl"},{children:[r.jsx(y.default,Object.assign({className:C.default("pxe-prose",i),components:Q,remarkPlugins:[P.default,[O.default,{singleDollarTextMath:!1}],s.remarkSmartQuotes],rehypePlugins:[s.rehypeCode,$.default,..._?[]:[S.default],[s.rehypeSanitize,{disableJs:N,disableCss:E}]]},{children:G})),o]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),r=require("../PickaxeMarkdown/Renderer.js"),t=require("../PickaxeMarkdown/Components/A/FilePreview.js"),i=require("../../../../common/utils.js"),s=require("../../../../common/cn.js");const a=n.lazy((()=>Promise.resolve().then((function(){return require("./TextPart/index.js")})))),o=n.lazy((()=>Promise.resolve().then((function(){return require("./ReasoningPart/index.js")})))),l=n.lazy((()=>Promise.resolve().then((function(){return require("./ActionToolCaptionPart/index.js")})))),u=n.lazy((()=>Promise.resolve().then((function(){return require("./ReasoningCaptionPart/index.js")})))),c=/(!?)\[([^\]\n]+)\]\((https?:\/\/[^\s)]+|www\.[^\s)]+)\)/g;exports.default=({className:d,parts:p})=>{const f=n.useRef(new Set);return f.current=new Set,e.jsx("div",Object.assign({className:s.default("flex flex-col gap-2",d)},{children:e.jsx(n.Suspense,Object.assign({fallback:e.jsx("div",{})},{children:p.map(((n,s)=>{if(!n.isVisible)return null;if("text"===n.type){const i=((e,n)=>{var r,i;const s=[];let a=0;for(const o of e.matchAll(c)){const l=null!==(r=o.index)&&void 0!==r?r:0,u=o[0],c="!"===o[1],d=null===(i=o[2])||void 0===i?void 0:i.trim(),p=o[3],f=t.getFilePreviewInfo(p);if(!f)continue;l>a&&s.push({type:"markdown",value:e.slice(a,l)});const v=d&&t.normalizeMarkdownUrl(d)!==f.url?d:void 0;t.shouldRenderFilePreview(f,n)?s.push({type:"preview",key:`${f.url}-${l}`,fileInfo:f,displayName:v}):s.push({type:"markdown",value:c?u:`[${d||f.fileName}](${f.url})`}),a=l+u.length}return a<e.length&&s.push({type:"markdown",value:e.slice(a)}),s.length?s:[{type:"markdown",value:e}]})(n.content,f);return e.jsx(a,{children:i.map(((n,i)=>"preview"===n.type?e.jsx(t.default,{fileInfo:n.fileInfo,displayName:n.displayName},n.key):n.value?e.jsx(r.PickaxeMarkdownRenderer,{value:n.value,filePreviewSeenRef:f},i):null))},s)}if("reasoning"===n.type)return e.jsx(o,Object.assign({isReasoning:s===p.length-1},{children:e.jsx(r.PickaxeMarkdownRenderer,{value:n.content})}),s);if("data-action-tool-caption"===n.type){const r=i.safeJSONParse(n.content);return e.jsx(l,Object.assign({},r&&r,{isLoading:s===p.length-1}),s)}if("data-reasoning-caption"===n.type){const r=i.safeJSONParse(n.content);return e.jsx(u,Object.assign({},r&&r,{isLoading:s===p.length-1}),s)}return null}))}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),r=require("../PickaxeMarkdown/Renderer.js"),s=require("../PickaxeMarkdown/Components/A/FilePreview.js"),t=require("../../../../common/utils.js"),i=require("../../../../common/cn.js");const a=n.lazy((()=>Promise.resolve().then((function(){return require("./TextPart/index.js")})))),o=n.lazy((()=>Promise.resolve().then((function(){return require("./ReasoningPart/index.js")})))),l=n.lazy((()=>Promise.resolve().then((function(){return require("./ActionToolCaptionPart/index.js")})))),u=n.lazy((()=>Promise.resolve().then((function(){return require("./ReasoningCaptionPart/index.js")})))),c=/(!?)\[([^\]\n]+)\]\((https?:\/\/[^\s)]+|www\.[^\s)]+)\)/g,d=e=>{const n=new Set;for(const r of e){if("data-tool-assets"!==r.type)continue;const e=t.safeJSONParse(r.content);if(null==e?void 0:e.assets)for(const r of e.assets)r.value&&!s.isGeneratedFileUrl(r.value)&&n.add(s.normalizeMarkdownUrl(r.value))}return n};exports.default=({className:p,parts:f})=>{const v=n.useRef(new Set);v.current=new Set;const x=d(f);return e.jsx("div",Object.assign({className:i.default("flex flex-col gap-2",p)},{children:e.jsx(n.Suspense,Object.assign({fallback:e.jsx("div",{})},{children:f.map(((n,i)=>{if(!n.isVisible)return null;if("text"===n.type){const t=((e,n,r)=>{var t,i;const a=[];let o=0;for(const l of e.matchAll(c)){const u=null!==(t=l.index)&&void 0!==t?t:0,c=l[0],d="!"===l[1],p=null===(i=l[2])||void 0===i?void 0:i.trim(),f=l[3],v=s.getFilePreviewInfo(f);if(!v)continue;if(s.shouldSuppressRichPreviewForUrl(v.url,r))continue;u>o&&a.push({type:"markdown",value:e.slice(o,u)});const x=p&&s.normalizeMarkdownUrl(p)!==v.url?p:void 0;s.shouldRenderFilePreview(v,n)?a.push({type:"preview",key:`${v.url}-${u}`,fileInfo:v,displayName:x}):a.push({type:"markdown",value:d?c:`[${p||v.fileName}](${v.url})`}),o=u+c.length}return o<e.length&&a.push({type:"markdown",value:e.slice(o)}),a.length?a:[{type:"markdown",value:e}]})(n.content,v,x);return e.jsx(a,{children:t.map(((n,t)=>"preview"===n.type?e.jsx(s.default,{fileInfo:n.fileInfo,displayName:n.displayName},n.key):n.value?e.jsx(r.PickaxeMarkdownRenderer,{value:n.value,filePreviewSeenRef:v,suppressedRichPreviewUrls:x},t):null))},i)}if("reasoning"===n.type)return e.jsx(o,Object.assign({isReasoning:i===f.length-1},{children:e.jsx(r.PickaxeMarkdownRenderer,{value:n.content,suppressedRichPreviewUrls:x})}),i);if("data-action-tool-caption"===n.type){const r=t.safeJSONParse(n.content);return e.jsx(l,Object.assign({},r&&r,{isLoading:i===f.length-1}),i)}if("data-reasoning-caption"===n.type){const r=t.safeJSONParse(n.content);return e.jsx(u,Object.assign({},r&&r,{isLoading:i===f.length-1}),i)}return null}))}))}))},exports.getSuppressedRichPreviewUrls=d;
@@ -7,7 +7,13 @@ export type FilePreviewInfo = {
7
7
  kind: FilePreviewKind;
8
8
  };
9
9
  export type FilePreviewSeenRef = MutableRefObject<Set<string>>;
10
+ export type SuppressedRichPreviewUrls = Set<string>;
10
11
  export declare const normalizeMarkdownUrl: (href: string) => string;
12
+ export declare const isGeneratedFileUrl: (href: string) => boolean;
13
+ export declare const isDocumentSourceUrl: (href: string) => boolean;
14
+ export declare const isSourceLikeRichPreviewUrl: (href: string) => boolean;
15
+ export declare const shouldSuppressRichPreviewForUrl: (href: string, suppressedRichPreviewUrls?: SuppressedRichPreviewUrls) => boolean | undefined;
16
+ export declare const shouldSuppressRichPreviewInText: (value: string, suppressedRichPreviewUrls?: SuppressedRichPreviewUrls) => boolean;
11
17
  export declare const getFilePreviewInfo: (href: string) => FilePreviewInfo | null;
12
18
  export declare const shouldRenderFilePreview: (fileInfo: FilePreviewInfo | null, seenRef?: FilePreviewSeenRef) => boolean;
13
19
  interface FilePreviewProps {
@@ -1,7 +1,8 @@
1
1
  import type { MarkdownComponent } from "../..";
2
- import type { FilePreviewSeenRef } from "./FilePreview";
2
+ import type { FilePreviewSeenRef, SuppressedRichPreviewUrls } from "./FilePreview";
3
3
  type AProps = Parameters<MarkdownComponent<"a">>[0] & {
4
4
  filePreviewSeenRef?: FilePreviewSeenRef;
5
+ suppressedRichPreviewUrls?: SuppressedRichPreviewUrls;
5
6
  };
6
- export declare const A: ({ href, children, filePreviewSeenRef }: AProps) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const A: ({ href, children, filePreviewSeenRef, suppressedRichPreviewUrls, }: AProps) => import("react/jsx-runtime").JSX.Element;
7
8
  export {};
@@ -1,2 +1,7 @@
1
1
  import type { MarkdownComponent } from "../..";
2
- export declare const P: MarkdownComponent<"p">;
2
+ import type { SuppressedRichPreviewUrls } from "../A/FilePreview";
3
+ type PProps = Parameters<MarkdownComponent<"p">>[0] & {
4
+ suppressedRichPreviewUrls?: SuppressedRichPreviewUrls;
5
+ };
6
+ export declare const P: ({ children, suppressedRichPreviewUrls }: PProps) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode, type CSSProperties } from "react";
2
- import { type FilePreviewSeenRef } from "./Components/A/FilePreview";
2
+ import { type FilePreviewSeenRef, type SuppressedRichPreviewUrls } from "./Components/A/FilePreview";
3
3
  export interface PickaxeMarkdownRendererProps {
4
4
  className?: string;
5
5
  style?: CSSProperties;
@@ -10,5 +10,6 @@ export interface PickaxeMarkdownRendererProps {
10
10
  multiLineBreaks?: boolean;
11
11
  onExpandClick?: () => void;
12
12
  filePreviewSeenRef?: FilePreviewSeenRef;
13
+ suppressedRichPreviewUrls?: SuppressedRichPreviewUrls;
13
14
  }
14
- export declare const PickaxeMarkdownRenderer: ({ className, style, children: _children, value, maxLines, maxChars, multiLineBreaks, onExpandClick, filePreviewSeenRef, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const PickaxeMarkdownRenderer: ({ className, style, children: _children, value, maxLines, maxChars, multiLineBreaks, onExpandClick, filePreviewSeenRef, suppressedRichPreviewUrls, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,9 @@
1
1
  import type { PickaxeHistoryMessagePart } from "../../../../types/history";
2
+ import { type SuppressedRichPreviewUrls } from "../PickaxeMarkdown/Components/A/FilePreview";
2
3
  interface PickaxeMessagePartsProps {
3
4
  className?: string;
4
5
  parts: PickaxeHistoryMessagePart[];
5
6
  }
7
+ export declare const getSuppressedRichPreviewUrls: (parts: PickaxeHistoryMessagePart[]) => SuppressedRichPreviewUrls;
6
8
  declare const PickaxeMessageParts: ({ className, parts, }: PickaxeMessagePartsProps) => import("react/jsx-runtime").JSX.Element;
7
9
  export default PickaxeMessageParts;
@@ -35,7 +35,7 @@ export type PickaxeHistoryMessage = {
35
35
  createdAt: string;
36
36
  area?: PickaxeHistoryMessageArea;
37
37
  };
38
- export type PickaxeHistoryMessagePartsType = "text" | "reasoning" | "data-action-tool-caption" | "data-reasoning-caption";
38
+ export type PickaxeHistoryMessagePartsType = "text" | "reasoning" | "data-action-tool-caption" | "data-reasoning-caption" | "data-tool-assets";
39
39
  export type PickaxeHistoryMessagePart = {
40
40
  type: PickaxeHistoryMessagePartsType;
41
41
  content: string;
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as s,jsx as t,Fragment as o}from"react/jsx-runtime";import{useState as n,useRef as a,useEffect as i,useMemo as r}from"react";import{usePickaxeContext as l}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{format as m}from"date-fns";import p from"../../../../common/api/pickaxe.js";import{Check as u,X as h,MoreHorizontal as b,Pencil as f}from"lucide-react";import g from"../../../Icons/trash-2.svg.js";import v from"../../../Icons/chat.svg.js";import y from"../../../Icons/copy.svg.js";import x from"../../../Icons/copied.svg.js";import j from"../../../Icons/expand.svg.js";import w from"../../../Icons/collapse.svg.js";import{PickaxeMarkdown as k}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as N}from"../../common/PickaxeMarkdown/Renderer.js";import C from"../../../../common/cn.js";const O=({item:O,onDelete:_})=>{const{pickaxe:I,sender:P,colors:M,translations:R,styles:D,isRtl:E,disableCss:T,disableHtml:q,disableJs:F,setSessionId:S,setIsNewChat:$}=l(),{setMessages:A}=c(),{setDocuments:H}=d(),[J,z]=n(!1),[L,B]=n(!1),[K,G]=n(!1),[Q,U]=n(!1),[V,W]=n(!1),X=a(null),[Y,Z]=n(O.shortSummary||O.summary||(null==R?void 0:R["conversation-name"])||"Conversation name"),[ee,se]=n("");i((()=>{Z(O.shortSummary||O.summary||(null==R?void 0:R["conversation-name"])||"Conversation name")}),[O.shortSummary,O.summary,R]),i((()=>{const e=e=>{X.current&&!X.current.contains(e.target)&&z(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const te=r((()=>O?"FORM"===O.pickaxeType&&0===O.messages.length?O.question.responseParts?O.question.responseParts.length:0:O.messages.length:0),[O]),oe=r((()=>m(new Date(O.updatedAt),"MMM dd, yyy hh:mm a")),[O]),ne=r((()=>{var e;const s=(null==R?void 0:R["not-available"])||"n/a";if("FORM"===O.pickaxeType){if(O.messages&&0!==O.messages.length){const e=O.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const t=null!==(e=O.question.inputs)&&void 0!==e?e:[];return V?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||s}</p>\n</div>`)).join(""):t.map((e=>`${e.question}: ${e.answer||s}`)).join(" | ")}const t=O.messages.find((e=>"user"===e.role));return t?t.parts[0].content:""}),[O,V,R]),ae=r((()=>{if("FORM"===O.pickaxeType){if(O.messages&&0!==O.messages.length){const e=O.messages.find((e=>"assistant"===e.role));return e?e.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" "):""}return O.question.responseParts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")}const e=O.messages.find((e=>"assistant"===e.role));return e?e.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" "):""}),[O]),ie=()=>{B(!1),se("")},re=()=>e(void 0,void 0,void 0,(function*(){if(ee.trim()){G(!0);try{yield p.post("/edit_conversation_name",{sessionId:O.sessionId,name:ee,userId:P}),Z(ee),B(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==R?void 0:R["failed-update-name"])||"Failed to update name.")}finally{G(!1)}}}));return s("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:M.secondary,borderRadius:D.cornerRadius}},{children:[t("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:M.primary,color:M.text}},{children:L?s("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[t("input",{autoFocus:!0,type:"text",value:ee,onChange:e=>se(e.target.value),onKeyDown:e=>{"Enter"===e.key&&re(),"Escape"===e.key&&ie()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:M.primary,borderColor:M.secondary}}),t("button",Object.assign({onClick:re,disabled:K,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==R?void 0:R.save)||"Save"},{children:t(u,{className:"h-4 w-4"})})),t("button",Object.assign({onClick:ie,disabled:K,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==R?void 0:R.cancel)||"Cancel"},{children:t(h,{className:"h-4 w-4"})}))]})):s(o,{children:[t("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:Y})),s("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[t("button",Object.assign({onClick:e=>{e.stopPropagation(),W(!V)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:V?(null==R?void 0:R.collapse)||"Collapse":(null==R?void 0:R.expand)||"Expand"},{children:t(V?w:j,{className:"h-4 w-4"})})),s("div",Object.assign({className:"relative"},{children:[t("button",Object.assign({onClick:e=>{e.stopPropagation(),z(!J)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:t(b,{className:"h-6 w-6"})})),J&&s("div",Object.assign({ref:X,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:M.secondary,color:M.secondaryText,borderColor:M.primary}},{children:[s("button",Object.assign({onClick:e=>{e.stopPropagation(),se(Y),B(!0),z(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:M.primary}},{children:[t(f,{className:"h-4 w-4"}),t("span",Object.assign({className:"font-medium text-sm"},{children:(null==R?void 0:R["rename-chat"])||"Rename chat"}))]})),s("button",Object.assign({onClick:s=>{s.stopPropagation(),e(void 0,void 0,void 0,(function*(){if(window.confirm((null==R?void 0:R["delete-confirm"])||"Are you sure you want to delete this conversation?")){z(!1);try{yield p.post("/delete_pickaxe_conversation",{sessionId:O.sessionId,userId:P}),_&&_(O.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==R?void 0:R["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:[t(g,{className:"h-4 w-4"}),t("span",Object.assign({className:"font-medium text-sm"},{children:(null==R?void 0:R["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s("div",Object.assign({className:C("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",V?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:M.secondary,color:M.secondaryText}},{children:[s("div",Object.assign({className:"flex flex-col"},{children:[t("div",Object.assign({className:C("w-full",V?"mb-0":"mb-2")},{children:t(k,Object.assign({theme:D.theme,colors:M},E&&{rtl:!0},q&&{disableHtml:!0},F&&{disableJs:!0},T&&{disableCss:!0},{children:t(N,{style:{display:"block"},className:C("w-full",!V&&["[&_*]:!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"],V&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:ne})}))})),t("div",Object.assign({className:"w-full"},{children:t(k,Object.assign({theme:D.theme,colors:M},E&&{rtl:!0},q&&{disableHtml:!0},F&&{disableJs:!0},T&&{disableCss:!0},{children:t(N,{style:{display:"block"},className:C("w-full text-sm",!V&&["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"],V&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:ae})}))}))]})),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==I?void 0:I.chatflag)||!(null==I?void 0:I.chatflag)&&(null==I?void 0:I.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=O.sessionId,H([]),A([]),$(!1),S(s)},title:(null==R?void 0:R["open-chat"])||"Open Chat"},{children:[t(v,{className:"h-4 w-4"}),t("span",Object.assign({className:"text-sm font-medium"},{children:te}))]})),t("button",Object.assign({className:"transition-colors "+(Q?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(ae),U(!0),setTimeout((()=>{U(!1)}),2e3)},title:Q?(null==R?void 0:R.copied)||"Copied!":(null==R?void 0:R["copy-assistant-message"])||"Copy assistant message"},{children:Q?t(x,{className:"h-4 w-4",style:{color:M.accent},fill:M.accent}):t(y,{className:"h-4 w-4"})}))]})),t("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:oe}))]}))]}))]}))};export{O as default};
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 r}from"react";import{usePickaxeContext as l}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{format as m}from"date-fns";import p from"../../../../common/api/pickaxe.js";import{Check as u,X as h,MoreHorizontal as b,Pencil as g}from"lucide-react";import v from"../../../Icons/trash-2.svg.js";import f from"../../../Icons/chat.svg.js";import y from"../../../Icons/copy.svg.js";import x from"../../../Icons/copied.svg.js";import j from"../../../Icons/expand.svg.js";import w from"../../../Icons/collapse.svg.js";import{PickaxeMarkdown as k}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as N}from"../../common/PickaxeMarkdown/Renderer.js";import{getSuppressedRichPreviewUrls as C}from"../../common/PickaxeMessageParts/index.js";import O from"../../../../common/cn.js";const _=({item:_,onDelete:I})=>{const{pickaxe:P,sender:M,colors:R,translations:D,styles:E,isRtl:T,disableCss:q,disableHtml:F,disableJs:S,setSessionId:$,setIsNewChat:A}=l(),{setMessages:H}=c(),{setDocuments:J}=d(),[z,L]=n(!1),[B,K]=n(!1),[U,G]=n(!1),[Q,V]=n(!1),[W,X]=n(!1),Y=a(null),[Z,ee]=n(_.shortSummary||_.summary||(null==D?void 0:D["conversation-name"])||"Conversation name"),[se,oe]=n("");i((()=>{ee(_.shortSummary||_.summary||(null==D?void 0:D["conversation-name"])||"Conversation name")}),[_.shortSummary,_.summary,D]),i((()=>{const e=e=>{Y.current&&!Y.current.contains(e.target)&&L(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const te=r((()=>_?"FORM"===_.pickaxeType&&0===_.messages.length?_.question.responseParts?_.question.responseParts.length:0:_.messages.length:0),[_]),ne=r((()=>m(new Date(_.updatedAt),"MMM dd, yyy hh:mm a")),[_]),ae=r((()=>{var e;const s=(null==D?void 0:D["not-available"])||"n/a";if("FORM"===_.pickaxeType){if(_.messages&&0!==_.messages.length){const e=_.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const o=null!==(e=_.question.inputs)&&void 0!==e?e:[];return W?o.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||s}</p>\n</div>`)).join(""):o.map((e=>`${e.question}: ${e.answer||s}`)).join(" | ")}const o=_.messages.find((e=>"user"===e.role));return o?o.parts[0].content:""}),[_,W,D]),ie=r((()=>{var e,s,o,t;return"FORM"===_.pickaxeType?_.messages&&0!==_.messages.length?null!==(s=null===(e=_.messages.find((e=>"assistant"===e.role)))||void 0===e?void 0:e.parts)&&void 0!==s?s:[]:_.question.responseParts:null!==(t=null===(o=_.messages.find((e=>"assistant"===e.role)))||void 0===o?void 0:o.parts)&&void 0!==t?t:[]}),[_]),re=r((()=>ie.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")),[ie]),le=r((()=>C(ie)),[ie]),ce=()=>{K(!1),oe("")},de=()=>e(void 0,void 0,void 0,(function*(){if(se.trim()){G(!0);try{yield p.post("/edit_conversation_name",{sessionId:_.sessionId,name:se,userId:M}),ee(se),K(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==D?void 0:D["failed-update-name"])||"Failed to update name.")}finally{G(!1)}}}));return s("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:R.secondary,borderRadius:E.cornerRadius}},{children:[o("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:R.primary,color:R.text}},{children:B?s("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[o("input",{autoFocus:!0,type:"text",value:se,onChange:e=>oe(e.target.value),onKeyDown:e=>{"Enter"===e.key&&de(),"Escape"===e.key&&ce()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:R.primary,borderColor:R.secondary}}),o("button",Object.assign({onClick:de,disabled:U,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==D?void 0:D.save)||"Save"},{children:o(u,{className:"h-4 w-4"})})),o("button",Object.assign({onClick:ce,disabled:U,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==D?void 0:D.cancel)||"Cancel"},{children:o(h,{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:Z})),s("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[o("button",Object.assign({onClick:e=>{e.stopPropagation(),X(!W)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:W?(null==D?void 0:D.collapse)||"Collapse":(null==D?void 0:D.expand)||"Expand"},{children:o(W?w:j,{className:"h-4 w-4"})})),s("div",Object.assign({className:"relative"},{children:[o("button",Object.assign({onClick:e=>{e.stopPropagation(),L(!z)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:o(b,{className:"h-6 w-6"})})),z&&s("div",Object.assign({ref:Y,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:R.secondary,color:R.secondaryText,borderColor:R.primary}},{children:[s("button",Object.assign({onClick:e=>{e.stopPropagation(),oe(Z),K(!0),L(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:R.primary}},{children:[o(g,{className:"h-4 w-4"}),o("span",Object.assign({className:"font-medium text-sm"},{children:(null==D?void 0:D["rename-chat"])||"Rename chat"}))]})),s("button",Object.assign({onClick:s=>{s.stopPropagation(),e(void 0,void 0,void 0,(function*(){if(window.confirm((null==D?void 0:D["delete-confirm"])||"Are you sure you want to delete this conversation?")){L(!1);try{yield p.post("/delete_pickaxe_conversation",{sessionId:_.sessionId,userId:M}),I&&I(_.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==D?void 0:D["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(v,{className:"h-4 w-4"}),o("span",Object.assign({className:"font-medium text-sm"},{children:(null==D?void 0:D["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s("div",Object.assign({className:O("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",W?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:R.secondary,color:R.secondaryText}},{children:[s("div",Object.assign({className:"flex flex-col"},{children:[o("div",Object.assign({className:O("w-full",W?"mb-0":"mb-2")},{children:o(k,Object.assign({theme:E.theme,colors:R},T&&{rtl:!0},F&&{disableHtml:!0},S&&{disableJs:!0},q&&{disableCss:!0},{children:o(N,{style:{display:"block"},className:O("w-full",!W&&["[&_*]:!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"],W&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:ae})}))})),o("div",Object.assign({className:"w-full"},{children:o(k,Object.assign({theme:E.theme,colors:R},T&&{rtl:!0},F&&{disableHtml:!0},S&&{disableJs:!0},q&&{disableCss:!0},{children:o(N,{style:{display:"block"},className:O("w-full text-sm",!W&&["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"],W&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:re,suppressedRichPreviewUrls:le})}))}))]})),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==P?void 0:P.chatflag)||!(null==P?void 0:P.chatflag)&&(null==P?void 0:P.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=_.sessionId,J([]),H([]),A(!1),$(s)},title:(null==D?void 0:D["open-chat"])||"Open Chat"},{children:[o(f,{className:"h-4 w-4"}),o("span",Object.assign({className:"text-sm font-medium"},{children:te}))]})),o("button",Object.assign({className:"transition-colors "+(Q?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(re),V(!0),setTimeout((()=>{V(!1)}),2e3)},title:Q?(null==D?void 0:D.copied)||"Copied!":(null==D?void 0:D["copy-assistant-message"])||"Copy assistant message"},{children:Q?o(x,{className:"h-4 w-4",style:{color:R.accent},fill:R.accent}):o(y,{className:"h-4 w-4"})}))]})),o("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:ne}))]}))]}))]}))};export{_ 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 i}from"react";import{usePickaxeContext as l}from"../../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as a}from"../../../../Addons/Auth/hooks/useAuthContext.js";import{useSubmitDocument as n}from"../../../../../../hooks/pickaxe/useSubmitDocument.js";import{usePickaxeMarkdownContext as s}from"../../hooks/usePickaxeMarkdownContext.js";import r from"../../../../../Icons/download.svg.js";import c from"../../../../../Icons/copy.svg.js";import d from"../../../../../Icons/copied.svg.js";import p from"../../../../../Icons/file.svg.js";import m from"../../../../../Icons/upload-cloud.svg.js";import f from"copy-to-clipboard";import u from"../../../../../../common/error.js";const b=new Set(["jpeg","jpg","gif","bmp","webp","svg","tiff","avif","png","jfif","pjpeg","pjp"]),g=new Set(["mp3","wav","ogg","flac","aac","wma","alac","m4a","aiff","ape","au","mid","midi","opus"]),h=new Set(["mp4","webm","mov","avi","mkv","m4v"]),v=new Set(["csv","tsv","txt","json","xml","md","log","yaml","yml"]),w=new Set(["doc","docx","xls","xlsx","ppt","pptx"]),x=e=>b.has(e)?"image":g.has(e)?"audio":h.has(e)?"video":"pdf"===e?"pdf":"html"===e||"htm"===e?"html":v.has(e)?"text":w.has(e)?"office":"file",k=e=>{const o=(e=>{let o=e.trim();for(;/[),.;!?]$/.test(o);)o=o.slice(0,-1);return o})(e);return o.startsWith("http://")?`https://${o.slice(7)}`:o.startsWith("www.")?`https://${o}`:o},y=e=>{var o,t;try{const i=k(e),l=new URL(i);if("https:"!==l.protocol&&"http:"!==l.protocol)return null;const a=l.pathname.split("/").filter(Boolean).pop();if(!a)return null;const n=decodeURIComponent(a),s=null===(t=null===(o=n.match(/\.([a-z0-9]{1,10})$/i))||void 0===o?void 0:o[1])||void 0===t?void 0:t.toLowerCase();return s?{url:i,fileName:n,extension:s,kind:x(s)}:null}catch(e){return null}},j=(e,o)=>!!e&&(!o||!o.current.has(e.url)&&(o.current.add(e.url),!0)),N=({fileInfo:b,displayName:g})=>{const{theme:h,colors:v,disableHtml:w,disableJs:x}=s(),{contextId:k,pickaxeId:y,pickaxe:j,translations:N}=l(),{isLoggedIn:C,token:O}=a(),I=n(),[S,F]=i(!1),[$,D]=i(!1),[T,B]=i(!1),R=(e,o)=>{var t;return null!==(t=null==N?void 0:N[e])&&void 0!==t?t:o},U="dark"===h?"#30363D":"#D0D7DE",A="dark"===h?"#0D1117":"#F6F8FA",E="dark"===h?"#161B22":"#FFFFFF",P=(null==g?void 0:g.trim())||b.fileName,_=P!==b.fileName,L={display:"inline-flex",width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:4,color:v.accentText,backgroundColor:v.accent,opacity:.88,flexShrink:0},H=(e,i,l)=>t("div",Object.assign({className:"flex w-full p-4"},{children:o("div",Object.assign({className:"relative w-full overflow-hidden rounded-md shadow-sm",style:{aspectRatio:"8.5 / 11",backgroundColor:E,border:`1px solid ${U}`}},{children:[t("iframe",Object.assign({src:e,title:i},l,{className:"h-full w-full",scrolling:"no",tabIndex:-1,style:{border:"none",pointerEvents:"none"}})),t("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10",style:{background:"dark"===h?"linear-gradient(to top, rgba(22,27,34,0.95), rgba(22,27,34,0))":"linear-gradient(to top, rgba(255,255,255,0.95), rgba(255,255,255,0))"}})]}))}));return o("div",Object.assign({className:"my-2 w-full overflow-hidden rounded-lg",style:{border:`1px solid ${U}`,backgroundColor:A,color:v.secondaryText}},{children:[o("div",Object.assign({className:"flex items-center justify-between gap-3 border-b px-3 py-2",style:{borderColor:U}},{children:[t("a",Object.assign({href:b.url,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 flex-1 truncate text-sm font-semibold hover:underline",style:{color:v.secondaryText},title:_?`${P} (${b.fileName})`:P},{children:P})),o("div",Object.assign({className:"flex shrink-0 items-center gap-1.5"},{children:[t("button",Object.assign({type:"button",onClick:()=>{const e=document.createElement("a");e.href=b.url,e.download=b.fileName,e.target="_blank",e.rel="noopener noreferrer",e.click()},title:R("download","Download"),"aria-label":R("download","Download"),style:L},{children:t(r,{className:"h-[18px] w-[18px]"})})),t("button",Object.assign({type:"button",onClick:()=>{e(void 0,void 0,void 0,(function*(){try{F(!0),f(b.url),yield new Promise((e=>setTimeout(e,1500)))}finally{F(!1)}}))},title:S?R("copied","Copied"):R("copy-link","Copy link"),"aria-label":S?R("copied","Copied"):R("copy-link","Copy link"),style:Object.assign(Object.assign({},L),{opacity:S?1:L.opacity})},{children:t(S?d:c,{className:"h-[18px] w-[18px]"})})),C&&O&&t("button",Object.assign({type:"button",disabled:$||T,onClick:()=>{e(void 0,void 0,void 0,(function*(){if(O&&!$){D(!0),B(!1);try{const e=yield fetch(b.url);if(!e.ok)throw new Error("Failed to download generated file.");const o=yield e.blob(),t=new File([o],b.fileName,{type:o.type||"application/octet-stream"});yield I.document(Object.assign(Object.assign({contextId:k,pickaxeId:y,file:t},(null==j?void 0:j.workspaceid)&&{workspaceId:j.workspaceid}),{studioSessionToken:O,isUserDocument:!0})),B(!0),yield new Promise((e=>setTimeout(e,1500)))}catch(e){alert(u(e))}finally{D(!1),B(!1)}}}))},title:$?R("saving","Saving..."):T?R("saved","Saved"):R("save-to-knowledge-base","Save to Knowledge Base"),"aria-label":$?R("saving","Saving..."):T?R("saved","Saved"):R("save-to-knowledge-base","Save to Knowledge Base"),style:Object.assign(Object.assign({},L),{opacity:$||T?.55:L.opacity,cursor:$||T?"not-allowed":"pointer"})},{children:t(m,{className:"h-[18px] w-[18px]"})}))]}))]})),t("div",{children:(()=>{if("image"===b.kind)return t("img",{src:b.url,alt:b.fileName,className:"block max-h-[420px] w-full object-contain"});if("audio"===b.kind)return t("div",Object.assign({className:"flex min-h-[72px] items-center p-4"},{children:t("audio",{className:"w-full",controls:!0,src:b.url})}));if("video"===b.kind)return t("video",{className:"block max-h-[420px] w-full bg-black",controls:!0,preload:"metadata",src:b.url});if("pdf"===b.kind||"text"===b.kind){const e="pdf"===b.kind?`${b.url}#page=1&toolbar=0&navpanes=0&scrollbar=0&view=FitH`:b.url;return H(e,b.fileName)}if("html"===b.kind&&!w){const e=["allow-same-origin","allow-forms","allow-popups","allow-downloads","allow-modals",x?"":"allow-scripts"].filter(Boolean).join(" ");return H(b.url,b.fileName,{sandbox:e})}return"office"===b.kind?H(`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(b.url)}`,b.fileName):o("div",Object.assign({className:"flex min-h-[120px] items-center justify-center gap-3 p-6 text-sm"},{children:[t(p,{className:"h-8 w-8 shrink-0"}),t("span",Object.assign({className:"break-all"},{children:b.extension.toUpperCase()}))]}))})()})]}))};export{N as default,y as getFilePreviewInfo,k as normalizeMarkdownUrl,j as shouldRenderFilePreview};
1
+ import{__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as n}from"react";import{usePickaxeContext as i}from"../../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as l}from"../../../../Addons/Auth/hooks/useAuthContext.js";import{useSubmitDocument as a}from"../../../../../../hooks/pickaxe/useSubmitDocument.js";import{usePickaxeMarkdownContext as r}from"../../hooks/usePickaxeMarkdownContext.js";import s from"../../../../../Icons/download.svg.js";import c from"../../../../../Icons/copy.svg.js";import d from"../../../../../Icons/copied.svg.js";import m from"../../../../../Icons/file.svg.js";import p from"../../../../../Icons/upload-cloud.svg.js";import u from"copy-to-clipboard";import f from"../../../../../../common/error.js";const h=/(?:https?:\/\/|www\.)[^\s<>"']+/gi,b=new Set(["jpeg","jpg","gif","bmp","webp","svg","tiff","avif","png","jfif","pjpeg","pjp"]),v=new Set(["mp3","wav","ogg","flac","aac","wma","alac","m4a","aiff","ape","au","mid","midi","opus"]),w=new Set(["mp4","webm","mov","avi","mkv","m4v"]),g=new Set(["csv","tsv","txt","json","xml","md","log","yaml","yml"]),x=new Set(["doc","docx","xls","xlsx","ppt","pptx"]),k=new Set(["pdf","html","htm",...g,...x]),y=e=>b.has(e)?"image":v.has(e)?"audio":w.has(e)?"video":"pdf"===e?"pdf":"html"===e||"htm"===e?"html":g.has(e)?"text":x.has(e)?"office":"file",j=e=>{const t=(e=>{let t=e.trim();for(;/[),.;!?]$/.test(t);)t=t.slice(0,-1);return t})(e);return t.startsWith("http://")?`https://${t.slice(7)}`:t.startsWith("www.")?`https://${t}`:t},N=e=>{try{return new URL(j(e)).pathname.includes("/action_generated_files/")}catch(e){return!1}},C=e=>{try{return new URL(j(e)).pathname.includes("/documentinterrogation/")}catch(e){return!1}},O=e=>{const t=j(e);if(N(t))return!1;if(C(t))return!0;if((e=>{const t=j(e);return/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i.test(t)||/loom\.com\/(?:share|embed)\/([\w-]+)/i.test(t)||/vimeo\.com\/(?:video\/)?(\d+)/i.test(t)||/streamable\.com\/([\w-]+)/i.test(t)})(t))return!0;const o=(e=>{var t,o,n,i;try{const l=new URL(j(e));return"https:"!==l.protocol&&"http:"!==l.protocol?null:null!==(i=null===(n=null===(o=null===(t=l.pathname.split("/").filter(Boolean).pop())||void 0===t?void 0:t.match(/\.([a-z0-9]{1,10})$/i))||void 0===o?void 0:o[1])||void 0===n?void 0:n.toLowerCase())&&void 0!==i?i:null}catch(e){return null}})(t);return!!o&&k.has(o)},I=(e,t)=>{const o=j(e);return O(o)||(null==t?void 0:t.has(o))},S=(e,t)=>{for(const o of e.matchAll(h))if(I(o[0],t))return!0;return!1},F=e=>{var t,o;try{const n=j(e),i=new URL(n);if("https:"!==i.protocol&&"http:"!==i.protocol)return null;const l=i.pathname.split("/").filter(Boolean).pop();if(!l)return null;const a=decodeURIComponent(l),r=null===(o=null===(t=a.match(/\.([a-z0-9]{1,10})$/i))||void 0===t?void 0:t[1])||void 0===o?void 0:o.toLowerCase();return r?{url:n,fileName:a,extension:r,kind:y(r)}:null}catch(e){return null}},$=(e,t)=>!!e&&(!t||!t.current.has(e.url)&&(t.current.add(e.url),!0)),D=({fileInfo:h,displayName:b})=>{const{theme:v,colors:w,disableHtml:g,disableJs:x}=r(),{contextId:k,pickaxeId:y,pickaxe:j,translations:N}=i(),{isLoggedIn:C,token:O}=l(),I=a(),[S,F]=n(!1),[$,D]=n(!1),[R,U]=n(!1),L=(e,t)=>{var o;return null!==(o=null==N?void 0:N[e])&&void 0!==o?o:t},B="dark"===v?"#30363D":"#D0D7DE",T="dark"===v?"#0D1117":"#F6F8FA",_="dark"===v?"#161B22":"#FFFFFF",A=(null==b?void 0:b.trim())||h.fileName,E=A!==h.fileName,P={display:"inline-flex",width:32,height:32,alignItems:"center",justifyContent:"center",borderRadius:4,color:w.accentText,backgroundColor:w.accent,opacity:.88,flexShrink:0},z=(e,n,i)=>o("div",Object.assign({className:"flex w-full p-4"},{children:t("div",Object.assign({className:"relative w-full overflow-hidden rounded-md shadow-sm",style:{aspectRatio:"8.5 / 11",backgroundColor:_,border:`1px solid ${B}`}},{children:[o("iframe",Object.assign({src:e,title:n},i,{className:"h-full w-full",scrolling:"no",tabIndex:-1,style:{border:"none",pointerEvents:"none"}})),o("div",{className:"pointer-events-none absolute inset-x-0 bottom-0 h-10",style:{background:"dark"===v?"linear-gradient(to top, rgba(22,27,34,0.95), rgba(22,27,34,0))":"linear-gradient(to top, rgba(255,255,255,0.95), rgba(255,255,255,0))"}})]}))}));return t("div",Object.assign({className:"my-2 w-full overflow-hidden rounded-lg",style:{border:`1px solid ${B}`,backgroundColor:T,color:w.secondaryText}},{children:[t("div",Object.assign({className:"flex items-center justify-between gap-3 border-b px-3 py-2",style:{borderColor:B}},{children:[o("a",Object.assign({href:h.url,target:"_blank",rel:"noopener noreferrer",className:"min-w-0 flex-1 truncate text-sm font-semibold hover:underline",style:{color:w.secondaryText},title:E?`${A} (${h.fileName})`:A},{children:A})),t("div",Object.assign({className:"flex shrink-0 items-center gap-1.5"},{children:[o("button",Object.assign({type:"button",onClick:()=>{const e=document.createElement("a");e.href=h.url,e.download=h.fileName,e.target="_blank",e.rel="noopener noreferrer",e.click()},title:L("download","Download"),"aria-label":L("download","Download"),style:P},{children:o(s,{className:"h-[18px] w-[18px]"})})),o("button",Object.assign({type:"button",onClick:()=>{e(void 0,void 0,void 0,(function*(){try{F(!0),u(h.url),yield new Promise((e=>setTimeout(e,1500)))}finally{F(!1)}}))},title:S?L("copied","Copied"):L("copy-link","Copy link"),"aria-label":S?L("copied","Copied"):L("copy-link","Copy link"),style:Object.assign(Object.assign({},P),{opacity:S?1:P.opacity})},{children:o(S?d:c,{className:"h-[18px] w-[18px]"})})),C&&O&&o("button",Object.assign({type:"button",disabled:$||R,onClick:()=>{e(void 0,void 0,void 0,(function*(){if(O&&!$){D(!0),U(!1);try{const e=yield fetch(h.url);if(!e.ok)throw new Error("Failed to download generated file.");const t=yield e.blob(),o=new File([t],h.fileName,{type:t.type||"application/octet-stream"});yield I.document(Object.assign(Object.assign({contextId:k,pickaxeId:y,file:o},(null==j?void 0:j.workspaceid)&&{workspaceId:j.workspaceid}),{studioSessionToken:O,isUserDocument:!0})),U(!0),yield new Promise((e=>setTimeout(e,1500)))}catch(e){alert(f(e))}finally{D(!1),U(!1)}}}))},title:$?L("saving","Saving..."):R?L("saved","Saved"):L("save-to-knowledge-base","Save to Knowledge Base"),"aria-label":$?L("saving","Saving..."):R?L("saved","Saved"):L("save-to-knowledge-base","Save to Knowledge Base"),style:Object.assign(Object.assign({},P),{opacity:$||R?.55:P.opacity,cursor:$||R?"not-allowed":"pointer"})},{children:o(p,{className:"h-[18px] w-[18px]"})}))]}))]})),o("div",{children:(()=>{if("image"===h.kind)return o("img",{src:h.url,alt:h.fileName,className:"block max-h-[420px] w-full object-contain"});if("audio"===h.kind)return o("div",Object.assign({className:"flex min-h-[72px] items-center p-4"},{children:o("audio",{className:"w-full",controls:!0,src:h.url})}));if("video"===h.kind)return o("video",{className:"block max-h-[420px] w-full bg-black",controls:!0,preload:"metadata",src:h.url});if("pdf"===h.kind||"text"===h.kind){const e="pdf"===h.kind?`${h.url}#page=1&toolbar=0&navpanes=0&scrollbar=0&view=FitH`:h.url;return z(e,h.fileName)}if("html"===h.kind&&!g){const e=["allow-same-origin","allow-forms","allow-popups","allow-downloads","allow-modals",x?"":"allow-scripts"].filter(Boolean).join(" ");return z(h.url,h.fileName,{sandbox:e})}return"office"===h.kind?z(`https://view.officeapps.live.com/op/embed.aspx?src=${encodeURIComponent(h.url)}`,h.fileName):t("div",Object.assign({className:"flex min-h-[120px] items-center justify-center gap-3 p-6 text-sm"},{children:[o(m,{className:"h-8 w-8 shrink-0"}),o("span",Object.assign({className:"break-all"},{children:h.extension.toUpperCase()}))]}))})()})]}))};export{D as default,F as getFilePreviewInfo,C as isDocumentSourceUrl,N as isGeneratedFileUrl,O as isSourceLikeRichPreviewUrl,j as normalizeMarkdownUrl,$ as shouldRenderFilePreview,I as shouldSuppressRichPreviewForUrl,S as shouldSuppressRichPreviewInText};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useMemo as t,Children as r,isValidElement as o}from"react";import{usePickaxeMarkdownContext as m}from"../../hooks/usePickaxeMarkdownContext.js";import c from"../common/IframeVideo.js";import i,{normalizeMarkdownUrl as s,getFilePreviewInfo as n,shouldRenderFilePreview as l}from"./FilePreview.js";const a=e=>{let t="";return r.forEach(e,(e=>{"string"!=typeof e&&"number"!=typeof e?o(e)&&(t+=a(e.props.children)):t+=e})),t.trim().replace(/\s+/g," ")},f=({href:r="",children:o,filePreviewSeenRef:f})=>{const{colors:u}=m(),p=t((()=>r?s(r):""),[r]),b=t((()=>n(p)),[p]),h=t((()=>((e,t)=>{const r=a(e);if(r&&r!==t&&s(r)!==t)return r})(o,p)),[o,p]),d=t((()=>{if(b)return null;const e=p.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const t=p.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(t)return{title:"loom-embed",src:`https://www.loom.com/embed/${t[1]}`};const r=p.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(r)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${r[1]}`};const o=p.match(/streamable\.com\/([\w-]+)/i);return o?{title:"streamable-embed",src:`https://streamable.com/e/${o[1]}`}:null}),[b,p]);return d?e(c,{title:d.title,src:d.src}):b&&l(b,f)?e(i,{fileInfo:b,displayName:h}):e("a",Object.assign({href:p,target:"_blank",rel:"noopener noreferrer",style:{color:u.accent}},{children:o}))};export{f as A};
1
+ import{jsx as e}from"react/jsx-runtime";import{useMemo as r,Children as t,isValidElement as o}from"react";import{usePickaxeMarkdownContext as m}from"../../hooks/usePickaxeMarkdownContext.js";import i from"../common/IframeVideo.js";import c,{normalizeMarkdownUrl as s,shouldSuppressRichPreviewForUrl as n,getFilePreviewInfo as l,shouldRenderFilePreview as a}from"./FilePreview.js";const u=e=>{let r="";return t.forEach(e,(e=>{"string"!=typeof e&&"number"!=typeof e?o(e)&&(r+=u(e.props.children)):r+=e})),r.trim().replace(/\s+/g," ")},f=({href:t="",children:o,filePreviewSeenRef:f,suppressedRichPreviewUrls:p})=>{const{colors:h}=m(),b=r((()=>t?s(t):""),[t]),d=r((()=>n(b,p)),[b,p]),w=r((()=>l(b)),[b]),v=r((()=>((e,r)=>{const t=u(e);if(t&&t!==r&&s(t)!==r)return t})(o,b)),[o,b]),y=r((()=>{if(d)return null;if(w)return null;const e=b.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const r=b.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(r)return{title:"loom-embed",src:`https://www.loom.com/embed/${r[1]}`};const t=b.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(t)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${t[1]}`};const o=b.match(/streamable\.com\/([\w-]+)/i);return o?{title:"streamable-embed",src:`https://streamable.com/e/${o[1]}`}:null}),[w,b,d]);return y?e(i,{title:y.title,src:y.src}):w&&!d&&a(w,f)?e(c,{fileInfo:w,displayName:v}):e("a",Object.assign({href:b,target:"_blank",rel:"noopener noreferrer",style:{color:h.accent}},{children:o}))};export{f as A};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useMemo as t}from"react";import o from"../common/IframeVideo.js";const m=({children:m})=>{const r=t((()=>{if("string"!=typeof m)return null;const e=m.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const t=m.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(t)return{title:"loom-embed",src:`https://www.loom.com/embed/${t[1]}`};const o=m.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(o)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${o[1]}`};const r=m.match(/streamable\.com\/([\w-]+)/i);return r?{title:"streamable-embed",src:`https://streamable.com/e/${r[1]}`}:null}),[m]);return r?e(o,{title:r.title,src:r.src}):e("p",{children:m})};export{m as P};
1
+ import{jsx as e}from"react/jsx-runtime";import{useMemo as t}from"react";import r from"../common/IframeVideo.js";import{shouldSuppressRichPreviewInText as o}from"../A/FilePreview.js";const m=({children:m,suppressedRichPreviewUrls:i})=>{const c=t((()=>{if("string"!=typeof m)return null;if(o(m,i))return null;const e=m.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const t=m.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(t)return{title:"loom-embed",src:`https://www.loom.com/embed/${t[1]}`};const r=m.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(r)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${r[1]}`};const c=m.match(/streamable\.com\/([\w-]+)/i);return c?{title:"streamable-embed",src:`https://streamable.com/e/${c[1]}`}:null}),[m,i]);return c?e(r,{title:c.title,src:c.src}):e("p",{children:m})};export{m as P};
@@ -1 +1 @@
1
- import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as o,useMemo as i,useEffect as s}from"react";import{usePickaxeMarkdownContext as a}from"./hooks/usePickaxeMarkdownContext.js";import{remarkSmartQuotes as m,rehypeCode as l,rehypeSanitize as c}from"./utils/custom-plugins.js";import p from"react-markdown";import f from"remark-gfm";import d from"remark-math";import h from"rehype-katex";import u from"rehype-raw";import{A as g}from"./Components/A/index.js";import x,{getFilePreviewInfo as b,shouldRenderFilePreview as j}from"./Components/A/FilePreview.js";import{P as C}from"./Components/P/index.js";import{Img as k}from"./Components/Img/index.js";import{Iframe as w}from"./Components/Iframe/index.js";import{Code as v}from"./Components/Code/index.js";import{H1 as $,H2 as y,H3 as O,H4 as S,H5 as P}from"./Components/Headings/index.js";import{Ol as N,Ul as A,Li as I}from"./Components/List/index.js";import{Table as L,Th as M,Tr as R,Td as T}from"./Components/Table/index.js";import{Hr as H,Br as _,Blockquote as B}from"./Components/Others/index.js";import{ActionCaption as J,ActionFinished as W,ActionError as q}from"./Components/Action/index.js";import{Artifact as z,ArtifactError as D}from"./Components/Artifact/index.js";import{Think as E}from"./Components/Others/Think.js";import F from"../../../../common/cn.js";const G=({className:G,style:K,children:Q,value:U,maxLines:V,maxChars:X,multiLineBreaks:Y,onExpandClick:Z,filePreviewSeenRef:ee})=>{const{colors:re,rtl:te,disableHtml:ne,disableJs:oe,disableCss:ie}=a(),[se,ae]=n({width:0,height:0}),[me,le]=n(null),ce=o(null),pe=i((()=>{if(!U)return"";let e=U.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),Y&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[U,Y]);s((()=>{if(X)return void le(pe.length>X?pe.slice(0,X)+'<span class="pxe-expand-btn">...</span>':null);if(!V)return void le(null);if(!ce.current||!pe||me)return;const e=ce.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),t=V*r;if(!(se.height>t))return;const n=Math.floor(se.width/8),o=Math.floor(n*V);le(pe.slice(0,o)+'<span class="pxe-expand-btn">...</span>')}),[pe,V,X,se,me]);const fe=o(new Set);ee||(fe.current=new Set);const de=null!=ee?ee:fe,he={h1:$,h2:y,h3:O,h4:S,h5:P,p:C,a:e=>t(g,Object.assign({},e,{filePreviewSeenRef:de})),img:e=>{const r="string"==typeof e.src?e.src:"",n=b(r);return n?j(n,de)?t(x,{fileInfo:n,displayName:"string"==typeof e.alt?e.alt:void 0}):t("a",Object.assign({href:n.url,target:"_blank",rel:"noopener noreferrer",style:{color:re.accent}},{children:e.alt||n.fileName})):t(k,Object.assign({},e))},iframe:w,code:v,ol:N,ul:A,li:I,table:L,th:M,tr:R,td:T,hr:H,br:_,blockquote:B,span:r=>{var{children:n}=r,o=e(r,["children"]);return"pxe-expand-btn"===o.className?t("span",Object.assign({},o,{style:Object.assign({display:"inline",fontWeight:500,color:re.accent,marginLeft:".25rem",userSelect:"none"},Z&&{cursor:"pointer"})},Z&&{onClick:Z},{children:n})):t("span",Object.assign({},o,{children:n}))},"action-caption":J,"action-finished":W,"action-error":q,artifact:z,"artifact-error":D,think:E};s((()=>{if(!ce.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:t}=r.contentRect;ae({width:e,height:t})}}));return e.observe(ce.current),()=>{e.disconnect()}}),[]);const ue=me||pe;return r("div",Object.assign({className:"pxe-markdown",ref:ce,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},K)},te&&{dir:"rtl"},{children:[t(p,Object.assign({className:F("pxe-prose",G),components:he,remarkPlugins:[f,[d,{singleDollarTextMath:!1}],m],rehypePlugins:[l,h,...ne?[]:[u],[c,{disableJs:oe,disableCss:ie}]]},{children:ue})),Q]}))};export{G as PickaxeMarkdownRenderer};
1
+ import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as i,useMemo as o,useEffect as s}from"react";import{usePickaxeMarkdownContext as a}from"./hooks/usePickaxeMarkdownContext.js";import{remarkSmartQuotes as l,rehypeCode as m,rehypeSanitize as p}from"./utils/custom-plugins.js";import c from"react-markdown";import d from"remark-gfm";import f from"remark-math";import h from"rehype-katex";import u from"rehype-raw";import{A as g}from"./Components/A/index.js";import x,{getFilePreviewInfo as b,shouldSuppressRichPreviewForUrl as j,shouldRenderFilePreview as w}from"./Components/A/FilePreview.js";import{P as C}from"./Components/P/index.js";import{Img as k}from"./Components/Img/index.js";import{Iframe as v}from"./Components/Iframe/index.js";import{Code as $}from"./Components/Code/index.js";import{H1 as y,H2 as O,H3 as P,H4 as S,H5 as R}from"./Components/Headings/index.js";import{Ol as N,Ul as A,Li as I}from"./Components/List/index.js";import{Table as L,Th as M,Tr as T,Td as H}from"./Components/Table/index.js";import{Hr as U,Br as _,Blockquote as B}from"./Components/Others/index.js";import{ActionCaption as J,ActionFinished as W,ActionError as q}from"./Components/Action/index.js";import{Artifact as z,ArtifactError as D}from"./Components/Artifact/index.js";import{Think as E}from"./Components/Others/Think.js";import F from"../../../../common/cn.js";const G=({className:G,style:K,children:Q,value:V,maxLines:X,maxChars:Y,multiLineBreaks:Z,onExpandClick:ee,filePreviewSeenRef:re,suppressedRichPreviewUrls:te})=>{const{colors:ne,rtl:ie,disableHtml:oe,disableJs:se,disableCss:ae}=a(),[le,me]=n({width:0,height:0}),[pe,ce]=n(null),de=i(null),fe=o((()=>{if(!V)return"";let e=V.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\\((.*?)\\\)/g,"$$$ $1 $$$"),e=e.replace(/\\\[(.*?)\\\]/g,"$$$ $1 $$$"),e=e.replace(/<\/think>/g,"\n</think>"),Z&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[V,Z]);s((()=>{if(Y)return void ce(fe.length>Y?fe.slice(0,Y)+'<span class="pxe-expand-btn">...</span>':null);if(!X)return void ce(null);if(!de.current||!fe||pe)return;const e=de.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),t=X*r;if(!(le.height>t))return;const n=Math.floor(le.width/8),i=Math.floor(n*X);ce(fe.slice(0,i)+'<span class="pxe-expand-btn">...</span>')}),[fe,X,Y,le,pe]);const he=i(new Set);re||(he.current=new Set);const ue=null!=re?re:he,ge={h1:y,h2:O,h3:P,h4:S,h5:R,p:e=>t(C,Object.assign({},e,{suppressedRichPreviewUrls:te})),a:e=>t(g,Object.assign({},e,{filePreviewSeenRef:ue,suppressedRichPreviewUrls:te})),img:e=>{const r="string"==typeof e.src?e.src:"",n=b(r);return n&&!j(n.url,te)?w(n,ue)?t(x,{fileInfo:n,displayName:"string"==typeof e.alt?e.alt:void 0}):t("a",Object.assign({href:n.url,target:"_blank",rel:"noopener noreferrer",style:{color:ne.accent}},{children:e.alt||n.fileName})):t(k,Object.assign({},e))},iframe:v,code:$,ol:N,ul:A,li:I,table:L,th:M,tr:T,td:H,hr:U,br:_,blockquote:B,span:r=>{var{children:n}=r,i=e(r,["children"]);return"pxe-expand-btn"===i.className?t("span",Object.assign({},i,{style:Object.assign({display:"inline",fontWeight:500,color:ne.accent,marginLeft:".25rem",userSelect:"none"},ee&&{cursor:"pointer"})},ee&&{onClick:ee},{children:n})):t("span",Object.assign({},i,{children:n}))},"action-caption":J,"action-finished":W,"action-error":q,artifact:z,"artifact-error":D,think:E};s((()=>{if(!de.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:t}=r.contentRect;me({width:e,height:t})}}));return e.observe(de.current),()=>{e.disconnect()}}),[]);const xe=pe||fe;return r("div",Object.assign({className:"pxe-markdown",ref:de,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem",width:"100%"},K)},ie&&{dir:"rtl"},{children:[t(c,Object.assign({className:F("pxe-prose",G),components:ge,remarkPlugins:[d,[f,{singleDollarTextMath:!1}],l],rehypePlugins:[m,h,...oe?[]:[u],[p,{disableJs:se,disableCss:ae}]]},{children:xe})),Q]}))};export{G as PickaxeMarkdownRenderer};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useRef as n,Suspense as t,lazy as i}from"react";import{PickaxeMarkdownRenderer as o}from"../PickaxeMarkdown/Renderer.js";import r,{getFilePreviewInfo as a,normalizeMarkdownUrl as s,shouldRenderFilePreview as l}from"../PickaxeMarkdown/Components/A/FilePreview.js";import{safeJSONParse as c}from"../../../../common/utils.js";import p from"../../../../common/cn.js";const m=i((()=>import("./TextPart/index.js"))),u=i((()=>import("./ReasoningPart/index.js"))),d=i((()=>import("./ActionToolCaptionPart/index.js"))),f=i((()=>import("./ReasoningCaptionPart/index.js"))),g=/(!?)\[([^\]\n]+)\]\((https?:\/\/[^\s)]+|www\.[^\s)]+)\)/g,v=({className:i,parts:v})=>{const h=n(new Set);return h.current=new Set,e("div",Object.assign({className:p("flex flex-col gap-2",i)},{children:e(t,Object.assign({fallback:e("div",{})},{children:v.map(((n,t)=>{if(!n.isVisible)return null;if("text"===n.type){const i=((e,n)=>{var t,i;const o=[];let r=0;for(const c of e.matchAll(g)){const p=null!==(t=c.index)&&void 0!==t?t:0,m=c[0],u="!"===c[1],d=null===(i=c[2])||void 0===i?void 0:i.trim(),f=c[3],g=a(f);if(!g)continue;p>r&&o.push({type:"markdown",value:e.slice(r,p)});const v=d&&s(d)!==g.url?d:void 0;l(g,n)?o.push({type:"preview",key:`${g.url}-${p}`,fileInfo:g,displayName:v}):o.push({type:"markdown",value:u?m:`[${d||g.fileName}](${g.url})`}),r=p+m.length}return r<e.length&&o.push({type:"markdown",value:e.slice(r)}),o.length?o:[{type:"markdown",value:e}]})(n.content,h);return e(m,{children:i.map(((n,t)=>"preview"===n.type?e(r,{fileInfo:n.fileInfo,displayName:n.displayName},n.key):n.value?e(o,{value:n.value,filePreviewSeenRef:h},t):null))},t)}if("reasoning"===n.type)return e(u,Object.assign({isReasoning:t===v.length-1},{children:e(o,{value:n.content})}),t);if("data-action-tool-caption"===n.type){const i=c(n.content);return e(d,Object.assign({},i&&i,{isLoading:t===v.length-1}),t)}if("data-reasoning-caption"===n.type){const i=c(n.content);return e(f,Object.assign({},i&&i,{isLoading:t===v.length-1}),t)}return null}))}))}))};export{v as default};
1
+ import{jsx as e}from"react/jsx-runtime";import{useRef as t,Suspense as n,lazy as i}from"react";import{PickaxeMarkdownRenderer as o}from"../PickaxeMarkdown/Renderer.js";import s,{isGeneratedFileUrl as r,normalizeMarkdownUrl as a,getFilePreviewInfo as l,shouldSuppressRichPreviewForUrl as c,shouldRenderFilePreview as p}from"../PickaxeMarkdown/Components/A/FilePreview.js";import{safeJSONParse as u}from"../../../../common/utils.js";import d from"../../../../common/cn.js";const m=i((()=>import("./TextPart/index.js"))),f=i((()=>import("./ReasoningPart/index.js"))),v=i((()=>import("./ActionToolCaptionPart/index.js"))),g=i((()=>import("./ReasoningCaptionPart/index.js"))),h=/(!?)\[([^\]\n]+)\]\((https?:\/\/[^\s)]+|www\.[^\s)]+)\)/g,w=e=>{const t=new Set;for(const n of e){if("data-tool-assets"!==n.type)continue;const e=u(n.content);if(null==e?void 0:e.assets)for(const n of e.assets)n.value&&!r(n.value)&&t.add(a(n.value))}return t},y=({className:i,parts:r})=>{const y=t(new Set);y.current=new Set;const j=w(r);return e("div",Object.assign({className:d("flex flex-col gap-2",i)},{children:e(n,Object.assign({fallback:e("div",{})},{children:r.map(((t,n)=>{if(!t.isVisible)return null;if("text"===t.type){const i=((e,t,n)=>{var i,o;const s=[];let r=0;for(const u of e.matchAll(h)){const d=null!==(i=u.index)&&void 0!==i?i:0,m=u[0],f="!"===u[1],v=null===(o=u[2])||void 0===o?void 0:o.trim(),g=u[3],h=l(g);if(!h)continue;if(c(h.url,n))continue;d>r&&s.push({type:"markdown",value:e.slice(r,d)});const w=v&&a(v)!==h.url?v:void 0;p(h,t)?s.push({type:"preview",key:`${h.url}-${d}`,fileInfo:h,displayName:w}):s.push({type:"markdown",value:f?m:`[${v||h.fileName}](${h.url})`}),r=d+m.length}return r<e.length&&s.push({type:"markdown",value:e.slice(r)}),s.length?s:[{type:"markdown",value:e}]})(t.content,y,j);return e(m,{children:i.map(((t,n)=>"preview"===t.type?e(s,{fileInfo:t.fileInfo,displayName:t.displayName},t.key):t.value?e(o,{value:t.value,filePreviewSeenRef:y,suppressedRichPreviewUrls:j},n):null))},n)}if("reasoning"===t.type)return e(f,Object.assign({isReasoning:n===r.length-1},{children:e(o,{value:t.content,suppressedRichPreviewUrls:j})}),n);if("data-action-tool-caption"===t.type){const i=u(t.content);return e(v,Object.assign({},i&&i,{isLoading:n===r.length-1}),n)}if("data-reasoning-caption"===t.type){const i=u(t.content);return e(g,Object.assign({},i&&i,{isLoading:n===r.length-1}),n)}return null}))}))}))};export{y as default,w as getSuppressedRichPreviewUrls};
@@ -7,7 +7,13 @@ export type FilePreviewInfo = {
7
7
  kind: FilePreviewKind;
8
8
  };
9
9
  export type FilePreviewSeenRef = MutableRefObject<Set<string>>;
10
+ export type SuppressedRichPreviewUrls = Set<string>;
10
11
  export declare const normalizeMarkdownUrl: (href: string) => string;
12
+ export declare const isGeneratedFileUrl: (href: string) => boolean;
13
+ export declare const isDocumentSourceUrl: (href: string) => boolean;
14
+ export declare const isSourceLikeRichPreviewUrl: (href: string) => boolean;
15
+ export declare const shouldSuppressRichPreviewForUrl: (href: string, suppressedRichPreviewUrls?: SuppressedRichPreviewUrls) => boolean | undefined;
16
+ export declare const shouldSuppressRichPreviewInText: (value: string, suppressedRichPreviewUrls?: SuppressedRichPreviewUrls) => boolean;
11
17
  export declare const getFilePreviewInfo: (href: string) => FilePreviewInfo | null;
12
18
  export declare const shouldRenderFilePreview: (fileInfo: FilePreviewInfo | null, seenRef?: FilePreviewSeenRef) => boolean;
13
19
  interface FilePreviewProps {
@@ -1,7 +1,8 @@
1
1
  import type { MarkdownComponent } from "../..";
2
- import type { FilePreviewSeenRef } from "./FilePreview";
2
+ import type { FilePreviewSeenRef, SuppressedRichPreviewUrls } from "./FilePreview";
3
3
  type AProps = Parameters<MarkdownComponent<"a">>[0] & {
4
4
  filePreviewSeenRef?: FilePreviewSeenRef;
5
+ suppressedRichPreviewUrls?: SuppressedRichPreviewUrls;
5
6
  };
6
- export declare const A: ({ href, children, filePreviewSeenRef }: AProps) => import("react/jsx-runtime").JSX.Element;
7
+ export declare const A: ({ href, children, filePreviewSeenRef, suppressedRichPreviewUrls, }: AProps) => import("react/jsx-runtime").JSX.Element;
7
8
  export {};
@@ -1,2 +1,7 @@
1
1
  import type { MarkdownComponent } from "../..";
2
- export declare const P: MarkdownComponent<"p">;
2
+ import type { SuppressedRichPreviewUrls } from "../A/FilePreview";
3
+ type PProps = Parameters<MarkdownComponent<"p">>[0] & {
4
+ suppressedRichPreviewUrls?: SuppressedRichPreviewUrls;
5
+ };
6
+ export declare const P: ({ children, suppressedRichPreviewUrls }: PProps) => import("react/jsx-runtime").JSX.Element;
7
+ export {};
@@ -1,5 +1,5 @@
1
1
  import { type ReactNode, type CSSProperties } from "react";
2
- import { type FilePreviewSeenRef } from "./Components/A/FilePreview";
2
+ import { type FilePreviewSeenRef, type SuppressedRichPreviewUrls } from "./Components/A/FilePreview";
3
3
  export interface PickaxeMarkdownRendererProps {
4
4
  className?: string;
5
5
  style?: CSSProperties;
@@ -10,5 +10,6 @@ export interface PickaxeMarkdownRendererProps {
10
10
  multiLineBreaks?: boolean;
11
11
  onExpandClick?: () => void;
12
12
  filePreviewSeenRef?: FilePreviewSeenRef;
13
+ suppressedRichPreviewUrls?: SuppressedRichPreviewUrls;
13
14
  }
14
- export declare const PickaxeMarkdownRenderer: ({ className, style, children: _children, value, maxLines, maxChars, multiLineBreaks, onExpandClick, filePreviewSeenRef, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
15
+ export declare const PickaxeMarkdownRenderer: ({ className, style, children: _children, value, maxLines, maxChars, multiLineBreaks, onExpandClick, filePreviewSeenRef, suppressedRichPreviewUrls, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
@@ -1,7 +1,9 @@
1
1
  import type { PickaxeHistoryMessagePart } from "../../../../types/history";
2
+ import { type SuppressedRichPreviewUrls } from "../PickaxeMarkdown/Components/A/FilePreview";
2
3
  interface PickaxeMessagePartsProps {
3
4
  className?: string;
4
5
  parts: PickaxeHistoryMessagePart[];
5
6
  }
7
+ export declare const getSuppressedRichPreviewUrls: (parts: PickaxeHistoryMessagePart[]) => SuppressedRichPreviewUrls;
6
8
  declare const PickaxeMessageParts: ({ className, parts, }: PickaxeMessagePartsProps) => import("react/jsx-runtime").JSX.Element;
7
9
  export default PickaxeMessageParts;
@@ -35,7 +35,7 @@ export type PickaxeHistoryMessage = {
35
35
  createdAt: string;
36
36
  area?: PickaxeHistoryMessageArea;
37
37
  };
38
- export type PickaxeHistoryMessagePartsType = "text" | "reasoning" | "data-action-tool-caption" | "data-reasoning-caption";
38
+ export type PickaxeHistoryMessagePartsType = "text" | "reasoning" | "data-action-tool-caption" | "data-reasoning-caption" | "data-tool-assets";
39
39
  export type PickaxeHistoryMessagePart = {
40
40
  type: PickaxeHistoryMessagePartsType;
41
41
  content: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "6.6.0",
3
+ "version": "6.6.1",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",