@pickaxeproject/react 3.10.2 → 3.11.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.
@@ -0,0 +1 @@
1
+ "use strict";function e(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}Object.defineProperty(exports,"__esModule",{value:!0});var r,t,n=e(require("react"));function a(){return a=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},a.apply(null,arguments)}var o=e=>n.createElement("svg",a({xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},e),r||(r=n.createElement("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3"})),t||(t=n.createElement("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2M12 19v4M8 23h8"})));exports.default=o;
@@ -0,0 +1 @@
1
+ "use strict";function e(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}Object.defineProperty(exports,"__esModule",{value:!0});var r,t=e(require("react"));function n(){return n=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},n.apply(null,arguments)}var o=e=>t.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},e),r||(r=t.createElement("path",{d:"M6 6h12v12H6z"})));exports.default=o;
@@ -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"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../hooks/studio/useStyleInput.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../../../hooks/pickaxe/useSubmit.js"),u=require("../Addons/Document/hooks/useDocument.js"),c=require("../Addons/Scroll/hooks/useScroll.js"),f=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),p=require("../../../common/documents.js"),v=require("eventsource-parser"),h=require("../../Icons/attach-vertical.svg.js"),g=require("../../Icons/arrow-right.svg.js"),x=require("../Addons/IceBreaker/index.js"),j=require("../Addons/Document/List.js"),b=require("../../Core/Textarea.js"),y=require("../../Core/ErrorAlert.js"),k=require("../common/PickaxeBranding.js"),O=require("../../../common/error.js"),w=require("../../../common/cn.js");exports.default=({isFocused:S,onFocus:I,onBlur:q})=>{var N,C,A;const{formId:_,chatId:D,userId:B,studioUserId:E,embedUserId:T,deploymentId:F,deploymentType:U,pickaxe:W,styles:H,colors:J,misc:L,responsiveBy:P,isNewChat:R,isRtl:M,isEmailLogin:z,setIsNewChat:G,setIsShowIceBreaker:K,onGenerateComplete:Q}=i.usePickaxeContext(),{token:V,isLoggedOut:X,isSent:Y}=l.useAuthContext(),{messages:Z,status:$,limits:ee,isGenerating:te,setMessages:se,setStatus:ie,setLimitData:re,setError:ne}=r.useResponseContext(),{documents:oe,isUploading:ae,isImageUploadAllowed:le,documentError:de,onFileUpload:ue,setDocuments:ce,setDocumentError:fe}=u.useDocument(),{scrollStartSession:me,scrollEndSession:pe,scrollToBottom:ve}=c.useScroll({auto:!0}),{artifacts:he,currentPopupType:ge,setArtifacts:xe,setCurrentArtifact:je}=f.useArtifactContext(),be=a.useConversation(),ye=d.useSubmit(),[ke,Oe]=s.useState(""),we=s.useRef(null),Se=m.useHover(),{isHover:Ie}=Se,qe=e.__rest(Se,["isHover"]),Ne=m.useHover(),{isHover:Ce}=Ne,Ae=e.__rest(Ne,["isHover"]),_e=o.useStyleFontSize(),De=n.useStyleInput(),Be="chat-input"===U&&R&&!Y,Ee="chat-input"===U&&z&&X&&Y,Te=s.useMemo((()=>{var e,t,s;return!!R&&(!!W&&(!be.isLoading&&(!((null!==(t=null===(e=be.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(s=W.icebreakers)||void 0===s?void 0:s.length))))}),[W,R,be.data,be.isLoading]),Fe=s.useMemo((()=>{if(te||ae)return!1;return!!ke.trim()&&oe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[te,ae,ke,oe]),Ue=t=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;try{if("idle"!==$||ae)return;const i=null!=t?t:ke;if(!i)return;ne(""),fe(""),re(null),Oe(""),G(!1),ie("fetching"),me(),ve();const r=oe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),n=null!==(s=null===(e=null==W?void 0:W.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==s&&s&&r.length>0,o=[...Array.from(Z),Object.assign({id:Z.length+1,role:"user",content:i},n&&{documentIds:r})];se(o),ve(),n&&ce([]);const a=(yield ye.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:_,responseId:D,value:i},n&&{documentIds:r}),B&&{userId:B}),E&&{studioUserId:E}),T&&{embedUserId:T}),V&&{studioSessionToken:V}),F&&{deploymentId:F}))).body;if(!a)throw new Error("Streaming error");const l=o.length,d=new TextDecoder,u=a.getReader();let c="",f=!0,m=!1,p=[...null!=he?he:[]];const h=v.createParser({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");c+=t,se([...o.slice(0,l),{id:Z.length+1,role:"assistant",content:c}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);p=p.filter((e=>!(e.id===t.id&&e.version===t.version))),p.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),xe(p),ge.startsWith("inline")||je({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);p=p.filter((e=>!(e.id===t.id&&e.version===t.version))),p.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),xe(p),ge.startsWith("inline")||je({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);p=p.filter((e=>!(e.id===t.id&&e.version===t.version))),p.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),xe(p),ge.startsWith("inline")||je({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");p=p.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),xe(p)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);xe(p.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);ne(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(f=!1)}});for(;f;){const{value:e,done:t}=yield u.read();if(t){f=!1;break}const s=d.decode(e);s&&(m||(ie("streaming"),m=!0),h.feed(s))}null==Q||Q(D)}catch(e){let t=O.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(ee).find((([e])=>t.includes(e)));s?re(s[1]):ne(t)}finally{ve(),ie("idle"),pe()}}));return s.useEffect((()=>{K(Te)}),[Te]),Ee?null:t.jsx("div",Object.assign({className:w.default("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!Be&&"px-4 pb-4"),dir:M?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!Be&&t.jsx("div",Object.assign({className:w.default("absolute bottom-full",M?"left-0":"right-0")},{children:t.jsxs("div",Object.assign({className:w.default("flex flex-col gap-2 pb-4 px-2",M?"justify-start":"justify-end","viewport"===P?M?"min-[767px]:items-start":"min-[767px]:items-end":M?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:[!L.isWhiteLabel&&t.jsx(k.default,{containerClassName:"justify-end"}),Te&&!S&&t.jsx(x.default,{data:(null==W?void 0:W.icebreakers)||[],onSend:Ue})]}))})),t.jsxs("div",Object.assign({className:w.default("flex flex-col gap-y-3 px-4 py-3","block"===H.formFieldStyle&&"shadow"),style:De},{children:["idle"===$&&oe.length>0&&t.jsx(j.default,{isDisabled:"idle"!==$}),t.jsxs("div",Object.assign({className:w.default("flex items-end gap-x-2",M&&"flex-row-reverse")},{children:[t.jsx(b.default,Object.assign({className:w.default(_e.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!ke.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",M?"text-right":"text-left"),value:ke,placeholder:null!==(N=null==W?void 0:W.placeholdertext)&&void 0!==N?N:M?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>Oe(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ae||"idle"!==$||Ue()))}},I&&{onFocus:I},q&&{onBlur:q},{dir:M?"rtl":"ltr"})),t.jsxs("div",Object.assign({className:"flex items-center gap-x-2"},{children:[null!==(A=null===(C=null==W?void 0:W.documentuploadtype)||void 0===C?void 0:C.startsWith("enduserupload"))&&void 0!==A&&A&&t.jsxs("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:Ce?J.accent+"10":void 0,color:Ce?J.accent:J.accent+"80"},disabled:ae||"idle"!==$,onClick:()=>{var e;return null===(e=we.current)||void 0===e?void 0:e.click()}},Ae,{children:[t.jsx("input",{id:"file-upload",ref:we,type:"file",accept:[...p.allowedFileMimeTypes,...le?p.allowedImageMimeTypes:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){G(!1),yield ue(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(h.default,{className:"h-6 w-6 shrink-0"})]})),t.jsx("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:Ie||Fe?J.accent:J.accent+"10",color:Ie||Fe?J.accentText:J.accent+"80"},disabled:"idle"!==$||ae,onClick:()=>Ue()},qe,{children:t.jsx(g.default,{className:w.default("h-6 w-6 shrink-0",M&&"transform scale-x-[-1]")})}))]}))]}))]})),de&&t.jsx(y.default,{error:de,className:"mt-3"})]}))}))};
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("../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../hooks/studio/useStyleInput.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../Addons/Auth/hooks/useAuthContext.js"),c=require("../../../hooks/pickaxe/useSubmit.js"),d=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),f=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),p=require("../../../common/documents.js"),v=require("eventsource-parser"),g=require("../../Icons/attach-vertical.svg.js"),h=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),b=require("../../../hooks/pickaxe/useSpeechRecognition.js"),y=require("../Addons/IceBreaker/index.js"),k=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),w=require("../../Core/ErrorAlert.js"),S=require("../common/PickaxeBranding.js"),N=require("../../../common/error.js"),I=require("../../../common/cn.js");const q=({colors:e})=>{var s;return t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full",style:{backgroundColor:null!==(s=e.accent)&&void 0!==s?s:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm",style:{color:e.text+"90"}},{children:"Listening..."}))]}))};exports.default=({isFocused:C,onFocus:A,onBlur:_})=>{var H,T,E;const{formId:L,chatId:D,userId:B,studioUserId:R,embedUserId:F,deploymentId:U,deploymentType:W,pickaxe:J,styles:P,colors:M,misc:$,responsiveBy:z,isNewChat:G,isRtl:K,studioLang:Q,isEmailLogin:V,setIsNewChat:X,setIsShowIceBreaker:Y,onGenerateComplete:Z}=n.usePickaxeContext(),{token:ee,isLoggedOut:te,isSent:se}=l.useAuthContext(),{messages:ne,status:ie,limits:re,isGenerating:oe,setMessages:ae,setStatus:le,setLimitData:ce,setError:de}=i.useResponseContext(),{documents:ue,isUploading:fe,isImageUploadAllowed:me,documentError:pe,onFileUpload:ve,setDocuments:ge,setDocumentError:he}=d.useDocument(),{scrollStartSession:xe,scrollEndSession:je,scrollToBottom:be}=u.useScroll({auto:!0}),{artifacts:ye,currentPopupType:ke,setArtifacts:Oe,setCurrentArtifact:we}=f.useArtifactContext(),Se=a.useConversation(),Ne=c.useSubmit(),[Ie,qe]=s.useState(""),Ce=s.useRef(null),{isSupported:Ae,isListening:_e,finalTranscript:He,interimTranscript:Te,startListening:Ee,stopListening:Le}=b.useSpeechRecognition({lang:Q||"en"}),De=s.useRef("");s.useEffect((()=>{if(_e){const e=`${De.current} ${He} ${Te}`.trim();qe(e)}}),[He,Te,_e]),s.useEffect((()=>{!_e&&De.current&&(qe(`${De.current} ${He}`.trim()),De.current="")}),[_e,He]);const Be=m.useHover(),{isHover:Re}=Be,Fe=e.__rest(Be,["isHover"]),Ue=m.useHover(),{isHover:We}=Ue,Je=e.__rest(Ue,["isHover"]),Pe=m.useHover(),{isHover:Me}=Pe,$e=e.__rest(Pe,["isHover"]),ze=m.useHover(),{isHover:Ge}=ze,Ke=e.__rest(ze,["isHover"]),Qe=o.useStyleFontSize(),Ve=r.useStyleInput(),Xe="chat-input"===W&&G&&!se,Ye="chat-input"===W&&V&&te&&se,Ze=s.useMemo((()=>{var e,t,s;return!!G&&(!!J&&(!Se.isLoading&&(!((null!==(t=null===(e=Se.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))))}),[J,G,Se.data,Se.isLoading]),et=s.useMemo((()=>{if(oe||fe)return!1;return!!Ie.trim()&&ue.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[oe,fe,Ie,ue]),tt=t=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;try{if("idle"!==ie||fe||_e)return;const n=null!=t?t:Ie;if(!n)return;de(""),he(""),ce(null),qe(""),X(!1),le("fetching"),xe(),be();const i=ue.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),r=null!==(s=null===(e=null==J?void 0:J.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==s&&s&&i.length>0,o=[...Array.from(ne),Object.assign({id:ne.length+1,role:"user",content:n},r&&{documentIds:i})];ae(o),be(),r&&ge([]);const a=(yield Ne.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:L,responseId:D,value:n},r&&{documentIds:i}),B&&{userId:B}),R&&{studioUserId:R}),F&&{embedUserId:F}),ee&&{studioSessionToken:ee}),U&&{deploymentId:U}))).body;if(!a)throw new Error("Streaming error");const l=o.length,c=new TextDecoder,d=a.getReader();let u="",f=!0,m=!1,p=[...null!=ye?ye:[]];const g=v.createParser({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");u+=t,ae([...o.slice(0,l),{id:ne.length+1,role:"assistant",content:u}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);p=p.filter((e=>!(e.id===t.id&&e.version===t.version))),p.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Oe(p),ke.startsWith("inline")||we({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);p=p.filter((e=>!(e.id===t.id&&e.version===t.version))),p.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Oe(p),ke.startsWith("inline")||we({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);p=p.filter((e=>!(e.id===t.id&&e.version===t.version))),p.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Oe(p),ke.startsWith("inline")||we({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");p=p.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Oe(p)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Oe(p.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&&(f=!1)}});for(;f;){const{value:e,done:t}=yield d.read();if(t){f=!1;break}const s=c.decode(e);s&&(m||(le("streaming"),m=!0),g.feed(s))}null==Z||Z(D)}catch(e){let t=N.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(re).find((([e])=>t.includes(e)));s?ce(s[1]):de(t)}finally{be(),le("idle"),je()}}));return s.useEffect((()=>{Y(Ze)}),[Ze]),Ye?null:t.jsx("div",Object.assign({className:I.default("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!Xe&&"px-4 pb-4"),dir:K?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!Xe&&t.jsx("div",Object.assign({className:I.default("absolute bottom-full",K?"left-0":"right-0")},{children:t.jsxs("div",Object.assign({className:I.default("flex flex-col gap-2 pb-4 px-2",K?"justify-start":"justify-end","viewport"===z?K?"min-[767px]:items-start":"min-[767px]:items-end":K?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:[!$.isWhiteLabel&&t.jsx(S.default,{containerClassName:"justify-end"}),Ze&&!C&&t.jsx(y.default,{data:(null==J?void 0:J.icebreakers)||[],onSend:tt})]}))})),t.jsxs("div",Object.assign({className:I.default("flex flex-col gap-y-3 px-4 py-3","block"===P.formFieldStyle&&"shadow"),style:Ve},{children:[_e&&t.jsx(q,{colors:M}),"idle"===ie&&ue.length>0&&t.jsx(k.default,{isDisabled:"idle"!==ie}),t.jsxs("div",Object.assign({className:I.default("flex items-end gap-x-2",K&&"flex-row-reverse")},{children:[t.jsx(O.default,Object.assign({className:I.default(Qe.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!Ie.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",K?"text-right":"text-left",_e&&"text-transparent"),value:Ie,placeholder:null!==(H=null==J?void 0:J.placeholdertext)&&void 0!==H?H:K?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>qe(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),fe||"idle"!==ie||tt()))}},A&&{onFocus:A},_&&{onBlur:_},{dir:K?"rtl":"ltr"})),t.jsx("div",Object.assign({className:"flex items-center gap-x-2"},{children:_e?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:Le,style:{backgroundColor:Ge?M.accent:M.accent+"10",color:Ge?M.accentText:M.accent}},Ke,{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[null!==(E=null===(T=null==J?void 0:J.documentuploadtype)||void 0===T?void 0:T.startsWith("enduserupload"))&&void 0!==E&&E&&t.jsxs("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:We?M.accent+"10":void 0,color:We?M.accent:M.accent+"80"},disabled:fe||"idle"!==ie,onClick:()=>{var e;return null===(e=Ce.current)||void 0===e?void 0:e.click()}},Je,{children:[t.jsx("input",{id:"file-upload",ref:Ce,type:"file",accept:[...p.allowedFileMimeTypes,...me?p.allowedImageMimeTypes:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){X(!1),yield ve(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(g.default,{className:"h-6 w-6 shrink-0"})]})),Ae&&(null==J?void 0:J.enablevoicetotext)&&t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center \n justify-center rounded-full\n outline-none transition-colors \n duration-200 ease-in-out\n disabled:cursor-default",style:{backgroundColor:_e?M.accent:Me?M.accent+"10":void 0,color:_e?M.accentText:Me?M.accent:M.accent+"80"},disabled:fe||"idle"!==ie,onClick:()=>{_e?Le():(De.current=Ie,Ee())}},$e,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:Re||et?M.accent:M.accent+"10",color:Re||et?M.accentText:M.accent+"80"},disabled:"idle"!==ie||fe,onClick:()=>tt()},Fe,{children:t.jsx(h.default,{className:I.default("h-6 w-6 shrink-0",K&&"transform scale-x-[-1]")})}))]})}))]}))]})),pe&&t.jsx(w.default,{error:pe,className:"mt-3"})]}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),s=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),r=require("./ResponseProvider.js"),n=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function d(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const l=i.createContext({});exports.PickaxeContext=l,exports.PickaxeProvider=({children:c,userId:u="",studioUserId:f="",deploymentId:p="",embedUserId:y="",deploymentType:h,deploymentDimensions:m,deploymentMisc:b,styles:v,colors:g,limits:x={},misc:j={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:I={popupType:"auto"},responsiveBy:F="viewport",forceMobile:S=!1,disableHtml:w=!1,disableJs:k=!1,disableCss:C=!1,loadFont:O=!0,isRtl:D=!1,isEmbed:E=!1,isDropShadow:q=!1,isEmailLogin:H=!1,onGenerateComplete:R})=>{const[_,A]=i.useState(""),[L,T]=i.useState(""),[M,U]=i.useState(""),[B,N]=i.useState(""),[W,z]=i.useState(null),[G,J]=i.useState(!1),[Y,K]=i.useState(!0),[Q,V]=i.useState(!0);return i.useEffect((()=>{J(!1)}),[null==v?void 0:v.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&O&&!G&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield Promise.resolve().then((function(){return d(require("webfontloader"))}))).default.load({google:{families:[v.font]},active:()=>{J(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),J(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),J(!0)}}))}),[O,G,null==v?void 0:v.font]),t.jsx(l.Provider,Object.assign({value:Object.assign({formId:_,chatId:L,lastChatId:M,sessionId:B,userId:u,studioUserId:f,embedUserId:y,deploymentId:p,deploymentType:h,deploymentDimensions:m,deploymentMisc:b,pickaxe:W,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},g),misc:j,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet."},P),artifact:I,responsiveBy:F,forceMobile:S,loadFont:O,disableHtml:w,disableJs:k,disableCss:C,isFontLoaded:G,isNewChat:Y,isShowIceBreaker:Q,isRtl:D,isEmbed:E,isDropShadow:q,isEmailLogin:H,setIsFontLoaded:J,setFormId:A,setChatId:T,setLastChatId:U,setSessionId:N,setPickaxe:z,setIsNewChat:K,setIsShowIceBreaker:V},R&&{onGenerateComplete:R})},{children:t.jsx(a.default,{children:t.jsx(o.default,{children:t.jsx(r.default,Object.assign({limits:x},{children:t.jsx(n.default,{children:t.jsx(s.ArtifactProvider,Object.assign({},I,{children:c}))})}))})})}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),s=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),r=require("./ResponseProvider.js"),n=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function d(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const l=i.createContext({});exports.PickaxeContext=l,exports.PickaxeProvider=({children:c,userId:u="",studioUserId:f="",deploymentId:p="",embedUserId:y="",deploymentType:h,deploymentDimensions:m,deploymentMisc:b,styles:v,colors:g,limits:x={},misc:j={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:I={popupType:"auto"},responsiveBy:F="viewport",forceMobile:S=!1,disableHtml:w=!1,disableJs:k=!1,disableCss:C=!1,loadFont:O=!0,isRtl:D=!1,studioLang:E="en",isEmbed:q=!1,isDropShadow:L=!1,isEmailLogin:H=!1,onGenerateComplete:R})=>{const[_,A]=i.useState(""),[T,M]=i.useState(""),[U,B]=i.useState(""),[N,W]=i.useState(""),[z,G]=i.useState(null),[J,Y]=i.useState(!1),[K,Q]=i.useState(!0),[V,X]=i.useState(!0);return i.useEffect((()=>{Y(!1)}),[null==v?void 0:v.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&O&&!J&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield Promise.resolve().then((function(){return d(require("webfontloader"))}))).default.load({google:{families:[v.font]},active:()=>{Y(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),Y(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),Y(!0)}}))}),[O,J,null==v?void 0:v.font]),t.jsx(l.Provider,Object.assign({value:Object.assign({formId:_,chatId:T,lastChatId:U,sessionId:N,userId:u,studioUserId:f,embedUserId:y,deploymentId:p,deploymentType:h,deploymentDimensions:m,deploymentMisc:b,pickaxe:z,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},g),misc:j,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet."},P),artifact:I,responsiveBy:F,forceMobile:S,loadFont:O,disableHtml:w,disableJs:k,disableCss:C,isFontLoaded:J,isNewChat:K,isShowIceBreaker:V,isRtl:D,studioLang:E,isEmbed:q,isDropShadow:L,isEmailLogin:H,setIsFontLoaded:Y,setFormId:A,setChatId:M,setLastChatId:B,setSessionId:W,setPickaxe:G,setIsNewChat:Q,setIsShowIceBreaker:X},R&&{onGenerateComplete:R})},{children:t.jsx(a.default,{children:t.jsx(o.default,{children:t.jsx(r.default,Object.assign({limits:x},{children:t.jsx(n.default,{children:t.jsx(s.ArtifactProvider,Object.assign({},I,{children:c}))})}))})})}))};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");const r=()=>globalThis.SpeechRecognition||globalThis.webkitSpeechRecognition;exports.useSpeechRecognition=(t={})=>{const{lang:n="en"}=t,[o,s]=e.useState(!1),[i,c]=e.useState(""),[u,l]=e.useState(""),[a,p]=e.useState(null),g=e.useRef(null);e.useEffect((()=>{const e=r();if(!e)return void console.warn("SpeechRecognition API is not supported in this browser.");const t=new e;return t.lang=n,t.continuous=!0,t.interimResults=!0,t.onresult=e=>{let r="",t="";for(let n=e.resultIndex;n<e.results.length;++n){const o=e.results[n][0].transcript;e.results[n].isFinal?t+=o+" ":r+=o}l(r),c((e=>e+t))},t.onerror=e=>{console.error("Speech recognition error:",e.error,e.message),p(`Speech recognition error: ${e.error}. Please check microphone permissions.`),s(!1)},t.onend=()=>{s(!1),l("")},g.current=t,()=>{var e;null===(e=g.current)||void 0===e||e.stop()}}),[n]);const h=e.useCallback((()=>{if(g.current&&!o)try{c(""),l(""),p(null),g.current.start(),s(!0)}catch(e){console.error("Could not start speech recognition:",e),p("Could not start recognition. It might already be active or an error occurred.")}}),[o]),d=e.useCallback((()=>{g.current&&o&&g.current.stop()}),[o]);return{isSupported:!!r(),isListening:o,finalTranscript:i,interimTranscript:u,error:a,startListening:h,stopListening:d}};
@@ -80,6 +80,7 @@ type PickaxeContextType = {
80
80
  isNewChat: boolean;
81
81
  isShowIceBreaker: boolean;
82
82
  isRtl: boolean;
83
+ studioLang: string;
83
84
  isEmbed: boolean;
84
85
  isDropShadow: boolean;
85
86
  isEmailLogin: boolean;
@@ -115,11 +116,12 @@ export interface IPickaxeProviderProps {
115
116
  disableJs?: boolean;
116
117
  disableCss?: boolean;
117
118
  isRtl?: boolean;
119
+ studioLang?: string;
118
120
  isEmbed?: boolean;
119
121
  isDropShadow?: boolean;
120
122
  isEmailLogin?: boolean;
121
123
  onGenerateComplete?: (responseId: string) => void;
122
124
  }
123
125
  export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
124
- export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, embedUserId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, artifact, responsiveBy, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, isEmbed, isDropShadow, isEmailLogin, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
126
+ export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, embedUserId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, artifact, responsiveBy, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, studioLang, isEmbed, isDropShadow, isEmailLogin, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
125
127
  export {};
@@ -26,6 +26,7 @@ export declare const usePickaxeContext: () => {
26
26
  isNewChat: boolean;
27
27
  isShowIceBreaker: boolean;
28
28
  isRtl: boolean;
29
+ studioLang: string;
29
30
  isEmbed: boolean;
30
31
  isDropShadow: boolean;
31
32
  isEmailLogin: boolean;
@@ -0,0 +1,13 @@
1
+ interface SpeechRecognitionOptions {
2
+ lang?: string;
3
+ }
4
+ export declare const useSpeechRecognition: (options?: SpeechRecognitionOptions) => {
5
+ isSupported: boolean;
6
+ isListening: boolean;
7
+ finalTranscript: string;
8
+ interimTranscript: string;
9
+ error: string | null;
10
+ startListening: () => void;
11
+ stopListening: () => void;
12
+ };
13
+ export {};
@@ -20,6 +20,7 @@ export type Pickaxe = {
20
20
  documentuploadtype: PickaxeDocumentUploadType;
21
21
  embedlink: string;
22
22
  enablechatresponses: boolean;
23
+ enablevoicetotext: boolean;
23
24
  featured: boolean;
24
25
  formdescription: string;
25
26
  formtitle: string;
@@ -66,6 +67,7 @@ export type LimitedPickaxe = {
66
67
  chaticon: string;
67
68
  documentuploadtype: PickaxeDocumentUploadType;
68
69
  enablechatresponses: boolean;
70
+ enablevoicetotext: boolean;
69
71
  formdescription: string;
70
72
  formtitle: string;
71
73
  model: PickaxeModel;
@@ -0,0 +1 @@
1
+ import*as e from"react";var r,t;function n(){return n=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},n.apply(null,arguments)}var a=a=>e.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},a),r||(r=e.createElement("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3"})),t||(t=e.createElement("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2M12 19v4M8 23h8"})));export{a as default};
@@ -0,0 +1 @@
1
+ import*as r from"react";var e;function t(){return t=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},t.apply(null,arguments)}var n=n=>r.createElement("svg",t({xmlns:"http://www.w3.org/2000/svg",fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,viewBox:"0 0 24 24"},n),e||(e=r.createElement("path",{d:"M6 6h12v12H6z"})));export{n as default};
@@ -1 +1 @@
1
- import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as o}from"react/jsx-runtime";import{useState as i,useRef as n,useMemo as r,useEffect as a}from"react";import{usePickaxeContext as l}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as d}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as c}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as u}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as m}from"../../../hooks/pickaxe/useConversation.js";import{useAuthContext as p}from"../Addons/Auth/hooks/useAuthContext.js";import{useSubmit as f}from"../../../hooks/pickaxe/useSubmit.js";import{useDocument as v}from"../Addons/Document/hooks/useDocument.js";import{useScroll as h}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as g}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as j}from"../../../hooks/core/useHover.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as x}from"../../../common/documents.js";import{createParser as k}from"eventsource-parser";import y from"../../Icons/attach-vertical.svg.js";import O from"../../Icons/arrow-right.svg.js";import w from"../Addons/IceBreaker/index.js";import I from"../Addons/Document/List.js";import N from"../../Core/Textarea.js";import S from"../../Core/ErrorAlert.js";import A from"../common/PickaxeBranding.js";import C from"../../../common/error.js";import B from"../../../common/cn.js";const D=({isFocused:D,onFocus:E,onBlur:U})=>{var W,J,L;const{formId:T,chatId:_,userId:F,studioUserId:H,embedUserId:R,deploymentId:P,deploymentType:z,pickaxe:G,styles:K,colors:M,misc:q,responsiveBy:Q,isNewChat:V,isRtl:X,isEmailLogin:Y,setIsNewChat:Z,setIsShowIceBreaker:$,onGenerateComplete:ee}=l(),{token:te,isLoggedOut:se,isSent:oe}=p(),{messages:ie,status:ne,limits:re,isGenerating:ae,setMessages:le,setStatus:de,setLimitData:ce,setError:ue}=d(),{documents:me,isUploading:pe,isImageUploadAllowed:fe,documentError:ve,onFileUpload:he,setDocuments:ge,setDocumentError:je}=v(),{scrollStartSession:be,scrollEndSession:xe,scrollToBottom:ke}=h({auto:!0}),{artifacts:ye,currentPopupType:Oe,setArtifacts:we,setCurrentArtifact:Ie}=g(),Ne=m(),Se=f(),[Ae,Ce]=i(""),Be=n(null),De=j(),{isHover:Ee}=De,Ue=e(De,["isHover"]),We=j(),{isHover:Je}=We,Le=e(We,["isHover"]),Te=u(),_e=c(),Fe="chat-input"===z&&V&&!oe,He="chat-input"===z&&Y&&se&&oe,Re=r((()=>{var e,t,s;return!!V&&(!!G&&(!Ne.isLoading&&(!((null!==(t=null===(e=Ne.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(s=G.icebreakers)||void 0===s?void 0:s.length))))}),[G,V,Ne.data,Ne.isLoading]),Pe=r((()=>{if(ae||pe)return!1;return!!Ae.trim()&&me.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ae,pe,Ae,me]),ze=e=>t(void 0,void 0,void 0,(function*(){var t,s;try{if("idle"!==ne||pe)return;const o=null!=e?e:Ae;if(!o)return;ue(""),je(""),ce(null),Ce(""),Z(!1),de("fetching"),be(),ke();const i=me.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),n=null!==(s=null===(t=null==G?void 0:G.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s&&i.length>0,r=[...Array.from(ie),Object.assign({id:ie.length+1,role:"user",content:o},n&&{documentIds:i})];le(r),ke(),n&&ge([]);const a=(yield Se.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:T,responseId:_,value:o},n&&{documentIds:i}),F&&{userId:F}),H&&{studioUserId:H}),R&&{embedUserId:R}),te&&{studioSessionToken:te}),P&&{deploymentId:P}))).body;if(!a)throw new Error("Streaming error");const l=r.length,d=new TextDecoder,c=a.getReader();let u="",m=!0,p=!1,f=[...null!=ye?ye:[]];const v=k({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");u+=t,le([...r.slice(0,l),{id:ie.length+1,role:"assistant",content:u}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);f=f.filter((e=>!(e.id===t.id&&e.version===t.version))),f.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),we(f),Oe.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);f=f.filter((e=>!(e.id===t.id&&e.version===t.version))),f.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),we(f),Oe.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);f=f.filter((e=>!(e.id===t.id&&e.version===t.version))),f.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),we(f),Oe.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");f=f.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),we(f)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);we(f.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);ue(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(m=!1)}});for(;m;){const{value:e,done:t}=yield c.read();if(t){m=!1;break}const s=d.decode(e);s&&(p||(de("streaming"),p=!0),v.feed(s))}null==ee||ee(_)}catch(e){let t=C(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(re).find((([e])=>t.includes(e)));s?ce(s[1]):ue(t)}finally{ke(),de("idle"),xe()}}));return a((()=>{$(Re)}),[Re]),He?null:s("div",Object.assign({className:B("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!Fe&&"px-4 pb-4"),dir:X?"rtl":"ltr"},{children:o("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!Fe&&s("div",Object.assign({className:B("absolute bottom-full",X?"left-0":"right-0")},{children:o("div",Object.assign({className:B("flex flex-col gap-2 pb-4 px-2",X?"justify-start":"justify-end","viewport"===Q?X?"min-[767px]:items-start":"min-[767px]:items-end":X?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:[!q.isWhiteLabel&&s(A,{containerClassName:"justify-end"}),Re&&!D&&s(w,{data:(null==G?void 0:G.icebreakers)||[],onSend:ze})]}))})),o("div",Object.assign({className:B("flex flex-col gap-y-3 px-4 py-3","block"===K.formFieldStyle&&"shadow"),style:_e},{children:["idle"===ne&&me.length>0&&s(I,{isDisabled:"idle"!==ne}),o("div",Object.assign({className:B("flex items-end gap-x-2",X&&"flex-row-reverse")},{children:[s(N,Object.assign({className:B(Te.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!Ae.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",X?"text-right":"text-left"),value:Ae,placeholder:null!==(W=null==G?void 0:G.placeholdertext)&&void 0!==W?W:X?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>Ce(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),pe||"idle"!==ne||ze()))}},E&&{onFocus:E},U&&{onBlur:U},{dir:X?"rtl":"ltr"})),o("div",Object.assign({className:"flex items-center gap-x-2"},{children:[null!==(L=null===(J=null==G?void 0:G.documentuploadtype)||void 0===J?void 0:J.startsWith("enduserupload"))&&void 0!==L&&L&&o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:Je?M.accent+"10":void 0,color:Je?M.accent:M.accent+"80"},disabled:pe||"idle"!==ne,onClick:()=>{var e;return null===(e=Be.current)||void 0===e?void 0:e.click()}},Le,{children:[s("input",{id:"file-upload",ref:Be,type:"file",accept:[...b,...fe?x:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){Z(!1),yield he(Array.from(e.target.files||[])),e.target.value=""}))}),s(y,{className:"h-6 w-6 shrink-0"})]})),s("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:Ee||Pe?M.accent:M.accent+"10",color:Ee||Pe?M.accentText:M.accent+"80"},disabled:"idle"!==ne||pe,onClick:()=>ze()},Ue,{children:s(O,{className:B("h-6 w-6 shrink-0",X&&"transform scale-x-[-1]")})}))]}))]}))]})),ve&&s(S,{error:ve,className:"mt-3"})]}))}))};export{D as default};
1
+ import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as o,Fragment as n}from"react/jsx-runtime";import{useState as i,useRef as r,useEffect as a,useMemo as l}from"react";import{usePickaxeContext as c}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as d}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as u}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as m}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../hooks/pickaxe/useConversation.js";import{useAuthContext as f}from"../Addons/Auth/hooks/useAuthContext.js";import{useSubmit as g}from"../../../hooks/pickaxe/useSubmit.js";import{useDocument as h}from"../Addons/Document/hooks/useDocument.js";import{useScroll as v}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as b}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as j}from"../../../hooks/core/useHover.js";import{allowedFileMimeTypes as x,allowedImageMimeTypes as k}from"../../../common/documents.js";import{createParser as y}from"eventsource-parser";import O from"../../Icons/attach-vertical.svg.js";import w from"../../Icons/arrow-right.svg.js";import N from"../../Icons/microphone.svg.js";import I from"../../Icons/stop.svg.js";import{useSpeechRecognition as S}from"../../../hooks/pickaxe/useSpeechRecognition.js";import C from"../Addons/IceBreaker/index.js";import A from"../Addons/Document/List.js";import L from"../../Core/Textarea.js";import T from"../../Core/ErrorAlert.js";import B from"../common/PickaxeBranding.js";import D from"../../../common/error.js";import E from"../../../common/cn.js";const H=({colors:e})=>{var t;return o("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 items-center gap-x-2"},{children:[s("span",{className:"h-2 w-2 animate-pulse rounded-full",style:{backgroundColor:null!==(t=e.accent)&&void 0!==t?t:"#ff0000"}}),s("span",Object.assign({className:"text-sm",style:{color:e.text+"90"}},{children:"Listening..."}))]}))},U=({isFocused:U,onFocus:W,onBlur:J})=>{var _,F,R;const{formId:$,chatId:P,userId:z,studioUserId:G,embedUserId:K,deploymentId:M,deploymentType:q,pickaxe:Q,styles:V,colors:X,misc:Y,responsiveBy:Z,isNewChat:ee,isRtl:te,studioLang:se,isEmailLogin:oe,setIsNewChat:ne,setIsShowIceBreaker:ie,onGenerateComplete:re}=c(),{token:ae,isLoggedOut:le,isSent:ce}=f(),{messages:de,status:ue,limits:me,isGenerating:pe,setMessages:fe,setStatus:ge,setLimitData:he,setError:ve}=d(),{documents:be,isUploading:je,isImageUploadAllowed:xe,documentError:ke,onFileUpload:ye,setDocuments:Oe,setDocumentError:we}=h(),{scrollStartSession:Ne,scrollEndSession:Ie,scrollToBottom:Se}=v({auto:!0}),{artifacts:Ce,currentPopupType:Ae,setArtifacts:Le,setCurrentArtifact:Te}=b(),Be=p(),De=g(),[Ee,He]=i(""),Ue=r(null),{isSupported:We,isListening:Je,finalTranscript:_e,interimTranscript:Fe,startListening:Re,stopListening:$e}=S({lang:se||"en"}),Pe=r("");a((()=>{if(Je){const e=`${Pe.current} ${_e} ${Fe}`.trim();He(e)}}),[_e,Fe,Je]),a((()=>{!Je&&Pe.current&&(He(`${Pe.current} ${_e}`.trim()),Pe.current="")}),[Je,_e]);const ze=j(),{isHover:Ge}=ze,Ke=e(ze,["isHover"]),Me=j(),{isHover:qe}=Me,Qe=e(Me,["isHover"]),Ve=j(),{isHover:Xe}=Ve,Ye=e(Ve,["isHover"]),Ze=j(),{isHover:et}=Ze,tt=e(Ze,["isHover"]),st=m(),ot=u(),nt="chat-input"===q&&ee&&!ce,it="chat-input"===q&&oe&&le&&ce,rt=l((()=>{var e,t,s;return!!ee&&(!!Q&&(!Be.isLoading&&(!((null!==(t=null===(e=Be.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(s=Q.icebreakers)||void 0===s?void 0:s.length))))}),[Q,ee,Be.data,Be.isLoading]),at=l((()=>{if(pe||je)return!1;return!!Ee.trim()&&be.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[pe,je,Ee,be]),lt=e=>t(void 0,void 0,void 0,(function*(){var t,s;try{if("idle"!==ue||je||Je)return;const o=null!=e?e:Ee;if(!o)return;ve(""),we(""),he(null),He(""),ne(!1),ge("fetching"),Ne(),Se();const n=be.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),i=null!==(s=null===(t=null==Q?void 0:Q.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s&&n.length>0,r=[...Array.from(de),Object.assign({id:de.length+1,role:"user",content:o},i&&{documentIds:n})];fe(r),Se(),i&&Oe([]);const a=(yield De.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:$,responseId:P,value:o},i&&{documentIds:n}),z&&{userId:z}),G&&{studioUserId:G}),K&&{embedUserId:K}),ae&&{studioSessionToken:ae}),M&&{deploymentId:M}))).body;if(!a)throw new Error("Streaming error");const l=r.length,c=new TextDecoder,d=a.getReader();let u="",m=!0,p=!1,f=[...null!=Ce?Ce:[]];const g=y({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");u+=t,fe([...r.slice(0,l),{id:de.length+1,role:"assistant",content:u}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);f=f.filter((e=>!(e.id===t.id&&e.version===t.version))),f.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Le(f),Ae.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);f=f.filter((e=>!(e.id===t.id&&e.version===t.version))),f.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Le(f),Ae.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);f=f.filter((e=>!(e.id===t.id&&e.version===t.version))),f.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Le(f),Ae.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");f=f.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Le(f)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Le(f.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);ve(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(m=!1)}});for(;m;){const{value:e,done:t}=yield d.read();if(t){m=!1;break}const s=c.decode(e);s&&(p||(ge("streaming"),p=!0),g.feed(s))}null==re||re(P)}catch(e){let t=D(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(me).find((([e])=>t.includes(e)));s?he(s[1]):ve(t)}finally{Se(),ge("idle"),Ie()}}));return a((()=>{ie(rt)}),[rt]),it?null:s("div",Object.assign({className:E("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!nt&&"px-4 pb-4"),dir:te?"rtl":"ltr"},{children:o("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!nt&&s("div",Object.assign({className:E("absolute bottom-full",te?"left-0":"right-0")},{children:o("div",Object.assign({className:E("flex flex-col gap-2 pb-4 px-2",te?"justify-start":"justify-end","viewport"===Z?te?"min-[767px]:items-start":"min-[767px]:items-end":te?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:[!Y.isWhiteLabel&&s(B,{containerClassName:"justify-end"}),rt&&!U&&s(C,{data:(null==Q?void 0:Q.icebreakers)||[],onSend:lt})]}))})),o("div",Object.assign({className:E("flex flex-col gap-y-3 px-4 py-3","block"===V.formFieldStyle&&"shadow"),style:ot},{children:[Je&&s(H,{colors:X}),"idle"===ue&&be.length>0&&s(A,{isDisabled:"idle"!==ue}),o("div",Object.assign({className:E("flex items-end gap-x-2",te&&"flex-row-reverse")},{children:[s(L,Object.assign({className:E(st.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!Ee.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",te?"text-right":"text-left",Je&&"text-transparent"),value:Ee,placeholder:null!==(_=null==Q?void 0:Q.placeholdertext)&&void 0!==_?_:te?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>He(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),je||"idle"!==ue||lt()))}},W&&{onFocus:W},J&&{onBlur:J},{dir:te?"rtl":"ltr"})),s("div",Object.assign({className:"flex items-center gap-x-2"},{children:Je?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",onClick:$e,style:{backgroundColor:et?X.accent:X.accent+"10",color:et?X.accentText:X.accent}},tt,{children:s(I,{className:"h-4 w-4 shrink-0"})})):o(n,{children:[null!==(R=null===(F=null==Q?void 0:Q.documentuploadtype)||void 0===F?void 0:F.startsWith("enduserupload"))&&void 0!==R&&R&&o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:qe?X.accent+"10":void 0,color:qe?X.accent:X.accent+"80"},disabled:je||"idle"!==ue,onClick:()=>{var e;return null===(e=Ue.current)||void 0===e?void 0:e.click()}},Qe,{children:[s("input",{id:"file-upload",ref:Ue,type:"file",accept:[...x,...xe?k:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){ne(!1),yield ye(Array.from(e.target.files||[])),e.target.value=""}))}),s(O,{className:"h-6 w-6 shrink-0"})]})),We&&(null==Q?void 0:Q.enablevoicetotext)&&s("button",Object.assign({className:"flex h-8 w-8 items-center \n justify-center rounded-full\n outline-none transition-colors \n duration-200 ease-in-out\n disabled:cursor-default",style:{backgroundColor:Je?X.accent:Xe?X.accent+"10":void 0,color:Je?X.accentText:Xe?X.accent:X.accent+"80"},disabled:je||"idle"!==ue,onClick:()=>{Je?$e():(Pe.current=Ee,Re())}},Ye,{children:s(N,{className:"h-5 w-5 shrink-0"})})),s("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:Ge||at?X.accent:X.accent+"10",color:Ge||at?X.accentText:X.accent+"80"},disabled:"idle"!==ue||je,onClick:()=>lt()},Ke,{children:s(w,{className:E("h-6 w-6 shrink-0",te&&"transform scale-x-[-1]")})}))]})}))]}))]})),ke&&s(T,{error:ke,className:"mt-3"})]}))}))};export{U as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as i}from"react/jsx-runtime";import{createContext as o,useState as t,useEffect as s}from"react";import{ArtifactProvider as n}from"./Addons/Artifact/Provider.js";import r from"./DimensionProvider.js";import a from"./ResponseProvider.js";import d from"./Addons/Document/Provider.js";import l from"./Addons/Auth/Provider.js";const c=o({}),m=({children:o,userId:m="",studioUserId:p="",deploymentId:h="",embedUserId:y="",deploymentType:f,deploymentDimensions:u,deploymentMisc:b,styles:v,colors:g,limits:I={},misc:F={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:w,artifact:x={popupType:"auto"},responsiveBy:P="viewport",forceMobile:j=!1,disableHtml:C=!1,disableJs:S=!1,disableCss:k=!1,loadFont:D=!0,isRtl:H=!1,isEmbed:R=!1,isDropShadow:E=!1,isEmailLogin:L=!1,onGenerateComplete:O})=>{const[T,A]=t(""),[U,B]=t(""),[M,N]=t(""),[W,G]=t(""),[J,_]=t(null),[z,Y]=t(!1),[q,K]=t(!0),[Q,V]=t(!0);return s((()=>{Y(!1)}),[null==v?void 0:v.font]),s((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&D&&!z&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield import("webfontloader")).default.load({google:{families:[v.font]},active:()=>{Y(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),Y(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),Y(!0)}}))}),[D,z,null==v?void 0:v.font]),i(c.Provider,Object.assign({value:Object.assign({formId:T,chatId:U,lastChatId:M,sessionId:W,userId:m,studioUserId:p,embedUserId:y,deploymentId:h,deploymentType:f,deploymentDimensions:u,deploymentMisc:b,pickaxe:J,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},g),misc:F,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet."},w),artifact:x,responsiveBy:P,forceMobile:j,loadFont:D,disableHtml:C,disableJs:S,disableCss:k,isFontLoaded:z,isNewChat:q,isShowIceBreaker:Q,isRtl:H,isEmbed:R,isDropShadow:E,isEmailLogin:L,setIsFontLoaded:Y,setFormId:A,setChatId:B,setLastChatId:N,setSessionId:G,setPickaxe:_,setIsNewChat:K,setIsShowIceBreaker:V},O&&{onGenerateComplete:O})},{children:i(l,{children:i(r,{children:i(a,Object.assign({limits:I},{children:i(d,{children:i(n,Object.assign({},x,{children:o}))})}))})})}))};export{c as PickaxeContext,m as PickaxeProvider};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as i}from"react/jsx-runtime";import{createContext as o,useState as t,useEffect as s}from"react";import{ArtifactProvider as n}from"./Addons/Artifact/Provider.js";import r from"./DimensionProvider.js";import a from"./ResponseProvider.js";import d from"./Addons/Document/Provider.js";import l from"./Addons/Auth/Provider.js";const c=o({}),m=({children:o,userId:m="",studioUserId:p="",deploymentId:h="",embedUserId:y="",deploymentType:u,deploymentDimensions:f,deploymentMisc:b,styles:g,colors:v,limits:I={},misc:F={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:w,artifact:x={popupType:"auto"},responsiveBy:P="viewport",forceMobile:j=!1,disableHtml:C=!1,disableJs:S=!1,disableCss:k=!1,loadFont:D=!0,isRtl:L=!1,studioLang:H="en",isEmbed:R=!1,isDropShadow:E=!1,isEmailLogin:O=!1,onGenerateComplete:T})=>{const[A,U]=t(""),[B,M]=t(""),[N,W]=t(""),[G,J]=t(""),[_,z]=t(null),[Y,q]=t(!1),[K,Q]=t(!0),[V,X]=t(!0);return s((()=>{q(!1)}),[null==g?void 0:g.font]),s((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&D&&!Y&&(null==g?void 0:g.font)&&"Real Head Pro"!==g.font)try{(yield import("webfontloader")).default.load({google:{families:[g.font]},active:()=>{q(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),q(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),q(!0)}}))}),[D,Y,null==g?void 0:g.font]),i(c.Provider,Object.assign({value:Object.assign({formId:A,chatId:B,lastChatId:N,sessionId:G,userId:m,studioUserId:p,embedUserId:y,deploymentId:h,deploymentType:u,deploymentDimensions:f,deploymentMisc:b,pickaxe:_,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},g),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},v),misc:F,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet."},w),artifact:x,responsiveBy:P,forceMobile:j,loadFont:D,disableHtml:C,disableJs:S,disableCss:k,isFontLoaded:Y,isNewChat:K,isShowIceBreaker:V,isRtl:L,studioLang:H,isEmbed:R,isDropShadow:E,isEmailLogin:O,setIsFontLoaded:q,setFormId:U,setChatId:M,setLastChatId:W,setSessionId:J,setPickaxe:z,setIsNewChat:Q,setIsShowIceBreaker:X},T&&{onGenerateComplete:T})},{children:i(l,{children:i(r,{children:i(a,Object.assign({limits:I},{children:i(d,{children:i(n,Object.assign({},x,{children:o}))})}))})})}))};export{c as PickaxeContext,m as PickaxeProvider};
@@ -0,0 +1 @@
1
+ import{useState as r,useRef as e,useEffect as n,useCallback as t}from"react";const o=()=>globalThis.SpeechRecognition||globalThis.webkitSpeechRecognition,i=(i={})=>{const{lang:s="en"}=i,[c,l]=r(!1),[u,a]=r(""),[p,g]=r(""),[h,d]=r(null),m=e(null);n((()=>{const r=o();if(!r)return void console.warn("SpeechRecognition API is not supported in this browser.");const e=new r;return e.lang=s,e.continuous=!0,e.interimResults=!0,e.onresult=r=>{let e="",n="";for(let t=r.resultIndex;t<r.results.length;++t){const o=r.results[t][0].transcript;r.results[t].isFinal?n+=o+" ":e+=o}g(e),a((r=>r+n))},e.onerror=r=>{console.error("Speech recognition error:",r.error,r.message),d(`Speech recognition error: ${r.error}. Please check microphone permissions.`),l(!1)},e.onend=()=>{l(!1),g("")},m.current=e,()=>{var r;null===(r=m.current)||void 0===r||r.stop()}}),[s]);const S=t((()=>{if(m.current&&!c)try{a(""),g(""),d(null),m.current.start(),l(!0)}catch(r){console.error("Could not start speech recognition:",r),d("Could not start recognition. It might already be active or an error occurred.")}}),[c]),b=t((()=>{m.current&&c&&m.current.stop()}),[c]);return{isSupported:!!o(),isListening:c,finalTranscript:u,interimTranscript:p,error:h,startListening:S,stopListening:b}};export{i as useSpeechRecognition};
@@ -80,6 +80,7 @@ type PickaxeContextType = {
80
80
  isNewChat: boolean;
81
81
  isShowIceBreaker: boolean;
82
82
  isRtl: boolean;
83
+ studioLang: string;
83
84
  isEmbed: boolean;
84
85
  isDropShadow: boolean;
85
86
  isEmailLogin: boolean;
@@ -115,11 +116,12 @@ export interface IPickaxeProviderProps {
115
116
  disableJs?: boolean;
116
117
  disableCss?: boolean;
117
118
  isRtl?: boolean;
119
+ studioLang?: string;
118
120
  isEmbed?: boolean;
119
121
  isDropShadow?: boolean;
120
122
  isEmailLogin?: boolean;
121
123
  onGenerateComplete?: (responseId: string) => void;
122
124
  }
123
125
  export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
124
- export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, embedUserId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, artifact, responsiveBy, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, isEmbed, isDropShadow, isEmailLogin, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
126
+ export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, embedUserId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, artifact, responsiveBy, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, studioLang, isEmbed, isDropShadow, isEmailLogin, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
125
127
  export {};
@@ -26,6 +26,7 @@ export declare const usePickaxeContext: () => {
26
26
  isNewChat: boolean;
27
27
  isShowIceBreaker: boolean;
28
28
  isRtl: boolean;
29
+ studioLang: string;
29
30
  isEmbed: boolean;
30
31
  isDropShadow: boolean;
31
32
  isEmailLogin: boolean;
@@ -0,0 +1,13 @@
1
+ interface SpeechRecognitionOptions {
2
+ lang?: string;
3
+ }
4
+ export declare const useSpeechRecognition: (options?: SpeechRecognitionOptions) => {
5
+ isSupported: boolean;
6
+ isListening: boolean;
7
+ finalTranscript: string;
8
+ interimTranscript: string;
9
+ error: string | null;
10
+ startListening: () => void;
11
+ stopListening: () => void;
12
+ };
13
+ export {};
@@ -20,6 +20,7 @@ export type Pickaxe = {
20
20
  documentuploadtype: PickaxeDocumentUploadType;
21
21
  embedlink: string;
22
22
  enablechatresponses: boolean;
23
+ enablevoicetotext: boolean;
23
24
  featured: boolean;
24
25
  formdescription: string;
25
26
  formtitle: string;
@@ -66,6 +67,7 @@ export type LimitedPickaxe = {
66
67
  chaticon: string;
67
68
  documentuploadtype: PickaxeDocumentUploadType;
68
69
  enablechatresponses: boolean;
70
+ enablevoicetotext: boolean;
69
71
  formdescription: string;
70
72
  formtitle: string;
71
73
  model: PickaxeModel;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "3.10.2",
3
+ "version": "3.11.0",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",