@pickaxeproject/react 0.0.14 → 0.0.16

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("react/jsx-runtime"),t=require("react"),s=require("../../common/cn.js");exports.default=({src:r,alt:a,width:i=24,height:d=24,className:l,isLoading:c})=>{const[n,o]=t.useState(!1),u=r||"";return c?e.jsx("div",{className:s.default("shrink-0 animate-pulse rounded bg-c-skeleton dark:bg-c-skeleton-dark",l),style:{width:i,height:d}}):"NONE"===u?null:!u||n?e.jsx("div",{className:s.default("shrink-0 rounded bg-c-skeleton dark:bg-c-skeleton-dark",l),style:{width:i,height:d}}):e.jsx("div",Object.assign({className:"relative shrink-0 rounded",style:{width:i,height:d}},{children:e.jsx("img",{src:u,alt:a||"Pickaxe's Profile Picture",width:i,height:d,className:s.default("select-none rounded object-cover",l),draggable:!1,onError:()=>o(!0)})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../Icons/spark.svg.js"),r=require("../../common/cn.js");exports.default=({src:a,alt:i,width:c=24,height:l=24,className:d,textColor:n,isLoading:h})=>{const[o,u]=s.useState(!1),g=a||"";return h?e.jsx("div",{className:r.default("shrink-0 animate-pulse rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]",d),style:{width:c,height:l}}):n&&"https://pickaxe.chat/builder/assets/images/pickaxe-chaticons/chaticon2.png"===g?e.jsx(t.default,{className:r.default("h-6 w-6 shrink-0",d),style:{color:n}}):"NONE"===g?null:!g||o?e.jsx("div",{className:r.default("shrink-0 rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]",d),style:{width:c,height:l}}):e.jsx("div",Object.assign({className:"relative shrink-0 rounded",style:{width:c,height:l}},{children:e.jsx("img",{src:g,alt:i||"Pickaxe's Profile Picture",width:c,height:l,className:r.default("select-none rounded object-cover",d),draggable:!1,onError:()=>u(!0)})}))};
@@ -0,0 +1 @@
1
+ "use strict";function e(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}Object.defineProperty(exports,"__esModule",{value:!0});var r,t,n,o=e(require("react"));function a(){return a=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},a.apply(null,arguments)}var c=e=>o.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},e),r||(r=o.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v3M12 18v3M3 12h3M18 12h3"})),t||(t=o.createElement("circle",{cx:12,cy:12,r:2,stroke:"currentColor",strokeWidth:2})),n||(n=o.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M18 8h-1.2a.8.8 0 0 1-.8-.8V6M6 8h1.2a.8.8 0 0 0 .8-.8V6M18 16h-1.2a.8.8 0 0 0-.8.8V18M6 16h1.2a.8.8 0 0 1 .8.8V18"})));exports.default=c;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../Core/PickaxeIcon.js"),t=require("../../../Core/CopyButton.js"),l=require("../../../Core/MarkdownRenderer.js");exports.default=({message:r})=>{var c;const{formId:i,pickaxe:x}=s.usePickaxeContext(),o=null!==(c=null==x?void 0:x.chaticon)&&void 0!==c?c:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${i}.png`;return"assistant"===r.role?e.jsx("div",Object.assign({className:"flex max-w-[80%] flex-col max-[767px]:max-w-full"},{children:e.jsxs("div",Object.assign({className:"flex gap-x-3"},{children:["NONE"!==o&&e.jsx(a.default,{src:o,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6"}),e.jsxs("div",Object.assign({className:"flex flex-col"},{children:[e.jsx("div",Object.assign({className:"chat-message overflow-x-auto overflow-y-hidden rounded bg-blue-100/50 px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B]"},{children:e.jsx(l.default,{className:"relative max-[767px]:text-sm",html:r.content})})),e.jsx("div",Object.assign({className:"mb-2 ml-2 mt-4 flex gap-3"},{children:e.jsx(t.default,{text:r.content})}))]}))]}))})):"user"===r.role?e.jsx("div",Object.assign({className:"flex max-w-[80%] gap-x-3 justify-self-end max-[767px]:max-w-full max-[767px]:pl-9"},{children:e.jsx("div",Object.assign({className:"overflow-x-auto overflow-y-hidden rounded bg-white px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B]"},{children:e.jsx(l.default,{className:"relative max-[767px]:text-sm",html:r.content})}))})):e.jsx("div",{})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../Core/PickaxeIcon.js"),t=require("../../../Core/CopyButton.js"),l=require("../../../Core/MarkdownRenderer.js");exports.default=({message:r})=>{var c;const{formId:o,pickaxe:x,colors:i}=s.usePickaxeContext(),n=null!==(c=null==x?void 0:x.chaticon)&&void 0!==c?c:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${o}.png`;return"assistant"===r.role?e.jsx("div",Object.assign({className:"flex max-w-[80%] flex-col max-[767px]:max-w-full"},{children:e.jsxs("div",Object.assign({className:"flex gap-x-3"},{children:["NONE"!==n&&e.jsx(a.default,{src:n,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:i.text}),e.jsxs("div",Object.assign({className:"flex flex-col"},{children:[e.jsx("div",Object.assign({className:"chat-message overflow-x-auto overflow-y-hidden rounded px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B]",style:{backgroundColor:i.secondary+"80",color:i.secondaryText}},{children:e.jsx(l.default,{className:"relative max-[767px]:text-sm",html:r.content})})),e.jsx("div",Object.assign({className:"mb-2 ml-2 mt-4 flex gap-3"},{children:e.jsx(t.default,{text:r.content})}))]}))]}))})):"user"===r.role?e.jsx("div",Object.assign({className:"flex max-w-[80%] gap-x-3 justify-self-end max-[767px]:max-w-full max-[767px]:pl-9"},{children:e.jsx("div",Object.assign({className:"overflow-x-auto overflow-y-hidden rounded bg-white px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B]"},{children:e.jsx(l.default,{className:"relative max-[767px]:text-sm",html:r.content})}))})):e.jsx("div",{})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../../hooks/pickaxe/useConversation.js"),i=require("../../../Icons/circle-info.svg.js"),c=require("../../../Core/PickaxeIcon.js"),n=require("../../Addons/Scroll/ScrollLockView.js"),r=require("../../InfoModal.js"),o=require("./Message.js"),d=require("../../../../common/cn.js"),x=require("../../../Core/HtmlRenderer.js");exports.default=()=>{var u;const{pickaxe:m,colors:j,isNewChat:f}=a.usePickaxeContext(),{messages:p,status:g,error:h}=t.useResponseContext(),b=l.useConversation(),[v,w]=s.useState(!1),N=s.useMemo((()=>!!b.data&&!(b.data.messages.length<=1)),[b.data]),y=s.useMemo((()=>b.isSuccess&&f&&!N),[b.isSuccess,f,N]);return e.jsxs("div",Object.assign({className:"relative flex flex-grow flex-col justify-end"},{children:[v&&e.jsx(r.default,{isOpen:v,onChangeIsOpen:w}),e.jsxs("div",Object.assign({className:d.default("absolute left-1/2 top-5 flex w-full max-w-[400px] -translate-x-1/2 -translate-y-1/3 transform flex-col items-center px-4 opacity-0 duration-300",y&&"top-1/3 opacity-100")},{children:[e.jsx(c.default,{src:null==m?void 0:m.coverphoto,alt:`${null==m?void 0:m.formtitle}'s Profile Picture`,width:64,height:64,className:"h-16 w-16 rounded-full"}),e.jsxs("div",Object.assign({className:"flex flex-col items-center"},{children:[e.jsxs("h2",Object.assign({className:"mt-6 text-center text-lg font-semibold opacity-70 max-[767px]:text-base"},{children:[`${null==m?void 0:m.formtitle.slice(0,130)}${(null!==(u=null==m?void 0:m.formtitle)&&void 0!==u?u:"").length>130?"...":""}`,e.jsx("button",Object.assign({className:"ml-2 inline-block outline-none hover:opacity-70 hover:duration-300 active:opacity-100",onClick:()=>w(!0)},{children:e.jsx(i.default,{className:"h-5 w-5 shrink-0",style:{color:j.accent}})}))]})),e.jsx("p",Object.assign({className:"mt-2 line-clamp-3 whitespace-pre-line max-w-[600px] text-center font-semilight opacity-70"},{children:null==m?void 0:m.formdescription}))]}))]})),e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:b.isLoading?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[e.jsx("div",{className:"h-10 w-[70%] animate-pulse justify-self-end rounded bg-gray-200"}),e.jsx("div",{className:"h-[150px] w-[70%] animate-pulse rounded bg-gray-200"}),e.jsx("div",{className:"h-10 w-[50%] animate-pulse justify-self-end rounded bg-gray-200"})]})):b.isError?e.jsx("div",Object.assign({className:"flex w-full max-w-[800px] justify-center pt-10"},{children:e.jsxs("p",Object.assign({className:"text-center text-xl font-semibold"},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help"},{children:"contact us"}))," ","for help."]}))})):e.jsxs("div",Object.assign({className:"relative grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-4 pt-10 max-[767px]:pt-6"},{children:[b.data.messages.map(((s,a)=>e.jsx(o.default,{message:s},a))),p.map(((s,a)=>e.jsx(o.default,{message:s},a))),"fetching"===g?e.jsxs("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:["NONE"!==(null==m?void 0:m.chaticon)&&e.jsx(c.default,{src:null==m?void 0:m.chaticon,alt:`${null==m?void 0:m.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6"}),e.jsxs("div",Object.assign({className:"flex items-center gap-x-2 rounded bg-blue-100/50 px-4 py-4"},{children:[e.jsx("div",{className:"h-1.5 w-1.5 animate-dot rounded-full bg-black/60"}),e.jsx("div",{className:"h-1.5 w-1.5 animate-dot-down rounded-full bg-black/60"}),e.jsx("div",{className:"h-1.5 w-1.5 animate-dot rounded-full bg-black/60"})]}))]})):h?e.jsxs("div",Object.assign({className:"flex max-w-[80%] gap-x-3"},{children:[e.jsx(i.default,{className:"mt-2 h-6 w-6 shrink-0 text-red-500"}),e.jsx(x.default,{className:"x-4 py-2 font-semibold text-red-500",html:h})]})):null,e.jsx(n.default,{className:"absolute bottom-0 left-0 w-full"})]}))}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../../hooks/pickaxe/useConversation.js"),i=require("../../../Icons/circle-info.svg.js"),c=require("../../../Core/PickaxeIcon.js"),n=require("../../Addons/Scroll/ScrollLockView.js"),r=require("../../InfoModal.js"),o=require("./Message.js"),d=require("../../../../common/cn.js"),x=require("../../../Core/HtmlRenderer.js");exports.default=()=>{var u;const{pickaxe:m,colors:j,isNewChat:f}=a.usePickaxeContext(),{messages:p,status:g,error:h}=t.useResponseContext(),b=l.useConversation(),[v,w]=s.useState(!1),N=s.useMemo((()=>!!b.data&&!(b.data.messages.length<=1)),[b.data]),k=s.useMemo((()=>b.isSuccess&&f&&!N),[b.isSuccess,f,N]);return e.jsxs("div",Object.assign({className:"relative flex flex-grow flex-col justify-end"},{children:[v&&e.jsx(r.default,{isOpen:v,onChangeIsOpen:w}),e.jsxs("div",Object.assign({className:d.default("absolute left-1/2 top-5 flex w-full max-w-[400px] -translate-x-1/2 -translate-y-1/3 transform flex-col items-center px-4 opacity-0 duration-300",k&&"top-1/3 opacity-100")},{children:[e.jsx(c.default,{src:null==m?void 0:m.coverphoto,alt:`${null==m?void 0:m.formtitle}'s Profile Picture`,width:90,height:90,className:"h-[90px] w-[90px] rounded-full"}),e.jsxs("div",Object.assign({className:"flex flex-col items-center"},{children:[e.jsxs("h2",Object.assign({className:"mt-6 text-center text-lg font-semibold opacity-70 max-[767px]:text-base"},{children:[`${null==m?void 0:m.formtitle.slice(0,130)}${(null!==(u=null==m?void 0:m.formtitle)&&void 0!==u?u:"").length>130?"...":""}`,e.jsx("button",Object.assign({className:"ml-2 inline-block outline-none hover:opacity-70 hover:duration-300 active:opacity-100",onClick:()=>w(!0)},{children:e.jsx(i.default,{className:"h-5 w-5 shrink-0",style:{color:j.accent}})}))]})),e.jsx("p",Object.assign({className:"mt-2 line-clamp-3 whitespace-pre-line max-w-[600px] text-center font-semilight opacity-70"},{children:null==m?void 0:m.formdescription}))]}))]})),e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:b.isLoading?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[e.jsx("div",{className:"h-10 w-[70%] animate-pulse justify-self-end rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]"}),e.jsx("div",{className:"h-[150px] w-[70%] animate-pulse rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]"}),e.jsx("div",{className:"h-10 w-[50%] animate-pulse justify-self-end rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]"})]})):b.isError?e.jsx("div",Object.assign({className:"flex w-full max-w-[800px] justify-center pt-10"},{children:e.jsxs("p",Object.assign({className:"text-center text-xl font-semibold"},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help"},{children:"contact us"}))," ","for help."]}))})):e.jsxs("div",Object.assign({className:"relative grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-4 pt-10 max-[767px]:pt-6"},{children:[b.data.messages.map(((s,a)=>e.jsx(o.default,{message:s},a))),p.map(((s,a)=>e.jsx(o.default,{message:s},a))),"fetching"===g?e.jsxs("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:["NONE"!==(null==m?void 0:m.chaticon)&&e.jsx(c.default,{src:null==m?void 0:m.chaticon,alt:`${null==m?void 0:m.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6"}),e.jsxs("div",Object.assign({className:"flex items-center gap-x-2 rounded bg-blue-100/50 px-4 py-4"},{children:[e.jsx("div",{className:"h-1.5 w-1.5 animate-dot rounded-full bg-black/60"}),e.jsx("div",{className:"h-1.5 w-1.5 animate-dot-down rounded-full bg-black/60"}),e.jsx("div",{className:"h-1.5 w-1.5 animate-dot rounded-full bg-black/60"})]}))]})):h?e.jsxs("div",Object.assign({className:"flex max-w-[80%] gap-x-3"},{children:[e.jsx(i.default,{className:"mt-2 h-6 w-6 shrink-0 text-red-500"}),e.jsx(x.default,{className:"x-4 py-2 font-semibold text-red-500",html:h})]})):null,e.jsx(n.default,{className:"absolute bottom-0 left-0 w-full"})]}))}))]}))};
@@ -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"),r=require("../../../hooks/core/useMediaQuery.js"),o=require("../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../hooks/pickaxe/useConversation.js"),n=require("../../../hooks/pickaxe/useSubmit.js"),l=require("../../../hooks/pickaxe/useSubmitResult.js"),d=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),c=require("../../../common/documents.js"),m=require("../../../common/api/streamer.js"),p=require("../../../node_modules/.pnpm/react-textarea-autosize@8.5.7_@types_react@18.3.18_react@18.3.1/node_modules/react-textarea-autosize/dist/react-textarea-autosize.esm.js"),h=require("../../Icons/attach.svg.js"),x=require("../../Icons/send.svg.js"),f=require("../Addons/IceBreaker/index.js"),g=require("../../../common/error.js"),v=require("../../../common/cn.js");exports.default=()=>{var j,b,w,y;const{formId:k,chatId:I,pickaxe:q,colors:S,isNewChat:D,setIsNewChat:A}=o.usePickaxeContext(),{messages:_,status:C,setMessage:N,setStatus:R,setError:E}=a.useResponseContext(),{documents:O,isUploading:M,isImageUploadAllowed:U,upsertDocuments:z,onFileUpload:B,onEditDocumentByDocId:F}=d.useDocument(),{isScrollIncreasing:P,scrollToBottom:T,scrollStart:K,scrollEnd:L}=u.useScroll(),Q=i.useConversation(),W=n.useSubmit(),H=l.useSubmitResult(),[Y,G]=t.useState(""),J=t.useRef(null),[V]=r.useMediaQuery("(max-width: 767px)"),X=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(M)return;E(""),A(!1);const e=null!=s?s:Y;if(!e||"fetching"===C||"streaming"===C)return;const t=new Date;G("");const r="enduserupload"===(null==q?void 0:q.documentuploadtype),o=O.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),a=o.length?o[o.length-1].documentId:"";R("fetching"),N({id:_.length+1,role:"user",content:e});const{success:i,data:n,usedDocumentIds:l,newDocumentId:d,newDocumentName:u,isInsertedFile:c,error:p}=yield W.mutateAsync(Object.assign({formId:k,responseId:I,value:e},r&&a&&{documentId:a}));if(!i)throw new Error(null!=p?p:"An error occurred, please try again.");c&&a&&F({documentId:a,isInsertedAsRaw:!0}),d&&u&&z([{type:"website",id:u,name:u,status:"finished",documentId:d}]),K(),T();const h=(yield m.streamer({formId:k,responseId:I,data:n})).body;if(!h)throw new Error("Streaming error");const x=h.getReader(),f=new TextDecoder;let g="",v=!0;for(;v;){const{value:e,done:s}=yield x.read();v=!s;if(g+=f.decode(e),g)R("streaming"),N({id:_.length+2,role:"assistant",content:g}),P&&T();else if(!v&&!g)throw new Error("Server error")}const j=new Date;g&&(T(),R("idle"),yield H.mutateAsync({formId:k,responseId:I,documentIds:l,studioUserId:"USER68RFBSHU4YS2I4L",messages:[{role:"user",message:e,sentAt:t},{role:"assistant",message:g,sentAt:j}]}))}catch(e){let s=g.default(e);s.includes("Unexpected token 'A',")&&(s="Oops! We're experiencing high traffic at the moment. Please try again later."),E(s),T()}finally{R("idle"),L()}}));return s.jsxs("div",Object.assign({className:"relative flex w-full flex-col max-[767px]:fixed max-[767px]:bottom-0 max-[767px]:left-0"},{children:[D&&q&&!Q.isLoading&&(null!==(b=null===(j=Q.data)||void 0===j?void 0:j.messages.length)&&void 0!==b?b:0)<=1&&q.icebreakers&&q.icebreakers.length>0&&s.jsx(f.default,{data:null!==(w=q.icebreakers)&&void 0!==w?w:[],style:{color:"#000000"},isMobile:V,onSend:X}),s.jsxs("div",Object.assign({className:"flex min-h-[56px] items-end gap-x-2 bg-white px-4 py-3 pb-[15px] shadow"},{children:["enduserupload"===(null==q?void 0:q.documentuploadtype)&&s.jsxs("div",Object.assign({className:"tooltip"},{children:[s.jsx("input",{id:"file-upload",ref:J,type:"file",accept:[...c.allowedFileMimeTypes,...U?c.allowedImageMimeTypes:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield B(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx("button",Object.assign({className:"flex items-center disabled:cursor-wait disabled:opacity-50",disabled:M,onClick:()=>{var e;return null===(e=J.current)||void 0===e?void 0:e.click()}},{children:s.jsx(h.default,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:S.accent}})}))]})),s.jsx(p.default,{className:v.default("max-h-60 w-full resize-none border-black bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:font-semilight",!Y.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:Y,placeholder:null!==(y=null==q?void 0:q.placeholdertext)&&void 0!==y?y:"What do you want to talk about?",onChange:e=>G(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),X())}}),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-default disabled:opacity-50",disabled:"idle"!==C||M,onClick:()=>X()},{children:s.jsx(x.default,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:S.accent}})}))]}))]}))};
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"),a=require("../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../hooks/studio/useStyleInput.js"),i=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useSubmit.js"),d=require("../../../hooks/pickaxe/useSubmitResult.js"),u=require("../Addons/Document/hooks/useDocument.js"),c=require("../Addons/Scroll/hooks/useScroll.js"),m=require("../../../common/documents.js"),p=require("../../../common/api/streamer.js"),h=require("../../../node_modules/.pnpm/react-textarea-autosize@8.5.7_@types_react@18.3.18_react@18.3.1/node_modules/react-textarea-autosize/dist/react-textarea-autosize.esm.js"),x=require("../../Icons/attach.svg.js"),f=require("../../Icons/send.svg.js"),g=require("../Addons/IceBreaker/index.js"),y=require("../../../common/error.js"),j=require("../../../common/cn.js");exports.default=()=>{var v,b,w,k;const{formId:I,chatId:q,pickaxe:S,colors:D,isNewChat:A,setIsNewChat:C}=r.usePickaxeContext(),{messages:_,status:N,setMessages:R,setStatus:E,setError:O}=a.useResponseContext(),{documents:M,isUploading:U,isImageUploadAllowed:T,upsertDocuments:z,onFileUpload:B,onEditDocumentByDocId:F}=u.useDocument(),{isScrollIncreasing:P,scrollToBottom:K,scrollStart:L,scrollEnd:Q}=c.useScroll(),W=i.useConversation(),H=l.useSubmit(),Y=d.useSubmitResult(),[G,J]=t.useState(""),V=t.useRef(null),[X]=o.useMediaQuery("(max-width: 767px)"),Z=n.useStyleInput(),$=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(U)return;O(""),C(!1);const e=null!=s?s:G;if(!e||"fetching"===N||"streaming"===N)return;const t=new Date;J("");const o="enduserupload"===(null==S?void 0:S.documentuploadtype),r=M.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),a=r.length?r[r.length-1].documentId:"";E("fetching");const n=[..._,{id:_.length+1,role:"user",content:e}];R(n);const{success:i,data:l,usedDocumentIds:d,newDocumentId:u,newDocumentName:c,isInsertedFile:m,error:h}=yield H.mutateAsync(Object.assign({formId:I,responseId:q,value:e},o&&a&&{documentId:a}));if(!i)throw new Error(null!=h?h:"An error occurred, please try again.");m&&a&&F({documentId:a,isInsertedAsRaw:!0}),u&&c&&z([{type:"website",id:c,name:c,status:"finished",documentId:u}]),L(),K();const x=(yield p.streamer({formId:I,responseId:q,data:l})).body;if(!x)throw new Error("Streaming error");const f=x.getReader(),g=new TextDecoder,y=n.length;let j="",v=!0;for(E("streaming");v;){const{value:e,done:s}=yield f.read();v=!s;if(j+=g.decode(e),j)R([...n.slice(0,y),{id:_.length+1,role:"assistant",content:j}]),P&&K();else if(!v&&!j)throw new Error("Server error")}const b=new Date;j&&(K(),E("idle"),yield Y.mutateAsync({formId:I,responseId:q,documentIds:d,studioUserId:"USER68RFBSHU4YS2I4L",messages:[{role:"user",message:e,sentAt:t},{role:"assistant",message:j,sentAt:b}]}))}catch(e){let s=y.default(e);s.includes("Unexpected token 'A',")&&(s="Oops! We're experiencing high traffic at the moment. Please try again later."),O(s),K()}finally{E("idle"),Q()}}));return s.jsxs("div",Object.assign({className:"relative flex w-full flex-col max-[767px]:fixed max-[767px]:bottom-0 max-[767px]:left-0"},{children:[A&&S&&!W.isLoading&&(null!==(b=null===(v=W.data)||void 0===v?void 0:v.messages.length)&&void 0!==b?b:0)<=1&&S.icebreakers&&S.icebreakers.length>0&&s.jsx(g.default,{data:null!==(w=S.icebreakers)&&void 0!==w?w:[],style:{backgroundColor:D.secondary,color:D.secondaryText},isMobile:X,onSend:$}),s.jsxs("div",Object.assign({style:Z,className:"flex min-h-[56px] items-end gap-x-2 bg-white px-4 py-3 pb-[15px] shadow"},{children:["enduserupload"===(null==S?void 0:S.documentuploadtype)&&s.jsxs("div",Object.assign({className:"tooltip"},{children:[s.jsx("input",{id:"file-upload",ref:V,type:"file",accept:[...m.allowedFileMimeTypes,...T?m.allowedImageMimeTypes:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield B(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx("button",Object.assign({className:"flex items-center disabled:cursor-wait disabled:opacity-50",disabled:U,onClick:()=>{var e;return null===(e=V.current)||void 0===e?void 0:e.click()}},{children:s.jsx(x.default,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:D.accent}})}))]})),s.jsx(h.default,{className:j.default("max-h-60 w-full resize-none border-black bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:font-semilight",!G.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:G,placeholder:null!==(k=null==S?void 0:S.placeholdertext)&&void 0!==k?k:"What do you want to talk about?",onChange:e=>J(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),$())}}),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-default disabled:opacity-50",disabled:"idle"!==N||U,onClick:()=>$()},{children:s.jsx(f.default,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:D.accent}})}))]}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("react-intersection-observer"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../hooks/pickaxe/useHistory.js"),t=require("../../../Icons/spinner-circle.svg.js"),n=require("./Item.js");exports.default=()=>{var l;const{colors:c,isShowHistory:o}=a.usePickaxeContext(),x=r.useHistory({enabled:o}),{ref:u}=i.useInView({onChange(e){e&&x.hasNextPage&&x.fetchNextPage()}});return o&&x.isLoading?e.jsx("div",{className:"w-full min-h-[300px] animate-pulse bg-gray-200"}):x.isError?e.jsx("div",{}):o?e.jsxs("div",Object.assign({className:"flex flex-col gap-y-8"},{children:[null===(l=x.data)||void 0===l?void 0:l.pages.map(((i,a)=>e.jsx(s.Fragment,{children:i.data.map((i=>e.jsx(s.Fragment,{children:e.jsx(n.default,{item:i})},i.responseId)))},a))),e.jsx("div",Object.assign({className:"flex items-center justify-center"},{children:x.isFetchingNextPage?e.jsx(t.default,{className:"my-10 h-14 w-14 animate-spin animate-spin text-gray-300",style:{fill:c.accent}}):x.hasNextPage?e.jsx("div",{ref:u,className:"invisible h-14 w-14"}):null}))]})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("react-intersection-observer"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../hooks/pickaxe/useHistory.js"),t=require("../../../Icons/spinner-circle.svg.js"),n=require("./Item.js");exports.default=()=>{var l;const{colors:c,isShowHistory:o}=a.usePickaxeContext(),x=r.useHistory({enabled:o}),{ref:u}=i.useInView({onChange(e){e&&x.hasNextPage&&x.fetchNextPage()}});return o&&x.isLoading?e.jsx("div",{className:"w-full min-h-[300px] animate-pulse bg-[#E5E7EB] dark:bg-[#1E1E1F]"}):x.isError?e.jsx("div",{}):o?e.jsxs("div",Object.assign({className:"flex flex-col gap-y-8"},{children:[null===(l=x.data)||void 0===l?void 0:l.pages.map(((i,a)=>e.jsx(s.Fragment,{children:i.data.map((i=>e.jsx(s.Fragment,{children:e.jsx(n.default,{item:i})},i.responseId)))},a))),e.jsx("div",Object.assign({className:"flex items-center justify-center"},{children:x.isFetchingNextPage?e.jsx(t.default,{className:"my-10 h-14 w-14 animate-spin animate-spin text-gray-300",style:{fill:c.accent}}):x.hasNextPage?e.jsx("div",{ref:u,className:"invisible h-14 w-14"}):null}))]})):null};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../hooks/pickaxe/useResponseContext.js"),a=require("date-fns"),l=require("../../../Icons/message-square-notes.svg.js"),n=require("../../../Icons/visitor.svg.js"),o=require("../../../Core/PickaxeIcon.js"),i=require("../../../Core/CopyButton.js"),c=require("../../../Core/MarkdownRenderer.js"),d=require("../../Addons/Scroll/ScrollLockView.js");exports.default=()=>{var x;const{pickaxe:h,colors:p,setChatId:u,setIsNewChat:m}=t.usePickaxeContext(),{response:j}=r.useResponseContext(),f=s.useMemo((()=>j?a.format(j.createdAt,"hh:mm a MMM dd, yy"):a.format(new Date,"hh:mm a MMM dd, yy")),[j]),b=s.useMemo((()=>{var e;if(!j)return"";return(null!==(e=j.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[j]);return j?e.jsxs("div",Object.assign({className:"flex flex-col shadow-black transition hover:shadow"},{children:[e.jsxs("div",Object.assign({className:"flex gap-x-3 overflow-hidden bg-white px-4 py-5"},{children:[e.jsx("div",Object.assign({className:"shrink-0 pt-1"},{children:e.jsx(n.default,{className:"h-6 w-6"})})),e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar-track-gray-100 scrollbar-thumb-[#4A4A4B] lg:max-w-[520px] lg:scrollbar-thin"},{children:[e.jsx("input",{id:`${j.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:b.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:b}}),e.jsx("label",Object.assign({htmlFor:`${j.responseId}-input`,className:"mt-1 flex shrink-0 whitespace-nowrap text-sm font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer",style:{color:p.accent}},{children:"See input"})),e.jsx("label",Object.assign({htmlFor:`${j.responseId}-input`,className:"hidden shrink-0 whitespace-nowrap text-sm font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer",style:{color:p.accent}},{children:"Hide input"}))]}))]})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:p.secondary,color:p.secondaryText}},{children:[e.jsx(o.default,{src:null==h?void 0:h.chaticon,alt:`${null==h?void 0:h.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1"}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[e.jsx(c.default,{className:"overflow-x-auto pb-2 font-light opacity-90 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B]",html:j.questionResponse}),e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==h?void 0:h.enablechatresponses)&&e.jsxs("button",Object.assign({className:"flex items-center gap-x-1 hover:cursor-pointer hover:text-c-blue",onClick:()=>{return e=j.responseId,m(!1),void u(e);var e}},{children:[e.jsx(l.default,{className:"h-4 w-4"}),e.jsx("p",Object.assign({className:"text-sm font-semibold"},{children:j.messages.length+1}))]})),e.jsx(i.default,{text:null!==(x=j.questionResponse)&&void 0!==x?x:""})]})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:"text-sm font-semibold uppercase opacity-30"},{children:f}))}))]}))]}))]})),e.jsx(d.default,{})]})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../hooks/pickaxe/useResponseContext.js"),a=require("date-fns"),l=require("../../../Icons/message-square-notes.svg.js"),o=require("../../../Icons/visitor.svg.js"),n=require("../../../Core/PickaxeIcon.js"),i=require("../../../Core/CopyButton.js"),c=require("../../../Core/MarkdownRenderer.js"),d=require("../../Addons/Scroll/ScrollLockView.js");exports.default=()=>{var x;const{pickaxe:h,colors:p,setChatId:u,setIsNewChat:m}=t.usePickaxeContext(),{response:j}=r.useResponseContext(),f=s.useMemo((()=>j?a.format(j.createdAt,"hh:mm a MMM dd, yy"):a.format(new Date,"hh:mm a MMM dd, yy")),[j]),b=s.useMemo((()=>{var e;if(!j)return"";return(null!==(e=j.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[j]);return j?e.jsxs("div",Object.assign({className:"flex flex-col shadow-black transition hover:shadow"},{children:[e.jsxs("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:p.primary,color:p.text}},{children:[e.jsx("div",Object.assign({className:"shrink-0 pt-1"},{children:e.jsx(o.default,{className:"h-6 w-6"})})),e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar-track-gray-100 scrollbar-thumb-[#4A4A4B] lg:max-w-[520px] lg:scrollbar-thin"},{children:[e.jsx("input",{id:`${j.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:b.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:b}}),e.jsx("label",Object.assign({htmlFor:`${j.responseId}-input`,className:"mt-1 flex shrink-0 whitespace-nowrap text-sm font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer",style:{color:p.accent}},{children:"See input"})),e.jsx("label",Object.assign({htmlFor:`${j.responseId}-input`,className:"hidden shrink-0 whitespace-nowrap text-sm font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer",style:{color:p.accent}},{children:"Hide input"}))]}))]})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:p.secondary,color:p.secondaryText}},{children:[e.jsx(n.default,{src:null==h?void 0:h.chaticon,alt:`${null==h?void 0:h.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1"}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[e.jsx(c.default,{className:"overflow-x-auto pb-2 font-light opacity-90 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B]",html:j.questionResponse}),e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==h?void 0:h.enablechatresponses)&&e.jsxs("button",Object.assign({className:"flex items-center gap-x-1 hover:cursor-pointer hover:text-c-blue",onClick:()=>{return e=j.responseId,m(!1),void u(e);var e}},{children:[e.jsx(l.default,{className:"h-4 w-4"}),e.jsx("p",Object.assign({className:"text-sm font-semibold"},{children:j.messages.length+1}))]})),e.jsx(i.default,{text:null!==(x=j.questionResponse)&&void 0!==x?x:""})]})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:"text-sm font-semibold uppercase opacity-30"},{children:f}))}))]}))]}))]})),e.jsx(d.default,{})]})):null};
@@ -4,7 +4,8 @@ interface PickaxeIconProps {
4
4
  width?: number;
5
5
  height?: number;
6
6
  className?: string;
7
+ textColor?: string;
7
8
  isLoading?: boolean;
8
9
  }
9
- declare const PickaxeIcon: ({ src, alt, width, height, className, isLoading, }: PickaxeIconProps) => import("react/jsx-runtime").JSX.Element | null;
10
+ declare const PickaxeIcon: ({ src, alt, width, height, className, textColor, isLoading, }: PickaxeIconProps) => import("react/jsx-runtime").JSX.Element | null;
10
11
  export default PickaxeIcon;
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{useState as t}from"react";import r from"../../common/cn.js";const s=({src:s,alt:i,width:a=24,height:o=24,className:n,isLoading:c})=>{const[d,l]=t(!1),h=s||"";return c?e("div",{className:r("shrink-0 animate-pulse rounded bg-c-skeleton dark:bg-c-skeleton-dark",n),style:{width:a,height:o}}):"NONE"===h?null:e("div",!h||d?{className:r("shrink-0 rounded bg-c-skeleton dark:bg-c-skeleton-dark",n),style:{width:a,height:o}}:Object.assign({className:"relative shrink-0 rounded",style:{width:a,height:o}},{children:e("img",{src:h,alt:i||"Pickaxe's Profile Picture",width:a,height:o,className:r("select-none rounded object-cover",n),draggable:!1,onError:()=>l(!0)})}))};export{s as default};
1
+ import{jsx as e}from"react/jsx-runtime";import{useState as s}from"react";import t from"../Icons/spark.svg.js";import r from"../../common/cn.js";const i=({src:i,alt:a,width:o=24,height:c=24,className:n,textColor:h,isLoading:l})=>{const[d,m]=s(!1),g=i||"";return l?e("div",{className:r("shrink-0 animate-pulse rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]",n),style:{width:o,height:c}}):h&&"https://pickaxe.chat/builder/assets/images/pickaxe-chaticons/chaticon2.png"===g?e(t,{className:r("h-6 w-6 shrink-0",n),style:{color:h}}):"NONE"===g?null:e("div",!g||d?{className:r("shrink-0 rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]",n),style:{width:o,height:c}}:Object.assign({className:"relative shrink-0 rounded",style:{width:o,height:c}},{children:e("img",{src:g,alt:a||"Pickaxe's Profile Picture",width:o,height:c,className:r("select-none rounded object-cover",n),draggable:!1,onError:()=>m(!0)})}))};export{i as default};
@@ -0,0 +1 @@
1
+ import*as r from"react";var e,t,n;function o(){return o=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},o.apply(null,arguments)}var a=a=>r.createElement("svg",o({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},a),e||(e=r.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 3v3M12 18v3M3 12h3M18 12h3"})),t||(t=r.createElement("circle",{cx:12,cy:12,r:2,stroke:"currentColor",strokeWidth:2})),n||(n=r.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M18 8h-1.2a.8.8 0 0 1-.8-.8V6M6 8h1.2a.8.8 0 0 0 .8-.8V6M18 16h-1.2a.8.8 0 0 0-.8.8V18M6 16h1.2a.8.8 0 0 1 .8.8V18"})));export{a as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as s}from"react/jsx-runtime";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import t from"../../../Core/PickaxeIcon.js";import l from"../../../Core/CopyButton.js";import r from"../../../Core/MarkdownRenderer.js";const o=({message:o})=>{var c;const{formId:i,pickaxe:m}=a(),n=null!==(c=null==m?void 0:m.chaticon)&&void 0!==c?c:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${i}.png`;return"assistant"===o.role?e("div",Object.assign({className:"flex max-w-[80%] flex-col max-[767px]:max-w-full"},{children:s("div",Object.assign({className:"flex gap-x-3"},{children:["NONE"!==n&&e(t,{src:n,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6"}),s("div",Object.assign({className:"flex flex-col"},{children:[e("div",Object.assign({className:"chat-message overflow-x-auto overflow-y-hidden rounded bg-blue-100/50 px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B]"},{children:e(r,{className:"relative max-[767px]:text-sm",html:o.content})})),e("div",Object.assign({className:"mb-2 ml-2 mt-4 flex gap-3"},{children:e(l,{text:o.content})}))]}))]}))})):"user"===o.role?e("div",Object.assign({className:"flex max-w-[80%] gap-x-3 justify-self-end max-[767px]:max-w-full max-[767px]:pl-9"},{children:e("div",Object.assign({className:"overflow-x-auto overflow-y-hidden rounded bg-white px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B]"},{children:e(r,{className:"relative max-[767px]:text-sm",html:o.content})}))})):e("div",{})};export{o as default};
1
+ import{jsx as e,jsxs as s}from"react/jsx-runtime";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import t from"../../../Core/PickaxeIcon.js";import o from"../../../Core/CopyButton.js";import l from"../../../Core/MarkdownRenderer.js";const r=({message:r})=>{var c;const{formId:i,pickaxe:n,colors:m}=a(),x=null!==(c=null==n?void 0:n.chaticon)&&void 0!==c?c:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${i}.png`;return"assistant"===r.role?e("div",Object.assign({className:"flex max-w-[80%] flex-col max-[767px]:max-w-full"},{children:s("div",Object.assign({className:"flex gap-x-3"},{children:["NONE"!==x&&e(t,{src:x,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:m.text}),s("div",Object.assign({className:"flex flex-col"},{children:[e("div",Object.assign({className:"chat-message overflow-x-auto overflow-y-hidden rounded px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B]",style:{backgroundColor:m.secondary+"80",color:m.secondaryText}},{children:e(l,{className:"relative max-[767px]:text-sm",html:r.content})})),e("div",Object.assign({className:"mb-2 ml-2 mt-4 flex gap-3"},{children:e(o,{text:r.content})}))]}))]}))})):"user"===r.role?e("div",Object.assign({className:"flex max-w-[80%] gap-x-3 justify-self-end max-[767px]:max-w-full max-[767px]:pl-9"},{children:e("div",Object.assign({className:"overflow-x-auto overflow-y-hidden rounded bg-white px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B]"},{children:e(l,{className:"relative max-[767px]:text-sm",html:r.content})}))})):e("div",{})};export{r as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useState as a,useMemo as t}from"react";import{usePickaxeContext as l}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useConversation as o}from"../../../../hooks/pickaxe/useConversation.js";import c from"../../../Icons/circle-info.svg.js";import n from"../../../Core/PickaxeIcon.js";import r from"../../Addons/Scroll/ScrollLockView.js";import m from"../../InfoModal.js";import d from"./Message.js";import p from"../../../../common/cn.js";import f from"../../../Core/HtmlRenderer.js";const x=()=>{var x;const{pickaxe:u,colors:g,isNewChat:h}=l(),{messages:b,status:v,error:j}=i(),w=o(),[N,y]=a(!1),k=t((()=>!!w.data&&!(w.data.messages.length<=1)),[w.data]),O=t((()=>w.isSuccess&&h&&!k),[w.isSuccess,h,k]);return e("div",Object.assign({className:"relative flex flex-grow flex-col justify-end"},{children:[N&&s(m,{isOpen:N,onChangeIsOpen:y}),e("div",Object.assign({className:p("absolute left-1/2 top-5 flex w-full max-w-[400px] -translate-x-1/2 -translate-y-1/3 transform flex-col items-center px-4 opacity-0 duration-300",O&&"top-1/3 opacity-100")},{children:[s(n,{src:null==u?void 0:u.coverphoto,alt:`${null==u?void 0:u.formtitle}'s Profile Picture`,width:64,height:64,className:"h-16 w-16 rounded-full"}),e("div",Object.assign({className:"flex flex-col items-center"},{children:[e("h2",Object.assign({className:"mt-6 text-center text-lg font-semibold opacity-70 max-[767px]:text-base"},{children:[`${null==u?void 0:u.formtitle.slice(0,130)}${(null!==(x=null==u?void 0:u.formtitle)&&void 0!==x?x:"").length>130?"...":""}`,s("button",Object.assign({className:"ml-2 inline-block outline-none hover:opacity-70 hover:duration-300 active:opacity-100",onClick:()=>y(!0)},{children:s(c,{className:"h-5 w-5 shrink-0",style:{color:g.accent}})}))]})),s("p",Object.assign({className:"mt-2 line-clamp-3 whitespace-pre-line max-w-[600px] text-center font-semilight opacity-70"},{children:null==u?void 0:u.formdescription}))]}))]})),s("div",Object.assign({className:"flex w-full justify-center"},{children:w.isLoading?e("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[s("div",{className:"h-10 w-[70%] animate-pulse justify-self-end rounded bg-gray-200"}),s("div",{className:"h-[150px] w-[70%] animate-pulse rounded bg-gray-200"}),s("div",{className:"h-10 w-[50%] animate-pulse justify-self-end rounded bg-gray-200"})]})):w.isError?s("div",Object.assign({className:"flex w-full max-w-[800px] justify-center pt-10"},{children:e("p",Object.assign({className:"text-center text-xl font-semibold"},{children:["Something went wrong. Please try again, or"," ",s("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help"},{children:"contact us"}))," ","for help."]}))})):e("div",Object.assign({className:"relative grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-4 pt-10 max-[767px]:pt-6"},{children:[w.data.messages.map(((e,a)=>s(d,{message:e},a))),b.map(((e,a)=>s(d,{message:e},a))),"fetching"===v?e("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:["NONE"!==(null==u?void 0:u.chaticon)&&s(n,{src:null==u?void 0:u.chaticon,alt:`${null==u?void 0:u.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6"}),e("div",Object.assign({className:"flex items-center gap-x-2 rounded bg-blue-100/50 px-4 py-4"},{children:[s("div",{className:"h-1.5 w-1.5 animate-dot rounded-full bg-black/60"}),s("div",{className:"h-1.5 w-1.5 animate-dot-down rounded-full bg-black/60"}),s("div",{className:"h-1.5 w-1.5 animate-dot rounded-full bg-black/60"})]}))]})):j?e("div",Object.assign({className:"flex max-w-[80%] gap-x-3"},{children:[s(c,{className:"mt-2 h-6 w-6 shrink-0 text-red-500"}),s(f,{className:"x-4 py-2 font-semibold text-red-500",html:j})]})):null,s(r,{className:"absolute bottom-0 left-0 w-full"})]}))}))]}))};export{x as default};
1
+ import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useState as a,useMemo as t}from"react";import{usePickaxeContext as l}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useConversation as o}from"../../../../hooks/pickaxe/useConversation.js";import c from"../../../Icons/circle-info.svg.js";import n from"../../../Core/PickaxeIcon.js";import r from"../../Addons/Scroll/ScrollLockView.js";import m from"../../InfoModal.js";import d from"./Message.js";import p from"../../../../common/cn.js";import f from"../../../Core/HtmlRenderer.js";const x=()=>{var x;const{pickaxe:u,colors:g,isNewChat:h}=l(),{messages:b,status:v,error:j}=i(),w=o(),[N,k]=a(!1),y=t((()=>!!w.data&&!(w.data.messages.length<=1)),[w.data]),O=t((()=>w.isSuccess&&h&&!y),[w.isSuccess,h,y]);return e("div",Object.assign({className:"relative flex flex-grow flex-col justify-end"},{children:[N&&s(m,{isOpen:N,onChangeIsOpen:k}),e("div",Object.assign({className:p("absolute left-1/2 top-5 flex w-full max-w-[400px] -translate-x-1/2 -translate-y-1/3 transform flex-col items-center px-4 opacity-0 duration-300",O&&"top-1/3 opacity-100")},{children:[s(n,{src:null==u?void 0:u.coverphoto,alt:`${null==u?void 0:u.formtitle}'s Profile Picture`,width:90,height:90,className:"h-[90px] w-[90px] rounded-full"}),e("div",Object.assign({className:"flex flex-col items-center"},{children:[e("h2",Object.assign({className:"mt-6 text-center text-lg font-semibold opacity-70 max-[767px]:text-base"},{children:[`${null==u?void 0:u.formtitle.slice(0,130)}${(null!==(x=null==u?void 0:u.formtitle)&&void 0!==x?x:"").length>130?"...":""}`,s("button",Object.assign({className:"ml-2 inline-block outline-none hover:opacity-70 hover:duration-300 active:opacity-100",onClick:()=>k(!0)},{children:s(c,{className:"h-5 w-5 shrink-0",style:{color:g.accent}})}))]})),s("p",Object.assign({className:"mt-2 line-clamp-3 whitespace-pre-line max-w-[600px] text-center font-semilight opacity-70"},{children:null==u?void 0:u.formdescription}))]}))]})),s("div",Object.assign({className:"flex w-full justify-center"},{children:w.isLoading?e("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[s("div",{className:"h-10 w-[70%] animate-pulse justify-self-end rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]"}),s("div",{className:"h-[150px] w-[70%] animate-pulse rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]"}),s("div",{className:"h-10 w-[50%] animate-pulse justify-self-end rounded bg-[#E5E7EB] dark:bg-[#1E1E1F]"})]})):w.isError?s("div",Object.assign({className:"flex w-full max-w-[800px] justify-center pt-10"},{children:e("p",Object.assign({className:"text-center text-xl font-semibold"},{children:["Something went wrong. Please try again, or"," ",s("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help"},{children:"contact us"}))," ","for help."]}))})):e("div",Object.assign({className:"relative grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-4 pt-10 max-[767px]:pt-6"},{children:[w.data.messages.map(((e,a)=>s(d,{message:e},a))),b.map(((e,a)=>s(d,{message:e},a))),"fetching"===v?e("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:["NONE"!==(null==u?void 0:u.chaticon)&&s(n,{src:null==u?void 0:u.chaticon,alt:`${null==u?void 0:u.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6"}),e("div",Object.assign({className:"flex items-center gap-x-2 rounded bg-blue-100/50 px-4 py-4"},{children:[s("div",{className:"h-1.5 w-1.5 animate-dot rounded-full bg-black/60"}),s("div",{className:"h-1.5 w-1.5 animate-dot-down rounded-full bg-black/60"}),s("div",{className:"h-1.5 w-1.5 animate-dot rounded-full bg-black/60"})]}))]})):j?e("div",Object.assign({className:"flex max-w-[80%] gap-x-3"},{children:[s(c,{className:"mt-2 h-6 w-6 shrink-0 text-red-500"}),s(f,{className:"x-4 py-2 font-semibold text-red-500",html:j})]})):null,s(r,{className:"absolute bottom-0 left-0 w-full"})]}))}))]}))};export{x 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 s,useRef as r}from"react";import{useMediaQuery as n}from"../../../hooks/core/useMediaQuery.js";import{usePickaxeContext as i}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as a}from"../../../hooks/pickaxe/useResponseContext.js";import{useConversation as l}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as d}from"../../../hooks/pickaxe/useSubmit.js";import{useSubmitResult as c}from"../../../hooks/pickaxe/useSubmitResult.js";import{useDocument as m}from"../Addons/Document/hooks/useDocument.js";import{useScroll as u}from"../Addons/Scroll/hooks/useScroll.js";import{allowedFileMimeTypes as p,allowedImageMimeTypes as f}from"../../../common/documents.js";import{streamer as h}from"../../../common/api/streamer.js";import g from"../../../node_modules/.pnpm/react-textarea-autosize@8.5.7_@types_react@18.3.18_react@18.3.1/node_modules/react-textarea-autosize/dist/react-textarea-autosize.esm.js";import x from"../../Icons/attach.svg.js";import v from"../../Icons/send.svg.js";import b from"../Addons/IceBreaker/index.js";import k from"../../../common/error.js";import w from"../../../common/cn.js";const y=()=>{var y,I,j,A;const{formId:D,chatId:S,pickaxe:N,colors:C,isNewChat:E,setIsNewChat:O}=i(),{messages:R,status:U,setMessage:_,setStatus:z,setError:B}=a(),{documents:F,isUploading:M,isImageUploadAllowed:K,upsertDocuments:L,onFileUpload:P,onEditDocumentByDocId:T}=m(),{isScrollIncreasing:W,scrollToBottom:H,scrollStart:Q,scrollEnd:Y}=u(),q=l(),G=d(),J=c(),[V,X]=s(""),Z=r(null),[$]=n("(max-width: 767px)"),ee=o=>e(void 0,void 0,void 0,(function*(){try{if(M)return;B(""),O(!1);const e=null!=o?o:V;if(!e||"fetching"===U||"streaming"===U)return;const t=new Date;X("");const s="enduserupload"===(null==N?void 0:N.documentuploadtype),r=F.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),n=r.length?r[r.length-1].documentId:"";z("fetching"),_({id:R.length+1,role:"user",content:e});const{success:i,data:a,usedDocumentIds:l,newDocumentId:d,newDocumentName:c,isInsertedFile:m,error:u}=yield G.mutateAsync(Object.assign({formId:D,responseId:S,value:e},s&&n&&{documentId:n}));if(!i)throw new Error(null!=u?u:"An error occurred, please try again.");m&&n&&T({documentId:n,isInsertedAsRaw:!0}),d&&c&&L([{type:"website",id:c,name:c,status:"finished",documentId:d}]),Q(),H();const p=(yield h({formId:D,responseId:S,data:a})).body;if(!p)throw new Error("Streaming error");const f=p.getReader(),g=new TextDecoder;let x="",v=!0;for(;v;){const{value:e,done:o}=yield f.read();v=!o;if(x+=g.decode(e),x)z("streaming"),_({id:R.length+2,role:"assistant",content:x}),W&&H();else if(!v&&!x)throw new Error("Server error")}const b=new Date;x&&(H(),z("idle"),yield J.mutateAsync({formId:D,responseId:S,documentIds:l,studioUserId:"USER68RFBSHU4YS2I4L",messages:[{role:"user",message:e,sentAt:t},{role:"assistant",message:x,sentAt:b}]}))}catch(e){let o=k(e);o.includes("Unexpected token 'A',")&&(o="Oops! We're experiencing high traffic at the moment. Please try again later."),B(o),H()}finally{z("idle"),Y()}}));return o("div",Object.assign({className:"relative flex w-full flex-col max-[767px]:fixed max-[767px]:bottom-0 max-[767px]:left-0"},{children:[E&&N&&!q.isLoading&&(null!==(I=null===(y=q.data)||void 0===y?void 0:y.messages.length)&&void 0!==I?I:0)<=1&&N.icebreakers&&N.icebreakers.length>0&&t(b,{data:null!==(j=N.icebreakers)&&void 0!==j?j:[],style:{color:"#000000"},isMobile:$,onSend:ee}),o("div",Object.assign({className:"flex min-h-[56px] items-end gap-x-2 bg-white px-4 py-3 pb-[15px] shadow"},{children:["enduserupload"===(null==N?void 0:N.documentuploadtype)&&o("div",Object.assign({className:"tooltip"},{children:[t("input",{id:"file-upload",ref:Z,type:"file",accept:[...p,...K?f:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:o=>e(void 0,void 0,void 0,(function*(){yield P(Array.from(o.target.files||[])),o.target.value=""}))}),t("button",Object.assign({className:"flex items-center disabled:cursor-wait disabled:opacity-50",disabled:M,onClick:()=>{var e;return null===(e=Z.current)||void 0===e?void 0:e.click()}},{children:t(x,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:C.accent}})}))]})),t(g,{className:w("max-h-60 w-full resize-none border-black bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:font-semilight",!V.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:V,placeholder:null!==(A=null==N?void 0:N.placeholdertext)&&void 0!==A?A:"What do you want to talk about?",onChange:e=>X(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),ee())}}),t("button",Object.assign({className:"outline-none disabled:cursor-default disabled:opacity-50",disabled:"idle"!==U||M,onClick:()=>ee()},{children:t(v,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:C.accent}})}))]}))]}))};export{y 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 r}from"react";import{useMediaQuery as n}from"../../../hooks/core/useMediaQuery.js";import{usePickaxeContext as i}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as a}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as l}from"../../../hooks/studio/useStyleInput.js";import{useConversation as d}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as c}from"../../../hooks/pickaxe/useSubmit.js";import{useSubmitResult as m}from"../../../hooks/pickaxe/useSubmitResult.js";import{useDocument as u}from"../Addons/Document/hooks/useDocument.js";import{useScroll as p}from"../Addons/Scroll/hooks/useScroll.js";import{allowedFileMimeTypes as f,allowedImageMimeTypes as h}from"../../../common/documents.js";import{streamer as g}from"../../../common/api/streamer.js";import x from"../../../node_modules/.pnpm/react-textarea-autosize@8.5.7_@types_react@18.3.18_react@18.3.1/node_modules/react-textarea-autosize/dist/react-textarea-autosize.esm.js";import v from"../../Icons/attach.svg.js";import y from"../../Icons/send.svg.js";import b from"../Addons/IceBreaker/index.js";import k from"../../../common/error.js";import w from"../../../common/cn.js";const I=()=>{var I,j,S,A;const{formId:D,chatId:N,pickaxe:C,colors:E,isNewChat:O,setIsNewChat:R}=i(),{messages:U,status:_,setMessages:z,setStatus:B,setError:F}=a(),{documents:M,isUploading:T,isImageUploadAllowed:K,upsertDocuments:L,onFileUpload:P,onEditDocumentByDocId:W}=u(),{isScrollIncreasing:H,scrollToBottom:Q,scrollStart:Y,scrollEnd:q}=p(),G=d(),J=c(),V=m(),[X,Z]=s(""),$=r(null),[ee]=n("(max-width: 767px)"),oe=l(),te=o=>e(void 0,void 0,void 0,(function*(){try{if(T)return;F(""),R(!1);const e=null!=o?o:X;if(!e||"fetching"===_||"streaming"===_)return;const t=new Date;Z("");const s="enduserupload"===(null==C?void 0:C.documentuploadtype),r=M.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),n=r.length?r[r.length-1].documentId:"";B("fetching");const i=[...U,{id:U.length+1,role:"user",content:e}];z(i);const{success:a,data:l,usedDocumentIds:d,newDocumentId:c,newDocumentName:m,isInsertedFile:u,error:p}=yield J.mutateAsync(Object.assign({formId:D,responseId:N,value:e},s&&n&&{documentId:n}));if(!a)throw new Error(null!=p?p:"An error occurred, please try again.");u&&n&&W({documentId:n,isInsertedAsRaw:!0}),c&&m&&L([{type:"website",id:m,name:m,status:"finished",documentId:c}]),Y(),Q();const f=(yield g({formId:D,responseId:N,data:l})).body;if(!f)throw new Error("Streaming error");const h=f.getReader(),x=new TextDecoder,v=i.length;let y="",b=!0;for(B("streaming");b;){const{value:e,done:o}=yield h.read();b=!o;if(y+=x.decode(e),y)z([...i.slice(0,v),{id:U.length+1,role:"assistant",content:y}]),H&&Q();else if(!b&&!y)throw new Error("Server error")}const k=new Date;y&&(Q(),B("idle"),yield V.mutateAsync({formId:D,responseId:N,documentIds:d,studioUserId:"USER68RFBSHU4YS2I4L",messages:[{role:"user",message:e,sentAt:t},{role:"assistant",message:y,sentAt:k}]}))}catch(e){let o=k(e);o.includes("Unexpected token 'A',")&&(o="Oops! We're experiencing high traffic at the moment. Please try again later."),F(o),Q()}finally{B("idle"),q()}}));return o("div",Object.assign({className:"relative flex w-full flex-col max-[767px]:fixed max-[767px]:bottom-0 max-[767px]:left-0"},{children:[O&&C&&!G.isLoading&&(null!==(j=null===(I=G.data)||void 0===I?void 0:I.messages.length)&&void 0!==j?j:0)<=1&&C.icebreakers&&C.icebreakers.length>0&&t(b,{data:null!==(S=C.icebreakers)&&void 0!==S?S:[],style:{backgroundColor:E.secondary,color:E.secondaryText},isMobile:ee,onSend:te}),o("div",Object.assign({style:oe,className:"flex min-h-[56px] items-end gap-x-2 bg-white px-4 py-3 pb-[15px] shadow"},{children:["enduserupload"===(null==C?void 0:C.documentuploadtype)&&o("div",Object.assign({className:"tooltip"},{children:[t("input",{id:"file-upload",ref:$,type:"file",accept:[...f,...K?h:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:o=>e(void 0,void 0,void 0,(function*(){yield P(Array.from(o.target.files||[])),o.target.value=""}))}),t("button",Object.assign({className:"flex items-center disabled:cursor-wait disabled:opacity-50",disabled:T,onClick:()=>{var e;return null===(e=$.current)||void 0===e?void 0:e.click()}},{children:t(v,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:E.accent}})}))]})),t(x,{className:w("max-h-60 w-full resize-none border-black bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:font-semilight",!X.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:X,placeholder:null!==(A=null==C?void 0:C.placeholdertext)&&void 0!==A?A:"What do you want to talk about?",onChange:e=>Z(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),te())}}),t("button",Object.assign({className:"outline-none disabled:cursor-default disabled:opacity-50",disabled:"idle"!==_||T,onClick:()=>te()},{children:t(y,{className:"h-6 w-6 shrink-0 stroke-2",style:{color:E.accent}})}))]}))]}))};export{I as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as s}from"react/jsx-runtime";import{Fragment as i}from"react";import{useInView as a}from"react-intersection-observer";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useHistory as r}from"../../../../hooks/pickaxe/useHistory.js";import o from"../../../Icons/spinner-circle.svg.js";import n from"./Item.js";const c=()=>{var c;const{colors:l,isShowHistory:m}=t(),p=r({enabled:m}),{ref:d}=a({onChange(e){e&&p.hasNextPage&&p.fetchNextPage()}});return m&&p.isLoading?e("div",{className:"w-full min-h-[300px] animate-pulse bg-gray-200"}):p.isError?e("div",{}):m?s("div",Object.assign({className:"flex flex-col gap-y-8"},{children:[null===(c=p.data)||void 0===c?void 0:c.pages.map(((s,a)=>e(i,{children:s.data.map((s=>e(i,{children:e(n,{item:s})},s.responseId)))},a))),e("div",Object.assign({className:"flex items-center justify-center"},{children:p.isFetchingNextPage?e(o,{className:"my-10 h-14 w-14 animate-spin animate-spin text-gray-300",style:{fill:l.accent}}):p.hasNextPage?e("div",{ref:d,className:"invisible h-14 w-14"}):null}))]})):null};export{c as default};
1
+ import{jsx as e,jsxs as s}from"react/jsx-runtime";import{Fragment as i}from"react";import{useInView as a}from"react-intersection-observer";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useHistory as r}from"../../../../hooks/pickaxe/useHistory.js";import o from"../../../Icons/spinner-circle.svg.js";import n from"./Item.js";const c=()=>{var c;const{colors:l,isShowHistory:m}=t(),p=r({enabled:m}),{ref:d}=a({onChange(e){e&&p.hasNextPage&&p.fetchNextPage()}});return m&&p.isLoading?e("div",{className:"w-full min-h-[300px] animate-pulse bg-[#E5E7EB] dark:bg-[#1E1E1F]"}):p.isError?e("div",{}):m?s("div",Object.assign({className:"flex flex-col gap-y-8"},{children:[null===(c=p.data)||void 0===c?void 0:c.pages.map(((s,a)=>e(i,{children:s.data.map((s=>e(i,{children:e(n,{item:s})},s.responseId)))},a))),e("div",Object.assign({className:"flex items-center justify-center"},{children:p.isFetchingNextPage?e(o,{className:"my-10 h-14 w-14 animate-spin animate-spin text-gray-300",style:{fill:l.accent}}):p.hasNextPage?e("div",{ref:d,className:"invisible h-14 w-14"}):null}))]})):null};export{c as default};
@@ -1 +1 @@
1
- import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as t}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as r}from"../../../../hooks/pickaxe/useResponseContext.js";import{format as l}from"date-fns";import a from"../../../Icons/message-square-notes.svg.js";import n from"../../../Icons/visitor.svg.js";import i from"../../../Core/PickaxeIcon.js";import c from"../../../Core/CopyButton.js";import d from"../../../Core/MarkdownRenderer.js";import p from"../../Addons/Scroll/ScrollLockView.js";const m=()=>{var m;const{pickaxe:h,colors:x,setChatId:f,setIsNewChat:u}=o(),{response:g}=r(),b=t((()=>l(g?g.createdAt:new Date,"hh:mm a MMM dd, yy")),[g]),v=t((()=>{var e;if(!g)return"";return(null!==(e=g.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[g]);return g?e("div",Object.assign({className:"flex flex-col shadow-black transition hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden bg-white px-4 py-5"},{children:[s("div",Object.assign({className:"shrink-0 pt-1"},{children:s(n,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar-track-gray-100 scrollbar-thumb-[#4A4A4B] lg:max-w-[520px] lg:scrollbar-thin"},{children:[s("input",{id:`${g.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:v.length<280}),s("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:v}}),s("label",Object.assign({htmlFor:`${g.responseId}-input`,className:"mt-1 flex shrink-0 whitespace-nowrap text-sm font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer",style:{color:x.accent}},{children:"See input"})),s("label",Object.assign({htmlFor:`${g.responseId}-input`,className:"hidden shrink-0 whitespace-nowrap text-sm font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer",style:{color:x.accent}},{children:"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:x.secondary,color:x.secondaryText}},{children:[s(i,{src:null==h?void 0:h.chaticon,alt:`${null==h?void 0:h.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1"}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[s(d,{className:"overflow-x-auto pb-2 font-light opacity-90 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B]",html:g.questionResponse}),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==h?void 0:h.enablechatresponses)&&e("button",Object.assign({className:"flex items-center gap-x-1 hover:cursor-pointer hover:text-c-blue",onClick:()=>{return e=g.responseId,u(!1),void f(e);var e}},{children:[s(a,{className:"h-4 w-4"}),s("p",Object.assign({className:"text-sm font-semibold"},{children:g.messages.length+1}))]})),s(c,{text:null!==(m=g.questionResponse)&&void 0!==m?m:""})]})),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:"text-sm font-semibold uppercase opacity-30"},{children:b}))}))]}))]}))]})),s(p,{})]})):null};export{m as default};
1
+ import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as t}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as r}from"../../../../hooks/pickaxe/useResponseContext.js";import{format as l}from"date-fns";import a from"../../../Icons/message-square-notes.svg.js";import n from"../../../Icons/visitor.svg.js";import i from"../../../Core/PickaxeIcon.js";import c from"../../../Core/CopyButton.js";import d from"../../../Core/MarkdownRenderer.js";import p from"../../Addons/Scroll/ScrollLockView.js";const m=()=>{var m;const{pickaxe:h,colors:x,setChatId:f,setIsNewChat:u}=o(),{response:g}=r(),b=t((()=>l(g?g.createdAt:new Date,"hh:mm a MMM dd, yy")),[g]),v=t((()=>{var e;if(!g)return"";return(null!==(e=g.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[g]);return g?e("div",Object.assign({className:"flex flex-col shadow-black transition hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:x.primary,color:x.text}},{children:[s("div",Object.assign({className:"shrink-0 pt-1"},{children:s(n,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar-track-gray-100 scrollbar-thumb-[#4A4A4B] lg:max-w-[520px] lg:scrollbar-thin"},{children:[s("input",{id:`${g.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:v.length<280}),s("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:v}}),s("label",Object.assign({htmlFor:`${g.responseId}-input`,className:"mt-1 flex shrink-0 whitespace-nowrap text-sm font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer",style:{color:x.accent}},{children:"See input"})),s("label",Object.assign({htmlFor:`${g.responseId}-input`,className:"hidden shrink-0 whitespace-nowrap text-sm font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer",style:{color:x.accent}},{children:"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:x.secondary,color:x.secondaryText}},{children:[s(i,{src:null==h?void 0:h.chaticon,alt:`${null==h?void 0:h.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1"}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[s(d,{className:"overflow-x-auto pb-2 font-light opacity-90 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B]",html:g.questionResponse}),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==h?void 0:h.enablechatresponses)&&e("button",Object.assign({className:"flex items-center gap-x-1 hover:cursor-pointer hover:text-c-blue",onClick:()=>{return e=g.responseId,u(!1),void f(e);var e}},{children:[s(a,{className:"h-4 w-4"}),s("p",Object.assign({className:"text-sm font-semibold"},{children:g.messages.length+1}))]})),s(c,{text:null!==(m=g.questionResponse)&&void 0!==m?m:""})]})),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:"text-sm font-semibold uppercase opacity-30"},{children:b}))}))]}))]}))]})),s(p,{})]})):null};export{m as default};
@@ -4,7 +4,8 @@ interface PickaxeIconProps {
4
4
  width?: number;
5
5
  height?: number;
6
6
  className?: string;
7
+ textColor?: string;
7
8
  isLoading?: boolean;
8
9
  }
9
- declare const PickaxeIcon: ({ src, alt, width, height, className, isLoading, }: PickaxeIconProps) => import("react/jsx-runtime").JSX.Element | null;
10
+ declare const PickaxeIcon: ({ src, alt, width, height, className, textColor, isLoading, }: PickaxeIconProps) => import("react/jsx-runtime").JSX.Element | null;
10
11
  export default PickaxeIcon;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "main": "dist/cjs/index.js",
15
15
  "module": "dist/esm/index.js",
16
- "types": "dist/esm/index.d.ts",
16
+ "types": "dist/esm/src/index.d.ts",
17
17
  "files": [
18
18
  "dist"
19
19
  ],