@pickaxeproject/react 2.5.0 → 2.6.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.
- package/dist/cjs/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/index.js +1 -1
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeHead.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/A/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Components/P/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
- package/dist/cjs/components/Pickaxe/index.js +1 -1
- package/dist/cjs/hooks/pickaxe/usePickaxe.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/prose.css +1 -1
- package/dist/cjs/src/components/EmbedPreview/ChatInput.d.ts +9 -0
- package/dist/cjs/src/components/EmbedPreview/FAB.d.ts +10 -0
- package/dist/cjs/src/components/EmbedPreview/Inline.d.ts +5 -0
- package/dist/cjs/src/components/EmbedPreview/Popup.d.ts +10 -0
- package/dist/cjs/src/components/Pickaxe/Chat/Input.d.ts +3 -3
- package/dist/cjs/src/components/Pickaxe/Provider.d.ts +31 -5
- package/dist/cjs/src/components/Pickaxe/common/PickaxeHead.d.ts +2 -2
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Renderer.d.ts +2 -1
- package/dist/cjs/src/hooks/pickaxe/usePickaxe.d.ts +1 -0
- package/dist/cjs/src/hooks/pickaxe/usePickaxeContext.d.ts +6 -2
- package/dist/esm/components/Pickaxe/Chat/History/index.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/index.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeHead.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/A/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Components/P/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
- package/dist/esm/components/Pickaxe/index.js +1 -1
- package/dist/esm/hooks/pickaxe/usePickaxe.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/prose.css +1 -1
- package/dist/esm/src/components/EmbedPreview/ChatInput.d.ts +9 -0
- package/dist/esm/src/components/EmbedPreview/FAB.d.ts +10 -0
- package/dist/esm/src/components/EmbedPreview/Inline.d.ts +5 -0
- package/dist/esm/src/components/EmbedPreview/Popup.d.ts +10 -0
- package/dist/esm/src/components/Pickaxe/Chat/Input.d.ts +3 -3
- package/dist/esm/src/components/Pickaxe/Provider.d.ts +31 -5
- package/dist/esm/src/components/Pickaxe/common/PickaxeHead.d.ts +2 -2
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Renderer.d.ts +2 -1
- package/dist/esm/src/hooks/pickaxe/usePickaxe.d.ts +1 -0
- package/dist/esm/src/hooks/pickaxe/usePickaxeContext.d.ts +6 -2
- package/package.json +1 -1
- package/dist/cjs/src/components/Pickaxe/ui/Input/StyledAttachmentGrid.d.ts +0 -7
- package/dist/cjs/src/components/Pickaxe/ui/Input/StyledIconButton.d.ts +0 -10
- package/dist/cjs/src/components/Pickaxe/ui/Input/StyledImagePreview.d.ts +0 -12
- package/dist/cjs/src/components/Pickaxe/ui/Input/StyledInputContainer.d.ts +0 -13
- package/dist/cjs/src/components/Pickaxe/ui/Input/StyledInputWrapper.d.ts +0 -13
- package/dist/cjs/src/components/Pickaxe/ui/Input/StyledRemoveButton.d.ts +0 -13
- package/dist/cjs/src/components/Pickaxe/ui/Input/StyledTextareaWrapper.d.ts +0 -8
- package/dist/cjs/src/components/Pickaxe/ui/Message/StyledIconWrapper.d.ts +0 -11
- package/dist/cjs/src/components/Pickaxe/ui/Message/StyledMessage.d.ts +0 -10
- package/dist/cjs/src/components/Pickaxe/ui/Message/StyledMessageBubble.d.ts +0 -14
- package/dist/cjs/src/components/Pickaxe/ui/Message/StyledMessageContainer.d.ts +0 -10
- package/dist/cjs/src/components/Pickaxe/ui/StyledCopyButton.d.ts +0 -12
- package/dist/cjs/src/components/Pickaxe/ui/StyledDocumentCard.d.ts +0 -25
- package/dist/cjs/src/components/Pickaxe/ui/StyledIceBreaker.d.ts +0 -20
- package/dist/cjs/src/components/Pickaxe/ui/StyledLoadingDots.d.ts +0 -9
- package/dist/cjs/src/components/Pickaxe/ui/index.d.ts +0 -20
- package/dist/cjs/src/components/Pickaxe/ui/types.d.ts +0 -5
- package/dist/esm/src/components/Pickaxe/ui/Input/StyledAttachmentGrid.d.ts +0 -7
- package/dist/esm/src/components/Pickaxe/ui/Input/StyledIconButton.d.ts +0 -10
- package/dist/esm/src/components/Pickaxe/ui/Input/StyledImagePreview.d.ts +0 -12
- package/dist/esm/src/components/Pickaxe/ui/Input/StyledInputContainer.d.ts +0 -13
- package/dist/esm/src/components/Pickaxe/ui/Input/StyledInputWrapper.d.ts +0 -13
- package/dist/esm/src/components/Pickaxe/ui/Input/StyledRemoveButton.d.ts +0 -13
- package/dist/esm/src/components/Pickaxe/ui/Input/StyledTextareaWrapper.d.ts +0 -8
- package/dist/esm/src/components/Pickaxe/ui/Message/StyledIconWrapper.d.ts +0 -11
- package/dist/esm/src/components/Pickaxe/ui/Message/StyledMessage.d.ts +0 -10
- package/dist/esm/src/components/Pickaxe/ui/Message/StyledMessageBubble.d.ts +0 -14
- package/dist/esm/src/components/Pickaxe/ui/Message/StyledMessageContainer.d.ts +0 -10
- package/dist/esm/src/components/Pickaxe/ui/StyledCopyButton.d.ts +0 -12
- package/dist/esm/src/components/Pickaxe/ui/StyledDocumentCard.d.ts +0 -25
- package/dist/esm/src/components/Pickaxe/ui/StyledIceBreaker.d.ts +0 -20
- package/dist/esm/src/components/Pickaxe/ui/StyledLoadingDots.d.ts +0 -9
- package/dist/esm/src/components/Pickaxe/ui/index.d.ts +0 -20
- package/dist/esm/src/components/Pickaxe/ui/types.d.ts +0 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../../hooks/pickaxe/useDimensionContext.js"),i=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../../../hooks/pickaxe/useConversation.js"),r=require("../../common/PickaxeIcon.js"),c=require("../../../Core/ErrorAlert.js"),d=require("../../../Core/Skeleton.js"),u=require("../../Addons/Scroll/ScrollLockView.js"),x=require("../../common/PickaxeHead.js"),m=require("../../common/PickaxeCompactHead.js"),f=require("../../common/PickaxeUpgradeCard.js"),j=require("./Message.js"),h=require("../../common/PickaxeBranding.js"),p=require("../../../../common/cn.js");exports.default=({hideInfo:g,isInputFocused:v})=>{var w;const N=n.useConversation(),b=o.useStyleFontSize(),{pickaxe:k,colors:y,misc:C,isNewChat:O,isRtl:q,isEmbed:S,setChatId:P}=a.usePickaxeContext(),{scrollContainerRef:I}=i.useScrollContext(),{messages:E,status:L,limitData:M,error:A}=t.useResponseContext(),{height:D}=l.useDimensionContext(),H=s.useMemo((()=>!!N.data&&!(N.data.messages.length<=1)),[N.data]),R=s.useMemo((()=>!g&&N.isSuccess&&O&&!H),[g,N.isSuccess,O,H]),z=s.useMemo((()=>{var e,s;return!!E.length&&!(null!==(s=null===(e=null==E?void 0:E[E.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[E]);return e.jsx("div",Object.assign({ref:I,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-8",style:{height:`calc(${D}px - 74px)`}},{children:e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px] px-4"},{children:[(R||!S)&&!C.isWhiteLabel&&e.jsx(h.default,{className:p.default("absolute top-4 right-4",!R&&!S&&"top-2"),animateHover:!0}),e.jsx(x.default,{className:p.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",R&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500,onIconClick:()=>P("")}),S&&!N.isLoading&&e.jsx(m.default,{className:p.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full",!R&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",onIconClick:()=>P("")}),e.jsx("div",Object.assign({className:p.default("flex flex-col mt-6 transition-all duration-300 ease-in-out w-full",S&&!N.isLoading&&!R&&"mt-0")},{children:N.isLoading&&!(null==k?void 0:k.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[O&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(d.default,{className:"w-[72px] h-[72px]"}),e.jsx(d.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(d.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(d.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(d.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(d.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(d.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):N.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:p.default(b.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):N.data?e.jsxs("div",Object.assign({className:"flex flex-col w-full"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[N.data.messages.map(((s,a)=>e.jsx(j.default,Object.assign({index:a,message:s},0===a&&{isIntroExpand:v}),a))),E.map(((s,a)=>e.jsx(j.default,{index:N.data.messages.length+a,message:s},a))),"fetching"===L||z?e.jsx("div",Object.assign({className:p.default("flex w-full",q?"justify-end":"justify-start")},{children:e.jsx("div",Object.assign({className:"flex flex-col"},{children:e.jsxs("div",Object.assign({className:p.default("flex gap-x-3",q&&"flex-row-reverse")},{children:["NONE"!==(null==k?void 0:k.chaticon)&&e.jsx(r.default,{src:null!==(w=null==k?void 0:k.chaticon)&&void 0!==w?w:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==k?void 0:k.formid}.png`,alt:`${null==k?void 0:k.formtitle}'s Chat Icon`,width:24,height:24,className:"my-3 h-6 w-6",textColor:y.text}),e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded px-2"},{children:Array.from({length:3}).map(((s,a)=>e.jsx("div",{className:p.default("h-1.5 w-1.5 animate-dot rounded-full",1===a&&"animate-dot-down"),style:{backgroundColor:y.secondaryText}},a)))}))]}))}))})):M?e.jsx("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e.jsx(f.default,{})})):A?e.jsx("div",Object.assign({className:p.default("flex items-center gap-x-3",q?"justify-end":"justify-start")},{children:e.jsx(c.default,{error:A})})):null]})),e.jsx(u.default,{className:"w-full"})]})):null}))]}))}))};
|
|
@@ -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"),
|
|
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"),b=require("../../Icons/x.svg.js"),j=require("../../Icons/arrow-right.svg.js"),v=require("../Addons/IceBreaker/index.js"),y=require("../../Core/Textarea.js"),k=require("../../../common/error.js"),w=require("../../../common/cn.js");exports.default=({isFocused:I,onFocus:N,onBlur:O})=>{var C;const{formId:q,chatId:S,userId:R,studioUserId:T,embedUserId:_,deploymentId:A,deploymentType:F,pickaxe:B,styles:D,colors:U,responsiveBy:H,isNewChat:E,isRtl:z,setIsNewChat:M,setIsShowIceBreaker:P,onGenerateComplete:L}=r.usePickaxeContext(),{messages:$,status:G,limits:J,isGenerating:K,setMessages:W,setStatus:Q,setLimitData:V,setError:X}=o.useResponseContext(),{documents:Y,isUploading:Z,isImageUploadAllowed:ee,setDocuments:se,onFileUpload:te}=d.useDocument(),{scrollStartSession:re,scrollEndSession:oe,scrollToBottom:le}=c.useScroll({auto:!0}),ae=i.useConversation(),ie=n.useSubmit(),[ne,de]=t.useState(""),ce=t.useRef(null),ue=u.useHover(),{isHover:me}=ue,fe=e.__rest(ue,["isHover"]),xe=u.useHover(),{isHover:pe}=xe,he=e.__rest(xe,["isHover"]),ge=a.useStyleFontSize(),be=l.useStyleInput(),je=t.useMemo((()=>{var e,s,t;return!!E&&(!!B&&(!ae.isLoading&&(!((null!==(s=null===(e=ae.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=B.icebreakers)||void 0===t?void 0:t.length))))}),[B,E,ae.data,ae.isLoading]),ve=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if("idle"!==G||Z)return;const e=null!=s?s:ne;if(!e)return;X(""),V(null),de(""),M(!1),Q("fetching"),re(),le();const t=Y.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),r=t.length?t[t.length-1].documentId:"",o="enduserupload"===(null==B?void 0:B.documentuploadtype)&&r,l=[...Array.from($),Object.assign({id:$.length+1,role:"user",content:e},o&&{documentIds:[r]})];W(l),le(),o&&se([]);const a=(yield ie.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:q,responseId:S,value:e},o&&{documentId:r}),R&&{userId:R}),T&&{studioUserId:T}),_&&{embedUserId:_}),A&&{deploymentId:A}))).body;if(!a)throw new Error("Streaming error");const i=l.length,n=new TextDecoder,d=a.getReader();let c="",u=!0,m=!1;const f=x.createParser({onEvent:e=>{if("delta"===e.event){const s=JSON.parse(e.data).token.replace(/\u200B/g,"");c+=s,W([...l.slice(0,i),{id:$.length+1,role:"assistant",content:c}])}else if("error"===e.event){const s=JSON.parse(e.data);X(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(u=!1)}});for(;u;){const{value:e,done:s}=yield d.read();if(s){u=!1;break}const t=n.decode(e);t&&(m||(Q("streaming"),m=!0),f.feed(t))}null==L||L(S)}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(J).find((([e])=>s.includes(e)));t?V(t[1]):X(s)}finally{le(),Q("idle"),oe()}}));return t.useEffect((()=>{P(je)}),[je]),s.jsx("div",Object.assign({className:w.default("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===F&&E)&&"px-4 pb-4"),dir:z?"rtl":"ltr"},{children:s.jsxs("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===F&&E)&&s.jsx("div",Object.assign({className:w.default("absolute bottom-full",z?"left-0":"right-0")},{children:s.jsx("div",Object.assign({className:w.default("flex flex-col gap-2 pb-4 px-2",z?"justify-start":"justify-end","viewport"===H?z?"min-[767px]:items-start":"min-[767px]:items-end":z?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:je&&!I&&s.jsx(v.default,{data:(null==B?void 0:B.icebreakers)||[],onSend:ve})}))})),s.jsxs("div",Object.assign({className:w.default("flex flex-col gap-y-2 px-4 py-3","block"===D.formFieldStyle&&"shadow"),style:be},{children:["idle"===G&&Y.length>0&&s.jsx("div",Object.assign({className:w.default("grid grid-cols-1","viewport"===H?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:Y.map((e=>{var r,o,l;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:w.default("relative gap-x-[10px] flex items-center px-2 h-[56px] border",z&&"flex-row-reverse"),style:{borderRadius:be.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:be.borderRadius}},{children:Z?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:w.default("flex flex-col justify-center truncate",z?"text-right items-end":"text-left items-start")},{children:[s.jsx("p",Object.assign({className:(w.default(ge.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:w.default(ge.b4,"opacity-80 truncate")},{children:m.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",className:w.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",z?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:U.accent,borderColor:be.backgroundColor},disabled:Z||"idle"!==G,onClick:()=>se([])},{children:s.jsx(b.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:be.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:be.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:be.borderRadius,backgroundColor:U.secondary}}),s.jsx("button",Object.assign({type:"button",className:w.default("absolute w-5 h-5 rounded-full -top-2 flex items-center justify-center border outline-none disabled:cursor-default",z?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:U.accent,borderColor:be.backgroundColor},disabled:Z||"idle"!==G,onClick:()=>se([])},{children:s.jsx(b.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):null},e.id)}))})),s.jsxs("div",Object.assign({className:w.default("flex items-end gap-x-2",z&&"flex-row-reverse")},{children:[s.jsx(y.default,Object.assign({className:w.default(ge.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!ne.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",z?"text-right":"text-left"),value:ne,placeholder:z?"بماذا تريد أن تتحدث؟":null!==(C=null==B?void 0:B.placeholdertext)&&void 0!==C?C:"What do you want to talk about?",onChange:e=>de(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Z||"idle"!==G||ve()))}},N&&{onFocus:N},O&&{onBlur:O},{dir:z?"rtl":"ltr"})),s.jsxs("div",Object.assign({className:w.default("flex items-center gap-x-2")},{children:["enduserupload"===(null==B?void 0:B.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:pe?U.accent+"10":void 0},disabled:Z||"idle"!==G,onClick:()=>{var e;return null===(e=ce.current)||void 0===e?void 0:e.click()}},he,{children:[s.jsx("input",{id:"file-upload",ref:ce,type:"file",accept:[...f.allowedFileMimeTypes,...ee?f.allowedImageMimeTypes:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){M(!1),yield te(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:pe?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:(me||ne.length||Y.length&&Y.every((e=>"finished"===e.status)))&&!K?U.accent:U.accent+"10"},disabled:Z||"idle"!==G,onClick:()=>ve()},fe,{children:s.jsx(j.default,{className:w.default("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",z&&"transform scale-x-[-1]"),style:{color:(me||ne.length||Y.length&&Y.every((e=>"finished"===e.status)))&&!K?U.accentText:U.accent+"80"}})}))]}))]}))]}))]}))}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../../hooks/pickaxe/
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useDimensionContext.js"),n=require("../Addons/Document/hooks/useDocument.js"),i=require("./History/index.js"),o=require("./Input.js");exports.default=()=>{const{deploymentType:u,isNewChat:c}=s.usePickaxeContext(),{width:x,height:a,setDimension:l}=r.useDimensionContext(),{setDocuments:d}=n.useDocument(),[f,h]=t.useState(!1),j=t.useRef(null);return t.useEffect((()=>()=>{d([])}),[]),t.useEffect((()=>{if(!j.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;l(parseInt(e.toFixed(0)),parseInt(s.toFixed(0)))}}));return e.observe(j.current),()=>{e.disconnect()}}),[j.current]),"chat-input"===u&&c?e.jsx("div",Object.assign({className:"relative flex flex-grow flex-col items-center"},{children:e.jsx(o.default,{})})):e.jsxs("div",Object.assign({ref:j,className:"flex flex-grow flex-col items-center"},{children:[e.jsx(i.default,{hideInfo:a<=545||x<=500||f,isInputFocused:f}),e.jsx(o.default,{isFocused:f,onFocus:()=>h(!0),onBlur:()=>h(!1)})]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),
|
|
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(null),[T,U]=i.useState(!1),[B,L]=i.useState(!0),[N,z]=i.useState(!0);return i.useEffect((()=>{U(!1)}),[null==y?void 0:y.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&S&&!T&&(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:()=>{U(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),U(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),U(!0)}}))}),[S,T,null==y?void 0:y.font]),t.jsx(d.Provider,Object.assign({value:Object.assign({formId:_,chatId:E,userId:l,studioUserId:c,embedUserId:f,deploymentId:u,deploymentType:p,deploymentDimensions:m,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"},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:T,isNewChat:B,isShowIceBreaker:N,isRtl:O,isEmbed:k,isDropShadow:C,setIsFontLoaded:U,setFormId:q,setChatId:H,setPickaxe:R,setIsNewChat:L,setIsShowIceBreaker:z},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 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../hooks/studio/useStyleFontSize.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../hooks/studio/useStyleFontSize.js"),r=require("./PickaxeMarkdown/Renderer.js"),l=require("./PickaxeIcon.js"),a=require("./PickaxeInfoModal.js"),o=require("./PickaxeMarkdown/index.js"),c=require("../../../common/cn.js");exports.default=({className:n,iconClassName:d,maxDescriptionChars:u,onIconClick:x})=>{const{pickaxe:m,styles:p,colors:j,misc:k,disableHtml:f,disableJs:h,disableCss:b,isRtl:C}=i.usePickaxeContext(),[P,v]=s.useState(!1),g=t.useStyleFontSize(),q=s.useMemo((()=>({title:(null==m?void 0:m.formtitle)||"",description:(null==m?void 0:m.formdescription)||""})),[m]);return e.jsxs("div",Object.assign({className:c.default("flex flex-col items-center",n)},{children:[P&&e.jsx(a.default,{isOpen:P,onChangeIsOpen:v}),k.isProfileImage&&e.jsx(l.default,Object.assign({src:null==m?void 0:m.coverphoto,alt:`${null==m?void 0:m.formtitle}'s Profile Picture`,width:72,height:72,className:c.default("h-[72px] w-[72px] rounded-full",d,!!x&&"cursor-pointer")},x&&{onClick:x})),k.isTitle&&!!q.title&&e.jsx("h2",Object.assign({className:c.default(g.h2,"mt-6 text-center font-semilight opacity-90",!u&&"line-clamp-2")},{children:null==m?void 0:m.formtitle})),k.isDescription&&!!q.description&&e.jsx(o.PickaxeMarkdown,Object.assign({theme:p.theme,accentColor:j.accent},C&&{rtl:!0},f&&{disableHtml:!0},h&&{disableJs:!0},b&&{disableCss:!0},{children:e.jsx(r.PickaxeMarkdownRenderer,Object.assign({className:"mt-2 text-center",value:q.description},u&&{maxDescriptionChars:u},{onExpandClick:()=>v(!0)}))}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),r=require("../../hooks/usePickaxeMarkdownContext.js"),s=require("../Img/index.js"),i=require("../common/Action.js"),o=require("./Audio.js"),a=require("./Html/index.js");exports.A=({href:c="",children:m})=>{const{accentColor:l,actions:n}=r.usePickaxeMarkdownContext(),u=t.useMemo((()=>{if(!c)return"";return c.startsWith("http://")?`https://${c.slice(7)}`:c.startsWith("www.")?`https://${c}`:c}),[c]),d=t.useMemo((()=>{const e=u.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const t=u.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(t)return{title:"loom-embed",src:`https://www.loom.com/embed/${t[1]}`};const r=u.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(r)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${r[1]}`};const s=u.match(/streamable\.com\/([\w-]+)/i);return s?{title:"streamable-embed",src:`https://streamable.com/e/${s[1]}`}:null}),[u]),p=t.useMemo((()=>u.match(/\.(jpeg|jpg|gif|bmp|webp|svg|tiff|avif|png|jfif|pjpeg|pjp)$/)),[u]),f=t.useMemo((()=>u.includes("action_generated_files")&&u.match(/\.(mp3|wav|ogg|flac|aac|wma|alac|m4a|aiff|ape|au|mid|midi|opus)$/)),[u]),h=t.useMemo((()=>u.includes("action_generated_files")&&u.match(/\.html$/)),[u]),b=t.useMemo((()=>n&&u.includes("pickaxe")&&(u.includes("/api/fn/result")||u.includes("/api/function_call_results"))),[n,u]);return d?e.jsx("div",Object.assign({className:"pxe-markdown-video"},{children:e.jsx("iframe",Object.assign({title:d.title,src:d.src,allowFullScreen:!0,style:{width:"100%",maxWidth:"560px",aspectRatio:"16 / 9"}},{children:"Iframe not supported, use a different browser."}))})):p?e.jsx(s.Img,{src:u,alt:"string"==typeof m?m:"Markdown Image"}):f?e.jsx(o.default,{url:u}):h?e.jsx(a.default,{url:u}):b?e.jsx(i.default,{jobUrl:u}):e.jsx("a",Object.assign({href:u,target:"_blank",rel:"noopener noreferrer",style:{color:l}},{children:m}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react")
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");exports.P=({children:r})=>{const o=t.useMemo((()=>{if("string"!=typeof r)return null;const e=r.match(/(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(e)return{title:"youtube-embed",src:`https://www.youtube.com/embed/${e[1]}`};const t=r.match(/loom\.com\/(?:share|embed)\/([\w-]+)/i);if(t)return{title:"loom-embed",src:`https://www.loom.com/embed/${t[1]}`};const o=r.match(/vimeo\.com\/(?:video\/)?(\d+)/i);if(o)return{title:"vimeo-embed",src:`https://player.vimeo.com/video/${o[1]}`};const s=r.match(/streamable\.com\/([\w-]+)/i);return s?{title:"streamable-embed",src:`https://streamable.com/e/${s[1]}`}:null}),[r]);return o?e.jsx("div",Object.assign({className:"pxe-markdown-video"},{children:e.jsx("iframe",Object.assign({title:o.title,src:o.src,allowFullScreen:!0,style:{width:"100%",maxWidth:"560px",aspectRatio:"16 / 9"}},{children:"Iframe not supported, use a different browser."}))})):e.jsx("p",{children:r})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),s=require("./utils/custom-plugins.js"),i=require("react-markdown"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),t=require("./hooks/usePickaxeMarkdownContext.js"),s=require("./utils/custom-plugins.js"),i=require("react-markdown"),a=require("remark-gfm"),o=require("remark-math"),l=require("rehype-katex"),u=require("rehype-raw"),c=require("./Components/A/index.js"),d=require("./Components/P/index.js"),p=require("./Components/Img/index.js"),h=require("./Components/Iframe/index.js"),m=require("./Components/Code/index.js"),x=require("./Components/Headings/index.js"),g=require("./Components/List/index.js"),f=require("./Components/Table/index.js"),b=require("./Components/Others/index.js"),j=require("./Components/Action/index.js"),C=require("../../../../common/cn.js");function q(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var k=q(i),w=q(a),v=q(o),y=q(l),A=q(u);exports.PickaxeMarkdownRenderer=({className:i,style:a,children:o,value:l,maxLines:u,maxChars:q,multiLineBreaks:O,recursion:H,onExpandClick:P})=>{const{accentColor:S,rtl:M,disableHtml:$,disableJs:T,disableCss:_}=t.usePickaxeMarkdownContext(),[E,I]=n.useState({width:0,height:0}),[L,B]=n.useState(null),N=n.useRef(null),R=n.useMemo((()=>{if(!l)return"";let e=l.trim();return e=e.replace(/<!--[\s\S]*?-->/g,""),e=e.replace(/\u200B/g,""),e=e.replace(/\\[\s\S]*?\\]/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")).replace(/\\\(\s*[\s\S]*?\s*\\\)/g,(e=>"$$"+e.substring(2,e.length-2)+"$$")),O&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,O]);n.useEffect((()=>{if(q)return void B(R.length>q?R.slice(0,q)+'<span class="pxe-expand-btn">...</span>':null);if(!u)return void B(null);if(!N.current||!R||L)return;const e=N.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=u*r;if(!(E.height>n))return;const t=Math.floor(E.width/8),s=Math.floor(t*u);B(R.slice(0,s)+'<span class="pxe-expand-btn">...</span>')}),[R,u,q,E,L]);const z={h1:x.H1,h2:x.H2,h3:x.H3,h4:x.H4,h5:x.H5,p:d.P,a:c.A,img:p.Img,iframe:h.Iframe,code:m.Code,ol:g.Ol,ul:g.Ul,li:g.Li,table:f.Table,th:f.Th,tr:f.Tr,td:f.Td,hr:b.Hr,br:b.Br,blockquote:b.Blockquote,span:n=>{var{children:t}=n,s=e.__rest(n,["children"]);return"pxe-expand-btn"===s.className?r.jsx("span",Object.assign({},s,{style:Object.assign({display:"inline",fontWeight:500,color:S,marginLeft:".25rem",userSelect:"none"},P&&{cursor:"pointer"})},P&&{onClick:P},{children:t})):r.jsx("span",Object.assign({},s,{children:t}))},ActionCaption:j.ActionCaption,ActionFinished:j.ActionFinished,ActionError:j.ActionError};n.useEffect((()=>{if(!N.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;I({width:e,height:n})}}));return e.observe(N.current),()=>{e.disconnect()}}),[]);const F=L||R;return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:N,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},a)},M&&{dir:"rtl"},{children:[r.jsx(k.default,Object.assign({className:C.default(!H&&"pxe-prose",i),components:z,remarkPlugins:[w.default,[v.default,{singleDollarTextMath:!1}]],rehypePlugins:[y.default,...$?[]:[A.default],[s.rehypeSanitize,{disableJs:T,disableCss:_}],s.rehypePickaxeAction]},{children:F})),o]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../hooks/pickaxe/usePickaxe.js"),t=require("react"),a=require("../../hooks/pickaxe/usePickaxeContext.js"),l=require("../../hooks/pickaxe/useResponseContext.js"),r=require("../../common/utils.js"),i=require("./Addons/Scroll/Provider.js"),x=require("../Core/Skeleton.js"),o=require("./Chat/index.js"),c=require("./Form/index.js"),u=require("../../common/cn.js");exports.Pickaxe=({formId:n,className:d})=>{const{chatId:f,styles:p,colors:m,responsiveBy:j,deploymentType:h,isNewChat:k,setFormId:w,setChatId:g,setPickaxe:q}=a.usePickaxeContext(),{setMessages:v,setResponse:N,setError:b,setLimitData:y,setStatus:C}=l.useResponseContext(),[P,O]=t.useState(!1),I=s.usePickaxe();return t.useEffect((()=>{w(n)}),[n]),t.useEffect((()=>{if(!I.data)return;const e=I.data.chatflag;g(e?r.generateId(15):""),e?v([]):N(null),b(""),y(null),q(I.data),O(!0)}),[I.data]),t.useEffect((()=>{v([]),N(null),C("idle"),y(null),b("")}),[f]),I.data?e.jsx("div",Object.assign({className:u.default("relative @container/pickaxe-root flex flex-col flex-grow w-full",!h&&"h-full","popup"===h&&f&&"h-full","dark"===p.theme&&"dark",d),style:Object.assign({backgroundColor:"chat-input"===h&&k?"transparent":m.primary,color:m.text},p.font&&"Real Head Pro"!==p.font&&{fontFamily:p.font})},{children:I.isLoading||!P?e.jsx("div",Object.assign({className:u.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===j?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:e.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[e.jsx(x.default,{className:"w-[72px] h-[72px]"}),e.jsx(x.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(x.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(x.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),e.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:e.jsx(x.default,{className:u.default("w-full min-h-[48px]","viewport"===j?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):e.jsx(e.Fragment,{children:f?e.jsx(i.default,{children:e.jsx(o.default,{})}):e.jsx(i.default,{children:e.jsx(c.default,{})})})})):null};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),r=require("@tanstack/react-query"),t=require("./usePickaxeContext.js");
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),r=require("@tanstack/react-query"),t=require("./usePickaxeContext.js");const i=r=>e.__awaiter(void 0,void 0,void 0,(function*(){if(!r)return null;const e=yield fetch(`${process.env.NEXT_PUBLIC_API_URL}/pickaxe?formid=${r}`,{method:"GET",headers:{"Content-Type":"application/json"}}),{success:t,data:i,error:o}=yield e.json();if(!t)throw new Error(o||"Failed to fetch pickaxe");return i}));exports.useInstantPickaxe=t=>r.useQuery({queryKey:["form",t],queryFn:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return i(t)})),enabled:!!t,staleTime:18e4}),exports.usePickaxe=()=>{const{formId:o}=t.usePickaxeContext();return r.useQuery({queryKey:["form",o],queryFn:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return i(o)})),enabled:!!o,staleTime:18e4})};
|
package/dist/cjs/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./components/Pickaxe/index.js"),o=require("./components/Pickaxe/Provider.js"),s=require("./components/Pickaxe/ResponseProvider.js"),r=require("./components/Pickaxe/common/PickaxeMarkdown/index.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("./components/Pickaxe/index.js"),o=require("./components/Pickaxe/Provider.js"),s=require("./components/Pickaxe/ResponseProvider.js"),r=require("./components/Pickaxe/common/PickaxeMarkdown/index.js"),t=require("./components/Pickaxe/common/PickaxeMarkdown/Renderer.js"),i=require("./hooks/pickaxe/useConversation.js"),x=require("./hooks/pickaxe/useHistory.js"),n=require("./hooks/pickaxe/usePickaxe.js"),k=require("./hooks/pickaxe/usePickaxeContext.js"),u=require("./hooks/pickaxe/useResponseContext.js"),a=require("./hooks/pickaxe/useDimensionContext.js"),c=require("./hooks/pickaxe/useSubmit.js"),p=require("./hooks/pickaxe/useSubmitDocument.js");exports.Pickaxe=e.Pickaxe,exports.PickaxeContext=o.PickaxeContext,exports.PickaxeProvider=o.PickaxeProvider,exports.ResponseContext=s.ResponseContext,exports.PickaxeMarkdown=r.PickaxeMarkdown,exports.PickaxeMarkdownContext=r.PickaxeMarkdownContext,exports.PickaxeMarkdownRenderer=t.PickaxeMarkdownRenderer,exports.useConversation=i.useConversation,exports.useHistory=x.useHistory,exports.useInstantPickaxe=n.useInstantPickaxe,exports.usePickaxe=n.usePickaxe,exports.usePickaxeContext=k.usePickaxeContext,exports.useResponseContext=u.useResponseContext,exports.useDimensionContext=a.useDimensionContext,exports.useSubmit=c.useSubmit,exports.useSubmitDocument=p.useSubmitDocument;
|
package/dist/cjs/prose.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.pxe-prose p{font-weight:350}.pxe-prose p:not(:only-child){margin-bottom:.75rem}.pxe-prose a{font-weight:600;text-decoration:underline;text-underline-offset:.2rem}.pxe-prose iframe{margin-bottom:1.5rem}.pxe-prose blockquote{margin-bottom:2.5rem;padding-bottom:.25rem;padding-left:1rem;padding-top:.25rem}.pxe-prose hr{margin-bottom:1.5rem}.pxe-prose .pxe-markdown-image,.pxe-prose .pxe-markdown-
|
|
1
|
+
.pxe-prose p{font-weight:350}.pxe-prose p:not(:only-child){margin-bottom:.75rem}.pxe-prose a{font-weight:600;text-decoration:underline;text-underline-offset:.2rem}.pxe-prose iframe{margin-bottom:1.5rem}.pxe-prose blockquote{margin-bottom:2.5rem;padding-bottom:.25rem;padding-left:1rem;padding-top:.25rem}.pxe-prose hr{margin-bottom:1.5rem}.pxe-prose .pxe-markdown-image,.pxe-prose .pxe-markdown-video{margin-bottom:1.5rem;margin-top:1.5rem}.pxe-prose .pxe-markdown-video{display:flex;justify-content:center;width:100%}.pxe-prose .pxe-markdown-code{margin-bottom:1.5rem}.pxe-prose ol{list-style-type:decimal}.pxe-prose ol,.pxe-prose ul{list-style-position:inside;margin-bottom:1.5rem;padding-left:1rem}.pxe-prose ul{list-style-type:disc}.pxe-prose li{margin:10px 10px 14px}.pxe-prose li>p{display:inline}.pxe-prose .pxe-markdown-table{margin-bottom:2.5rem;overflow:auto;position:relative}.pxe-prose table{font-size:.875rem;line-height:1.24rem;table-layout:fixed}.pxe-prose th{font-weight:600;text-align:left}.pxe-prose td,.pxe-prose th{padding:.75em 1em}.pxe-prose h1{font-size:2.25rem;line-height:2.5rem;margin-bottom:1.5rem}.pxe-prose h2{font-size:1.875rem;line-height:2.25rem;margin-bottom:1.5rem}.pxe-prose h3{font-size:1.5rem;line-height:2rem;margin-bottom:1.5rem}.pxe-prose h4{font-size:1.25rem}.pxe-prose h4,.pxe-prose h5{line-height:1.75rem;margin-bottom:1rem}.pxe-prose h5{font-size:1.125rem}.pxe-prose h2:not(:first-child){margin-top:2.5rem}.pxe-prose h3:not(:first-child),.pxe-prose h4:not(:first-child),.pxe-prose>pre:not(:first-child){margin-top:1rem}.pxe-prose .pxe-markdown-code{display:flex;flex-direction:column}.pxe-prose .pxe-markdown-code>div:first-child{background-color:#1d1f21;border-radius:.3em;display:flex;flex-direction:column;max-width:min-content;padding-top:1em;position:relative}.pxe-prose .pxe-markdown-code>div:first-child>div:first-child{display:flex;justify-content:flex-end;padding:0 1em}.pxe-prose .pxe-markdown-code>div:first-child>div:last-child{overflow:auto}.pxe-prose .pxe-action[data-action-id]:not(:nth-child(2)){margin-top:1rem}.pxe-prose .pxe-markdown-code-inline{background-color:#1d1f21;border-radius:.3em;color:#fff;font-size:10pt;padding:.15em .4em}.pxe-link-previews{display:flex;flex-direction:column;gap:2rem}.pxe-prose>p:first-child>.pxe-markdown-image,.pxe-prose>p:first-child>.pxe-markdown-video{margin-top:0}.pxe-prose .pxe-blink{animation:blink 1s ease-in-out infinite}.pxe-prose .pxe-red{color:red}.pxe-prose .pxe-action-error{display:flex;flex-direction:column}.pxe-prose .pxe-animated-token{animation:fadeIn .3s ease-out forwards;display:inline-block;opacity:0}@keyframes fadeIn{0%{opacity:0;transform:translateX(5px)}to{opacity:1;transform:translateX(0)}}@keyframes blink{0%{opacity:1}50%{opacity:.5}to{opacity:1}}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { PickaxeProps } from "../Pickaxe";
|
|
3
|
+
import { IPickaxeProviderProps } from "../Pickaxe/Provider";
|
|
4
|
+
type ChatInputProps = PickaxeProps & Omit<IPickaxeProviderProps, "deploymentType">;
|
|
5
|
+
export declare const ChatInput: ({ formId, className, ...props }: ChatInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const ChatInputWrapper: ({ children }: {
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SetState } from "../../types/common";
|
|
2
|
+
import { PickaxeProps } from "../Pickaxe";
|
|
3
|
+
import { IPickaxeProviderProps } from "../Pickaxe/Provider";
|
|
4
|
+
type FABProps = PickaxeProps & Omit<IPickaxeProviderProps, "deploymentType">;
|
|
5
|
+
export declare const FAB: ({ formId, className, ...props }: FABProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const FABButton: ({ isOpen, setIsOpen, }: {
|
|
7
|
+
isOpen: boolean;
|
|
8
|
+
setIsOpen: SetState<boolean>;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { PickaxeProps } from "../Pickaxe";
|
|
2
|
+
import { IPickaxeProviderProps } from "../Pickaxe/Provider";
|
|
3
|
+
type InlineProps = PickaxeProps & Omit<IPickaxeProviderProps, "deploymentType">;
|
|
4
|
+
export declare const Inline: ({ formId, className, ...props }: InlineProps) => import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SetState } from "../../types/common";
|
|
2
|
+
import { PickaxeProps } from "../Pickaxe";
|
|
3
|
+
import { IPickaxeProviderProps } from "../Pickaxe/Provider";
|
|
4
|
+
type PopupProps = PickaxeProps & Omit<IPickaxeProviderProps, "deploymentType">;
|
|
5
|
+
export declare const Popup: ({ formId, className, ...props }: PopupProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const PopupCTAButton: ({ formId, setIsOpen, }: {
|
|
7
|
+
formId: string;
|
|
8
|
+
setIsOpen: SetState<boolean>;
|
|
9
|
+
}) => import("react/jsx-runtime").JSX.Element | null;
|
|
10
|
+
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
interface InputProps {
|
|
2
|
-
isFocused
|
|
3
|
-
onFocus
|
|
4
|
-
onBlur
|
|
2
|
+
isFocused?: boolean;
|
|
3
|
+
onFocus?: () => void;
|
|
4
|
+
onBlur?: () => void;
|
|
5
5
|
}
|
|
6
6
|
declare const Input: ({ isFocused, onFocus, onBlur }: InputProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
export default Input;
|
|
@@ -33,13 +33,34 @@ export type PickaxeMisc = {
|
|
|
33
33
|
isDescription: boolean;
|
|
34
34
|
isHistory?: boolean;
|
|
35
35
|
};
|
|
36
|
+
export type PickaxeDeploymentEmbedType = "inline" | "fab" | "popup" | "chat-input";
|
|
37
|
+
export type PickaxeDeploymentDimensions = {
|
|
38
|
+
width: {
|
|
39
|
+
value: number;
|
|
40
|
+
unit: "%" | "px";
|
|
41
|
+
};
|
|
42
|
+
maxWidth: number;
|
|
43
|
+
height: {
|
|
44
|
+
value: number;
|
|
45
|
+
unit: "px" | "auto";
|
|
46
|
+
};
|
|
47
|
+
minHeight: number;
|
|
48
|
+
maxHeight: number;
|
|
49
|
+
};
|
|
50
|
+
export type PickaxeDeploymentMisc = {
|
|
51
|
+
popupText?: string;
|
|
52
|
+
fabImage?: string;
|
|
53
|
+
};
|
|
36
54
|
type PickaxeContextType = {
|
|
37
55
|
formId: string;
|
|
38
56
|
chatId: string;
|
|
39
57
|
userId: string;
|
|
40
58
|
studioUserId: string;
|
|
41
|
-
deploymentId: string;
|
|
42
59
|
embedUserId: string;
|
|
60
|
+
deploymentId: string;
|
|
61
|
+
deploymentType?: PickaxeDeploymentEmbedType;
|
|
62
|
+
deploymentDimensions?: PickaxeDeploymentDimensions;
|
|
63
|
+
deploymentMisc?: PickaxeDeploymentMisc;
|
|
43
64
|
pickaxe: LimitedPickaxe | null;
|
|
44
65
|
styles: PickaxeProviderStyles;
|
|
45
66
|
colors: PickaxeProviderColors;
|
|
@@ -54,8 +75,9 @@ type PickaxeContextType = {
|
|
|
54
75
|
isFontLoaded: boolean;
|
|
55
76
|
isNewChat: boolean;
|
|
56
77
|
isShowIceBreaker: boolean;
|
|
57
|
-
isEmbed: boolean;
|
|
58
78
|
isRtl: boolean;
|
|
79
|
+
isEmbed: boolean;
|
|
80
|
+
isDropShadow: boolean;
|
|
59
81
|
setFormId: SetState<string>;
|
|
60
82
|
setChatId: SetState<string>;
|
|
61
83
|
setPickaxe: SetState<LimitedPickaxe | null>;
|
|
@@ -68,8 +90,11 @@ export interface IPickaxeProviderProps {
|
|
|
68
90
|
children: ReactNode;
|
|
69
91
|
userId?: string;
|
|
70
92
|
studioUserId?: string;
|
|
71
|
-
deploymentId?: string;
|
|
72
93
|
embedUserId?: string;
|
|
94
|
+
deploymentId?: string;
|
|
95
|
+
deploymentType?: PickaxeDeploymentEmbedType;
|
|
96
|
+
deploymentDimensions?: PickaxeDeploymentDimensions;
|
|
97
|
+
deploymentMisc?: PickaxeDeploymentMisc;
|
|
73
98
|
styles?: Partial<PickaxeProviderStyles>;
|
|
74
99
|
colors?: Partial<PickaxeProviderColors>;
|
|
75
100
|
limits?: Record<string, PickaxeLimitData>;
|
|
@@ -81,10 +106,11 @@ export interface IPickaxeProviderProps {
|
|
|
81
106
|
disableHtml?: boolean;
|
|
82
107
|
disableJs?: boolean;
|
|
83
108
|
disableCss?: boolean;
|
|
84
|
-
isEmbed?: boolean;
|
|
85
109
|
isRtl?: boolean;
|
|
110
|
+
isEmbed?: boolean;
|
|
111
|
+
isDropShadow?: boolean;
|
|
86
112
|
onGenerateComplete?: (responseId: string) => void;
|
|
87
113
|
}
|
|
88
114
|
export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
|
|
89
|
-
export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, embedUserId, styles, colors, limits, misc, translations, responsiveBy, forceMobile, disableHtml, disableJs, disableCss, loadFont, isEmbed,
|
|
115
|
+
export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, embedUserId, deploymentType, deploymentDimensions, deploymentMisc, styles, colors, limits, misc, translations, responsiveBy, forceMobile, disableHtml, disableJs, disableCss, loadFont, isRtl, isEmbed, isDropShadow, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
|
|
90
116
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
interface PickaxeHeadProps {
|
|
2
2
|
className?: string;
|
|
3
3
|
iconClassName?: string;
|
|
4
|
-
|
|
4
|
+
maxDescriptionChars?: number;
|
|
5
5
|
onIconClick?: () => void;
|
|
6
6
|
}
|
|
7
|
-
declare const PickaxeHead: ({ className, iconClassName,
|
|
7
|
+
declare const PickaxeHead: ({ className, iconClassName, maxDescriptionChars, onIconClick, }: PickaxeHeadProps) => import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
export default PickaxeHead;
|
|
@@ -5,8 +5,9 @@ export interface PickaxeMarkdownRendererProps {
|
|
|
5
5
|
children?: ReactNode;
|
|
6
6
|
value?: string | null;
|
|
7
7
|
maxLines?: number;
|
|
8
|
+
maxChars?: number;
|
|
8
9
|
multiLineBreaks?: boolean;
|
|
9
10
|
recursion?: boolean;
|
|
10
11
|
onExpandClick?: () => void;
|
|
11
12
|
}
|
|
12
|
-
export declare const PickaxeMarkdownRenderer: ({ className, style, children: _children, value, maxLines, multiLineBreaks, recursion, onExpandClick, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export declare const PickaxeMarkdownRenderer: ({ className, style, children: _children, value, maxLines, maxChars, multiLineBreaks, recursion, onExpandClick, }: PickaxeMarkdownRendererProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
import type { LimitedPickaxe } from "../../types/pickaxe";
|
|
2
2
|
export declare const usePickaxe: () => import("@tanstack/react-query").UseQueryResult<LimitedPickaxe | null, Error>;
|
|
3
|
+
export declare const useInstantPickaxe: (formId: string) => import("@tanstack/react-query").UseQueryResult<LimitedPickaxe | null, Error>;
|
|
@@ -3,8 +3,11 @@ export declare const usePickaxeContext: () => {
|
|
|
3
3
|
chatId: string;
|
|
4
4
|
userId: string;
|
|
5
5
|
studioUserId: string;
|
|
6
|
-
deploymentId: string;
|
|
7
6
|
embedUserId: string;
|
|
7
|
+
deploymentId: string;
|
|
8
|
+
deploymentType?: import("../../components/Pickaxe/Provider").PickaxeDeploymentEmbedType | undefined;
|
|
9
|
+
deploymentDimensions?: import("../../components/Pickaxe/Provider").PickaxeDeploymentDimensions | undefined;
|
|
10
|
+
deploymentMisc?: import("../../components/Pickaxe/Provider").PickaxeDeploymentMisc | undefined;
|
|
8
11
|
pickaxe: import("../../types/pickaxe").LimitedPickaxe | null;
|
|
9
12
|
styles: import("../../components/Pickaxe/Provider").PickaxeProviderStyles;
|
|
10
13
|
colors: import("../../components/Pickaxe/Provider").PickaxeProviderColors;
|
|
@@ -19,8 +22,9 @@ export declare const usePickaxeContext: () => {
|
|
|
19
22
|
isFontLoaded: boolean;
|
|
20
23
|
isNewChat: boolean;
|
|
21
24
|
isShowIceBreaker: boolean;
|
|
22
|
-
isEmbed: boolean;
|
|
23
25
|
isRtl: boolean;
|
|
26
|
+
isEmbed: boolean;
|
|
27
|
+
isDropShadow: boolean;
|
|
24
28
|
setFormId: import("../../types/common").SetState<string>;
|
|
25
29
|
setChatId: import("../../types/common").SetState<string>;
|
|
26
30
|
setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").LimitedPickaxe | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e,jsxs as s}from"react/jsx-runtime";import{useMemo as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as t}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as i}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as l}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as r}from"../../../../hooks/pickaxe/useConversation.js";import c from"../../common/PickaxeIcon.js";import m from"../../../Core/ErrorAlert.js";import d from"../../../Core/Skeleton.js";import
|
|
1
|
+
import{jsx as e,jsxs as s}from"react/jsx-runtime";import{useMemo as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as t}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as i}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as l}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as r}from"../../../../hooks/pickaxe/useConversation.js";import c from"../../common/PickaxeIcon.js";import m from"../../../Core/ErrorAlert.js";import d from"../../../Core/Skeleton.js";import p from"../../Addons/Scroll/ScrollLockView.js";import f from"../../common/PickaxeHead.js";import x from"../../common/PickaxeCompactHead.js";import u from"../../common/PickaxeUpgradeCard.js";import h from"./Message.js";import g from"../../common/PickaxeBranding.js";import j from"../../../../common/cn.js";const w=({hideInfo:w,isInputFocused:v})=>{var N;const b=r(),k=n(),{pickaxe:y,colors:C,misc:O,isNewChat:S,isRtl:I,isEmbed:P,setChatId:E}=o(),{scrollContainerRef:L}=l(),{messages:A,status:H,limitData:D,error:R}=t(),{height:$}=i(),z=a((()=>!!b.data&&!(b.data.messages.length<=1)),[b.data]),F=a((()=>!w&&b.isSuccess&&S&&!z),[w,b.isSuccess,S,z]),B=a((()=>{var e,s;return!!A.length&&!(null!==(s=null===(e=null==A?void 0:A[A.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[A]);return e("div",Object.assign({ref:L,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-8",style:{height:`calc(${$}px - 74px)`}},{children:s("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px] px-4"},{children:[(F||!P)&&!O.isWhiteLabel&&e(g,{className:j("absolute top-4 right-4",!F&&!P&&"top-2"),animateHover:!0}),e(f,{className:j("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",F&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxDescriptionChars:500,onIconClick:()=>E("")}),P&&!b.isLoading&&e(x,{className:j("opacity-0 transition-all duration-500 ease-in-out h-0 w-full",!F&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",onIconClick:()=>E("")}),e("div",Object.assign({className:j("flex flex-col mt-6 transition-all duration-300 ease-in-out w-full",P&&!b.isLoading&&!F&&"mt-0")},{children:b.isLoading&&!(null==y?void 0:y.enablechatresponses)?s("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[S&&s("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e(d,{className:"w-[72px] h-[72px]"}),e(d,{className:"h-[20px] mt-6 w-full"}),e(d,{className:"h-[20px] mt-2 w-full"}),e(d,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e(d,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e(d,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e(d,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):b.isError?e("div",Object.assign({className:"flex w-full justify-center"},{children:s("p",Object.assign({className:j(k.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):b.data?s("div",Object.assign({className:"flex flex-col w-full"},{children:[s("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[b.data.messages.map(((s,a)=>e(h,Object.assign({index:a,message:s},0===a&&{isIntroExpand:v}),a))),A.map(((s,a)=>e(h,{index:b.data.messages.length+a,message:s},a))),"fetching"===H||B?e("div",Object.assign({className:j("flex w-full",I?"justify-end":"justify-start")},{children:e("div",Object.assign({className:"flex flex-col"},{children:s("div",Object.assign({className:j("flex gap-x-3",I&&"flex-row-reverse")},{children:["NONE"!==(null==y?void 0:y.chaticon)&&e(c,{src:null!==(N=null==y?void 0:y.chaticon)&&void 0!==N?N:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==y?void 0:y.formid}.png`,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"my-3 h-6 w-6",textColor:C.text}),e("div",Object.assign({className:"flex items-center gap-x-2 rounded px-2"},{children:Array.from({length:3}).map(((s,a)=>e("div",{className:j("h-1.5 w-1.5 animate-dot rounded-full",1===a&&"animate-dot-down"),style:{backgroundColor:C.secondaryText}},a)))}))]}))}))})):D?e("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e(u,{})})):R?e("div",Object.assign({className:j("flex items-center gap-x-3",I?"justify-end":"justify-start")},{children:e(m,{error:R})})):null]})),e(p,{className:"w-full"})]})):null}))]}))}))};export{w 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"../../../common/error.js";import
|
|
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"../../../common/error.js";import T from"../../../common/cn.js";const A=({isFocused:A,onFocus:U,onBlur:B})=>{var D;const{formId:F,chatId:E,userId:H,studioUserId:z,embedUserId:L,deploymentId:$,deploymentType:G,pickaxe:J,styles:K,colors:P,responsiveBy:W,isNewChat:_,isRtl:M,setIsNewChat:q,setIsShowIceBreaker:Q,onGenerateComplete:V}=c(),{messages:X,status:Y,limits:Z,isGenerating:ee,setMessages:te,setStatus:se,setLimitData:oe,setError:re}=d(),{documents:ie,isUploading:ne,isImageUploadAllowed:le,setDocuments:ae,onFileUpload:ce}=h(),{scrollStartSession:de,scrollEndSession:ue,scrollToBottom:me}=g({auto:!0}),pe=p(),fe=f(),[he,ge]=r(""),be=i(null),ve=b(),{isHover:xe}=ve,ye=e(ve,["isHover"]),je=b(),{isHover:ke}=je,we=e(je,["isHover"]),Ne=m(),Ie=u(),Oe=n((()=>{var e,t,s;return!!_&&(!!J&&(!pe.isLoading&&(!((null!==(t=null===(e=pe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(s=J.icebreakers)||void 0===s?void 0:s.length))))}),[J,_,pe.data,pe.isLoading]),Ce=e=>t(void 0,void 0,void 0,(function*(){try{if("idle"!==Y||ne)return;const t=null!=e?e:he;if(!t)return;re(""),oe(null),ge(""),q(!1),se("fetching"),de(),me();const s=ie.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),o=s.length?s[s.length-1].documentId:"",r="enduserupload"===(null==J?void 0:J.documentuploadtype)&&o,i=[...Array.from(X),Object.assign({id:X.length+1,role:"user",content:t},r&&{documentIds:[o]})];te(i),me(),r&&ae([]);const n=(yield fe.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:F,responseId:E,value:t},r&&{documentId:o}),H&&{userId:H}),z&&{studioUserId:z}),L&&{embedUserId:L}),$&&{deploymentId:$}))).body;if(!n)throw new Error("Streaming error");const l=i.length,a=new TextDecoder,c=n.getReader();let d="",u=!0,m=!1;const p=j({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");d+=t,te([...i.slice(0,l),{id:X.length+1,role:"assistant",content:d}])}else if("error"===e.event){const t=JSON.parse(e.data);re(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(u=!1)}});for(;u;){const{value:e,done:t}=yield c.read();if(t){u=!1;break}const s=a.decode(e);s&&(m||(se("streaming"),m=!0),p.feed(s))}null==V||V(E)}catch(e){let t=R(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(Z).find((([e])=>t.includes(e)));s?oe(s[1]):re(t)}finally{me(),se("idle"),ue()}}));return l((()=>{Q(Oe)}),[Oe]),s("div",Object.assign({className:T("w-full flex flex-col items-center absolute bottom-0 left-0 z-1",!("chat-input"===G&&_)&&"px-4 pb-4"),dir:M?"rtl":"ltr"},{children:o("div",Object.assign({className:"relative flex flex-col max-w-[800px] w-full"},{children:[!("chat-input"===G&&_)&&s("div",Object.assign({className:T("absolute bottom-full",M?"left-0":"right-0")},{children:s("div",Object.assign({className:T("flex flex-col gap-2 pb-4 px-2",M?"justify-start":"justify-end","viewport"===W?M?"min-[767px]:items-start":"min-[767px]:items-end":M?"@[767px]/pickaxe-root:items-start":"@[767px]/pickaxe-root:items-end")},{children:Oe&&!A&&s(C,{data:(null==J?void 0:J.icebreakers)||[],onSend:Ce})}))})),o("div",Object.assign({className:T("flex flex-col gap-y-2 px-4 py-3","block"===K.formFieldStyle&&"shadow"),style:Ie},{children:["idle"===Y&&ie.length>0&&s("div",Object.assign({className:T("grid grid-cols-1","viewport"===W?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:ie.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",M&&"flex-row-reverse"),style:{borderRadius:Ie.borderRadius,borderColor:P.secondaryText+"50"}},{children:[s("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:P.accent,borderRadius:Ie.borderRadius}},{children:ne?s(w,{className:"w-5 h-5 animate-spin",style:{color:P.accentText}}):s(N,{className:"w-5 h-5",style:{color:P.accentText}})})),o("div",Object.assign({className:T("flex flex-col justify-center truncate",M?"text-right items-end":"text-left items-start")},{children:[s("p",Object.assign({className:(T(Ne.b3),"font-medium truncate")},{children:e.name})),s("p",Object.assign({className:T(Ne.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",M?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:P.accent,borderColor:Ie.backgroundColor},disabled:ne||"idle"!==Y,onClick:()=>ae([])},{children:s(I,{className:"w-4 h-4",style:{color:P.accentText}})}))]})):"image"===e.type?o("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:Ie.borderRadius}},{children:["finished"===e.status?s("img",{style:{borderRadius:Ie.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:Ie.borderRadius,backgroundColor:P.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",M?"-left-2 right-auto":"-right-2 left-auto"),style:{backgroundColor:P.accent,borderColor:Ie.backgroundColor},disabled:ne||"idle"!==Y,onClick:()=>ae([])},{children:s(I,{className:"w-4 h-4",style:{color:P.accentText}})}))]})):null},e.id)}))})),o("div",Object.assign({className:T("flex items-end gap-x-2",M&&"flex-row-reverse")},{children:[s(S,Object.assign({className:T(Ne.i1,"max-h-60 min-h-[27px] w-full border-transparent bg-transparent",!he.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap",M?"text-right":"text-left"),value:he,placeholder:M?"بماذا تريد أن تتحدث؟":null!==(D=null==J?void 0:J.placeholdertext)&&void 0!==D?D:"What do you want to talk about?",onChange:e=>ge(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ne||"idle"!==Y||Ce()))}},U&&{onFocus:U},B&&{onBlur:B},{dir:M?"rtl":"ltr"})),o("div",Object.assign({className:T("flex items-center gap-x-2")},{children:["enduserupload"===(null==J?void 0:J.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:ke?P.accent+"10":void 0},disabled:ne||"idle"!==Y,onClick:()=>{var e;return null===(e=be.current)||void 0===e?void 0:e.click()}},we,{children:[s("input",{id:"file-upload",ref:be,type:"file",accept:[...x,...le?y:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){q(!1),yield ce(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:ke?P.accent:P.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:(xe||he.length||ie.length&&ie.every((e=>"finished"===e.status)))&&!ee?P.accent:P.accent+"10"},disabled:ne||"idle"!==Y,onClick:()=>Ce()},ye,{children:s(O,{className:T("h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",M&&"transform scale-x-[-1]"),style:{color:(xe||he.length||ie.length&&ie.every((e=>"finished"===e.status)))&&!ee?P.accentText:P.accent+"80"}})}))]}))]}))]}))]}))}))};export{A as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{jsx as e,jsxs as t}from"react/jsx-runtime";import{useState as o,useRef as s,useEffect as r}from"react";import{usePickaxeContext as n}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useDimensionContext as i}from"../../../hooks/pickaxe/useDimensionContext.js";import{useDocument as c}from"../Addons/Document/hooks/useDocument.js";import m from"./History/index.js";import u from"./Input.js";const f=()=>{const{deploymentType:f,isNewChat:a}=n(),{width:l,height:d,setDimension:p}=i(),{setDocuments:x}=c(),[h,j]=o(!1),g=s(null);return r((()=>()=>{x([])}),[]),r((()=>{if(!g.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:o}=t.contentRect;p(parseInt(e.toFixed(0)),parseInt(o.toFixed(0)))}}));return e.observe(g.current),()=>{e.disconnect()}}),[g.current]),"chat-input"===f&&a?e("div",Object.assign({className:"relative flex flex-grow flex-col items-center"},{children:e(u,{})})):t("div",Object.assign({ref:g,className:"flex flex-grow flex-col items-center"},{children:[e(m,{hideInfo:d<=545||l<=500||h,isInputFocused:h}),e(u,{isFocused:h,onFocus:()=>j(!0),onBlur:()=>j(!1)})]}))};export{f as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
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 r from"./Addons/Document/Provider.js";import n 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:D=!0,isRtl:S=!1,isEmbed:k=!1,isDropShadow:C=!1,onGenerateComplete:H})=>{const[O,R]=s(""),[T,U]=s(""),[B,L]=s(null),[M,E]=s(!1),[N,A]=s(!0),[G,J]=s(!0);return t((()=>{E(!1)}),[null==h?void 0:h.font]),t((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&D&&!M&&(null==h?void 0:h.font)&&"Real Head Pro"!==h.font)try{(yield import("webfontloader")).default.load({google:{families:[h.font]},active:()=>{E(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),E(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),E(!0)}}))}),[D,M,null==h?void 0:h.font]),o(l.Provider,Object.assign({value:Object.assign({formId:O,chatId:T,userId:a,studioUserId:c,embedUserId:p,deploymentId:m,deploymentType:f,deploymentDimensions:b,deploymentMisc:y,pickaxe:B,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:D,disableHtml:x,disableJs:P,disableCss:j,isFontLoaded:M,isNewChat:N,isShowIceBreaker:G,isRtl:S,isEmbed:k,isDropShadow:C,setIsFontLoaded:E,setFormId:R,setChatId:U,setPickaxe:L,setIsNewChat:A,setIsShowIceBreaker:J},H&&{onGenerateComplete:H})},{children:o(n,Object.assign({limits:F},{children:o(d,{children:o(r,{children:i})})}))}))};export{l as PickaxeContext,a as PickaxeProvider};
|