@pickaxeproject/react 6.0.1-0 → 6.0.1-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../hooks/pickaxe/useDimensionContext.js"),i=require("../Addons/Document/hooks/useDocument.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("./History/index.js"),c=require("./Input.js"),u=require("../../Icons/attach-vertical.svg.js"),d=require("../../../common/cn.js"),m=require("../../../common/api/pickaxe.js"),x=require("lucide-react"),f=require("uuid"),h=require("../../Icons/trash-2.svg.js"),p=require("../../Icons/pencil.svg.js"),b=require("../../../hooks/pickaxe/useResponseContext.js");const j=({children:e,className:s})=>t.jsx("div",Object.assign({className:d.default("flex items-center gap-2 transition-all duration-200 select-none","rounded-[40px] h-[72px] border border-white/70 px-6 py-3 bg-white/10 backdrop-blur-md shadow-lg",s)},{children:e})),g=({text:e,icon:s,className:n,onClick:r})=>t.jsx("div",Object.assign({onClick:r,className:d.default("relative flex items-center justify-center px-3 h-full shrink-0 transition-all duration-200 rounded-[40px] border border-white/70 bg-[#FFFFFF1A]",n)},{children:t.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20"},{children:[s&&t.jsx("img",{src:s,alt:"",className:"h-5 w-5 rounded-full object-cover"}),t.jsx("p",Object.assign({className:"text-sm font-medium truncate max-w-[150px] text-foreground"},{children:e}))]}))})),v=({text:n,className:r,onRename:o,onDelete:i})=>{const[a,l]=s.useState(!1),[c,u]=s.useState(!1),[m,f]=s.useState(n),[b,j]=s.useState(!1),g=s.useRef(null),v=s.useRef(null);s.useEffect((()=>{c||f(n)}),[n,c]),s.useEffect((()=>{const e=e=>{v.current&&!v.current.contains(e.target)&&l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const w=()=>e.__awaiter(void 0,void 0,void 0,(function*(){m.trim()&&(j(!0),yield o(m),j(!1),u(!1))})),y=()=>{f(n),u(!1)};return t.jsxs("div",Object.assign({ref:v,className:"relative z-40 h-full"},{children:[t.jsx("div",Object.assign({className:d.default("relative flex items-center justify-center px-3 h-full shrink-0 rounded-[40px] overflow-visible transition-all duration-200 cursor-pointer group border border-white/70 bg-[#FFFFFF1A]",r),onClick:e=>{e.stopPropagation(),c||a?a&&l(!1):l(!0)}},{children:c?t.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-[140px]",onClick:e=>e.stopPropagation()},{children:[t.jsx("input",{autoFocus:!0,type:"text",value:m,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&w(),"Escape"===e.key&&y()},className:"bg-transparent border-b border-black/30 text-sm font-medium focus:outline-none w-full min-w-[80px] text-foreground"}),t.jsx("button",Object.assign({onClick:w,disabled:b,className:"p-1 rounded hover:bg-black/10 text-green-600"},{children:t.jsx(x.Check,{className:"h-4 w-4"})})),t.jsx("button",Object.assign({onClick:y,disabled:b,className:"p-1 rounded hover:bg-black/10 text-red-600"},{children:t.jsx(x.X,{className:"h-4 w-4"})}))]})):t.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 max-w-[200px]"},{children:[t.jsx("p",Object.assign({className:"text-sm font-medium truncate text-foreground"},{children:n})),t.jsx(x.MoreHorizontal,{className:d.default("h-4 w-4 opacity-50 group-hover:opacity-100 transition-opacity")})]}))})),a&&t.jsxs("div",Object.assign({className:"absolute top-full right-0 mt-2 w-48 shadow-xl z-50 rounded-[16px] border border-white/70 bg-neutral-400 backdrop-blur-md overflow-hidden animate-in fade-in zoom-in-95 duration-100",ref:g},{children:[t.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),l(!1),u(!0)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors border-b border-white/10 hover:bg-white/10"},{children:[t.jsx(p.default,{className:"h-4 w-4"}),t.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Rename chat"}))]})),t.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),l(!1),i()},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors hover:bg-white/10"},{children:[t.jsx(h.default,{className:"h-4 w-4"}),t.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Delete chat"}))]}))]}))]}))};exports.default=()=>{const{deploymentType:x,isNewChat:h,setIsNewChat:p,sessionId:w,setSessionId:y,pickaxeId:k,sender:N,colors:O,styles:C,pickaxe:F,isEmbed:D}=n.usePickaxeContext(),{isSent:_}=r.useAuthContext(),{width:I,height:S,setDimension:q}=o.useDimensionContext(),{setDocuments:E,onFileUpload:P}=i.useDocument(),{isGenerating:z}=b.useResponseContext(),A=a.useStyleFontSize(),[R,T]=s.useState(0),[H,L]=s.useState(!1),[M,B]=s.useState(!1),G=s.useRef(null),K=s.useRef(null),U=s.useRef(0),[X,J]=s.useState(null),[Q,V]=s.useState(!1),W="chat-input"===x&&h&&!_;s.useEffect((()=>()=>{E([])}),[]);const Y=s.useCallback((()=>{if(!k||!N)return;const t=(s=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield m.default.post("/get_pickaxe_conversation",{sessionId:w,userId:N});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void $(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}s<20&&setTimeout((()=>t(s+1)),3e3)}));t()}),[k,N,w]);s.useEffect((()=>{z||h||!w||Y()}),[z,h,w,Y]),s.useEffect((()=>{if(!G.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;q(parseInt(e.toFixed(0)),parseInt(s.toFixed(0)))}}));return e.observe(G.current),()=>{e.disconnect()}}),[G.current]);const[Z,$]=s.useState("New Chat"),ee=(null==F?void 0:F.formtitle)||"Pickaxe",te=(null==F?void 0:F.coverphoto)||void 0,se=!W&&!D;return t.jsxs("div",Object.assign({ref:G,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),U.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&B(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),U.current-=1,0===U.current&&B(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),B(!1),U.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(p(!1),yield P(e))}))},{children:[M&&t.jsxs("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(u.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:d.default(A.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),t.jsx("p",Object.assign({className:d.default(A.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),W?t.jsx(c.default,{}):t.jsxs(t.Fragment,{children:[t.jsxs("div",Object.assign({className:d.default("flex flex-col w-full items-center h-full relative z-0",se?"pt-6":"")},{children:[se&&t.jsx("div",Object.assign({className:"w-full max-w-3xl px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500"},{children:t.jsxs(j,Object.assign({colors:O,styles:C},{children:[t.jsx(g,{text:ee,icon:te,colors:O,styles:C}),h||"New Chat"===Z?t.jsx(g,{text:Z,colors:O,styles:C}):t.jsx(v,{text:Z,sessionId:w,colors:O,styles:C,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(w)try{yield m.default.post("/edit_conversation_name",{sessionId:w,name:t,userId:N}),$(t)}catch(e){console.error("Error renaming chat:",e),alert("Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(w&&window.confirm("Are you sure you want to delete this conversation?"))try{yield m.default.post("/delete_pickaxe_conversation",{sessionId:w,userId:N}),p(!0),y(f.v4()),$("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}}))})]}))})),t.jsx(l.default,{additionalScrollHeight:R,isForceHideInfo:S<=545||I<=350||H,isInputFocused:H,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){K.current&&K.current.onSubmit(t)})),smitheryAuthData:X,resubmitPrompt:()=>{J(null),V(!0)}})]})),t.jsx(c.default,{ref:K,onFocus:()=>L(!0),onBlur:()=>L(!1),onInputHeightChange:T,initSmitheryAuthData:e=>J(e),resubmitPrompt:Q})]})]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../Addons/Auth/hooks/useAuthContext.js"),o=require("../../../hooks/pickaxe/useDimensionContext.js"),i=require("../Addons/Document/hooks/useDocument.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("./History/index.js"),c=require("./Input.js"),u=require("../../Icons/attach-vertical.svg.js"),d=require("../../../common/cn.js"),m=require("../../../common/api/pickaxe.js"),x=require("lucide-react"),f=require("uuid"),h=require("../../Icons/trash-2.svg.js"),p=require("../../Icons/pencil.svg.js"),b=require("../../../hooks/pickaxe/useResponseContext.js");const j=({children:e,className:s})=>t.jsx("div",Object.assign({className:d.default("flex items-center gap-2 transition-all duration-200 select-none","rounded-[40px] h-[72px] border border-white/70 px-6 py-3 bg-white/10 backdrop-blur-md shadow-md",s)},{children:e})),v=({text:e,icon:s,className:n,onClick:r})=>t.jsx("div",Object.assign({onClick:r,className:d.default("relative flex items-center justify-center px-3 h-full shrink-0 transition-all duration-200 rounded-[40px] border border-white/70 bg-[#FFFFFF1A]",n)},{children:t.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20"},{children:[s&&t.jsx("img",{src:s,alt:"",className:"h-5 w-5 rounded-full object-cover"}),t.jsx("p",Object.assign({className:"text-sm font-medium truncate max-w-[150px] text-foreground"},{children:e}))]}))})),g=({text:n,className:r,onRename:o,onDelete:i})=>{const[a,l]=s.useState(!1),[c,u]=s.useState(!1),[m,f]=s.useState(n),[b,j]=s.useState(!1),v=s.useRef(null),g=s.useRef(null);s.useEffect((()=>{c||f(n)}),[n,c]),s.useEffect((()=>{const e=e=>{g.current&&!g.current.contains(e.target)&&l(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const w=()=>e.__awaiter(void 0,void 0,void 0,(function*(){m.trim()&&(j(!0),yield o(m),j(!1),u(!1))})),y=()=>{f(n),u(!1)};return t.jsxs("div",Object.assign({ref:g,className:"relative z-40 h-full"},{children:[t.jsx("div",Object.assign({className:d.default("relative flex items-center justify-center px-3 h-full shrink-0 rounded-[40px] overflow-visible transition-all duration-200 cursor-pointer group border border-white/70 bg-[#FFFFFF1A]",r),onClick:e=>{e.stopPropagation(),c||a?a&&l(!1):l(!0)}},{children:c?t.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 min-w-[140px]",onClick:e=>e.stopPropagation()},{children:[t.jsx("input",{autoFocus:!0,type:"text",value:m,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&w(),"Escape"===e.key&&y()},className:"bg-transparent border-b border-black/30 text-sm font-medium focus:outline-none w-full min-w-[80px] text-foreground"}),t.jsx("button",Object.assign({onClick:w,disabled:b,className:"p-1 rounded hover:bg-black/10 text-green-600"},{children:t.jsx(x.Check,{className:"h-4 w-4"})})),t.jsx("button",Object.assign({onClick:y,disabled:b,className:"p-1 rounded hover:bg-black/10 text-red-600"},{children:t.jsx(x.X,{className:"h-4 w-4"})}))]})):t.jsxs("div",Object.assign({className:"flex items-center gap-2 z-20 max-w-[200px]"},{children:[t.jsx("p",Object.assign({className:"text-sm font-medium truncate text-foreground"},{children:n})),t.jsx(x.MoreHorizontal,{className:d.default("h-4 w-4 opacity-50 group-hover:opacity-100 transition-opacity")})]}))})),a&&t.jsxs("div",Object.assign({className:"absolute top-full right-0 mt-2 w-48 shadow-xl z-50 rounded-[16px] border border-white/70 bg-neutral-50 backdrop-blur-md overflow-hidden animate-in fade-in zoom-in-95 duration-100",ref:v},{children:[t.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),l(!1),u(!0)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors border-b border-white/10 hover:bg-white/10"},{children:[t.jsx(p.default,{className:"h-4 w-4"}),t.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Rename chat"}))]})),t.jsxs("button",Object.assign({onClick:e=>{e.stopPropagation(),l(!1),i()},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors hover:bg-white/10"},{children:[t.jsx(h.default,{className:"h-4 w-4"}),t.jsx("span",Object.assign({className:"font-medium text-sm"},{children:"Delete chat"}))]}))]}))]}))};exports.default=()=>{const{deploymentType:x,isNewChat:h,setIsNewChat:p,sessionId:w,setSessionId:y,pickaxeId:k,sender:N,colors:O,styles:C,pickaxe:F,isEmbed:D}=n.usePickaxeContext(),{isSent:_}=r.useAuthContext(),{width:I,height:S,setDimension:q}=o.useDimensionContext(),{setDocuments:E,onFileUpload:P}=i.useDocument(),{isGenerating:z}=b.useResponseContext(),A=a.useStyleFontSize(),[R,T]=s.useState(0),[H,L]=s.useState(!1),[M,B]=s.useState(!1),G=s.useRef(null),K=s.useRef(null),U=s.useRef(0),[X,J]=s.useState(null),[Q,V]=s.useState(!1),W="chat-input"===x&&h&&!_;s.useEffect((()=>()=>{E([])}),[]);const Y=s.useCallback((()=>{if(!k||!N)return;const t=(s=0)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e;try{const t=yield m.default.post("/get_pickaxe_conversation",{sessionId:w,userId:N});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void $(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}s<20&&setTimeout((()=>t(s+1)),3e3)}));t()}),[k,N,w]);s.useEffect((()=>{z||h||!w||Y()}),[z,h,w,Y]),s.useEffect((()=>{if(!G.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;q(parseInt(e.toFixed(0)),parseInt(s.toFixed(0)))}}));return e.observe(G.current),()=>{e.disconnect()}}),[G.current]);const[Z,$]=s.useState("New Chat"),ee=(null==F?void 0:F.formtitle)||"Pickaxe",te=(null==F?void 0:F.coverphoto)||void 0,se=!W&&!D;return t.jsxs("div",Object.assign({ref:G,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),U.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&B(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),U.current-=1,0===U.current&&B(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e.__awaiter(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),B(!1),U.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(p(!1),yield P(e))}))},{children:[M&&t.jsxs("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[t.jsx("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:t.jsx(u.default,{className:"h-10 w-10"})})),t.jsx("h3",Object.assign({className:d.default(A.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),t.jsx("p",Object.assign({className:d.default(A.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),W?t.jsx(c.default,{}):t.jsxs(t.Fragment,{children:[t.jsxs("div",Object.assign({className:d.default("flex flex-col w-full items-center h-full relative z-0",se?"pt-6":"")},{children:[se&&t.jsx("div",Object.assign({className:"w-full max-w-3xl px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500"},{children:t.jsxs(j,Object.assign({colors:O,styles:C},{children:[t.jsx(v,{text:ee,icon:te,colors:O,styles:C}),h||"New Chat"===Z?t.jsx(v,{text:Z,colors:O,styles:C}):t.jsx(g,{text:Z,sessionId:w,colors:O,styles:C,onRename:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(w)try{yield m.default.post("/edit_conversation_name",{sessionId:w,name:t,userId:N}),$(t)}catch(e){console.error("Error renaming chat:",e),alert("Failed to rename chat.")}})),onDelete:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(w&&window.confirm("Are you sure you want to delete this conversation?"))try{yield m.default.post("/delete_pickaxe_conversation",{sessionId:w,userId:N}),p(!0),y(f.v4()),$("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}}))})]}))})),t.jsx(l.default,{additionalScrollHeight:R,isForceHideInfo:S<=545||I<=350||H,isInputFocused:H,onSubmit:t=>e.__awaiter(void 0,void 0,void 0,(function*(){K.current&&K.current.onSubmit(t)})),smitheryAuthData:X,resubmitPrompt:()=>{J(null),V(!0)}})]})),t.jsx(c.default,{ref:K,onFocus:()=>L(!0),onBlur:()=>L(!1),onInputHeightChange:T,initSmitheryAuthData:e=>J(e),resubmitPrompt:Q})]})]}))};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as n}from"react/jsx-runtime";import{useState as s,useRef as r,useEffect as i,useCallback as a}from"react";import{usePickaxeContext as c}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as l}from"../Addons/Auth/hooks/useAuthContext.js";import{useDimensionContext as d}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as m}from"../Addons/Document/hooks/useDocument.js";import{useStyleFontSize as u}from"../../../hooks/studio/useStyleFontSize.js";import p from"./History/index.js";import h from"./Input.js";import f from"../../Icons/attach-vertical.svg.js";import b from"../../../common/cn.js";import g from"../../../common/api/pickaxe.js";import{Check as v,X as x,MoreHorizontal as w}from"lucide-react";import{v4 as j}from"uuid";import y from"../../Icons/trash-2.svg.js";import N from"../../Icons/pencil.svg.js";import{useResponseContext as k}from"../../../hooks/pickaxe/useResponseContext.js";const O=({children:e,className:t})=>o("div",Object.assign({className:b("flex items-center gap-2 transition-all duration-200 select-none","rounded-[40px] h-[72px] border border-white/70 px-6 py-3 bg-white/10 backdrop-blur-md shadow-lg",t)},{children:e})),F=({text:e,icon:n,className:s,onClick:r})=>o("div",Object.assign({onClick:r,className:b("relative flex items-center justify-center px-3 h-full shrink-0 transition-all duration-200 rounded-[40px] border border-white/70 bg-[#FFFFFF1A]",s)},{children:t("div",Object.assign({className:"flex items-center gap-2 z-20"},{children:[n&&o("img",{src:n,alt:"",className:"h-5 w-5 rounded-full object-cover"}),o("p",Object.assign({className:"text-sm font-medium truncate max-w-[150px] text-foreground"},{children:e}))]}))})),C=({text:n,className:a,onRename:c,onDelete:l})=>{const[d,m]=s(!1),[u,p]=s(!1),[h,f]=s(n),[g,j]=s(!1),k=r(null),O=r(null);i((()=>{u||f(n)}),[n,u]),i((()=>{const e=e=>{O.current&&!O.current.contains(e.target)&&m(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const F=()=>e(void 0,void 0,void 0,(function*(){h.trim()&&(j(!0),yield c(h),j(!1),p(!1))})),C=()=>{f(n),p(!1)};return t("div",Object.assign({ref:O,className:"relative z-40 h-full"},{children:[o("div",Object.assign({className:b("relative flex items-center justify-center px-3 h-full shrink-0 rounded-[40px] overflow-visible transition-all duration-200 cursor-pointer group border border-white/70 bg-[#FFFFFF1A]",a),onClick:e=>{e.stopPropagation(),u||d?d&&m(!1):m(!0)}},{children:t("div",u?Object.assign({className:"flex items-center gap-2 z-20 min-w-[140px]",onClick:e=>e.stopPropagation()},{children:[o("input",{autoFocus:!0,type:"text",value:h,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&F(),"Escape"===e.key&&C()},className:"bg-transparent border-b border-black/30 text-sm font-medium focus:outline-none w-full min-w-[80px] text-foreground"}),o("button",Object.assign({onClick:F,disabled:g,className:"p-1 rounded hover:bg-black/10 text-green-600"},{children:o(v,{className:"h-4 w-4"})})),o("button",Object.assign({onClick:C,disabled:g,className:"p-1 rounded hover:bg-black/10 text-red-600"},{children:o(x,{className:"h-4 w-4"})}))]}):Object.assign({className:"flex items-center gap-2 z-20 max-w-[200px]"},{children:[o("p",Object.assign({className:"text-sm font-medium truncate text-foreground"},{children:n})),o(w,{className:b("h-4 w-4 opacity-50 group-hover:opacity-100 transition-opacity")})]}))})),d&&t("div",Object.assign({className:"absolute top-full right-0 mt-2 w-48 shadow-xl z-50 rounded-[16px] border border-white/70 bg-neutral-400 backdrop-blur-md overflow-hidden animate-in fade-in zoom-in-95 duration-100",ref:k},{children:[t("button",Object.assign({onClick:e=>{e.stopPropagation(),m(!1),p(!0)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors border-b border-white/10 hover:bg-white/10"},{children:[o(N,{className:"h-4 w-4"}),o("span",Object.assign({className:"font-medium text-sm"},{children:"Rename chat"}))]})),t("button",Object.assign({onClick:e=>{e.stopPropagation(),m(!1),l()},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors hover:bg-white/10"},{children:[o(y,{className:"h-4 w-4"}),o("span",Object.assign({className:"font-medium text-sm"},{children:"Delete chat"}))]}))]}))]}))},D=()=>{const{deploymentType:v,isNewChat:x,setIsNewChat:w,sessionId:y,setSessionId:N,pickaxeId:D,sender:I,colors:P,styles:z,pickaxe:A,isEmbed:E}=c(),{isSent:S}=l(),{width:_,height:R,setDimension:T}=d(),{setDocuments:H,onFileUpload:L}=m(),{isGenerating:B}=k(),G=u(),[K,U]=s(0),[q,J]=s(!1),[M,Q]=s(!1),V=r(null),W=r(null),X=r(0),[Y,Z]=s(null),[$,ee]=s(!1),te="chat-input"===v&&x&&!S;i((()=>()=>{H([])}),[]);const oe=a((()=>{if(!D||!I)return;const t=(o=0)=>e(void 0,void 0,void 0,(function*(){var e;try{const t=yield g.post("/get_pickaxe_conversation",{sessionId:y,userId:I});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void se(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}o<20&&setTimeout((()=>t(o+1)),3e3)}));t()}),[D,I,y]);i((()=>{B||x||!y||oe()}),[B,x,y,oe]),i((()=>{if(!V.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;T(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(V.current),()=>{e.disconnect()}}),[V.current]);const[ne,se]=s("New Chat"),re=(null==A?void 0:A.formtitle)||"Pickaxe",ie=(null==A?void 0:A.coverphoto)||void 0,ae=!te&&!E;return t("div",Object.assign({ref:V,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),X.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&Q(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),X.current-=1,0===X.current&&Q(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),Q(!1),X.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(w(!1),yield L(e))}))},{children:[M&&t("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[o("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:o(f,{className:"h-10 w-10"})})),o("h3",Object.assign({className:b(G.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),o("p",Object.assign({className:b(G.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),te?o(h,{}):t(n,{children:[t("div",Object.assign({className:b("flex flex-col w-full items-center h-full relative z-0",ae?"pt-6":"")},{children:[ae&&o("div",Object.assign({className:"w-full max-w-3xl px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500"},{children:t(O,Object.assign({colors:P,styles:z},{children:[o(F,{text:re,icon:ie,colors:P,styles:z}),x||"New Chat"===ne?o(F,{text:ne,colors:P,styles:z}):o(C,{text:ne,sessionId:y,colors:P,styles:z,onRename:t=>e(void 0,void 0,void 0,(function*(){if(y)try{yield g.post("/edit_conversation_name",{sessionId:y,name:t,userId:I}),se(t)}catch(e){console.error("Error renaming chat:",e),alert("Failed to rename chat.")}})),onDelete:()=>e(void 0,void 0,void 0,(function*(){if(y&&window.confirm("Are you sure you want to delete this conversation?"))try{yield g.post("/delete_pickaxe_conversation",{sessionId:y,userId:I}),w(!0),N(j()),se("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}}))})]}))})),o(p,{additionalScrollHeight:K,isForceHideInfo:R<=545||_<=350||q,isInputFocused:q,onSubmit:t=>e(void 0,void 0,void 0,(function*(){W.current&&W.current.onSubmit(t)})),smitheryAuthData:Y,resubmitPrompt:()=>{Z(null),ee(!0)}})]})),o(h,{ref:W,onFocus:()=>J(!0),onBlur:()=>J(!1),onInputHeightChange:U,initSmitheryAuthData:e=>Z(e),resubmitPrompt:$})]})]}))};export{D as default};
1
+ import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as n}from"react/jsx-runtime";import{useState as s,useRef as r,useEffect as i,useCallback as a}from"react";import{usePickaxeContext as c}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as l}from"../Addons/Auth/hooks/useAuthContext.js";import{useDimensionContext as d}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as m}from"../Addons/Document/hooks/useDocument.js";import{useStyleFontSize as u}from"../../../hooks/studio/useStyleFontSize.js";import p from"./History/index.js";import h from"./Input.js";import f from"../../Icons/attach-vertical.svg.js";import b from"../../../common/cn.js";import g from"../../../common/api/pickaxe.js";import{Check as v,X as x,MoreHorizontal as w}from"lucide-react";import{v4 as j}from"uuid";import y from"../../Icons/trash-2.svg.js";import N from"../../Icons/pencil.svg.js";import{useResponseContext as k}from"../../../hooks/pickaxe/useResponseContext.js";const O=({children:e,className:t})=>o("div",Object.assign({className:b("flex items-center gap-2 transition-all duration-200 select-none","rounded-[40px] h-[72px] border border-white/70 px-6 py-3 bg-white/10 backdrop-blur-md shadow-md",t)},{children:e})),F=({text:e,icon:n,className:s,onClick:r})=>o("div",Object.assign({onClick:r,className:b("relative flex items-center justify-center px-3 h-full shrink-0 transition-all duration-200 rounded-[40px] border border-white/70 bg-[#FFFFFF1A]",s)},{children:t("div",Object.assign({className:"flex items-center gap-2 z-20"},{children:[n&&o("img",{src:n,alt:"",className:"h-5 w-5 rounded-full object-cover"}),o("p",Object.assign({className:"text-sm font-medium truncate max-w-[150px] text-foreground"},{children:e}))]}))})),C=({text:n,className:a,onRename:c,onDelete:l})=>{const[d,m]=s(!1),[u,p]=s(!1),[h,f]=s(n),[g,j]=s(!1),k=r(null),O=r(null);i((()=>{u||f(n)}),[n,u]),i((()=>{const e=e=>{O.current&&!O.current.contains(e.target)&&m(!1)};return document.addEventListener("mousedown",e),()=>document.removeEventListener("mousedown",e)}),[]);const F=()=>e(void 0,void 0,void 0,(function*(){h.trim()&&(j(!0),yield c(h),j(!1),p(!1))})),C=()=>{f(n),p(!1)};return t("div",Object.assign({ref:O,className:"relative z-40 h-full"},{children:[o("div",Object.assign({className:b("relative flex items-center justify-center px-3 h-full shrink-0 rounded-[40px] overflow-visible transition-all duration-200 cursor-pointer group border border-white/70 bg-[#FFFFFF1A]",a),onClick:e=>{e.stopPropagation(),u||d?d&&m(!1):m(!0)}},{children:t("div",u?Object.assign({className:"flex items-center gap-2 z-20 min-w-[140px]",onClick:e=>e.stopPropagation()},{children:[o("input",{autoFocus:!0,type:"text",value:h,onChange:e=>f(e.target.value),onKeyDown:e=>{"Enter"===e.key&&F(),"Escape"===e.key&&C()},className:"bg-transparent border-b border-black/30 text-sm font-medium focus:outline-none w-full min-w-[80px] text-foreground"}),o("button",Object.assign({onClick:F,disabled:g,className:"p-1 rounded hover:bg-black/10 text-green-600"},{children:o(v,{className:"h-4 w-4"})})),o("button",Object.assign({onClick:C,disabled:g,className:"p-1 rounded hover:bg-black/10 text-red-600"},{children:o(x,{className:"h-4 w-4"})}))]}):Object.assign({className:"flex items-center gap-2 z-20 max-w-[200px]"},{children:[o("p",Object.assign({className:"text-sm font-medium truncate text-foreground"},{children:n})),o(w,{className:b("h-4 w-4 opacity-50 group-hover:opacity-100 transition-opacity")})]}))})),d&&t("div",Object.assign({className:"absolute top-full right-0 mt-2 w-48 shadow-xl z-50 rounded-[16px] border border-white/70 bg-neutral-50 backdrop-blur-md overflow-hidden animate-in fade-in zoom-in-95 duration-100",ref:k},{children:[t("button",Object.assign({onClick:e=>{e.stopPropagation(),m(!1),p(!0)},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors border-b border-white/10 hover:bg-white/10"},{children:[o(N,{className:"h-4 w-4"}),o("span",Object.assign({className:"font-medium text-sm"},{children:"Rename chat"}))]})),t("button",Object.assign({onClick:e=>{e.stopPropagation(),m(!1),l()},className:"w-full text-left px-4 py-3 flex items-center gap-3 transition-colors hover:bg-white/10"},{children:[o(y,{className:"h-4 w-4"}),o("span",Object.assign({className:"font-medium text-sm"},{children:"Delete chat"}))]}))]}))]}))},D=()=>{const{deploymentType:v,isNewChat:x,setIsNewChat:w,sessionId:y,setSessionId:N,pickaxeId:D,sender:I,colors:P,styles:z,pickaxe:A,isEmbed:E}=c(),{isSent:S}=l(),{width:_,height:R,setDimension:T}=d(),{setDocuments:H,onFileUpload:L}=m(),{isGenerating:B}=k(),G=u(),[K,U]=s(0),[q,J]=s(!1),[M,Q]=s(!1),V=r(null),W=r(null),X=r(0),[Y,Z]=s(null),[$,ee]=s(!1),te="chat-input"===v&&x&&!S;i((()=>()=>{H([])}),[]);const oe=a((()=>{if(!D||!I)return;const t=(o=0)=>e(void 0,void 0,void 0,(function*(){var e;try{const t=yield g.post("/get_pickaxe_conversation",{sessionId:y,userId:I});if(t.data&&t.data.success){const e=t.data.title;if(e&&"Conversation Title"!==e)return void se(e)}else console.error("Failed to load conversation:",null===(e=t.data)||void 0===e?void 0:e.error)}catch(e){console.error("Error fetching conversation:",e)}o<20&&setTimeout((()=>t(o+1)),3e3)}));t()}),[D,I,y]);i((()=>{B||x||!y||oe()}),[B,x,y,oe]),i((()=>{if(!V.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;T(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(V.current),()=>{e.disconnect()}}),[V.current]);const[ne,se]=s("New Chat"),re=(null==A?void 0:A.formtitle)||"Pickaxe",ie=(null==A?void 0:A.coverphoto)||void 0,ae=!te&&!E;return t("div",Object.assign({ref:V,className:"relative flex h-full w-full flex-col items-center overflow-hidden",onDragEnter:e=>{e.preventDefault(),e.stopPropagation(),X.current+=1,e.dataTransfer.items&&e.dataTransfer.items.length>0&&Q(!0)},onDragLeave:e=>{e.preventDefault(),e.stopPropagation(),X.current-=1,0===X.current&&Q(!1)},onDragOver:e=>{e.preventDefault(),e.stopPropagation()},onDrop:t=>e(void 0,void 0,void 0,(function*(){t.preventDefault(),t.stopPropagation(),Q(!1),X.current=0;const e=Array.from(t.dataTransfer.files||[]);e.length>0&&(w(!1),yield L(e))}))},{children:[M&&t("div",Object.assign({className:"absolute inset-0 z-50 flex flex-col items-center justify-center rounded-lg bg-white/80 backdrop-blur-sm transition-all duration-300"},{children:[o("div",Object.assign({className:"flex h-24 w-24 items-center justify-center rounded-full bg-white shadow-lg animate-bounce text-black"},{children:o(f,{className:"h-10 w-10"})})),o("h3",Object.assign({className:b(G.h3,"mt-6 font-semibold text-c-primary text-black")},{children:"Drop files to upload"})),o("p",Object.assign({className:b(G.b2,"mt-2 opacity-60 text-black")},{children:"Add anything to the conversation"}))]})),te?o(h,{}):t(n,{children:[t("div",Object.assign({className:b("flex flex-col w-full items-center h-full relative z-0",ae?"pt-6":"")},{children:[ae&&o("div",Object.assign({className:"w-full max-w-3xl px-4 md:px-0 flex justify-start z-30 mb-4 animate-in fade-in slide-in-from-top-4 duration-500"},{children:t(O,Object.assign({colors:P,styles:z},{children:[o(F,{text:re,icon:ie,colors:P,styles:z}),x||"New Chat"===ne?o(F,{text:ne,colors:P,styles:z}):o(C,{text:ne,sessionId:y,colors:P,styles:z,onRename:t=>e(void 0,void 0,void 0,(function*(){if(y)try{yield g.post("/edit_conversation_name",{sessionId:y,name:t,userId:I}),se(t)}catch(e){console.error("Error renaming chat:",e),alert("Failed to rename chat.")}})),onDelete:()=>e(void 0,void 0,void 0,(function*(){if(y&&window.confirm("Are you sure you want to delete this conversation?"))try{yield g.post("/delete_pickaxe_conversation",{sessionId:y,userId:I}),w(!0),N(j()),se("New Chat")}catch(e){console.error("Error deleting chat:",e),alert("Failed to delete chat.")}}))})]}))})),o(p,{additionalScrollHeight:K,isForceHideInfo:R<=545||_<=350||q,isInputFocused:q,onSubmit:t=>e(void 0,void 0,void 0,(function*(){W.current&&W.current.onSubmit(t)})),smitheryAuthData:Y,resubmitPrompt:()=>{Z(null),ee(!0)}})]})),o(h,{ref:W,onFocus:()=>J(!0),onBlur:()=>J(!1),onInputHeightChange:U,initSmitheryAuthData:e=>Z(e),resubmitPrompt:$})]})]}))};export{D as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "6.0.1-0",
3
+ "version": "6.0.1-2",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",