@pickaxeproject/react 6.1.1 → 6.2.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/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Input.js +1 -1
- package/dist/cjs/hooks/pickaxe/useSpeech.js +1 -0
- package/dist/cjs/src/components/Pickaxe/Chat/Input.d.ts +0 -1
- package/dist/cjs/src/components/Pickaxe/Form/Questions/Input.d.ts +0 -1
- package/dist/cjs/src/hooks/pickaxe/useSpeech.d.ts +9 -0
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Input.js +1 -1
- package/dist/esm/hooks/pickaxe/useSpeech.js +1 -0
- package/dist/esm/src/components/Pickaxe/Chat/Input.d.ts +0 -1
- package/dist/esm/src/components/Pickaxe/Form/Questions/Input.d.ts +0 -1
- package/dist/esm/src/hooks/pickaxe/useSpeech.d.ts +9 -0
- package/package.json +211 -207
- package/dist/cjs/src/hooks/pickaxe/useSpeechRecognition.d.ts +0 -13
- package/dist/esm/src/hooks/pickaxe/useSpeechRecognition.d.ts +0 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react");require("../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var n=require("react-speech-recognition"),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("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),u=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),g=require("../../../hooks/core/useMediaQuery.js"),h=require("../../../common/documents.js"),v=require("eventsource-parser"),b=require("../../Icons/attach-vertical.svg.js"),x=require("../../Icons/arrow-right.svg.js"),j=require("../../Icons/microphone.svg.js"),y=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),k=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),C=require("../../../common/validation.js"),N=require("../../../common/cn.js"),I=require("../../../common/utils.js"),_=require("../../../hooks/studio/useStudio.js");function E(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var T=E(n);const A=s.forwardRef((({resubmitPrompt:E,onFocus:A,onBlur:R,onInputHeightChange:q,initSmitheryAuthData:P},D)=>{var U,L,M;const{origin:$,pickaxeId:F,sessionId:B,sender:H,senderType:V,portalId:X,deploymentId:K,deploymentType:W,pickaxe:J,styles:z,colors:G,locale:Q,forceMobile:Y,isNewChat:Z,isRtl:ee,isShowFeedbackMessage:te,accessGroup:se,setIsNewChat:ne,setIsShowIceBreaker:ie,setValidationStatus:re,setValidationUpgradeGroups:oe,setValidationUpgradeUrl:ae,onGenerateComplete:le}=i.usePickaxeContext(),{token:ce,isLoggedOut:de,isSent:ue,isPricingAuth:fe}=d.useAuthContext(),{messages:pe,isGenerating:me,setMessages:ge,setStatus:he,setLimitData:ve,setError:be}=r.useResponseContext(),{documents:xe,isUploading:je,documentError:ye,onFileUpload:we,setDocuments:Oe,setDocumentError:ke}=u.useDocument(),{studio:Se}=_.useStudio(),{scrollStartSession:Ce,scrollEndSession:Ne,scrollToBottom:Ie}=f.useScroll({auto:!0}),{artifacts:_e,currentPopupType:Ee,setArtifacts:Te,setCurrentArtifact:Ae}=p.useArtifactContext(),{height:Re}=c.useDimensionContext(),qe=l.useConversation(),[Pe,De]=s.useState(""),[Ue,Le]=s.useState(!1),[Me,$e]=s.useState(!1),[Fe,Be]=s.useState(null),[He,Ve]=s.useState(null),[Xe,Ke]=s.useState(!1),We=s.useRef(null),Je=s.useRef(""),ze=s.useRef(null),Ge=s.useRef(null),Qe=s.useRef(null),Ye=s.useRef(null),Ze=s.useRef(null),et=Math.max(.4*Re,100),{transcript:tt,listening:st,resetTranscript:nt,browserSupportsSpeechRecognition:it}=n.useSpeechRecognition(),[rt]=g.useMediaQuery("(max-width: 480px)"),ot=m.useHover(),{isHover:at}=ot,lt=e.__rest(ot,["isHover"]),ct=m.useHover(),{isHover:dt}=ct,ut=e.__rest(ct,["isHover"]),ft=m.useHover(),{isHover:pt}=ft,mt=e.__rest(ft,["isHover"]),gt=a.useStyleFontSize(),ht=o.useStyleInput(),vt="undefined"!=typeof window?window.location.hostname:"",bt="undefined"!=typeof window?window.location.href:"",xt="undefined"!=typeof window&&window.self!==window.top,jt=vt.includes("pickaxe.co")&&!bt.includes("https://studio.pickaxe.co/_embed")&&!xt,yt=null===(U=null==J?void 0:J.documentuploadtype)||void 0===U?void 0:U.startsWith("enduserupload"),wt=it&&(null==J?void 0:J.enablevoicetotext),Ot="chat-input"===W&&Z&&!ue,kt="chat-input"===W&&fe&&de&&ue,St=s.useCallback((e=>{const t=C.getValidationFailure(e);return!!t&&(be(""),ve(null),re(t.status),oe(t.upgradeGroups),ae(t.upgradeUrl),!0)}),[be,ve,re,oe,ae]),Ct=null!==(L=null==J?void 0:J.placeholdertext)&&void 0!==L?L:ee?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",Nt=Ue||Me,It=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==J?void 0:J.studioid},H&&{sender:H}),ce&&{studioSessionToken:ce}),!ce&&!H&&{sender:I.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),jt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Be(t.studioUser),Ve(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[$,F,B,V,H,ce,X,K,jt]);s.useEffect((()=>{It()}),[It]);const _t=(null==se?void 0:se.limit)||0,Et=(null==Fe?void 0:Fe.currentUses)||0,Tt=(null==Fe?void 0:Fe.extraUses)||0,At=!!(null==Se?void 0:Se.data.usage)&&Se.data.usage.isCredits,Rt=_t>Et?_t-Et+Tt:Tt,qt=s.useMemo((()=>!!Fe&&(!Xe&&(!(_t<=0)&&Rt<=.05*_t))),[Fe,Xe,Rt,_t]),Pt=s.useMemo((()=>{var e,t,s;return!!Z&&(!!J&&(!qe.isLoading&&(!((null!==(t=null===(e=qe.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)&&(!te&&!Ot)))))}),[J,Z,te,Ot,qe.data,qe.isLoading]),Dt=s.useMemo((()=>{if(me||je)return!1;const e=xe.length>0&&xe.every((e=>"finished"===e.status));return!(!Pe.trim()&&!e)&&xe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[me,je,Pe,xe]);s.useImperativeHandle(D,(()=>({onSubmit:Ut}))),s.useEffect((()=>{ie(Pt)}),[Pt]),s.useEffect((()=>{var e;if(E){const t=Array.from(pe),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Ut(s,!0)}}),[E]),s.useEffect((()=>{if(!Ye.current||!q)return;const e=new ResizeObserver((e=>{for(const t of e)q(t.contentRect.height)}));return e.observe(Ye.current),()=>{e.disconnect()}}),[q]),s.useEffect((()=>{if(!st)return;const e=Je.current?`${Je.current} `:"";De(`${e}${tt}`)}),[tt,st]),s.useEffect((()=>{if(!Ge.current)return;(()=>{if(!Ge.current)return;let e=Ge.current.scrollHeight>52;Pe.includes("\n")||xe.length?e=!0:Pe.trim()||(e=!1),Le(e)})()}),[Pe,xe]),s.useEffect((()=>{const e=Ge.current,t=Qe.current;if(!e||!t||Ue||Pe.includes("\n"))return void $e(!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=Pe||Ct,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;$e(r>l)}),[Pe,Ue,Ct]);const Ut=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(me||je)return;const r=xe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),o=r.map((e=>e.documentId)).filter(Boolean),a=r.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=o.length>0,c=null!=t?t:Pe;if(!c&&!l)return;be(""),ke(""),ve(null),De(""),ne(!1),he("fetching"),Ce(),Ie();const d=null!==(n=null===(e=null==J?void 0:J.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&o.length>0,u=[...s?Array.from(pe.slice(0,pe.length-1)):Array.from(pe),...s?[]:[{id:pe.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?o:[]}],{id:pe.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];ge(u),Ie(),d&&Oe([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:$,pickaxeId:F,sessionId:B,senderType:V,value:c},d&&{documentIds:o}),H&&{sender:H}),ce&&{studioSessionToken:ce}),!ce&&!H&&{sender:I.initializeEmbedUserId()}),X&&{portalId:X}),K&&{deploymentId:K}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},jt&&{credentials:"include"})),p=yield f.json();if(!p.success){if(St(p))return;const e=new Error(p.error||p.message||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const m=p.submissionId;he("streaming"),Ze.current=new AbortController;const g=u.length-1,h=[];let b=[...null!=_e?_e:[]],x=0,j=!1,y="";for(;!j;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${x}`,{signal:null===(i=Ze.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();ze.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&x++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong.";return St(t)||be(s),void(j=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&P){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw j=!0,P({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw j=!0,P({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)y="",h.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)y+=n.delta,h[h.length-1].content=y;else if("text-end"===n.type)y="";else if("reasoning-start"===n.type)y="",h.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)y+=n.delta,h[h.length-1].content=y;else if("reasoning-end"===n.type)y="";else if(n.type.startsWith("data-")){const e=n;h.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ge([...u.slice(0,g),Object.assign(Object.assign({},u[u.length-1]),{id:pe.length+1,role:"assistant",parts:h})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Te([...b]),Ee.startsWith("inline")||Ae({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Te(b),Ee.startsWith("inline")||Ae({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Te(b),Ee.startsWith("inline")||Ae({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Te(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Te(b.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),s=t.error||t.message||"Something went wrong, please try again.";if(St(t))return void(j=!0);be(s)}else"stop"===e.event&&(j=!0)}else j=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}j||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(j=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==le||le(B)}catch(e){if(e.limitData)ve(e.limitData),be("");else{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."),St(t)||be(t)}}finally{Ie(),he("idle"),Ne(),ze.current=null,yield It()}}));return kt?null:t.jsx("div",Object.assign({className:N.default("flex w-full flex-shrink-0 flex-col items-center",!Ot&&"px-4 pb-8"),dir:ee?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Ye,className:N.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===z.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},ht),{maxHeight:`${et}px`,overflowY:"auto"})},{children:[qt&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:ht.backgroundColor?`${ht.backgroundColor}E6`:void 0,borderColor:G.text+"20",color:G.text,borderTopRightRadius:z.cornerRadius+"px",borderTopLeftRadius:z.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[Rt," ",At?"credits":"uses"," remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:G.accent,color:G.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${He}${null==se?void 0:se.accessGroupId}`;I.isInIframe()?window.open(t):location.href=t}},{children:"Upgrade"})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Ke(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!me&&xe.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:me}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[st&&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!==(M=G.accent)&&void 0!==M?M:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:G.text+"90"}},{children:"Listening..."}))]})),t.jsx(O.default,Object.assign({ref:Ge,className:N.default(gt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Pe.trim()&&!Pe.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",ee?"text-right":"text-left",Nt&&"mb-12",st&&"text-transparent"),value:Pe,placeholder:Ct,onChange:e=>{if(De(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=>{Y||rt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),je||me||Ut()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),ne(!1),yield we(e))}))},A&&{onFocus:A},R&&{onBlur:R},{dir:ee?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Qe,className:N.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",Nt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Nt&&ht.backgroundColor&&{backgroundColor:ht.backgroundColor}),{borderTopRightRadius:z.cornerRadius+"px",borderBottomRightRadius:z.cornerRadius+"px"})},{children:me?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:()=>{Ze.current&&(Ze.current.abort(),Ze.current=null),ze.current&&(ze.current.cancel(),ze.current=null),he("idle")},style:{backgroundColor:G.accent,color:G.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):st?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:T.default.stopListening,style:{backgroundColor:G.accent,color:G.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[yt&&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:dt?G.accent+"10":void 0,color:dt?G.accent:G.accent+"80"},disabled:je||me,onClick:()=>{var e;return null===(e=We.current)||void 0===e?void 0:e.click()}},ut,{children:[t.jsx("input",{id:"file-upload",ref:We,type:"file",accept:[...h.allowedFileMimeTypes,...h.allowedImageMimeTypes,...h.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){ne(!1),yield we(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),wt&&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:st?G.accent:pt?G.accent+"10":void 0,color:st?G.accentText:pt?G.accent:G.accent+"80"},disabled:je||me,onClick:()=>{st?T.default.stopListening():(Je.current=Pe,nt(),T.default.startListening({continuous:!0,interimResults:!0,language:Q||"en-US"}))}},mt,{children:t.jsx(j.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:at||Dt?G.accent:G.accent+"10",color:at||Dt?G.accentText:G.accent+"80"},disabled:!Dt,onClick:()=>Ut()},lt,{children:t.jsx(x.default,{className:N.default("h-6 w-6 shrink-0",ee&&"scale-x-[-1] transform")})}))]})}))]}))]})),ye&&t.jsx(k.default,{error:ye,className:"mt-3"})]}))}))}));A.displayName="Input",exports.default=A;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),r=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useDimensionContext.js"),c=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),f=require("../../../hooks/core/useHover.js"),h=require("../../../hooks/core/useMediaQuery.js"),m=require("../../../common/documents.js"),g=require("eventsource-parser"),v=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),y=require("../Addons/Document/List.js"),w=require("../../Core/Textarea.js"),O=require("../../Core/ErrorAlert.js"),S=require("../../../common/error.js"),k=require("../../../common/validation.js"),C=require("../../../common/cn.js"),N=require("../../../common/utils.js"),I=require("../../../hooks/studio/useStudio.js"),_=require("../../../hooks/pickaxe/useSpeech.js");const E=s.forwardRef((({resubmitPrompt:E,onFocus:T,onBlur:A,onInputHeightChange:P,initSmitheryAuthData:q},R)=>{var D,U,L;const{origin:M,pickaxeId:$,sessionId:F,sender:B,senderType:H,portalId:V,deploymentId:X,deploymentType:K,pickaxe:W,styles:J,colors:z,locale:G,forceMobile:Q,isNewChat:Y,isRtl:Z,isShowFeedbackMessage:ee,accessGroup:te,setIsNewChat:se,setIsShowIceBreaker:ne,setValidationStatus:ie,setValidationUpgradeGroups:oe,setValidationUpgradeUrl:re,onGenerateComplete:ae}=n.usePickaxeContext(),{token:le,isLoggedOut:ce,isSent:de,isPricingAuth:ue}=c.useAuthContext(),{messages:pe,isGenerating:fe,setMessages:he,setStatus:me,setLimitData:ge,setError:ve}=i.useResponseContext(),{documents:be,isUploading:xe,documentError:je,onFileUpload:ye,setDocuments:we,setDocumentError:Oe}=d.useDocument(),{studio:Se}=I.useStudio(),{scrollStartSession:ke,scrollEndSession:Ce,scrollToBottom:Ne}=u.useScroll({auto:!0}),{artifacts:Ie,currentPopupType:_e,setArtifacts:Ee,setCurrentArtifact:Te}=p.useArtifactContext(),{height:Ae}=l.useDimensionContext(),Pe=a.useConversation(),[qe,Re]=s.useState(""),[De,Ue]=s.useState(!1),[Le,Me]=s.useState(!1),[$e,Fe]=s.useState(null),[Be,He]=s.useState(null),[Ve,Xe]=s.useState(!1),Ke=s.useRef(null),We=s.useRef(""),Je=s.useRef(null),ze=s.useRef(null),Ge=s.useRef(null),Qe=s.useRef(null),Ye=s.useRef(null),Ze=Math.max(.4*Ae,100),{speechTranscript:et,isSpeechListening:tt,isSpeechProcessing:st,isSpeechSupported:nt,onStartListening:it,onStopListening:ot}=_.useSpeech(),[rt]=h.useMediaQuery("(max-width: 480px)"),at=f.useHover(),{isHover:lt}=at,ct=e.__rest(at,["isHover"]),dt=f.useHover(),{isHover:ut}=dt,pt=e.__rest(dt,["isHover"]),ft=f.useHover(),{isHover:ht}=ft,mt=e.__rest(ft,["isHover"]),gt=r.useStyleFontSize(),vt=o.useStyleInput(),bt="undefined"!=typeof window?window.location.hostname:"",xt="undefined"!=typeof window?window.location.href:"",jt="undefined"!=typeof window&&window.self!==window.top,yt=bt.includes("pickaxe.co")&&!xt.includes("https://studio.pickaxe.co/_embed")&&!jt,wt=null===(D=null==W?void 0:W.documentuploadtype)||void 0===D?void 0:D.startsWith("enduserupload"),Ot=nt&&(null==W?void 0:W.enablevoicetotext),St="chat-input"===K&&Y&&!de,kt="chat-input"===K&&ue&&ce&&de,Ct=s.useCallback((e=>{const t=k.getValidationFailure(e);return!!t&&(ve(""),ge(null),ie(t.status),oe(t.upgradeGroups),re(t.upgradeUrl),!0)}),[ve,ge,ie,oe,re]),Nt=null!==(U=null==W?void 0:W.placeholdertext)&&void 0!==U?U:Z?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",It=De||Le,_t=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==W?void 0:W.studioid},B&&{sender:B}),le&&{studioSessionToken:le}),!le&&!B&&{sender:N.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),yt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Fe(t.studioUser),He(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[M,$,F,H,B,le,V,X,yt]);s.useEffect((()=>{_t()}),[_t]);const Et=(null==te?void 0:te.limit)||0,Tt=(null==$e?void 0:$e.currentUses)||0,At=(null==$e?void 0:$e.extraUses)||0,Pt=!!(null==Se?void 0:Se.data.usage)&&Se.data.usage.isCredits,qt=Et>Tt?Et-Tt+At:At,Rt=s.useMemo((()=>!!$e&&(!Ve&&(!(Et<=0)&&qt<=.05*Et))),[$e,Ve,qt,Et]),Dt=s.useMemo((()=>{var e,t,s;return!!Y&&(!!W&&(!Pe.isLoading&&(!((null!==(t=null===(e=Pe.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)&&(!ee&&!St)))))}),[W,Y,ee,St,Pe.data,Pe.isLoading]),Ut=s.useMemo((()=>{if(fe||xe)return!1;const e=be.length>0&&be.every((e=>"finished"===e.status));return!(!qe.trim()&&!e)&&be.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[fe,xe,qe,be]);s.useImperativeHandle(R,(()=>({onSubmit:Lt}))),s.useEffect((()=>{ne(Dt)}),[Dt]),s.useEffect((()=>{var e;if(E){const t=Array.from(pe),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Lt(s,!0)}}),[E]),s.useEffect((()=>{if(!Qe.current||!P)return;const e=new ResizeObserver((e=>{for(const t of e)P(t.contentRect.height)}));return e.observe(Qe.current),()=>{e.disconnect()}}),[P]),s.useEffect((()=>{if(!tt)return;const e=We.current?`${We.current} `:"";Re(`${e}${et}`)}),[et,tt]),s.useEffect((()=>{if(!ze.current)return;(()=>{if(!ze.current)return;let e=ze.current.scrollHeight>52;qe.includes("\n")||be.length?e=!0:qe.trim()||(e=!1),Ue(e)})()}),[qe,be]),s.useEffect((()=>{const e=ze.current,t=Ge.current;if(!e||!t||De||qe.includes("\n"))return void Me(!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=qe||Nt,document.body.appendChild(i);const o=i.offsetWidth;i.remove();const r=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Me(o>l)}),[qe,De,Nt]);const Lt=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(fe||xe)return;const o=be.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=o.map((e=>e.documentId)).filter(Boolean),a=o.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=t?t:qe;if(!c&&!l)return;ve(""),Oe(""),ge(null),Re(""),se(!1),me("fetching"),ke(),Ne();const d=null!==(n=null===(e=null==W?void 0:W.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(pe.slice(0,pe.length-1)):Array.from(pe),...s?[]:[{id:pe.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:pe.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];he(u),Ne(),d&&we([]);const p=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:M,pickaxeId:$,sessionId:F,senderType:H,value:c},d&&{documentIds:r}),B&&{sender:B}),le&&{studioSessionToken:le}),!le&&!B&&{sender:N.initializeEmbedUserId()}),V&&{portalId:V}),X&&{deploymentId:X}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},yt&&{credentials:"include"})),f=yield p.json();if(!f.success){if(Ct(f))return;const e=new Error(f.error||f.message||"Failed to start generation");throw f.limitData&&(e.limitData=f.limitData),e}const h=f.submissionId;me("streaming"),Ye.current=new AbortController;const m=u.length-1,v=[];let b=[...null!=Ie?Ie:[]],x=0,j=!1,y="";for(;!j;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${h}?index=${x}`,{signal:null===(i=Ye.current)||void 0===i?void 0:i.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Je.current=t;const s=new TextDecoder,n=g.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&x++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong.";return Ct(t)||ve(s),void(j=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&q){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw j=!0,q({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw j=!0,q({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)y="",v.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)y+=n.delta,v[v.length-1].content=y;else if("text-end"===n.type)y="";else if("reasoning-start"===n.type)y="",v.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)y+=n.delta,v[v.length-1].content=y;else if("reasoning-end"===n.type)y="";else if(n.type.startsWith("data-")){const e=n;v.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}he([...u.slice(0,m),Object.assign(Object.assign({},u[u.length-1]),{id:pe.length+1,role:"assistant",parts:v})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ee([...b]),_e.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Ee(b),_e.startsWith("inline")||Te({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);b=b.filter((e=>!(e.id===t.id&&e.version===t.version))),b.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ee(b),_e.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,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Ee(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ee(b.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),s=t.error||t.message||"Something went wrong, please try again.";if(Ct(t))return void(j=!0);ve(s)}else"stop"===e.event&&(j=!0)}else j=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}j||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(j=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==ae||ae(F)}catch(e){if(e.limitData)ge(e.limitData),ve("");else{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."),Ct(t)||ve(t)}}finally{Ne(),me("idle"),Ce(),Je.current=null,yield _t()}}));return kt?null:t.jsx("div",Object.assign({className:C.default("flex w-full flex-shrink-0 flex-col items-center",!St&&"px-4 pb-8"),dir:Z?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Qe,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({},vt),{maxHeight:`${Ze}px`,overflowY:"auto"})},{children:[Rt&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:vt.backgroundColor?`${vt.backgroundColor}E6`:void 0,borderColor:z.text+"20",color:z.text,borderTopRightRadius:J.cornerRadius+"px",borderTopLeftRadius:J.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[qt," ",Pt?"credits":"uses"," remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:z.accent,color:z.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${Be}${null==te?void 0:te.accessGroupId}`;N.isInIframe()?window.open(t):location.href=t}},{children:"Upgrade"})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Xe(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!fe&&be.length>0&&t.jsx(y.default,{className:"p-4 pb-0",isDisabled:fe}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[tt&&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!==(L=z.accent)&&void 0!==L?L:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:z.text+"90"}},{children:"Listening..."}))]})),t.jsx(w.default,Object.assign({ref:ze,className:C.default(gt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!qe.trim()&&!qe.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Z?"text-right":"text-left",It&&"mb-12",tt&&"text-transparent"),value:qe,placeholder:Nt,onChange:e=>{if(Re(e),P){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void P(0);if(t>=11)return;let s=0;t>1&&(s=50),P(24*(t-1)+s)}},onKeyDown:e=>{Q||rt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),xe||fe||Lt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),se(!1),yield ye(e))}))},T&&{onFocus:T},A&&{onBlur:A},{dir:Z?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Ge,className:C.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",It?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!It&&vt.backgroundColor&&{backgroundColor:vt.backgroundColor}),{borderTopRightRadius:J.cornerRadius+"px",borderBottomRightRadius:J.cornerRadius+"px"})},{children: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:()=>{Ye.current&&(Ye.current.abort(),Ye.current=null),Je.current&&(Je.current.cancel(),Je.current=null),me("idle")},style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):tt?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:ot,style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[wt&&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:ut?z.accent+"10":void 0,color:ut?z.accent:z.accent+"80"},disabled:xe||fe,onClick:()=>{var e;return null===(e=Ke.current)||void 0===e?void 0:e.click()}},pt,{children:[t.jsx("input",{id:"file-upload",ref:Ke,type:"file",accept:[...m.allowedFileMimeTypes,...m.allowedImageMimeTypes,...m.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){se(!1),yield ye(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(v.default,{className:"h-6 w-6 shrink-0"})]})),Ot&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:tt?z.accent:ht?z.accent+"10":void 0,color:tt?z.accentText:ht?z.accent:z.accent+"80"},disabled:xe||fe||st,onClick:()=>{tt?ot():(We.current=qe,it(G||"en-US"))}},mt,{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:lt||Ut?z.accent:z.accent+"10",color:lt||Ut?z.accentText:z.accent+"80"},disabled:!Ut,onClick:()=>Lt()},ct,{children:t.jsx(b.default,{className:C.default("h-6 w-6 shrink-0",Z&&"scale-x-[-1] transform")})}))]})}))]}))]})),je&&t.jsx(O.default,{error:je,className:"mt-3"})]}))}))}));E.displayName="Input",exports.default=E;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),n=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/studio/useStyleInput.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),a=require("../../../../hooks/core/useHover.js"),l=require("../../../../hooks/pickaxe/useSpeech.js"),c=require("../../../Core/Textarea.js"),u=require("../../../Icons/microphone.svg.js"),d=require("../../../Icons/stop.svg.js"),p=require("../../../../common/cn.js");exports.default=({field:h,update:x,activeVoiceId:g,setActiveVoiceId:j})=>{var m;const{styles:b,colors:f,isRtl:v,pickaxe:y,locale:k}=o.usePickaxeContext(),{setError:O}=n.useResponseContext(),[S,N]=t.useState(!1),w=r.useStyleFontSize(),q=i.useStyleInput(),{speechTranscript:C,isSpeechListening:_,isSpeechProcessing:I,isSpeechSupported:L,onStartListening:R,onStopListening:P}=l.useSpeech(),T=t.useRef(""),z=a.useHover(),{isHover:F}=z,H=e.__rest(z,["isHover"]),$=L&&(null==y?void 0:y.enablevoicetotext),B=_&&g===h.id,D=e=>{O("");const s=e.length;x(Object.assign(Object.assign({},h),{input:e,length:s}))};return t.useEffect((()=>{if(!_||g!==h.id)return;const e=T.current?`${T.current} `:"";D(`${e}${C}`)}),[C,_,g,h.id]),s.jsxs("div",Object.assign({className:"group relative flex flex-col gap-y-1",dir:v?"rtl":"ltr"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[s.jsx("p",Object.assign({className:p.default(w.b3,"font-semibold opacity-70")},{children:h.main})),h.isRequired&&s.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:f.accent}},{children:"*"}))]})),s.jsxs("div",Object.assign({className:"relative w-full"},{children:[B&&s.jsxs("div",Object.assign({className:p.default("absolute top-3.5 z-10 flex select-none items-center gap-x-2 pointer-events-none",v?"right-4":"left-4")},{children:[s.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full",style:{backgroundColor:null!==(m=f.accent)&&void 0!==m?m:"#ff0000"}}),s.jsx("span",Object.assign({className:"text-sm font-semilight",style:{color:f.text+"90"}},{children:"Listening..."}))]})),s.jsx(c.default,{className:p.default(w.i1,"rounded-sm border border-transparent py-3 duration-300 ease-in-out transition-all placeholder:font-semilight w-full",v?$?"pl-10 pr-4":"px-4":$?"pl-4 pr-10":"px-4",h.maxLength<10&&"max-w-[400px]","block"===b.formFieldStyle&&"shadow hover:shadow-none",B&&"caret-transparent"),style:Object.assign(Object.assign({},q),B&&{color:"transparent"}),placeholder:B?"":h.placeholder,rows:1,value:h.input,tabIndex:h.order,onChange:D,onFocus:()=>N(!0),onBlur:()=>N(!1),onPaste:e=>{if(e.clipboardData.getData("text").length<1e3)return;const s=e.target;setTimeout((()=>{const e=s.getBoundingClientRect().bottom+window.scrollY;window.scrollTo({top:e,behavior:"smooth"})}),250)}}),$&&s.jsx("div",Object.assign({className:p.default("absolute top-2 z-20",v?"left-2":"right-2")},{children:s.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",style:{backgroundColor:B?f.accent:F?f.accent+"10":void 0,color:B?f.accentText:F?f.accent:f.accent+"80"},disabled:I,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){_?(yield P(),j(h.id)):(j(h.id),T.current=h.input||"",yield R(k||"en-US"),N(!0))}))},H,{type:"button"},{children:B?s.jsx(d.default,{className:"h-4 w-4 shrink-0"}):s.jsx(u.default,{className:"h-5 w-5 shrink-0"})}))}))]}))]})),s.jsx("div",Object.assign({className:"pointer-events-none absolute bottom-0 right-0 p-1 px-2"},{children:s.jsxs("p",Object.assign({className:p.default(w.b4,"font-semibold opacity-20 opacity-0 group-hover:opacity-100 group-hover:duration-200",h.length>h.maxLength&&"text-c-red opacity-100",S&&"opacity-100")},{children:[h.length,"/",h.maxLength]}))}))]}))};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js");require("../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js");var t=require("react-speech-recognition"),i=require("web-speech-cognitive-services"),r=require("react"),n=require("../../common/api/pickaxe.js");function o(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var s=o(t);exports.useSpeech=()=>{const{transcript:o,listening:a,resetTranscript:c}=t.useSpeechRecognition(),[u,l]=r.useState(!1),[p,d]=r.useState(!1);return{speechTranscript:o,isSpeechSupported:!0,isSpeechProcessing:u,isSpeechListening:a,onStartListening:t=>e.__awaiter(void 0,void 0,void 0,(function*(){try{l(!0),yield navigator.mediaDevices.getUserMedia({audio:!0});const e=(yield n.default.post("/speech")).data;if(!p){const{SpeechRecognition:t}=i.createSpeechServicesPonyfill({credentials:{region:"eastus",authorizationToken:e.token}});s.default.applyPolyfill(t),d(!0)}c();const r={ar:"ar-SA",ca:"ca-ES",cs:"cs-CZ",da:"da-DK",de:"de-DE",en:"en-US",es:"es-ES",fi:"fi-FI",fr:"fr-FR",hi:"hi-IN",it:"it-IT",iw:"he-IL",ja:"ja-JP",ko:"ko-KR",nb:"nb-NO",nl:"nl-NL",pl:"pl-PL",pt:"pt-PT","pt-BR":"pt-BR",ro:"ro-RO",ru:"ru-RU",sv:"sv-SE",th:"th-TH",tr:"tr-TR",vi:"vi-VN",zh:"zh-CN",zu:"zu-ZA"};yield s.default.startListening({continuous:!0,interimResults:!0,language:r[t]||"en-US"})}catch(e){console.error(e)}finally{l(!1)}})),onStopListening:()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{l(!0),yield s.default.abortListening()}catch(e){console.error(e)}finally{l(!1)}}))}};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "regenerator-runtime/runtime";
|
|
2
|
+
export declare const useSpeech: () => {
|
|
3
|
+
speechTranscript: string;
|
|
4
|
+
isSpeechSupported: boolean;
|
|
5
|
+
isSpeechProcessing: boolean;
|
|
6
|
+
isSpeechListening: boolean;
|
|
7
|
+
onStartListening: (locale: string) => Promise<void>;
|
|
8
|
+
onStopListening: () => Promise<void>;
|
|
9
|
+
};
|
|
@@ -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,useCallback as l,useEffect as c,useMemo as d,useImperativeHandle as u}from"react";import"../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import p,{useSpeechRecognition as m}from"react-speech-recognition";import{usePickaxeContext as f}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as g}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as h}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as v}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as b}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as y}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as j}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as x}from"../Addons/Document/hooks/useDocument.js";import{useScroll as w}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 N}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as S,allowedImageMimeTypes as C,additionalAllowedFileExtensions as I}from"../../../common/documents.js";import{createParser as _}from"eventsource-parser";import E from"../../Icons/attach-vertical.svg.js";import T from"../../Icons/arrow-right.svg.js";import A from"../../Icons/microphone.svg.js";import P from"../../Icons/stop.svg.js";import R from"../Addons/Document/List.js";import D from"../../Core/Textarea.js";import L from"../../Core/ErrorAlert.js";import U from"../../../common/error.js";import{getValidationFailure as $}from"../../../common/validation.js";import B from"../../../common/cn.js";import{isInIframe as V,initializeEmbedUserId as X}from"../../../common/utils.js";import{useStudio as K}from"../../../hooks/studio/useStudio.js";const W=i((({resubmitPrompt:i,onFocus:W,onBlur:F,onInputHeightChange:H,initSmitheryAuthData:J},M)=>{var z,G,q;const{origin:Q,pickaxeId:Y,sessionId:Z,sender:ee,senderType:te,portalId:se,deploymentId:ne,deploymentType:oe,pickaxe:ie,styles:re,colors:ae,locale:le,forceMobile:ce,isNewChat:de,isRtl:ue,isShowFeedbackMessage:pe,accessGroup:me,setIsNewChat:fe,setIsShowIceBreaker:ge,setValidationStatus:he,setValidationUpgradeGroups:ve,setValidationUpgradeUrl:be,onGenerateComplete:ye}=f(),{token:je,isLoggedOut:xe,isSent:we,isPricingAuth:Oe}=j(),{messages:ke,isGenerating:Ne,setMessages:Se,setStatus:Ce,setLimitData:Ie,setError:_e}=g(),{documents:Ee,isUploading:Te,documentError:Ae,onFileUpload:Pe,setDocuments:Re,setDocumentError:De}=x(),{studio:Le}=K(),{scrollStartSession:Ue,scrollEndSession:$e,scrollToBottom:Be}=w({auto:!0}),{artifacts:Ve,currentPopupType:Xe,setArtifacts:Ke,setCurrentArtifact:We}=O(),{height:Fe}=y(),He=b(),[Je,Me]=r(""),[ze,Ge]=r(!1),[qe,Qe]=r(!1),[Ye,Ze]=r(null),[et,tt]=r(null),[st,nt]=r(!1),ot=a(null),it=a(""),rt=a(null),at=a(null),lt=a(null),ct=a(null),dt=a(null),ut=Math.max(.4*Fe,100),{transcript:pt,listening:mt,resetTranscript:ft,browserSupportsSpeechRecognition:gt}=m(),[ht]=N("(max-width: 480px)"),vt=k(),{isHover:bt}=vt,yt=e(vt,["isHover"]),jt=k(),{isHover:xt}=jt,wt=e(jt,["isHover"]),Ot=k(),{isHover:kt}=Ot,Nt=e(Ot,["isHover"]),St=v(),Ct=h(),It="undefined"!=typeof window?window.location.hostname:"",_t="undefined"!=typeof window?window.location.href:"",Et="undefined"!=typeof window&&window.self!==window.top,Tt=It.includes("pickaxe.co")&&!_t.includes("https://studio.pickaxe.co/_embed")&&!Et,At=null===(z=null==ie?void 0:ie.documentuploadtype)||void 0===z?void 0:z.startsWith("enduserupload"),Pt=gt&&(null==ie?void 0:ie.enablevoicetotext),Rt="chat-input"===oe&&de&&!we,Dt="chat-input"===oe&&Oe&&xe&&we,Lt=l((e=>{const t=$(e);return!!t&&(_e(""),Ie(null),he(t.status),ve(t.upgradeGroups),be(t.upgradeUrl),!0)}),[_e,Ie,he,ve,be]),Ut=null!==(G=null==ie?void 0:ie.placeholdertext)&&void 0!==G?G:ue?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",$t=ze||qe,Bt=l((()=>t(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==ie?void 0:ie.studioid},ee&&{sender:ee}),je&&{studioSessionToken:je}),!je&&!ee&&{sender:X()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),Tt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Ze(t.studioUser),tt(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[Q,Y,Z,te,ee,je,se,ne,Tt]);c((()=>{Bt()}),[Bt]);const Vt=(null==me?void 0:me.limit)||0,Xt=(null==Ye?void 0:Ye.currentUses)||0,Kt=(null==Ye?void 0:Ye.extraUses)||0,Wt=!!(null==Le?void 0:Le.data.usage)&&Le.data.usage.isCredits,Ft=Vt>Xt?Vt-Xt+Kt:Kt,Ht=d((()=>!!Ye&&(!st&&(!(Vt<=0)&&Ft<=.05*Vt))),[Ye,st,Ft,Vt]),Jt=d((()=>{var e,t,s;return!!de&&(!!ie&&(!He.isLoading&&(!((null!==(t=null===(e=He.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=ie.icebreakers)||void 0===s?void 0:s.length)&&(!pe&&!Rt)))))}),[ie,de,pe,Rt,He.data,He.isLoading]),Mt=d((()=>{if(Ne||Te)return!1;const e=Ee.length>0&&Ee.every((e=>"finished"===e.status));return!(!Je.trim()&&!e)&&Ee.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Ne,Te,Je,Ee]);u(M,(()=>({onSubmit:zt}))),c((()=>{ge(Jt)}),[Jt]),c((()=>{var e;if(i){const t=Array.from(ke),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;zt(s,!0)}}),[i]),c((()=>{if(!ct.current||!H)return;const e=new ResizeObserver((e=>{for(const t of e)H(t.contentRect.height)}));return e.observe(ct.current),()=>{e.disconnect()}}),[H]),c((()=>{if(!mt)return;const e=it.current?`${it.current} `:"";Me(`${e}${pt}`)}),[pt,mt]),c((()=>{if(!at.current)return;(()=>{if(!at.current)return;let e=at.current.scrollHeight>52;Je.includes("\n")||Ee.length?e=!0:Je.trim()||(e=!1),Ge(e)})()}),[Je,Ee]),c((()=>{const e=at.current,t=lt.current;if(!e||!t||ze||Je.includes("\n"))return void Qe(!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=Je||Ut,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;Qe(i>l)}),[Je,ze,Ut]);const zt=(e,s=!1)=>t(void 0,void 0,void 0,(function*(){var t,n,o;try{if(Ne||Te)return;const i=Ee.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=i.map((e=>e.documentId)).filter(Boolean),a=i.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=e?e:Je;if(!c&&!l)return;_e(""),De(""),Ie(null),Me(""),fe(!1),Ce("fetching"),Ue(),Be();const d=null!==(n=null===(t=null==ie?void 0:ie.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(ke.slice(0,ke.length-1)):Array.from(ke),...s?[]:[{id:ke.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:ke.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];Se(u),Be(),d&&Re([]);const p=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:Q,pickaxeId:Y,sessionId:Z,senderType:te,value:c},d&&{documentIds:r}),ee&&{sender:ee}),je&&{studioSessionToken:je}),!je&&!ee&&{sender:X()}),se&&{portalId:se}),ne&&{deploymentId:ne}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},Tt&&{credentials:"include"})),m=yield p.json();if(!m.success){if(Lt(m))return;const e=new Error(m.error||m.message||"Failed to start generation");throw m.limitData&&(e.limitData=m.limitData),e}const f=m.submissionId;Ce("streaming"),dt.current=new AbortController;const g=u.length-1,h=[];let v=[...null!=Ve?Ve:[]],b=0,y=!1,j="";for(;!y;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${f}?index=${b}`,{signal:null===(o=dt.current)||void 0===o?void 0:o.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();rt.current=t;const s=new TextDecoder,n=_({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong.";return Lt(t)||_e(s),void(y=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&J){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw y=!0,J({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,J({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",h.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,h[h.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",h.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,h[h.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;h.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Se([...u.slice(0,g),Object.assign(Object.assign({},u[u.length-1]),{id:ke.length+1,role:"assistant",parts:h})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ke([...v]),Xe.startsWith("inline")||We({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Ke(v),Xe.startsWith("inline")||We({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ke(v),Xe.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,"");v=v.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Ke(v)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ke(v.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),s=t.error||t.message||"Something went wrong, please try again.";if(Lt(t))return void(y=!0);_e(s)}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;n.feed(s.decode(e))}y||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(y=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==ye||ye(Z)}catch(e){if(e.limitData)Ie(e.limitData),_e("");else{let t=U(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),Lt(t)||_e(t)}}finally{Be(),Ce("idle"),$e(),rt.current=null,yield Bt()}}));return Dt?null:s("div",Object.assign({className:B("flex w-full flex-shrink-0 flex-col items-center",!Rt&&"px-4 pb-8"),dir:ue?"rtl":"ltr"},{children:n("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[n("div",Object.assign({ref:ct,className:B("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===re.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Ct),{maxHeight:`${ut}px`,overflowY:"auto"})},{children:[Ht&&n("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:Ct.backgroundColor?`${Ct.backgroundColor}E6`:void 0,borderColor:ae.text+"20",color:ae.text,borderTopRightRadius:re.cornerRadius+"px",borderTopLeftRadius:re.cornerRadius+"px"}},{children:[s("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:n("span",{children:[Ft," ",Wt?"credits":"uses"," remaining"]})})),n("div",Object.assign({className:"flex items-center gap-3"},{children:[s("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:ae.accent,color:ae.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${et}${null==me?void 0:me.accessGroupId}`;V()?window.open(t):location.href=t}},{children:"Upgrade"})),s("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>nt(!0)},{children:s("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!Ne&&Ee.length>0&&s(R,{className:"p-4 pb-0",isDisabled:Ne}),n("div",Object.assign({className:"relative flex w-full flex-col"},{children:[mt&&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!==(q=ae.accent)&&void 0!==q?q:"#ff0000"}}),s("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:ae.text+"90"}},{children:"Listening..."}))]})),s(D,Object.assign({ref:at,className:B(St.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Je.trim()&&!Je.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",ue?"text-right":"text-left",$t&&"mb-12",mt&&"text-transparent"),value:Je,placeholder:Ut,onChange:e=>{if(Me(e),H){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void H(0);if(t>=11)return;let s=0;t>1&&(s=50),H(24*(t-1)+s)}},onKeyDown:e=>{ce||ht||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Te||Ne||zt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),fe(!1),yield Pe(t))}))},W&&{onFocus:W},F&&{onBlur:F},{dir:ue?"rtl":"ltr"})),s("div",Object.assign({ref:lt,className:B("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",$t?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!$t&&Ct.backgroundColor&&{backgroundColor:Ct.backgroundColor}),{borderTopRightRadius:re.cornerRadius+"px",borderBottomRightRadius:re.cornerRadius+"px"})},{children:Ne?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:()=>{dt.current&&(dt.current.abort(),dt.current=null),rt.current&&(rt.current.cancel(),rt.current=null),Ce("idle")},style:{backgroundColor:ae.accent,color:ae.accentText}},{children:s(P,{className:"h-4 w-4 shrink-0"})})):mt?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:p.stopListening,style:{backgroundColor:ae.accent,color:ae.accentText}},{children:s(P,{className:"h-4 w-4 shrink-0"})})):n(o,{children:[At&&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:xt?ae.accent+"10":void 0,color:xt?ae.accent:ae.accent+"80"},disabled:Te||Ne,onClick:()=>{var e;return null===(e=ot.current)||void 0===e?void 0:e.click()}},wt,{children:[s("input",{id:"file-upload",ref:ot,type:"file",accept:[...S,...C,...I].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){fe(!1),yield Pe(Array.from(e.target.files||[])),e.target.value=""}))}),s(E,{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:mt?ae.accent:kt?ae.accent+"10":void 0,color:mt?ae.accentText:kt?ae.accent:ae.accent+"80"},disabled:Te||Ne,onClick:()=>{mt?p.stopListening():(it.current=Je,ft(),p.startListening({continuous:!0,interimResults:!0,language:le||"en-US"}))}},Nt,{children:s(A,{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:bt||Mt?ae.accent:ae.accent+"10",color:bt||Mt?ae.accentText:ae.accent+"80"},disabled:!Mt,onClick:()=>zt()},yt,{children:s(T,{className:B("h-6 w-6 shrink-0",ue&&"scale-x-[-1] transform")})}))]})}))]}))]})),Ae&&s(L,{error:Ae,className:"mt-3"})]}))}))}));W.displayName="Input";export{W as default};
|
|
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,useCallback as l,useEffect as c,useMemo as d,useImperativeHandle as u}from"react";import{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as m}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as f}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as h}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as g}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as v}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as y}from"../Addons/Document/hooks/useDocument.js";import{useScroll as x}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as j}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as O}from"../../../hooks/core/useHover.js";import{useMediaQuery as w}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as k,allowedImageMimeTypes as N,additionalAllowedFileExtensions as S}from"../../../common/documents.js";import{createParser as C}from"eventsource-parser";import I from"../../Icons/attach-vertical.svg.js";import E from"../../Icons/arrow-right.svg.js";import _ from"../../Icons/microphone.svg.js";import T from"../../Icons/stop.svg.js";import A from"../Addons/Document/List.js";import P from"../../Core/Textarea.js";import D from"../../Core/ErrorAlert.js";import R from"../../../common/error.js";import{getValidationFailure as L}from"../../../common/validation.js";import U from"../../../common/cn.js";import{isInIframe as $,initializeEmbedUserId as B}from"../../../common/utils.js";import{useStudio as V}from"../../../hooks/studio/useStudio.js";import{useSpeech as X}from"../../../hooks/pickaxe/useSpeech.js";const K=i((({resubmitPrompt:i,onFocus:K,onBlur:W,onInputHeightChange:F,initSmitheryAuthData:H},J)=>{var M,z,G;const{origin:q,pickaxeId:Q,sessionId:Y,sender:Z,senderType:ee,portalId:te,deploymentId:se,deploymentType:ne,pickaxe:oe,styles:ie,colors:re,locale:ae,forceMobile:le,isNewChat:ce,isRtl:de,isShowFeedbackMessage:ue,accessGroup:pe,setIsNewChat:me,setIsShowIceBreaker:fe,setValidationStatus:he,setValidationUpgradeGroups:ge,setValidationUpgradeUrl:ve,onGenerateComplete:be}=p(),{token:ye,isLoggedOut:xe,isSent:je,isPricingAuth:Oe}=b(),{messages:we,isGenerating:ke,setMessages:Ne,setStatus:Se,setLimitData:Ce,setError:Ie}=m(),{documents:Ee,isUploading:_e,documentError:Te,onFileUpload:Ae,setDocuments:Pe,setDocumentError:De}=y(),{studio:Re}=V(),{scrollStartSession:Le,scrollEndSession:Ue,scrollToBottom:$e}=x({auto:!0}),{artifacts:Be,currentPopupType:Ve,setArtifacts:Xe,setCurrentArtifact:Ke}=j(),{height:We}=v(),Fe=g(),[He,Je]=r(""),[Me,ze]=r(!1),[Ge,qe]=r(!1),[Qe,Ye]=r(null),[Ze,et]=r(null),[tt,st]=r(!1),nt=a(null),ot=a(""),it=a(null),rt=a(null),at=a(null),lt=a(null),ct=a(null),dt=Math.max(.4*We,100),{speechTranscript:ut,isSpeechListening:pt,isSpeechProcessing:mt,isSpeechSupported:ft,onStartListening:ht,onStopListening:gt}=X(),[vt]=w("(max-width: 480px)"),bt=O(),{isHover:yt}=bt,xt=e(bt,["isHover"]),jt=O(),{isHover:Ot}=jt,wt=e(jt,["isHover"]),kt=O(),{isHover:Nt}=kt,St=e(kt,["isHover"]),Ct=h(),It=f(),Et="undefined"!=typeof window?window.location.hostname:"",_t="undefined"!=typeof window?window.location.href:"",Tt="undefined"!=typeof window&&window.self!==window.top,At=Et.includes("pickaxe.co")&&!_t.includes("https://studio.pickaxe.co/_embed")&&!Tt,Pt=null===(M=null==oe?void 0:oe.documentuploadtype)||void 0===M?void 0:M.startsWith("enduserupload"),Dt=ft&&(null==oe?void 0:oe.enablevoicetotext),Rt="chat-input"===ne&&ce&&!je,Lt="chat-input"===ne&&Oe&&xe&&je,Ut=l((e=>{const t=L(e);return!!t&&(Ie(""),Ce(null),he(t.status),ge(t.upgradeGroups),ve(t.upgradeUrl),!0)}),[Ie,Ce,he,ge,ve]),$t=null!==(z=null==oe?void 0:oe.placeholdertext)&&void 0!==z?z:de?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",Bt=Me||Ge,Vt=l((()=>t(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==oe?void 0:oe.studioid},Z&&{sender:Z}),ye&&{studioSessionToken:ye}),!ye&&!Z&&{sender:B()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),At&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Ye(t.studioUser),et(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[q,Q,Y,ee,Z,ye,te,se,At]);c((()=>{Vt()}),[Vt]);const Xt=(null==pe?void 0:pe.limit)||0,Kt=(null==Qe?void 0:Qe.currentUses)||0,Wt=(null==Qe?void 0:Qe.extraUses)||0,Ft=!!(null==Re?void 0:Re.data.usage)&&Re.data.usage.isCredits,Ht=Xt>Kt?Xt-Kt+Wt:Wt,Jt=d((()=>!!Qe&&(!tt&&(!(Xt<=0)&&Ht<=.05*Xt))),[Qe,tt,Ht,Xt]),Mt=d((()=>{var e,t,s;return!!ce&&(!!oe&&(!Fe.isLoading&&(!((null!==(t=null===(e=Fe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=oe.icebreakers)||void 0===s?void 0:s.length)&&(!ue&&!Rt)))))}),[oe,ce,ue,Rt,Fe.data,Fe.isLoading]),zt=d((()=>{if(ke||_e)return!1;const e=Ee.length>0&&Ee.every((e=>"finished"===e.status));return!(!He.trim()&&!e)&&Ee.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ke,_e,He,Ee]);u(J,(()=>({onSubmit:Gt}))),c((()=>{fe(Mt)}),[Mt]),c((()=>{var e;if(i){const t=Array.from(we),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Gt(s,!0)}}),[i]),c((()=>{if(!lt.current||!F)return;const e=new ResizeObserver((e=>{for(const t of e)F(t.contentRect.height)}));return e.observe(lt.current),()=>{e.disconnect()}}),[F]),c((()=>{if(!pt)return;const e=ot.current?`${ot.current} `:"";Je(`${e}${ut}`)}),[ut,pt]),c((()=>{if(!rt.current)return;(()=>{if(!rt.current)return;let e=rt.current.scrollHeight>52;He.includes("\n")||Ee.length?e=!0:He.trim()||(e=!1),ze(e)})()}),[He,Ee]),c((()=>{const e=rt.current,t=at.current;if(!e||!t||Me||He.includes("\n"))return void qe(!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=He||$t,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;qe(i>l)}),[He,Me,$t]);const Gt=(e,s=!1)=>t(void 0,void 0,void 0,(function*(){var t,n,o;try{if(ke||_e)return;const i=Ee.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=i.map((e=>e.documentId)).filter(Boolean),a=i.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=e?e:He;if(!c&&!l)return;Ie(""),De(""),Ce(null),Je(""),me(!1),Se("fetching"),Le(),$e();const d=null!==(n=null===(t=null==oe?void 0:oe.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(we.slice(0,we.length-1)):Array.from(we),...s?[]:[{id:we.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:we.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];Ne(u),$e(),d&&Pe([]);const p=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:q,pickaxeId:Q,sessionId:Y,senderType:ee,value:c},d&&{documentIds:r}),Z&&{sender:Z}),ye&&{studioSessionToken:ye}),!ye&&!Z&&{sender:B()}),te&&{portalId:te}),se&&{deploymentId:se}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},At&&{credentials:"include"})),m=yield p.json();if(!m.success){if(Ut(m))return;const e=new Error(m.error||m.message||"Failed to start generation");throw m.limitData&&(e.limitData=m.limitData),e}const f=m.submissionId;Se("streaming"),ct.current=new AbortController;const h=u.length-1,g=[];let v=[...null!=Be?Be:[]],b=0,y=!1,x="";for(;!y;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${f}?index=${b}`,{signal:null===(o=ct.current)||void 0===o?void 0:o.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();it.current=t;const s=new TextDecoder,n=C({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong.";return Ut(t)||Ie(s),void(y=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&H){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw y=!0,H({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,H({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)x="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)x+=n.delta,g[g.length-1].content=x;else if("text-end"===n.type)x="";else if("reasoning-start"===n.type)x="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)x+=n.delta,g[g.length-1].content=x;else if("reasoning-end"===n.type)x="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Ne([...u.slice(0,h),Object.assign(Object.assign({},u[u.length-1]),{id:we.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Xe([...v]),Ve.startsWith("inline")||Ke({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Xe(v),Ve.startsWith("inline")||Ke({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Xe(v),Ve.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,"");v=v.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Xe(v)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Xe(v.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),s=t.error||t.message||"Something went wrong, please try again.";if(Ut(t))return void(y=!0);Ie(s)}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;n.feed(s.decode(e))}y||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(y=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==be||be(Y)}catch(e){if(e.limitData)Ce(e.limitData),Ie("");else{let t=R(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),Ut(t)||Ie(t)}}finally{$e(),Se("idle"),Ue(),it.current=null,yield Vt()}}));return Lt?null:s("div",Object.assign({className:U("flex w-full flex-shrink-0 flex-col items-center",!Rt&&"px-4 pb-8"),dir:de?"rtl":"ltr"},{children:n("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[n("div",Object.assign({ref:lt,className:U("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ie.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},It),{maxHeight:`${dt}px`,overflowY:"auto"})},{children:[Jt&&n("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:It.backgroundColor?`${It.backgroundColor}E6`:void 0,borderColor:re.text+"20",color:re.text,borderTopRightRadius:ie.cornerRadius+"px",borderTopLeftRadius:ie.cornerRadius+"px"}},{children:[s("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:n("span",{children:[Ht," ",Ft?"credits":"uses"," remaining"]})})),n("div",Object.assign({className:"flex items-center gap-3"},{children:[s("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:re.accent,color:re.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${Ze}${null==pe?void 0:pe.accessGroupId}`;$()?window.open(t):location.href=t}},{children:"Upgrade"})),s("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>st(!0)},{children:s("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!ke&&Ee.length>0&&s(A,{className:"p-4 pb-0",isDisabled:ke}),n("div",Object.assign({className:"relative flex w-full flex-col"},{children:[pt&&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!==(G=re.accent)&&void 0!==G?G:"#ff0000"}}),s("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:re.text+"90"}},{children:"Listening..."}))]})),s(P,Object.assign({ref:rt,className:U(Ct.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!He.trim()&&!He.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",de?"text-right":"text-left",Bt&&"mb-12",pt&&"text-transparent"),value:He,placeholder:$t,onChange:e=>{if(Je(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=>{le||vt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),_e||ke||Gt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),me(!1),yield Ae(t))}))},K&&{onFocus:K},W&&{onBlur:W},{dir:de?"rtl":"ltr"})),s("div",Object.assign({ref:at,className:U("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",Bt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Bt&&It.backgroundColor&&{backgroundColor:It.backgroundColor}),{borderTopRightRadius:ie.cornerRadius+"px",borderBottomRightRadius:ie.cornerRadius+"px"})},{children:ke?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:()=>{ct.current&&(ct.current.abort(),ct.current=null),it.current&&(it.current.cancel(),it.current=null),Se("idle")},style:{backgroundColor:re.accent,color:re.accentText}},{children:s(T,{className:"h-4 w-4 shrink-0"})})):pt?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:gt,style:{backgroundColor:re.accent,color:re.accentText}},{children:s(T,{className:"h-4 w-4 shrink-0"})})):n(o,{children:[Pt&&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:Ot?re.accent+"10":void 0,color:Ot?re.accent:re.accent+"80"},disabled:_e||ke,onClick:()=>{var e;return null===(e=nt.current)||void 0===e?void 0:e.click()}},wt,{children:[s("input",{id:"file-upload",ref:nt,type:"file",accept:[...k,...N,...S].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){me(!1),yield Ae(Array.from(e.target.files||[])),e.target.value=""}))}),s(I,{className:"h-6 w-6 shrink-0"})]})),Dt&&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:pt?re.accent:Nt?re.accent+"10":void 0,color:pt?re.accentText:Nt?re.accent:re.accent+"80"},disabled:_e||ke||mt,onClick:()=>{pt?gt():(ot.current=He,ht(ae||"en-US"))}},St,{children:s(_,{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:yt||zt?re.accent:re.accent+"10",color:yt||zt?re.accentText:re.accent+"80"},disabled:!zt,onClick:()=>Gt()},xt,{children:s(E,{className:U("h-6 w-6 shrink-0",de&&"scale-x-[-1] transform")})}))]})}))]}))]})),Te&&s(D,{error:Te,className:"mt-3"})]}))}))}));K.displayName="Input";export{K as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as
|
|
1
|
+
import{__rest as e,__awaiter as t}from"../../../../_virtual/_tslib.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as n,useRef as i,useEffect as r}from"react";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as l}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as p}from"../../../../hooks/studio/useStyleFontSize.js";import{useHover as d}from"../../../../hooks/core/useHover.js";import{useSpeech as m}from"../../../../hooks/pickaxe/useSpeech.js";import u from"../../../Core/Textarea.js";import h from"../../../Icons/microphone.svg.js";import g from"../../../Icons/stop.svg.js";import f from"../../../../common/cn.js";const b=({field:b,update:x,activeVoiceId:v,setActiveVoiceId:j})=>{var y;const{styles:k,colors:N,isRtl:O,pickaxe:w,locale:S}=a(),{setError:C}=c(),[L,I]=n(!1),T=p(),R=l(),{speechTranscript:z,isSpeechListening:F,isSpeechProcessing:H,isSpeechSupported:P,onStartListening:$,onStopListening:B}=m(),D=i(""),V=d(),{isHover:_}=V,q=e(V,["isHover"]),A=P&&(null==w?void 0:w.enablevoicetotext),E=F&&v===b.id,U=e=>{C("");const t=e.length;x(Object.assign(Object.assign({},b),{input:e,length:t}))};return r((()=>{if(!F||v!==b.id)return;const e=D.current?`${D.current} `:"";U(`${e}${z}`)}),[z,F,v,b.id]),o("div",Object.assign({className:"group relative flex flex-col gap-y-1",dir:O?"rtl":"ltr"},{children:[o("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[o("div",Object.assign({className:"flex items-center gap-1"},{children:[s("p",Object.assign({className:f(T.b3,"font-semibold opacity-70")},{children:b.main})),b.isRequired&&s("span",Object.assign({className:"select-none font-semibold",style:{color:N.accent}},{children:"*"}))]})),o("div",Object.assign({className:"relative w-full"},{children:[E&&o("div",Object.assign({className:f("absolute top-3.5 z-10 flex select-none items-center gap-x-2 pointer-events-none",O?"right-4":"left-4")},{children:[s("span",{className:"h-2 w-2 animate-pulse rounded-full",style:{backgroundColor:null!==(y=N.accent)&&void 0!==y?y:"#ff0000"}}),s("span",Object.assign({className:"text-sm font-semilight",style:{color:N.text+"90"}},{children:"Listening..."}))]})),s(u,{className:f(T.i1,"rounded-sm border border-transparent py-3 duration-300 ease-in-out transition-all placeholder:font-semilight w-full",O?A?"pl-10 pr-4":"px-4":A?"pl-4 pr-10":"px-4",b.maxLength<10&&"max-w-[400px]","block"===k.formFieldStyle&&"shadow hover:shadow-none",E&&"caret-transparent"),style:Object.assign(Object.assign({},R),E&&{color:"transparent"}),placeholder:E?"":b.placeholder,rows:1,value:b.input,tabIndex:b.order,onChange:U,onFocus:()=>I(!0),onBlur:()=>I(!1),onPaste:e=>{if(e.clipboardData.getData("text").length<1e3)return;const t=e.target;setTimeout((()=>{const e=t.getBoundingClientRect().bottom+window.scrollY;window.scrollTo({top:e,behavior:"smooth"})}),250)}}),A&&s("div",Object.assign({className:f("absolute top-2 z-20",O?"left-2":"right-2")},{children: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",style:{backgroundColor:E?N.accent:_?N.accent+"10":void 0,color:E?N.accentText:_?N.accent:N.accent+"80"},disabled:H,onClick:()=>t(void 0,void 0,void 0,(function*(){F?(yield B(),j(b.id)):(j(b.id),D.current=b.input||"",yield $(S||"en-US"),I(!0))}))},q,{type:"button"},{children:E?s(g,{className:"h-4 w-4 shrink-0"}):s(h,{className:"h-5 w-5 shrink-0"})}))}))]}))]})),s("div",Object.assign({className:"pointer-events-none absolute bottom-0 right-0 p-1 px-2"},{children:o("p",Object.assign({className:f(T.b4,"font-semibold opacity-20 opacity-0 group-hover:opacity-100 group-hover:duration-200",b.length>b.maxLength&&"text-c-red opacity-100",L&&"opacity-100")},{children:[b.length,"/",b.maxLength]}))}))]}))};export{b as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import"../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import i,{useSpeechRecognition as t}from"react-speech-recognition";import{createSpeechServicesPonyfill as o}from"web-speech-cognitive-services";import{useState as r}from"react";import n from"../../common/api/pickaxe.js";const s=()=>{const{transcript:s,listening:c,resetTranscript:a}=t(),[p,l]=r(!1),[d,m]=r(!1);return{speechTranscript:s,isSpeechSupported:!0,isSpeechProcessing:p,isSpeechListening:c,onStartListening:t=>e(void 0,void 0,void 0,(function*(){try{l(!0),yield navigator.mediaDevices.getUserMedia({audio:!0});const e=(yield n.post("/speech")).data;if(!d){const{SpeechRecognition:t}=o({credentials:{region:"eastus",authorizationToken:e.token}});i.applyPolyfill(t),m(!0)}a();const r={ar:"ar-SA",ca:"ca-ES",cs:"cs-CZ",da:"da-DK",de:"de-DE",en:"en-US",es:"es-ES",fi:"fi-FI",fr:"fr-FR",hi:"hi-IN",it:"it-IT",iw:"he-IL",ja:"ja-JP",ko:"ko-KR",nb:"nb-NO",nl:"nl-NL",pl:"pl-PL",pt:"pt-PT","pt-BR":"pt-BR",ro:"ro-RO",ru:"ru-RU",sv:"sv-SE",th:"th-TH",tr:"tr-TR",vi:"vi-VN",zh:"zh-CN",zu:"zu-ZA"};yield i.startListening({continuous:!0,interimResults:!0,language:r[t]||"en-US"})}catch(e){console.error(e)}finally{l(!1)}})),onStopListening:()=>e(void 0,void 0,void 0,(function*(){try{l(!0),yield i.abortListening()}catch(e){console.error(e)}finally{l(!1)}}))}};export{s as useSpeech};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "regenerator-runtime/runtime";
|
|
2
|
+
export declare const useSpeech: () => {
|
|
3
|
+
speechTranscript: string;
|
|
4
|
+
isSpeechSupported: boolean;
|
|
5
|
+
isSpeechProcessing: boolean;
|
|
6
|
+
isSpeechListening: boolean;
|
|
7
|
+
onStartListening: (locale: string) => Promise<void>;
|
|
8
|
+
onStopListening: () => Promise<void>;
|
|
9
|
+
};
|
package/package.json
CHANGED
|
@@ -1,208 +1,212 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
}
|
|
2
|
+
"name": "@pickaxeproject/react",
|
|
3
|
+
"version": "6.2.1",
|
|
4
|
+
"description": "Client utility library for Pickaxe",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/pickaxeproject/v2-pickaxe-react.git"
|
|
8
|
+
},
|
|
9
|
+
"sideEffects": false,
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"import": "./dist/esm/index.js",
|
|
13
|
+
"require": "./dist/cjs/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./embed": {
|
|
16
|
+
"import": "./dist/esm/embed/index.js",
|
|
17
|
+
"require": "./dist/cjs/embed/index.js"
|
|
18
|
+
},
|
|
19
|
+
"./prose.css": "./dist/esm/prose.css"
|
|
20
|
+
},
|
|
21
|
+
"main": "dist/cjs/index.js",
|
|
22
|
+
"module": "dist/esm/index.js",
|
|
23
|
+
"types": "dist/esm/src/index.d.ts",
|
|
24
|
+
"files": [
|
|
25
|
+
"dist"
|
|
26
|
+
],
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "cross-env NODE_ENV=production rollup -c",
|
|
29
|
+
"lint": "eslint . --ext .ts,.tsx,.js,.jsx",
|
|
30
|
+
"lint:format": "prettier --check src/**/*",
|
|
31
|
+
"lint:staged": "pnpm run lint && pnpm run lint:format",
|
|
32
|
+
"format": "prettier --write .",
|
|
33
|
+
"prepare": "husky install",
|
|
34
|
+
"changeset": "changeset",
|
|
35
|
+
"release": "changeset publish",
|
|
36
|
+
"publish": "pnpm build && pnpm release",
|
|
37
|
+
"dev": "storybook dev -p 6006",
|
|
38
|
+
"storybook": "storybook dev -p 6006",
|
|
39
|
+
"build-storybook": "storybook build"
|
|
40
|
+
},
|
|
41
|
+
"browserslist": [
|
|
42
|
+
"> 1%",
|
|
43
|
+
"not dead",
|
|
44
|
+
"not edge <= 18",
|
|
45
|
+
"not ie 11",
|
|
46
|
+
"not op_mini all"
|
|
47
|
+
],
|
|
48
|
+
"dependencies": {
|
|
49
|
+
"@babel/runtime": "^7.20.7",
|
|
50
|
+
"@modelcontextprotocol/sdk": "1.20.2",
|
|
51
|
+
"@radix-ui/react-avatar": "^1.1.11",
|
|
52
|
+
"franc-min": "^6.2.0",
|
|
53
|
+
"jose": "^6.1.3",
|
|
54
|
+
"lucide-react": "^0.563.0",
|
|
55
|
+
"pkce-challenge": "3.0.0",
|
|
56
|
+
"react-speech-recognition": "^4.0.1",
|
|
57
|
+
"regenerator-runtime": "^0.14.1",
|
|
58
|
+
"remove-markdown": "^0.6.3",
|
|
59
|
+
"tldts": "^7.0.23"
|
|
60
|
+
},
|
|
61
|
+
"devDependencies": {
|
|
62
|
+
"@babel/core": "^7.20.12",
|
|
63
|
+
"@babel/plugin-transform-runtime": "^7.19.6",
|
|
64
|
+
"@babel/preset-env": "^7.20.2",
|
|
65
|
+
"@babel/preset-react": "^7.18.6",
|
|
66
|
+
"@babel/preset-typescript": "^7.26.0",
|
|
67
|
+
"@changesets/cli": "^2.26.0",
|
|
68
|
+
"@chromatic-com/storybook": "3.2.3",
|
|
69
|
+
"@mdx-js/react": "^3.1.0",
|
|
70
|
+
"@nem035/gpt-3-encoder": "^1.1.7",
|
|
71
|
+
"@prettier/plugin-xml": "^3.4.1",
|
|
72
|
+
"@rollup/plugin-alias": "^5.1.1",
|
|
73
|
+
"@rollup/plugin-babel": "^6.0.3",
|
|
74
|
+
"@rollup/plugin-commonjs": "^24.0.0",
|
|
75
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
76
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
77
|
+
"@rollup/plugin-replace": "^6.0.2",
|
|
78
|
+
"@rollup/plugin-terser": "^0.3.0",
|
|
79
|
+
"@storybook/addon-a11y": "^8.5.3",
|
|
80
|
+
"@storybook/addon-docs": "^8.5.3",
|
|
81
|
+
"@storybook/addon-essentials": "^8.5.3",
|
|
82
|
+
"@storybook/addon-interactions": "^8.5.3",
|
|
83
|
+
"@storybook/addon-links": "^8.5.3",
|
|
84
|
+
"@storybook/addon-themes": "^8.5.3",
|
|
85
|
+
"@storybook/blocks": "^8.5.3",
|
|
86
|
+
"@storybook/react": "^8.5.3",
|
|
87
|
+
"@storybook/react-vite": "^8.5.3",
|
|
88
|
+
"@storybook/test": "^8.5.3",
|
|
89
|
+
"@stripe/react-stripe-js": "^4.0.2",
|
|
90
|
+
"@stripe/stripe-js": "^7.9.0",
|
|
91
|
+
"@svgr/rollup": "^8.1.0",
|
|
92
|
+
"@tailwindcss/container-queries": "^0.1.1",
|
|
93
|
+
"@tanstack/react-query": "^4.36.1",
|
|
94
|
+
"@types/hast": "^3.0.4",
|
|
95
|
+
"@types/katex": "^0.16.7",
|
|
96
|
+
"@types/node": "^18.11.18",
|
|
97
|
+
"@types/react": "^18.0.26",
|
|
98
|
+
"@types/react-dom": "^18.0.10",
|
|
99
|
+
"@types/react-speech-recognition": "^3.9.6",
|
|
100
|
+
"@types/react-syntax-highlighter": "^15.5.13",
|
|
101
|
+
"@types/uuid": "^10.0.0",
|
|
102
|
+
"@types/webfontloader": "^1.6.38",
|
|
103
|
+
"@typescript-eslint/eslint-plugin": "^5.48.1",
|
|
104
|
+
"@typescript-eslint/parser": "^5.48.1",
|
|
105
|
+
"@zerollup/ts-transform-paths": "^1.7.18",
|
|
106
|
+
"autoprefixer": "^10.4.20",
|
|
107
|
+
"axios": "^1.7.9",
|
|
108
|
+
"babel-loader": "^9.1.2",
|
|
109
|
+
"clsx": "^2.1.1",
|
|
110
|
+
"copy-to-clipboard": "^3.3.3",
|
|
111
|
+
"cross-env": "^7.0.3",
|
|
112
|
+
"csv-to-markdown-table": "^1.5.0",
|
|
113
|
+
"date-fns": "^3.6.0",
|
|
114
|
+
"docx": "^9.5.1",
|
|
115
|
+
"eslint": "8.31.0",
|
|
116
|
+
"eslint-config-prettier": "^8.6.0",
|
|
117
|
+
"eslint-plugin-jsx-a11y": "^6.7.1",
|
|
118
|
+
"eslint-plugin-prettier": "^5.4.0",
|
|
119
|
+
"eslint-plugin-react": "^7.32.0",
|
|
120
|
+
"eslint-plugin-react-hooks": "^4.6.0",
|
|
121
|
+
"eslint-plugin-storybook": "^0.11.2",
|
|
122
|
+
"eventsource-parser": "^3.0.2",
|
|
123
|
+
"file-saver": "^2.0.5",
|
|
124
|
+
"framer-motion": "^11.17.0",
|
|
125
|
+
"husky": "^8.0.3",
|
|
126
|
+
"isomorphic-dompurify": "^2.20.0",
|
|
127
|
+
"katex": "^0.16.19",
|
|
128
|
+
"lottie-react": "^2.4.0",
|
|
129
|
+
"mermaid": "^11.7.0",
|
|
130
|
+
"postcss": "^8.4.49",
|
|
131
|
+
"prettier": "^3.5.3",
|
|
132
|
+
"prismjs": "^1.29.0",
|
|
133
|
+
"react": "^18.2.0",
|
|
134
|
+
"react-dom": "^18.2.0",
|
|
135
|
+
"react-intersection-observer": "^9.14.1",
|
|
136
|
+
"react-markdown": "^9.0.3",
|
|
137
|
+
"react-resizable-panels": "^3.0.3",
|
|
138
|
+
"react-syntax-highlighter": "^15.6.1",
|
|
139
|
+
"react-textarea-autosize": "^8.5.9",
|
|
140
|
+
"react-to-print": "^3.1.1",
|
|
141
|
+
"react-tooltip": "^5.28.0",
|
|
142
|
+
"react-virtualized-auto-sizer": "^1.0.25",
|
|
143
|
+
"rehype-katex": "^7.0.1",
|
|
144
|
+
"rehype-raw": "^7.0.0",
|
|
145
|
+
"remark-gfm": "^4.0.0",
|
|
146
|
+
"remark-math": "^6.0.0",
|
|
147
|
+
"rollup": "^2.79.1",
|
|
148
|
+
"rollup-plugin-delete": "^2.0.0",
|
|
149
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
150
|
+
"rollup-plugin-polyfill-node": "^0.13.0",
|
|
151
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
152
|
+
"rollup-plugin-typescript2": "^0.34.1",
|
|
153
|
+
"storybook": "^8.5.3",
|
|
154
|
+
"tailwind-merge": "^2.6.0",
|
|
155
|
+
"tailwind-scrollbar": "^3.1.0",
|
|
156
|
+
"tailwindcss": "^3.4.17",
|
|
157
|
+
"tslib": "^2.4.1",
|
|
158
|
+
"ttypescript": "^1.5.15",
|
|
159
|
+
"typescript": "^4.9.4",
|
|
160
|
+
"typescript-transform-paths": "^3.4.6",
|
|
161
|
+
"unist-util-visit": "^5.0.0",
|
|
162
|
+
"uuid": "^11.1.0",
|
|
163
|
+
"vite": "^6.0.7",
|
|
164
|
+
"vite-plugin-node-polyfills": "^0.24.0",
|
|
165
|
+
"vite-plugin-svgr": "^4.3.0",
|
|
166
|
+
"vite-tsconfig-paths": "^5.1.4",
|
|
167
|
+
"web-speech-cognitive-services": "^8.1.4",
|
|
168
|
+
"webfontloader": "^1.6.28",
|
|
169
|
+
"webpack": "^5.75.0",
|
|
170
|
+
"webpack-cli": "^5.0.1"
|
|
171
|
+
},
|
|
172
|
+
"peerDependencies": {
|
|
173
|
+
"@nem035/gpt-3-encoder": "^1.1.7",
|
|
174
|
+
"@tailwindcss/container-queries": "^0.1.1",
|
|
175
|
+
"@tanstack/react-query": "^4.36.1",
|
|
176
|
+
"axios": "^1.7.9",
|
|
177
|
+
"clsx": "^2.1.1",
|
|
178
|
+
"copy-to-clipboard": "^3.3.3",
|
|
179
|
+
"csv-to-markdown-table": "^1.5.0",
|
|
180
|
+
"date-fns": "^3.6.0",
|
|
181
|
+
"docx": "^9.5.1",
|
|
182
|
+
"eventsource-parser": "^3.0.2",
|
|
183
|
+
"file-saver": "^2.0.5",
|
|
184
|
+
"framer-motion": "^11.17.0",
|
|
185
|
+
"isomorphic-dompurify": "^2.20.0",
|
|
186
|
+
"katex": "^0.16.19",
|
|
187
|
+
"lottie-react": "^2.4.0",
|
|
188
|
+
"prismjs": "^1.29.0",
|
|
189
|
+
"react": "^16.8.0 || ^17 || ^18",
|
|
190
|
+
"react-dom": "^16.8.0 || ^17 || ^18",
|
|
191
|
+
"react-intersection-observer": "^9.14.1",
|
|
192
|
+
"react-markdown": "^9.0.3",
|
|
193
|
+
"react-syntax-highlighter": "^15.6.1",
|
|
194
|
+
"react-textarea-autosize": "^8.5.9",
|
|
195
|
+
"react-to-print": "^3.1.1",
|
|
196
|
+
"react-tooltip": "^5.28.0",
|
|
197
|
+
"react-virtualized-auto-sizer": "^1.0.25",
|
|
198
|
+
"rehype-katex": "^7.0.1",
|
|
199
|
+
"rehype-raw": "^7.0.0",
|
|
200
|
+
"remark-gfm": "^4.0.0",
|
|
201
|
+
"remark-math": "^6.0.0",
|
|
202
|
+
"tailwind-merge": "^2.6.0",
|
|
203
|
+
"tailwind-scrollbar": "^3.1.0",
|
|
204
|
+
"unist-util-visit": "^5.0.0",
|
|
205
|
+
"uuid": "^11.1.0",
|
|
206
|
+
"web-speech-cognitive-services": "^8.1.4",
|
|
207
|
+
"webfontloader": "^1.6.28"
|
|
208
|
+
},
|
|
209
|
+
"engines": {
|
|
210
|
+
"node": ">=18"
|
|
211
|
+
}
|
|
212
|
+
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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 {};
|
|
@@ -1,13 +0,0 @@
|
|
|
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 {};
|