@pickaxeproject/react 0.0.67 → 0.0.69

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.
@@ -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"),o=require("../../../hooks/core/useMediaQuery.js"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),d=require("../../../hooks/pickaxe/useSubmit.js"),u=require("../../../hooks/pickaxe/useSubmitResult.js"),c=require("../Addons/Document/hooks/useDocument.js"),m=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../../../common/documents.js"),f=require("../../../common/api/streamer.js"),h=require("react-textarea-autosize"),x=require("../../Icons/attach.svg.js"),g=require("../../Icons/arrow-right.svg.js"),j=require("../common/PickaxeBranding.js"),b=require("../Addons/IceBreaker/index.js"),y=require("../../../common/error.js"),v=require("../../../common/cn.js");function I(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var k=I(h);exports.default=()=>{var h;const{formId:I,chatId:w,userId:S,studioUserId:q,deploymentId:D,pickaxe:O,styles:C,colors:A,misc:N,responsiveBy:M,isNewChat:E,forceMobile:R,setIsNewChat:U,setIsShowIceBreaker:_,onGenerateComplete:B}=r.usePickaxeContext(),{messages:F,status:T,limits:P,setMessages:z,setStatus:L,setLimitData:W,setError:G,setIsGenerating:K}=i.useResponseContext(),{documents:Q,isUploading:H,isImageUploadAllowed:J,upsertDocuments:V,onFileUpload:X,onEditDocumentByDocId:Y}=c.useDocument(),{scrollStartSession:Z,scrollEndSession:$,scrollToBottom:ee}=m.useScroll({auto:!0}),se=l.useConversation(),te=d.useSubmit(),oe=u.useSubmitResult(),re=a.useStyleFontSize(),[ie,ne]=t.useState(""),ae=t.useRef(null),[le]=o.useMediaQuery("(max-width: 767px)"),de=n.useStyleInput(),ue=t.useMemo((()=>{var e,s,t;return!!E&&(!!O&&(!se.isLoading&&(!((null!==(s=null===(e=se.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=O.icebreakers)||void 0===t?void 0:t.length))))}),[O,E,se.data,se.isLoading]);t.useEffect((()=>{_(ue)}),[ue]);const ce=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(H||"idle"!==T)return;const e=null!=s?s:ie;if(!e)return;ne(""),G(""),W(null),K(!0),U(!1);const t=new Date,o="enduserupload"===(null==O?void 0:O.documentuploadtype),r=Q.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),i=r.length?r[r.length-1].documentId:"";L("fetching"),Z(),ee();const n=[...F,{id:F.length+1,role:"user",content:e}];z(n),ee();const{success:a,data:l,actionData:d,usedDocumentIds:u,newDocumentId:c,newDocumentName:m,rawUserInput:p,isInsertedFile:h,error:x}=yield te.mutateAsync(Object.assign(Object.assign(Object.assign({formId:I,responseId:w,value:e},o&&i&&{documentId:i}),q&&{studioUserId:q}),D&&{deploymentId:D}));if(!a)throw new Error(null!=x?x:"An error occurred, please try again.");ee(),h&&i&&Y({documentId:i,isInsertedAsRaw:!0}),c&&m&&V([{type:"website",id:m,name:m,status:"finished",documentId:c}]),ee();const g=(yield f.streamer({formId:I,responseId:w,data:l,actionData:d})).body;if(!g)throw new Error("Streaming error");const j=g.getReader(),b=new TextDecoder,y=n.length;let v="",k=!0,C=!1;for(;k;){const{value:e,done:s}=yield j.read();k=!s;if(v+=b.decode(e),v)z([...n.slice(0,y),{id:F.length+1,role:"assistant",content:v}]),C||(L("streaming"),C=!0);else if(!k&&!v)throw new Error("Server error")}const A=new Date;v&&(ee(),L("idle"),yield oe.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:I,responseId:w,documentIds:u},S&&{userId:S}),q&&{studioUserId:q}),q&&(null==O?void 0:O.studioid)&&{studioId:O.studioid}),D&&{deploymentId:D}),{messages:[{role:"user",message:p,sentAt:t},{role:"assistant",message:v,sentAt:A}]})),null==B||B(w))}catch(e){let s=y.default(e)||"";s&&!s.includes("Unexpected token 'A',")||(s="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(P).find((([e])=>s.includes(e)));t?W(t[1]):G(s),ee()}finally{L("idle"),K(!1),$()}}));return s.jsxs("div",Object.assign({className:v.default("fixed flex w-full flex-col bottom-0 left-0","viewport"===M?"min-[767px]:relative min-[767px]:bottom-auto min-[767px]:left-auto":"absolute @[767px]/pickaxe-root:relative @[767px]/pickaxe-root:bottom-auto @[767px]/pickaxe-root:left-auto")},{children:[!N.isWhiteLabel&&s.jsx("div",Object.assign({className:"flex justify-end pr-3"},{children:s.jsx(j.default,{animateHover:!0})})),ue&&s.jsx(b.default,{data:(null==O?void 0:O.icebreakers)||[],style:{backgroundColor:A.secondary,color:A.secondaryText},isMobile:R||le,onSend:ce}),s.jsxs("div",Object.assign({style:de,className:v.default("flex min-h-[56px] items-end gap-x-2 px-4 py-3 pb-[15px]","block"===C.formFieldStyle&&"shadow")},{children:["enduserupload"===(null==O?void 0:O.documentuploadtype)&&s.jsxs("div",Object.assign({className:"tooltip"},{children:[s.jsx("input",{id:"file-upload",ref:ae,type:"file",accept:[...p.allowedFileMimeTypes,...J?p.allowedImageMimeTypes:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield X(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx("button",Object.assign({className:"flex items-center disabled:cursor-wait disabled:opacity-50",disabled:H,onClick:()=>{var e;return null===(e=ae.current)||void 0===e?void 0:e.click()}},{children:s.jsx(x.default,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:A.accent}})}))]})),s.jsx(k.default,{className:v.default(re.b2,"max-h-60 w-full resize-none border-transparent bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:font-semilight",!ie.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:ie,placeholder:null!==(h=null==O?void 0:O.placeholdertext)&&void 0!==h?h:"What do you want to talk about?",onChange:e=>ne(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),H||"idle"!==T||ce()))}}),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-default disabled:opacity-50",disabled:H||"idle"!==T,onClick:()=>ce()},{children:s.jsx(g.default,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:H||"idle"!==T?A.secondaryText+"70":A.accent}})}))]}))]}))};
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/core/useMediaQuery.js"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),d=require("../../../hooks/pickaxe/useSubmit.js"),u=require("../../../hooks/pickaxe/useSubmitResult.js"),c=require("../Addons/Document/hooks/useDocument.js"),m=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../../../common/documents.js"),f=require("../../../common/api/streamer.js"),h=require("react-textarea-autosize"),x=require("../../Icons/attach.svg.js"),g=require("../../Icons/arrow-right.svg.js"),b=require("../common/PickaxeBranding.js"),j=require("../Addons/IceBreaker/index.js"),v=require("../../../common/error.js"),y=require("../../../common/cn.js");function I(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var k=I(h);exports.default=()=>{var h;const{formId:I,chatId:w,userId:S,studioUserId:q,deploymentId:D,pickaxe:O,styles:C,colors:A,misc:N,responsiveBy:M,isNewChat:E,forceMobile:R,setIsNewChat:U,setIsShowIceBreaker:_,onGenerateComplete:B}=i.usePickaxeContext(),{messages:F,status:T,limits:P,setMessages:z,setStatus:L,setLimitData:W,setError:G,setIsGenerating:K}=r.useResponseContext(),{documents:Q,isUploading:H,isImageUploadAllowed:J,upsertDocuments:V,onFileUpload:X,onEditDocumentByDocId:Y}=c.useDocument(),{scrollStartSession:Z,scrollEndSession:$,scrollToBottom:ee}=m.useScroll({auto:!0}),te=l.useConversation(),se=d.useSubmit(),oe=u.useSubmitResult(),ie=a.useStyleFontSize(),[re,ne]=s.useState(""),ae=s.useRef(null),[le]=o.useMediaQuery("(max-width: 767px)"),de=n.useStyleInput(),ue=s.useMemo((()=>{var e,t,s;return!!E&&(!!O&&(!te.isLoading&&(!((null!==(t=null===(e=te.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(s=O.icebreakers)||void 0===s?void 0:s.length))))}),[O,E,te.data,te.isLoading]);s.useEffect((()=>{_(ue)}),[ue]);const ce=t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(H||"idle"!==T)return;const e=null!=t?t:re;if(!e)return;ne(""),G(""),W(null),K(!0),U(!1);const s=new Date,o="enduserupload"===(null==O?void 0:O.documentuploadtype),i=Q.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=i.length?i[i.length-1].documentId:"";L("fetching"),Z(),ee();const n=[...F,{id:F.length+1,role:"user",content:e}];z(n),ee();const{success:a,data:l,actionData:d,usedDocumentIds:u,newDocumentId:c,newDocumentName:m,rawUserInput:p,isInsertedFile:h,error:x}=yield se.mutateAsync(Object.assign(Object.assign(Object.assign({formId:I,responseId:w,value:e},o&&r&&{documentId:r}),q&&{studioUserId:q}),D&&{deploymentId:D}));if(!a)throw new Error(null!=x?x:"An error occurred, please try again.");ee(),h&&r&&Y({documentId:r,isInsertedAsRaw:!0}),c&&m&&V([{type:"website",id:m,name:m,status:"finished",documentId:c}]),ee();const g=(yield f.streamer({formId:I,responseId:w,data:l,actionData:d})).body;if(!g)throw new Error("Streaming error");const b=g.getReader(),j=new TextDecoder,v=n.length;let y="",k=!0,C=!1;for(;k;){const{value:e,done:t}=yield b.read();k=!t;if(y+=j.decode(e),y)z([...n.slice(0,v),{id:F.length+1,role:"assistant",content:y}]),C||(L("streaming"),C=!0);else if(!k&&!y)throw new Error("Server error")}const A=new Date;y&&(ee(),L("idle"),yield oe.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:I,responseId:w,documentIds:u},S&&{userId:S}),q&&{studioUserId:q}),q&&(null==O?void 0:O.studioid)&&{studioId:O.studioid}),D&&{deploymentId:D}),{messages:[{role:"user",message:p,sentAt:s},{role:"assistant",message:y,sentAt:A}]})),null==B||B(w))}catch(e){let t=v.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(P).find((([e])=>t.includes(e)));s?W(s[1]):G(t),ee()}finally{L("idle"),K(!1),$()}}));return t.jsxs("div",Object.assign({className:y.default("fixed flex w-full flex-col bottom-0 left-0","viewport"===M?"min-[767px]:relative min-[767px]:bottom-auto min-[767px]:left-auto":"absolute @[767px]/pickaxe-root:relative @[767px]/pickaxe-root:bottom-auto @[767px]/pickaxe-root:left-auto")},{children:[!N.isWhiteLabel&&t.jsx("div",Object.assign({className:"flex justify-end pr-3"},{children:t.jsx(b.default,{animateHover:!0})})),ue&&t.jsx(j.default,{data:(null==O?void 0:O.icebreakers)||[],style:{backgroundColor:A.secondary,color:A.secondaryText},isMobile:R||le,onSend:ce}),t.jsxs("div",Object.assign({id:(null==O?void 0:O.formid)+"--chat-parent",style:de,className:y.default("flex min-h-[56px] items-end gap-x-2 px-4 py-3 pb-[15px]","block"===C.formFieldStyle&&"shadow")},{children:["enduserupload"===(null==O?void 0:O.documentuploadtype)&&t.jsxs("div",Object.assign({className:"tooltip"},{children:[t.jsx("input",{id:"file-upload",ref:ae,type:"file",accept:[...p.allowedFileMimeTypes,...J?p.allowedImageMimeTypes:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){yield X(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx("button",Object.assign({className:"flex items-center disabled:cursor-wait disabled:opacity-50",disabled:H,onClick:()=>{var e;return null===(e=ae.current)||void 0===e?void 0:e.click()}},{children:t.jsx(x.default,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:A.accent}})}))]})),t.jsx(k.default,{id:(null==O?void 0:O.formid)+"--chat-textarea",className:y.default(ie.b2,"max-h-60 w-full resize-none border-transparent bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:font-semilight",!re.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:re,placeholder:null!==(h=null==O?void 0:O.placeholdertext)&&void 0!==h?h:"What do you want to talk about?",onChange:e=>ne(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),H||"idle"!==T||ce()))}}),t.jsx("button",Object.assign({id:(null==O?void 0:O.formid)+"--chat-button",className:"outline-none disabled:cursor-default disabled:opacity-50",disabled:H||"idle"!==T,onClick:()=>ce()},{children:t.jsx(g.default,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:H||"idle"!==T?A.secondaryText+"70":A.accent}})}))]}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime");exports.default=t=>{var{node:i,title:l="Random Iframe",children:s}=t,a=e.__rest(t,["node","title","children"]);return r.jsx("iframe",Object.assign({title:l,style:{borderRadius:"8px",width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},a,{children:s}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime");exports.default=t=>{var{node:i,title:l="Random Iframe",children:s,style:a}=t,n=e.__rest(t,["node","title","children","style"]);return r.jsx("iframe",Object.assign({title:l,style:Object.assign({borderRadius:"8px",width:"100%",marginBottom:"1.5rem"},a),allowFullScreen:!0},n,{children:s}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../hooks/usePickaxeMarkdownContext.js"),s=require("../common/Action.js");exports.default=({node:i,children:n})=>{const{actions:r}=t.usePickaxeMarkdownContext(),l="string"==typeof n&&n.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(l&&(null==l?void 0:l[1]))return e.jsx("div",Object.assign({style:{display:"flex",width:"100%",justifyContent:"center"}},{children:e.jsx("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${l[1]}`,style:{width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));if(r&&"string"==typeof n&&n.includes("pickaxe")&&(n.includes("/api/fn/result")||n.includes("/api/function_call_results"))){const t=n.replace(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g,""),i=n.match(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g);return e.jsxs("div",Object.assign({className:"flex flex-col"},{children:[e.jsx("p",Object.assign({style:{fontWeight:350}},{children:t})),e.jsx(s.default,{jobUrl:(null==i?void 0:i[0])||""})]}))}return e.jsx("p",Object.assign({style:{fontWeight:350}},{children:n}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../hooks/usePickaxeMarkdownContext.js"),s=require("../common/Action.js");exports.default=({node:i,children:n})=>{const{actions:r}=t.usePickaxeMarkdownContext(),l="string"==typeof n&&n.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(l&&(null==l?void 0:l[1]))return e.jsx("div",Object.assign({style:{display:"flex",width:"100%",justifyContent:"center"}},{children:e.jsx("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${l[1]}`,style:{width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));if(r&&"string"==typeof n&&n.includes("pickaxe")&&(n.includes("/api/fn/result")||n.includes("/api/function_call_results"))){const t=n.replace(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g,""),i=n.match(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g);return e.jsxs("div",Object.assign({className:"flex flex-col"},{children:[e.jsx("p",Object.assign({style:{fontWeight:350,marginBottom:"0.75rem"}},{children:t})),e.jsx(s.default,{jobUrl:(null==i?void 0:i[0])||""})]}))}return e.jsx("p",Object.assign({style:{fontWeight:350,marginBottom:"0.75rem"}},{children:n}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),i=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),n=require("react-markdown"),s=require("remark-gfm"),l=require("remark-math"),a=require("rehype-katex"),d=require("rehype-raw"),o=require("./Custom/A/index.js"),c=require("./Custom/P/index.js"),m=require("./Custom/Img/index.js"),u=require("./Custom/Iframe/index.js"),h=require("./Custom/Code/index.js"),g=require("./Custom/common/LinkPreview.js"),j=require("./Custom/common/TextModal.js");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=x(n),f=x(s),b=x(l),y=x(a),k=x(d);exports.PickaxeMarkdownRenderer=({className:n,style:s,value:l,recursion:a=!1,children:d,maxChar:x})=>{const{theme:O,accentColor:q,websiteMetadatas:v}=t.usePickaxeMarkdownContext(),[C,D]=i.useState(!1),S=i.useRef(null),w=i.useMemo((()=>{if(!l)return"";let e=l;return e=l.replace(/<!--[\s\S]*?-->/g,""),e=l.replace(/\u200B/g,""),x&&(e=e.slice(0,x)),e}),[l,x]),P={h1:({node:e,children:i})=>r.jsx("h1",Object.assign({style:{fontSize:"2.25rem",lineHeight:"2.5rem"}},{children:i})),h2:({node:e,children:i})=>r.jsx("h2",Object.assign({style:{fontSize:"1.875rem",lineHeight:"2.25rem"}},{children:i})),h3:({node:e,children:i})=>r.jsx("h3",Object.assign({style:{fontSize:"1.5rem",lineHeight:"2rem"}},{children:i})),h4:({node:e,children:i})=>r.jsx("h4",Object.assign({className:"mt-2",style:{fontSize:"1.25rem",lineHeight:"1.75rem"}},{children:i})),h5:({node:e,children:i})=>r.jsx("h5",Object.assign({style:{fontSize:"1.125rem",lineHeight:"1.75rem"}},{children:i})),p:c.default,a:o.default,ol:({node:e,children:i})=>r.jsx("ol",Object.assign({style:{listStyleType:"decimal",listStylePosition:"inside",paddingLeft:"1.5rem",marginBottom:"1.5rem"}},{children:i})),ul:({node:e,children:i})=>r.jsx("ul",Object.assign({style:{listStyleType:"disc",listStylePosition:"inside",paddingLeft:"1.5rem",marginBottom:"1.5rem"}},{children:i})),li:({node:e,children:i})=>r.jsx("li",{children:i}),table:({children:e})=>r.jsx("div",Object.assign({style:{position:"relative",overflow:"auto",marginBottom:"1.5rem"}},{children:r.jsx("table",Object.assign({style:{tableLayout:"fixed",fontSize:"0.875rem",lineHeight:"1.24rem"}},{children:e}))})),th:({node:e,children:i})=>r.jsx("th",Object.assign({style:{padding:"0.75em 1em",fontWeight:600,textAlign:"left"}},{children:i})),tr:({node:e,children:i})=>r.jsx("tr",Object.assign({style:{border:"dark"===O?"1px solid #30363D":"1px solid #D0D7DE"}},{children:i})),td:({node:e,children:i})=>r.jsx("td",Object.assign({style:{padding:"0.75em 1em"}},{children:i})),code:h.default,blockquote:({node:e,children:i})=>r.jsx("blockquote",Object.assign({style:{lineHeight:"15px",borderLeft:"dark"===O?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===O?"#8B8B8B":"#656D76",paddingLeft:"1rem",marginBottom:"1rem"}},{children:i})),img:m.default,iframe:u.default,hr:()=>r.jsx("hr",{style:{border:0,borderTop:"dark"===O?"1px solid #30363D":"1px solid #D0D7DE",marginTop:"1.5rem",marginBottom:"1.5rem"}}),span:i=>{var{node:t,children:n}=i,s=e.__rest(i,["node","children"]);return"intro-msg-expand-btn"===s.className?r.jsx("span",Object.assign({},s,{style:{display:"inline",fontWeight:500,color:q,cursor:"pointer"},onClick:()=>D(!0)},{children:n})):r.jsx("span",Object.assign({},s,{children:n}))}};return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:S,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},s)},{children:[C&&r.jsx(j.default,{value:w,isOpen:C,onChangeIsOpen:D}),r.jsx(p.default,Object.assign({},n&&{className:n},{components:P,remarkPlugins:[f.default,b.default],rehypePlugins:[y.default,k.default]},{children:`${w}${!a&&v.length>0?"\n\n---":""}${"number"==typeof x&&w.length>=x?'<span class="intro-msg-expand-btn">...</span>':""}`})),!a&&v.length>0&&r.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"2rem",marginTop:"2rem"}},{children:v.map(((e,i)=>r.jsx(g.default,{data:e},i)))})),d]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),i=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),n=require("react-markdown"),s=require("remark-gfm"),l=require("remark-math"),a=require("rehype-katex"),o=require("rehype-raw"),d=require("./Custom/A/index.js"),m=require("./Custom/P/index.js"),c=require("./Custom/Img/index.js"),u=require("./Custom/Iframe/index.js"),h=require("./Custom/Code/index.js"),g=require("./Custom/common/LinkPreview.js"),j=require("./Custom/common/TextModal.js");function x(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var p=x(n),f=x(s),b=x(l),y=x(a),k=x(o);exports.PickaxeMarkdownRenderer=({className:n,style:s,value:l,recursion:a=!1,children:o,maxChar:x})=>{const{theme:O,accentColor:q,websiteMetadatas:v}=t.usePickaxeMarkdownContext(),[C,B]=i.useState(!1),D=i.useRef(null),S=i.useMemo((()=>{if(!l)return"";let e=l;return e=l.replace(/<!--[\s\S]*?-->/g,""),e=l.replace(/\u200B/g,""),x&&(e=e.slice(0,x)),e}),[l,x]),w={h1:({node:e,children:i})=>r.jsx("h1",Object.assign({style:{fontSize:"2.25rem",lineHeight:"2.5rem",marginBottom:"1.5rem"}},{children:i})),h2:({node:e,children:i})=>r.jsx("h2",Object.assign({style:{fontSize:"1.875rem",lineHeight:"2.25rem",marginBottom:"0.75rem"}},{children:i})),h3:({node:e,children:i})=>r.jsx("h3",Object.assign({style:{fontSize:"1.5rem",lineHeight:"2rem",marginBottom:"0.5rem"}},{children:i})),h4:({node:e,children:i})=>r.jsx("h4",Object.assign({className:"mt-2",style:{fontSize:"1.25rem",lineHeight:"1.75rem",marginBottom:"0.5rem"}},{children:i})),h5:({node:e,children:i})=>r.jsx("h5",Object.assign({style:{fontSize:"1.125rem",lineHeight:"1.75rem",marginBottom:"0.5rem"}},{children:i})),p:m.default,a:d.default,ol:({node:e,children:i})=>r.jsx("ol",Object.assign({style:{listStyleType:"decimal",listStylePosition:"inside",paddingLeft:"1.5rem",marginBottom:"1.5rem"}},{children:i})),ul:({node:e,children:i})=>r.jsx("ul",Object.assign({style:{listStyleType:"disc",listStylePosition:"inside",paddingLeft:"1.5rem",marginBottom:"1.5rem"}},{children:i})),li:({node:e,children:i})=>r.jsx("li",{children:i}),table:({children:e})=>r.jsx("div",Object.assign({style:{position:"relative",overflow:"auto",marginBottom:"1.5rem"}},{children:r.jsx("table",Object.assign({style:{tableLayout:"fixed",fontSize:"0.875rem",lineHeight:"1.24rem"}},{children:e}))})),th:({node:e,children:i})=>r.jsx("th",Object.assign({style:{padding:"0.75em 1em",fontWeight:600,textAlign:"left"}},{children:i})),tr:({node:e,children:i})=>r.jsx("tr",Object.assign({style:{border:"dark"===O?"1px solid #30363D":"1px solid #D0D7DE"}},{children:i})),td:({node:e,children:i})=>r.jsx("td",Object.assign({style:{padding:"0.75em 1em"}},{children:i})),code:h.default,blockquote:({node:e,children:i})=>r.jsx("blockquote",Object.assign({style:{lineHeight:"15px",borderLeft:"dark"===O?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===O?"#8B8B8B":"#656D76",paddingLeft:"1rem",marginBottom:"1rem"}},{children:i})),img:c.default,iframe:u.default,hr:()=>r.jsx("hr",{style:{border:0,borderTop:"dark"===O?"1px solid #30363D":"1px solid #D0D7DE",marginBottom:"1.5rem"}}),span:i=>{var{node:t,children:n}=i,s=e.__rest(i,["node","children"]);return"intro-msg-expand-btn"===s.className?r.jsx("span",Object.assign({},s,{style:{display:"inline",fontWeight:500,color:q,cursor:"pointer"},onClick:()=>B(!0)},{children:n})):r.jsx("span",Object.assign({},s,{children:n}))}};return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:D,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},s)},{children:[C&&r.jsx(j.default,{value:S,isOpen:C,onChangeIsOpen:B}),r.jsx(p.default,Object.assign({},n&&{className:n},{components:w,remarkPlugins:[f.default,b.default],rehypePlugins:[y.default,k.default]},{children:`${S}${!a&&v.length>0?"\n\n---":""}${"number"==typeof x&&S.length>=x?'<span class="intro-msg-expand-btn">...</span>':""}`})),!a&&v.length>0&&r.jsx("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"2rem",marginTop:"2rem"}},{children:v.map(((e,i)=>r.jsx(g.default,{data:e},i)))})),o]}))};
@@ -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 s,useRef as r,useMemo as i,useEffect as n}from"react";import{useMediaQuery as a}from"../../../hooks/core/useMediaQuery.js";import{usePickaxeContext as l}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as d}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as c}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as m}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as u}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as p}from"../../../hooks/pickaxe/useSubmit.js";import{useSubmitResult as f}from"../../../hooks/pickaxe/useSubmitResult.js";import{useDocument as h}from"../Addons/Document/hooks/useDocument.js";import{useScroll as g}from"../Addons/Scroll/hooks/useScroll.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as x}from"../../../common/documents.js";import{streamer as v}from"../../../common/api/streamer.js";import y from"react-textarea-autosize";import I from"../../Icons/attach.svg.js";import j from"../../Icons/arrow-right.svg.js";import k from"../common/PickaxeBranding.js";import w from"../Addons/IceBreaker/index.js";import D from"../../../common/error.js";import O from"../../../common/cn.js";const S=()=>{var S;const{formId:A,chatId:N,userId:C,studioUserId:U,deploymentId:E,pickaxe:B,styles:R,colors:F,misc:L,responsiveBy:M,isNewChat:T,forceMobile:z,setIsNewChat:P,setIsShowIceBreaker:W,onGenerateComplete:G}=l(),{messages:K,status:_,limits:H,setMessages:Q,setStatus:q,setLimitData:J,setError:V,setIsGenerating:X}=d(),{documents:Y,isUploading:Z,isImageUploadAllowed:$,upsertDocuments:ee,onFileUpload:oe,onEditDocumentByDocId:te}=h(),{scrollStartSession:se,scrollEndSession:re,scrollToBottom:ie}=g({auto:!0}),ne=u(),ae=p(),le=f(),de=m(),[ce,me]=s(""),ue=r(null),[pe]=a("(max-width: 767px)"),fe=c(),he=i((()=>{var e,o,t;return!!T&&(!!B&&(!ne.isLoading&&(!((null!==(o=null===(e=ne.data)||void 0===e?void 0:e.messages.length)&&void 0!==o?o:0)>1)&&!!(null===(t=B.icebreakers)||void 0===t?void 0:t.length))))}),[B,T,ne.data,ne.isLoading]);n((()=>{W(he)}),[he]);const ge=o=>e(void 0,void 0,void 0,(function*(){try{if(Z||"idle"!==_)return;const e=null!=o?o:ce;if(!e)return;me(""),V(""),J(null),X(!0),P(!1);const t=new Date,s="enduserupload"===(null==B?void 0:B.documentuploadtype),r=Y.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),i=r.length?r[r.length-1].documentId:"";q("fetching"),se(),ie();const n=[...K,{id:K.length+1,role:"user",content:e}];Q(n),ie();const{success:a,data:l,actionData:d,usedDocumentIds:c,newDocumentId:m,newDocumentName:u,rawUserInput:p,isInsertedFile:f,error:h}=yield ae.mutateAsync(Object.assign(Object.assign(Object.assign({formId:A,responseId:N,value:e},s&&i&&{documentId:i}),U&&{studioUserId:U}),E&&{deploymentId:E}));if(!a)throw new Error(null!=h?h:"An error occurred, please try again.");ie(),f&&i&&te({documentId:i,isInsertedAsRaw:!0}),m&&u&&ee([{type:"website",id:u,name:u,status:"finished",documentId:m}]),ie();const g=(yield v({formId:A,responseId:N,data:l,actionData:d})).body;if(!g)throw new Error("Streaming error");const b=g.getReader(),x=new TextDecoder,y=n.length;let I="",j=!0,k=!1;for(;j;){const{value:e,done:o}=yield b.read();j=!o;if(I+=x.decode(e),I)Q([...n.slice(0,y),{id:K.length+1,role:"assistant",content:I}]),k||(q("streaming"),k=!0);else if(!j&&!I)throw new Error("Server error")}const w=new Date;I&&(ie(),q("idle"),yield le.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:A,responseId:N,documentIds:c},C&&{userId:C}),U&&{studioUserId:U}),U&&(null==B?void 0:B.studioid)&&{studioId:B.studioid}),E&&{deploymentId:E}),{messages:[{role:"user",message:p,sentAt:t},{role:"assistant",message:I,sentAt:w}]})),null==G||G(N))}catch(e){let o=D(e)||"";o&&!o.includes("Unexpected token 'A',")||(o="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(H).find((([e])=>o.includes(e)));t?J(t[1]):V(o),ie()}finally{q("idle"),X(!1),re()}}));return o("div",Object.assign({className:O("fixed flex w-full flex-col bottom-0 left-0","viewport"===M?"min-[767px]:relative min-[767px]:bottom-auto min-[767px]:left-auto":"absolute @[767px]/pickaxe-root:relative @[767px]/pickaxe-root:bottom-auto @[767px]/pickaxe-root:left-auto")},{children:[!L.isWhiteLabel&&t("div",Object.assign({className:"flex justify-end pr-3"},{children:t(k,{animateHover:!0})})),he&&t(w,{data:(null==B?void 0:B.icebreakers)||[],style:{backgroundColor:F.secondary,color:F.secondaryText},isMobile:z||pe,onSend:ge}),o("div",Object.assign({style:fe,className:O("flex min-h-[56px] items-end gap-x-2 px-4 py-3 pb-[15px]","block"===R.formFieldStyle&&"shadow")},{children:["enduserupload"===(null==B?void 0:B.documentuploadtype)&&o("div",Object.assign({className:"tooltip"},{children:[t("input",{id:"file-upload",ref:ue,type:"file",accept:[...b,...$?x:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:o=>e(void 0,void 0,void 0,(function*(){yield oe(Array.from(o.target.files||[])),o.target.value=""}))}),t("button",Object.assign({className:"flex items-center disabled:cursor-wait disabled:opacity-50",disabled:Z,onClick:()=>{var e;return null===(e=ue.current)||void 0===e?void 0:e.click()}},{children:t(I,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:F.accent}})}))]})),t(y,{className:O(de.b2,"max-h-60 w-full resize-none border-transparent bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:font-semilight",!ce.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:ce,placeholder:null!==(S=null==B?void 0:B.placeholdertext)&&void 0!==S?S:"What do you want to talk about?",onChange:e=>me(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Z||"idle"!==_||ge()))}}),t("button",Object.assign({className:"outline-none disabled:cursor-default disabled:opacity-50",disabled:Z||"idle"!==_,onClick:()=>ge()},{children:t(j,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:Z||"idle"!==_?F.secondaryText+"70":F.accent}})}))]}))]}))};export{S as default};
1
+ import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as s,useRef as i,useMemo as r,useEffect as n}from"react";import{useMediaQuery as a}from"../../../hooks/core/useMediaQuery.js";import{usePickaxeContext as l}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as d}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as c}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as m}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as u}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as p}from"../../../hooks/pickaxe/useSubmit.js";import{useSubmitResult as f}from"../../../hooks/pickaxe/useSubmitResult.js";import{useDocument as h}from"../Addons/Document/hooks/useDocument.js";import{useScroll as g}from"../Addons/Scroll/hooks/useScroll.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as v}from"../../../common/documents.js";import{streamer as x}from"../../../common/api/streamer.js";import y from"react-textarea-autosize";import I from"../../Icons/attach.svg.js";import j from"../../Icons/arrow-right.svg.js";import k from"../common/PickaxeBranding.js";import w from"../Addons/IceBreaker/index.js";import D from"../../../common/error.js";import O from"../../../common/cn.js";const S=()=>{var S;const{formId:A,chatId:N,userId:C,studioUserId:U,deploymentId:E,pickaxe:B,styles:R,colors:F,misc:L,responsiveBy:M,isNewChat:T,forceMobile:z,setIsNewChat:P,setIsShowIceBreaker:W,onGenerateComplete:G}=l(),{messages:K,status:_,limits:H,setMessages:Q,setStatus:q,setLimitData:J,setError:V,setIsGenerating:X}=d(),{documents:Y,isUploading:Z,isImageUploadAllowed:$,upsertDocuments:ee,onFileUpload:oe,onEditDocumentByDocId:te}=h(),{scrollStartSession:se,scrollEndSession:ie,scrollToBottom:re}=g({auto:!0}),ne=u(),ae=p(),le=f(),de=m(),[ce,me]=s(""),ue=i(null),[pe]=a("(max-width: 767px)"),fe=c(),he=r((()=>{var e,o,t;return!!T&&(!!B&&(!ne.isLoading&&(!((null!==(o=null===(e=ne.data)||void 0===e?void 0:e.messages.length)&&void 0!==o?o:0)>1)&&!!(null===(t=B.icebreakers)||void 0===t?void 0:t.length))))}),[B,T,ne.data,ne.isLoading]);n((()=>{W(he)}),[he]);const ge=o=>e(void 0,void 0,void 0,(function*(){try{if(Z||"idle"!==_)return;const e=null!=o?o:ce;if(!e)return;me(""),V(""),J(null),X(!0),P(!1);const t=new Date,s="enduserupload"===(null==B?void 0:B.documentuploadtype),i=Y.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=i.length?i[i.length-1].documentId:"";q("fetching"),se(),re();const n=[...K,{id:K.length+1,role:"user",content:e}];Q(n),re();const{success:a,data:l,actionData:d,usedDocumentIds:c,newDocumentId:m,newDocumentName:u,rawUserInput:p,isInsertedFile:f,error:h}=yield ae.mutateAsync(Object.assign(Object.assign(Object.assign({formId:A,responseId:N,value:e},s&&r&&{documentId:r}),U&&{studioUserId:U}),E&&{deploymentId:E}));if(!a)throw new Error(null!=h?h:"An error occurred, please try again.");re(),f&&r&&te({documentId:r,isInsertedAsRaw:!0}),m&&u&&ee([{type:"website",id:u,name:u,status:"finished",documentId:m}]),re();const g=(yield x({formId:A,responseId:N,data:l,actionData:d})).body;if(!g)throw new Error("Streaming error");const b=g.getReader(),v=new TextDecoder,y=n.length;let I="",j=!0,k=!1;for(;j;){const{value:e,done:o}=yield b.read();j=!o;if(I+=v.decode(e),I)Q([...n.slice(0,y),{id:K.length+1,role:"assistant",content:I}]),k||(q("streaming"),k=!0);else if(!j&&!I)throw new Error("Server error")}const w=new Date;I&&(re(),q("idle"),yield le.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:A,responseId:N,documentIds:c},C&&{userId:C}),U&&{studioUserId:U}),U&&(null==B?void 0:B.studioid)&&{studioId:B.studioid}),E&&{deploymentId:E}),{messages:[{role:"user",message:p,sentAt:t},{role:"assistant",message:I,sentAt:w}]})),null==G||G(N))}catch(e){let o=D(e)||"";o&&!o.includes("Unexpected token 'A',")||(o="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(H).find((([e])=>o.includes(e)));t?J(t[1]):V(o),re()}finally{q("idle"),X(!1),ie()}}));return o("div",Object.assign({className:O("fixed flex w-full flex-col bottom-0 left-0","viewport"===M?"min-[767px]:relative min-[767px]:bottom-auto min-[767px]:left-auto":"absolute @[767px]/pickaxe-root:relative @[767px]/pickaxe-root:bottom-auto @[767px]/pickaxe-root:left-auto")},{children:[!L.isWhiteLabel&&t("div",Object.assign({className:"flex justify-end pr-3"},{children:t(k,{animateHover:!0})})),he&&t(w,{data:(null==B?void 0:B.icebreakers)||[],style:{backgroundColor:F.secondary,color:F.secondaryText},isMobile:z||pe,onSend:ge}),o("div",Object.assign({id:(null==B?void 0:B.formid)+"--chat-parent",style:fe,className:O("flex min-h-[56px] items-end gap-x-2 px-4 py-3 pb-[15px]","block"===R.formFieldStyle&&"shadow")},{children:["enduserupload"===(null==B?void 0:B.documentuploadtype)&&o("div",Object.assign({className:"tooltip"},{children:[t("input",{id:"file-upload",ref:ue,type:"file",accept:[...b,...$?v:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:o=>e(void 0,void 0,void 0,(function*(){yield oe(Array.from(o.target.files||[])),o.target.value=""}))}),t("button",Object.assign({className:"flex items-center disabled:cursor-wait disabled:opacity-50",disabled:Z,onClick:()=>{var e;return null===(e=ue.current)||void 0===e?void 0:e.click()}},{children:t(I,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:F.accent}})}))]})),t(y,{id:(null==B?void 0:B.formid)+"--chat-textarea",className:O(de.b2,"max-h-60 w-full resize-none border-transparent bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:font-semilight",!ce.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:ce,placeholder:null!==(S=null==B?void 0:B.placeholdertext)&&void 0!==S?S:"What do you want to talk about?",onChange:e=>me(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Z||"idle"!==_||ge()))}}),t("button",Object.assign({id:(null==B?void 0:B.formid)+"--chat-button",className:"outline-none disabled:cursor-default disabled:opacity-50",disabled:Z||"idle"!==_,onClick:()=>ge()},{children:t(j,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:Z||"idle"!==_?F.secondaryText+"70":F.accent}})}))]}))]}))};export{S as default};
@@ -1 +1 @@
1
- import{__rest as e}from"../../../../../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";const r=r=>{var{node:i,title:l="Random Iframe",children:a}=r,n=e(r,["node","title","children"]);return t("iframe",Object.assign({title:l,style:{borderRadius:"8px",width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},n,{children:a}))};export{r as default};
1
+ import{__rest as e}from"../../../../../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";const r=r=>{var{node:i,title:l="Random Iframe",children:a,style:n}=r,o=e(r,["node","title","children","style"]);return t("iframe",Object.assign({title:l,style:Object.assign({borderRadius:"8px",width:"100%",marginBottom:"1.5rem"},n),allowFullScreen:!0},o,{children:a}))};export{r as default};
@@ -1 +1 @@
1
- import{jsx as t,jsxs as e}from"react/jsx-runtime";import{usePickaxeMarkdownContext as i}from"../../hooks/usePickaxeMarkdownContext.js";import s from"../common/Action.js";const n=({node:n,children:l})=>{const{actions:o}=i(),r="string"==typeof l&&l.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(r&&(null==r?void 0:r[1]))return t("div",Object.assign({style:{display:"flex",width:"100%",justifyContent:"center"}},{children:t("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${r[1]}`,style:{width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));if(o&&"string"==typeof l&&l.includes("pickaxe")&&(l.includes("/api/fn/result")||l.includes("/api/function_call_results"))){const i=l.replace(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g,""),n=l.match(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g);return e("div",Object.assign({className:"flex flex-col"},{children:[t("p",Object.assign({style:{fontWeight:350}},{children:i})),t(s,{jobUrl:(null==n?void 0:n[0])||""})]}))}return t("p",Object.assign({style:{fontWeight:350}},{children:l}))};export{n as default};
1
+ import{jsx as t,jsxs as e}from"react/jsx-runtime";import{usePickaxeMarkdownContext as i}from"../../hooks/usePickaxeMarkdownContext.js";import n from"../common/Action.js";const s=({node:s,children:o})=>{const{actions:r}=i(),l="string"==typeof o&&o.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(l&&(null==l?void 0:l[1]))return t("div",Object.assign({style:{display:"flex",width:"100%",justifyContent:"center"}},{children:t("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${l[1]}`,style:{width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));if(r&&"string"==typeof o&&o.includes("pickaxe")&&(o.includes("/api/fn/result")||o.includes("/api/function_call_results"))){const i=o.replace(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g,""),s=o.match(/https:\/\/\S*(\/api\/fn\/result|\/api\/function_call_results)\S*/g);return e("div",Object.assign({className:"flex flex-col"},{children:[t("p",Object.assign({style:{fontWeight:350,marginBottom:"0.75rem"}},{children:i})),t(n,{jobUrl:(null==s?void 0:s[0])||""})]}))}return t("p",Object.assign({style:{fontWeight:350,marginBottom:"0.75rem"}},{children:o}))};export{s as default};
@@ -1 +1 @@
1
- import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as i}from"react/jsx-runtime";import{useState as t,useRef as n,useMemo as o}from"react";import{usePickaxeMarkdownContext as s}from"./hooks/usePickaxeMarkdownContext.js";import l from"react-markdown";import m from"remark-gfm";import a from"remark-math";import d from"rehype-katex";import c from"rehype-raw";import h from"./Custom/A/index.js";import p from"./Custom/P/index.js";import g from"./Custom/Img/index.js";import f from"./Custom/Iframe/index.js";import b from"./Custom/Code/index.js";import y from"./Custom/common/LinkPreview.js";import u from"./Custom/common/TextModal.js";const j=({className:j,style:x,value:O,recursion:k=!1,children:C,maxChar:D})=>{const{theme:v,accentColor:S,websiteMetadatas:w}=s(),[B,H]=t(!1),P=n(null),T=o((()=>{if(!O)return"";let e=O;return e=O.replace(/<!--[\s\S]*?-->/g,""),e=O.replace(/\u200B/g,""),D&&(e=e.slice(0,D)),e}),[O,D]),z={h1:({node:e,children:r})=>i("h1",Object.assign({style:{fontSize:"2.25rem",lineHeight:"2.5rem"}},{children:r})),h2:({node:e,children:r})=>i("h2",Object.assign({style:{fontSize:"1.875rem",lineHeight:"2.25rem"}},{children:r})),h3:({node:e,children:r})=>i("h3",Object.assign({style:{fontSize:"1.5rem",lineHeight:"2rem"}},{children:r})),h4:({node:e,children:r})=>i("h4",Object.assign({className:"mt-2",style:{fontSize:"1.25rem",lineHeight:"1.75rem"}},{children:r})),h5:({node:e,children:r})=>i("h5",Object.assign({style:{fontSize:"1.125rem",lineHeight:"1.75rem"}},{children:r})),p:p,a:h,ol:({node:e,children:r})=>i("ol",Object.assign({style:{listStyleType:"decimal",listStylePosition:"inside",paddingLeft:"1.5rem",marginBottom:"1.5rem"}},{children:r})),ul:({node:e,children:r})=>i("ul",Object.assign({style:{listStyleType:"disc",listStylePosition:"inside",paddingLeft:"1.5rem",marginBottom:"1.5rem"}},{children:r})),li:({node:e,children:r})=>i("li",{children:r}),table:({children:e})=>i("div",Object.assign({style:{position:"relative",overflow:"auto",marginBottom:"1.5rem"}},{children:i("table",Object.assign({style:{tableLayout:"fixed",fontSize:"0.875rem",lineHeight:"1.24rem"}},{children:e}))})),th:({node:e,children:r})=>i("th",Object.assign({style:{padding:"0.75em 1em",fontWeight:600,textAlign:"left"}},{children:r})),tr:({node:e,children:r})=>i("tr",Object.assign({style:{border:"dark"===v?"1px solid #30363D":"1px solid #D0D7DE"}},{children:r})),td:({node:e,children:r})=>i("td",Object.assign({style:{padding:"0.75em 1em"}},{children:r})),code:b,blockquote:({node:e,children:r})=>i("blockquote",Object.assign({style:{lineHeight:"15px",borderLeft:"dark"===v?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===v?"#8B8B8B":"#656D76",paddingLeft:"1rem",marginBottom:"1rem"}},{children:r})),img:g,iframe:f,hr:()=>i("hr",{style:{border:0,borderTop:"dark"===v?"1px solid #30363D":"1px solid #D0D7DE",marginTop:"1.5rem",marginBottom:"1.5rem"}}),span:r=>{var{node:t,children:n}=r,o=e(r,["node","children"]);return"intro-msg-expand-btn"===o.className?i("span",Object.assign({},o,{style:{display:"inline",fontWeight:500,color:S,cursor:"pointer"},onClick:()=>H(!0)},{children:n})):i("span",Object.assign({},o,{children:n}))}};return r("div",Object.assign({className:"pxe-markdown",ref:P,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},x)},{children:[B&&i(u,{value:T,isOpen:B,onChangeIsOpen:H}),i(l,Object.assign({},j&&{className:j},{components:z,remarkPlugins:[m,a],rehypePlugins:[d,c]},{children:`${T}${!k&&w.length>0?"\n\n---":""}${"number"==typeof D&&T.length>=D?'<span class="intro-msg-expand-btn">...</span>':""}`})),!k&&w.length>0&&i("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"2rem",marginTop:"2rem"}},{children:w.map(((e,r)=>i(y,{data:e},r)))})),C]}))};export{j as PickaxeMarkdownRenderer};
1
+ import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as i}from"react/jsx-runtime";import{useState as t,useRef as n,useMemo as o}from"react";import{usePickaxeMarkdownContext as s}from"./hooks/usePickaxeMarkdownContext.js";import l from"react-markdown";import m from"remark-gfm";import a from"remark-math";import d from"rehype-katex";import c from"rehype-raw";import h from"./Custom/A/index.js";import p from"./Custom/P/index.js";import g from"./Custom/Img/index.js";import f from"./Custom/Iframe/index.js";import b from"./Custom/Code/index.js";import y from"./Custom/common/LinkPreview.js";import u from"./Custom/common/TextModal.js";const j=({className:j,style:x,value:O,recursion:k=!1,children:B,maxChar:C})=>{const{theme:D,accentColor:v,websiteMetadatas:S}=s(),[w,H]=t(!1),P=n(null),z=o((()=>{if(!O)return"";let e=O;return e=O.replace(/<!--[\s\S]*?-->/g,""),e=O.replace(/\u200B/g,""),C&&(e=e.slice(0,C)),e}),[O,C]),L={h1:({node:e,children:r})=>i("h1",Object.assign({style:{fontSize:"2.25rem",lineHeight:"2.5rem",marginBottom:"1.5rem"}},{children:r})),h2:({node:e,children:r})=>i("h2",Object.assign({style:{fontSize:"1.875rem",lineHeight:"2.25rem",marginBottom:"0.75rem"}},{children:r})),h3:({node:e,children:r})=>i("h3",Object.assign({style:{fontSize:"1.5rem",lineHeight:"2rem",marginBottom:"0.5rem"}},{children:r})),h4:({node:e,children:r})=>i("h4",Object.assign({className:"mt-2",style:{fontSize:"1.25rem",lineHeight:"1.75rem",marginBottom:"0.5rem"}},{children:r})),h5:({node:e,children:r})=>i("h5",Object.assign({style:{fontSize:"1.125rem",lineHeight:"1.75rem",marginBottom:"0.5rem"}},{children:r})),p:p,a:h,ol:({node:e,children:r})=>i("ol",Object.assign({style:{listStyleType:"decimal",listStylePosition:"inside",paddingLeft:"1.5rem",marginBottom:"1.5rem"}},{children:r})),ul:({node:e,children:r})=>i("ul",Object.assign({style:{listStyleType:"disc",listStylePosition:"inside",paddingLeft:"1.5rem",marginBottom:"1.5rem"}},{children:r})),li:({node:e,children:r})=>i("li",{children:r}),table:({children:e})=>i("div",Object.assign({style:{position:"relative",overflow:"auto",marginBottom:"1.5rem"}},{children:i("table",Object.assign({style:{tableLayout:"fixed",fontSize:"0.875rem",lineHeight:"1.24rem"}},{children:e}))})),th:({node:e,children:r})=>i("th",Object.assign({style:{padding:"0.75em 1em",fontWeight:600,textAlign:"left"}},{children:r})),tr:({node:e,children:r})=>i("tr",Object.assign({style:{border:"dark"===D?"1px solid #30363D":"1px solid #D0D7DE"}},{children:r})),td:({node:e,children:r})=>i("td",Object.assign({style:{padding:"0.75em 1em"}},{children:r})),code:b,blockquote:({node:e,children:r})=>i("blockquote",Object.assign({style:{lineHeight:"15px",borderLeft:"dark"===D?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===D?"#8B8B8B":"#656D76",paddingLeft:"1rem",marginBottom:"1rem"}},{children:r})),img:g,iframe:f,hr:()=>i("hr",{style:{border:0,borderTop:"dark"===D?"1px solid #30363D":"1px solid #D0D7DE",marginBottom:"1.5rem"}}),span:r=>{var{node:t,children:n}=r,o=e(r,["node","children"]);return"intro-msg-expand-btn"===o.className?i("span",Object.assign({},o,{style:{display:"inline",fontWeight:500,color:v,cursor:"pointer"},onClick:()=>H(!0)},{children:n})):i("span",Object.assign({},o,{children:n}))}};return r("div",Object.assign({className:"pxe-markdown",ref:P,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},x)},{children:[w&&i(u,{value:z,isOpen:w,onChangeIsOpen:H}),i(l,Object.assign({},j&&{className:j},{components:L,remarkPlugins:[m,a],rehypePlugins:[d,c]},{children:`${z}${!k&&S.length>0?"\n\n---":""}${"number"==typeof C&&z.length>=C?'<span class="intro-msg-expand-btn">...</span>':""}`})),!k&&S.length>0&&i("div",Object.assign({style:{display:"flex",flexDirection:"column",gap:"2rem",marginTop:"2rem"}},{children:S.map(((e,r)=>i(y,{data:e},r)))})),B]}))};export{j as PickaxeMarkdownRenderer};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "0.0.67",
3
+ "version": "0.0.69",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",