@pickaxeproject/react 6.23.6 → 6.23.7

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.
Files changed (53) hide show
  1. package/dist/cjs/common/canChat.js +1 -0
  2. package/dist/cjs/components/Pickaxe/Chat/History/Message.js +1 -1
  3. package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
  4. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  5. package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
  6. package/dist/cjs/components/Pickaxe/Form/History/Item.js +1 -1
  7. package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
  8. package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
  9. package/dist/cjs/components/Pickaxe/Provider.js +1 -1
  10. package/dist/cjs/components/Pickaxe/common/PickaxeCopyButton.js +1 -1
  11. package/dist/cjs/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
  12. package/dist/cjs/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
  13. package/dist/cjs/hooks/pickaxe/useConversation.js +1 -1
  14. package/dist/cjs/index.js +1 -1
  15. package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  16. package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  17. package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  18. package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  19. package/dist/cjs/src/common/canChat.d.ts +5 -0
  20. package/dist/cjs/src/components/Pickaxe/Provider.d.ts +16 -2
  21. package/dist/cjs/src/components/Pickaxe/common/PickaxeCopyButton.d.ts +7 -1
  22. package/dist/cjs/src/components/Pickaxe/common/PickaxeDownloadButton.d.ts +10 -1
  23. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageActions.d.ts +5 -1
  24. package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
  25. package/dist/cjs/src/index.d.ts +5 -0
  26. package/dist/cjs/src/types/history.d.ts +3 -0
  27. package/dist/esm/common/canChat.js +1 -0
  28. package/dist/esm/components/Pickaxe/Chat/History/Message.js +1 -1
  29. package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
  30. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  31. package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
  32. package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
  33. package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
  34. package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
  35. package/dist/esm/components/Pickaxe/Provider.js +1 -1
  36. package/dist/esm/components/Pickaxe/common/PickaxeCopyButton.js +1 -1
  37. package/dist/esm/components/Pickaxe/common/PickaxeDownloadButton.js +1 -1
  38. package/dist/esm/components/Pickaxe/common/PickaxeMessageActions.js +1 -1
  39. package/dist/esm/hooks/pickaxe/useConversation.js +1 -1
  40. package/dist/esm/index.js +1 -1
  41. package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  42. package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  43. package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  44. package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  45. package/dist/esm/src/common/canChat.d.ts +5 -0
  46. package/dist/esm/src/components/Pickaxe/Provider.d.ts +16 -2
  47. package/dist/esm/src/components/Pickaxe/common/PickaxeCopyButton.d.ts +7 -1
  48. package/dist/esm/src/components/Pickaxe/common/PickaxeDownloadButton.d.ts +10 -1
  49. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageActions.d.ts +5 -1
  50. package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
  51. package/dist/esm/src/index.d.ts +5 -0
  52. package/dist/esm/src/types/history.d.ts +3 -0
  53. package/package.json +3 -2
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.canChat=e=>Boolean(e&&(e.chatflag||e.enablechatresponses));
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../common/formatUserMessage.js"),t=require("../../common/PickaxeMarkdown/Renderer.js"),a=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../Addons/Artifact/hooks/useArtifact.js"),l=require("../../common/PickaxeMarkdown/index.js"),d=require("../../common/PickaxeIcon.js"),c=require("./Document.js"),m=require("../../common/PickaxeMessageActions.js"),u=require("../../common/PickaxeMessageParts/index.js"),x=require("../../../../common/cn.js"),p=require("../../../../common/isoMap.js"),f=require("franc-min"),j=require("../../common/ComposioConnectView.js"),g=require("../../common/SmitheryConnectView.js"),h=require("../../../../hooks/pickaxe/useTextToSpeech.js");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=v(require("remove-markdown"));exports.default=({index:v,message:k,smitheryData:y,resubmitPrompt:w,isLastMessage:O=!1})=>{var q,N;const{pickaxeId:C,pickaxe:I,styles:P,colors:A,misc:M,responsiveBy:R,disableHtml:S,disableJs:T,disableCss:L,isNewChat:F,isRtl:H}=i.usePickaxeContext(),{isGenerating:J}=o.useResponseContext(),{onLoadArtifact:U}=n.useArtifact(),V=r.useStyleFontSize(),z=null!==(q=null==I?void 0:I.chaticon)&&void 0!==q?q:`https://cdn.mail.studio/chaticons/${C}.png`,B=O&&J,D=null==I?void 0:I.enablereadout,{isLoading:_,isSpeaking:E,speak:G,stop:$}=h.useTextToSpeech(D&&"assistant"===k.role,{provider:null==I?void 0:I.readoutprovider,pickaxeId:C,voiceName:null==I?void 0:I.readoutvoice}),K=()=>{if(_||E)return void $();const e=k.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ");if(!e)return;const s=b.default(e,{stripListLeaders:!0,listUnicodeChar:"",gfm:!0,useImgAltText:!1}),t=f.franc(s),a=p.convertToIso1(t);G(s,a)},Q=!k.parts.some((e=>["text","reasoning","data-action-tool-caption"].includes(e.type)));return"assistant"===k.role?e.jsx("div",Object.assign({className:x.default("flex w-full",H?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:x.default("flex flex-col w-full",0===v&&F&&"viewport"===R&&"min-[767px]:max-w-[80%]",0===v&&F&&"container"===R&&"@[767px]/pickaxe-root:max-w-[80%]")},{children:e.jsxs("div",Object.assign({className:x.default("flex gap-x-3",H&&"flex-row-reverse")},{children:[M.isChatImage&&"NONE"!==z&&e.jsx(d.default,{src:z,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:A.text}),e.jsxs("div",Object.assign({className:x.default("flex flex-col flex-grow",H?"items-end":"items-start")},{children:[e.jsxs("div",Object.assign({className:x.default(V.b2,"chat-message pt-3 w-full",H?"text-right":"text-left")},{children:[e.jsx(l.PickaxeMarkdown,Object.assign({theme:P.theme,colors:A,isStreaming:B},H&&{rtl:!0},S&&{disableHtml:!0},T&&{disableJs:!0},L&&{disableCss:!0},{disableReasoning:null!==(N=null==I?void 0:I.enablereasoningdisplay)&&void 0!==N&&N,onArtifactClick:U},{children:e.jsx(u.default,{parts:k.parts,isStreaming:B})})),O&&y&&w&&("composio"===y.provider?e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(j.default,{serverId:y.serverId,toolkitSlug:y.toolkitSlug||"",name:y.name,resubmitPrompt:()=>w()})})):e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(g.default,{serverId:y.serverId,smitheryId:y.smitheryId||"",name:y.name||y.smitheryId,resubmitPrompt:()=>w()})})))]})),e.jsx("div",Object.assign({className:x.default("flex flex-col gap-6 my-4",Q&&"mt-2")},{children:B?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:x.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:A.secondaryText}},t)))})):e.jsx(m.default,Object.assign({content:k.parts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),index:v},"intromessage"===k.area&&{isHideFeedback:!0},{onReadOut:K,isReadOut:D||!1,isReadOutLoading:_,isReading:E}))}))]}))]}))}))})):"user"===k.role?e.jsx("div",Object.assign({className:x.default("flex w-full",H?"justify-start":"justify-end")},{children:e.jsx("div",Object.assign({className:x.default("flex gap-x-3 max-w-[80%]",H?"pr-9":"pl-9","viewport"===R?H?"min-[767px]:pr-0":"min-[767px]:pl-0":H?"@[767px]/pickaxe-root:pr-0":"@[767px]/pickaxe-root:pl-0")},{children:e.jsxs("div",Object.assign({className:x.default(V.b2,"overflow-x-auto overflow-y-hidden px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B] flex flex-col gap-y-3",H?"text-right":"text-left"),style:{backgroundColor:A.secondary+"80",color:A.secondaryText,borderRadius:P.cornerRadius}},{children:[k.documentIds&&k.documentIds.length>0&&e.jsx("div",Object.assign({className:x.default("flex flex-col gap-y-2",H?"items-start":"items-end")},{children:k.documentIds.map((s=>e.jsx(a.Fragment,{children:e.jsx(c.default,{documentId:s})},s)))})),e.jsx(l.PickaxeMarkdown,Object.assign({theme:P.theme,colors:A},H&&{rtl:!0},{disableHtml:!0,disableJs:!0,disableCss:!0},{children:k.parts.map(((a,i)=>"text"===a.type?e.jsx(t.PickaxeMarkdownRenderer,{value:s.formatUserMessage(a.content)},i):null))}))]}))}))})):e.jsx("div",{})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../common/formatUserMessage.js"),t=require("../../common/PickaxeMarkdown/Renderer.js"),i=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../Addons/Artifact/hooks/useArtifact.js"),l=require("../../common/PickaxeMarkdown/index.js"),c=require("../../common/PickaxeIcon.js"),d=require("./Document.js"),m=require("../../common/PickaxeMessageActions.js"),u=require("../../common/PickaxeMessageParts/index.js"),x=require("../../../../common/cn.js"),p=require("../../../../common/isoMap.js"),f=require("franc-min"),j=require("../../common/ComposioConnectView.js"),g=require("../../common/SmitheryConnectView.js"),h=require("../../../../hooks/pickaxe/useTextToSpeech.js");function v(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var b=v(require("remove-markdown"));exports.default=({index:v,message:k,smitheryData:y,resubmitPrompt:w,isLastMessage:O=!1})=>{var q,N;const{pickaxeId:C,pickaxe:I,styles:P,colors:R,misc:A,responsiveBy:M,disableHtml:S,disableJs:T,disableCss:L,isNewChat:H,isRtl:F}=a.usePickaxeContext(),{isGenerating:J}=o.useResponseContext(),{onLoadArtifact:U}=n.useArtifact(),V=r.useStyleFontSize(),z=null!==(q=null==I?void 0:I.chaticon)&&void 0!==q?q:`https://cdn.mail.studio/chaticons/${C}.png`,B=O&&J,D=null==I?void 0:I.enablereadout,{isLoading:_,isSpeaking:E,speak:G,stop:$}=h.useTextToSpeech(D&&"assistant"===k.role,{provider:null==I?void 0:I.readoutprovider,pickaxeId:C,voiceName:null==I?void 0:I.readoutvoice}),K=()=>{if(_||E)return void $();const e=k.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ");if(!e)return;const s=b.default(e,{stripListLeaders:!0,listUnicodeChar:"",gfm:!0,useImgAltText:!1}),t=f.franc(s),i=p.convertToIso1(t);G(s,i)},Q=!k.parts.some((e=>["text","reasoning","data-action-tool-caption"].includes(e.type)));return"assistant"===k.role?e.jsx("div",Object.assign({className:x.default("flex w-full",F?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:x.default("flex flex-col w-full",0===v&&H&&"viewport"===M&&"min-[767px]:max-w-[80%]",0===v&&H&&"container"===M&&"@[767px]/pickaxe-root:max-w-[80%]")},{children:e.jsxs("div",Object.assign({className:x.default("flex gap-x-3",F&&"flex-row-reverse")},{children:[A.isChatImage&&"NONE"!==z&&e.jsx(c.default,{src:z,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:R.text}),e.jsxs("div",Object.assign({className:x.default("flex flex-col flex-grow",F?"items-end":"items-start")},{children:[e.jsxs("div",Object.assign({className:x.default(V.b2,"chat-message pt-3 w-full",F?"text-right":"text-left")},{children:[e.jsx(l.PickaxeMarkdown,Object.assign({theme:P.theme,colors:R,isStreaming:B},F&&{rtl:!0},S&&{disableHtml:!0},T&&{disableJs:!0},L&&{disableCss:!0},{disableReasoning:null!==(N=null==I?void 0:I.enablereasoningdisplay)&&void 0!==N&&N,onArtifactClick:U},{children:e.jsx(u.default,{parts:k.parts,isStreaming:B})})),O&&y&&w&&("composio"===y.provider?e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(j.default,{serverId:y.serverId,toolkitSlug:y.toolkitSlug||"",name:y.name,resubmitPrompt:()=>w()})})):e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(g.default,{serverId:y.serverId,smitheryId:y.smitheryId||"",name:y.name||y.smitheryId,resubmitPrompt:()=>w()})})))]})),e.jsx("div",Object.assign({className:x.default("flex flex-col gap-6 my-4",Q&&"mt-2")},{children:B?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:x.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:R.secondaryText}},t)))})):e.jsx(m.default,Object.assign({responseReference:k.responseReference,content:k.parts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),index:v},"intromessage"===k.area&&{isHideFeedback:!0,isHideResponseAction:!0},{onReadOut:K,isReadOut:D||!1,isReadOutLoading:_,isReading:E}))}))]}))]}))}))})):"user"===k.role?e.jsx("div",Object.assign({className:x.default("flex w-full",F?"justify-start":"justify-end")},{children:e.jsx("div",Object.assign({className:x.default("flex gap-x-3 max-w-[80%]",F?"pr-9":"pl-9","viewport"===M?F?"min-[767px]:pr-0":"min-[767px]:pl-0":F?"@[767px]/pickaxe-root:pr-0":"@[767px]/pickaxe-root:pl-0")},{children:e.jsxs("div",Object.assign({className:x.default(V.b2,"overflow-x-auto overflow-y-hidden px-4 py-3 scrollbar-thin scrollbar-track-white scrollbar-thumb-[#4A4A4B] flex flex-col gap-y-3",F?"text-right":"text-left"),style:{backgroundColor:R.secondary+"80",color:R.secondaryText,borderRadius:P.cornerRadius}},{children:[k.documentIds&&k.documentIds.length>0&&e.jsx("div",Object.assign({className:x.default("flex flex-col gap-y-2",F?"items-start":"items-end")},{children:k.documentIds.map((s=>e.jsx(i.Fragment,{children:e.jsx(d.default,{documentId:s})},s)))})),e.jsx(l.PickaxeMarkdown,Object.assign({theme:P.theme,colors:R},F&&{rtl:!0},{disableHtml:!0,disableJs:!0,disableCss:!0},{children:k.parts.map(((i,a)=>"text"===i.type?e.jsx(t.PickaxeMarkdownRenderer,{value:s.formatUserMessage(i.content)},a):null))}))]}))}))})):e.jsx("div",{})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../Addons/Auth/hooks/useAuthContext.js"),t=require("../../Addons/Auth/hooks/useAuth.js"),l=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/pickaxe/useDimensionContext.js"),o=require("../../Addons/Scroll/hooks/useScrollContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),c=require("../../../../hooks/pickaxe/useConversation.js"),d=require("../../Addons/Artifact/hooks/useArtifactContext.js"),u=require("framer-motion"),x=require("../../../Icons/lock.svg.js"),m=require("../../../Core/ErrorAlert.js"),f=require("../../common/PickaxeHead.js"),h=require("../../common/PickaxeEmbedHead.js"),j=require("../../common/PickaxeUpgradeCard.js"),g=require("../../common/PickaxeSkeleton.js"),p=require("../../common/PickaxeHistoryButton.js"),v=require("../../Addons/Scroll/ScrollLockView.js"),b=require("../../Addons/Artifact/Renderer/index.js"),y=require("./Message.js"),k=require("./CustomMessage.js"),w=require("../../Addons/IceBreaker/index.js"),N=require("../../common/PickaxeBranding.js"),C=require("../../../../common/cn.js"),O=require("../../../../common/chatMessages.js"),q=require("../../Addons/Auth/VerificationCodeForm.js");exports.default=({additionalScrollHeight:A,smitheryAuthData:S,isForceHideInfo:P,isInputFocused:I,onSubmit:L,resubmitPrompt:M})=>{var H,R,D,F,B;const{sessionId:E,deploymentType:T,pickaxe:z,translations:W,misc:$,isNewChat:_,isRtl:V,isEmbed:U,isShowIceBreaker:G,setSessionId:J,setLastSessionId:K}=i.usePickaxeContext(),{emailInput:Q,isLoggedOut:X,isSending:Y,isResendDisabled:Z,isSent:ee,isPricingAuth:se}=a.useAuthContext(),{onSend:ie}=t.useAuth(),{scrollContainerRef:ae,isLocked:te}=o.useScrollContext(),{messages:le,limitData:ne,error:oe}=l.useResponseContext(),{height:re,width:ce}=n.useDimensionContext(),{currentArtifact:de,chatPopupType:ue,currentPopupType:xe}=d.useArtifactContext(),me=c.useConversation(),fe=r.useStyleFontSize(),he=s.useMemo((()=>(null==z?void 0:z.icebreakers)?z.icebreakers.slice(0,3):[]),[null==z?void 0:z.icebreakers]),je=s.useMemo((()=>{const e=!!me.data&&me.data.messages.length>1;return!P&&me.isSuccess&&_&&!e}),[P,me.isSuccess,_,me.data]),ge=s.useMemo((()=>!(null==z?void 0:z.chatflag)&&(null==z?void 0:z.enablechatresponses)&&le.length>0),[z,le]),pe=s.useMemo((()=>!!me.data&&me.data.messages.some((e=>"intromessage"===e.area))),[me.data]),ve="chat-input"===T&&se&&X&&ee,be=G&&!I&&!pe&&je&&ce>767,ye=G&&!I&&(pe||ce<=767),ke=s.useMemo((()=>{var e,s;const i=null!==(s=null===(e=me.data)||void 0===e?void 0:e.messages)&&void 0!==s?s:[];return O.mergeConversationMessages(le,i)}),[null===(H=me.data)||void 0===H?void 0:H.messages,le]),we=()=>{K(E),J("")};return s.useLayoutEffect((()=>{if(!te)return;const e=ae.current;e&&(e.scrollTop=e.scrollHeight)}),[A,null===(R=me.data)||void 0===R?void 0:R.messages.length,te,ae,ke.length]),e.jsxs("div",Object.assign({ref:ae,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4 [overflow-anchor:none]"},{children:[e.jsx(u.AnimatePresence,{children:!!de&&"inline"===xe&&e.jsx(u.motion.div,Object.assign({className:C.default("absolute top-0 z-20 w-full px-4 py-2",ue),style:{height:`calc(${re-A}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:e.jsx(b.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:de.id,version:de.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[je&&U&&e.jsx("div",Object.assign({className:C.default("absolute right-4 top-3 flex items-center gap-2","popup"===T&&"right-12")},{children:e.jsx(p.default,{tip:(null==W?void 0:W["chat-history"])||"Chat History",onClick:we})})),e.jsx(f.default,Object.assign({className:C.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",je&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!ve&&{onIconClick:we})),U&&!me.isLoading&&e.jsx(h.default,Object.assign({className:C.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!je&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==W?void 0:W["chat-history"])||"Chat History"},!ve&&{onIconClick:we,onHistoryClick:we})),e.jsxs("div",Object.assign({className:C.default("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",U&&!me.isLoading&&!je&&"mt-0")},{children:[be&&e.jsx("div",Object.assign({className:C.default("grid grid-cols-3 gap-4",2===he.length&&"grid-cols-2",1===he.length&&"grid-cols-1")},{children:e.jsx(w.default,{type:"center",data:he,onSend:L})})),ve?e.jsx("div",Object.assign({className:"flex flex-col w-full"},{children:e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[e.jsx(k.default,Object.assign({chatRole:"user"},{children:e.jsxs("div",Object.assign({className:"flex items-center gap-x-3"},{children:[e.jsx(x.default,{className:"h-6 w-6 shrink-0"}),e.jsx("p",Object.assign({className:"font-semilight"},{children:Q}))]}))})),e.jsxs(k.default,Object.assign({chatRole:"assistant"},{children:[e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(D=null==W?void 0:W["we-sent-your-an-activation-link"])&&void 0!==D?D:"We sent you an activation link. Please be sure to check your spam folder too."} `,e.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{Z||Y||ie(!0)}},{children:Y?null!==(F=null==W?void 0:W.resending)&&void 0!==F?F:"Resending...":null!==(B=null==W?void 0:W.resend)&&void 0!==B?B:"Resend"}))]})),e.jsx(q.default,{compact:!0})]}))]}))})):e.jsx(e.Fragment,{children:me.isLoading&&!(null==z?void 0:z.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[_&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(g.default,{className:"w-[72px] h-[72px]"}),e.jsx(g.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(g.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(g.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(g.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(g.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):me.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:C.default(fe.b2,"text-center font-semibold")},{children:[(null==W?void 0:W["something-went-wrong-please-try-again"])||"Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:(null==W?void 0:W["contact-us"])||"contact us"}))," ",(null==W?void 0:W["for-help"])||"for help."]}))})):me.data||ge?e.jsxs("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[ke.map(((s,i)=>e.jsx(y.default,{smitheryData:S,resubmitPrompt:M,index:i,message:s,isLastMessage:i===ke.length-1},`message-${i}`))),ne?e.jsx("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:e.jsx(j.default,{})})):oe?e.jsx("div",Object.assign({className:C.default("flex items-center gap-x-3",V?"justify-end":"justify-start")},{children:e.jsx(m.default,{error:oe})})):null]})),e.jsxs("div",Object.assign({className:C.default("flex flex-col",!$.isWhiteLabel||ye&&"mt-4")},{children:[!$.isWhiteLabel&&e.jsx(N.default,{containerClassName:C.default("justify-end",ye&&"mb-2")}),ye&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(w.default,{type:"right",data:he,onSend:L})})),e.jsx(v.default,{})]}))]})):null})]}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../common/canChat.js"),a=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../Addons/Auth/hooks/useAuthContext.js"),l=require("../../Addons/Auth/hooks/useAuth.js"),n=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../hooks/pickaxe/useDimensionContext.js"),r=require("../../Addons/Scroll/hooks/useScrollContext.js"),c=require("../../../../hooks/studio/useStyleFontSize.js"),d=require("../../../../hooks/pickaxe/useConversation.js"),u=require("../../Addons/Artifact/hooks/useArtifactContext.js"),m=require("framer-motion"),x=require("../../../Icons/lock.svg.js"),h=require("../../../Core/ErrorAlert.js"),f=require("../../common/PickaxeHead.js"),j=require("../../common/PickaxeEmbedHead.js"),g=require("../../common/PickaxeUpgradeCard.js"),p=require("../../common/PickaxeSkeleton.js"),v=require("../../common/PickaxeHistoryButton.js"),b=require("../../Addons/Scroll/ScrollLockView.js"),y=require("../../Addons/Artifact/Renderer/index.js"),k=require("./Message.js"),w=require("./CustomMessage.js"),N=require("../../Addons/IceBreaker/index.js"),C=require("../../common/PickaxeBranding.js"),O=require("../../../../common/cn.js"),q=require("../../../../common/chatMessages.js"),A=require("../../Addons/Auth/VerificationCodeForm.js");exports.default=({additionalScrollHeight:S,smitheryAuthData:P,isForceHideInfo:I,isInputFocused:L,onSubmit:M,resubmitPrompt:H})=>{var R,D,F,B,E;const{sessionId:T,deploymentType:z,pickaxe:W,translations:$,misc:_,isNewChat:V,isRtl:U,isEmbed:G,isShowIceBreaker:J,setSessionId:K,setLastSessionId:Q}=i.usePickaxeContext(),{emailInput:X,isLoggedOut:Y,isSending:Z,isResendDisabled:ee,isSent:se,isPricingAuth:ae}=t.useAuthContext(),{onSend:ie}=l.useAuth(),{scrollContainerRef:te,isLocked:le}=r.useScrollContext(),{messages:ne,limitData:oe,error:re}=n.useResponseContext(),{height:ce,width:de}=o.useDimensionContext(),{currentArtifact:ue,chatPopupType:me,currentPopupType:xe}=u.useArtifactContext(),he=d.useConversation(),fe=c.useStyleFontSize(),je=a.useMemo((()=>(null==W?void 0:W.icebreakers)?W.icebreakers.slice(0,3):[]),[null==W?void 0:W.icebreakers]),ge=a.useMemo((()=>{const e=!!he.data&&he.data.messages.length>1;return!I&&he.isSuccess&&V&&!e}),[I,he.isSuccess,V,he.data]),pe=a.useMemo((()=>!(null==W?void 0:W.chatflag)&&(null==W?void 0:W.enablechatresponses)&&ne.length>0),[W,ne]),ve=a.useMemo((()=>!!he.data&&he.data.messages.some((e=>"intromessage"===e.area))),[he.data]),be="chat-input"===z&&ae&&Y&&se,ye=s.canChat(W),ke=ye&&J&&!L&&!ve&&ge&&de>767,we=ye&&J&&!L&&(ve||de<=767),Ne=a.useMemo((()=>{var e,s;const a=null!==(s=null===(e=he.data)||void 0===e?void 0:e.messages)&&void 0!==s?s:[];return q.mergeConversationMessages(ne,a)}),[null===(R=he.data)||void 0===R?void 0:R.messages,ne]),Ce=()=>{Q(T),K("")};return a.useLayoutEffect((()=>{if(!le)return;const e=te.current;e&&(e.scrollTop=e.scrollHeight)}),[S,null===(D=he.data)||void 0===D?void 0:D.messages.length,le,te,Ne.length]),e.jsxs("div",Object.assign({ref:te,className:"flex flex-1 w-full flex-col items-center overflow-y-auto pb-4 scrollbar scrollbar-thin min-h-0 mb-4 [overflow-anchor:none]"},{children:[e.jsx(m.AnimatePresence,{children:!!ue&&"inline"===xe&&e.jsx(m.motion.div,Object.assign({className:O.default("absolute top-0 z-20 w-full px-4 py-2",me),style:{height:`calc(${ce-S}px - 80px)`},initial:{opacity:0,y:-20},animate:{opacity:1,y:0},exit:{opacity:0,y:-20},transition:{duration:.2,ease:"easeOut"}},{children:e.jsx(y.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:ue.id,version:ue.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[ge&&G&&e.jsx("div",Object.assign({className:O.default("absolute right-4 top-3 flex items-center gap-2","popup"===z&&"right-12")},{children:e.jsx(v.default,{tip:(null==$?void 0:$["chat-history"])||"Chat History",onClick:Ce})})),e.jsx(f.default,Object.assign({className:O.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",ge&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!be&&{onIconClick:Ce})),G&&!he.isLoading&&e.jsx(j.default,Object.assign({className:O.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!ge&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==$?void 0:$["chat-history"])||"Chat History"},!be&&{onIconClick:Ce,onHistoryClick:Ce})),e.jsxs("div",Object.assign({className:O.default("flex flex-col flex-grow mt-6 transition-all duration-300 ease-in-out w-full px-4",G&&!he.isLoading&&!ge&&"mt-0")},{children:[ke&&e.jsx("div",Object.assign({className:O.default("grid grid-cols-3 gap-4",2===je.length&&"grid-cols-2",1===je.length&&"grid-cols-1")},{children:e.jsx(N.default,{type:"center",data:je,onSend:M})})),be?e.jsx("div",Object.assign({className:"flex flex-col w-full"},{children:e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[e.jsx(w.default,Object.assign({chatRole:"user"},{children:e.jsxs("div",Object.assign({className:"flex items-center gap-x-3"},{children:[e.jsx(x.default,{className:"h-6 w-6 shrink-0"}),e.jsx("p",Object.assign({className:"font-semilight"},{children:X}))]}))})),e.jsxs(w.default,Object.assign({chatRole:"assistant"},{children:[e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(F=null==$?void 0:$["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."} `,e.jsx("span",Object.assign({className:"underline underline-offset-2 cursor-pointer",onClick:()=>{ee||Z||ie(!0)}},{children:Z?null!==(B=null==$?void 0:$.resending)&&void 0!==B?B:"Resending...":null!==(E=null==$?void 0:$.resend)&&void 0!==E?E:"Resend"}))]})),e.jsx(A.default,{compact:!0})]}))]}))})):e.jsx(e.Fragment,{children:he.isLoading&&!(null==W?void 0:W.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[V&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(p.default,{className:"w-[72px] h-[72px]"}),e.jsx(p.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(p.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(p.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(p.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(p.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(p.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):he.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:O.default(fe.b2,"text-center font-semibold")},{children:[(null==$?void 0:$["something-went-wrong-please-try-again"])||"Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:(null==$?void 0:$["contact-us"])||"contact us"}))," ",(null==$?void 0:$["for-help"])||"for help."]}))})):he.data||pe?e.jsxs("div",Object.assign({className:"flex flex-col w-full flex-grow justify-between"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[Ne.map(((s,a)=>e.jsx(k.default,{smitheryData:P,resubmitPrompt:H,index:a,message:s,isLastMessage:a===Ne.length-1},`message-${a}`))),oe?e.jsx("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:e.jsx(g.default,{})})):re?e.jsx("div",Object.assign({className:O.default("flex items-center gap-x-3",U?"justify-end":"justify-start")},{children:e.jsx(h.default,{error:re})})):null]})),e.jsxs("div",Object.assign({className:O.default("flex flex-col",!_.isWhiteLabel||we&&"mt-4")},{children:[!_.isWhiteLabel&&e.jsx(C.default,{containerClassName:O.default("justify-end",we&&"mb-2")}),we&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(N.default,{type:"right",data:je,onSend:M})})),e.jsx(b.default,{})]}))]})):null})]}))]}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../../hooks/pickaxe/useEndUserModel.js"),n=require("../common/EndUserModelPicker.js"),i=require("../../../common/actionApproval.js"),r=require("react"),o=require("../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../hooks/studio/useStyleInput.js"),d=require("../../../hooks/studio/useStyleFontSize.js"),c=require("../../../hooks/pickaxe/useConversation.js"),u=require("../../../hooks/pickaxe/useDimensionContext.js"),p=require("../Addons/Auth/hooks/useAuthContext.js"),m=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),g=require("../Addons/Artifact/hooks/useArtifactContext.js"),v=require("../../../hooks/core/useHover.js"),h=require("../../../hooks/core/useMediaQuery.js"),b=require("../../../common/documents.js"),x=require("eventsource-parser"),y=require("../../Icons/attach-vertical.svg.js"),I=require("../../Icons/arrow-right.svg.js"),j=require("../../Icons/microphone.svg.js"),S=require("../../Icons/message-clock.svg.js"),N=require("../../Icons/stop.svg.js"),O=require("../../Icons/trash.svg.js"),w=require("../../Icons/pencil.svg.js"),k=require("../Addons/Document/List.js"),_=require("../../Core/Textarea.js"),E=require("../../Core/ErrorAlert.js"),T=require("../../Core/Menu/index.js"),C=require("../../Core/Menu/Button.js"),U=require("../../Core/Menu/List.js"),A=require("../../../common/error.js"),D=require("../../../common/api/pickaxe.js"),P=require("../../../common/validation.js"),L=require("../../../common/cn.js"),q=require("../../../common/utils.js"),M=require("../../../common/pickaxeConfig.js"),R=require("../../../common/agentPrefill.js"),F=require("../../../common/deploymentWebhooks.js"),V=require("../../../hooks/studio/useStudio.js"),$=require("../../../hooks/pickaxe/useSpeechToText.js"),B=require("../common/PickaxeCommon.js");const X=(e,t)=>{const s=e.find((e=>e.id===t));return s?e.filter((e=>e.id!==t)).map((e=>e.predecessorSubmissionId===t?Object.assign(Object.assign({},e),{predecessorSubmissionId:s.predecessorSubmissionId}):e)):e},K=e=>"string"==typeof e&&e.trim().length>0,G=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`,H=e=>e.map((e=>Object.assign({},e))),Y=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),W=(e,t)=>{if(e&&"object"==typeof e)return e[t]},z=(e,t)=>{const s=W(e,t);return K(s)?s:null},J=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},Q=({studioUser:e,deploymentId:t,portalId:s})=>{var n,i;const r=Array.isArray(W(e,"uses"))?W(e,"uses"):[],o=(({deploymentId:e,portalId:t})=>K(e)?{type:"deployment",id:e}:K(t)?{type:"portal",id:t}:null)({deploymentId:t,portalId:s});if(!o)return{scope:o,record:null};const a=null!==(i=null!==(n=r.find((e=>e.id===o.id&&e.type===o.type)))&&void 0!==n?n:r.find((e=>e.id===o.id)))&&void 0!==i?i:null;return{scope:o,record:a}},Z=r.forwardRef((({resubmitPrompt:W,onFocus:Z,onBlur:ee,onInputHeightChange:te,initSmitheryAuthData:se},ne)=>{var ie,re,oe,ae,le,de,ce,ue,pe,me,fe,ge,ve,he,be,xe,ye,Ie;const{origin:je,pickaxeId:Se,sessionId:Ne,sender:Oe,senderType:we,portalId:ke,deploymentId:_e,deploymentType:Ee,pickaxe:Te,styles:Ce,colors:Ue,translations:Ae,locale:De,forceMobile:Pe,isNewChat:Le,isRtl:qe,isEmbed:Me,isShowFeedbackMessage:Re,accessGroup:Fe,setIsNewChat:Ve,setIsShowIceBreaker:$e,setValidationStatus:Be,setValidationUpgradeGroups:Xe,setValidationUpgradeUrl:Ke,setAccessGroup:Ge,onUpgrade:He,onGenerateComplete:Ye}=o.usePickaxeContext(),{value:We,enabled:ze}=s.useEndUserModel(),{token:Je,isLoggedOut:Qe,isSent:Ze,isPricingAuth:et}=p.useAuthContext(),{messages:tt,isGenerating:st,setMessages:nt,setStatus:it,setLimitData:rt,setError:ot,setActionApprovalToken:at}=a.useResponseContext(),{documents:lt,isUploading:dt,documentError:ct,onFileUpload:ut,setDocuments:pt,setDocumentError:mt}=m.useDocument(),{studio:ft}=V.useStudio(),[gt]=h.useMediaQuery("(max-width: 480px)"),{scrollStartSession:vt,scrollEndSession:ht,scrollToBottom:bt}=f.useScroll({auto:!0,smooth:!(Pe||gt)}),{artifacts:xt,currentPopupType:yt,setArtifacts:It,setCurrentArtifact:jt}=g.useArtifactContext(),{height:St}=u.useDimensionContext(),Nt=c.useConversation(),[Ot,wt]=r.useState((()=>R.readAgentPrefill([_e,Se]).chatInput)),[kt,_t]=r.useState(!1),[Et,Tt]=r.useState(!1),[Ct,Ut]=r.useState(!1),[At,Dt]=r.useState(!1),[Pt,Lt]=r.useState([]),[qt,Mt]=r.useState(!1),[Rt,Ft]=r.useState(null),[Vt,$t]=r.useState(null),[Bt,Xt]=r.useState(null),[Kt,Gt]=r.useState(null),[Ht,Yt]=r.useState(!1),[Wt,zt]=r.useState(!1),[Jt,Qt]=r.useState(0),Zt=r.useRef(null),es=r.useRef(""),ts=r.useRef(null),ss=r.useRef(null),ns=r.useRef(null),is=r.useRef([]),rs=r.useRef(null),os=r.useRef(null),as=r.useRef(null),ls=r.useRef(null),ds=r.useRef(new Set),cs=r.useRef(null),us=Math.max(.4*St,100),{speechTranscript:ps,isSpeechListening:ms,isSpeechProcessing:fs,isSpeechSupported:gs,onStartListening:vs,onStopListening:hs}=$.useSpeechToText(),bs=v.useHover(),{isHover:xs}=bs,ys=e.__rest(bs,["isHover"]),Is=v.useHover(),{isHover:js}=Is,Ss=e.__rest(Is,["isHover"]),Ns=v.useHover(),{isHover:Os}=Ns,ws=e.__rest(Ns,["isHover"]),ks=d.useStyleFontSize(),_s=l.useStyleInput(),Es="undefined"!=typeof window?window.location.hostname:"",Ts="undefined"!=typeof window?window.location.href:"",Cs="undefined"!=typeof window&&window.self!==window.top,Us=Es.includes("pickaxe.co")&&!Ts.includes("https://studio.pickaxe.co/_embed")&&!Cs,As=null!==(re=null===(ie=null==Te?void 0:Te.documentuploadtype)||void 0===ie?void 0:ie.startsWith("enduserupload"))&&void 0!==re&&re,Ds=gs&&(null==Te?void 0:Te.enablevoicetotext),Ps=ms&&!Ot.trim(),Ls=K(_e),qs="chat-input"===Ee&&Le&&!Ze,Ms="chat-input"===Ee&&et&&Qe&&Ze,Rs=r.useCallback((e=>{const t=P.getValidationFailure(e);return!!t&&(ot(""),rt(null),Be(t.status),Ge(t.accessGroup),Xe(t.upgradeGroups),Ke(t.upgradeUrl),!0)}),[ot,at,rt,Be,Xe,Ke,Ge]),Fs=null!==(oe=null==Te?void 0:Te.placeholdertext)&&void 0!==oe?oe:qe?"بماذا تريد أن تتحدث؟":(null==Ae?void 0:Ae["what-do-you-want-to-talk-about"])||"What do you want to talk about?",Vs=kt||Et,$s=r.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){Yt(!1);try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({studioId:null==Te?void 0:Te.studioid},Je?{studioSessionToken:Je}:Oe?{sender:Oe}:{sender:q.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),Us&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Xt(t.studioUser),Gt(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{Yt(!0)}}))),[Us,null==Te?void 0:Te.studioid,Oe,Je]);r.useEffect((()=>{$s()}),[$s]);const Bs=Number(null!==(ae=null==Fe?void 0:Fe.limit)&&void 0!==ae?ae:0),Xs="string"==typeof(null==Fe?void 0:Fe.limitInterval)?Fe.limitInterval:null,Ks=!!(null==ft?void 0:ft.data.usage)&&ft.data.usage.isCredits,Gs=r.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=ke?ke:z(Bt,"portalId"))&&void 0!==e?e:z(Bt,"portalid"))&&void 0!==t?t:z(Fe,"portalId"))&&void 0!==s?s:z(Fe,"portalid"))&&void 0!==n?n:z(Te,"portalId"))&&void 0!==i?i:z(Te,"portalid")}),[Fe,ke,Te,Bt]),Hs=r.useMemo((()=>Q({studioUser:Bt,deploymentId:_e,portalId:Gs})),[_e,Gs,Bt]);r.useEffect((()=>{Ls&&Le&&Ne&&ds.current.add(Ne)}),[Le,Ne,Ls]);const Ys=r.useCallback((()=>{var e,t,s;return{studioId:null==Te?void 0:Te.studioid,userEmail:z(Bt,"email"),userId:null!==(e=z(Bt,"userId"))&&void 0!==e?e:z(Bt,"userid"),sessionId:Ne,deploymentId:_e,deploymentType:Ee,portalId:Gs,accessGroupId:null!==(t=null==Fe?void 0:Fe.accessGroupId)&&void 0!==t?t:null,pickaxeId:Se,sender:Oe,senderType:we,origin:je,metadata:null!==(s=M.getPickaxeConfigMetadata(_e))&&void 0!==s?s:null}}),[null==Fe?void 0:Fe.accessGroupId,_e,Ee,je,null==Te?void 0:Te.studioid,Se,Gs,Oe,we,Ne,Bt]),Ws=r.useCallback((()=>!!(Ls&&Ht&&Ne)&&(!!ds.current.has(Ne)&&(F.fireDeploymentSessionInitializedWebhook(Ys()),ds.current.delete(Ne),!0))),[Ys,Ht,Ne,Ls]);r.useEffect((()=>{if(!Ht||!Ne)return;Ws();const e=cs.current;(null==e?void 0:e.sessionId)===Ne&&(F.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),Ys()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),cs.current=null)}),[Ws,Ys,Ht,Ne]);const zs={currentUses:J(null==Bt?void 0:Bt.currentUses),extraUses:J(null==Bt?void 0:Bt.extraUses)},Js=Hs.scope?{currentUses:null!==(de=J(null===(le=Hs.record)||void 0===le?void 0:le.currentUses))&&void 0!==de?de:0,extraUses:null!==(ue=J(null===(ce=Hs.record)||void 0===ce?void 0:ce.extraUses))&&void 0!==ue?ue:0}:{currentUses:0,extraUses:0},Qs=z(Bt,"type"),Zs="guest"===Qs||!Qs&&Qe?Js:zs;r.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(Ks&&(null===(e=null==ft?void 0:ft.data)||void 0===e?void 0:e.workspaceId))try{const e=yield D.pickaxeApi2.get(`/cost_per_run?workspaceId=${ft.data.workspaceId}`,{withCredentials:!1});t&&Qt(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&Qt(0)}else t&&Qt(0)})),()=>{t=!1}}),[Ks,null===(pe=null==ft?void 0:ft.data)||void 0===pe?void 0:pe.workspaceId]);const en=(({accessGroupType:e,currentUses:t,extraUses:s,limit:n,limitInterval:i})=>{const r=Number(null!=t?t:0),o=Number(null!=s?s:0);return"public"===e&&"one_time"===i?n===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:Math.max(0,n-r):n===B.STUDIO_INFINITY_VALUE||o===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:"one_time"===i?Math.max(0,o-r):Math.max(0,n-r)+o})({accessGroupType:null==Fe?void 0:Fe.type,currentUses:Zs.currentUses,extraUses:Zs.extraUses,limit:Bs,limitInterval:Xs}),tn=en===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(en)),sn=(({accessGroupType:e,extraUses:t,limit:s,limitInterval:n})=>{const i=Number(null!=t?t:0);return"public"===e&&"one_time"===n?s===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:Math.max(0,s):s===B.STUDIO_INFINITY_VALUE||i===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:"one_time"===n?Math.max(0,i):Math.max(0,s)+Math.max(0,i)})({accessGroupType:null==Fe?void 0:Fe.type,extraUses:Zs.extraUses,limit:Bs,limitInterval:Xs}),nn=sn===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:Math.ceil(.05*sn),rn=Ks?Math.ceil(5*Jt):5,on=nn===B.STUDIO_INFINITY_VALUE?B.STUDIO_INFINITY_VALUE:Math.max(nn,rn),an=r.useMemo((()=>!!Bt&&(!Wt&&(tn!==B.STUDIO_INFINITY_VALUE&&(!(sn<=0||tn>=sn)&&tn<=on)))),[Wt,on,tn,Bt,sn]),ln=Boolean(null==Fe?void 0:Fe.hideUpgradeOptions),dn=Boolean(!ln&&((null===(me=null==Fe?void 0:Fe.upgrade)||void 0===me?void 0:me.isBuyMoreUses)||(null===(fe=null==Fe?void 0:Fe.upgrade)||void 0===fe?void 0:fe.isLinkToCustomURL)||(null===(ge=null==Fe?void 0:Fe.upgrade)||void 0===ge?void 0:ge.isUpgradeToAnotherGroup)&&(null===(ve=Fe.upgrade.accessGroupIds)||void 0===ve?void 0:ve.length))),cn=!ln&&(null===(he=null==Fe?void 0:Fe.upgrade)||void 0===he?void 0:he.isLinkToCustomURL)&&"string"==typeof Fe.upgrade.limitLink&&Fe.upgrade.limitLink.trim().length>0?Fe.upgrade.limitLink.trim():null,un=cn&&"string"==typeof(null===(be=null==Fe?void 0:Fe.upgrade)||void 0===be?void 0:be.limitCTA)&&Fe.upgrade.limitCTA.trim().length>0?Fe.upgrade.limitCTA:(null==Ae?void 0:Ae["pricing.upgrade"])||(null==Ae?void 0:Ae.upgrade)||"Upgrade",pn=r.useMemo((()=>{var e,t,s;return!!Le&&(!!Te&&(!Nt.isLoading&&(!((null!==(t=null===(e=Nt.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=Te.icebreakers)||void 0===s?void 0:s.length)&&(!Re&&!qs)))))}),[Te,Le,Re,qs,Nt.data,Nt.isLoading]),mn=r.useMemo((()=>{if(dt||Ct)return!1;const e=As&&lt.length>0&&lt.every((e=>"finished"===e.status));return!(!Ot.trim()&&!e)&&lt.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[As,dt,Ct,Ot,lt]);r.useImperativeHandle(ne,(()=>({onSubmit:bn}))),r.useEffect((()=>{$e(pn)}),[pn]),r.useEffect((()=>{var e;if(W){const t=Array.from(tt),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;bn(s,!0)}}),[W]),r.useEffect((()=>{if(!as.current||!te)return;const e=new ResizeObserver((e=>{for(const t of e)te(t.contentRect.height)}));return e.observe(as.current),()=>{e.disconnect()}}),[te]),r.useEffect((()=>{if(!ms)return;const e=es.current?`${es.current} `:"";wt(`${e}${ps}`)}),[ps,ms]),r.useEffect((()=>{if(!rs.current)return;(()=>{if(!rs.current)return;let e=rs.current.scrollHeight>52;Ot.includes("\n")||lt.length?e=!0:Ot.trim()||(e=!1),_t(e)})()}),[Ot,lt]),r.useEffect((()=>{const e=rs.current,t=os.current;if(!e||!t||ze||kt||Ot.includes("\n"))return void Tt(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=Ot||Fs,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;Tt(r>l)}),[Ot,kt,Fs,ze]);const fn=t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:ss.current))return!1;const e=H(is.current);try{return(yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/cancel/${t}`,Object.assign({method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},(!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()}),body:JSON.stringify({outputMessageParts:e})},Us&&{credentials:"include"}))).ok}catch(e){return console.warn("Failed to cancel submission",e),!1}})),gn=e=>{ns.current=e,ls.current&&(ls.current.abort(),ls.current=null),ts.current&&(ts.current.cancel().catch((()=>{})),ts.current=null)},vn=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Date.now()+3e4;for(;Date.now()<e;){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/status/${t}`,Object.assign({headers:Object.assign({"Cache-Control":"no-cache"},(!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}))},Us&&{credentials:"include"}));if(e.ok){if((yield e.json()).terminal)return!0}}catch(e){console.warn("Failed to read submission status",e)}yield new Promise((e=>setTimeout(e,250)))}return!1})),hn=()=>{const e=ss.current;e&&!Ct&&!dt&&Ot.trim()&&(Lt((t=>{var s,n;return[...t,{id:G(),message:Ot,predecessorSubmissionId:null!==(n=null===(s=t[t.length-1])||void 0===s?void 0:s.id)&&void 0!==n?n:e}]})),wt(""))},bn=(t,s=!1,n=!1,r,o=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,a,l,d,c;let u=null;try{if(st&&!n||dt)return;const p=lt.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),m=p.map((e=>e.documentId)).filter(Boolean),f=p.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),g=null!=t?t:Ot,v=null!==(a=null===(e=null==Te?void 0:Te.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==a&&a&&m.length>0;if(!g&&!v)return;ot(""),mt(""),rt(null),wt(""),Ve(!1),Dt(!1),it("fetching"),vt(),bt();const h=s?tt.slice(0,tt.length-1):tt,b=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(h),y=b+(s?0:1),I={id:y,role:"assistant",parts:[],documentIds:[]},j=[...h,...s?[]:[{id:b,role:"user",parts:[{type:"text",content:g,isVisible:!0}],documentIds:v?m:[]}],I];nt(j),bt(),v&&pt([]);const S=M.getPickaxeConfigMetadata(_e),N=null!=r?r:G();u=N,ss.current=N,ns.current=null,is.current=[];const O=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({supportsActionConfirmation:!0,selectedModel:We||void 0,origin:je,pickaxeId:Se,sessionId:Ne,submissionId:N},o&&{interactionType:"steer"}),{senderType:we,value:g}),v&&{documentIds:m}),Oe&&{sender:Oe}),Je&&{studioSessionToken:Je}),!Je&&!Oe&&{sender:q.initializeEmbedUserId()}),Gs&&{portalId:Gs}),_e&&{deploymentId:_e}),S&&{metadata:S}),v&&f.length>0?{uploadedModelImages:f}:{})),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()})},Us&&{credentials:"include"})),w=yield O.json();if(!w.success){if(w.limitData){const e=new Error(w.error||w.message||(null==Ae?void 0:Ae["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=w.limitData,e}if(Rs(w))return;throw new Error(w.error||w.message||(null==Ae?void 0:Ae["failed-to-start-generation"])||"Failed to start generation")}at(null!==(l=w.actionApprovalToken)&&void 0!==l?l:null);const k=null!==(d=w.submissionId)&&void 0!==d?d:N;u=k,ss.current=k;const _=()=>ns.current===k;if(_())return;Ls&&Le&&Ne&&ds.current.add(Ne);const E=Object.assign(Object.assign({},Ys()),{message:g,documentIds:v?m:[],uploadedModelImages:v?f:[],hasUploadedDocuments:v,isHidden:s,metadata:null!=S?S:null});Ht?(Ws(),F.fireDeploymentFirstMessageSubmittedWebhook(E)):cs.current=E,it("streaming"),ls.current=new AbortController;const T=[];let C=[...null!=xt?xt:[]],U=0,A=!1,D="";for(;!A;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${k}?index=${U}`,{signal:null===(c=ls.current)||void 0===c?void 0:c.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();ts.current=t;const s=new TextDecoder,n=x.createParser({onEvent:e=>{var t,s;if(_())A=!0;else if(e.event&&"ping"!==e.event&&U++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return rt(t.limitData),ot(""),void(A=!0);const s=t.error||t.message||(null==Ae?void 0:Ae["something-went-wrong"])||"Something went wrong.";return Rs(t)||ot(s),void(A=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("finish"===n.type)return void Dt(!0);if("data-error"===n.type&&se){const e=n.data.error;if("string"==typeof e){const t=/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e),s=/['"]type['"]\s*:\s*['"]unauthorized_composio['"]/.test(e);if(t){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 A=!0,se({provider:"smithery",smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}else if(s){const t=e.match(/['"]toolkitSlug['"]\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 A=!0,se({provider:"composio",toolkitSlug: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 A=!0,se({provider:"smithery",smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM");if("unauthorized_composio"===t.type&&t.toolkitSlug&&t.serverId&&t.name)throw A=!0,se({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)D="",T.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)D+=n.delta,i.updateStreamTextPart(T,"text",D);else if("text-end"===n.type)D="";else if("reasoning-start"===n.type)D="",T.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)D+=n.delta,i.updateStreamTextPart(T,"reasoning",D);else if("reasoning-end"===n.type)D="";else if(n.type.startsWith("data-")){const e=n;"data-action-approval"===e.type?i.upsertActionApprovalPart(T,e.data):T.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}is.current=H(T);const r=H(T);nt((e=>{const t=e.findIndex((e=>e.id===y)),s=Object.assign(Object.assign({},I),{parts:r});return-1===t?[...e,s]:e.map(((e,n)=>n===t?s:e))}))}else if("artifact_created"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),It([...C]),yt.startsWith("inline")||jt({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),It(C),yt.startsWith("inline")||jt({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),It(C),yt.startsWith("inline")||jt({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");C=C.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),It(C)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);It(C.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);if(t.limitData)return rt(t.limitData),ot(""),void(A=!0);const s=t.error||t.message||(null==Ae?void 0:Ae["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(Rs(t))return void(A=!0);ot(s)}else"stop"===e.event&&(A=!0)}else A=!0}});for(;;){if(_()){A=!0,t.cancel().catch((()=>{}));break}const{value:e,done:i}=yield t.read();if(_()){A=!0,t.cancel().catch((()=>{}));break}if(i)break;n.feed(s.decode(e))}A||_()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||Y(e)||_())return void(A=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==Ye||Ye(Ne)}catch(e){if(Y(e))return;if(e.limitData)rt(e.limitData),ot("");else{let t=A.default(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."),Rs(t)||ot(t)}}finally{const e=!u||ss.current===u;bt(),e&&(it("idle"),ht(),ts.current=null),u&&e&&(ss.current=null,is.current=[]),yield $s()}}));return r.useEffect((()=>{if(st||Ct||qt||0===Pt.length)return;const t=Pt[0];Mt(!0),Ft(t.id),e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!(yield vn(t.predecessorSubmissionId)))return void ot((null==Ae?void 0:Ae["queued-message-waiting"])||"A queued message is waiting for the previous response to finish.");Lt((e=>e.filter((e=>e.id!==t.id)))),yield bn(t.message,!1,!0,t.id)}finally{Mt(!1),Ft(null)}}))}),[st,qt,Ct,Pt]),Ms?null:t.jsx("div",Object.assign({className:L.default("flex w-full flex-shrink-0 flex-col items-center",!qs&&"px-4 pb-8"),dir:qe?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[Pt.length>0&&t.jsx("div",Object.assign({className:"mx-3 -mb-3 overflow-hidden border pb-3",style:{borderColor:Ue.text+"18",backgroundColor:null!==(xe=_s.backgroundColor)&&void 0!==xe?xe:Ue.text+"08",color:Ue.text,borderTopLeftRadius:Math.max(Ce.cornerRadius-4,12),borderTopRightRadius:Math.max(Ce.cornerRadius-4,12)}},{children:Pt.map(((s,n)=>{var i;return t.jsxs("div",Object.assign({className:"flex min-h-10 items-center gap-2 px-3 py-2",style:n<Pt.length-1?{borderBottom:`1px solid ${Ue.text}12`}:void 0},{children:[t.jsx(S.default,{className:"h-4 w-4 shrink-0 opacity-50","aria-hidden":"true"}),t.jsx("span",Object.assign({className:"min-w-0 flex-1 truncate text-sm",title:s.message},{children:s.message})),Vt===s.id||Rt===s.id?t.jsxs("span",Object.assign({className:"flex shrink-0 items-center gap-1.5 px-2 py-1 text-xs opacity-60","aria-live":"polite"},{children:[t.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border border-current border-r-transparent","aria-hidden":"true"}),Vt===s.id?(null==Ae?void 0:Ae.steering)||"Steering...":(null==Ae?void 0:Ae.starting)||"Starting..."]})):t.jsxs(t.Fragment,{children:[t.jsxs("button",Object.assign({type:"button",className:"shrink-0 rounded-md px-2 py-1 text-xs font-medium opacity-70 transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-40",disabled:Ct||!st,onClick:()=>{(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){const e=ss.current;if(!e||Ct)return;const s=Pt.findIndex((e=>e.id===t.id));if(-1===s)return;Ut(!0),$t(t.id),ot(""),gn(e);let n=!1;try{if(!(yield fn(e)))throw new Error((null==Ae?void 0:Ae["failed-to-interrupt-current-response"])||"Failed to interrupt the current response.");if(!(yield vn(e)))throw new Error((null==Ae?void 0:Ae["current-response-still-stopping"])||"The current response is still stopping. Please send your message again in a moment.");it("idle"),Lt((e=>e.filter((e=>e.id!==t.id)))),n=!0,Ut(!1),$t(null),yield bn(t.message,!1,!0,t.id,!0)}catch(e){it("idle"),n&&Lt((e=>{if(e.some((e=>e.id===t.id)))return e;const n=[...e];return n.splice(s,0,t),n})),ot(A.default(e))}finally{Ut(!1),$t(null)}}))})(s)},"aria-label":`${(null==Ae?void 0:Ae["steer-with"])||"Steer with"}: ${s.message}`},{children:[t.jsx("span",Object.assign({"aria-hidden":"true"},{children:"↳ "})),(null==Ae?void 0:Ae.steer)||"Steer"]})),t.jsx("button",Object.assign({type:"button",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-30",disabled:Ct,onClick:()=>{return e=s.id,void Lt((t=>X(t,e)));var e},"aria-label":`${(null==Ae?void 0:Ae["remove-queued-message"])||"Remove queued message"}: ${s.message}`},{children:t.jsx(O.default,{className:"h-4 w-4","aria-hidden":"true"})})),t.jsxs(T.default,Object.assign({id:`queued-message-menu-${s.id}`,className:"shrink-0"},{children:[t.jsx(C.default,Object.assign({className:"flex h-7 w-7 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100",isDisabled:Ct,role:"button",tabIndex:Ct?-1:0,"aria-haspopup":"menu","aria-label":(null==Ae?void 0:Ae["more-options"])||"More options",onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.currentTarget.click())}},{children:t.jsxs("svg",Object.assign({viewBox:"0 0 24 24",className:"h-4 w-4",fill:"currentColor","aria-hidden":"true"},{children:[t.jsx("circle",{cx:"5",cy:"12",r:"1.6"}),t.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),t.jsx("circle",{cx:"19",cy:"12",r:"1.6"})]}))})),t.jsx(U.default,Object.assign({role:"menu",align:qe?"bottom-start":"bottom-end",positionStrategy:Me?"absolute":"fixed",width:"auto",className:"p-1 text-sm shadow-xl",style:{backgroundColor:null!==(i=_s.backgroundColor)&&void 0!==i?i:Ue.primary,color:Ue.text,borderRadius:"12px"},border:`1px solid ${Ue.text}20`},{children:t.jsxs("button",Object.assign({type:"button",role:"menuitem",className:"flex min-w-36 items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/5 dark:hover:bg-white/10",onClick:()=>(e=>{Lt((t=>X(t,e.id))),wt(e.message),requestAnimationFrame((()=>{const t=rs.current;t&&(t.focus(),t.setSelectionRange(e.message.length,e.message.length))}))})(s)},{children:[t.jsx(w.default,{className:"h-4 w-4 shrink-0"}),(null==Ae?void 0:Ae["edit-message"])||"Edit message"]}))}))]}))]})]}),s.id)}))})),t.jsxs("div",Object.assign({ref:as,className:L.default("relative z-10 flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===Ce.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},_s),{maxHeight:`${us}px`,overflowY:"auto"})},{children:[an&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:_s.backgroundColor?`${_s.backgroundColor}E6`:void 0,borderColor:Ue.text+"20",color:Ue.text,borderTopRightRadius:Ce.cornerRadius+"px",borderTopLeftRadius:Ce.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[tn.toLocaleString()," ",Ks?(null==Ae?void 0:Ae.credits)||"Credits":(null==Ae?void 0:Ae.uses)||"Uses"," ",(null==Ae?void 0:Ae.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[dn&&t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:Ue.accent,color:Ue.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),cn)return void window.open(cn,"_blank","noopener,noreferrer");if(He)return void He();const t=q.buildUpgradeUrl({baseUrl:Kt,accessGroupId:null==Fe?void 0:Fe.accessGroupId});t&&q.openAuthenticatedPricingUrl({deploymentId:_e,pricingUrl:t,studioId:null==Te?void 0:Te.studioid,studioSessionToken:Je})}},{children:un})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>zt(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!st&&lt.length>0&&t.jsx(k.default,{className:"p-4 pb-0",isDisabled:st}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Ps&&t.jsxs("div",Object.assign({className:L.default(ze?"top-6":"top-1/2","pointer-events-none absolute z-10 flex -translate-y-1/2 select-none items-center gap-x-2",qe?"right-4":"left-4")},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(ye=Ue.accent)&&void 0!==ye?ye:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:Ue.text+"90"}},{children:(null==Ae?void 0:Ae.listening)||"Listening..."}))]})),t.jsx(_.default,Object.assign({ref:rs,className:L.default(ks.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!Ot.trim()&&!Ot.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",qe?"text-right":"text-left",!ze&&Vs&&"mb-12"),value:Ot,placeholder:Ps?"":Fs,onChange:e=>{wt(e)},onKeyDown:e=>{Pe||gt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),dt||Ct||(st?hn():bn())))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!As)return;t.preventDefault(),Ve(!1),yield ut(e)}}))},Z&&{onFocus:Z},ee&&{onBlur:ee},{dir:qe?"rtl":"ltr"})),t.jsxs("div",Object.assign({ref:os,className:ze?"relative flex w-full items-center gap-2 px-3 pb-2 [&>button]:shrink-0 [&>button]:mr-0":L.default("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",Vs?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Vs&&_s.backgroundColor&&{backgroundColor:_s.backgroundColor}),{borderTopRightRadius:Ce.cornerRadius+"px",borderBottomRightRadius:Ce.cornerRadius+"px"})},{children:[!st&&!ms&&As&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:js?Ue.accent+"10":void 0,color:js?Ue.accent:Ue.accent+"80"},disabled:dt||st,"aria-label":null!==(Ie=null==Ae?void 0:Ae["attach-files"])&&void 0!==Ie?Ie:"Attach files",onClick:()=>{var e;return null===(e=Zt.current)||void 0===e?void 0:e.click()}},Ss,{children:[t.jsx("input",{id:"file-upload",ref:Zt,type:"file",accept:[...b.allowedFileMimeTypes,...b.allowedImageMimeTypes,...b.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Ve(!1),yield ut(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(y.default,{className:"h-6 w-6 shrink-0"})]})),t.jsx(n.default,{compact:!0}),st&&!At?t.jsxs(t.Fragment,{children:[t.jsx("button",Object.assign({"aria-label":(null==Ae?void 0:Ae["stop-response"])||"Stop response",className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{const e=ss.current;e&&(gn(e),fn(e)),it("idle")},style:{backgroundColor:Ue.accent+"10",color:Ue.accent}},{children:t.jsx(N.default,{className:"h-4 w-4 shrink-0"})})),t.jsx("button",Object.assign({"aria-label":(null==Ae?void 0:Ae["queue-message"])||"Queue message",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",disabled:Ct||dt||!Ot.trim(),onClick:hn,style:{backgroundColor:Ot.trim()?Ue.accent:Ue.accent+"10",color:Ot.trim()?Ue.accentText:Ue.accent+"80"}},{children:t.jsx(I.default,{className:L.default("h-6 w-6 shrink-0",qe&&"scale-x-[-1] transform")})}))]}):ms?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:hs,style:{backgroundColor:Ue.accent,color:Ue.accentText}},{children:t.jsx(N.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Ds&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:ms?Ue.accent:Os?Ue.accent+"10":void 0,color:ms?Ue.accentText:Os?Ue.accent:Ue.accent+"80"},disabled:dt||st||fs,onClick:()=>{ms?hs():(es.current=Ot,vs(De||"en-US"))}},ws,{children:t.jsx(j.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:xs||mn?Ue.accent:Ue.accent+"10",color:xs||mn?Ue.accentText:Ue.accent+"80"},disabled:!mn,onClick:()=>bn()},ys,{children:t.jsx(I.default,{className:L.default("h-6 w-6 shrink-0",qe&&"scale-x-[-1] transform")})}))]})]}))]}))]})),ct&&t.jsx(E.default,{error:ct,className:"mt-3"})]}))}))}));Z.displayName="Input",exports.default=Z;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../../common/canChat.js"),n=require("../../../hooks/pickaxe/useEndUserModel.js"),i=require("../common/EndUserModelPicker.js"),r=require("../../../common/actionApproval.js"),o=require("react"),a=require("../../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../../hooks/pickaxe/useResponseContext.js"),d=require("../../../hooks/studio/useStyleInput.js"),c=require("../../../hooks/studio/useStyleFontSize.js"),u=require("../../../hooks/pickaxe/useConversation.js"),p=require("../../../hooks/pickaxe/useDimensionContext.js"),m=require("../Addons/Auth/hooks/useAuthContext.js"),f=require("../Addons/Document/hooks/useDocument.js"),g=require("../Addons/Scroll/hooks/useScroll.js"),v=require("../Addons/Artifact/hooks/useArtifactContext.js"),h=require("../../../hooks/core/useHover.js"),b=require("../../../hooks/core/useMediaQuery.js"),x=require("../../../common/documents.js"),y=require("eventsource-parser"),I=require("../../Icons/attach-vertical.svg.js"),j=require("../../Icons/arrow-right.svg.js"),S=require("../../Icons/microphone.svg.js"),N=require("../../Icons/message-clock.svg.js"),O=require("../../Icons/stop.svg.js"),w=require("../../Icons/trash.svg.js"),k=require("../../Icons/pencil.svg.js"),_=require("../Addons/Document/List.js"),E=require("../../Core/Textarea.js"),T=require("../../Core/ErrorAlert.js"),C=require("../../Core/Menu/index.js"),U=require("../../Core/Menu/Button.js"),A=require("../../Core/Menu/List.js"),D=require("../../../common/error.js"),P=require("../../../common/api/pickaxe.js"),L=require("../../../common/validation.js"),q=require("../../../common/cn.js"),M=require("../../../common/utils.js"),R=require("../../../common/pickaxeConfig.js"),F=require("../../../common/agentPrefill.js"),V=require("../../../common/deploymentWebhooks.js"),$=require("../../../hooks/studio/useStudio.js"),B=require("../../../hooks/pickaxe/useSpeechToText.js"),X=require("../common/PickaxeCommon.js");const K=(e,t)=>{const s=e.find((e=>e.id===t));return s?e.filter((e=>e.id!==t)).map((e=>e.predecessorSubmissionId===t?Object.assign(Object.assign({},e),{predecessorSubmissionId:s.predecessorSubmissionId}):e)):e},G=e=>"string"==typeof e&&e.trim().length>0,H=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`,Y=e=>e.map((e=>Object.assign({},e))),W=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),z=(e,t)=>{if(e&&"object"==typeof e)return e[t]},J=(e,t)=>{const s=z(e,t);return G(s)?s:null},Q=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},Z=({studioUser:e,deploymentId:t,portalId:s})=>{var n,i;const r=Array.isArray(z(e,"uses"))?z(e,"uses"):[],o=(({deploymentId:e,portalId:t})=>G(e)?{type:"deployment",id:e}:G(t)?{type:"portal",id:t}:null)({deploymentId:t,portalId:s});if(!o)return{scope:o,record:null};const a=null!==(i=null!==(n=r.find((e=>e.id===o.id&&e.type===o.type)))&&void 0!==n?n:r.find((e=>e.id===o.id)))&&void 0!==i?i:null;return{scope:o,record:a}},ee=o.forwardRef((({resubmitPrompt:z,onFocus:ee,onBlur:te,onInputHeightChange:se,initSmitheryAuthData:ne},ie)=>{var re,oe,ae,le,de,ce,ue,pe,me,fe,ge,ve,he,be,xe,ye,Ie,je;const{origin:Se,pickaxeId:Ne,sessionId:Oe,sender:we,senderType:ke,portalId:_e,deploymentId:Ee,deploymentType:Te,pickaxe:Ce,styles:Ue,colors:Ae,translations:De,locale:Pe,forceMobile:Le,isNewChat:qe,isRtl:Me,isEmbed:Re,isShowFeedbackMessage:Fe,accessGroup:Ve,setIsNewChat:$e,setIsShowIceBreaker:Be,setValidationStatus:Xe,setValidationUpgradeGroups:Ke,setValidationUpgradeUrl:Ge,setAccessGroup:He,onUpgrade:Ye,onGenerateComplete:We}=a.usePickaxeContext(),{value:ze,enabled:Je}=n.useEndUserModel(),{token:Qe,isLoggedOut:Ze,isSent:et,isPricingAuth:tt}=m.useAuthContext(),{messages:st,isGenerating:nt,setMessages:it,setStatus:rt,setLimitData:ot,setError:at,setActionApprovalToken:lt}=l.useResponseContext(),{documents:dt,isUploading:ct,documentError:ut,onFileUpload:pt,setDocuments:mt,setDocumentError:ft}=f.useDocument(),{studio:gt}=$.useStudio(),[vt]=b.useMediaQuery("(max-width: 480px)"),{scrollStartSession:ht,scrollEndSession:bt,scrollToBottom:xt}=g.useScroll({auto:!0,smooth:!(Le||vt)}),{artifacts:yt,currentPopupType:It,setArtifacts:jt,setCurrentArtifact:St}=v.useArtifactContext(),{height:Nt}=p.useDimensionContext(),Ot=u.useConversation(),[wt,kt]=o.useState((()=>F.readAgentPrefill([Ee,Ne]).chatInput)),[_t,Et]=o.useState(!1),[Tt,Ct]=o.useState(!1),[Ut,At]=o.useState(!1),[Dt,Pt]=o.useState(!1),[Lt,qt]=o.useState([]),[Mt,Rt]=o.useState(!1),[Ft,Vt]=o.useState(null),[$t,Bt]=o.useState(null),[Xt,Kt]=o.useState(null),[Gt,Ht]=o.useState(null),[Yt,Wt]=o.useState(!1),[zt,Jt]=o.useState(!1),[Qt,Zt]=o.useState(0),es=o.useRef(null),ts=o.useRef(""),ss=o.useRef(null),ns=o.useRef(null),is=o.useRef(null),rs=o.useRef([]),os=o.useRef(null),as=o.useRef(null),ls=o.useRef(null),ds=o.useRef(null),cs=o.useRef(new Set),us=o.useRef(null),ps=Math.max(.4*Nt,100),{speechTranscript:ms,isSpeechListening:fs,isSpeechProcessing:gs,isSpeechSupported:vs,onStartListening:hs,onStopListening:bs}=B.useSpeechToText(),xs=h.useHover(),{isHover:ys}=xs,Is=e.__rest(xs,["isHover"]),js=h.useHover(),{isHover:Ss}=js,Ns=e.__rest(js,["isHover"]),Os=h.useHover(),{isHover:ws}=Os,ks=e.__rest(Os,["isHover"]),_s=c.useStyleFontSize(),Es=d.useStyleInput(),Ts="undefined"!=typeof window?window.location.hostname:"",Cs="undefined"!=typeof window?window.location.href:"",Us="undefined"!=typeof window&&window.self!==window.top,As=Ts.includes("pickaxe.co")&&!Cs.includes("https://studio.pickaxe.co/_embed")&&!Us,Ds=null!==(oe=null===(re=null==Ce?void 0:Ce.documentuploadtype)||void 0===re?void 0:re.startsWith("enduserupload"))&&void 0!==oe&&oe,Ps=vs&&(null==Ce?void 0:Ce.enablevoicetotext),Ls=fs&&!wt.trim(),qs=G(Ee),Ms="chat-input"===Te&&qe&&!et,Rs="chat-input"===Te&&tt&&Ze&&et,Fs=o.useCallback((e=>{const t=L.getValidationFailure(e);return!!t&&(at(""),ot(null),Xe(t.status),He(t.accessGroup),Ke(t.upgradeGroups),Ge(t.upgradeUrl),!0)}),[at,lt,ot,Xe,Ke,Ge,He]),Vs=null!==(ae=null==Ce?void 0:Ce.placeholdertext)&&void 0!==ae?ae:Me?"بماذا تريد أن تتحدث؟":(null==De?void 0:De["what-do-you-want-to-talk-about"])||"What do you want to talk about?",$s=_t||Tt,Bs=o.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){Wt(!1);try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({studioId:null==Ce?void 0:Ce.studioid},Qe?{studioSessionToken:Qe}:we?{sender:we}:{sender:M.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),As&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Kt(t.studioUser),Ht(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{Wt(!0)}}))),[As,null==Ce?void 0:Ce.studioid,we,Qe]);o.useEffect((()=>{Bs()}),[Bs]);const Xs=Number(null!==(le=null==Ve?void 0:Ve.limit)&&void 0!==le?le:0),Ks="string"==typeof(null==Ve?void 0:Ve.limitInterval)?Ve.limitInterval:null,Gs=!!(null==gt?void 0:gt.data.usage)&&gt.data.usage.isCredits,Hs=o.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=_e?_e:J(Xt,"portalId"))&&void 0!==e?e:J(Xt,"portalid"))&&void 0!==t?t:J(Ve,"portalId"))&&void 0!==s?s:J(Ve,"portalid"))&&void 0!==n?n:J(Ce,"portalId"))&&void 0!==i?i:J(Ce,"portalid")}),[Ve,_e,Ce,Xt]),Ys=o.useMemo((()=>Z({studioUser:Xt,deploymentId:Ee,portalId:Hs})),[Ee,Hs,Xt]);o.useEffect((()=>{qs&&qe&&Oe&&cs.current.add(Oe)}),[qe,Oe,qs]);const Ws=o.useCallback((()=>{var e,t,s;return{studioId:null==Ce?void 0:Ce.studioid,userEmail:J(Xt,"email"),userId:null!==(e=J(Xt,"userId"))&&void 0!==e?e:J(Xt,"userid"),sessionId:Oe,deploymentId:Ee,deploymentType:Te,portalId:Hs,accessGroupId:null!==(t=null==Ve?void 0:Ve.accessGroupId)&&void 0!==t?t:null,pickaxeId:Ne,sender:we,senderType:ke,origin:Se,metadata:null!==(s=R.getPickaxeConfigMetadata(Ee))&&void 0!==s?s:null}}),[null==Ve?void 0:Ve.accessGroupId,Ee,Te,Se,null==Ce?void 0:Ce.studioid,Ne,Hs,we,ke,Oe,Xt]),zs=o.useCallback((()=>!!(qs&&Yt&&Oe)&&(!!cs.current.has(Oe)&&(V.fireDeploymentSessionInitializedWebhook(Ws()),cs.current.delete(Oe),!0))),[Ws,Yt,Oe,qs]);o.useEffect((()=>{if(!Yt||!Oe)return;zs();const e=us.current;(null==e?void 0:e.sessionId)===Oe&&(V.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),Ws()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),us.current=null)}),[zs,Ws,Yt,Oe]);const Js={currentUses:Q(null==Xt?void 0:Xt.currentUses),extraUses:Q(null==Xt?void 0:Xt.extraUses)},Qs=Ys.scope?{currentUses:null!==(ce=Q(null===(de=Ys.record)||void 0===de?void 0:de.currentUses))&&void 0!==ce?ce:0,extraUses:null!==(pe=Q(null===(ue=Ys.record)||void 0===ue?void 0:ue.extraUses))&&void 0!==pe?pe:0}:{currentUses:0,extraUses:0},Zs=J(Xt,"type"),en="guest"===Zs||!Zs&&Ze?Qs:Js;o.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(Gs&&(null===(e=null==gt?void 0:gt.data)||void 0===e?void 0:e.workspaceId))try{const e=yield P.pickaxeApi2.get(`/cost_per_run?workspaceId=${gt.data.workspaceId}`,{withCredentials:!1});t&&Zt(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&Zt(0)}else t&&Zt(0)})),()=>{t=!1}}),[Gs,null===(me=null==gt?void 0:gt.data)||void 0===me?void 0:me.workspaceId]);const tn=(({accessGroupType:e,currentUses:t,extraUses:s,limit:n,limitInterval:i})=>{const r=Number(null!=t?t:0),o=Number(null!=s?s:0);return"public"===e&&"one_time"===i?n===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:Math.max(0,n-r):n===X.STUDIO_INFINITY_VALUE||o===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:"one_time"===i?Math.max(0,o-r):Math.max(0,n-r)+o})({accessGroupType:null==Ve?void 0:Ve.type,currentUses:en.currentUses,extraUses:en.extraUses,limit:Xs,limitInterval:Ks}),sn=tn===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(tn)),nn=(({accessGroupType:e,extraUses:t,limit:s,limitInterval:n})=>{const i=Number(null!=t?t:0);return"public"===e&&"one_time"===n?s===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:Math.max(0,s):s===X.STUDIO_INFINITY_VALUE||i===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:"one_time"===n?Math.max(0,i):Math.max(0,s)+Math.max(0,i)})({accessGroupType:null==Ve?void 0:Ve.type,extraUses:en.extraUses,limit:Xs,limitInterval:Ks}),rn=nn===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:Math.ceil(.05*nn),on=Gs?Math.ceil(5*Qt):5,an=rn===X.STUDIO_INFINITY_VALUE?X.STUDIO_INFINITY_VALUE:Math.max(rn,on),ln=o.useMemo((()=>!!Xt&&(!zt&&(sn!==X.STUDIO_INFINITY_VALUE&&(!(nn<=0||sn>=nn)&&sn<=an)))),[zt,an,sn,Xt,nn]),dn=Boolean(null==Ve?void 0:Ve.hideUpgradeOptions),cn=Boolean(!dn&&((null===(fe=null==Ve?void 0:Ve.upgrade)||void 0===fe?void 0:fe.isBuyMoreUses)||(null===(ge=null==Ve?void 0:Ve.upgrade)||void 0===ge?void 0:ge.isLinkToCustomURL)||(null===(ve=null==Ve?void 0:Ve.upgrade)||void 0===ve?void 0:ve.isUpgradeToAnotherGroup)&&(null===(he=Ve.upgrade.accessGroupIds)||void 0===he?void 0:he.length))),un=!dn&&(null===(be=null==Ve?void 0:Ve.upgrade)||void 0===be?void 0:be.isLinkToCustomURL)&&"string"==typeof Ve.upgrade.limitLink&&Ve.upgrade.limitLink.trim().length>0?Ve.upgrade.limitLink.trim():null,pn=un&&"string"==typeof(null===(xe=null==Ve?void 0:Ve.upgrade)||void 0===xe?void 0:xe.limitCTA)&&Ve.upgrade.limitCTA.trim().length>0?Ve.upgrade.limitCTA:(null==De?void 0:De["pricing.upgrade"])||(null==De?void 0:De.upgrade)||"Upgrade",mn=o.useMemo((()=>{var e,t,s;return!!qe&&(!!Ce&&(!Ot.isLoading&&(!((null!==(t=null===(e=Ot.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=Ce.icebreakers)||void 0===s?void 0:s.length)&&(!Fe&&!Ms)))))}),[Ce,qe,Fe,Ms,Ot.data,Ot.isLoading]),fn=o.useMemo((()=>{if(ct||Ut)return!1;const e=Ds&&dt.length>0&&dt.every((e=>"finished"===e.status));return!(!wt.trim()&&!e)&&dt.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Ds,ct,Ut,wt,dt]);o.useImperativeHandle(ie,(()=>({onSubmit:xn}))),o.useEffect((()=>{Be(mn)}),[mn]),o.useEffect((()=>{var e;if(z){const t=Array.from(st),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;xn(s,!0)}}),[z]),o.useEffect((()=>{if(!ls.current||!se)return;const e=new ResizeObserver((e=>{for(const t of e)se(t.contentRect.height)}));return e.observe(ls.current),()=>{e.disconnect()}}),[se]),o.useEffect((()=>{if(!fs)return;const e=ts.current?`${ts.current} `:"";kt(`${e}${ms}`)}),[ms,fs]),o.useEffect((()=>{if(!os.current)return;(()=>{if(!os.current)return;let e=os.current.scrollHeight>52;wt.includes("\n")||dt.length?e=!0:wt.trim()||(e=!1),Et(e)})()}),[wt,dt]),o.useEffect((()=>{const e=os.current,t=as.current;if(!e||!t||Je||_t||wt.includes("\n"))return void Ct(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=wt||Vs,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;Ct(r>l)}),[wt,_t,Vs,Je]);const gn=t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:ns.current))return!1;const e=Y(rs.current);try{return(yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/cancel/${t}`,Object.assign({method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},(!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()}),body:JSON.stringify({outputMessageParts:e})},As&&{credentials:"include"}))).ok}catch(e){return console.warn("Failed to cancel submission",e),!1}})),vn=e=>{is.current=e,ds.current&&(ds.current.abort(),ds.current=null),ss.current&&(ss.current.cancel().catch((()=>{})),ss.current=null)},hn=t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Date.now()+3e4;for(;Date.now()<e;){try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/status/${t}`,Object.assign({headers:Object.assign({"Cache-Control":"no-cache"},(!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}))},As&&{credentials:"include"}));if(e.ok){if((yield e.json()).terminal)return!0}}catch(e){console.warn("Failed to read submission status",e)}yield new Promise((e=>setTimeout(e,250)))}return!1})),bn=()=>{const e=ns.current;e&&!Ut&&!ct&&wt.trim()&&(qt((t=>{var s,n;return[...t,{id:H(),message:wt,predecessorSubmissionId:null!==(n=null===(s=t[t.length-1])||void 0===s?void 0:s.id)&&void 0!==n?n:e}]})),kt(""))},xn=(t,n=!1,i=!1,o,a=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,l,d,c,u;if(!s.canChat(Ce))return;let p=null;try{if(nt&&!i||ct)return;const s=dt.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),m=s.map((e=>e.documentId)).filter(Boolean),f=s.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),g=null!=t?t:wt,v=null!==(l=null===(e=null==Ce?void 0:Ce.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==l&&l&&m.length>0;if(!g&&!v)return;at(""),ft(""),ot(null),kt(""),$e(!1),Pt(!1),rt("fetching"),ht(),xt();const h=n?st.slice(0,st.length-1):st,b=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(h),x=b+(n?0:1),I={id:x,role:"assistant",parts:[],documentIds:[]},j=[...h,...n?[]:[{id:b,role:"user",parts:[{type:"text",content:g,isVisible:!0}],documentIds:v?m:[]}],I];it(j),xt(),v&&mt([]);const S=R.getPickaxeConfigMetadata(Ee),N=null!=o?o:H();p=N,ns.current=N,is.current=null,rs.current=[];const O=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({supportsActionConfirmation:!0,selectedModel:ze||void 0,origin:Se,pickaxeId:Ne,sessionId:Oe,submissionId:N},a&&{interactionType:"steer"}),{senderType:ke,value:g}),v&&{documentIds:m}),we&&{sender:we}),Qe&&{studioSessionToken:Qe}),!Qe&&!we&&{sender:M.initializeEmbedUserId()}),Hs&&{portalId:Hs}),Ee&&{deploymentId:Ee}),S&&{metadata:S}),v&&f.length>0?{uploadedModelImages:f}:{})),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()})},As&&{credentials:"include"})),w=yield O.json();if(!w.success){if(w.limitData){const e=new Error(w.error||w.message||(null==De?void 0:De["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=w.limitData,e}if(Fs(w))return;throw new Error(w.error||w.message||(null==De?void 0:De["failed-to-start-generation"])||"Failed to start generation")}lt(null!==(d=w.actionApprovalToken)&&void 0!==d?d:null);const k=null!==(c=w.submissionId)&&void 0!==c?c:N;p=k,ns.current=k;const _=()=>is.current===k;if(_())return;qs&&qe&&Oe&&cs.current.add(Oe);const E=Object.assign(Object.assign({},Ws()),{message:g,documentIds:v?m:[],uploadedModelImages:v?f:[],hasUploadedDocuments:v,isHidden:n,metadata:null!=S?S:null});Yt?(zs(),V.fireDeploymentFirstMessageSubmittedWebhook(E)):us.current=E,rt("streaming"),ds.current=new AbortController;const T=[];let C=[...null!=yt?yt:[]],U=0,A=!1,D="";for(;!A;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${k}?index=${U}`,{signal:null===(u=ds.current)||void 0===u?void 0:u.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();ss.current=t;const s=new TextDecoder,n=y.createParser({onEvent:e=>{var t,s;if(_())A=!0;else if(e.event&&"ping"!==e.event&&U++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return ot(t.limitData),at(""),void(A=!0);const s=t.error||t.message||(null==De?void 0:De["something-went-wrong"])||"Something went wrong.";return Fs(t)||at(s),void(A=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("finish"===n.type)return void Pt(!0);if("data-error"===n.type&&ne){const e=n.data.error;if("string"==typeof e){const t=/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e),s=/['"]type['"]\s*:\s*['"]unauthorized_composio['"]/.test(e);if(t){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 A=!0,ne({provider:"smithery",smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}else if(s){const t=e.match(/['"]toolkitSlug['"]\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 A=!0,ne({provider:"composio",toolkitSlug: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 A=!0,ne({provider:"smithery",smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM");if("unauthorized_composio"===t.type&&t.toolkitSlug&&t.serverId&&t.name)throw A=!0,ne({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)D="",T.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)D+=n.delta,r.updateStreamTextPart(T,"text",D);else if("text-end"===n.type)D="";else if("reasoning-start"===n.type)D="",T.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)D+=n.delta,r.updateStreamTextPart(T,"reasoning",D);else if("reasoning-end"===n.type)D="";else if(n.type.startsWith("data-")){const e=n;"data-action-approval"===e.type?r.upsertActionApprovalPart(T,e.data):T.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}rs.current=Y(T);const i=Y(T);it((e=>{const t=e.findIndex((e=>e.id===x)),s=Object.assign(Object.assign({},I),{parts:i});return-1===t?[...e,s]:e.map(((e,n)=>n===t?s:e))}))}else if("artifact_created"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),jt([...C]),It.startsWith("inline")||St({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),jt(C),It.startsWith("inline")||St({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),jt(C),It.startsWith("inline")||St({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");C=C.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),jt(C)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);jt(C.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);if(t.limitData)return ot(t.limitData),at(""),void(A=!0);const s=t.error||t.message||(null==De?void 0:De["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(Fs(t))return void(A=!0);at(s)}else"stop"===e.event&&(A=!0)}else A=!0}});for(;;){if(_()){A=!0,t.cancel().catch((()=>{}));break}const{value:e,done:i}=yield t.read();if(_()){A=!0,t.cancel().catch((()=>{}));break}if(i)break;n.feed(s.decode(e))}A||_()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||W(e)||_())return void(A=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==We||We(Oe)}catch(e){if(W(e))return;if(e.limitData)ot(e.limitData),at("");else{let t=D.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==De?void 0:De["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),Fs(t)||at(t)}}finally{const e=!p||ns.current===p;xt(),e&&(rt("idle"),bt(),ss.current=null),p&&e&&(ns.current=null,rs.current=[]),yield Bs()}}));return o.useEffect((()=>{if(nt||Ut||Mt||0===Lt.length)return;const t=Lt[0];Rt(!0),Vt(t.id),e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!(yield hn(t.predecessorSubmissionId)))return void at((null==De?void 0:De["queued-message-waiting"])||"A queued message is waiting for the previous response to finish.");qt((e=>e.filter((e=>e.id!==t.id)))),yield xn(t.message,!1,!0,t.id)}finally{Rt(!1),Vt(null)}}))}),[nt,Mt,Ut,Lt]),Rs?null:t.jsx("div",Object.assign({className:q.default("flex w-full flex-shrink-0 flex-col items-center",!Ms&&"px-4 pb-8"),dir:Me?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[Lt.length>0&&t.jsx("div",Object.assign({className:"mx-3 -mb-3 overflow-hidden border pb-3",style:{borderColor:Ae.text+"18",backgroundColor:null!==(ye=Es.backgroundColor)&&void 0!==ye?ye:Ae.text+"08",color:Ae.text,borderTopLeftRadius:Math.max(Ue.cornerRadius-4,12),borderTopRightRadius:Math.max(Ue.cornerRadius-4,12)}},{children:Lt.map(((s,n)=>{var i;return t.jsxs("div",Object.assign({className:"flex min-h-10 items-center gap-2 px-3 py-2",style:n<Lt.length-1?{borderBottom:`1px solid ${Ae.text}12`}:void 0},{children:[t.jsx(N.default,{className:"h-4 w-4 shrink-0 opacity-50","aria-hidden":"true"}),t.jsx("span",Object.assign({className:"min-w-0 flex-1 truncate text-sm",title:s.message},{children:s.message})),$t===s.id||Ft===s.id?t.jsxs("span",Object.assign({className:"flex shrink-0 items-center gap-1.5 px-2 py-1 text-xs opacity-60","aria-live":"polite"},{children:[t.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border border-current border-r-transparent","aria-hidden":"true"}),$t===s.id?(null==De?void 0:De.steering)||"Steering...":(null==De?void 0:De.starting)||"Starting..."]})):t.jsxs(t.Fragment,{children:[t.jsxs("button",Object.assign({type:"button",className:"shrink-0 rounded-md px-2 py-1 text-xs font-medium opacity-70 transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-40",disabled:Ut||!nt,onClick:()=>{(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){const e=ns.current;if(!e||Ut)return;const s=Lt.findIndex((e=>e.id===t.id));if(-1===s)return;At(!0),Bt(t.id),at(""),vn(e);let n=!1;try{if(!(yield gn(e)))throw new Error((null==De?void 0:De["failed-to-interrupt-current-response"])||"Failed to interrupt the current response.");if(!(yield hn(e)))throw new Error((null==De?void 0:De["current-response-still-stopping"])||"The current response is still stopping. Please send your message again in a moment.");rt("idle"),qt((e=>e.filter((e=>e.id!==t.id)))),n=!0,At(!1),Bt(null),yield xn(t.message,!1,!0,t.id,!0)}catch(e){rt("idle"),n&&qt((e=>{if(e.some((e=>e.id===t.id)))return e;const n=[...e];return n.splice(s,0,t),n})),at(D.default(e))}finally{At(!1),Bt(null)}}))})(s)},"aria-label":`${(null==De?void 0:De["steer-with"])||"Steer with"}: ${s.message}`},{children:[t.jsx("span",Object.assign({"aria-hidden":"true"},{children:"↳ "})),(null==De?void 0:De.steer)||"Steer"]})),t.jsx("button",Object.assign({type:"button",className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100 disabled:cursor-default disabled:opacity-30",disabled:Ut,onClick:()=>{return e=s.id,void qt((t=>K(t,e)));var e},"aria-label":`${(null==De?void 0:De["remove-queued-message"])||"Remove queued message"}: ${s.message}`},{children:t.jsx(w.default,{className:"h-4 w-4","aria-hidden":"true"})})),t.jsxs(C.default,Object.assign({id:`queued-message-menu-${s.id}`,className:"shrink-0"},{children:[t.jsx(U.default,Object.assign({className:"flex h-7 w-7 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100",isDisabled:Ut,role:"button",tabIndex:Ut?-1:0,"aria-haspopup":"menu","aria-label":(null==De?void 0:De["more-options"])||"More options",onKeyDown:e=>{"Enter"!==e.key&&" "!==e.key||(e.preventDefault(),e.currentTarget.click())}},{children:t.jsxs("svg",Object.assign({viewBox:"0 0 24 24",className:"h-4 w-4",fill:"currentColor","aria-hidden":"true"},{children:[t.jsx("circle",{cx:"5",cy:"12",r:"1.6"}),t.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),t.jsx("circle",{cx:"19",cy:"12",r:"1.6"})]}))})),t.jsx(A.default,Object.assign({role:"menu",align:Me?"bottom-start":"bottom-end",positionStrategy:Re?"absolute":"fixed",width:"auto",className:"p-1 text-sm shadow-xl",style:{backgroundColor:null!==(i=Es.backgroundColor)&&void 0!==i?i:Ae.primary,color:Ae.text,borderRadius:"12px"},border:`1px solid ${Ae.text}20`},{children:t.jsxs("button",Object.assign({type:"button",role:"menuitem",className:"flex min-w-36 items-center gap-2 rounded-lg px-3 py-2 text-left transition-colors hover:bg-black/5 dark:hover:bg-white/10",onClick:()=>(e=>{qt((t=>K(t,e.id))),kt(e.message),requestAnimationFrame((()=>{const t=os.current;t&&(t.focus(),t.setSelectionRange(e.message.length,e.message.length))}))})(s)},{children:[t.jsx(k.default,{className:"h-4 w-4 shrink-0"}),(null==De?void 0:De["edit-message"])||"Edit message"]}))}))]}))]})]}),s.id)}))})),t.jsxs("div",Object.assign({ref:ls,className:q.default("relative z-10 flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===Ue.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Es),{maxHeight:`${ps}px`,overflowY:"auto"})},{children:[ln&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:Es.backgroundColor?`${Es.backgroundColor}E6`:void 0,borderColor:Ae.text+"20",color:Ae.text,borderTopRightRadius:Ue.cornerRadius+"px",borderTopLeftRadius:Ue.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[sn.toLocaleString()," ",Gs?(null==De?void 0:De.credits)||"Credits":(null==De?void 0:De.uses)||"Uses"," ",(null==De?void 0:De.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[cn&&t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:Ae.accent,color:Ae.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),un)return void window.open(un,"_blank","noopener,noreferrer");if(Ye)return void Ye();const t=M.buildUpgradeUrl({baseUrl:Gt,accessGroupId:null==Ve?void 0:Ve.accessGroupId});t&&M.openAuthenticatedPricingUrl({deploymentId:Ee,pricingUrl:t,studioId:null==Ce?void 0:Ce.studioid,studioSessionToken:Qe})}},{children:pn})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>Jt(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!nt&&dt.length>0&&t.jsx(_.default,{className:"p-4 pb-0",isDisabled:nt}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Ls&&t.jsxs("div",Object.assign({className:q.default(Je?"top-6":"top-1/2","pointer-events-none absolute z-10 flex -translate-y-1/2 select-none items-center gap-x-2",Me?"right-4":"left-4")},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(Ie=Ae.accent)&&void 0!==Ie?Ie:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:Ae.text+"90"}},{children:(null==De?void 0:De.listening)||"Listening..."}))]})),t.jsx(E.default,Object.assign({ref:os,className:q.default(_s.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!wt.trim()&&!wt.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Me?"text-right":"text-left",!Je&&$s&&"mb-12"),value:wt,placeholder:Ls?"":Vs,onChange:e=>{kt(e)},onKeyDown:e=>{Le||vt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ct||Ut||(nt?bn():xn())))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!Ds)return;t.preventDefault(),$e(!1),yield pt(e)}}))},ee&&{onFocus:ee},te&&{onBlur:te},{dir:Me?"rtl":"ltr"})),t.jsxs("div",Object.assign({ref:as,className:Je?"relative flex w-full items-center gap-2 px-3 pb-2 [&>button]:shrink-0 [&>button]:mr-0":q.default("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",$s?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!$s&&Es.backgroundColor&&{backgroundColor:Es.backgroundColor}),{borderTopRightRadius:Ue.cornerRadius+"px",borderBottomRightRadius:Ue.cornerRadius+"px"})},{children:[!nt&&!fs&&Ds&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Ss?Ae.accent+"10":void 0,color:Ss?Ae.accent:Ae.accent+"80"},disabled:ct||nt,"aria-label":null!==(je=null==De?void 0:De["attach-files"])&&void 0!==je?je:"Attach files",onClick:()=>{var e;return null===(e=es.current)||void 0===e?void 0:e.click()}},Ns,{children:[t.jsx("input",{id:"file-upload",ref:es,type:"file",accept:[...x.allowedFileMimeTypes,...x.allowedImageMimeTypes,...x.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){$e(!1),yield pt(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(I.default,{className:"h-6 w-6 shrink-0"})]})),t.jsx(i.default,{compact:!0}),nt&&!Dt?t.jsxs(t.Fragment,{children:[t.jsx("button",Object.assign({"aria-label":(null==De?void 0:De["stop-response"])||"Stop response",className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{const e=ns.current;e&&(vn(e),gn(e)),rt("idle")},style:{backgroundColor:Ae.accent+"10",color:Ae.accent}},{children:t.jsx(O.default,{className:"h-4 w-4 shrink-0"})})),t.jsx("button",Object.assign({"aria-label":(null==De?void 0:De["queue-message"])||"Queue message",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",disabled:Ut||ct||!wt.trim(),onClick:bn,style:{backgroundColor:wt.trim()?Ae.accent:Ae.accent+"10",color:wt.trim()?Ae.accentText:Ae.accent+"80"}},{children:t.jsx(j.default,{className:q.default("h-6 w-6 shrink-0",Me&&"scale-x-[-1] transform")})}))]}):fs?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:bs,style:{backgroundColor:Ae.accent,color:Ae.accentText}},{children:t.jsx(O.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Ps&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:fs?Ae.accent:ws?Ae.accent+"10":void 0,color:fs?Ae.accentText:ws?Ae.accent:Ae.accent+"80"},disabled:ct||nt||gs,onClick:()=>{fs?bs():(ts.current=wt,hs(Pe||"en-US"))}},ks,{children:t.jsx(S.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:ys||fn?Ae.accent:Ae.accent+"10",color:ys||fn?Ae.accentText:Ae.accent+"80"},disabled:!fn,onClick:()=>xn()},Is,{children:t.jsx(j.default,{className:q.default("h-6 w-6 shrink-0",Me&&"scale-x-[-1] transform")})}))]})]}))]}))]})),ut&&t.jsx(T.default,{error:ut,className:"mt-3"})]}))}))}));ee.displayName="Input",exports.default=ee;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("react"),s=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../Addons/Auth/hooks/useAuthContext.js"),n=require("../../../hooks/pickaxe/useDimensionContext.js"),r=require("../Addons/Document/hooks/useDocument.js"),a=require("../Addons/Scroll/hooks/useScrollContext.js"),l=require("../../../hooks/studio/useStyleFontSize.js"),u=require("../../../hooks/core/useScrollToBottomVisibility.js"),c=require("./History/index.js"),d=require("./Input.js"),f=require("../../Icons/attach-vertical.svg.js"),h=require("../../../common/cn.js"),m=require("../../../common/api/pickaxe.js"),p=require("uuid"),x=require("../../Core/StudioTip.js"),v=require("../common/ScrollToBottomButton.js"),j=require("../common/PickaxeMCPButton.js"),g=require("../../../hooks/pickaxe/useResponseContext.js"),b=require("../Addons/Navbar/NavPill.js"),k=require("../../Icons/history.svg.js");exports.default=()=>{var y,S;const{deploymentType:w,isNewChat:C,setIsNewChat:q,sessionId:I,setSessionId:D,setLastSessionId:N,pickaxeId:T,sender:P,pickaxe:A,styles:O,isEmbed:_,mcpEnabled:F,translations:E}=s.usePickaxeContext(),{isSent:R,token:H}=i.useAuthContext(),{width:z,height:B,setDimension:L}=n.useDimensionContext(),{setDocuments:M,onFileUpload:G}=r.useDocument(),{scrollContainerRef:V,hasScrolledRef:U,isLocked:W,setIsLocked:J}=a.useScrollContext(),{isGenerating:K,messages:Q}=g.useResponseContext(),X=l.useStyleFontSize(),[Y,Z]=o.useState(0),[$,ee]=o.useState(!1),[te,oe]=o.useState(!1),se=o.useRef(null),ie=o.useRef(null),ne=o.useRef(0),[re,ae]=o.useState(null),[le,ue]=o.useState(!1),ce=(null==E?void 0:E["new-chat"])||"New chat",de="chat-input"===w&&C&&!R,fe=null!==(S=null===(y=null==A?void 0:A.documentuploadtype)||void 0===y?void 0:y.startsWith("enduserupload"))&&void 0!==S&&S,{hasScrollableContent:he,isNearBottom:me}=u.default(V);o.useEffect((()=>()=>{M([])}),[]);const pe=o.useCallback((()=>{if(!T||!P&&!H)return;const t=(o=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield m.pickaxeApi2.post("/conversation/title",Object.assign({sessionId:I},H?{studioSessionToken:H}:P?{userId:P}:{}));if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void ve(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,P,I,H]);o.useEffect((()=>{K||C||!I||pe()}),[K,C,I,pe]),o.useEffect((()=>{if(!se.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(se.current),()=>{e.disconnect()}}),[L]);const[xe,ve]=o.useState(ce),je=(null==A?void 0:A.formtitle)||"Pickaxe",ge=(null==A?void 0:A.coverphoto)||void 0,[be,ke]=o.useState(!1);o.useEffect((()=>{const e=!de&&!_&&O.portalTheme&&(Q.filter((e=>"user"===e.role)).length>0||$||!C);ke(null!=e&&e)}),[de,_,$,C,Q,O.portalTheme]);const ye=o.useCallback((()=>{U.current=!1,J(!0),requestAnimationFrame((()=>{const e=V.current;e&&e.scrollTo({top:Math.max(0,e.scrollHeight-e.clientHeight),behavior:"smooth"})}))}),[U,V,J]);return t.jsxs("div",Object.assign({ref:se,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),fe&&(ne.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&oe(!0))},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),fe&&(ne.current-=1,0===ne.current&&oe(!1))},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(t.preventDefault(),t.stopPropagation(),oe(!1),ne.current=0,!fe)return;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(q(!1),yield G(e))}))},{children:[te&&t.jsxs("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:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(f.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:h.default(X.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==E?void 0:E["drop-files-to-upload"])||"Drop files to upload"})),t.jsx("p",Object.assign({className:h.default(X.b2,"mt-2 opacity-60 text-black")},{children:(null==E?void 0:E["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),!_&&F?t.jsx("div",Object.assign({className:"pointer-events-none absolute left-1/2 top-4 z-40 flex w-full max-w-[800px] -translate-x-1/2 justify-end px-4"},{children:t.jsx("div",Object.assign({className:"pointer-events-auto"},{children:t.jsx(j.default,{})}))})):null,de?t.jsx(d.default,{}):t.jsxs(t.Fragment,{children:[be&&t.jsxs("div",Object.assign({className:h.default("direct-link"===w?"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"===O.portalTheme?"glass-dark ":"")},{children:[t.jsx(b.NavPill,{text:je,icon:ge}),C||xe===ce?t.jsx(b.NavPill,{text:xe}):t.jsx(b.EditableNavPill,{text:xe,sessionId:I,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(I)try{yield m.pickaxeApi2.patch("/conversation/title",Object.assign({sessionId:I,name:t},H?{studioSessionToken:H}:P?{userId:P}:{})),ve(t)}catch(e){console.error("Error renaming chat:",e),alert((null==E?void 0:E["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(I&&window.confirm((null==E?void 0:E["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield m.pickaxeApi2.delete("/conversation",{data:Object.assign({sessionId:I},H?{studioSessionToken:H}:P?{userId:P}:{})}),q(!0),D(p.v4()),ve(ce)}catch(e){console.error("Error deleting chat:",e),alert((null==E?void 0:E["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===O.portalTheme}),t.jsx(x.StudioTip,Object.assign({content:E["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:t.jsx(b.HistoryPill,{icon:t.jsx(k.default,{}),onClick:()=>{D(""),N(I)}})}))]})),t.jsx(c.default,{additionalScrollHeight:Y,isForceHideInfo:B<=545||z<=350||$,isInputFocused:$,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){ie.current&&ie.current.onSubmit(t)})),smitheryAuthData:re,resubmitPrompt:()=>{ae(null),ue(!0)}}),t.jsx(v.default,{isVisible:he&&!W&&!me,bottom:Y+65,onClick:ye}),t.jsx(d.default,{ref:ie,onFocus:()=>ee(!0),onBlur:()=>ee(!1),onInputHeightChange:Z,initSmitheryAuthData:e=>ae(e),resubmitPrompt:le})]})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("../../../common/canChat.js"),s=require("react"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),n=require("../Addons/Auth/hooks/useAuthContext.js"),r=require("../../../hooks/pickaxe/useDimensionContext.js"),a=require("../Addons/Document/hooks/useDocument.js"),l=require("../Addons/Scroll/hooks/useScrollContext.js"),u=require("../../../hooks/studio/useStyleFontSize.js"),c=require("../../../hooks/core/useScrollToBottomVisibility.js"),d=require("./History/index.js"),f=require("./Input.js"),h=require("../../Icons/attach-vertical.svg.js"),m=require("../../../common/cn.js"),p=require("../../../common/api/pickaxe.js"),x=require("uuid"),v=require("../../Core/StudioTip.js"),j=require("../common/ScrollToBottomButton.js"),g=require("../common/PickaxeMCPButton.js"),b=require("../../../hooks/pickaxe/useResponseContext.js"),k=require("../Addons/Navbar/NavPill.js"),y=require("../../Icons/history.svg.js");exports.default=()=>{var S,w;const{deploymentType:C,isNewChat:q,setIsNewChat:I,sessionId:D,setSessionId:N,setLastSessionId:T,pickaxeId:P,sender:A,pickaxe:O,styles:_,isEmbed:F,mcpEnabled:E,translations:R}=i.usePickaxeContext(),{isSent:H,token:z}=n.useAuthContext(),{width:B,height:L,setDimension:M}=r.useDimensionContext(),{setDocuments:G,onFileUpload:V}=a.useDocument(),{scrollContainerRef:U,hasScrolledRef:W,isLocked:J,setIsLocked:K}=l.useScrollContext(),{isGenerating:Q,messages:X}=b.useResponseContext(),Y=u.useStyleFontSize(),[Z,$]=s.useState(0),[ee,te]=s.useState(!1),[oe,se]=s.useState(!1),ie=s.useRef(null),ne=s.useRef(null),re=s.useRef(0),[ae,le]=s.useState(null),[ue,ce]=s.useState(!1),de=(null==R?void 0:R["new-chat"])||"New chat",fe=o.canChat(O),he=fe&&"chat-input"===C&&q&&!H,me=fe&&null!==(w=null===(S=null==O?void 0:O.documentuploadtype)||void 0===S?void 0:S.startsWith("enduserupload"))&&void 0!==w&&w,{hasScrollableContent:pe,isNearBottom:xe}=c.default(U);s.useEffect((()=>()=>{G([])}),[]);const ve=s.useCallback((()=>{if(!P||!A&&!z)return;const t=(o=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield p.pickaxeApi2.post("/conversation/title",Object.assign({sessionId:D},z?{studioSessionToken:z}:A?{userId:A}:{}));if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void ge(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()}),[P,A,D,z]);s.useEffect((()=>{Q||q||!D||ve()}),[Q,q,D,ve]),s.useEffect((()=>{if(!ie.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;M(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(ie.current),()=>{e.disconnect()}}),[M]);const[je,ge]=s.useState(de),be=(null==O?void 0:O.formtitle)||"Pickaxe",ke=(null==O?void 0:O.coverphoto)||void 0,[ye,Se]=s.useState(!1);s.useEffect((()=>{const e=!he&&!F&&_.portalTheme&&(X.filter((e=>"user"===e.role)).length>0||ee||!q);Se(null!=e&&e)}),[he,F,ee,q,X,_.portalTheme]);const we=s.useCallback((()=>{W.current=!1,K(!0),requestAnimationFrame((()=>{const e=U.current;e&&e.scrollTo({top:Math.max(0,e.scrollHeight-e.clientHeight),behavior:"smooth"})}))}),[W,U,K]);return t.jsxs("div",Object.assign({ref:ie,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),me&&(re.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&se(!0))},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),me&&(re.current-=1,0===re.current&&se(!1))},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(t.preventDefault(),t.stopPropagation(),se(!1),re.current=0,!me)return;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(I(!1),yield V(e))}))},{children:[oe&&t.jsxs("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:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(h.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:m.default(Y.h3,"mt-6 font-semibold text-c-primary text-black")},{children:(null==R?void 0:R["drop-files-to-upload"])||"Drop files to upload"})),t.jsx("p",Object.assign({className:m.default(Y.b2,"mt-2 opacity-60 text-black")},{children:(null==R?void 0:R["add-anything-to-the-conversation"])||"Add anything to the conversation"}))]})),!F&&E?t.jsx("div",Object.assign({className:"pointer-events-none absolute left-1/2 top-4 z-40 flex w-full max-w-[800px] -translate-x-1/2 justify-end px-4"},{children:t.jsx("div",Object.assign({className:"pointer-events-auto"},{children:t.jsx(g.default,{})}))})):null,he?t.jsx(f.default,{}):t.jsxs(t.Fragment,{children:[ye&&t.jsxs("div",Object.assign({className:m.default("direct-link"===C?"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:[t.jsx(k.NavPill,{text:be,icon:ke}),q||je===de?t.jsx(k.NavPill,{text:je}):t.jsx(k.EditableNavPill,{text:je,sessionId:D,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(D)try{yield p.pickaxeApi2.patch("/conversation/title",Object.assign({sessionId:D,name:t},z?{studioSessionToken:z}:A?{userId:A}:{})),ge(t)}catch(e){console.error("Error renaming chat:",e),alert((null==R?void 0:R["failed-rename-chat"])||"Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(D&&window.confirm((null==R?void 0:R["delete-confirm"])||"Are you sure you want to delete this conversation?"))try{yield p.pickaxeApi2.delete("/conversation",{data:Object.assign({sessionId:D},z?{studioSessionToken:z}:A?{userId:A}:{})}),I(!0),N(fe?x.v4():""),ge(de)}catch(e){console.error("Error deleting chat:",e),alert((null==R?void 0:R["failed-delete-chat"])||"Failed to delete chat.")}})),isDarkGlass:"dark"===_.portalTheme}),t.jsx(v.StudioTip,Object.assign({content:R["chat-history"]||"Chat History",align:"bottom",containerClassName:"inline-flex shrink-0"},{children:t.jsx(k.HistoryPill,{icon:t.jsx(y.default,{}),onClick:()=>{N(""),T(D)}})}))]})),t.jsx(d.default,{additionalScrollHeight:Z,isForceHideInfo:L<=545||B<=350||ee,isInputFocused:ee,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){fe&&ne.current&&ne.current.onSubmit(t)})),smitheryAuthData:ae,resubmitPrompt:()=>{le(null),ce(!0)}}),t.jsx(j.default,{isVisible:pe&&!J&&!xe,bottom:Z+65,onClick:we}),fe&&t.jsx(f.default,{ref:ne,onFocus:()=>te(!0),onBlur:()=>te(!1),onInputHeightChange:$,initSmitheryAuthData:e=>le(e),resubmitPrompt:ue})]})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../Addons/Document/hooks/useDocument.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),r=require("../../../../common/api/pickaxe.js"),l=require("../../../../common/date.js"),c=require("lucide-react"),d=require("../../../Icons/trash-2.svg.js"),u=require("../../../Icons/chat.svg.js"),m=require("../../../Icons/copy.svg.js"),p=require("../../../Icons/copied.svg.js"),x=require("../../../Icons/expand.svg.js"),h=require("../../../Icons/collapse.svg.js"),v=require("../../common/PickaxeMarkdown/index.js"),g=require("../../common/PickaxeMarkdown/Renderer.js"),b=require("../../common/PickaxeMessageParts/index.js"),j=require("../../../../common/cn.js");exports.default=({item:f,onDelete:y})=>{const{pickaxe:k,sender:w,colors:N,translations:C,styles:O,isRtl:_,disableCss:q,disableHtml:P,disableJs:M,setSessionId:I,setIsNewChat:R}=n.usePickaxeContext(),{token:S}=i.useAuthContext(),{setMessages:T}=a.useResponseContext(),{setDocuments:A}=o.useDocument(),[E,D]=t.useState(!1),[F,H]=t.useState(!1),[$,z]=t.useState(!1),[J,L]=t.useState(!1),[U,B]=t.useState(!1),K=t.useRef(null),[X,G]=t.useState(f.shortSummary||f.summary||(null==C?void 0:C["conversation-name"])||"Conversation name"),[Q,V]=t.useState("");t.useEffect((()=>{G(f.shortSummary||f.summary||(null==C?void 0:C["conversation-name"])||"Conversation name")}),[f.shortSummary,f.summary,C]),t.useEffect((()=>{const e=e=>{K.current&&!K.current.contains(e.target)&&D(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const W=t.useMemo((()=>f?"FORM"===f.pickaxeType?f.question?0===f.messages.length?f.question.responseParts?f.question.responseParts.length:0:f.messages.length:0:f.messages.length:0),[f]),Y=l.formatLocalDateTime(f.updatedAt,"MMM dd, yyyy hh:mm a"),Z=t.useMemo((()=>{var e,s;const t=(null==C?void 0:C["not-available"])||"n/a";if("FORM"===f.pickaxeType){if(f.messages&&0!==f.messages.length){const e=f.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const n=null!==(s=null===(e=f.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[];return U?n.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||t}</p>\n</div>`)).join(""):n.map((e=>`${e.question}: ${e.answer||t}`)).join(" | ")}const n=f.messages.find((e=>"user"===e.role));return n?n.parts[0].content:""}),[f,U,C]),ee=t.useMemo((()=>{var e,s,t,n,a,o;return"FORM"===f.pickaxeType?f.messages&&0!==f.messages.length?null!==(s=null===(e=f.messages.find((e=>"assistant"===e.role)))||void 0===e?void 0:e.parts)&&void 0!==s?s:[]:null!==(n=null===(t=f.question)||void 0===t?void 0:t.responseParts)&&void 0!==n?n:[]:null!==(o=null===(a=f.messages.find((e=>"assistant"===e.role)))||void 0===a?void 0:a.parts)&&void 0!==o?o:[]}),[f]),se=t.useMemo((()=>ee.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")),[ee]),te=t.useMemo((()=>b.getSuppressedRichPreviewUrls(ee)),[ee]),ne=()=>{H(!1),V("")},ae=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(Q.trim()){z(!0);try{yield r.pickaxeApi2.patch("/conversation/title",Object.assign({sessionId:f.sessionId,name:Q},S?{studioSessionToken:S}:w?{userId:w}:{})),G(Q),H(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==C?void 0:C["failed-update-name"])||"Failed to update name.")}finally{z(!1)}}}));return s.jsxs("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:N.secondary,borderRadius:O.cornerRadius}},{children:[s.jsx("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:N.primary,color:N.text}},{children:F?s.jsxs("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[s.jsx("input",{autoFocus:!0,type:"text",value:Q,onChange:e=>V(e.target.value),onKeyDown:e=>{"Enter"===e.key&&ae(),"Escape"===e.key&&ne()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:N.primary,borderColor:N.secondary}}),s.jsx("button",Object.assign({onClick:ae,disabled:$,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==C?void 0:C.save)||"Save"},{children:s.jsx(c.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:ne,disabled:$,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==C?void 0:C.cancel)||"Cancel"},{children:s.jsx(c.X,{className:"h-4 w-4"})}))]})):s.jsxs(s.Fragment,{children:[s.jsx("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:X})),s.jsxs("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),B(!U)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:U?(null==C?void 0:C.collapse)||"Collapse":(null==C?void 0:C.expand)||"Expand"},{children:U?s.jsx(h.default,{className:"h-4 w-4"}):s.jsx(x.default,{className:"h-4 w-4"})})),s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),D(!E)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:s.jsx(c.MoreHorizontal,{className:"h-6 w-6"})})),E&&s.jsxs("div",Object.assign({ref:K,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:N.secondary,color:N.secondaryText,borderColor:N.primary}},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),V(X),H(!0),D(!1)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-all hover:brightness-95 border-b",style:{borderBottomColor:N.primary}},{children:[s.jsx(c.Pencil,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==C?void 0:C["rename-chat"])||"Rename chat"}))]})),s.jsxs("button",Object.assign({onClick:s=>{s.stopPropagation(),e.__awaiter(void 0,void 0,void 0,(function*(){if(window.confirm((null==C?void 0:C["delete-confirm"])||"Are you sure you want to delete this conversation?")){D(!1);try{yield r.pickaxeApi2.delete("/conversation",{data:Object.assign({sessionId:f.sessionId},S?{studioSessionToken:S}:w?{userId:w}:{})}),y&&y(f.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==C?void 0:C["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:[s.jsx(d.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==C?void 0:C["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s.jsxs("div",Object.assign({className:j.default("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",U?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:N.secondary,color:N.secondaryText}},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsx("div",Object.assign({className:j.default("w-full",U?"mb-0":"mb-2")},{children:s.jsx(v.PickaxeMarkdown,Object.assign({theme:O.theme,colors:N},_&&{rtl:!0},P&&{disableHtml:!0},M&&{disableJs:!0},q&&{disableCss:!0},{children:s.jsx(g.PickaxeMarkdownRenderer,{style:{display:"block"},className:j.default("w-full",!U&&["[&_*]:!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"],U&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:Z})}))})),s.jsx("div",Object.assign({className:"w-full"},{children:s.jsx(v.PickaxeMarkdown,Object.assign({theme:O.theme,colors:N},_&&{rtl:!0},P&&{disableHtml:!0},M&&{disableJs:!0},q&&{disableCss:!0},{children:s.jsx(g.PickaxeMarkdownRenderer,{style:{display:"block"},className:j.default("w-full text-sm",!U&&["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"],U&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:se,suppressedRichPreviewUrls:te})}))}))]})),s.jsxs("div",Object.assign({className:"flex items-center justify-between mt-4 pt-2 border-t border-transparent"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-4"},{children:[((null==k?void 0:k.chatflag)||!(null==k?void 0:k.chatflag)&&(null==k?void 0:k.enablechatresponses))&&s.jsxs("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=f.sessionId,A([]),T([]),R(!1),I(s)},title:(null==C?void 0:C["open-chat"])||"Open Chat"},{children:[s.jsx(u.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"text-sm font-medium"},{children:W}))]})),s.jsx("button",Object.assign({className:"transition-colors "+(J?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(se),L(!0),setTimeout((()=>{L(!1)}),2e3)},title:J?(null==C?void 0:C.copied)||"Copied!":(null==C?void 0:C["copy-assistant-message"])||"Copy assistant message"},{children:J?s.jsx(p.default,{className:"h-4 w-4",style:{color:N.accent},fill:N.accent}):s.jsx(m.default,{className:"h-4 w-4"})}))]})),s.jsx("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:Y}))]}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),a=require("../../Addons/Document/hooks/useDocument.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),l=require("../../../../common/api/pickaxe.js"),r=require("../../../../common/date.js"),c=require("lucide-react"),d=require("../../../Icons/trash-2.svg.js"),u=require("../../../Icons/chat.svg.js"),m=require("../../../Icons/copy.svg.js"),p=require("../../../Icons/copied.svg.js"),x=require("../../../Icons/expand.svg.js"),h=require("../../../Icons/collapse.svg.js"),v=require("../../common/PickaxeMarkdown/index.js"),b=require("../../common/PickaxeMarkdown/Renderer.js"),g=require("../../common/PickaxeMessageParts/index.js"),j=require("../../../../common/cn.js");exports.default=({item:f,onDelete:y})=>{var k,w;const{pickaxe:N,pickaxeId:C,renderResponseAction:O,sender:_,colors:q,translations:P,styles:M,isRtl:I,disableCss:R,disableHtml:S,disableJs:T,setSessionId:A,setIsNewChat:E}=n.usePickaxeContext(),{token:D}=i.useAuthContext(),{setMessages:F}=o.useResponseContext(),{setDocuments:H}=a.useDocument(),[$,z]=t.useState(!1),[J,L]=t.useState(!1),[U,V]=t.useState(!1),[B,K]=t.useState(!1),[X,G]=t.useState(!1),Q=t.useRef(null),[W,Y]=t.useState(f.shortSummary||f.summary||(null==P?void 0:P["conversation-name"])||"Conversation name"),[Z,ee]=t.useState("");t.useEffect((()=>{Y(f.shortSummary||f.summary||(null==P?void 0:P["conversation-name"])||"Conversation name")}),[f.shortSummary,f.summary,P]),t.useEffect((()=>{const e=e=>{Q.current&&!Q.current.contains(e.target)&&z(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const se=t.useMemo((()=>f?"FORM"===f.pickaxeType?f.question?0===f.messages.length?f.question.responseParts?f.question.responseParts.length:0:f.messages.length:0:f.messages.length:0),[f]),te=r.formatLocalDateTime(f.updatedAt,"MMM dd, yyyy hh:mm a"),ne=t.useMemo((()=>{var e,s;const t=(null==P?void 0:P["not-available"])||"n/a";if("FORM"===f.pickaxeType){if(f.messages&&0!==f.messages.length){const e=f.messages.find((e=>"user"===e.role));return e?e.parts[0].content:""}const n=null!==(s=null===(e=f.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[];return X?n.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||t}</p>\n</div>`)).join(""):n.map((e=>`${e.question}: ${e.answer||t}`)).join(" | ")}const n=f.messages.find((e=>"user"===e.role));return n?n.parts[0].content:""}),[f,X,P]),oe=t.useMemo((()=>{var e,s,t,n,o,a;return"FORM"===f.pickaxeType?f.messages&&0!==f.messages.length?null!==(s=null===(e=f.messages.find((e=>"assistant"===e.role)))||void 0===e?void 0:e.parts)&&void 0!==s?s:[]:null!==(n=null===(t=f.question)||void 0===t?void 0:t.responseParts)&&void 0!==n?n:[]:null!==(a=null===(o=f.messages.find((e=>"assistant"===e.role)))||void 0===o?void 0:o.parts)&&void 0!==a?a:[]}),[f]),ae=t.useMemo((()=>oe.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ")),[oe]),ie=t.useMemo((()=>g.getSuppressedRichPreviewUrls(oe)),[oe]),le=()=>{L(!1),ee("")},re=()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(Z.trim()){V(!0);try{yield l.pickaxeApi2.patch("/conversation/title",Object.assign({sessionId:f.sessionId,name:Z},D?{studioSessionToken:D}:_?{userId:_}:{})),Y(Z),L(!1)}catch(e){console.error("Error updating conversation name:",e),alert((null==P?void 0:P["failed-update-name"])||"Failed to update name.")}finally{V(!1)}}}));return s.jsxs("div",Object.assign({className:"flex flex-col overflow-hidden transition duration-300 hover:shadow w-full shrink-0 border",style:{borderColor:q.secondary,borderRadius:M.cornerRadius}},{children:[s.jsx("div",Object.assign({className:"flex items-center justify-between px-4 py-3 h-[44px]",style:{backgroundColor:q.primary,color:q.text}},{children:J?s.jsxs("div",Object.assign({className:"flex items-center w-full gap-2",onClick:e=>e.stopPropagation()},{children:[s.jsx("input",{autoFocus:!0,type:"text",value:Z,onChange:e=>ee(e.target.value),onKeyDown:e=>{"Enter"===e.key&&re(),"Escape"===e.key&&le()},className:"flex-1 text-inherit px-2 py-1 rounded border focus:outline-none focus:ring-0 text-sm",style:{backgroundColor:q.primary,borderColor:q.secondary}}),s.jsx("button",Object.assign({onClick:re,disabled:U,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==P?void 0:P.save)||"Save"},{children:s.jsx(c.Check,{className:"h-4 w-4"})})),s.jsx("button",Object.assign({onClick:le,disabled:U,className:"p-1 rounded hover:bg-black/20 transition-colors",title:(null==P?void 0:P.cancel)||"Cancel"},{children:s.jsx(c.X,{className:"h-4 w-4"})}))]})):s.jsxs(s.Fragment,{children:[s.jsx("h3",Object.assign({className:"font-bold text-lg truncate pr-2 flex-1 min-w-0 select-none"},{children:W})),s.jsxs("div",Object.assign({className:"flex items-center gap-1 shrink-0"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),G(!X)},className:"p-1 rounded-full transition-colors hover:bg-black/10",title:X?(null==P?void 0:P.collapse)||"Collapse":(null==P?void 0:P.expand)||"Expand"},{children:X?s.jsx(h.default,{className:"h-4 w-4"}):s.jsx(x.default,{className:"h-4 w-4"})})),s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsx("button",Object.assign({onClick:e=>{e.stopPropagation(),z(!$)},className:"p-1 rounded-full transition-colors hover:bg-black/10"},{children:s.jsx(c.MoreHorizontal,{className:"h-6 w-6"})})),$&&s.jsxs("div",Object.assign({ref:Q,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:q.secondary,color:q.secondaryText,borderColor:q.primary}},{children:[s.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),ee(W),L(!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:q.primary}},{children:[s.jsx(c.Pencil,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==P?void 0:P["rename-chat"])||"Rename chat"}))]})),s.jsxs("button",Object.assign({onClick:s=>{s.stopPropagation(),e.__awaiter(void 0,void 0,void 0,(function*(){if(window.confirm((null==P?void 0:P["delete-confirm"])||"Are you sure you want to delete this conversation?")){z(!1);try{yield l.pickaxeApi2.delete("/conversation",{data:Object.assign({sessionId:f.sessionId},D?{studioSessionToken:D}:_?{userId:_}:{})}),y&&y(f.sessionId)}catch(e){console.error("Error deleting conversation:",e),alert((null==P?void 0:P["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:[s.jsx(d.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"font-medium text-sm"},{children:(null==P?void 0:P["delete-chat"])||"Delete chat"}))]}))]}))]}))]}))]})})),s.jsxs("div",Object.assign({className:j.default("px-4 py-5 flex flex-col justify-between transition-all duration-200 ease-in-out",X?"h-auto min-h-[130px]":"h-[130px]"),style:{backgroundColor:q.secondary,color:q.secondaryText}},{children:[s.jsxs("div",Object.assign({className:"flex flex-col"},{children:[s.jsx("div",Object.assign({className:j.default("w-full",X?"mb-0":"mb-2")},{children:s.jsx(v.PickaxeMarkdown,Object.assign({theme:M.theme,colors:q},I&&{rtl:!0},S&&{disableHtml:!0},T&&{disableJs:!0},R&&{disableCss:!0},{children:s.jsx(b.PickaxeMarkdownRenderer,{style:{display:"block"},className:j.default("w-full",!X&&["[&_*]:!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"],X&&"[&_*]:!text-sm [&_*]:!font-semibold mb-0.5 [&_p]:!m-0"),value:ne})}))})),s.jsx("div",Object.assign({className:"w-full"},{children:s.jsx(v.PickaxeMarkdown,Object.assign({theme:M.theme,colors:q},I&&{rtl:!0},S&&{disableHtml:!0},T&&{disableJs:!0},R&&{disableCss:!0},{children:s.jsx(b.PickaxeMarkdownRenderer,{style:{display:"block"},className:j.default("w-full text-sm",!X&&["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"],X&&"font-normal opacity-90 mt-2 border-t pt-2 border-dashed"),value:ae,suppressedRichPreviewUrls:ie})}))}))]})),s.jsxs("div",Object.assign({className:"flex items-center justify-between mt-4 pt-2 border-t border-transparent"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-4"},{children:[((null==N?void 0:N.chatflag)||!(null==N?void 0:N.chatflag)&&(null==N?void 0:N.enablechatresponses))&&s.jsxs("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=f.sessionId,H([]),F([]),E(!1),A(s)},title:(null==P?void 0:P["open-chat"])||"Open Chat"},{children:[s.jsx(u.default,{className:"h-4 w-4"}),s.jsx("span",Object.assign({className:"text-sm font-medium"},{children:se}))]})),s.jsx("button",Object.assign({className:"transition-colors "+(B?"opacity-100":"opacity-70 hover:opacity-100"),onClick:e=>{e.stopPropagation(),navigator.clipboard.writeText(ae),K(!0),setTimeout((()=>{K(!1)}),2e3)},title:B?(null==P?void 0:P.copied)||"Copied!":(null==P?void 0:P["copy-assistant-message"])||"Copy assistant message"},{children:B?s.jsx(p.default,{className:"h-4 w-4",style:{color:q.accent},fill:q.accent}):s.jsx(m.default,{className:"h-4 w-4"})})),"FORM"===f.pickaxeType&&!(null==N?void 0:N.chatflag)&&!(null==N?void 0:N.enablechatresponses)&&(null===(w=null===(k=f.question)||void 0===k?void 0:k.responseParts)||void 0===w?void 0:w.some((e=>e.isVisible&&"text"===e.type&&e.content.trim())))&&(null==O?void 0:O({pickaxeId:C,sessionId:f.sessionId,kind:"form",responseReference:"form-result",agentName:(null==N?void 0:N.formtitle)||C,content:f.question.responseParts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n")}))]})),s.jsx("span",Object.assign({className:"text-xs font-semibold uppercase opacity-30 whitespace-nowrap"},{children:te}))]}))]}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../Addons/Scroll/hooks/useScrollContext.js"),l=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Artifact/hooks/useArtifact.js"),r=require("../../common/PickaxeMarkdown/index.js"),c=require("../../common/PickaxeIcon.js"),d=require("../../Addons/Scroll/ScrollLockView.js"),u=require("../../common/PickaxeMessageParts/index.js"),x=require("../../common/PickaxeMessageActions.js"),m=require("../../../../common/cn.js"),p=require("../../../../common/date.js");exports.default=()=>{var h,f,j,b,g,v;const{pickaxe:y,styles:k,colors:w,misc:C,translations:q,disableHtml:N,disableJs:O,disableCss:S,isRtl:A,setSessionId:I,setIsNewChat:P}=t.usePickaxeContext(),{response:D,isGenerating:M}=i.useResponseContext(),{scrollTargetRef:R}=n.useScrollContext(),{setDocuments:T}=l.useDocument(),{onLoadArtifact:$}=a.useArtifact(),F=o.useStyleFontSize(),H=p.formatLocalDateTime(null!==(h=null==D?void 0:D.sentAt)&&void 0!==h?h:new Date,"hh:mm a MMM dd, yy"),L=s.useMemo((()=>{var e,s;if(!D)return"";const t=(null==q?void 0:q["not-available"])||"n/a";return(null!==(s=null===(e=D.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[]).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||t}</p>\n</div>`)).join("")}),[D,q]);return D?e.jsxs("div",Object.assign({ref:R,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsx("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:w.primary,color:w.text}},{children:e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[e.jsx("input",{id:`${D.sessionId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:L.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:L}}),e.jsx("label",Object.assign({htmlFor:`${D.sessionId}-input`,className:m.default(F.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:w.accent}},{children:(null==q?void 0:q["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${D.sessionId}-input`,className:m.default(F.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:w.accent}},{children:(null==q?void 0:q["hide-input"])||"Hide input"}))]}))})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:w.secondary,color:w.secondaryText}},{children:[C.isChatImage&&e.jsx(c.default,{src:null==y?void 0:y.chaticon,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:w.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2"},{children:[e.jsx(r.PickaxeMarkdown,Object.assign({theme:k.theme,colors:w,isStreaming:M},A&&{rtl:!0},N&&{disableHtml:!0},O&&{disableJs:!0},S&&{disableCss:!0},{disableReasoning:null!==(f=null==y?void 0:y.enablereasoningdisplay)&&void 0!==f&&f,onArtifactClick:$},{children:e.jsx(u.default,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",parts:null!==(b=null===(j=D.question)||void 0===j?void 0:j.responseParts)&&void 0!==b?b:[],isStreaming:M})})),e.jsx("div",Object.assign({className:"flex flex-col"},{children:M?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:m.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:w.secondaryText}},t)))})):e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsx("div",Object.assign({className:"flex items-center gap-3"},{children:e.jsx(x.default,{content:(null!==(v=null===(g=D.question)||void 0===g?void 0:g.responseParts)&&void 0!==v?v:[]).filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),sessionId:D.sessionId,messagesCount:D.messageCount+1,onOpenChat:()=>{return e=D.sessionId,T([]),P(!1),void I(e);var e},isReadOut:!1})})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:m.default(F.b3,"font-semibold uppercase opacity-30")},{children:H}))}))]}))}))]}))]})),e.jsx(d.default,{})]})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../Addons/Scroll/hooks/useScrollContext.js"),l=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Artifact/hooks/useArtifact.js"),r=require("../../common/PickaxeMarkdown/index.js"),c=require("../../common/PickaxeIcon.js"),d=require("../../Addons/Scroll/ScrollLockView.js"),u=require("../../common/PickaxeMessageParts/index.js"),x=require("../../common/PickaxeMessageActions.js"),m=require("../../../../common/cn.js"),p=require("../../../../common/date.js");exports.default=()=>{var h,f,j,b,g,v;const{pickaxe:y,styles:k,colors:w,misc:C,translations:q,disableHtml:N,disableJs:O,disableCss:S,isRtl:A,setSessionId:I,setIsNewChat:P}=t.usePickaxeContext(),{response:D,isGenerating:M}=i.useResponseContext(),{scrollTargetRef:R}=n.useScrollContext(),{setDocuments:T}=l.useDocument(),{onLoadArtifact:$}=a.useArtifact(),F=o.useStyleFontSize(),H=p.formatLocalDateTime(null!==(h=null==D?void 0:D.sentAt)&&void 0!==h?h:new Date,"hh:mm a MMM dd, yy"),L=s.useMemo((()=>{var e,s;if(!D)return"";const t=(null==q?void 0:q["not-available"])||"n/a";return(null!==(s=null===(e=D.question)||void 0===e?void 0:e.inputs)&&void 0!==s?s:[]).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||t}</p>\n</div>`)).join("")}),[D,q]);return D?e.jsxs("div",Object.assign({ref:R,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsx("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:w.primary,color:w.text}},{children:e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[e.jsx("input",{id:`${D.sessionId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:L.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:L}}),e.jsx("label",Object.assign({htmlFor:`${D.sessionId}-input`,className:m.default(F.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:w.accent}},{children:(null==q?void 0:q["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${D.sessionId}-input`,className:m.default(F.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:w.accent}},{children:(null==q?void 0:q["hide-input"])||"Hide input"}))]}))})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:w.secondary,color:w.secondaryText}},{children:[C.isChatImage&&e.jsx(c.default,{src:null==y?void 0:y.chaticon,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:w.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2"},{children:[e.jsx(r.PickaxeMarkdown,Object.assign({theme:k.theme,colors:w,isStreaming:M},A&&{rtl:!0},N&&{disableHtml:!0},O&&{disableJs:!0},S&&{disableCss:!0},{disableReasoning:null!==(f=null==y?void 0:y.enablereasoningdisplay)&&void 0!==f&&f,onArtifactClick:$},{children:e.jsx(u.default,{className:"overflow-x-auto pb-2 font-semilight scrollbar scrollbar-thin",parts:null!==(b=null===(j=D.question)||void 0===j?void 0:j.responseParts)&&void 0!==b?b:[],isStreaming:M})})),e.jsx("div",Object.assign({className:"flex flex-col"},{children:M?e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded"},{children:Array.from({length:3}).map(((s,t)=>e.jsx("div",{className:m.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:w.secondaryText}},t)))})):e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsx("div",Object.assign({className:"flex items-center gap-3"},{children:e.jsx(x.default,{responseKind:"form",content:(null!==(v=null===(g=D.question)||void 0===g?void 0:g.responseParts)&&void 0!==v?v:[]).filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),sessionId:D.sessionId,messagesCount:D.messageCount+1,onOpenChat:()=>{return e=D.sessionId,T([]),P(!1),void I(e);var e},isReadOut:!1})})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:m.default(F.b3,"font-semibold uppercase opacity-30")},{children:H}))}))]}))}))]}))]})),e.jsx(d.default,{})]})):null};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../../../common/formQuestionValidation.js"),n=require("../../../../hooks/pickaxe/useEndUserModel.js"),i=require("../../common/EndUserModelPicker.js"),o=require("../../../../common/actionApproval.js"),r=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../Addons/Auth/hooks/useAuthContext.js"),d=require("../../../../hooks/pickaxe/useResponseContext.js"),u=require("../../Addons/Document/hooks/useDocument.js"),c=require("../../Addons/Scroll/hooks/useScroll.js"),p=require("../../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../../common/utils.js"),f=require("eventsource-parser"),g=require("../../common/PickaxeBranding.js"),v=require("../../common/PickaxeButton.js"),h=require("../../../../common/error.js"),x=require("../../../../common/validation.js");exports.default=({navigation:b,paged:j=!1,questions:y,resetQuestions:O,onInvalidQuestion:w})=>{var S;const{origin:k,pickaxeId:I,sender:A,senderType:C,portalId:P,deploymentId:E,pickaxe:q,misc:_,translations:N,isRtl:T,setSessionId:U,setIsNewChat:D,setValidationStatus:L,setValidationUpgradeGroups:V,setValidationUpgradeUrl:B,setAccessGroup:J,onGenerateComplete:R}=a.usePickaxeContext(),{value:K}=n.useEndUserModel(),{token:W}=l.useAuthContext(),{isGenerating:X,setResponse:M,setMessages:G,setStatus:F,setLimitData:Q,setError:$,setActionApprovalToken:z,setIsSwitchedToChat:Y}=d.useResponseContext(),{documents:H,websiteLink:Z,isUploading:ee,onWebsiteUpload:te,setDocuments:se,setDocumentError:ne}=u.useDocument(),{scrollStartSession:ie,scrollEndSession:oe,scrollToTarget:re}=c.useScroll({auto:!(null==q?void 0:q.enablechatresponses)}),{artifacts:ae,currentPopupType:le,setArtifacts:de,setCurrentArtifact:ue}=p.useArtifactContext(),[ce,pe]=r.useState(!1),[me,fe]=r.useState(!1),ge=r.useRef(null),ve=e=>{const t=x.getValidationFailure(e);return!!t&&($(""),Q(null),L(t.status),J(t.accessGroup),V(t.upgradeGroups),B(t.upgradeUrl),!0)},he=r.useMemo((()=>y.some((e=>("Short Answer"===e.type||"Long Answer"===e.type||"long"===e.type||"short"===e.type||"Checkbox"===e.type||"Knowledge Upload"===e.type||e.id.includes("documentupload"))&&e.input.length>0))),[y])&&t.jsx(v.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:ee||X||ce,onClick:O},{children:(null==N?void 0:N["form.clear-form"])||(null==N?void 0:N["clear-form"])||"Clear form"}));return t.jsxs("div",Object.assign({className:j?"flex flex-col gap-4":"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:T?"rtl":"ltr"},{children:[j&&t.jsx(i.default,{}),t.jsxs("div",Object.assign({className:j?"flex flex-wrap items-center justify-end gap-2":"flex items-center flex-grow flex-wrap gap-2"},{children:[!j&&t.jsx(i.default,{}),j&&b&&t.jsx("div",Object.assign({className:"me-auto shrink-0"},{children:b})),j&&he,t.jsx(v.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:ee||X||ce,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,n,i,r;try{if(X||ee||ce)return;$(""),ne(""),Q(null),M(null);for(const t of y){const n=s.getFormQuestionError(t);if(n)throw null==w||w(t.id),new Error(null!==(e=null==N?void 0:N[n])&&void 0!==e?e:"response-too-long"===n?"One or more of your responses is too long!":"You must fill out all required fields.")}const a=H.filter((e=>"finished"===e.status)),l=H.map((e=>e.name)),d=null!==(n=null===(t=null==q?void 0:q.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==n&&n,u=y.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),c=m.extractUrlsFromText(Z).filter((e=>!l.includes(e)));if(c.length){const e=c[c.length-1];pe(!0);const t=yield te(e);t&&(a.push(t),yield new Promise((e=>setTimeout(e,5e3)))),pe(!1)}else if(u&&d&&!a.length)return null==w||w("userinput:documentupload"),void ne((null==N?void 0:N["document-upload-required"])||"Please paste a valid website/video link or drag a file to add to the knowledge base.");const p=a.map((e=>e.documentId||"")).filter(Boolean),g=d&&p.length>0,v={};y.forEach((e=>{v[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?a.map((e=>e.name)).join(",")||"":e.input})),fe(!1),F("fetching"),ie(),re();const h=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,{method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},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()}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({supportsActionConfirmation:!0,selectedModel:K||void 0,origin:k,pickaxeId:I,senderType:C,valueObj:v},g&&{documentIds:p}),A&&{sender:A}),W&&{studioSessionToken:W}),!W&&!A&&{sender:m.initializeEmbedUserId()}),P&&{portalId:P}),E&&{deploymentId:E}))}),x=yield h.json();if(!x.success){const e=new Error(x.error||x.message||(null==N?void 0:N["failed-to-start-generation"])||"Failed to start generation");if(x.limitData)throw e.limitData=x.limitData,e;if(ve(x))return;throw e}if(!x.submissionId||!x.sessionId)throw new Error((null==N?void 0:N["failed-to-start-generation"])||"Failed to start generation");z(null!==(i=x.actionApprovalToken)&&void 0!==i?i:null);const b=x.submissionId,j=x.sessionId,O={sessionId:j,documentIds:g?p:[],question:{inputs:y.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};M(O),(null==q?void 0:q.enablechatresponses)&&(U(j),D(!1),Y(!0),G([{id:0,role:"assistant",parts:[],documentIds:[]}])),g&&se([]),F("streaming"),ge.current=new AbortController;const S=[];let _=[...null!=ae?ae:[]],T=0,L=!1,V="";for(;!L;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${b}?index=${T}`,{signal:null===(r=ge.current)||void 0===r?void 0:r.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),s=new TextDecoder,n=f.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&T++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Q(t.limitData),$(""),void(L=!0);const s=t.error||t.message||(null==N?void 0:N["something-went-wrong"])||"Something went wrong.";return ve(t)||$(s),void(L=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("finish"===n.type)return void fe(!0);if("text-start"===n.type)V="",S.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)V+=n.delta,o.updateStreamTextPart(S,"text",V);else if("text-end"===n.type)V="";else if("reasoning-start"===n.type)V="",S.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)V+=n.delta,o.updateStreamTextPart(S,"reasoning",V);else if("reasoning-end"===n.type)V="";else if(n.type.startsWith("data-")){const e=n;"data-action-approval"===e.type?o.upsertActionApprovalPart(S,e.data):S.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},O),{question:Object.assign(Object.assign({},O.question),{responseParts:[...S]})});M(i),(null==q?void 0:q.enablechatresponses)&&G([{id:0,role:"assistant",parts:[...S],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),de([..._]),le.startsWith("inline")||ue({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),de([..._]),le.startsWith("inline")||ue({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),de([..._]),le.startsWith("inline")||ue({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");_=_.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),de([..._])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);de(_.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else L=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}L||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if(e instanceof Error&&"AbortError"===e.name)return void(L=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==R||R(j)}catch(e){if((e=>e instanceof Error&&Boolean(e.limitData))(e))return Q(e.limitData),$(""),void re();let t=h.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==N?void 0:N["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),ve(t)||$(t),re()}finally{F("idle"),pe(!1),oe()}}))},{children:ce?(null==N?void 0:N.processing)||"Processing...":ee?(null==N?void 0:N.uploading)||"Uploading...":X&&!me?(null==N?void 0:N.loading)||"Loading...":null!==(S=null==q?void 0:q.submittext)&&void 0!==S?S:"Submit"})),!j&&he]})),!_.isWhiteLabel&&t.jsx(g.default,{containerClassName:"justify-end"})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../../../common/formQuestionValidation.js"),n=require("../../../../hooks/pickaxe/useEndUserModel.js"),i=require("../../common/EndUserModelPicker.js"),o=require("../../../../common/actionApproval.js"),r=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../Addons/Auth/hooks/useAuthContext.js"),d=require("../../../../hooks/pickaxe/useResponseContext.js"),u=require("../../Addons/Document/hooks/useDocument.js"),c=require("../../Addons/Scroll/hooks/useScroll.js"),p=require("../../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../../common/utils.js"),f=require("eventsource-parser"),g=require("../../common/PickaxeBranding.js"),v=require("../../common/PickaxeButton.js"),h=require("../../../../common/error.js"),x=require("../../../../common/validation.js");exports.default=({navigation:b,paged:j=!1,questions:y,resetQuestions:O,onInvalidQuestion:w})=>{var S;const{origin:k,pickaxeId:I,sender:A,senderType:C,portalId:P,deploymentId:E,pickaxe:q,misc:_,translations:N,isRtl:T,setSessionId:U,setIsNewChat:D,setValidationStatus:L,setValidationUpgradeGroups:R,setValidationUpgradeUrl:V,setAccessGroup:B,onGenerateComplete:J}=a.usePickaxeContext(),{value:K}=n.useEndUserModel(),{token:W}=l.useAuthContext(),{isGenerating:X,setResponse:M,setMessages:G,setStatus:F,setLimitData:Q,setError:$,setActionApprovalToken:z,setIsSwitchedToChat:Y}=d.useResponseContext(),{documents:H,websiteLink:Z,isUploading:ee,onWebsiteUpload:te,setDocuments:se,setDocumentError:ne}=u.useDocument(),{scrollStartSession:ie,scrollEndSession:oe,scrollToTarget:re}=c.useScroll({auto:!(null==q?void 0:q.enablechatresponses)}),{artifacts:ae,currentPopupType:le,setArtifacts:de,setCurrentArtifact:ue}=p.useArtifactContext(),[ce,pe]=r.useState(!1),[me,fe]=r.useState(!1),ge=r.useRef(null),ve=e=>{const t=x.getValidationFailure(e);return!!t&&($(""),Q(null),L(t.status),B(t.accessGroup),R(t.upgradeGroups),V(t.upgradeUrl),!0)},he=r.useMemo((()=>y.some((e=>("Short Answer"===e.type||"Long Answer"===e.type||"long"===e.type||"short"===e.type||"Checkbox"===e.type||"Knowledge Upload"===e.type||e.id.includes("documentupload"))&&e.input.length>0))),[y])&&t.jsx(v.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:ee||X||ce,onClick:O},{children:(null==N?void 0:N["form.clear-form"])||(null==N?void 0:N["clear-form"])||"Clear form"}));return t.jsxs("div",Object.assign({className:j?"flex flex-col gap-4":"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:T?"rtl":"ltr"},{children:[j&&t.jsx(i.default,{}),t.jsxs("div",Object.assign({className:j?"flex flex-wrap items-center justify-end gap-2":"flex items-center flex-grow flex-wrap gap-2"},{children:[!j&&t.jsx(i.default,{}),j&&b&&t.jsx("div",Object.assign({className:"me-auto shrink-0"},{children:b})),j&&he,t.jsx(v.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:ee||X||ce,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,n,i,r;try{if(X||ee||ce)return;$(""),ne(""),Q(null),M(null);for(const t of y){const n=s.getFormQuestionError(t);if(n)throw null==w||w(t.id),new Error(null!==(e=null==N?void 0:N[n])&&void 0!==e?e:"response-too-long"===n?"One or more of your responses is too long!":"You must fill out all required fields.")}const a=H.filter((e=>"finished"===e.status)),l=H.map((e=>e.name)),d=null!==(n=null===(t=null==q?void 0:q.documentuploadtype)||void 0===t?void 0:t.startsWith("enduserupload"))&&void 0!==n&&n,u=y.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),c=m.extractUrlsFromText(Z).filter((e=>!l.includes(e)));if(c.length){const e=c[c.length-1];pe(!0);const t=yield te(e);t&&(a.push(t),yield new Promise((e=>setTimeout(e,5e3)))),pe(!1)}else if(u&&d&&!a.length)return null==w||w("userinput:documentupload"),void ne((null==N?void 0:N["document-upload-required"])||"Please paste a valid website/video link or drag a file to add to the knowledge base.");const p=a.map((e=>e.documentId||"")).filter(Boolean),g=d&&p.length>0,v={};y.forEach((e=>{v[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?a.map((e=>e.name)).join(",")||"":e.input})),fe(!1),F("fetching"),ie(),re();const h=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,{method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},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()}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({supportsActionConfirmation:!0,selectedModel:K||void 0,origin:k,pickaxeId:I,senderType:C,valueObj:v},g&&{documentIds:p}),A&&{sender:A}),W&&{studioSessionToken:W}),!W&&!A&&{sender:m.initializeEmbedUserId()}),P&&{portalId:P}),E&&{deploymentId:E}))}),x=yield h.json();if(!x.success){const e=new Error(x.error||x.message||(null==N?void 0:N["failed-to-start-generation"])||"Failed to start generation");if(x.limitData)throw e.limitData=x.limitData,e;if(ve(x))return;throw e}if(!x.submissionId||!x.sessionId)throw new Error((null==N?void 0:N["failed-to-start-generation"])||"Failed to start generation");z(null!==(i=x.actionApprovalToken)&&void 0!==i?i:null);const b=x.submissionId,j=x.sessionId,O={sessionId:j,documentIds:g?p:[],question:{inputs:y.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};M(O),(null==q?void 0:q.enablechatresponses)&&(U(j),D(!1),Y(!0),G([{id:0,role:"assistant",parts:[],documentIds:[],responseReference:"form-result"}])),g&&se([]),F("streaming"),ge.current=new AbortController;const S=[];let _=[...null!=ae?ae:[]],T=0,L=!1,R="";for(;!L;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${b}?index=${T}`,{signal:null===(r=ge.current)||void 0===r?void 0:r.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),s=new TextDecoder,n=f.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&T++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Q(t.limitData),$(""),void(L=!0);const s=t.error||t.message||(null==N?void 0:N["something-went-wrong"])||"Something went wrong.";return ve(t)||$(s),void(L=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("finish"===n.type)return void fe(!0);if("text-start"===n.type)R="",S.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)R+=n.delta,o.updateStreamTextPart(S,"text",R);else if("text-end"===n.type)R="";else if("reasoning-start"===n.type)R="",S.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)R+=n.delta,o.updateStreamTextPart(S,"reasoning",R);else if("reasoning-end"===n.type)R="";else if(n.type.startsWith("data-")){const e=n;"data-action-approval"===e.type?o.upsertActionApprovalPart(S,e.data):S.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},O),{question:Object.assign(Object.assign({},O.question),{responseParts:[...S]})});M(i),(null==q?void 0:q.enablechatresponses)&&G([{id:0,responseReference:"form-result",role:"assistant",parts:[...S],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),de([..._]),le.startsWith("inline")||ue({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),de([..._]),le.startsWith("inline")||ue({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),de([..._]),le.startsWith("inline")||ue({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");_=_.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),de([..._])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);de(_.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else L=!0}});for(;;){const{value:e,done:i}=yield t.read();if(i)break;n.feed(s.decode(e))}L||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if(e instanceof Error&&"AbortError"===e.name)return void(L=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==J||J(j)}catch(e){if((e=>e instanceof Error&&Boolean(e.limitData))(e))return Q(e.limitData),$(""),void re();let t=h.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==N?void 0:N["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),ve(t)||$(t),re()}finally{F("idle"),pe(!1),oe()}}))},{children:ce?(null==N?void 0:N.processing)||"Processing...":ee?(null==N?void 0:N.uploading)||"Uploading...":X&&!me?(null==N?void 0:N.loading)||"Loading...":null!==(S=null==q?void 0:q.submittext)&&void 0!==S?S:"Submit"})),!j&&he]})),!_.isWhiteLabel&&t.jsx(g.default,{containerClassName:"justify-end"})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),o=require("./Addons/Artifact/Provider.js"),n=require("./DimensionProvider.js"),a=require("./ResponseProvider.js"),s=require("./Addons/Document/Provider.js"),r=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:p,senderType:f,deploymentId:g,portalId:m,deploymentType:h,deploymentDimensions:y,deploymentMisc:v,styles:b,colors:w,limits:S={},misc:k={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0,isResponseDownload:!1},translations:P,artifact:C={popupType:"auto"},responsiveBy:x="viewport",locale:I="en",opacity:F=1,forceMobile:A=!1,disableHtml:q=!1,disableJs:T=!1,disableCss:j=!1,loadFont:D=!0,isRtl:O=!1,isEmbed:U=!1,mcpEnabled:E=!1,mcpGuestId:R,studioSessionToken:M,isDropShadow:L=!1,allowGuestUsage:G=!0,persistActiveConversation:H=!1,preventInitialSessionId:W=!1,onUpgrade:_,onGenerateComplete:B,onSessionIdChange:N})=>{const[V,Y]=i.useState(""),[X,z]=i.useState(""),[J,Q]=i.useState(""),[K,Z]=i.useState(""),[$,ee]=i.useState(p),[te,ie]=i.useState(null),[oe,ne]=i.useState(f),[ae,se]=i.useState("loading"),[re,le]=i.useState([]),[de,ce]=i.useState(null),[ue,pe]=i.useState(null),[fe,ge]=i.useState(null),[me,he]=i.useState(null),[ye,ve]=i.useState("");i.useEffect((()=>ve("")),[X]);const[be,we]=i.useState(!1),[Se,ke]=i.useState(!0),[Pe,Ce]=i.useState(!0),[xe,Ie]=i.useState(!1);return i.useEffect((()=>{we(!1)}),[null==b?void 0:b.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&D&&!be&&(null==b?void 0:b.font)&&"Real Head Pro"!==b.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[b.font]},active:()=>{we(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),we(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),we(!0)}}))}),[D,be,null==b?void 0:b.font]),i.useEffect((()=>{ee(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign(Object.assign({origin:u,contextId:V,pickaxeId:X,sessionId:J,lastSessionId:K,sender:$,senderType:oe,portalId:m,deploymentId:g,deploymentType:h,validationStatus:ae,validationUpgradeGroups:re,validationUpgradeUrl:de,deploymentDimensions:y,deploymentMisc:v,accessGroup:te,pickaxe:me,selectedModel:ye,setSelectedModel:ve,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},b),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},w),misc:k,translations:Object.assign({"form-next":"Next","form-progress":"Form progress","form-page-progress":"Question {current} of {total}","action-confirmation-needed":"Confirmation needed","action-confirmation-unavailable":"Confirmation unavailable","action-approved":"Approved","action-declined":"Declined","action-expired":"Expired","action-not-run":"Not run","action-label":"Action: {name}","action-confirmation-description":"Review this action before it runs. Your decision applies only to this call.","action-inputs":"Action inputs","decline-action":"Decline","approve-action":"Approve action","action-confirmation-resolved":"This confirmation has expired or already been resolved.","action-decision-failed":"Could not save your decision. Please try again.","ai-model":"AI model","default-ai-model":"Default ({model})","attach-files":"Attach files","new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.","something-wrong-occured":"Something wrong occurred",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","enter-verification-code":"Or enter the 6-digit code from the email","verification-code-session-missing":"Your login request could not be found. Please resend the email.","verification-code-invalid":"Invalid verification code.",verifying:"Verifying...",verify:"Verify","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","mcp-use-with-ai-app":"Use with an AI app","mcp-use-agent-in-ai-app":"Use this agent in your AI app","mcp-connect-description":"Connect through MCP. Requests will be sent as your signed-in Studio user.","mcp-ai-app":"AI app","mcp-copy-configuration":"Copy MCP configuration","mcp-private-configuration-note":"Keep this configuration private. It contains your Studio session token and stops working when that session expires.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.","queue-message":"Queue message","stop-response":"Stop response",steer:"Steer","steer-with":"Steer with",steering:"Steering...",starting:"Starting...","remove-queued-message":"Remove queued message","edit-message":"Edit message","more-options":"More options","failed-to-interrupt-current-response":"Failed to interrupt the current response.","current-response-still-stopping":"The current response is still stopping. Please send your message again in a moment.","queued-message-waiting":"A queued message is waiting for the previous response to finish.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, GIF, or M4A files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},P),artifact:C,responsiveBy:x,locale:I,opacity:F,forceMobile:A,loadFont:D,disableHtml:q,disableJs:T,disableCss:j,isFontLoaded:be,isNewChat:Se,isShowIceBreaker:Pe,isShowFeedbackMessage:xe,isRtl:O,isEmbed:U,mcpEnabled:E,mcpGuestId:R,isDropShadow:L,allowGuestUsage:G,persistActiveConversation:H,clientSecret:fe,stripeAccountId:ue,preventInitialSessionId:W,setClientSecret:ge,setStripeAccountId:pe,setContextId:Y,setValidationStatus:se,setValidationUpgradeGroups:le,setValidationUpgradeUrl:ce,setPickaxeId:z,setSessionId:e=>{Q((t=>{const i="function"==typeof e?e(t):e;return null==N||N(i),i}))},setLastSessionId:Z,setSender:ee,setSenderType:ne,setAccessGroup:ie,setPickaxe:he,setIsFontLoaded:we,setIsNewChat:ke,setIsShowIceBreaker:Ce,setIsShowFeedbackMessage:Ie},_&&{onUpgrade:_}),B&&{onGenerateComplete:B})},{children:t.jsx(r.default,Object.assign({initialToken:M},{children:t.jsx(n.default,{children:t.jsx(a.default,Object.assign({limits:S},{children:t.jsx(s.default,{children:t.jsx(o.ArtifactProvider,Object.assign({},C,{children:c}))})}))})}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),o=require("./Addons/Artifact/Provider.js"),n=require("./DimensionProvider.js"),a=require("./ResponseProvider.js"),s=require("./Addons/Document/Provider.js"),r=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,renderResponseAction:u,origin:p,sender:f,senderType:g,deploymentId:m,portalId:h,deploymentType:y,deploymentDimensions:v,deploymentMisc:b,styles:w,colors:S,limits:k={},misc:P={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0,isResponseDownload:!1},translations:C,artifact:x={popupType:"auto"},responsiveBy:I="viewport",locale:F="en",opacity:A=1,forceMobile:q=!1,disableHtml:T=!1,disableJs:j=!1,disableCss:D=!1,loadFont:O=!0,isRtl:U=!1,isEmbed:R=!1,mcpEnabled:E=!1,mcpGuestId:M,studioSessionToken:L,isDropShadow:G=!1,allowGuestUsage:H=!0,persistActiveConversation:W=!1,preventInitialSessionId:_=!1,onUpgrade:B,onGenerateComplete:N,onSessionIdChange:V})=>{const[Y,X]=i.useState(""),[z,J]=i.useState(""),[Q,K]=i.useState(""),[Z,$]=i.useState(""),[ee,te]=i.useState(f),[ie,oe]=i.useState(null),[ne,ae]=i.useState(g),[se,re]=i.useState("loading"),[le,de]=i.useState([]),[ce,ue]=i.useState(null),[pe,fe]=i.useState(null),[ge,me]=i.useState(null),[he,ye]=i.useState(null),[ve,be]=i.useState("");i.useEffect((()=>be("")),[z]);const[we,Se]=i.useState(!1),[ke,Pe]=i.useState(!0),[Ce,xe]=i.useState(!0),[Ie,Fe]=i.useState(!1);return i.useEffect((()=>{Se(!1)}),[null==w?void 0:w.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&O&&!we&&(null==w?void 0:w.font)&&"Real Head Pro"!==w.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[w.font]},active:()=>{Se(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),Se(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),Se(!0)}}))}),[O,we,null==w?void 0:w.font]),i.useEffect((()=>{te(f)}),[f]),t.jsx(d.Provider,Object.assign({value:Object.assign(Object.assign({origin:p,contextId:Y,pickaxeId:z,sessionId:Q,lastSessionId:Z,sender:ee,senderType:ne,portalId:h,deploymentId:m,deploymentType:y,validationStatus:se,validationUpgradeGroups:le,validationUpgradeUrl:ce,deploymentDimensions:v,deploymentMisc:b,accessGroup:ie,pickaxe:he,selectedModel:ve,setSelectedModel:be,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},w),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},S),misc:P,translations:Object.assign({"form-next":"Next","form-progress":"Form progress","form-page-progress":"Question {current} of {total}","action-confirmation-needed":"Confirmation needed","action-confirmation-unavailable":"Confirmation unavailable","action-approved":"Approved","action-declined":"Declined","action-expired":"Expired","action-not-run":"Not run","action-label":"Action: {name}","action-confirmation-description":"Review this action before it runs. Your decision applies only to this call.","action-inputs":"Action inputs","decline-action":"Decline","approve-action":"Approve action","action-confirmation-resolved":"This confirmation has expired or already been resolved.","action-decision-failed":"Could not save your decision. Please try again.","ai-model":"AI model","default-ai-model":"Default ({model})","attach-files":"Attach files","new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.","something-wrong-occured":"Something wrong occurred",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","enter-verification-code":"Or enter the 6-digit code from the email","verification-code-session-missing":"Your login request could not be found. Please resend the email.","verification-code-invalid":"Invalid verification code.",verifying:"Verifying...",verify:"Verify","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","mcp-use-with-ai-app":"Use with an AI app","mcp-use-agent-in-ai-app":"Use this agent in your AI app","mcp-connect-description":"Connect through MCP. Requests will be sent as your signed-in Studio user.","mcp-ai-app":"AI app","mcp-copy-configuration":"Copy MCP configuration","mcp-private-configuration-note":"Keep this configuration private. It contains your Studio session token and stops working when that session expires.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.","queue-message":"Queue message","stop-response":"Stop response",steer:"Steer","steer-with":"Steer with",steering:"Steering...",starting:"Starting...","remove-queued-message":"Remove queued message","edit-message":"Edit message","more-options":"More options","failed-to-interrupt-current-response":"Failed to interrupt the current response.","current-response-still-stopping":"The current response is still stopping. Please send your message again in a moment.","queued-message-waiting":"A queued message is waiting for the previous response to finish.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, GIF, or M4A files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},C),artifact:x,renderResponseAction:u,responsiveBy:I,locale:F,opacity:A,forceMobile:q,loadFont:O,disableHtml:T,disableJs:j,disableCss:D,isFontLoaded:we,isNewChat:ke,isShowIceBreaker:Ce,isShowFeedbackMessage:Ie,isRtl:U,isEmbed:R,mcpEnabled:E,mcpGuestId:M,isDropShadow:G,allowGuestUsage:H,persistActiveConversation:W,clientSecret:ge,stripeAccountId:pe,preventInitialSessionId:_,setClientSecret:me,setStripeAccountId:fe,setContextId:X,setValidationStatus:re,setValidationUpgradeGroups:de,setValidationUpgradeUrl:ue,setPickaxeId:J,setSessionId:e=>{K((t=>{const i="function"==typeof e?e(t):e;return null==V||V(i),i}))},setLastSessionId:$,setSender:te,setSenderType:ae,setAccessGroup:oe,setPickaxe:ye,setIsFontLoaded:Se,setIsNewChat:Pe,setIsShowIceBreaker:xe,setIsShowFeedbackMessage:Fe},B&&{onUpgrade:B}),N&&{onGenerateComplete:N})},{children:t.jsx(r.default,Object.assign({initialToken:L},{children:t.jsx(n.default,{children:t.jsx(a.default,Object.assign({limits:k},{children:t.jsx(s.default,{children:t.jsx(o.ArtifactProvider,Object.assign({},x,{children:c}))})}))})}))}))};