@pickaxeproject/react 4.0.1 → 4.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/_virtual/runtime.js +1 -0
- package/dist/cjs/components/Pickaxe/Addons/Artifact/hooks/useArtifact.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Artifact/hooks/useArtifactData.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/cjs/hooks/pickaxe/useHistory.js +1 -1
- package/dist/cjs/node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js +1 -0
- package/dist/cjs/src/components/Pickaxe/Addons/Artifact/hooks/useArtifactData.d.ts +1 -0
- package/dist/cjs/src/components/Pickaxe/Chat/Input.d.ts +1 -0
- package/dist/esm/_virtual/runtime.js +1 -0
- package/dist/esm/components/Pickaxe/Addons/Artifact/hooks/useArtifact.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Artifact/hooks/useArtifactData.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/hooks/pickaxe/useHistory.js +1 -1
- package/dist/esm/node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js +1 -0
- package/dist/esm/src/components/Pickaxe/Addons/Artifact/hooks/useArtifactData.d.ts +1 -0
- package/dist/esm/src/components/Pickaxe/Chat/Input.d.ts +1 -0
- package/package.json +5 -2
- package/dist/cjs/hooks/pickaxe/useSpeechRecognition.js +0 -1
- package/dist/esm/hooks/pickaxe/useSpeechRecognition.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.__module={exports:{}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../Auth/hooks/useAuthContext.js"),i=require("./useArtifactContext.js"),r=require("./useArtifactData.js");exports.useArtifact=()=>{const{sender:n,senderType:o}=t.usePickaxeContext(),{token:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../Auth/hooks/useAuthContext.js"),i=require("./useArtifactContext.js"),r=require("./useArtifactData.js");exports.useArtifact=()=>{const{sender:n,senderType:o,pickaxe:a}=t.usePickaxeContext(),{token:u}=s.useAuthContext(),{artifacts:c,currentPopupType:d,setArtifacts:f,setCurrentArtifact:j}=i.useArtifactContext(),v=r.useArtifactData();return{onLoadArtifact:(t,s)=>e.__awaiter(void 0,void 0,void 0,(function*(){if(t){if(!c.some((e=>e.id===t.id&&e.version===t.version))){const e=yield v.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({artifactId:t.id},a&&a.studioid&&{studioId:a.studioid}),{senderType:o,version:t.version}),n&&{sender:n}),u&&{studioSessionToken:u}),void 0!==s&&{sender:s}));e&&f((t=>[...t,Object.assign(Object.assign({},e),{status:"finished"})]))}d.startsWith("inline")||j({id:t.id,version:t.version})}else j(null)}))}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("@tanstack/react-query"),r=require("../../../../../common/api/pickaxe.js");exports.useArtifactData=()=>t.useMutation({mutationFn:t=>(({artifactId:t,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("@tanstack/react-query"),r=require("../../../../../common/api/pickaxe.js");exports.useArtifactData=()=>t.useMutation({mutationFn:t=>(({artifactId:t,studioId:a,sender:i,senderType:s,studioSessionToken:o,version:d})=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!t||!d)return Promise.reject(new Error("[_getArtifactData] artifactId and version are required"));let e=`/artifact?artifactId=${t}&senderType=${s}`;a&&(e+=`&studioId=${a}`),i&&(e+=`&sender=${i}`),o&&(e+=`&studioSessionToken=${o}`),d&&(e+=`&version=${d}`);const n=yield r.default.get(e),u=n.data;if(200!==n.status)throw new Error("[_getArtifactData] Failed to fetch artifact "+u);return u.data})))(t)});
|
|
@@ -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"),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"),u=require("../Addons/Document/hooks/useDocument.js"),d=require("../Addons/Scroll/hooks/useScroll.js"),f=require("../Addons/Artifact/hooks/useArtifactContext.js"),p=require("../../../hooks/pickaxe/useSpeechRecognition.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"),j=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),y=require("../../Icons/stop.svg.js"),k=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),w=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),C=require("../../../common/cn.js");const N=s.forwardRef((({onFocus:N,onBlur:I,onInputHeightChange:q},A)=>{var E,_,D;const{origin:R,pickaxeId:T,sessionId:H,sender:W,senderType:F,deploymentId:L,deploymentType:M,pickaxe:P,styles:$,colors:J,locale:B,forceMobile:V,isNewChat:z,isRtl:G,isEmailLogin:U,isShowFeedbackMessage:K,setIsNewChat:Q,setIsShowIceBreaker:X,onGenerateComplete:Y}=n.usePickaxeContext(),{token:Z,isLoggedOut:ee,isSent:te}=l.useAuthContext(),{messages:se,limits:ne,isGenerating:ie,setMessages:re,setStatus:oe,setLimitData:ae,setError:le}=i.useResponseContext(),{documents:ce,isUploading:ue,isImageUploadAllowed:de,documentError:fe,onFileUpload:pe,setDocuments:ge,setDocumentError:he}=u.useDocument(),{scrollStartSession:me,scrollEndSession:ve,scrollToBottom:be}=d.useScroll({auto:!0}),{artifacts:je,currentPopupType:xe,setArtifacts:ye,setCurrentArtifact:ke}=f.useArtifactContext(),Oe=a.useConversation(),we=c.useSubmit(),[Se,Ce]=s.useState(""),[Ne,Ie]=s.useState(!1),[qe,Ae]=s.useState(!1),Ee=s.useRef(null),_e=s.useRef(""),De=s.useRef(null),Re=s.useRef(null),Te=s.useRef(null),{isSupported:He,isListening:We,finalTranscript:Fe,interimTranscript:Le,startListening:Me,stopListening:Pe}=p.useSpeechRecognition({lang:B}),[$e]=h.useMediaQuery("(max-width: 480px)"),Je=g.useHover(),{isHover:Be}=Je,Ve=e.__rest(Je,["isHover"]),ze=g.useHover(),{isHover:Ge}=ze,Ue=e.__rest(ze,["isHover"]),Ke=g.useHover(),{isHover:Qe}=Ke,Xe=e.__rest(Ke,["isHover"]),[Ye,Ze]=s.useState(!1),et=o.useStyleFontSize(),tt=r.useStyleInput(),st=null===(E=null==P?void 0:P.documentuploadtype)||void 0===E?void 0:E.startsWith("enduserupload"),nt=He&&(null==P?void 0:P.enablevoicetotext),it="chat-input"===M&&z&&!te,rt="chat-input"===M&&U&&ee&&te,ot=Ne||qe,at=s.useMemo((()=>{var e,t,s;return!!z&&(!!P&&(!Oe.isLoading&&(!((null!==(t=null===(e=Oe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=P.icebreakers)||void 0===s?void 0:s.length)&&(!K&&!it)))))}),[P,z,K,it,Oe.data,Oe.isLoading]),lt=s.useMemo((()=>{if(ie||ue)return!1;const e=ce.length>0&&ce.every((e=>{var t;return"finished"===e.status&&(null===(t=e.documentId)||void 0===t?void 0:t.startsWith("IMAGE-"))}));return!(!Se.trim()&&!e)&&ce.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ie,ue,Se,ce]);s.useImperativeHandle(A,(()=>({onSubmit:ct}))),s.useEffect((()=>{X(at)}),[at]),s.useEffect((()=>{if(!We)return;const e=`${_e.current} ${Fe} ${Le}`.trim();Ce(e)}),[Fe,Le,We]),s.useEffect((()=>{!We&&_e.current&&(Ce(`${_e.current} ${Fe}`.trim()),_e.current="")}),[We,Fe]),s.useEffect((()=>{if(!Re.current)return;(()=>{if(!Re.current)return;let e=Re.current.scrollHeight>52;Se.includes("\n")||ce.length?e=!0:Se.trim()||(e=!1),Ie(e)})()}),[Se,ce]),s.useEffect((()=>{const e=Re.current,t=Te.current;if(!e||!t||Ne||Se.includes("\n"))return void Ae(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=Se,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;Ae(r>l)}),[Se,Ne]);const ct=t=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;try{if(ie||ue)return;const n=ce.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),i=n.length>0&&n.every((e=>e.startsWith("IMAGE-"))),r=null!=t?t:Se;if(!r&&!i)return;le(""),he(""),ae(null),Ce(""),Q(!1),oe("fetching"),me(),be();const o=null!==(s=null===(e=null==P?void 0:P.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==s&&s&&n.length>0,a=[...Array.from(se),{id:se.length+1,role:"user",parts:[{type:"text",content:r,isVisible:!0}],documentIds:o?n:[]},{id:se.length+2,role:"assistant",parts:[],documentIds:[]}];re(a),be(),o&&ge([]);const l=(yield we.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign({origin:R,pickaxeId:T,sessionId:H,senderType:F,value:r},o&&{documentIds:n}),W&&{sender:W}),Z&&{studioSessionToken:Z}),L&&{deploymentId:L}))).body;if(!l)throw new Error("Streaming error");const c=a.length-1,u=new TextDecoder;De.current=l.getReader();const d=[];let f="",p=!0,g=!1,h=[...null!=je?je:[]];const m=v.createParser({onEvent:e=>{var t,s;if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)f="",d.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t}),re([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:se.length+1,role:"assistant",parts:d})]);else if("text-delta"===n.type)f+=n.delta,d[d.length-1].content=f,re([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:se.length+1,role:"assistant",parts:d})]);else if("text-end"===n.type)f="";else if("reasoning-start"===n.type)f="",d.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s}),re([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:se.length+1,role:"assistant",parts:d})]);else if("reasoning-delta"===n.type)f+=n.delta,d[d.length-1].content=f,re([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:se.length+1,role:"assistant",parts:d})]);else if("reasoning-end"===n.type)f="";else if(n.type.startsWith("data-")){const e=n;d.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0}),re([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:se.length+1,role:"assistant",parts:d})])}}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"})),ye(h),xe.startsWith("inline")||ke({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"})),ye(h),xe.startsWith("inline")||ke({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"})),ye(h),xe.startsWith("inline")||ke({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)),ye(h)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);ye(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);le(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(p=!1)}});for(;p&&De.current;){const{value:e,done:t}=yield De.current.read();if(t){p=!1;break}const s=u.decode(e);s&&(g||(oe("streaming"),g=!0),m.feed(s))}null==Y||Y(H)}catch(e){if("AbortError"===e.name)return;let t=S.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(ne).find((([e])=>t.includes(e)));s?ae(s[1]):le(t)}finally{be(),oe("idle"),ve(),De.current=null}}));return rt?null:t.jsx("div",Object.assign({className:C.default("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!it&&"px-4 pb-4"),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({className:C.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===$.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},tt),Ye&&{backgroundColor:"#EEEEEE"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),Ze(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),Ze(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),Ze(!0)},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),Ze(!1);const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(Q(!1),yield pe(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!==(_=J.accent)&&void 0!==_?_:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:J.text+"90"}},{children:"Listening..."}))]})),!ie&&ce.length>0&&t.jsx(k.default,{className:"p-4 pb-0",isDisabled:ie}),t.jsx(O.default,Object.assign({ref:Re,className:C.default(et.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Se.trim()&&!Se.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap",G?"text-right":"text-left",ot&&"mb-12",We&&"text-transparent"),value:Se,placeholder:null!==(D=null==P?void 0:P.placeholdertext)&&void 0!==D?D:G?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if(Ce(e),q){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void q(0);if(t>=11)return;let s=0;t>1&&(s=50),q(24*(t-1)+s)}},onKeyDown:e=>{V||$e||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ue||ie||ct()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),Q(!1),yield pe(e))}))},N&&{onFocus:N},I&&{onBlur:I},{dir:G?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Te,className:C.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",ot?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!ot&&tt.backgroundColor&&{backgroundColor:tt.backgroundColor}),{borderTopRightRadius:$.cornerRadius+"px",borderBottomRightRadius:$.cornerRadius+"px"})},{children:ie?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:()=>{De.current&&(De.current.cancel(),De.current=null),oe("idle")},style:{backgroundColor:J.accent,color:J.accentText}},{children:t.jsx(y.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:Pe,style:{backgroundColor:J.accent,color:J.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[st&&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?J.accent+"10":void 0,color:Ge?J.accent:J.accent+"80"},disabled:ue||ie,onClick:()=>{var e;return null===(e=Ee.current)||void 0===e?void 0:e.click()}},Ue,{children:[t.jsx("input",{id:"file-upload",ref:Ee,type:"file",accept:[...m.allowedFileMimeTypes,...de?m.allowedImageMimeTypes:[],...m.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Q(!1),yield pe(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),nt&&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?J.accent:Qe?J.accent+"10":void 0,color:We?J.accentText:Qe?J.accent:J.accent+"80"},disabled:ue||ie,onClick:()=>{We?Pe():(_e.current=Se,Me())}},Xe,{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:Be||lt?J.accent:J.accent+"10",color:Be||lt?J.accentText:J.accent+"80"},disabled:!lt,onClick:()=>ct()},Ve,{children:t.jsx(j.default,{className:C.default("h-6 w-6 shrink-0",G&&"scale-x-[-1] transform")})}))]})}))]})),fe&&t.jsx(w.default,{error:fe,className:"mt-3"})]}))}))}));N.displayName="Input",exports.default=N;
|
|
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"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=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("../Addons/Auth/hooks/useAuthContext.js"),u=require("../../../hooks/pickaxe/useSubmit.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"),j=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),y=require("../../Icons/stop.svg.js"),O=require("../Addons/Document/List.js"),k=require("../../Core/Textarea.js"),w=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),C=require("../../../common/cn.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var I=N(n);const q=s.forwardRef((({onFocus:N,onBlur:q,onInputHeightChange:A},E)=>{var _,R,D;const{origin:T,pickaxeId:H,sessionId:W,sender:F,senderType:L,deploymentId:M,deploymentType:P,pickaxe:$,styles:J,colors:B,locale:V,forceMobile:z,isNewChat:U,isRtl:G,isEmailLogin:K,isShowFeedbackMessage:Q,setIsNewChat:X,setIsShowIceBreaker:Y,onGenerateComplete:Z}=i.usePickaxeContext(),{token:ee,isLoggedOut:te,isSent:se}=c.useAuthContext(),{messages:ne,limits:ie,isGenerating:re,setMessages:oe,setStatus:ae,setLimitData:le,setError:ce}=r.useResponseContext(),{documents:ue,isUploading:de,isImageUploadAllowed:fe,documentError:pe,onFileUpload:ge,setDocuments:he,setDocumentError:me}=d.useDocument(),{scrollStartSession:ve,scrollEndSession:be,scrollToBottom:je}=f.useScroll({auto:!0}),{artifacts:xe,currentPopupType:ye,setArtifacts:Oe,setCurrentArtifact:ke}=p.useArtifactContext(),we=l.useConversation(),Se=u.useSubmit(),[Ce,Ne]=s.useState(""),[Ie,qe]=s.useState(!1),[Ae,Ee]=s.useState(!1),_e=s.useRef(null),Re=s.useRef(""),De=s.useRef(null),Te=s.useRef(null),He=s.useRef(null),{transcript:We,listening:Fe,resetTranscript:Le,browserSupportsSpeechRecognition:Me}=n.useSpeechRecognition(),[Pe]=h.useMediaQuery("(max-width: 480px)"),$e=g.useHover(),{isHover:Je}=$e,Be=e.__rest($e,["isHover"]),Ve=g.useHover(),{isHover:ze}=Ve,Ue=e.__rest(Ve,["isHover"]),Ge=g.useHover(),{isHover:Ke}=Ge,Qe=e.__rest(Ge,["isHover"]),[Xe,Ye]=s.useState(!1),Ze=a.useStyleFontSize(),et=o.useStyleInput(),tt=null===(_=null==$?void 0:$.documentuploadtype)||void 0===_?void 0:_.startsWith("enduserupload"),st=Me&&(null==$?void 0:$.enablevoicetotext),nt="chat-input"===P&&U&&!se,it="chat-input"===P&&K&&te&&se,rt=Ie||Ae,ot=s.useMemo((()=>{var e,t,s;return!!U&&(!!$&&(!we.isLoading&&(!((null!==(t=null===(e=we.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=$.icebreakers)||void 0===s?void 0:s.length)&&(!Q&&!nt)))))}),[$,U,Q,nt,we.data,we.isLoading]),at=s.useMemo((()=>{if(re||de)return!1;const e=ue.length>0&&ue.every((e=>{var t;return"finished"===e.status&&(null===(t=e.documentId)||void 0===t?void 0:t.startsWith("IMAGE-"))}));return!(!Ce.trim()&&!e)&&ue.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[re,de,Ce,ue]);s.useImperativeHandle(E,(()=>({onSubmit:lt}))),s.useEffect((()=>{Y(ot)}),[ot]),s.useEffect((()=>{if(!Fe)return;const e=Re.current?`${Re.current} `:"";Ne(`${e}${We}`)}),[We,Fe]),s.useEffect((()=>{if(!Te.current)return;(()=>{if(!Te.current)return;let e=Te.current.scrollHeight>52;Ce.includes("\n")||ue.length?e=!0:Ce.trim()||(e=!1),qe(e)})()}),[Ce,ue]),s.useEffect((()=>{const e=Te.current,t=He.current;if(!e||!t||Ie||Ce.includes("\n"))return void Ee(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=Ce,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;Ee(r>l)}),[Ce,Ie]);const lt=t=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;try{if(re||de)return;const n=ue.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),i=n.length>0&&n.every((e=>e.startsWith("IMAGE-"))),r=null!=t?t:Ce;if(!r&&!i)return;ce(""),me(""),le(null),Ne(""),X(!1),ae("fetching"),ve(),je();const o=null!==(s=null===(e=null==$?void 0:$.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==s&&s&&n.length>0,a=[...Array.from(ne),{id:ne.length+1,role:"user",parts:[{type:"text",content:r,isVisible:!0}],documentIds:o?n:[]},{id:ne.length+2,role:"assistant",parts:[],documentIds:[]}];oe(a),je(),o&&he([]);const l=(yield Se.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign({origin:T,pickaxeId:H,sessionId:W,senderType:L,value:r},o&&{documentIds:n}),F&&{sender:F}),ee&&{studioSessionToken:ee}),M&&{deploymentId:M}))).body;if(!l)throw new Error("Streaming error");const c=a.length-1,u=new TextDecoder;De.current=l.getReader();const d=[];let f="",p=!0,g=!1,h=[...null!=xe?xe:[]];const m=v.createParser({onEvent:e=>{var t,s;if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)f="",d.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t}),oe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ne.length+1,role:"assistant",parts:d})]);else if("text-delta"===n.type)f+=n.delta,d[d.length-1].content=f,oe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ne.length+1,role:"assistant",parts:d})]);else if("text-end"===n.type)f="";else if("reasoning-start"===n.type)f="",d.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s}),oe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ne.length+1,role:"assistant",parts:d})]);else if("reasoning-delta"===n.type)f+=n.delta,d[d.length-1].content=f,oe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ne.length+1,role:"assistant",parts:d})]);else if("reasoning-end"===n.type)f="";else if(n.type.startsWith("data-")){const e=n;d.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0}),oe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ne.length+1,role:"assistant",parts:d})])}}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"})),Oe(h),ye.startsWith("inline")||ke({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"})),Oe(h),ye.startsWith("inline")||ke({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"})),Oe(h),ye.startsWith("inline")||ke({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)),Oe(h)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Oe(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);ce(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(p=!1)}});for(;p&&De.current;){const{value:e,done:t}=yield De.current.read();if(t){p=!1;break}const s=u.decode(e);s&&(g||(ae("streaming"),g=!0),m.feed(s))}null==Z||Z(W)}catch(e){if("AbortError"===e.name)return;let t=S.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(ie).find((([e])=>t.includes(e)));s?le(s[1]):ce(t)}finally{je(),ae("idle"),be(),De.current=null}}));return it?null:t.jsx("div",Object.assign({className:C.default("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!nt&&"px-4 pb-4"),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({className:C.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===J.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},et),Xe&&{backgroundColor:"#EEEEEE"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),Ye(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),Ye(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),Ye(!0)},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),Ye(!1);const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(X(!1),yield ge(e))}))},{children:[Fe&&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!==(R=B.accent)&&void 0!==R?R:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:B.text+"90"}},{children:"Listening..."}))]})),!re&&ue.length>0&&t.jsx(O.default,{className:"p-4 pb-0",isDisabled:re}),t.jsx(k.default,Object.assign({ref:Te,className:C.default(Ze.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ce.trim()&&!Ce.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap",G?"text-right":"text-left",rt&&"mb-12",Fe&&"text-transparent"),value:Ce,placeholder:null!==(D=null==$?void 0:$.placeholdertext)&&void 0!==D?D:G?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if(Ne(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=>{z||Pe||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),de||re||lt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),X(!1),yield ge(e))}))},N&&{onFocus:N},q&&{onBlur:q},{dir:G?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:He,className:C.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",rt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!rt&&et.backgroundColor&&{backgroundColor:et.backgroundColor}),{borderTopRightRadius:J.cornerRadius+"px",borderBottomRightRadius:J.cornerRadius+"px"})},{children:re?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:()=>{De.current&&(De.current.cancel(),De.current=null),ae("idle")},style:{backgroundColor:B.accent,color:B.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):Fe?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:B.accent,color:B.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[tt&&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:ze?B.accent+"10":void 0,color:ze?B.accent:B.accent+"80"},disabled:de||re,onClick:()=>{var e;return null===(e=_e.current)||void 0===e?void 0:e.click()}},Ue,{children:[t.jsx("input",{id:"file-upload",ref:_e,type:"file",accept:[...m.allowedFileMimeTypes,...fe?m.allowedImageMimeTypes:[],...m.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){X(!1),yield ge(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),st&&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:Fe?B.accent:Ke?B.accent+"10":void 0,color:Fe?B.accentText:Ke?B.accent:B.accent+"80"},disabled:de||re,onClick:()=>{Fe?I.default.stopListening():(Re.current=Ce,Le(),I.default.startListening({continuous:!0,interimResults:!0,language:V||"en-US"}))}},Qe,{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:Je||at?B.accent:B.accent+"10",color:Je||at?B.accentText:B.accent+"80"},disabled:!at,onClick:()=>lt()},Be,{children:t.jsx(j.default,{className:C.default("h-6 w-6 shrink-0",G&&"scale-x-[-1] transform")})}))]})}))]})),pe&&t.jsx(w.default,{error:pe,className:"mt-3"})]}))}))}));q.displayName="Input",exports.default=q;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("@tanstack/react-query"),t=require("./usePickaxeContext.js"),r=require("../../components/Pickaxe/Addons/Auth/hooks/useAuthContext.js"),i=require("../../common/api/pickaxe.js");
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("@tanstack/react-query"),t=require("./usePickaxeContext.js"),r=require("../../components/Pickaxe/Addons/Auth/hooks/useAuthContext.js"),i=require("../../common/api/pickaxe.js");const o=({pickaxeId:s,studioId:t,sender:r,senderType:o,studioSessionToken:n,searchQuery:a,place:d})=>e.__awaiter(void 0,void 0,void 0,(function*(){let e=`/history?pickaxeId=${s}&senderType=${o}&place=${d}`;t&&(e+=`&studioId=${t}`),r&&(e+=`&sender=${r}`),n&&(e+=`&studioSessionToken=${n}`),a&&(e+=`&searchQuery=${a}`);const u=yield i.default.get(e),c=u.data;if(200!==u.status)throw new Error("[_getHistory] Failed to fetch history "+c);return{next:c.history.length<3?void 0:d+3,data:c.history}}));exports.useHistory=({enabled:e=!0,searchQuery:i}={enabled:!0})=>{const{pickaxeId:n,sender:a,senderType:d,pickaxe:u}=t.usePickaxeContext(),{token:c}=r.useAuthContext();return s.useInfiniteQuery({queryKey:["form",n,"history"],queryFn:({pageParam:e=0})=>o(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({pickaxeId:n},u&&u.studioid&&{studioId:u.studioid}),a&&{sender:a}),{senderType:d}),c&&{studioSessionToken:c}),i&&{searchQuery:i}),{place:e})),getNextPageParam:e=>e.next,enabled:e&&!!n})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var t=require("../../../../../_virtual/runtime.js");t.__module.exports,function(t){var r=function(t){var r,e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,r,e){t[r]=e.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function l(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{l({},"")}catch(t){l=function(t,r,e){return t[r]=e}}function h(t,r,e,n){var i=r&&r.prototype instanceof d?r:d,a=Object.create(i.prototype),c=new T(n||[]);return o(a,"_invoke",{value:O(t,e,c)}),a}function f(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var s="suspendedStart",p="suspendedYield",y="executing",v="completed",g={};function d(){}function m(){}function w(){}var b={};l(b,a,(function(){return this}));var L=Object.getPrototypeOf,x=L&&L(L(P([])));x&&x!==e&&n.call(x,a)&&(b=x);var E=w.prototype=d.prototype=Object.create(b);function _(t){["next","throw","return"].forEach((function(r){l(t,r,(function(t){return this._invoke(r,t)}))}))}function j(t,r){function e(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&n.call(h,"__await")?r.resolve(h.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(h).then((function(t){l.value=t,a(l)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new r((function(r,o){e(t,n,r,o)}))}return i=i?i.then(o,o):o()}})}function O(t,e,n){var o=s;return function(i,a){if(o===y)throw new Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:r,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===s)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var l=f(t,e,n);if("normal"===l.type){if(o=n.done?v:p,l.arg===g)continue;return{value:l.arg,done:n.done}}"throw"===l.type&&(o=v,n.method="throw",n.arg=l.arg)}}}function k(t,e){var n=e.method,o=t.iterator[n];if(o===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=r,k(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=f(o,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,g):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function G(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function N(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(G,this),this.reset(!0)}function P(t){if(null!=t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function e(){for(;++o<t.length;)if(n.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=r,e.done=!0,e};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return m.prototype=w,o(E,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:m,configurable:!0}),m.displayName=l(w,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===m||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,l(t,u,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},_(j.prototype),l(j.prototype,c,(function(){return this})),t.AsyncIterator=j,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new j(h(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},_(E),l(E,u,"Generator"),l(E,a,(function(){return this})),l(E,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=P,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(N),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function o(n,o){return c.type="throw",c.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),l=n.call(a,"finallyLoc");if(u&&l){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!l)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),g},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),N(e),g}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;N(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:P(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),g}},t}(t.exports);try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}(t.__module),t.__module.exports;
|
|
@@ -2,6 +2,7 @@ import type { ArtifactData } from "../../../../../types/artifact";
|
|
|
2
2
|
import type { PickaxeHistorySenderType } from "../../../../../types/history";
|
|
3
3
|
type MutationParams = {
|
|
4
4
|
artifactId: string;
|
|
5
|
+
studioId?: string;
|
|
5
6
|
sender?: string;
|
|
6
7
|
senderType: PickaxeHistorySenderType;
|
|
7
8
|
studioSessionToken?: string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={exports:{}};export{e as __module};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t}from"../../../../../_virtual/_tslib.js";import{usePickaxeContext as s}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as
|
|
1
|
+
import{__awaiter as t}from"../../../../../_virtual/_tslib.js";import{usePickaxeContext as s}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as i}from"../../Auth/hooks/useAuthContext.js";import{useArtifactContext as e}from"./useArtifactContext.js";import{useArtifactData as o}from"./useArtifactData.js";const n=()=>{const{sender:n,senderType:r,pickaxe:a}=s(),{token:d}=i(),{artifacts:c,currentPopupType:u,setArtifacts:f,setCurrentArtifact:p}=e(),j=o();return{onLoadArtifact:(s,i)=>t(void 0,void 0,void 0,(function*(){if(s){if(!c.some((t=>t.id===s.id&&t.version===s.version))){const t=yield j.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({artifactId:s.id},a&&a.studioid&&{studioId:a.studioid}),{senderType:r,version:s.version}),n&&{sender:n}),d&&{studioSessionToken:d}),void 0!==i&&{sender:i}));t&&f((s=>[...s,Object.assign(Object.assign({},t),{status:"finished"})]))}u.startsWith("inline")||p({id:s.id,version:s.version})}else p(null)}))}};export{n as useArtifact};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as t}from"../../../../../_virtual/_tslib.js";import{useMutation as r}from"@tanstack/react-query";import e from"../../../../../common/api/pickaxe.js";const i=()=>r({mutationFn:r=>(({artifactId:r,
|
|
1
|
+
import{__awaiter as t}from"../../../../../_virtual/_tslib.js";import{useMutation as r}from"@tanstack/react-query";import e from"../../../../../common/api/pickaxe.js";const i=()=>r({mutationFn:r=>(({artifactId:r,studioId:i,sender:o,senderType:a,studioSessionToken:n,version:s})=>t(void 0,void 0,void 0,(function*(){if(!r||!s)return Promise.reject(new Error("[_getArtifactData] artifactId and version are required"));let t=`/artifact?artifactId=${r}&senderType=${a}`;i&&(t+=`&studioId=${i}`),o&&(t+=`&sender=${o}`),n&&(t+=`&studioSessionToken=${n}`),s&&(t+=`&version=${s}`);const d=yield e.get(t),c=d.data;if(200!==d.status)throw new Error("[_getArtifactData] Failed to fetch artifact "+c);return c.data})))(r)});export{i as useArtifactData};
|
|
@@ -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{usePickaxeContext as u}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as p}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as m}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as f}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as g}from"../../../hooks/pickaxe/useConversation.js";import{useAuthContext as h}from"../Addons/Auth/hooks/useAuthContext.js";import{useSubmit as v}from"../../../hooks/pickaxe/useSubmit.js";import{useDocument as b}from"../Addons/Document/hooks/useDocument.js";import{useScroll as y}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as j}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useSpeechRecognition as x}from"../../../hooks/pickaxe/useSpeechRecognition.js";import{useHover as k}from"../../../hooks/core/useHover.js";import{useMediaQuery as O}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as w,allowedImageMimeTypes as S,additionalAllowedFileExtensions as C}from"../../../common/documents.js";import{createParser as N}from"eventsource-parser";import I from"../../Icons/attach-vertical.svg.js";import A from"../../Icons/arrow-right.svg.js";import D from"../../Icons/microphone.svg.js";import E from"../../Icons/stop.svg.js";import T from"../Addons/Document/List.js";import W from"../../Core/Textarea.js";import R from"../../Core/ErrorAlert.js";import L from"../../../common/error.js";import $ from"../../../common/cn.js";const H=i((({onFocus:i,onBlur:H,onInputHeightChange:F},J)=>{var P,B,V;const{origin:_,pickaxeId:M,sessionId:z,sender:G,senderType:U,deploymentId:K,deploymentType:Q,pickaxe:q,styles:X,colors:Y,locale:Z,forceMobile:ee,isNewChat:te,isRtl:se,isEmailLogin:ne,isShowFeedbackMessage:oe,setIsNewChat:ie,setIsShowIceBreaker:re,onGenerateComplete:ae}=u(),{token:le,isLoggedOut:ce,isSent:de}=h(),{messages:ue,limits:pe,isGenerating:me,setMessages:fe,setStatus:ge,setLimitData:he,setError:ve}=p(),{documents:be,isUploading:ye,isImageUploadAllowed:je,documentError:xe,onFileUpload:ke,setDocuments:Oe,setDocumentError:we}=b(),{scrollStartSession:Se,scrollEndSession:Ce,scrollToBottom:Ne}=y({auto:!0}),{artifacts:Ie,currentPopupType:Ae,setArtifacts:De,setCurrentArtifact:Ee}=j(),Te=g(),We=v(),[Re,Le]=r(""),[$e,He]=r(!1),[Fe,Je]=r(!1),Pe=a(null),Be=a(""),Ve=a(null),_e=a(null),Me=a(null),{isSupported:ze,isListening:Ge,finalTranscript:Ue,interimTranscript:Ke,startListening:Qe,stopListening:qe}=x({lang:Z}),[Xe]=O("(max-width: 480px)"),Ye=k(),{isHover:Ze}=Ye,et=e(Ye,["isHover"]),tt=k(),{isHover:st}=tt,nt=e(tt,["isHover"]),ot=k(),{isHover:it}=ot,rt=e(ot,["isHover"]),[at,lt]=r(!1),ct=f(),dt=m(),ut=null===(P=null==q?void 0:q.documentuploadtype)||void 0===P?void 0:P.startsWith("enduserupload"),pt=ze&&(null==q?void 0:q.enablevoicetotext),mt="chat-input"===Q&&te&&!de,ft="chat-input"===Q&&ne&&ce&&de,gt=$e||Fe,ht=l((()=>{var e,t,s;return!!te&&(!!q&&(!Te.isLoading&&(!((null!==(t=null===(e=Te.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)&&(!oe&&!mt)))))}),[q,te,oe,mt,Te.data,Te.isLoading]),vt=l((()=>{if(me||ye)return!1;const e=be.length>0&&be.every((e=>{var t;return"finished"===e.status&&(null===(t=e.documentId)||void 0===t?void 0:t.startsWith("IMAGE-"))}));return!(!Re.trim()&&!e)&&be.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[me,ye,Re,be]);c(J,(()=>({onSubmit:bt}))),d((()=>{re(ht)}),[ht]),d((()=>{if(!Ge)return;const e=`${Be.current} ${Ue} ${Ke}`.trim();Le(e)}),[Ue,Ke,Ge]),d((()=>{!Ge&&Be.current&&(Le(`${Be.current} ${Ue}`.trim()),Be.current="")}),[Ge,Ue]),d((()=>{if(!_e.current)return;(()=>{if(!_e.current)return;let e=_e.current.scrollHeight>52;Re.includes("\n")||be.length?e=!0:Re.trim()||(e=!1),He(e)})()}),[Re,be]),d((()=>{const e=_e.current,t=Me.current;if(!e||!t||$e||Re.includes("\n"))return void Je(!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=Re,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;Je(i>l)}),[Re,$e]);const bt=e=>t(void 0,void 0,void 0,(function*(){var t,s;try{if(me||ye)return;const n=be.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),o=n.length>0&&n.every((e=>e.startsWith("IMAGE-"))),i=null!=e?e:Re;if(!i&&!o)return;ve(""),we(""),he(null),Le(""),ie(!1),ge("fetching"),Se(),Ne();const r=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,a=[...Array.from(ue),{id:ue.length+1,role:"user",parts:[{type:"text",content:i,isVisible:!0}],documentIds:r?n:[]},{id:ue.length+2,role:"assistant",parts:[],documentIds:[]}];fe(a),Ne(),r&&Oe([]);const l=(yield We.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign({origin:_,pickaxeId:M,sessionId:z,senderType:U,value:i},r&&{documentIds:n}),G&&{sender:G}),le&&{studioSessionToken:le}),K&&{deploymentId:K}))).body;if(!l)throw new Error("Streaming error");const c=a.length-1,d=new TextDecoder;Ve.current=l.getReader();const u=[];let p="",m=!0,f=!1,g=[...null!=Ie?Ie:[]];const h=N({onEvent:e=>{var t,s;if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)p="",u.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t}),fe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ue.length+1,role:"assistant",parts:u})]);else if("text-delta"===n.type)p+=n.delta,u[u.length-1].content=p,fe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ue.length+1,role:"assistant",parts:u})]);else if("text-end"===n.type)p="";else if("reasoning-start"===n.type)p="",u.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s}),fe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ue.length+1,role:"assistant",parts:u})]);else if("reasoning-delta"===n.type)p+=n.delta,u[u.length-1].content=p,fe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ue.length+1,role:"assistant",parts:u})]);else if("reasoning-end"===n.type)p="";else if(n.type.startsWith("data-")){const e=n;u.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0}),fe([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:ue.length+1,role:"assistant",parts:u})])}}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"})),De(g),Ae.startsWith("inline")||Ee({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"})),De(g),Ae.startsWith("inline")||Ee({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"})),De(g),Ae.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,"");g=g.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),De(g)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);De(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);ve(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(m=!1)}});for(;m&&Ve.current;){const{value:e,done:t}=yield Ve.current.read();if(t){m=!1;break}const s=d.decode(e);s&&(f||(ge("streaming"),f=!0),h.feed(s))}null==ae||ae(z)}catch(e){if("AbortError"===e.name)return;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 s=Object.entries(pe).find((([e])=>t.includes(e)));s?he(s[1]):ve(t)}finally{Ne(),ge("idle"),Ce(),Ve.current=null}}));return ft?null:s("div",Object.assign({className:$("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!mt&&"px-4 pb-4"),dir:se?"rtl":"ltr"},{children:n("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[n("div",Object.assign({className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===X.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},dt),at&&{backgroundColor:"#EEEEEE"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),lt(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),lt(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),lt(!0)},onDrop:e=>t(void 0,void 0,void 0,(function*(){e.preventDefault(),e.stopPropagation(),lt(!1);const t=Array.from(e.dataTransfer.files||[]);t.length>0&&(ie(!1),yield ke(t))}))},{children:[Ge&&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!==(B=Y.accent)&&void 0!==B?B:"#ff0000"}}),s("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:Y.text+"90"}},{children:"Listening..."}))]})),!me&&be.length>0&&s(T,{className:"p-4 pb-0",isDisabled:me}),s(W,Object.assign({ref:_e,className:$(ct.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Re.trim()&&!Re.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap",se?"text-right":"text-left",gt&&"mb-12",Ge&&"text-transparent"),value:Re,placeholder:null!==(V=null==q?void 0:q.placeholdertext)&&void 0!==V?V:se?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if(Le(e),F){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void F(0);if(t>=11)return;let s=0;t>1&&(s=50),F(24*(t-1)+s)}},onKeyDown:e=>{ee||Xe||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ye||me||bt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),ie(!1),yield ke(t))}))},i&&{onFocus:i},H&&{onBlur:H},{dir:se?"rtl":"ltr"})),s("div",Object.assign({ref:Me,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",gt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!gt&&dt.backgroundColor&&{backgroundColor:dt.backgroundColor}),{borderTopRightRadius:X.cornerRadius+"px",borderBottomRightRadius:X.cornerRadius+"px"})},{children:me?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:()=>{Ve.current&&(Ve.current.cancel(),Ve.current=null),ge("idle")},style:{backgroundColor:Y.accent,color:Y.accentText}},{children:s(E,{className:"h-4 w-4 shrink-0"})})):Ge?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:qe,style:{backgroundColor:Y.accent,color:Y.accentText}},{children:s(E,{className:"h-4 w-4 shrink-0"})})):n(o,{children:[ut&&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:st?Y.accent+"10":void 0,color:st?Y.accent:Y.accent+"80"},disabled:ye||me,onClick:()=>{var e;return null===(e=Pe.current)||void 0===e?void 0:e.click()}},nt,{children:[s("input",{id:"file-upload",ref:Pe,type:"file",accept:[...w,...je?S:[],...C].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){ie(!1),yield ke(Array.from(e.target.files||[])),e.target.value=""}))}),s(I,{className:"h-6 w-6 shrink-0"})]})),pt&&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:Ge?Y.accent:it?Y.accent+"10":void 0,color:Ge?Y.accentText:it?Y.accent:Y.accent+"80"},disabled:ye||me,onClick:()=>{Ge?qe():(Be.current=Re,Qe())}},rt,{children:s(D,{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:Ze||vt?Y.accent:Y.accent+"10",color:Ze||vt?Y.accentText:Y.accent+"80"},disabled:!vt,onClick:()=>bt()},et,{children:s(A,{className:$("h-6 w-6 shrink-0",se&&"scale-x-[-1] transform")})}))]})}))]})),xe&&s(R,{error:xe,className:"mt-3"})]}))}))}));H.displayName="Input";export{H 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 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 p}from"react-speech-recognition";import{usePickaxeContext as m}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{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import{useSubmit as y}from"../../../hooks/pickaxe/useSubmit.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 k}from"../../../hooks/core/useHover.js";import{useMediaQuery as w}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 A from"../../Icons/attach-vertical.svg.js";import D from"../../Icons/arrow-right.svg.js";import E from"../../Icons/microphone.svg.js";import T from"../../Icons/stop.svg.js";import R from"../Addons/Document/List.js";import W from"../../Core/Textarea.js";import L from"../../Core/ErrorAlert.js";import H from"../../../common/error.js";import F from"../../../common/cn.js";const $=i((({onFocus:i,onBlur:$,onInputHeightChange:_},J)=>{var P,B,V;const{origin:M,pickaxeId:U,sessionId:z,sender:G,senderType:K,deploymentId:Q,deploymentType:q,pickaxe:X,styles:Y,colors:Z,locale:ee,forceMobile:te,isNewChat:ne,isRtl:se,isEmailLogin:oe,isShowFeedbackMessage:ie,setIsNewChat:re,setIsShowIceBreaker:ae,onGenerateComplete:le}=m(),{token:ce,isLoggedOut:de,isSent:ue}=b(),{messages:pe,limits:me,isGenerating:fe,setMessages:ge,setStatus:he,setLimitData:ve,setError:be}=f(),{documents:ye,isUploading:je,isImageUploadAllowed:xe,documentError:Oe,onFileUpload:ke,setDocuments:we,setDocumentError:Se}=j(),{scrollStartSession:Ce,scrollEndSession:Ne,scrollToBottom:Ie}=x({auto:!0}),{artifacts:Ae,currentPopupType:De,setArtifacts:Ee,setCurrentArtifact:Te}=O(),Re=v(),We=y(),[Le,He]=r(""),[Fe,$e]=r(!1),[_e,Je]=r(!1),Pe=a(null),Be=a(""),Ve=a(null),Me=a(null),Ue=a(null),{transcript:ze,listening:Ge,resetTranscript:Ke,browserSupportsSpeechRecognition:Qe}=p(),[qe]=w("(max-width: 480px)"),Xe=k(),{isHover:Ye}=Xe,Ze=e(Xe,["isHover"]),et=k(),{isHover:tt}=et,nt=e(et,["isHover"]),st=k(),{isHover:ot}=st,it=e(st,["isHover"]),[rt,at]=r(!1),lt=h(),ct=g(),dt=null===(P=null==X?void 0:X.documentuploadtype)||void 0===P?void 0:P.startsWith("enduserupload"),ut=Qe&&(null==X?void 0:X.enablevoicetotext),pt="chat-input"===q&&ne&&!ue,mt="chat-input"===q&&oe&&de&&ue,ft=Fe||_e,gt=l((()=>{var e,t,n;return!!ne&&(!!X&&(!Re.isLoading&&(!((null!==(t=null===(e=Re.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=X.icebreakers)||void 0===n?void 0:n.length)&&(!ie&&!pt)))))}),[X,ne,ie,pt,Re.data,Re.isLoading]),ht=l((()=>{if(fe||je)return!1;const e=ye.length>0&&ye.every((e=>{var t;return"finished"===e.status&&(null===(t=e.documentId)||void 0===t?void 0:t.startsWith("IMAGE-"))}));return!(!Le.trim()&&!e)&&ye.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[fe,je,Le,ye]);c(J,(()=>({onSubmit:vt}))),d((()=>{ae(gt)}),[gt]),d((()=>{if(!Ge)return;const e=Be.current?`${Be.current} `:"";He(`${e}${ze}`)}),[ze,Ge]),d((()=>{if(!Me.current)return;(()=>{if(!Me.current)return;let e=Me.current.scrollHeight>52;Le.includes("\n")||ye.length?e=!0:Le.trim()||(e=!1),$e(e)})()}),[Le,ye]),d((()=>{const e=Me.current,t=Ue.current;if(!e||!t||Fe||Le.includes("\n"))return void Je(!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 i=o.offsetWidth;o.remove();const r=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Je(i>l)}),[Le,Fe]);const vt=e=>t(void 0,void 0,void 0,(function*(){var t,n;try{if(fe||je)return;const s=ye.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),o=s.length>0&&s.every((e=>e.startsWith("IMAGE-"))),i=null!=e?e:Le;if(!i&&!o)return;be(""),Se(""),ve(null),He(""),re(!1),he("fetching"),Ce(),Ie();const r=null!==(n=null===(t=null==X?void 0:X.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==n&&n&&s.length>0,a=[...Array.from(pe),{id:pe.length+1,role:"user",parts:[{type:"text",content:i,isVisible:!0}],documentIds:r?s:[]},{id:pe.length+2,role:"assistant",parts:[],documentIds:[]}];ge(a),Ie(),r&&we([]);const l=(yield We.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign({origin:M,pickaxeId:U,sessionId:z,senderType:K,value:i},r&&{documentIds:s}),G&&{sender:G}),ce&&{studioSessionToken:ce}),Q&&{deploymentId:Q}))).body;if(!l)throw new Error("Streaming error");const c=a.length-1,d=new TextDecoder;Ve.current=l.getReader();const u=[];let p="",m=!0,f=!1,g=[...null!=Ae?Ae:[]];const h=I({onEvent:e=>{var t,n;if("delta"===e.event){const s=JSON.parse(e.data);if("text-start"===s.type)p="",u.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t}),ge([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:pe.length+1,role:"assistant",parts:u})]);else if("text-delta"===s.type)p+=s.delta,u[u.length-1].content=p,ge([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:pe.length+1,role:"assistant",parts:u})]);else if("text-end"===s.type)p="";else if("reasoning-start"===s.type)p="",u.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n}),ge([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:pe.length+1,role:"assistant",parts:u})]);else if("reasoning-delta"===s.type)p+=s.delta,u[u.length-1].content=p,ge([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:pe.length+1,role:"assistant",parts:u})]);else if("reasoning-end"===s.type)p="";else if(s.type.startsWith("data-")){const e=s;u.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0}),ge([...a.slice(0,c),Object.assign(Object.assign({},a[a.length-1]),{id:pe.length+1,role:"assistant",parts:u})])}}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"})),Ee(g),De.startsWith("inline")||Te({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"})),Ee(g),De.startsWith("inline")||Te({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"})),Ee(g),De.startsWith("inline")||Te({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)),Ee(g)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ee(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);be(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(m=!1)}});for(;m&&Ve.current;){const{value:e,done:t}=yield Ve.current.read();if(t){m=!1;break}const n=d.decode(e);n&&(f||(he("streaming"),f=!0),h.feed(n))}null==le||le(z)}catch(e){if("AbortError"===e.name)return;let t=H(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(me).find((([e])=>t.includes(e)));n?ve(n[1]):be(t)}finally{Ie(),he("idle"),Ne(),Ve.current=null}}));return mt?null:n("div",Object.assign({className:F("z-1 absolute bottom-0 left-0 flex w-full flex-col items-center",!pt&&"px-4 pb-4"),dir:se?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[s("div",Object.assign({className:F("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===Y.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},ct),rt&&{backgroundColor:"#EEEEEE"}),onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),at(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),at(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation(),at(!0)},onDrop:e=>t(void 0,void 0,void 0,(function*(){e.preventDefault(),e.stopPropagation(),at(!1);const t=Array.from(e.dataTransfer.files||[]);t.length>0&&(re(!1),yield ke(t))}))},{children:[Ge&&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!==(B=Z.accent)&&void 0!==B?B:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:Z.text+"90"}},{children:"Listening..."}))]})),!fe&&ye.length>0&&n(R,{className:"p-4 pb-0",isDisabled:fe}),n(W,Object.assign({ref:Me,className:F(lt.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",se?"text-right":"text-left",ft&&"mb-12",Ge&&"text-transparent"),value:Le,placeholder:null!==(V=null==X?void 0:X.placeholdertext)&&void 0!==V?V:se?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>{if(He(e),_){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void _(0);if(t>=11)return;let n=0;t>1&&(n=50),_(24*(t-1)+n)}},onKeyDown:e=>{te||qe||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),je||fe||vt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),re(!1),yield ke(t))}))},i&&{onFocus:i},$&&{onBlur:$},{dir:se?"rtl":"ltr"})),n("div",Object.assign({ref:Ue,className:F("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",ft?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!ft&&ct.backgroundColor&&{backgroundColor:ct.backgroundColor}),{borderTopRightRadius:Y.cornerRadius+"px",borderBottomRightRadius:Y.cornerRadius+"px"})},{children:fe?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.cancel(),Ve.current=null),he("idle")},style:{backgroundColor:Z.accent,color:Z.accentText}},{children:n(T,{className:"h-4 w-4 shrink-0"})})):Ge?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:Z.accent,color:Z.accentText}},{children:n(T,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[dt&&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:tt?Z.accent+"10":void 0,color:tt?Z.accent:Z.accent+"80"},disabled:je||fe,onClick:()=>{var e;return null===(e=Pe.current)||void 0===e?void 0:e.click()}},nt,{children:[n("input",{id:"file-upload",ref:Pe,type:"file",accept:[...S,...xe?C:[],...N].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){re(!1),yield ke(Array.from(e.target.files||[])),e.target.value=""}))}),n(A,{className:"h-6 w-6 shrink-0"})]})),ut&&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:Ge?Z.accent:ot?Z.accent+"10":void 0,color:Ge?Z.accentText:ot?Z.accent:Z.accent+"80"},disabled:je||fe,onClick:()=>{Ge?u.stopListening():(Be.current=Le,Ke(),u.startListening({continuous:!0,interimResults:!0,language:ee||"en-US"}))}},it,{children:n(E,{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:Ye||ht?Z.accent:Z.accent+"10",color:Ye||ht?Z.accentText:Z.accent+"80"},disabled:!ht,onClick:()=>vt()},Ze,{children:n(D,{className:F("h-6 w-6 shrink-0",se&&"scale-x-[-1] transform")})}))]})}))]})),Oe&&n(L,{error:Oe,className:"mt-3"})]}))}))}));$.displayName="Input";export{$ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{useInfiniteQuery as
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{useInfiniteQuery as s}from"@tanstack/react-query";import{usePickaxeContext as t}from"./usePickaxeContext.js";import{useAuthContext as o}from"../../components/Pickaxe/Addons/Auth/hooks/useAuthContext.js";import i from"../../common/api/pickaxe.js";const r=({enabled:r=!0,searchQuery:n}={enabled:!0})=>{const{pickaxeId:a,sender:d,senderType:c,pickaxe:u}=t(),{token:p}=o(),y=s({queryKey:["form",a,"history"],queryFn:({pageParam:s=0})=>(({pickaxeId:s,studioId:t,sender:o,senderType:r,studioSessionToken:n,searchQuery:a,place:d})=>e(void 0,void 0,void 0,(function*(){let e=`/history?pickaxeId=${s}&senderType=${r}&place=${d}`;t&&(e+=`&studioId=${t}`),o&&(e+=`&sender=${o}`),n&&(e+=`&studioSessionToken=${n}`),a&&(e+=`&searchQuery=${a}`);const c=yield i.get(e),u=c.data;if(200!==c.status)throw new Error("[_getHistory] Failed to fetch history "+u);return{next:u.history.length<3?void 0:d+3,data:u.history}})))(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({pickaxeId:a},u&&u.studioid&&{studioId:u.studioid}),d&&{sender:d}),{senderType:c}),p&&{studioSessionToken:p}),n&&{searchQuery:n}),{place:s})),getNextPageParam:e=>e.next,enabled:r&&!!a});return y};export{r as useHistory};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__module as t}from"../../../../../_virtual/runtime.js";t.exports,function(t){var r=function(t){var r,e=Object.prototype,n=e.hasOwnProperty,o=Object.defineProperty||function(t,r,e){t[r]=e.value},i="function"==typeof Symbol?Symbol:{},a=i.iterator||"@@iterator",c=i.asyncIterator||"@@asyncIterator",u=i.toStringTag||"@@toStringTag";function h(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{h({},"")}catch(t){h=function(t,r,e){return t[r]=e}}function l(t,r,e,n){var i=r&&r.prototype instanceof d?r:d,a=Object.create(i.prototype),c=new T(n||[]);return o(a,"_invoke",{value:O(t,e,c)}),a}function f(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=l;var s="suspendedStart",p="suspendedYield",y="executing",v="completed",g={};function d(){}function m(){}function w(){}var b={};h(b,a,(function(){return this}));var L=Object.getPrototypeOf,x=L&&L(L(P([])));x&&x!==e&&n.call(x,a)&&(b=x);var E=w.prototype=d.prototype=Object.create(b);function _(t){["next","throw","return"].forEach((function(r){h(t,r,(function(t){return this._invoke(r,t)}))}))}function j(t,r){function e(o,i,a,c){var u=f(t[o],t,i);if("throw"!==u.type){var h=u.arg,l=h.value;return l&&"object"==typeof l&&n.call(l,"__await")?r.resolve(l.__await).then((function(t){e("next",t,a,c)}),(function(t){e("throw",t,a,c)})):r.resolve(l).then((function(t){h.value=t,a(h)}),(function(t){return e("throw",t,a,c)}))}c(u.arg)}var i;o(this,"_invoke",{value:function(t,n){function o(){return new r((function(r,o){e(t,n,r,o)}))}return i=i?i.then(o,o):o()}})}function O(t,e,n){var o=s;return function(i,a){if(o===y)throw new Error("Generator is already running");if(o===v){if("throw"===i)throw a;return{value:r,done:!0}}for(n.method=i,n.arg=a;;){var c=n.delegate;if(c){var u=k(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===s)throw o=v,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=y;var h=f(t,e,n);if("normal"===h.type){if(o=n.done?v:p,h.arg===g)continue;return{value:h.arg,done:n.done}}"throw"===h.type&&(o=v,n.method="throw",n.arg=h.arg)}}}function k(t,e){var n=e.method,o=t.iterator[n];if(o===r)return e.delegate=null,"throw"===n&&t.iterator.return&&(e.method="return",e.arg=r,k(t,e),"throw"===e.method)||"return"!==n&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var i=f(o,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,g;var a=i.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=r),e.delegate=null,g):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,g)}function G(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function N(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(G,this),this.reset(!0)}function P(t){if(null!=t){var e=t[a];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function e(){for(;++o<t.length;)if(n.call(t,o))return e.value=t[o],e.done=!1,e;return e.value=r,e.done=!0,e};return i.next=i}}throw new TypeError(typeof t+" is not iterable")}return m.prototype=w,o(E,"constructor",{value:w,configurable:!0}),o(w,"constructor",{value:m,configurable:!0}),m.displayName=h(w,u,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===m||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,w):(t.__proto__=w,h(t,u,"GeneratorFunction")),t.prototype=Object.create(E),t},t.awrap=function(t){return{__await:t}},_(j.prototype),h(j.prototype,c,(function(){return this})),t.AsyncIterator=j,t.async=function(r,e,n,o,i){void 0===i&&(i=Promise);var a=new j(l(r,e,n,o),i);return t.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},_(E),h(E,u,"Generator"),h(E,a,(function(){return this})),h(E,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var r=Object(t),e=[];for(var n in r)e.push(n);return e.reverse(),function t(){for(;e.length;){var n=e.pop();if(n in r)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=P,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=r,this.done=!1,this.delegate=null,this.method="next",this.arg=r,this.tryEntries.forEach(N),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=r)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function o(n,o){return c.type="throw",c.arg=t,e.next=n,o&&(e.method="next",e.arg=r),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],c=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),h=n.call(a,"finallyLoc");if(u&&h){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!h)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,r){for(var e=this.tryEntries.length-1;e>=0;--e){var o=this.tryEntries[e];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=r&&r<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=r,i?(this.method="next",this.next=i.finallyLoc,g):this.complete(a)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),g},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),N(e),g}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;N(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:P(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=r),g}},t}(t.exports);try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}(t),t.exports;
|
|
@@ -2,6 +2,7 @@ import type { ArtifactData } from "../../../../../types/artifact";
|
|
|
2
2
|
import type { PickaxeHistorySenderType } from "../../../../../types/history";
|
|
3
3
|
type MutationParams = {
|
|
4
4
|
artifactId: string;
|
|
5
|
+
studioId?: string;
|
|
5
6
|
sender?: string;
|
|
6
7
|
senderType: PickaxeHistorySenderType;
|
|
7
8
|
studioSessionToken?: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pickaxeproject/react",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.1.1",
|
|
4
4
|
"description": "Client utility library for Pickaxe",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,7 +32,10 @@
|
|
|
32
32
|
"not op_mini all"
|
|
33
33
|
],
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@babel/runtime": "^7.20.7"
|
|
35
|
+
"@babel/runtime": "^7.20.7",
|
|
36
|
+
"@types/react-speech-recognition": "^3.9.6",
|
|
37
|
+
"react-speech-recognition": "^4.0.1",
|
|
38
|
+
"regenerator-runtime": "^0.14.1"
|
|
36
39
|
},
|
|
37
40
|
"devDependencies": {
|
|
38
41
|
"@babel/core": "^7.20.12",
|
|
@@ -1 +0,0 @@
|
|
|
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}};
|
|
@@ -1 +0,0 @@
|
|
|
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};
|