@pickaxeproject/react 6.0.1-15 → 6.0.1-17
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/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/common/AccessGroupCardPreview.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/cjs/components/Pickaxe/index.js +1 -1
- package/dist/cjs/hooks/studio/useStudio.js +1 -0
- package/dist/cjs/src/components/Pickaxe/Addons/Auth/hooks/useAuthContext.d.ts +4 -0
- package/dist/cjs/src/components/Pickaxe/Provider.d.ts +6 -0
- package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +8 -1
- package/dist/cjs/src/hooks/studio/useStudio.d.ts +5 -0
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/common/AccessGroupCardPreview.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/esm/components/Pickaxe/index.js +1 -1
- package/dist/esm/hooks/studio/useStudio.js +1 -0
- package/dist/esm/src/components/Pickaxe/Addons/Auth/hooks/useAuthContext.d.ts +4 -0
- package/dist/esm/src/components/Pickaxe/Provider.d.ts +6 -0
- package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +8 -1
- package/dist/esm/src/hooks/studio/useStudio.d.ts +5 -0
- package/package.json +1 -1
|
@@ -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"),u=require("../Addons/Auth/hooks/useAuthContext.js"),d=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),h=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),b=require("../../Icons/attach-vertical.svg.js"),y=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),j=require("../../Icons/stop.svg.js"),w=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),S=require("../../Core/ErrorAlert.js"),k=require("../../../common/error.js"),I=require("../../../common/cn.js"),C=require("../../../common/utils.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var _=N(n);const E=s.forwardRef((({resubmitPrompt:N,onFocus:E,onBlur:A,onInputHeightChange:q,initSmitheryAuthData:R},T)=>{var P,D,L;const{origin:H,pickaxeId:M,sessionId:F,sender:$,senderType:W,portalId:B,deploymentId:U,deploymentType:J,pickaxe:V,styles:z,colors:K,locale:X,forceMobile:G,isNewChat:Q,isRtl:Y,isShowFeedbackMessage:Z,setIsNewChat:ee,setIsShowIceBreaker:te,onGenerateComplete:se}=i.usePickaxeContext(),{token:ne,isLoggedOut:ie,isSent:re,isPricingAuth:oe}=u.useAuthContext(),{messages:ae,isGenerating:le,setMessages:ce,setStatus:ue,setLimitData:de,setError:fe}=r.useResponseContext(),{documents:pe,isUploading:me,documentError:he,onFileUpload:ge,setDocuments:ve,setDocumentError:be}=d.useDocument(),{scrollStartSession:ye,scrollEndSession:xe,scrollToBottom:je}=f.useScroll({auto:!0}),{artifacts:we,currentPopupType:Oe,setArtifacts:Se,setCurrentArtifact:ke}=p.useArtifactContext(),{height:Ie}=c.useDimensionContext(),Ce=l.useConversation(),[Ne,_e]=s.useState(""),[Ee,Ae]=s.useState(!1),[qe,Re]=s.useState(!1),Te=s.useRef(null),Pe=s.useRef(""),De=s.useRef(null),Le=s.useRef(null),He=s.useRef(null),Me=s.useRef(null),Fe=s.useRef(null),$e=Math.max(.4*Ie,100),{transcript:We,listening:Be,resetTranscript:Ue,browserSupportsSpeechRecognition:Je}=n.useSpeechRecognition(),[Ve]=h.useMediaQuery("(max-width: 480px)"),ze=m.useHover(),{isHover:Ke}=ze,Xe=e.__rest(ze,["isHover"]),Ge=m.useHover(),{isHover:Qe}=Ge,Ye=e.__rest(Ge,["isHover"]),Ze=m.useHover(),{isHover:et}=Ze,tt=e.__rest(Ze,["isHover"]),st=a.useStyleFontSize(),nt=o.useStyleInput(),it="undefined"!=typeof window?window.location.hostname:"",rt="undefined"!=typeof window?window.location.href:"",ot="undefined"!=typeof window&&window.self!==window.top,at=it.includes("pickaxe.co")&&!rt.includes("https://studio.pickaxe.co/_embed")&&!ot,lt=null===(P=null==V?void 0:V.documentuploadtype)||void 0===P?void 0:P.startsWith("enduserupload"),ct=Je&&(null==V?void 0:V.enablevoicetotext),ut="chat-input"===J&&Q&&!re,dt="chat-input"===J&&oe&&ie&&re,ft=null!==(D=null==V?void 0:V.placeholdertext)&&void 0!==D?D:Y?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",pt=Ee||qe,mt=s.useMemo((()=>{var e,t,s;return!!Q&&(!!V&&(!Ce.isLoading&&(!((null!==(t=null===(e=Ce.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=V.icebreakers)||void 0===s?void 0:s.length)&&(!Z&&!ut)))))}),[V,Q,Z,ut,Ce.data,Ce.isLoading]),ht=s.useMemo((()=>{if(le||me)return!1;const e=pe.length>0&&pe.every((e=>"finished"===e.status));return!(!Ne.trim()&&!e)&&pe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[le,me,Ne,pe]);s.useImperativeHandle(T,(()=>({onSubmit:gt}))),s.useEffect((()=>{te(mt)}),[mt]),s.useEffect((()=>{var e;if(N){const t=Array.from(ae),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;gt(s,!0)}}),[N]),s.useEffect((()=>{if(!Me.current||!q)return;const e=new ResizeObserver((e=>{for(const t of e)q(t.contentRect.height)}));return e.observe(Me.current),()=>{e.disconnect()}}),[q]),s.useEffect((()=>{if(!Be)return;const e=Pe.current?`${Pe.current} `:"";_e(`${e}${We}`)}),[We,Be]),s.useEffect((()=>{if(!Le.current)return;(()=>{if(!Le.current)return;let e=Le.current.scrollHeight>52;Ne.includes("\n")||pe.length?e=!0:Ne.trim()||(e=!1),Ae(e)})()}),[Ne,pe]),s.useEffect((()=>{const e=Le.current,t=He.current;if(!e||!t||Ee||Ne.includes("\n"))return void Re(!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=Ne||ft,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;Re(r>l)}),[Ne,Ee,ft]);const gt=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(le||me)return;const r=pe.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:Ne;if(!c&&!l)return;fe(""),be(""),de(null),_e(""),ee(!1),ue("fetching"),ye(),je();const u=null!==(n=null===(e=null==V?void 0:V.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&o.length>0,d=[...s?Array.from(ae.slice(0,ae.length-1)):Array.from(ae),...s?[]:[{id:ae.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:u?o:[]}],{id:ae.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];ce(d),je(),u&&ve([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:H,pickaxeId:M,sessionId:F,senderType:W,value:c},u&&{documentIds:o}),$&&{sender:$}),ne&&{studioSessionToken:ne}),!ne&&!$&&{sender:C.initializeEmbedUserId()}),B&&{portalId:B}),U&&{deploymentId:U}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),at&&{credentials:"include"})),p=yield f.json();if(!p.success){const e=new Error(p.error||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const m=p.submissionId;ue("streaming"),Fe.current=new AbortController;const h=d.length-1,g=[];let b=[...null!=we?we:[]],y=0,x=!1,j="";for(;!x;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${m}?index=${y}`,{signal:null===(i=Fe.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();De.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&y++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return fe(t),void(x=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&R){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw x=!0,R({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 x=!0,R({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ce([...d.slice(0,h),Object.assign(Object.assign({},d[d.length-1]),{id:ae.length+1,role:"assistant",parts:g})])}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"})),Se([...b]),Oe.startsWith("inline")||ke({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"})),Se(b),Oe.startsWith("inline")||ke({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"})),Se(b),Oe.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,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Se(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Se(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);fe(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(x=!0)}else x=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}x||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(x=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==se||se(F)}catch(e){if(e.limitData)de(e.limitData),fe("");else{let t=k.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),fe(t)}}finally{je(),ue("idle"),xe(),De.current=null}}));return dt?null:t.jsx("div",Object.assign({className:I.default("flex w-full flex-shrink-0 flex-col items-center",!ut&&"px-4 pb-8"),dir:Y?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:Me,className:I.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===z.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},nt),{maxHeight:`${$e}px`,overflowY:"auto"})},{children:[Be&&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=K.accent)&&void 0!==L?L:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:K.text+"90"}},{children:"Listening..."}))]})),!le&&pe.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:le}),t.jsx(O.default,Object.assign({ref:Le,className:I.default(st.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ne.trim()&&!Ne.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Y?"text-right":"text-left",pt&&"mb-12",Be&&"text-transparent"),value:Ne,placeholder:ft,onChange:e=>{if(_e(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=>{G||Ve||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),me||le||gt()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);e.length>0&&(t.preventDefault(),ee(!1),yield ge(e))}))},E&&{onFocus:E},A&&{onBlur:A},{dir:Y?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:He,className:I.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",pt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!pt&&nt.backgroundColor&&{backgroundColor:nt.backgroundColor}),{borderTopRightRadius:z.cornerRadius+"px",borderBottomRightRadius:z.cornerRadius+"px"})},{children:le?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{Fe.current&&(Fe.current.abort(),Fe.current=null),De.current&&(De.current.cancel(),De.current=null),ue("idle")},style:{backgroundColor:K.accent,color:K.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):Be?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:_.default.stopListening,style:{backgroundColor:K.accent,color:K.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[lt&&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:Qe?K.accent+"10":void 0,color:Qe?K.accent:K.accent+"80"},disabled:me||le,onClick:()=>{var e;return null===(e=Te.current)||void 0===e?void 0:e.click()}},Ye,{children:[t.jsx("input",{id:"file-upload",ref:Te,type:"file",accept:[...g.allowedFileMimeTypes,...g.allowedImageMimeTypes,...g.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){ee(!1),yield ge(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),ct&&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:Be?K.accent:et?K.accent+"10":void 0,color:Be?K.accentText:et?K.accent:K.accent+"80"},disabled:me||le,onClick:()=>{Be?_.default.stopListening():(Pe.current=Ne,Ue(),_.default.startListening({continuous:!0,interimResults:!0,language:X||"en-US"}))}},tt,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ke||ht?K.accent:K.accent+"10",color:Ke||ht?K.accentText:K.accent+"80"},disabled:!ht,onClick:()=>gt()},Xe,{children:t.jsx(y.default,{className:I.default("h-6 w-6 shrink-0",Y&&"scale-x-[-1] transform")})}))]})}))]})),he&&t.jsx(S.default,{error:he,className:"mt-3"})]}))}))}));E.displayName="Input",exports.default=E;
|
|
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"),o=require("../../../hooks/pickaxe/useResponseContext.js"),r=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"),h=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),b=require("../../Icons/attach-vertical.svg.js"),x=require("../../Icons/arrow-right.svg.js"),y=require("../../Icons/microphone.svg.js"),j=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"),N=require("../../../common/cn.js"),C=require("../../../common/utils.js"),I=require("../../../hooks/studio/useStudio.js");function _(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var E=_(n);const T=s.forwardRef((({resubmitPrompt:_,onFocus:T,onBlur:A,onInputHeightChange:R,initSmitheryAuthData:P},q)=>{var D,L,U;const{origin:M,pickaxeId:$,sessionId:B,sender:F,senderType:H,portalId:X,deploymentId:K,deploymentType:W,pickaxe:J,styles:V,colors:z,locale:G,forceMobile:Q,isNewChat:Y,isRtl:Z,isShowFeedbackMessage:ee,accessGroup:te,setIsNewChat:se,setIsShowIceBreaker:ne,onGenerateComplete:ie}=i.usePickaxeContext(),{token:oe,isLoggedOut:re,isSent:ae,isPricingAuth:le}=d.useAuthContext(),{messages:ce,isGenerating:de,setMessages:ue,setStatus:fe,setLimitData:pe,setError:me}=o.useResponseContext(),{documents:he,isUploading:ge,documentError:ve,onFileUpload:be,setDocuments:xe,setDocumentError:ye}=u.useDocument(),{studio:je}=I.useStudio(),{scrollStartSession:we,scrollEndSession:Oe,scrollToBottom:ke}=f.useScroll({auto:!0}),{artifacts:Se,currentPopupType:Ne,setArtifacts:Ce,setCurrentArtifact:Ie}=p.useArtifactContext(),{height:_e}=c.useDimensionContext(),Ee=l.useConversation(),[Te,Ae]=s.useState(""),[Re,Pe]=s.useState(!1),[qe,De]=s.useState(!1),[Le,Ue]=s.useState(null),[Me,$e]=s.useState(null),[Be,Fe]=s.useState(!1),He=s.useRef(null),Xe=s.useRef(""),Ke=s.useRef(null),We=s.useRef(null),Je=s.useRef(null),Ve=s.useRef(null),ze=s.useRef(null),Ge=Math.max(.4*_e,100),{transcript:Qe,listening:Ye,resetTranscript:Ze,browserSupportsSpeechRecognition:et}=n.useSpeechRecognition(),[tt]=h.useMediaQuery("(max-width: 480px)"),st=m.useHover(),{isHover:nt}=st,it=e.__rest(st,["isHover"]),ot=m.useHover(),{isHover:rt}=ot,at=e.__rest(ot,["isHover"]),lt=m.useHover(),{isHover:ct}=lt,dt=e.__rest(lt,["isHover"]),ut=a.useStyleFontSize(),ft=r.useStyleInput(),pt="undefined"!=typeof window?window.location.hostname:"",mt="undefined"!=typeof window?window.location.href:"",ht="undefined"!=typeof window&&window.self!==window.top,gt=pt.includes("pickaxe.co")&&!mt.includes("https://studio.pickaxe.co/_embed")&&!ht,vt=null===(D=null==J?void 0:J.documentuploadtype)||void 0===D?void 0:D.startsWith("enduserupload"),bt=et&&(null==J?void 0:J.enablevoicetotext),xt="chat-input"===W&&Y&&!ae,yt="chat-input"===W&&le&&re&&ae,jt=null!==(L=null==J?void 0:J.placeholdertext)&&void 0!==L?L:Z?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",wt=Re||qe,Ot=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},F&&{sender:F}),oe&&{studioSessionToken:oe}),!oe&&!F&&{sender:C.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}})),gt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Ue(t.studioUser),$e(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[M,$,B,H,F,oe,X,K,gt]);s.useEffect((()=>{Ot()}),[Ot]);const kt=(null==te?void 0:te.limit)||0,St=(null==Le?void 0:Le.currentUses)||0,Nt=(null==Le?void 0:Le.extraUses)||0,Ct=!!(null==je?void 0:je.data.usage)&&je.data.usage.isCredits,It=kt>St?kt-St+Nt:Nt,_t=s.useMemo((()=>!!Le&&(!Be&&(!(kt<=0)&&It<=.05*kt))),[Le,Be,It,kt]),Et=s.useMemo((()=>{var e,t,s;return!!Y&&(!!J&&(!Ee.isLoading&&(!((null!==(t=null===(e=Ee.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)&&(!ee&&!xt)))))}),[J,Y,ee,xt,Ee.data,Ee.isLoading]),Tt=s.useMemo((()=>{if(de||ge)return!1;const e=he.length>0&&he.every((e=>"finished"===e.status));return!(!Te.trim()&&!e)&&he.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[de,ge,Te,he]);s.useImperativeHandle(q,(()=>({onSubmit:At}))),s.useEffect((()=>{ne(Et)}),[Et]),s.useEffect((()=>{var e;if(_){const t=Array.from(ce),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;At(s,!0)}}),[_]),s.useEffect((()=>{if(!Ve.current||!R)return;const e=new ResizeObserver((e=>{for(const t of e)R(t.contentRect.height)}));return e.observe(Ve.current),()=>{e.disconnect()}}),[R]),s.useEffect((()=>{if(!Ye)return;const e=Xe.current?`${Xe.current} `:"";Ae(`${e}${Qe}`)}),[Qe,Ye]),s.useEffect((()=>{if(!We.current)return;(()=>{if(!We.current)return;let e=We.current.scrollHeight>52;Te.includes("\n")||he.length?e=!0:Te.trim()||(e=!1),Pe(e)})()}),[Te,he]),s.useEffect((()=>{const e=We.current,t=Je.current;if(!e||!t||Re||Te.includes("\n"))return void De(!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=Te||jt,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;De(o>l)}),[Te,Re,jt]);const At=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i;try{if(de||ge)return;const o=he.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:Te;if(!c&&!l)return;me(""),ye(""),pe(null),Ae(""),se(!1),fe("fetching"),we(),ke();const d=null!==(n=null===(e=null==J?void 0:J.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(ce.slice(0,ce.length-1)):Array.from(ce),...s?[]:[{id:ce.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:ce.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];ue(u),ke(),d&&xe([]);const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(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:B,senderType:H,value:c},d&&{documentIds:r}),F&&{sender:F}),oe&&{studioSessionToken:oe}),!oe&&!F&&{sender:C.initializeEmbedUserId()}),X&&{portalId:X}),K&&{deploymentId:K}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),gt&&{credentials:"include"})),p=yield f.json();if(!p.success){const e=new Error(p.error||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const m=p.submissionId;fe("streaming"),ze.current=new AbortController;const h=u.length-1,g=[];let b=[...null!=Se?Se:[]],x=0,y=!1,j="";for(;!y;)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();Ke.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).error||"Something went wrong.";return me(t),void(y=!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 y=!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 y=!0,P({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)j="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("text-end"===n.type)j="";else if("reasoning-start"===n.type)j="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)j+=n.delta,g[g.length-1].content=j;else if("reasoning-end"===n.type)j="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}ue([...u.slice(0,h),Object.assign(Object.assign({},u[u.length-1]),{id:ce.length+1,role:"assistant",parts:g})])}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"})),Ce([...b]),Ne.startsWith("inline")||Ie({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"})),Ce(b),Ne.startsWith("inline")||Ie({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"})),Ce(b),Ne.startsWith("inline")||Ie({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");b=b.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Ce(b)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ce(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);me(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)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==ie||ie(B)}catch(e){if(e.limitData)pe(e.limitData),me("");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."),me(t)}}finally{ke(),fe("idle"),Oe(),Ke.current=null,yield Ot()}}));return yt?null:t.jsx("div",Object.assign({className:N.default("flex w-full flex-shrink-0 flex-col items-center",!xt&&"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:Ve,className:N.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===V.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},ft),{maxHeight:`${Ge}px`,overflowY:"auto"})},{children:[_t&&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:ft.backgroundColor?`${ft.backgroundColor}E6`:void 0,borderColor:z.text+"20",color:z.text,borderTopRightRadius:V.cornerRadius+"px",borderTopLeftRadius:V.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[It," ",Ct?"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=`${Me}${null==te?void 0:te.accessGroupId}`;C.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:()=>Fe(!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"})}))}))]}))]})),!de&&he.length>0&&t.jsx(w.default,{className:"p-4 pb-0",isDisabled:de}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Ye&&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!==(U=z.accent)&&void 0!==U?U:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:z.text+"90"}},{children:"Listening..."}))]})),t.jsx(O.default,Object.assign({ref:We,className:N.default(ut.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Te.trim()&&!Te.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Z?"text-right":"text-left",wt&&"mb-12",Ye&&"text-transparent"),value:Te,placeholder:jt,onChange:e=>{if(Ae(e),R){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void R(0);if(t>=11)return;let s=0;t>1&&(s=50),R(24*(t-1)+s)}},onKeyDown:e=>{Q||tt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ge||de||At()))},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 be(e))}))},T&&{onFocus:T},A&&{onBlur:A},{dir:Z?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Je,className:N.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",wt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!wt&&ft.backgroundColor&&{backgroundColor:ft.backgroundColor}),{borderTopRightRadius:V.cornerRadius+"px",borderBottomRightRadius:V.cornerRadius+"px"})},{children:de?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),Ke.current&&(Ke.current.cancel(),Ke.current=null),fe("idle")},style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):Ye?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:E.default.stopListening,style:{backgroundColor:z.accent,color:z.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[vt&&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:rt?z.accent+"10":void 0,color:rt?z.accent:z.accent+"80"},disabled:ge||de,onClick:()=>{var e;return null===(e=He.current)||void 0===e?void 0:e.click()}},at,{children:[t.jsx("input",{id:"file-upload",ref:He,type:"file",accept:[...g.allowedFileMimeTypes,...g.allowedImageMimeTypes,...g.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){se(!1),yield be(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),bt&&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:Ye?z.accent:ct?z.accent+"10":void 0,color:Ye?z.accentText:ct?z.accent:z.accent+"80"},disabled:ge||de,onClick:()=>{Ye?E.default.stopListening():(Xe.current=Te,Ze(),E.default.startListening({continuous:!0,interimResults:!0,language:G||"en-US"}))}},dt,{children:t.jsx(y.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:nt||Tt?z.accent:z.accent+"10",color:nt||Tt?z.accentText:z.accent+"80"},disabled:!Tt,onClick:()=>At()},it,{children:t.jsx(x.default,{className:N.default("h-6 w-6 shrink-0",Z&&"scale-x-[-1] transform")})}))]})}))]}))]})),ve&&t.jsx(k.default,{error:ve,className:"mt-3"})]}))}))}));T.displayName="Input",exports.default=T;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),i=require("./Addons/Artifact/Provider.js"),o=require("./DimensionProvider.js"),r=require("./ResponseProvider.js"),n=require("./Addons/Document/Provider.js"),a=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}const d=s.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:p,senderType:f,portalId:y,deploymentId:h,deploymentType:m,deploymentDimensions:b,deploymentMisc:S,styles:g,colors:v,limits:x={},misc:j={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:w={popupType:"auto"},responsiveBy:F="viewport",locale:I="en",opacity:k=1,forceMobile:C=!1,disableHtml:O=!1,disableJs:A=!1,disableCss:D=!1,loadFont:T=!0,isRtl:q=!1,isEmbed:E=!1,isDropShadow:H=!1,allowGuestUsage:M=!0,onGenerateComplete:R})=>{const[_,G]=s.useState(""),[L,B]=s.useState(""),[N,U]=s.useState(""),[W,z]=s.useState(""),[J,V]=s.useState(p),[Y,K]=s.useState(null),[Q,X]=s.useState(f),[Z,$]=s.useState("loading"),[ee,te]=s.useState(null),[se,ie]=s.useState(null),[oe,re]=s.useState(null),[ne,ae]=s.useState(!1),[le,de]=s.useState(!0),[ce,ue]=s.useState(!0),[pe,fe]=s.useState(!1);return s.useEffect((()=>{ae(!1)}),[null==g?void 0:g.font]),s.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&T&&!ne&&(null==g?void 0:g.font)&&"Real Head Pro"!==g.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[g.font]},active:()=>{ae(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),ae(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),ae(!0)}}))}),[T,ne,null==g?void 0:g.font]),s.useEffect((()=>{V(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign({origin:u,contextId:_,pickaxeId:L,sessionId:N,lastSessionId:W,sender:J,senderType:Q,portalId:y,deploymentId:h,deploymentType:m,validationStatus:Z,deploymentDimensions:b,deploymentMisc:S,accessGroup:Y,pickaxe:oe,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},g),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},v),misc:j,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","log-out":"Log Out","clear-form":"Clear form"},P),artifact:w,responsiveBy:F,locale:I,opacity:k,forceMobile:C,loadFont:T,disableHtml:O,disableJs:A,disableCss:D,isFontLoaded:ne,isNewChat:le,isShowIceBreaker:ce,isShowFeedbackMessage:pe,isRtl:q,isEmbed:E,isDropShadow:H,allowGuestUsage:M,clientSecret:se,stripeAccountId:ee,setClientSecret:ie,setStripeAccountId:te,setContextId:G,setValidationStatus:$,setPickaxeId:B,setSessionId:U,setLastSessionId:z,setSender:V,setSenderType:X,setAccessGroup:K,setPickaxe:re,setIsFontLoaded:ae,setIsNewChat:de,setIsShowIceBreaker:ue,setIsShowFeedbackMessage:fe},R&&{onGenerateComplete:R})},{children:t.jsx(a.default,{children:t.jsx(o.default,{children:t.jsx(r.default,Object.assign({limits:x},{children:t.jsx(n.default,{children:t.jsx(i.ArtifactProvider,Object.assign({},w,{children:c}))})}))})})}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),i=require("react"),t=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("./PickaxeButton.js"),a=require("./PickaxeCommon.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),i=require("react"),t=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("./PickaxeButton.js"),a=require("./PickaxeCommon.js"),o=require("./PickaxeCurrency.js"),n=require("./PickaxeAvatar.js"),c=require("../Addons/Auth/hooks/useAuthContext.js"),l=require("../../../common/api/pickaxe.js"),u=require("../../../common/utils.js"),d=require("../../../hooks/pickaxe/useResponseContext.js"),x=require("../../../hooks/studio/useStudio.js");exports.default=({data:m,children:p,upgradeUrl:f})=>{var j;const{limitData:v}=d.useResponseContext(),{studio:h}=x.useStudio(),{colors:b,sender:g,pickaxe:k,setValidationStatus:y,setStripeAccountId:I,setClientSecret:O}=t.usePickaxeContext(),{token:N,setRedirectUrl:S}=c.useAuthContext(),_=i.useMemo((()=>{var e;return null!==(e=m.displayName)&&void 0!==e?e:m.name}),[m]),q=i.useMemo((()=>{var e;return null!==(e=m.displayDescription)&&void 0!==e?e:m.description}),[m]),C=!!(null==h?void 0:h.data.usage)&&h.data.usage.isCredits,w=i.useMemo((()=>{var e;const{price:s,priceInterval:i,currency:t}=m;if(!s)return{price:"Free",suffix:""};const r=a.intervalToSuffix(i,!0);return{price:`${(null!==(e=o.currencyOptions.find((e=>e.id===t)))&&void 0!==e?e:o.currencyOptions[0]).symbol}${s.toLocaleString()}`,suffix:r}}),[m]),A=i.useMemo((()=>{const{limit:e,limitInterval:s}=m;if(e===a.STUDIO_INFINITY_VALUE)return{limit:"Unlimited",suffix:""};const i=a.intervalToSuffix(s,!0);return{limit:e.toLocaleString(),suffix:i}}),[m]);return s.jsxs("div",Object.assign({className:"relative flex min-h-[260px] w-[220px] shrink-0 snap-center flex-col justify-between rounded-xl border p-4 shadow-sm",style:{backgroundColor:b.secondary,color:b.secondaryText}},{children:[p,s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsxs(n.Avatar,Object.assign({className:"h-8 w-8"},{children:[s.jsx(n.AvatarImage,{src:null!==(j=m.image)&&void 0!==j?j:"",alt:_}),s.jsx(n.AvatarFallback,{})]})),s.jsx("p",Object.assign({className:"mt-2 text-sm font-semibold line-clamp-1",title:_},{children:_})),Boolean(q)&&s.jsx("p",Object.assign({className:"mt-1 text-[10px] opacity-70 line-clamp-2 leading-tight"},{children:q})),s.jsxs("p",Object.assign({className:"mt-2 text-base font-semibold"},{children:[w.price,s.jsx("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:w.suffix}))]}))]})),s.jsxs("div",Object.assign({className:"mt-3 flex flex-col border-t py-2",style:{borderTopColor:b.secondaryText}},{children:[s.jsx("span",Object.assign({className:"text-[10px] font-bold opacity-50"},{children:C?"CREDITS":"USES"})),s.jsxs("p",Object.assign({className:"text-base font-semibold"},{children:[A.limit,s.jsx("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:A.suffix}))]}))]}))]})),s.jsx(r.default,Object.assign({variant:"primary",className:"w-full mt-2 min-h-[32px] text-xs",onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(N)e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield l.default.post("/access_group_checkout",{data:{studioUserId:g||void 0,studioId:null==k?void 0:k.studioid,accessGroupId:m.accessGroupId,successUrl:document.URL,isEmbed:u.isInIframe(),studioSessionToken:N}}),{success:s,url:i,clientSecret:t,stripeAccountId:r,error:a}=e.data;s?u.isInIframe()?t&&r?(I(r),O(t),y("stripe_checkout")):i&&window.open(i,"_blank"):i&&(window.location.href=i):alert(a)}catch(e){alert(e)}}));else if(u.isInIframe()){const e=f||(null==v?void 0:v.limitLink);S(e||null),y("login_required")}else window.location.href=f||`${null==v?void 0:v.limitLink}?redirectUrl=${document.URL}`}))},{children:m.ctaButtonText}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),i=require("framer-motion"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../common/utils.js"),n=require("../../Icons/circle-exclamation.svg.js"),c=require("../../Core/SpringTransition.js"),d=require("../../Core/HtmlRenderer.js"),u=require("./PickaxeButton.js"),x=require("../../../common/cn.js"),p=require("../../../common/api/pickaxe.js"),m=require("../Addons/Auth/hooks/useAuthContext.js"),f=require("./AccessGroupCardPreview.js"),v=require("../../../hooks/studio/useStudio.js"),j=require("./PickaxeCurrency.js");const g=({price:e,uses:t,isCredits:i,isSelected:r,costPerRun:a,onClick:o,colors:l})=>{const n={backgroundColor:l.secondary,color:l.secondaryText,borderColor:r?l.secondaryText:"rgba(0,0,0,0.1)"},c=i&&a?Math.ceil(t/a):0;return i?s.jsxs("button",Object.assign({onClick:o,className:x.default("flex min-w-[200px] shrink-0 cursor-pointer flex-col rounded-[16px] px-6 py-5 text-left transition-all duration-200",r?"border-2 shadow-sm":"border opacity-80 hover:opacity-100"),style:n},{children:[s.jsxs("div",Object.assign({className:"mb-4 flex items-center gap-2"},{children:[s.jsx("span",Object.assign({className:"text-[24px] font-semibold tracking-tight"},{children:e})),s.jsxs("span",Object.assign({className:"text-[14px] font-light opacity-80"},{children:["/",t," credits"]}))]})),s.jsx("div",{className:"mb-4 h-[1px] w-full",style:{backgroundColor:l.secondaryText,opacity:.15}}),s.jsxs("span",Object.assign({className:"text-[14px] italic opacity-70"},{children:["~ ",void 0!==c&&c>0?c.toLocaleString():"..."," ","runs"]}))]})):s.jsxs("button",Object.assign({onClick:o,className:x.default("flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-[16px] px-5 py-3 transition-all duration-200",r?"border-2 shadow-sm":"border opacity-80 hover:opacity-100"),style:n},{children:[s.jsx("span",Object.assign({className:"text-[24px] font-semibold tracking-tight"},{children:e})),s.jsxs("span",Object.assign({className:"text-[14px] font-light opacity-80"},{children:["/",t," uses"]}))]}))};exports.default=({className:h,iconClassName:b,htmlClassName:y})=>{var k,w,C,N,O,_;const{colors:q,pickaxe:S,sender:I,setValidationStatus:A,setClientSecret:U,setStripeAccountId:P}=r.usePickaxeContext(),{token:R,setRedirectUrl:L}=m.useAuthContext(),{limitData:T}=a.useResponseContext(),{studio:G}=v.useStudio(),$=o.useStyleFontSize(),[B,E]=t.useState(0),[F,M]=t.useState(null),z=!!(null==G?void 0:G.data.usage)&&G.data.usage.isCredits,D=null!==(w=null===(k=j.currencyOptions.find((e=>e.id===(null==G?void 0:G.data.currency))))||void 0===k?void 0:k.symbol)&&void 0!==w?w:j.currencyOptions[0].symbol;if(t.useEffect((()=>{var e;(null===(e=null==T?void 0:T.buyUses)||void 0===e?void 0:e.length)&&E(0)}),[T]),!T)return null;const H=T.customLink,V=T.limitCTA,J=Array.isArray(T.upgradeGroups)&&T.upgradeGroups.length>0,K=(z?null===(C=null==G?void 0:G.data.usage)||void 0===C?void 0:C.availableCredits:null===(N=null==G?void 0:G.data.usage)||void 0===N?void 0:N.availableUses)||T.buyUses,Q=Array.isArray(K)&&K.length>0,W=Q&&Array.isArray(K)&&K[B];t.useEffect((()=>{let s=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(G&&(null===(e=G.data)||void 0===e?void 0:e.workspaceId))try{const e=yield p.default.get(`/cost_per_run?workspaceId=${G.data.workspaceId}`);if(s){const s=1e4*e.data.costPerRun||0;M(s)}}catch(e){console.error("Failed to fetch cost per run:",e),s&&M(0)}else M(0)})),()=>{s=!1}}),[G,null===(O=null==G?void 0:G.data)||void 0===O?void 0:O.workspaceId,M]);return s.jsx(i.AnimatePresence,{children:s.jsxs(c.default,Object.assign({className:x.default("flex flex-col gap-5 w-full",h)},{children:[s.jsxs("div",Object.assign({className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between rounded-lg p-3 bg-opacity-5",style:{backgroundColor:q.secondary}},{children:[s.jsxs("div",Object.assign({className:"flex gap-3 items-start"},{children:[s.jsx(n.default,{className:x.default("h-5 w-5 shrink-0 mt-0.5",b),style:{color:q.accent}}),s.jsx(d.default,{className:x.default($.b2,"font-semibold leading-relaxed text-sm",y),style:{color:q.text},html:T.limitMessage||""})]})),H&&s.jsx(u.default,Object.assign({variant:"primary",className:"whitespace-nowrap min-h-[32px] w-full sm:w-auto text-sm",onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(l.isInIframe()){if(!R)return L(H||null),void A("login_required");window.open(H)}else window.location.href=`${H}?redirectUrl=${document.URL}`}))},{children:V}))]})),J&&s.jsxs("div",Object.assign({className:"flex flex-col gap-2"},{children:[s.jsx("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:q.text}},{children:"Available Plans"})),s.jsx("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-4 pt-1 snap-x scrollbar-thin"},{children:null===(_=T.upgradeGroups)||void 0===_?void 0:_.map(((e,t)=>s.jsx(f.default,{data:e},e.accessGroupId||t)))}))]})),Q&&W&&s.jsxs("div",Object.assign({className:"flex flex-col gap-3"},{children:[s.jsxs("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:q.text}},{children:["Buy ",z?"Credits":"Uses"]})),s.jsx("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-2 pt-1 snap-x scrollbar-thin"},{children:null==K?void 0:K.map(((e,t)=>s.jsx(g,{price:e.price,uses:e.uses,isCredits:z,costPerRun:F||void 0,isSelected:t===B,onClick:()=>E(t),colors:q},t)))})),s.jsxs(u.default,Object.assign({variant:"primary",className:"w-full py-3 text-sm font-bold shadow-md",onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var s,t;R?(s=W.uses,t=W.price,e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield p.default.post("/get_extra_usage_payment_link",{data:{sender:I||void 0,studioSessionToken:R,studioId:null==S?void 0:S.studioid,cost:t,isEmbed:l.isInIframe(),extraUses:s,successUrl:document.URL}}),{success:i,url:r,clientSecret:a,stripeAccountId:o,error:n}=e.data;i?l.isInIframe()?a&&o?(P(o),U(a),A("stripe_checkout")):r&&window.open(r,"_blank"):r&&(window.location.href=r):alert(n)}catch(e){alert(e)}}))):l.isInIframe()?(L(H||null),A("login_required")):window.location.href=`${H}?redirectUrl=${document.URL}`}))},{children:["Buy ",W.uses.toLocaleString()," ",z?"Credits":"Uses"," for ",D,W.price]}))]}))]}))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),r=require("../../hooks/pickaxe/usePickaxeContext.js"),i=require("./Addons/Auth/hooks/useAuthContext.js"),l=require("../../hooks/pickaxe/useResponseContext.js"),c=require("./Addons/Document/hooks/useDocumentContext.js"),o=require("./Addons/Artifact/hooks/useArtifactContext.js"),n=require("uuid"),d=require("./Addons/Scroll/Provider.js"),u=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),p=require("./Addons/Auth/index.js"),f=require("../../common/cn.js"),j=require("../../common/api/pickaxe.js"),h=require("./common/AccessGroupCardPreview.js"),g=require("./common/PickaxeAvatar.js"),v=require("../Icons/lock.svg.js"),b=require("../../node_modules/.pnpm/@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js"),k=require("../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js");const y=({className:e})=>s.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e},{children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}));exports.Pickaxe=({pickaxeId:w,className:N})=>{const{sessionId:q,styles:_,colors:O,responsiveBy:C,deploymentType:A,isNewChat:S,isEmbed:I,opacity:P,deploymentId:E,sender:L,portalId:R,validationStatus:T,stripeAccountId:D,clientSecret:G,setClientSecret:M,setStripeAccountId:U,setValidationStatus:B,setContextId:F,setPickaxeId:$,setSessionId:W,setPickaxe:z,setAccessGroup:H}=r.usePickaxeContext(),{isSent:J,token:K}=i.useAuthContext(),{setMessages:V,setResponse:X,setError:Y,setLimitData:Q,setIsSwitchedToChat:Z}=l.useResponseContext(),{setDocumentError:ee}=c.useDocumentContext(),{setCurrentArtifact:se}=o.useArtifactContext(),[te,ae]=a.useState(!1),[re,ie]=a.useState([]),[le,ce]=a.useState(null),oe=t.usePickaxe(),ne="chat-input"===A&&S&&!J,de=a.useMemo((()=>D?k.loadStripe(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:D}):null),[D]);a.useEffect((()=>{$(w)}),[w]);a.useEffect((()=>{if(!E&&!R||!oe.data)return;if("stripe_checkout"===T)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;B("loading");try{const s=yield j.default.post("/validate_studio_deployment",{data:{deploymentId:E,sender:L||void 0,studioSessionToken:K,portalId:R,studioId:null===(e=oe.data)||void 0===e?void 0:e.studioid}});s.data.success?(B("success"),H(s.data.accessGroup)):"Login required."===s.data.message?(B("login_required"),ae(!0)):"Access denied."===s.data.message?(B("access_denied"),ie(s.data.upgradeGroups||[]),ae(!0)):"Upgrade required."===s.data.message?(B("upgrade_required"),ie(s.data.upgradeGroups||[]),ce(s.data.upgradeUrl),ae(!0)):B("login_required")}catch(e){console.error("Failed to validate deployment:",e),B("success")}}))}),[E,L,K,R,oe.data]),a.useEffect((()=>{if(!oe.data)return;const e=oe.data.chatflag;W(e?n.v4():""),F(n.v4()),e?V([]):X(null),Y(""),ee(""),Q(null),se(null),Z(!1),z(oe.data),ae(!0)}),[oe.data]),a.useEffect((()=>{Y(""),ee(""),Q(null),V([]),X(null),se(null)}),[q]);const ue=a.useMemo((()=>{const e=null!=P?P:1;if(!O.primary||!O.primary.startsWith("#")||e<0||e>1)return O.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${O.primary}${s}`}),[O.primary,P]);if(!oe.data)return null;return s.jsx("div",Object.assign({className:f.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===_.theme&&"dark",N),style:Object.assign({backgroundColor:ne?"transparent":ue,color:O.text},_.font&&"Real Head Pro"!==_.font&&{fontFamily:_.font})},{children:"stripe_checkout"===T&&G&&de?s.jsxs("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:O.secondary||"#ffffff",color:O.secondaryText||"#000000"}},{children:[s.jsx("div",Object.assign({className:"flex items-center p-4 border-b border-gray-100 shrink-0"},{children:s.jsxs("button",Object.assign({onClick:()=>{M&&M(null),U&&U(null),B("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:O.text}},{children:[s.jsx(y,{className:"w-5 h-5"}),s.jsx("span",{children:"Back"})]}))})),s.jsx("div",Object.assign({className:"flex-1 w-full h-full overflow-y-auto [&>div]:h-full"},{children:s.jsx(b.EmbeddedCheckoutProvider,Object.assign({stripe:de,options:{clientSecret:G}},{children:s.jsx(b.EmbeddedCheckout,{})}))}))]})):oe.isLoading||!te||"loading"===T?s.jsx("div",Object.assign({className:f.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===C?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s.jsx(u.default,{className:"w-[72px] h-[72px]"}),s.jsx(u.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s.jsx(u.default,{className:f.default("w-full min-h-[48px]","viewport"===C?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===T?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:re&&re.length>0?s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[s.jsxs("div",Object.assign({className:"text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),s.jsx("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:re.map(((e,t)=>s.jsx(h.default,{data:e,upgradeUrl:le},e.id||t)))}))]})):s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===T&&I?s.jsx(p.default,{}):"login_required"!==T||I?"access_denied"===T?s.jsxs("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[s.jsxs(g.Avatar,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s.jsx(g.AvatarImage,{src:null===(xe=oe.data)||void 0===xe?void 0:xe.coverphoto,alt:`${null===(me=oe.data)||void 0===me?void 0:me.formtitle} Logo`}),s.jsx(g.AvatarFallback,{})]})),s.jsxs("div",Object.assign({className:"text-center mb-6"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsxs("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s.jsx(v.default,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s.jsx("p",Object.assign({className:"ml-1"},{children:"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s.jsx("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:O.accent,color:O.accentText,borderRadius:_.cornerRadius},onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;const t=re.map((e=>e.accessGroupId));try{const a=yield j.default.post("/request_access",{data:{sender:L||void 0,studioSessionToken:K,studioId:null===(e=oe.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=oe.data)||void 0===s?void 0:s.formid,deploymentId:E,accessGroupIds:t})}});a.data.success?alert("Successfully requested access!"):alert(a.data.error)}catch(e){alert(`Couldn't request access. Error: ${e}`)}}))}},{children:"Request Access"})),s.jsx("span",Object.assign({className:"mt-4 mb-2"},{children:"or"})),s.jsx("span",Object.assign({className:"font-medium text-lg"},{children:"Sign in with a different account"}))]})):q?s.jsx(d.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(d.ScrollProvider,{children:s.jsx(m.default,{})}):s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}));var xe,me};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../common/api/pickaxe.js"),r=require("../pickaxe/usePickaxeContext.js"),t=require("@tanstack/react-query");exports.useStudio=()=>{const{pickaxe:i}=r.usePickaxeContext(),u=null==i?void 0:i.studioid,{data:s,isLoading:o,error:a}=t.useQuery({queryKey:["studio",u],queryFn:()=>e.default.get("get_studio",{params:{studioId:u}}),enabled:!!u});return{studio:s,isLoading:o,error:a}};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const useAuthContext: () => {
|
|
2
2
|
emailInput: string;
|
|
3
|
+
redirectUrl: string | null;
|
|
3
4
|
token: string | null;
|
|
4
5
|
isLoggedIn: boolean;
|
|
5
6
|
isLoggedOut: boolean;
|
|
@@ -7,10 +8,13 @@ export declare const useAuthContext: () => {
|
|
|
7
8
|
isSending: boolean;
|
|
8
9
|
isResendDisabled: boolean;
|
|
9
10
|
isSent: boolean;
|
|
11
|
+
isPricingAuth: boolean;
|
|
10
12
|
setEmailInput: import("../../../../../types/common").SetState<string>;
|
|
11
13
|
setToken: import("../../../../../types/common").SetState<string | null>;
|
|
12
14
|
setIsLoggingIn: import("../../../../../types/common").SetState<boolean>;
|
|
13
15
|
setIsSending: import("../../../../../types/common").SetState<boolean>;
|
|
14
16
|
setIsResendDisabled: import("../../../../../types/common").SetState<boolean>;
|
|
15
17
|
setIsSent: import("../../../../../types/common").SetState<boolean>;
|
|
18
|
+
setIsPricingAuth: import("../../../../../types/common").SetState<boolean>;
|
|
19
|
+
setRedirectUrl: import("../../../../../types/common").SetState<string | null>;
|
|
16
20
|
};
|
|
@@ -55,6 +55,10 @@ export type PickaxeDeploymentMisc = {
|
|
|
55
55
|
popupText?: string;
|
|
56
56
|
fabImage?: string;
|
|
57
57
|
};
|
|
58
|
+
export type AccessGroup = {
|
|
59
|
+
limit: number;
|
|
60
|
+
accessGroupId: string;
|
|
61
|
+
};
|
|
58
62
|
type PickaxeContextType = {
|
|
59
63
|
origin: PickaxeHistoryOriginType;
|
|
60
64
|
contextId: string;
|
|
@@ -69,6 +73,7 @@ type PickaxeContextType = {
|
|
|
69
73
|
deploymentDimensions?: PickaxeDeploymentDimensions;
|
|
70
74
|
deploymentMisc?: PickaxeDeploymentMisc;
|
|
71
75
|
portalId?: string;
|
|
76
|
+
accessGroup?: AccessGroup | null;
|
|
72
77
|
pickaxe: LimitedPickaxe | null;
|
|
73
78
|
styles: PickaxeProviderStyles;
|
|
74
79
|
colors: PickaxeProviderColors;
|
|
@@ -96,6 +101,7 @@ type PickaxeContextType = {
|
|
|
96
101
|
setContextId: SetState<string>;
|
|
97
102
|
setPickaxeId: SetState<string>;
|
|
98
103
|
setSessionId: SetState<string>;
|
|
104
|
+
setAccessGroup: SetState<AccessGroup | null>;
|
|
99
105
|
setLastSessionId: SetState<string>;
|
|
100
106
|
setValidationStatus: SetState<ValidationStatus>;
|
|
101
107
|
setSender: SetState<string | undefined>;
|
|
@@ -8,9 +8,11 @@ export declare const usePickaxeContext: () => {
|
|
|
8
8
|
senderType: import("../../types/history").PickaxeHistorySenderType;
|
|
9
9
|
deploymentId?: string | undefined;
|
|
10
10
|
deploymentType?: import("../../components/Pickaxe/Provider").PickaxeDeploymentEmbedType | undefined;
|
|
11
|
+
validationStatus: "loading" | "success" | "login_required" | "upgrade_required" | "access_denied" | "stripe_checkout";
|
|
11
12
|
deploymentDimensions?: import("../../components/Pickaxe/Provider").PickaxeDeploymentDimensions | undefined;
|
|
12
13
|
deploymentMisc?: import("../../components/Pickaxe/Provider").PickaxeDeploymentMisc | undefined;
|
|
13
14
|
portalId?: string | undefined;
|
|
15
|
+
accessGroup?: import("../../components/Pickaxe/Provider").AccessGroup | null | undefined;
|
|
14
16
|
pickaxe: import("../../types/pickaxe").LimitedPickaxe | null;
|
|
15
17
|
styles: import("../../components/Pickaxe/Provider").PickaxeProviderStyles;
|
|
16
18
|
colors: import("../../components/Pickaxe/Provider").PickaxeProviderColors;
|
|
@@ -32,12 +34,15 @@ export declare const usePickaxeContext: () => {
|
|
|
32
34
|
isRtl: boolean;
|
|
33
35
|
isEmbed: boolean;
|
|
34
36
|
isDropShadow: boolean;
|
|
35
|
-
isEmailLogin: boolean;
|
|
36
37
|
allowGuestUsage: boolean;
|
|
38
|
+
stripeAccountId: string | null;
|
|
39
|
+
clientSecret: string | null;
|
|
37
40
|
setContextId: import("../../types/common").SetState<string>;
|
|
38
41
|
setPickaxeId: import("../../types/common").SetState<string>;
|
|
39
42
|
setSessionId: import("../../types/common").SetState<string>;
|
|
43
|
+
setAccessGroup: import("../../types/common").SetState<import("../../components/Pickaxe/Provider").AccessGroup | null>;
|
|
40
44
|
setLastSessionId: import("../../types/common").SetState<string>;
|
|
45
|
+
setValidationStatus: import("../../types/common").SetState<"loading" | "success" | "login_required" | "upgrade_required" | "access_denied" | "stripe_checkout">;
|
|
41
46
|
setSender: import("../../types/common").SetState<string | undefined>;
|
|
42
47
|
setSenderType: import("../../types/common").SetState<import("../../types/history").PickaxeHistorySenderType>;
|
|
43
48
|
setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").LimitedPickaxe | null>;
|
|
@@ -45,5 +50,7 @@ export declare const usePickaxeContext: () => {
|
|
|
45
50
|
setIsNewChat: import("../../types/common").SetState<boolean>;
|
|
46
51
|
setIsShowIceBreaker: import("../../types/common").SetState<boolean>;
|
|
47
52
|
setIsShowFeedbackMessage: import("../../types/common").SetState<boolean>;
|
|
53
|
+
setStripeAccountId: import("../../types/common").SetState<string | null>;
|
|
54
|
+
setClientSecret: import("../../types/common").SetState<string | null>;
|
|
48
55
|
onGenerateComplete?: ((responseId: string) => void) | undefined;
|
|
49
56
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as s,Fragment as o}from"react/jsx-runtime";import{forwardRef as i,useState as r,useRef as a,useMemo as l,useImperativeHandle as c,useEffect as d}from"react";import"../../../node_modules/.pnpm/regenerator-runtime@0.14.1/node_modules/regenerator-runtime/runtime.js";import u,{useSpeechRecognition as m}from"react-speech-recognition";import{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as f}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as h}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as g}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as v}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as b}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as y}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as j}from"../Addons/Document/hooks/useDocument.js";import{useScroll as x}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as w}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as O}from"../../../hooks/core/useHover.js";import{useMediaQuery as k}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as S,allowedImageMimeTypes as N,additionalAllowedFileExtensions as I}from"../../../common/documents.js";import{createParser as C}from"eventsource-parser";import A from"../../Icons/attach-vertical.svg.js";import _ from"../../Icons/arrow-right.svg.js";import E from"../../Icons/microphone.svg.js";import T from"../../Icons/stop.svg.js";import P from"../Addons/Document/List.js";import D from"../../Core/Textarea.js";import R from"../../Core/ErrorAlert.js";import L from"../../../common/error.js";import $ from"../../../common/cn.js";import{initializeEmbedUserId as W}from"../../../common/utils.js";const B=i((({resubmitPrompt:i,onFocus:B,onBlur:H,onInputHeightChange:F,initSmitheryAuthData:J},U)=>{var M,V,K;const{origin:X,pickaxeId:z,sessionId:q,sender:G,senderType:Q,portalId:Y,deploymentId:Z,deploymentType:ee,pickaxe:te,styles:ne,colors:se,locale:oe,forceMobile:ie,isNewChat:re,isRtl:ae,isShowFeedbackMessage:le,setIsNewChat:ce,setIsShowIceBreaker:de,onGenerateComplete:ue}=p(),{token:me,isLoggedOut:pe,isSent:fe,isPricingAuth:he}=y(),{messages:ge,isGenerating:ve,setMessages:be,setStatus:ye,setLimitData:je,setError:xe}=f(),{documents:we,isUploading:Oe,documentError:ke,onFileUpload:Se,setDocuments:Ne,setDocumentError:Ie}=j(),{scrollStartSession:Ce,scrollEndSession:Ae,scrollToBottom:_e}=x({auto:!0}),{artifacts:Ee,currentPopupType:Te,setArtifacts:Pe,setCurrentArtifact:De}=w(),{height:Re}=b(),Le=v(),[$e,We]=r(""),[Be,He]=r(!1),[Fe,Je]=r(!1),Ue=a(null),Me=a(""),Ve=a(null),Ke=a(null),Xe=a(null),ze=a(null),qe=a(null),Ge=Math.max(.4*Re,100),{transcript:Qe,listening:Ye,resetTranscript:Ze,browserSupportsSpeechRecognition:et}=m(),[tt]=k("(max-width: 480px)"),nt=O(),{isHover:st}=nt,ot=e(nt,["isHover"]),it=O(),{isHover:rt}=it,at=e(it,["isHover"]),lt=O(),{isHover:ct}=lt,dt=e(lt,["isHover"]),ut=g(),mt=h(),pt="undefined"!=typeof window?window.location.hostname:"",ft="undefined"!=typeof window?window.location.href:"",ht="undefined"!=typeof window&&window.self!==window.top,gt=pt.includes("pickaxe.co")&&!ft.includes("https://studio.pickaxe.co/_embed")&&!ht,vt=null===(M=null==te?void 0:te.documentuploadtype)||void 0===M?void 0:M.startsWith("enduserupload"),bt=et&&(null==te?void 0:te.enablevoicetotext),yt="chat-input"===ee&&re&&!fe,jt="chat-input"===ee&&he&&pe&&fe,xt=null!==(V=null==te?void 0:te.placeholdertext)&&void 0!==V?V:ae?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",wt=Be||Fe,Ot=l((()=>{var e,t,n;return!!re&&(!!te&&(!Le.isLoading&&(!((null!==(t=null===(e=Le.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=te.icebreakers)||void 0===n?void 0:n.length)&&(!le&&!yt)))))}),[te,re,le,yt,Le.data,Le.isLoading]),kt=l((()=>{if(ve||Oe)return!1;const e=we.length>0&&we.every((e=>"finished"===e.status));return!(!$e.trim()&&!e)&&we.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ve,Oe,$e,we]);c(U,(()=>({onSubmit:St}))),d((()=>{de(Ot)}),[Ot]),d((()=>{var e;if(i){const t=Array.from(ge),n=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;St(n,!0)}}),[i]),d((()=>{if(!ze.current||!F)return;const e=new ResizeObserver((e=>{for(const t of e)F(t.contentRect.height)}));return e.observe(ze.current),()=>{e.disconnect()}}),[F]),d((()=>{if(!Ye)return;const e=Me.current?`${Me.current} `:"";We(`${e}${Qe}`)}),[Qe,Ye]),d((()=>{if(!Ke.current)return;(()=>{if(!Ke.current)return;let e=Ke.current.scrollHeight>52;$e.includes("\n")||we.length?e=!0:$e.trim()||(e=!1),He(e)})()}),[$e,we]),d((()=>{const e=Ke.current,t=Xe.current;if(!e||!t||Be||$e.includes("\n"))return void Je(!1);const n=window.getComputedStyle(e),s=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} / ${n.lineHeight} ${n.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:s,letterSpacing:n.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=$e||xt,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Je(i>l)}),[$e,Be,xt]);const St=(e,n=!1)=>t(void 0,void 0,void 0,(function*(){var t,s,o;try{if(ve||Oe)return;const i=we.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:$e;if(!c&&!l)return;xe(""),Ie(""),je(null),We(""),ce(!1),ye("fetching"),Ce(),_e();const d=null!==(s=null===(t=null==te?void 0:te.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s&&r.length>0,u=[...n?Array.from(ge.slice(0,ge.length-1)):Array.from(ge),...n?[]:[{id:ge.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:ge.length+(n?0:2),role:"assistant",parts:[],documentIds:[]}];be(u),_e(),d&&Ne([]);const m=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:X,pickaxeId:z,sessionId:q,senderType:Q,value:c},d&&{documentIds:r}),G&&{sender:G}),me&&{studioSessionToken:me}),!me&&!G&&{sender:W()}),Y&&{portalId:Y}),Z&&{deploymentId:Z}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),gt&&{credentials:"include"})),p=yield m.json();if(!p.success){const e=new Error(p.error||"Failed to start generation");throw p.limitData&&(e.limitData=p.limitData),e}const f=p.submissionId;ye("streaming"),qe.current=new AbortController;const h=u.length-1,g=[];let v=[...null!=Ee?Ee:[]],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=qe.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();Ve.current=t;const n=new TextDecoder,s=C({onEvent:e=>{var t,n;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return xe(t),void(y=!0)}if("delta"===e.event){const s=JSON.parse(e.data);if("data-error"===s.type&&J){const e=s.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw y=!0,J({smitheryId:t[1],serverId:n[1],name:s[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,J({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===s.type)j="",g.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t});else if("text-delta"===s.type)j+=s.delta,g[g.length-1].content=j;else if("text-end"===s.type)j="";else if("reasoning-start"===s.type)j="",g.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n});else if("reasoning-delta"===s.type)j+=s.delta,g[g.length-1].content=j;else if("reasoning-end"===s.type)j="";else if(s.type.startsWith("data-")){const e=s;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}be([...u.slice(0,h),Object.assign(Object.assign({},u[u.length-1]),{id:ge.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"})),Pe([...v]),Te.startsWith("inline")||De({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"})),Pe(v),Te.startsWith("inline")||De({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"})),Pe(v),Te.startsWith("inline")||De({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),n=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+n,status:"streaming"}):e)),Pe(v)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Pe(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);xe(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;s.feed(n.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==ue||ue(q)}catch(e){if(e.limitData)je(e.limitData),xe("");else{let t=L(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),xe(t)}}finally{_e(),ye("idle"),Ae(),Ve.current=null}}));return jt?null:n("div",Object.assign({className:$("flex w-full flex-shrink-0 flex-col items-center",!yt&&"px-4 pb-8"),dir:ae?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[s("div",Object.assign({ref:ze,className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ne.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},mt),{maxHeight:`${Ge}px`,overflowY:"auto"})},{children:[Ye&&s("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[n("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(K=se.accent)&&void 0!==K?K:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:se.text+"90"}},{children:"Listening..."}))]})),!ve&&we.length>0&&n(P,{className:"p-4 pb-0",isDisabled:ve}),n(D,Object.assign({ref:Ke,className:$(ut.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!$e.trim()&&!$e.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",ae?"text-right":"text-left",wt&&"mb-12",Ye&&"text-transparent"),value:$e,placeholder:xt,onChange:e=>{if(We(e),F){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void F(0);if(t>=11)return;let n=0;t>1&&(n=50),F(24*(t-1)+n)}},onKeyDown:e=>{ie||tt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Oe||ve||St()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),ce(!1),yield Se(t))}))},B&&{onFocus:B},H&&{onBlur:H},{dir:ae?"rtl":"ltr"})),n("div",Object.assign({ref:Xe,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",wt?"mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!wt&&mt.backgroundColor&&{backgroundColor:mt.backgroundColor}),{borderTopRightRadius:ne.cornerRadius+"px",borderBottomRightRadius:ne.cornerRadius+"px"})},{children:ve?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{qe.current&&(qe.current.abort(),qe.current=null),Ve.current&&(Ve.current.cancel(),Ve.current=null),ye("idle")},style:{backgroundColor:se.accent,color:se.accentText}},{children:n(T,{className:"h-4 w-4 shrink-0"})})):Ye?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:u.stopListening,style:{backgroundColor:se.accent,color:se.accentText}},{children:n(T,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[vt&&s("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:rt?se.accent+"10":void 0,color:rt?se.accent:se.accent+"80"},disabled:Oe||ve,onClick:()=>{var e;return null===(e=Ue.current)||void 0===e?void 0:e.click()}},at,{children:[n("input",{id:"file-upload",ref:Ue,type:"file",accept:[...S,...N,...I].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){ce(!1),yield Se(Array.from(e.target.files||[])),e.target.value=""}))}),n(A,{className:"h-6 w-6 shrink-0"})]})),bt&&n("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Ye?se.accent:ct?se.accent+"10":void 0,color:Ye?se.accentText:ct?se.accent:se.accent+"80"},disabled:Oe||ve,onClick:()=>{Ye?u.stopListening():(Me.current=$e,Ze(),u.startListening({continuous:!0,interimResults:!0,language:oe||"en-US"}))}},dt,{children:n(E,{className:"h-5 w-5 shrink-0"})})),n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:st||kt?se.accent:se.accent+"10",color:st||kt?se.accentText:se.accent+"80"},disabled:!kt,onClick:()=>St()},ot,{children:n(_,{className:$("h-6 w-6 shrink-0",ae&&"scale-x-[-1] transform")})}))]})}))]})),ke&&n(R,{error:ke,className:"mt-3"})]}))}))}));B.displayName="Input";export{B as default};
|
|
1
|
+
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as n,jsxs as s,Fragment as o}from"react/jsx-runtime";import{forwardRef as i,useState as r,useRef as a,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 h}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as g}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 x}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as j}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 C,allowedImageMimeTypes as S,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 $ from"../../../common/cn.js";import{isInIframe as B,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 V,z,G;const{origin:q,pickaxeId:Q,sessionId:Y,sender:Z,senderType:ee,portalId:te,deploymentId:ne,deploymentType:se,pickaxe:oe,styles:ie,colors:re,locale:ae,forceMobile:le,isNewChat:ce,isRtl:de,isShowFeedbackMessage:ue,accessGroup:pe,setIsNewChat:me,setIsShowIceBreaker:fe,onGenerateComplete:he}=f(),{token:ge,isLoggedOut:ve,isSent:be,isPricingAuth:ye}=x(),{messages:xe,isGenerating:je,setMessages:we,setStatus:Oe,setLimitData:ke,setError:Ne}=h(),{documents:Ce,isUploading:Se,documentError:Ie,onFileUpload:_e,setDocuments:Ee,setDocumentError:Te}=j(),{studio:Ae}=K(),{scrollStartSession:Pe,scrollEndSession:Re,scrollToBottom:De}=w({auto:!0}),{artifacts:Le,currentPopupType:Ue,setArtifacts:$e,setCurrentArtifact:Be}=O(),{height:Xe}=y(),Ke=b(),[We,Fe]=r(""),[He,Je]=r(!1),[Me,Ve]=r(!1),[ze,Ge]=r(null),[qe,Qe]=r(null),[Ye,Ze]=r(!1),et=a(null),tt=a(""),nt=a(null),st=a(null),ot=a(null),it=a(null),rt=a(null),at=Math.max(.4*Xe,100),{transcript:lt,listening:ct,resetTranscript:dt,browserSupportsSpeechRecognition:ut}=m(),[pt]=N("(max-width: 480px)"),mt=k(),{isHover:ft}=mt,ht=e(mt,["isHover"]),gt=k(),{isHover:vt}=gt,bt=e(gt,["isHover"]),yt=k(),{isHover:xt}=yt,jt=e(yt,["isHover"]),wt=v(),Ot=g(),kt="undefined"!=typeof window?window.location.hostname:"",Nt="undefined"!=typeof window?window.location.href:"",Ct="undefined"!=typeof window&&window.self!==window.top,St=kt.includes("pickaxe.co")&&!Nt.includes("https://studio.pickaxe.co/_embed")&&!Ct,It=null===(V=null==oe?void 0:oe.documentuploadtype)||void 0===V?void 0:V.startsWith("enduserupload"),_t=ut&&(null==oe?void 0:oe.enablevoicetotext),Et="chat-input"===se&&ce&&!be,Tt="chat-input"===se&&ye&&ve&&be,At=null!==(z=null==oe?void 0:oe.placeholdertext)&&void 0!==z?z:de?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",Pt=He||Me,Rt=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}),ge&&{studioSessionToken:ge}),!ge&&!Z&&{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}})),St&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Ge(t.studioUser),Qe(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[q,Q,Y,ee,Z,ge,te,ne,St]);c((()=>{Rt()}),[Rt]);const Dt=(null==pe?void 0:pe.limit)||0,Lt=(null==ze?void 0:ze.currentUses)||0,Ut=(null==ze?void 0:ze.extraUses)||0,$t=!!(null==Ae?void 0:Ae.data.usage)&&Ae.data.usage.isCredits,Bt=Dt>Lt?Dt-Lt+Ut:Ut,Xt=d((()=>!!ze&&(!Ye&&(!(Dt<=0)&&Bt<=.05*Dt))),[ze,Ye,Bt,Dt]),Kt=d((()=>{var e,t,n;return!!ce&&(!!oe&&(!Ke.isLoading&&(!((null!==(t=null===(e=Ke.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(n=oe.icebreakers)||void 0===n?void 0:n.length)&&(!ue&&!Et)))))}),[oe,ce,ue,Et,Ke.data,Ke.isLoading]),Wt=d((()=>{if(je||Se)return!1;const e=Ce.length>0&&Ce.every((e=>"finished"===e.status));return!(!We.trim()&&!e)&&Ce.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[je,Se,We,Ce]);u(M,(()=>({onSubmit:Ft}))),c((()=>{fe(Kt)}),[Kt]),c((()=>{var e;if(i){const t=Array.from(xe),n=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Ft(n,!0)}}),[i]),c((()=>{if(!it.current||!H)return;const e=new ResizeObserver((e=>{for(const t of e)H(t.contentRect.height)}));return e.observe(it.current),()=>{e.disconnect()}}),[H]),c((()=>{if(!ct)return;const e=tt.current?`${tt.current} `:"";Fe(`${e}${lt}`)}),[lt,ct]),c((()=>{if(!st.current)return;(()=>{if(!st.current)return;let e=st.current.scrollHeight>52;We.includes("\n")||Ce.length?e=!0:We.trim()||(e=!1),Je(e)})()}),[We,Ce]),c((()=>{const e=st.current,t=ot.current;if(!e||!t||He||We.includes("\n"))return void Ve(!1);const n=window.getComputedStyle(e),s=`${n.fontStyle} ${n.fontVariant} ${n.fontWeight} ${n.fontSize} / ${n.lineHeight} ${n.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:s,letterSpacing:n.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=We||At,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(n.paddingLeft)||0,a=parseFloat(n.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;Ve(i>l)}),[We,He,At]);const Ft=(e,n=!1)=>t(void 0,void 0,void 0,(function*(){var t,s,o;try{if(je||Se)return;const i=Ce.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:We;if(!c&&!l)return;Ne(""),Te(""),ke(null),Fe(""),me(!1),Oe("fetching"),Pe(),De();const d=null!==(s=null===(t=null==oe?void 0:oe.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==s&&s&&r.length>0,u=[...n?Array.from(xe.slice(0,xe.length-1)):Array.from(xe),...n?[]:[{id:xe.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:xe.length+(n?0:2),role:"assistant",parts:[],documentIds:[]}];we(u),De(),d&&Ee([]);const p=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign(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}),ge&&{studioSessionToken:ge}),!ge&&!Z&&{sender:X()}),te&&{portalId:te}),ne&&{deploymentId:ne}),a.length>0&&{uploadedModelImages:a}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),St&&{credentials:"include"})),m=yield p.json();if(!m.success){const e=new Error(m.error||"Failed to start generation");throw m.limitData&&(e.limitData=m.limitData),e}const f=m.submissionId;Oe("streaming"),rt.current=new AbortController;const h=u.length-1,g=[];let v=[...null!=Le?Le:[]],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=rt.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();nt.current=t;const n=new TextDecoder,s=_({onEvent:e=>{var t,n;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data).error||"Something went wrong.";return Ne(t),void(y=!0)}if("delta"===e.event){const s=JSON.parse(e.data);if("data-error"===s.type&&J){const e=s.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&n&&n[1]&&s&&s[1])throw y=!0,J({smitheryId:t[1],serverId:n[1],name:s[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,J({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===s.type)x="",g.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t});else if("text-delta"===s.type)x+=s.delta,g[g.length-1].content=x;else if("text-end"===s.type)x="";else if("reasoning-start"===s.type)x="",g.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n});else if("reasoning-delta"===s.type)x+=s.delta,g[g.length-1].content=x;else if("reasoning-end"===s.type)x="";else if(s.type.startsWith("data-")){const e=s;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}we([...u.slice(0,h),Object.assign(Object.assign({},u[u.length-1]),{id:xe.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"})),$e([...v]),Ue.startsWith("inline")||Be({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"})),$e(v),Ue.startsWith("inline")||Be({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"})),$e(v),Ue.startsWith("inline")||Be({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),n=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+n,status:"streaming"}):e)),$e(v)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);$e(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);Ne(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;s.feed(n.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==he||he(Y)}catch(e){if(e.limitData)ke(e.limitData),Ne("");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."),Ne(t)}}finally{De(),Oe("idle"),Re(),nt.current=null,yield Rt()}}));return Tt?null:n("div",Object.assign({className:$("flex w-full flex-shrink-0 flex-col items-center",!Et&&"px-4 pb-8"),dir:de?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[s("div",Object.assign({ref:it,className:$("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ie.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Ot),{maxHeight:`${at}px`,overflowY:"auto"})},{children:[Xt&&s("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:Ot.backgroundColor?`${Ot.backgroundColor}E6`:void 0,borderColor:re.text+"20",color:re.text,borderTopRightRadius:ie.cornerRadius+"px",borderTopLeftRadius:ie.cornerRadius+"px"}},{children:[n("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:s("span",{children:[Bt," ",$t?"credits":"uses"," remaining"]})})),s("div",Object.assign({className:"flex items-center gap-3"},{children:[n("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=`${qe}${null==pe?void 0:pe.accessGroupId}`;B()?window.open(t):location.href=t}},{children:"Upgrade"})),n("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Ze(!0)},{children:n("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:n("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!je&&Ce.length>0&&n(R,{className:"p-4 pb-0",isDisabled:je}),s("div",Object.assign({className:"relative flex w-full flex-col"},{children:[ct&&s("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[n("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(G=re.accent)&&void 0!==G?G:"#ff0000"}}),n("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:re.text+"90"}},{children:"Listening..."}))]})),n(D,Object.assign({ref:st,className:$(wt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!We.trim()&&!We.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",de?"text-right":"text-left",Pt&&"mb-12",ct&&"text-transparent"),value:We,placeholder:At,onChange:e=>{if(Fe(e),H){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void H(0);if(t>=11)return;let n=0;t>1&&(n=50),H(24*(t-1)+n)}},onKeyDown:e=>{le||pt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Se||je||Ft()))},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 _e(t))}))},W&&{onFocus:W},F&&{onBlur:F},{dir:de?"rtl":"ltr"})),n("div",Object.assign({ref:ot,className:$("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",Pt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Pt&&Ot.backgroundColor&&{backgroundColor:Ot.backgroundColor}),{borderTopRightRadius:ie.cornerRadius+"px",borderBottomRightRadius:ie.cornerRadius+"px"})},{children:je?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{rt.current&&(rt.current.abort(),rt.current=null),nt.current&&(nt.current.cancel(),nt.current=null),Oe("idle")},style:{backgroundColor:re.accent,color:re.accentText}},{children:n(P,{className:"h-4 w-4 shrink-0"})})):ct?n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:p.stopListening,style:{backgroundColor:re.accent,color:re.accentText}},{children:n(P,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[It&&s("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:vt?re.accent+"10":void 0,color:vt?re.accent:re.accent+"80"},disabled:Se||je,onClick:()=>{var e;return null===(e=et.current)||void 0===e?void 0:e.click()}},bt,{children:[n("input",{id:"file-upload",ref:et,type:"file",accept:[...C,...S,...I].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){me(!1),yield _e(Array.from(e.target.files||[])),e.target.value=""}))}),n(E,{className:"h-6 w-6 shrink-0"})]})),_t&&n("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:ct?re.accent:xt?re.accent+"10":void 0,color:ct?re.accentText:xt?re.accent:re.accent+"80"},disabled:Se||je,onClick:()=>{ct?p.stopListening():(tt.current=We,dt(),p.startListening({continuous:!0,interimResults:!0,language:ae||"en-US"}))}},jt,{children:n(A,{className:"h-5 w-5 shrink-0"})})),n("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:ft||Wt?re.accent:re.accent+"10",color:ft||Wt?re.accentText:re.accent+"80"},disabled:!Wt,onClick:()=>Ft()},ht,{children:n(T,{className:$("h-6 w-6 shrink-0",de&&"scale-x-[-1] transform")})}))]})}))]}))]})),Ie&&n(L,{error:Ie,className:"mt-3"})]}))}))}));W.displayName="Input";export{W as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as o}from"react/jsx-runtime";import{createContext as t,useState as i,useEffect as s}from"react";import{ArtifactProvider as n}from"./Addons/Artifact/Provider.js";import r from"./DimensionProvider.js";import a from"./ResponseProvider.js";import l from"./Addons/Document/Provider.js";import d from"./Addons/Auth/Provider.js";const c=t({}),p=({children:t,origin:p,sender:m,senderType:
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as o}from"react/jsx-runtime";import{createContext as t,useState as i,useEffect as s}from"react";import{ArtifactProvider as n}from"./Addons/Artifact/Provider.js";import r from"./DimensionProvider.js";import a from"./ResponseProvider.js";import l from"./Addons/Document/Provider.js";import d from"./Addons/Auth/Provider.js";const c=t({}),p=({children:t,origin:p,sender:m,senderType:u,portalId:y,deploymentId:h,deploymentType:f,deploymentDimensions:b,deploymentMisc:g,styles:v,colors:S,limits:F={},misc:I={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:w,artifact:x={popupType:"auto"},responsiveBy:k="viewport",locale:P="en",opacity:j=1,forceMobile:C=!1,disableHtml:T=!1,disableJs:A=!1,disableCss:D=!1,loadFont:H=!0,isRtl:O=!1,isEmbed:R=!1,isDropShadow:G=!1,allowGuestUsage:L=!0,onGenerateComplete:M})=>{const[E,B]=i(""),[N,U]=i(""),[W,J]=i(""),[_,z]=i(""),[V,Y]=i(m),[q,K]=i(null),[Q,X]=i(u),[Z,$]=i("loading"),[ee,oe]=i(null),[te,ie]=i(null),[se,ne]=i(null),[re,ae]=i(!1),[le,de]=i(!0),[ce,pe]=i(!0),[me,ue]=i(!1);return s((()=>{ae(!1)}),[null==v?void 0:v.font]),s((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&H&&!re&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield import("webfontloader")).default.load({google:{families:[v.font]},active:()=>{ae(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),ae(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),ae(!0)}}))}),[H,re,null==v?void 0:v.font]),s((()=>{Y(m)}),[m]),o(c.Provider,Object.assign({value:Object.assign({origin:p,contextId:E,pickaxeId:N,sessionId:W,lastSessionId:_,sender:V,senderType:Q,portalId:y,deploymentId:h,deploymentType:f,validationStatus:Z,deploymentDimensions:b,deploymentMisc:g,accessGroup:q,pickaxe:se,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},S),misc:I,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","log-out":"Log Out","clear-form":"Clear form"},w),artifact:x,responsiveBy:k,locale:P,opacity:j,forceMobile:C,loadFont:H,disableHtml:T,disableJs:A,disableCss:D,isFontLoaded:re,isNewChat:le,isShowIceBreaker:ce,isShowFeedbackMessage:me,isRtl:O,isEmbed:R,isDropShadow:G,allowGuestUsage:L,clientSecret:te,stripeAccountId:ee,setClientSecret:ie,setStripeAccountId:oe,setContextId:B,setValidationStatus:$,setPickaxeId:U,setSessionId:J,setLastSessionId:z,setSender:Y,setSenderType:X,setAccessGroup:K,setPickaxe:ne,setIsFontLoaded:ae,setIsNewChat:de,setIsShowIceBreaker:pe,setIsShowFeedbackMessage:ue},M&&{onGenerateComplete:M})},{children:o(d,{children:o(r,{children:o(a,Object.assign({limits:F},{children:o(l,{children:o(n,Object.assign({},x,{children:t}))})}))})})}))};export{c as PickaxeContext,p as PickaxeProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useMemo as s}from"react";import{usePickaxeContext as o}from"../../../hooks/pickaxe/usePickaxeContext.js";import r from"./PickaxeButton.js";import{STUDIO_INFINITY_VALUE as n,intervalToSuffix as c}from"./PickaxeCommon.js";import{currencyOptions as a}from"./PickaxeCurrency.js";import{Avatar as l,AvatarImage as d,AvatarFallback as m}from"./PickaxeAvatar.js";import{useAuthContext as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useMemo as s}from"react";import{usePickaxeContext as o}from"../../../hooks/pickaxe/usePickaxeContext.js";import r from"./PickaxeButton.js";import{STUDIO_INFINITY_VALUE as n,intervalToSuffix as c}from"./PickaxeCommon.js";import{currencyOptions as a}from"./PickaxeCurrency.js";import{Avatar as l,AvatarImage as d,AvatarFallback as m}from"./PickaxeAvatar.js";import{useAuthContext as u}from"../Addons/Auth/hooks/useAuthContext.js";import p from"../../../common/api/pickaxe.js";import{isInIframe as f}from"../../../common/utils.js";import{useResponseContext as x}from"../../../hooks/pickaxe/useResponseContext.js";import{useStudio as h}from"../../../hooks/studio/useStudio.js";const v=({data:v,children:b,upgradeUrl:j})=>{var g;const{limitData:k}=x(),{studio:y}=h(),{colors:N,sender:O,pickaxe:w,setValidationStatus:C,setStripeAccountId:S,setClientSecret:I}=o(),{token:U,setRedirectUrl:_}=u(),A=s((()=>{var e;return null!==(e=v.displayName)&&void 0!==e?e:v.name}),[v]),L=s((()=>{var e;return null!==(e=v.displayDescription)&&void 0!==e?e:v.description}),[v]),T=!!(null==y?void 0:y.data.usage)&&y.data.usage.isCredits,P=s((()=>{var e;const{price:t,priceInterval:i,currency:s}=v;if(!t)return{price:"Free",suffix:""};const o=c(i,!0);return{price:`${(null!==(e=a.find((e=>e.id===s)))&&void 0!==e?e:a[0]).symbol}${t.toLocaleString()}`,suffix:o}}),[v]),R=s((()=>{const{limit:e,limitInterval:t}=v;if(e===n)return{limit:"Unlimited",suffix:""};const i=c(t,!0);return{limit:e.toLocaleString(),suffix:i}}),[v]);return t("div",Object.assign({className:"relative flex min-h-[260px] w-[220px] shrink-0 snap-center flex-col justify-between rounded-xl border p-4 shadow-sm",style:{backgroundColor:N.secondary,color:N.secondaryText}},{children:[b,t("div",Object.assign({className:"flex flex-col"},{children:[t("div",Object.assign({className:"flex flex-col"},{children:[t(l,Object.assign({className:"h-8 w-8"},{children:[i(d,{src:null!==(g=v.image)&&void 0!==g?g:"",alt:A}),i(m,{})]})),i("p",Object.assign({className:"mt-2 text-sm font-semibold line-clamp-1",title:A},{children:A})),Boolean(L)&&i("p",Object.assign({className:"mt-1 text-[10px] opacity-70 line-clamp-2 leading-tight"},{children:L})),t("p",Object.assign({className:"mt-2 text-base font-semibold"},{children:[P.price,i("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:P.suffix}))]}))]})),t("div",Object.assign({className:"mt-3 flex flex-col border-t py-2",style:{borderTopColor:N.secondaryText}},{children:[i("span",Object.assign({className:"text-[10px] font-bold opacity-50"},{children:T?"CREDITS":"USES"})),t("p",Object.assign({className:"text-base font-semibold"},{children:[R.limit,i("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:R.suffix}))]}))]}))]})),i(r,Object.assign({variant:"primary",className:"w-full mt-2 min-h-[32px] text-xs",onClick:()=>e(void 0,void 0,void 0,(function*(){if(U)e(void 0,void 0,void 0,(function*(){try{const e=yield p.post("/access_group_checkout",{data:{studioUserId:O||void 0,studioId:null==w?void 0:w.studioid,accessGroupId:v.accessGroupId,successUrl:document.URL,isEmbed:f(),studioSessionToken:U}}),{success:t,url:i,clientSecret:s,stripeAccountId:o,error:r}=e.data;t?f()?s&&o?(S(o),I(s),C("stripe_checkout")):i&&window.open(i,"_blank"):i&&(window.location.href=i):alert(r)}catch(e){alert(e)}}));else if(f()){const e=j||(null==k?void 0:k.limitLink);_(e||null),C("login_required")}else window.location.href=j||`${null==k?void 0:k.limitLink}?redirectUrl=${document.URL}`}))},{children:v.ctaButtonText}))]}))};export{v as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as o}from"react/jsx-runtime";import{useState as t,useEffect as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as o}from"react/jsx-runtime";import{useState as t,useEffect as i}from"react";import{AnimatePresence as r}from"framer-motion";import{usePickaxeContext as a}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as l}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as n}from"../../../hooks/studio/useStyleFontSize.js";import{isInIframe as c}from"../../../common/utils.js";import d from"../../Icons/circle-exclamation.svg.js";import u from"../../Core/SpringTransition.js";import p from"../../Core/HtmlRenderer.js";import m from"./PickaxeButton.js";import x from"../../../common/cn.js";import f from"../../../common/api/pickaxe.js";import{useAuthContext as v}from"../Addons/Auth/hooks/useAuthContext.js";import g from"./AccessGroupCardPreview.js";import{useStudio as h}from"../../../hooks/studio/useStudio.js";import{currencyOptions as b}from"./PickaxeCurrency.js";const y=({price:e,uses:t,isCredits:i,isSelected:r,costPerRun:a,onClick:l,colors:n})=>{const c={backgroundColor:n.secondary,color:n.secondaryText,borderColor:r?n.secondaryText:"rgba(0,0,0,0.1)"},d=i&&a?Math.ceil(t/a):0;return o("button",i?Object.assign({onClick:l,className:x("flex min-w-[200px] shrink-0 cursor-pointer flex-col rounded-[16px] px-6 py-5 text-left transition-all duration-200",r?"border-2 shadow-sm":"border opacity-80 hover:opacity-100"),style:c},{children:[o("div",Object.assign({className:"mb-4 flex items-center gap-2"},{children:[s("span",Object.assign({className:"text-[24px] font-semibold tracking-tight"},{children:e})),o("span",Object.assign({className:"text-[14px] font-light opacity-80"},{children:["/",t," credits"]}))]})),s("div",{className:"mb-4 h-[1px] w-full",style:{backgroundColor:n.secondaryText,opacity:.15}}),o("span",Object.assign({className:"text-[14px] italic opacity-70"},{children:["~ ",void 0!==d&&d>0?d.toLocaleString():"..."," ","runs"]}))]}):Object.assign({onClick:l,className:x("flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-[16px] px-5 py-3 transition-all duration-200",r?"border-2 shadow-sm":"border opacity-80 hover:opacity-100"),style:c},{children:[s("span",Object.assign({className:"text-[24px] font-semibold tracking-tight"},{children:e})),o("span",Object.assign({className:"text-[14px] font-light opacity-80"},{children:["/",t," uses"]}))]}))},j=({className:j,iconClassName:k,htmlClassName:w})=>{var C,N,O,A,S,U;const{colors:_,pickaxe:I,sender:R,setValidationStatus:P,setClientSecret:L,setStripeAccountId:T}=a(),{token:G,setRedirectUrl:$}=v(),{limitData:B}=l(),{studio:q}=h(),F=n(),[M,z]=t(0),[D,E]=t(null),H=!!(null==q?void 0:q.data.usage)&&q.data.usage.isCredits,V=null!==(N=null===(C=b.find((e=>e.id===(null==q?void 0:q.data.currency))))||void 0===C?void 0:C.symbol)&&void 0!==N?N:b[0].symbol;if(i((()=>{var e;(null===(e=null==B?void 0:B.buyUses)||void 0===e?void 0:e.length)&&z(0)}),[B]),!B)return null;const J=B.customLink,K=B.limitCTA,Q=Array.isArray(B.upgradeGroups)&&B.upgradeGroups.length>0,W=(H?null===(O=null==q?void 0:q.data.usage)||void 0===O?void 0:O.availableCredits:null===(A=null==q?void 0:q.data.usage)||void 0===A?void 0:A.availableUses)||B.buyUses,X=Array.isArray(W)&&W.length>0,Y=X&&Array.isArray(W)&&W[M];i((()=>{let s=!0;return e(void 0,void 0,void 0,(function*(){var e;if(q&&(null===(e=q.data)||void 0===e?void 0:e.workspaceId))try{const e=yield f.get(`/cost_per_run?workspaceId=${q.data.workspaceId}`);if(s){const s=1e4*e.data.costPerRun||0;E(s)}}catch(e){console.error("Failed to fetch cost per run:",e),s&&E(0)}else E(0)})),()=>{s=!1}}),[q,null===(S=null==q?void 0:q.data)||void 0===S?void 0:S.workspaceId,E]);return s(r,{children:o(u,Object.assign({className:x("flex flex-col gap-5 w-full",j)},{children:[o("div",Object.assign({className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between rounded-lg p-3 bg-opacity-5",style:{backgroundColor:_.secondary}},{children:[o("div",Object.assign({className:"flex gap-3 items-start"},{children:[s(d,{className:x("h-5 w-5 shrink-0 mt-0.5",k),style:{color:_.accent}}),s(p,{className:x(F.b2,"font-semibold leading-relaxed text-sm",w),style:{color:_.text},html:B.limitMessage||""})]})),J&&s(m,Object.assign({variant:"primary",className:"whitespace-nowrap min-h-[32px] w-full sm:w-auto text-sm",onClick:()=>e(void 0,void 0,void 0,(function*(){if(c()){if(!G)return $(J||null),void P("login_required");window.open(J)}else window.location.href=`${J}?redirectUrl=${document.URL}`}))},{children:K}))]})),Q&&o("div",Object.assign({className:"flex flex-col gap-2"},{children:[s("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:_.text}},{children:"Available Plans"})),s("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-4 pt-1 snap-x scrollbar-thin"},{children:null===(U=B.upgradeGroups)||void 0===U?void 0:U.map(((e,o)=>s(g,{data:e},e.accessGroupId||o)))}))]})),X&&Y&&o("div",Object.assign({className:"flex flex-col gap-3"},{children:[o("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:_.text}},{children:["Buy ",H?"Credits":"Uses"]})),s("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-2 pt-1 snap-x scrollbar-thin"},{children:null==W?void 0:W.map(((e,o)=>s(y,{price:e.price,uses:e.uses,isCredits:H,costPerRun:D||void 0,isSelected:o===M,onClick:()=>z(o),colors:_},o)))})),o(m,Object.assign({variant:"primary",className:"w-full py-3 text-sm font-bold shadow-md",onClick:()=>e(void 0,void 0,void 0,(function*(){var s,o;G?(s=Y.uses,o=Y.price,e(void 0,void 0,void 0,(function*(){try{const e=yield f.post("/get_extra_usage_payment_link",{data:{sender:R||void 0,studioSessionToken:G,studioId:null==I?void 0:I.studioid,cost:o,isEmbed:c(),extraUses:s,successUrl:document.URL}}),{success:t,url:i,clientSecret:r,stripeAccountId:a,error:l}=e.data;t?c()?r&&a?(T(a),L(r),P("stripe_checkout")):i&&window.open(i,"_blank"):i&&(window.location.href=i):alert(l)}catch(e){alert(e)}}))):c()?($(J||null),P("login_required")):window.location.href=`${J}?redirectUrl=${document.URL}`}))},{children:["Buy ",Y.uses.toLocaleString()," ",H?"Credits":"Uses"," for ",V,Y.price]}))]}))]}))})};export{j as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as s,jsxs as t}from"react/jsx-runtime";import{usePickaxe as o}from"../../hooks/pickaxe/usePickaxe.js";import{useState as
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as s,jsxs as t}from"react/jsx-runtime";import{usePickaxe as o}from"../../hooks/pickaxe/usePickaxe.js";import{useState as a,useMemo as i,useEffect as r}from"react";import{usePickaxeContext as c}from"../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as l}from"./Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as n}from"../../hooks/pickaxe/useResponseContext.js";import{useDocumentContext as d}from"./Addons/Document/hooks/useDocumentContext.js";import{useArtifactContext as m}from"./Addons/Artifact/hooks/useArtifactContext.js";import{v4 as u}from"uuid";import{ScrollProvider as p}from"./Addons/Scroll/Provider.js";import f from"./common/PickaxeSkeleton.js";import x from"./Chat/index.js";import h from"./Form/index.js";import g from"./Addons/Auth/index.js";import j from"../../common/cn.js";import v from"../../common/api/pickaxe.js";import b from"./common/AccessGroupCardPreview.js";import{Avatar as y,AvatarImage as k,AvatarFallback as w}from"./common/PickaxeAvatar.js";import N from"../Icons/lock.svg.js";import{EmbeddedCheckoutProvider as O,EmbeddedCheckout as _}from"../../node_modules/.pnpm/@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js";import{loadStripe as A}from"../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js";const I=({className:e})=>s("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e},{children:s("polyline",{points:"15 18 9 12 15 6"})})),C=({pickaxeId:C,className:S})=>{const{sessionId:q,styles:P,colors:L,responsiveBy:T,deploymentType:R,isNewChat:E,isEmbed:G,opacity:D,deploymentId:U,sender:B,portalId:$,validationStatus:F,stripeAccountId:M,clientSecret:W,setClientSecret:z,setStripeAccountId:H,setValidationStatus:J,setContextId:K,setPickaxeId:V,setSessionId:X,setPickaxe:Y,setAccessGroup:Q}=c(),{isSent:Z,token:ee}=l(),{setMessages:se,setResponse:te,setError:oe,setLimitData:ae,setIsSwitchedToChat:ie}=n(),{setDocumentError:re}=d(),{setCurrentArtifact:ce}=m(),[le,ne]=a(!1),[de,me]=a([]),[ue,pe]=a(null),fe=o(),xe="chat-input"===R&&E&&!Z,he=i((()=>M?A(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:M}):null),[M]);r((()=>{V(C)}),[C]);r((()=>{if(!U&&!$||!fe.data)return;if("stripe_checkout"===F)return;e(void 0,void 0,void 0,(function*(){var e;J("loading");try{const s=yield v.post("/validate_studio_deployment",{data:{deploymentId:U,sender:B||void 0,studioSessionToken:ee,portalId:$,studioId:null===(e=fe.data)||void 0===e?void 0:e.studioid}});s.data.success?(J("success"),Q(s.data.accessGroup)):"Login required."===s.data.message?(J("login_required"),ne(!0)):"Access denied."===s.data.message?(J("access_denied"),me(s.data.upgradeGroups||[]),ne(!0)):"Upgrade required."===s.data.message?(J("upgrade_required"),me(s.data.upgradeGroups||[]),pe(s.data.upgradeUrl),ne(!0)):J("login_required")}catch(e){console.error("Failed to validate deployment:",e),J("success")}}))}),[U,B,ee,$,fe.data]),r((()=>{if(!fe.data)return;const e=fe.data.chatflag;X(e?u():""),K(u()),e?se([]):te(null),oe(""),re(""),ae(null),ce(null),ie(!1),Y(fe.data),ne(!0)}),[fe.data]),r((()=>{oe(""),re(""),ae(null),se([]),te(null),ce(null)}),[q]);const ge=i((()=>{const e=null!=D?D:1;if(!L.primary||!L.primary.startsWith("#")||e<0||e>1)return L.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${L.primary}${s}`}),[L.primary,D]);if(!fe.data)return null;return s("div",Object.assign({className:j("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===P.theme&&"dark",S),style:Object.assign({backgroundColor:xe?"transparent":ge,color:L.text},P.font&&"Real Head Pro"!==P.font&&{fontFamily:P.font})},{children:"stripe_checkout"===F&&W&&he?t("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:L.secondary||"#ffffff",color:L.secondaryText||"#000000"}},{children:[s("div",Object.assign({className:"flex items-center p-4 border-b border-gray-100 shrink-0"},{children:t("button",Object.assign({onClick:()=>{z&&z(null),H&&H(null),J("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:L.text}},{children:[s(I,{className:"w-5 h-5"}),s("span",{children:"Back"})]}))})),s("div",Object.assign({className:"flex-1 w-full h-full overflow-y-auto [&>div]:h-full"},{children:s(O,Object.assign({stripe:he,options:{clientSecret:W}},{children:s(_,{})}))}))]})):fe.isLoading||!le||"loading"===F?s("div",Object.assign({className:j("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===T?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:t("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s(f,{className:"w-[72px] h-[72px]"}),s(f,{className:"h-[20px] mt-6 w-full"}),s(f,{className:"h-[20px] mt-2 w-full"}),s(f,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s(f,{className:j("w-full min-h-[48px]","viewport"===T?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===F?s("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:de&&de.length>0?t("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[t("div",Object.assign({className:"text-center"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),s("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),s("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:de.map(((e,t)=>s(b,{data:e,upgradeUrl:ue},e.id||t)))}))]})):t("div",Object.assign({className:"text-center mb-8"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),s("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===F&&G?s(g,{}):"login_required"!==F||G?"access_denied"===F?t("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[t(y,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s(k,{src:null===(je=fe.data)||void 0===je?void 0:je.coverphoto,alt:`${null===(ve=fe.data)||void 0===ve?void 0:ve.formtitle} Logo`}),s(w,{})]})),t("div",Object.assign({className:"text-center mb-6"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),t("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s(N,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s("p",Object.assign({className:"ml-1"},{children:"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:L.accent,color:L.accentText,borderRadius:P.cornerRadius},onClick:()=>{e(void 0,void 0,void 0,(function*(){var e,s;const t=de.map((e=>e.accessGroupId));try{const o=yield v.post("/request_access",{data:{sender:B||void 0,studioSessionToken:ee,studioId:null===(e=fe.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=fe.data)||void 0===s?void 0:s.formid,deploymentId:U,accessGroupIds:t})}});o.data.success?alert("Successfully requested access!"):alert(o.data.error)}catch(e){alert(`Couldn't request access. Error: ${e}`)}}))}},{children:"Request Access"})),s("span",Object.assign({className:"mt-4 mb-2"},{children:"or"})),s("span",Object.assign({className:"font-medium text-lg"},{children:"Sign in with a different account"}))]})):s(p,q?{children:s(x,{})}:{children:s(h,{})}):s("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:t("div",Object.assign({className:"text-center mb-8"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}));var je,ve};export{C as Pickaxe};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import o from"../../common/api/pickaxe.js";import{usePickaxeContext as r}from"../pickaxe/usePickaxeContext.js";import{useQuery as t}from"@tanstack/react-query";const e=()=>{const{pickaxe:e}=r(),i=null==e?void 0:e.studioid,{data:a,isLoading:s,error:d}=t({queryKey:["studio",i],queryFn:()=>o.get("get_studio",{params:{studioId:i}}),enabled:!!i});return{studio:a,isLoading:s,error:d}};export{e as useStudio};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const useAuthContext: () => {
|
|
2
2
|
emailInput: string;
|
|
3
|
+
redirectUrl: string | null;
|
|
3
4
|
token: string | null;
|
|
4
5
|
isLoggedIn: boolean;
|
|
5
6
|
isLoggedOut: boolean;
|
|
@@ -7,10 +8,13 @@ export declare const useAuthContext: () => {
|
|
|
7
8
|
isSending: boolean;
|
|
8
9
|
isResendDisabled: boolean;
|
|
9
10
|
isSent: boolean;
|
|
11
|
+
isPricingAuth: boolean;
|
|
10
12
|
setEmailInput: import("../../../../../types/common").SetState<string>;
|
|
11
13
|
setToken: import("../../../../../types/common").SetState<string | null>;
|
|
12
14
|
setIsLoggingIn: import("../../../../../types/common").SetState<boolean>;
|
|
13
15
|
setIsSending: import("../../../../../types/common").SetState<boolean>;
|
|
14
16
|
setIsResendDisabled: import("../../../../../types/common").SetState<boolean>;
|
|
15
17
|
setIsSent: import("../../../../../types/common").SetState<boolean>;
|
|
18
|
+
setIsPricingAuth: import("../../../../../types/common").SetState<boolean>;
|
|
19
|
+
setRedirectUrl: import("../../../../../types/common").SetState<string | null>;
|
|
16
20
|
};
|
|
@@ -55,6 +55,10 @@ export type PickaxeDeploymentMisc = {
|
|
|
55
55
|
popupText?: string;
|
|
56
56
|
fabImage?: string;
|
|
57
57
|
};
|
|
58
|
+
export type AccessGroup = {
|
|
59
|
+
limit: number;
|
|
60
|
+
accessGroupId: string;
|
|
61
|
+
};
|
|
58
62
|
type PickaxeContextType = {
|
|
59
63
|
origin: PickaxeHistoryOriginType;
|
|
60
64
|
contextId: string;
|
|
@@ -69,6 +73,7 @@ type PickaxeContextType = {
|
|
|
69
73
|
deploymentDimensions?: PickaxeDeploymentDimensions;
|
|
70
74
|
deploymentMisc?: PickaxeDeploymentMisc;
|
|
71
75
|
portalId?: string;
|
|
76
|
+
accessGroup?: AccessGroup | null;
|
|
72
77
|
pickaxe: LimitedPickaxe | null;
|
|
73
78
|
styles: PickaxeProviderStyles;
|
|
74
79
|
colors: PickaxeProviderColors;
|
|
@@ -96,6 +101,7 @@ type PickaxeContextType = {
|
|
|
96
101
|
setContextId: SetState<string>;
|
|
97
102
|
setPickaxeId: SetState<string>;
|
|
98
103
|
setSessionId: SetState<string>;
|
|
104
|
+
setAccessGroup: SetState<AccessGroup | null>;
|
|
99
105
|
setLastSessionId: SetState<string>;
|
|
100
106
|
setValidationStatus: SetState<ValidationStatus>;
|
|
101
107
|
setSender: SetState<string | undefined>;
|
|
@@ -8,9 +8,11 @@ export declare const usePickaxeContext: () => {
|
|
|
8
8
|
senderType: import("../../types/history").PickaxeHistorySenderType;
|
|
9
9
|
deploymentId?: string | undefined;
|
|
10
10
|
deploymentType?: import("../../components/Pickaxe/Provider").PickaxeDeploymentEmbedType | undefined;
|
|
11
|
+
validationStatus: "loading" | "success" | "login_required" | "upgrade_required" | "access_denied" | "stripe_checkout";
|
|
11
12
|
deploymentDimensions?: import("../../components/Pickaxe/Provider").PickaxeDeploymentDimensions | undefined;
|
|
12
13
|
deploymentMisc?: import("../../components/Pickaxe/Provider").PickaxeDeploymentMisc | undefined;
|
|
13
14
|
portalId?: string | undefined;
|
|
15
|
+
accessGroup?: import("../../components/Pickaxe/Provider").AccessGroup | null | undefined;
|
|
14
16
|
pickaxe: import("../../types/pickaxe").LimitedPickaxe | null;
|
|
15
17
|
styles: import("../../components/Pickaxe/Provider").PickaxeProviderStyles;
|
|
16
18
|
colors: import("../../components/Pickaxe/Provider").PickaxeProviderColors;
|
|
@@ -32,12 +34,15 @@ export declare const usePickaxeContext: () => {
|
|
|
32
34
|
isRtl: boolean;
|
|
33
35
|
isEmbed: boolean;
|
|
34
36
|
isDropShadow: boolean;
|
|
35
|
-
isEmailLogin: boolean;
|
|
36
37
|
allowGuestUsage: boolean;
|
|
38
|
+
stripeAccountId: string | null;
|
|
39
|
+
clientSecret: string | null;
|
|
37
40
|
setContextId: import("../../types/common").SetState<string>;
|
|
38
41
|
setPickaxeId: import("../../types/common").SetState<string>;
|
|
39
42
|
setSessionId: import("../../types/common").SetState<string>;
|
|
43
|
+
setAccessGroup: import("../../types/common").SetState<import("../../components/Pickaxe/Provider").AccessGroup | null>;
|
|
40
44
|
setLastSessionId: import("../../types/common").SetState<string>;
|
|
45
|
+
setValidationStatus: import("../../types/common").SetState<"loading" | "success" | "login_required" | "upgrade_required" | "access_denied" | "stripe_checkout">;
|
|
41
46
|
setSender: import("../../types/common").SetState<string | undefined>;
|
|
42
47
|
setSenderType: import("../../types/common").SetState<import("../../types/history").PickaxeHistorySenderType>;
|
|
43
48
|
setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").LimitedPickaxe | null>;
|
|
@@ -45,5 +50,7 @@ export declare const usePickaxeContext: () => {
|
|
|
45
50
|
setIsNewChat: import("../../types/common").SetState<boolean>;
|
|
46
51
|
setIsShowIceBreaker: import("../../types/common").SetState<boolean>;
|
|
47
52
|
setIsShowFeedbackMessage: import("../../types/common").SetState<boolean>;
|
|
53
|
+
setStripeAccountId: import("../../types/common").SetState<string | null>;
|
|
54
|
+
setClientSecret: import("../../types/common").SetState<string | null>;
|
|
48
55
|
onGenerateComplete?: ((responseId: string) => void) | undefined;
|
|
49
56
|
};
|