@pickaxeproject/react 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../hooks/pickaxe/useDimensionContext.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"),c=require("../../../hooks/pickaxe/useSubmitResult.js"),u=require("../../../common/documents.js"),m=require("../../../common/api/streamer.js"),p=require("../Addons/Document/hooks/useDocument.js"),x=require("../Addons/Scroll/hooks/useScroll.js"),f=require("../../../hooks/core/useHover.js"),b=require("../../../common/utils.js"),g=require("../../Icons/attach-vertical.svg.js"),h=require("../../Icons/spinner-lines.svg.js"),j=require("../../Icons/file.svg.js"),v=require("../../Icons/x.svg.js"),y=require("../../Icons/arrow-right.svg.js"),k=require("../common/PickaxeBranding.js"),w=require("../Addons/IceBreaker/index.js"),I=require("react-textarea-autosize"),O=require("../../../common/error.js"),C=require("../../../common/cn.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var q=N(I);exports.default=()=>{var I;const{formId:N,chatId:S,userId:R,studioUserId:D,deploymentId:A,pickaxe:_,styles:T,colors:U,misc:H,responsiveBy:E,forceMobile:M,isNewChat:z,setIsNewChat:B,setIsShowIceBreaker:F,onGenerateComplete:L}=o.usePickaxeContext(),{messages:P,status:W,limits:$,setMessages:G,setStatus:K,setLimitData:J,setError:Q,setIsGenerating:V}=r.useResponseContext(),{isMobile:X}=i.useDimensionContext(),{documents:Y,isUploading:Z,isImageUploadAllowed:ee,upsertDocuments:se,onFileUpload:te}=p.useDocument(),{scrollStartSession:oe,scrollEndSession:re,scrollToBottom:ie}=x.useScroll({auto:!0}),ne=l.useConversation(),ae=d.useSubmit(),le=c.useSubmitResult(),de=a.useStyleFontSize(),ce=n.useStyleInput(),[ue,me]=t.useState(""),pe=t.useRef(null),xe=f.useHover(),{isHover:fe}=xe,be=e.__rest(xe,["isHover"]),ge=f.useHover(),{isHover:he}=ge,je=e.__rest(ge,["isHover"]),ve=t.useMemo((()=>{var e,s,t;return!!z&&(!!_&&(!ne.isLoading&&(!((null!==(s=null===(e=ne.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=_.icebreakers)||void 0===t?void 0:t.length))))}),[_,z,ne.data,ne.isLoading]),ye=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(Z||"idle"!==W)return;const e=null!=s?s:ue;if(!e)return;me(""),Q(""),J(null),V(!0),B(!1);const t=new Date,o="enduserupload"===(null==_?void 0:_.documentuploadtype),r=Y.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),i=r.length?r[r.length-1].documentId:"";K("fetching"),oe(),ie();const n=Array.from(P);let a=[...n,{id:P.length+1,role:"user",content:e}];G(a),ie();const{success:l,data:d,actionData:c,usedDocumentIds:u,endUserDocumentId:p,endUserImageId:x,rawUserInput:f,error:b}=yield ae.mutateAsync(Object.assign(Object.assign(Object.assign({formId:N,responseId:S,value:e},o&&i&&{documentId:i}),D&&{studioUserId:D}),A&&{deploymentId:A}));if(!l)throw new Error(null!=b?b:"An error occurred, please try again.");const g=[];p&&g.push(p),x&&g.push(x),g.length>0&&(a=[...n,Object.assign({id:P.length+1,role:"user",content:e},g&&{documentIds:g})],G(a),ie()),se([]),ie();const h=(yield m.streamer({formId:N,responseId:S,data:d,actionData:c})).body;if(!h)throw new Error("Streaming error");const j=h.getReader(),v=new TextDecoder,y=a.length;let k="",w=!0,I=!1;for(;w;){const{value:e,done:s}=yield j.read();w=!s;if(k+=v.decode(e),k)G([...a.slice(0,y),{id:P.length+1,role:"assistant",content:k}]),I||(K("streaming"),I=!0);else if(!w&&!k)throw new Error("Server error")}const O=new Date;k&&(ie(),K("idle"),yield le.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:N,responseId:S,documentIds:u},R&&{userId:R}),D&&{studioUserId:D}),D&&(null==_?void 0:_.studioid)&&{studioId:_.studioid}),A&&{deploymentId:A}),{messages:[Object.assign(Object.assign({role:"user",message:f},g&&{documentIds:g}),{sentAt:t}),{role:"assistant",message:k,sentAt:O}]})),null==L||L(S))}catch(e){let s=O.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($).find((([e])=>s.includes(e)));t?J(t[1]):Q(s),ie()}finally{K("idle"),V(!1),re()}}));return t.useEffect((()=>{F(ve)}),[ve]),s.jsxs("div",Object.assign({className:C.default("fixed flex w-full flex-col bottom-0 left-0","viewport"===E?"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:[!H.isWhiteLabel&&s.jsx("div",Object.assign({className:"flex justify-end pr-3 pb-3 @[767px]/pickaxe-root:pr-0"},{children:s.jsx(k.default,{animateHover:!0})})),ve&&s.jsx(w.default,{data:(null==_?void 0:_.icebreakers)||[],onSend:ye}),s.jsxs("div",Object.assign({id:(null==_?void 0:_.formid)+"--chat-parent",style:Object.assign(Object.assign({},ce),(X||M)&&{paddingLeft:"0.75rem",paddingRight:"0.75rem"}),className:C.default("flex min-h-[56px] flex-col gap-y-2 px-4 py-3 pb-[15px]","block"===T.formFieldStyle&&"shadow")},{children:["idle"===W&&Y.length>0&&s.jsx("div",Object.assign({className:C.default("grid grid-cols-1","viewport"===E?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:Y.map((e=>{var o,r,i;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:"relative gap-x-[10px] flex items-center px-2 h-[56px] border",style:{borderRadius:ce.borderRadius,borderColor:U.secondaryText+"50"}},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:U.accent,borderRadius:ce.borderRadius}},{children:Z?s.jsx(h.default,{className:"w-5 h-5 animate-spin",style:{color:U.accentText}}):s.jsx(j.default,{className:"w-5 h-5",style:{color:U.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(C.default(de.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:C.default(de.b4,"opacity-80 truncate")},{children:b.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",disabled:Z||"idle"!==W,onClick:()=>se([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:U.accent,borderColor:ce.backgroundColor}},{children:s.jsx(v.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):"image"===e.type?s.jsxs("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:ce.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:ce.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(o=e.documentId)||void 0===o?void 0:o.split("-")[2]}/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[1]}.${null===(i=e.documentId)||void 0===i?void 0:i.split("-")[2]}`,alt:""}):s.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:ce.borderRadius,backgroundColor:U.secondary}}),s.jsx("button",Object.assign({type:"button",disabled:Z||"idle"!==W,onClick:()=>se([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:U.accent,borderColor:ce.backgroundColor}},{children:s.jsx(v.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):null},e.id)}))})),s.jsxs("div",Object.assign({className:"flex items-end gap-x-2 grow"},{children:[s.jsx(q.default,{id:(null==_?void 0:_.formid)+"--chat-textarea",className:C.default(de.b2,"max-h-60 mb-[0.2em] w-full resize-none border-transparent bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:text-inherit placeholder:opacity-50",!ue.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:ue,placeholder:null!==(I=null==_?void 0:_.placeholdertext)&&void 0!==I?I:"What do you want to talk about?",onChange:e=>me(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Z||"idle"!==W||ye()))}}),s.jsxs("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==_?void 0:_.documentuploadtype)&&s.jsxs("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:he?U.accent+"10":void 0},disabled:Z||"idle"!==W,onClick:()=>{var e;return null===(e=pe.current)||void 0===e?void 0:e.click()}},je,{children:[s.jsx("input",{id:"file-upload",ref:pe,type:"file",accept:[...u.allowedFileMimeTypes,...ee?u.allowedImageMimeTypes:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield te(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx(g.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:he?U.accent:U.accent+"80"}})]})),s.jsx("button",Object.assign({id:(null==_?void 0:_.formid)+"--chat-button",className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:fe?U.accent:U.accent+"10"},disabled:Z||"idle"!==W,onClick:()=>ye()},be,{children:s.jsx(y.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:fe?U.accentText:U.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/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../hooks/pickaxe/useDimensionContext.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"),c=require("../../../hooks/pickaxe/useSubmitResult.js"),u=require("../../../common/documents.js"),m=require("../../../common/api/streamer.js"),p=require("../Addons/Document/hooks/useDocument.js"),x=require("../Addons/Scroll/hooks/useScroll.js"),f=require("../../../hooks/core/useHover.js"),b=require("../../../common/utils.js"),g=require("../../Icons/attach-vertical.svg.js"),h=require("../../Icons/spinner-lines.svg.js"),j=require("../../Icons/file.svg.js"),v=require("../../Icons/x.svg.js"),y=require("../../Icons/arrow-right.svg.js"),k=require("../common/PickaxeBranding.js"),w=require("../Addons/IceBreaker/index.js"),I=require("react-textarea-autosize"),O=require("../../../common/error.js"),C=require("../../../common/cn.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var q=N(I);exports.default=()=>{var I;const{formId:N,chatId:S,userId:R,studioUserId:D,deploymentId:A,pickaxe:_,styles:T,colors:U,misc:E,chatInput:H,responsiveBy:M,forceMobile:z,isNewChat:B,setIsNewChat:F,setIsShowIceBreaker:L,onGenerateComplete:P}=o.usePickaxeContext(),{messages:W,status:$,limits:G,setMessages:K,setStatus:J,setLimitData:Q,setError:V,setIsGenerating:X}=r.useResponseContext(),{isMobile:Y}=i.useDimensionContext(),{documents:Z,isUploading:ee,isImageUploadAllowed:se,upsertDocuments:te,onFileUpload:oe}=p.useDocument(),{scrollStartSession:re,scrollEndSession:ie,scrollToBottom:ne}=x.useScroll({auto:!0}),ae=l.useConversation(),le=d.useSubmit(),de=c.useSubmitResult(),ce=a.useStyleFontSize(),ue=n.useStyleInput(),[me,pe]=t.useState(H),xe=t.useRef(null),fe=f.useHover(),{isHover:be}=fe,ge=e.__rest(fe,["isHover"]),he=f.useHover(),{isHover:je}=he,ve=e.__rest(he,["isHover"]),ye=t.useMemo((()=>{var e,s,t;return!!B&&(!!_&&(!ae.isLoading&&(!((null!==(s=null===(e=ae.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=_.icebreakers)||void 0===t?void 0:t.length))))}),[_,B,ae.data,ae.isLoading]),ke=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(ee||"idle"!==$)return;const e=null!=s?s:me;if(!e)return;pe(""),V(""),Q(null),X(!0),F(!1);const t=new Date,o="enduserupload"===(null==_?void 0:_.documentuploadtype),r=Z.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),i=r.length?r[r.length-1].documentId:"";J("fetching"),re(),ne();const n=Array.from(W);let a=[...n,{id:W.length+1,role:"user",content:e}];K(a),ne();const{success:l,data:d,actionData:c,usedDocumentIds:u,endUserDocumentId:p,endUserImageId:x,rawUserInput:f,error:b}=yield le.mutateAsync(Object.assign(Object.assign(Object.assign({formId:N,responseId:S,value:e},o&&i&&{documentId:i}),D&&{studioUserId:D}),A&&{deploymentId:A}));if(!l)throw new Error(null!=b?b:"An error occurred, please try again.");const g=[];p&&g.push(p),x&&g.push(x),g.length>0&&(a=[...n,Object.assign({id:W.length+1,role:"user",content:e},g&&{documentIds:g})],K(a),ne()),te([]),ne();const h=(yield m.streamer({formId:N,responseId:S,data:d,actionData:c})).body;if(!h)throw new Error("Streaming error");const j=h.getReader(),v=new TextDecoder,y=a.length;let k="",w=!0,I=!1;for(;w;){const{value:e,done:s}=yield j.read();w=!s;if(k+=v.decode(e),k)K([...a.slice(0,y),{id:W.length+1,role:"assistant",content:k}]),I||(J("streaming"),I=!0);else if(!w&&!k)throw new Error("Server error")}const O=new Date;k&&(ne(),J("idle"),yield de.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:N,responseId:S,documentIds:u},R&&{userId:R}),D&&{studioUserId:D}),D&&(null==_?void 0:_.studioid)&&{studioId:_.studioid}),A&&{deploymentId:A}),{messages:[Object.assign(Object.assign({role:"user",message:f},g&&{documentIds:g}),{sentAt:t}),{role:"assistant",message:k,sentAt:O}]})),null==P||P(S))}catch(e){let s=O.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(G).find((([e])=>s.includes(e)));t?Q(t[1]):V(s),ne()}finally{J("idle"),X(!1),ie()}}));return t.useEffect((()=>{L(ye)}),[ye]),t.useEffect((()=>{pe(H)}),[H]),s.jsxs("div",Object.assign({className:C.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:[!E.isWhiteLabel&&s.jsx("div",Object.assign({className:"flex justify-end pr-3 pb-3 @[767px]/pickaxe-root:pr-0"},{children:s.jsx(k.default,{animateHover:!0})})),ye&&s.jsx(w.default,{data:(null==_?void 0:_.icebreakers)||[],onSend:ke}),s.jsxs("div",Object.assign({id:(null==_?void 0:_.formid)+"--chat-parent",style:Object.assign(Object.assign({},ue),(Y||z)&&{paddingLeft:"0.75rem",paddingRight:"0.75rem"}),className:C.default("flex min-h-[56px] flex-col gap-y-2 px-4 py-3 pb-[15px]","block"===T.formFieldStyle&&"shadow")},{children:["idle"===$&&Z.length>0&&s.jsx("div",Object.assign({className:C.default("grid grid-cols-1","viewport"===M?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:Z.map((e=>{var o,r,i;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:"relative gap-x-[10px] flex items-center px-2 h-[56px] border",style:{borderRadius:ue.borderRadius,borderColor:U.secondaryText+"50"}},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:U.accent,borderRadius:ue.borderRadius}},{children:ee?s.jsx(h.default,{className:"w-5 h-5 animate-spin",style:{color:U.accentText}}):s.jsx(j.default,{className:"w-5 h-5",style:{color:U.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(C.default(ce.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:C.default(ce.b4,"opacity-80 truncate")},{children:b.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",disabled:ee||"idle"!==$,onClick:()=>te([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:U.accent,borderColor:ue.backgroundColor}},{children:s.jsx(v.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):"image"===e.type?s.jsxs("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:ue.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:ue.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(o=e.documentId)||void 0===o?void 0:o.split("-")[2]}/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[1]}.${null===(i=e.documentId)||void 0===i?void 0:i.split("-")[2]}`,alt:""}):s.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:ue.borderRadius,backgroundColor:U.secondary}}),s.jsx("button",Object.assign({type:"button",disabled:ee||"idle"!==$,onClick:()=>te([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:U.accent,borderColor:ue.backgroundColor}},{children:s.jsx(v.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):null},e.id)}))})),s.jsxs("div",Object.assign({className:"flex items-end gap-x-2 grow"},{children:[s.jsx(q.default,{id:(null==_?void 0:_.formid)+"--chat-textarea",className:C.default(ce.b2,"max-h-60 mb-[0.2em] w-full resize-none border-transparent bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:text-inherit placeholder:opacity-50",!me.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:me,placeholder:null!==(I=null==_?void 0:_.placeholdertext)&&void 0!==I?I:"What do you want to talk about?",onChange:e=>pe(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ee||"idle"!==$||ke()))}}),s.jsxs("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==_?void 0:_.documentuploadtype)&&s.jsxs("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:je?U.accent+"10":void 0},disabled:ee||"idle"!==$,onClick:()=>{var e;return null===(e=xe.current)||void 0===e?void 0:e.click()}},ve,{children:[s.jsx("input",{id:"file-upload",ref:xe,type:"file",accept:[...u.allowedFileMimeTypes,...se?u.allowedImageMimeTypes:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield oe(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx(g.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:je?U.accent:U.accent+"80"}})]})),s.jsx("button",Object.assign({id:(null==_?void 0:_.formid)+"--chat-button",className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:be?U.accent:U.accent+"10"},disabled:ee||"idle"!==$,onClick:()=>ke()},ge,{children:s.jsx(y.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:be?U.accentText:U.accent}})}))]}))]}))]}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("./Addons/Document/Provider.js"),i=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");const o=s.createContext({});exports.PickaxeContext=o,exports.PickaxeProvider=({children:a,userId:n="",studioUserId:d="",deploymentId:c="",styles:l,colors:u,limits:h={},misc:F={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:m,responsiveBy:p="viewport",loadFont:x=!0,forceMobile:I=!1,onGenerateComplete:y})=>{const[f,g]=s.useState(""),[j,S]=s.useState(""),[b,v]=s.useState(null),[P,w]=s.useState(!1),[C,k]=s.useState(!0),[O,q]=s.useState(!0),[D,B]=s.useState(!1);return s.useEffect((()=>{w(!1)}),[null==l?void 0:l.font]),e.jsx(o.Provider,Object.assign({value:Object.assign({formId:f,chatId:j,userId:n,studioUserId:d,deploymentId:c,pickaxe:b,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},l),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},u),misc:F,translations:Object.assign({"new-chat":"New chat","see-history":"See history",processing:"Processing...",uploading:"Uploading...",loading:"Loading..."},m),responsiveBy:p,isFontLoaded:P,isNewChat:C,isShowIceBreaker:O,isShowHistory:D,loadFont:x,forceMobile:I,setIsFontLoaded:w,setFormId:g,setChatId:S,setPickaxe:v,setIsNewChat:k,setIsShowIceBreaker:q,setIsShowHistory:B},y&&{onGenerateComplete:y})},{children:e.jsx(i.default,Object.assign({limits:h},{children:e.jsx(r.default,{children:e.jsx(t.default,{children:a})})}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("./Addons/Document/Provider.js"),i=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");const o=t.createContext({});exports.PickaxeContext=o,exports.PickaxeProvider=({children:a,userId:n="",studioUserId:d="",deploymentId:c="",styles:l,colors:u,limits:h={},misc:F={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:p,chatInput:I="",responsiveBy:m="viewport",loadFont:x=!0,forceMobile:y=!1,onGenerateComplete:f})=>{const[g,j]=t.useState(""),[S,b]=t.useState(""),[v,P]=t.useState(null),[w,C]=t.useState(!1),[k,O]=t.useState(!0),[q,D]=t.useState(!0),[B,H]=t.useState(!1);return t.useEffect((()=>{C(!1)}),[null==l?void 0:l.font]),e.jsx(o.Provider,Object.assign({value:Object.assign({formId:g,chatId:S,userId:n,studioUserId:d,deploymentId:c,pickaxe:v,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},l),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},u),misc:F,translations:Object.assign({"new-chat":"New chat","see-history":"See history",processing:"Processing...",uploading:"Uploading...",loading:"Loading..."},p),chatInput:I,responsiveBy:m,isFontLoaded:w,isNewChat:k,isShowIceBreaker:q,isShowHistory:B,loadFont:x,forceMobile:y,setIsFontLoaded:C,setFormId:j,setChatId:b,setPickaxe:P,setIsNewChat:O,setIsShowIceBreaker:D,setIsShowHistory:H},f&&{onGenerateComplete:f})},{children:e.jsx(i.default,Object.assign({limits:h},{children:e.jsx(r.default,{children:e.jsx(s.default,{children:a})})}))}))};
@@ -43,6 +43,7 @@ type PickaxeContextType = {
43
43
  styles: PickaxeProviderStyles;
44
44
  colors: PickaxeProviderColors;
45
45
  misc: PickaxeMisc;
46
+ chatInput: string;
46
47
  translations: PickaxeTranslations;
47
48
  responsiveBy: PickaxeResponsiveBy;
48
49
  isFontLoaded: boolean;
@@ -70,11 +71,12 @@ export interface IPickaxeProviderProps {
70
71
  limits?: Record<string, PickaxeLimitData>;
71
72
  misc?: PickaxeMisc;
72
73
  translations?: PickaxeTranslations;
74
+ chatInput?: string;
73
75
  responsiveBy?: PickaxeResponsiveBy;
74
76
  loadFont?: boolean;
75
77
  forceMobile?: boolean;
76
78
  onGenerateComplete?: (responseId: string) => void;
77
79
  }
78
80
  export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
79
- export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, styles, colors, limits, misc, translations, responsiveBy, loadFont, forceMobile, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
81
+ export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, styles, colors, limits, misc, translations, chatInput, responsiveBy, loadFont, forceMobile, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
80
82
  export {};
@@ -8,6 +8,7 @@ export declare const usePickaxeContext: () => {
8
8
  styles: import("../../components/Pickaxe/Provider").PickaxeProviderStyles;
9
9
  colors: import("../../components/Pickaxe/Provider").PickaxeProviderColors;
10
10
  misc: import("../../components/Pickaxe/Provider").PickaxeMisc;
11
+ chatInput: string;
11
12
  translations: import("../../components/Pickaxe/Provider").PickaxeTranslations;
12
13
  responsiveBy: import("../../components/Pickaxe/Provider").PickaxeResponsiveBy;
13
14
  isFontLoaded: boolean;
@@ -1 +1 @@
1
- import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as r,useRef as i,useMemo as n,useEffect as a,Fragment as l}from"react";import{usePickaxeContext as d}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as u}from"../../../hooks/pickaxe/useDimensionContext.js";import{useStyleInput as m}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as p}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as f}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as h}from"../../../hooks/pickaxe/useSubmit.js";import{useSubmitResult as g}from"../../../hooks/pickaxe/useSubmitResult.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as v}from"../../../common/documents.js";import{streamer as x}from"../../../common/api/streamer.js";import{useDocument as j}from"../Addons/Document/hooks/useDocument.js";import{useScroll as y}from"../Addons/Scroll/hooks/useScroll.js";import{useHover as k}from"../../../hooks/core/useHover.js";import{formatBytes as w}from"../../../common/utils.js";import I from"../../Icons/attach-vertical.svg.js";import O from"../../Icons/spinner-lines.svg.js";import N from"../../Icons/file.svg.js";import C from"../../Icons/x.svg.js";import S from"../../Icons/arrow-right.svg.js";import R from"../common/PickaxeBranding.js";import D from"../Addons/IceBreaker/index.js";import A from"react-textarea-autosize";import U from"../../../common/error.js";import T from"../../../common/cn.js";const E=()=>{var E;const{formId:H,chatId:z,userId:B,studioUserId:L,deploymentId:F,pickaxe:M,styles:P,colors:W,misc:$,responsiveBy:G,forceMobile:K,isNewChat:_,setIsNewChat:q,setIsShowIceBreaker:J,onGenerateComplete:Q}=d(),{messages:V,status:X,limits:Y,setMessages:Z,setStatus:ee,setLimitData:te,setError:oe,setIsGenerating:se}=c(),{isMobile:re}=u(),{documents:ie,isUploading:ne,isImageUploadAllowed:ae,upsertDocuments:le,onFileUpload:de}=j(),{scrollStartSession:ce,scrollEndSession:ue,scrollToBottom:me}=y({auto:!0}),pe=f(),fe=h(),he=g(),ge=p(),be=m(),[ve,xe]=r(""),je=i(null),ye=k(),{isHover:ke}=ye,we=e(ye,["isHover"]),Ie=k(),{isHover:Oe}=Ie,Ne=e(Ie,["isHover"]),Ce=n((()=>{var e,t,o;return!!_&&(!!M&&(!pe.isLoading&&(!((null!==(t=null===(e=pe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(o=M.icebreakers)||void 0===o?void 0:o.length))))}),[M,_,pe.data,pe.isLoading]),Se=e=>t(void 0,void 0,void 0,(function*(){try{if(ne||"idle"!==X)return;const t=null!=e?e:ve;if(!t)return;xe(""),oe(""),te(null),se(!0),q(!1);const o=new Date,s="enduserupload"===(null==M?void 0:M.documentuploadtype),r=ie.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),i=r.length?r[r.length-1].documentId:"";ee("fetching"),ce(),me();const n=Array.from(V);let a=[...n,{id:V.length+1,role:"user",content:t}];Z(a),me();const{success:l,data:d,actionData:c,usedDocumentIds:u,endUserDocumentId:m,endUserImageId:p,rawUserInput:f,error:h}=yield fe.mutateAsync(Object.assign(Object.assign(Object.assign({formId:H,responseId:z,value:t},s&&i&&{documentId:i}),L&&{studioUserId:L}),F&&{deploymentId:F}));if(!l)throw new Error(null!=h?h:"An error occurred, please try again.");const g=[];m&&g.push(m),p&&g.push(p),g.length>0&&(a=[...n,Object.assign({id:V.length+1,role:"user",content:t},g&&{documentIds:g})],Z(a),me()),le([]),me();const b=(yield x({formId:H,responseId:z,data:d,actionData:c})).body;if(!b)throw new Error("Streaming error");const v=b.getReader(),j=new TextDecoder,y=a.length;let k="",w=!0,I=!1;for(;w;){const{value:e,done:t}=yield v.read();w=!t;if(k+=j.decode(e),k)Z([...a.slice(0,y),{id:V.length+1,role:"assistant",content:k}]),I||(ee("streaming"),I=!0);else if(!w&&!k)throw new Error("Server error")}const O=new Date;k&&(me(),ee("idle"),yield he.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:H,responseId:z,documentIds:u},B&&{userId:B}),L&&{studioUserId:L}),L&&(null==M?void 0:M.studioid)&&{studioId:M.studioid}),F&&{deploymentId:F}),{messages:[Object.assign(Object.assign({role:"user",message:f},g&&{documentIds:g}),{sentAt:o}),{role:"assistant",message:k,sentAt:O}]})),null==Q||Q(z))}catch(e){let t=U(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const o=Object.entries(Y).find((([e])=>t.includes(e)));o?te(o[1]):oe(t),me()}finally{ee("idle"),se(!1),ue()}}));return a((()=>{J(Ce)}),[Ce]),o("div",Object.assign({className:T("fixed flex w-full flex-col bottom-0 left-0","viewport"===G?"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:[!$.isWhiteLabel&&s("div",Object.assign({className:"flex justify-end pr-3 pb-3 @[767px]/pickaxe-root:pr-0"},{children:s(R,{animateHover:!0})})),Ce&&s(D,{data:(null==M?void 0:M.icebreakers)||[],onSend:Se}),o("div",Object.assign({id:(null==M?void 0:M.formid)+"--chat-parent",style:Object.assign(Object.assign({},be),(re||K)&&{paddingLeft:"0.75rem",paddingRight:"0.75rem"}),className:T("flex min-h-[56px] flex-col gap-y-2 px-4 py-3 pb-[15px]","block"===P.formFieldStyle&&"shadow")},{children:["idle"===X&&ie.length>0&&s("div",Object.assign({className:T("grid grid-cols-1","viewport"===G?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:ie.map((e=>{var t,r,i;return s(l,{children:"document"===e.type?o("div",Object.assign({className:"relative gap-x-[10px] flex items-center px-2 h-[56px] border",style:{borderRadius:be.borderRadius,borderColor:W.secondaryText+"50"}},{children:[s("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:W.accent,borderRadius:be.borderRadius}},{children:ne?s(O,{className:"w-5 h-5 animate-spin",style:{color:W.accentText}}):s(N,{className:"w-5 h-5",style:{color:W.accentText}})})),o("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s("p",Object.assign({className:(T(ge.b3),"font-medium truncate")},{children:e.name})),s("p",Object.assign({className:T(ge.b4,"opacity-80 truncate")},{children:w(e.size)}))]})),s("button",Object.assign({type:"button",disabled:ne||"idle"!==X,onClick:()=>le([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:W.accent,borderColor:be.backgroundColor}},{children:s(C,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):"image"===e.type?o("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:be.borderRadius}},{children:["finished"===e.status?s("img",{style:{borderRadius:be.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(t=e.documentId)||void 0===t?void 0:t.split("-")[2]}/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[1]}.${null===(i=e.documentId)||void 0===i?void 0:i.split("-")[2]}`,alt:""}):s("div",{className:"h-full w-full animate-pulse",style:{borderRadius:be.borderRadius,backgroundColor:W.secondary}}),s("button",Object.assign({type:"button",disabled:ne||"idle"!==X,onClick:()=>le([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:W.accent,borderColor:be.backgroundColor}},{children:s(C,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):null},e.id)}))})),o("div",Object.assign({className:"flex items-end gap-x-2 grow"},{children:[s(A,{id:(null==M?void 0:M.formid)+"--chat-textarea",className:T(ge.b2,"max-h-60 mb-[0.2em] w-full resize-none border-transparent bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:text-inherit placeholder:opacity-50",!ve.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:ve,placeholder:null!==(E=null==M?void 0:M.placeholdertext)&&void 0!==E?E:"What do you want to talk about?",onChange:e=>xe(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ne||"idle"!==X||Se()))}}),o("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==M?void 0:M.documentuploadtype)&&o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:Oe?W.accent+"10":void 0},disabled:ne||"idle"!==X,onClick:()=>{var e;return null===(e=je.current)||void 0===e?void 0:e.click()}},Ne,{children:[s("input",{id:"file-upload",ref:je,type:"file",accept:[...b,...ae?v:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){yield de(Array.from(e.target.files||[])),e.target.value=""}))}),s(I,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:Oe?W.accent:W.accent+"80"}})]})),s("button",Object.assign({id:(null==M?void 0:M.formid)+"--chat-button",className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:ke?W.accent:W.accent+"10"},disabled:ne||"idle"!==X,onClick:()=>Se()},we,{children:s(S,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:ke?W.accentText:W.accent}})}))]}))]}))]}))]}))};export{E as default};
1
+ import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as r,useRef as i,useMemo as n,useEffect as a,Fragment as l}from"react";import{usePickaxeContext as d}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as u}from"../../../hooks/pickaxe/useDimensionContext.js";import{useStyleInput as m}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as p}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as f}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as h}from"../../../hooks/pickaxe/useSubmit.js";import{useSubmitResult as g}from"../../../hooks/pickaxe/useSubmitResult.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as v}from"../../../common/documents.js";import{streamer as x}from"../../../common/api/streamer.js";import{useDocument as j}from"../Addons/Document/hooks/useDocument.js";import{useScroll as y}from"../Addons/Scroll/hooks/useScroll.js";import{useHover as k}from"../../../hooks/core/useHover.js";import{formatBytes as I}from"../../../common/utils.js";import w from"../../Icons/attach-vertical.svg.js";import O from"../../Icons/spinner-lines.svg.js";import N from"../../Icons/file.svg.js";import C from"../../Icons/x.svg.js";import S from"../../Icons/arrow-right.svg.js";import R from"../common/PickaxeBranding.js";import D from"../Addons/IceBreaker/index.js";import A from"react-textarea-autosize";import U from"../../../common/error.js";import T from"../../../common/cn.js";const E=()=>{var E;const{formId:H,chatId:z,userId:B,studioUserId:L,deploymentId:F,pickaxe:M,styles:P,colors:W,misc:$,chatInput:G,responsiveBy:K,forceMobile:_,isNewChat:q,setIsNewChat:J,setIsShowIceBreaker:Q,onGenerateComplete:V}=d(),{messages:X,status:Y,limits:Z,setMessages:ee,setStatus:te,setLimitData:oe,setError:se,setIsGenerating:re}=c(),{isMobile:ie}=u(),{documents:ne,isUploading:ae,isImageUploadAllowed:le,upsertDocuments:de,onFileUpload:ce}=j(),{scrollStartSession:ue,scrollEndSession:me,scrollToBottom:pe}=y({auto:!0}),fe=f(),he=h(),ge=g(),be=p(),ve=m(),[xe,je]=r(G),ye=i(null),ke=k(),{isHover:Ie}=ke,we=e(ke,["isHover"]),Oe=k(),{isHover:Ne}=Oe,Ce=e(Oe,["isHover"]),Se=n((()=>{var e,t,o;return!!q&&(!!M&&(!fe.isLoading&&(!((null!==(t=null===(e=fe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(o=M.icebreakers)||void 0===o?void 0:o.length))))}),[M,q,fe.data,fe.isLoading]),Re=e=>t(void 0,void 0,void 0,(function*(){try{if(ae||"idle"!==Y)return;const t=null!=e?e:xe;if(!t)return;je(""),se(""),oe(null),re(!0),J(!1);const o=new Date,s="enduserupload"===(null==M?void 0:M.documentuploadtype),r=ne.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),i=r.length?r[r.length-1].documentId:"";te("fetching"),ue(),pe();const n=Array.from(X);let a=[...n,{id:X.length+1,role:"user",content:t}];ee(a),pe();const{success:l,data:d,actionData:c,usedDocumentIds:u,endUserDocumentId:m,endUserImageId:p,rawUserInput:f,error:h}=yield he.mutateAsync(Object.assign(Object.assign(Object.assign({formId:H,responseId:z,value:t},s&&i&&{documentId:i}),L&&{studioUserId:L}),F&&{deploymentId:F}));if(!l)throw new Error(null!=h?h:"An error occurred, please try again.");const g=[];m&&g.push(m),p&&g.push(p),g.length>0&&(a=[...n,Object.assign({id:X.length+1,role:"user",content:t},g&&{documentIds:g})],ee(a),pe()),de([]),pe();const b=(yield x({formId:H,responseId:z,data:d,actionData:c})).body;if(!b)throw new Error("Streaming error");const v=b.getReader(),j=new TextDecoder,y=a.length;let k="",I=!0,w=!1;for(;I;){const{value:e,done:t}=yield v.read();I=!t;if(k+=j.decode(e),k)ee([...a.slice(0,y),{id:X.length+1,role:"assistant",content:k}]),w||(te("streaming"),w=!0);else if(!I&&!k)throw new Error("Server error")}const O=new Date;k&&(pe(),te("idle"),yield ge.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:H,responseId:z,documentIds:u},B&&{userId:B}),L&&{studioUserId:L}),L&&(null==M?void 0:M.studioid)&&{studioId:M.studioid}),F&&{deploymentId:F}),{messages:[Object.assign(Object.assign({role:"user",message:f},g&&{documentIds:g}),{sentAt:o}),{role:"assistant",message:k,sentAt:O}]})),null==V||V(z))}catch(e){let t=U(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const o=Object.entries(Z).find((([e])=>t.includes(e)));o?oe(o[1]):se(t),pe()}finally{te("idle"),re(!1),me()}}));return a((()=>{Q(Se)}),[Se]),a((()=>{je(G)}),[G]),o("div",Object.assign({className:T("fixed flex w-full flex-col bottom-0 left-0","viewport"===K?"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:[!$.isWhiteLabel&&s("div",Object.assign({className:"flex justify-end pr-3 pb-3 @[767px]/pickaxe-root:pr-0"},{children:s(R,{animateHover:!0})})),Se&&s(D,{data:(null==M?void 0:M.icebreakers)||[],onSend:Re}),o("div",Object.assign({id:(null==M?void 0:M.formid)+"--chat-parent",style:Object.assign(Object.assign({},ve),(ie||_)&&{paddingLeft:"0.75rem",paddingRight:"0.75rem"}),className:T("flex min-h-[56px] flex-col gap-y-2 px-4 py-3 pb-[15px]","block"===P.formFieldStyle&&"shadow")},{children:["idle"===Y&&ne.length>0&&s("div",Object.assign({className:T("grid grid-cols-1","viewport"===K?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:ne.map((e=>{var t,r,i;return s(l,{children:"document"===e.type?o("div",Object.assign({className:"relative gap-x-[10px] flex items-center px-2 h-[56px] border",style:{borderRadius:ve.borderRadius,borderColor:W.secondaryText+"50"}},{children:[s("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:W.accent,borderRadius:ve.borderRadius}},{children:ae?s(O,{className:"w-5 h-5 animate-spin",style:{color:W.accentText}}):s(N,{className:"w-5 h-5",style:{color:W.accentText}})})),o("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s("p",Object.assign({className:(T(be.b3),"font-medium truncate")},{children:e.name})),s("p",Object.assign({className:T(be.b4,"opacity-80 truncate")},{children:I(e.size)}))]})),s("button",Object.assign({type:"button",disabled:ae||"idle"!==Y,onClick:()=>de([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:W.accent,borderColor:ve.backgroundColor}},{children:s(C,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):"image"===e.type?o("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:ve.borderRadius}},{children:["finished"===e.status?s("img",{style:{borderRadius:ve.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(t=e.documentId)||void 0===t?void 0:t.split("-")[2]}/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[1]}.${null===(i=e.documentId)||void 0===i?void 0:i.split("-")[2]}`,alt:""}):s("div",{className:"h-full w-full animate-pulse",style:{borderRadius:ve.borderRadius,backgroundColor:W.secondary}}),s("button",Object.assign({type:"button",disabled:ae||"idle"!==Y,onClick:()=>de([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:W.accent,borderColor:ve.backgroundColor}},{children:s(C,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):null},e.id)}))})),o("div",Object.assign({className:"flex items-end gap-x-2 grow"},{children:[s(A,{id:(null==M?void 0:M.formid)+"--chat-textarea",className:T(be.b2,"max-h-60 mb-[0.2em] w-full resize-none border-transparent bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:text-inherit placeholder:opacity-50",!xe.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:xe,placeholder:null!==(E=null==M?void 0:M.placeholdertext)&&void 0!==E?E:"What do you want to talk about?",onChange:e=>je(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ae||"idle"!==Y||Re()))}}),o("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==M?void 0:M.documentuploadtype)&&o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:Ne?W.accent+"10":void 0},disabled:ae||"idle"!==Y,onClick:()=>{var e;return null===(e=ye.current)||void 0===e?void 0:e.click()}},Ce,{children:[s("input",{id:"file-upload",ref:ye,type:"file",accept:[...b,...le?v:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){yield ce(Array.from(e.target.files||[])),e.target.value=""}))}),s(w,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:Ne?W.accent:W.accent+"80"}})]})),s("button",Object.assign({id:(null==M?void 0:M.formid)+"--chat-button",className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:Ie?W.accent:W.accent+"10"},disabled:ae||"idle"!==Y,onClick:()=>Re()},we,{children:s(S,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:Ie?W.accentText:W.accent}})}))]}))]}))]}))]}))};export{E as default};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{createContext as s,useState as o,useEffect as t}from"react";import i from"./Addons/Document/Provider.js";import r from"./ResponseProvider.js";import n from"./DimensionProvider.js";const a=s({}),d=({children:s,userId:d="",studioUserId:c="",deploymentId:l="",styles:m,colors:h,limits:F={},misc:p={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:I,responsiveBy:y="viewport",loadFont:g=!0,forceMobile:f=!1,onGenerateComplete:u})=>{const[b,j]=o(""),[v,w]=o(""),[x,P]=o(null),[S,C]=o(!1),[O,k]=o(!0),[D,B]=o(!0),[H,L]=o(!1);return t((()=>{C(!1)}),[null==m?void 0:m.font]),e(a.Provider,Object.assign({value:Object.assign({formId:b,chatId:v,userId:d,studioUserId:c,deploymentId:l,pickaxe:x,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},m),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},h),misc:p,translations:Object.assign({"new-chat":"New chat","see-history":"See history",processing:"Processing...",uploading:"Uploading...",loading:"Loading..."},I),responsiveBy:y,isFontLoaded:S,isNewChat:O,isShowIceBreaker:D,isShowHistory:H,loadFont:g,forceMobile:f,setIsFontLoaded:C,setFormId:j,setChatId:w,setPickaxe:P,setIsNewChat:k,setIsShowIceBreaker:B,setIsShowHistory:L},u&&{onGenerateComplete:u})},{children:e(r,Object.assign({limits:F},{children:e(n,{children:e(i,{children:s})})}))}))};export{a as PickaxeContext,d as PickaxeProvider};
1
+ import{jsx as e}from"react/jsx-runtime";import{createContext as s,useState as o,useEffect as t}from"react";import i from"./Addons/Document/Provider.js";import r from"./ResponseProvider.js";import n from"./DimensionProvider.js";const a=s({}),d=({children:s,userId:d="",studioUserId:c="",deploymentId:l="",styles:m,colors:h,limits:p={},misc:F={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:I,chatInput:y="",responsiveBy:g="viewport",loadFont:u=!0,forceMobile:f=!1,onGenerateComplete:b})=>{const[j,v]=o(""),[w,x]=o(""),[P,S]=o(null),[C,O]=o(!1),[k,D]=o(!0),[B,H]=o(!0),[L,T]=o(!1);return t((()=>{O(!1)}),[null==m?void 0:m.font]),e(a.Provider,Object.assign({value:Object.assign({formId:j,chatId:w,userId:d,studioUserId:c,deploymentId:l,pickaxe:P,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},m),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},h),misc:F,translations:Object.assign({"new-chat":"New chat","see-history":"See history",processing:"Processing...",uploading:"Uploading...",loading:"Loading..."},I),chatInput:y,responsiveBy:g,isFontLoaded:C,isNewChat:k,isShowIceBreaker:B,isShowHistory:L,loadFont:u,forceMobile:f,setIsFontLoaded:O,setFormId:v,setChatId:x,setPickaxe:S,setIsNewChat:D,setIsShowIceBreaker:H,setIsShowHistory:T},b&&{onGenerateComplete:b})},{children:e(r,Object.assign({limits:p},{children:e(n,{children:e(i,{children:s})})}))}))};export{a as PickaxeContext,d as PickaxeProvider};
@@ -43,6 +43,7 @@ type PickaxeContextType = {
43
43
  styles: PickaxeProviderStyles;
44
44
  colors: PickaxeProviderColors;
45
45
  misc: PickaxeMisc;
46
+ chatInput: string;
46
47
  translations: PickaxeTranslations;
47
48
  responsiveBy: PickaxeResponsiveBy;
48
49
  isFontLoaded: boolean;
@@ -70,11 +71,12 @@ export interface IPickaxeProviderProps {
70
71
  limits?: Record<string, PickaxeLimitData>;
71
72
  misc?: PickaxeMisc;
72
73
  translations?: PickaxeTranslations;
74
+ chatInput?: string;
73
75
  responsiveBy?: PickaxeResponsiveBy;
74
76
  loadFont?: boolean;
75
77
  forceMobile?: boolean;
76
78
  onGenerateComplete?: (responseId: string) => void;
77
79
  }
78
80
  export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
79
- export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, styles, colors, limits, misc, translations, responsiveBy, loadFont, forceMobile, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
81
+ export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, styles, colors, limits, misc, translations, chatInput, responsiveBy, loadFont, forceMobile, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
80
82
  export {};
@@ -8,6 +8,7 @@ export declare const usePickaxeContext: () => {
8
8
  styles: import("../../components/Pickaxe/Provider").PickaxeProviderStyles;
9
9
  colors: import("../../components/Pickaxe/Provider").PickaxeProviderColors;
10
10
  misc: import("../../components/Pickaxe/Provider").PickaxeMisc;
11
+ chatInput: string;
11
12
  translations: import("../../components/Pickaxe/Provider").PickaxeTranslations;
12
13
  responsiveBy: import("../../components/Pickaxe/Provider").PickaxeResponsiveBy;
13
14
  isFontLoaded: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",