@pickaxeproject/react 1.2.2 → 1.2.3
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/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Checkbox.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Document.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Dropdown.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Form/Questions/Option.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/A/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Custom/Code/index.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
- package/dist/cjs/prose.css +1 -1
- package/dist/cjs/src/components/Pickaxe/common/PickaxeMarkdown/Custom/Code/index.d.ts +3 -1
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Checkbox.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Document.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Dropdown.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Form/Questions/Option.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/A/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Custom/Code/index.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeMarkdown/Renderer.js +1 -1
- package/dist/esm/prose.css +1 -1
- package/dist/esm/src/components/Pickaxe/common/PickaxeMarkdown/Custom/Code/index.d.ts +3 -1
- package/package.json +1 -1
|
@@ -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"),o=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../hooks/pickaxe/useDimensionContext.js"),n=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),d=require("../../../hooks/pickaxe/useSubmit.js"),c=require("../../../hooks/pickaxe/useSubmitResult.js"),u=require("../../../common/documents.js"),m=require("../../../common/api/streamer.js"),p=require("../Addons/Document/hooks/useDocument.js"),f=require("../Addons/Scroll/hooks/useScroll.js"),h=require("../../../hooks/core/useHover.js"),x=require("../../../common/utils.js"),g=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/spinner-lines.svg.js"),j=require("../../Icons/file.svg.js"),v=require("../../Icons/x.svg.js"),y=require("../../Icons/arrow-right.svg.js"),k=require("../common/PickaxeBranding.js"),w=require("../Addons/IceBreaker/index.js"),I=require("react-textarea-autosize"),O=require("../../../common/error.js"),C=require("../../../common/cn.js");function N(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var q=N(I);exports.default=()=>{var I;const{formId:N,chatId:S,userId:R,studioUserId:D,deploymentId:A,pickaxe:_,styles:T,colors:U,misc:E,chatInput:H,responsiveBy:B,forceMobile:M,isNewChat:z,setIsNewChat:F,setIsShowIceBreaker:L,onGenerateComplete:P}=o.usePickaxeContext(),{messages:W,status:$,limits:G,setMessages:K,setStatus:J,setLimitData:Q,setError:V,setIsGenerating:X}=r.useResponseContext(),{isMobile:Y}=i.useDimensionContext(),{documents:Z,isUploading:ee,isImageUploadAllowed:se,upsertDocuments:te,onFileUpload:oe}=p.useDocument(),{scrollStartSession:re,scrollEndSession:ie,scrollToBottom:ne}=f.useScroll({auto:!0}),ae=l.useConversation(),le=d.useSubmit(),de=c.useSubmitResult(),ce=a.useStyleFontSize(),ue=n.useStyleInput(),[me,pe]=t.useState(H),fe=t.useRef(null),he=h.useHover(),{isHover:xe}=he,ge=e.__rest(he,["isHover"]),be=h.useHover(),{isHover:je}=be,ve=e.__rest(be,["isHover"]),ye=t.useMemo((()=>{var e,s,t;return!!z&&(!!_&&(!ae.isLoading&&(!((null!==(s=null===(e=ae.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=_.icebreakers)||void 0===t?void 0:t.length))))}),[_,z,ae.data,ae.isLoading]),ke=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(ee||"idle"!==$)return;const e=null!=s?s:me;if(!e)return;pe(""),V(""),Q(null),X(!0),F(!1);const t=new Date,o="enduserupload"===(null==_?void 0:_.documentuploadtype),r=Z.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),i=r.length?r[r.length-1].documentId:"";J("fetching"),re(),ne();const n=Array.from(W);let a=[...n,{id:W.length+1,role:"user",content:e}];K(a),ne();const{success:l,data:d,actionData:c,usedDocumentIds:u,endUserDocumentId:p,endUserImageId:f,rawUserInput:h,error:x}=yield le.mutateAsync(Object.assign(Object.assign(Object.assign({formId:N,responseId:S,value:e},o&&i&&{documentId:i}),D&&{studioUserId:D}),A&&{deploymentId:A}));if(!l)throw new Error(null!=x?x:"An error occurred, please try again.");const g=[];p&&g.push(p),f&&g.push(f),g.length>0&&(a=[...n,Object.assign({id:W.length+1,role:"user",content:e},g&&{documentIds:g})],K(a),ne()),te([]),ne();const b=(yield m.streamer({formId:N,responseId:S,data:d,actionData:c})).body;if(!b)throw new Error("Streaming error");const j=b.getReader(),v=new TextDecoder,y=a.length;let k="",w=!0,I=!1;for(;w;){const{value:e,done:s}=yield j.read();w=!s;if(k+=v.decode(e).replace(/\u200B/g,""),k)I||(J("streaming"),I=!0),K([...a.slice(0,y),{id:W.length+1,role:"assistant",content:k}]);else if(!w&&!k)throw new Error("Server error")}const O=new Date;k&&(ne(),J("idle"),yield de.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:N,responseId:S,documentIds:u},R&&{userId:R}),D&&{studioUserId:D}),D&&(null==_?void 0:_.studioid)&&{studioId:_.studioid}),A&&{deploymentId:A}),{messages:[Object.assign(Object.assign({role:"user",message:h},g&&{documentIds:g}),{sentAt:t}),{role:"assistant",message:k,sentAt:O}]})),null==P||P(S))}catch(e){let s=O.default(e)||"";s&&!s.includes("Unexpected token 'A',")||(s="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(G).find((([e])=>s.includes(e)));t?Q(t[1]):V(s),ne()}finally{J("idle"),X(!1),ie()}}));return t.useEffect((()=>{L(ye)}),[ye]),t.useEffect((()=>{pe(H)}),[H]),s.jsxs("div",Object.assign({className:C.default("fixed flex w-full flex-col bottom-0 left-0","viewport"===B?"min-[767px]:relative min-[767px]:bottom-auto min-[767px]:left-auto":"absolute @[767px]/pickaxe-root:relative @[767px]/pickaxe-root:bottom-auto @[767px]/pickaxe-root:left-auto")},{children:[!E.isWhiteLabel&&s.jsx("div",Object.assign({className:"flex justify-end pr-3 pb-3 @[767px]/pickaxe-root:pr-0"},{children:s.jsx(k.default,{animateHover:!0})})),ye&&s.jsx(w.default,{data:(null==_?void 0:_.icebreakers)||[],onSend:ke}),s.jsxs("div",Object.assign({id:(null==_?void 0:_.formid)+"--chat-parent",style:Object.assign(Object.assign({},ue),(Y||M)&&{paddingLeft:"0.75rem",paddingRight:"0.75rem"}),className:C.default("flex min-h-[56px] flex-col gap-y-2 px-4 py-3 pb-[15px]","block"===T.formFieldStyle&&"shadow")},{children:["idle"===$&&Z.length>0&&s.jsx("div",Object.assign({className:C.default("grid grid-cols-1","viewport"===B?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:Z.map((e=>{var o,r,i;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:"relative gap-x-[10px] flex items-center px-2 h-[56px] border",style:{borderRadius:ue.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:ue.borderRadius}},{children:ee?s.jsx(b.default,{className:"w-5 h-5 animate-spin",style:{color:U.accentText}}):s.jsx(j.default,{className:"w-5 h-5",style:{color:U.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(C.default(ce.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:C.default(ce.b4,"opacity-80 truncate")},{children:x.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",disabled:ee||"idle"!==$,onClick:()=>te([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:U.accent,borderColor:ue.backgroundColor}},{children:s.jsx(v.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:ue.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:ue.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(o=e.documentId)||void 0===o?void 0:o.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.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:ue.borderRadius,backgroundColor:U.secondary}}),s.jsx("button",Object.assign({type:"button",disabled:ee||"idle"!==$,onClick:()=>te([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:U.accent,borderColor:ue.backgroundColor}},{children:s.jsx(v.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):null},e.id)}))})),s.jsxs("div",Object.assign({className:"flex items-end gap-x-2 grow"},{children:[s.jsx(q.default,{id:(null==_?void 0:_.formid)+"--chat-textarea",className:C.default(ce.b2,"max-h-60 mb-[0.2em] w-full resize-none border-transparent bg-transparent outline-none ring-0 scrollbar scrollbar-thin placeholder:text-inherit placeholder:opacity-50",!me.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:me,placeholder:null!==(I=null==_?void 0:_.placeholdertext)&&void 0!==I?I:"What do you want to talk about?",onChange:e=>pe(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ee||"idle"!==$||ke()))}}),s.jsxs("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==_?void 0:_.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:je?U.accent+"10":void 0},disabled:ee||"idle"!==$,onClick:()=>{var e;return null===(e=fe.current)||void 0===e?void 0:e.click()}},ve,{children:[s.jsx("input",{id:"file-upload",ref:fe,type:"file",accept:[...u.allowedFileMimeTypes,...se?u.allowedImageMimeTypes:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield oe(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx(g.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:je?U.accent:U.accent+"80"}})]})),s.jsx("button",Object.assign({id:(null==_?void 0:_.formid)+"--chat-button",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||me.length||Z.length&&Z.every((e=>"finished"===e.status))?U.accent:U.accent+"10"},disabled:ee||"idle"!==$,onClick:()=>ke()},ge,{children:s.jsx(y.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:xe||me.length||Z.length&&Z.every((e=>"finished"===e.status))?U.accentText:U.accent+"80"}})}))]}))]}))]}))]}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),o=require("../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../hooks/pickaxe/useDimensionContext.js"),n=require("../../../hooks/studio/useStyleInput.js"),a=require("../../../hooks/studio/useStyleFontSize.js"),l=require("../../../hooks/pickaxe/useConversation.js"),d=require("../../../hooks/pickaxe/useSubmit.js"),c=require("../../../hooks/pickaxe/useSubmitResult.js"),u=require("../../../common/documents.js"),m=require("../../../common/api/streamer.js"),p=require("../Addons/Document/hooks/useDocument.js"),x=require("../Addons/Scroll/hooks/useScroll.js"),g=require("../../../hooks/core/useHover.js"),f=require("../../../common/utils.js"),h=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/spinner-lines.svg.js"),j=require("../../Icons/file.svg.js"),v=require("../../Icons/x.svg.js"),y=require("../../Icons/arrow-right.svg.js"),k=require("../common/PickaxeBranding.js"),w=require("../Addons/IceBreaker/index.js"),I=require("../../Core/Textarea.js"),O=require("../../../common/error.js"),C=require("../../../common/cn.js");exports.default=()=>{var N;const{formId:q,chatId:S,userId:R,studioUserId:D,deploymentId:A,pickaxe:_,styles:T,colors:U,misc:E,chatInput:H,responsiveBy:B,forceMobile:M,isNewChat:F,setIsNewChat:L,setIsShowIceBreaker:P,onGenerateComplete:z}=o.usePickaxeContext(),{messages:W,status:$,limits:G,setMessages:K,setStatus:J,setLimitData:Q,setError:V,setIsGenerating:X}=r.useResponseContext(),{isMobile:Y}=i.useDimensionContext(),{documents:Z,isUploading:ee,isImageUploadAllowed:se,upsertDocuments:te,onFileUpload:oe}=p.useDocument(),{scrollStartSession:re,scrollEndSession:ie,scrollToBottom:ne}=x.useScroll({auto:!0}),ae=l.useConversation(),le=d.useSubmit(),de=c.useSubmitResult(),ce=a.useStyleFontSize(),ue=n.useStyleInput(),[me,pe]=t.useState(H),xe=t.useRef(null),ge=g.useHover(),{isHover:fe}=ge,he=e.__rest(ge,["isHover"]),be=g.useHover(),{isHover:je}=be,ve=e.__rest(be,["isHover"]),ye=t.useMemo((()=>{var e,s,t;return!!F&&(!!_&&(!ae.isLoading&&(!((null!==(s=null===(e=ae.data)||void 0===e?void 0:e.messages.length)&&void 0!==s?s:0)>1)&&!!(null===(t=_.icebreakers)||void 0===t?void 0:t.length))))}),[_,F,ae.data,ae.isLoading]),ke=s=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(ee||"idle"!==$)return;const e=null!=s?s:me;if(!e)return;pe(""),V(""),Q(null),X(!0),L(!1);const t=new Date,o="enduserupload"===(null==_?void 0:_.documentuploadtype),r=Z.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),i=r.length?r[r.length-1].documentId:"";J("fetching"),re(),ne();const n=Array.from(W);let a=[...n,{id:W.length+1,role:"user",content:e}];K(a),ne();const{success:l,data:d,actionData:c,usedDocumentIds:u,endUserDocumentId:p,endUserImageId:x,rawUserInput:g,error:f}=yield le.mutateAsync(Object.assign(Object.assign(Object.assign({formId:q,responseId:S,value:e},o&&i&&{documentId:i}),D&&{studioUserId:D}),A&&{deploymentId:A}));if(!l)throw new Error(null!=f?f:"An error occurred, please try again.");const h=[];p&&h.push(p),x&&h.push(x),h.length>0&&(a=[...n,Object.assign({id:W.length+1,role:"user",content:e},h&&{documentIds:h})],K(a),ne()),te([]),ne();const b=(yield m.streamer({formId:q,responseId:S,data:d,actionData:c})).body;if(!b)throw new Error("Streaming error");const j=b.getReader(),v=new TextDecoder,y=a.length;let k="",w=!0,I=!1;for(;w;){const{value:e,done:s}=yield j.read();w=!s;if(k+=v.decode(e).replace(/\u200B/g,""),k)I||(J("streaming"),I=!0),K([...a.slice(0,y),{id:W.length+1,role:"assistant",content:k}]);else if(!w&&!k)throw new Error("Server error")}const O=new Date;k&&(ne(),J("idle"),yield de.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:q,responseId:S,documentIds:u},R&&{userId:R}),D&&{studioUserId:D}),D&&(null==_?void 0:_.studioid)&&{studioId:_.studioid}),A&&{deploymentId:A}),{messages:[Object.assign(Object.assign({role:"user",message:g},h&&{documentIds:h}),{sentAt:t}),{role:"assistant",message:k,sentAt:O}]})),null==z||z(S))}catch(e){let s=O.default(e)||"";s&&!s.includes("Unexpected token 'A',")||(s="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(G).find((([e])=>s.includes(e)));t?Q(t[1]):V(s),ne()}finally{J("idle"),X(!1),ie()}}));return t.useEffect((()=>{P(ye)}),[ye]),t.useEffect((()=>{pe(H)}),[H]),s.jsxs("div",Object.assign({className:C.default("fixed flex w-full flex-col bottom-0 left-0","viewport"===B?"min-[767px]:relative min-[767px]:bottom-auto min-[767px]:left-auto":"absolute @[767px]/pickaxe-root:relative @[767px]/pickaxe-root:bottom-auto @[767px]/pickaxe-root:left-auto")},{children:[!E.isWhiteLabel&&s.jsx("div",Object.assign({className:"flex justify-end pr-3 pb-3 @[767px]/pickaxe-root:pr-0"},{children:s.jsx(k.default,{animateHover:!0})})),ye&&s.jsx(w.default,{data:(null==_?void 0:_.icebreakers)||[],onSend:ke}),s.jsxs("div",Object.assign({id:(null==_?void 0:_.formid)+"--chat-parent",style:Object.assign(Object.assign({},ue),(Y||M)&&{paddingLeft:"0.75rem",paddingRight:"0.75rem"}),className:C.default("flex min-h-[56px] flex-col gap-y-2 px-4 py-3 pb-[15px]","block"===T.formFieldStyle&&"shadow")},{children:["idle"===$&&Z.length>0&&s.jsx("div",Object.assign({className:C.default("grid grid-cols-1","viewport"===B?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:Z.map((e=>{var o,r,i;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:"relative gap-x-[10px] flex items-center px-2 h-[56px] border",style:{borderRadius:ue.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:ue.borderRadius}},{children:ee?s.jsx(b.default,{className:"w-5 h-5 animate-spin",style:{color:U.accentText}}):s.jsx(j.default,{className:"w-5 h-5",style:{color:U.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(C.default(ce.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:C.default(ce.b4,"opacity-80 truncate")},{children:f.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",disabled:ee||"idle"!==$,onClick:()=>te([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:U.accent,borderColor:ue.backgroundColor}},{children:s.jsx(v.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:ue.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:ue.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(o=e.documentId)||void 0===o?void 0:o.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.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:ue.borderRadius,backgroundColor:U.secondary}}),s.jsx("button",Object.assign({type:"button",disabled:ee||"idle"!==$,onClick:()=>te([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:U.accent,borderColor:ue.backgroundColor}},{children:s.jsx(v.default,{className:"w-4 h-4",style:{color:U.accentText}})}))]})):null},e.id)}))})),s.jsxs("div",Object.assign({className:"flex items-end gap-x-2 grow"},{children:[s.jsx(I.default,{id:(null==_?void 0:_.formid)+"--chat-textarea",className:C.default(ce.b2,"max-h-60 mb-[0.2em] w-full border-transparent bg-transparent",!me.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:me,placeholder:null!==(N=null==_?void 0:_.placeholdertext)&&void 0!==N?N:"What do you want to talk about?",onChange:e=>pe(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ee||"idle"!==$||ke()))}}),s.jsxs("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==_?void 0:_.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:je?U.accent+"10":void 0},disabled:ee||"idle"!==$,onClick:()=>{var e;return null===(e=xe.current)||void 0===e?void 0:e.click()}},ve,{children:[s.jsx("input",{id:"file-upload",ref:xe,type:"file",accept:[...u.allowedFileMimeTypes,...se?u.allowedImageMimeTypes:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield oe(Array.from(s.target.files||[])),s.target.value=""}))}),s.jsx(h.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:je?U.accent:U.accent+"80"}})]})),s.jsx("button",Object.assign({id:(null==_?void 0:_.formid)+"--chat-button",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:fe||me.length||Z.length&&Z.every((e=>"finished"===e.status))?U.accent:U.accent+"10"},disabled:ee||"idle"!==$,onClick:()=>ke()},he,{children:s.jsx(y.default,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:fe||me.length||Z.length&&Z.every((e=>"finished"===e.status))?U.accentText:U.accent+"80"}})}))]}))]}))]}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/studio/useStyleFontSize.js"),c=require("../../../Icons/check.svg.js"),r=require("./Dropdown.js"),a=require("../../../../common/cn.js");exports.default=({field:o,update:l})=>{const{colors:u}=t.usePickaxeContext(),{setError:d}=i.useResponseContext(),p=n.useStyleFontSize(),x=s.useMemo((()=>o.input?o.input.split(","):[]),[o.input]);return e.jsxs("div",Object.assign({className:"flex flex-col gap-y-3"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../hooks/pickaxe/useResponseContext.js"),n=require("../../../../hooks/studio/useStyleFontSize.js"),c=require("../../../Icons/check.svg.js"),r=require("./Dropdown.js"),a=require("../../../../common/cn.js");exports.default=({field:o,update:l})=>{const{colors:u}=t.usePickaxeContext(),{setError:d}=i.useResponseContext(),p=n.useStyleFontSize(),x=s.useMemo((()=>o.input?o.input.split(","):[]),[o.input]);return e.jsxs("div",Object.assign({className:"flex flex-col gap-y-3"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[e.jsx("p",Object.assign({className:a.default(p.b3,"font-semibold opacity-70")},{children:o.main})),o.isRequired&&e.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:u.error}},{children:"*"}))]})),e.jsx(r.default,Object.assign({id:o.id.replace(/[^A-Za-z]+/g,""),value:o.input.replace(/,/g,", "),placeholder:"Select option(s)",closeOnSelect:!1,maxToken:o.maxLength,isDropdown:o.isDropdown},{children:e.jsx("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:o.example.split("S3P32X").map(((s,t)=>e.jsxs("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{d("");const s=x.includes(e),t=o.input?o.input.split(","):[],i=new Set(t);s&&i.has(e)?i.delete(e):s||i.has(e)||i.add(e);const n=Array.from(i).filter((e=>""!==e.trim()));l(Object.assign(Object.assign({},o),{input:n.join(",")}))})(s)},{children:[e.jsx("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:x.includes(s)?u.accent:u.accent+"80"},x.includes(s)&&{backgroundColor:u.accent})},{children:e.jsx(c.default,{className:a.default("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",x.includes(s)&&"opacity-100"),style:{color:u.accentText}})})),e.jsx("p",Object.assign({className:a.default(p.b2,"select-none")},{children:s}))]}),t)))}))}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),l=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleInput.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),o=require("../../Addons/Document/hooks/useDocument.js"),i=require("../../../../hooks/core/useHover.js"),n=require("../../../../common/documents.js"),c=require("../../../../common/utils.js"),d=require("../../../Icons/attach-vertical.svg.js"),u=require("../../../Icons/check.svg.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),l=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/studio/useStyleInput.js"),r=require("../../../../hooks/studio/useStyleFontSize.js"),o=require("../../Addons/Document/hooks/useDocument.js"),i=require("../../../../hooks/core/useHover.js"),n=require("../../../../common/documents.js"),c=require("../../../../common/utils.js"),d=require("../../../Icons/attach-vertical.svg.js"),u=require("../../../Icons/check.svg.js"),b=require("../../../Icons/spinner-lines.svg.js"),m=require("../../../Icons/file.svg.js"),x=require("../../../Icons/x.svg.js"),j=require("../../../Icons/link.svg.js"),f=require("../../../Core/ErrorAlert.js"),p=require("../../../../common/cn.js");exports.default=({field:h,update:g})=>{var y;const v=r.useStyleFontSize(),{colors:w,styles:N,translations:k,responsiveBy:O}=l.usePickaxeContext(),C=i.useHover(),{isHover:q}=C,I=e.__rest(C,["isHover"]),{documents:R,documentError:T,websiteLink:_,isUploading:D,isImageUploadAllowed:F,upsertDocuments:S,setDocumentError:A,setWebsiteLink:U,onFileUpload:z,onWebsiteUpload:E}=o.useDocument({onQuestionChange:e=>{g(Object.assign(Object.assign({},h),e))}}),[H,P]=t.useState(!1),B=t.useRef(null),L=a.useStyleInput();return s.jsxs("div",Object.assign({className:"flex flex-col gap-y-4"},{children:[s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[s.jsx("p",Object.assign({className:p.default(v.b3,"font-semibold opacity-70")},{children:h.main})),h.isRequired&&s.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:w.error}},{children:"*"}))]})),s.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[s.jsx("input",{ref:B,type:"file",accept:[...n.allowedFileMimeTypes,...F?n.allowedImageMimeTypes:[]].join(", "),id:h.id,hidden:!0,multiple:!1,className:"hidden",onChange:s=>e.__awaiter(void 0,void 0,void 0,(function*(){yield z(Array.from(s.target.files||[])),s.target.value=""})),disabled:D}),s.jsxs("div",Object.assign({className:p.default("flex items-center justify-between rounded-sm border border-transparent bg-white py-3 pl-4 pr-3 duration-300 ease-in-out transition-all",H&&"block"===N.formFieldStyle&&"shadow","block"===N.formFieldStyle&&"shadow hover:shadow-none"),style:L},{children:[s.jsx("input",{type:"text",value:_,className:p.default(v.b2,"w-full outline-none ring-0 bg-transparent placeholder:text-inherit placeholder:opacity-50"),placeholder:null!==(y=null==k?void 0:k["form-doc-placeholder"])&&void 0!==y?y:"Paste a website/video link or drag a file",onChange:e=>U(e.target.value),onDrop:s=>e.__awaiter(void 0,void 0,void 0,(function*(){s.preventDefault(),yield z(Array.from(s.dataTransfer.files||[]))})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),E(_))},onFocus:()=>P(!0),onBlur:()=>P(!1)}),s.jsx("div",Object.assign({className:"flex items-center gap-3 pl-4"},{children:_.length>0?s.jsxs(s.Fragment,{children:[s.jsx("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:D,onClick:()=>E(_)},{children:s.jsx(u.default,{className:"h-5 w-5 shrink-0",style:{color:w.accent}})})),s.jsx("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:D,onClick:()=>{U(""),A("")}},{children:s.jsx(x.default,{className:"h-6 w-6 shrink-0",style:{color:w.accent}})}))]}):s.jsx("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",disabled:D,onClick:()=>{var e;null===(e=B.current)||void 0===e||e.click()},style:{backgroundColor:q?w.accent+"10":void 0}},I,{children:s.jsx(d.default,{className:"h-6 w-6 shrink-0",style:{color:q?w.accent:w.accent+"80"}})}))}))]}))]}))]})),R.length>0&&s.jsx("div",Object.assign({className:p.default("flex gap-4","viewport"===O?"min-[765px]:flex-col":"@[767px]/pickaxe-root:flex-col")},{children:R.map((e=>{var l,a,r;return s.jsx(t.Fragment,{children:"document"===e.type?s.jsxs("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:L},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:w.accent,borderRadius:L.borderRadius}},{children:D?s.jsx(b.default,{className:"w-5 h-5 animate-spin",style:{color:w.accentText}}):s.jsx(m.default,{className:"w-5 h-5",style:{color:w.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(p.default(v.b3),"font-medium truncate")},{children:e.name})),s.jsx("p",Object.assign({className:p.default(v.b4,"opacity-80 truncate")},{children:c.formatBytes(e.size)}))]})),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:w.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4",style:{color:w.accentText}})}))]})):"image"===e.type?s.jsxs("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:L.borderRadius}},{children:["finished"===e.status?s.jsx("img",{style:{borderRadius:L.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[2]}/${null===(a=e.documentId)||void 0===a?void 0:a.split("-")[1]}.${null===(r=e.documentId)||void 0===r?void 0:r.split("-")[2]}`,alt:""}):s.jsx("div",{className:"h-full w-full animate-pulse",style:{borderRadius:L.borderRadius,backgroundColor:w.secondary}}),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:w.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4",style:{color:w.accentText}})}))]})):"website"===e.type?s.jsxs("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:L},{children:[s.jsx("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:w.accent,borderRadius:L.borderRadius}},{children:D?s.jsx(b.default,{className:"w-5 h-5 animate-spin",style:{color:w.accentText}}):s.jsx(j.default,{className:"w-5 h-5",style:{color:w.accentText}})})),s.jsxs("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s.jsx("p",Object.assign({className:(p.default(v.b3),"font-medium truncate")},{children:new URL(e.name).hostname})),s.jsx("p",Object.assign({className:p.default(v.b4,"opacity-80 truncate")},{children:"Website"}))]})),s.jsx("button",Object.assign({type:"button",disabled:D,onClick:()=>S([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:w.accent,borderColor:L.backgroundColor}},{children:s.jsx(x.default,{className:"w-4 h-4",style:{color:w.accentText}})}))]})):null},e.id)}))})),T&&s.jsx(f.default,{error:T,className:"mt-3"})]}))};
|
|
@@ -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"),r=require("react/jsx-runtime"),s=require("react"),o=require("../../../../hooks/pickaxe/usePickaxeContext.js"),a=require("../../../../hooks/core/useHover.js"),t=require("../../../Core/Menu/index.js"),n=require("../../../Core/Menu/Button.js"),c=require("../../../Core/Menu/List.js"),d=require("../../../../common/cn.js");exports.default=({id:i,children:l,placeholder:u,value:F,className:x,style:b,closeOnSelect:j=!0,maxToken:h=50,isDropdown:p=!1})=>{const{styles:m,colors:v}=o.usePickaxeContext(),y=a.useHover(),{isHover:k}=y,g=e.__rest(y,["isHover"]),[q,w]=s.useState(!1);return p?r.jsxs(t.default,Object.assign({id:i,closeOnSelect:j,onChange:w,className:"relative"},{children:[r.jsx(n.default,Object.assign({variant:"anchor",className:d.default("flex items-center justify-between rounded-sm border border-transparent py-3 pl-4 pr-3 shadow duration-300 hover:border-black/25",x,q&&"border-black/70 shadow-none hover:border-black/70 dark:border-white/70 dark:hover:border-white/70",h<=50&&"max-w-[400px]"),style:Object.assign({backgroundColor:"#FFFFFF"===v.secondaryText?"#000000":"#FFFFFF",color:v.secondaryText,borderRadius:`${m.cornerRadius}px`,borderColor:q?v.secondaryText+"B3":k?v.secondaryText+(q?"B3":"40"):"transparent"},b)},g,{children:r.jsx("p",Object.assign({className:"line-clamp-1 select-none"},{children:(null!=F?F:"")||u}))})),r.jsx(c.default,Object.assign({className:"p-3 shadow-md",border:"#FFFFFF"===v.secondaryText?"1px solid rgba(255,255,255,0.7)":"1px solid rgba(0,0,0,0.7)",align:"bottom-end",width:h<=50?"400px":"100%",style:Object.assign({backgroundColor:"#FFFFFF"===v.secondaryText?"#000000":"#FFFFFF",color:v.secondaryText},b)},{children:l}))]})):r.jsx("div",{children:l})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),a=require("../../../../hooks/studio/useStyleInput.js"),n=require("../../../../hooks/studio/useStyleFontSize.js"),r=require("@nem035/gpt-3-encoder"),i=require("../../../Core/Textarea.js"),l=require("../../../../common/cn.js");exports.default=({field:c,update:u})=>{const d=n.useStyleFontSize(),{styles:p,colors:x}=t.usePickaxeContext(),{setError:h}=o.useResponseContext(),[g,m]=s.useState(!1),j=a.useStyleInput();return e.jsxs("div",Object.assign({className:"group relative flex flex-col gap-y-1"},{children:[e.jsxs("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[e.jsx("p",Object.assign({className:l.default(d.b3,"font-semibold opacity-70")},{children:c.main})),c.isRequired&&e.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:x.accent}},{children:"*"}))]})),e.jsx(i.default,{className:l.default(d.b2,"rounded-sm border border-transparent px-4 py-3 duration-300 ease-in-out transition-all placeholder:font-semilight",c.maxLength<10&&"max-w-[400px]","block"===p.formFieldStyle&&"shadow hover:shadow-none"),style:j,placeholder:c.example,rows:1,value:c.input,tabIndex:c.order,onChange:e=>{h("");const s=r.encode(e).length;u(Object.assign(Object.assign({},c),{input:e,length:s}))},onFocus:()=>m(!0),onBlur:()=>m(!1)})]})),e.jsx("div",Object.assign({className:"pointer-events-none absolute bottom-0 right-0 p-1 px-2"},{children:e.jsxs("p",Object.assign({className:l.default(d.b4,"font-semibold opacity-20 opacity-0 group-hover:opacity-100 group-hover:duration-200",c.length>c.maxLength&&"text-c-red opacity-100",g&&"opacity-100")},{children:[c.length,"/",c.maxLength]}))}))]}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("./Dropdown.js"),a=require("../../../../common/cn.js");exports.default=({field:r,update:c})=>{const{colors:o}=s.usePickaxeContext(),{setError:l}=t.useResponseContext(),d=i.useStyleFontSize();return e.jsxs("div",Object.assign({className:"flex flex-col gap-y-3"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("./Dropdown.js"),a=require("../../../../common/cn.js");exports.default=({field:r,update:c})=>{const{colors:o}=s.usePickaxeContext(),{setError:l}=t.useResponseContext(),d=i.useStyleFontSize();return e.jsxs("div",Object.assign({className:"flex flex-col gap-y-3"},{children:[e.jsxs("div",Object.assign({className:"flex items-center gap-1"},{children:[e.jsx("p",Object.assign({className:a.default(d.b3,"font-semibold opacity-70")},{children:r.main})),r.isRequired&&e.jsx("span",Object.assign({className:"select-none font-semibold",style:{color:o.error}},{children:"*"}))]})),e.jsx(n.default,Object.assign({id:r.id.replace(/[^A-Za-z]+/g,""),value:r.input,placeholder:"Select an option",closeOnSelect:!1,maxToken:r.maxLength,isDropdown:r.isDropdown},{children:e.jsx("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:r.example.split("S3P32X").map(((s,t)=>e.jsxs("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>{return e=s,l(""),void c(Object.assign(Object.assign({},r),{input:e}));var e}},{children:[e.jsx("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2",style:Object.assign({borderColor:r.input===s?o.accent:o.accent+"80"},r.input===s&&{backgroundColor:o.accent})},{children:e.jsx("div",{className:a.default("h-2 w-2 shrink-0 transition-opacity opacity-0 ease-in-out duration-200 rounded-full",r.input===s&&"opacity-100"),style:{backgroundColor:o.accentText}})})),e.jsx("p",Object.assign({className:a.default(d.b2,"select-none")},{children:s}))]}),t)))}))}))]}))};
|
|
@@ -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"),i=require("../../hooks/usePickaxeMarkdownContext.js"),a=require("../common/Action.js"),
|
|
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"),i=require("../../hooks/usePickaxeMarkdownContext.js"),a=require("../common/Action.js"),o=require("../Img/index.js"),n=require("../common/Audio.js"),u=require("../common/Html/index.js"),c=require("../../../../../../common/api/utils.js"),l=require("../../../../../../common/error.js");exports.default=({node:d,href:f="",children:p})=>{const{accentColor:m,websiteMetadatas:h,linkPreviews:w,actions:j,setWebsiteMetadatas:x}=i.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,t=setTimeout((()=>{e!==b&&v(e)}),200);return()=>clearTimeout(t)}),[f,b]),s.useQuery({queryKey:["website-metadata",b],queryFn:()=>e.__awaiter(void 0,void 0,void 0,(function*(){return 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 c.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=l.default(e);console.error("[getJobResult]",t)}return 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 g=b.match(/(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/watch\?v=|youtu\.be\/)([\w-]+)/i);if(g&&(null==g?void 0:g[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/${g[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(a.default,{jobUrl:b}):t.jsx("a",Object.assign({href:b,target:"_blank",rel:"noopener noreferrer",style:{color:m}},{children:p}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../../_virtual/_tslib.js"),i=require("react/jsx-runtime"),s=require("react-syntax-highlighter"),r=require("../../hooks/usePickaxeMarkdownContext.js"),n=require("../../../PickaxeCopyButton.js");exports.default=t=>{var a,l,{node:c,children:d,inline:o,className:u}=t,x=e.__rest(t,["node","children","inline","className"]);const{syntaxTheme:h}=r.usePickaxeMarkdownContext(),j=/language-(\w+)/.exec(u||"");return!j||o?i.jsx("code",Object.assign({},x,{className:"pxe-markdown-code-inline"},{children:d})):i.jsx("div",Object.assign({className:"pxe-markdown-code"},{children:i.jsxs("div",{children:[i.jsx("div",{children:i.jsx(n.default,{color:"#FFFFFF",text:null!==(a=null==d?void 0:d.toString())&&void 0!==a?a:"",iconClassName:"w-4 h-4 text-white"})}),i.jsx("div",{children:i.jsx(s.Prism,Object.assign({},x,{PreTag:"div",language:null!==(l=null==j?void 0:j[1])&&void 0!==l?l:"js",style:h,showLineNumbers:!0},{children:String(d).replace(/\n$/,"")}))})]})}))};
|
|
@@ -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"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),r=require("react/jsx-runtime"),n=require("react"),s=require("./hooks/usePickaxeMarkdownContext.js"),t=require("react-markdown"),i=require("remark-gfm"),l=require("remark-math"),d=require("rehype-katex"),a=require("rehype-raw"),o=require("./Custom/A/index.js"),c=require("./Custom/P/index.js"),u=require("./Custom/Img/index.js"),h=require("./Custom/Iframe/index.js"),x=require("./Custom/Code/index.js"),p=require("./Custom/common/LinkPreview.js"),j=require("../../../../common/cn.js");function m(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=m(t),g=m(i),b=m(l),k=m(d),w=m(a);exports.PickaxeMarkdownRenderer=({className:t,style:i,value:l,recursion:d=!1,children:a,maxLines:m,multiLineBreaks:q,onExpandClick:v})=>{const{theme:y,accentColor:C,websiteMetadatas:D}=s.usePickaxeMarkdownContext(),[O,M]=n.useState({width:0,height:0}),[P,S]=n.useState(null),$=n.useRef(null),E=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)+"$")),q&&(e=e.replace(/```[\s\S]*?```|(\n(?=\n))/g,((e,r)=>r?"\n\n<br/>\n":e))),e||""}),[l,q]);n.useEffect((()=>{if(!m)return void S(null);if(!$.current||!E||P)return;const e=$.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=m*r;if(!(O.height>n))return;const s=Math.floor(O.width/8),t=Math.floor(s*m);S(E.slice(0,t)+'<span class="pxe-expand-btn">...</span>')}),[E,m,O,P]);const N={h1:({node:e,children:n})=>r.jsx("h1",{children:n}),h2:({node:e,children:n})=>r.jsx("h2",{children:n}),h3:({node:e,children:n})=>r.jsx("h3",{children:n}),h4:({node:e,children:n})=>r.jsx("h4",{children:n}),h5:({node:e,children:n})=>r.jsx("h5",{children:n}),p:c.default,a:o.default,ol:({node:e,children:n})=>r.jsx("ol",{children:n}),ul:({node:e,children:n})=>r.jsx("ul",{children:n}),li:({node:e,children:n})=>r.jsx("li",{children:n}),table:({children:e})=>r.jsx("div",Object.assign({className:"pxe-markdown-table"},{children:r.jsx("table",{children:e})})),th:({node:e,children:n})=>r.jsx("th",{children:n}),tr:({node:e,children:n})=>r.jsx("tr",Object.assign({style:{border:"dark"===y?"1px solid #30363D":"1px solid #D0D7DE"}},{children:n})),td:({node:e,children:n})=>r.jsx("td",{children:n}),code:x.default,blockquote:({node:e,children:n})=>r.jsx("blockquote",Object.assign({style:{borderLeft:"dark"===y?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===y?"#8B8B8B":"#656D76"}},{children:n})),img:u.default,iframe:h.default,hr:()=>r.jsx("hr",{style:{border:0,borderTop:"dark"===y?"1px solid #30363D":"1px solid #D0D7DE"}}),span:n=>{var{node:s,children:t}=n,i=e.__rest(n,["node","children"]);return"pxe-expand-btn"===i.className?r.jsx("span",Object.assign({},i,{style:Object.assign({display:"inline",fontWeight:500,color:C,marginLeft:".25rem",userSelect:"none"},v&&{cursor:"pointer"})},v&&{onClick:v},{children:t})):r.jsx("span",Object.assign({},i,{children:t}))},br:()=>r.jsx("br",{})};n.useEffect((()=>{if(!$.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;M({width:e,height:n})}}));return e.observe($.current),()=>{e.disconnect()}}),[]);const _=P||E,B=!d&&D.length>0?"\n\n---":"";return r.jsxs("div",Object.assign({className:"pxe-markdown",ref:$,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},i)},{children:[r.jsx(f.default,Object.assign({className:j.default(!d&&"pxe-prose",t),components:N,remarkPlugins:[g.default,b.default],rehypePlugins:[k.default,w.default]},{children:`${_}${B}`})),!d&&D.length>0&&r.jsx("div",Object.assign({className:"pxe-link-previews"},{children:D.map(((e,n)=>r.jsx(p.default,{data:e},n)))})),a]}))};
|
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-youtube{margin-bottom:1.5rem;margin-top:1.5rem}.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}.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),.pxe-prose h3:not(:first-child),.pxe-prose h4:not(:first-child),.pxe-prose h5:not(:first-child){margin-top:2.5rem}.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>p:first-child>.pxe-markdown-image,.pxe-prose>p:first-child>.pxe-markdown-youtube{margin-top:0}
|
|
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-youtube{margin-bottom:1.5rem;margin-top:1.5rem}.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),.pxe-prose h3:not(:first-child),.pxe-prose h4:not(:first-child),.pxe-prose h5:not(:first-child){margin-top:2.5rem}.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-prose .pxe-animated-token{animation:fadeIn .3s ease-out forwards;display:inline-block;opacity:0}.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-youtube{margin-top:0}@keyframes fadeIn{0%{opacity:0;transform:translateX(5px)}to{opacity:1;transform:translateX(0)}}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type FC, type ComponentPropsWithoutRef } from "react";
|
|
2
2
|
import type { Node } from "../../Renderer";
|
|
3
|
-
declare const Code: FC<ComponentPropsWithoutRef<"code"> & Node
|
|
3
|
+
declare const Code: FC<ComponentPropsWithoutRef<"code"> & Node & {
|
|
4
|
+
inline?: boolean;
|
|
5
|
+
}>;
|
|
4
6
|
export default Code;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as r,useRef as i,useMemo as n,useEffect as a,Fragment as l}from"react";import{usePickaxeContext as d}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as u}from"../../../hooks/pickaxe/useDimensionContext.js";import{useStyleInput as m}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as p}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as f}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as h}from"../../../hooks/pickaxe/useSubmit.js";import{useSubmitResult as g}from"../../../hooks/pickaxe/useSubmitResult.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as v}from"../../../common/documents.js";import{streamer as x}from"../../../common/api/streamer.js";import{useDocument as j}from"../Addons/Document/hooks/useDocument.js";import{useScroll as y}from"../Addons/Scroll/hooks/useScroll.js";import{useHover as k}from"../../../hooks/core/useHover.js";import{formatBytes as I}from"../../../common/utils.js";import w from"../../Icons/attach-vertical.svg.js";import O from"../../Icons/spinner-lines.svg.js";import N from"../../Icons/file.svg.js";import C from"../../Icons/x.svg.js";import S from"../../Icons/arrow-right.svg.js";import R from"../common/PickaxeBranding.js";import D from"../Addons/IceBreaker/index.js";import A from"
|
|
1
|
+
import{__rest as e,__awaiter as t}from"../../../_virtual/_tslib.js";import{jsxs as o,jsx as s}from"react/jsx-runtime";import{useState as r,useRef as i,useMemo as n,useEffect as a,Fragment as l}from"react";import{usePickaxeContext as d}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as u}from"../../../hooks/pickaxe/useDimensionContext.js";import{useStyleInput as m}from"../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as p}from"../../../hooks/studio/useStyleFontSize.js";import{useConversation as f}from"../../../hooks/pickaxe/useConversation.js";import{useSubmit as h}from"../../../hooks/pickaxe/useSubmit.js";import{useSubmitResult as g}from"../../../hooks/pickaxe/useSubmitResult.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as v}from"../../../common/documents.js";import{streamer as x}from"../../../common/api/streamer.js";import{useDocument as j}from"../Addons/Document/hooks/useDocument.js";import{useScroll as y}from"../Addons/Scroll/hooks/useScroll.js";import{useHover as k}from"../../../hooks/core/useHover.js";import{formatBytes as I}from"../../../common/utils.js";import w from"../../Icons/attach-vertical.svg.js";import O from"../../Icons/spinner-lines.svg.js";import N from"../../Icons/file.svg.js";import C from"../../Icons/x.svg.js";import S from"../../Icons/arrow-right.svg.js";import R from"../common/PickaxeBranding.js";import D from"../Addons/IceBreaker/index.js";import A from"../../Core/Textarea.js";import U from"../../../common/error.js";import T from"../../../common/cn.js";const B=()=>{var B;const{formId:E,chatId:H,userId:L,studioUserId:z,deploymentId:F,pickaxe:M,styles:P,colors:W,misc:$,chatInput:G,responsiveBy:K,forceMobile:_,isNewChat:q,setIsNewChat:J,setIsShowIceBreaker:Q,onGenerateComplete:V}=d(),{messages:X,status:Y,limits:Z,setMessages:ee,setStatus:te,setLimitData:oe,setError:se,setIsGenerating:re}=c(),{isMobile:ie}=u(),{documents:ne,isUploading:ae,isImageUploadAllowed:le,upsertDocuments:de,onFileUpload:ce}=j(),{scrollStartSession:ue,scrollEndSession:me,scrollToBottom:pe}=y({auto:!0}),fe=f(),he=h(),ge=g(),be=p(),ve=m(),[xe,je]=r(G),ye=i(null),ke=k(),{isHover:Ie}=ke,we=e(ke,["isHover"]),Oe=k(),{isHover:Ne}=Oe,Ce=e(Oe,["isHover"]),Se=n((()=>{var e,t,o;return!!q&&(!!M&&(!fe.isLoading&&(!((null!==(t=null===(e=fe.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&!!(null===(o=M.icebreakers)||void 0===o?void 0:o.length))))}),[M,q,fe.data,fe.isLoading]),Re=e=>t(void 0,void 0,void 0,(function*(){try{if(ae||"idle"!==Y)return;const t=null!=e?e:xe;if(!t)return;je(""),se(""),oe(null),re(!0),J(!1);const o=new Date,s="enduserupload"===(null==M?void 0:M.documentuploadtype),r=ne.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),i=r.length?r[r.length-1].documentId:"";te("fetching"),ue(),pe();const n=Array.from(X);let a=[...n,{id:X.length+1,role:"user",content:t}];ee(a),pe();const{success:l,data:d,actionData:c,usedDocumentIds:u,endUserDocumentId:m,endUserImageId:p,rawUserInput:f,error:h}=yield he.mutateAsync(Object.assign(Object.assign(Object.assign({formId:E,responseId:H,value:t},s&&i&&{documentId:i}),z&&{studioUserId:z}),F&&{deploymentId:F}));if(!l)throw new Error(null!=h?h:"An error occurred, please try again.");const g=[];m&&g.push(m),p&&g.push(p),g.length>0&&(a=[...n,Object.assign({id:X.length+1,role:"user",content:t},g&&{documentIds:g})],ee(a),pe()),de([]),pe();const b=(yield x({formId:E,responseId:H,data:d,actionData:c})).body;if(!b)throw new Error("Streaming error");const v=b.getReader(),j=new TextDecoder,y=a.length;let k="",I=!0,w=!1;for(;I;){const{value:e,done:t}=yield v.read();I=!t;if(k+=j.decode(e).replace(/\u200B/g,""),k)w||(te("streaming"),w=!0),ee([...a.slice(0,y),{id:X.length+1,role:"assistant",content:k}]);else if(!I&&!k)throw new Error("Server error")}const O=new Date;k&&(pe(),te("idle"),yield ge.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:E,responseId:H,documentIds:u},L&&{userId:L}),z&&{studioUserId:z}),z&&(null==M?void 0:M.studioid)&&{studioId:M.studioid}),F&&{deploymentId:F}),{messages:[Object.assign(Object.assign({role:"user",message:f},g&&{documentIds:g}),{sentAt:o}),{role:"assistant",message:k,sentAt:O}]})),null==V||V(H))}catch(e){let t=U(e)||"";t&&!t.includes("Unexpected token 'A',")||(t="Oops! We're experiencing high traffic at the moment. Please try again later.");const o=Object.entries(Z).find((([e])=>t.includes(e)));o?oe(o[1]):se(t),pe()}finally{te("idle"),re(!1),me()}}));return a((()=>{Q(Se)}),[Se]),a((()=>{je(G)}),[G]),o("div",Object.assign({className:T("fixed flex w-full flex-col bottom-0 left-0","viewport"===K?"min-[767px]:relative min-[767px]:bottom-auto min-[767px]:left-auto":"absolute @[767px]/pickaxe-root:relative @[767px]/pickaxe-root:bottom-auto @[767px]/pickaxe-root:left-auto")},{children:[!$.isWhiteLabel&&s("div",Object.assign({className:"flex justify-end pr-3 pb-3 @[767px]/pickaxe-root:pr-0"},{children:s(R,{animateHover:!0})})),Se&&s(D,{data:(null==M?void 0:M.icebreakers)||[],onSend:Re}),o("div",Object.assign({id:(null==M?void 0:M.formid)+"--chat-parent",style:Object.assign(Object.assign({},ve),(ie||_)&&{paddingLeft:"0.75rem",paddingRight:"0.75rem"}),className:T("flex min-h-[56px] flex-col gap-y-2 px-4 py-3 pb-[15px]","block"===P.formFieldStyle&&"shadow")},{children:["idle"===Y&&ne.length>0&&s("div",Object.assign({className:T("grid grid-cols-1","viewport"===K?"min-[765px]:grid-cols-2":"@[767px]/pickaxe-root:grid-cols-2")},{children:ne.map((e=>{var t,r,i;return s(l,{children:"document"===e.type?o("div",Object.assign({className:"relative gap-x-[10px] flex items-center px-2 h-[56px] border",style:{borderRadius:ve.borderRadius,borderColor:W.secondaryText+"50"}},{children:[s("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:W.accent,borderRadius:ve.borderRadius}},{children:ae?s(O,{className:"w-5 h-5 animate-spin",style:{color:W.accentText}}):s(N,{className:"w-5 h-5",style:{color:W.accentText}})})),o("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[s("p",Object.assign({className:(T(be.b3),"font-medium truncate")},{children:e.name})),s("p",Object.assign({className:T(be.b4,"opacity-80 truncate")},{children:I(e.size)}))]})),s("button",Object.assign({type:"button",disabled:ae||"idle"!==Y,onClick:()=>de([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:W.accent,borderColor:ve.backgroundColor}},{children:s(C,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):"image"===e.type?o("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:ve.borderRadius}},{children:["finished"===e.status?s("img",{style:{borderRadius:ve.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:ve.borderRadius,backgroundColor:W.secondary}}),s("button",Object.assign({type:"button",disabled:ae||"idle"!==Y,onClick:()=>de([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:W.accent,borderColor:ve.backgroundColor}},{children:s(C,{className:"w-4 h-4",style:{color:W.accentText}})}))]})):null},e.id)}))})),o("div",Object.assign({className:"flex items-end gap-x-2 grow"},{children:[s(A,{id:(null==M?void 0:M.formid)+"--chat-textarea",className:T(be.b2,"max-h-60 mb-[0.2em] w-full border-transparent bg-transparent",!xe.length&&"max-h-6 overflow-hidden text-ellipsis whitespace-nowrap"),value:xe,placeholder:null!==(B=null==M?void 0:M.placeholdertext)&&void 0!==B?B:"What do you want to talk about?",onChange:e=>je(e),onKeyDown:e=>{"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),ae||"idle"!==Y||Re()))}}),o("div",Object.assign({className:"flex items-center gap-x-2"},{children:["enduserupload"===(null==M?void 0:M.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:Ne?W.accent+"10":void 0},disabled:ae||"idle"!==Y,onClick:()=>{var e;return null===(e=ye.current)||void 0===e?void 0:e.click()}},Ce,{children:[s("input",{id:"file-upload",ref:ye,type:"file",accept:[...b,...le?v:[]].join(", "),multiple:!1,hidden:!0,className:"hidden",onChange:e=>t(void 0,void 0,void 0,(function*(){yield ce(Array.from(e.target.files||[])),e.target.value=""}))}),s(w,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:Ne?W.accent:W.accent+"80"}})]})),s("button",Object.assign({id:(null==M?void 0:M.formid)+"--chat-button",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:Ie||xe.length||ne.length&&ne.every((e=>"finished"===e.status))?W.accent:W.accent+"10"},disabled:ae||"idle"!==Y,onClick:()=>Re()},we,{children:s(S,{className:"h-6 w-6 shrink-0 duration-200 transition-colors ease-in-out",style:{color:Ie||xe.length||ne.length&&ne.every((e=>"finished"===e.status))?W.accentText:W.accent+"80"}})}))]}))]}))]}))]}))};export{B as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as t}from"react";import{usePickaxeContext as i}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as o}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import c from"../../../Icons/check.svg.js";import r from"./Dropdown.js";import a from"../../../../common/cn.js";const l=({field:l,update:p})=>{const{colors:m}=i(),{setError:d}=o(),u=n(),f=t((()=>l.input?l.input.split(","):[]),[l.input]);return e("div",Object.assign({className:"flex flex-col gap-y-3"},{children:[e("div",Object.assign({className:"flex items-center gap-
|
|
1
|
+
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{useMemo as t}from"react";import{usePickaxeContext as i}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as o}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import c from"../../../Icons/check.svg.js";import r from"./Dropdown.js";import a from"../../../../common/cn.js";const l=({field:l,update:p})=>{const{colors:m}=i(),{setError:d}=o(),u=n(),f=t((()=>l.input?l.input.split(","):[]),[l.input]);return e("div",Object.assign({className:"flex flex-col gap-y-3"},{children:[e("div",Object.assign({className:"flex items-center gap-1"},{children:[s("p",Object.assign({className:a(u.b3,"font-semibold opacity-70")},{children:l.main})),l.isRequired&&s("span",Object.assign({className:"select-none font-semibold",style:{color:m.error}},{children:"*"}))]})),s(r,Object.assign({id:l.id.replace(/[^A-Za-z]+/g,""),value:l.input.replace(/,/g,", "),placeholder:"Select option(s)",closeOnSelect:!1,maxToken:l.maxLength,isDropdown:l.isDropdown},{children:s("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:l.example.split("S3P32X").map(((t,i)=>e("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>(e=>{d("");const s=f.includes(e),t=l.input?l.input.split(","):[],i=new Set(t);s&&i.has(e)?i.delete(e):s||i.has(e)||i.add(e);const o=Array.from(i).filter((e=>""!==e.trim()));p(Object.assign(Object.assign({},l),{input:o.join(",")}))})(t)},{children:[s("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center border-2 rounded-sm transition-colors ease-in-out duration-200",style:Object.assign({borderColor:f.includes(t)?m.accent:m.accent+"80"},f.includes(t)&&{backgroundColor:m.accent})},{children:s(c,{className:a("h-3 w-3 shrink-0 transition-opacity opacity-0 ease-in-out duration-200",f.includes(t)&&"opacity-100"),style:{color:m.accentText}})})),s("p",Object.assign({className:a(u.b2,"select-none")},{children:t}))]}),i)))}))}))]}))};export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e,__awaiter as s}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as r,Fragment as n}from"react";import{usePickaxeContext as i}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleInput as c}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as
|
|
1
|
+
import{__rest as e,__awaiter as s}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o,Fragment as l}from"react/jsx-runtime";import{useState as a,useRef as r,Fragment as n}from"react";import{usePickaxeContext as i}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useStyleInput as c}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as d}from"../../../../hooks/studio/useStyleFontSize.js";import{useDocument as u}from"../../Addons/Document/hooks/useDocument.js";import{useHover as m}from"../../../../hooks/core/useHover.js";import{allowedFileMimeTypes as b,allowedImageMimeTypes as p}from"../../../../common/documents.js";import{formatBytes as f}from"../../../../common/utils.js";import h from"../../../Icons/attach-vertical.svg.js";import g from"../../../Icons/check.svg.js";import y from"../../../Icons/spinner-lines.svg.js";import v from"../../../Icons/file.svg.js";import x from"../../../Icons/x.svg.js";import j from"../../../Icons/link.svg.js";import N from"../../../Core/ErrorAlert.js";import w from"../../../../common/cn.js";const k=({field:k,update:O})=>{var C;const R=d(),{colors:I,styles:D,translations:T,responsiveBy:F}=i(),A=m(),{isHover:S}=A,U=e(A,["isHover"]),{documents:E,documentError:z,websiteLink:H,isUploading:L,isImageUploadAllowed:W,upsertDocuments:$,setDocumentError:B,setWebsiteLink:P,onFileUpload:_,onWebsiteUpload:q}=u({onQuestionChange:e=>{O(Object.assign(Object.assign({},k),e))}}),[K,Q]=a(!1),G=r(null),J=c();return t("div",Object.assign({className:"flex flex-col gap-y-4"},{children:[t("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[t("div",Object.assign({className:"flex items-center gap-1"},{children:[o("p",Object.assign({className:w(R.b3,"font-semibold opacity-70")},{children:k.main})),k.isRequired&&o("span",Object.assign({className:"select-none font-semibold",style:{color:I.error}},{children:"*"}))]})),t("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[o("input",{ref:G,type:"file",accept:[...b,...W?p:[]].join(", "),id:k.id,hidden:!0,multiple:!1,className:"hidden",onChange:e=>s(void 0,void 0,void 0,(function*(){yield _(Array.from(e.target.files||[])),e.target.value=""})),disabled:L}),t("div",Object.assign({className:w("flex items-center justify-between rounded-sm border border-transparent bg-white py-3 pl-4 pr-3 duration-300 ease-in-out transition-all",K&&"block"===D.formFieldStyle&&"shadow","block"===D.formFieldStyle&&"shadow hover:shadow-none"),style:J},{children:[o("input",{type:"text",value:H,className:w(R.b2,"w-full outline-none ring-0 bg-transparent placeholder:text-inherit placeholder:opacity-50"),placeholder:null!==(C=null==T?void 0:T["form-doc-placeholder"])&&void 0!==C?C:"Paste a website/video link or drag a file",onChange:e=>P(e.target.value),onDrop:e=>s(void 0,void 0,void 0,(function*(){e.preventDefault(),yield _(Array.from(e.dataTransfer.files||[]))})),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),q(H))},onFocus:()=>Q(!0),onBlur:()=>Q(!1)}),o("div",Object.assign({className:"flex items-center gap-3 pl-4"},{children:H.length>0?t(l,{children:[o("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:L,onClick:()=>q(H)},{children:o(g,{className:"h-5 w-5 shrink-0",style:{color:I.accent}})})),o("button",Object.assign({className:"outline-none disabled:cursor-wait disabled:opacity-80",disabled:L,onClick:()=>{P(""),B("")}},{children:o(x,{className:"h-6 w-6 shrink-0",style:{color:I.accent}})}))]}):o("button",Object.assign({className:"outline-none disabled:cursor-default w-8 h-8 flex items-center justify-center rounded-full transition-colors duration-200 ease-in-out",disabled:L,onClick:()=>{var e;null===(e=G.current)||void 0===e||e.click()},style:{backgroundColor:S?I.accent+"10":void 0}},U,{children:o(h,{className:"h-6 w-6 shrink-0",style:{color:S?I.accent:I.accent+"80"}})}))}))]}))]}))]})),E.length>0&&o("div",Object.assign({className:w("flex gap-4","viewport"===F?"min-[765px]:flex-col":"@[767px]/pickaxe-root:flex-col")},{children:E.map((e=>{var s,l,a;return o(n,{children:"document"===e.type?t("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:J},{children:[o("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:I.accent,borderRadius:J.borderRadius}},{children:L?o(y,{className:"w-5 h-5 animate-spin",style:{color:I.accentText}}):o(v,{className:"w-5 h-5",style:{color:I.accentText}})})),t("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[o("p",Object.assign({className:(w(R.b3),"font-medium truncate")},{children:e.name})),o("p",Object.assign({className:w(R.b4,"opacity-80 truncate")},{children:f(e.size)}))]})),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4",style:{color:I.accentText}})}))]})):"image"===e.type?t("div",Object.assign({className:"relative h-[56px] w-[56px] bg-stone-100",style:{borderRadius:J.borderRadius}},{children:["finished"===e.status?o("img",{style:{borderRadius:J.borderRadius},className:"object-cover w-full h-full",src:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/documentinterrogation/${null===(s=e.documentId)||void 0===s?void 0:s.split("-")[2]}/${null===(l=e.documentId)||void 0===l?void 0:l.split("-")[1]}.${null===(a=e.documentId)||void 0===a?void 0:a.split("-")[2]}`,alt:""}):o("div",{className:"h-full w-full animate-pulse",style:{borderRadius:J.borderRadius,backgroundColor:I.secondary}}),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4",style:{color:I.accentText}})}))]})):"website"===e.type?t("div",Object.assign({className:"relative w-full max-w-[350px] gap-x-[10px] flex items-center px-2 h-[56px] border",style:J},{children:[o("div",Object.assign({className:"w-10 h-10 flex items-center justify-center shrink-0",style:{backgroundColor:I.accent,borderRadius:J.borderRadius}},{children:L?o(y,{className:"w-5 h-5 animate-spin",style:{color:I.accentText}}):o(j,{className:"w-5 h-5",style:{color:I.accentText}})})),t("div",Object.assign({className:"flex flex-col justify-center truncate"},{children:[o("p",Object.assign({className:(w(R.b3),"font-medium truncate")},{children:new URL(e.name).hostname})),o("p",Object.assign({className:w(R.b4,"opacity-80 truncate")},{children:"Website"}))]})),o("button",Object.assign({type:"button",disabled:L,onClick:()=>$([]),className:"absolute w-5 h-5 rounded-full -right-2 -top-2 flex items-center justify-center border outline-none disabled:cursor-default",style:{backgroundColor:I.accent,borderColor:J.backgroundColor}},{children:o(x,{className:"w-4 h-4",style:{color:I.accentText}})}))]})):null},e.id)}))})),z&&o(N,{error:z,className:"mt-3"})]}))};export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as
|
|
1
|
+
import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsx as r,jsxs as o}from"react/jsx-runtime";import{useState as s}from"react";import{usePickaxeContext as a}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useHover as t}from"../../../../hooks/core/useHover.js";import n from"../../../Core/Menu/index.js";import c from"../../../Core/Menu/Button.js";import i from"../../../Core/Menu/List.js";import d from"../../../../common/cn.js";const l=({id:l,children:m,placeholder:F,value:b,className:p,style:x,closeOnSelect:h=!0,maxToken:u=50,isDropdown:j=!1})=>{const{styles:y,colors:f}=a(),g=t(),{isHover:k}=g,v=e(g,["isHover"]),[w,C]=s(!1);return j?o(n,Object.assign({id:l,closeOnSelect:h,onChange:C,className:"relative"},{children:[r(c,Object.assign({variant:"anchor",className:d("flex items-center justify-between rounded-sm border border-transparent py-3 pl-4 pr-3 shadow duration-300 hover:border-black/25",p,w&&"border-black/70 shadow-none hover:border-black/70 dark:border-white/70 dark:hover:border-white/70",u<=50&&"max-w-[400px]"),style:Object.assign({backgroundColor:"#FFFFFF"===f.secondaryText?"#000000":"#FFFFFF",color:f.secondaryText,borderRadius:`${y.cornerRadius}px`,borderColor:w?f.secondaryText+"B3":k?f.secondaryText+(w?"B3":"40"):"transparent"},x)},v,{children:r("p",Object.assign({className:"line-clamp-1 select-none"},{children:(null!=b?b:"")||F}))})),r(i,Object.assign({className:"p-3 shadow-md",border:"#FFFFFF"===f.secondaryText?"1px solid rgba(255,255,255,0.7)":"1px solid rgba(0,0,0,0.7)",align:"bottom-end",width:u<=50?"400px":"100%",style:Object.assign({backgroundColor:"#FFFFFF"===f.secondaryText?"#000000":"#FFFFFF",color:f.secondaryText},x)},{children:m}))]})):r("div",{children:m})};export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useState as t}from"react";import{usePickaxeContext as s}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as
|
|
1
|
+
import{jsxs as e,jsx as o}from"react/jsx-runtime";import{useState as t}from"react";import{usePickaxeContext as s}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as a}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleInput as n}from"../../../../hooks/studio/useStyleInput.js";import{useStyleFontSize as r}from"../../../../hooks/studio/useStyleFontSize.js";import{encode as i}from"@nem035/gpt-3-encoder";import c from"../../../Core/Textarea.js";import l from"../../../../common/cn.js";const m=({field:m,update:p})=>{const d=r(),{styles:h,colors:g}=s(),{setError:u}=a(),[x,b]=t(!1),f=n();return e("div",Object.assign({className:"group relative flex flex-col gap-y-1"},{children:[e("div",Object.assign({className:"flex flex-col gap-y-2"},{children:[e("div",Object.assign({className:"flex items-center gap-1"},{children:[o("p",Object.assign({className:l(d.b3,"font-semibold opacity-70")},{children:m.main})),m.isRequired&&o("span",Object.assign({className:"select-none font-semibold",style:{color:g.accent}},{children:"*"}))]})),o(c,{className:l(d.b2,"rounded-sm border border-transparent px-4 py-3 duration-300 ease-in-out transition-all placeholder:font-semilight",m.maxLength<10&&"max-w-[400px]","block"===h.formFieldStyle&&"shadow hover:shadow-none"),style:f,placeholder:m.example,rows:1,value:m.input,tabIndex:m.order,onChange:e=>{u("");const o=i(e).length;p(Object.assign(Object.assign({},m),{input:e,length:o}))},onFocus:()=>b(!0),onBlur:()=>b(!1)})]})),o("div",Object.assign({className:"pointer-events-none absolute bottom-0 right-0 p-1 px-2"},{children:e("p",Object.assign({className:l(d.b4,"font-semibold opacity-20 opacity-0 group-hover:opacity-100 group-hover:duration-200",m.length>m.maxLength&&"text-c-red opacity-100",x&&"opacity-100")},{children:[m.length,"/",m.maxLength]}))}))]}))};export{m as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as t}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as i}from"../../../../hooks/studio/useStyleFontSize.js";import n from"./Dropdown.js";import c from"../../../../common/cn.js";const a=({field:a,update:r})=>{const{colors:l}=o(),{setError:p}=t(),d=i();return e("div",Object.assign({className:"flex flex-col gap-y-3"},{children:[e("div",Object.assign({className:"flex items-center gap-
|
|
1
|
+
import{jsxs as e,jsx as s}from"react/jsx-runtime";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as t}from"../../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as i}from"../../../../hooks/studio/useStyleFontSize.js";import n from"./Dropdown.js";import c from"../../../../common/cn.js";const a=({field:a,update:r})=>{const{colors:l}=o(),{setError:p}=t(),d=i();return e("div",Object.assign({className:"flex flex-col gap-y-3"},{children:[e("div",Object.assign({className:"flex items-center gap-1"},{children:[s("p",Object.assign({className:c(d.b3,"font-semibold opacity-70")},{children:a.main})),a.isRequired&&s("span",Object.assign({className:"select-none font-semibold",style:{color:l.error}},{children:"*"}))]})),s(n,Object.assign({id:a.id.replace(/[^A-Za-z]+/g,""),value:a.input,placeholder:"Select an option",closeOnSelect:!1,maxToken:a.maxLength,isDropdown:a.isDropdown},{children:s("div",Object.assign({className:"flex flex-col items-start gap-y-3"},{children:a.example.split("S3P32X").map(((o,t)=>e("div",Object.assign({className:"flex items-center gap-x-3 hover:cursor-pointer",onClick:()=>{return e=o,p(""),void r(Object.assign(Object.assign({},a),{input:e}));var e}},{children:[s("div",Object.assign({className:"flex h-[18px] w-[18px] shrink-0 items-center justify-center rounded-full border-2",style:Object.assign({borderColor:a.input===o?l.accent:l.accent+"80"},a.input===o&&{backgroundColor:l.accent})},{children:s("div",{className:c("h-2 w-2 shrink-0 transition-opacity opacity-0 ease-in-out duration-200 rounded-full",a.input===o&&"opacity-100"),style:{backgroundColor:l.accentText}})})),s("p",Object.assign({className:c(d.b2,"select-none")},{children:o}))]}),t)))}))}))]}))};export{a as default};
|
|
@@ -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 n from"../common/Action.js";import a 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 p=({node:p,href:d="",children:f})=>{const{accentColor:h,websiteMetadatas:w,linkPreviews:b,actions:g,setWebsiteMetadatas:j}=s(),[v,y]=r("");o((()=>{if(!d)return;const e=d.startsWith("http://")?`https://${d.slice(7)}`:d.startsWith("www.")?`https://${d}`:d
|
|
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 n from"../common/Action.js";import a 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 p=({node:p,href:d="",children:f})=>{const{accentColor:h,websiteMetadatas:w,linkPreviews:b,actions:g,setWebsiteMetadatas:j}=s(),[v,y]=r("");o((()=>{if(!d)return;const e=d.startsWith("http://")?`https://${d.slice(7)}`:d.startsWith("www.")?`https://${d}`:d,t=setTimeout((()=>{e!==v&&y(e)}),200);return()=>clearTimeout(t)}),[d,v]),i({queryKey:["website-metadata",v],queryFn:()=>e(void 0,void 0,void 0,(function*(){return t=v,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}}));var t})),enabled:"undefined"!=typeof window&&b&&Boolean(v)&&!w.some((e=>e.href===v))&&v.includes(".")&&!v.includes("https://prod-pickaxe-assets")&&!v.includes("https://pickaxeproject--v2"),retry:2,onSuccess:e=>{e&&e.title&&(w.some((t=>t.href===e.href))||j((t=>[...t,e])))}});const x=v.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(v.match(/\.(jpeg|jpg|gif|bmp|webp|svg|tiff|avif|png|jfif|pjpeg|pjp)$/))return t(a,{src:v,alt:"string"==typeof f?f:"Markdown Image"});if(v.match(/\.(mp3|wav|ogg|flac|aac|wma|alac|m4a|aiff|ape|au|mid|midi|opus)$/))return t(c,{url:v});return v.includes("action_generated_files")&&v.match(/\.html$/)?t(l,{url:v}):g&&v.includes("pickaxe")&&(v.includes("/api/fn/result")||v.includes("/api/function_call_results"))?t(n,{jobUrl:v}):t("a",Object.assign({href:v,target:"_blank",rel:"noopener noreferrer",style:{color:h}},{children:f}))};export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../../../../../_virtual/_tslib.js";import{jsx as
|
|
1
|
+
import{__rest as e}from"../../../../../../_virtual/_tslib.js";import{jsx as i,jsxs as n}from"react/jsx-runtime";import{Prism as r}from"react-syntax-highlighter";import{usePickaxeMarkdownContext as o}from"../../hooks/usePickaxeMarkdownContext.js";import t from"../../../PickaxeCopyButton.js";const l=l=>{var a,s,{node:c,children:d,inline:m,className:h}=l,u=e(l,["node","children","inline","className"]);const{syntaxTheme:g}=o(),x=/language-(\w+)/.exec(h||"");return!x||m?i("code",Object.assign({},u,{className:"pxe-markdown-code-inline"},{children:d})):i("div",Object.assign({className:"pxe-markdown-code"},{children:n("div",{children:[i("div",{children:i(t,{color:"#FFFFFF",text:null!==(a=null==d?void 0:d.toString())&&void 0!==a?a:"",iconClassName:"w-4 h-4 text-white"})}),i("div",{children:i(r,Object.assign({},u,{PreTag:"div",language:null!==(s=null==x?void 0:x[1])&&void 0!==s?s:"js",style:g,showLineNumbers:!0},{children:String(d).replace(/\n$/,"")}))})]})}))};export{l as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as n}from"react/jsx-runtime";import{useState as i,useRef as t,useMemo as o,useEffect as s}from"react";import{usePickaxeMarkdownContext as l}from"./hooks/usePickaxeMarkdownContext.js";import d from"react-markdown";import c from"remark-gfm";import a from"remark-math";import
|
|
1
|
+
import{__rest as e}from"../../../../_virtual/_tslib.js";import{jsxs as r,jsx as n}from"react/jsx-runtime";import{useState as i,useRef as t,useMemo as o,useEffect as s}from"react";import{usePickaxeMarkdownContext as l}from"./hooks/usePickaxeMarkdownContext.js";import d from"react-markdown";import c from"remark-gfm";import a from"remark-math";import h from"rehype-katex";import m from"rehype-raw";import p from"./Custom/A/index.js";import u from"./Custom/P/index.js";import g from"./Custom/Img/index.js";import f from"./Custom/Iframe/index.js";import b from"./Custom/Code/index.js";import x from"./Custom/common/LinkPreview.js";import k from"../../../../common/cn.js";const j=({className:j,style:w,value:v,recursion:C=!1,children:D,maxLines:y,multiLineBreaks:O,onExpandClick:$})=>{const{theme:N,accentColor:S,websiteMetadatas:B}=l(),[L,P]=i({width:0,height:0}),[E,M]=i(null),I=t(null),q=o((()=>{if(!v)return"";let e=v.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||""}),[v,O]);s((()=>{if(!y)return void M(null);if(!I.current||!q||E)return;const e=I.current,r=parseInt(window.getComputedStyle(e).lineHeight,10),n=y*r;if(!(L.height>n))return;const i=Math.floor(L.width/8),t=Math.floor(i*y);M(q.slice(0,t)+'<span class="pxe-expand-btn">...</span>')}),[q,y,L,E]);const R={h1:({node:e,children:r})=>n("h1",{children:r}),h2:({node:e,children:r})=>n("h2",{children:r}),h3:({node:e,children:r})=>n("h3",{children:r}),h4:({node:e,children:r})=>n("h4",{children:r}),h5:({node:e,children:r})=>n("h5",{children:r}),p:u,a:p,ol:({node:e,children:r})=>n("ol",{children:r}),ul:({node:e,children:r})=>n("ul",{children:r}),li:({node:e,children:r})=>n("li",{children:r}),table:({children:e})=>n("div",Object.assign({className:"pxe-markdown-table"},{children:n("table",{children:e})})),th:({node:e,children:r})=>n("th",{children:r}),tr:({node:e,children:r})=>n("tr",Object.assign({style:{border:"dark"===N?"1px solid #30363D":"1px solid #D0D7DE"}},{children:r})),td:({node:e,children:r})=>n("td",{children:r}),code:b,blockquote:({node:e,children:r})=>n("blockquote",Object.assign({style:{borderLeft:"dark"===N?"4px solid #30363D":"4px solid #D0D7DE",color:"dark"===N?"#8B8B8B":"#656D76"}},{children:r})),img:g,iframe:f,hr:()=>n("hr",{style:{border:0,borderTop:"dark"===N?"1px solid #30363D":"1px solid #D0D7DE"}}),span:r=>{var{node:i,children:t}=r,o=e(r,["node","children"]);return"pxe-expand-btn"===o.className?n("span",Object.assign({},o,{style:Object.assign({display:"inline",fontWeight:500,color:S,marginLeft:".25rem",userSelect:"none"},$&&{cursor:"pointer"})},$&&{onClick:$},{children:t})):n("span",Object.assign({},o,{children:t}))},br:()=>n("br",{})};s((()=>{if(!I.current)return;const e=new ResizeObserver((e=>{for(const r of e){const{width:e,height:n}=r.contentRect;P({width:e,height:n})}}));return e.observe(I.current),()=>{e.disconnect()}}),[]);const T=E||q,W=!C&&B.length>0?"\n\n---":"";return r("div",Object.assign({className:"pxe-markdown",ref:I,style:Object.assign({position:"relative",overflowWrap:"break-word",display:"grid",gridTemplateColumns:"repeat(1, minmax(0, 1fr))",gap:".625rem"},w)},{children:[n(d,Object.assign({className:k(!C&&"pxe-prose",j),components:R,remarkPlugins:[c,a],rehypePlugins:[h,m]},{children:`${T}${W}`})),!C&&B.length>0&&n("div",Object.assign({className:"pxe-link-previews"},{children:B.map(((e,r)=>n(x,{data:e},r)))})),D]}))};export{j as PickaxeMarkdownRenderer};
|
package/dist/esm/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-youtube{margin-bottom:1.5rem;margin-top:1.5rem}.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}.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),.pxe-prose h3:not(:first-child),.pxe-prose h4:not(:first-child),.pxe-prose h5:not(:first-child){margin-top:2.5rem}.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>p:first-child>.pxe-markdown-image,.pxe-prose>p:first-child>.pxe-markdown-youtube{margin-top:0}
|
|
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-youtube{margin-bottom:1.5rem;margin-top:1.5rem}.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),.pxe-prose h3:not(:first-child),.pxe-prose h4:not(:first-child),.pxe-prose h5:not(:first-child){margin-top:2.5rem}.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-prose .pxe-animated-token{animation:fadeIn .3s ease-out forwards;display:inline-block;opacity:0}.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-youtube{margin-top:0}@keyframes fadeIn{0%{opacity:0;transform:translateX(5px)}to{opacity:1;transform:translateX(0)}}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type FC, type ComponentPropsWithoutRef } from "react";
|
|
2
2
|
import type { Node } from "../../Renderer";
|
|
3
|
-
declare const Code: FC<ComponentPropsWithoutRef<"code"> & Node
|
|
3
|
+
declare const Code: FC<ComponentPropsWithoutRef<"code"> & Node & {
|
|
4
|
+
inline?: boolean;
|
|
5
|
+
}>;
|
|
4
6
|
export default Code;
|