@pickaxeproject/react 2.7.3 → 2.8.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 (24) hide show
  1. package/README.md +9 -0
  2. package/dist/cjs/components/Icons/{link.svg.js → circle-info.svg.js} +1 -1
  3. package/dist/cjs/components/Pickaxe/Addons/Document/List.js +1 -0
  4. package/dist/cjs/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
  5. package/dist/cjs/components/Pickaxe/Addons/Document/hooks/useDocumentData.js +1 -0
  6. package/dist/cjs/components/Pickaxe/Chat/History/Document.js +1 -1
  7. package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
  8. package/dist/cjs/components/Pickaxe/Form/Questions/Document.js +1 -1
  9. package/dist/cjs/components/Pickaxe/Provider.js +1 -1
  10. package/dist/cjs/src/components/Pickaxe/Addons/Document/List.d.ts +2 -1
  11. package/dist/esm/components/Icons/{link.svg.js → circle-info.svg.js} +1 -1
  12. package/dist/esm/components/Pickaxe/Addons/Document/List.js +1 -0
  13. package/dist/esm/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
  14. package/dist/esm/components/Pickaxe/Addons/Document/hooks/useDocumentData.js +1 -0
  15. package/dist/esm/components/Pickaxe/Chat/History/Document.js +1 -1
  16. package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
  17. package/dist/esm/components/Pickaxe/Form/Questions/Document.js +1 -1
  18. package/dist/esm/components/Pickaxe/Provider.js +1 -1
  19. package/dist/esm/src/components/Pickaxe/Addons/Document/List.d.ts +2 -1
  20. package/package.json +1 -1
  21. package/dist/cjs/hooks/pickaxe/useDocumentData.js +0 -1
  22. package/dist/esm/hooks/pickaxe/useDocumentData.js +0 -1
  23. /package/dist/cjs/src/{hooks/pickaxe → components/Pickaxe/Addons/Document/hooks}/useDocumentData.d.ts +0 -0
  24. /package/dist/esm/src/{hooks/pickaxe → components/Pickaxe/Addons/Document/hooks}/useDocumentData.d.ts +0 -0
package/README.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  > Client utility library for Pickaxes
4
4
 
5
+ ## Setup
6
+
7
+ In terminal run
8
+
9
+ ```
10
+ chmod +x setup.sh
11
+ ./setup.sh
12
+ ```
13
+
5
14
  ## How to publish
6
15
 
7
16
  - `git pull` locally
@@ -1 +1 @@
1
- "use strict";function e(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}Object.defineProperty(exports,"__esModule",{value:!0});var r,t=e(require("react"));function n(){return n=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},n.apply(null,arguments)}var o=e=>t.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},e),r||(r=t.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 7h3a5 5 0 1 1 0 10h-3m-6 0H6A5 5 0 1 1 6 7h3M8 12h8"})));exports.default=o;
1
+ "use strict";function e(e){if(e&&e.__esModule)return e;var r=Object.create(null);return e&&Object.keys(e).forEach((function(t){if("default"!==t){var n=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(r,t,n.get?n:{enumerable:!0,get:function(){return e[t]}})}})),r.default=e,Object.freeze(r)}Object.defineProperty(exports,"__esModule",{value:!0});var r,t=e(require("react"));function n(){return n=Object.assign?Object.assign.bind():function(e){for(var r=1;r<arguments.length;r++){var t=arguments[r];for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e},n.apply(null,arguments)}var o=e=>t.createElement("svg",n({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 22 22"},e),r||(r=t.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 21c5.523 0 10-4.477 10-10S16.523 1 11 1 1 5.477 1 11s4.477 10 10 10M11 15v-4M11 7h.01"})));exports.default=o;
@@ -0,0 +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"),r=require("../../../../hooks/studio/useStyleFontSize.js"),a=require("./hooks/useDocument.js"),l=require("../../../../common/utils.js"),i=require("../../../Icons/spinner-lines.svg.js"),o=require("../../../Icons/file.svg.js"),c=require("../../../Icons/x.svg.js"),n=require("../../../Icons/circle-info.svg.js"),u=require("../../../../common/cn.js");exports.default=({className:d,isDisabled:f})=>{const{styles:m,colors:x,translations:h,isRtl:j}=t.usePickaxeContext(),{documents:b,isUploading:g,removeDocument:p}=a.useDocument(),v=r.useStyleFontSize();return e.jsx("div",Object.assign({className:u.default("flex flex-row gap-3 flex-wrap",d)},{children:b.map(((t,r)=>{var a,d,b,k,y;return e.jsx(s.Fragment,{children:"document"===t.type?e.jsxs("div",Object.assign({className:u.default("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",j&&"flex-row-reverse"),style:{borderRadius:m.cornerRadius,borderColor:x.secondaryText+"50"}},{children:[e.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:m.cornerRadius,backgroundColor:x.accent,color:x.accentText},"failed"===t.status&&{backgroundColor:x.error,color:"white"})},{children:"uploading"===t.status?e.jsx(i.default,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===t.status?e.jsx(n.default,{className:"w-5 h-5 shrink-0"}):e.jsx(o.default,{className:"w-5 h-5 shrink-0"})})),e.jsxs("div",Object.assign({className:u.default("flex flex-col justify-center truncate",j?"text-right items-end":"text-left items-start")},{children:[e.jsx("p",Object.assign({className:u.default(v.b3,"font-medium truncate")},{children:t.name})),e.jsx("p",Object.assign({className:u.default(v.b4,"opacity-80 truncate")},{children:"failed"===t.status?(null===(a=t.error)||void 0===a?void 0:a.includes("You have reached the file limit"))?null!==(d=null==h?void 0:h["file-limit-reached"])&&void 0!==d?d:"You have reached the file limit.":t.error:l.formatBytes(t.size)}))]})),!g&&e.jsx("button",Object.assign({type:"button",className:u.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",j?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:x.accent,color:x.accentText},disabled:g||f,onClick:()=>p(t.id)},{children:e.jsx(c.default,{className:"w-4 h-4 shrink-0"})}))]})):"image"===t.type?e.jsxs("div",Object.assign({className:"relative h-[56px] flex flex-col items-center justify-center w-[56px]",style:Object.assign({borderRadius:m.cornerRadius,backgroundColor:x.accent,color:x.accentText},"failed"===t.status&&{backgroundColor:x.error,color:"white"})},{children:["finished"===t.status?e.jsx("img",{className:"object-cover w-full h-full",style:{borderRadius:m.cornerRadius},src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(b=t.documentId)||void 0===b?void 0:b.split("-")[2]}/${null===(k=t.documentId)||void 0===k?void 0:k.split("-")[1]}.${null===(y=t.documentId)||void 0===y?void 0:y.split("-")[2]}`,alt:""}):"failed"===t.status?e.jsx(n.default,{className:"w-5 h-5 shrink-0"}):e.jsx(i.default,{className:"w-5 h-5 animate-spin shrink-0"}),!g&&e.jsx("button",Object.assign({type:"button",className:u.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",j?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:x.accent,color:x.accentText},disabled:g||f,onClick:()=>p(t.id)},{children:e.jsx(c.default,{className:"w-4 h-4 shrink-0"})}))]})):null},r)}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),s=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),o=require("./useDocumentContext.js"),n=require("../../../../../common/documents.js"),r=require("../../../../../common/error.js"),a=require("uuid");const u=["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","o1"];exports.useDocument=({onQuestionChange:d}={})=>{const{formId:l,chatId:c,sessionId:m,pickaxe:p}=s.usePickaxeContext(),f=o.useDocumentContext(),w=i.useSubmitDocument(),g=t.useMemo((()=>{var e;return u.includes(null!==(e=null==p?void 0:p.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[p]),I=e=>{const t=[...n.allowedFileMimeTypes,...g?n.allowedImageMimeTypes:[]];if(e.some((e=>!t.includes(e.type)))){const e=new Error(g?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again."),t=r.default(e);return f.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},f),{isImageUploadAllowed:g,onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(f.setDocumentError(""),!t.length)return null;if(I(t))return null;f.setIsUploading(!0),f.setIsShowList(!0);const s=t.map((e=>({file:e,id:a.v4()})));s.forEach((({file:e,id:t})=>{f.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,error:o}=yield w.document(Object.assign({formId:l,responseId:c,file:t,sessionId:m},(null==p?void 0:p.workspaceid)&&{workspaceId:p.workspaceid}));if(!e)throw new Error(null!=o?o:"Document processing failed");null==d||d({input:t.name,documentId:i});const n=i.startsWith("IMAGE-");return f.editDocument({id:s,type:n?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i}),{name:t.name,documentId:i}}catch(e){const i=r.default(e);return f.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}})))),o=yield Promise.allSettled(i),n=new Set;for(const e of o)"fulfilled"===e.status&&"error"in e.value&&n.add(e.value.error);n.size>0&&f.setDocumentError([...n].join(", ")),f.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){f.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");f.setIsUploading(!0),f.setIsShowList(!0),f.setWebsiteLink(""),f.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield w.website(Object.assign({formId:l,responseId:c,website:e},(null==p?void 0:p.workspaceid)&&{workspaceId:p.workspaceid})),{success:s,documentId:i}=t;if(!s)throw new Error("Website processing failed, please try again.");f.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=r.default(t);if(console.log("[onWebsiteUpload] Error",s),s.includes("Please paste a valid website URL"))return f.setDocumentError(s),null;f.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{f.setIsUploading(!1)}}))})};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("react"),s=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),o=require("./useDocumentContext.js"),n=require("../../../../../common/documents.js"),r=require("../../../../../common/error.js"),a=require("uuid");const d=["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","o1"];exports.useDocument=({onQuestionChange:u}={})=>{const{formId:l,chatId:c,sessionId:m,pickaxe:p}=s.usePickaxeContext(),f=o.useDocumentContext(),w=i.useSubmitDocument(),g=t.useMemo((()=>{var e;return d.includes(null!==(e=null==p?void 0:p.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[p]),I=e=>{const t=[...n.allowedFileMimeTypes,...g?n.allowedImageMimeTypes:[]];if(e.some((e=>!t.includes(e.type)))){const e=new Error(g?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again."),t=r.default(e);return f.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},f),{isImageUploadAllowed:g,onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(f.setDocumentError(""),!t.length)return null;if(I(t))return null;f.setIsUploading(!0),f.setIsShowList(!0);const s=t.map((e=>({file:e,id:a.v4()})));s.forEach((({file:e,id:t})=>{f.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,error:o}=yield w.document(Object.assign({formId:l,responseId:c,file:t,sessionId:m},(null==p?void 0:p.workspaceid)&&{workspaceId:p.workspaceid}));if(!e)throw new Error(null!=o?o:"Document processing failed");null==u||u({input:t.name,documentId:i});const n=i.startsWith("IMAGE-");return f.editDocument({id:s,type:n?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i}),{name:t.name,documentId:i}}catch(e){const i=r.default(e);return f.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}}))));yield Promise.allSettled(i),f.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){f.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");f.setIsUploading(!0),f.setIsShowList(!0),f.setWebsiteLink(""),f.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield w.website(Object.assign({formId:l,responseId:c,website:e},(null==p?void 0:p.workspaceid)&&{workspaceId:p.workspaceid})),{success:s,documentId:i}=t;if(!s)throw new Error("Website processing failed, please try again.");f.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=r.default(t);if(console.log("[onWebsiteUpload] Error",s),s.includes("Please paste a valid website URL"))return f.setDocumentError(s),null;f.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{f.setIsUploading(!1)}}))})};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("@tanstack/react-query");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=r(require("axios"));exports.useDocumentData=({documentId:r})=>{const o=t.useQuery({queryKey:["documentData",r],queryFn:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return(({documentId:t})=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield u.default.get(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_data?documentid=${t}`),r=e.data;if(200!==e.status)throw new Error("[_getDocumentData] Failed to fetch document data "+r);return r})))({documentId:r})})),staleTime:18e4});return o};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../common/cn.js"),t=require("../../../../common/utils.js"),r=require("../../../../hooks/pickaxe/useDocumentData.js"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),c=require("../../../../hooks/studio/useStyleFontSize.js"),o=require("../../../Icons/file.svg.js");exports.default=({documentId:i})=>{const n=r.useDocumentData({documentId:i}),{colors:l,styles:u,isRtl:d}=a.usePickaxeContext(),x=c.useStyleFontSize();return"success"!==n.status?e.jsx("div",{}):e.jsxs("a",Object.assign({href:n.data.storageUrl?n.data.storageUrl:"#",target:"_blank",className:s.default("gap-x-[10px] w-full max-w-[500px] flex items-center px-2 h-[56px] border",d&&"flex-row-reverse"),style:{borderRadius:u.cornerRadius,borderColor:l.secondary+"50"},rel:"noreferrer"},{children:[e.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:l.accent,borderRadius:u.cornerRadius}},{children:e.jsx(o.default,{className:"w-5 h-5",style:{color:l.accentText}})})),e.jsxs("div",Object.assign({className:s.default("flex flex-col justify-center truncate",d?"text-right":"text-left")},{children:[e.jsx("p",Object.assign({className:(s.default(x.b3),"font-medium truncate")},{children:n.data.name})),e.jsxs("p",Object.assign({className:s.default(x.b4,"opacity-80 truncate")},{children:[n.data.extension&&n.data.extension.toUpperCase()+", ",t.formatBytes(n.data.size)]}))]}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../Addons/Document/hooks/useDocumentData.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),a=require("../../../../common/utils.js"),o=require("../../../Icons/file.svg.js"),c=require("../../../../common/cn.js");exports.default=({documentId:n})=>{const{colors:i,styles:l,isRtl:u}=s.usePickaxeContext(),d=t.useDocumentData({documentId:n}),x=r.useStyleFontSize();return"success"!==d.status?e.jsx("div",{}):e.jsxs("a",Object.assign({href:d.data.storageUrl?d.data.storageUrl:"#",target:"_blank",className:c.default("gap-x-[10px] w-full max-w-[500px] flex items-center px-2 h-[56px] border",u&&"flex-row-reverse"),style:{borderRadius:l.cornerRadius,borderColor:i.secondary+"50"},rel:"noreferrer"},{children:[e.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:i.accent,borderRadius:l.cornerRadius}},{children:e.jsx(o.default,{className:"w-5 h-5",style:{color:i.accentText}})})),e.jsxs("div",Object.assign({className:c.default("flex flex-col justify-center truncate",u?"text-right":"text-left")},{children:[e.jsx("p",Object.assign({className:(c.default(x.b3),"font-medium truncate")},{children:d.data.name})),e.jsxs("p",Object.assign({className:c.default(x.b4,"opacity-80 truncate")},{children:[d.data.extension&&d.data.extension.toUpperCase()+", ",a.formatBytes(d.data.size)]}))]}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),i=require("../../../hooks/pickaxe/useConversation.js"),n=require("../../../hooks/pickaxe/useSubmit.js"),d=require("../Addons/Document/hooks/useDocument.js"),c=require("../Addons/Scroll/hooks/useScroll.js"),u=require("../../../hooks/core/useHover.js"),m=require("../../../common/utils.js"),f=require("../../../common/documents.js"),x=require("eventsource-parser"),p=require("../../Icons/attach-vertical.svg.js"),h=require("../../Icons/spinner-lines.svg.js"),g=require("../../Icons/file.svg.js"),j=require("../../Icons/x.svg.js"),b=require("../../Icons/arrow-right.svg.js"),v=require("../Addons/IceBreaker/index.js"),y=require("../../Core/Textarea.js"),w=require("../../Core/ErrorAlert.js"),k=require("../../../common/error.js"),N=require("../../../common/cn.js");exports.default=({isFocused:I,onFocus:O,onBlur:C})=>{var q;const{formId:S,chatId:R,userId:T,studioUserId:_,embedUserId:A,deploymentId:D,deploymentType:B,pickaxe:E,styles:F,colors:U,responsiveBy:H,isNewChat:z,isRtl:M,setIsNewChat:P,setIsShowIceBreaker:L,onGenerateComplete:$}=r.usePickaxeContext(),{messages:G,status:J,limits:K,isGenerating:W,setMessages:Q,setStatus:V,setLimitData:X,setError:Y}=o.useResponseContext(),{documents:Z,isUploading:ee,isImageUploadAllowed:se,documentError:te,onFileUpload:re,setDocuments:oe,setDocumentError:le,removeDocument:ae}=d.useDocument(),{scrollStartSession:ie,scrollEndSession:ne,scrollToBottom:de}=c.useScroll({auto:!0}),ce=i.useConversation(),ue=n.useSubmit(),[me,fe]=t.useState(""),xe=t.useRef(null),pe=u.useHover(),{isHover:he}=pe,ge=e.__rest(pe,["isHover"]),je=u.useHover(),{isHover:be}=je,ve=e.__rest(je,["isHover"]),ye=a.useStyleFontSize(),we=l.useStyleInput(),ke=t.useMemo((()=>{var e,s,t;return!!z&&(!!E&&(!ce.isLoading&&(!((null!==(s=null===(e=ce.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=E.icebreakers)||void 0===t?void 0:t.length))))}),[E,z,ce.data,ce.isLoading]),Ne=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if("idle"!==J||ee)return;const e=null!=s?s:me;if(!e)return;Y(""),le(""),X(null),fe(""),P(!1),V("fetching"),ie(),de();const t=Z.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),r="enduserupload"===(null==E?void 0:E.documentuploadtype)&&t.length>0,o=[...Array.from(G),Object.assign({id:G.length+1,role:"user",content:e},r&&{documentIds:t})];Q(o),de(),r&&oe([]);const l=(yield ue.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:S,responseId:R,value:e},r&&{documentIds:t}),T&&{userId:T}),_&&{studioUserId:_}),A&&{embedUserId:A}),D&&{deploymentId:D}))).body;if(!l)throw new Error("Streaming error");const a=o.length,i=new TextDecoder,n=l.getReader();let d="",c=!0,u=!1;const m=x.createParser({onEvent:e=>{if("delta"===e.event){const s=JSON.parse(e.data).token.replace(/\u200B/g,"");d+=s,Q([...o.slice(0,a),{id:G.length+1,role:"assistant",content:d}])}else if("error"===e.event){const s=JSON.parse(e.data);Y(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(c=!1)}});for(;c;){const{value:e,done:s}=yield n.read();if(s){c=!1;break}const t=i.decode(e);t&&(u||(V("streaming"),u=!0),m.feed(t))}null==$||$(R)}catch(e){let s=k.default(e)||"";s&&!s.includes("Unexpected token 'A',")||(s="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(K).find((([e])=>s.includes(e)));t?X(t[1]):Y(s)}finally{de(),V("idle"),ne()}}));return t.useEffect((()=>{L(ke)}),[ke]),s.jsx("div",Object.assign({className:N.default("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===B&&z)&&"px-4 pb-4"),dir:M?"rtl":"ltr"},{children:s.jsxs("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===B&&z)&&s.jsx("div",Object.assign({className:N.default("absolute bottom-full",M?"left-0":"right-0")},{children:s.jsx("div",Object.assign({className:N.default("flex flex-col gap-2 pb-4 px-2",M?"justify-start":"justify-end","viewport"===H?M?"min-[767px]:items-start":"min-[767px]:items-end":M?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:ke&&!I&&s.jsx(v.default,{data:(null==E?void 0:E.icebreakers)||[],onSend:Ne})}))})),s.jsxs("div",Object.assign({className:N.default("flex flex-col gap-y-2 px-4 py-3","block"===F.formFieldStyle&&"shadow"),style:we},{children:["idle"===J&&Z.length>0&&s.jsx("div",Object.assign({className:"flex flex-row gap-2 flex-wrap"},{children:Z.filter((e=>"failed"!==e.status)).map((e=>{var r,o,l;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:N.default("relative gap-x-[10px] flex items-center px-2 h-[56px] border",M&&"flex-row-reverse"),style:{borderRadius:we.borderRadius,borderColor:U.secondaryText+"50"}},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:U.accent,borderRadius:we.borderRadius}},{children:ee?s.jsx(h.default,{className:"w-5 h-5 animate-spin",style:{color:U.accentText}}):s.jsx(g.default,{className:"w-5 h-5",style:{color:U.accentText}})})),s.jsxs("div",Object.assign({className:N.default("flex flex-col justify-center truncate",M?"text-right items-end":"text-left items-start")},{children:[s.jsx("p",Object.assign({className:(N.default(ye.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:N.default(ye.b4,"opacity-80 truncate")},{children:m.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",className:N.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",M?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:U.accent,borderColor:we.backgroundColor},disabled:ee||"idle"!==J,onClick:()=>ae(e.id)},{children:s.jsx(j.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):"image"===e.type?s.jsxs("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:we.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:we.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[2]}/${null===(o=e.documentId)||void 0===o?void 0:o.split("-")[1]}.${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[2]}`,alt:""}):s.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:we.borderRadius,backgroundColor:U.secondary}}),s.jsx("button",Object.assign({type:"button",className:N.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",M?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:U.accent,borderColor:we.backgroundColor},disabled:ee||"idle"!==J,onClick:()=>ae(e.id)},{children:s.jsx(j.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):null},e.id)}))})),s.jsxs("div",Object.assign({className:N.default("flex items-end gap-x-2",M&&"flex-row-reverse")},{children:[s.jsx(y.default,Object.assign({className:N.default(ye.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!me.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",M?"text-right":"text-left"),value:me,placeholder:null!==(q=null==E?void 0:E.placeholdertext)&&void 0!==q?q:M?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>fe(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ee||"idle"!==J||Ne()))}},O&&{onFocus:O},C&&{onBlur:C},{dir:M?"rtl":"ltr"})),s.jsxs("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==E?void 0:E.documentuploadtype)&&s.jsxs("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:be?U.accent+"10":void 0},disabled:ee||"idle"!==J,onClick:()=>{var e;return null===(e=xe.current)||void 0===e?void 0:e.click()}},ve,{children:[s.jsx("input",{id:"file-upload",ref:xe,type:"file",accept:[...f.allowedFileMimeTypes,...se?f.allowedImageMimeTypes:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){P(!1),yield re(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx(p.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:be?U.accent:U.accent+"80"}})]})),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:(he||me.length||Z.length&&Z.every((e=>"finished"===e.status)))&&!W?U.accent:U.accent+"10"},disabled:ee||"idle"!==J,onClick:()=>Ne()},ge,{children:s.jsx(b.default,{className:N.default("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",M&&"transform scale-x-[-1]"),style:{color:(he||me.length||Z.length&&Z.every((e=>"finished"===e.status)))&&!W?U.accentText:U.accent+"80"}})}))]}))]}))]})),te&&s.jsx(w.default,{error:te,className:"mt-3"})]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../hooks/studio/useStyleInput.js"),n=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),a=require("../../../hooks/pickaxe/useSubmit.js"),d=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),c=require("../../../hooks/core/useHover.js"),m=require("../../../common/documents.js"),f=require("eventsource-parser"),p=require("../../Icons/attach-vertical.svg.js"),x=require("../../Icons/arrow-right.svg.js"),h=require("../Addons/IceBreaker/index.js"),g=require("../Addons/Document/List.js"),v=require("../../Core/Textarea.js"),j=require("../../Core/ErrorAlert.js"),b=require("../../../common/error.js"),y=require("../../../common/cn.js");exports.default=({isFocused:k,onFocus:w,onBlur:I})=>{var S;const{formId:q,chatId:O,userId:N,studioUserId:C,embedUserId:A,deploymentId:_,deploymentType:D,pickaxe:E,styles:B,colors:F,responsiveBy:U,isNewChat:H,isRtl:R,setIsNewChat:T,setIsShowIceBreaker:M,onGenerateComplete:P}=r.usePickaxeContext(),{messages:L,status:z,limits:G,isGenerating:J,setMessages:K,setStatus:W,setLimitData:Q,setError:V}=o.useResponseContext(),{documents:X,isUploading:Y,isImageUploadAllowed:Z,documentError:$,onFileUpload:ee,setDocuments:se,setDocumentError:te}=d.useDocument(),{scrollStartSession:re,scrollEndSession:oe,scrollToBottom:ie}=u.useScroll({auto:!0}),ne=l.useConversation(),le=a.useSubmit(),[ae,de]=t.useState(""),ue=t.useRef(null),ce=c.useHover(),{isHover:me}=ce,fe=e.__rest(ce,["isHover"]),pe=c.useHover(),{isHover:xe}=pe,he=e.__rest(pe,["isHover"]),ge=n.useStyleFontSize(),ve=i.useStyleInput(),je=t.useMemo((()=>{var e,s,t;return!!H&&(!!E&&(!ne.isLoading&&(!((null!==(s=null===(e=ne.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=E.icebreakers)||void 0===t?void 0:t.length))))}),[E,H,ne.data,ne.isLoading]),be=t.useMemo((()=>{if(J||Y)return!1;return!!ae.trim()&&X.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[J,Y,ae,X]),ye=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if("idle"!==z||Y)return;const e=null!=s?s:ae;if(!e)return;V(""),te(""),Q(null),de(""),T(!1),W("fetching"),re(),ie();const t=X.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),r="enduserupload"===(null==E?void 0:E.documentuploadtype)&&t.length>0,o=[...Array.from(L),Object.assign({id:L.length+1,role:"user",content:e},r&&{documentIds:t})];K(o),ie(),r&&se([]);const i=(yield le.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:q,responseId:O,value:e},r&&{documentIds:t}),N&&{userId:N}),C&&{studioUserId:C}),A&&{embedUserId:A}),_&&{deploymentId:_}))).body;if(!i)throw new Error("Streaming error");const n=o.length,l=new TextDecoder,a=i.getReader();let d="",u=!0,c=!1;const m=f.createParser({onEvent:e=>{if("delta"===e.event){const s=JSON.parse(e.data).token.replace(/\u200B/g,"");d+=s,K([...o.slice(0,n),{id:L.length+1,role:"assistant",content:d}])}else if("error"===e.event){const s=JSON.parse(e.data);V(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(u=!1)}});for(;u;){const{value:e,done:s}=yield a.read();if(s){u=!1;break}const t=l.decode(e);t&&(c||(W("streaming"),c=!0),m.feed(t))}null==P||P(O)}catch(e){let s=b.default(e)||"";s&&!s.includes("Unexpected token 'A',")||(s="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(G).find((([e])=>s.includes(e)));t?Q(t[1]):V(s)}finally{ie(),W("idle"),oe()}}));return t.useEffect((()=>{M(je)}),[je]),s.jsx("div",Object.assign({className:y.default("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===D&&H)&&"px-4 pb-4"),dir:R?"rtl":"ltr"},{children:s.jsxs("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===D&&H)&&s.jsx("div",Object.assign({className:y.default("absolute bottom-full",R?"left-0":"right-0")},{children:s.jsx("div",Object.assign({className:y.default("flex flex-col gap-2 pb-4 px-2",R?"justify-start":"justify-end","viewport"===U?R?"min-[767px]:items-start":"min-[767px]:items-end":R?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:je&&!k&&s.jsx(h.default,{data:(null==E?void 0:E.icebreakers)||[],onSend:ye})}))})),s.jsxs("div",Object.assign({className:y.default("flex flex-col gap-y-3 px-4 py-3","block"===B.formFieldStyle&&"shadow"),style:ve},{children:["idle"===z&&X.length>0&&s.jsx(g.default,{isDisabled:"idle"!==z}),s.jsxs("div",Object.assign({className:y.default("flex items-end gap-x-2",R&&"flex-row-reverse")},{children:[s.jsx(v.default,Object.assign({className:y.default(ge.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!ae.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",R?"text-right":"text-left"),value:ae,placeholder:null!==(S=null==E?void 0:E.placeholdertext)&&void 0!==S?S:R?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>de(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Y||"idle"!==z||ye()))}},w&&{onFocus:w},I&&{onBlur:I},{dir:R?"rtl":"ltr"})),s.jsxs("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==E?void 0:E.documentuploadtype)&&s.jsxs("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:xe?F.accent+"10":void 0,color:xe?F.accent:F.accent+"80"},disabled:Y||"idle"!==z,onClick:()=>{var e;return null===(e=ue.current)||void 0===e?void 0:e.click()}},he,{children:[s.jsx("input",{id:"file-upload",ref:ue,type:"file",accept:[...m.allowedFileMimeTypes,...Z?m.allowedImageMimeTypes:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){T(!1),yield ee(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx(p.default,{className:"h-6 w-6 shrink-0"})]})),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:me||be?F.accent:F.accent+"10",color:me||be?F.accentText:F.accent+"80"},disabled:"idle"!==z||Y,onClick:()=>ye()},fe,{children:s.jsx(x.default,{className:y.default("h-6 w-6 shrink-0",R&&"transform scale-x-[-1]")})}))]}))]}))]})),$&&s.jsx(j.default,{error:$,className:"mt-3"})]}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),l=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleInput.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),i=require("../../Addons/Document/hooks/useDocument.js"),n=require("../../../../hooks/core/useHover.js"),o=require("../../../../common/documents.js"),c=require("../../../../common/utils.js"),d=require("../../../Icons/attach-vertical.svg.js"),u=require("../../../Icons/check.svg.js"),m=require("../../../Icons/spinner-lines.svg.js"),b=require("../../../Icons/file.svg.js"),x=require("../../../Icons/x.svg.js"),j=require("../../../Icons/link.svg.js"),f=require("../../../Core/ErrorAlert.js"),h=require("../../../../common/cn.js");exports.default=({field:p,update:g})=>{var y;const v=r.useStyleFontSize(),{colors:k,styles:w,translations:N,responsiveBy:O}=l.usePickaxeContext(),C=n.useHover(),{isHover:q}=C,I=e.__rest(C,["isHover"]),{documents:R,documentError:T,websiteLink:_,isUploading:D,isImageUploadAllowed:F,removeDocument:S,setDocumentError:A,setWebsiteLink:U,onFileUpload:z,onWebsiteUpload:E}=i.useDocument({onQuestionChange:e=>{g(Object.assign(Object.assign({},p),e))}}),[H,P]=t.useState(!1),B=t.useRef(null),L=a.useStyleInput();return s.jsxs("div",Object.assign({className:"flex flex-col gap-y-4"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[s.jsx("p",Object.assign({className:h.default(v.b3,"font-semibold opacity-70")},{children:p.main})),p.isRequired&&s.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:k.error}},{children:"*"}))]})),s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsx("input",{ref:B,type:"file",accept:[...o.allowedFileMimeTypes,...F?o.allowedImageMimeTypes:[]].join(", "),id:p.id,hidden:!0,multiple:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield z(Array.from(s.target.files||[])),s.target.value=""})),disabled:D}),s.jsxs("div",Object.assign({className:h.default("flex items-center justify-between rounded-sm border border-transparent bg-white py-3 pl-4 pr-3 duration-300 ease-in-out transition-all",H&&"block"===w.formFieldStyle&&"shadow","block"===w.formFieldStyle&&"shadow hover:shadow-none"),style:L},{children:[s.jsx("input",{type:"text",value:_,className:h.default(v.i1,"w-full outline-none ring-0 bg-transparent placeholder:text-inherit placeholder:opacity-50"),placeholder:null!==(y=null==N?void 0:N["form-doc-placeholder"])&&void 0!==y?y:"Paste a website/video link or drag a file",onChange:e=>U(e.target.value),onDrop:s=>e.__awaiter(void 0,void 0,void 0,(function*(){s.preventDefault(),yield z(Array.from(s.dataTransfer.files||[]))})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),E(_))},onFocus:()=>P(!0),onBlur:()=>P(!1)}),s.jsx("div",Object.assign({className:"flex items-center gap-3 pl-4"},{children:_.length>0?s.jsxs(s.Fragment,{children:[s.jsx("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:D,onClick:()=>E(_)},{children:s.jsx(u.default,{className:"h-5 w-5 shrink-0",style:{color:k.accent}})})),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:D,onClick:()=>{U(""),A("")}},{children:s.jsx(x.default,{className:"h-6 w-6 shrink-0",style:{color:k.accent}})}))]}):s.jsx("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",disabled:D,onClick:()=>{var e;null===(e=B.current)||void 0===e||e.click()},style:{backgroundColor:q?k.accent+"10":void 0}},I,{children:s.jsx(d.default,{className:"h-6 w-6 shrink-0",style:{color:q?k.accent:k.accent+"80"}})}))}))]}))]}))]})),R.length>0&&s.jsx("div",Object.assign({className:h.default("flex gap-4","viewport"===O?"min-[765px]:flex-col":"@[767px]/pickaxe-root:flex-col")},{children:s.jsx("div",Object.assign({className:"flex flex-row gap-x-2"},{children:R.filter((e=>"failed"!==e.status)).map((e=>{var l,a,r;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:L},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:k.accent,borderRadius:L.borderRadius}},{children:D?s.jsx(m.default,{className:"w-5 h-5 shrink-0 animate-spin",style:{color:k.accentText}}):s.jsx(b.default,{className:"w-5 h-5 shrink-0",style:{color:k.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(h.default(v.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:h.default(v.b4,"opacity-80 truncate")},{children:c.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:k.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4 shrink-0",style:{color:k.accentText}})}))]})):"image"===e.type?s.jsxs("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:L.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:L.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[2]}/${null===(a=e.documentId)||void 0===a?void 0:a.split("-")[1]}.${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[2]}`,alt:""}):s.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:L.borderRadius,backgroundColor:k.secondary}}),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:k.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4 shrink-0",style:{color:k.accentText}})}))]})):"website"===e.type?s.jsxs("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:L},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:k.accent,borderRadius:L.borderRadius}},{children:D?s.jsx(m.default,{className:"w-5 h-5 animate-spin shrink-0",style:{color:k.accentText}}):s.jsx(j.default,{className:"w-5 h-5 shrink-0",style:{color:k.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(h.default(v.b3),"font-medium truncate")},{children:new URL(e.name).hostname})),s.jsx("p",Object.assign({className:h.default(v.b4,"opacity-80 truncate")},{children:(null==N?void 0:N.website)||"Website"}))]})),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:k.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4 shrink-0",style:{color:k.accentText}})}))]})):null},e.id)}))}))})),T&&s.jsx(f.default,{error:T,className:"mt-3"})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),i=require("../../../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../../../hooks/studio/useStyleInput.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),a=require("../../Addons/Document/hooks/useDocument.js"),r=require("../../../../hooks/core/useHover.js"),n=require("../../../../common/documents.js"),c=require("../../../Icons/attach-vertical.svg.js"),d=require("../../../Icons/check.svg.js"),u=require("../../../Icons/x.svg.js"),j=require("../../../Core/ErrorAlert.js"),m=require("../../Addons/Document/List.js"),f=require("../../../../common/cn.js");exports.default=({field:h,update:p})=>{var b;const x=o.useStyleFontSize(),{colors:g,styles:v,translations:y}=i.usePickaxeContext(),k=r.useHover(),{isHover:w}=k,N=e.__rest(k,["isHover"]),{documents:q,documentError:O,websiteLink:C,isUploading:_,isImageUploadAllowed:D,setDocumentError:S,setWebsiteLink:F,onFileUpload:I,onWebsiteUpload:A}=a.useDocument({onQuestionChange:e=>{p(Object.assign(Object.assign({},h),e))}}),[E,H]=t.useState(!1),P=t.useRef(null),U=l.useStyleInput();return s.jsxs("div",Object.assign({className:"flex flex-col gap-y-4"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[s.jsx("p",Object.assign({className:f.default(x.b3,"font-semibold opacity-70")},{children:h.main})),h.isRequired&&s.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:g.error}},{children:"*"}))]})),s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsx("input",{ref:P,type:"file",accept:[...n.allowedFileMimeTypes,...D?n.allowedImageMimeTypes:[]].join(", "),id:h.id,hidden:!0,multiple:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield I(Array.from(s.target.files||[])),s.target.value=""})),disabled:_}),s.jsxs("div",Object.assign({className:f.default("flex items-center justify-between rounded-sm border border-transparent bg-white py-3 pl-4 pr-3 duration-300 ease-in-out transition-all",E&&"block"===v.formFieldStyle&&"shadow","block"===v.formFieldStyle&&"shadow hover:shadow-none"),style:U},{children:[s.jsx("input",{type:"text",value:C,className:f.default(x.i1,"w-full outline-none ring-0 bg-transparent placeholder:text-inherit placeholder:opacity-50"),placeholder:null!==(b=null==y?void 0:y["form-doc-placeholder"])&&void 0!==b?b:"Paste a website/video link or drag a file",onChange:e=>F(e.target.value),onDrop:s=>e.__awaiter(void 0,void 0,void 0,(function*(){s.preventDefault(),yield I(Array.from(s.dataTransfer.files||[]))})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),A(C))},onFocus:()=>H(!0),onBlur:()=>H(!1)}),s.jsx("div",Object.assign({className:"flex items-center gap-3 pl-4"},{children:C.length>0?s.jsxs(s.Fragment,{children:[s.jsx("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:_,onClick:()=>A(C)},{children:s.jsx(d.default,{className:"h-5 w-5 shrink-0",style:{color:g.accent}})})),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:_,onClick:()=>{F(""),S("")}},{children:s.jsx(u.default,{className:"h-6 w-6 shrink-0",style:{color:g.accent}})}))]}):s.jsx("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",disabled:_,onClick:()=>{var e;null===(e=P.current)||void 0===e||e.click()},style:{backgroundColor:w?g.accent+"10":void 0}},N,{children:s.jsx(c.default,{className:"h-6 w-6 shrink-0",style:{color:w?g.accent:g.accent+"80"}})}))}))]}))]}))]})),q.length>0&&s.jsx(m.default,{}),O&&s.jsx(j.default,{error:O,className:"mt-3"})]}))};
@@ -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"),i=require("./Addons/Document/Provider.js"),o=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var i=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,i.get?i:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}const d=s.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:a,userId:l="",studioUserId:c="",deploymentId:u="",embedUserId:f="",deploymentType:p,deploymentDimensions:m,deploymentMisc:b,styles:y,colors:h,limits:v={},misc:x={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:F,responsiveBy:g="viewport",forceMobile:j=!1,disableHtml:I=!1,disableJs:P=!1,disableCss:w=!1,loadFont:S=!0,isRtl:O=!1,isEmbed:k=!1,isDropShadow:C=!1,onGenerateComplete:D})=>{const[_,q]=s.useState(""),[E,H]=s.useState(""),[M,R]=s.useState(""),[T,U]=s.useState(null),[B,L]=s.useState(!1),[N,z]=s.useState(!0),[A,G]=s.useState(!0);return s.useEffect((()=>{L(!1)}),[null==y?void 0:y.font]),s.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&S&&!B&&(null==y?void 0:y.font)&&"Real Head Pro"!==y.font)try{(yield Promise.resolve().then((function(){return n(require("webfontloader"))}))).default.load({google:{families:[y.font]},active:()=>{L(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),L(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),L(!0)}}))}),[S,B,null==y?void 0:y.font]),t.jsx(d.Provider,Object.assign({value:Object.assign({formId:_,chatId:E,sessionId:M,userId:l,studioUserId:c,embedUserId:f,deploymentId:u,deploymentType:p,deploymentDimensions:m,deploymentMisc:b,pickaxe:T,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},y),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},h),misc:x,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website"},F),responsiveBy:g,forceMobile:j,loadFont:S,disableHtml:I,disableJs:P,disableCss:w,isFontLoaded:B,isNewChat:N,isShowIceBreaker:A,isRtl:O,isEmbed:k,isDropShadow:C,setIsFontLoaded:L,setFormId:q,setChatId:H,setSessionId:R,setPickaxe:U,setIsNewChat:z,setIsShowIceBreaker:G},D&&{onGenerateComplete:D})},{children:t.jsx(o.default,Object.assign({limits:v},{children:t.jsx(r.default,{children:t.jsx(i.default,{children:a})})}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),s=require("./Addons/Document/Provider.js"),o=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");function n(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var s=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,s.get?s:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:a,userId:l="",studioUserId:c="",deploymentId:u="",embedUserId:f="",deploymentType:p,deploymentDimensions:m,deploymentMisc:b,styles:y,colors:h,limits:v={},misc:x={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:F,responsiveBy:g="viewport",forceMobile:j=!1,disableHtml:I=!1,disableJs:P=!1,disableCss:w=!1,loadFont:S=!0,isRtl:O=!1,isEmbed:k=!1,isDropShadow:C=!1,onGenerateComplete:D})=>{const[_,q]=i.useState(""),[E,H]=i.useState(""),[M,R]=i.useState(""),[T,U]=i.useState(null),[B,L]=i.useState(!1),[N,z]=i.useState(!0),[A,G]=i.useState(!0);return i.useEffect((()=>{L(!1)}),[null==y?void 0:y.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&S&&!B&&(null==y?void 0:y.font)&&"Real Head Pro"!==y.font)try{(yield Promise.resolve().then((function(){return n(require("webfontloader"))}))).default.load({google:{families:[y.font]},active:()=>{L(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),L(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),L(!0)}}))}),[S,B,null==y?void 0:y.font]),t.jsx(d.Provider,Object.assign({value:Object.assign({formId:_,chatId:E,sessionId:M,userId:l,studioUserId:c,embedUserId:f,deploymentId:u,deploymentType:p,deploymentDimensions:m,deploymentMisc:b,pickaxe:T,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},y),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},h),misc:x,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website","file-limit-reached":"You have reached the file limit."},F),responsiveBy:g,forceMobile:j,loadFont:S,disableHtml:I,disableJs:P,disableCss:w,isFontLoaded:B,isNewChat:N,isShowIceBreaker:A,isRtl:O,isEmbed:k,isDropShadow:C,setIsFontLoaded:L,setFormId:q,setChatId:H,setSessionId:R,setPickaxe:U,setIsNewChat:z,setIsShowIceBreaker:G},D&&{onGenerateComplete:D})},{children:t.jsx(o.default,Object.assign({limits:v},{children:t.jsx(r.default,{children:t.jsx(s.default,{children:a})})}))}))};
@@ -1,5 +1,6 @@
1
1
  interface DocumentListProps {
2
2
  className?: string;
3
+ isDisabled?: boolean;
3
4
  }
4
- declare const DocumentList: ({ className }: DocumentListProps) => import("react/jsx-runtime").JSX.Element;
5
+ declare const DocumentList: ({ className, isDisabled }: DocumentListProps) => import("react/jsx-runtime").JSX.Element;
5
6
  export default DocumentList;
@@ -1 +1 @@
1
- import*as r from"react";var e;function t(){return t=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},t.apply(null,arguments)}var n=n=>r.createElement("svg",t({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24"},n),e||(e=r.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M15 7h3a5 5 0 1 1 0 10h-3m-6 0H6A5 5 0 1 1 6 7h3M8 12h8"})));export{n as default};
1
+ import*as r from"react";var e;function t(){return t=Object.assign?Object.assign.bind():function(r){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var n in t)({}).hasOwnProperty.call(t,n)&&(r[n]=t[n])}return r},t.apply(null,arguments)}var n=n=>r.createElement("svg",t({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 22 22"},n),e||(e=r.createElement("path",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M11 21c5.523 0 10-4.477 10-10S16.523 1 11 1 1 5.477 1 11s4.477 10 10 10M11 15v-4M11 7h.01"})));export{n as default};
@@ -0,0 +1 @@
1
+ import{jsx as e,jsxs as s}from"react/jsx-runtime";import{Fragment as t}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as r}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as i}from"./hooks/useDocument.js";import{formatBytes as a}from"../../../../common/utils.js";import l from"../../../Icons/spinner-lines.svg.js";import c from"../../../Icons/file.svg.js";import n from"../../../Icons/x.svg.js";import d from"../../../Icons/circle-info.svg.js";import u from"../../../../common/cn.js";const m=({className:m,isDisabled:f})=>{const{styles:h,colors:p,translations:b,isRtl:g}=o(),{documents:x,isUploading:j,removeDocument:v}=i(),k=r();return e("div",Object.assign({className:u("flex flex-row gap-3 flex-wrap",m)},{children:x.map(((o,r)=>{var i,m,x,w,y;return e(t,{children:"document"===o.type?s("div",Object.assign({className:u("relative flex items-center gap-x-2.5 pl-2 pr-4 h-[56px] border",g&&"flex-row-reverse"),style:{borderRadius:h.cornerRadius,borderColor:p.secondaryText+"50"}},{children:[e("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:Object.assign({borderRadius:h.cornerRadius,backgroundColor:p.accent,color:p.accentText},"failed"===o.status&&{backgroundColor:p.error,color:"white"})},{children:"uploading"===o.status?e(l,{className:"w-5 h-5 animate-spin shrink-0"}):"failed"===o.status?e(d,{className:"w-5 h-5 shrink-0"}):e(c,{className:"w-5 h-5 shrink-0"})})),s("div",Object.assign({className:u("flex flex-col justify-center truncate",g?"text-right items-end":"text-left items-start")},{children:[e("p",Object.assign({className:u(k.b3,"font-medium truncate")},{children:o.name})),e("p",Object.assign({className:u(k.b4,"opacity-80 truncate")},{children:"failed"===o.status?(null===(i=o.error)||void 0===i?void 0:i.includes("You have reached the file limit"))?null!==(m=null==b?void 0:b["file-limit-reached"])&&void 0!==m?m:"You have reached the file limit.":o.error:a(o.size)}))]})),!j&&e("button",Object.assign({type:"button",className:u("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",g?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:p.accent,color:p.accentText},disabled:j||f,onClick:()=>v(o.id)},{children:e(n,{className:"w-4 h-4 shrink-0"})}))]})):"image"===o.type?s("div",Object.assign({className:"relative h-[56px] flex flex-col items-center justify-center w-[56px]",style:Object.assign({borderRadius:h.cornerRadius,backgroundColor:p.accent,color:p.accentText},"failed"===o.status&&{backgroundColor:p.error,color:"white"})},{children:["finished"===o.status?e("img",{className:"object-cover w-full h-full",style:{borderRadius:h.cornerRadius},src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(x=o.documentId)||void 0===x?void 0:x.split("-")[2]}/${null===(w=o.documentId)||void 0===w?void 0:w.split("-")[1]}.${null===(y=o.documentId)||void 0===y?void 0:y.split("-")[2]}`,alt:""}):"failed"===o.status?e(d,{className:"w-5 h-5 shrink-0"}):e(l,{className:"w-5 h-5 animate-spin shrink-0"}),!j&&e("button",Object.assign({type:"button",className:u("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center outline-none disabled:cursor-default",g?"-left-1 right-auto":"-right-1 left-auto"),style:{backgroundColor:p.accent,color:p.accentText},disabled:j||f,onClick:()=>v(o.id)},{children:e(n,{className:"w-4 h-4 shrink-0"})}))]})):null},r)}))}))};export{m as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useMemo as t}from"react";import{usePickaxeContext as o}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useSubmitDocument as s}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as i}from"./useDocumentContext.js";import{allowedFileMimeTypes as n,allowedImageMimeTypes as r}from"../../../../../common/documents.js";import d from"../../../../../common/error.js";import{v4 as a}from"uuid";const u=["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","o1"],l=({onQuestionChange:l}={})=>{const{formId:c,chatId:m,sessionId:p,pickaxe:f}=o(),g=i(),w=s(),I=t((()=>{var e;return u.includes(null!==(e=null==f?void 0:f.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[f]),h=e=>{const t=[...n,...I?r:[]];if(e.some((e=>!t.includes(e.type)))){const e=new Error(I?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again."),t=d(e);return g.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},g),{isImageUploadAllowed:I,onFileUpload:t=>e(void 0,void 0,void 0,(function*(){if(g.setDocumentError(""),!t.length)return null;if(h(t))return null;g.setIsUploading(!0),g.setIsShowList(!0);const o=t.map((e=>({file:e,id:a()})));o.forEach((({file:e,id:t})=>{g.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const s=o.map((({file:t,id:o})=>e(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:s,error:i}=yield w.document(Object.assign({formId:c,responseId:m,file:t,sessionId:p},(null==f?void 0:f.workspaceid)&&{workspaceId:f.workspaceid}));if(!e)throw new Error(null!=i?i:"Document processing failed");null==l||l({input:t.name,documentId:s});const n=s.startsWith("IMAGE-");return g.editDocument({id:o,type:n?"image":"document",name:t.name,size:t.size,status:"finished",documentId:s}),{name:t.name,documentId:s}}catch(e){const s=d(e);return g.editDocument({id:o,name:t.name,size:t.size,status:"failed",error:s}),{error:s}}})))),i=yield Promise.allSettled(s),n=new Set;for(const e of i)"fulfilled"===e.status&&"error"in e.value&&n.add(e.value.error);n.size>0&&g.setDocumentError([...n].join(", ")),g.setIsUploading(!1)})),onWebsiteUpload:t=>e(void 0,void 0,void 0,(function*(){g.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");g.setIsUploading(!0),g.setIsShowList(!0),g.setWebsiteLink(""),g.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield w.website(Object.assign({formId:c,responseId:m,website:e},(null==f?void 0:f.workspaceid)&&{workspaceId:f.workspaceid})),{success:o,documentId:s}=t;if(!o)throw new Error("Website processing failed, please try again.");g.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:s}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:s}}catch(t){const o=d(t);if(console.log("[onWebsiteUpload] Error",o),o.includes("Please paste a valid website URL"))return g.setDocumentError(o),null;g.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:o});return{type:"website",id:e,size:0,name:e,status:"failed",error:o}}finally{g.setIsUploading(!1)}}))})};export{l as useDocument};
1
+ import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useMemo as t}from"react";import{usePickaxeContext as o}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useSubmitDocument as s}from"../../../../../hooks/pickaxe/useSubmitDocument.js";import{useDocumentContext as i}from"./useDocumentContext.js";import{allowedFileMimeTypes as n,allowedImageMimeTypes as r}from"../../../../../common/documents.js";import d from"../../../../../common/error.js";import{v4 as a}from"uuid";const u=["gpt-4o","gpt-4o-mini","gpt-4.1","gpt-4.1-mini","gpt-4.1-nano","o1"],l=({onQuestionChange:l}={})=>{const{formId:c,chatId:m,sessionId:p,pickaxe:f}=o(),g=i(),w=s(),I=t((()=>{var e;return u.includes(null!==(e=null==f?void 0:f.model)&&void 0!==e?e:"gpt-3.5-turbo")}),[f]),h=e=>{const t=[...n,...I?r:[]];if(e.some((e=>!t.includes(e.type)))){const e=new Error(I?"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, PNG, JPEG, WEBP, or GIF files. Please try again.":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, or PPTX files. Please try again."),t=d(e);return g.setDocumentError(t),!0}return!1};return Object.assign(Object.assign({},g),{isImageUploadAllowed:I,onFileUpload:t=>e(void 0,void 0,void 0,(function*(){if(g.setDocumentError(""),!t.length)return null;if(h(t))return null;g.setIsUploading(!0),g.setIsShowList(!0);const o=t.map((e=>({file:e,id:a()})));o.forEach((({file:e,id:t})=>{g.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const s=o.map((({file:t,id:o})=>e(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:s,error:i}=yield w.document(Object.assign({formId:c,responseId:m,file:t,sessionId:p},(null==f?void 0:f.workspaceid)&&{workspaceId:f.workspaceid}));if(!e)throw new Error(null!=i?i:"Document processing failed");null==l||l({input:t.name,documentId:s});const n=s.startsWith("IMAGE-");return g.editDocument({id:o,type:n?"image":"document",name:t.name,size:t.size,status:"finished",documentId:s}),{name:t.name,documentId:s}}catch(e){const s=d(e);return g.editDocument({id:o,name:t.name,size:t.size,status:"failed",error:s}),{error:s}}}))));yield Promise.allSettled(s),g.setIsUploading(!1)})),onWebsiteUpload:t=>e(void 0,void 0,void 0,(function*(){g.setDocumentError("");let e=t.trim();if(!e)return null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error("Please paste a valid website URL or Youtube video link to add to the knowledge base.");g.setIsUploading(!0),g.setIsShowList(!0),g.setWebsiteLink(""),g.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield w.website(Object.assign({formId:c,responseId:m,website:e},(null==f?void 0:f.workspaceid)&&{workspaceId:f.workspaceid})),{success:o,documentId:s}=t;if(!o)throw new Error("Website processing failed, please try again.");g.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:s}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:s}}catch(t){const o=d(t);if(console.log("[onWebsiteUpload] Error",o),o.includes("Please paste a valid website URL"))return g.setDocumentError(o),null;g.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:o});return{type:"website",id:e,size:0,name:e,status:"failed",error:o}}finally{g.setIsUploading(!1)}}))})};export{l as useDocument};
@@ -0,0 +1 @@
1
+ import{__awaiter as t}from"../../../../../_virtual/_tslib.js";import{useQuery as o}from"@tanstack/react-query";import e from"axios";const r=({documentId:r})=>{const d=o({queryKey:["documentData",r],queryFn:()=>t(void 0,void 0,void 0,(function*(){return(({documentId:o})=>t(void 0,void 0,void 0,(function*(){const t=yield e.get(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_data?documentid=${o}`),r=t.data;if(200!==t.status)throw new Error("[_getDocumentData] Failed to fetch document data "+r);return r})))({documentId:r})})),staleTime:18e4});return d};export{r as useDocumentData};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as t}from"react/jsx-runtime";import s from"../../../../common/cn.js";import{formatBytes as r}from"../../../../common/utils.js";import{useDocumentData as o}from"../../../../hooks/pickaxe/useDocumentData.js";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as c}from"../../../../hooks/studio/useStyleFontSize.js";import n from"../../../Icons/file.svg.js";const i=({documentId:i})=>{const l=o({documentId:i}),{colors:m,styles:d,isRtl:u}=a(),x=c();return"success"!==l.status?e("div",{}):t("a",Object.assign({href:l.data.storageUrl?l.data.storageUrl:"#",target:"_blank",className:s("gap-x-[10px] w-full max-w-[500px] flex items-center px-2 h-[56px] border",u&&"flex-row-reverse"),style:{borderRadius:d.cornerRadius,borderColor:m.secondary+"50"},rel:"noreferrer"},{children:[e("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:m.accent,borderRadius:d.cornerRadius}},{children:e(n,{className:"w-5 h-5",style:{color:m.accentText}})})),t("div",Object.assign({className:s("flex flex-col justify-center truncate",u?"text-right":"text-left")},{children:[e("p",Object.assign({className:(s(x.b3),"font-medium truncate")},{children:l.data.name})),t("p",Object.assign({className:s(x.b4,"opacity-80 truncate")},{children:[l.data.extension&&l.data.extension.toUpperCase()+", ",r(l.data.size)]}))]}))]}))};export{i as default};
1
+ import{jsx as e,jsxs as t}from"react/jsx-runtime";import{usePickaxeContext as s}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useDocumentData as r}from"../../Addons/Document/hooks/useDocumentData.js";import{useStyleFontSize as o}from"../../../../hooks/studio/useStyleFontSize.js";import{formatBytes as a}from"../../../../common/utils.js";import c from"../../../Icons/file.svg.js";import n from"../../../../common/cn.js";const i=({documentId:i})=>{const{colors:l,styles:m,isRtl:d}=s(),u=r({documentId:i}),f=o();return"success"!==u.status?e("div",{}):t("a",Object.assign({href:u.data.storageUrl?u.data.storageUrl:"#",target:"_blank",className:n("gap-x-[10px] w-full max-w-[500px] flex items-center px-2 h-[56px] border",d&&"flex-row-reverse"),style:{borderRadius:m.cornerRadius,borderColor:l.secondary+"50"},rel:"noreferrer"},{children:[e("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:l.accent,borderRadius:m.cornerRadius}},{children:e(c,{className:"w-5 h-5",style:{color:l.accentText}})})),t("div",Object.assign({className:n("flex flex-col justify-center truncate",d?"text-right":"text-left")},{children:[e("p",Object.assign({className:(n(f.b3),"font-medium truncate")},{children:u.data.name})),t("p",Object.assign({className:n(f.b4,"opacity-80 truncate")},{children:[u.data.extension&&u.data.extension.toUpperCase()+", ",a(u.data.size)]}))]}))]}))};export{i as default};
@@ -1 +1 @@
1
- import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as o}from"react/jsx-runtime";import{useState as r,useRef as i,useMemo as n,useEffect as l,Fragment as a}from"react";import{usePickaxeContext as c}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as d}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as u}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as m}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as p}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as f}from"../../../hooks/pickaxe/useSubmit.js";import{useDocument as h}from"../Addons/Document/hooks/useDocument.js";import{useScroll as g}from"../Addons/Scroll/hooks/useScroll.js";import{useHover as b}from"../../../hooks/core/useHover.js";import{formatBytes as v}from"../../../common/utils.js";import{allowedFileMimeTypes as x,allowedImageMimeTypes as y}from"../../../common/documents.js";import{createParser as j}from"eventsource-parser";import k from"../../Icons/attach-vertical.svg.js";import w from"../../Icons/spinner-lines.svg.js";import N from"../../Icons/file.svg.js";import I from"../../Icons/x.svg.js";import O from"../../Icons/arrow-right.svg.js";import C from"../Addons/IceBreaker/index.js";import S from"../../Core/Textarea.js";import R from"../../Core/ErrorAlert.js";import A from"../../../common/error.js";import T from"../../../common/cn.js";const D=({isFocused:D,onFocus:B,onBlur:E})=>{var U;const{formId:F,chatId:H,userId:z,studioUserId:L,embedUserId:$,deploymentId:G,deploymentType:J,pickaxe:K,styles:P,colors:W,responsiveBy:_,isNewChat:M,isRtl:q,setIsNewChat:Q,setIsShowIceBreaker:V,onGenerateComplete:X}=c(),{messages:Y,status:Z,limits:ee,isGenerating:te,setMessages:se,setStatus:oe,setLimitData:re,setError:ie}=d(),{documents:ne,isUploading:le,isImageUploadAllowed:ae,documentError:ce,onFileUpload:de,setDocuments:ue,setDocumentError:me,removeDocument:pe}=h(),{scrollStartSession:fe,scrollEndSession:he,scrollToBottom:ge}=g({auto:!0}),be=p(),ve=f(),[xe,ye]=r(""),je=i(null),ke=b(),{isHover:we}=ke,Ne=e(ke,["isHover"]),Ie=b(),{isHover:Oe}=Ie,Ce=e(Ie,["isHover"]),Se=m(),Re=u(),Ae=n((()=>{var e,t,s;return!!M&&(!!K&&(!be.isLoading&&(!((null!==(t=null===(e=be.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(s=K.icebreakers)||void 0===s?void 0:s.length))))}),[K,M,be.data,be.isLoading]),Te=e=>t(void 0,void 0,void 0,(function*(){try{if("idle"!==Z||le)return;const t=null!=e?e:xe;if(!t)return;ie(""),me(""),re(null),ye(""),Q(!1),oe("fetching"),fe(),ge();const s=ne.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),o="enduserupload"===(null==K?void 0:K.documentuploadtype)&&s.length>0,r=[...Array.from(Y),Object.assign({id:Y.length+1,role:"user",content:t},o&&{documentIds:s})];se(r),ge(),o&&ue([]);const i=(yield ve.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:F,responseId:H,value:t},o&&{documentIds:s}),z&&{userId:z}),L&&{studioUserId:L}),$&&{embedUserId:$}),G&&{deploymentId:G}))).body;if(!i)throw new Error("Streaming error");const n=r.length,l=new TextDecoder,a=i.getReader();let c="",d=!0,u=!1;const m=j({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");c+=t,se([...r.slice(0,n),{id:Y.length+1,role:"assistant",content:c}])}else if("error"===e.event){const t=JSON.parse(e.data);ie(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(d=!1)}});for(;d;){const{value:e,done:t}=yield a.read();if(t){d=!1;break}const s=l.decode(e);s&&(u||(oe("streaming"),u=!0),m.feed(s))}null==X||X(H)}catch(e){let t=A(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const s=Object.entries(ee).find((([e])=>t.includes(e)));s?re(s[1]):ie(t)}finally{ge(),oe("idle"),he()}}));return l((()=>{V(Ae)}),[Ae]),s("div",Object.assign({className:T("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===J&&M)&&"px-4 pb-4"),dir:q?"rtl":"ltr"},{children:o("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===J&&M)&&s("div",Object.assign({className:T("absolute bottom-full",q?"left-0":"right-0")},{children:s("div",Object.assign({className:T("flex flex-col gap-2 pb-4 px-2",q?"justify-start":"justify-end","viewport"===_?q?"min-[767px]:items-start":"min-[767px]:items-end":q?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:Ae&&!D&&s(C,{data:(null==K?void 0:K.icebreakers)||[],onSend:Te})}))})),o("div",Object.assign({className:T("flex flex-col gap-y-2 px-4 py-3","block"===P.formFieldStyle&&"shadow"),style:Re},{children:["idle"===Z&&ne.length>0&&s("div",Object.assign({className:"flex flex-row gap-2 flex-wrap"},{children:ne.filter((e=>"failed"!==e.status)).map((e=>{var t,r,i;return s(a,{children:"document"===e.type?o("div",Object.assign({className:T("relative gap-x-[10px] flex items-center px-2 h-[56px] border",q&&"flex-row-reverse"),style:{borderRadius:Re.borderRadius,borderColor:W.secondaryText+"50"}},{children:[s("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:W.accent,borderRadius:Re.borderRadius}},{children:le?s(w,{className:"w-5 h-5 animate-spin",style:{color:W.accentText}}):s(N,{className:"w-5 h-5",style:{color:W.accentText}})})),o("div",Object.assign({className:T("flex flex-col justify-center truncate",q?"text-right items-end":"text-left items-start")},{children:[s("p",Object.assign({className:(T(Se.b3),"font-medium truncate")},{children:e.name})),s("p",Object.assign({className:T(Se.b4,"opacity-80 truncate")},{children:v(e.size)}))]})),s("button",Object.assign({type:"button",className:T("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",q?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:W.accent,borderColor:Re.backgroundColor},disabled:le||"idle"!==Z,onClick:()=>pe(e.id)},{children:s(I,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):"image"===e.type?o("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:Re.borderRadius}},{children:["finished"===e.status?s("img",{style:{borderRadius:Re.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(t=e.documentId)||void 0===t?void 0:t.split("-")[2]}/${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[1]}.${null===(i=e.documentId)||void 0===i?void 0:i.split("-")[2]}`,alt:""}):s("div",{className:"h-full w-full animate-pulse",style:{borderRadius:Re.borderRadius,backgroundColor:W.secondary}}),s("button",Object.assign({type:"button",className:T("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",q?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:W.accent,borderColor:Re.backgroundColor},disabled:le||"idle"!==Z,onClick:()=>pe(e.id)},{children:s(I,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):null},e.id)}))})),o("div",Object.assign({className:T("flex items-end gap-x-2",q&&"flex-row-reverse")},{children:[s(S,Object.assign({className:T(Se.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!xe.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",q?"text-right":"text-left"),value:xe,placeholder:null!==(U=null==K?void 0:K.placeholdertext)&&void 0!==U?U:q?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>ye(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),le||"idle"!==Z||Te()))}},B&&{onFocus:B},E&&{onBlur:E},{dir:q?"rtl":"ltr"})),o("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==K?void 0:K.documentuploadtype)&&o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:Oe?W.accent+"10":void 0},disabled:le||"idle"!==Z,onClick:()=>{var e;return null===(e=je.current)||void 0===e?void 0:e.click()}},Ce,{children:[s("input",{id:"file-upload",ref:je,type:"file",accept:[...x,...ae?y:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){Q(!1),yield de(Array.from(e.target.files||[])),e.target.value=""}))}),s(k,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:Oe?W.accent:W.accent+"80"}})]})),s("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:(we||xe.length||ne.length&&ne.every((e=>"finished"===e.status)))&&!te?W.accent:W.accent+"10"},disabled:le||"idle"!==Z,onClick:()=>Te()},Ne,{children:s(O,{className:T("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",q&&"transform scale-x-[-1]"),style:{color:(we||xe.length||ne.length&&ne.every((e=>"finished"===e.status)))&&!te?W.accentText:W.accent+"80"}})}))]}))]}))]})),ce&&s(R,{error:ce,className:"mt-3"})]}))}))};export{D as default};
1
+ import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsx as o,jsxs as s}from"react/jsx-runtime";import{useState as r,useRef as n,useMemo as i,useEffect as l}from"react";import{usePickaxeContext as a}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as d}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as c}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as m}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as u}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as p}from"../../../hooks/pickaxe/useSubmit.js";import{useDocument as f}from"../Addons/Document/hooks/useDocument.js";import{useScroll as h}from"../Addons/Scroll/hooks/useScroll.js";import{useHover as g}from"../../../hooks/core/useHover.js";import{allowedFileMimeTypes as v,allowedImageMimeTypes as x}from"../../../common/documents.js";import{createParser as b}from"eventsource-parser";import j from"../../Icons/attach-vertical.svg.js";import y from"../../Icons/arrow-right.svg.js";import k from"../Addons/IceBreaker/index.js";import w from"../Addons/Document/List.js";import I from"../../Core/Textarea.js";import O from"../../Core/ErrorAlert.js";import N from"../../../common/error.js";import S from"../../../common/cn.js";const C=({isFocused:C,onFocus:A,onBlur:D})=>{var B;const{formId:E,chatId:U,userId:F,studioUserId:H,embedUserId:R,deploymentId:T,deploymentType:L,pickaxe:z,styles:G,colors:J,responsiveBy:K,isNewChat:P,isRtl:W,setIsNewChat:_,setIsShowIceBreaker:M,onGenerateComplete:q}=a(),{messages:Q,status:V,limits:X,isGenerating:Y,setMessages:Z,setStatus:$,setLimitData:ee,setError:te}=d(),{documents:oe,isUploading:se,isImageUploadAllowed:re,documentError:ne,onFileUpload:ie,setDocuments:le,setDocumentError:ae}=f(),{scrollStartSession:de,scrollEndSession:ce,scrollToBottom:me}=h({auto:!0}),ue=u(),pe=p(),[fe,he]=r(""),ge=n(null),ve=g(),{isHover:xe}=ve,be=e(ve,["isHover"]),je=g(),{isHover:ye}=je,ke=e(je,["isHover"]),we=m(),Ie=c(),Oe=i((()=>{var e,t,o;return!!P&&(!!z&&(!ue.isLoading&&(!((null!==(t=null===(e=ue.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(o=z.icebreakers)||void 0===o?void 0:o.length))))}),[z,P,ue.data,ue.isLoading]),Ne=i((()=>{if(Y||se)return!1;return!!fe.trim()&&oe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Y,se,fe,oe]),Se=e=>t(void 0,void 0,void 0,(function*(){try{if("idle"!==V||se)return;const t=null!=e?e:fe;if(!t)return;te(""),ae(""),ee(null),he(""),_(!1),$("fetching"),de(),me();const o=oe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)).map((e=>e.documentId)).filter(Boolean),s="enduserupload"===(null==z?void 0:z.documentuploadtype)&&o.length>0,r=[...Array.from(Q),Object.assign({id:Q.length+1,role:"user",content:t},s&&{documentIds:o})];Z(r),me(),s&&le([]);const n=(yield pe.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:E,responseId:U,value:t},s&&{documentIds:o}),F&&{userId:F}),H&&{studioUserId:H}),R&&{embedUserId:R}),T&&{deploymentId:T}))).body;if(!n)throw new Error("Streaming error");const i=r.length,l=new TextDecoder,a=n.getReader();let d="",c=!0,m=!1;const u=b({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");d+=t,Z([...r.slice(0,i),{id:Q.length+1,role:"assistant",content:d}])}else if("error"===e.event){const t=JSON.parse(e.data);te(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(c=!1)}});for(;c;){const{value:e,done:t}=yield a.read();if(t){c=!1;break}const o=l.decode(e);o&&(m||($("streaming"),m=!0),u.feed(o))}null==q||q(U)}catch(e){let t=N(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const o=Object.entries(X).find((([e])=>t.includes(e)));o?ee(o[1]):te(t)}finally{me(),$("idle"),ce()}}));return l((()=>{M(Oe)}),[Oe]),o("div",Object.assign({className:S("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===L&&P)&&"px-4 pb-4"),dir:W?"rtl":"ltr"},{children:s("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===L&&P)&&o("div",Object.assign({className:S("absolute bottom-full",W?"left-0":"right-0")},{children:o("div",Object.assign({className:S("flex flex-col gap-2 pb-4 px-2",W?"justify-start":"justify-end","viewport"===K?W?"min-[767px]:items-start":"min-[767px]:items-end":W?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:Oe&&!C&&o(k,{data:(null==z?void 0:z.icebreakers)||[],onSend:Se})}))})),s("div",Object.assign({className:S("flex flex-col gap-y-3 px-4 py-3","block"===G.formFieldStyle&&"shadow"),style:Ie},{children:["idle"===V&&oe.length>0&&o(w,{isDisabled:"idle"!==V}),s("div",Object.assign({className:S("flex items-end gap-x-2",W&&"flex-row-reverse")},{children:[o(I,Object.assign({className:S(we.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!fe.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",W?"text-right":"text-left"),value:fe,placeholder:null!==(B=null==z?void 0:z.placeholdertext)&&void 0!==B?B:W?"بماذا تريد أن تتحدث؟":"What do you want to talk about?",onChange:e=>he(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),se||"idle"!==V||Se()))}},A&&{onFocus:A},D&&{onBlur:D},{dir:W?"rtl":"ltr"})),s("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==z?void 0:z.documentuploadtype)&&s("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",style:{backgroundColor:ye?J.accent+"10":void 0,color:ye?J.accent:J.accent+"80"},disabled:se||"idle"!==V,onClick:()=>{var e;return null===(e=ge.current)||void 0===e?void 0:e.click()}},ke,{children:[o("input",{id:"file-upload",ref:ge,type:"file",accept:[...v,...re?x:[]].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){_(!1),yield ie(Array.from(e.target.files||[])),e.target.value=""}))}),o(j,{className:"h-6 w-6 shrink-0"})]})),o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full duration-200 transition-colors ease-in-out",style:{backgroundColor:xe||Ne?J.accent:J.accent+"10",color:xe||Ne?J.accentText:J.accent+"80"},disabled:"idle"!==V||se,onClick:()=>Se()},be,{children:o(y,{className:S("h-6 w-6 shrink-0",W&&"transform scale-x-[-1]")})}))]}))]}))]})),ne&&o(O,{error:ne,className:"mt-3"})]}))}))};export{C as default};
@@ -1 +1 @@
1
- import{__rest as e,__awaiter as s}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as l}from"react/jsx-runtime";import{useState as i,useRef as r,Fragment as a}from"react";import{usePickaxeContext as n}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleInput as c}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as u}from"../../Addons/Document/hooks/useDocument.js";import{useHover as m}from"../../../../hooks/core/useHover.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as p}from"../../../../common/documents.js";import{formatBytes as f}from"../../../../common/utils.js";import h from"../../../Icons/attach-vertical.svg.js";import g from"../../../Icons/check.svg.js";import y from"../../../Icons/spinner-lines.svg.js";import v from"../../../Icons/file.svg.js";import x from"../../../Icons/x.svg.js";import j from"../../../Icons/link.svg.js";import k from"../../../Core/ErrorAlert.js";import w from"../../../../common/cn.js";const N=({field:N,update:O})=>{var C;const R=d(),{colors:I,styles:D,translations:T,responsiveBy:F}=n(),A=m(),{isHover:S}=A,U=e(A,["isHover"]),{documents:E,documentError:z,websiteLink:H,isUploading:L,isImageUploadAllowed:W,removeDocument:$,setDocumentError:B,setWebsiteLink:P,onFileUpload:_,onWebsiteUpload:q}=u({onQuestionChange:e=>{O(Object.assign(Object.assign({},N),e))}}),[K,Q]=i(!1),G=r(null),J=c();return t("div",Object.assign({className:"flex flex-col gap-y-4"},{children:[t("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[t("div",Object.assign({className:"flex items-center gap-1"},{children:[o("p",Object.assign({className:w(R.b3,"font-semibold opacity-70")},{children:N.main})),N.isRequired&&o("span",Object.assign({className:"select-none font-semibold",style:{color:I.error}},{children:"*"}))]})),t("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[o("input",{ref:G,type:"file",accept:[...b,...W?p:[]].join(", "),id:N.id,hidden:!0,multiple:!0,className:"hidden",onChange:e=>s(void 0,void 0,void 0,(function*(){yield _(Array.from(e.target.files||[])),e.target.value=""})),disabled:L}),t("div",Object.assign({className:w("flex items-center justify-between rounded-sm border border-transparent bg-white py-3 pl-4 pr-3 duration-300 ease-in-out transition-all",K&&"block"===D.formFieldStyle&&"shadow","block"===D.formFieldStyle&&"shadow hover:shadow-none"),style:J},{children:[o("input",{type:"text",value:H,className:w(R.i1,"w-full outline-none ring-0 bg-transparent placeholder:text-inherit placeholder:opacity-50"),placeholder:null!==(C=null==T?void 0:T["form-doc-placeholder"])&&void 0!==C?C:"Paste a website/video link or drag a file",onChange:e=>P(e.target.value),onDrop:e=>s(void 0,void 0,void 0,(function*(){e.preventDefault(),yield _(Array.from(e.dataTransfer.files||[]))})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),q(H))},onFocus:()=>Q(!0),onBlur:()=>Q(!1)}),o("div",Object.assign({className:"flex items-center gap-3 pl-4"},{children:H.length>0?t(l,{children:[o("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:L,onClick:()=>q(H)},{children:o(g,{className:"h-5 w-5 shrink-0",style:{color:I.accent}})})),o("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:L,onClick:()=>{P(""),B("")}},{children:o(x,{className:"h-6 w-6 shrink-0",style:{color:I.accent}})}))]}):o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",disabled:L,onClick:()=>{var e;null===(e=G.current)||void 0===e||e.click()},style:{backgroundColor:S?I.accent+"10":void 0}},U,{children:o(h,{className:"h-6 w-6 shrink-0",style:{color:S?I.accent:I.accent+"80"}})}))}))]}))]}))]})),E.length>0&&o("div",Object.assign({className:w("flex gap-4","viewport"===F?"min-[765px]:flex-col":"@[767px]/pickaxe-root:flex-col")},{children:o("div",Object.assign({className:"flex flex-row gap-x-2"},{children:E.filter((e=>"failed"!==e.status)).map((e=>{var s,l,i;return o(a,{children:"document"===e.type?t("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:J},{children:[o("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:I.accent,borderRadius:J.borderRadius}},{children:L?o(y,{className:"w-5 h-5 shrink-0 animate-spin",style:{color:I.accentText}}):o(v,{className:"w-5 h-5 shrink-0",style:{color:I.accentText}})})),t("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[o("p",Object.assign({className:(w(R.b3),"font-medium truncate")},{children:e.name})),o("p",Object.assign({className:w(R.b4,"opacity-80 truncate")},{children:f(e.size)}))]})),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4 shrink-0",style:{color:I.accentText}})}))]})):"image"===e.type?t("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:J.borderRadius}},{children:["finished"===e.status?o("img",{style:{borderRadius:J.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(s=e.documentId)||void 0===s?void 0:s.split("-")[2]}/${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[1]}.${null===(i=e.documentId)||void 0===i?void 0:i.split("-")[2]}`,alt:""}):o("div",{className:"h-full w-full animate-pulse",style:{borderRadius:J.borderRadius,backgroundColor:I.secondary}}),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4 shrink-0",style:{color:I.accentText}})}))]})):"website"===e.type?t("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:J},{children:[o("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:I.accent,borderRadius:J.borderRadius}},{children:L?o(y,{className:"w-5 h-5 animate-spin shrink-0",style:{color:I.accentText}}):o(j,{className:"w-5 h-5 shrink-0",style:{color:I.accentText}})})),t("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[o("p",Object.assign({className:(w(R.b3),"font-medium truncate")},{children:new URL(e.name).hostname})),o("p",Object.assign({className:w(R.b4,"opacity-80 truncate")},{children:(null==T?void 0:T.website)||"Website"}))]})),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$(e.id),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4 shrink-0",style:{color:I.accentText}})}))]})):null},e.id)}))}))})),z&&o(k,{error:z,className:"mt-3"})]}))};export{N as default};
1
+ import{__rest as e,__awaiter as o}from"../../../../_virtual/_tslib.js";import{jsxs as s,jsx as t,Fragment as i}from"react/jsx-runtime";import{useState as n,useRef as r}from"react";import{usePickaxeContext as l}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleInput as a}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as c}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as d}from"../../Addons/Document/hooks/useDocument.js";import{useHover as m}from"../../../../hooks/core/useHover.js";import{allowedFileMimeTypes as u,allowedImageMimeTypes as p}from"../../../../common/documents.js";import f from"../../../Icons/attach-vertical.svg.js";import h from"../../../Icons/check.svg.js";import b from"../../../Icons/x.svg.js";import g from"../../../Core/ErrorAlert.js";import v from"../../Addons/Document/List.js";import j from"../../../../common/cn.js";const y=({field:y,update:k})=>{var x;const N=c(),{colors:w,styles:O,translations:C}=l(),D=m(),{isHover:A}=D,F=e(D,["isHover"]),{documents:I,documentError:S,websiteLink:E,isUploading:U,isImageUploadAllowed:H,setDocumentError:L,setWebsiteLink:P,onFileUpload:W,onWebsiteUpload:_}=d({onQuestionChange:e=>{k(Object.assign(Object.assign({},y),e))}}),[q,z]=n(!1),B=r(null),K=a();return s("div",Object.assign({className:"flex flex-col gap-y-4"},{children:[s("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s("div",Object.assign({className:"flex items-center gap-1"},{children:[t("p",Object.assign({className:j(N.b3,"font-semibold opacity-70")},{children:y.main})),y.isRequired&&t("span",Object.assign({className:"select-none font-semibold",style:{color:w.error}},{children:"*"}))]})),s("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[t("input",{ref:B,type:"file",accept:[...u,...H?p:[]].join(", "),id:y.id,hidden:!0,multiple:!0,className:"hidden",onChange:e=>o(void 0,void 0,void 0,(function*(){yield W(Array.from(e.target.files||[])),e.target.value=""})),disabled:U}),s("div",Object.assign({className:j("flex items-center justify-between rounded-sm border border-transparent bg-white py-3 pl-4 pr-3 duration-300 ease-in-out transition-all",q&&"block"===O.formFieldStyle&&"shadow","block"===O.formFieldStyle&&"shadow hover:shadow-none"),style:K},{children:[t("input",{type:"text",value:E,className:j(N.i1,"w-full outline-none ring-0 bg-transparent placeholder:text-inherit placeholder:opacity-50"),placeholder:null!==(x=null==C?void 0:C["form-doc-placeholder"])&&void 0!==x?x:"Paste a website/video link or drag a file",onChange:e=>P(e.target.value),onDrop:e=>o(void 0,void 0,void 0,(function*(){e.preventDefault(),yield W(Array.from(e.dataTransfer.files||[]))})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),_(E))},onFocus:()=>z(!0),onBlur:()=>z(!1)}),t("div",Object.assign({className:"flex items-center gap-3 pl-4"},{children:E.length>0?s(i,{children:[t("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:U,onClick:()=>_(E)},{children:t(h,{className:"h-5 w-5 shrink-0",style:{color:w.accent}})})),t("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:U,onClick:()=>{P(""),L("")}},{children:t(b,{className:"h-6 w-6 shrink-0",style:{color:w.accent}})}))]}):t("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",disabled:U,onClick:()=>{var e;null===(e=B.current)||void 0===e||e.click()},style:{backgroundColor:A?w.accent+"10":void 0}},F,{children:t(f,{className:"h-6 w-6 shrink-0",style:{color:A?w.accent:w.accent+"80"}})}))}))]}))]}))]})),I.length>0&&t(v,{}),S&&t(g,{error:S,className:"mt-3"})]}))};export{y as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as o}from"react/jsx-runtime";import{createContext as i,useState as s,useEffect as t}from"react";import n from"./Addons/Document/Provider.js";import r from"./ResponseProvider.js";import d from"./DimensionProvider.js";const l=i({}),a=({children:i,userId:a="",studioUserId:c="",deploymentId:m="",embedUserId:p="",deploymentType:f,deploymentDimensions:b,deploymentMisc:y,styles:h,colors:u,limits:F={},misc:I={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:g,responsiveBy:v="viewport",forceMobile:w=!1,disableHtml:x=!1,disableJs:P=!1,disableCss:j=!1,loadFont:S=!0,isRtl:D=!1,isEmbed:k=!1,isDropShadow:C=!1,onGenerateComplete:H})=>{const[O,R]=s(""),[T,U]=s(""),[B,L]=s(""),[M,E]=s(null),[N,A]=s(!1),[G,J]=s(!0),[W,_]=s(!0);return t((()=>{A(!1)}),[null==h?void 0:h.font]),t((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&S&&!N&&(null==h?void 0:h.font)&&"Real Head Pro"!==h.font)try{(yield import("webfontloader")).default.load({google:{families:[h.font]},active:()=>{A(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),A(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),A(!0)}}))}),[S,N,null==h?void 0:h.font]),o(l.Provider,Object.assign({value:Object.assign({formId:O,chatId:T,sessionId:B,userId:a,studioUserId:c,embedUserId:p,deploymentId:m,deploymentType:f,deploymentDimensions:b,deploymentMisc:y,pickaxe:M,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},h),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},u),misc:I,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website"},g),responsiveBy:v,forceMobile:w,loadFont:S,disableHtml:x,disableJs:P,disableCss:j,isFontLoaded:N,isNewChat:G,isShowIceBreaker:W,isRtl:D,isEmbed:k,isDropShadow:C,setIsFontLoaded:A,setFormId:R,setChatId:U,setSessionId:L,setPickaxe:E,setIsNewChat:J,setIsShowIceBreaker:_},H&&{onGenerateComplete:H})},{children:o(r,Object.assign({limits:F},{children:o(d,{children:o(n,{children:i})})}))}))};export{l as PickaxeContext,a as PickaxeProvider};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as i}from"react/jsx-runtime";import{createContext as o,useState as s,useEffect as t}from"react";import r from"./Addons/Document/Provider.js";import d from"./ResponseProvider.js";import n from"./DimensionProvider.js";const l=o({}),a=({children:o,userId:a="",studioUserId:c="",deploymentId:m="",embedUserId:p="",deploymentType:f,deploymentDimensions:h,deploymentMisc:b,styles:y,colors:u,limits:F={},misc:I={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:v,responsiveBy:g="viewport",forceMobile:w=!1,disableHtml:x=!1,disableJs:P=!1,disableCss:j=!1,loadFont:S=!0,isRtl:D=!1,isEmbed:k=!1,isDropShadow:C=!1,onGenerateComplete:H})=>{const[O,R]=s(""),[T,U]=s(""),[B,L]=s(""),[M,E]=s(null),[N,A]=s(!1),[G,J]=s(!0),[W,_]=s(!0);return t((()=>{A(!1)}),[null==y?void 0:y.font]),t((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&S&&!N&&(null==y?void 0:y.font)&&"Real Head Pro"!==y.font)try{(yield import("webfontloader")).default.load({google:{families:[y.font]},active:()=>{A(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),A(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),A(!0)}}))}),[S,N,null==y?void 0:y.font]),i(l.Provider,Object.assign({value:Object.assign({formId:O,chatId:T,sessionId:B,userId:a,studioUserId:c,embedUserId:p,deploymentId:m,deploymentType:f,deploymentDimensions:h,deploymentMisc:b,pickaxe:M,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},y),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},u),misc:I,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website","file-limit-reached":"You have reached the file limit."},v),responsiveBy:g,forceMobile:w,loadFont:S,disableHtml:x,disableJs:P,disableCss:j,isFontLoaded:N,isNewChat:G,isShowIceBreaker:W,isRtl:D,isEmbed:k,isDropShadow:C,setIsFontLoaded:A,setFormId:R,setChatId:U,setSessionId:L,setPickaxe:E,setIsNewChat:J,setIsShowIceBreaker:_},H&&{onGenerateComplete:H})},{children:i(d,Object.assign({limits:F},{children:i(n,{children:i(r,{children:o})})}))}))};export{l as PickaxeContext,a as PickaxeProvider};
@@ -1,5 +1,6 @@
1
1
  interface DocumentListProps {
2
2
  className?: string;
3
+ isDisabled?: boolean;
3
4
  }
4
- declare const DocumentList: ({ className }: DocumentListProps) => import("react/jsx-runtime").JSX.Element;
5
+ declare const DocumentList: ({ className, isDisabled }: DocumentListProps) => import("react/jsx-runtime").JSX.Element;
5
6
  export default DocumentList;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "2.7.3",
3
+ "version": "2.8.0",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1 +0,0 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("@tanstack/react-query");function r(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=r(require("axios"));exports.useDocumentData=({documentId:r})=>{const o=t.useQuery({queryKey:["documentData",r],queryFn:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return(({documentId:t})=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=yield u.default.get(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_data?documentid=${t}`),r=e.data;if(200!==e.status)throw new Error("[_getDocumentData] Failed to fetch document data "+r);return r})))({documentId:r})})),staleTime:18e4});return o};
@@ -1 +0,0 @@
1
- import{__awaiter as t}from"../../_virtual/_tslib.js";import{useQuery as o}from"@tanstack/react-query";import e from"axios";const r=({documentId:r})=>{const d=o({queryKey:["documentData",r],queryFn:()=>t(void 0,void 0,void 0,(function*(){return(({documentId:o})=>t(void 0,void 0,void 0,(function*(){const t=yield e.get(`${process.env.NEXT_PUBLIC_MODAL_DOC_APP_URL}/get_document_data?documentid=${o}`),r=t.data;if(200!==t.status)throw new Error("[_getDocumentData] Failed to fetch document data "+r);return r})))({documentId:r})})),staleTime:18e4});return d};export{r as useDocumentData};