@pickaxeproject/react 4.5.3 → 5.0.0

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"),t=require("react/jsx-runtime"),s=require("react");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),c=require("../../../hooks/pickaxe/useDimensionContext.js"),u=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../../../hooks/pickaxe/useSubmit.js"),f=require("../Addons/Document/hooks/useDocument.js"),p=require("../Addons/Scroll/hooks/useScroll.js"),g=require("../Addons/Artifact/hooks/useArtifactContext.js"),h=require("../../../hooks/core/useHover.js"),m=require("../../../hooks/core/useMediaQuery.js"),v=require("../../../common/documents.js"),b=require("eventsource-parser"),j=require("../../Icons/attach-vertical.svg.js"),x=require("../../Icons/arrow-right.svg.js"),y=require("../../Icons/microphone.svg.js"),O=require("../../Icons/stop.svg.js"),k=require("../Addons/Document/List.js"),w=require("../../Core/Textarea.js"),S=require("../../Core/ErrorAlert.js"),C=require("../../../common/error.js"),N=require("../../../common/cn.js");function q(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var I=q(n);const A=s.forwardRef((({resubmitPrompt:q,onFocus:A,onBlur:_,onInputHeightChange:E,initSmitheryAuthData:R},D)=>{var T,H,F;const{origin:L,pickaxeId:P,sessionId:W,sender:M,senderType:$,deploymentId:z,deploymentType:J,pickaxe:B,styles:V,colors:U,locale:G,forceMobile:K,isNewChat:Q,isRtl:Y,isEmailLogin:X,isShowFeedbackMessage:Z,setIsNewChat:ee,setIsShowIceBreaker:te,onGenerateComplete:se}=r.usePickaxeContext(),{token:ne,isLoggedOut:re,isSent:ie}=u.useAuthContext(),{messages:oe,limits:ae,isGenerating:le,setMessages:ce,setStatus:ue,setLimitData:de,setError:fe}=i.useResponseContext(),{documents:pe,isUploading:ge,documentError:he,onFileUpload:me,setDocuments:ve,setDocumentError:be}=f.useDocument(),{scrollStartSession:je,scrollEndSession:xe,scrollToBottom:ye}=p.useScroll({auto:!0}),{artifacts:Oe,currentPopupType:ke,setArtifacts:we,setCurrentArtifact:Se}=g.useArtifactContext(),{height:Ce}=c.useDimensionContext(),Ne=l.useConversation(),qe=d.useSubmit(),[Ie,Ae]=s.useState(""),[_e,Ee]=s.useState(!1),[Re,De]=s.useState(!1),Te=s.useRef(null),He=s.useRef(""),Fe=s.useRef(null),Le=s.useRef(null),Pe=s.useRef(null),We=s.useRef(null),Me=Math.max(.2*Ce,100),{transcript:$e,listening:ze,resetTranscript:Je,browserSupportsSpeechRecognition:Be}=n.useSpeechRecognition(),[Ve]=m.useMediaQuery("(max-width: 480px)"),Ue=h.useHover(),{isHover:Ge}=Ue,Ke=e.__rest(Ue,["isHover"]),Qe=h.useHover(),{isHover:Ye}=Qe,Xe=e.__rest(Qe,["isHover"]),Ze=h.useHover(),{isHover:et}=Ze,tt=e.__rest(Ze,["isHover"]),[st,nt]=s.useState(!1),rt=a.useStyleFontSize(),it=o.useStyleInput(),ot=null===(T=null==B?void 0:B.documentuploadtype)||void 0===T?void 0:T.startsWith("enduserupload"),at=Be&&(null==B?void 0:B.enablevoicetotext),lt="chat-input"===J&&Q&&!ie,ct="chat-input"===J&&X&&re&&ie,ut=_e||Re,dt=s.useMemo((()=>{var e,t,s;return!!Q&&(!!B&&(!Ne.isLoading&&(!((null!==(t=null===(e=Ne.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=B.icebreakers)||void 0===s?void 0:s.length)&&(!Z&&!lt)))))}),[B,Q,Z,lt,Ne.data,Ne.isLoading]),ft=s.useMemo((()=>{if(le||ge)return!1;const e=pe.length>0&&pe.every((e=>"finished"===e.status));return!(!Ie.trim()&&!e)&&pe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[le,ge,Ie,pe]);s.useImperativeHandle(D,(()=>({onSubmit:pt}))),s.useEffect((()=>{te(dt)}),[dt]),s.useEffect((()=>{var e;if(q){const t=Array.from(oe),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;pt(s,!0)}}),[q]),s.useEffect((()=>{if(!We.current||!E)return;const e=new ResizeObserver((e=>{for(const t of e)E(t.contentRect.height)}));return e.observe(We.current),()=>{e.disconnect()}}),[E]),s.useEffect((()=>{if(!ze)return;const e=He.current?`${He.current} `:"";Ae(`${e}${$e}`)}),[$e,ze]),s.useEffect((()=>{if(!Le.current)return;(()=>{if(!Le.current)return;let e=Le.current.scrollHeight>52;Ie.includes("\n")||pe.length?e=!0:Ie.trim()||(e=!1),Ee(e)})()}),[Ie,pe]),s.useEffect((()=>{const e=Le.current,t=Pe.current;if(!e||!t||_e||Ie.includes("\n"))return void De(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,r=document.createElement("span");Object.assign(r.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),r.textContent=Ie,document.body.appendChild(r);const i=r.offsetWidth;r.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;De(i>l)}),[Ie,_e]);const pt=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n;try{if(le||ge)return;const r=pe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),i=r.length>0,o=null!=t?t:Ie;if(!o&&!i)return;fe(""),be(""),de(null),Ae(""),ee(!1),ue("fetching"),je(),ye();const a=null!==(n=null===(e=null==B?void 0:B.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,l=[...s?Array.from(oe.slice(0,oe.length-1)):Array.from(oe),...s?[]:[{id:oe.length+1,role:"user",parts:[{type:"text",content:o,isVisible:!0}],documentIds:a?r:[]}],{id:oe.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];ce(l),ye(),a&&ve([]);const c=(yield qe.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign({origin:L,pickaxeId:P,sessionId:W,senderType:$,value:o},a&&{documentIds:r}),M&&{sender:M}),ne&&{studioSessionToken:ne}),z&&{deploymentId:z}))).body;if(!c)throw new Error("Streaming error");const u=l.length-1,d=new TextDecoder;Fe.current=c.getReader();const f=[];let p="",g=!0,h=!1,m=[...null!=Oe?Oe:[]];const v=b.createParser({onEvent:e=>{var t,s;if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&R){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);t&&t[1]&&s&&s[1]&&n&&n[1]&&(g=!1,R({smitheryId:t[1],serverId:s[1],name:n[1]}))}}else if("object"==typeof e&&null!==e){const t=e;"unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name&&(g=!1,R({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}))}}else if("text-start"===n.type)p="",f.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t}),ce([...l.slice(0,u),Object.assign(Object.assign({},l[l.length-1]),{id:oe.length+1,role:"assistant",parts:f})]);else if("text-delta"===n.type)p+=n.delta,f[f.length-1].content=p,ce([...l.slice(0,u),Object.assign(Object.assign({},l[l.length-1]),{id:oe.length+1,role:"assistant",parts:f})]);else if("text-end"===n.type)p="";else if("reasoning-start"===n.type)p="",f.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s}),ce([...l.slice(0,u),Object.assign(Object.assign({},l[l.length-1]),{id:oe.length+1,role:"assistant",parts:f})]);else if("reasoning-delta"===n.type)p+=n.delta,f[f.length-1].content=p,ce([...l.slice(0,u),Object.assign(Object.assign({},l[l.length-1]),{id:oe.length+1,role:"assistant",parts:f})]);else if("reasoning-end"===n.type)p="";else if(n.type.startsWith("data-")){const e=n;f.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0}),ce([...l.slice(0,u),Object.assign(Object.assign({},l[l.length-1]),{id:oe.length+1,role:"assistant",parts:f})])}}else if("artifact_created"===e.event){const t=JSON.parse(e.data);m=m.filter((e=>!(e.id===t.id&&e.version===t.version))),m.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),we(m),ke.startsWith("inline")||Se({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);m=m.filter((e=>!(e.id===t.id&&e.version===t.version))),m.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),we(m),ke.startsWith("inline")||Se({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);m=m.filter((e=>!(e.id===t.id&&e.version===t.version))),m.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),we(m),ke.startsWith("inline")||Se({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");m=m.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),we(m)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);we(m.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);fe(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(g=!1)}});for(;g&&Fe.current;){const{value:e,done:t}=yield Fe.current.read();if(t){g=!1;break}const s=d.decode(e);s&&(h||(ue("streaming"),h=!0),v.feed(s))}null==se||se(W)}catch(e){if("AbortError"===e.name)return;let t=C.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(ae).find((([e])=>t.includes(e)));s?de(s[1]):fe(t)}finally{ye(),ue("idle"),xe(),Fe.current=null}}));return ct?null:t.jsx("div",Object.assign({className:N.default("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!lt&&"px-4 pb-8"),dir:Y?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:We,className:N.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===V.formFieldStyle&&"shadow"),style:Object.assign(Object.assign(Object.assign({},it),st&&{backgroundColor:"#EEEEEE"}),{maxHeight:`${Me}px`,overflowY:"auto"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),nt(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),nt(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),nt(!0)},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),nt(!1);const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(ee(!1),yield me(e))}))},{children:[ze&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(H=U.accent)&&void 0!==H?H:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:U.text+"90"}},{children:"Listening..."}))]})),!le&&pe.length>0&&t.jsx(k.default,{className:"p-4 pb-0",isDisabled:le}),t.jsx(w.default,Object.assign({ref:Le,className:N.default(rt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ie.trim()&&!Ie.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Y?"text-right":"text-left",ut&&"mb-12",ze&&"text-transparent"),value:Ie,placeholder:null!==(F=null==B?void 0:B.placeholdertext)&&void 0!==F?F:Y?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if(Ae(e),E){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void E(0);if(t>=11)return;let s=0;t>1&&(s=50),E(24*(t-1)+s)}},onKeyDown:e=>{K||Ve||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ge||le||pt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),ee(!1),yield me(e))}))},A&&{onFocus:A},_&&{onBlur:_},{dir:Y?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Pe,className:N.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",ut?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!ut&&it.backgroundColor&&{backgroundColor:it.backgroundColor}),{borderTopRightRadius:V.cornerRadius+"px",borderBottomRightRadius:V.cornerRadius+"px"})},{children:le?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Fe.current&&(Fe.current.cancel(),Fe.current=null),ue("idle")},style:{backgroundColor:U.accent,color:U.accentText}},{children:t.jsx(O.default,{className:"h-4 w-4 shrink-0"})})):ze?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:I.default.stopListening,style:{backgroundColor:U.accent,color:U.accentText}},{children:t.jsx(O.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[ot&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ye?U.accent+"10":void 0,color:Ye?U.accent:U.accent+"80"},disabled:ge||le,onClick:()=>{var e;return null===(e=Te.current)||void 0===e?void 0:e.click()}},Xe,{children:[t.jsx("input",{id:"file-upload",ref:Te,type:"file",accept:[...v.allowedFileMimeTypes,...v.allowedImageMimeTypes,...v.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){ee(!1),yield me(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(j.default,{className:"h-6 w-6 shrink-0"})]})),at&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:ze?U.accent:et?U.accent+"10":void 0,color:ze?U.accentText:et?U.accent:U.accent+"80"},disabled:ge||le,onClick:()=>{ze?I.default.stopListening():(He.current=Ie,Je(),I.default.startListening({continuous:!0,interimResults:!0,language:G||"en-US"}))}},tt,{children:t.jsx(y.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ge||ft?U.accent:U.accent+"10",color:Ge||ft?U.accentText:U.accent+"80"},disabled:!ft,onClick:()=>pt()},Ke,{children:t.jsx(x.default,{className:N.default("h-6 w-6 shrink-0",Y&&"scale-x-[-1] transform")})}))]})}))]})),he&&t.jsx(S.default,{error:he,className:"mt-3"})]}))}))}));A.displayName="Input",exports.default=A;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),c=require("../../../hooks/pickaxe/useDimensionContext.js"),u=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),g=require("../../../hooks/core/useHover.js"),h=require("../../../hooks/core/useMediaQuery.js"),m=require("../../../common/documents.js"),v=require("eventsource-parser"),b=require("../../Icons/attach-vertical.svg.js"),y=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),S=require("../../Core/Textarea.js"),O=require("../../Core/ErrorAlert.js"),k=require("../../../common/error.js"),C=require("../../../common/cn.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var _=N(n);const I=s.forwardRef((({resubmitPrompt:N,onFocus:I,onBlur:E,onInputHeightChange:A,initSmitheryAuthData:T},q)=>{var R,P,D;const{origin:L,pickaxeId:H,sessionId:F,sender:M,senderType:$,deploymentId:W,deploymentType:B,pickaxe:J,styles:U,colors:z,locale:K,forceMobile:X,isNewChat:V,isRtl:G,isEmailLogin:Q,isShowFeedbackMessage:Y,setIsNewChat:Z,setIsShowIceBreaker:ee,onGenerateComplete:te}=r.usePickaxeContext(),{token:se,isLoggedOut:ne,isSent:re}=u.useAuthContext(),{messages:ie,limits:oe,isGenerating:ae,setMessages:le,setStatus:ce,setLimitData:ue,setError:de}=i.useResponseContext(),{documents:fe,isUploading:pe,documentError:ge,onFileUpload:he,setDocuments:me,setDocumentError:ve}=d.useDocument(),{scrollStartSession:be,scrollEndSession:ye,scrollToBottom:xe}=f.useScroll({auto:!0}),{artifacts:je,currentPopupType:we,setArtifacts:Se,setCurrentArtifact:Oe}=p.useArtifactContext(),{height:ke}=c.useDimensionContext(),Ce=l.useConversation(),[Ne,_e]=s.useState(""),[Ie,Ee]=s.useState(!1),[Ae,Te]=s.useState(!1),qe=s.useRef(null),Re=s.useRef(""),Pe=s.useRef(null),De=s.useRef(null),Le=s.useRef(null),He=s.useRef(null),Fe=s.useRef(null),Me=Math.max(.2*ke,100),{transcript:$e,listening:We,resetTranscript:Be,browserSupportsSpeechRecognition:Je}=n.useSpeechRecognition(),[Ue]=h.useMediaQuery("(max-width: 480px)"),ze=g.useHover(),{isHover:Ke}=ze,Xe=e.__rest(ze,["isHover"]),Ve=g.useHover(),{isHover:Ge}=Ve,Qe=e.__rest(Ve,["isHover"]),Ye=g.useHover(),{isHover:Ze}=Ye,et=e.__rest(Ye,["isHover"]),[tt,st]=s.useState(!1),nt=a.useStyleFontSize(),rt=o.useStyleInput(),it=null===(R=null==J?void 0:J.documentuploadtype)||void 0===R?void 0:R.startsWith("enduserupload"),ot=Je&&(null==J?void 0:J.enablevoicetotext),at="chat-input"===B&&V&&!re,lt="chat-input"===B&&Q&&ne&&re,ct=Ie||Ae,ut=s.useMemo((()=>{var e,t,s;return!!V&&(!!J&&(!Ce.isLoading&&(!((null!==(t=null===(e=Ce.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=J.icebreakers)||void 0===s?void 0:s.length)&&(!Y&&!at)))))}),[J,V,Y,at,Ce.data,Ce.isLoading]),dt=s.useMemo((()=>{if(ae||pe)return!1;const e=fe.length>0&&fe.every((e=>"finished"===e.status));return!(!Ne.trim()&&!e)&&fe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ae,pe,Ne,fe]);s.useImperativeHandle(q,(()=>({onSubmit:ft}))),s.useEffect((()=>{ee(ut)}),[ut]),s.useEffect((()=>{var e;if(N){const t=Array.from(ie),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;ft(s,!0)}}),[N]),s.useEffect((()=>{if(!He.current||!A)return;const e=new ResizeObserver((e=>{for(const t of e)A(t.contentRect.height)}));return e.observe(He.current),()=>{e.disconnect()}}),[A]),s.useEffect((()=>{if(!We)return;const e=Re.current?`${Re.current} `:"";_e(`${e}${$e}`)}),[$e,We]),s.useEffect((()=>{if(!De.current)return;(()=>{if(!De.current)return;let e=De.current.scrollHeight>52;Ne.includes("\n")||fe.length?e=!0:Ne.trim()||(e=!1),Ee(e)})()}),[Ne,fe]),s.useEffect((()=>{const e=De.current,t=Le.current;if(!e||!t||Ie||Ne.includes("\n"))return void Te(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,r=document.createElement("span");Object.assign(r.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),r.textContent=Ne,document.body.appendChild(r);const i=r.offsetWidth;r.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;Te(i>l)}),[Ne,Ie]);const ft=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,r;try{if(ae||pe)return;const i=fe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),o=i.length>0,a=null!=t?t:Ne;if(!a&&!o)return;de(""),ve(""),ue(null),_e(""),Z(!1),ce("fetching"),be(),xe();const l=null!==(n=null===(e=null==J?void 0:J.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&i.length>0,c=[...s?Array.from(ie.slice(0,ie.length-1)):Array.from(ie),...s?[]:[{id:ie.length+1,role:"user",parts:[{type:"text",content:a,isVisible:!0}],documentIds:l?i:[]}],{id:ie.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];le(c),xe(),l&&me([]);const u=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({origin:L,pickaxeId:H,sessionId:F,senderType:$,value:a},l&&{documentIds:i}),M&&{sender:M}),se&&{studioSessionToken:se}),W&&{deploymentId:W}))}),d=yield u.json();if(console.log("SubmitData: ",d),!d.success)throw new Error(d.error||"Failed to start generation");const f=d.submissionId;ce("streaming"),Fe.current=new AbortController;const p=c.length-1,g=[];let h=[...null!=je?je:[]],m=0,b=!1,y="";for(;!b;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${f}?index=${m}`,{signal:null===(r=Fe.current)||void 0===r?void 0:r.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Pe.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&m++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);return de(t.error||"Something went wrong."),void(b=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&T){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw b=!0,T({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw b=!0,T({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)y="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)y+=n.delta,g[g.length-1].content=y;else if("text-end"===n.type)y="";else if("reasoning-start"===n.type)y="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)y+=n.delta,g[g.length-1].content=y;else if("reasoning-end"===n.type)y="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}le([...c.slice(0,p),Object.assign(Object.assign({},c[c.length-1]),{id:ie.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);h=h.filter((e=>!(e.id===t.id&&e.version===t.version))),h.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Se([...h]),we.startsWith("inline")||Oe({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);h=h.filter((e=>!(e.id===t.id&&e.version===t.version))),h.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Se(h),we.startsWith("inline")||Oe({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);h=h.filter((e=>!(e.id===t.id&&e.version===t.version))),h.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Se(h),we.startsWith("inline")||Oe({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");h=h.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Se(h)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Se(h.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);de(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(b=!0)}else b=!0}});for(;;){const{value:e,done:r}=yield t.read();if(r)break;n.feed(s.decode(e))}b||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(b=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==te||te(F)}catch(e){let t=k.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(oe).find((([e])=>t.includes(e)));s?ue(s[1]):de(t)}finally{xe(),ce("idle"),ye(),Pe.current=null}}));return lt?null:t.jsx("div",Object.assign({className:C.default("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!at&&"px-4 pb-8"),dir:G?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:He,className:C.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===U.formFieldStyle&&"shadow"),style:Object.assign(Object.assign(Object.assign({},rt),tt&&{backgroundColor:"#EEEEEE"}),{maxHeight:`${Me}px`,overflowY:"auto"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),st(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),st(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),st(!0)},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),st(!1);const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(Z(!1),yield he(e))}))},{children:[We&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(P=z.accent)&&void 0!==P?P:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:z.text+"90"}},{children:"Listening..."}))]})),!ae&&fe.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:ae}),t.jsx(S.default,Object.assign({ref:De,className:C.default(nt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ne.trim()&&!Ne.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",G?"text-right":"text-left",ct&&"mb-12",We&&"text-transparent"),value:Ne,placeholder:null!==(D=null==J?void 0:J.placeholdertext)&&void 0!==D?D:G?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if(_e(e),A){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void A(0);if(t>=11)return;let s=0;t>1&&(s=50),A(24*(t-1)+s)}},onKeyDown:e=>{X||Ue||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),pe||ae||ft()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),Z(!1),yield he(e))}))},I&&{onFocus:I},E&&{onBlur:E},{dir:G?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Le,className:C.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",ct?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!ct&&rt.backgroundColor&&{backgroundColor:rt.backgroundColor}),{borderTopRightRadius:U.cornerRadius+"px",borderBottomRightRadius:U.cornerRadius+"px"})},{children:ae?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Fe.current&&(Fe.current.abort(),Fe.current=null),Pe.current&&(Pe.current.cancel(),Pe.current=null),ce("idle")},style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):We?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:_.default.stopListening,style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[it&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ge?z.accent+"10":void 0,color:Ge?z.accent:z.accent+"80"},disabled:pe||ae,onClick:()=>{var e;return null===(e=qe.current)||void 0===e?void 0:e.click()}},Qe,{children:[t.jsx("input",{id:"file-upload",ref:qe,type:"file",accept:[...m.allowedFileMimeTypes,...m.allowedImageMimeTypes,...m.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Z(!1),yield he(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),ot&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:We?z.accent:Ze?z.accent+"10":void 0,color:We?z.accentText:Ze?z.accent:z.accent+"80"},disabled:pe||ae,onClick:()=>{We?_.default.stopListening():(Re.current=Ne,Be(),_.default.startListening({continuous:!0,interimResults:!0,language:K||"en-US"}))}},et,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ke||dt?z.accent:z.accent+"10",color:Ke||dt?z.accentText:z.accent+"80"},disabled:!dt,onClick:()=>ft()},Xe,{children:t.jsx(y.default,{className:C.default("h-6 w-6 shrink-0",G&&"scale-x-[-1] transform")})}))]})}))]})),ge&&t.jsx(O.default,{error:ge,className:"mt-3"})]}))}))}));I.displayName="Input",exports.default=I;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),a=require("../../../../hooks/pickaxe/useSubmit.js"),r=require("../../Addons/Document/hooks/useDocument.js"),l=require("../../Addons/Scroll/hooks/useScroll.js"),d=require("../../Addons/Artifact/hooks/useArtifactContext.js"),c=require("../../../../common/utils.js"),u=require("@nem035/gpt-3-encoder"),p=require("eventsource-parser"),g=require("../../common/PickaxeBranding.js"),m=require("../../common/PickaxeButton.js"),b=require("../../../../common/error.js");exports.default=({questions:f,resetQuestions:h})=>{var j;const{origin:v,pickaxeId:O,sender:x,senderType:y,deploymentId:q,pickaxe:k,misc:w,translations:S,isRtl:C,setSessionId:I,setIsNewChat:P,onGenerateComplete:A}=n.usePickaxeContext(),{token:N}=i.useAuthContext(),{limits:_,isGenerating:D,setResponse:T,setMessages:E,setStatus:J,setLimitData:W,setError:R,setIsSwitchedToChat:U}=o.useResponseContext(),{documents:L,websiteLink:V,isUploading:B,onWebsiteUpload:M,setDocuments:G,setDocumentError:K}=r.useDocument(),{scrollStartSession:F,scrollEndSession:Q,scrollToTarget:X}=l.useScroll({auto:!(null==k?void 0:k.enablechatresponses)}),{artifacts:Y,currentPopupType:z,setArtifacts:H,setCurrentArtifact:Z}=d.useArtifactContext(),$=a.useSubmit(),[ee,se]=t.useState(!1),te=t.useMemo((()=>f.some((e=>!("Short Answer"!==e.type&&"Long Answer"!==e.type&&"long"!==e.type&&"short"!==e.type&&"Checkbox"!==e.type&&"Knowledge Upload"!==e.type&&!e.id.includes("documentupload")||!(e.input.length>0))))),[f]);return s.jsxs("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:C?"rtl":"ltr"},{children:[s.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[s.jsx(m.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:B||D||ee,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;try{if(D||B||ee)return;R(""),K(""),W(null),T(null);const t=["Multiple Choice","Checkbox"];for(const e of f){if(u.encode(e.input).length>e.maxLength&&!t.includes(e.type))throw new Error("One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error("You must fill out all required fields.")}const n=L.filter((e=>"finished"===e.status)),i=L.map((e=>e.name)),o=null!==(s=null===(e=null==k?void 0:k.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==s&&s,a=f.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),r=c.extractUrlsFromText(V).filter((e=>!i.includes(e)));if(r.length){const e=r[r.length-1];se(!0);const s=yield M(e);s&&(n.push(s),yield new Promise((e=>setTimeout(e,5e3)))),se(!1)}else if(a&&o&&!n.length)return void K("Please paste a valid website/video link or drag a file to add to the knowledge base.");const l=n.map((e=>e.documentId)).filter(Boolean),d=o&&l.length>0;let g={};f.forEach((e=>g=Object.assign(Object.assign({},g),{[e.id]:"Knowledge Upload"===e.type||e.id.includes("documentupload")?n.map((e=>e.name)).join(",")||"":e.input}))),J("fetching"),F(),X();const m=yield $.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign({origin:v,pickaxeId:O,senderType:y,valueObj:g},d&&{documentIds:l}),x&&{sender:x}),N&&{studioSessionToken:N}),q&&{deploymentId:q})),b=m.body;if(!b)throw new Error("Streaming error");const h=m.headers.get("X-Pickaxe-Session-Id");if(!h)throw new Error("Post SessionId not found");const j={sessionId:h,documentIds:d?l:[],question:{inputs:f.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[{type:"text",content:"",isVisible:!0}]},messageCount:0,sentAt:new Date};T(j);let w=[];(null==k?void 0:k.enablechatresponses)&&(w=[{id:0,role:"assistant",parts:[],documentIds:[]}],E(w));const S=new TextDecoder,C=b.getReader(),_=[];let Q="",te=!0,ne=!1,ie=[...null!=Y?Y:[]];const oe=p.createParser({onEvent:e=>{var s,t;if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)Q="",_.push({type:"text",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s}),T(Object.assign(Object.assign({},j),{question:Object.assign(Object.assign({},j.question),{responseParts:_})})),(null==k?void 0:k.enablechatresponses)&&E([{id:0,role:"assistant",parts:_,documentIds:[]}]);else if("text-delta"===n.type)Q+=n.delta,_[_.length-1].content=Q,T(Object.assign(Object.assign({},j),{question:Object.assign(Object.assign({},j.question),{responseParts:_})})),(null==k?void 0:k.enablechatresponses)&&E([{id:0,role:"assistant",parts:_,documentIds:[]}]);else if("text-end"===n.type)Q="";else if("reasoning-start"===n.type)Q="",_.push({type:"reasoning",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t}),T(Object.assign(Object.assign({},j),{question:Object.assign(Object.assign({},j.question),{responseParts:_})})),(null==k?void 0:k.enablechatresponses)&&E([{id:0,role:"assistant",parts:_,documentIds:[]}]);else if("reasoning-delta"===n.type)Q+=n.delta,_[_.length-1].content=Q,T(Object.assign(Object.assign({},j),{question:Object.assign(Object.assign({},j.question),{responseParts:_})})),(null==k?void 0:k.enablechatresponses)&&E([{id:0,role:"assistant",parts:_,documentIds:[]}]);else if("reasoning-end"===n.type)Q="";else if(n.type.startsWith("data-")){const e=n;_.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0}),T(Object.assign(Object.assign({},j),{question:Object.assign(Object.assign({},j.question),{responseParts:_})})),(null==k?void 0:k.enablechatresponses)&&E([{id:0,role:"assistant",parts:_,documentIds:[]}])}}else if("artifact_created"===e.event){const s=JSON.parse(e.data);ie=ie.filter((e=>!(e.id===s.id&&e.version===s.version))),ie.push(Object.assign(Object.assign({},s),{content:"",status:"streaming"})),H(ie),z.startsWith("inline")||Z({id:s.id,version:s.version})}else if("artifact_updated"===e.event){const s=JSON.parse(e.data);ie=ie.filter((e=>!(e.id===s.id&&e.version===s.version))),ie.push(Object.assign(Object.assign({},s),{content:"",status:"updating"})),H(ie),z.startsWith("inline")||Z({id:s.id,version:s.version})}else if("artifact_rewrite"===e.event){const s=JSON.parse(e.data);ie=ie.filter((e=>!(e.id===s.id&&e.version===s.version))),ie.push(Object.assign(Object.assign({},s),{content:"",status:"streaming"})),H(ie),z.startsWith("inline")||Z({id:s.id,version:s.version})}else if("artifact_content"===e.event){const s=JSON.parse(e.data),t=s.token.replace(/\u200B/g,"");ie=ie.map((e=>e.id===s.id&&e.version===s.version?Object.assign(Object.assign({},e),{content:e.content+t,status:"streaming"}):e)),H(ie)}else if("artifact_finished"===e.event){const s=JSON.parse(e.data);H(ie.map((e=>e.id===s.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const s=JSON.parse(e.data);R(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(te=!1)}});for(;te;){const{value:e,done:s}=yield C.read();if(s){te=!1;break}const t=S.decode(e);t&&(ne||(J("streaming"),ne=!0,d&&G([]),(null==k?void 0:k.enablechatresponses)&&(I(h),P(!1),U(!0))),oe.feed(t))}null==A||A(h)}catch(e){let s=b.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?W(t[1]):R(s),X()}finally{J("idle"),se(!1),Q()}}))},{children:ee?(null==S?void 0:S.processing)||"Processing...":B?(null==S?void 0:S.uploading)||"Uploading...":D?(null==S?void 0:S.loading)||"Loading...":null!==(j=null==k?void 0:k.submittext)&&void 0!==j?j:"Submit"})),te&&s.jsx(m.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:B||D||ee,onClick:h},{children:(null==S?void 0:S["clear-form"])||"Clear form"}))]})),!w.isWhiteLabel&&s.jsx(g.default,{containerClassName:"justify-end"})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Scroll/hooks/useScroll.js"),l=require("../../Addons/Artifact/hooks/useArtifactContext.js"),d=require("../../../../common/utils.js"),c=require("@nem035/gpt-3-encoder"),u=require("eventsource-parser"),p=require("../../common/PickaxeBranding.js"),m=require("../../common/PickaxeButton.js"),g=require("../../../../common/error.js");exports.default=({questions:f,resetQuestions:h})=>{var v;const{origin:b,pickaxeId:x,sender:y,senderType:j,deploymentId:O,pickaxe:w,misc:C,translations:S,isRtl:k,setSessionId:I,setIsNewChat:_,onGenerateComplete:P}=n.usePickaxeContext(),{token:A}=i.useAuthContext(),{limits:N,isGenerating:q,setResponse:E,setMessages:T,setStatus:U,setLimitData:L,setError:D,setIsSwitchedToChat:R}=o.useResponseContext(),{documents:J,websiteLink:B,isUploading:K,onWebsiteUpload:W,setDocuments:X,setDocumentError:V}=r.useDocument(),{scrollStartSession:M,scrollEndSession:$,scrollToTarget:F}=a.useScroll({auto:!(null==w?void 0:w.enablechatresponses)}),{artifacts:G,currentPopupType:Q,setArtifacts:Y,setCurrentArtifact:z}=l.useArtifactContext(),[H,Z]=s.useState(!1),ee=s.useRef(null),te=s.useMemo((()=>f.some((e=>("Short Answer"===e.type||"Long Answer"===e.type||"long"===e.type||"short"===e.type||"Checkbox"===e.type||"Knowledge Upload"===e.type||e.id.includes("documentupload"))&&e.input.length>0))),[f]);return t.jsxs("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:k?"rtl":"ltr"},{children:[t.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[t.jsx(m.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:K||q||H,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,s;try{if(q||K||H)return;D(""),V(""),L(null),E(null);const n=["Multiple Choice","Checkbox"];for(const e of f){if(c.encode(e.input).length>e.maxLength&&!n.includes(e.type))throw new Error("One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error("You must fill out all required fields.")}const i=J.filter((e=>"finished"===e.status)),o=J.map((e=>e.name)),r=null!==(t=null===(e=null==w?void 0:w.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==t&&t,a=f.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),l=d.extractUrlsFromText(B).filter((e=>!o.includes(e)));if(l.length){const e=l[l.length-1];Z(!0);const t=yield W(e);t&&(i.push(t),yield new Promise((e=>setTimeout(e,5e3)))),Z(!1)}else if(a&&r&&!i.length)return void V("Please paste a valid website/video link or drag a file to add to the knowledge base.");const p=i.map((e=>e.documentId)).filter(Boolean),m=r&&p.length>0;let g={};f.forEach((e=>{g[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?i.map((e=>e.name)).join(",")||"":e.input})),U("fetching"),M(),F();const h=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({origin:b,pickaxeId:x,senderType:j,valueObj:g},m&&{documentIds:p}),y&&{sender:y}),A&&{studioSessionToken:A}),O&&{deploymentId:O}))}),v=yield h.json();if(!v.success)throw new Error(v.error||"Failed to start generation");const C=v.submissionId,S=v.sessionId,k={sessionId:S,documentIds:m?p:[],question:{inputs:f.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};E(k),(null==w?void 0:w.enablechatresponses)&&(I(S),_(!1),R(!0),T([{id:0,role:"assistant",parts:[],documentIds:[]}])),m&&X([]),U("streaming"),ee.current=new AbortController;const N=[];let $=[...null!=G?G:[]],te=0,se=!1,ne="";for(;!se;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${C}?index=${te}`,{signal:null===(s=ee.current)||void 0===s?void 0:s.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),n=new TextDecoder,i=u.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&te++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);return D(t.error||"Something went wrong."),void(se=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)ne="",N.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)ne+=n.delta,N[N.length-1].content=ne;else if("text-end"===n.type)ne="";else if("reasoning-start"===n.type)ne="",N.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)ne+=n.delta,N[N.length-1].content=ne;else if("reasoning-end"===n.type)ne="";else if(n.type.startsWith("data-")){const e=n;N.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},k),{question:Object.assign(Object.assign({},k.question),{responseParts:[...N]})});E(i),(null==w?void 0:w.enablechatresponses)&&T([{id:0,role:"assistant",parts:[...N],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);$=$.filter((e=>!(e.id===t.id&&e.version===t.version))),$.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Y([...$]),Q.startsWith("inline")||z({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);$=$.filter((e=>!(e.id===t.id&&e.version===t.version))),$.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Y([...$]),Q.startsWith("inline")||z({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);$=$.filter((e=>!(e.id===t.id&&e.version===t.version))),$.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Y([...$]),Q.startsWith("inline")||z({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");$=$.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Y([...$])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Y($.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else se=!0}});for(;;){const{value:e,done:s}=yield t.read();if(s)break;i.feed(n.decode(e))}se||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("AbortError"===e.name)return void(se=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==P||P(S)}catch(e){let t=g.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(N).find((([e])=>t.includes(e)));s?L(s[1]):D(t),F()}finally{U("idle"),Z(!1),$()}}))},{children:H?(null==S?void 0:S.processing)||"Processing...":K?(null==S?void 0:S.uploading)||"Uploading...":q?(null==S?void 0:S.loading)||"Loading...":null!==(v=null==w?void 0:w.submittext)&&void 0!==v?v:"Submit"})),te&&t.jsx(m.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:K||q||H,onClick:h},{children:(null==S?void 0:S["clear-form"])||"Clear form"}))]})),!C.isWhiteLabel&&t.jsx(p.default,{containerClassName:"justify-end"})]}))};
@@ -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"),i=require("../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),r=require("./PickaxeIcon.js"),l=require("./PickaxeHistoryButton.js"),n=require("./PickaxeLogoutButton.js"),c=require("../../../common/cn.js");exports.default=({className:u,iconClassName:a,historyBtnTip:d,showHistory:x,onIconClick:p,onHistoryClick:j})=>{const{deploymentType:h,pickaxe:m,misc:f,colors:k,translations:g}=t.usePickaxeContext(),{isLoggedIn:y}=i.useAuthContext(),v=o.useStyleFontSize(),b=s.useMemo((()=>({title:(null==m?void 0:m.formtitle)||"",description:(null==m?void 0:m.formdescription)||""})),[m]);return f.isTitle||f.isDescription||!f.isWhiteLabel?e.jsxs("div",Object.assign({className:c.default("flex min-h-[56px] items-center justify-between gap-4 px-4",u),style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-4"},{children:[f.isProfileImage&&e.jsx(r.default,Object.assign({src:null==m?void 0:m.coverphoto,alt:`${null==m?void 0:m.formtitle}'s Profile Picture`,width:32,height:32,className:c.default("h-[32px] w-[32px] shrink-0 rounded-full",a,!!p&&"cursor-pointer")},p&&{onClick:p})),f.isTitle&&e.jsx("p",Object.assign({className:c.default(v.b1)},{children:b.title}))]})),!!j&&e.jsxs("div",Object.assign({className:c.default("popup"===h&&"pr-12","flex")},{children:[e.jsx(l.default,{tip:d,onClick:j}),y&&x&&e.jsx(n.default,{tip:(null==g?void 0:g["log-out"])||"Log Out"})]}))]})):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"),i=require("../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),r=require("./PickaxeIcon.js"),l=require("./PickaxeHistoryButton.js"),n=require("./PickaxeLogoutButton.js"),c=require("../../../common/cn.js");exports.default=({className:u,iconClassName:a,historyBtnTip:d,onIconClick:x,onHistoryClick:p})=>{const{deploymentType:j,pickaxe:m,misc:f,colors:h,translations:k}=t.usePickaxeContext(),{isLoggedIn:g}=i.useAuthContext(),y=o.useStyleFontSize(),v=s.useMemo((()=>({title:(null==m?void 0:m.formtitle)||"",description:(null==m?void 0:m.formdescription)||""})),[m]);return f.isTitle||f.isDescription||!f.isWhiteLabel?e.jsxs("div",Object.assign({className:c.default("flex min-h-[56px] items-center justify-between gap-4 px-4",u),style:{backgroundColor:h.secondary,color:h.secondaryText}},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-4"},{children:[f.isProfileImage&&e.jsx(r.default,Object.assign({src:null==m?void 0:m.coverphoto,alt:`${null==m?void 0:m.formtitle}'s Profile Picture`,width:32,height:32,className:c.default("h-[32px] w-[32px] shrink-0 rounded-full",a,!!x&&"cursor-pointer")},x&&{onClick:x})),f.isTitle&&e.jsx("p",Object.assign({className:c.default(y.b1)},{children:v.title}))]})),!!p&&e.jsxs("div",Object.assign({className:c.default("popup"===j&&"pr-12","flex")},{children:[e.jsx(l.default,{tip:d,onClick:p}),g&&e.jsx(n.default,{tip:(null==k?void 0:k["log-out"])||"Log Out"})]}))]})):null};
@@ -2,9 +2,8 @@ interface PickaxeEmbedHeadProps {
2
2
  className?: string;
3
3
  iconClassName?: string;
4
4
  historyBtnTip?: string;
5
- showHistory?: boolean;
6
5
  onIconClick?: () => void;
7
6
  onHistoryClick?: () => void;
8
7
  }
9
- declare const PickaxeEmbedHead: ({ className, iconClassName, historyBtnTip, showHistory, onIconClick, onHistoryClick, }: PickaxeEmbedHeadProps) => import("react/jsx-runtime").JSX.Element | null;
8
+ declare const PickaxeEmbedHead: ({ className, iconClassName, historyBtnTip, onIconClick, onHistoryClick, }: PickaxeEmbedHeadProps) => import("react/jsx-runtime").JSX.Element | null;
10
9
  export default PickaxeEmbedHead;
@@ -1 +1 @@
1
- import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as n,Fragment as o}from"react/jsx-runtime";import{forwardRef as i,useState as r,useRef as a,useMemo as l,useImperativeHandle as c,useEffect as d}from"react";import"../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import u,{useSpeechRecognition as m}from"react-speech-recognition";import{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as f}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as g}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as h}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as v}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as b}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as y}from"../Addons/Auth/hooks/useAuthContext.js";import{useSubmit as j}from"../../../hooks/pickaxe/useSubmit.js";import{useDocument as x}from"../Addons/Document/hooks/useDocument.js";import{useScroll as O}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as k}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as w}from"../../../hooks/core/useHover.js";import{useMediaQuery as S}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as N,allowedImageMimeTypes as C,additionalAllowedFileExtensions as I}from"../../../common/documents.js";import{createParser as A}from"eventsource-parser";import D from"../../Icons/attach-vertical.svg.js";import E from"../../Icons/arrow-right.svg.js";import R from"../../Icons/microphone.svg.js";import T from"../../Icons/stop.svg.js";import L from"../Addons/Document/List.js";import W from"../../Core/Textarea.js";import H from"../../Core/ErrorAlert.js";import _ from"../../../common/error.js";import $ from"../../../common/cn.js";const F=i((({resubmitPrompt:i,onFocus:F,onBlur:P,onInputHeightChange:J,initSmitheryAuthData:z},B)=>{var V,M,U;const{origin:q,pickaxeId:G,sessionId:K,sender:Q,senderType:Y,deploymentId:X,deploymentType:Z,pickaxe:ee,styles:te,colors:se,locale:ne,forceMobile:oe,isNewChat:ie,isRtl:re,isEmailLogin:ae,isShowFeedbackMessage:le,setIsNewChat:ce,setIsShowIceBreaker:de,onGenerateComplete:ue}=p(),{token:me,isLoggedOut:pe,isSent:fe}=y(),{messages:ge,limits:he,isGenerating:ve,setMessages:be,setStatus:ye,setLimitData:je,setError:xe}=f(),{documents:Oe,isUploading:ke,documentError:we,onFileUpload:Se,setDocuments:Ne,setDocumentError:Ce}=x(),{scrollStartSession:Ie,scrollEndSession:Ae,scrollToBottom:De}=O({auto:!0}),{artifacts:Ee,currentPopupType:Re,setArtifacts:Te,setCurrentArtifact:Le}=k(),{height:We}=b(),He=v(),_e=j(),[$e,Fe]=r(""),[Pe,Je]=r(!1),[ze,Be]=r(!1),Ve=a(null),Me=a(""),Ue=a(null),qe=a(null),Ge=a(null),Ke=a(null),Qe=Math.max(.2*We,100),{transcript:Ye,listening:Xe,resetTranscript:Ze,browserSupportsSpeechRecognition:et}=m(),[tt]=S("(max-width: 480px)"),st=w(),{isHover:nt}=st,ot=e(st,["isHover"]),it=w(),{isHover:rt}=it,at=e(it,["isHover"]),lt=w(),{isHover:ct}=lt,dt=e(lt,["isHover"]),[ut,mt]=r(!1),pt=h(),ft=g(),gt=null===(V=null==ee?void 0:ee.documentuploadtype)||void 0===V?void 0:V.startsWith("enduserupload"),ht=et&&(null==ee?void 0:ee.enablevoicetotext),vt="chat-input"===Z&&ie&&!fe,bt="chat-input"===Z&&ae&&pe&&fe,yt=Pe||ze,jt=l((()=>{var e,t,s;return!!ie&&(!!ee&&(!He.isLoading&&(!((null!==(t=null===(e=He.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=ee.icebreakers)||void 0===s?void 0:s.length)&&(!le&&!vt)))))}),[ee,ie,le,vt,He.data,He.isLoading]),xt=l((()=>{if(ve||ke)return!1;const e=Oe.length>0&&Oe.every((e=>"finished"===e.status));return!(!$e.trim()&&!e)&&Oe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ve,ke,$e,Oe]);c(B,(()=>({onSubmit:Ot}))),d((()=>{de(jt)}),[jt]),d((()=>{var e;if(i){const t=Array.from(ge),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Ot(s,!0)}}),[i]),d((()=>{if(!Ke.current||!J)return;const e=new ResizeObserver((e=>{for(const t of e)J(t.contentRect.height)}));return e.observe(Ke.current),()=>{e.disconnect()}}),[J]),d((()=>{if(!Xe)return;const e=Me.current?`${Me.current} `:"";Fe(`${e}${Ye}`)}),[Ye,Xe]),d((()=>{if(!qe.current)return;(()=>{if(!qe.current)return;let e=qe.current.scrollHeight>52;$e.includes("\n")||Oe.length?e=!0:$e.trim()||(e=!1),Je(e)})()}),[$e,Oe]),d((()=>{const e=qe.current,t=Ge.current;if(!e||!t||Pe||$e.includes("\n"))return void Be(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=$e,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Be(i>l)}),[$e,Pe]);const Ot=(e,s=!1)=>t(void 0,void 0,void 0,(function*(){var t,n;try{if(ve||ke)return;const o=Oe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),i=o.length>0,r=null!=e?e:$e;if(!r&&!i)return;xe(""),Ce(""),je(null),Fe(""),ce(!1),ye("fetching"),Ie(),De();const a=null!==(n=null===(t=null==ee?void 0:ee.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==n&&n&&o.length>0,l=[...s?Array.from(ge.slice(0,ge.length-1)):Array.from(ge),...s?[]:[{id:ge.length+1,role:"user",parts:[{type:"text",content:r,isVisible:!0}],documentIds:a?o:[]}],{id:ge.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];be(l),De(),a&&Ne([]);const c=(yield _e.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign({origin:q,pickaxeId:G,sessionId:K,senderType:Y,value:r},a&&{documentIds:o}),Q&&{sender:Q}),me&&{studioSessionToken:me}),X&&{deploymentId:X}))).body;if(!c)throw new Error("Streaming error");const d=l.length-1,u=new TextDecoder;Ue.current=c.getReader();const m=[];let p="",f=!0,g=!1,h=[...null!=Ee?Ee:[]];const v=A({onEvent:e=>{var t,s;if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&z){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);t&&t[1]&&s&&s[1]&&n&&n[1]&&(f=!1,z({smitheryId:t[1],serverId:s[1],name:n[1]}))}}else if("object"==typeof e&&null!==e){const t=e;"unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name&&(f=!1,z({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}))}}else if("text-start"===n.type)p="",m.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t}),be([...l.slice(0,d),Object.assign(Object.assign({},l[l.length-1]),{id:ge.length+1,role:"assistant",parts:m})]);else if("text-delta"===n.type)p+=n.delta,m[m.length-1].content=p,be([...l.slice(0,d),Object.assign(Object.assign({},l[l.length-1]),{id:ge.length+1,role:"assistant",parts:m})]);else if("text-end"===n.type)p="";else if("reasoning-start"===n.type)p="",m.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s}),be([...l.slice(0,d),Object.assign(Object.assign({},l[l.length-1]),{id:ge.length+1,role:"assistant",parts:m})]);else if("reasoning-delta"===n.type)p+=n.delta,m[m.length-1].content=p,be([...l.slice(0,d),Object.assign(Object.assign({},l[l.length-1]),{id:ge.length+1,role:"assistant",parts:m})]);else if("reasoning-end"===n.type)p="";else if(n.type.startsWith("data-")){const e=n;m.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0}),be([...l.slice(0,d),Object.assign(Object.assign({},l[l.length-1]),{id:ge.length+1,role:"assistant",parts:m})])}}else if("artifact_created"===e.event){const t=JSON.parse(e.data);h=h.filter((e=>!(e.id===t.id&&e.version===t.version))),h.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Te(h),Re.startsWith("inline")||Le({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);h=h.filter((e=>!(e.id===t.id&&e.version===t.version))),h.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Te(h),Re.startsWith("inline")||Le({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);h=h.filter((e=>!(e.id===t.id&&e.version===t.version))),h.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Te(h),Re.startsWith("inline")||Le({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");h=h.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Te(h)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Te(h.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);xe(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(f=!1)}});for(;f&&Ue.current;){const{value:e,done:t}=yield Ue.current.read();if(t){f=!1;break}const s=u.decode(e);s&&(g||(ye("streaming"),g=!0),v.feed(s))}null==ue||ue(K)}catch(e){if("AbortError"===e.name)return;let t=_(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(he).find((([e])=>t.includes(e)));s?je(s[1]):xe(t)}finally{De(),ye("idle"),Ae(),Ue.current=null}}));return bt?null:s("div",Object.assign({className:$("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!vt&&"px-4 pb-8"),dir:re?"rtl":"ltr"},{children:n("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[n("div",Object.assign({ref:Ke,className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===te.formFieldStyle&&"shadow"),style:Object.assign(Object.assign(Object.assign({},ft),ut&&{backgroundColor:"#EEEEEE"}),{maxHeight:`${Qe}px`,overflowY:"auto"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),mt(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),mt(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),mt(!0)},onDrop:e=>t(void 0,void 0,void 0,(function*(){e.preventDefault(),e.stopPropagation(),mt(!1);const t=Array.from(e.dataTransfer.files||[]);t.length>0&&(ce(!1),yield Se(t))}))},{children:[Xe&&n("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[s("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(M=se.accent)&&void 0!==M?M:"#ff0000"}}),s("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:se.text+"90"}},{children:"Listening..."}))]})),!ve&&Oe.length>0&&s(L,{className:"p-4 pb-0",isDisabled:ve}),s(W,Object.assign({ref:qe,className:$(pt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!$e.trim()&&!$e.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",re?"text-right":"text-left",yt&&"mb-12",Xe&&"text-transparent"),value:$e,placeholder:null!==(U=null==ee?void 0:ee.placeholdertext)&&void 0!==U?U:re?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if(Fe(e),J){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void J(0);if(t>=11)return;let s=0;t>1&&(s=50),J(24*(t-1)+s)}},onKeyDown:e=>{oe||tt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ke||ve||Ot()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),ce(!1),yield Se(t))}))},F&&{onFocus:F},P&&{onBlur:P},{dir:re?"rtl":"ltr"})),s("div",Object.assign({ref:Ge,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",yt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!yt&&ft.backgroundColor&&{backgroundColor:ft.backgroundColor}),{borderTopRightRadius:te.cornerRadius+"px",borderBottomRightRadius:te.cornerRadius+"px"})},{children:ve?s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Ue.current&&(Ue.current.cancel(),Ue.current=null),ye("idle")},style:{backgroundColor:se.accent,color:se.accentText}},{children:s(T,{className:"h-4 w-4 shrink-0"})})):Xe?s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:u.stopListening,style:{backgroundColor:se.accent,color:se.accentText}},{children:s(T,{className:"h-4 w-4 shrink-0"})})):n(o,{children:[gt&&n("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:rt?se.accent+"10":void 0,color:rt?se.accent:se.accent+"80"},disabled:ke||ve,onClick:()=>{var e;return null===(e=Ve.current)||void 0===e?void 0:e.click()}},at,{children:[s("input",{id:"file-upload",ref:Ve,type:"file",accept:[...N,...C,...I].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){ce(!1),yield Se(Array.from(e.target.files||[])),e.target.value=""}))}),s(D,{className:"h-6 w-6 shrink-0"})]})),ht&&s("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Xe?se.accent:ct?se.accent+"10":void 0,color:Xe?se.accentText:ct?se.accent:se.accent+"80"},disabled:ke||ve,onClick:()=>{Xe?u.stopListening():(Me.current=$e,Ze(),u.startListening({continuous:!0,interimResults:!0,language:ne||"en-US"}))}},dt,{children:s(R,{className:"h-5 w-5 shrink-0"})})),s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:nt||xt?se.accent:se.accent+"10",color:nt||xt?se.accentText:se.accent+"80"},disabled:!xt,onClick:()=>Ot()},ot,{children:s(E,{className:$("h-6 w-6 shrink-0",re&&"scale-x-[-1] transform")})}))]})}))]})),we&&s(H,{error:we,className:"mt-3"})]}))}))}));F.displayName="Input";export{F as default};
1
+ import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as s,Fragment as o}from"react/jsx-runtime";import{forwardRef as r,useState as i,useRef as a,useMemo as l,useImperativeHandle as c,useEffect as d}from"react";import"../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import u,{useSpeechRecognition as m}from"react-speech-recognition";import{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as f}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as g}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as h}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as v}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as b}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as y}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as j}from"../Addons/Document/hooks/useDocument.js";import{useScroll as x}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as O}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as w}from"../../../hooks/core/useHover.js";import{useMediaQuery as k}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as S,allowedImageMimeTypes as C,additionalAllowedFileExtensions as N}from"../../../common/documents.js";import{createParser as I}from"eventsource-parser";import E from"../../Icons/attach-vertical.svg.js";import A from"../../Icons/arrow-right.svg.js";import T from"../../Icons/microphone.svg.js";import _ from"../../Icons/stop.svg.js";import P from"../Addons/Document/List.js";import D from"../../Core/Textarea.js";import R from"../../Core/ErrorAlert.js";import L from"../../../common/error.js";import $ from"../../../common/cn.js";const W=r((({resubmitPrompt:r,onFocus:W,onBlur:B,onInputHeightChange:H,initSmitheryAuthData:F},J)=>{var U,K,M;const{origin:X,pickaxeId:z,sessionId:V,sender:q,senderType:G,deploymentId:Q,deploymentType:Y,pickaxe:Z,styles:ee,colors:te,locale:ne,forceMobile:se,isNewChat:oe,isRtl:re,isEmailLogin:ie,isShowFeedbackMessage:ae,setIsNewChat:le,setIsShowIceBreaker:ce,onGenerateComplete:de}=p(),{token:ue,isLoggedOut:me,isSent:pe}=y(),{messages:fe,limits:ge,isGenerating:he,setMessages:ve,setStatus:be,setLimitData:ye,setError:je}=f(),{documents:xe,isUploading:Oe,documentError:we,onFileUpload:ke,setDocuments:Se,setDocumentError:Ce}=j(),{scrollStartSession:Ne,scrollEndSession:Ie,scrollToBottom:Ee}=x({auto:!0}),{artifacts:Ae,currentPopupType:Te,setArtifacts:_e,setCurrentArtifact:Pe}=O(),{height:De}=b(),Re=v(),[Le,$e]=i(""),[We,Be]=i(!1),[He,Fe]=i(!1),Je=a(null),Ue=a(""),Ke=a(null),Me=a(null),Xe=a(null),ze=a(null),Ve=a(null),qe=Math.max(.2*De,100),{transcript:Ge,listening:Qe,resetTranscript:Ye,browserSupportsSpeechRecognition:Ze}=m(),[et]=k("(max-width: 480px)"),tt=w(),{isHover:nt}=tt,st=e(tt,["isHover"]),ot=w(),{isHover:rt}=ot,it=e(ot,["isHover"]),at=w(),{isHover:lt}=at,ct=e(at,["isHover"]),[dt,ut]=i(!1),mt=h(),pt=g(),ft=null===(U=null==Z?void 0:Z.documentuploadtype)||void 0===U?void 0:U.startsWith("enduserupload"),gt=Ze&&(null==Z?void 0:Z.enablevoicetotext),ht="chat-input"===Y&&oe&&!pe,vt="chat-input"===Y&&ie&&me&&pe,bt=We||He,yt=l((()=>{var e,t,n;return!!oe&&(!!Z&&(!Re.isLoading&&(!((null!==(t=null===(e=Re.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=Z.icebreakers)||void 0===n?void 0:n.length)&&(!ae&&!ht)))))}),[Z,oe,ae,ht,Re.data,Re.isLoading]),jt=l((()=>{if(he||Oe)return!1;const e=xe.length>0&&xe.every((e=>"finished"===e.status));return!(!Le.trim()&&!e)&&xe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[he,Oe,Le,xe]);c(J,(()=>({onSubmit:xt}))),d((()=>{ce(yt)}),[yt]),d((()=>{var e;if(r){const t=Array.from(fe),n=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;xt(n,!0)}}),[r]),d((()=>{if(!ze.current||!H)return;const e=new ResizeObserver((e=>{for(const t of e)H(t.contentRect.height)}));return e.observe(ze.current),()=>{e.disconnect()}}),[H]),d((()=>{if(!Qe)return;const e=Ue.current?`${Ue.current} `:"";$e(`${e}${Ge}`)}),[Ge,Qe]),d((()=>{if(!Me.current)return;(()=>{if(!Me.current)return;let e=Me.current.scrollHeight>52;Le.includes("\n")||xe.length?e=!0:Le.trim()||(e=!1),Be(e)})()}),[Le,xe]),d((()=>{const e=Me.current,t=Xe.current;if(!e||!t||We||Le.includes("\n"))return void Fe(!1);const n=window.getComputedStyle(e),s=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} / ${n.lineHeight} ${n.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:s,letterSpacing:n.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=Le,document.body.appendChild(o);const r=o.offsetWidth;o.remove();const i=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-i-a-t.offsetWidth;Fe(r>l)}),[Le,We]);const xt=(e,n=!1)=>t(void 0,void 0,void 0,(function*(){var t,s,o;try{if(he||Oe)return;const r=xe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),i=r.length>0,a=null!=e?e:Le;if(!a&&!i)return;je(""),Ce(""),ye(null),$e(""),le(!1),be("fetching"),Ne(),Ee();const l=null!==(s=null===(t=null==Z?void 0:Z.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s&&r.length>0,c=[...n?Array.from(fe.slice(0,fe.length-1)):Array.from(fe),...n?[]:[{id:fe.length+1,role:"user",parts:[{type:"text",content:a,isVisible:!0}],documentIds:l?r:[]}],{id:fe.length+(n?0:2),role:"assistant",parts:[],documentIds:[]}];ve(c),Ee(),l&&Se([]);const d=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({origin:X,pickaxeId:z,sessionId:V,senderType:G,value:a},l&&{documentIds:r}),q&&{sender:q}),ue&&{studioSessionToken:ue}),Q&&{deploymentId:Q}))}),u=yield d.json();if(console.log("SubmitData: ",u),!u.success)throw new Error(u.error||"Failed to start generation");const m=u.submissionId;be("streaming"),Ve.current=new AbortController;const p=c.length-1,f=[];let g=[...null!=Ae?Ae:[]],h=0,v=!1,b="";for(;!v;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${h}`,{signal:null===(o=Ve.current)||void 0===o?void 0:o.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Ke.current=t;const n=new TextDecoder,s=I({onEvent:e=>{var t,n;if(e.event&&"ping"!==e.event&&h++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);return je(t.error||"Something went wrong."),void(v=!0)}if("delta"===e.event){const s=JSON.parse(e.data);if("data-error"===s.type&&F){const e=s.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw v=!0,F({smitheryId:t[1],serverId:n[1],name:s[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw v=!0,F({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===s.type)b="",f.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t});else if("text-delta"===s.type)b+=s.delta,f[f.length-1].content=b;else if("text-end"===s.type)b="";else if("reasoning-start"===s.type)b="",f.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n});else if("reasoning-delta"===s.type)b+=s.delta,f[f.length-1].content=b;else if("reasoning-end"===s.type)b="";else if(s.type.startsWith("data-")){const e=s;f.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ve([...c.slice(0,p),Object.assign(Object.assign({},c[c.length-1]),{id:fe.length+1,role:"assistant",parts:f})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);g=g.filter((e=>!(e.id===t.id&&e.version===t.version))),g.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),_e([...g]),Te.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);g=g.filter((e=>!(e.id===t.id&&e.version===t.version))),g.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),_e(g),Te.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);g=g.filter((e=>!(e.id===t.id&&e.version===t.version))),g.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),_e(g),Te.startsWith("inline")||Pe({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),n=t.token.replace(/\u200B/g,"");g=g.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+n,status:"streaming"}):e)),_e(g)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);_e(g.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);je(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(v=!0)}else v=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;s.feed(n.decode(e))}v||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(v=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==de||de(V)}catch(e){let t=L(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const n=Object.entries(ge).find((([e])=>t.includes(e)));n?ye(n[1]):je(t)}finally{Ee(),be("idle"),Ie(),Ke.current=null}}));return vt?null:n("div",Object.assign({className:$("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!ht&&"px-4 pb-8"),dir:re?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[s("div",Object.assign({ref:ze,className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ee.formFieldStyle&&"shadow"),style:Object.assign(Object.assign(Object.assign({},pt),dt&&{backgroundColor:"#EEEEEE"}),{maxHeight:`${qe}px`,overflowY:"auto"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),ut(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),ut(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),ut(!0)},onDrop:e=>t(void 0,void 0,void 0,(function*(){e.preventDefault(),e.stopPropagation(),ut(!1);const t=Array.from(e.dataTransfer.files||[]);t.length>0&&(le(!1),yield ke(t))}))},{children:[Qe&&s("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[n("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(K=te.accent)&&void 0!==K?K:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:te.text+"90"}},{children:"Listening..."}))]})),!he&&xe.length>0&&n(P,{className:"p-4 pb-0",isDisabled:he}),n(D,Object.assign({ref:Me,className:$(mt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Le.trim()&&!Le.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",re?"text-right":"text-left",bt&&"mb-12",Qe&&"text-transparent"),value:Le,placeholder:null!==(M=null==Z?void 0:Z.placeholdertext)&&void 0!==M?M:re?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if($e(e),H){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void H(0);if(t>=11)return;let n=0;t>1&&(n=50),H(24*(t-1)+n)}},onKeyDown:e=>{se||et||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Oe||he||xt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),le(!1),yield ke(t))}))},W&&{onFocus:W},B&&{onBlur:B},{dir:re?"rtl":"ltr"})),n("div",Object.assign({ref:Xe,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",bt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!bt&&pt.backgroundColor&&{backgroundColor:pt.backgroundColor}),{borderTopRightRadius:ee.cornerRadius+"px",borderBottomRightRadius:ee.cornerRadius+"px"})},{children:he?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Ve.current&&(Ve.current.abort(),Ve.current=null),Ke.current&&(Ke.current.cancel(),Ke.current=null),be("idle")},style:{backgroundColor:te.accent,color:te.accentText}},{children:n(_,{className:"h-4 w-4 shrink-0"})})):Qe?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:u.stopListening,style:{backgroundColor:te.accent,color:te.accentText}},{children:n(_,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[ft&&s("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:rt?te.accent+"10":void 0,color:rt?te.accent:te.accent+"80"},disabled:Oe||he,onClick:()=>{var e;return null===(e=Je.current)||void 0===e?void 0:e.click()}},it,{children:[n("input",{id:"file-upload",ref:Je,type:"file",accept:[...S,...C,...N].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){le(!1),yield ke(Array.from(e.target.files||[])),e.target.value=""}))}),n(E,{className:"h-6 w-6 shrink-0"})]})),gt&&n("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Qe?te.accent:lt?te.accent+"10":void 0,color:Qe?te.accentText:lt?te.accent:te.accent+"80"},disabled:Oe||he,onClick:()=>{Qe?u.stopListening():(Ue.current=Le,Ye(),u.startListening({continuous:!0,interimResults:!0,language:ne||"en-US"}))}},ct,{children:n(T,{className:"h-5 w-5 shrink-0"})})),n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:nt||jt?te.accent:te.accent+"10",color:nt||jt?te.accentText:te.accent+"80"},disabled:!jt,onClick:()=>xt()},st,{children:n(A,{className:$("h-6 w-6 shrink-0",re&&"scale-x-[-1] transform")})}))]})}))]})),we&&n(R,{error:we,className:"mt-3"})]}))}))}));W.displayName="Input";export{W as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as s,jsx as t}from"react/jsx-runtime";import{useState as n,useMemo as i}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as a}from"../../Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as r}from"../../../../hooks/pickaxe/useResponseContext.js";import{useSubmit as l}from"../../../../hooks/pickaxe/useSubmit.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{useScroll as c}from"../../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as u}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{extractUrlsFromText as p}from"../../../../common/utils.js";import{encode as m}from"@nem035/gpt-3-encoder";import{createParser as g}from"eventsource-parser";import f from"../../common/PickaxeBranding.js";import b from"../../common/PickaxeButton.js";import h from"../../../../common/error.js";const v=({questions:v,resetQuestions:j})=>{var O;const{origin:y,pickaxeId:x,sender:k,senderType:w,deploymentId:S,pickaxe:I,misc:q,translations:C,isRtl:P,setSessionId:A,setIsNewChat:N,onGenerateComplete:D}=o(),{token:E}=a(),{limits:T,isGenerating:J,setResponse:W,setMessages:_,setStatus:L,setLimitData:R,setError:U,setIsSwitchedToChat:V}=r(),{documents:B,websiteLink:G,isUploading:K,onWebsiteUpload:M,setDocuments:Q,setDocumentError:X}=d(),{scrollStartSession:Y,scrollEndSession:z,scrollToTarget:F}=c({auto:!(null==I?void 0:I.enablechatresponses)}),{artifacts:H,currentPopupType:Z,setArtifacts:$,setCurrentArtifact:ee}=u(),se=l(),[te,ne]=n(!1),ie=i((()=>v.some((e=>!("Short Answer"!==e.type&&"Long Answer"!==e.type&&"long"!==e.type&&"short"!==e.type&&"Checkbox"!==e.type&&"Knowledge Upload"!==e.type&&!e.id.includes("documentupload")||!(e.input.length>0))))),[v]);return s("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:P?"rtl":"ltr"},{children:[s("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[t(b,Object.assign({className:"px-5 min-h-[42px]",isDisabled:K||J||te,onClick:()=>e(void 0,void 0,void 0,(function*(){var e,s;try{if(J||K||te)return;U(""),X(""),R(null),W(null);const t=["Multiple Choice","Checkbox"];for(const e of v){if(m(e.input).length>e.maxLength&&!t.includes(e.type))throw new Error("One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error("You must fill out all required fields.")}const n=B.filter((e=>"finished"===e.status)),i=B.map((e=>e.name)),o=null!==(s=null===(e=null==I?void 0:I.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==s&&s,a=v.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),r=p(G).filter((e=>!i.includes(e)));if(r.length){const e=r[r.length-1];ne(!0);const s=yield M(e);s&&(n.push(s),yield new Promise((e=>setTimeout(e,5e3)))),ne(!1)}else if(a&&o&&!n.length)return void X("Please paste a valid website/video link or drag a file to add to the knowledge base.");const l=n.map((e=>e.documentId)).filter(Boolean),d=o&&l.length>0;let c={};v.forEach((e=>c=Object.assign(Object.assign({},c),{[e.id]:"Knowledge Upload"===e.type||e.id.includes("documentupload")?n.map((e=>e.name)).join(",")||"":e.input}))),L("fetching"),Y(),F();const u=yield se.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign({origin:y,pickaxeId:x,senderType:w,valueObj:c},d&&{documentIds:l}),k&&{sender:k}),E&&{studioSessionToken:E}),S&&{deploymentId:S})),f=u.body;if(!f)throw new Error("Streaming error");const b=u.headers.get("X-Pickaxe-Session-Id");if(!b)throw new Error("Post SessionId not found");const h={sessionId:b,documentIds:d?l:[],question:{inputs:v.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[{type:"text",content:"",isVisible:!0}]},messageCount:0,sentAt:new Date};W(h);let j=[];(null==I?void 0:I.enablechatresponses)&&(j=[{id:0,role:"assistant",parts:[],documentIds:[]}],_(j));const O=new TextDecoder,q=f.getReader(),C=[];let P="",T=!0,z=!1,ie=[...null!=H?H:[]];const oe=g({onEvent:e=>{var s,t;if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)P="",C.push({type:"text",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s}),W(Object.assign(Object.assign({},h),{question:Object.assign(Object.assign({},h.question),{responseParts:C})})),(null==I?void 0:I.enablechatresponses)&&_([{id:0,role:"assistant",parts:C,documentIds:[]}]);else if("text-delta"===n.type)P+=n.delta,C[C.length-1].content=P,W(Object.assign(Object.assign({},h),{question:Object.assign(Object.assign({},h.question),{responseParts:C})})),(null==I?void 0:I.enablechatresponses)&&_([{id:0,role:"assistant",parts:C,documentIds:[]}]);else if("text-end"===n.type)P="";else if("reasoning-start"===n.type)P="",C.push({type:"reasoning",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t}),W(Object.assign(Object.assign({},h),{question:Object.assign(Object.assign({},h.question),{responseParts:C})})),(null==I?void 0:I.enablechatresponses)&&_([{id:0,role:"assistant",parts:C,documentIds:[]}]);else if("reasoning-delta"===n.type)P+=n.delta,C[C.length-1].content=P,W(Object.assign(Object.assign({},h),{question:Object.assign(Object.assign({},h.question),{responseParts:C})})),(null==I?void 0:I.enablechatresponses)&&_([{id:0,role:"assistant",parts:C,documentIds:[]}]);else if("reasoning-end"===n.type)P="";else if(n.type.startsWith("data-")){const e=n;C.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0}),W(Object.assign(Object.assign({},h),{question:Object.assign(Object.assign({},h.question),{responseParts:C})})),(null==I?void 0:I.enablechatresponses)&&_([{id:0,role:"assistant",parts:C,documentIds:[]}])}}else if("artifact_created"===e.event){const s=JSON.parse(e.data);ie=ie.filter((e=>!(e.id===s.id&&e.version===s.version))),ie.push(Object.assign(Object.assign({},s),{content:"",status:"streaming"})),$(ie),Z.startsWith("inline")||ee({id:s.id,version:s.version})}else if("artifact_updated"===e.event){const s=JSON.parse(e.data);ie=ie.filter((e=>!(e.id===s.id&&e.version===s.version))),ie.push(Object.assign(Object.assign({},s),{content:"",status:"updating"})),$(ie),Z.startsWith("inline")||ee({id:s.id,version:s.version})}else if("artifact_rewrite"===e.event){const s=JSON.parse(e.data);ie=ie.filter((e=>!(e.id===s.id&&e.version===s.version))),ie.push(Object.assign(Object.assign({},s),{content:"",status:"streaming"})),$(ie),Z.startsWith("inline")||ee({id:s.id,version:s.version})}else if("artifact_content"===e.event){const s=JSON.parse(e.data),t=s.token.replace(/\u200B/g,"");ie=ie.map((e=>e.id===s.id&&e.version===s.version?Object.assign(Object.assign({},e),{content:e.content+t,status:"streaming"}):e)),$(ie)}else if("artifact_finished"===e.event){const s=JSON.parse(e.data);$(ie.map((e=>e.id===s.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const s=JSON.parse(e.data);U(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(T=!1)}});for(;T;){const{value:e,done:s}=yield q.read();if(s){T=!1;break}const t=O.decode(e);t&&(z||(L("streaming"),z=!0,d&&Q([]),(null==I?void 0:I.enablechatresponses)&&(A(b),N(!1),V(!0))),oe.feed(t))}null==D||D(b)}catch(e){let s=h(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(T).find((([e])=>s.includes(e)));t?R(t[1]):U(s),F()}finally{L("idle"),ne(!1),z()}}))},{children:te?(null==C?void 0:C.processing)||"Processing...":K?(null==C?void 0:C.uploading)||"Uploading...":J?(null==C?void 0:C.loading)||"Loading...":null!==(O=null==I?void 0:I.submittext)&&void 0!==O?O:"Submit"})),ie&&t(b,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:K||J||te,onClick:j},{children:(null==C?void 0:C["clear-form"])||"Clear form"}))]})),!q.isWhiteLabel&&t(f,{containerClassName:"justify-end"})]}))};export{v as default};
1
+ import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as s}from"react/jsx-runtime";import{useState as n,useRef as i,useMemo as o}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as a}from"../../Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as l}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{useScroll as c}from"../../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as p}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{extractUrlsFromText as u}from"../../../../common/utils.js";import{encode as m}from"@nem035/gpt-3-encoder";import{createParser as f}from"eventsource-parser";import g from"../../common/PickaxeBranding.js";import h from"../../common/PickaxeButton.js";import v from"../../../../common/error.js";const b=({questions:b,resetQuestions:y})=>{var j;const{origin:O,pickaxeId:x,sender:w,senderType:k,deploymentId:C,pickaxe:S,misc:I,translations:N,isRtl:P,setSessionId:_,setIsNewChat:A,onGenerateComplete:E}=r(),{token:T}=a(),{limits:L,isGenerating:U,setResponse:D,setMessages:J,setStatus:q,setLimitData:B,setError:K,setIsSwitchedToChat:R}=l(),{documents:W,websiteLink:X,isUploading:V,onWebsiteUpload:$,setDocuments:G,setDocumentError:M}=d(),{scrollStartSession:F,scrollEndSession:Q,scrollToTarget:Y}=c({auto:!(null==S?void 0:S.enablechatresponses)}),{artifacts:z,currentPopupType:H,setArtifacts:Z,setCurrentArtifact:ee}=p(),[te,se]=n(!1),ne=i(null),ie=o((()=>b.some((e=>("Short Answer"===e.type||"Long Answer"===e.type||"long"===e.type||"short"===e.type||"Checkbox"===e.type||"Knowledge Upload"===e.type||e.id.includes("documentupload"))&&e.input.length>0))),[b]);return t("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:P?"rtl":"ltr"},{children:[t("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[s(h,Object.assign({className:"px-5 min-h-[42px]",isDisabled:V||U||te,onClick:()=>e(void 0,void 0,void 0,(function*(){var e,t,s;try{if(U||V||te)return;K(""),M(""),B(null),D(null);const n=["Multiple Choice","Checkbox"];for(const e of b){if(m(e.input).length>e.maxLength&&!n.includes(e.type))throw new Error("One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error("You must fill out all required fields.")}const i=W.filter((e=>"finished"===e.status)),o=W.map((e=>e.name)),r=null!==(t=null===(e=null==S?void 0:S.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==t&&t,a=b.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),l=u(X).filter((e=>!o.includes(e)));if(l.length){const e=l[l.length-1];se(!0);const t=yield $(e);t&&(i.push(t),yield new Promise((e=>setTimeout(e,5e3)))),se(!1)}else if(a&&r&&!i.length)return void M("Please paste a valid website/video link or drag a file to add to the knowledge base.");const d=i.map((e=>e.documentId)).filter(Boolean),c=r&&d.length>0;let p={};b.forEach((e=>{p[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?i.map((e=>e.name)).join(",")||"":e.input})),q("fetching"),F(),Y();const g=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,{method:"POST",headers:Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign({origin:O,pickaxeId:x,senderType:k,valueObj:p},c&&{documentIds:d}),w&&{sender:w}),T&&{studioSessionToken:T}),C&&{deploymentId:C}))}),h=yield g.json();if(!h.success)throw new Error(h.error||"Failed to start generation");const v=h.submissionId,y=h.sessionId,j={sessionId:y,documentIds:c?d:[],question:{inputs:b.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};D(j),(null==S?void 0:S.enablechatresponses)&&(_(y),A(!1),R(!0),J([{id:0,role:"assistant",parts:[],documentIds:[]}])),c&&G([]),q("streaming"),ne.current=new AbortController;const I=[];let N=[...null!=z?z:[]],P=0,L=!1,Q="";for(;!L;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${v}?index=${P}`,{signal:null===(s=ne.current)||void 0===s?void 0:s.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),n=new TextDecoder,i=f({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&P++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);return K(t.error||"Something went wrong."),void(L=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)Q="",I.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)Q+=n.delta,I[I.length-1].content=Q;else if("text-end"===n.type)Q="";else if("reasoning-start"===n.type)Q="",I.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)Q+=n.delta,I[I.length-1].content=Q;else if("reasoning-end"===n.type)Q="";else if(n.type.startsWith("data-")){const e=n;I.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},j),{question:Object.assign(Object.assign({},j.question),{responseParts:[...I]})});D(i),(null==S?void 0:S.enablechatresponses)&&J([{id:0,role:"assistant",parts:[...I],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);N=N.filter((e=>!(e.id===t.id&&e.version===t.version))),N.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Z([...N]),H.startsWith("inline")||ee({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);N=N.filter((e=>!(e.id===t.id&&e.version===t.version))),N.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Z([...N]),H.startsWith("inline")||ee({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);N=N.filter((e=>!(e.id===t.id&&e.version===t.version))),N.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Z([...N]),H.startsWith("inline")||ee({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");N=N.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Z([...N])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Z(N.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else L=!0}});for(;;){const{value:e,done:s}=yield t.read();if(s)break;i.feed(n.decode(e))}L||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("AbortError"===e.name)return void(L=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==E||E(y)}catch(e){let t=v(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(L).find((([e])=>t.includes(e)));s?B(s[1]):K(t),Y()}finally{q("idle"),se(!1),Q()}}))},{children:te?(null==N?void 0:N.processing)||"Processing...":V?(null==N?void 0:N.uploading)||"Uploading...":U?(null==N?void 0:N.loading)||"Loading...":null!==(j=null==S?void 0:S.submittext)&&void 0!==j?j:"Submit"})),ie&&s(h,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:V||U||te,onClick:y},{children:(null==N?void 0:N["clear-form"])||"Clear form"}))]})),!I.isWhiteLabel&&s(g,{containerClassName:"justify-end"})]}))};export{b as default};
@@ -1 +1 @@
1
- import{jsxs as o,jsx as i}from"react/jsx-runtime";import{useMemo as t}from"react";import{usePickaxeContext as e}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as s}from"../Addons/Auth/hooks/useAuthContext.js";import{useStyleFontSize as r}from"../../../hooks/studio/useStyleFontSize.js";import n from"./PickaxeIcon.js";import l from"./PickaxeHistoryButton.js";import c from"./PickaxeLogoutButton.js";import a from"../../../common/cn.js";const m=({className:m,iconClassName:p,historyBtnTip:u,showHistory:d,onIconClick:f,onHistoryClick:h})=>{const{deploymentType:x,pickaxe:g,misc:k,colors:j,translations:y}=e(),{isLoggedIn:b}=s(),v=r(),C=t((()=>({title:(null==g?void 0:g.formtitle)||"",description:(null==g?void 0:g.formdescription)||""})),[g]);return k.isTitle||k.isDescription||!k.isWhiteLabel?o("div",Object.assign({className:a("flex min-h-[56px] items-center justify-between gap-4 px-4",m),style:{backgroundColor:j.secondary,color:j.secondaryText}},{children:[o("div",Object.assign({className:"flex items-center gap-4"},{children:[k.isProfileImage&&i(n,Object.assign({src:null==g?void 0:g.coverphoto,alt:`${null==g?void 0:g.formtitle}'s Profile Picture`,width:32,height:32,className:a("h-[32px] w-[32px] shrink-0 rounded-full",p,!!f&&"cursor-pointer")},f&&{onClick:f})),k.isTitle&&i("p",Object.assign({className:a(v.b1)},{children:C.title}))]})),!!h&&o("div",Object.assign({className:a("popup"===x&&"pr-12","flex")},{children:[i(l,{tip:u,onClick:h}),b&&d&&i(c,{tip:(null==y?void 0:y["log-out"])||"Log Out"})]}))]})):null};export{m as default};
1
+ import{jsxs as o,jsx as i}from"react/jsx-runtime";import{useMemo as t}from"react";import{usePickaxeContext as e}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as s}from"../Addons/Auth/hooks/useAuthContext.js";import{useStyleFontSize as r}from"../../../hooks/studio/useStyleFontSize.js";import n from"./PickaxeIcon.js";import l from"./PickaxeHistoryButton.js";import c from"./PickaxeLogoutButton.js";import a from"../../../common/cn.js";const m=({className:m,iconClassName:p,historyBtnTip:u,onIconClick:d,onHistoryClick:f})=>{const{deploymentType:h,pickaxe:x,misc:g,colors:k,translations:j}=e(),{isLoggedIn:y}=s(),b=r(),v=t((()=>({title:(null==x?void 0:x.formtitle)||"",description:(null==x?void 0:x.formdescription)||""})),[x]);return g.isTitle||g.isDescription||!g.isWhiteLabel?o("div",Object.assign({className:a("flex min-h-[56px] items-center justify-between gap-4 px-4",m),style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[o("div",Object.assign({className:"flex items-center gap-4"},{children:[g.isProfileImage&&i(n,Object.assign({src:null==x?void 0:x.coverphoto,alt:`${null==x?void 0:x.formtitle}'s Profile Picture`,width:32,height:32,className:a("h-[32px] w-[32px] shrink-0 rounded-full",p,!!d&&"cursor-pointer")},d&&{onClick:d})),g.isTitle&&i("p",Object.assign({className:a(b.b1)},{children:v.title}))]})),!!f&&o("div",Object.assign({className:a("popup"===h&&"pr-12","flex")},{children:[i(l,{tip:u,onClick:f}),y&&i(c,{tip:(null==j?void 0:j["log-out"])||"Log Out"})]}))]})):null};export{m as default};
@@ -2,9 +2,8 @@ interface PickaxeEmbedHeadProps {
2
2
  className?: string;
3
3
  iconClassName?: string;
4
4
  historyBtnTip?: string;
5
- showHistory?: boolean;
6
5
  onIconClick?: () => void;
7
6
  onHistoryClick?: () => void;
8
7
  }
9
- declare const PickaxeEmbedHead: ({ className, iconClassName, historyBtnTip, showHistory, onIconClick, onHistoryClick, }: PickaxeEmbedHeadProps) => import("react/jsx-runtime").JSX.Element | null;
8
+ declare const PickaxeEmbedHead: ({ className, iconClassName, historyBtnTip, onIconClick, onHistoryClick, }: PickaxeEmbedHeadProps) => import("react/jsx-runtime").JSX.Element | null;
10
9
  export default PickaxeEmbedHead;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "4.5.3",
3
+ "version": "5.0.0",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",