@pickaxeproject/react 6.18.0 → 6.18.2-beta.0

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 (69) hide show
  1. package/dist/cjs/common/actionApproval.js +1 -0
  2. package/dist/cjs/common/chatMessages.js +1 -1
  3. package/dist/cjs/components/Pickaxe/Chat/History/Message.js +1 -1
  4. package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
  5. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  6. package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
  7. package/dist/cjs/components/Pickaxe/Form/Questions/Submit.js +1 -1
  8. package/dist/cjs/components/Pickaxe/ResponseProvider.js +1 -1
  9. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/Action/index.js +1 -1
  10. package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/index.js +1 -1
  11. package/dist/cjs/components/Pickaxe/common/PickaxeMessageParts/ActionApprovalPart.js +1 -0
  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/hooks/pickaxe/useActionApprovals.js +1 -0
  16. package/dist/cjs/hooks/pickaxe/useTextToSpeech.js +1 -1
  17. package/dist/cjs/index.js +1 -1
  18. package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  19. package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  20. package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  21. package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  22. package/dist/cjs/src/common/actionApproval.d.ts +16 -0
  23. package/dist/cjs/src/common/chatMessages.d.ts +1 -1
  24. package/dist/cjs/src/components/Pickaxe/ResponseProvider.d.ts +3 -0
  25. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +1 -0
  26. package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +3 -1
  27. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/ActionApprovalPart.d.ts +6 -0
  28. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.d.ts +2 -1
  29. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.d.ts +2 -1
  30. package/dist/cjs/src/components/Pickaxe/common/PickaxeMessageParts/index.d.ts +5 -1
  31. package/dist/cjs/src/hooks/pickaxe/useActionApprovals.d.ts +10 -0
  32. package/dist/cjs/src/hooks/pickaxe/useResponseContext.d.ts +10 -0
  33. package/dist/cjs/src/index.d.ts +2 -0
  34. package/dist/cjs/src/types/history.d.ts +6 -2
  35. package/dist/esm/common/actionApproval.js +1 -0
  36. package/dist/esm/common/chatMessages.js +1 -1
  37. package/dist/esm/components/Pickaxe/Chat/History/Message.js +1 -1
  38. package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
  39. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  40. package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
  41. package/dist/esm/components/Pickaxe/Form/Questions/Submit.js +1 -1
  42. package/dist/esm/components/Pickaxe/ResponseProvider.js +1 -1
  43. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/Action/index.js +1 -1
  44. package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/index.js +1 -1
  45. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ActionApprovalPart.js +1 -0
  46. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.js +1 -1
  47. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.js +1 -1
  48. package/dist/esm/components/Pickaxe/common/PickaxeMessageParts/index.js +1 -1
  49. package/dist/esm/hooks/pickaxe/useActionApprovals.js +1 -0
  50. package/dist/esm/hooks/pickaxe/useTextToSpeech.js +1 -1
  51. package/dist/esm/index.js +1 -1
  52. package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
  53. package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
  54. package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
  55. package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
  56. package/dist/esm/src/common/actionApproval.d.ts +16 -0
  57. package/dist/esm/src/common/chatMessages.d.ts +1 -1
  58. package/dist/esm/src/components/Pickaxe/ResponseProvider.d.ts +3 -0
  59. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/hooks/usePickaxeMarkdownContext.d.ts +1 -0
  60. package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/index.d.ts +3 -1
  61. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/ActionApprovalPart.d.ts +6 -0
  62. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/ActionToolCaptionPart/index.d.ts +2 -1
  63. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/ReasoningCaptionPart/index.d.ts +2 -1
  64. package/dist/esm/src/components/Pickaxe/common/PickaxeMessageParts/index.d.ts +5 -1
  65. package/dist/esm/src/hooks/pickaxe/useActionApprovals.d.ts +10 -0
  66. package/dist/esm/src/hooks/pickaxe/useResponseContext.d.ts +10 -0
  67. package/dist/esm/src/index.d.ts +2 -0
  68. package/dist/esm/src/types/history.d.ts +6 -2
  69. package/package.json +207 -206
@@ -0,0 +1 @@
1
+ "use strict";function t(t){try{const e=JSON.parse(t);return e&&"string"==typeof e.id&&"string"==typeof e.name&&"string"==typeof e.pickaxeId&&"number"==typeof e.expiresAt&&["action","mcp"].includes(e.kind)&&["pending","approved","declined","expired","cancelled"].includes(e.status)&&(void 0===e.arguments||"string"==typeof e.arguments)?e:null}catch(t){return null}}Object.defineProperty(exports,"__esModule",{value:!0}),exports.parseActionApproval=t,exports.updateStreamTextPart=function(t,e,n){for(let r=t.length-1;r>=0;r--)if(t[r].type===e)return void(t[r].content=n)},exports.upsertActionApprovalPart=function(e,n){const r=e.findIndex((e=>{var r;return"data-action-approval"===e.type&&(null===(r=t(e.content))||void 0===r?void 0:r.id)===n.id})),i={type:"data-action-approval",content:JSON.stringify(n),isVisible:!0};r<0?e.push(i):e[r]=i};
@@ -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;
@@ -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("../../../common/actionApproval.js"),n=require("react"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),o=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),d=require("../../../hooks/pickaxe/useDimensionContext.js"),c=require("../Addons/Auth/hooks/useAuthContext.js"),u=require("../Addons/Document/hooks/useDocument.js"),p=require("../Addons/Scroll/hooks/useScroll.js"),m=require("../Addons/Artifact/hooks/useArtifactContext.js"),f=require("../../../hooks/core/useHover.js"),g=require("../../../hooks/core/useMediaQuery.js"),v=require("../../../common/documents.js"),h=require("eventsource-parser"),b=require("../../Icons/attach-vertical.svg.js"),x=require("../../Icons/arrow-right.svg.js"),y=require("../../Icons/microphone.svg.js"),I=require("../../Icons/message-clock.svg.js"),j=require("../../Icons/stop.svg.js"),w=require("../../Icons/trash.svg.js"),S=require("../../Icons/pencil.svg.js"),O=require("../Addons/Document/List.js"),N=require("../../Core/Textarea.js"),k=require("../../Core/ErrorAlert.js"),_=require("../../Core/Menu/index.js"),E=require("../../Core/Menu/Button.js"),C=require("../../Core/Menu/List.js"),T=require("../../../common/error.js"),U=require("../../../common/api/pickaxe.js"),A=require("../../../common/validation.js"),P=require("../../../common/cn.js"),D=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=n.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,fe,ge,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:Pe,isEmbed:De,isShowFeedbackMessage:Le,accessGroup:qe,setIsNewChat:Re,setIsShowIceBreaker:Me,setValidationStatus:Fe,setValidationUpgradeGroups:Ve,setValidationUpgradeUrl:$e,setAccessGroup:Be,onUpgrade:Xe,onGenerateComplete:Ke}=i.usePickaxeContext(),{token:He,isLoggedOut:We,isSent:ze,isPricingAuth:Ge}=c.useAuthContext(),{messages:Ye,isGenerating:Je,setMessages:Qe,setStatus:Ze,setLimitData:et,setError:tt,setActionApprovalToken:st}=r.useResponseContext(),{documents:nt,isUploading:it,documentError:rt,onFileUpload:ot,setDocuments:at,setDocumentError:lt}=u.useDocument(),{studio:dt}=M.useStudio(),[ct]=g.useMediaQuery("(max-width: 480px)"),{scrollStartSession:ut,scrollEndSession:pt,scrollToBottom:mt}=p.useScroll({auto:!0,smooth:!(Ue||ct)}),{artifacts:ft,currentPopupType:gt,setArtifacts:vt,setCurrentArtifact:ht}=m.useArtifactContext(),{height:bt}=d.useDimensionContext(),xt=l.useConversation(),[yt,It]=n.useState((()=>q.readAgentPrefill([Oe,ye]).chatInput)),[jt,wt]=n.useState(!1),[St,Ot]=n.useState(!1),[Nt,kt]=n.useState(!1),[_t,Et]=n.useState([]),[Ct,Tt]=n.useState(!1),[Ut,At]=n.useState(null),[Pt,Dt]=n.useState(null),[Lt,qt]=n.useState(null),[Rt,Mt]=n.useState(null),[Ft,Vt]=n.useState(!1),[$t,Bt]=n.useState(!1),[Xt,Kt]=n.useState(0),Ht=n.useRef(null),Wt=n.useRef(""),zt=n.useRef(null),Gt=n.useRef(null),Yt=n.useRef(null),Jt=n.useRef([]),Qt=n.useRef(null),Zt=n.useRef(null),es=n.useRef(null),ts=n.useRef(null),ss=n.useRef(new Set),ns=n.useRef(null),is=Math.max(.4*bt,100),{speechTranscript:rs,isSpeechListening:os,isSpeechProcessing:as,isSpeechSupported:ls,onStartListening:ds,onStopListening:cs}=F.useSpeechToText(),us=f.useHover(),{isHover:ps}=us,ms=e.__rest(us,["isHover"]),fs=f.useHover(),{isHover:gs}=fs,vs=e.__rest(fs,["isHover"]),hs=f.useHover(),{isHover:bs}=hs,xs=e.__rest(hs,["isHover"]),ys=a.useStyleFontSize(),Is=o.useStyleInput(),js="undefined"!=typeof window?window.location.hostname:"",ws="undefined"!=typeof window?window.location.href:"",Ss="undefined"!=typeof window&&window.self!==window.top,Os=js.includes("pickaxe.co")&&!ws.includes("https://studio.pickaxe.co/_embed")&&!Ss,Ns=null!==(ne=null===(se=null==ke?void 0:ke.documentuploadtype)||void 0===se?void 0:se.startsWith("enduserupload"))&&void 0!==ne&&ne,ks=ls&&(null==ke?void 0:ke.enablevoicetotext),_s=os&&!yt.trim(),Es=B(Oe),Cs="chat-input"===Ne&&Ae&&!ze,Ts="chat-input"===Ne&&Ge&&We&&ze,Us=n.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,st,et,Fe,Ve,$e,Be]),As=null!==(ie=null==ke?void 0:ke.placeholdertext)&&void 0!==ie?ie:Pe?"بماذا تريد أن تتحدث؟":(null==Ce?void 0:Ce["what-do-you-want-to-talk-about"])||"What do you want to talk about?",Ps=jt||St,Ds=n.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){Vt(!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: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}})),Os&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(qt(t.studioUser),Mt(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{Vt(!0)}}))),[Os,null==ke?void 0:ke.studioid,je,He]);n.useEffect((()=>{Ds()}),[Ds]);const Ls=Number(null!==(re=null==qe?void 0:qe.limit)&&void 0!==re?re:0),qs="string"==typeof(null==qe?void 0:qe.limitInterval)?qe.limitInterval:null,Rs=!!(null==dt?void 0:dt.data.usage)&&dt.data.usage.isCredits,Ms=n.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=Se?Se:z(Lt,"portalId"))&&void 0!==e?e:z(Lt,"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,Lt]),Fs=n.useMemo((()=>Y({studioUser:Lt,deploymentId:Oe,portalId:Ms})),[Oe,Ms,Lt]);n.useEffect((()=>{Es&&Ae&&Ie&&ss.current.add(Ie)}),[Ae,Ie,Es]);const Vs=n.useCallback((()=>{var e,t,s;return{studioId:null==ke?void 0:ke.studioid,userEmail:z(Lt,"email"),userId:null!==(e=z(Lt,"userId"))&&void 0!==e?e:z(Lt,"userid"),sessionId:Ie,deploymentId:Oe,deploymentType:Ne,portalId:Ms,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,Ms,je,we,Ie,Lt]),$s=n.useCallback((()=>!!(Es&&Ft&&Ie)&&(!!ss.current.has(Ie)&&(R.fireDeploymentSessionInitializedWebhook(Vs()),ss.current.delete(Ie),!0))),[Vs,Ft,Ie,Es]);n.useEffect((()=>{if(!Ft||!Ie)return;$s();const e=ns.current;(null==e?void 0:e.sessionId)===Ie&&(R.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),Vs()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),ns.current=null)}),[$s,Vs,Ft,Ie]);const Bs={currentUses:G(null==Lt?void 0:Lt.currentUses),extraUses:G(null==Lt?void 0:Lt.extraUses)},Xs=Fs.scope?{currentUses:null!==(ae=G(null===(oe=Fs.record)||void 0===oe?void 0:oe.currentUses))&&void 0!==ae?ae:0,extraUses:null!==(de=G(null===(le=Fs.record)||void 0===le?void 0:le.extraUses))&&void 0!==de?de:0}:{currentUses:0,extraUses:0},Ks=z(Lt,"type"),Hs="guest"===Ks||!Ks&&We?Xs:Bs;n.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(Rs&&(null===(e=null==dt?void 0:dt.data)||void 0===e?void 0:e.workspaceId))try{const e=yield U.pickaxeApi2.get(`/cost_per_run?workspaceId=${dt.data.workspaceId}`,{withCredentials:!1});t&&Kt(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&Kt(0)}else t&&Kt(0)})),()=>{t=!1}}),[Rs,null===(ce=null==dt?void 0:dt.data)||void 0===ce?void 0:ce.workspaceId]);const Ws=(({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:Hs.currentUses,extraUses:Hs.extraUses,limit:Ls,limitInterval:qs}),zs=Ws===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(Ws)),Gs=(({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:Hs.extraUses,limit:Ls,limitInterval:qs}),Ys=Gs===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:Math.ceil(.05*Gs),Js=Rs?Math.ceil(5*Xt):5,Qs=Ys===V.STUDIO_INFINITY_VALUE?V.STUDIO_INFINITY_VALUE:Math.max(Ys,Js),Zs=n.useMemo((()=>!!Lt&&(!$t&&(zs!==V.STUDIO_INFINITY_VALUE&&zs<=Qs))),[$t,Qs,zs,Lt]),en=Boolean(null==qe?void 0:qe.hideUpgradeOptions),tn=Boolean(!en&&((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===(fe=qe.upgrade.accessGroupIds)||void 0===fe?void 0:fe.length))),sn=!en&&(null===(ge=null==qe?void 0:qe.upgrade)||void 0===ge?void 0:ge.isLinkToCustomURL)&&"string"==typeof qe.upgrade.limitLink&&qe.upgrade.limitLink.trim().length>0?qe.upgrade.limitLink.trim():null,nn=sn&&"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",rn=n.useMemo((()=>{var e,t,s;return!!Ae&&(!!ke&&(!xt.isLoading&&(!((null!==(t=null===(e=xt.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&&!Cs)))))}),[ke,Ae,Le,Cs,xt.data,xt.isLoading]),on=n.useMemo((()=>{if(it||Nt)return!1;const e=Ns&&nt.length>0&&nt.every((e=>"finished"===e.status));return!(!yt.trim()&&!e)&&nt.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Ns,it,Nt,yt,nt]);n.useImperativeHandle(te,(()=>({onSubmit:un}))),n.useEffect((()=>{Me(rn)}),[rn]),n.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;un(s,!0)}}),[W]),n.useEffect((()=>{if(!es.current||!Z)return;const e=new ResizeObserver((e=>{for(const t of e)Z(t.contentRect.height)}));return e.observe(es.current),()=>{e.disconnect()}}),[Z]),n.useEffect((()=>{if(!os)return;const e=Wt.current?`${Wt.current} `:"";It(`${e}${rs}`)}),[rs,os]),n.useEffect((()=>{if(!Qt.current)return;(()=>{if(!Qt.current)return;let e=Qt.current.scrollHeight>52;yt.includes("\n")||nt.length?e=!0:yt.trim()||(e=!1),wt(e)})()}),[yt,nt]),n.useEffect((()=>{const e=Qt.current,t=Zt.current;if(!e||!t||jt||yt.includes("\n"))return void Ot(!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=yt||As,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;Ot(r>l)}),[yt,jt,As]);const an=t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:Gt.current))return!1;const e=K(Jt.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})},Os&&{credentials:"include"}))).ok}catch(e){return console.warn("Failed to cancel submission",e),!1}})),ln=e=>{Yt.current=e,ts.current&&(ts.current.abort(),ts.current=null),zt.current&&(zt.current.cancel().catch((()=>{})),zt.current=null)},dn=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}))},Os&&{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})),cn=()=>{const e=Gt.current;e&&!Nt&&!it&&yt.trim()&&(Et((t=>{var s,n;return[...t,{id:X(),message:yt,predecessorSubmissionId:null!==(n=null===(s=t[t.length-1])||void 0===s?void 0:s.id)&&void 0!==n?n:e}]})),It(""))},un=(t,n=!1,i=!1,r)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,o,a,l,d;let c=null;try{if(Je&&!i||it)return;const u=nt.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}})),f=null!=t?t:yt,g=null!==(o=null===(e=null==ke?void 0:ke.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==o&&o&&p.length>0;if(!f&&!g)return;tt(""),lt(""),et(null),It(""),Re(!1),Ze("fetching"),ut(),mt();const v=n?Ye.slice(0,Ye.length-1):Ye,b=(e=>e.reduce(((e,t)=>Math.max(e,t.id)),0)+1)(v),x=b+(n?0:1),y={id:x,role:"assistant",parts:[],documentIds:[]},I=[...v,...n?[]:[{id:b,role:"user",parts:[{type:"text",content:f,isVisible:!0}],documentIds:g?p:[]}],y];Qe(I),mt(),g&&at([]);const j=L.getPickaxeConfigMetadata(Oe),w=null!=r?r:X();c=w,Gt.current=w,Yt.current=null,Jt.current=[];const S=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({supportsActionConfirmation:!0,origin:xe,pickaxeId:ye,sessionId:Ie,submissionId:w,senderType:we,value:f},g&&{documentIds:p}),je&&{sender:je}),He&&{studioSessionToken:He}),!He&&!je&&{sender:D.initializeEmbedUserId()}),Ms&&{portalId:Ms}),Oe&&{deploymentId:Oe}),j&&{metadata:j}),g&&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()})},Os&&{credentials:"include"})),O=yield S.json();if(!O.success){if(O.limitData){const e=new Error(O.error||O.message||(null==Ce?void 0:Ce["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=O.limitData,e}if(Us(O))return;throw new Error(O.error||O.message||(null==Ce?void 0:Ce["failed-to-start-generation"])||"Failed to start generation")}st(null!==(a=O.actionApprovalToken)&&void 0!==a?a:null);const N=null!==(l=O.submissionId)&&void 0!==l?l:w;c=N,Gt.current=N;const k=()=>Yt.current===N;if(k())return;Es&&Ae&&Ie&&ss.current.add(Ie);const _=Object.assign(Object.assign({},Vs()),{message:f,documentIds:g?p:[],uploadedModelImages:g?m:[],hasUploadedDocuments:g,isHidden:n,metadata:null!=j?j:null});Ft?($s(),R.fireDeploymentFirstMessageSubmittedWebhook(_)):ns.current=_,Ze("streaming"),ts.current=new AbortController;const E=[];let C=[...null!=ft?ft:[]],T=0,U=!1,A="";for(;!U;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${N}?index=${T}`,{signal:null===(d=ts.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();zt.current=t;const n=new TextDecoder,i=h.createParser({onEvent:e=>{var t,n;if(k())U=!0;else if(e.event&&"ping"!==e.event&&T++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return et(t.limitData),tt(""),void(U=!0);const s=t.error||t.message||(null==Ce?void 0:Ce["something-went-wrong"])||"Something went wrong.";return Us(t)||tt(s),void(U=!0)}if("delta"===e.event){const i=JSON.parse(e.data);if("data-error"===i.type&&ee){const e=i.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 U=!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 U=!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 U=!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 U=!0,ee({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===i.type)A="",E.push({type:"text",content:"",isVisible:null===(t=i.isVisible)||void 0===t||t});else if("text-delta"===i.type)A+=i.delta,s.updateStreamTextPart(E,"text",A);else if("text-end"===i.type)A="";else if("reasoning-start"===i.type)A="",E.push({type:"reasoning",content:"",isVisible:null===(n=i.isVisible)||void 0===n||n});else if("reasoning-delta"===i.type)A+=i.delta,s.updateStreamTextPart(E,"reasoning",A);else if("reasoning-end"===i.type)A="";else if(i.type.startsWith("data-")){const e=i;"data-action-approval"===e.type?s.upsertActionApprovalPart(E,e.data):E.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}Jt.current=K(E);const r=K(E);Qe((e=>{const t=e.findIndex((e=>e.id===x)),s=Object.assign(Object.assign({},y),{parts:r});return-1===t?[...e,s]:e.map(((e,n)=>n===t?s:e))}))}else if("artifact_created"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),vt([...C]),gt.startsWith("inline")||ht({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),vt(C),gt.startsWith("inline")||ht({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);C=C.filter((e=>!(e.id===t.id&&e.version===t.version))),C.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),vt(C),gt.startsWith("inline")||ht({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");C=C.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),vt(C)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);vt(C.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return et(t.limitData),tt(""),void(U=!0);const s=t.error||t.message||(null==Ce?void 0:Ce["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(Us(t))return void(U=!0);tt(s)}else"stop"===e.event&&(U=!0)}else U=!0}});for(;;){if(k()){U=!0,t.cancel().catch((()=>{}));break}const{value:e,done:s}=yield t.read();if(k()){U=!0,t.cancel().catch((()=>{}));break}if(s)break;i.feed(n.decode(e))}U||k()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||H(e)||k())return void(U=!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=T.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."),Us(t)||tt(t)}}finally{const e=!c||Gt.current===c;mt(),e&&(Ze("idle"),pt(),zt.current=null),c&&e&&(Gt.current=null,Jt.current=[]),yield Ds()}}));return n.useEffect((()=>{if(Je||Nt||Ct||0===_t.length)return;const t=_t[0];Tt(!0),At(t.id),e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!(yield dn(t.predecessorSubmissionId)))return void tt((null==Ce?void 0:Ce["queued-message-waiting"])||"A queued message is waiting for the previous response to finish.");Et((e=>e.filter((e=>e.id!==t.id)))),yield un(t.message,!1,!0,t.id)}finally{Tt(!1),At(null)}}))}),[Je,Ct,Nt,_t]),Ts?null:t.jsx("div",Object.assign({className:P.default("flex w-full flex-shrink-0 flex-col items-center",!Cs&&"px-4 pb-8"),dir:Pe?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[_t.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=Is.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:_t.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<_t.length-1?{borderBottom:`1px solid ${Ee.text}12`}:void 0},{children:[t.jsx(I.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})),Pt===s.id||Ut===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"}),Pt===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:Nt||!Je,onClick:()=>{(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){const e=Gt.current;if(!e||Nt)return;const s=_t.findIndex((e=>e.id===t.id));if(-1===s)return;kt(!0),Dt(t.id),tt(""),ln(e);let n=!1;try{if(!(yield an(e)))throw new Error((null==Ce?void 0:Ce["failed-to-interrupt-current-response"])||"Failed to interrupt the current response.");if(!(yield dn(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"),Et((e=>e.filter((e=>e.id!==t.id)))),n=!0,kt(!1),Dt(null),yield un(t.message,!1,!0,t.id)}catch(e){Ze("idle"),n&&Et((e=>{if(e.some((e=>e.id===t.id)))return e;const n=[...e];return n.splice(s,0,t),n})),tt(T.default(e))}finally{kt(!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:Nt,onClick:()=>{return e=s.id,void Et((t=>$(t,e)));var e},"aria-label":`${(null==Ce?void 0:Ce["remove-queued-message"])||"Remove queued message"}: ${s.message}`},{children:t.jsx(w.default,{className:"h-4 w-4","aria-hidden":"true"})})),t.jsxs(_.default,Object.assign({id:`queued-message-menu-${s.id}`,className:"shrink-0"},{children:[t.jsx(E.default,Object.assign({className:"flex h-7 w-7 items-center justify-center rounded-md opacity-50 transition-opacity hover:opacity-100",isDisabled:Nt,role:"button",tabIndex:Nt?-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(C.default,Object.assign({role:"menu",align:Pe?"bottom-start":"bottom-end",positionStrategy:De?"absolute":"fixed",width:"auto",className:"p-1 text-sm shadow-xl",style:{backgroundColor:null!==(i=Is.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=>{Et((t=>$(t,e.id))),It(e.message),requestAnimationFrame((()=>{const t=Qt.current;t&&(t.focus(),t.setSelectionRange(e.message.length,e.message.length))}))})(s)},{children:[t.jsx(S.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:es,className:P.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({},Is),{maxHeight:`${is}px`,overflowY:"auto"})},{children:[Zs&&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:Is.backgroundColor?`${Is.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:[zs.toLocaleString()," ",Rs?(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:[tn&&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(),sn)return void window.open(sn,"_blank","noopener,noreferrer");if(Xe)return void Xe();const t=D.buildUpgradeUrl({baseUrl:Rt,accessGroupId:null==qe?void 0:qe.accessGroupId});t&&D.openAuthenticatedPricingUrl({deploymentId:Oe,pricingUrl:t,studioId:null==ke?void 0:ke.studioid,studioSessionToken:He})}},{children:nn})),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:()=>Bt(!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&&nt.length>0&&t.jsx(O.default,{className:"p-4 pb-0",isDisabled:Je}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[_s&&t.jsxs("div",Object.assign({className:P.default("pointer-events-none absolute top-1/2 z-10 flex -translate-y-1/2 select-none items-center gap-x-2",Pe?"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(N.default,Object.assign({ref:Qt,className:P.default(ys.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!yt.trim()&&!yt.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Pe?"text-right":"text-left",Ps&&"mb-12"),value:yt,placeholder:_s?"":As,onChange:e=>{It(e)},onKeyDown:e=>{Ue||ct||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),it||Nt||(Je?cn():un())))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!Ns)return;t.preventDefault(),Re(!1),yield ot(e)}}))},J&&{onFocus:J},Q&&{onBlur:Q},{dir:Pe?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Zt,className:P.default("flex items-center gap-2 absolute z-2 transition-all duration-200 ease-in-out",Ps?"bottom-3 right-2":"right-0 top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!Ps&&Is.backgroundColor&&{backgroundColor:Is.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=Gt.current;e&&(ln(e),an(e)),Ze("idle")},style:{backgroundColor:Ee.accent+"10",color:Ee.accent}},{children:t.jsx(j.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:Nt||it||!yt.trim(),onClick:cn,style:{backgroundColor:yt.trim()?Ee.accent:Ee.accent+"10",color:yt.trim()?Ee.accentText:Ee.accent+"80"}},{children:t.jsx(x.default,{className:P.default("h-6 w-6 shrink-0",Pe&&"scale-x-[-1] transform")})}))]}):os?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:cs,style:{backgroundColor:Ee.accent,color:Ee.accentText}},{children:t.jsx(j.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Ns&&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:it||Je,onClick:()=>{var e;return null===(e=Ht.current)||void 0===e?void 0:e.click()}},vs,{children:[t.jsx("input",{id:"file-upload",ref:Ht,type:"file",accept:[...v.allowedFileMimeTypes,...v.allowedImageMimeTypes,...v.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){Re(!1),yield ot(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(b.default,{className:"h-6 w-6 shrink-0"})]})),ks&&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:os?Ee.accent:bs?Ee.accent+"10":void 0,color:os?Ee.accentText:bs?Ee.accent:Ee.accent+"80"},disabled:it||Je||as,onClick:()=>{os?cs():(Wt.current=yt,ds(Te||"en-US"))}},xs,{children:t.jsx(y.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:ps||on?Ee.accent:Ee.accent+"10",color:ps||on?Ee.accentText:Ee.accent+"80"},disabled:!on,onClick:()=>un()},ms,{children:t.jsx(x.default,{className:P.default("h-6 w-6 shrink-0",Pe&&"scale-x-[-1] transform")})}))]})}))]}))]})),rt&&t.jsx(k.default,{error:rt,className:"mt-3"})]}))}))}));J.displayName="Input",exports.default=J;
@@ -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"),s=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),r=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Scroll/hooks/useScroll.js"),l=require("../../Addons/Artifact/hooks/useArtifactContext.js"),d=require("../../../../common/utils.js"),u=require("@nem035/gpt-3-encoder"),c=require("eventsource-parser"),p=require("../../common/PickaxeBranding.js"),g=require("../../common/PickaxeButton.js"),m=require("../../../../common/error.js"),f=require("../../../../common/validation.js");exports.default=({questions:v,resetQuestions:h})=>{var b;const{origin:x,pickaxeId:j,sender:y,senderType:O,portalId:w,deploymentId:S,pickaxe:C,misc:I,translations:k,isRtl:q,setSessionId:_,setIsNewChat:E,setValidationStatus:P,setValidationUpgradeGroups:A,setValidationUpgradeUrl:N,setAccessGroup:T,onGenerateComplete:D}=n.usePickaxeContext(),{token:U}=i.useAuthContext(),{isGenerating:L,setResponse:R,setMessages:B,setStatus:J,setLimitData:V,setError:K,setIsSwitchedToChat:W}=o.useResponseContext(),{documents:X,websiteLink:G,isUploading:F,onWebsiteUpload:M,setDocuments:$,setDocumentError:z}=r.useDocument(),{scrollStartSession:Q,scrollEndSession:Y,scrollToTarget:H}=a.useScroll({auto:!(null==C?void 0:C.enablechatresponses)}),{artifacts:Z,currentPopupType:ee,setArtifacts:te,setCurrentArtifact:se}=l.useArtifactContext(),[ne,ie]=s.useState(!1),oe=s.useRef(null),re=e=>{const t=f.getValidationFailure(e);return!!t&&(K(""),V(null),P(t.status),T(t.accessGroup),A(t.upgradeGroups),N(t.upgradeUrl),!0)},ae=s.useMemo((()=>v.some((e=>("Short Answer"===e.type||"Long Answer"===e.type||"long"===e.type||"short"===e.type||"Checkbox"===e.type||"Knowledge Upload"===e.type||e.id.includes("documentupload"))&&e.input.length>0))),[v]);return t.jsxs("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:q?"rtl":"ltr"},{children:[t.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[t.jsx(g.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:F||L||ne,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,s;try{if(L||F||ne)return;K(""),z(""),V(null),R(null);const n=["Multiple Choice","Checkbox"];for(const e of v){if(u.encode(e.input).length>e.maxLength&&!n.includes(e.type))throw new Error((null==k?void 0:k["response-too-long"])||"One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error((null==k?void 0:k["required-fields-missing"])||"You must fill out all required fields.")}const i=X.filter((e=>"finished"===e.status)),o=X.map((e=>e.name)),r=null!==(t=null===(e=null==C?void 0:C.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==t&&t,a=v.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),l=d.extractUrlsFromText(G).filter((e=>!o.includes(e)));if(l.length){const e=l[l.length-1];ie(!0);const t=yield M(e);t&&(i.push(t),yield new Promise((e=>setTimeout(e,5e3)))),ie(!1)}else if(a&&r&&!i.length)return void z((null==k?void 0:k["document-upload-required"])||"Please paste a valid website/video link or drag a file to add to the knowledge base.");const p=i.map((e=>e.documentId||"")).filter(Boolean),g=r&&p.length>0,m={};v.forEach((e=>{m[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?i.map((e=>e.name)).join(",")||"":e.input})),J("fetching"),Q(),H();const f=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,{method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),{"x-request-sent-at":(new Date).toISOString()}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:x,pickaxeId:j,senderType:O,valueObj:m},g&&{documentIds:p}),y&&{sender:y}),U&&{studioSessionToken:U}),!U&&!y&&{sender:d.initializeEmbedUserId()}),w&&{portalId:w}),S&&{deploymentId:S}))}),h=yield f.json();if(!h.success){const e=new Error(h.error||h.message||(null==k?void 0:k["failed-to-start-generation"])||"Failed to start generation");if(h.limitData)throw e.limitData=h.limitData,e;if(re(h))return;throw e}if(!h.submissionId||!h.sessionId)throw new Error((null==k?void 0:k["failed-to-start-generation"])||"Failed to start generation");const b=h.submissionId,I=h.sessionId,q={sessionId:I,documentIds:g?p:[],question:{inputs:v.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};R(q),(null==C?void 0:C.enablechatresponses)&&(_(I),E(!1),W(!0),B([{id:0,role:"assistant",parts:[],documentIds:[]}])),g&&$([]),J("streaming"),oe.current=new AbortController;const P=[];let A=[...null!=Z?Z:[]],N=0,T=!1,Y="";for(;!T;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${b}?index=${N}`,{signal:null===(s=oe.current)||void 0===s?void 0:s.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),n=new TextDecoder,i=c.createParser({onEvent:e=>{var t,s;if(e.event&&"ping"!==e.event&&N++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return V(t.limitData),K(""),void(T=!0);const s=t.error||t.message||(null==k?void 0:k["something-went-wrong"])||"Something went wrong.";return re(t)||K(s),void(T=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)Y="",P.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)Y+=n.delta,P[P.length-1].content=Y;else if("text-end"===n.type)Y="";else if("reasoning-start"===n.type)Y="",P.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)Y+=n.delta,P[P.length-1].content=Y;else if("reasoning-end"===n.type)Y="";else if(n.type.startsWith("data-")){const e=n;P.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const i=Object.assign(Object.assign({},q),{question:Object.assign(Object.assign({},q.question),{responseParts:[...P]})});R(i),(null==C?void 0:C.enablechatresponses)&&B([{id:0,role:"assistant",parts:[...P],documentIds:[]}])}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"})),te([...A]),ee.startsWith("inline")||se({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"})),te([...A]),ee.startsWith("inline")||se({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"})),te([...A]),ee.startsWith("inline")||se({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)),te([...A])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);te(A.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else T=!0}});for(;;){const{value:e,done:s}=yield t.read();if(s)break;i.feed(n.decode(e))}T||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if(e instanceof Error&&"AbortError"===e.name)return void(T=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==D||D(I)}catch(e){if((e=>e instanceof Error&&Boolean(e.limitData))(e))return V(e.limitData),K(""),void H();let t=m.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==k?void 0:k["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),re(t)||K(t),H()}finally{J("idle"),ie(!1),Y()}}))},{children:ne?(null==k?void 0:k.processing)||"Processing...":F?(null==k?void 0:k.uploading)||"Uploading...":L?(null==k?void 0:k.loading)||"Loading...":null!==(b=null==C?void 0:C.submittext)&&void 0!==b?b:"Submit"})),ae&&t.jsx(g.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:F||L||ne,onClick:h},{children:(null==k?void 0:k["form.clear-form"])||(null==k?void 0:k["clear-form"])||"Clear form"}))]})),!I.isWhiteLabel&&t.jsx(p.default,{containerClassName:"justify-end"})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../../../common/actionApproval.js"),i=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../Addons/Auth/hooks/useAuthContext.js"),r=require("../../../../hooks/pickaxe/useResponseContext.js"),a=require("../../Addons/Document/hooks/useDocument.js"),l=require("../../Addons/Scroll/hooks/useScroll.js"),d=require("../../Addons/Artifact/hooks/useArtifactContext.js"),u=require("../../../../common/utils.js"),c=require("@nem035/gpt-3-encoder"),p=require("eventsource-parser"),m=require("../../common/PickaxeBranding.js"),g=require("../../common/PickaxeButton.js"),f=require("../../../../common/error.js"),v=require("../../../../common/validation.js");exports.default=({questions:h,resetQuestions:b})=>{var x;const{origin:j,pickaxeId:y,sender:O,senderType:w,portalId:S,deploymentId:C,pickaxe:I,misc:k,translations:A,isRtl:P,setSessionId:q,setIsNewChat:_,setValidationStatus:E,setValidationUpgradeGroups:N,setValidationUpgradeUrl:T,setAccessGroup:D,onGenerateComplete:U}=n.usePickaxeContext(),{token:L}=o.useAuthContext(),{isGenerating:R,setResponse:B,setMessages:J,setStatus:V,setLimitData:K,setError:W,setActionApprovalToken:X,setIsSwitchedToChat:G}=r.useResponseContext(),{documents:F,websiteLink:M,isUploading:$,onWebsiteUpload:z,setDocuments:Q,setDocumentError:Y}=a.useDocument(),{scrollStartSession:H,scrollEndSession:Z,scrollToTarget:ee}=l.useScroll({auto:!(null==I?void 0:I.enablechatresponses)}),{artifacts:te,currentPopupType:se,setArtifacts:ie,setCurrentArtifact:ne}=d.useArtifactContext(),[oe,re]=i.useState(!1),ae=i.useRef(null),le=e=>{const t=v.getValidationFailure(e);return!!t&&(W(""),K(null),E(t.status),D(t.accessGroup),N(t.upgradeGroups),T(t.upgradeUrl),!0)},de=i.useMemo((()=>h.some((e=>("Short Answer"===e.type||"Long Answer"===e.type||"long"===e.type||"short"===e.type||"Checkbox"===e.type||"Knowledge Upload"===e.type||e.id.includes("documentupload"))&&e.input.length>0))),[h]);return t.jsxs("div",Object.assign({className:"mt-4 flex flex-wrap justify-between gap-4 items-center",dir:P?"rtl":"ltr"},{children:[t.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[t.jsx(g.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:$||R||oe,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,t,i,n;try{if(R||$||oe)return;W(""),Y(""),K(null),B(null);const o=["Multiple Choice","Checkbox"];for(const e of h){if(c.encode(e.input).length>e.maxLength&&!o.includes(e.type))throw new Error((null==A?void 0:A["response-too-long"])||"One or more of your responses is too long!");if(e.isRequired&&!e.input.trim()&&"userinput:documentupload"!==e.id)throw new Error((null==A?void 0:A["required-fields-missing"])||"You must fill out all required fields.")}const r=F.filter((e=>"finished"===e.status)),a=F.map((e=>e.name)),l=null!==(t=null===(e=null==I?void 0:I.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==t&&t,d=h.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),m=u.extractUrlsFromText(M).filter((e=>!a.includes(e)));if(m.length){const e=m[m.length-1];re(!0);const t=yield z(e);t&&(r.push(t),yield new Promise((e=>setTimeout(e,5e3)))),re(!1)}else if(d&&l&&!r.length)return void Y((null==A?void 0:A["document-upload-required"])||"Please paste a valid website/video link or drag a file to add to the knowledge base.");const g=r.map((e=>e.documentId||"")).filter(Boolean),f=l&&g.length>0,v={};h.forEach((e=>{v[e.id]="Knowledge Upload"===e.type||e.id.includes("documentupload")?r.map((e=>e.name)).join(",")||"":e.input})),V("fetching"),H(),ee();const b=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,{method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}),{"x-request-sent-at":(new Date).toISOString()}),body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({supportsActionConfirmation:!0,origin:j,pickaxeId:y,senderType:w,valueObj:v},f&&{documentIds:g}),O&&{sender:O}),L&&{studioSessionToken:L}),!L&&!O&&{sender:u.initializeEmbedUserId()}),S&&{portalId:S}),C&&{deploymentId:C}))}),x=yield b.json();if(!x.success){const e=new Error(x.error||x.message||(null==A?void 0:A["failed-to-start-generation"])||"Failed to start generation");if(x.limitData)throw e.limitData=x.limitData,e;if(le(x))return;throw e}if(!x.submissionId||!x.sessionId)throw new Error((null==A?void 0:A["failed-to-start-generation"])||"Failed to start generation");X(null!==(i=x.actionApprovalToken)&&void 0!==i?i:null);const k=x.submissionId,P=x.sessionId,E={sessionId:P,documentIds:f?g:[],question:{inputs:h.map((e=>({id:e.id,question:e.main,answer:e.input}))),responseParts:[]},messageCount:0,sentAt:new Date};B(E),(null==I?void 0:I.enablechatresponses)&&(q(P),_(!1),G(!0),J([{id:0,role:"assistant",parts:[],documentIds:[]}])),f&&Q([]),V("streaming"),ae.current=new AbortController;const N=[];let T=[...null!=te?te:[]],D=0,Z=!1,de="";for(;!Z;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${k}?index=${D}`,{signal:null===(n=ae.current)||void 0===n?void 0:n.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader(),i=new TextDecoder,o=p.createParser({onEvent:e=>{var t,i;if(e.event&&"ping"!==e.event&&D++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return K(t.limitData),W(""),void(Z=!0);const s=t.error||t.message||(null==A?void 0:A["something-went-wrong"])||"Something went wrong.";return le(t)||W(s),void(Z=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("text-start"===n.type)de="",N.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)de+=n.delta,s.updateStreamTextPart(N,"text",de);else if("text-end"===n.type)de="";else if("reasoning-start"===n.type)de="",N.push({type:"reasoning",content:"",isVisible:null===(i=n.isVisible)||void 0===i||i});else if("reasoning-delta"===n.type)de+=n.delta,s.updateStreamTextPart(N,"reasoning",de);else if("reasoning-end"===n.type)de="";else if(n.type.startsWith("data-")){const e=n;"data-action-approval"===e.type?s.upsertActionApprovalPart(N,e.data):N.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}const o=Object.assign(Object.assign({},E),{question:Object.assign(Object.assign({},E.question),{responseParts:[...N]})});B(o),(null==I?void 0:I.enablechatresponses)&&J([{id:0,role:"assistant",parts:[...N],documentIds:[]}])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);T=T.filter((e=>!(e.id===t.id&&e.version===t.version))),T.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ie([...T]),se.startsWith("inline")||ne({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);T=T.filter((e=>!(e.id===t.id&&e.version===t.version))),T.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),ie([...T]),se.startsWith("inline")||ne({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);T=T.filter((e=>!(e.id===t.id&&e.version===t.version))),T.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),ie([...T]),se.startsWith("inline")||ne({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");T=T.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),ie([...T])}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);ie(T.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}}else Z=!0}});for(;;){const{value:e,done:s}=yield t.read();if(s)break;o.feed(i.decode(e))}Z||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if(e instanceof Error&&"AbortError"===e.name)return void(Z=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==U||U(P)}catch(e){if((e=>e instanceof Error&&Boolean(e.limitData))(e))return K(e.limitData),W(""),void ee();let t=f.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==A?void 0:A["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),le(t)||W(t),ee()}finally{V("idle"),re(!1),Z()}}))},{children:oe?(null==A?void 0:A.processing)||"Processing...":$?(null==A?void 0:A.uploading)||"Uploading...":R?(null==A?void 0:A.loading)||"Loading...":null!==(x=null==I?void 0:I.submittext)&&void 0!==x?x:"Submit"})),de&&t.jsx(g.default,Object.assign({variant:"transparent-text",className:"min-h-[42px] px-5",isDisabled:$||R||oe,onClick:b},{children:(null==A?void 0:A["form.clear-form"])||(null==A?void 0:A["clear-form"])||"Clear form"}))]})),!k.isWhiteLabel&&t.jsx(m.default,{containerClassName:"justify-end"})]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");const s=t.createContext({});exports.ResponseContext=s,exports.default=({limits:i,children:r})=>{const[a,u]=t.useState("idle"),[n,o]=t.useState([]),[c,l]=t.useState(null),[d,S]=t.useState(null),[h,m]=t.useState(!1),[p,x]=t.useState(!1),[g,j]=t.useState("");return e.jsx(s.Provider,Object.assign({value:{messages:n,response:c,status:a,limits:i,limitData:d,error:g,isGenerating:"fetching"===a||"streaming"===a,isGuestLimitReached:h,isSwitchedToChat:p,setMessages:o,setResponse:l,setStatus:u,setLimitData:S,setError:j,setIsGuestLimitReached:m,setIsSwitchedToChat:x}},{children:r}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/useActionApprovals.js"),s=require("react");const i=s.createContext({});exports.ResponseContext=i,exports.default=({limits:r,children:a})=>{const[o,n]=s.useState("idle"),u=t.useActionApprovals("streaming"===o),[c,l]=s.useState([]),[p,d]=s.useState(null),[h,m]=s.useState(null),[S,v]=s.useState(!1),[x,g]=s.useState(!1),[A,j]=s.useState("");return e.jsx(i.Provider,Object.assign({value:{messages:c,response:p,status:o,limits:r,limitData:h,error:A,isGenerating:"fetching"===o||"streaming"===o,isGuestLimitReached:S,isSwitchedToChat:x,setMessages:l,setResponse:d,setStatus:n,setLimitData:m,setError:j,setActionApprovalToken:u.setToken,actionApproval:u,setIsGuestLimitReached:v,setIsSwitchedToChat:g}},{children:a}))};
@@ -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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../common/actionApproval.js");exports.ActionApprovalPart=function({content:n,isStreaming:i=!1,approval:t}){var a;const r=s.parseActionApproval(n);if(!r)return null;const o=null!==(a=null==t?void 0:t.decisions[r.id])&&void 0!==a?a:r.status,l="pending"===o&&i&&(null==t?void 0:t.enabled)&&1e3*r.expiresAt>Date.now(),d=Boolean(null==t?void 0:t.busyId),c="pending"===o?l?"Confirmation needed":"Confirmation unavailable":{approved:"Approved",declined:"Declined",expired:"Expired",cancelled:"Not run"}[o];let p=r.arguments;try{p&&(p=JSON.stringify(JSON.parse(p),null,2))}catch(e){}return e.jsxs("section",Object.assign({"aria-label":`Action: ${r.name}`,className:"my-2 w-full min-w-0 rounded-xl border p-4 text-sm",style:{borderColor:"color-mix(in srgb, currentColor 20%, transparent)"}},{children:[e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-2"},{children:[e.jsx("span",Object.assign({className:"break-words font-semibold"},{children:r.name})),e.jsx("span",Object.assign({role:"status",className:"rounded-full border px-2 py-0.5 text-xs"},{children:c}))]})),l&&e.jsx("p",Object.assign({className:"mt-2 opacity-70"},{children:"Review this action before it runs. Your decision applies only to this call."})),p&&e.jsxs("details",Object.assign({className:"mt-3",open:"pending"===o},{children:[e.jsx("summary",Object.assign({className:"cursor-pointer text-xs font-medium"},{children:"Action inputs"})),e.jsx("pre",Object.assign({className:"mt-2 max-h-64 overflow-auto whitespace-pre-wrap break-words rounded-lg bg-black/5 p-3 text-xs"},{children:p}))]})),l&&e.jsxs("div",Object.assign({className:"mt-4 flex flex-wrap justify-end gap-2"},{children:[e.jsx("button",Object.assign({type:"button",className:"rounded-lg border px-3 py-2 font-semibold transition-opacity hover:opacity-70 disabled:opacity-50",disabled:d,onClick:()=>{null==t||t.decide(r.id,"declined")}},{children:"Decline"})),e.jsx("button",Object.assign({type:"button",className:"rounded-lg border px-3 py-2 font-semibold transition-opacity hover:opacity-70 disabled:opacity-50",disabled:d,onClick:()=>{null==t||t.decide(r.id,"approved")}},{children:"Approve action"}))]})),(null==t?void 0:t.errors[r.id])&&e.jsx("p",Object.assign({role:"alert",className:"mt-2 text-xs"},{children:t.errors[r.id]}))]}))};
@@ -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("./ActionApprovalPart.js"),r=require("../../../../hooks/pickaxe/useResponseContext.js"),s=require("react"),t=require("../PickaxeMarkdown/Renderer.js"),i=require("../PickaxeMarkdown/Components/A/FilePreview.js"),o=require("../../../../common/utils.js"),a=require("../../../../common/cn.js");const l=s.lazy((()=>Promise.resolve().then((function(){return require("./TextPart/index.js")})))),u=s.lazy((()=>Promise.resolve().then((function(){return require("./ReasoningPart/index.js")})))),c=s.lazy((()=>Promise.resolve().then((function(){return require("./ActionToolCaptionPart/index.js")})))),p=s.lazy((()=>Promise.resolve().then((function(){return require("./ReasoningCaptionPart/index.js")})))),d=/(!?)\[([^\]\n]+)\]\((https?:\/\/[^\s)]+|www\.[^\s)]+)\)/g,f=e=>{const n=new Set;for(const r of e){if("data-tool-assets"!==r.type)continue;const e=o.safeJSONParse(r.content);if(null==e?void 0:e.assets)for(const r of e.assets)r.value&&!i.isGeneratedFileUrl(r.value)&&n.add(i.normalizeMarkdownUrl(r.value))}return n};exports.default=({className:v,parts:x,isStreaming:j=!1,actionApproval:m})=>{const{actionApproval:w}=r.useResponseContext(),P=null!=m?m:w,h=s.useRef(new Set);h.current=new Set;const g=f(x),y=x.reduce(((e,n,r)=>n.isVisible?r:e),-1);return e.jsx("div",Object.assign({className:a.default("flex flex-col gap-2",v)},{children:e.jsx(s.Suspense,Object.assign({fallback:e.jsx("div",{})},{children:x.map(((r,s)=>{if(!r.isVisible)return null;if("data-action-approval"===r.type)return e.jsx(n.ActionApprovalPart,{content:r.content,isStreaming:j,approval:P},s);if("text"===r.type){const n=((e,n,r)=>{var s,t;const o=[];let a=0;for(const l of e.matchAll(d)){const u=null!==(s=l.index)&&void 0!==s?s:0,c=l[0],p="!"===l[1],d=null===(t=l[2])||void 0===t?void 0:t.trim(),f=l[3],v=i.getFilePreviewInfo(f);if(!v)continue;if(i.shouldSuppressRichPreviewForUrl(v.url,r))continue;u>a&&o.push({type:"markdown",value:e.slice(a,u)});const x=d&&i.normalizeMarkdownUrl(d)!==v.url?d:void 0;i.shouldRenderFilePreview(v,n)?o.push({type:"preview",key:`${v.url}-${u}`,fileInfo:v,displayName:x}):o.push({type:"markdown",value:p?c:`[${d||v.fileName}](${v.url})`}),a=u+c.length}return a<e.length&&o.push({type:"markdown",value:e.slice(a)}),o.length?o:[{type:"markdown",value:e}]})(r.content,h,g);return e.jsx(l,{children:n.map(((n,r)=>"preview"===n.type?e.jsx(i.default,{fileInfo:n.fileInfo,displayName:n.displayName},n.key):n.value?e.jsx(t.PickaxeMarkdownRenderer,{value:n.value,filePreviewSeenRef:h,suppressedRichPreviewUrls:g},r):null))},s)}if("reasoning"===r.type)return e.jsx(u,Object.assign({isReasoning:s===x.length-1},{children:e.jsx(t.PickaxeMarkdownRenderer,{value:r.content,suppressedRichPreviewUrls:g})}),s);if("data-action-tool-caption"===r.type){const n=o.safeJSONParse(r.content),t=s===y;return e.jsx(c,Object.assign({},n&&n,{isLoading:j&&t,isVisible:t}),s)}if("data-reasoning-caption"===r.type){const n=o.safeJSONParse(r.content),t=s===y;return e.jsx(p,Object.assign({},n&&n,{isLoading:j&&t,isVisible:t}),s)}return null}))}))}))},exports.getSuppressedRichPreviewUrls=f;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),r=require("react");exports.useActionApprovals=function(t){const[n,s]=r.useState(null),[o,a]=r.useState(null),[i,u]=r.useState({}),[c,l]=r.useState({}),d=r.useRef(null);r.useEffect((()=>(a(null),u({}),l({}),()=>{var e;null===(e=d.current)||void 0===e||e.abort(),d.current=null})),[n,t]);const b=r.useCallback(((r,s)=>e.__awaiter(this,void 0,void 0,(function*(){if(!t||!n||d.current)return;const e=new AbortController;d.current=e;const o=setTimeout((()=>e.abort()),15e3);a(r),u((e=>Object.assign(Object.assign({},e),{[r]:""})));try{const t=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/action-approvals/${r}`,{method:"POST",headers:{Authorization:`Bearer ${n}`,"Content-Type":"application/json"},body:JSON.stringify({decision:s}),signal:e.signal});if(!t.ok)throw new Error(409===t.status?"This confirmation has expired or already been resolved.":"Could not save your decision. Please try again.");d.current===e&&l((e=>Object.assign(Object.assign({},e),{[r]:s})))}catch(t){d.current===e&&u((e=>Object.assign(Object.assign({},e),{[r]:t instanceof Error&&"AbortError"!==t.name?t.message:"Could not save your decision. Please try again."})))}finally{clearTimeout(o),d.current===e&&(d.current=null,a(null))}}))),[t,n]);return{setToken:s,enabled:t&&Boolean(n),busyId:o,errors:i,decisions:c,decide:b}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),n=require("../../common/api/pickaxe.js"),r=require("react");function t(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}})),n.default=e,Object.freeze(n)}const o={ar:"ar-SA",ca:"ca-ES",cs:"cs-CZ",da:"da-DK",de:"de-DE",en:"en-US",es:"es-ES",fi:"fi-FI",fr:"fr-FR",he:"he-IL",hi:"hi-IN",it:"it-IT",ja:"ja-JP",ko:"ko-KR",nb:"nb-NO",nl:"nl-NL",pl:"pl-PL",pt:"pt-PT",ro:"ro-RO",ru:"ru-RU",sv:"sv-SE",th:"th-TH",tr:"tr-TR",vi:"vi-VN",zh:"zh-CN",zu:"zu-ZA"};let i=null;const s=new Map,l=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),a=({text:r,language:a,provider:c,pickaxeId:u,preferredVoiceName:d,browserVoices:p=[],onLoading:h,onPlay:f,onEnd:v})=>{var w;null==i||i.cancel(),null===(w=window.speechSynthesis)||void 0===w||w.cancel();let y=null,g=null,S=null,b=null,m=null,k=!1,L=!1,E=!1;const A=()=>{L||(L=!0,null==y||y.close(),y=null,null==m||m.abort(),m=null,null==S||S.pause(),S=null,b&&URL.revokeObjectURL(b),b=null,i===O&&(i=null),v())},R=()=>{k||L||f()},O={cancel:()=>{var e;k||L||(k=!0,null==g||g.close(),g=null,null==y||y.pause(),null==y||y.close(),y=null,null==m||m.abort(),m=null,null==S||S.pause(),S=null,b&&URL.revokeObjectURL(b),b=null,null===(e=window.speechSynthesis)||void 0===e||e.cancel(),A())}};i=O,h();const x=(i=!0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const[{data:c},u]=yield Promise.all([n.pickaxeApi2.post("/speech"),Promise.resolve().then((function(){return t(require("microsoft-cognitiveservices-speech-sdk"))}))]);if(!c.success||!c.token)throw new Error(c.error||"Azure Speech token was not returned");if(k||L)return;const p=(e=>{if(!e)return"en-US";const n=e.toLowerCase();return"pt-br"===n?"pt-BR":o[n.split("-")[0]]||e})(a),h=u.SpeechConfig.fromAuthorizationToken(c.token,"eastus");h.speechSynthesisLanguage=p,h.speechSynthesisOutputFormat=u.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3;const f=new u.SpeakerAudioDestination;f.onAudioStart=()=>{const e=f.internalAudio;e?e.addEventListener("playing",R,{once:!0}):R()},f.onAudioEnd=A,y=f;const v=u.AudioConfig.fromSpeakerOutput(f),w=new u.SpeechSynthesizer(h,v);g=w;let S=(i?d:void 0)||s.get(p);if(!S){const n=yield w.getVoicesAsync(p);if(k||L)return;if(S=null===(e=n.voices.find((e=>e.locale===p)))||void 0===e?void 0:e.shortName,!S)throw new Error(`No Azure voice is available for ${p}`);s.set(p,S)}const b=S,m=yield new Promise(((e,n)=>{const t=`<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="${p}"><voice name="${l(b)}"><break time="500ms"/>${l(r)}</voice></speak>`;w.speakSsmlAsync(t,e,n)}));if(w.close(),g=null,k||L)return;if(m.reason!==u.ResultReason.SynthesizingAudioCompleted)throw new Error(m.errorDetails||"Azure speech synthesis failed")}catch(e){if(null==g||g.close(),g=null,null==y||y.close(),y=null,k||L)return;console.warn("Azure text-to-speech failed; using browser speech",e),(()=>{if(k||L||E)return;if(E=!0,!("speechSynthesis"in window)||!("SpeechSynthesisUtterance"in window))return void A();const e=new SpeechSynthesisUtterance(r),n=a||"en",t=p.find((e=>e.lang.startsWith(n)&&e.name.includes("Google")))||p.find((e=>e.lang.startsWith(n)));t?(e.voice=t,e.lang=t.lang):e.lang=n,e.onstart=R,e.onend=A,e.onerror=A,window.speechSynthesis.speak(e)})()}}));return"elevenlabs"===c?e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!u)throw new Error("A Pickaxe ID is required");m=new AbortController;const e=yield fetch(`${n.pickaxeApi2.defaults.baseURL}/speech/elevenlabs/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:r,pickaxeId:u}),signal:m.signal});if(!e.ok)throw new Error("ElevenLabs speech synthesis failed");if(k||L)return;if(S=new Audio,S.onplaying=R,S.onended=A,S.onerror=A,!("MediaSource"in window)||!MediaSource.isTypeSupported("audio/mpeg")||!e.body)return b=URL.createObjectURL(yield e.blob()),S.src=b,void(yield S.play());const t=new MediaSource;b=URL.createObjectURL(t),S.src=b;const o=yield new Promise(((e,n)=>{t.addEventListener("sourceopen",(()=>{try{e(t.addSourceBuffer("audio/mpeg"))}catch(e){n(e)}}),{once:!0})})),i=e.body.getReader();let s,l=!1,a=null;for(;!k&&!L;){const{done:e,value:n}=yield i.read();if(e)break;(null==n?void 0:n.byteLength)&&(yield new Promise(((e,r)=>{const t=()=>{o.removeEventListener("updateend",i),o.removeEventListener("error",s)},i=()=>{t(),e()},s=()=>{t(),r(new Error("Audio buffer failed"))};o.addEventListener("updateend",i),o.addEventListener("error",s),o.appendBuffer(n)})),l||(l=!0,a=S.play().catch((e=>{s=e}))))}if(k||"open"!==t.readyState||t.endOfStream(),!a)throw new Error("ElevenLabs returned no audio");if(yield a,s)throw s}catch(e){if(k||L)return;console.warn("ElevenLabs text-to-speech failed; using Azure speech",e),null==m||m.abort(),m=null,null==S||S.pause(),S=null,b&&URL.revokeObjectURL(b),b=null,x(!1)}})):x(),O};exports.useTextToSpeech=(e=!0,n={})=>{const[t,o]=r.useState(!1),[i,s]=r.useState(!1),[l,c]=r.useState([]),u=r.useRef(null),d=r.useRef(!0);r.useEffect((()=>(d.current=!0,()=>{var e;d.current=!1,null===(e=u.current)||void 0===e||e.cancel(),u.current=null})),[]),r.useEffect((()=>{if(!e||!("speechSynthesis"in window))return;const n=()=>{const e=window.speechSynthesis.getVoices();e.length>0&&c(e)};return n(),window.speechSynthesis.addEventListener("voiceschanged",n),()=>{window.speechSynthesis.removeEventListener("voiceschanged",n)}}),[e]);const p=r.useCallback((()=>{var e;null===(e=u.current)||void 0===e||e.cancel(),u.current=null}),[]);return{isLoading:t,isSpeaking:i,speak:r.useCallback(((e,r)=>{if(!e)return;const t=a({text:e,language:r,provider:n.provider,pickaxeId:n.pickaxeId,preferredVoiceName:n.voiceName,browserVoices:l,onLoading:()=>{d.current&&(o(!0),s(!1))},onPlay:()=>{d.current&&(o(!1),s(!0))},onEnd:()=>{u.current===t&&(u.current=null),d.current&&(o(!1),s(!1))}});u.current=t}),[l,n]),stop:p}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),n=require("../../common/api/pickaxe.js"),r=require("react");function t(e){if(e&&e.__esModule)return e;var n=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var t=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(n,r,t.get?t:{enumerable:!0,get:function(){return e[r]}})}})),n.default=e,Object.freeze(n)}const o={ar:"ar-SA",ca:"ca-ES",cs:"cs-CZ",da:"da-DK",de:"de-DE",en:"en-US",es:"es-ES",fi:"fi-FI",fr:"fr-FR",he:"he-IL",hi:"hi-IN",it:"it-IT",ja:"ja-JP",ko:"ko-KR",nb:"nb-NO",nl:"nl-NL",pl:"pl-PL",pt:"pt-PT",ro:"ro-RO",ru:"ru-RU",sv:"sv-SE",th:"th-TH",tr:"tr-TR",vi:"vi-VN",zh:"zh-CN",zu:"zu-ZA"};let i=null;const s=new Map,l=e=>e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&apos;"),a=({text:r,language:a,provider:c,pickaxeId:u,preferredVoiceName:d,browserVoices:p=[],onLoading:h,onPlay:f,onEnd:v})=>{var w;null==i||i.cancel(),null===(w=window.speechSynthesis)||void 0===w||w.cancel();let y=null,g=null,b=null,S=null,m=null,k=!1,L=!1,E=!1,A=!1;const R=()=>{L||(L=!0,null==y||y.close(),y=null,null==m||m.abort(),m=null,null==b||b.pause(),b=null,S&&URL.revokeObjectURL(S),S=null,i===x&&(i=null),v())},O=()=>{k||L||f()},x={cancel:()=>{var e;k||L||(k=!0,null==g||g.close(),g=null,null==y||y.pause(),null==y||y.close(),y=null,null==m||m.abort(),m=null,null==b||b.pause(),b=null,S&&URL.revokeObjectURL(S),S=null,null===(e=window.speechSynthesis)||void 0===e||e.cancel(),R())}};i=x,h();const j=(i=!0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const[{data:c},u]=yield Promise.all([n.pickaxeApi2.post("/speech"),Promise.resolve().then((function(){return t(require("microsoft-cognitiveservices-speech-sdk"))}))]);if(!c.success||!c.token)throw new Error(c.error||"Azure Speech token was not returned");if(k||L)return;const p=(e=>{if(!e)return"en-US";const n=e.toLowerCase();return"pt-br"===n?"pt-BR":o[n.split("-")[0]]||e})(a),h=u.SpeechConfig.fromAuthorizationToken(c.token,"eastus");h.speechSynthesisLanguage=p,h.speechSynthesisOutputFormat=u.SpeechSynthesisOutputFormat.Audio24Khz48KBitRateMonoMp3;const f=new u.SpeakerAudioDestination;f.onAudioStart=()=>{const e=f.internalAudio;e?e.addEventListener("playing",O,{once:!0}):O()},f.onAudioEnd=R,y=f;const v=u.AudioConfig.fromSpeakerOutput(f),w=new u.SpeechSynthesizer(h,v);g=w;let b=(i?d:void 0)||s.get(p);if(!b){const n=yield w.getVoicesAsync(p);if(k||L)return;if(b=null===(e=n.voices.find((e=>e.locale===p)))||void 0===e?void 0:e.shortName,!b)throw new Error(`No Azure voice is available for ${p}`);s.set(p,b)}const S=b,m=yield new Promise(((e,n)=>{const t=`<speak version="1.0" xmlns="http://www.w3.org/2001/10/synthesis" xml:lang="${p}"><voice name="${l(S)}"><break time="500ms"/>${l(r)}</voice></speak>`;w.speakSsmlAsync(t,e,n)}));if(w.close(),g=null,k||L)return;if(m.reason!==u.ResultReason.SynthesizingAudioCompleted)throw new Error(m.errorDetails||"Azure speech synthesis failed")}catch(e){if(null==g||g.close(),g=null,null==y||y.close(),y=null,k||L)return;console.warn("Azure text-to-speech failed; using browser speech",e),(()=>{if(k||L||E)return;if(E=!0,!("speechSynthesis"in window)||!("SpeechSynthesisUtterance"in window))return void R();const e=new SpeechSynthesisUtterance(r),n=a||"en",t=p.find((e=>e.lang.startsWith(n)&&e.name.includes("Google")))||p.find((e=>e.lang.startsWith(n)));t?(e.voice=t,e.lang=t.lang):e.lang=n,e.onstart=O,e.onend=R,e.onerror=R,window.speechSynthesis.speak(e)})()}})),U=e=>{k||L||A||(A=!0,console.warn("ElevenLabs text-to-speech failed; using Azure speech",e),null==m||m.abort(),m=null,b&&(b.onplaying=null,b.onended=null,b.onerror=null,b.pause()),b=null,S&&URL.revokeObjectURL(S),S=null,j(!1))};return"elevenlabs"===c?e.__awaiter(void 0,void 0,void 0,(function*(){let e=!1,t=!1;try{if(!u)throw new Error("A Pickaxe ID is required");m=new AbortController;const o=yield fetch(`${n.pickaxeApi2.defaults.baseURL}/speech/elevenlabs/stream`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({text:r,pickaxeId:u}),signal:m.signal});if(!o.ok)throw new Error("ElevenLabs speech synthesis failed");if(k||L)return;if(b=new Audio,b.onplaying=O,b.onended=()=>{!e||t?R():console.warn("ElevenLabs audio ended before its response stream completed; waiting for more audio")},b.onerror=()=>{const e=null==b?void 0:b.error;U(new Error("ElevenLabs audio playback failed"+(e?` (code ${e.code})`:"")))},!("MediaSource"in window)||!MediaSource.isTypeSupported("audio/mpeg")||!o.body)return S=URL.createObjectURL(yield o.blob()),b.src=S,void(yield b.play());e=!0;const i=new MediaSource;S=URL.createObjectURL(i),b.src=S;const s=yield new Promise(((e,n)=>{i.addEventListener("sourceopen",(()=>{try{e(i.addSourceBuffer("audio/mpeg"))}catch(e){n(e)}}),{once:!0})})),l=o.body.getReader();let a,c=!1,d=null;for(;!k&&!L&&!A;){const{done:e,value:n}=yield l.read();if(e)break;(null==n?void 0:n.byteLength)&&(yield new Promise(((e,r)=>{const t=()=>{s.removeEventListener("updateend",o),s.removeEventListener("error",i)},o=()=>{t(),e()},i=()=>{t(),r(new Error("Audio buffer failed"))};s.addEventListener("updateend",o),s.addEventListener("error",i),s.appendBuffer(n)})),c?!b.paused||k||L||b.play().catch(U):(c=!0,d=b.play().catch((e=>{a=e}))))}if(t=!0,k||"open"!==i.readyState||i.endOfStream(),k||A||!(null==b?void 0:b.ended)||R(),!d)throw new Error("ElevenLabs returned no audio");if(yield d,a)throw a}catch(e){U(e)}})):j(),x};exports.useTextToSpeech=(e=!0,n={})=>{const[t,o]=r.useState(!1),[i,s]=r.useState(!1),[l,c]=r.useState([]),u=r.useRef(null),d=r.useRef(!0);r.useEffect((()=>(d.current=!0,()=>{var e;d.current=!1,null===(e=u.current)||void 0===e||e.cancel(),u.current=null})),[]),r.useEffect((()=>{if(!e||!("speechSynthesis"in window))return;const n=()=>{const e=window.speechSynthesis.getVoices();e.length>0&&c(e)};return n(),window.speechSynthesis.addEventListener("voiceschanged",n),()=>{window.speechSynthesis.removeEventListener("voiceschanged",n)}}),[e]);const p=r.useCallback((()=>{var e;null===(e=u.current)||void 0===e||e.cancel(),u.current=null}),[]);return{isLoading:t,isSpeaking:i,speak:r.useCallback(((e,r)=>{if(!e)return;const t=a({text:e,language:r,provider:n.provider,pickaxeId:n.pickaxeId,preferredVoiceName:n.voiceName,browserVoices:l,onLoading:()=>{d.current&&(o(!0),s(!1))},onPlay:()=>{d.current&&(o(!1),s(!0))},onEnd:()=>{u.current===t&&(u.current=null),d.current&&(o(!1),s(!1))}});u.current=t}),[l,n]),stop:p}};
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./components/Pickaxe/index.js"),o=require("./components/Pickaxe/Provider.js"),t=require("./components/Pickaxe/ResponseProvider.js"),r=require("./components/Pickaxe/Addons/Scroll/Provider.js"),s=require("./components/Pickaxe/common/PickaxeMarkdown/index.js"),i=require("./components/Pickaxe/common/PickaxeMarkdown/Renderer.js"),n=require("./components/Pickaxe/common/PickaxeMessageParts/index.js"),x=require("./hooks/pickaxe/useConversation.js"),c=require("./hooks/pickaxe/useHistory.js"),a=require("./hooks/pickaxe/usePickaxe.js"),p=require("./hooks/pickaxe/usePickaxeContext.js"),u=require("./hooks/pickaxe/useResponseContext.js"),k=require("./hooks/pickaxe/useDimensionContext.js"),P=require("./hooks/pickaxe/useSubmitDocument.js"),d=require("./components/EmbedPreview/Inline.js"),m=require("./components/EmbedPreview/FAB.js"),C=require("./components/EmbedPreview/Popup.js"),A=require("./components/EmbedPreview/ChatInput.js"),j=require("./components/Pickaxe/Addons/Artifact/index.js"),q=require("./components/Pickaxe/Addons/Artifact/Renderer/index.js"),f=require("./components/Pickaxe/Addons/Artifact/Provider.js"),v=require("./components/Pickaxe/Addons/Artifact/hooks/useArtifactContext.js"),l=require("./components/Pickaxe/Addons/Artifact/hooks/useArtifact.js");exports.Pickaxe=e.Pickaxe,exports.PickaxeContext=o.PickaxeContext,exports.PickaxeProvider=o.PickaxeProvider,exports.ResponseContext=t.ResponseContext,exports.ScrollContext=r.ScrollContext,exports.ScrollProvider=r.ScrollProvider,exports.PickaxeMarkdown=s.PickaxeMarkdown,exports.PickaxeMarkdownContext=s.PickaxeMarkdownContext,exports.PickaxeMarkdownRenderer=i.PickaxeMarkdownRenderer,exports.PickaxeMessageParts=n.default,exports.useConversation=x.useConversation,exports.useHistory=c.useHistory,exports.useInstantPickaxe=a.useInstantPickaxe,exports.usePickaxe=a.usePickaxe,exports.usePickaxeContext=p.usePickaxeContext,exports.useResponseContext=u.useResponseContext,exports.useDimensionContext=k.useDimensionContext,exports.useSubmitDocument=P.useSubmitDocument,exports.Inline=d.Inline,exports.FAB=m.FAB,exports.FABButton=m.FABButton,exports.Popup=C.Popup,exports.PopupCTAButton=C.PopupCTAButton,exports.ChatInput=A.ChatInput,exports.ChatInputWrapper=A.ChatInputWrapper,exports.PickaxeArtifact=j.PickaxeArtifact,exports.PickaxeArtifactRenderer=q.default,exports.ArtifactContext=f.ArtifactContext,exports.ArtifactProvider=f.ArtifactProvider,exports.useArtifactContext=v.useArtifactContext,exports.useArtifact=l.useArtifact;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./components/Pickaxe/index.js"),o=require("./components/Pickaxe/Provider.js"),t=require("./components/Pickaxe/ResponseProvider.js"),r=require("./components/Pickaxe/Addons/Scroll/Provider.js"),s=require("./components/Pickaxe/common/PickaxeMarkdown/index.js"),i=require("./components/Pickaxe/common/PickaxeMarkdown/Renderer.js"),n=require("./components/Pickaxe/common/PickaxeMessageParts/index.js"),x=require("./hooks/pickaxe/useConversation.js"),a=require("./hooks/pickaxe/useHistory.js"),c=require("./hooks/pickaxe/usePickaxe.js"),p=require("./hooks/pickaxe/usePickaxeContext.js"),u=require("./hooks/pickaxe/useResponseContext.js"),P=require("./hooks/pickaxe/useDimensionContext.js"),k=require("./hooks/pickaxe/useSubmitDocument.js"),d=require("./components/EmbedPreview/Inline.js"),m=require("./components/EmbedPreview/FAB.js"),A=require("./components/EmbedPreview/Popup.js"),C=require("./components/EmbedPreview/ChatInput.js"),j=require("./components/Pickaxe/Addons/Artifact/index.js"),q=require("./components/Pickaxe/Addons/Artifact/Renderer/index.js"),v=require("./components/Pickaxe/Addons/Artifact/Provider.js"),f=require("./components/Pickaxe/Addons/Artifact/hooks/useArtifactContext.js"),l=require("./components/Pickaxe/Addons/Artifact/hooks/useArtifact.js"),h=require("./components/Pickaxe/common/PickaxeMessageParts/ActionApprovalPart.js");exports.Pickaxe=e.Pickaxe,exports.PickaxeContext=o.PickaxeContext,exports.PickaxeProvider=o.PickaxeProvider,exports.ResponseContext=t.ResponseContext,exports.ScrollContext=r.ScrollContext,exports.ScrollProvider=r.ScrollProvider,exports.PickaxeMarkdown=s.PickaxeMarkdown,exports.PickaxeMarkdownContext=s.PickaxeMarkdownContext,exports.PickaxeMarkdownRenderer=i.PickaxeMarkdownRenderer,exports.PickaxeMessageParts=n.default,exports.useConversation=x.useConversation,exports.useHistory=a.useHistory,exports.useInstantPickaxe=c.useInstantPickaxe,exports.usePickaxe=c.usePickaxe,exports.usePickaxeContext=p.usePickaxeContext,exports.useResponseContext=u.useResponseContext,exports.useDimensionContext=P.useDimensionContext,exports.useSubmitDocument=k.useSubmitDocument,exports.Inline=d.Inline,exports.FAB=m.FAB,exports.FABButton=m.FABButton,exports.Popup=A.Popup,exports.PopupCTAButton=A.PopupCTAButton,exports.ChatInput=C.ChatInput,exports.ChatInputWrapper=C.ChatInputWrapper,exports.PickaxeArtifact=j.PickaxeArtifact,exports.PickaxeArtifactRenderer=q.default,exports.ArtifactContext=v.ArtifactContext,exports.ArtifactProvider=v.ArtifactProvider,exports.useArtifactContext=f.useArtifactContext,exports.useArtifact=l.useArtifact,exports.ActionApprovalPart=h.ActionApprovalPart;