@pickaxeproject/react 6.3.0 → 6.3.2
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/Core/StudioTip.js +1 -0
- package/dist/cjs/components/EmbedPreview/FAB.js +1 -1
- package/dist/cjs/components/EmbedPreview/Popup.js +1 -1
- package/dist/cjs/components/Icons/history.svg.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Artifact/Renderer/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Auth/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Navbar/NavPill.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Checkbox.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Option.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Submit.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/PickaxeMarkdown/Components/A/Html/HtmlModal.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/A/Html/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Artifact/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Iframe/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Img/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/common/IframeVideo.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ReasoningPart/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/cjs/components/Pickaxe/common/SmitheryConnectView.js +1 -1
- package/dist/cjs/components/Pickaxe/index.js +1 -1
- package/dist/cjs/src/components/Core/StudioTip.d.ts +11 -0
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Components/common/IframeVideo.d.ts +1 -1
- package/dist/esm/components/Core/StudioTip.js +1 -0
- package/dist/esm/components/EmbedPreview/FAB.js +1 -1
- package/dist/esm/components/EmbedPreview/Popup.js +1 -1
- package/dist/esm/components/Icons/history.svg.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Artifact/Renderer/index.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Auth/index.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Navbar/NavPill.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Checkbox.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Option.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Submit.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/PickaxeMarkdown/Components/A/Html/HtmlModal.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/A/Html/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Artifact/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Iframe/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Img/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/common/IframeVideo.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ReasoningPart/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/esm/components/Pickaxe/common/SmitheryConnectView.js +1 -1
- package/dist/esm/components/Pickaxe/index.js +1 -1
- package/dist/esm/src/components/Core/StudioTip.d.ts +11 -0
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Components/common/IframeVideo.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as i,useMemo as a,useEffect as r}from"react";import{useArtifactContext as l}from"../hooks/useArtifactContext.js";import{usePickaxeContext as c}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useScroll as s}from"../../Scroll/hooks/useScroll.js";import{useArtifact as p}from"../hooks/useArtifact.js";import{useReactToPrint as d}from"react-to-print";import{PickaxeMarkdown as m}from"../../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as u}from"../../../common/PickaxeMarkdown/Renderer.js";import{Prism as y}from"react-syntax-highlighter";import{convertMarkdownToDocx as v,downloadDocx as f}from"../../../../../common/docx/index.js";import x from"file-saver";import g from"../../Scroll/ScrollLockView.js";import b from"../../../../Icons/expand.svg.js";import h from"../../../../Icons/shrink.svg.js";import w from"../../../../Icons/collapse-new.svg.js";import C from"../../../../Icons/copy-new.svg.js";import k from"../../../../Icons/download-new.svg.js";import j from"../../../common/PickaxeCopyButton.js";import F from"../../../../Core/ScrollArea.js";import T from"../../../../Core/TipContainer.js";import O from"../MermaidRenderer.js";import A from"./SaveMenu.js";import S from"./ViewOptions.js";import D from"csv-to-markdown-table";import N from"copy-to-clipboard";import E from"../../../../../common/cn.js";const B="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co",$=$=>{var z,M,L,P;const{artifacts:R,currentPopupType:W,currentArtifact:H,setCurrentArtifact:I}=l(),{onLoadArtifact:_}=p(),{styles:V,colors:X,translations:q}=c(),[G,J]=n("code"),[K,Q]=n(!1),U=i(),Y=i(null),Z=i(null),ee=d({contentRef:U}),{scrollContainerRef:oe,scrollStartSession:te,scrollToBottom:ne,scrollEndSession:ie}=s({auto:"code"===G}),ae=null!==(M=null===(z=$.styling)||void 0===z?void 0:z.styles)&&void 0!==M?M:V,re=null!==(P=null===(L=$.styling)||void 0===L?void 0:L.colors)&&void 0!==P?P:X,le=a((()=>{var e,o,t,n,i;if(!$.artifact&&!H)return null;const a=null!==(o=null===(e=$.artifact)||void 0===e?void 0:e.id)&&void 0!==o?o:null==H?void 0:H.id,r=null!==(n=null===(t=$.artifact)||void 0===t?void 0:t.version)&&void 0!==n?n:null==H?void 0:H.version;return null!==(i=R.find((e=>e.id===a&&e.version===r)))&&void 0!==i?i:null}),[H,R,$.artifact]),ce=a((()=>le?"text/csv"===le.type?D(le.content,",",!0):"text/tab-separated-values"===le.type?D(le.content,"\t",!0):null:null),[le]),se=a((()=>(re.secondaryText||"").toLowerCase().startsWith("#ffffff")),[null==re?void 0:re.secondaryText]),pe=a((()=>{const e=$.artifact&&(null==H?void 0:H.id)===$.artifact.id&&(null==H?void 0:H.version)===$.artifact.version;return"inline"===$.type&&("inline-form"===W?!!H:e)}),[H,W,$.type,$.artifact]);r((()=>{e(void 0,void 0,void 0,(function*(){"inline"===$.type&&$.artifact&&(R.some((e=>$.artifact&&e.id===$.artifact.id&&e.version===$.artifact.version))||_({id:$.artifact.id,version:$.artifact.version}))}))}),[R,$.type,$.artifact]),r((()=>{if("application/vnd.pxe.code"===(null==le?void 0:le.type)&&J("code"),"finished"!==(null==le?void 0:le.status))return J("code"),te(),void ne();ie(),"application/vnd.pxe.code"!==le.type&&J("render")}),[null==le?void 0:le.status,null==le?void 0:le.type]),r((()=>{var e;!Z.current||"text/html"!==(null==le?void 0:le.type)&&"application/pdf"!==(null==le?void 0:le.type)&&"application/vnd.pxe.react"!==(null==le?void 0:le.type)||null===(e=Z.current.contentWindow)||void 0===e||e.postMessage({type:"application/vnd.pxe.react"!==le.type?"HTML_CODE":"REACT_CODE",content:le.content},B)}),[null==le?void 0:le.content,null==le?void 0:le.type]);const de=()=>e(void 0,void 0,void 0,(function*(){if(!le)return;if("text/html"===le.type||"application/pdf"===le.type){const e=le.content,o=window.open("","_blank");return void(o&&(o.document.open(),o.document.write(e),o.document.close(),o.focus(),o.print()))}const e=G;"code"===e&&(J("render"),yield new Promise((e=>setTimeout(e,50)))),ee(),"code"===e&&J(e)})),me=()=>e(void 0,void 0,void 0,(function*(){if(!le)return;const e=yield v(le.content);f(e,`${le.title}.docx`)})),ue=o=>e(void 0,void 0,void 0,(function*(){var e;if(!le)return;let t={mimeType:"text/plain",extension:".txt"};switch(o){case"text/markdown":t={mimeType:"text/markdown",extension:".md"};break;case"text/html":t={mimeType:"text/html",extension:".html"};break;case"text/csv":t={mimeType:"text/csv",extension:".csv"};break;case"text/tab-separated-values":t={mimeType:"text/tab-separated-values",extension:".tsv"};break;case"image/svg+xml":case"application/vnd.pxe.mermaid":t={mimeType:"image/svg+xml",extension:".svg"};break;case"application/pdf":t={mimeType:"application/pdf",extension:".pdf"};break;case"application/vnd.pxe.code":t={mimeType:`application/${le.programmingLanguage||"text"};charset=utf-8`,extension:`.${le.programmingLanguage||"txt"}`};break;case"application/vnd.pxe.react":t={mimeType:"text/typescript",extension:".tsx"};break;default:t={mimeType:"text/plain",extension:".txt"}}let n=null;if("application/vnd.pxe.mermaid"===le.type){const o=G;"code"===o&&(J("render"),yield new Promise((e=>setTimeout(e,50))));const t=null===(e=Y.current)||void 0===e?void 0:e.querySelector("svg");t&&(n=(new XMLSerializer).serializeToString(t)),"code"===o&&J(o)}const i=new Blob([null!=n?n:le.content],{type:t.mimeType});x(i,`${le.title}${t.extension}`)})),ye=()=>{"inline"!==$.type||!$.artifact||pe?I(null):I({id:$.artifact.id,version:$.artifact.version})},ve=pe||!W.startsWith("inline");return le?o("div",Object.assign({className:E("pxe-artifact-renderer flex flex-col","inline"===$.type&&!pe&&"min-h-[320px] mb-6",$.className),style:Object.assign(Object.assign({backgroundColor:re.secondary,color:re.secondaryText},"auto"!==W&&{borderRadius:ae.cornerRadius}),$.style)},{children:[o("div",Object.assign({className:"flex items-center gap-4 justify-between px-4 py-3 shadow-sm"},{children:[o("div",Object.assign({className:"pxe-artifact-create-header flex min-w-0 items-center gap-4"},{children:[ve&&t(S,{type:le.type,view:G,colors:re,onChange:J}),t("p",Object.assign({className:"w-[220px] max-w-full truncate text-[18px] font-semilight leading-tight",title:le.title},{children:le.title}))]})),"inline"===$.type&&!ve&&t("div",Object.assign({className:"shrink-0"},{children:t("button",Object.assign({type:"button",style:{color:re.secondaryText},onClick:ye,title:(null==q?void 0:q.expand)||"Expand","aria-label":(null==q?void 0:q.expand)||"Expand artifact"},{children:t(pe?h:b,{className:"w-6 h-6 shrink-0"})}))}))]})),ve&&t("div",Object.assign({className:"flex items-center justify-between border-y px-4 py-2.5",style:{borderColor:re.primary}},{children:o("div",Object.assign({className:"flex items-center gap-3"},{children:[t("button",Object.assign({type:"button",className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100",style:{color:re.secondaryText},onClick:ye,title:"inline"===$.type?(null==q?void 0:q.collapse)||"Collapse":(null==q?void 0:q.close)||"Close","aria-label":"inline"===$.type?(null==q?void 0:q.collapse)||"Collapse artifact":(null==q?void 0:q.close)||"Close artifact"},{children:t(w,{className:"h-5 w-5 shrink-0"})})),t("button",Object.assign({type:"button",className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-50",style:{color:re.secondaryText},disabled:K,onClick:()=>e(void 0,void 0,void 0,(function*(){if(le)try{N(le.content),Q(!0),yield new Promise((e=>setTimeout(e,1500)))}finally{Q(!1)}})),title:(null==q?void 0:q.copy)||"Copy","aria-label":(null==q?void 0:q.copy)||"Copy artifact content"},{children:t(C,{className:"h-[18px] w-[18px] shrink-0"})})),t(A,Object.assign({data:le,colors:re,onDownload:ue,onSaveAsPDF:de,onSaveAsDOCX:me,className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100"},{children:t("div",Object.assign({role:"button",className:"cursor-pointer",style:{color:re.secondaryText},title:(null==q?void 0:q.save)||"Download","aria-label":(null==q?void 0:q.save)||"Download artifact content"},{children:t(k,{className:"h-6 w-6 shrink-0"})}))}))]}))})),t("div",Object.assign({className:"flex flex-col flex-grow @container/pickaxe-artifact"},{children:o(F,Object.assign({ref:oe,innerClassName:"flex-grow w-full"},{children:["render"===G&&"application/vnd.pxe.code"!==le.type?t("div",Object.assign({ref:U,className:E("p-4 pb-6 flex-grow flex flex-col","text/html"===le.type&&"p-0","text/csv"===le.type&&"p-0","application/pdf"===le.type&&"p-0","application/vnd.pxe.react"===le.type&&"p-0")},{children:"text/markdown"===le.type||"text/csv"===le.type||"text/tab-separated-values"===le.type||"image/svg+xml"===le.type?t(m,Object.assign({theme:ae.theme,colors:re},{children:t(u,{value:null!=ce?ce:le.content,className:E("px-6 @[767px]/pickaxe-artifact:px-11 mx-auto w-full",("text/csv"===le.type||"text/tab-separated-values"===le.type)&&"px-4 @[767px]/pickaxe-artifact:px-4 mx-0"),style:{flex:1}})})):"application/vnd.pxe.mermaid"===le.type?t(O,{ref:Y,id:`mermaid-${le.id}-${le.version}`,data:le.content}):"text/html"===le.type||"application/pdf"===le.type||"application/vnd.pxe.react"===le.type?t("iframe",Object.assign({ref:Z,title:le.title,src:`${B}/${"application/vnd.pxe.react"!==le.type?"html":"react"}?theme=${se?"dark":"light"}&bg=${re.secondary}&accent=${re.accent}`,style:{width:"100%",flex:1,border:"none",backgroundColor:null==re?void 0:re.secondary},loading:"lazy",allow:"fullscreen; camera; microphone; gyroscope; accelerometer; geolocation; clipboard-write; autoplay",sandbox:"allow-scripts allow-same-origin allow-forms allow-downloads allow-popups-to-escape-sandbox allow-pointer-lock allow-popups allow-modals allow-orientation-lock allow-presentation",onLoad:e=>{const o=e.target;setTimeout((()=>{var e;try{null===(e=o.contentWindow)||void 0===e||e.postMessage({type:"application/vnd.pxe.react"!==le.type?"HTML_CODE":"REACT_CODE",content:le.content},B)}catch(e){console.error("Error sending message to iframe:",e)}}),100),ne()}},{children:"Iframe is not supported, please view this artifact in a browser that supports it."})):null})):t(y,Object.assign({PreTag:"div",language:"text/markdown"===le.type?"markdown":"text/html"===le.type||"image/svg+xml"===le.type?"xml":"application/vnd.pxe.react"===le.type?"typescript":le.programmingLanguage,showLineNumbers:!0,customStyle:{margin:0,flex:1},style:Object.assign({'code[class*="language-"]':Object.assign(Object.assign({color:null==re?void 0:re.secondaryText},se&&{textShadow:"0 1px rgba(0, 0, 0, 0.3)"}),{fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"}),'pre[class*="language-"]':Object.assign(Object.assign({color:null==re?void 0:re.secondaryText},se&&{textShadow:"0 1px rgba(0, 0, 0, 0.3)"}),{fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",borderRadius:"0.3em",minWidth:0,paddingLeft:"1em",paddingRight:"1em",paddingBottom:"2em",background:null==re?void 0:re.secondary}),':not(pre) > code[class*="language-"]':{background:null==re?void 0:re.secondary,padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:null==re?void 0:re.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}},!se&&{comment:{color:"#7D8B99"},prolog:{color:"#7D8B99"},doctype:{color:"#7D8B99"},cdata:{color:"#7D8B99"},punctuation:{color:"#4D4D4C"},property:{color:"#4078F2"},keyword:{color:"#8959A8"},tag:{color:"#8959A8"},"class-name":{color:"#D75F00"},boolean:{color:"#0086B3"},constant:{color:"#0086B3"},symbol:{color:"#990055"},deleted:{color:"#990000"},number:{color:"#005CC5"},selector:{color:"#63A35C"},"attr-name":{color:"#63A35C"},string:{color:"#50A14F"},char:{color:"#50A14F"},builtin:{color:"#50A14F"},inserted:{color:"#50A14F"},variable:{color:"#A626A4"},operator:{color:"#4D4D4C"},entity:{color:"#E45649",cursor:"help"},url:{color:"#4078F2"},".language-css .token.string":{color:"#50A14F"},".style .token.string":{color:"#50A14F"},atrule:{color:"#C18401"},"attr-value":{color:"#986801"},function:{color:"#005CC5"},regex:{color:"#D16969"},important:{color:null==re?void 0:re.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}})},{children:le.content})),t(g,{})]}))})),"inline"===$.type&&!pe&&o("div",Object.assign({className:"flex items-center gap-4 p-4 pt-6"},{children:[t(T,Object.assign({id:`artifact-copy-${le.id}-${le.version}`,tip:(null==q?void 0:q.copy)||"Copy",style:{padding:"0.25rem 0.5rem",backgroundColor:re.secondary,color:re.secondaryText,fontSize:"12px"},align:"bottom"},{children:t(j,{color:re.secondaryText,text:le.content,className:"opacity-100",iconClassName:"w-5 h-5"})})),t(T,Object.assign({id:`artifact-save-${le.id}-${le.version}`,tip:(null==q?void 0:q.save)||"Save",style:{padding:"0.25rem 0.5rem",backgroundColor:re.secondary,color:re.secondaryText,fontSize:"12px"},align:"bottom"},{children:t(A,Object.assign({data:le,colors:re,onDownload:ue,onSaveAsPDF:de,onSaveAsDOCX:me},{children:t("button",Object.assign({style:{color:re.secondaryText}},{children:t(k,{className:"w-5 h-5 shrink-0"})}))}))}))]}))]})):null};export{$ as default};
|
|
1
|
+
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as n,useRef as i,useMemo as a,useEffect as r}from"react";import{useArtifactContext as l}from"../hooks/useArtifactContext.js";import{usePickaxeContext as c}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useScroll as s}from"../../Scroll/hooks/useScroll.js";import{useArtifact as p}from"../hooks/useArtifact.js";import{useReactToPrint as d}from"react-to-print";import{PickaxeMarkdown as m}from"../../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as u}from"../../../common/PickaxeMarkdown/Renderer.js";import{Prism as y}from"react-syntax-highlighter";import{convertMarkdownToDocx as v,downloadDocx as f}from"../../../../../common/docx/index.js";import x from"file-saver";import g from"../../Scroll/ScrollLockView.js";import b from"../../../../Icons/expand.svg.js";import h from"../../../../Icons/shrink.svg.js";import w from"../../../../Icons/collapse-new.svg.js";import C from"../../../../Icons/copy-new.svg.js";import k from"../../../../Icons/download-new.svg.js";import j from"../../../common/PickaxeCopyButton.js";import F from"../../../../Core/ScrollArea.js";import T from"../../../../Core/TipContainer.js";import O from"../MermaidRenderer.js";import A from"./SaveMenu.js";import S from"./ViewOptions.js";import D from"csv-to-markdown-table";import N from"copy-to-clipboard";import E from"../../../../../common/cn.js";const B="development"===process.env.NODE_ENV?"http://localhost:3007":"https://user-content.pickaxe.co",$=$=>{var z,M,L,P;const{artifacts:R,currentPopupType:W,currentArtifact:H,setCurrentArtifact:I}=l(),{onLoadArtifact:_}=p(),{styles:V,colors:X,translations:q}=c(),[G,J]=n("code"),[K,Q]=n(!1),U=i(),Y=i(null),Z=i(null),ee=d({contentRef:U}),{scrollContainerRef:oe,scrollStartSession:te,scrollToBottom:ne,scrollEndSession:ie}=s({auto:"code"===G}),ae=null!==(M=null===(z=$.styling)||void 0===z?void 0:z.styles)&&void 0!==M?M:V,re=null!==(P=null===(L=$.styling)||void 0===L?void 0:L.colors)&&void 0!==P?P:X,le=a((()=>{var e,o,t,n,i;if(!$.artifact&&!H)return null;const a=null!==(o=null===(e=$.artifact)||void 0===e?void 0:e.id)&&void 0!==o?o:null==H?void 0:H.id,r=null!==(n=null===(t=$.artifact)||void 0===t?void 0:t.version)&&void 0!==n?n:null==H?void 0:H.version;return null!==(i=R.find((e=>e.id===a&&e.version===r)))&&void 0!==i?i:null}),[H,R,$.artifact]),ce=a((()=>le?"text/csv"===le.type?D(le.content,",",!0):"text/tab-separated-values"===le.type?D(le.content,"\t",!0):null:null),[le]),se=a((()=>(re.secondaryText||"").toLowerCase().startsWith("#ffffff")),[null==re?void 0:re.secondaryText]),pe=a((()=>{const e=$.artifact&&(null==H?void 0:H.id)===$.artifact.id&&(null==H?void 0:H.version)===$.artifact.version;return"inline"===$.type&&("inline-form"===W?!!H:e)}),[H,W,$.type,$.artifact]);r((()=>{e(void 0,void 0,void 0,(function*(){"inline"===$.type&&$.artifact&&(R.some((e=>$.artifact&&e.id===$.artifact.id&&e.version===$.artifact.version))||_({id:$.artifact.id,version:$.artifact.version}))}))}),[R,$.type,$.artifact]),r((()=>{if("application/vnd.pxe.code"===(null==le?void 0:le.type)&&J("code"),"finished"!==(null==le?void 0:le.status))return J("code"),te(),void ne();ie(),"application/vnd.pxe.code"!==le.type&&J("render")}),[null==le?void 0:le.status,null==le?void 0:le.type]),r((()=>{var e;!Z.current||"text/html"!==(null==le?void 0:le.type)&&"application/pdf"!==(null==le?void 0:le.type)&&"application/vnd.pxe.react"!==(null==le?void 0:le.type)||null===(e=Z.current.contentWindow)||void 0===e||e.postMessage({type:"application/vnd.pxe.react"!==le.type?"HTML_CODE":"REACT_CODE",content:le.content},B)}),[null==le?void 0:le.content,null==le?void 0:le.type]);const de=()=>e(void 0,void 0,void 0,(function*(){if(!le)return;if("text/html"===le.type||"application/pdf"===le.type){const e=le.content,o=window.open("","_blank");return void(o&&(o.document.open(),o.document.write(e),o.document.close(),o.focus(),o.print()))}const e=G;"code"===e&&(J("render"),yield new Promise((e=>setTimeout(e,50)))),ee(),"code"===e&&J(e)})),me=()=>e(void 0,void 0,void 0,(function*(){if(!le)return;const e=yield v(le.content);f(e,`${le.title}.docx`)})),ue=o=>e(void 0,void 0,void 0,(function*(){var e;if(!le)return;let t={mimeType:"text/plain",extension:".txt"};switch(o){case"text/markdown":t={mimeType:"text/markdown",extension:".md"};break;case"text/html":t={mimeType:"text/html",extension:".html"};break;case"text/csv":t={mimeType:"text/csv",extension:".csv"};break;case"text/tab-separated-values":t={mimeType:"text/tab-separated-values",extension:".tsv"};break;case"image/svg+xml":case"application/vnd.pxe.mermaid":t={mimeType:"image/svg+xml",extension:".svg"};break;case"application/pdf":t={mimeType:"application/pdf",extension:".pdf"};break;case"application/vnd.pxe.code":t={mimeType:`application/${le.programmingLanguage||"text"};charset=utf-8`,extension:`.${le.programmingLanguage||"txt"}`};break;case"application/vnd.pxe.react":t={mimeType:"text/typescript",extension:".tsx"};break;default:t={mimeType:"text/plain",extension:".txt"}}let n=null;if("application/vnd.pxe.mermaid"===le.type){const o=G;"code"===o&&(J("render"),yield new Promise((e=>setTimeout(e,50))));const t=null===(e=Y.current)||void 0===e?void 0:e.querySelector("svg");t&&(n=(new XMLSerializer).serializeToString(t)),"code"===o&&J(o)}const i=new Blob([null!=n?n:le.content],{type:t.mimeType});x(i,`${le.title}${t.extension}`)})),ye=()=>{"inline"!==$.type||!$.artifact||pe?I(null):I({id:$.artifact.id,version:$.artifact.version})},ve=pe||!W.startsWith("inline");return le?o("div",Object.assign({className:E("pxe-artifact-renderer flex flex-col","inline"===$.type&&!pe&&"min-h-[320px] mb-6",$.className),style:Object.assign(Object.assign({backgroundColor:re.secondary,color:re.secondaryText},"auto"!==W&&{borderRadius:ae.cornerRadius}),$.style)},{children:[o("div",Object.assign({className:"flex items-center gap-4 justify-between px-4 py-3 shadow-sm"},{children:[o("div",Object.assign({className:"pxe-artifact-create-header flex min-w-0 items-center gap-4"},{children:[ve&&t(S,{type:le.type,view:G,colors:re,onChange:J}),t("p",Object.assign({className:"w-[220px] max-w-full truncate text-[18px] font-semilight leading-tight",title:le.title},{children:le.title}))]})),"inline"===$.type&&!ve&&t("div",Object.assign({className:"shrink-0"},{children:t("button",Object.assign({type:"button",style:{color:re.secondaryText},onClick:ye,title:(null==q?void 0:q.expand)||"Expand","aria-label":(null==q?void 0:q.expand)||"Expand artifact"},{children:t(pe?h:b,{className:"w-6 h-6 shrink-0"})}))}))]})),ve&&t("div",Object.assign({className:"flex items-center justify-between border-y px-4 py-2.5",style:{borderColor:re.primary}},{children:o("div",Object.assign({className:"flex items-center gap-3"},{children:[t("button",Object.assign({type:"button",className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100",style:{color:re.secondaryText},onClick:ye,title:"inline"===$.type?(null==q?void 0:q.collapse)||"Collapse":(null==q?void 0:q.close)||"Close","aria-label":"inline"===$.type?(null==q?void 0:q.collapse)||"Collapse artifact":(null==q?void 0:q.close)||"Close artifact"},{children:t(w,{className:"h-5 w-5 shrink-0"})})),t("button",Object.assign({type:"button",className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100 disabled:cursor-not-allowed disabled:opacity-50",style:{color:re.secondaryText},disabled:K,onClick:()=>e(void 0,void 0,void 0,(function*(){if(le)try{N(le.content),Q(!0),yield new Promise((e=>setTimeout(e,1500)))}finally{Q(!1)}})),title:(null==q?void 0:q.copy)||"Copy","aria-label":(null==q?void 0:q.copy)||"Copy artifact content"},{children:t(C,{className:"h-[18px] w-[18px] shrink-0"})})),t(A,Object.assign({data:le,colors:re,onDownload:ue,onSaveAsPDF:de,onSaveAsDOCX:me,className:"opacity-70 transition-opacity duration-300 ease-in-out hover:opacity-100"},{children:t("div",Object.assign({role:"button",className:"cursor-pointer",style:{color:re.secondaryText},title:(null==q?void 0:q.save)||"Download","aria-label":(null==q?void 0:q.save)||"Download artifact content"},{children:t(k,{className:"h-6 w-6 shrink-0"})}))}))]}))})),t("div",Object.assign({className:"flex flex-col flex-grow @container/pickaxe-artifact"},{children:o(F,Object.assign({ref:oe,innerClassName:"flex-grow w-full"},{children:["render"===G&&"application/vnd.pxe.code"!==le.type?t("div",Object.assign({ref:U,className:E("p-4 pb-6 flex-grow flex flex-col","text/html"===le.type&&"p-0","text/csv"===le.type&&"p-0","application/pdf"===le.type&&"p-0","application/vnd.pxe.react"===le.type&&"p-0")},{children:"text/markdown"===le.type||"text/csv"===le.type||"text/tab-separated-values"===le.type||"image/svg+xml"===le.type?t(m,Object.assign({theme:ae.theme,colors:re},{children:t(u,{value:null!=ce?ce:le.content,className:E("px-6 @[767px]/pickaxe-artifact:px-11 mx-auto w-full",("text/csv"===le.type||"text/tab-separated-values"===le.type)&&"px-4 @[767px]/pickaxe-artifact:px-4 mx-0"),style:{flex:1}})})):"application/vnd.pxe.mermaid"===le.type?t(O,{ref:Y,id:`mermaid-${le.id}-${le.version}`,data:le.content}):"text/html"===le.type||"application/pdf"===le.type||"application/vnd.pxe.react"===le.type?t("iframe",Object.assign({ref:Z,title:le.title,src:`${B}/${"application/vnd.pxe.react"!==le.type?"html":"react"}?theme=${se?"dark":"light"}&bg=${re.secondary}&accent=${re.accent}`,style:{width:"100%",flex:1,border:"none",backgroundColor:null==re?void 0:re.secondary},loading:"lazy",allow:"fullscreen; camera; microphone; gyroscope; accelerometer; geolocation; clipboard-write; autoplay",sandbox:"allow-scripts allow-same-origin allow-forms allow-downloads allow-popups-to-escape-sandbox allow-pointer-lock allow-popups allow-modals allow-orientation-lock allow-presentation",onLoad:e=>{const o=e.target;setTimeout((()=>{var e;try{null===(e=o.contentWindow)||void 0===e||e.postMessage({type:"application/vnd.pxe.react"!==le.type?"HTML_CODE":"REACT_CODE",content:le.content},B)}catch(e){console.error("Error sending message to iframe:",e)}}),100),ne()}},{children:(null==q?void 0:q["iframe-artifact-fallback"])||"Iframe is not supported, please view this artifact in a browser that supports it."})):null})):t(y,Object.assign({PreTag:"div",language:"text/markdown"===le.type?"markdown":"text/html"===le.type||"image/svg+xml"===le.type?"xml":"application/vnd.pxe.react"===le.type?"typescript":le.programmingLanguage,showLineNumbers:!0,customStyle:{margin:0,flex:1},style:Object.assign({'code[class*="language-"]':Object.assign(Object.assign({color:null==re?void 0:re.secondaryText},se&&{textShadow:"0 1px rgba(0, 0, 0, 0.3)"}),{fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none"}),'pre[class*="language-"]':Object.assign(Object.assign({color:null==re?void 0:re.secondaryText},se&&{textShadow:"0 1px rgba(0, 0, 0, 0.3)"}),{fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",borderRadius:"0.3em",minWidth:0,paddingLeft:"1em",paddingRight:"1em",paddingBottom:"2em",background:null==re?void 0:re.secondary}),':not(pre) > code[class*="language-"]':{background:null==re?void 0:re.secondary,padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:null==re?void 0:re.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}},!se&&{comment:{color:"#7D8B99"},prolog:{color:"#7D8B99"},doctype:{color:"#7D8B99"},cdata:{color:"#7D8B99"},punctuation:{color:"#4D4D4C"},property:{color:"#4078F2"},keyword:{color:"#8959A8"},tag:{color:"#8959A8"},"class-name":{color:"#D75F00"},boolean:{color:"#0086B3"},constant:{color:"#0086B3"},symbol:{color:"#990055"},deleted:{color:"#990000"},number:{color:"#005CC5"},selector:{color:"#63A35C"},"attr-name":{color:"#63A35C"},string:{color:"#50A14F"},char:{color:"#50A14F"},builtin:{color:"#50A14F"},inserted:{color:"#50A14F"},variable:{color:"#A626A4"},operator:{color:"#4D4D4C"},entity:{color:"#E45649",cursor:"help"},url:{color:"#4078F2"},".language-css .token.string":{color:"#50A14F"},".style .token.string":{color:"#50A14F"},atrule:{color:"#C18401"},"attr-value":{color:"#986801"},function:{color:"#005CC5"},regex:{color:"#D16969"},important:{color:null==re?void 0:re.secondaryText,fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}})},{children:le.content})),t(g,{})]}))})),"inline"===$.type&&!pe&&o("div",Object.assign({className:"flex items-center gap-4 p-4 pt-6"},{children:[t(T,Object.assign({id:`artifact-copy-${le.id}-${le.version}`,tip:(null==q?void 0:q.copy)||"Copy",style:{padding:"0.25rem 0.5rem",backgroundColor:re.secondary,color:re.secondaryText,fontSize:"12px"},align:"bottom"},{children:t(j,{color:re.secondaryText,text:le.content,className:"opacity-100",iconClassName:"w-5 h-5"})})),t(T,Object.assign({id:`artifact-save-${le.id}-${le.version}`,tip:(null==q?void 0:q.save)||"Save",style:{padding:"0.25rem 0.5rem",backgroundColor:re.secondary,color:re.secondaryText,fontSize:"12px"},align:"bottom"},{children:t(A,Object.assign({data:le,colors:re,onDownload:ue,onSaveAsPDF:de,onSaveAsDOCX:me},{children:t("button",Object.assign({style:{color:re.secondaryText}},{children:t(k,{className:"w-5 h-5 shrink-0"})}))}))}))]}))]})):null};export{$ as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useEffect as
|
|
1
|
+
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useEffect as i}from"react";import{usePickaxeContext as t}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as o}from"./useAuthContext.js";import{useAuthVerify as s}from"./useAuthVerify.js";import{getAuthToken as n,deleteAuthToken as r,setAuthToken as d}from"../../../../../common/utils.js";import a from"../../../../../common/api/pickaxe.js";import l from"../../../../../common/error.js";import{useResponseContext as m}from"../../../../../hooks/pickaxe/useResponseContext.js";const u=()=>{const{deploymentId:u,pickaxe:c,translations:p,setSender:f,setSenderType:g}=t(),{emailInput:k,redirectUrl:I,isSending:v,isLoggedOut:h,isPricingAuth:w,setToken:y,setIsLoggingIn:j,setIsSending:x,setIsSent:S,setIsResendDisabled:E,setIsPricingAuth:P}=o(),b=s({token:n((null==c?void 0:c.studioid)||"")||"",enabled:h,setIsLoggingIn:j}),{setLimitData:L}=m();i((()=>{if("undefined"==typeof window)return;if(!b.data)return;const{success:e,token:i,error:t}=b.data;if(!e||t)return r(`PXE-token-${null==c?void 0:c.studioid}`),void P(!1);e&&i&&(y(i),f(void 0),g("STUDIO_USER"),w&&(P(!1),L(null)))}),[b.data,null==c?void 0:c.studioid]);return{onSend:i=>e(void 0,void 0,void 0,(function*(){try{if(!c)return;if(v)return;const e=k.trim().toLowerCase();if(!e)throw new Error((null==p?void 0:p["email-address-cannot-be-empty"])||"Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error((null==p?void 0:p["please-enter-valid-email-address"])||"Please enter a valid email address.");if(!c.studioid)throw new Error(`Studio ID is missing for ${c.formid}. Please contact support.`);x(!0),i&&E(!0);const t=(yield a.post("/auth/email",Object.assign(Object.assign({pickaxeId:c.formid,studioId:c.studioid,email:e},u&&{deploymentId:u}),{redirectUrl:I}))).data;if(!t.success)throw new Error(t.error||(null==p?void 0:p["failed-to-send-sign-in-link"])||"Failed to send sign-in link.");x(!1),S(!0),i&&(yield new Promise((e=>setTimeout(e,3e4))),E(!1)),d(`PXE-token-${c.studioid}`,t.token),P(!0)}catch(e){const i=l(e);alert(i)}finally{x(!1)}}))}};export{u as useAuth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsx as i,jsxs as o,Fragment as n}from"react/jsx-runtime";import{useMemo as l}from"react";import{useHover as s}from"../../../../hooks/core/useHover.js";import{useStyleFontSize as t}from"../../../../hooks/studio/useStyleFontSize.js";import{useStyleInput as r}from"../../../../hooks/studio/useStyleInput.js";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as c}from"./hooks/useAuthContext.js";import{useAuth as m}from"./hooks/useAuth.js";import d from"../../../Icons/spinner-circle.svg.js";import u from"../../../Icons/lock.svg.js";import p from"../../../Icons/email.svg.js";import f from"../../../Icons/arrow-right.svg.js";import x from"../../common/PickaxeIcon.js";import h from"../../common/PickaxeInput.js";import g from"../../common/PickaxeButton.js";import v from"../../common/PickaxeBranding.js";import y from"../../../../common/cn.js";const k=()=>{var k,j,b,w,N,O,C,I,P,S,R;const{deploymentType:D,pickaxe:E,styles:T,colors:B,misc:H,responsiveBy:L,translations:W,isRtl:$}=a(),{emailInput:A,isLoggingIn:F,isSending:K,isResendDisabled:_,isSent:z,setEmailInput:q}=c(),{onSend:G}=m(),J=t(),M=r(),Q=s(),{isHover:U}=Q,V=e(Q,["isHover"]),X=l((()=>A.trim()&&!K&&!z),[A,K,z]);return"chat-input"===D?i("div",Object.assign({className:y("flex items-center gap-x-2 px-4 py-3 overflow-hidden","block"===T.formFieldStyle&&"shadow",z&&"justify-center"),style:M,dir:$?"rtl":"ltr"},{children:z?o("p",Object.assign({className:"font-semilight text-center py-1"},{children:[`${null!==(j=null==W?void 0:W["we-sent-your-an-activation-link"])&&void 0!==j?j:"We sent you an activation link. Please be sure to check your spam folder too."} `,i("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{_||K||G(!0)}},{children:K?null!==(b=null==W?void 0:W.resending)&&void 0!==b?b:"Resending...":null!==(w=null==W?void 0:W.resend)&&void 0!==w?w:"Resend"}))]})):o(n,{children:[i(u,{className:"w-6 h-6 shrink-0",style:{color:B.accent}}),i("input",{id:"email",name:"email",type:"email",className:"outline-none ring-0 flex-grow bg-transparent",placeholder:null!==(k=null==W?void 0:W["enter-email-to-continue"])&&void 0!==k?k:"Enter here your email to continue",value:A,onChange:e=>q(e.target.value),onKeyDown:e=>{"Enter"===e.key&&G(!1)},autoComplete:"off"}),i("button",Object.assign({className:y("outline-none rounded-full w-8 h-8 disabled:cursor-default items-center justify-center flex duration-200 transition-colors ease-in-out",K&&"disabled:cursor-wait"),style:{backgroundColor:U||X?B.accent:B.accent+"10",color:U||X?B.accentText:B.accent+"80"},disabled:!A.trim()||K,onClick:()=>G(!1)},V,{children:i(f,{className:y("h-6 w-6 shrink-0",$&&"transform scale-x-[-1]")})}))]})})):o("div",Object.assign({className:"flex flex-col items-center flex-grow relative justify-center p-4",style:{backgroundColor:B.primary,color:B.text,borderRadius:T.cornerRadius},dir:$?"rtl":"ltr"},{children:[!H.isWhiteLabel&&i(v,{className:y("absolute top-4 right-4","popup"===D&&"right-12")}),F||!E?i(d,{className:"h-6 w-6 animate-spin animate-spin",style:{fill:B.accent,color:B.primary}}):o("div",Object.assign({className:"w-full flex flex-col items-center text-center max-w-[328px]"},{children:[H.isProfileImage&&i(x,{src:null==E?void 0:E.coverphoto,alt:`${null==E?void 0:E.formtitle}'s Profile Picture`,width:72,height:72,className:"h-[72px] w-[72px] rounded-full"}),i("h3",Object.assign({className:y(J.h3,"my-6")},{children:E.formtitle||"Tool"})),o("div",z?Object.assign({className:"flex flex-col items-center gap-6 w-full"},{children:[o("div",Object.assign({className:"flex items-center gap-2"},{children:[i(p,{className:"w-6 h-6 shrink-0"}),i("p",Object.assign({className:"font-semilight text-[20px]"},{children:null!==(I=null==W?void 0:W["check-your-inbox"])&&void 0!==I?I:"Check your inbox"}))]})),o("p",Object.assign({className:"font-semilight"},{children:[`${null!==(P=null==W?void 0:W["we-sent-your-an-activation-link"])&&void 0!==P?P:"We sent you an activation link. Please be sure to check your spam folder too."} `,i("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{_||K||G(!0)}},{children:K?null!==(S=null==W?void 0:W.resending)&&void 0!==S?S:"Resending...":null!==(R=null==W?void 0:W.resend)&&void 0!==R?R:"Resend"}))]}))]}):Object.assign({className:"flex flex-col items-center gap-6 w-full"},{children:[o("div",Object.assign({className:"flex items-center gap-2 flex-grow"},{children:[i(u,{className:"w-6 h-6 shrink-0"}),i("p",Object.assign({className:"font-semilight"},{children:null!==(N=null==W?void 0:W["please-enter-email-to-continue"])&&void 0!==N?N:"Please enter your email to continue:"}))]})),o("div",Object.assign({className:y("flex flex-col items-center gap-x-3 gap-y-6 w-full","viewport"===L?"min-[899px]:flex-row":"@[420px]/pickaxe-root:flex-row")},{children:[i(h,{id:"email",name:"email",type:"email",className:y("w-full py-3","viewport"===L?"min-[899px]:flex-grow min-[899px]:py-2":"@[420px]/pickaxe-root:flex-grow @[420px]/pickaxe-root:py-2"),placeholder:"jane.doe@email.com",value:A,onChange:e=>q(e.target.value),onKeyDown:e=>{"Enter"===e.key&&G(!1)}}),i(g,Object.assign({className:y("px-8 min-h-[40px]","viewport"===L?"min-[899px]:px-4":"@[420px]/pickaxe-root:px-4"),loadingText:null!==(O=null==W?void 0:W.sending)&&void 0!==O?O:"Sending...",isLoading:K,isDisabled:!A.trim(),onClick:()=>G(!1)},{children:null!==(C=null==W?void 0:W.submit)&&void 0!==C?C:"Submit"}))]}))]}))]}))]}))};export{k as default};
|
|
1
|
+
import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsx as i,jsxs as o,Fragment as n}from"react/jsx-runtime";import{useMemo as l}from"react";import{useHover as s}from"../../../../hooks/core/useHover.js";import{useStyleFontSize as t}from"../../../../hooks/studio/useStyleFontSize.js";import{useStyleInput as r}from"../../../../hooks/studio/useStyleInput.js";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as c}from"./hooks/useAuthContext.js";import{useAuth as m}from"./hooks/useAuth.js";import d from"../../../Icons/spinner-circle.svg.js";import u from"../../../Icons/lock.svg.js";import p from"../../../Icons/email.svg.js";import f from"../../../Icons/arrow-right.svg.js";import x from"../../common/PickaxeIcon.js";import h from"../../common/PickaxeInput.js";import g from"../../common/PickaxeButton.js";import v from"../../common/PickaxeBranding.js";import y from"../../../../common/cn.js";const k=()=>{var k,j,b,w,N,O,C,I,P,S,R;const{deploymentType:D,pickaxe:E,styles:T,colors:B,misc:H,responsiveBy:L,translations:W,isRtl:$}=a(),{emailInput:A,isLoggingIn:F,isSending:K,isResendDisabled:_,isSent:z,setEmailInput:q}=c(),{onSend:G}=m(),J=t(),M=r(),Q=s(),{isHover:U}=Q,V=e(Q,["isHover"]),X=l((()=>A.trim()&&!K&&!z),[A,K,z]);return"chat-input"===D?i("div",Object.assign({className:y("flex items-center gap-x-2 px-4 py-3 overflow-hidden","block"===T.formFieldStyle&&"shadow",z&&"justify-center"),style:M,dir:$?"rtl":"ltr"},{children:z?o("p",Object.assign({className:"font-semilight text-center py-1"},{children:[`${null!==(j=null==W?void 0:W["we-sent-your-an-activation-link"])&&void 0!==j?j:"We sent you an activation link. Please be sure to check your spam folder too."} `,i("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{_||K||G(!0)}},{children:K?null!==(b=null==W?void 0:W.resending)&&void 0!==b?b:"Resending...":null!==(w=null==W?void 0:W.resend)&&void 0!==w?w:"Resend"}))]})):o(n,{children:[i(u,{className:"w-6 h-6 shrink-0",style:{color:B.accent}}),i("input",{id:"email",name:"email",type:"email",className:"outline-none ring-0 flex-grow bg-transparent",placeholder:null!==(k=null==W?void 0:W["enter-email-to-continue"])&&void 0!==k?k:"Enter here your email to continue",value:A,onChange:e=>q(e.target.value),onKeyDown:e=>{"Enter"===e.key&&G(!1)},autoComplete:"off"}),i("button",Object.assign({className:y("outline-none rounded-full w-8 h-8 disabled:cursor-default items-center justify-center flex duration-200 transition-colors ease-in-out",K&&"disabled:cursor-wait"),style:{backgroundColor:U||X?B.accent:B.accent+"10",color:U||X?B.accentText:B.accent+"80"},disabled:!A.trim()||K,onClick:()=>G(!1)},V,{children:i(f,{className:y("h-6 w-6 shrink-0",$&&"transform scale-x-[-1]")})}))]})})):o("div",Object.assign({className:"flex flex-col items-center flex-grow relative justify-center p-4",style:{backgroundColor:B.primary,color:B.text,borderRadius:T.cornerRadius},dir:$?"rtl":"ltr"},{children:[!H.isWhiteLabel&&i(v,{className:y("absolute top-4 right-4","popup"===D&&"right-12")}),F||!E?i(d,{className:"h-6 w-6 animate-spin animate-spin",style:{fill:B.accent,color:B.primary}}):o("div",Object.assign({className:"w-full flex flex-col items-center text-center max-w-[328px]"},{children:[H.isProfileImage&&i(x,{src:null==E?void 0:E.coverphoto,alt:`${null==E?void 0:E.formtitle}'s Profile Picture`,width:72,height:72,className:"h-[72px] w-[72px] rounded-full"}),i("h3",Object.assign({className:y(J.h3,"my-6")},{children:E.formtitle||(null==W?void 0:W.tool)||"Tool"})),o("div",z?Object.assign({className:"flex flex-col items-center gap-6 w-full"},{children:[o("div",Object.assign({className:"flex items-center gap-2"},{children:[i(p,{className:"w-6 h-6 shrink-0"}),i("p",Object.assign({className:"font-semilight text-[20px]"},{children:null!==(I=null==W?void 0:W["check-your-inbox"])&&void 0!==I?I:"Check your inbox"}))]})),o("p",Object.assign({className:"font-semilight"},{children:[`${null!==(P=null==W?void 0:W["we-sent-your-an-activation-link"])&&void 0!==P?P:"We sent you an activation link. Please be sure to check your spam folder too."} `,i("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{_||K||G(!0)}},{children:K?null!==(S=null==W?void 0:W.resending)&&void 0!==S?S:"Resending...":null!==(R=null==W?void 0:W.resend)&&void 0!==R?R:"Resend"}))]}))]}):Object.assign({className:"flex flex-col items-center gap-6 w-full"},{children:[o("div",Object.assign({className:"flex items-center gap-2 flex-grow"},{children:[i(u,{className:"w-6 h-6 shrink-0"}),i("p",Object.assign({className:"font-semilight"},{children:null!==(N=null==W?void 0:W["please-enter-email-to-continue"])&&void 0!==N?N:"Please enter your email to continue:"}))]})),o("div",Object.assign({className:y("flex flex-col items-center gap-x-3 gap-y-6 w-full","viewport"===L?"min-[899px]:flex-row":"@[420px]/pickaxe-root:flex-row")},{children:[i(h,{id:"email",name:"email",type:"email",className:y("w-full py-3","viewport"===L?"min-[899px]:flex-grow min-[899px]:py-2":"@[420px]/pickaxe-root:flex-grow @[420px]/pickaxe-root:py-2"),placeholder:"jane.doe@email.com",value:A,onChange:e=>q(e.target.value),onKeyDown:e=>{"Enter"===e.key&&G(!1)}}),i(g,Object.assign({className:y("px-8 min-h-[40px]","viewport"===L?"min-[899px]:px-4":"@[420px]/pickaxe-root:px-4"),loadingText:null!==(O=null==W?void 0:W.sending)&&void 0!==O?O:"Sending...",isLoading:K,isDisabled:!A.trim(),onClick:()=>G(!1)},{children:null!==(C=null==W?void 0:W.submit)&&void 0!==C?C:"Submit"}))]}))]}))]}))]}))};export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{usePickaxeContext as t}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as s}from"../../Auth/hooks/useAuthContext.js";import{useSubmitDocument as i}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as o}from"./useDocumentContext.js";import{allowedImageMimeTypes as n,additionalAllowedFileExtensions as r,allowedFileMimeTypes as d}from"../../../../../common/documents.js";import{v4 as a}from"uuid";import u from"../../../../../common/error.js";const c=({onQuestionChange:c}={})=>{const{contextId:l,pickaxeId:m,sessionId:p,sender:f,senderType:
|
|
1
|
+
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{usePickaxeContext as t}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as s}from"../../Auth/hooks/useAuthContext.js";import{useSubmitDocument as i}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as o}from"./useDocumentContext.js";import{allowedImageMimeTypes as n,additionalAllowedFileExtensions as r,allowedFileMimeTypes as d}from"../../../../../common/documents.js";import{v4 as a}from"uuid";import u from"../../../../../common/error.js";const c=({onQuestionChange:c}={})=>{const{contextId:l,pickaxeId:m,sessionId:p,sender:f,senderType:b,pickaxe:w,translations:I}=t(),{token:h}=s(),v=o(),g=i(),k=e=>{const t=[...d,...n];if(e.some((e=>{var s;if(t.includes(e.type))return!1;if(""===e.type){const t=null===(s=e.name.split(".").pop())||void 0===s?void 0:s.toLowerCase();if(t&&r.includes(`.${t}`))return!1}return!0}))){const e=(null==I?void 0:I["invalid-upload-file-types"])||"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, XML, PNG, JPEG, WEBP, or GIF files. Please try again.",t=new Error(e),s=u(t);return v.setDocumentError(s),!0}return!1};return Object.assign(Object.assign({},v),{onFileUpload:t=>e(void 0,void 0,void 0,(function*(){if(v.setDocumentError(""),!t.length)return null;if(k(t))return null;v.setIsUploading(!0),v.setIsShowList(!0);const s=t.map((e=>({file:e,id:a()})));s.forEach((({file:e,id:t})=>{v.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,folder:o,error:r}=yield g.document(Object.assign(Object.assign(Object.assign({contextId:l,pickaxeId:m,sessionId:p,file:t},(null==w?void 0:w.workspaceid)&&{workspaceId:w.workspaceid}),"STUDIO_USER"===b&&{studioUserId:f}),h&&{studioSessionToken:h}));if(!e)throw new Error(r||(null==I?void 0:I["document-processing-failed"])||"Document processing failed");null==c||c({input:t.name,documentId:i});const d=i.startsWith("IMAGE-")||n.includes(t.type);return v.editDocument(Object.assign({id:s,type:d?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i},d&&o&&{folder:o})),{name:t.name,documentId:i}}catch(e){const i=u(e);return v.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}}))));yield Promise.allSettled(i),v.setIsUploading(!1)})),onWebsiteUpload:t=>e(void 0,void 0,void 0,(function*(){v.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error((null==I?void 0:I["invalid-website-or-youtube-link"])||"Please paste a valid website URL or Youtube video link to add to the knowledge base.");v.setIsUploading(!0),v.setIsShowList(!0),v.setWebsiteLink(""),v.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield g.website(Object.assign(Object.assign(Object.assign({pickaxeId:m,sessionId:p,website:e},(null==w?void 0:w.workspaceid)&&{workspaceId:w.workspaceid}),"STUDIO_USER"===b&&{studioUserId:f}),h&&{studioSessionToken:h})),{success:s,documentId:i}=t;if(!s)throw new Error((null==I?void 0:I["website-processing-failed"])||"Website processing failed, please try again.");v.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=u(t);if(s.includes((null==I?void 0:I["invalid-website-url"])||"Please paste a valid website URL"))return v.setDocumentError(s),null;v.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{v.setIsUploading(!1)}}))})};export{c as useDocument};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsx as t,jsxs as n}from"react/jsx-runtime";import s from"../../../../common/cn.js";import{useState as
|
|
1
|
+
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsx as t,jsxs as n}from"react/jsx-runtime";import s from"../../../../common/cn.js";import{usePickaxeContext as i}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useState as a,useRef as o,useEffect as r}from"react";import{Check as l,X as c,MoreHorizontal as m}from"lucide-react";import d from"../../../Icons/trash-2.svg.js";import p from"../../../Icons/pencil.svg.js";const u=({text:e,icon:i,className:a,onClick:o})=>t("div",Object.assign({onClick:e=>{e.stopPropagation(),null==o||o()},className:s("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 transition-all duration-200 cursor-pointer","glass",a),onMouseDown:e=>{e.preventDefault()}},{children:n("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-0"},{children:[i&&t("img",{src:i,alt:"",className:"h-5 w-5 shrink-0 rounded-full object-cover"}),t("p",Object.assign({className:"text-xs md:text-sm font-medium truncate max-w-[80px] md:max-w-[150px]"},{children:e}))]}))})),h=({text:u,className:h,onRename:x,onDelete:f,isDarkGlass:g})=>{const{translations:b}=i(),[v,w]=a(!1),[k,j]=a(!1),[N,y]=a(u),[O,C]=a(!1),D=o(null),z=o(null);r((()=>{k||y(u)}),[u,k]),r((()=>{const e=e=>{z.current&&!z.current.contains(e.target)&&w(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const E=()=>e(void 0,void 0,void 0,(function*(){N.trim()&&(C(!0),yield x(N),C(!1),j(!1))})),P=()=>{y(u),j(!1)};return n("div",Object.assign({ref:z,className:"relative z-40 h-full shrink min-w-0",onMouseDown:e=>{e.preventDefault()}},{children:[t("div",Object.assign({className:s("relative flex items-center justify-center px-3 py-2 md:px-4 md:py-3 h-full shrink min-w-0 overflow-visible transition-all duration-200 cursor-pointer group","glass",h),onClick:e=>{e.stopPropagation(),k||v?v&&w(!1):w(!0)}},{children:n("div",k?Object.assign({className:"flex items-center gap-2 z-20 min-w-[100px] md:min-w-[140px]",onClick:e=>e.stopPropagation()},{children:[t("input",{autoFocus:!0,type:"text",value:N,onChange:e=>y(e.target.value),onKeyDown:e=>{"Enter"===e.key&&E(),"Escape"===e.key&&P()},className:"bg-transparent border-b border-current text-xs md:text-sm font-medium focus:outline-none w-full min-w-[60px] md:min-w-[80px]",style:{color:"inherit"}}),t("button",Object.assign({onClick:E,disabled:O,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:t(l,{className:"h-4 w-4"})})),t("button",Object.assign({onClick:P,disabled:O,className:"p-1 rounded hover:bg-black/10 dark:hover:bg-white/10 shrink-0"},{children:t(c,{className:"h-4 w-4"})}))]}):Object.assign({className:"flex items-center gap-2 z-20 min-w-0 max-w-[140px] md:max-w-[200px]"},{children:[t("p",Object.assign({className:"text-xs md:text-sm font-medium truncate"},{children:u})),t(m,{className:s("h-4 w-4 opacity-50 group-hover:opacity-100 transition-opacity shrink-0")})]}))})),v&&n("div",Object.assign({className:s("absolute top-full right-0 mt-2 w-48 shadow-xl z-50 rounded-[16px] overflow-hidden animate-in fade-in zoom-in-95 duration-100",g?"bg-[#313131] text-white":"bg-white text-black"),ref:D},{children:[n("button",Object.assign({onClick:e=>{e.stopPropagation(),w(!1),j(!0)},className:s("w-full text-left px-4 py-3 flex items-center gap-3 transition-colors border-b hover:opacity-70",g?"border-current":"border-[#EBEAEB]")},{children:[t(p,{className:"h-4 w-4"}),t("span",Object.assign({className:"font-medium text-sm"},{children:(null==b?void 0:b["rename-chat"])||"Rename chat"}))]})),n("button",Object.assign({onClick:e=>{e.stopPropagation(),w(!1),f()},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors hover:opacity-70"},{children:[t(d,{className:"h-4 w-4"}),t("span",Object.assign({className:"font-medium text-sm"},{children:(null==b?void 0:b["delete-chat"])||"Delete chat"}))]}))]}))]}))},x=({icon:e,className:n,onClick:i})=>t("div",Object.assign({onClick:e=>{e.stopPropagation(),null==i||i()},className:s("relative flex items-center justify-center h-full aspect-square p-2 md:p-3 shrink-0 transition-all duration-200 cursor-pointer","glass rounded-full",n),onMouseDown:e=>{e.preventDefault()}},{children:t("div",Object.assign({className:"flex items-center justify-center z-20"},{children:e}))}));export{h as EditableNavPill,x as HistoryPill,u as NavPill};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as t,useEffect as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as n}from"../../Addons/Auth/hooks/useAuthContext.js";import{useAuth as l}from"../../Addons/Auth/hooks/useAuth.js";import{useResponseContext as r}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as c}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as m}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../../hooks/pickaxe/useConversation.js";import{useArtifactContext as u}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{AnimatePresence as h,motion as f}from"framer-motion";import g from"../../../Icons/lock.svg.js";import x from"../../../Core/ErrorAlert.js";import j from"../../common/PickaxeHead.js";import b from"../../common/PickaxeEmbedHead.js";import v from"../../common/PickaxeUpgradeCard.js";import y from"../../common/PickaxeSkeleton.js";import k from"../../common/PickaxeHistoryButton.js";import w from"../../Addons/Scroll/ScrollLockView.js";import N from"../../Addons/Artifact/Renderer/index.js";import O from"./Message.js";import C from"./CustomMessage.js";import S from"../../Addons/IceBreaker/index.js";import A from"../../common/PickaxeBranding.js";import P from"../../../../common/cn.js";const I=({additionalScrollHeight:I,smitheryAuthData:H,isForceHideInfo:L,isInputFocused:R,onSubmit:D,resubmitPrompt:B})=>{var T,E,F,z,M;const{sessionId:W,deploymentType:$,pickaxe:q,translations:U,misc:V,isNewChat:_,isRtl:G,isEmbed:J,isShowIceBreaker:K,setSessionId:Q,setLastSessionId:X}=o(),{emailInput:Y,isLoggedOut:Z,isSending:ee,isResendDisabled:se,isSent:ie,isPricingAuth:te}=n(),{onSend:ae}=l(),{scrollContainerRef:oe}=m(),{messages:ne,limitData:le,error:re}=r(),{height:ce,width:me}=c(),{currentArtifact:de,chatPopupType:pe,currentPopupType:ue}=u(),he=p(),fe=d(),ge=t((()=>(null==q?void 0:q.icebreakers)?q.icebreakers.slice(0,3):[]),[null==q?void 0:q.icebreakers]),xe=t((()=>{const e=!!he.data&&he.data.messages.length>1;return!L&&he.isSuccess&&_&&!e}),[L,he.isSuccess,_,he.data]),je=t((()=>!(null==q?void 0:q.chatflag)&&(null==q?void 0:q.enablechatresponses)&&ne.length>0),[q,ne]),be=t((()=>!!he.data&&he.data.messages.some((e=>"intromessage"===e.area))),[he.data]),ve="chat-input"===$&&te&&Z&&ie,ye=K&&!R&&!be&&xe&&me>767,ke=K&&!R&&(be||me<=767),we=()=>{X(W),Q("")};return a((()=>{oe.current&&requestAnimationFrame((()=>{oe.current&&(oe.current.scrollTop=oe.current.scrollHeight)}))}),[I,oe]),e("div",Object.assign({ref:oe,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[s(h,{children:!!de&&"inline"===ue&&s(f.div,Object.assign({className:P("absolute top-0 z-20 w-full px-4 py-2",pe),style:{height:`calc(${ce-I}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:s(N,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:de.id,version:de.version}})}))}),e("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[xe&&J&&s("div",Object.assign({className:P("absolute right-4 top-3 flex items-center gap-2","popup"===$&&"right-12")},{children:s(k,{tip:(null==U?void 0:U["chat-history"])||"Chat History",onClick:we})})),s(j,Object.assign({className:P("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",xe&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!ve&&{onIconClick:we})),J&&!he.isLoading&&s(b,Object.assign({className:P("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!xe&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==U?void 0:U["chat-history"])||"Chat History"},!ve&&{onIconClick:we,onHistoryClick:we})),e("div",Object.assign({className:P("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",J&&!he.isLoading&&!xe&&"mt-0")},{children:[ye&&s("div",Object.assign({className:P("grid grid-cols-3 gap-4",2===ge.length&&"grid-cols-2",1===ge.length&&"grid-cols-1")},{children:s(S,{type:"center",data:ge,onSend:D})})),ve?s("div",Object.assign({className:"flex flex-col w-full"},{children:e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[s(C,Object.assign({chatRole:"user"},{children:e("div",Object.assign({className:"flex items-center gap-x-3"},{children:[s(g,{className:"h-6 w-6 shrink-0"}),s("p",Object.assign({className:"font-semilight"},{children:Y}))]}))})),s(C,Object.assign({chatRole:"assistant"},{children:e("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(F=null==U?void 0:U["we-sent-your-an-activation-link"])&&void 0!==F?F:"We sent you an activation link. Please be sure to check your spam folder too."} `,s("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{se||ee||ae(!0)}},{children:ee?null!==(z=null==U?void 0:U.resending)&&void 0!==z?z:"Resending...":null!==(M=null==U?void 0:U.resend)&&void 0!==M?M:"Resend"}))]}))}))]}))})):s(i,{children:he.isLoading&&!(null==q?void 0:q.enablechatresponses)?e("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[_&&e("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[s(y,{className:"w-[72px] h-[72px]"}),s(y,{className:"h-[20px] mt-6 w-full"}),s(y,{className:"h-[20px] mt-2 w-full"}),s(y,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),s(y,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),s(y,{className:"h-[150px] w-[70%] animate-pulse rounded"}),s(y,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):he.isError?s("div",Object.assign({className:"flex w-full justify-center"},{children:e("p",Object.assign({className:P(fe.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",s("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):he.data||je?e("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(E=null===(T=he.data)||void 0===T?void 0:T.messages)&&void 0!==E?E:[]).map(((e,i)=>s(O,{index:i,message:e},i))),ne.map(((e,i)=>{var t,a;return s(O,{smitheryData:H,resubmitPrompt:B,index:(null!==(a=null===(t=he.data)||void 0===t?void 0:t.messages.length)&&void 0!==a?a:0)+i,message:e,isLastMessage:i===ne.length-1},i)})),le?s("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:s(v,{})})):re?s("div",Object.assign({className:P("flex items-center gap-x-3",G?"justify-end":"justify-start")},{children:s(x,{error:re})})):null]})),e("div",Object.assign({className:P("flex flex-col",!V.isWhiteLabel||ke&&"mt-4")},{children:[!V.isWhiteLabel&&s(A,{containerClassName:P("justify-end",ke&&"mb-2")}),ke&&s("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:s(S,{type:"right",data:ge,onSend:D})})),s(w,{})]}))]})):null})]}))]}))]}))};export{I as default};
|
|
1
|
+
import{jsxs as e,jsx as s,Fragment as i}from"react/jsx-runtime";import{useMemo as t,useEffect as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as n}from"../../Addons/Auth/hooks/useAuthContext.js";import{useAuth as l}from"../../Addons/Auth/hooks/useAuth.js";import{useResponseContext as r}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as c}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as m}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../../hooks/pickaxe/useConversation.js";import{useArtifactContext as u}from"../../Addons/Artifact/hooks/useArtifactContext.js";import{AnimatePresence as h,motion as f}from"framer-motion";import g from"../../../Icons/lock.svg.js";import x from"../../../Core/ErrorAlert.js";import j from"../../common/PickaxeHead.js";import b from"../../common/PickaxeEmbedHead.js";import v from"../../common/PickaxeUpgradeCard.js";import y from"../../common/PickaxeSkeleton.js";import k from"../../common/PickaxeHistoryButton.js";import w from"../../Addons/Scroll/ScrollLockView.js";import N from"../../Addons/Artifact/Renderer/index.js";import O from"./Message.js";import C from"./CustomMessage.js";import S from"../../Addons/IceBreaker/index.js";import A from"../../common/PickaxeBranding.js";import P from"../../../../common/cn.js";const I=({additionalScrollHeight:I,smitheryAuthData:H,isForceHideInfo:L,isInputFocused:R,onSubmit:D,resubmitPrompt:B})=>{var T,E,F,z,M;const{sessionId:W,deploymentType:$,pickaxe:q,translations:U,misc:V,isNewChat:_,isRtl:G,isEmbed:J,isShowIceBreaker:K,setSessionId:Q,setLastSessionId:X}=o(),{emailInput:Y,isLoggedOut:Z,isSending:ee,isResendDisabled:se,isSent:ie,isPricingAuth:te}=n(),{onSend:ae}=l(),{scrollContainerRef:oe}=m(),{messages:ne,limitData:le,error:re}=r(),{height:ce,width:me}=c(),{currentArtifact:de,chatPopupType:pe,currentPopupType:ue}=u(),he=p(),fe=d(),ge=t((()=>(null==q?void 0:q.icebreakers)?q.icebreakers.slice(0,3):[]),[null==q?void 0:q.icebreakers]),xe=t((()=>{const e=!!he.data&&he.data.messages.length>1;return!L&&he.isSuccess&&_&&!e}),[L,he.isSuccess,_,he.data]),je=t((()=>!(null==q?void 0:q.chatflag)&&(null==q?void 0:q.enablechatresponses)&&ne.length>0),[q,ne]),be=t((()=>!!he.data&&he.data.messages.some((e=>"intromessage"===e.area))),[he.data]),ve="chat-input"===$&&te&&Z&&ie,ye=K&&!R&&!be&&xe&&me>767,ke=K&&!R&&(be||me<=767),we=()=>{X(W),Q("")};return a((()=>{oe.current&&requestAnimationFrame((()=>{oe.current&&(oe.current.scrollTop=oe.current.scrollHeight)}))}),[I,oe]),e("div",Object.assign({ref:oe,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4"},{children:[s(h,{children:!!de&&"inline"===ue&&s(f.div,Object.assign({className:P("absolute top-0 z-20 w-full px-4 py-2",pe),style:{height:`calc(${ce-I}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:s(N,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:de.id,version:de.version}})}))}),e("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[xe&&J&&s("div",Object.assign({className:P("absolute right-4 top-3 flex items-center gap-2","popup"===$&&"right-12")},{children:s(k,{tip:(null==U?void 0:U["chat-history"])||"Chat History",onClick:we})})),s(j,Object.assign({className:P("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",xe&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!ve&&{onIconClick:we})),J&&!he.isLoading&&s(b,Object.assign({className:P("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!xe&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==U?void 0:U["chat-history"])||"Chat History"},!ve&&{onIconClick:we,onHistoryClick:we})),e("div",Object.assign({className:P("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",J&&!he.isLoading&&!xe&&"mt-0")},{children:[ye&&s("div",Object.assign({className:P("grid grid-cols-3 gap-4",2===ge.length&&"grid-cols-2",1===ge.length&&"grid-cols-1")},{children:s(S,{type:"center",data:ge,onSend:D})})),ve?s("div",Object.assign({className:"flex flex-col w-full"},{children:e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[s(C,Object.assign({chatRole:"user"},{children:e("div",Object.assign({className:"flex items-center gap-x-3"},{children:[s(g,{className:"h-6 w-6 shrink-0"}),s("p",Object.assign({className:"font-semilight"},{children:Y}))]}))})),s(C,Object.assign({chatRole:"assistant"},{children:e("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(F=null==U?void 0:U["we-sent-your-an-activation-link"])&&void 0!==F?F:"We sent you an activation link. Please be sure to check your spam folder too."} `,s("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{se||ee||ae(!0)}},{children:ee?null!==(z=null==U?void 0:U.resending)&&void 0!==z?z:"Resending...":null!==(M=null==U?void 0:U.resend)&&void 0!==M?M:"Resend"}))]}))}))]}))})):s(i,{children:he.isLoading&&!(null==q?void 0:q.enablechatresponses)?e("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[_&&e("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[s(y,{className:"w-[72px] h-[72px]"}),s(y,{className:"h-[20px] mt-6 w-full"}),s(y,{className:"h-[20px] mt-2 w-full"}),s(y,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),s(y,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),s(y,{className:"h-[150px] w-[70%] animate-pulse rounded"}),s(y,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):he.isError?s("div",Object.assign({className:"flex w-full justify-center"},{children:e("p",Object.assign({className:P(fe.b2,"text-center font-semibold")},{children:[(null==U?void 0:U["something-went-wrong-please-try-again"])||"Something went wrong. Please try again, or"," ",s("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:(null==U?void 0:U["contact-us"])||"contact us"}))," ",(null==U?void 0:U["for-help"])||"for help."]}))})):he.data||je?e("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[(null!==(E=null===(T=he.data)||void 0===T?void 0:T.messages)&&void 0!==E?E:[]).map(((e,i)=>s(O,{index:i,message:e},i))),ne.map(((e,i)=>{var t,a;return s(O,{smitheryData:H,resubmitPrompt:B,index:(null!==(a=null===(t=he.data)||void 0===t?void 0:t.messages.length)&&void 0!==a?a:0)+i,message:e,isLastMessage:i===ne.length-1},i)})),le?s("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:s(v,{})})):re?s("div",Object.assign({className:P("flex items-center gap-x-3",G?"justify-end":"justify-start")},{children:s(x,{error:re})})):null]})),e("div",Object.assign({className:P("flex flex-col",!V.isWhiteLabel||ke&&"mt-4")},{children:[!V.isWhiteLabel&&s(A,{containerClassName:P("justify-end",ke&&"mb-2")}),ke&&s("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:s(S,{type:"right",data:ge,onSend:D})})),s(w,{})]}))]})):null})]}))]}))]}))};export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as n,Fragment as o}from"react/jsx-runtime";import{forwardRef as i,useState as r,useRef as a,useCallback as l,useEffect as c,useMemo as d,useImperativeHandle as u}from"react";import{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as m}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as f}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as h}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as g}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as v}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as y}from"../Addons/Document/hooks/useDocument.js";import{useScroll as x}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as j}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as O}from"../../../hooks/core/useHover.js";import{useMediaQuery as w}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as k,allowedImageMimeTypes as N,additionalAllowedFileExtensions as S}from"../../../common/documents.js";import{createParser as C}from"eventsource-parser";import I from"../../Icons/attach-vertical.svg.js";import E from"../../Icons/arrow-right.svg.js";import _ from"../../Icons/microphone.svg.js";import T from"../../Icons/stop.svg.js";import A from"../Addons/Document/List.js";import P from"../../Core/Textarea.js";import D from"../../Core/ErrorAlert.js";import R from"../../../common/error.js";import{getValidationFailure as L}from"../../../common/validation.js";import U from"../../../common/cn.js";import{isInIframe as $,initializeEmbedUserId as B}from"../../../common/utils.js";import{useStudio as V}from"../../../hooks/studio/useStudio.js";import{useSpeech as X}from"../../../hooks/pickaxe/useSpeech.js";const K=i((({resubmitPrompt:i,onFocus:K,onBlur:W,onInputHeightChange:F,initSmitheryAuthData:H},J)=>{var M,z,G;const{origin:q,pickaxeId:Q,sessionId:Y,sender:Z,senderType:ee,portalId:te,deploymentId:se,deploymentType:ne,pickaxe:oe,styles:ie,colors:re,locale:ae,forceMobile:le,isNewChat:ce,isRtl:de,isShowFeedbackMessage:ue,accessGroup:pe,setIsNewChat:me,setIsShowIceBreaker:fe,setValidationStatus:he,setValidationUpgradeGroups:ge,setValidationUpgradeUrl:ve,onGenerateComplete:be}=p(),{token:ye,isLoggedOut:xe,isSent:je,isPricingAuth:Oe}=b(),{messages:we,isGenerating:ke,setMessages:Ne,setStatus:Se,setLimitData:Ce,setError:Ie}=m(),{documents:Ee,isUploading:_e,documentError:Te,onFileUpload:Ae,setDocuments:Pe,setDocumentError:De}=y(),{studio:Re}=V(),{scrollStartSession:Le,scrollEndSession:Ue,scrollToBottom:$e}=x({auto:!0}),{artifacts:Be,currentPopupType:Ve,setArtifacts:Xe,setCurrentArtifact:Ke}=j(),{height:We}=v(),Fe=g(),[He,Je]=r(""),[Me,ze]=r(!1),[Ge,qe]=r(!1),[Qe,Ye]=r(null),[Ze,et]=r(null),[tt,st]=r(!1),nt=a(null),ot=a(""),it=a(null),rt=a(null),at=a(null),lt=a(null),ct=a(null),dt=Math.max(.4*We,100),{speechTranscript:ut,isSpeechListening:pt,isSpeechProcessing:mt,isSpeechSupported:ft,onStartListening:ht,onStopListening:gt}=X(),[vt]=w("(max-width: 480px)"),bt=O(),{isHover:yt}=bt,xt=e(bt,["isHover"]),jt=O(),{isHover:Ot}=jt,wt=e(jt,["isHover"]),kt=O(),{isHover:Nt}=kt,St=e(kt,["isHover"]),Ct=h(),It=f(),Et="undefined"!=typeof window?window.location.hostname:"",_t="undefined"!=typeof window?window.location.href:"",Tt="undefined"!=typeof window&&window.self!==window.top,At=Et.includes("pickaxe.co")&&!_t.includes("https://studio.pickaxe.co/_embed")&&!Tt,Pt=null===(M=null==oe?void 0:oe.documentuploadtype)||void 0===M?void 0:M.startsWith("enduserupload"),Dt=ft&&(null==oe?void 0:oe.enablevoicetotext),Rt="chat-input"===ne&&ce&&!je,Lt="chat-input"===ne&&Oe&&xe&&je,Ut=l((e=>{const t=L(e);return!!t&&(Ie(""),Ce(null),he(t.status),ge(t.upgradeGroups),ve(t.upgradeUrl),!0)}),[Ie,Ce,he,ge,ve]),$t=null!==(z=null==oe?void 0:oe.placeholdertext)&&void 0!==z?z:de?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",Bt=Me||Ge,Vt=l((()=>t(void 0,void 0,void 0,(function*(){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/get_user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign(Object.assign(Object.assign({studioId:null==oe?void 0:oe.studioid},Z&&{sender:Z}),ye&&{studioSessionToken:ye}),!ye&&!Z&&{sender:B()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),At&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Ye(t.studioUser),et(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[q,Q,Y,ee,Z,ye,te,se,At]);c((()=>{Vt()}),[Vt]);const Xt=(null==pe?void 0:pe.limit)||0,Kt=(null==Qe?void 0:Qe.currentUses)||0,Wt=(null==Qe?void 0:Qe.extraUses)||0,Ft=!!(null==Re?void 0:Re.data.usage)&&Re.data.usage.isCredits,Ht=Xt>Kt?Xt-Kt+Wt:Wt,Jt=d((()=>!!Qe&&(!tt&&(!(Xt<=0)&&Ht<=.05*Xt))),[Qe,tt,Ht,Xt]),Mt=d((()=>{var e,t,s;return!!ce&&(!!oe&&(!Fe.isLoading&&(!((null!==(t=null===(e=Fe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=oe.icebreakers)||void 0===s?void 0:s.length)&&(!ue&&!Rt)))))}),[oe,ce,ue,Rt,Fe.data,Fe.isLoading]),zt=d((()=>{if(ke||_e)return!1;const e=Ee.length>0&&Ee.every((e=>"finished"===e.status));return!(!He.trim()&&!e)&&Ee.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[ke,_e,He,Ee]);u(J,(()=>({onSubmit:Gt}))),c((()=>{fe(Mt)}),[Mt]),c((()=>{var e;if(i){const t=Array.from(we),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Gt(s,!0)}}),[i]),c((()=>{if(!lt.current||!F)return;const e=new ResizeObserver((e=>{for(const t of e)F(t.contentRect.height)}));return e.observe(lt.current),()=>{e.disconnect()}}),[F]),c((()=>{if(!pt)return;const e=ot.current?`${ot.current} `:"";Je(`${e}${ut}`)}),[ut,pt]),c((()=>{if(!rt.current)return;(()=>{if(!rt.current)return;let e=rt.current.scrollHeight>52;He.includes("\n")||Ee.length?e=!0:He.trim()||(e=!1),ze(e)})()}),[He,Ee]),c((()=>{const e=rt.current,t=at.current;if(!e||!t||Me||He.includes("\n"))return void qe(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,o=document.createElement("span");Object.assign(o.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),o.textContent=He||$t,document.body.appendChild(o);const i=o.offsetWidth;o.remove();const r=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-r-a-t.offsetWidth;qe(i>l)}),[He,Me,$t]);const Gt=(e,s=!1)=>t(void 0,void 0,void 0,(function*(){var t,n,o;try{if(ke||_e)return;const i=Ee.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=i.map((e=>e.documentId)).filter(Boolean),a=i.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=e?e:He;if(!c&&!l)return;Ie(""),De(""),Ce(null),Je(""),me(!1),Se("fetching"),Le(),$e();const d=null!==(n=null===(t=null==oe?void 0:oe.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==n&&n&&r.length>0,u=[...s?Array.from(we.slice(0,we.length-1)):Array.from(we),...s?[]:[{id:we.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:we.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];Ne(u),$e(),d&&Pe([]);const p=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:q,pickaxeId:Q,sessionId:Y,senderType:ee,value:c},d&&{documentIds:r}),Z&&{sender:Z}),ye&&{studioSessionToken:ye}),!ye&&!Z&&{sender:B()}),te&&{portalId:te}),se&&{deploymentId:se}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},At&&{credentials:"include"})),m=yield p.json();if(!m.success){if(Ut(m))return;const e=new Error(m.error||m.message||"Failed to start generation");throw m.limitData&&(e.limitData=m.limitData),e}const f=m.submissionId;Se("streaming"),ct.current=new AbortController;const h=u.length-1,g=[];let v=[...null!=Be?Be:[]],b=0,y=!1,x="";for(;!y;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${f}?index=${b}`,{signal:null===(o=ct.current)||void 0===o?void 0:o.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();it.current=t;const s=new TextDecoder,n=C({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&b++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong.";return Ut(t)||Ie(s),void(y=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&H){const e=n.data.error;if("string"==typeof e){if(/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e)){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw y=!0,H({smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw y=!0,H({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)x="",g.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)x+=n.delta,g[g.length-1].content=x;else if("text-end"===n.type)x="";else if("reasoning-start"===n.type)x="",g.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)x+=n.delta,g[g.length-1].content=x;else if("reasoning-end"===n.type)x="";else if(n.type.startsWith("data-")){const e=n;g.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Ne([...u.slice(0,h),Object.assign(Object.assign({},u[u.length-1]),{id:we.length+1,role:"assistant",parts:g})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Xe([...v]),Ve.startsWith("inline")||Ke({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Xe(v),Ve.startsWith("inline")||Ke({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Xe(v),Ve.startsWith("inline")||Ke({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");v=v.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Xe(v)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Xe(v.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data),s=t.error||t.message||"Something went wrong, please try again.";if(Ut(t))return void(y=!0);Ie(s)}else"stop"===e.event&&(y=!0)}else y=!0}});for(;;){const{value:e,done:o}=yield t.read();if(o)break;n.feed(s.decode(e))}y||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||"AbortError"===e.name)return void(y=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==be||be(Y)}catch(e){if(e.limitData)Ce(e.limitData),Ie("");else{let t=R(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later."),Ut(t)||Ie(t)}}finally{$e(),Se("idle"),Ue(),it.current=null,yield Vt()}}));return Lt?null:s("div",Object.assign({className:U("flex w-full flex-shrink-0 flex-col items-center",!Rt&&"px-4 pb-8"),dir:de?"rtl":"ltr"},{children:n("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[n("div",Object.assign({ref:lt,className:U("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ie.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},It),{maxHeight:`${dt}px`,overflowY:"auto"})},{children:[Jt&&n("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:It.backgroundColor?`${It.backgroundColor}E6`:void 0,borderColor:re.text+"20",color:re.text,borderTopRightRadius:ie.cornerRadius+"px",borderTopLeftRadius:ie.cornerRadius+"px"}},{children:[s("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:n("span",{children:[Ht," ",Ft?"credits":"uses"," remaining"]})})),n("div",Object.assign({className:"flex items-center gap-3"},{children:[s("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:re.accent,color:re.accentText},onClick:e=>{e.preventDefault(),e.stopPropagation();const t=`${Ze}${null==pe?void 0:pe.accessGroupId}`;$()?window.open(t):location.href=t}},{children:"Upgrade"})),s("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>st(!0)},{children:s("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:s("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!ke&&Ee.length>0&&s(A,{className:"p-4 pb-0",isDisabled:ke}),n("div",Object.assign({className:"relative flex w-full flex-col"},{children:[pt&&n("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[s("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(G=re.accent)&&void 0!==G?G:"#ff0000"}}),s("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:re.text+"90"}},{children:"Listening..."}))]})),s(P,Object.assign({ref:rt,className:U(Ct.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!He.trim()&&!He.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",de?"text-right":"text-left",Bt&&"mb-12",pt&&"text-transparent"),value:He,placeholder:$t,onChange:e=>{if(Je(e),F){const t=(e.match(/\n/g)||[]).length+1;if(!e)return void F(0);if(t>=11)return;let s=0;t>1&&(s=50),F(24*(t-1)+s)}},onKeyDown:e=>{le||vt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),_e||ke||Gt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),me(!1),yield Ae(t))}))},K&&{onFocus:K},W&&{onBlur:W},{dir:de?"rtl":"ltr"})),s("div",Object.assign({ref:at,className:U("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",Bt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Bt&&It.backgroundColor&&{backgroundColor:It.backgroundColor}),{borderTopRightRadius:ie.cornerRadius+"px",borderBottomRightRadius:ie.cornerRadius+"px"})},{children:ke?s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{ct.current&&(ct.current.abort(),ct.current=null),it.current&&(it.current.cancel(),it.current=null),Se("idle")},style:{backgroundColor:re.accent,color:re.accentText}},{children:s(T,{className:"h-4 w-4 shrink-0"})})):pt?s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:gt,style:{backgroundColor:re.accent,color:re.accentText}},{children:s(T,{className:"h-4 w-4 shrink-0"})})):n(o,{children:[Pt&&n("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ot?re.accent+"10":void 0,color:Ot?re.accent:re.accent+"80"},disabled:_e||ke,onClick:()=>{var e;return null===(e=nt.current)||void 0===e?void 0:e.click()}},wt,{children:[s("input",{id:"file-upload",ref:nt,type:"file",accept:[...k,...N,...S].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){me(!1),yield Ae(Array.from(e.target.files||[])),e.target.value=""}))}),s(I,{className:"h-6 w-6 shrink-0"})]})),Dt&&s("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:pt?re.accent:Nt?re.accent+"10":void 0,color:pt?re.accentText:Nt?re.accent:re.accent+"80"},disabled:_e||ke||mt,onClick:()=>{pt?gt():(ot.current=He,ht(ae||"en-US"))}},St,{children:s(_,{className:"h-5 w-5 shrink-0"})})),s("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:yt||zt?re.accent:re.accent+"10",color:yt||zt?re.accentText:re.accent+"80"},disabled:!zt,onClick:()=>Gt()},xt,{children:s(E,{className:U("h-6 w-6 shrink-0",de&&"scale-x-[-1] transform")})}))]})}))]}))]})),Te&&s(D,{error:Te,className:"mt-3"})]}))}))}));K.displayName="Input";export{K as default};
|
|
1
|
+
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{usePickaxeContext as p}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as m}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as f}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as g}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as h}from"../../../hooks/pickaxe/useConversation.js";import{useDimensionContext as v}from"../../../hooks/pickaxe/useDimensionContext.js";import{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import{useDocument as y}from"../Addons/Document/hooks/useDocument.js";import{useScroll as x}from"../Addons/Scroll/hooks/useScroll.js";import{useArtifactContext as j}from"../Addons/Artifact/hooks/useArtifactContext.js";import{useHover as w}from"../../../hooks/core/useHover.js";import{useMediaQuery as O}from"../../../hooks/core/useMediaQuery.js";import{allowedFileMimeTypes as k,allowedImageMimeTypes as N,additionalAllowedFileExtensions as S}from"../../../common/documents.js";import{createParser as C}from"eventsource-parser";import I from"../../Icons/attach-vertical.svg.js";import E from"../../Icons/arrow-right.svg.js";import _ from"../../Icons/microphone.svg.js";import T from"../../Icons/stop.svg.js";import A from"../Addons/Document/List.js";import P from"../../Core/Textarea.js";import D from"../../Core/ErrorAlert.js";import R from"../../../common/error.js";import{getValidationFailure as L}from"../../../common/validation.js";import U from"../../../common/cn.js";import{isInIframe as $,initializeEmbedUserId as B}from"../../../common/utils.js";import{useStudio as V}from"../../../hooks/studio/useStudio.js";import{useSpeech as X}from"../../../hooks/pickaxe/useSpeech.js";const K=i((({resubmitPrompt:i,onFocus:K,onBlur:W,onInputHeightChange:F,initSmitheryAuthData:H},J)=>{var M,z,G;const{origin:q,pickaxeId:Q,sessionId:Y,sender:Z,senderType:ee,portalId:te,deploymentId:ne,deploymentType:se,pickaxe:oe,styles:ie,colors:re,translations:ae,locale:le,forceMobile:ce,isNewChat:de,isRtl:ue,isShowFeedbackMessage:pe,accessGroup:me,setIsNewChat:fe,setIsShowIceBreaker:ge,setValidationStatus:he,setValidationUpgradeGroups:ve,setValidationUpgradeUrl:be,onGenerateComplete:ye}=p(),{token:xe,isLoggedOut:je,isSent:we,isPricingAuth:Oe}=b(),{messages:ke,isGenerating:Ne,setMessages:Se,setStatus:Ce,setLimitData:Ie,setError:Ee}=m(),{documents:_e,isUploading:Te,documentError:Ae,onFileUpload:Pe,setDocuments:De,setDocumentError:Re}=y(),{studio:Le}=V(),{scrollStartSession:Ue,scrollEndSession:$e,scrollToBottom:Be}=x({auto:!0}),{artifacts:Ve,currentPopupType:Xe,setArtifacts:Ke,setCurrentArtifact:We}=j(),{height:Fe}=v(),He=h(),[Je,Me]=r(""),[ze,Ge]=r(!1),[qe,Qe]=r(!1),[Ye,Ze]=r(null),[et,tt]=r(null),[nt,st]=r(!1),ot=a(null),it=a(""),rt=a(null),at=a(null),lt=a(null),ct=a(null),dt=a(null),ut=Math.max(.4*Fe,100),{speechTranscript:pt,isSpeechListening:mt,isSpeechProcessing:ft,isSpeechSupported:gt,onStartListening:ht,onStopListening:vt}=X(),[bt]=O("(max-width: 480px)"),yt=w(),{isHover:xt}=yt,jt=e(yt,["isHover"]),wt=w(),{isHover:Ot}=wt,kt=e(wt,["isHover"]),Nt=w(),{isHover:St}=Nt,Ct=e(Nt,["isHover"]),It=g(),Et=f(),_t="undefined"!=typeof window?window.location.hostname:"",Tt="undefined"!=typeof window?window.location.href:"",At="undefined"!=typeof window&&window.self!==window.top,Pt=_t.includes("pickaxe.co")&&!Tt.includes("https://studio.pickaxe.co/_embed")&&!At,Dt=null===(M=null==oe?void 0:oe.documentuploadtype)||void 0===M?void 0:M.startsWith("enduserupload"),Rt=gt&&(null==oe?void 0:oe.enablevoicetotext),Lt="chat-input"===se&&de&&!we,Ut="chat-input"===se&&Oe&&je&&we,$t=l((e=>{const t=L(e);return!!t&&(Ee(""),Ie(null),he(t.status),ve(t.upgradeGroups),be(t.upgradeUrl),!0)}),[Ee,Ie,he,ve,be]),Bt=null!==(z=null==oe?void 0:oe.placeholdertext)&&void 0!==z?z:ue?"بماذا تريد أن تتحدث؟":(null==ae?void 0:ae["what-do-you-want-to-talk-about"])||"What do you want to talk about?",Vt=ze||qe,Xt=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}),xe&&{studioSessionToken:xe}),!xe&&!Z&&{sender:B()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),Pt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Ze(t.studioUser),tt(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}}))),[q,Q,Y,ee,Z,xe,te,ne,Pt]);c((()=>{Xt()}),[Xt]);const Kt=(null==me?void 0:me.limit)||0,Wt=(null==Ye?void 0:Ye.currentUses)||0,Ft=(null==Ye?void 0:Ye.extraUses)||0,Ht=!!(null==Le?void 0:Le.data.usage)&&Le.data.usage.isCredits,Jt=Kt>Wt?Kt-Wt+Ft:Ft,Mt=d((()=>!!Ye&&(!nt&&(!(Kt<=0)&&Jt<=.05*Kt))),[Ye,nt,Jt,Kt]),zt=d((()=>{var e,t,n;return!!de&&(!!oe&&(!He.isLoading&&(!((null!==(t=null===(e=He.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)&&(!pe&&!Lt)))))}),[oe,de,pe,Lt,He.data,He.isLoading]),Gt=d((()=>{if(Ne||Te)return!1;const e=_e.length>0&&_e.every((e=>"finished"===e.status));return!(!Je.trim()&&!e)&&_e.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Ne,Te,Je,_e]);u(J,(()=>({onSubmit:qt}))),c((()=>{ge(zt)}),[zt]),c((()=>{var e;if(i){const t=Array.from(ke),n=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;qt(n,!0)}}),[i]),c((()=>{if(!ct.current||!F)return;const e=new ResizeObserver((e=>{for(const t of e)F(t.contentRect.height)}));return e.observe(ct.current),()=>{e.disconnect()}}),[F]),c((()=>{if(!mt)return;const e=it.current?`${it.current} `:"";Me(`${e}${pt}`)}),[pt,mt]),c((()=>{if(!at.current)return;(()=>{if(!at.current)return;let e=at.current.scrollHeight>52;Je.includes("\n")||_e.length?e=!0:Je.trim()||(e=!1),Ge(e)})()}),[Je,_e]),c((()=>{const e=at.current,t=lt.current;if(!e||!t||ze||Je.includes("\n"))return void Qe(!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=Je||Bt,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;Qe(i>l)}),[Je,ze,Bt]);const qt=(e,n=!1)=>t(void 0,void 0,void 0,(function*(){var t,s,o;try{if(Ne||Te)return;const i=_e.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=i.map((e=>e.documentId)).filter(Boolean),a=i.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),l=r.length>0,c=null!=e?e:Je;if(!c&&!l)return;Ee(""),Re(""),Ie(null),Me(""),fe(!1),Ce("fetching"),Ue(),Be();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(ke.slice(0,ke.length-1)):Array.from(ke),...n?[]:[{id:ke.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:d?r:[]}],{id:ke.length+(n?0:2),role:"assistant",parts:[],documentIds:[]}];Se(u),Be(),d&&De([]);const p=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:q,pickaxeId:Q,sessionId:Y,senderType:ee,value:c},d&&{documentIds:r}),Z&&{sender:Z}),xe&&{studioSessionToken:xe}),!xe&&!Z&&{sender:B()}),te&&{portalId:te}),ne&&{deploymentId:ne}),a.length>0&&{uploadedModelImages:a})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},Pt&&{credentials:"include"})),m=yield p.json();if(!m.success){if($t(m))return;const e=new Error(m.error||m.message||(null==ae?void 0:ae["failed-to-start-generation"])||"Failed to start generation");throw m.limitData&&(e.limitData=m.limitData),e}const f=m.submissionId;Ce("streaming"),dt.current=new AbortController;const g=u.length-1,h=[];let v=[...null!=Ve?Ve:[]],b=0,y=!1,x="";for(;!y;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API_URL}/stream/${f}?index=${b}`,{signal:null===(o=dt.current)||void 0===o?void 0:o.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();rt.current=t;const 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),n=t.error||t.message||(null==ae?void 0:ae["something-went-wrong"])||"Something went wrong.";return $t(t)||Ee(n),void(y=!0)}if("delta"===e.event){const s=JSON.parse(e.data);if("data-error"===s.type&&H){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,H({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,H({smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===s.type)x="",h.push({type:"text",content:"",isVisible:null===(t=s.isVisible)||void 0===t||t});else if("text-delta"===s.type)x+=s.delta,h[h.length-1].content=x;else if("text-end"===s.type)x="";else if("reasoning-start"===s.type)x="",h.push({type:"reasoning",content:"",isVisible:null===(n=s.isVisible)||void 0===n||n});else if("reasoning-delta"===s.type)x+=s.delta,h[h.length-1].content=x;else if("reasoning-end"===s.type)x="";else if(s.type.startsWith("data-")){const e=s;h.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Se([...u.slice(0,g),Object.assign(Object.assign({},u[u.length-1]),{id:ke.length+1,role:"assistant",parts:h})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ke([...v]),Xe.startsWith("inline")||We({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Ke(v),Xe.startsWith("inline")||We({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);v=v.filter((e=>!(e.id===t.id&&e.version===t.version))),v.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Ke(v),Xe.startsWith("inline")||We({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),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)),Ke(v)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Ke(v.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data),n=t.error||t.message||(null==ae?void 0:ae["something-went-wrong-try-again"])||"Something went wrong, please try again.";if($t(t))return void(y=!0);Ee(n)}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==ye||ye(Y)}catch(e){if(e.limitData)Ie(e.limitData),Ee("");else{let t=R(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==ae?void 0:ae["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),$t(t)||Ee(t)}}finally{Be(),Ce("idle"),$e(),rt.current=null,yield Xt()}}));return Ut?null:n("div",Object.assign({className:U("flex w-full flex-shrink-0 flex-col items-center",!Lt&&"px-4 pb-8"),dir:ue?"rtl":"ltr"},{children:s("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[s("div",Object.assign({ref:ct,className:U("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ie.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Et),{maxHeight:`${ut}px`,overflowY:"auto"})},{children:[Mt&&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:Et.backgroundColor?`${Et.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:[Jt," ",Ht?(null==ae?void 0:ae.credits)||"Credits":(null==ae?void 0:ae.uses)||"Uses"," ",(null==ae?void 0:ae.remaining)||"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=`${et}${null==me?void 0:me.accessGroupId}`;$()?window.open(t):location.href=t}},{children:(null==ae?void 0:ae.upgrade)||"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:()=>st(!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"})}))}))]}))]})),!Ne&&_e.length>0&&n(A,{className:"p-4 pb-0",isDisabled:Ne}),s("div",Object.assign({className:"relative flex w-full flex-col"},{children:[mt&&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:(null==ae?void 0:ae.listening)||"Listening..."}))]})),n(P,Object.assign({ref:at,className:U(It.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Je.trim()&&!Je.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",ue?"text-right":"text-left",Vt&&"mb-12",mt&&"text-transparent"),value:Je,placeholder:Bt,onChange:e=>{if(Me(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=>{ce||bt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Te||Ne||qt()))},onPaste:e=>t(void 0,void 0,void 0,(function*(){const t=Array.from(e.clipboardData.files||[]);t.length>0&&(e.preventDefault(),fe(!1),yield Pe(t))}))},K&&{onFocus:K},W&&{onBlur:W},{dir:ue?"rtl":"ltr"})),n("div",Object.assign({ref:lt,className:U("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",Vt?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Vt&&Et.backgroundColor&&{backgroundColor:Et.backgroundColor}),{borderTopRightRadius:ie.cornerRadius+"px",borderBottomRightRadius:ie.cornerRadius+"px"})},{children:Ne?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:()=>{dt.current&&(dt.current.abort(),dt.current=null),rt.current&&(rt.current.cancel(),rt.current=null),Ce("idle")},style:{backgroundColor:re.accent,color:re.accentText}},{children:n(T,{className:"h-4 w-4 shrink-0"})})):mt?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:vt,style:{backgroundColor:re.accent,color:re.accentText}},{children:n(T,{className:"h-4 w-4 shrink-0"})})):s(o,{children:[Dt&&s("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ot?re.accent+"10":void 0,color:Ot?re.accent:re.accent+"80"},disabled:Te||Ne,onClick:()=>{var e;return null===(e=ot.current)||void 0===e?void 0:e.click()}},kt,{children:[n("input",{id:"file-upload",ref:ot,type:"file",accept:[...k,...N,...S].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){fe(!1),yield Pe(Array.from(e.target.files||[])),e.target.value=""}))}),n(I,{className:"h-6 w-6 shrink-0"})]})),Rt&&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:mt?re.accent:St?re.accent+"10":void 0,color:mt?re.accentText:St?re.accent:re.accent+"80"},disabled:Te||Ne||ft,onClick:()=>{mt?vt():(it.current=Je,ht(le||"en-US"))}},Ct,{children:n(_,{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:xt||Gt?re.accent:re.accent+"10",color:xt||Gt?re.accentText:re.accent+"80"},disabled:!Gt,onClick:()=>qt()},jt,{children:n(E,{className:U("h-6 w-6 shrink-0",ue&&"scale-x-[-1] transform")})}))]})}))]}))]})),Ae&&n(D,{error:Ae,className:"mt-3"})]}))}))}));K.displayName="Input";export{K as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as i}from"react/jsx-runtime";import{useState as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as i}from"react/jsx-runtime";import{useState as n,useRef as r,useEffect as s,useCallback as a}from"react";import{usePickaxeContext as l}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as c}from"../Addons/Auth/hooks/useAuthContext.js";import{useDimensionContext as d}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as m}from"../Addons/Document/hooks/useDocument.js";import{useStyleFontSize as u}from"../../../hooks/studio/useStyleFontSize.js";import p from"./History/index.js";import f from"./Input.js";import h from"../../Icons/attach-vertical.svg.js";import v from"../../../common/cn.js";import g from"../../../common/api/pickaxe.js";import{v4 as x}from"uuid";import{StudioTip as b}from"../../Core/StudioTip.js";import{useResponseContext as k}from"../../../hooks/pickaxe/useResponseContext.js";import{NavPill as y,EditableNavPill as j,HistoryPill as I}from"../Addons/Navbar/NavPill.js";import w from"../../Icons/history.svg.js";const D=()=>{const{deploymentType:D,isNewChat:N,setIsNewChat:C,sessionId:A,setSessionId:F,setLastSessionId:S,pickaxeId:T,sender:O,pickaxe:P,styles:_,isEmbed:z,translations:E}=l(),{isSent:H}=c(),{width:R,height:G,setDimension:L}=d(),{setDocuments:B,onFileUpload:U}=m(),{isGenerating:q,messages:J}=k(),K=u(),[M,Q]=n(0),[V,W]=n(!1),[X,Y]=n(!1),Z=r(null),$=r(null),ee=r(0),[te,oe]=n(null),[ie,ne]=n(!1),re=(null==E?void 0:E["new-chat"])||"New chat",se="chat-input"===D&&N&&!H;s((()=>()=>{B([])}),[]);const ae=a((()=>{if(!T||!O)return;const t=(o=0)=>e(void 0,void 0,void 0,(function*(){var e;try{const t=yield g.post("/get_pickaxe_conversation",{sessionId:A,userId:O});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void ce(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}o<20&&setTimeout((()=>t(o+1)),3e3)}));t()}),[T,O,A]);s((()=>{q||N||!A||ae()}),[q,N,A,ae]),s((()=>{if(!Z.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;L(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(Z.current),()=>{e.disconnect()}}),[Z.current]);const[le,ce]=n(re),de=(null==P?void 0:P.formtitle)||"Pickaxe",me=(null==P?void 0:P.coverphoto)||void 0,[ue,pe]=n(!1);s((()=>{const e=!se&&!z&&_.portalTheme&&(J.filter((e=>"user"===e.role)).length>0||V||!N);pe(null!=e&&e)}),[J,V,N]);return t("div",Object.assign({ref:Z,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),ee.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&Y(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),ee.current-=1,0===ee.current&&Y(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),Y(!1),ee.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(C(!1),yield U(e))}))},{children:[X&&t("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[o("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:o(h,{className:"h-10 w-10"})})),o("h3",Object.assign({className:v(K.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==E?void 0:E["drop-files-to-upload"])||"Drop files to upload"})),o("p",Object.assign({className:v(K.b2,"mt-2 opacity-60 text-black")},{children:(null==E?void 0:E["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),se?o(f,{}):t(i,{children:[ue&&t("div",Object.assign({className:v("direct-link"===D?"absolute top-4 left-4 md:top-6 md:left-6 z-40 flex items-center gap-2 animate-in fade-in slide-in-from-top-4 duration-500":"w-full max-w-3xl mt-6 px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500 gap-2","dark"===_.portalTheme?"glass-dark ":"")},{children:[o(y,{text:de,icon:me}),N||le===re?o(y,{text:le}):o(j,{text:le,sessionId:A,onRename:t=>e(void 0,void 0,void 0,(function*(){if(A)try{yield g.post("/edit_conversation_name",{sessionId:A,name:t,userId:O}),ce(t)}catch(e){console.error("Error renaming chat:",e),alert((null==E?void 0:E["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e(void 0,void 0,void 0,(function*(){if(A&&window.confirm((null==E?void 0:E["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield g.post("/delete_pickaxe_conversation",{sessionId:A,userId:O}),C(!0),F(x()),ce(re)}catch(e){console.error("Error deleting chat:",e),alert((null==E?void 0:E["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===_.portalTheme}),o(b,Object.assign({content:E["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:o(I,{icon:o(w,{}),onClick:()=>{F(""),S(A)}})}))]})),o(p,{additionalScrollHeight:M,isForceHideInfo:G<=545||R<=350||V,isInputFocused:V,onSubmit:t=>e(void 0,void 0,void 0,(function*(){$.current&&$.current.onSubmit(t)})),smitheryAuthData:te,resubmitPrompt:()=>{oe(null),ne(!0)}}),o(f,{ref:$,onFocus:()=>W(!0),onBlur:()=>W(!1),onInputHeightChange:Q,initSmitheryAuthData:e=>oe(e),resubmitPrompt:ie})]})]}))};export{D as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as s,jsx as t,Fragment as o}from"react/jsx-runtime";import{useState as n,useRef as a,useEffect as i,useMemo as r}from"react";import{usePickaxeContext as l}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{format as m}from"date-fns";import p from"../../../../common/api/pickaxe.js";import{Check as u,X as h,MoreHorizontal as b,Pencil as f}from"lucide-react";import g from"../../../Icons/trash-2.svg.js";import
|
|
1
|
+
import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as s,jsx as t,Fragment as o}from"react/jsx-runtime";import{useState as n,useRef as a,useEffect as i,useMemo as r}from"react";import{usePickaxeContext as l}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{format as m}from"date-fns";import p from"../../../../common/api/pickaxe.js";import{Check as u,X as h,MoreHorizontal as b,Pencil as f}from"lucide-react";import g from"../../../Icons/trash-2.svg.js";import v from"../../../Icons/chat.svg.js";import y from"../../../Icons/copy.svg.js";import x from"../../../Icons/copied.svg.js";import j from"../../../Icons/expand.svg.js";import w from"../../../Icons/collapse.svg.js";import{PickaxeMarkdown as k}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as N}from"../../common/PickaxeMarkdown/Renderer.js";import C from"../../../../common/cn.js";const O=({item:O,onDelete:_})=>{const{pickaxe:I,sender:P,colors:M,translations:R,styles:D,isRtl:E,disableCss:T,disableHtml:q,disableJs:F,setSessionId:S,setIsNewChat:$}=l(),{setMessages:A}=c(),{setDocuments:H}=d(),[J,z]=n(!1),[L,B]=n(!1),[K,G]=n(!1),[Q,U]=n(!1),[V,W]=n(!1),X=a(null),[Y,Z]=n(O.shortSummary||O.summary||(null==R?void 0:R["conversation-name"])||"Conversation name"),[ee,se]=n("");i((()=>{Z(O.shortSummary||O.summary||(null==R?void 0:R["conversation-name"])||"Conversation name")}),[O.shortSummary,O.summary,R]),i((()=>{const e=e=>{X.current&&!X.current.contains(e.target)&&z(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const te=r((()=>O?"FORM"===O.pickaxeType&&0===O.messages.length?O.question.responseParts?O.question.responseParts.length:0:O.messages.length:0),[O]),oe=r((()=>m(new Date(O.updatedAt),"MMM dd, yyy hh:mm a")),[O]),ne=r((()=>{var e;const s=(null==R?void 0:R["not-available"])||"n/a";if("FORM"===O.pickaxeType){if(O.messages&&0!==O.messages.length){const e=O.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const t=null!==(e=O.question.inputs)&&void 0!==e?e:[];return V?t.map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 600; opacity: 0.9;">${e.question}</p>\n <p style="opacity: 0.8;">${e.answer||s}</p>\n</div>`)).join(""):t.map((e=>`${e.question}: ${e.answer||s}`)).join(" | ")}const t=O.messages.find((e=>"user"===e.role));return t?t.parts[0].content:""}),[O,V,R]),ae=r((()=>{if("FORM"===O.pickaxeType){if(O.messages&&0!==O.messages.length){const e=O.messages.find((e=>"assistant"===e.role));return e?e.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" "):""}return O.question.responseParts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")}const e=O.messages.find((e=>"assistant"===e.role));return e?e.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" "):""}),[O]),ie=()=>{B(!1),se("")},re=()=>e(void 0,void 0,void 0,(function*(){if(ee.trim()){G(!0);try{yield p.post("/edit_conversation_name",{sessionId:O.sessionId,name:ee,userId:P}),Z(ee),B(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==R?void 0:R["failed-update-name"])||"Failed to update name.")}finally{G(!1)}}}));return s("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:M.secondary,borderRadius:D.cornerRadius}},{children:[t("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:M.primary,color:M.text}},{children:L?s("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[t("input",{autoFocus:!0,type:"text",value:ee,onChange:e=>se(e.target.value),onKeyDown:e=>{"Enter"===e.key&&re(),"Escape"===e.key&&ie()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:M.primary,borderColor:M.secondary}}),t("button",Object.assign({onClick:re,disabled:K,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==R?void 0:R.save)||"Save"},{children:t(u,{className:"h-4 w-4"})})),t("button",Object.assign({onClick:ie,disabled:K,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==R?void 0:R.cancel)||"Cancel"},{children:t(h,{className:"h-4 w-4"})}))]})):s(o,{children:[t("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:Y})),s("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[t("button",Object.assign({onClick:e=>{e.stopPropagation(),W(!V)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:V?(null==R?void 0:R.collapse)||"Collapse":(null==R?void 0:R.expand)||"Expand"},{children:t(V?w:j,{className:"h-4 w-4"})})),s("div",Object.assign({className:"relative"},{children:[t("button",Object.assign({onClick:e=>{e.stopPropagation(),z(!J)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:t(b,{className:"h-6 w-6"})})),J&&s("div",Object.assign({ref:X,className:"absolute right-0 top-8 w-48 rounded-xl shadow-xl z-40 border overflow-hidden animate-in fade-in zoom-in-95 duration-100",style:{backgroundColor:M.secondary,color:M.secondaryText,borderColor:M.primary}},{children:[s("button",Object.assign({onClick:e=>{e.stopPropagation(),se(Y),B(!0),z(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:M.primary}},{children:[t(f,{className:"h-4 w-4"}),t("span",Object.assign({className:"font-medium text-sm"},{children:(null==R?void 0:R["rename-chat"])||"Rename chat"}))]})),s("button",Object.assign({onClick:s=>{s.stopPropagation(),e(void 0,void 0,void 0,(function*(){if(window.confirm((null==R?void 0:R["delete-confirm"])||"Are you sure you want to delete this conversation?")){z(!1);try{yield p.post("/delete_pickaxe_conversation",{sessionId:O.sessionId,userId:P}),_&&_(O.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==R?void 0:R["failed-delete-conversation"])||"Failed to delete conversation.")}}}))},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95"},{children:[t(g,{className:"h-4 w-4"}),t("span",Object.assign({className:"font-medium text-sm"},{children:(null==R?void 0:R["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s("div",Object.assign({className:C("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",V?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:M.secondary,color:M.secondaryText}},{children:[s("div",Object.assign({className:"flex flex-col"},{children:[t("div",Object.assign({className:C("w-full",V?"mb-0":"mb-2")},{children:t(k,Object.assign({theme:D.theme,colors:M},E&&{rtl:!0},q&&{disableHtml:!0},F&&{disableJs:!0},T&&{disableCss:!0},{children:t(N,{style:{display:"block"},className:C("w-full",!V&&["[&_*]:!font-semibold mb-0.5 h-5 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],V&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:ne})}))})),t("div",Object.assign({className:"w-full"},{children:t(k,Object.assign({theme:D.theme,colors:M},E&&{rtl:!0},q&&{disableHtml:!0},F&&{disableJs:!0},T&&{disableCss:!0},{children:t(N,{style:{display:"block"},className:C("w-full text-sm",!V&&["font-normal h-5 opacity-80 truncate [&_p]:inline [&_p]:m-0","[&_*]:!inline","[&_*]:!m-0 [&_*]:!p-0","[&_*]:!text-sm","[&_*]:!leading-none","[&_img]:hidden [&_hr]:hidden [&_br]:hidden"],V&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:ae})}))}))]})),s("div",Object.assign({className:"flex items-center justify-between mt-4 pt-2 border-t border-transparent"},{children:[s("div",Object.assign({className:"flex items-center gap-4"},{children:[((null==I?void 0:I.chatflag)||!(null==I?void 0:I.chatflag)&&(null==I?void 0:I.enablechatresponses))&&s("div",Object.assign({className:"flex items-center gap-1.5 opacity-70 hover:opacity-100 cursor-pointer transition-opacity",onClick:e=>{var s;e.stopPropagation(),s=O.sessionId,H([]),A([]),$(!1),S(s)},title:(null==R?void 0:R["open-chat"])||"Open Chat"},{children:[t(v,{className:"h-4 w-4"}),t("span",Object.assign({className:"text-sm font-medium"},{children:te}))]})),t("button",Object.assign({className:"transition-colors "+(Q?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(ae),U(!0),setTimeout((()=>{U(!1)}),2e3)},title:Q?(null==R?void 0:R.copied)||"Copied!":(null==R?void 0:R["copy-assistant-message"])||"Copy assistant message"},{children:Q?t(x,{className:"h-4 w-4",style:{color:M.accent},fill:M.accent}):t(y,{className:"h-4 w-4"})}))]})),t("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:oe}))]}))]}))]}))};export{O as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useScrollContext as a}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useDocument as l}from"../../Addons/Document/hooks/useDocument.js";import{useArtifact as r}from"../../Addons/Artifact/hooks/useArtifact.js";import{PickaxeMarkdown as c}from"../../common/PickaxeMarkdown/index.js";import{format as d}from"date-fns";import m from"../../common/PickaxeIcon.js";import p from"../../Addons/Scroll/ScrollLockView.js";import h from"../../common/PickaxeMessageParts/index.js";import f from"../../common/PickaxeMessageActions.js";import u from"../../../../common/cn.js";const x=()=>{var x;const{pickaxe:b,styles:g,colors:
|
|
1
|
+
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useScrollContext as a}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useDocument as l}from"../../Addons/Document/hooks/useDocument.js";import{useArtifact as r}from"../../Addons/Artifact/hooks/useArtifact.js";import{PickaxeMarkdown as c}from"../../common/PickaxeMarkdown/index.js";import{format as d}from"date-fns";import m from"../../common/PickaxeIcon.js";import p from"../../Addons/Scroll/ScrollLockView.js";import h from"../../common/PickaxeMessageParts/index.js";import f from"../../common/PickaxeMessageActions.js";import u from"../../../../common/cn.js";const x=()=>{var x;const{pickaxe:b,styles:g,colors:v,misc:j,translations:y,disableHtml:k,disableJs:w,disableCss:N,isRtl:C,setSessionId:O,setIsNewChat:I}=t(),{response:A,isGenerating:S}=i(),{scrollTargetRef:D}=a(),{setDocuments:P}=l(),{onLoadArtifact:M}=r(),$=n(),R=o((()=>d(A?A.sentAt:new Date,"hh:mm a MMM dd, yy")),[A]),T=o((()=>{var e;if(!A)return"";const s=(null==y?void 0:y["not-available"])||"n/a";return(null!==(e=A.question.inputs)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||s}</p>\n</div>`)).join("")}),[A,y]);return A?e("div",Object.assign({ref:D,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[s("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:v.primary,color:v.text}},{children:e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[s("input",{id:`${A.sessionId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:T.length<280}),s("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:T}}),s("label",Object.assign({htmlFor:`${A.sessionId}-input`,className:u($.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:v.accent}},{children:(null==y?void 0:y["see-input"])||"See input"})),s("label",Object.assign({htmlFor:`${A.sessionId}-input`,className:u($.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:v.accent}},{children:(null==y?void 0:y["hide-input"])||"Hide input"}))]}))})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:v.secondary,color:v.secondaryText}},{children:[j.isChatImage&&s(m,{src:null==b?void 0:b.chaticon,alt:`${null==b?void 0:b.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:v.secondaryText}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2"},{children:[s(c,Object.assign({theme:g.theme,colors:v},C&&{rtl:!0},k&&{disableHtml:!0},w&&{disableJs:!0},N&&{disableCss:!0},{disableReasoning:null!==(x=null==b?void 0:b.enablereasoningdisplay)&&void 0!==x&&x,onArtifactClick:M},{children:s(h,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",parts:A.question.responseParts})})),s("div",Object.assign({className:"flex flex-col"},{children:S?s("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((e,o)=>s("div",{className:u("h-1.5 w-1.5 animate-dot rounded-full",1===o&&"animate-dot-down"),style:{backgroundColor:v.secondaryText}},o)))})):e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[s("div",Object.assign({className:"flex items-center gap-3"},{children:s(f,{content:A.question.responseParts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),sessionId:A.sessionId,messagesCount:A.messageCount+1,onOpenChat:()=>{return e=A.sessionId,P([]),I(!1),void O(e);var e},isReadOut:!1})})),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:u($.b3,"font-semibold uppercase opacity-30")},{children:R}))}))]}))}))]}))]})),s(p,{})]})):null};export{x as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useRef as s,useMemo as i,useState as n}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as o}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as c}from"../../../../hooks/studio/useStyleFontSize.js";import a from"../../../Icons/check.svg.js";import l from"./Dropdown.js";import d from"../../../../common/cn.js";const p=({field:p,update:u})=>{const{colors:m,isRtl:b,translations:f}=r(),{setError:h}=o(),g=c(),j=s(null),x=i((()=>p.example.split("S3P32X")),[p.example]),y=i((()=>p.input?p.input.split(","):[]),[p.input]),[O,v]=n((()=>{const e=x.includes(p.input);return p.allowOther&&p.input&&!e?p.input:""}));return e("div",Object.assign({className:"flex flex-col gap-y-3",dir:b?"rtl":"ltr"},{children:[e("div",Object.assign({className:"flex items-center gap-1"},{children:[t("p",Object.assign({className:d(g.b3,"font-semibold opacity-70")},{children:p.main})),p.isRequired&&t("span",Object.assign({className:"select-none font-semibold",style:{color:m.error}},{children:"*"}))]})),t(l,Object.assign({id:p.id.replace(/[^A-Za-z]+/g,""),value:p.input.replace(/,/g,", "),placeholder:"Select option(s)",closeOnSelect:!1,maxToken:p.maxLength,isDropdown:p.isDropdown},{children:e("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:[x.map(((s,i)=>e("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{h("");const t=y.includes(e),s=p.input?p.input.split(","):[],i=new Set(s);t&&i.has(e)?i.delete(e):t||i.has(e)||i.add(e);const n=Array.from(i).filter((e=>""!==e.trim()));u(Object.assign(Object.assign({},p),{input:n.join(",")}))})(s)},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:y.includes(s)?m.accent:m.accent+"80"},y.includes(s)&&{backgroundColor:m.accent})},{children:t(a,{className:d("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",y.includes(s)&&"opacity-100"),style:{color:m.accentText}})})),t("p",Object.assign({className:d(g.b2,"select-none")},{children:s}))]}),i))),p.allowOther&&e("div",Object.assign({className:"flex w-full items-center gap-x-3 hover:cursor-pointer",onClick:()=>{h("");const e=y.includes(O.trim()),t=p.input?p.input.split(","):[],s=Array.from(new Set(t)).filter((e=>""!==e.trim()&&x.includes(e)));e||s.push(O.trim()),u(Object.assign(Object.assign({},p),{input:s.join(",")})),setTimeout((()=>{var e;return null===(e=j.current)||void 0===e?void 0:e.focus()}),0)}},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:y.includes(O)?m.accent:m.accent+"80"},y.includes(O)&&{backgroundColor:m.accent})},{children:t(a,{className:d("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",y.includes(O)&&"opacity-100"),style:{color:m.accentText}})})),e("div",Object.assign({className:"flex flex-1 items-center gap-2"},{children:[e("p",Object.assign({className:d(g.b2,"select-none opacity-80 min-w-fit")},{children:[(null==f?void 0:f.other)||"Other",":"]})),t("input",{ref:j,type:"text",className:d(g.b2,"flex-1 bg-transparent border-b outline-none w-full pb-0.5 transition-colors duration-200","cursor-text"),style:{borderColor:y.includes(O)?m.accent:"rgba(0,0,0,0.2)"},value:O,onChange:e=>(e=>{h(""),v(e);const t=y.includes(e.trim()),s=p.input?p.input.split(","):[],i=new Set(s.filter((e=>x.includes(e))));t?i.delete(e.trim()):i.add(e.trim());const n=Array.from(i).filter((e=>""!==e.trim()));u(Object.assign(Object.assign({},p),{input:n.join(",")}))})(e.target.value),placeholder:"Type your answer..."})]}))]}))]}))}))]}))};export{p as default};
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useRef as s,useMemo as i,useState as n}from"react";import{usePickaxeContext as r}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as o}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as c}from"../../../../hooks/studio/useStyleFontSize.js";import a from"../../../Icons/check.svg.js";import l from"./Dropdown.js";import d from"../../../../common/cn.js";const p=({field:p,update:u})=>{const{colors:m,isRtl:b,translations:f}=r(),{setError:h}=o(),g=c(),j=s(null),x=i((()=>p.example.split("S3P32X")),[p.example]),y=i((()=>p.input?p.input.split(","):[]),[p.input]),[O,v]=n((()=>{const e=x.includes(p.input);return p.allowOther&&p.input&&!e?p.input:""}));return e("div",Object.assign({className:"flex flex-col gap-y-3",dir:b?"rtl":"ltr"},{children:[e("div",Object.assign({className:"flex items-center gap-1"},{children:[t("p",Object.assign({className:d(g.b3,"font-semibold opacity-70")},{children:p.main})),p.isRequired&&t("span",Object.assign({className:"select-none font-semibold",style:{color:m.error}},{children:"*"}))]})),t(l,Object.assign({id:p.id.replace(/[^A-Za-z]+/g,""),value:p.input.replace(/,/g,", "),placeholder:(null==f?void 0:f["select-options"])||"Select option(s)",closeOnSelect:!1,maxToken:p.maxLength,isDropdown:p.isDropdown},{children:e("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:[x.map(((s,i)=>e("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{h("");const t=y.includes(e),s=p.input?p.input.split(","):[],i=new Set(s);t&&i.has(e)?i.delete(e):t||i.has(e)||i.add(e);const n=Array.from(i).filter((e=>""!==e.trim()));u(Object.assign(Object.assign({},p),{input:n.join(",")}))})(s)},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:y.includes(s)?m.accent:m.accent+"80"},y.includes(s)&&{backgroundColor:m.accent})},{children:t(a,{className:d("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",y.includes(s)&&"opacity-100"),style:{color:m.accentText}})})),t("p",Object.assign({className:d(g.b2,"select-none")},{children:s}))]}),i))),p.allowOther&&e("div",Object.assign({className:"flex w-full items-center gap-x-3 hover:cursor-pointer",onClick:()=>{h("");const e=y.includes(O.trim()),t=p.input?p.input.split(","):[],s=Array.from(new Set(t)).filter((e=>""!==e.trim()&&x.includes(e)));e||s.push(O.trim()),u(Object.assign(Object.assign({},p),{input:s.join(",")})),setTimeout((()=>{var e;return null===(e=j.current)||void 0===e?void 0:e.focus()}),0)}},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:y.includes(O)?m.accent:m.accent+"80"},y.includes(O)&&{backgroundColor:m.accent})},{children:t(a,{className:d("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",y.includes(O)&&"opacity-100"),style:{color:m.accentText}})})),e("div",Object.assign({className:"flex flex-1 items-center gap-2"},{children:[e("p",Object.assign({className:d(g.b2,"select-none opacity-80 min-w-fit")},{children:[(null==f?void 0:f.other)||"Other",":"]})),t("input",{ref:j,type:"text",className:d(g.b2,"flex-1 bg-transparent border-b outline-none w-full pb-0.5 transition-colors duration-200","cursor-text"),style:{borderColor:y.includes(O)?m.accent:"rgba(0,0,0,0.2)"},value:O,onChange:e=>(e=>{h(""),v(e);const t=y.includes(e.trim()),s=p.input?p.input.split(","):[],i=new Set(s.filter((e=>x.includes(e))));t?i.delete(e.trim()):i.add(e.trim());const n=Array.from(i).filter((e=>""!==e.trim()));u(Object.assign(Object.assign({},p),{input:n.join(",")}))})(e.target.value),placeholder:(null==f?void 0:f["type-your-answer"])||"Type your answer..."})]}))]}))]}))}))]}))};export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__awaiter as t}from"../../../../_virtual/_tslib.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as n,useRef as i,useEffect as r}from"react";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as l}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as p}from"../../../../hooks/studio/useStyleFontSize.js";import{useHover as d}from"../../../../hooks/core/useHover.js";import{useSpeech as m}from"../../../../hooks/pickaxe/useSpeech.js";import u from"../../../Core/Textarea.js";import h from"../../../Icons/microphone.svg.js";import g from"../../../Icons/stop.svg.js";import f from"../../../../common/cn.js";const b=({field:b,update:
|
|
1
|
+
import{__rest as e,__awaiter as t}from"../../../../_virtual/_tslib.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as n,useRef as i,useEffect as r}from"react";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as l}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as p}from"../../../../hooks/studio/useStyleFontSize.js";import{useHover as d}from"../../../../hooks/core/useHover.js";import{useSpeech as m}from"../../../../hooks/pickaxe/useSpeech.js";import u from"../../../Core/Textarea.js";import h from"../../../Icons/microphone.svg.js";import g from"../../../Icons/stop.svg.js";import f from"../../../../common/cn.js";const b=({field:b,update:v,activeVoiceId:x,setActiveVoiceId:j})=>{var y;const{styles:k,colors:N,isRtl:O,pickaxe:w,locale:S,translations:C}=a(),{setError:L}=c(),[I,T]=n(!1),R=p(),z=l(),{speechTranscript:F,isSpeechListening:H,isSpeechProcessing:P,isSpeechSupported:$,onStartListening:B,onStopListening:D}=m(),V=i(""),_=d(),{isHover:q}=_,A=e(_,["isHover"]),E=$&&(null==w?void 0:w.enablevoicetotext),U=H&&x===b.id,Y=e=>{L("");const t=e.length;v(Object.assign(Object.assign({},b),{input:e,length:t}))};return r((()=>{if(!H||x!==b.id)return;const e=V.current?`${V.current} `:"";Y(`${e}${F}`)}),[F,H,x,b.id]),o("div",Object.assign({className:"group relative flex flex-col gap-y-1",dir:O?"rtl":"ltr"},{children:[o("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[o("div",Object.assign({className:"flex items-center gap-1"},{children:[s("p",Object.assign({className:f(R.b3,"font-semibold opacity-70")},{children:b.main})),b.isRequired&&s("span",Object.assign({className:"select-none font-semibold",style:{color:N.accent}},{children:"*"}))]})),o("div",Object.assign({className:"relative w-full"},{children:[U&&o("div",Object.assign({className:f("absolute top-3.5 z-10 flex select-none items-center gap-x-2 pointer-events-none",O?"right-4":"left-4")},{children:[s("span",{className:"h-2 w-2 animate-pulse rounded-full",style:{backgroundColor:null!==(y=N.accent)&&void 0!==y?y:"#ff0000"}}),s("span",Object.assign({className:"text-sm font-semilight",style:{color:N.text+"90"}},{children:(null==C?void 0:C.listening)||"Listening..."}))]})),s(u,{className:f(R.i1,"rounded-sm border border-transparent py-3 duration-300 ease-in-out transition-all placeholder:font-semilight w-full",O?E?"pl-10 pr-4":"px-4":E?"pl-4 pr-10":"px-4",b.maxLength<10&&"max-w-[400px]","block"===k.formFieldStyle&&"shadow hover:shadow-none",U&&"caret-transparent"),style:Object.assign(Object.assign({},z),U&&{color:"transparent"}),placeholder:U?"":b.placeholder,rows:1,value:b.input,tabIndex:b.order,onChange:Y,onFocus:()=>T(!0),onBlur:()=>T(!1),onPaste:e=>{if(e.clipboardData.getData("text").length<1e3)return;const t=e.target;setTimeout((()=>{const e=t.getBoundingClientRect().bottom+window.scrollY;window.scrollTo({top:e,behavior:"smooth"})}),250)}}),E&&s("div",Object.assign({className:f("absolute top-2 z-20",O?"left-2":"right-2")},{children:s("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:U?N.accent:q?N.accent+"10":void 0,color:U?N.accentText:q?N.accent:N.accent+"80"},disabled:P,onClick:()=>t(void 0,void 0,void 0,(function*(){H?(yield D(),j(b.id)):(j(b.id),V.current=b.input||"",yield B(S||"en-US"),T(!0))}))},A,{type:"button"},{children:U?s(g,{className:"h-4 w-4 shrink-0"}):s(h,{className:"h-5 w-5 shrink-0"})}))}))]}))]})),s("div",Object.assign({className:"pointer-events-none absolute bottom-0 right-0 p-1 px-2"},{children:o("p",Object.assign({className:f(R.b4,"font-semibold opacity-20 opacity-0 group-hover:opacity-100 group-hover:duration-200",b.length>b.maxLength&&"text-c-red opacity-100",I&&"opacity-100")},{children:[b.length,"/",b.maxLength]}))}))]}))};export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{usePickaxeContext as
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{usePickaxeContext as n}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as s}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as i}from"../../../../hooks/studio/useStyleFontSize.js";import{useRef as o,useMemo as r,useState as a}from"react";import c from"./Dropdown.js";import l from"../../../../common/cn.js";const p=({field:p,update:u})=>{const{colors:d,isRtl:m,translations:b}=n(),{setError:g}=s(),h=i(),f=o(null),x=r((()=>p.example.split("S3P32X")),[p.example]),[j,O]=a((()=>{const e=x.includes(p.input);return p.allowOther&&p.input&&!e?p.input:""})),y=r((()=>!!p.allowOther&&(!x.includes(p.input)&&""!==p.input)),[p.allowOther,p.input,x]);return e("div",Object.assign({className:"flex flex-col gap-y-3",dir:m?"rtl":"ltr"},{children:[e("div",Object.assign({className:"flex items-center gap-1"},{children:[t("p",Object.assign({className:l(h.b3,"font-semibold opacity-70")},{children:p.main})),p.isRequired&&t("span",Object.assign({className:"select-none font-semibold",style:{color:d.error}},{children:"*"}))]})),t(c,Object.assign({id:p.id.replace(/[^A-Za-z]+/g,""),value:p.input,placeholder:(null==b?void 0:b["select-an-option"])||"Select an option",closeOnSelect:!1,maxToken:p.maxLength,isDropdown:p.isDropdown},{children:e("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:[x.map(((n,s)=>e("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{g(""),u(Object.assign(Object.assign({},p),{input:e}))})(n)},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2",style:Object.assign({borderColor:p.input===n?d.accent:d.accent+"80"},p.input===n&&{backgroundColor:d.accent})},{children:t("div",{className:l("h-2 w-2 shrink-0 transition-opacity opacity-0 ease-in-out duration-200 rounded-full",p.input===n&&"opacity-100"),style:{backgroundColor:d.accentText}})})),t("p",Object.assign({className:l(h.b2,"select-none")},{children:n}))]}),s))),p.allowOther&&e("div",Object.assign({className:"flex w-full items-center gap-x-3 hover:cursor-pointer",onClick:()=>{g(""),u(Object.assign(Object.assign({},p),{input:j})),setTimeout((()=>{var e;return null===(e=f.current)||void 0===e?void 0:e.focus()}),0)}},{children:[t("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2",style:Object.assign({borderColor:y?d.accent:d.accent+"80"},y&&{backgroundColor:d.accent})},{children:t("div",{className:l("h-2 w-2 shrink-0 transition-opacity opacity-0 ease-in-out duration-200 rounded-full",y&&"opacity-100"),style:{backgroundColor:d.accentText}})})),e("div",Object.assign({className:"flex flex-1 items-center gap-2"},{children:[e("p",Object.assign({className:l(h.b2,"select-none opacity-80 min-w-fit")},{children:[(null==b?void 0:b.other)||"Other",":"]})),t("input",{ref:f,type:"text",className:l(h.b2,"flex-1 bg-transparent border-b outline-none w-full pb-0.5 transition-colors duration-200","cursor-text"),style:{borderColor:y?d.accent:"rgba(0,0,0,0.2)"},value:j,onChange:e=>{return t=e.target.value,g(""),O(t),void u(Object.assign(Object.assign({},p),{input:t}));var t},onFocus:()=>{y||u(Object.assign(Object.assign({},p),{input:j}))},placeholder:(null==b?void 0:b["type-your-answer"])||"Type your answer..."})]}))]}))]}))}))]}))};export{p as default};
|