@pickaxeproject/react 1.1.2 → 1.1.4
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.
- package/dist/cjs/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/History/Response.js +1 -1
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/A/index.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Item.js +1 -1
- package/dist/esm/components/Pickaxe/Form/History/Response.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/A/index.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleFontSize.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../Addons/Document/hooks/useDocument.js"),t=require("date-fns"),i=require("../../common/PickaxeMarkdown/index.js"),l=require("../../common/PickaxeMarkdown/Renderer.js"),r=require("../../../Icons/message-square-notes.svg.js"),c=require("../../../Icons/visitor.svg.js"),d=require("../../common/PickaxeIcon.js"),u=require("../../common/PickaxeSimpleButton.js"),m=require("../../common/PickaxeCopyButton.js"),x=require("../../../../common/cn.js");exports.default=({item:h})=>{const{pickaxe:p,styles:j,colors:f,misc:v,translations:g,setChatId:b,setIsNewChat:k}=o.usePickaxeContext(),y=a.useStyleFontSize(),{upsertDocuments:w}=n.useDocument(),N=s.useMemo((()=>t.format(h.createdAt,"hh:mm a MMM dd, yy")),[h]),q=s.useMemo((()=>h&&h.messages?h.messages.length:0),[h]),O=s.useMemo((()=>{var e,s,o,a;if("form"===h.type){return(null!==(e=h.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}return null!==(a=null===(o=null===(s=h.messages)||void 0===s?void 0:s[0])||void 0===o?void 0:o.message)&&void 0!==a?a:""}),[h]),C=s.useMemo((()=>{var e,s,o,a;return"form"===h.type?null!==(e=h.questionResponse)&&void 0!==e?e:"":null!==(a=null===(o=null===(s=h.messages)||void 0===s?void 0:s[1])||void 0===o?void 0:o.message)&&void 0!==a?a:""}),[h]);return e.jsxs("div",Object.assign({className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsxs("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:f.primary,color:f.text}},{children:[e.jsx("div",Object.assign({className:"shrink-0 pt-1"},{children:e.jsx(c.default,{className:"h-6 w-6"})})),e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-1.5 scrollbar-track-gray-100 scrollbar-thumb-[#4A4A4B] lg:max-w-[520px] lg:scrollbar-thin"},{children:[e.jsx("input",{id:`${h.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:O.length<280}),e.jsx("div",{className:"danger-html hidden flex-col peer-checked:flex",dangerouslySetInnerHTML:{__html:O}}),e.jsx("label",Object.assign({htmlFor:`${h.responseId}-input`,className:x.default(y.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold peer-checked:hidden hover:cursor-pointer"),style:{color:f.accent}},{children:(null==g?void 0:g["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${h.responseId}-input`,className:x.default(y.b3,"hidden shrink-0 whitespace-nowrap font-semibold peer-checked:flex hover:cursor-pointer"),style:{color:f.accent}},{children:(null==g?void 0:g["hide-input"])||"Hide input"}))]}))]})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:f.secondary,color:f.secondaryText}},{children:[v.isChatImage&&e.jsx(d.default,{src:null==p?void 0:p.chaticon,alt:`${null==p?void 0:p.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:f.secondaryText}),e.jsxs("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[e.jsx(i.PickaxeMarkdown,Object.assign({theme:j.theme,accentColor:f.accent,linkPreviews:!0,actions:!0},{children:e.jsx(l.PickaxeMarkdownRenderer,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:C})})),e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==p?void 0:p.enablechatresponses)&&e.jsxs(u.default,Object.assign({color:f.accent,onClick:()=>{return e=h.responseId,w([]),k(!1),void b(e);var e}},{children:[e.jsx(r.default,{className:"h-4 w-4 shrink-0"}),e.jsx("p",Object.assign({className:x.default(y.b3,"font-semibold")},{children:q+1}))]})),e.jsx(m.default,{color:f.accent,text:C})]})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:x.default(y.b3,"font-semibold uppercase opacity-30")},{children:N}))}))]}))]}))]}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../Addons/Scroll/hooks/useScrollContext.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),l=require("../../Addons/Document/hooks/useDocument.js"),a=require("date-fns"),i=require("../../common/PickaxeMarkdown/index.js"),c=require("../../common/PickaxeMarkdown/Renderer.js"),d=require("../../../Icons/message-square-notes.svg.js"),u=require("../../../Icons/visitor.svg.js"),x=require("../../common/PickaxeIcon.js"),h=require("../../common/PickaxeSimpleButton.js"),m=require("../../common/PickaxeCopyButton.js"),p=require("../../Addons/Scroll/ScrollLockView.js"),j=require("../../../../common/cn.js");exports.default=()=>{var f;const{pickaxe:b,styles:g,colors:k,misc:v,translations:y,setChatId:w,setIsNewChat:q}=o.usePickaxeContext(),{response:N}=t.useResponseContext(),{scrollTargetRef:C,scrollContainerRef:O}=n.useScrollContext(),M=r.useStyleFontSize(),{upsertDocuments:I}=l.useDocument(),S=s.useMemo((()=>N?a.format(N.createdAt,"hh:mm a MMM dd, yy"):a.format(new Date,"hh:mm a MMM dd, yy")),[N]),P=s.useMemo((()=>{var e;if(!N)return"";return(null!==(e=N.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[N]);return N?e.jsxs("div",Object.assign({ref:C,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e.jsxs("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:k.primary,color:k.text}},{children:[e.jsx("div",Object.assign({className:"shrink-0 pt-1"},{children:e.jsx(u.default,{className:"h-6 w-6"})})),e.jsxs("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[e.jsx("input",{id:`${N.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:P.length<280}),e.jsx("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:P}}),e.jsx("label",Object.assign({htmlFor:`${N.responseId}-input`,className:j.default(M.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:k.accent}},{children:(null==y?void 0:y["see-input"])||"See input"})),e.jsx("label",Object.assign({htmlFor:`${N.responseId}-input`,className:j.default(M.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:k.accent}},{children:(null==y?void 0:y["hide-input"])||"Hide input"}))]}))]})),e.jsxs("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[v.isChatImage&&e.jsx(x.default,{src:null==b?void 0:b.chaticon,alt:`${null==b?void 0:b.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:k.secondaryText}),e.jsxs("div",Object.assign({ref:O,className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[e.jsx(i.PickaxeMarkdown,Object.assign({theme:g.theme,accentColor:k.accent,linkPreviews:!0,actions:!0},{children:e.jsx(c.PickaxeMarkdownRenderer,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:N.questionResponse})})),e.jsxs("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==b?void 0:b.enablechatresponses)&&e.jsxs(h.default,Object.assign({color:k.accent,onClick:()=>{return e=N.responseId,I([]),q(!1),void w(e);var e}},{children:[e.jsx(d.default,{className:"h-4 w-4 shrink-0"}),e.jsx("p",Object.assign({className:j.default(M.b3,"font-semibold")},{children:N.messages.length+1}))]})),e.jsx(m.default,{color:k.accent,text:null!==(f=N.questionResponse)&&void 0!==f?f:""})]})),e.jsx("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:e.jsx("p",Object.assign({className:j.default(M.b3,"font-semibold uppercase opacity-30")},{children:S}))}))]}))]}))]})),e.jsx(p.default,{className:"w-full"})]})):null};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("./Addons/Document/Provider.js"),i=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");const o=t.createContext({});exports.PickaxeContext=o,exports.PickaxeProvider=({children:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("./Addons/Document/Provider.js"),i=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");const o=t.createContext({});exports.PickaxeContext=o,exports.PickaxeProvider=({children:n,userId:a="",studioUserId:d="",deploymentId:c="",styles:l,colors:u,limits:h={},misc:p={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:F,chatInput:m="",responsiveBy:I="viewport",loadFont:x=!0,forceMobile:y=!1,isEmbed:S=!1,onGenerateComplete:f})=>{const[g,j]=t.useState(""),[b,v]=t.useState(""),[P,w]=t.useState(null),[C,k]=t.useState(!1),[O,q]=t.useState(!0),[D,H]=t.useState(!0),[B,E]=t.useState(!1);return t.useEffect((()=>{k(!1)}),[null==l?void 0:l.font]),e.jsx(o.Provider,Object.assign({value:Object.assign({formId:g,chatId:b,userId:a,studioUserId:d,deploymentId:c,pickaxe:P,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},l),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},u),misc:p,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..."},F),chatInput:m,responsiveBy:I,isFontLoaded:C,isNewChat:O,isShowIceBreaker:D,isShowHistory:B,loadFont:x,forceMobile:y,isEmbed:S,setIsFontLoaded:k,setFormId:j,setChatId:v,setPickaxe:w,setIsNewChat:q,setIsShowIceBreaker:H,setIsShowHistory:E},f&&{onGenerateComplete:f})},{children:e.jsx(i.default,Object.assign({limits:h},{children:e.jsx(r.default,{children:e.jsx(s.default,{children:n})})}))}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),s=require("@tanstack/react-query"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),r=require("react"),s=require("@tanstack/react-query"),a=require("../../hooks/usePickaxeMarkdownContext.js"),i=require("../common/Action.js"),o=require("../Img/index.js"),n=require("../common/Audio.js"),u=require("../common/Html/index.js"),l=require("../../../../../../common/api/utils.js"),c=require("../../../../../../common/error.js");exports.default=({node:d,href:f="",children:p})=>{const{accentColor:m,websiteMetadatas:h,linkPreviews:w,actions:j,setWebsiteMetadatas:x}=a.usePickaxeMarkdownContext(),[b,v]=r.useState("");r.useEffect((()=>{if(!f)return;const e=f.startsWith("http://")?`https://${f.slice(7)}`:f.startsWith("www.")?`https://${f}`:f;e!==b&&v(e)}),[f,b]),s.useQuery({queryKey:["website-metadata",b],queryFn:()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const r=yield(t=b,e.__awaiter(void 0,void 0,void 0,(function*(){try{if("development"===process.env.NODE_ENV&&console.log("[getWebsiteMetadata]",t),!t||!t.startsWith("https")||!t.includes("."))return null;if(["/api/fn/result","/api/function_call_results","https://prod-pickaxe-assets.s3.amazonaws.com"].some((e=>t.includes(e))))return null;const e=(yield l.default.get(`/metadata?url=${encodeURIComponent(t)}`)).data;if(e.error)throw new Error(e.error||"Failed to fetch metadata");return e}catch(e){if("development"===process.env.NODE_ENV){const t=c.default(e);console.error("[getJobResult]",t)}return null}})));if(!r||!r.title)throw new Error("No valid metadata");return r}catch(e){return console.warn(`Failed to fetch metadata for URL: ${b}`,e),null}var t})),enabled:"undefined"!=typeof window&&w&&Boolean(b)&&!h.some((e=>e.href===b))&&b.includes(".")&&!b.includes("https://prod-pickaxe-assets")&&!b.includes("https://pickaxeproject--v2"),retry:2,onSuccess:e=>{e&&e.title&&!h.some((t=>t.href===e.href))&&x((t=>[...t,e]))}});const y=b.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(y&&(null==y?void 0:y[1]))return t.jsx("div",Object.assign({className:"pxe-markdown-youtube",style:{display:"flex",width:"100%",justifyContent:"center"}},{children:t.jsx("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${y[1]}`,style:{width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));if(b.match(/\.(jpeg|jpg|gif|bmp|webp|svg|tiff|avif|png|jfif|pjpeg|pjp)$/))return t.jsx(o.default,{src:b,alt:"string"==typeof p?p:"Markdown Image"});if(b.match(/\.(mp3|wav|ogg|flac|aac|wma|alac|m4a|aiff|ape|au|mid|midi|opus)$/))return t.jsx(n.default,{url:b});return b.includes("action_generated_files")&&b.match(/\.html$/)?t.jsx(u.default,{url:b}):j&&b.includes("pickaxe")&&(b.includes("/api/fn/result")||b.includes("/api/function_call_results"))?t.jsx(i.default,{jobUrl:b}):t.jsx("a",Object.assign({href:b,target:"_blank",rel:"noopener noreferrer",style:{color:m}},{children:p}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as i}from"../../Addons/Document/hooks/useDocument.js";import{format as
|
|
1
|
+
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as o}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as i}from"../../Addons/Document/hooks/useDocument.js";import{format as l}from"date-fns";import{PickaxeMarkdown as r}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as a}from"../../common/PickaxeMarkdown/Renderer.js";import c from"../../../Icons/message-square-notes.svg.js";import m from"../../../Icons/visitor.svg.js";import d from"../../common/PickaxeIcon.js";import p from"../../common/PickaxeSimpleButton.js";import h from"../../common/PickaxeCopyButton.js";import u from"../../../../common/cn.js";const f=({item:f})=>{const{pickaxe:g,styles:v,colors:x,misc:b,translations:j,setChatId:y,setIsNewChat:k}=t(),w=n(),{upsertDocuments:N}=i(),O=o((()=>l(f.createdAt,"hh:mm a MMM dd, yy")),[f]),C=o((()=>f&&f.messages?f.messages.length:0),[f]),I=o((()=>{var e,s,o,t;if("form"===f.type){return(null!==(e=f.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}return null!==(t=null===(o=null===(s=f.messages)||void 0===s?void 0:s[0])||void 0===o?void 0:o.message)&&void 0!==t?t:""}),[f]),P=o((()=>{var e,s,o,t;return"form"===f.type?null!==(e=f.questionResponse)&&void 0!==e?e:"":null!==(t=null===(o=null===(s=f.messages)||void 0===s?void 0:s[1])||void 0===o?void 0:o.message)&&void 0!==t?t:""}),[f]);return e("div",Object.assign({className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:x.primary,color:x.text}},{children:[s("div",Object.assign({className:"shrink-0 pt-1"},{children:s(m,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-1.5 scrollbar-track-gray-100 scrollbar-thumb-[#4A4A4B] lg:max-w-[520px] lg:scrollbar-thin"},{children:[s("input",{id:`${f.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:I.length<280}),s("div",{className:"danger-html hidden flex-col peer-checked:flex",dangerouslySetInnerHTML:{__html:I}}),s("label",Object.assign({htmlFor:`${f.responseId}-input`,className:u(w.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold peer-checked:hidden hover:cursor-pointer"),style:{color:x.accent}},{children:(null==j?void 0:j["see-input"])||"See input"})),s("label",Object.assign({htmlFor:`${f.responseId}-input`,className:u(w.b3,"hidden shrink-0 whitespace-nowrap font-semibold peer-checked:flex hover:cursor-pointer"),style:{color:x.accent}},{children:(null==j?void 0:j["hide-input"])||"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:x.secondary,color:x.secondaryText}},{children:[b.isChatImage&&s(d,{src:null==g?void 0:g.chaticon,alt:`${null==g?void 0:g.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:x.secondaryText}),e("div",Object.assign({className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[s(r,Object.assign({theme:v.theme,accentColor:x.accent,linkPreviews:!0,actions:!0},{children:s(a,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:P})})),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==g?void 0:g.enablechatresponses)&&e(p,Object.assign({color:x.accent,onClick:()=>{return e=f.responseId,N([]),k(!1),void y(e);var e}},{children:[s(c,{className:"h-4 w-4 shrink-0"}),s("p",Object.assign({className:u(w.b3,"font-semibold")},{children:C+1}))]})),s(h,{color:x.accent,text:P})]})),s("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:s("p",Object.assign({className:u(w.b3,"font-semibold uppercase opacity-30")},{children:O}))}))]}))]}))]}))]}))};export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useMemo as s}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as
|
|
1
|
+
import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useMemo as s}from"react";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as n}from"../../../../hooks/pickaxe/useResponseContext.js";import{useScrollContext as r}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as i}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as l}from"../../Addons/Document/hooks/useDocument.js";import{format as c}from"date-fns";import{PickaxeMarkdown as a}from"../../common/PickaxeMarkdown/index.js";import{PickaxeMarkdownRenderer as m}from"../../common/PickaxeMarkdown/Renderer.js";import d from"../../../Icons/message-square-notes.svg.js";import p from"../../../Icons/visitor.svg.js";import h from"../../common/PickaxeIcon.js";import f from"../../common/PickaxeSimpleButton.js";import u from"../../common/PickaxeCopyButton.js";import x from"../../Addons/Scroll/ScrollLockView.js";import g from"../../../../common/cn.js";const b=()=>{var b;const{pickaxe:v,styles:j,colors:k,misc:y,translations:w,setChatId:N,setIsNewChat:C}=t(),{response:O}=n(),{scrollTargetRef:I,scrollContainerRef:S}=r(),D=i(),{upsertDocuments:P}=l(),M=s((()=>c(O?O.createdAt:new Date,"hh:mm a MMM dd, yy")),[O]),R=s((()=>{var e;if(!O)return"";return(null!==(e=O.questions)&&void 0!==e?e:[]).map((e=>`<div style="display: flex; flex-direction: column; margin-bottom: 1em;">\n <p style="font-weight: 500;">${e.question}</p>\n <p>${e.answer||"n/a"}</p>\n</div>`)).join("")}),[O]);return O?e("div",Object.assign({ref:I,className:"flex flex-col shadow-black transition duration-300 hover:shadow"},{children:[e("div",Object.assign({className:"flex gap-x-3 overflow-hidden px-4 py-5",style:{backgroundColor:k.primary,color:k.text}},{children:[o("div",Object.assign({className:"shrink-0 pt-1"},{children:o(p,{className:"h-6 w-6"})})),e("div",Object.assign({className:"flex flex-col gap-y-1 overflow-x-auto pb-[6px] scrollbar scrollbar-thin"},{children:[o("input",{id:`${O.responseId}-input`,type:"checkbox",className:"peer hidden",defaultChecked:R.length<280}),o("div",{className:"danger-html hidden flex-col opacity-50 peer-checked:flex",dangerouslySetInnerHTML:{__html:R}}),o("label",Object.assign({htmlFor:`${O.responseId}-input`,className:g(D.b3,"mt-1 flex shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:hidden hover:cursor-pointer"),style:{color:k.accent}},{children:(null==w?void 0:w["see-input"])||"See input"})),o("label",Object.assign({htmlFor:`${O.responseId}-input`,className:g(D.b3,"hidden shrink-0 whitespace-nowrap font-semibold text-[#228DD7] peer-checked:flex hover:cursor-pointer"),style:{color:k.accent}},{children:(null==w?void 0:w["hide-input"])||"Hide input"}))]}))]})),e("div",Object.assign({className:"flex gap-x-3 px-4 py-5",style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[y.isChatImage&&o(h,{src:null==v?void 0:v.chaticon,alt:`${null==v?void 0:v.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6 pt-1",textColor:k.secondaryText}),e("div",Object.assign({ref:S,className:"flex w-full flex-col gap-y-2 overflow-hidden"},{children:[o(a,Object.assign({theme:j.theme,accentColor:k.accent,linkPreviews:!0,actions:!0},{children:o(m,{className:"overflow-x-auto pb-2 font-semilight opacity-90 scrollbar scrollbar-thin",value:O.questionResponse})})),e("div",Object.assign({className:"flex flex-wrap items-center justify-between gap-x-3 gap-y-1"},{children:[e("div",Object.assign({className:"flex items-center gap-3"},{children:[(null==v?void 0:v.enablechatresponses)&&e(f,Object.assign({color:k.accent,onClick:()=>{return e=O.responseId,P([]),C(!1),void N(e);var e}},{children:[o(d,{className:"h-4 w-4 shrink-0"}),o("p",Object.assign({className:g(D.b3,"font-semibold")},{children:O.messages.length+1}))]})),o(u,{color:k.accent,text:null!==(b=O.questionResponse)&&void 0!==b?b:""})]})),o("div",Object.assign({className:"flex shrink-0 grow justify-end"},{children:o("p",Object.assign({className:g(D.b3,"font-semibold uppercase opacity-30")},{children:M}))}))]}))]}))]})),o(x,{className:"w-full"})]})):null};export{b as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{createContext as s,useState as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{createContext as s,useState as t,useEffect as i}from"react";import o from"./Addons/Document/Provider.js";import r from"./ResponseProvider.js";import n from"./DimensionProvider.js";const a=s({}),d=({children:s,userId:d="",studioUserId:c="",deploymentId:l="",styles:m,colors:p,limits:h={},misc:F={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:I,chatInput:u="",responsiveBy:y="viewport",loadFont:g=!0,forceMobile:f=!1,isEmbed:b=!1,onGenerateComplete:j})=>{const[v,w]=t(""),[S,x]=t(""),[P,C]=t(null),[O,k]=t(!1),[D,H]=t(!0),[B,L]=t(!0),[T,E]=t(!1);return i((()=>{k(!1)}),[null==m?void 0:m.font]),e(a.Provider,Object.assign({value:Object.assign({formId:v,chatId:S,userId:d,studioUserId:c,deploymentId:l,pickaxe:P,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},m),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},p),misc:F,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..."},I),chatInput:u,responsiveBy:y,isFontLoaded:O,isNewChat:D,isShowIceBreaker:B,isShowHistory:T,loadFont:g,forceMobile:f,isEmbed:b,setIsFontLoaded:k,setFormId:w,setChatId:x,setPickaxe:C,setIsNewChat:H,setIsShowIceBreaker:L,setIsShowHistory:E},j&&{onGenerateComplete:j})},{children:e(r,Object.assign({limits:h},{children:e(n,{children:e(o,{children:s})})}))}))};export{a as PickaxeContext,d as PickaxeProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import{useState as r,useEffect as o}from"react";import{useQuery as i}from"@tanstack/react-query";import{usePickaxeMarkdownContext as s}from"../../hooks/usePickaxeMarkdownContext.js";import
|
|
1
|
+
import{__awaiter as e}from"../../../../../../_virtual/_tslib.js";import{jsx as t}from"react/jsx-runtime";import{useState as r,useEffect as o}from"react";import{useQuery as i}from"@tanstack/react-query";import{usePickaxeMarkdownContext as s}from"../../hooks/usePickaxeMarkdownContext.js";import a from"../common/Action.js";import n from"../Img/index.js";import c from"../common/Audio.js";import l from"../common/Html/index.js";import m from"../../../../../../common/api/utils.js";import u from"../../../../../../common/error.js";const d=({node:d,href:p="",children:f})=>{const{accentColor:h,websiteMetadatas:w,linkPreviews:b,actions:g,setWebsiteMetadatas:v}=s(),[y,j]=r("");o((()=>{if(!p)return;const e=p.startsWith("http://")?`https://${p.slice(7)}`:p.startsWith("www.")?`https://${p}`:p;e!==y&&j(e)}),[p,y]),i({queryKey:["website-metadata",y],queryFn:()=>e(void 0,void 0,void 0,(function*(){try{const r=yield(t=y,e(void 0,void 0,void 0,(function*(){try{if("development"===process.env.NODE_ENV&&console.log("[getWebsiteMetadata]",t),!t||!t.startsWith("https")||!t.includes("."))return null;if(["/api/fn/result","/api/function_call_results","https://prod-pickaxe-assets.s3.amazonaws.com"].some((e=>t.includes(e))))return null;const e=(yield m.get(`/metadata?url=${encodeURIComponent(t)}`)).data;if(e.error)throw new Error(e.error||"Failed to fetch metadata");return e}catch(e){if("development"===process.env.NODE_ENV){const t=u(e);console.error("[getJobResult]",t)}return null}})));if(!r||!r.title)throw new Error("No valid metadata");return r}catch(e){return console.warn(`Failed to fetch metadata for URL: ${y}`,e),null}var t})),enabled:"undefined"!=typeof window&&b&&Boolean(y)&&!w.some((e=>e.href===y))&&y.includes(".")&&!y.includes("https://prod-pickaxe-assets")&&!y.includes("https://pickaxeproject--v2"),retry:2,onSuccess:e=>{e&&e.title&&!w.some((t=>t.href===e.href))&&v((t=>[...t,e]))}});const x=y.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(x&&(null==x?void 0:x[1]))return t("div",Object.assign({className:"pxe-markdown-youtube",style:{display:"flex",width:"100%",justifyContent:"center"}},{children:t("iframe",Object.assign({title:"youtube-embed",src:`https://www.youtube.com/embed/${x[1]}`,style:{width:"100%",maxWidth:"560px",minHeight:"315px"},allowFullScreen:!0},{children:"Iframe not supported, use a different browser."}))}));if(y.match(/\.(jpeg|jpg|gif|bmp|webp|svg|tiff|avif|png|jfif|pjpeg|pjp)$/))return t(n,{src:y,alt:"string"==typeof f?f:"Markdown Image"});if(y.match(/\.(mp3|wav|ogg|flac|aac|wma|alac|m4a|aiff|ape|au|mid|midi|opus)$/))return t(c,{url:y});return y.includes("action_generated_files")&&y.match(/\.html$/)?t(l,{url:y}):g&&y.includes("pickaxe")&&(y.includes("/api/fn/result")||y.includes("/api/function_call_results"))?t(a,{jobUrl:y}):t("a",Object.assign({href:y,target:"_blank",rel:"noopener noreferrer",style:{color:h}},{children:f}))};export{d as default};
|