@pickaxeproject/react 6.17.0 → 6.18.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/cjs/common/chatMessages.js +1 -1
  2. package/dist/cjs/common/embedSession.js +1 -0
  3. package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuthBootstrap.js +1 -1
  4. package/dist/cjs/components/Pickaxe/Chat/History/Message.js +1 -1
  5. package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
  6. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  7. package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
  8. package/dist/cjs/components/Pickaxe/Provider.js +1 -1
  9. package/dist/cjs/components/Pickaxe/common/PickaxeLogoutButton.js +1 -1
  10. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Action/index.js +1 -1
  11. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/index.js +1 -1
  12. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -1
  13. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.js +1 -1
  14. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
  15. package/dist/cjs/components/Pickaxe/index.js +1 -1
  16. package/dist/cjs/hooks/pickaxe/useConversation.js +1 -1
  17. package/dist/cjs/hooks/pickaxe/useTextToSpeech.js +1 -1
  18. package/dist/cjs/src/common/chatMessages.d.ts +1 -1
  19. package/dist/cjs/src/common/embedSession.d.ts +15 -0
  20. package/dist/cjs/src/components/Pickaxe/Provider.d.ts +3 -1
  21. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +1 -0
  22. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +3 -1
  23. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.d.ts +2 -1
  24. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.d.ts +2 -1
  25. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/index.d.ts +2 -1
  26. package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
  27. package/dist/esm/common/chatMessages.js +1 -1
  28. package/dist/esm/common/embedSession.js +1 -0
  29. package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuthBootstrap.js +1 -1
  30. package/dist/esm/components/Pickaxe/Chat/History/Message.js +1 -1
  31. package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
  32. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  33. package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
  34. package/dist/esm/components/Pickaxe/Provider.js +1 -1
  35. package/dist/esm/components/Pickaxe/common/PickaxeLogoutButton.js +1 -1
  36. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Action/index.js +1 -1
  37. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/index.js +1 -1
  38. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -1
  39. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.js +1 -1
  40. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
  41. package/dist/esm/components/Pickaxe/index.js +1 -1
  42. package/dist/esm/hooks/pickaxe/useConversation.js +1 -1
  43. package/dist/esm/hooks/pickaxe/useTextToSpeech.js +1 -1
  44. package/dist/esm/src/common/chatMessages.d.ts +1 -1
  45. package/dist/esm/src/common/embedSession.d.ts +15 -0
  46. package/dist/esm/src/components/Pickaxe/Provider.d.ts +3 -1
  47. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +1 -0
  48. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +3 -1
  49. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.d.ts +2 -1
  50. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.d.ts +2 -1
  51. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/index.d.ts +2 -1
  52. package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +1 -0
  53. package/package.json +1 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=t=>{if("string"==typeof t)return t;if(null==t)return"";try{return JSON.stringify(t)}catch(e){return String(t)}},e=e=>{if(!e||"object"!=typeof e)return null;const r=e;return"string"!=typeof r.type?null:{type:r.type,content:t(r.content),isVisible:!1!==r.isVisible}},r=(t,r)=>{let s=t;if("string"==typeof s)try{const t=JSON.parse(s);Array.isArray(t)&&(s=t)}catch(t){}if(Array.isArray(s))return s.map(e).filter((t=>null!==t));const n=e(s);if(n)return[n];const i="string"==typeof s?s:r;return"string"==typeof i&&i?[{type:"text",content:i,isVisible:!0}]:[]},s=t=>{const e=r(t.parts).filter((t=>!1!==t.isVisible)),s=e.filter((t=>"text"===t.type)).map((t=>{var e;return null!==(e=t.content)&&void 0!==e?e:""})).join(""),n=s.replace(/\s+/g," ").replace(/\s*([.,!?;:])\s*/g,"$1").trim();return n?JSON.stringify({role:t.role,text:n}):JSON.stringify({role:t.role,parts:e.map((t=>{var e;return{type:t.type,content:null!==(e=t.content)&&void 0!==e?e:""}}))})};exports.getUnpersistedMemoryMessages=(t,e)=>{if(!e.length||!t.length)return t;const r=e.map(s),n=new Set(e.filter((t=>"assistant"===t.role)).map(s));let i=0;return t.filter((t=>{const e=s(t),o=r.indexOf(e,i);return-1!==o?(i=o+1,!1):"assistant"!==t.role||!n.has(e)}))},exports.normalizeHistoryMessages=t=>Array.isArray(t)?t.flatMap((t=>{var e;if(!t||"object"!=typeof t)return[];const s=t;return"user"!==s.role&&"assistant"!==s.role?[]:[Object.assign(Object.assign({},s),{documentIds:Array.isArray(s.documentIds)?s.documentIds.filter((t=>"string"==typeof t)):[],parts:r(s.parts,null!==(e=s.content)&&void 0!==e?e:s.message)})]})):[],exports.normalizeMessageParts=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const t=t=>{if("string"==typeof t)return t;if(null==t)return"";try{return JSON.stringify(t)}catch(e){return String(t)}},e=e=>{if(!e||"object"!=typeof e)return null;const r=e;return"string"!=typeof r.type?null:{type:r.type,content:t(r.content),isVisible:!1!==r.isVisible}},r=(t,r)=>{let n=t;if("string"==typeof n)try{const t=JSON.parse(n);Array.isArray(t)&&(n=t)}catch(t){}if(Array.isArray(n))return n.map(e).filter((t=>null!==t));const s=e(n);if(s)return[s];const i="string"==typeof n?n:r;return"string"==typeof i&&i?[{type:"text",content:i,isVisible:!0}]:[]},n=t=>{var e,n;const s=r(t.parts).filter((t=>!1!==t.isVisible)),i=s.filter((t=>"text"===t.type)).map((t=>{var e;return null!==(e=t.content)&&void 0!==e?e:""})).join(""),o=i.replace(/\s+/g," ").replace(/\s*([.,!?;:])\s*/g,"$1").trim();return o?JSON.stringify({role:t.role,text:o,documentIds:null!==(e=t.documentIds)&&void 0!==e?e:[]}):JSON.stringify({role:t.role,documentIds:null!==(n=t.documentIds)&&void 0!==n?n:[],parts:s.map((t=>{var e;return{type:t.type,content:null!==(e=t.content)&&void 0!==e?e:""}}))})};exports.mergeConversationMessages=(t,e)=>{if(!t.length)return e;if(!e.length)return t;const r=e.map(n),s=t.map(n),i=((t,e)=>{const r=Array.from({length:t.length+1},(()=>Array(e.length+1).fill(0)));for(let n=t.length-1;n>=0;n-=1)for(let s=e.length-1;s>=0;s-=1)r[n][s]=t[n]===e[s]?r[n+1][s+1]+1:Math.max(r[n+1][s],r[n][s+1]);return r})(r,s),o=[];let l=0,a=0;for(;l<e.length&&a<t.length;){const n=i[l][a];if(r[l]===s[a]){if(i[l+1][a]===n){o.push(e[l]),l+=1;continue}if(i[l][a+1]===n){o.push(t[a]),a+=1;continue}o.push(e[l]),l+=1,a+=1}else i[l+1][a]>=i[l][a+1]?(o.push(e[l]),l+=1):(o.push(t[a]),a+=1)}return[...o,...e.slice(l),...t.slice(a)]},exports.normalizeHistoryMessages=t=>Array.isArray(t)?t.flatMap((t=>{var e;if(!t||"object"!=typeof t)return[];const n=t;return"user"!==n.role&&"assistant"!==n.role?[]:[Object.assign(Object.assign({},n),{documentIds:Array.isArray(n.documentIds)?n.documentIds.filter((t=>"string"==typeof t)):[],parts:r(n.parts,null!==(e=n.content)&&void 0!==e?e:n.message)})]})):[],exports.normalizeMessageParts=r;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../_virtual/_tslib.js");const t="PXE-auth-active-conversation-v1",n=e=>encodeURIComponent(e.trim()),o=e=>{let t=2166136261,n=2654435769;for(let o=0;o<e.length;o+=1){const r=e.charCodeAt(o);t=Math.imul(t^r,16777619),n=Math.imul(n^r,2246822507)}return[t,n].map((e=>(e>>>0).toString(16).padStart(8,"0"))).join("")},r=({deploymentId:e,pickaxeId:r,authToken:i})=>[t,n(e),n(r),o(i)].join(":");exports.clearAuthenticatedEmbedSession=e=>{try{if("undefined"==typeof window)return;window.localStorage.removeItem(r(e))}catch(e){console.warn("[pxe] failed to clear authenticated embed session",e)}},exports.getAuthenticatedEmbedSessionStorageKey=r,exports.readAuthenticatedEmbedSession=e=>{var t;try{if("undefined"==typeof window)return null;const n=window.localStorage.getItem(r(e));if(!n)return null;const o=null===(t=JSON.parse(n).sessionId)||void 0===t?void 0:t.trim();return o?{sessionId:o}:null}catch(e){return console.warn("[pxe] failed to read authenticated embed session",e),null}},exports.writeAuthenticatedEmbedSession=t=>{var{sessionId:n}=t,o=e.__rest(t,["sessionId"]);try{if("undefined"==typeof window)return;const e=n.trim();if(!e)return;window.localStorage.setItem(r(o),JSON.stringify({sessionId:e}))}catch(e){console.warn("[pxe] failed to store authenticated embed session",e)}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../../common/utils.js"),i=require("./useAuthContext.js"),u=require("./useAuthVerify.js");exports.useAuthBootstrap=()=>{const{pickaxe:r,setSender:n,setSenderType:a}=t.usePickaxeContext(),{setLimitData:c}=s.useResponseContext(),{token:d,isLoggedOut:k,isPricingAuth:g,setToken:h,setIsLoggingIn:l,setIsPricingAuth:x,setIsAuthBootstrapComplete:f}=i.useAuthContext(),p=(null==r?void 0:r.studioid)||"",A=p?`PXE-token-${p}`:"",v=o.getAuthToken(p)||"",C=u.useAuthVerify({token:v,enabled:k&&!!v,setIsLoggingIn:l});e.useEffect((()=>{p&&f(!1)}),[f,p]);const E=e.useCallback((e=>{o.setAuthToken(A,e),h(e),n(void 0),a("STUDIO_USER"),g&&(x(!1),c(null))}),[A,g,x,c,n,a,h]);e.useEffect((()=>{if(!A)return;if(!C.data)return;const{success:e,token:t,error:s}=C.data;if(!e||s)return o.deleteAuthToken(A),x(!1),void f(!0);t&&(E(t),f(!0))}),[E,A,C.data,f,x]),e.useEffect((()=>{var e;p&&(d?f(!0):v?C.isLoading||C.isFetching||(C.isError||C.isSuccess&&!(null===(e=C.data)||void 0===e?void 0:e.token))&&f(!0):f(!0))}),[C.data,C.isError,C.isFetching,C.isLoading,C.isSuccess,f,v,p,d])};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../../../common/utils.js"),i=require("./useAuthContext.js"),n=require("./useAuthVerify.js"),u=require("../../../../../common/embedSession.js");exports.useAuthBootstrap=()=>{const{deploymentId:r,pickaxe:d,setSender:a,setSenderType:c}=t.usePickaxeContext(),{setLimitData:l}=s.useResponseContext(),{token:k,isLoggedOut:h,isPricingAuth:f,setToken:g,setIsLoggingIn:p,setIsPricingAuth:x,setIsAuthBootstrapComplete:m}=i.useAuthContext(),A=(null==d?void 0:d.studioid)||"",v=A?`PXE-token-${A}`:"",I=o.getAuthToken(A)||"",C=n.useAuthVerify({token:I,enabled:h&&!!I,setIsLoggingIn:p});e.useEffect((()=>{A&&m(!1)}),[m,A]);const E=e.useCallback((e=>{o.setAuthToken(v,e),g(e),a(void 0),c("STUDIO_USER"),f&&(x(!1),l(null))}),[v,f,x,l,a,c,g]);e.useEffect((()=>{if(!v)return;if(!C.data)return;const{success:e,token:t,error:s}=C.data;if(!e||s)return r&&(null==d?void 0:d.formid)&&I&&u.clearAuthenticatedEmbedSession({deploymentId:r,pickaxeId:d.formid,authToken:I}),o.deleteAuthToken(v),x(!1),void m(!0);t&&(E(t),m(!0))}),[E,v,C.data,r,null==d?void 0:d.formid,m,x,I]),e.useEffect((()=>{var e;A&&(k?m(!0):I?C.isLoading||C.isFetching||(C.isError||C.isSuccess&&!(null===(e=C.data)||void 0===e?void 0:e.token))&&m(!0):m(!0))}),[C.data,C.isError,C.isFetching,C.isLoading,C.isSuccess,m,I,A,k])};
@@ -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/studio/useStyleFontSize.js"),a=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Artifact/hooks/useArtifact.js"),o=require("../../common/PickaxeMarkdown/index.js"),l=require("../../common/PickaxeIcon.js"),n=require("./Document.js"),d=require("../../common/PickaxeMessageActions.js"),c=require("../../common/PickaxeMessageParts/index.js"),u=require("../../../../common/cn.js"),x=require("../../../../common/isoMap.js"),m=require("franc-min"),p=require("../../common/ComposioConnectView.js"),f=require("../../common/SmitheryConnectView.js"),j=require("../../../../hooks/pickaxe/useTextToSpeech.js");function h(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var g=h(require("remove-markdown"));exports.default=({index:h,message:b,smitheryData:v,resubmitPrompt:k,isLastMessage:y=!1})=>{var w,O;const{pickaxeId:N,pickaxe:q,styles:C,colors:I,misc:P,responsiveBy:A,disableHtml:R,disableJs:S,disableCss:M,isNewChat:T,isRtl:L}=t.usePickaxeContext(),{isGenerating:F}=a.useResponseContext(),{onLoadArtifact:H}=r.useArtifact(),J=i.useStyleFontSize(),V=null!==(w=null==q?void 0:q.chaticon)&&void 0!==w?w:`https://cdn.mail.studio/chaticons/${N}.png`,z=y&&F,B=null==q?void 0:q.enablereadout,{isLoading:D,isSpeaking:_,speak:E,stop:G}=j.useTextToSpeech(B&&"assistant"===b.role,{provider:null==q?void 0:q.readoutprovider,pickaxeId:N,voiceName:null==q?void 0:q.readoutvoice}),U=()=>{if(D||_)return void G();const e=b.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ");if(!e)return;const s=g.default(e,{stripListLeaders:!0,listUnicodeChar:"",gfm:!0,useImgAltText:!1}),t=m.franc(s),i=x.convertToIso1(t);E(s,i)},$=!b.parts.some((e=>["text","reasoning","data-action-tool-caption"].includes(e.type)));return"assistant"===b.role?e.jsx("div",Object.assign({className:u.default("flex w-full",L?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:u.default("flex flex-col w-full",0===h&&T&&"viewport"===A&&"min-[767px]:max-w-[80%]",0===h&&T&&"container"===A&&"@[767px]/pickaxe-root:max-w-[80%]")},{children:e.jsxs("div",Object.assign({className:u.default("flex gap-x-3",L&&"flex-row-reverse")},{children:[P.isChatImage&&"NONE"!==V&&e.jsx(l.default,{src:V,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:I.text}),e.jsxs("div",Object.assign({className:u.default("flex flex-col flex-grow",L?"items-end":"items-start")},{children:[e.jsxs("div",Object.assign({className:u.default(J.b2,"chat-message pt-3 w-full",L?"text-right":"text-left")},{children:[e.jsx(o.PickaxeMarkdown,Object.assign({theme:C.theme,colors:I},L&&{rtl:!0},R&&{disableHtml:!0},S&&{disableJs:!0},M&&{disableCss:!0},{disableReasoning:null!==(O=null==q?void 0:q.enablereasoningdisplay)&&void 0!==O&&O,onArtifactClick:H},{children:e.jsx(c.default,{parts:b.parts})})),y&&v&&k&&("composio"===v.provider?e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(p.default,{serverId:v.serverId,toolkitSlug:v.toolkitSlug||"",name:v.name,resubmitPrompt:()=>k()})})):e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(f.default,{serverId:v.serverId,smitheryId:v.smitheryId||"",name:v.name||v.smitheryId,resubmitPrompt:()=>k()})})))]})),e.jsx("div",Object.assign({className:u.default("flex flex-col gap-6 my-4",$&&"mt-2")},{children:z?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:u.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:I.secondaryText}},t)))})):e.jsx(d.default,Object.assign({content:b.parts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),index:h},"intromessage"===b.area&&{isHideFeedback:!0},{onReadOut:U,isReadOut:B||!1,isReadOutLoading:D,isReading:_}))}))]}))]}))}))})):"user"===b.role?e.jsx("div",Object.assign({className:u.default("flex w-full",L?"justify-start":"justify-end")},{children:e.jsx("div",Object.assign({className:u.default("flex gap-x-3 max-w-[80%]",L?"pr-9":"pl-9","viewport"===A?L?"min-[767px]:pr-0":"min-[767px]:pl-0":L?"@[767px]/pickaxe-root:pr-0":"@[767px]/pickaxe-root:pl-0")},{children:e.jsxs("div",Object.assign({className:u.default(J.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",L?"text-right":"text-left"),style:{backgroundColor:I.secondary+"80",color:I.secondaryText,borderRadius:C.cornerRadius}},{children:[b.documentIds&&b.documentIds.length>0&&e.jsx("div",Object.assign({className:u.default("flex flex-col gap-y-2",L?"items-start":"items-end")},{children:b.documentIds.map((t=>e.jsx(s.Fragment,{children:e.jsx(n.default,{documentId:t})},t)))})),e.jsx(o.PickaxeMarkdown,Object.assign({theme:C.theme,colors:I},L&&{rtl:!0},R&&{disableHtml:!0},S&&{disableJs:!0},M&&{disableCss:!0},{children:e.jsx(c.default,{parts:b.parts})}))]}))}))})):e.jsx("div",{})};
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/studio/useStyleFontSize.js"),a=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Artifact/hooks/useArtifact.js"),o=require("../../common/PickaxeMarkdown/index.js"),l=require("../../common/PickaxeIcon.js"),n=require("./Document.js"),d=require("../../common/PickaxeMessageActions.js"),c=require("../../common/PickaxeMessageParts/index.js"),u=require("../../../../common/cn.js"),m=require("../../../../common/isoMap.js"),x=require("franc-min"),p=require("../../common/ComposioConnectView.js"),f=require("../../common/SmitheryConnectView.js"),j=require("../../../../hooks/pickaxe/useTextToSpeech.js");function g(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=g(require("remove-markdown"));exports.default=({index:g,message:b,smitheryData:v,resubmitPrompt:k,isLastMessage:y=!1})=>{var w,O;const{pickaxeId:N,pickaxe:q,styles:C,colors:I,misc:P,responsiveBy:A,disableHtml:S,disableJs:R,disableCss:M,isNewChat:T,isRtl:L}=t.usePickaxeContext(),{isGenerating:F}=a.useResponseContext(),{onLoadArtifact:H}=r.useArtifact(),J=i.useStyleFontSize(),V=null!==(w=null==q?void 0:q.chaticon)&&void 0!==w?w:`https://cdn.mail.studio/chaticons/${N}.png`,z=y&&F,B=null==q?void 0:q.enablereadout,{isLoading:D,isSpeaking:_,speak:E,stop:G}=j.useTextToSpeech(B&&"assistant"===b.role,{provider:null==q?void 0:q.readoutprovider,pickaxeId:N,voiceName:null==q?void 0:q.readoutvoice}),U=()=>{if(D||_)return void G();const e=b.parts.filter((e=>"text"===e.type)).map((e=>e.content)).join(" ");if(!e)return;const s=h.default(e,{stripListLeaders:!0,listUnicodeChar:"",gfm:!0,useImgAltText:!1}),t=x.franc(s),i=m.convertToIso1(t);E(s,i)},$=!b.parts.some((e=>["text","reasoning","data-action-tool-caption"].includes(e.type)));return"assistant"===b.role?e.jsx("div",Object.assign({className:u.default("flex w-full",L?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:u.default("flex flex-col w-full",0===g&&T&&"viewport"===A&&"min-[767px]:max-w-[80%]",0===g&&T&&"container"===A&&"@[767px]/pickaxe-root:max-w-[80%]")},{children:e.jsxs("div",Object.assign({className:u.default("flex gap-x-3",L&&"flex-row-reverse")},{children:[P.isChatImage&&"NONE"!==V&&e.jsx(l.default,{src:V,alt:"Assistant",width:24,height:24,className:"my-3 h-6 w-6",textColor:I.text}),e.jsxs("div",Object.assign({className:u.default("flex flex-col flex-grow",L?"items-end":"items-start")},{children:[e.jsxs("div",Object.assign({className:u.default(J.b2,"chat-message pt-3 w-full",L?"text-right":"text-left")},{children:[e.jsx(o.PickaxeMarkdown,Object.assign({theme:C.theme,colors:I,isStreaming:z},L&&{rtl:!0},S&&{disableHtml:!0},R&&{disableJs:!0},M&&{disableCss:!0},{disableReasoning:null!==(O=null==q?void 0:q.enablereasoningdisplay)&&void 0!==O&&O,onArtifactClick:H},{children:e.jsx(c.default,{parts:b.parts,isStreaming:z})})),y&&v&&k&&("composio"===v.provider?e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(p.default,{serverId:v.serverId,toolkitSlug:v.toolkitSlug||"",name:v.name,resubmitPrompt:()=>k()})})):e.jsx("div",Object.assign({className:"mt-4 px-1"},{children:e.jsx(f.default,{serverId:v.serverId,smitheryId:v.smitheryId||"",name:v.name||v.smitheryId,resubmitPrompt:()=>k()})})))]})),e.jsx("div",Object.assign({className:u.default("flex flex-col gap-6 my-4",$&&"mt-2")},{children:z?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:u.default("h-1.5 w-1.5 animate-dot rounded-full",1===t&&"animate-dot-down"),style:{backgroundColor:I.secondaryText}},t)))})):e.jsx(d.default,Object.assign({content:b.parts.filter((e=>e.isVisible&&"text"===e.type)).map((e=>e.content)).join("\n"),index:g},"intromessage"===b.area&&{isHideFeedback:!0},{onReadOut:U,isReadOut:B||!1,isReadOutLoading:D,isReading:_}))}))]}))]}))}))})):"user"===b.role?e.jsx("div",Object.assign({className:u.default("flex w-full",L?"justify-start":"justify-end")},{children:e.jsx("div",Object.assign({className:u.default("flex gap-x-3 max-w-[80%]",L?"pr-9":"pl-9","viewport"===A?L?"min-[767px]:pr-0":"min-[767px]:pl-0":L?"@[767px]/pickaxe-root:pr-0":"@[767px]/pickaxe-root:pl-0")},{children:e.jsxs("div",Object.assign({className:u.default(J.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",L?"text-right":"text-left"),style:{backgroundColor:I.secondary+"80",color:I.secondaryText,borderRadius:C.cornerRadius}},{children:[b.documentIds&&b.documentIds.length>0&&e.jsx("div",Object.assign({className:u.default("flex flex-col gap-y-2",L?"items-start":"items-end")},{children:b.documentIds.map((t=>e.jsx(s.Fragment,{children:e.jsx(n.default,{documentId:t})},t)))})),e.jsx(o.PickaxeMarkdown,Object.assign({theme:C.theme,colors:I},L&&{rtl:!0},S&&{disableHtml:!0},R&&{disableJs:!0},M&&{disableCss:!0},{children:e.jsx(c.default,{parts:b.parts})}))]}))}))})):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"),t=require("../../Addons/Auth/hooks/useAuthContext.js"),a=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"),m=require("../../../Icons/lock.svg.js"),x=require("../../../Core/ErrorAlert.js"),h=require("../../common/PickaxeHead.js"),f=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"),y=require("../../Addons/Artifact/Renderer/index.js"),b=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:M,onSubmit:I,resubmitPrompt:L})=>{var H,R,D,F,B,E,T;const{sessionId:z,deploymentType:$,pickaxe:W,translations:_,misc:U,isNewChat:V,isRtl:G,isEmbed:J,isShowIceBreaker:K,setSessionId:Q,setLastSessionId:X}=i.usePickaxeContext(),{emailInput:Y,isLoggedOut:Z,isSending:ee,isResendDisabled:se,isSent:ie,isPricingAuth:te}=t.useAuthContext(),{onSend:ae}=a.useAuth(),{scrollContainerRef:le,isLocked:ne}=o.useScrollContext(),{messages:oe,limitData:re,error:ce,isGenerating:de}=l.useResponseContext(),{height:ue,width:me}=n.useDimensionContext(),{currentArtifact:xe,chatPopupType:he,currentPopupType:fe}=d.useArtifactContext(),je=c.useConversation(),ge=r.useStyleFontSize(),pe=s.useMemo((()=>(null==W?void 0:W.icebreakers)?W.icebreakers.slice(0,3):[]),[null==W?void 0:W.icebreakers]),ve=s.useMemo((()=>{const e=!!je.data&&je.data.messages.length>1;return!P&&je.isSuccess&&V&&!e}),[P,je.isSuccess,V,je.data]),ye=s.useMemo((()=>!(null==W?void 0:W.chatflag)&&(null==W?void 0:W.enablechatresponses)&&oe.length>0),[W,oe]),be=s.useMemo((()=>!!je.data&&je.data.messages.some((e=>"intromessage"===e.area))),[je.data]),ke="chat-input"===$&&te&&Z&&ie,we=K&&!M&&!be&&ve&&me>767,Ne=K&&!M&&(be||me<=767),Ce=s.useMemo((()=>{var e,s;const i=null!==(s=null===(e=je.data)||void 0===e?void 0:e.messages)&&void 0!==s?s:[];return!de&&i.length&&oe.length?O.getUnpersistedMemoryMessages(oe,i):oe}),[null===(H=je.data)||void 0===H?void 0:H.messages,de,oe]),Oe=()=>{X(z),Q("")};return s.useLayoutEffect((()=>{if(!ne)return;const e=le.current;e&&(e.scrollTop=e.scrollHeight)}),[A,null===(R=je.data)||void 0===R?void 0:R.messages.length,ne,le,Ce.length]),e.jsxs("div",Object.assign({ref:le,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:!!xe&&"inline"===fe&&e.jsx(u.motion.div,Object.assign({className:C.default("absolute top-0 z-20 w-full px-4 py-2",he),style:{height:`calc(${ue-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(y.default,{type:"inline",className:"pxe-artifact-inline h-full shadow",artifact:{id:xe.id,version:xe.version}})}))}),e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px]"},{children:[ve&&J&&e.jsx("div",Object.assign({className:C.default("absolute right-4 top-3 flex items-center gap-2","popup"===$&&"right-12")},{children:e.jsx(p.default,{tip:(null==_?void 0:_["chat-history"])||"Chat History",onClick:Oe})})),e.jsx(h.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]",ve&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500},!ke&&{onIconClick:Oe})),J&&!je.isLoading&&e.jsx(f.default,Object.assign({className:C.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full sticky top-0 z-10",!ve&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",historyBtnTip:(null==_?void 0:_["chat-history"])||"Chat History"},!ke&&{onIconClick:Oe,onHistoryClick:Oe})),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",J&&!je.isLoading&&!ve&&"mt-0")},{children:[we&&e.jsx("div",Object.assign({className:C.default("grid grid-cols-3 gap-4",2===pe.length&&"grid-cols-2",1===pe.length&&"grid-cols-1")},{children:e.jsx(w.default,{type:"center",data:pe,onSend:I})})),ke?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(m.default,{className:"h-6 w-6 shrink-0"}),e.jsx("p",Object.assign({className:"font-semilight"},{children:Y}))]}))})),e.jsxs(k.default,Object.assign({chatRole:"assistant"},{children:[e.jsxs("p",Object.assign({className:"py-3 font-semilight"},{children:[`${null!==(B=null==_?void 0:_["we-sent-your-an-activation-link"])&&void 0!==B?B:"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:()=>{se||ee||ae(!0)}},{children:ee?null!==(E=null==_?void 0:_.resending)&&void 0!==E?E:"Resending...":null!==(T=null==_?void 0:_.resend)&&void 0!==T?T:"Resend"}))]})),e.jsx(q.default,{compact:!0})]}))]}))})):e.jsx(e.Fragment,{children:je.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(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"})]})):je.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:C.default(ge.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."]}))})):je.data||ye?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:[(null!==(F=null===(D=je.data)||void 0===D?void 0:D.messages)&&void 0!==F?F:[]).map(((s,i)=>e.jsx(b.default,{index:i,message:s},`history-${i}`))),Ce.map(((s,i)=>{var t,a;return e.jsx(b.default,{smitheryData:S,resubmitPrompt:L,index:(null!==(a=null===(t=je.data)||void 0===t?void 0:t.messages.length)&&void 0!==a?a:0)+i,message:s,isLastMessage:i===Ce.length-1},`memory-${i}`)})),re?e.jsx("div",Object.assign({className:"flex max-w-[100%] items-center gap-x-3"},{children:e.jsx(j.default,{})})):ce?e.jsx("div",Object.assign({className:C.default("flex items-center gap-x-3",G?"justify-end":"justify-start")},{children:e.jsx(x.default,{error:ce})})):null]})),e.jsxs("div",Object.assign({className:C.default("flex flex-col",!U.isWhiteLabel||Ne&&"mt-4")},{children:[!U.isWhiteLabel&&e.jsx(N.default,{containerClassName:C.default("justify-end",Ne&&"mb-2")}),Ne&&e.jsx("div",Object.assign({className:"flex flex-col items-end gap-2"},{children:e.jsx(w.default,{type:"right",data:pe,onSend:I})})),e.jsx(v.default,{})]}))]})):null})]}))]}))]}))};
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 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../hooks/studio/useStyleInput.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),c=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),g=require("../../../hooks/core/useMediaQuery.js"),f=require("../../../common/documents.js"),v=require("eventsource-parser"),h=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),y=require("../../Icons/message-clock.svg.js"),I=require("../../Icons/stop.svg.js"),j=require("../../Icons/trash.svg.js"),w=require("../../Icons/pencil.svg.js"),S=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),N=require("../../Core/ErrorAlert.js"),k=require("../../Core/Menu/index.js"),_=require("../../Core/Menu/Button.js"),E=require("../../Core/Menu/List.js"),C=require("../../../common/error.js"),T=require("../../../common/chatMessages.js"),U=require("../../../common/api/pickaxe.js"),A=require("../../../common/validation.js"),D=require("../../../common/cn.js"),P=require("../../../common/utils.js"),L=require("../../../common/pickaxeConfig.js"),q=require("../../../common/agentPrefill.js"),R=require("../../../common/deploymentWebhooks.js"),M=require("../../../hooks/studio/useStudio.js"),F=require("../../../hooks/pickaxe/useSpeechToText.js"),V=require("../common/PickaxeCommon.js");const $=(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},B=e=>"string"==typeof e&&e.trim().length>0,X=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`,K=e=>e.map((e=>Object.assign({},e))),H=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 B(s)?s:null},G=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},Y=({studioUser:e,deploymentId:t,portalId:s})=>{var n,i;const r=Array.isArray(W(e,"uses"))?W(e,"uses"):[],o=(({deploymentId:e,portalId:t})=>B(e)?{type:"deployment",id:e}:B(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}},J=s.forwardRef((({resubmitPrompt:W,onFocus:J,onBlur:Q,onInputHeightChange:Z,initSmitheryAuthData:ee},te)=>{var se,ne,ie,re,oe,ae,le,de,ce,ue,pe,me,ge,fe,ve,he,be;const{origin:xe,pickaxeId:ye,sessionId:Ie,sender:je,senderType:we,portalId:Se,deploymentId:Oe,deploymentType:Ne,pickaxe:ke,styles:_e,colors:Ee,translations:Ce,locale:Te,forceMobile:Ue,isNewChat:Ae,isRtl:De,isEmbed:Pe,isShowFeedbackMessage:Le,accessGroup:qe,setIsNewChat:Re,setIsShowIceBreaker:Me,setValidationStatus:Fe,setValidationUpgradeGroups:Ve,setValidationUpgradeUrl:$e,setAccessGroup:Be,onUpgrade:Xe,onGenerateComplete:Ke}=n.usePickaxeContext(),{token:He,isLoggedOut:We,isSent:ze,isPricingAuth:Ge}=d.useAuthContext(),{messages:Ye,isGenerating:Je,setMessages:Qe,setStatus:Ze,setLimitData:et,setError:tt}=i.useResponseContext(),{documents:st,isUploading:nt,documentError:it,onFileUpload:rt,setDocuments:ot,setDocumentError:at}=c.useDocument(),{studio:lt}=M.useStudio(),[dt]=g.useMediaQuery("(max-width: 480px)"),{scrollStartSession:ct,scrollEndSession:ut,scrollToBottom:pt}=u.useScroll({auto:!0,smooth:!(Ue||dt)}),{artifacts:mt,currentPopupType:gt,setArtifacts:ft,setCurrentArtifact:vt}=p.useArtifactContext(),{height:ht}=l.useDimensionContext(),bt=a.useConversation(),[xt,yt]=s.useState((()=>q.readAgentPrefill([Oe,ye]).chatInput)),[It,jt]=s.useState(!1),[wt,St]=s.useState(!1),[Ot,Nt]=s.useState(!1),[kt,_t]=s.useState([]),[Et,Ct]=s.useState(!1),[Tt,Ut]=s.useState(null),[At,Dt]=s.useState(null),[Pt,Lt]=s.useState(null),[qt,Rt]=s.useState(null),[Mt,Ft]=s.useState(!1),[Vt,$t]=s.useState(!1),[Bt,Xt]=s.useState(0),Kt=s.useRef(null),Ht=s.useRef(""),Wt=s.useRef(null),zt=s.useRef(null),Gt=s.useRef(null),Yt=s.useRef([]),Jt=s.useRef(null),Qt=s.useRef(null),Zt=s.useRef(null),es=s.useRef(null),ts=s.useRef(new Set),ss=s.useRef(null),ns=Math.max(.4*ht,100),{speechTranscript:is,isSpeechListening:rs,isSpeechProcessing:os,isSpeechSupported:as,onStartListening:ls,onStopListening:ds}=F.useSpeechToText(),cs=m.useHover(),{isHover:us}=cs,ps=e.__rest(cs,["isHover"]),ms=m.useHover(),{isHover:gs}=ms,fs=e.__rest(ms,["isHover"]),vs=m.useHover(),{isHover:hs}=vs,bs=e.__rest(vs,["isHover"]),xs=o.useStyleFontSize(),ys=r.useStyleInput(),Is="undefined"!=typeof window?window.location.hostname:"",js="undefined"!=typeof window?window.location.href:"",ws="undefined"!=typeof window&&window.self!==window.top,Ss=Is.includes("pickaxe.co")&&!js.includes("https://studio.pickaxe.co/_embed")&&!ws,Os=null!==(ne=null===(se=null==ke?void 0:ke.documentuploadtype)||void 0===se?void 0:se.startsWith("enduserupload"))&&void 0!==ne&&ne,Ns=as&&(null==ke?void 0:ke.enablevoicetotext),ks=rs&&!xt.trim(),_s=B(Oe),Es="chat-input"===Ne&&Ae&&!ze,Cs="chat-input"===Ne&&Ge&&We&&ze,Ts=s.useCallback((e=>{const t=A.getValidationFailure(e);return!!t&&(tt(""),et(null),Fe(t.status),Be(t.accessGroup),Ve(t.upgradeGroups),$e(t.upgradeUrl),!0)}),[tt,et,Fe,Ve,$e,Be]),Us=null!==(ie=null==ke?void 0:ke.placeholdertext)&&void 0!==ie?ie:De?"بماذا تريد أن تتحدث؟":(null==Ce?void 0:Ce["what-do-you-want-to-talk-about"])||"What do you want to talk about?",As=It||wt,Ds=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){Ft(!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==ke?void 0:ke.studioid},He?{studioSessionToken:He}:je?{sender:je}:{sender:P.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}})),Ss&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Lt(t.studioUser),Rt(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{Ft(!0)}}))),[Ss,null==ke?void 0:ke.studioid,je,He]);s.useEffect((()=>{Ds()}),[Ds]);const Ps=Number(null!==(re=null==qe?void 0:qe.limit)&&void 0!==re?re:0),Ls="string"==typeof(null==qe?void 0:qe.limitInterval)?qe.limitInterval:null,qs=!!(null==lt?void 0:lt.data.usage)&&lt.data.usage.isCredits,Rs=s.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=Se?Se:z(Pt,"portalId"))&&void 0!==e?e:z(Pt,"portalid"))&&void 0!==t?t:z(qe,"portalId"))&&void 0!==s?s:z(qe,"portalid"))&&void 0!==n?n:z(ke,"portalId"))&&void 0!==i?i:z(ke,"portalid")}),[qe,Se,ke,Pt]),Ms=s.useMemo((()=>Y({studioUser:Pt,deploymentId:Oe,portalId:Rs})),[Oe,Rs,Pt]);s.useEffect((()=>{_s&&Ae&&Ie&&ts.current.add(Ie)}),[Ae,Ie,_s]);const Fs=s.useCallback((()=>{var e,t,s;return{studioId:null==ke?void 0:ke.studioid,userEmail:z(Pt,"email"),userId:null!==(e=z(Pt,"userId"))&&void 0!==e?e:z(Pt,"userid"),sessionId:Ie,deploymentId:Oe,deploymentType:Ne,portalId:Rs,accessGroupId:null!==(t=null==qe?void 0:qe.accessGroupId)&&void 0!==t?t:null,pickaxeId:ye,sender:je,senderType:we,origin:xe,metadata:null!==(s=L.getPickaxeConfigMetadata(Oe))&&void 0!==s?s:null}}),[null==qe?void 0:qe.accessGroupId,Oe,Ne,xe,null==ke?void 0:ke.studioid,ye,Rs,je,we,Ie,Pt]),Vs=s.useCallback((()=>!!(_s&&Mt&&Ie)&&(!!ts.current.has(Ie)&&(R.fireDeploymentSessionInitializedWebhook(Fs()),ts.current.delete(Ie),!0))),[Fs,Mt,Ie,_s]);s.useEffect((()=>{if(!Mt||!Ie)return;Vs();const e=ss.current;(null==e?void 0:e.sessionId)===Ie&&(R.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),Fs()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),ss.current=null)}),[Vs,Fs,Mt,Ie]);const $s={currentUses:G(null==Pt?void 0:Pt.currentUses),extraUses:G(null==Pt?void 0:Pt.extraUses)},Bs=Ms.scope?{currentUses:null!==(ae=G(null===(oe=Ms.record)||void 0===oe?void 0:oe.currentUses))&&void 0!==ae?ae:0,extraUses:null!==(de=G(null===(le=Ms.record)||void 0===le?void 0:le.extraUses))&&void 0!==de?de:0}:{currentUses:0,extraUses:0},Xs=z(Pt,"type"),Ks="guest"===Xs||!Xs&&We?Bs:$s;s.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(qs&&(null===(e=null==lt?void 0:lt.data)||void 0===e?void 0:e.workspaceId))try{const e=yield U.pickaxeApi2.get(`/cost_per_run?workspaceId=${lt.data.workspaceId}`,{withCredentials:!1});t&&Xt(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&Xt(0)}else t&&Xt(0)})),()=>{t=!1}}),[qs,null===(ce=null==lt?void 0:lt.data)||void 0===ce?void 0:ce.workspaceId]);const Hs=(({currentUses:e,extraUses:t,limit:s,limitInterval:n})=>{const i=Number(null!=e?e:0),r=Number(null!=t?t:0);return s===V.STUDIO_INFINITY_VALUE||r===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:"one_time"===n?Math.max(0,r-i):Math.max(0,s-i)+r})({currentUses:Ks.currentUses,extraUses:Ks.extraUses,limit:Ps,limitInterval:Ls}),Ws=Hs===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(Hs)),zs=(({extraUses:e,limit:t,limitInterval:s})=>{const n=Number(null!=e?e:0);return t===V.STUDIO_INFINITY_VALUE||n===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:"one_time"===s?Math.max(0,n):Math.max(0,t)+Math.max(0,n)})({extraUses:Ks.extraUses,limit:Ps,limitInterval:Ls}),Gs=zs===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:Math.ceil(.05*zs),Ys=qs?Math.ceil(5*Bt):5,Js=Gs===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:Math.max(Gs,Ys),Qs=s.useMemo((()=>!!Pt&&(!Vt&&(Ws!==V.STUDIO_INFINITY_VALUE&&Ws<=Js))),[Vt,Js,Ws,Pt]),Zs=Boolean(null==qe?void 0:qe.hideUpgradeOptions),en=Boolean(!Zs&&((null===(ue=null==qe?void 0:qe.upgrade)||void 0===ue?void 0:ue.isBuyMoreUses)||(null===(pe=null==qe?void 0:qe.upgrade)||void 0===pe?void 0:pe.isLinkToCustomURL)||(null===(me=null==qe?void 0:qe.upgrade)||void 0===me?void 0:me.isUpgradeToAnotherGroup)&&(null===(ge=qe.upgrade.accessGroupIds)||void 0===ge?void 0:ge.length))),tn=!Zs&&(null===(fe=null==qe?void 0:qe.upgrade)||void 0===fe?void 0:fe.isLinkToCustomURL)&&"string"==typeof qe.upgrade.limitLink&&qe.upgrade.limitLink.trim().length>0?qe.upgrade.limitLink.trim():null,sn=tn&&"string"==typeof(null===(ve=null==qe?void 0:qe.upgrade)||void 0===ve?void 0:ve.limitCTA)&&qe.upgrade.limitCTA.trim().length>0?qe.upgrade.limitCTA:(null==Ce?void 0:Ce["pricing.upgrade"])||(null==Ce?void 0:Ce.upgrade)||"Upgrade",nn=s.useMemo((()=>{var e,t,s;return!!Ae&&(!!ke&&(!bt.isLoading&&(!((null!==(t=null===(e=bt.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=ke.icebreakers)||void 0===s?void 0:s.length)&&(!Le&&!Es)))))}),[ke,Ae,Le,Es,bt.data,bt.isLoading]),rn=s.useMemo((()=>{if(nt||Ot)return!1;const e=Os&&st.length>0&&st.every((e=>"finished"===e.status));return!(!xt.trim()&&!e)&&st.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Os,nt,Ot,xt,st]);s.useImperativeHandle(te,(()=>({onSubmit:cn}))),s.useEffect((()=>{Me(nn)}),[nn]),s.useEffect((()=>{var e;if(W){const t=Array.from(Ye),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;cn(s,!0)}}),[W]),s.useEffect((()=>{if(!Zt.current||!Z)return;const e=new ResizeObserver((e=>{for(const t of e)Z(t.contentRect.height)}));return e.observe(Zt.current),()=>{e.disconnect()}}),[Z]),s.useEffect((()=>{if(!rs)return;const e=Ht.current?`${Ht.current} `:"";yt(`${e}${is}`)}),[is,rs]),s.useEffect((()=>{if(!Jt.current)return;(()=>{if(!Jt.current)return;let e=Jt.current.scrollHeight>52;xt.includes("\n")||st.length?e=!0:xt.trim()||(e=!1),jt(e)})()}),[xt,st]),s.useEffect((()=>{const e=Jt.current,t=Qt.current;if(!e||!t||It||xt.includes("\n"))return void St(!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=xt||Us,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;St(r>l)}),[xt,It,Us]);const on=t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:zt.current))return!1;const e=K(Yt.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})},Ss&&{credentials:"include"}))).ok}catch(e){return console.warn("Failed to cancel submission",e),!1}})),an=e=>{Gt.current=e,es.current&&(es.current.abort(),es.current=null),Wt.current&&(Wt.current.cancel().catch((()=>{})),Wt.current=null)},ln=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}))},Ss&&{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})),dn=()=>{const e=zt.current;e&&!Ot&&!nt&&xt.trim()&&(_t((t=>{var s,n;return[...t,{id:X(),message:xt,predecessorSubmissionId:null!==(n=null===(s=t[t.length-1])||void 0===s?void 0:s.id)&&void 0!==n?n:e}]})),yt(""))},cn=(t,s=!1,n=!1,i)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,r,o,a,l,d;let c=null;try{if(Je&&!n||nt)return;const u=st.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),p=u.map((e=>e.documentId)).filter(Boolean),m=u.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),g=null!=t?t:xt,f=null!==(r=null===(e=null==ke?void 0:ke.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==r&&r&&p.length>0;if(!g&&!f)return;tt(""),at(""),et(null),yt(""),Re(!1),Ze("fetching"),ct(),pt();const h=null!==(a=null===(o=bt.data)||void 0===o?void 0:o.messages)&&void 0!==a?a:[],b=T.getUnpersistedMemoryMessages(Ye,h),x=s?b.slice(0,b.length-1):b,y=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(x),I=y+(s?0:1),j={id:I,role:"assistant",parts:[],documentIds:[]},w=[...x,...s?[]:[{id:y,role:"user",parts:[{type:"text",content:g,isVisible:!0}],documentIds:f?p:[]}],j];Qe(w),pt(),f&&ot([]);const S=L.getPickaxeConfigMetadata(Oe),O=null!=i?i:X();c=O,zt.current=O,Gt.current=null,Yt.current=[];const N=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({origin:xe,pickaxeId:ye,sessionId:Ie,submissionId:O,senderType:we,value:g},f&&{documentIds:p}),je&&{sender:je}),He&&{studioSessionToken:He}),!He&&!je&&{sender:P.initializeEmbedUserId()}),Rs&&{portalId:Rs}),Oe&&{deploymentId:Oe}),S&&{metadata:S}),f&&m.length>0?{uploadedModelImages:m}:{})),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()})},Ss&&{credentials:"include"})),k=yield N.json();if(!k.success){if(k.limitData){const e=new Error(k.error||k.message||(null==Ce?void 0:Ce["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=k.limitData,e}if(Ts(k))return;throw new Error(k.error||k.message||(null==Ce?void 0:Ce["failed-to-start-generation"])||"Failed to start generation")}const _=null!==(l=k.submissionId)&&void 0!==l?l:O;c=_,zt.current=_;const E=()=>Gt.current===_;if(E())return;_s&&Ae&&Ie&&ts.current.add(Ie);const C=Object.assign(Object.assign({},Fs()),{message:g,documentIds:f?p:[],uploadedModelImages:f?m:[],hasUploadedDocuments:f,isHidden:s,metadata:null!=S?S:null});Mt?(Vs(),R.fireDeploymentFirstMessageSubmittedWebhook(C)):ss.current=C,Ze("streaming"),es.current=new AbortController;const U=[];let A=[...null!=mt?mt:[]],D=0,q=!1,M="";for(;!q;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${_}?index=${D}`,{signal:null===(d=es.current)||void 0===d?void 0:d.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Wt.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(E())q=!0;else if(e.event&&"ping"!==e.event&&D++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return et(t.limitData),tt(""),void(q=!0);const s=t.error||t.message||(null==Ce?void 0:Ce["something-went-wrong"])||"Something went wrong.";return Ts(t)||tt(s),void(q=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&ee){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 q=!0,ee({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 q=!0,ee({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 q=!0,ee({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 q=!0,ee({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)M="",U.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)M+=n.delta,U[U.length-1].content=M;else if("text-end"===n.type)M="";else if("reasoning-start"===n.type)M="",U.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)M+=n.delta,U[U.length-1].content=M;else if("reasoning-end"===n.type)M="";else if(n.type.startsWith("data-")){const e=n;U.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Yt.current=K(U);const i=K(U);Qe((e=>{const t=e.findIndex((e=>e.id===I)),s=Object.assign(Object.assign({},j),{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);A=A.filter((e=>!(e.id===t.id&&e.version===t.version))),A.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ft([...A]),gt.startsWith("inline")||vt({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);A=A.filter((e=>!(e.id===t.id&&e.version===t.version))),A.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),ft(A),gt.startsWith("inline")||vt({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);A=A.filter((e=>!(e.id===t.id&&e.version===t.version))),A.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ft(A),gt.startsWith("inline")||vt({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");A=A.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),ft(A)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);ft(A.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 et(t.limitData),tt(""),void(q=!0);const s=t.error||t.message||(null==Ce?void 0:Ce["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(Ts(t))return void(q=!0);tt(s)}else"stop"===e.event&&(q=!0)}else q=!0}});for(;;){if(E()){q=!0,t.cancel().catch((()=>{}));break}const{value:e,done:i}=yield t.read();if(E()){q=!0,t.cancel().catch((()=>{}));break}if(i)break;n.feed(s.decode(e))}q||E()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||H(e)||E())return void(q=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==Ke||Ke(Ie)}catch(e){if(H(e))return;if(e.limitData)et(e.limitData),tt("");else{let t=C.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==Ce?void 0:Ce["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),Ts(t)||tt(t)}}finally{const e=!c||zt.current===c;pt(),e&&(Ze("idle"),ut(),Wt.current=null),c&&e&&(zt.current=null,Yt.current=[]),yield Ds()}}));return s.useEffect((()=>{if(Je||Ot||Et||0===kt.length)return;const t=kt[0];Ct(!0),Ut(t.id),e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!(yield ln(t.predecessorSubmissionId)))return void tt((null==Ce?void 0:Ce["queued-message-waiting"])||"A queued message is waiting for the previous response to finish.");_t((e=>e.filter((e=>e.id!==t.id)))),yield cn(t.message,!1,!0,t.id)}finally{Ct(!1),Ut(null)}}))}),[Je,Et,Ot,kt]),Cs?null:t.jsx("div",Object.assign({className:D.default("flex w-full flex-shrink-0 flex-col items-center",!Es&&"px-4 pb-8"),dir:De?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[kt.length>0&&t.jsx("div",Object.assign({className:"mx-3 -mb-3 overflow-hidden border pb-3",style:{borderColor:Ee.text+"18",backgroundColor:null!==(he=ys.backgroundColor)&&void 0!==he?he:Ee.text+"08",color:Ee.text,borderTopLeftRadius:Math.max(_e.cornerRadius-4,12),borderTopRightRadius:Math.max(_e.cornerRadius-4,12)}},{children:kt.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<kt.length-1?{borderBottom:`1px solid ${Ee.text}12`}:void 0},{children:[t.jsx(y.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})),At===s.id||Tt===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"}),At===s.id?(null==Ce?void 0:Ce.steering)||"Steering...":(null==Ce?void 0:Ce.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:Ot||!Je,onClick:()=>{(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){const e=zt.current;if(!e||Ot)return;const s=kt.findIndex((e=>e.id===t.id));if(-1===s)return;Nt(!0),Dt(t.id),tt(""),an(e);let n=!1;try{if(!(yield on(e)))throw new Error((null==Ce?void 0:Ce["failed-to-interrupt-current-response"])||"Failed to interrupt the current response.");if(!(yield ln(e)))throw new Error((null==Ce?void 0:Ce["current-response-still-stopping"])||"The current response is still stopping. Please send your message again in a moment.");Ze("idle"),_t((e=>e.filter((e=>e.id!==t.id)))),n=!0,Nt(!1),Dt(null),yield cn(t.message,!1,!0,t.id)}catch(e){Ze("idle"),n&&_t((e=>{if(e.some((e=>e.id===t.id)))return e;const n=[...e];return n.splice(s,0,t),n})),tt(C.default(e))}finally{Nt(!1),Dt(null)}}))})(s)},"aria-label":`${(null==Ce?void 0:Ce["steer-with"])||"Steer with"}: ${s.message}`},{children:[t.jsx("span",Object.assign({"aria-hidden":"true"},{children:"↳ "})),(null==Ce?void 0:Ce.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:Ot,onClick:()=>{return e=s.id,void _t((t=>$(t,e)));var e},"aria-label":`${(null==Ce?void 0:Ce["remove-queued-message"])||"Remove queued message"}: ${s.message}`},{children:t.jsx(j.default,{className:"h-4 w-4","aria-hidden":"true"})})),t.jsxs(k.default,Object.assign({id:`queued-message-menu-${s.id}`,className:"shrink-0"},{children:[t.jsx(_.default,Object.assign({className:"flex h-7 w-7 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100",isDisabled:Ot,role:"button",tabIndex:Ot?-1:0,"aria-haspopup":"menu","aria-label":(null==Ce?void 0:Ce["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(E.default,Object.assign({role:"menu",align:De?"bottom-start":"bottom-end",positionStrategy:Pe?"absolute":"fixed",width:"auto",className:"p-1 text-sm shadow-xl",style:{backgroundColor:null!==(i=ys.backgroundColor)&&void 0!==i?i:Ee.primary,color:Ee.text,borderRadius:"12px"},border:`1px solid ${Ee.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=>{_t((t=>$(t,e.id))),yt(e.message),requestAnimationFrame((()=>{const t=Jt.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==Ce?void 0:Ce["edit-message"])||"Edit message"]}))}))]}))]})]}),s.id)}))})),t.jsxs("div",Object.assign({ref:Zt,className:D.default("relative z-10 flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===_e.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},ys),{maxHeight:`${ns}px`,overflowY:"auto"})},{children:[Qs&&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:ys.backgroundColor?`${ys.backgroundColor}E6`:void 0,borderColor:Ee.text+"20",color:Ee.text,borderTopRightRadius:_e.cornerRadius+"px",borderTopLeftRadius:_e.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[Ws.toLocaleString()," ",qs?(null==Ce?void 0:Ce.credits)||"Credits":(null==Ce?void 0:Ce.uses)||"Uses"," ",(null==Ce?void 0:Ce.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[en&&t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:Ee.accent,color:Ee.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),tn)return void window.open(tn,"_blank","noopener,noreferrer");if(Xe)return void Xe();const t=P.buildUpgradeUrl({baseUrl:qt,accessGroupId:null==qe?void 0:qe.accessGroupId});t&&P.openAuthenticatedPricingUrl({deploymentId:Oe,pricingUrl:t,studioId:null==ke?void 0:ke.studioid,studioSessionToken:He})}},{children:sn})),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:()=>$t(!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"})}))}))]}))]})),!Je&&st.length>0&&t.jsx(S.default,{className:"p-4 pb-0",isDisabled:Je}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[ks&&t.jsxs("div",Object.assign({className:D.default("pointer-events-none absolute top-1/2 z-10 flex -translate-y-1/2 select-none items-center gap-x-2",De?"right-4":"left-4")},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(be=Ee.accent)&&void 0!==be?be:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:Ee.text+"90"}},{children:(null==Ce?void 0:Ce.listening)||"Listening..."}))]})),t.jsx(O.default,Object.assign({ref:Jt,className:D.default(xs.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!xt.trim()&&!xt.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",De?"text-right":"text-left",As&&"mb-12"),value:xt,placeholder:ks?"":Us,onChange:e=>{yt(e)},onKeyDown:e=>{Ue||dt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),nt||Ot||(Je?dn():cn())))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!Os)return;t.preventDefault(),Re(!1),yield rt(e)}}))},J&&{onFocus:J},Q&&{onBlur:Q},{dir:De?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Qt,className:D.default("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",As?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!As&&ys.backgroundColor&&{backgroundColor:ys.backgroundColor}),{borderTopRightRadius:_e.cornerRadius+"px",borderBottomRightRadius:_e.cornerRadius+"px"})},{children:Je?t.jsxs(t.Fragment,{children:[t.jsx("button",Object.assign({"aria-label":(null==Ce?void 0:Ce["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=zt.current;e&&(an(e),on(e)),Ze("idle")},style:{backgroundColor:Ee.accent+"10",color:Ee.accent}},{children:t.jsx(I.default,{className:"h-4 w-4 shrink-0"})})),t.jsx("button",Object.assign({"aria-label":(null==Ce?void 0:Ce["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:Ot||nt||!xt.trim(),onClick:dn,style:{backgroundColor:xt.trim()?Ee.accent:Ee.accent+"10",color:xt.trim()?Ee.accentText:Ee.accent+"80"}},{children:t.jsx(b.default,{className:D.default("h-6 w-6 shrink-0",De&&"scale-x-[-1] transform")})}))]}):rs?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:ds,style:{backgroundColor:Ee.accent,color:Ee.accentText}},{children:t.jsx(I.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Os&&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:gs?Ee.accent+"10":void 0,color:gs?Ee.accent:Ee.accent+"80"},disabled:nt||Je,onClick:()=>{var e;return null===(e=Kt.current)||void 0===e?void 0:e.click()}},fs,{children:[t.jsx("input",{id:"file-upload",ref:Kt,type:"file",accept:[...f.allowedFileMimeTypes,...f.allowedImageMimeTypes,...f.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Re(!1),yield rt(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(h.default,{className:"h-6 w-6 shrink-0"})]})),Ns&&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:rs?Ee.accent:hs?Ee.accent+"10":void 0,color:rs?Ee.accentText:hs?Ee.accent:Ee.accent+"80"},disabled:nt||Je||os,onClick:()=>{rs?ds():(Ht.current=xt,ls(Te||"en-US"))}},bs,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:us||rn?Ee.accent:Ee.accent+"10",color:us||rn?Ee.accentText:Ee.accent+"80"},disabled:!rn,onClick:()=>cn()},ps,{children:t.jsx(b.default,{className:D.default("h-6 w-6 shrink-0",De&&"scale-x-[-1] transform")})}))]})}))]}))]})),it&&t.jsx(N.default,{error:it,className:"mt-3"})]}))}))}));J.displayName="Input",exports.default=J;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../hooks/studio/useStyleInput.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),c=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),f=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),h=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),x=require("../../Icons/microphone.svg.js"),y=require("../../Icons/message-clock.svg.js"),I=require("../../Icons/stop.svg.js"),j=require("../../Icons/trash.svg.js"),w=require("../../Icons/pencil.svg.js"),S=require("../Addons/Document/List.js"),O=require("../../Core/Textarea.js"),N=require("../../Core/ErrorAlert.js"),k=require("../../Core/Menu/index.js"),_=require("../../Core/Menu/Button.js"),E=require("../../Core/Menu/List.js"),C=require("../../../common/error.js"),T=require("../../../common/api/pickaxe.js"),U=require("../../../common/validation.js"),A=require("../../../common/cn.js"),D=require("../../../common/utils.js"),P=require("../../../common/pickaxeConfig.js"),L=require("../../../common/agentPrefill.js"),R=require("../../../common/deploymentWebhooks.js"),q=require("../../../hooks/studio/useStudio.js"),M=require("../../../hooks/pickaxe/useSpeechToText.js"),F=require("../common/PickaxeCommon.js");const V=(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},$=e=>"string"==typeof e&&e.trim().length>0,B=()=>"undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`,X=e=>e.map((e=>Object.assign({},e))),K=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),H=(e,t)=>{if(e&&"object"==typeof e)return e[t]},W=(e,t)=>{const s=H(e,t);return $(s)?s:null},z=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},G=({studioUser:e,deploymentId:t,portalId:s})=>{var n,i;const r=Array.isArray(H(e,"uses"))?H(e,"uses"):[],o=(({deploymentId:e,portalId:t})=>$(e)?{type:"deployment",id:e}:$(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}},Y=s.forwardRef((({resubmitPrompt:H,onFocus:Y,onBlur:J,onInputHeightChange:Q,initSmitheryAuthData:Z},ee)=>{var te,se,ne,ie,re,oe,ae,le,de,ce,ue,pe,me,fe,ge,ve,he;const{origin:be,pickaxeId:xe,sessionId:ye,sender:Ie,senderType:je,portalId:we,deploymentId:Se,deploymentType:Oe,pickaxe:Ne,styles:ke,colors:_e,translations:Ee,locale:Ce,forceMobile:Te,isNewChat:Ue,isRtl:Ae,isEmbed:De,isShowFeedbackMessage:Pe,accessGroup:Le,setIsNewChat:Re,setIsShowIceBreaker:qe,setValidationStatus:Me,setValidationUpgradeGroups:Fe,setValidationUpgradeUrl:Ve,setAccessGroup:$e,onUpgrade:Be,onGenerateComplete:Xe}=n.usePickaxeContext(),{token:Ke,isLoggedOut:He,isSent:We,isPricingAuth:ze}=d.useAuthContext(),{messages:Ge,isGenerating:Ye,setMessages:Je,setStatus:Qe,setLimitData:Ze,setError:et}=i.useResponseContext(),{documents:tt,isUploading:st,documentError:nt,onFileUpload:it,setDocuments:rt,setDocumentError:ot}=c.useDocument(),{studio:at}=q.useStudio(),[lt]=f.useMediaQuery("(max-width: 480px)"),{scrollStartSession:dt,scrollEndSession:ct,scrollToBottom:ut}=u.useScroll({auto:!0,smooth:!(Te||lt)}),{artifacts:pt,currentPopupType:mt,setArtifacts:ft,setCurrentArtifact:gt}=p.useArtifactContext(),{height:vt}=l.useDimensionContext(),ht=a.useConversation(),[bt,xt]=s.useState((()=>L.readAgentPrefill([Se,xe]).chatInput)),[yt,It]=s.useState(!1),[jt,wt]=s.useState(!1),[St,Ot]=s.useState(!1),[Nt,kt]=s.useState([]),[_t,Et]=s.useState(!1),[Ct,Tt]=s.useState(null),[Ut,At]=s.useState(null),[Dt,Pt]=s.useState(null),[Lt,Rt]=s.useState(null),[qt,Mt]=s.useState(!1),[Ft,Vt]=s.useState(!1),[$t,Bt]=s.useState(0),Xt=s.useRef(null),Kt=s.useRef(""),Ht=s.useRef(null),Wt=s.useRef(null),zt=s.useRef(null),Gt=s.useRef([]),Yt=s.useRef(null),Jt=s.useRef(null),Qt=s.useRef(null),Zt=s.useRef(null),es=s.useRef(new Set),ts=s.useRef(null),ss=Math.max(.4*vt,100),{speechTranscript:ns,isSpeechListening:is,isSpeechProcessing:rs,isSpeechSupported:os,onStartListening:as,onStopListening:ls}=M.useSpeechToText(),ds=m.useHover(),{isHover:cs}=ds,us=e.__rest(ds,["isHover"]),ps=m.useHover(),{isHover:ms}=ps,fs=e.__rest(ps,["isHover"]),gs=m.useHover(),{isHover:vs}=gs,hs=e.__rest(gs,["isHover"]),bs=o.useStyleFontSize(),xs=r.useStyleInput(),ys="undefined"!=typeof window?window.location.hostname:"",Is="undefined"!=typeof window?window.location.href:"",js="undefined"!=typeof window&&window.self!==window.top,ws=ys.includes("pickaxe.co")&&!Is.includes("https://studio.pickaxe.co/_embed")&&!js,Ss=null!==(se=null===(te=null==Ne?void 0:Ne.documentuploadtype)||void 0===te?void 0:te.startsWith("enduserupload"))&&void 0!==se&&se,Os=os&&(null==Ne?void 0:Ne.enablevoicetotext),Ns=is&&!bt.trim(),ks=$(Se),_s="chat-input"===Oe&&Ue&&!We,Es="chat-input"===Oe&&ze&&He&&We,Cs=s.useCallback((e=>{const t=U.getValidationFailure(e);return!!t&&(et(""),Ze(null),Me(t.status),$e(t.accessGroup),Fe(t.upgradeGroups),Ve(t.upgradeUrl),!0)}),[et,Ze,Me,Fe,Ve,$e]),Ts=null!==(ne=null==Ne?void 0:Ne.placeholdertext)&&void 0!==ne?ne:Ae?"بماذا تريد أن تتحدث؟":(null==Ee?void 0:Ee["what-do-you-want-to-talk-about"])||"What do you want to talk about?",Us=yt||jt,As=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){Mt(!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==Ne?void 0:Ne.studioid},Ke?{studioSessionToken:Ke}:Ie?{sender:Ie}:{sender:D.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}})),ws&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(Pt(t.studioUser),Rt(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{Mt(!0)}}))),[ws,null==Ne?void 0:Ne.studioid,Ie,Ke]);s.useEffect((()=>{As()}),[As]);const Ds=Number(null!==(ie=null==Le?void 0:Le.limit)&&void 0!==ie?ie:0),Ps="string"==typeof(null==Le?void 0:Le.limitInterval)?Le.limitInterval:null,Ls=!!(null==at?void 0:at.data.usage)&&at.data.usage.isCredits,Rs=s.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=we?we:W(Dt,"portalId"))&&void 0!==e?e:W(Dt,"portalid"))&&void 0!==t?t:W(Le,"portalId"))&&void 0!==s?s:W(Le,"portalid"))&&void 0!==n?n:W(Ne,"portalId"))&&void 0!==i?i:W(Ne,"portalid")}),[Le,we,Ne,Dt]),qs=s.useMemo((()=>G({studioUser:Dt,deploymentId:Se,portalId:Rs})),[Se,Rs,Dt]);s.useEffect((()=>{ks&&Ue&&ye&&es.current.add(ye)}),[Ue,ye,ks]);const Ms=s.useCallback((()=>{var e,t,s;return{studioId:null==Ne?void 0:Ne.studioid,userEmail:W(Dt,"email"),userId:null!==(e=W(Dt,"userId"))&&void 0!==e?e:W(Dt,"userid"),sessionId:ye,deploymentId:Se,deploymentType:Oe,portalId:Rs,accessGroupId:null!==(t=null==Le?void 0:Le.accessGroupId)&&void 0!==t?t:null,pickaxeId:xe,sender:Ie,senderType:je,origin:be,metadata:null!==(s=P.getPickaxeConfigMetadata(Se))&&void 0!==s?s:null}}),[null==Le?void 0:Le.accessGroupId,Se,Oe,be,null==Ne?void 0:Ne.studioid,xe,Rs,Ie,je,ye,Dt]),Fs=s.useCallback((()=>!!(ks&&qt&&ye)&&(!!es.current.has(ye)&&(R.fireDeploymentSessionInitializedWebhook(Ms()),es.current.delete(ye),!0))),[Ms,qt,ye,ks]);s.useEffect((()=>{if(!qt||!ye)return;Fs();const e=ts.current;(null==e?void 0:e.sessionId)===ye&&(R.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),Ms()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),ts.current=null)}),[Fs,Ms,qt,ye]);const Vs={currentUses:z(null==Dt?void 0:Dt.currentUses),extraUses:z(null==Dt?void 0:Dt.extraUses)},$s=qs.scope?{currentUses:null!==(oe=z(null===(re=qs.record)||void 0===re?void 0:re.currentUses))&&void 0!==oe?oe:0,extraUses:null!==(le=z(null===(ae=qs.record)||void 0===ae?void 0:ae.extraUses))&&void 0!==le?le:0}:{currentUses:0,extraUses:0},Bs=W(Dt,"type"),Xs="guest"===Bs||!Bs&&He?$s:Vs;s.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(Ls&&(null===(e=null==at?void 0:at.data)||void 0===e?void 0:e.workspaceId))try{const e=yield T.pickaxeApi2.get(`/cost_per_run?workspaceId=${at.data.workspaceId}`,{withCredentials:!1});t&&Bt(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&Bt(0)}else t&&Bt(0)})),()=>{t=!1}}),[Ls,null===(de=null==at?void 0:at.data)||void 0===de?void 0:de.workspaceId]);const Ks=(({currentUses:e,extraUses:t,limit:s,limitInterval:n})=>{const i=Number(null!=e?e:0),r=Number(null!=t?t:0);return s===F.STUDIO_INFINITY_VALUE||r===F.STUDIO_INFINITY_VALUE?F.STUDIO_INFINITY_VALUE:"one_time"===n?Math.max(0,r-i):Math.max(0,s-i)+r})({currentUses:Xs.currentUses,extraUses:Xs.extraUses,limit:Ds,limitInterval:Ps}),Hs=Ks===F.STUDIO_INFINITY_VALUE?F.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(Ks)),Ws=(({extraUses:e,limit:t,limitInterval:s})=>{const n=Number(null!=e?e:0);return t===F.STUDIO_INFINITY_VALUE||n===F.STUDIO_INFINITY_VALUE?F.STUDIO_INFINITY_VALUE:"one_time"===s?Math.max(0,n):Math.max(0,t)+Math.max(0,n)})({extraUses:Xs.extraUses,limit:Ds,limitInterval:Ps}),zs=Ws===F.STUDIO_INFINITY_VALUE?F.STUDIO_INFINITY_VALUE:Math.ceil(.05*Ws),Gs=Ls?Math.ceil(5*$t):5,Ys=zs===F.STUDIO_INFINITY_VALUE?F.STUDIO_INFINITY_VALUE:Math.max(zs,Gs),Js=s.useMemo((()=>!!Dt&&(!Ft&&(Hs!==F.STUDIO_INFINITY_VALUE&&Hs<=Ys))),[Ft,Ys,Hs,Dt]),Qs=Boolean(null==Le?void 0:Le.hideUpgradeOptions),Zs=Boolean(!Qs&&((null===(ce=null==Le?void 0:Le.upgrade)||void 0===ce?void 0:ce.isBuyMoreUses)||(null===(ue=null==Le?void 0:Le.upgrade)||void 0===ue?void 0:ue.isLinkToCustomURL)||(null===(pe=null==Le?void 0:Le.upgrade)||void 0===pe?void 0:pe.isUpgradeToAnotherGroup)&&(null===(me=Le.upgrade.accessGroupIds)||void 0===me?void 0:me.length))),en=!Qs&&(null===(fe=null==Le?void 0:Le.upgrade)||void 0===fe?void 0:fe.isLinkToCustomURL)&&"string"==typeof Le.upgrade.limitLink&&Le.upgrade.limitLink.trim().length>0?Le.upgrade.limitLink.trim():null,tn=en&&"string"==typeof(null===(ge=null==Le?void 0:Le.upgrade)||void 0===ge?void 0:ge.limitCTA)&&Le.upgrade.limitCTA.trim().length>0?Le.upgrade.limitCTA:(null==Ee?void 0:Ee["pricing.upgrade"])||(null==Ee?void 0:Ee.upgrade)||"Upgrade",sn=s.useMemo((()=>{var e,t,s;return!!Ue&&(!!Ne&&(!ht.isLoading&&(!((null!==(t=null===(e=ht.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=Ne.icebreakers)||void 0===s?void 0:s.length)&&(!Pe&&!_s)))))}),[Ne,Ue,Pe,_s,ht.data,ht.isLoading]),nn=s.useMemo((()=>{if(st||St)return!1;const e=Ss&&tt.length>0&&tt.every((e=>"finished"===e.status));return!(!bt.trim()&&!e)&&tt.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Ss,st,St,bt,tt]);s.useImperativeHandle(ee,(()=>({onSubmit:dn}))),s.useEffect((()=>{qe(sn)}),[sn]),s.useEffect((()=>{var e;if(H){const t=Array.from(Ge),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;dn(s,!0)}}),[H]),s.useEffect((()=>{if(!Qt.current||!Q)return;const e=new ResizeObserver((e=>{for(const t of e)Q(t.contentRect.height)}));return e.observe(Qt.current),()=>{e.disconnect()}}),[Q]),s.useEffect((()=>{if(!is)return;const e=Kt.current?`${Kt.current} `:"";xt(`${e}${ns}`)}),[ns,is]),s.useEffect((()=>{if(!Yt.current)return;(()=>{if(!Yt.current)return;let e=Yt.current.scrollHeight>52;bt.includes("\n")||tt.length?e=!0:bt.trim()||(e=!1),It(e)})()}),[bt,tt]),s.useEffect((()=>{const e=Yt.current,t=Jt.current;if(!e||!t||yt||bt.includes("\n"))return void wt(!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=bt||Ts,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;wt(r>l)}),[bt,yt,Ts]);const rn=t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:Wt.current))return!1;const e=X(Gt.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})},ws&&{credentials:"include"}))).ok}catch(e){return console.warn("Failed to cancel submission",e),!1}})),on=e=>{zt.current=e,Zt.current&&(Zt.current.abort(),Zt.current=null),Ht.current&&(Ht.current.cancel().catch((()=>{})),Ht.current=null)},an=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}))},ws&&{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})),ln=()=>{const e=Wt.current;e&&!St&&!st&&bt.trim()&&(kt((t=>{var s,n;return[...t,{id:B(),message:bt,predecessorSubmissionId:null!==(n=null===(s=t[t.length-1])||void 0===s?void 0:s.id)&&void 0!==n?n:e}]})),xt(""))},dn=(t,s=!1,n=!1,i)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,r,o,a;let l=null;try{if(Ye&&!n||st)return;const d=tt.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),c=d.map((e=>e.documentId)).filter(Boolean),u=d.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),p=null!=t?t:bt,m=null!==(r=null===(e=null==Ne?void 0:Ne.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==r&&r&&c.length>0;if(!p&&!m)return;et(""),ot(""),Ze(null),xt(""),Re(!1),Qe("fetching"),dt(),ut();const f=s?Ge.slice(0,Ge.length-1):Ge,g=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(f),h=g+(s?0:1),b={id:h,role:"assistant",parts:[],documentIds:[]},x=[...f,...s?[]:[{id:g,role:"user",parts:[{type:"text",content:p,isVisible:!0}],documentIds:m?c:[]}],b];Je(x),ut(),m&&rt([]);const y=P.getPickaxeConfigMetadata(Se),I=null!=i?i:B();l=I,Wt.current=I,zt.current=null,Gt.current=[];const j=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({origin:be,pickaxeId:xe,sessionId:ye,submissionId:I,senderType:je,value:p},m&&{documentIds:c}),Ie&&{sender:Ie}),Ke&&{studioSessionToken:Ke}),!Ke&&!Ie&&{sender:D.initializeEmbedUserId()}),Rs&&{portalId:Rs}),Se&&{deploymentId:Se}),y&&{metadata:y}),m&&u.length>0?{uploadedModelImages:u}:{})),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()})},ws&&{credentials:"include"})),w=yield j.json();if(!w.success){if(w.limitData){const e=new Error(w.error||w.message||(null==Ee?void 0:Ee["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=w.limitData,e}if(Cs(w))return;throw new Error(w.error||w.message||(null==Ee?void 0:Ee["failed-to-start-generation"])||"Failed to start generation")}const S=null!==(o=w.submissionId)&&void 0!==o?o:I;l=S,Wt.current=S;const O=()=>zt.current===S;if(O())return;ks&&Ue&&ye&&es.current.add(ye);const N=Object.assign(Object.assign({},Ms()),{message:p,documentIds:m?c:[],uploadedModelImages:m?u:[],hasUploadedDocuments:m,isHidden:s,metadata:null!=y?y:null});qt?(Fs(),R.fireDeploymentFirstMessageSubmittedWebhook(N)):ts.current=N,Qe("streaming"),Zt.current=new AbortController;const k=[];let _=[...null!=pt?pt:[]],E=0,C=!1,T="";for(;!C;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${S}?index=${E}`,{signal:null===(a=Zt.current)||void 0===a?void 0:a.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();Ht.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(O())C=!0;else if(e.event&&"ping"!==e.event&&E++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Ze(t.limitData),et(""),void(C=!0);const s=t.error||t.message||(null==Ee?void 0:Ee["something-went-wrong"])||"Something went wrong.";return Cs(t)||et(s),void(C=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&Z){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 C=!0,Z({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 C=!0,Z({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 C=!0,Z({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 C=!0,Z({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)T="",k.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)T+=n.delta,k[k.length-1].content=T;else if("text-end"===n.type)T="";else if("reasoning-start"===n.type)T="",k.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)T+=n.delta,k[k.length-1].content=T;else if("reasoning-end"===n.type)T="";else if(n.type.startsWith("data-")){const e=n;k.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Gt.current=X(k);const i=X(k);Je((e=>{const t=e.findIndex((e=>e.id===h)),s=Object.assign(Object.assign({},b),{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);_=_.filter((e=>!(e.id===t.id&&e.version===t.version))),_.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ft([..._]),mt.startsWith("inline")||gt({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"})),ft(_),mt.startsWith("inline")||gt({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"})),ft(_),mt.startsWith("inline")||gt({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)),ft(_)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);ft(_.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 Ze(t.limitData),et(""),void(C=!0);const s=t.error||t.message||(null==Ee?void 0:Ee["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(Cs(t))return void(C=!0);et(s)}else"stop"===e.event&&(C=!0)}else C=!0}});for(;;){if(O()){C=!0,t.cancel().catch((()=>{}));break}const{value:e,done:i}=yield t.read();if(O()){C=!0,t.cancel().catch((()=>{}));break}if(i)break;n.feed(s.decode(e))}C||O()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||K(e)||O())return void(C=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==Xe||Xe(ye)}catch(e){if(K(e))return;if(e.limitData)Ze(e.limitData),et("");else{let t=C.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==Ee?void 0:Ee["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),Cs(t)||et(t)}}finally{const e=!l||Wt.current===l;ut(),e&&(Qe("idle"),ct(),Ht.current=null),l&&e&&(Wt.current=null,Gt.current=[]),yield As()}}));return s.useEffect((()=>{if(Ye||St||_t||0===Nt.length)return;const t=Nt[0];Et(!0),Tt(t.id),e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!(yield an(t.predecessorSubmissionId)))return void et((null==Ee?void 0:Ee["queued-message-waiting"])||"A queued message is waiting for the previous response to finish.");kt((e=>e.filter((e=>e.id!==t.id)))),yield dn(t.message,!1,!0,t.id)}finally{Et(!1),Tt(null)}}))}),[Ye,_t,St,Nt]),Es?null:t.jsx("div",Object.assign({className:A.default("flex w-full flex-shrink-0 flex-col items-center",!_s&&"px-4 pb-8"),dir:Ae?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[Nt.length>0&&t.jsx("div",Object.assign({className:"mx-3 -mb-3 overflow-hidden border pb-3",style:{borderColor:_e.text+"18",backgroundColor:null!==(ve=xs.backgroundColor)&&void 0!==ve?ve:_e.text+"08",color:_e.text,borderTopLeftRadius:Math.max(ke.cornerRadius-4,12),borderTopRightRadius:Math.max(ke.cornerRadius-4,12)}},{children:Nt.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<Nt.length-1?{borderBottom:`1px solid ${_e.text}12`}:void 0},{children:[t.jsx(y.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})),Ut===s.id||Ct===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"}),Ut===s.id?(null==Ee?void 0:Ee.steering)||"Steering...":(null==Ee?void 0:Ee.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:St||!Ye,onClick:()=>{(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){const e=Wt.current;if(!e||St)return;const s=Nt.findIndex((e=>e.id===t.id));if(-1===s)return;Ot(!0),At(t.id),et(""),on(e);let n=!1;try{if(!(yield rn(e)))throw new Error((null==Ee?void 0:Ee["failed-to-interrupt-current-response"])||"Failed to interrupt the current response.");if(!(yield an(e)))throw new Error((null==Ee?void 0:Ee["current-response-still-stopping"])||"The current response is still stopping. Please send your message again in a moment.");Qe("idle"),kt((e=>e.filter((e=>e.id!==t.id)))),n=!0,Ot(!1),At(null),yield dn(t.message,!1,!0,t.id)}catch(e){Qe("idle"),n&&kt((e=>{if(e.some((e=>e.id===t.id)))return e;const n=[...e];return n.splice(s,0,t),n})),et(C.default(e))}finally{Ot(!1),At(null)}}))})(s)},"aria-label":`${(null==Ee?void 0:Ee["steer-with"])||"Steer with"}: ${s.message}`},{children:[t.jsx("span",Object.assign({"aria-hidden":"true"},{children:"↳ "})),(null==Ee?void 0:Ee.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:St,onClick:()=>{return e=s.id,void kt((t=>V(t,e)));var e},"aria-label":`${(null==Ee?void 0:Ee["remove-queued-message"])||"Remove queued message"}: ${s.message}`},{children:t.jsx(j.default,{className:"h-4 w-4","aria-hidden":"true"})})),t.jsxs(k.default,Object.assign({id:`queued-message-menu-${s.id}`,className:"shrink-0"},{children:[t.jsx(_.default,Object.assign({className:"flex h-7 w-7 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100",isDisabled:St,role:"button",tabIndex:St?-1:0,"aria-haspopup":"menu","aria-label":(null==Ee?void 0:Ee["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(E.default,Object.assign({role:"menu",align:Ae?"bottom-start":"bottom-end",positionStrategy:De?"absolute":"fixed",width:"auto",className:"p-1 text-sm shadow-xl",style:{backgroundColor:null!==(i=xs.backgroundColor)&&void 0!==i?i:_e.primary,color:_e.text,borderRadius:"12px"},border:`1px solid ${_e.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=>{kt((t=>V(t,e.id))),xt(e.message),requestAnimationFrame((()=>{const t=Yt.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==Ee?void 0:Ee["edit-message"])||"Edit message"]}))}))]}))]})]}),s.id)}))})),t.jsxs("div",Object.assign({ref:Qt,className:A.default("relative z-10 flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===ke.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},xs),{maxHeight:`${ss}px`,overflowY:"auto"})},{children:[Js&&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:xs.backgroundColor?`${xs.backgroundColor}E6`:void 0,borderColor:_e.text+"20",color:_e.text,borderTopRightRadius:ke.cornerRadius+"px",borderTopLeftRadius:ke.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[Hs.toLocaleString()," ",Ls?(null==Ee?void 0:Ee.credits)||"Credits":(null==Ee?void 0:Ee.uses)||"Uses"," ",(null==Ee?void 0:Ee.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[Zs&&t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:_e.accent,color:_e.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),en)return void window.open(en,"_blank","noopener,noreferrer");if(Be)return void Be();const t=D.buildUpgradeUrl({baseUrl:Lt,accessGroupId:null==Le?void 0:Le.accessGroupId});t&&D.openAuthenticatedPricingUrl({deploymentId:Se,pricingUrl:t,studioId:null==Ne?void 0:Ne.studioid,studioSessionToken:Ke})}},{children:tn})),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:()=>Vt(!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"})}))}))]}))]})),!Ye&&tt.length>0&&t.jsx(S.default,{className:"p-4 pb-0",isDisabled:Ye}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Ns&&t.jsxs("div",Object.assign({className:A.default("pointer-events-none absolute top-1/2 z-10 flex -translate-y-1/2 select-none items-center gap-x-2",Ae?"right-4":"left-4")},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(he=_e.accent)&&void 0!==he?he:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:_e.text+"90"}},{children:(null==Ee?void 0:Ee.listening)||"Listening..."}))]})),t.jsx(O.default,Object.assign({ref:Yt,className:A.default(bs.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!bt.trim()&&!bt.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Ae?"text-right":"text-left",Us&&"mb-12"),value:bt,placeholder:Ns?"":Ts,onChange:e=>{xt(e)},onKeyDown:e=>{Te||lt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),st||St||(Ye?ln():dn())))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!Ss)return;t.preventDefault(),Re(!1),yield it(e)}}))},Y&&{onFocus:Y},J&&{onBlur:J},{dir:Ae?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Jt,className:A.default("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",Us?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Us&&xs.backgroundColor&&{backgroundColor:xs.backgroundColor}),{borderTopRightRadius:ke.cornerRadius+"px",borderBottomRightRadius:ke.cornerRadius+"px"})},{children:Ye?t.jsxs(t.Fragment,{children:[t.jsx("button",Object.assign({"aria-label":(null==Ee?void 0:Ee["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=Wt.current;e&&(on(e),rn(e)),Qe("idle")},style:{backgroundColor:_e.accent+"10",color:_e.accent}},{children:t.jsx(I.default,{className:"h-4 w-4 shrink-0"})})),t.jsx("button",Object.assign({"aria-label":(null==Ee?void 0:Ee["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:St||st||!bt.trim(),onClick:ln,style:{backgroundColor:bt.trim()?_e.accent:_e.accent+"10",color:bt.trim()?_e.accentText:_e.accent+"80"}},{children:t.jsx(b.default,{className:A.default("h-6 w-6 shrink-0",Ae&&"scale-x-[-1] transform")})}))]}):is?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:ls,style:{backgroundColor:_e.accent,color:_e.accentText}},{children:t.jsx(I.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Ss&&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:ms?_e.accent+"10":void 0,color:ms?_e.accent:_e.accent+"80"},disabled:st||Ye,onClick:()=>{var e;return null===(e=Xt.current)||void 0===e?void 0:e.click()}},fs,{children:[t.jsx("input",{id:"file-upload",ref:Xt,type:"file",accept:[...g.allowedFileMimeTypes,...g.allowedImageMimeTypes,...g.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Re(!1),yield it(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(h.default,{className:"h-6 w-6 shrink-0"})]})),Os&&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:is?_e.accent:vs?_e.accent+"10":void 0,color:is?_e.accentText:vs?_e.accent:_e.accent+"80"},disabled:st||Ye||rs,onClick:()=>{is?ls():(Kt.current=bt,as(Ce||"en-US"))}},hs,{children:t.jsx(x.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:cs||nn?_e.accent:_e.accent+"10",color:cs||nn?_e.accentText:_e.accent+"80"},disabled:!nn,onClick:()=>dn()},us,{children:t.jsx(b.default,{className:A.default("h-6 w-6 shrink-0",Ae&&"scale-x-[-1] transform")})}))]})}))]}))]})),nt&&t.jsx(N.default,{error:nt,className:"mt-3"})]}))}))}));Y.displayName="Input",exports.default=Y;
@@ -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"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/studio/useStyleFontSize.js"),l=require("../../Addons/Scroll/hooks/useScrollContext.js"),n=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,v,g;const{pickaxe:y,styles:k,colors:w,misc:C,translations:q,disableHtml:N,disableJs:O,disableCss:A,isRtl:I,setSessionId:S,setIsNewChat:P}=t.usePickaxeContext(),{response:D,isGenerating:M}=o.useResponseContext(),{scrollTargetRef:R}=l.useScrollContext(),{setDocuments:T}=n.useDocument(),{onLoadArtifact:$}=a.useArtifact(),F=i.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},I&&{rtl:!0},N&&{disableHtml:!0},O&&{disableJs:!0},A&&{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:[]})})),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!==(g=null===(v=D.question)||void 0===v?void 0:v.responseParts)&&void 0!==g?g:[]).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 S(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,{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"),i=require("react"),o=require("./Addons/Artifact/Provider.js"),a=require("./DimensionProvider.js"),s=require("./ResponseProvider.js"),n=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:h,deploymentType:m,deploymentDimensions:y,deploymentMisc:b,styles:v,colors:w,limits:S={},misc:k={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:x={popupType:"auto"},responsiveBy:C="viewport",locale:F="en",opacity:I=1,forceMobile:q=!1,disableHtml:j=!1,disableJs:T=!1,disableCss:O=!1,loadFont:A=!0,isRtl:D=!1,isEmbed:U=!1,isDropShadow:E=!1,allowGuestUsage:R=!0,preventInitialSessionId:L=!1,onUpgrade:M,onGenerateComplete:G,onSessionIdChange:H})=>{const[W,_]=i.useState(""),[B,V]=i.useState(""),[N,X]=i.useState(""),[Y,z]=i.useState(""),[J,Q]=i.useState(p),[K,Z]=i.useState(null),[$,ee]=i.useState(f),[te,ie]=i.useState("loading"),[oe,ae]=i.useState([]),[se,ne]=i.useState(null),[re,le]=i.useState(null),[de,ce]=i.useState(null),[ue,pe]=i.useState(null),[fe,ge]=i.useState(!1),[he,me]=i.useState(!0),[ye,be]=i.useState(!0),[ve,we]=i.useState(!1);return i.useEffect((()=>{ge(!1)}),[null==v?void 0:v.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&A&&!fe&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[v.font]},active:()=>{ge(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),ge(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),ge(!0)}}))}),[A,fe,null==v?void 0:v.font]),i.useEffect((()=>{Q(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign(Object.assign({origin:u,contextId:W,pickaxeId:B,sessionId:N,lastSessionId:Y,sender:J,senderType:$,portalId:h,deploymentId:g,deploymentType:m,validationStatus:te,validationUpgradeGroups:oe,validationUpgradeUrl:se,deploymentDimensions:y,deploymentMisc:b,accessGroup:K,pickaxe:ue,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},w),misc:k,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","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.","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, or GIF 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:x,responsiveBy:C,locale:F,opacity:I,forceMobile:q,loadFont:A,disableHtml:j,disableJs:T,disableCss:O,isFontLoaded:fe,isNewChat:he,isShowIceBreaker:ye,isShowFeedbackMessage:ve,isRtl:D,isEmbed:U,isDropShadow:E,allowGuestUsage:R,clientSecret:de,stripeAccountId:re,preventInitialSessionId:L,setClientSecret:ce,setStripeAccountId:le,setContextId:_,setValidationStatus:ie,setValidationUpgradeGroups:ae,setValidationUpgradeUrl:ne,setPickaxeId:V,setSessionId:e=>{X((t=>{const i="function"==typeof e?e(t):e;return null==H||H(i),i}))},setLastSessionId:z,setSender:Q,setSenderType:ee,setAccessGroup:Z,setPickaxe:pe,setIsFontLoaded:ge,setIsNewChat:me,setIsShowIceBreaker:be,setIsShowFeedbackMessage:we},M&&{onUpgrade:M}),G&&{onGenerateComplete:G})},{children:t.jsx(r.default,{children:t.jsx(a.default,{children:t.jsx(s.default,Object.assign({limits:S},{children:t.jsx(n.default,{children:t.jsx(o.ArtifactProvider,Object.assign({},x,{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"),s=require("./DimensionProvider.js"),a=require("./ResponseProvider.js"),n=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:h,deploymentType:m,deploymentDimensions:y,deploymentMisc:b,styles:v,colors:w,limits:S={},misc:k={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:C={popupType:"auto"},responsiveBy:x="viewport",locale:F="en",opacity:I=1,forceMobile:q=!1,disableHtml:j=!1,disableJs:T=!1,disableCss:A=!1,loadFont:O=!0,isRtl:D=!1,isEmbed:U=!1,isDropShadow:E=!1,allowGuestUsage:R=!0,persistActiveConversation:L=!1,preventInitialSessionId:M=!1,onUpgrade:G,onGenerateComplete:H,onSessionIdChange:W})=>{const[_,B]=i.useState(""),[V,N]=i.useState(""),[X,Y]=i.useState(""),[z,J]=i.useState(""),[Q,K]=i.useState(p),[Z,$]=i.useState(null),[ee,te]=i.useState(f),[ie,oe]=i.useState("loading"),[se,ae]=i.useState([]),[ne,re]=i.useState(null),[le,de]=i.useState(null),[ce,ue]=i.useState(null),[pe,fe]=i.useState(null),[ge,he]=i.useState(!1),[me,ye]=i.useState(!0),[be,ve]=i.useState(!0),[we,Se]=i.useState(!1);return i.useEffect((()=>{he(!1)}),[null==v?void 0:v.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&O&&!ge&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[v.font]},active:()=>{he(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),he(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),he(!0)}}))}),[O,ge,null==v?void 0:v.font]),i.useEffect((()=>{K(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign(Object.assign({origin:u,contextId:_,pickaxeId:V,sessionId:X,lastSessionId:z,sender:Q,senderType:ee,portalId:h,deploymentId:g,deploymentType:m,validationStatus:ie,validationUpgradeGroups:se,validationUpgradeUrl:ne,deploymentDimensions:y,deploymentMisc:b,accessGroup:Z,pickaxe:pe,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},w),misc:k,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","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.","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, or GIF 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:F,opacity:I,forceMobile:q,loadFont:O,disableHtml:j,disableJs:T,disableCss:A,isFontLoaded:ge,isNewChat:me,isShowIceBreaker:be,isShowFeedbackMessage:we,isRtl:D,isEmbed:U,isDropShadow:E,allowGuestUsage:R,persistActiveConversation:L,clientSecret:ce,stripeAccountId:le,preventInitialSessionId:M,setClientSecret:ue,setStripeAccountId:de,setContextId:B,setValidationStatus:oe,setValidationUpgradeGroups:ae,setValidationUpgradeUrl:re,setPickaxeId:N,setSessionId:e=>{Y((t=>{const i="function"==typeof e?e(t):e;return null==W||W(i),i}))},setLastSessionId:J,setSender:K,setSenderType:te,setAccessGroup:$,setPickaxe:fe,setIsFontLoaded:he,setIsNewChat:ye,setIsShowIceBreaker:ve,setIsShowFeedbackMessage:Se},G&&{onUpgrade:G}),H&&{onGenerateComplete:H})},{children:t.jsx(r.default,{children:t.jsx(s.default,{children:t.jsx(a.default,Object.assign({limits:S},{children:t.jsx(n.default,{children:t.jsx(o.ArtifactProvider,Object.assign({},C,{children:c}))})}))})})}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../../hooks/core/useHover.js"),r=require("../../../hooks/core/usePressed.js"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("framer-motion"),a=require("../../../common/utils.js"),c=require("../../Icons/logout.svg.js"),n=require("./PickaxeSimpleButton.js");exports.default=({tip:u})=>{const{colors:l,styles:d,pickaxe:m}=i.usePickaxeContext(),x=t.useHover(),{isHover:j}=x,v=e.__rest(x,["isHover"]),k=r.usePressed(),{isActive:g}=k,h=e.__rest(k,["isActive"]);return s.jsxs("div",Object.assign({className:"relative"},{children:[s.jsx(n.default,Object.assign({className:"h-8 w-8 shrink-0 items-center justify-center rounded-full duration-300 ease-in-out",color:l.accent,style:{backgroundColor:g?l.accent+"30":j?l.accent+"10":void 0},onClick:()=>{const e=`PXE-token-${null==m?void 0:m.studioid}`;localStorage.getItem(e)?localStorage.removeItem(`PXE-token-${null==m?void 0:m.studioid}`):a.deleteCookie(e),location.reload()},reversed:!0},v,h,{children:s.jsx(c.default,{className:"h-5 w-5 shrink-0"})})),s.jsx(o.AnimatePresence,{children:j&&!!u&&s.jsx(o.motion.div,Object.assign({className:"absolute right-0 top-10 z-10 w-max rounded text-xs font-semibold",style:{background:l.accent,color:l.accentText,padding:"0.5rem 0.75rem",fontWeight:500,borderRadius:d.cornerRadius},initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2,ease:"easeInOut"}},{children:u}))})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),o=require("../../../hooks/core/useHover.js"),s=require("../../../hooks/core/usePressed.js"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("framer-motion"),n=require("../../../common/utils.js"),a=require("../../../common/embedSession.js"),c=require("../Addons/Auth/hooks/useAuthContext.js"),u=require("../../Icons/logout.svg.js"),d=require("./PickaxeSimpleButton.js");exports.default=({tip:l})=>{const{colors:m,styles:x,pickaxe:j,deploymentId:k}=i.usePickaxeContext(),{token:h}=c.useAuthContext(),v=o.useHover(),{isHover:p}=v,g=e.__rest(v,["isHover"]),y=s.usePressed(),{isActive:b}=y,f=e.__rest(y,["isActive"]);return t.jsxs("div",Object.assign({className:"relative"},{children:[t.jsx(d.default,Object.assign({className:"h-8 w-8 shrink-0 items-center justify-center rounded-full duration-300 ease-in-out",color:m.accent,style:{backgroundColor:b?m.accent+"30":p?m.accent+"10":void 0},onClick:()=>{h&&k&&(null==j?void 0:j.formid)&&a.clearAuthenticatedEmbedSession({deploymentId:k,pickaxeId:j.formid,authToken:h});const e=`PXE-token-${null==j?void 0:j.studioid}`;localStorage.getItem(e)?localStorage.removeItem(`PXE-token-${null==j?void 0:j.studioid}`):n.deleteCookie(e),location.reload()},reversed:!0},g,f,{children:t.jsx(u.default,{className:"h-5 w-5 shrink-0"})})),t.jsx(r.AnimatePresence,{children:p&&!!l&&t.jsx(r.motion.div,Object.assign({className:"absolute right-0 top-10 z-10 w-max rounded text-xs font-semibold",style:{background:m.accent,color:m.accentText,padding:"0.5rem 0.75rem",fontWeight:500,borderRadius:x.cornerRadius},initial:{opacity:0,y:-10},animate:{opacity:1,y:0},exit:{opacity:0,y:-10},transition:{duration:.2,ease:"easeInOut"}},{children:l}))})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../hooks/usePickaxeMarkdownContext.js"),n=require("../common/TextShimmer.js");exports.ActionCaption=({node:o,children:s})=>{const{theme:i,actionState:c}=r.usePickaxeMarkdownContext(),d=t.useMemo((()=>{if(!o||!o.properties)return"processing";const e=o.properties.dataIndex;return e?c[e]:"processing"}),[c]),u=t.useMemo((()=>{try{if("undefined"==typeof window||"undefined"==typeof document)return!1;if(!document.documentElement)return!1;return""!==getComputedStyle(document.documentElement).getPropertyValue("--tw-ring-color")}catch(e){return!1}}),[]),a=t.useMemo((()=>"string"==typeof s?s:(null==s?void 0:s.toString())||"Processing..."),[s]),p="done"===d||"error"===d;return e.jsx(n.default,Object.assign({theme:i,isDisabled:p||!u},!p&&!u&&{className:"pxe-blink"},{children:a}))},exports.ActionError=({node:n,children:o})=>{const{setActionState:s}=r.usePickaxeMarkdownContext();return t.useEffect((()=>{if(!n||!n.properties)return;const e=n.properties.dataIndex;e&&s((t=>Object.assign(Object.assign({},t),{[e]:"error"})))}),[]),e.jsx("div",Object.assign({className:"pxe-red pxe-action-error"},{children:o}))},exports.ActionFinished=({node:n})=>{const{setActionState:o}=r.usePickaxeMarkdownContext();return t.useEffect((()=>{if(!n||!n.properties)return;const e=n.properties.dataIndex;e&&o((t=>Object.assign(Object.assign({},t),{[e]:"done"})))}),[]),e.jsx("div",{})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../hooks/usePickaxeMarkdownContext.js"),n=require("../common/TextShimmer.js");exports.ActionCaption=({node:o,children:s})=>{const{theme:i,actionState:c,isStreaming:a}=r.usePickaxeMarkdownContext(),d=t.useMemo((()=>{if(!o||!o.properties)return"processing";const e=o.properties.dataIndex;return e?c[e]:"processing"}),[c]),u=t.useMemo((()=>{try{if("undefined"==typeof window||"undefined"==typeof document)return!1;if(!document.documentElement)return!1;return""!==getComputedStyle(document.documentElement).getPropertyValue("--tw-ring-color")}catch(e){return!1}}),[]),p=t.useMemo((()=>"string"==typeof s?s:(null==s?void 0:s.toString())||"Processing..."),[s]),x=!a||"done"===d||"error"===d;return e.jsx(n.default,Object.assign({theme:i,isDisabled:x||!u},!x&&!u&&{className:"pxe-blink"},{children:p}))},exports.ActionError=({node:n,children:o})=>{const{setActionState:s}=r.usePickaxeMarkdownContext();return t.useEffect((()=>{if(!n||!n.properties)return;const e=n.properties.dataIndex;e&&s((t=>Object.assign(Object.assign({},t),{[e]:"error"})))}),[]),e.jsx("div",Object.assign({className:"pxe-red pxe-action-error"},{children:o}))},exports.ActionFinished=({node:n})=>{const{setActionState:o}=r.usePickaxeMarkdownContext();return t.useEffect((()=>{if(!n||!n.properties)return;const e=n.properties.dataIndex;e&&o((t=>Object.assign(Object.assign({},t),{[e]:"done"})))}),[]),e.jsx("div",{})};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("react");const t=o.createContext({}),r=({children:r,theme:n="light",syntaxTheme:a,colors:l={primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},styles:c={theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"block",btnStyle:"filled",outlineThickness:1,cornerRadius:8},readOnly:i=!1,rtl:s=!1,disableHtml:d=!1,disableJs:F=!1,disableCss:p=!1,disableReasoning:C=!1,onArtifactClick:b})=>{const[m,u]=o.useState(n),[g,h]=o.useState({});return e.jsx(t.Provider,Object.assign({value:Object.assign(Object.assign({theme:m,colors:l,styles:c,actionState:g,readOnly:i,rtl:s,disableHtml:d,disableJs:F,disableCss:p,disableReasoning:C,setTheme:u,setActionState:h},!!b&&{onArtifactClick:b}),{syntaxTheme:a||{'code[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",width:"max-content"},'pre[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",overflow:"auto",borderRadius:"0.3em",background:"#1d1f21",width:"max-content"},':not(pre) > code[class*="language-"]':{background:"#1d1f21",padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6",textDecoration:"underline"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:"#fd971f",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}})},{children:r}))};exports.PickaxeMarkdown=r,exports.PickaxeMarkdownContext=t,exports.default=r;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),o=require("react");const t=o.createContext({}),r=({children:r,theme:n="light",syntaxTheme:a,colors:l={primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},styles:c={theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"block",btnStyle:"filled",outlineThickness:1,cornerRadius:8},readOnly:i=!1,isStreaming:s=!1,rtl:d=!1,disableHtml:F=!1,disableJs:m=!1,disableCss:p=!1,disableReasoning:g=!1,onArtifactClick:C})=>{const[b,u]=o.useState(n),[h,y]=o.useState({});return e.jsx(t.Provider,Object.assign({value:Object.assign(Object.assign({theme:b,colors:l,styles:c,actionState:h,isStreaming:s,readOnly:i,rtl:d,disableHtml:F,disableJs:m,disableCss:p,disableReasoning:g,setTheme:u,setActionState:y},!!C&&{onArtifactClick:C}),{syntaxTheme:a||{'code[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",width:"max-content"},'pre[class*="language-"]':{color:"#c5c8c6",textShadow:"0 1px rgba(0, 0, 0, 0.3)",fontFamily:"Inconsolata, Monaco, Consolas, 'Courier New', Courier, monospace",direction:"ltr",textAlign:"left",whiteSpace:"pre",wordSpacing:"normal",wordBreak:"normal",lineHeight:"1.5",MozTabSize:"4",OTabSize:"4",tabSize:"4",WebkitHyphens:"none",MozHyphens:"none",msHyphens:"none",hyphens:"none",padding:"1em",overflow:"auto",borderRadius:"0.3em",background:"#1d1f21",width:"max-content"},':not(pre) > code[class*="language-"]':{background:"#1d1f21",padding:".1em",borderRadius:".3em"},comment:{color:"#7C7C7C"},prolog:{color:"#7C7C7C"},doctype:{color:"#7C7C7C"},cdata:{color:"#7C7C7C"},punctuation:{color:"#c5c8c6"},".namespace":{opacity:".7"},property:{color:"#96CBFE"},keyword:{color:"#96CBFE"},tag:{color:"#96CBFE"},"class-name":{color:"#FFFFB6",textDecoration:"underline"},boolean:{color:"#99CC99"},constant:{color:"#99CC99"},symbol:{color:"#f92672"},deleted:{color:"#f92672"},number:{color:"#FF73FD"},selector:{color:"#A8FF60"},"attr-name":{color:"#A8FF60"},string:{color:"#A8FF60"},char:{color:"#A8FF60"},builtin:{color:"#A8FF60"},inserted:{color:"#A8FF60"},variable:{color:"#C6C5FE"},operator:{color:"#EDEDED"},entity:{color:"#FFFFB6",cursor:"help"},url:{color:"#96CBFE"},".language-css .token.string":{color:"#87C38A"},".style .token.string":{color:"#87C38A"},atrule:{color:"#F9EE98"},"attr-value":{color:"#F9EE98"},function:{color:"#DAD085"},regex:{color:"#E9C062"},important:{color:"#fd971f",fontWeight:"bold"},bold:{fontWeight:"bold"},italic:{fontStyle:"italic"}}})},{children:r}))};exports.PickaxeMarkdown=r,exports.PickaxeMarkdownContext=t,exports.default=r;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("./TextShimmer.js");exports.default=({caption:r,isLoading:s})=>{const{colors:a,translations:o}=t.usePickaxeContext();return s?e.jsx(i.default,Object.assign({theme:"#000000"===a.text?"light":"dark",isDisabled:!s},{children:r||((null==o?void 0:o.loading)||"Loading...")})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("./TextShimmer.js");exports.default=({caption:s,isLoading:r,isVisible:a})=>{const{colors:o,translations:n}=i.usePickaxeContext();return a?e.jsx(t.default,Object.assign({theme:"#000000"===o.text?"light":"dark",isDisabled:!r},{children:s||((null==n?void 0:n.loading)||"Loading...")})):null};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../ActionToolCaptionPart/TextShimmer.js");exports.default=({caption:r,isLoading:o})=>{const{colors:s,translations:a}=t.usePickaxeContext();return o?e.jsx(i.default,Object.assign({theme:"#000000"===s.text?"light":"dark",isDisabled:!o},{children:r||((null==a?void 0:a.loading)||"Loading...")})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../ActionToolCaptionPart/TextShimmer.js");exports.default=({caption:s,isLoading:r,isVisible:o})=>{const{colors:a,translations:n}=t.usePickaxeContext();return o?e.jsx(i.default,Object.assign({theme:"#000000"===a.text?"light":"dark",isDisabled:!r},{children:s||((null==n?void 0:n.loading)||"Loading...")})):null};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),r=require("../PickaxeMarkdown/Renderer.js"),s=require("../PickaxeMarkdown/Components/A/FilePreview.js"),t=require("../../../../common/utils.js"),i=require("../../../../common/cn.js");const a=n.lazy((()=>Promise.resolve().then((function(){return require("./TextPart/index.js")})))),o=n.lazy((()=>Promise.resolve().then((function(){return require("./ReasoningPart/index.js")})))),l=n.lazy((()=>Promise.resolve().then((function(){return require("./ActionToolCaptionPart/index.js")})))),u=n.lazy((()=>Promise.resolve().then((function(){return require("./ReasoningCaptionPart/index.js")})))),c=/(!?)\[([^\]\n]+)\]\((https?:\/\/[^\s)]+|www\.[^\s)]+)\)/g,d=e=>{const n=new Set;for(const r of e){if("data-tool-assets"!==r.type)continue;const e=t.safeJSONParse(r.content);if(null==e?void 0:e.assets)for(const r of e.assets)r.value&&!s.isGeneratedFileUrl(r.value)&&n.add(s.normalizeMarkdownUrl(r.value))}return n};exports.default=({className:p,parts:f})=>{const v=n.useRef(new Set);v.current=new Set;const x=d(f);return e.jsx("div",Object.assign({className:i.default("flex flex-col gap-2",p)},{children:e.jsx(n.Suspense,Object.assign({fallback:e.jsx("div",{})},{children:f.map(((n,i)=>{if(!n.isVisible)return null;if("text"===n.type){const t=((e,n,r)=>{var t,i;const a=[];let o=0;for(const l of e.matchAll(c)){const u=null!==(t=l.index)&&void 0!==t?t:0,c=l[0],d="!"===l[1],p=null===(i=l[2])||void 0===i?void 0:i.trim(),f=l[3],v=s.getFilePreviewInfo(f);if(!v)continue;if(s.shouldSuppressRichPreviewForUrl(v.url,r))continue;u>o&&a.push({type:"markdown",value:e.slice(o,u)});const x=p&&s.normalizeMarkdownUrl(p)!==v.url?p:void 0;s.shouldRenderFilePreview(v,n)?a.push({type:"preview",key:`${v.url}-${u}`,fileInfo:v,displayName:x}):a.push({type:"markdown",value:d?c:`[${p||v.fileName}](${v.url})`}),o=u+c.length}return o<e.length&&a.push({type:"markdown",value:e.slice(o)}),a.length?a:[{type:"markdown",value:e}]})(n.content,v,x);return e.jsx(a,{children:t.map(((n,t)=>"preview"===n.type?e.jsx(s.default,{fileInfo:n.fileInfo,displayName:n.displayName},n.key):n.value?e.jsx(r.PickaxeMarkdownRenderer,{value:n.value,filePreviewSeenRef:v,suppressedRichPreviewUrls:x},t):null))},i)}if("reasoning"===n.type)return e.jsx(o,Object.assign({isReasoning:i===f.length-1},{children:e.jsx(r.PickaxeMarkdownRenderer,{value:n.content,suppressedRichPreviewUrls:x})}),i);if("data-action-tool-caption"===n.type){const r=t.safeJSONParse(n.content);return e.jsx(l,Object.assign({},r&&r,{isLoading:i===f.length-1}),i)}if("data-reasoning-caption"===n.type){const r=t.safeJSONParse(n.content);return e.jsx(u,Object.assign({},r&&r,{isLoading:i===f.length-1}),i)}return null}))}))}))},exports.getSuppressedRichPreviewUrls=d;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),n=require("react"),r=require("../PickaxeMarkdown/Renderer.js"),s=require("../PickaxeMarkdown/Components/A/FilePreview.js"),i=require("../../../../common/utils.js"),t=require("../../../../common/cn.js");const a=n.lazy((()=>Promise.resolve().then((function(){return require("./TextPart/index.js")})))),o=n.lazy((()=>Promise.resolve().then((function(){return require("./ReasoningPart/index.js")})))),l=n.lazy((()=>Promise.resolve().then((function(){return require("./ActionToolCaptionPart/index.js")})))),u=n.lazy((()=>Promise.resolve().then((function(){return require("./ReasoningCaptionPart/index.js")})))),c=/(!?)\[([^\]\n]+)\]\((https?:\/\/[^\s)]+|www\.[^\s)]+)\)/g,d=e=>{const n=new Set;for(const r of e){if("data-tool-assets"!==r.type)continue;const e=i.safeJSONParse(r.content);if(null==e?void 0:e.assets)for(const r of e.assets)r.value&&!s.isGeneratedFileUrl(r.value)&&n.add(s.normalizeMarkdownUrl(r.value))}return n};exports.default=({className:p,parts:f,isStreaming:v=!1})=>{const m=n.useRef(new Set);m.current=new Set;const x=d(f),w=f.reduce(((e,n,r)=>n.isVisible?r:e),-1);return e.jsx("div",Object.assign({className:t.default("flex flex-col gap-2",p)},{children:e.jsx(n.Suspense,Object.assign({fallback:e.jsx("div",{})},{children:f.map(((n,t)=>{if(!n.isVisible)return null;if("text"===n.type){const i=((e,n,r)=>{var i,t;const a=[];let o=0;for(const l of e.matchAll(c)){const u=null!==(i=l.index)&&void 0!==i?i:0,c=l[0],d="!"===l[1],p=null===(t=l[2])||void 0===t?void 0:t.trim(),f=l[3],v=s.getFilePreviewInfo(f);if(!v)continue;if(s.shouldSuppressRichPreviewForUrl(v.url,r))continue;u>o&&a.push({type:"markdown",value:e.slice(o,u)});const m=p&&s.normalizeMarkdownUrl(p)!==v.url?p:void 0;s.shouldRenderFilePreview(v,n)?a.push({type:"preview",key:`${v.url}-${u}`,fileInfo:v,displayName:m}):a.push({type:"markdown",value:d?c:`[${p||v.fileName}](${v.url})`}),o=u+c.length}return o<e.length&&a.push({type:"markdown",value:e.slice(o)}),a.length?a:[{type:"markdown",value:e}]})(n.content,m,x);return e.jsx(a,{children:i.map(((n,i)=>"preview"===n.type?e.jsx(s.default,{fileInfo:n.fileInfo,displayName:n.displayName},n.key):n.value?e.jsx(r.PickaxeMarkdownRenderer,{value:n.value,filePreviewSeenRef:m,suppressedRichPreviewUrls:x},i):null))},t)}if("reasoning"===n.type)return e.jsx(o,Object.assign({isReasoning:t===f.length-1},{children:e.jsx(r.PickaxeMarkdownRenderer,{value:n.content,suppressedRichPreviewUrls:x})}),t);if("data-action-tool-caption"===n.type){const r=i.safeJSONParse(n.content),s=t===w;return e.jsx(l,Object.assign({},r&&r,{isLoading:v&&s,isVisible:s}),t)}if("data-reasoning-caption"===n.type){const r=i.safeJSONParse(n.content),s=t===w;return e.jsx(u,Object.assign({},r&&r,{isLoading:v&&s,isVisible:s}),t)}return null}))}))}))},exports.getSuppressedRichPreviewUrls=d;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),i=require("react"),a=require("../../hooks/pickaxe/usePickaxeContext.js"),r=require("./Addons/Auth/hooks/useAuthContext.js"),l=require("./Addons/Auth/hooks/useAuthBootstrap.js"),o=require("../../hooks/pickaxe/useResponseContext.js"),n=require("./Addons/Document/hooks/useDocumentContext.js"),c=require("./Addons/Artifact/hooks/useArtifactContext.js"),d=require("uuid"),u=require("./Addons/Scroll/Provider.js"),p=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),f=require("./Addons/Auth/index.js"),j=require("../../common/cn.js"),g=require("../../common/api/pickaxe.js"),h=require("../../common/error.js"),v=require("../../common/validation.js"),b=require("./common/AccessGroupCardPreview.js"),k=require("./common/HorizontalScrollCue.js"),y=require("./common/PickaxeButton.js"),w=require("./common/PickaxeAvatar.js"),N=require("../Icons/lock.svg.js"),q=require("../../node_modules/.pnpm/@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js"),O=require("../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js");const C=({className:e})=>s.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e},{children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}));exports.Pickaxe=({pickaxeId:A,className:_})=>{const{sessionId:I,styles:S,colors:P,responsiveBy:U,deploymentType:E,isNewChat:L,isEmbed:G,opacity:R,deploymentId:T,sender:B,portalId:M,validationStatus:D,validationUpgradeGroups:F,validationUpgradeUrl:V,accessGroup:$,stripeAccountId:z,clientSecret:H,translations:W,preventInitialSessionId:J,setClientSecret:K,setStripeAccountId:X,setValidationStatus:Y,setValidationUpgradeGroups:Q,setValidationUpgradeUrl:Z,setContextId:ee,setPickaxeId:se,setSessionId:te,setPickaxe:ie,setAccessGroup:ae}=a.usePickaxeContext(),{emailInput:re,isSent:le,token:oe,isAuthBootstrapComplete:ne}=r.useAuthContext(),{setMessages:ce,setResponse:de,setError:ue,setLimitData:pe,setIsSwitchedToChat:xe}=o.useResponseContext(),{setDocumentError:me}=n.useDocumentContext(),{setCurrentArtifact:fe}=c.useArtifactContext(),[je,ge]=i.useState(!1),he=t.usePickaxe();l.useAuthBootstrap();const ve="chat-input"===E&&L&&!le,be=i.useMemo((()=>z?O.loadStripe(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:z}):null),[z]);i.useEffect((()=>{se(A)}),[A]);i.useEffect((()=>{if(!T&&!M||!he.data)return;if(!ne)return;if("stripe_checkout"===D)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;Y("loading");try{const s=yield g.pickaxeApi2.post("/access/validate",{data:{deploymentId:T,sender:B||void 0,studioSessionToken:oe,portalId:M,studioId:null===(e=he.data)||void 0===e?void 0:e.studioid}});if(s.data.success)Y("success"),Q([]),Z(null),ae(((e,s)=>e&&s?Object.assign(Object.assign({},e),{hideUpgradeOptions:!0}):e)(s.data.accessGroup,s.data.hideUpgradeOptions));else{const e=v.getValidationFailure(s.data);if(!e)return Y("login_required"),Q([]),void Z(null);Y(e.status),ae(e.accessGroup),Q(e.upgradeGroups),Z(e.upgradeUrl),ge(!0)}}catch(e){console.error("Failed to validate deployment:",e),Y("success")}}))}),[T,ne,B,oe,M,he.data]),i.useEffect((()=>{if(!he.data)return;const e=he.data.chatflag;J||te(e?d.v4():""),ee(d.v4()),e?ce([]):de(null),ue(""),me(""),pe(null),fe(null),xe(!1),ie(he.data),ge(!0)}),[he.data]),i.useEffect((()=>{ue(""),me(""),pe(null),ce([]),de(null),fe(null)}),[I]);const ke=i.useMemo((()=>{const e=null!=R?R:1;if(!P.primary||!P.primary.startsWith("#")||e<0||e>1)return P.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${P.primary}${s}`}),[P.primary,R]);if(!he.data)return null;return s.jsx("div",Object.assign({className:j.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===S.theme&&"dark",_),style:Object.assign({backgroundColor:ve?"transparent":ke,color:P.text},S.font&&"Real Head Pro"!==S.font&&{fontFamily:S.font})},{children:(()=>{var t,i,a,r,l;if("stripe_checkout"===D&&H&&be)return s.jsxs("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:P.secondary||"#ffffff",color:P.secondaryText||"#000000"}},{children:[s.jsx("div",Object.assign({className:"flex items-center p-4 border-b border-gray-100 shrink-0"},{children:s.jsxs("button",Object.assign({onClick:()=>{K&&K(null),X&&X(null),Y("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:P.text}},{children:[s.jsx(C,{className:"w-5 h-5"}),s.jsx("span",{children:(null==W?void 0:W.back)||"Back"})]}))})),s.jsx("div",Object.assign({className:"flex-1 w-full h-full overflow-y-auto [&>div]:h-full"},{children:s.jsx(q.EmbeddedCheckoutProvider,Object.assign({stripe:be,options:{clientSecret:H}},{children:s.jsx(q.EmbeddedCheckout,{})}))}))]}));if(he.isLoading||!je||"loading"===D)return s.jsx("div",Object.assign({className:j.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===U?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s.jsx(p.default,{className:"w-[72px] h-[72px]"}),s.jsx(p.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(p.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(p.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s.jsx(p.default,{className:j.default("w-full min-h-[48px]","viewport"===U?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))}));if("upgrade_required"===D){const e=null==$?void 0:$.hideUpgradeOptions,r=!e&&F.length>0,l=!e&&(null===(t=null==$?void 0:$.upgrade)||void 0===t?void 0:t.isLinkToCustomURL)&&"string"==typeof $.upgrade.limitLink&&$.upgrade.limitLink.trim().length>0?$.upgrade.limitLink.trim():null,o="string"==typeof(null===(i=null==$?void 0:$.upgrade)||void 0===i?void 0:i.limitMessage)&&$.upgrade.limitMessage.trim().length>0?$.upgrade.limitMessage:(null==W?void 0:W["please-upgrade-to-continue-using-this-tool"])||"Please upgrade to continue using this tool.",n="string"==typeof(null===(a=null==$?void 0:$.upgrade)||void 0===a?void 0:a.limitCTA)&&$.upgrade.limitCTA.trim().length>0?$.upgrade.limitCTA:(null==W?void 0:W["pricing.upgrade"])||(null==W?void 0:W.upgrade)||"Upgrade";return s.jsx("div",Object.assign({className:"flex h-full min-h-0 w-full items-start justify-center overflow-y-auto p-4"},{children:l?s.jsxs("div",Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==W?void 0:W["upgrade-required"])||"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:o})),s.jsx(y.default,Object.assign({variant:"primary",className:"min-h-[40px] px-5 text-sm",onClick:()=>{window.open(l,"_blank","noopener,noreferrer")}},{children:n}))]})):r?s.jsxs("div",Object.assign({className:"flex w-full max-w-4xl flex-col items-center gap-6 py-6"},{children:[s.jsxs("div",Object.assign({className:"max-w-[640px] text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2 break-words"},{children:(null==W?void 0:W["upgrade-required"])||"Upgrade Required"})),s.jsx("p",Object.assign({className:"break-words opacity-80"},{children:(null==W?void 0:W["please-upgrade-to-continue-using-this-tool"])||"Please upgrade to continue using this tool."}))]})),s.jsx(k.default,Object.assign({className:"w-full",contentClassName:j.default("gap-4 pb-4",F.length<=3&&("viewport"===U?"min-[767px]:justify-center":"@[767px]/pickaxe-root:justify-center"))},{children:F.map(((e,t)=>s.jsx(b.default,{data:e,upgradeUrl:V},e.accessGroupId||e.id||t)))}))]})):e?s.jsxs("div",Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==W?void 0:W["upgrade-required"])||"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:o}))]})):s.jsxs("div",Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==W?void 0:W["access-locked"])||"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:(null==W?void 0:W["this-tool-is-locked-contact-owner"])||"This tool is locked to use. Contact owner for more information."}))]}))}))}return"login_required"===D&&G?s.jsx(f.default,{}):"login_required"!==D||G?"access_denied"===D?s.jsxs("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[s.jsxs(w.Avatar,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s.jsx(w.AvatarImage,{src:null===(r=he.data)||void 0===r?void 0:r.coverphoto,alt:`${null===(l=he.data)||void 0===l?void 0:l.formtitle} Logo`}),s.jsx(w.AvatarFallback,{})]})),s.jsxs("div",Object.assign({className:"text-center mb-6"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==W?void 0:W["access-denied"])||"Access Denied"})),s.jsxs("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s.jsx(N.default,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s.jsx("p",Object.assign({className:"ml-1"},{children:(null==W?void 0:W["no-access-request-access"])||"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s.jsx("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:P.accent,color:P.accentText,borderRadius:S.cornerRadius},onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;const t=(null==$?void 0:$.accessGroupId)?[$.accessGroupId]:[],i=re.trim().toLowerCase();if(i)try{const a=yield g.pickaxeApi2.post("/access/request",{data:{email:i,studioId:null===(e=he.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=he.data)||void 0===s?void 0:s.formid,deploymentId:T,accessGroupIds:t})}});a.data.success?alert((null==W?void 0:W["access-requested-successfully"])||"Successfully requested access!"):alert(a.data.error)}catch(e){const s=h.default(e);alert(((null==W?void 0:W["request-access-error"])||"Couldn't request access. Error: {error}").replace("{error}",s||String(e)))}else alert((null==W?void 0:W["email-address-cannot-be-empty"])||"Email address cannot be empty.")}))}},{children:(null==W?void 0:W["request-access"])||"Request Access"})),s.jsx("span",Object.assign({className:"mt-4 mb-2"},{children:(null==W?void 0:W.or)||"or"})),s.jsx("span",Object.assign({className:"font-medium text-lg"},{children:(null==W?void 0:W["sign-in-with-different-account"])||"Sign in with a different account"}))]})):I?s.jsx(u.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(u.ScrollProvider,{children:s.jsx(m.default,{})}):s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==W?void 0:W["access-denied"])||"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:(null==W?void 0:W["login-is-required"])||"Login is required."}))]}))}))})()}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),i=require("react"),a=require("../../hooks/pickaxe/usePickaxeContext.js"),o=require("./Addons/Auth/hooks/useAuthContext.js"),r=require("./Addons/Auth/hooks/useAuthBootstrap.js"),l=require("../../hooks/pickaxe/useResponseContext.js"),n=require("./Addons/Document/hooks/useDocumentContext.js"),c=require("./Addons/Artifact/hooks/useArtifactContext.js"),d=require("uuid"),u=require("./Addons/Scroll/Provider.js"),p=require("./common/PickaxeSkeleton.js"),m=require("./Chat/index.js"),x=require("./Form/index.js"),f=require("./Addons/Auth/index.js"),j=require("../../common/cn.js"),g=require("../../common/api/pickaxe.js"),h=require("../../common/error.js"),v=require("../../common/validation.js"),b=require("./common/AccessGroupCardPreview.js"),k=require("./common/HorizontalScrollCue.js"),y=require("./common/PickaxeButton.js"),w=require("./common/PickaxeAvatar.js"),N=require("../Icons/lock.svg.js"),q=require("../../node_modules/.pnpm/@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js"),O=require("../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js"),A=require("../../common/embedSession.js");const I=({className:e})=>s.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e},{children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}));exports.Pickaxe=({pickaxeId:C,className:S})=>{var _,P,E,U;const{sessionId:L,styles:T,colors:R,responsiveBy:G,deploymentType:B,isNewChat:M,isEmbed:D,opacity:F,deploymentId:V,sender:$,portalId:z,validationStatus:H,validationUpgradeGroups:W,validationUpgradeUrl:J,accessGroup:K,stripeAccountId:X,clientSecret:Y,translations:Q,preventInitialSessionId:Z,persistActiveConversation:ee,setClientSecret:se,setStripeAccountId:te,setValidationStatus:ie,setValidationUpgradeGroups:ae,setValidationUpgradeUrl:oe,setContextId:re,setPickaxeId:le,setSessionId:ne,setLastSessionId:ce,setIsNewChat:de,setPickaxe:ue,setAccessGroup:pe}=a.usePickaxeContext(),{emailInput:me,isSent:xe,token:fe,isAuthBootstrapComplete:je}=o.useAuthContext(),{setMessages:ge,setResponse:he,setError:ve,setLimitData:be,setIsSwitchedToChat:ke}=l.useResponseContext(),{setDocumentError:ye}=n.useDocumentContext(),{setCurrentArtifact:we}=c.useArtifactContext(),[Ne,qe]=i.useState(!1),Oe=t.usePickaxe();r.useAuthBootstrap();const Ae=Boolean(D&&V&&ee&&!Z&&(null===(_=Oe.data)||void 0===_?void 0:_.chatflag)&&!Oe.data.enablechatresponses),Ie=Ae?fe:null,Ce=!Ae||je,Se="chat-input"===B&&M&&!xe,_e=i.useMemo((()=>X?O.loadStripe(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:X}):null),[X]);i.useEffect((()=>{le(C)}),[C]);i.useEffect((()=>{if(!V&&!z||!Oe.data)return;if(!je)return;if("stripe_checkout"===H)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;ie("loading");try{const s=yield g.pickaxeApi2.post("/access/validate",{data:{deploymentId:V,sender:$||void 0,studioSessionToken:fe,portalId:z,studioId:null===(e=Oe.data)||void 0===e?void 0:e.studioid}});if(s.data.success)ie("success"),ae([]),oe(null),pe(((e,s)=>e&&s?Object.assign(Object.assign({},e),{hideUpgradeOptions:!0}):e)(s.data.accessGroup,s.data.hideUpgradeOptions));else{const e=v.getValidationFailure(s.data);if(!e)return ie("login_required"),ae([]),void oe(null);ie(e.status),pe(e.accessGroup),ae(e.upgradeGroups),oe(e.upgradeUrl),qe(!0)}}catch(e){console.error("Failed to validate deployment:",e),ie("success")}}))}),[V,je,$,fe,z,Oe.data]),i.useEffect((()=>{if(!Oe.data)return;const s=Oe.data;ue(s);const t=s.chatflag;if(!Ce)return void qe(!1);let i=!1;return e.__awaiter(void 0,void 0,void 0,(function*(){let e="";if(Ie&&V){const t={deploymentId:V,pickaxeId:s.formid,authToken:Ie},i=A.readAuthenticatedEmbedSession(t);if(null==i?void 0:i.sessionId)try{const t=new URLSearchParams({pickaxeId:s.formid,sessionId:i.sessionId,deploymentId:V,studioSessionToken:Ie,resume:"true"});yield g.pickaxeApi2.get(`/conversation?${t.toString()}`),e=i.sessionId}catch(e){A.clearAuthenticatedEmbedSession(t)}}i||(Z||(ne(e||(t?d.v4():"")),ce(e),de(!e)),re(d.v4()),t?ge([]):he(null),ve(""),ye(""),be(null),we(null),ke(!1),qe(!0))})),()=>{i=!0}}),[Ae,V,D,Ce,Ie,ee,Oe.data,Z]),i.useEffect((()=>{var e;if(!D||!V||!fe||!(null===(e=Oe.data)||void 0===e?void 0:e.formid)||Z)return;const s={deploymentId:V,pickaxeId:Oe.data.formid,authToken:fe};ee&&Oe.data.chatflag&&!Oe.data.enablechatresponses&&!M&&L?A.writeAuthenticatedEmbedSession(Object.assign(Object.assign({},s),{sessionId:L})):A.clearAuthenticatedEmbedSession(s)}),[V,D,M,ee,null===(P=Oe.data)||void 0===P?void 0:P.chatflag,null===(E=Oe.data)||void 0===E?void 0:E.enablechatresponses,null===(U=Oe.data)||void 0===U?void 0:U.formid,Z,L,fe]),i.useEffect((()=>{ve(""),ye(""),be(null),ge([]),he(null),we(null)}),[L]);const Pe=i.useMemo((()=>{const e=null!=F?F:1;if(!R.primary||!R.primary.startsWith("#")||e<0||e>1)return R.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${R.primary}${s}`}),[R.primary,F]);if(!Oe.data)return null;return s.jsx("div",Object.assign({className:j.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===T.theme&&"dark",S),style:Object.assign({backgroundColor:Se?"transparent":Pe,color:R.text},T.font&&"Real Head Pro"!==T.font&&{fontFamily:T.font})},{children:(()=>{var t,i,a,o,r;if("stripe_checkout"===H&&Y&&_e)return s.jsxs("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:R.secondary||"#ffffff",color:R.secondaryText||"#000000"}},{children:[s.jsx("div",Object.assign({className:"flex items-center p-4 border-b border-gray-100 shrink-0"},{children:s.jsxs("button",Object.assign({onClick:()=>{se&&se(null),te&&te(null),ie("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:R.text}},{children:[s.jsx(I,{className:"w-5 h-5"}),s.jsx("span",{children:(null==Q?void 0:Q.back)||"Back"})]}))})),s.jsx("div",Object.assign({className:"flex-1 w-full h-full overflow-y-auto [&>div]:h-full"},{children:s.jsx(q.EmbeddedCheckoutProvider,Object.assign({stripe:_e,options:{clientSecret:Y}},{children:s.jsx(q.EmbeddedCheckout,{})}))}))]}));if(Oe.isLoading||!Ne||"loading"===H)return s.jsx("div",Object.assign({className:j.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===G?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s.jsx(p.default,{className:"w-[72px] h-[72px]"}),s.jsx(p.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(p.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(p.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s.jsx(p.default,{className:j.default("w-full min-h-[48px]","viewport"===G?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))}));if("upgrade_required"===H){const e=null==K?void 0:K.hideUpgradeOptions,o=!e&&W.length>0,r=!e&&(null===(t=null==K?void 0:K.upgrade)||void 0===t?void 0:t.isLinkToCustomURL)&&"string"==typeof K.upgrade.limitLink&&K.upgrade.limitLink.trim().length>0?K.upgrade.limitLink.trim():null,l="string"==typeof(null===(i=null==K?void 0:K.upgrade)||void 0===i?void 0:i.limitMessage)&&K.upgrade.limitMessage.trim().length>0?K.upgrade.limitMessage:(null==Q?void 0:Q["please-upgrade-to-continue-using-this-tool"])||"Please upgrade to continue using this tool.",n="string"==typeof(null===(a=null==K?void 0:K.upgrade)||void 0===a?void 0:a.limitCTA)&&K.upgrade.limitCTA.trim().length>0?K.upgrade.limitCTA:(null==Q?void 0:Q["pricing.upgrade"])||(null==Q?void 0:Q.upgrade)||"Upgrade";return s.jsx("div",Object.assign({className:"flex h-full min-h-0 w-full items-start justify-center overflow-y-auto p-4"},{children:r?s.jsxs("div",Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==Q?void 0:Q["upgrade-required"])||"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:l})),s.jsx(y.default,Object.assign({variant:"primary",className:"min-h-[40px] px-5 text-sm",onClick:()=>{window.open(r,"_blank","noopener,noreferrer")}},{children:n}))]})):o?s.jsxs("div",Object.assign({className:"flex w-full max-w-4xl flex-col items-center gap-6 py-6"},{children:[s.jsxs("div",Object.assign({className:"max-w-[640px] text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2 break-words"},{children:(null==Q?void 0:Q["upgrade-required"])||"Upgrade Required"})),s.jsx("p",Object.assign({className:"break-words opacity-80"},{children:(null==Q?void 0:Q["please-upgrade-to-continue-using-this-tool"])||"Please upgrade to continue using this tool."}))]})),s.jsx(k.default,Object.assign({className:"w-full",contentClassName:j.default("gap-4 pb-4",W.length<=3&&("viewport"===G?"min-[767px]:justify-center":"@[767px]/pickaxe-root:justify-center"))},{children:W.map(((e,t)=>s.jsx(b.default,{data:e,upgradeUrl:J},e.accessGroupId||e.id||t)))}))]})):e?s.jsxs("div",Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==Q?void 0:Q["upgrade-required"])||"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:l}))]})):s.jsxs("div",Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==Q?void 0:Q["access-locked"])||"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:(null==Q?void 0:Q["this-tool-is-locked-contact-owner"])||"This tool is locked to use. Contact owner for more information."}))]}))}))}return"login_required"===H&&D?s.jsx(f.default,{}):"login_required"!==H||D?"access_denied"===H?s.jsxs("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[s.jsxs(w.Avatar,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s.jsx(w.AvatarImage,{src:null===(o=Oe.data)||void 0===o?void 0:o.coverphoto,alt:`${null===(r=Oe.data)||void 0===r?void 0:r.formtitle} Logo`}),s.jsx(w.AvatarFallback,{})]})),s.jsxs("div",Object.assign({className:"text-center mb-6"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==Q?void 0:Q["access-denied"])||"Access Denied"})),s.jsxs("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s.jsx(N.default,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s.jsx("p",Object.assign({className:"ml-1"},{children:(null==Q?void 0:Q["no-access-request-access"])||"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s.jsx("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:R.accent,color:R.accentText,borderRadius:T.cornerRadius},onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;const t=(null==K?void 0:K.accessGroupId)?[K.accessGroupId]:[],i=me.trim().toLowerCase();if(i)try{const a=yield g.pickaxeApi2.post("/access/request",{data:{email:i,studioId:null===(e=Oe.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=Oe.data)||void 0===s?void 0:s.formid,deploymentId:V,accessGroupIds:t})}});a.data.success?alert((null==Q?void 0:Q["access-requested-successfully"])||"Successfully requested access!"):alert(a.data.error)}catch(e){const s=h.default(e);alert(((null==Q?void 0:Q["request-access-error"])||"Couldn't request access. Error: {error}").replace("{error}",s||String(e)))}else alert((null==Q?void 0:Q["email-address-cannot-be-empty"])||"Email address cannot be empty.")}))}},{children:(null==Q?void 0:Q["request-access"])||"Request Access"})),s.jsx("span",Object.assign({className:"mt-4 mb-2"},{children:(null==Q?void 0:Q.or)||"or"})),s.jsx("span",Object.assign({className:"font-medium text-lg"},{children:(null==Q?void 0:Q["sign-in-with-different-account"])||"Sign in with a different account"}))]})):L?s.jsx(u.ScrollProvider,{children:s.jsx(m.default,{})}):s.jsx(u.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==Q?void 0:Q["access-denied"])||"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:(null==Q?void 0:Q["login-is-required"])||"Login is required."}))]}))}))})()}))};