@pickaxeproject/react 2.1.11 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./useScrollContext.js");exports.useScroll=({auto:t})=>{const{scrollContainerRef:n,scrollTargetRef:o,isLocked:l,isScrollSession:s,isScrollIncreasing:c,setIsLocked:u,setIsScrollSession:i,setIsScrolling:d,setIsScrollIncreasing:v}=r.useScrollContext(),[a,f]=e.useState(0),g=e.useRef(!1),E=e.useMemo((()=>null!=t&&t&&s),[t,s]),S=e.useMemo((()=>n&&n.current?n.current:"undefined"==typeof window?null:window),[n]);e.useEffect((()=>{if(!S)return;const e=e=>{s&&l&&("mousedown"===e.type||"wheel"===e.type||"DOMMouseScroll"===e.type||"mousewheel"===e.type)&&u(!1)};return null==S||S.addEventListener("scroll",e),null==S||S.addEventListener("mousedown",e),null==S||S.addEventListener("wheel",e),null==S||S.addEventListener("DOMMouseScroll",e),null==S||S.addEventListener("mousewheel",e),()=>{null==S||S.removeEventListener("scroll",e),null==S||S.removeEventListener("mousedown",e),null==S||S.removeEventListener("wheel",e),null==S||S.removeEventListener("DOMMouseScroll",e),null==S||S.removeEventListener("mousewheel",e)}}),[S,s,l]),e.useEffect((()=>{g.current=!l}),[l]),e.useEffect((()=>{const e=setInterval((()=>{if(!n.current)return;const e=n.current.scrollHeight;if(e===a)return;const r=e>a;v(r),f(e),r&&t&&m()}),100);return()=>clearInterval(e)}),[n,a,t]),e.useEffect((()=>{const e=setInterval((()=>{if(n.current)return;if(!o.current)return;const e=o.current.getBoundingClientRect().top+o.current.getBoundingClientRect().height+window.scrollY;if(e===a)return;const r=e>a;v(r),f(e),r&&E&&p()}),100);return()=>clearInterval(e)}),[o,a,E]);const m=()=>{try{if(d(!0),!n.current)return void("development"===process.env.NODE_ENV&&console.log("[useScroll] scrollContainerRef not detected"));if(g.current)return;const e=n.current.scrollHeight;n.current.scrollTo({top:e,behavior:"smooth"}),"development"===process.env.NODE_ENV&&console.log("[useScroll] scrolled scrollContainerRef")}finally{d(!1)}},p=()=>{try{if(d(!0),!o.current)return void("development"===process.env.NODE_ENV&&console.log("[useScroll] scrollTargetRef not detected"));if(g.current)return;const e=o.current.getBoundingClientRect().top+o.current.getBoundingClientRect().height+window.scrollY;window.scroll({top:e,behavior:"smooth"}),"development"===process.env.NODE_ENV&&console.log("[useScroll] scrolled scrollTargetRef")}finally{d(!1)}};return{isScrollIncreasing:c,scrollStartSession:()=>{i(!0),u(!0),g.current=!1},scrollEndSession:()=>{i(!1)},scrollToBottom:m,scrollToTarget:p}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react"),r=require("./useScrollContext.js");exports.useScroll=({auto:t})=>{const{scrollContainerRef:n,scrollTargetRef:o,isLocked:l,isScrollSession:s,isScrollIncreasing:c,setIsLocked:u,setIsScrollSession:i,setIsScrolling:d,setIsScrollIncreasing:v}=r.useScrollContext(),[a,f]=e.useState(0),g=e.useRef(!1),E=e.useMemo((()=>null!=t&&t&&s),[t,s]),S=e.useMemo((()=>n&&n.current?n.current:"undefined"==typeof window?null:window),[n]);e.useEffect((()=>{if(!S)return;const e=e=>{s&&l&&("mousedown"===e.type||"wheel"===e.type||"DOMMouseScroll"===e.type||"mousewheel"===e.type)&&u(!1)};return null==S||S.addEventListener("scroll",e),null==S||S.addEventListener("mousedown",e),null==S||S.addEventListener("wheel",e),null==S||S.addEventListener("DOMMouseScroll",e),null==S||S.addEventListener("mousewheel",e),()=>{null==S||S.removeEventListener("scroll",e),null==S||S.removeEventListener("mousedown",e),null==S||S.removeEventListener("wheel",e),null==S||S.removeEventListener("DOMMouseScroll",e),null==S||S.removeEventListener("mousewheel",e)}}),[S,s,l]),e.useEffect((()=>{g.current=!l}),[l]),e.useEffect((()=>{const e=setInterval((()=>{if(!n.current)return;const e=n.current.scrollHeight;if(e===a)return;const r=e>a;v(r),f(e),r&&t&&m()}),100);return()=>clearInterval(e)}),[n,a,t]),e.useEffect((()=>{const e=setInterval((()=>{if(n.current)return;if(!o.current)return;const e=o.current.getBoundingClientRect().top+o.current.getBoundingClientRect().height+window.scrollY;if(e===a)return;const r=e>a;v(r),f(e),r&&E&&p()}),100);return()=>clearInterval(e)}),[o,a,E]);const m=()=>{try{if(d(!0),!n.current)return void("development"===process.env.NODE_ENV&&console.log("[useScroll] scrollContainerRef not detected"));if(g.current)return;const e=n.current.scrollHeight;n.current.scrollTo({top:e,behavior:"smooth"}),"development"===process.env.NODE_ENV&&console.log("[useScroll] scrolled scrollContainerRef")}finally{d(!1)}},p=()=>{try{if(d(!0),!o.current)return void("development"===process.env.NODE_ENV&&console.log("[useScroll] scrollTargetRef not detected"));if(g.current)return;const e=o.current.getBoundingClientRect().top+o.current.getBoundingClientRect().height+window.scrollY;window.scrollTo({top:e-500,behavior:"smooth"}),"development"===process.env.NODE_ENV&&console.log("[useScroll] scrolled scrollTargetRef")}finally{d(!1)}};return{isScrollIncreasing:c,scrollStartSession:()=>{i(!0),u(!0),g.current=!1},scrollEndSession:()=>{i(!1)},scrollToBottom:m,scrollToTarget:p}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../../hooks/pickaxe/useDimensionContext.js"),i=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../../../hooks/pickaxe/useConversation.js"),r=require("../../common/PickaxeIcon.js"),c=require("../../../Core/ErrorAlert.js"),d=require("../../../Core/Skeleton.js"),u=require("../../Addons/Scroll/ScrollLockView.js"),x=require("../../common/PickaxeHead.js"),m=require("../../common/PickaxeCompactHead.js"),f=require("../../common/PickaxeUpgradeCard.js"),j=require("./Message.js"),h=require("../../common/PickaxeBranding.js"),p=require("../../../../common/cn.js");exports.default=({hideInfo:g,isInputFocused:w})=>{var v;const N=n.useConversation(),b=o.useStyleFontSize(),{pickaxe:k,colors:y,misc:C,isNewChat:q,isRtl:O,isEmbed:S,setChatId:P}=a.usePickaxeContext(),{scrollContainerRef:I}=i.useScrollContext(),{messages:L,status:E,limitData:M,error:A}=t.useResponseContext(),{height:H}=l.useDimensionContext(),R=s.useMemo((()=>!!N.data&&!(N.data.messages.length<=1)),[N.data]),z=s.useMemo((()=>!g&&N.isSuccess&&q&&!R),[g,N.isSuccess,q,R]),D=s.useMemo((()=>{var e,s;return!!L.length&&!(null!==(s=null===(e=null==L?void 0:L[L.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[L]);return e.jsx("div",Object.assign({ref:I,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-8",style:{height:`calc(${H}px - 74px)`}},{children:e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px] px-4"},{children:[(z||!S)&&!C.isWhiteLabel&&e.jsx(h.default,{className:p.default("absolute top-4 right-4",!z&&!S&&"top-2"),animateHover:!0}),e.jsx(x.default,{className:p.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",z&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxLines:2,onIconClick:()=>P("")}),S&&!N.isLoading&&e.jsx(m.default,{className:p.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full",!z&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",onIconClick:()=>P("")}),e.jsx("div",Object.assign({className:p.default("flex flex-col mt-6 transition-all duration-300 ease-in-out w-full",S&&!N.isLoading&&!z&&"mt-0")},{children:N.isLoading&&!(null==k?void 0:k.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[q&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(d.default,{className:"w-[72px] h-[72px]"}),e.jsx(d.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(d.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(d.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(d.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(d.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(d.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):N.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:p.default(b.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):N.data?e.jsxs("div",Object.assign({className:"flex flex-col w-full"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[N.data.messages.map(((s,a)=>e.jsx(j.default,Object.assign({index:a,message:s},0===a&&{isIntroExpand:w}),a))),L.map(((s,a)=>e.jsx(j.default,{index:N.data.messages.length+a,message:s},a))),"fetching"===E||D?e.jsxs("div",Object.assign({className:p.default("flex max-w-[80%] items-center gap-x-3 ",O?"justify-end":"justify-start")},{children:["NONE"!==(null==k?void 0:k.chaticon)&&e.jsx(r.default,{src:null!==(v=null==k?void 0:k.chaticon)&&void 0!==v?v:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==k?void 0:k.formid}.png`,alt:`${null==k?void 0:k.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6",textColor:y.text}),e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded px-4 py-4"},{children:Array.from({length:3}).map(((s,a)=>e.jsx("div",{className:p.default("h-1.5 w-1.5 animate-dot rounded-full",1===a&&"animate-dot-down"),style:{backgroundColor:y.secondaryText}},a)))}))]})):M?e.jsx("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e.jsx(f.default,{})})):A?e.jsx("div",Object.assign({className:p.default("flex items-center gap-x-3",O?"justify-end":"justify-start")},{children:e.jsx(c.default,{error:A})})):null]})),e.jsx(u.default,{className:"w-full"})]})):null}))]}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("../../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../../hooks/pickaxe/useDimensionContext.js"),i=require("../../Addons/Scroll/hooks/useScrollContext.js"),o=require("../../../../hooks/studio/useStyleFontSize.js"),n=require("../../../../hooks/pickaxe/useConversation.js"),r=require("../../common/PickaxeIcon.js"),c=require("../../../Core/ErrorAlert.js"),d=require("../../../Core/Skeleton.js"),u=require("../../Addons/Scroll/ScrollLockView.js"),x=require("../../common/PickaxeHead.js"),m=require("../../common/PickaxeCompactHead.js"),f=require("../../common/PickaxeUpgradeCard.js"),j=require("./Message.js"),h=require("../../common/PickaxeBranding.js"),p=require("../../../../common/cn.js");exports.default=({hideInfo:g,isInputFocused:w})=>{var v;const N=n.useConversation(),b=o.useStyleFontSize(),{pickaxe:k,colors:y,misc:C,isNewChat:q,isRtl:O,isEmbed:S,setChatId:P}=a.usePickaxeContext(),{scrollContainerRef:I}=i.useScrollContext(),{messages:L,status:E,limitData:M,error:A}=t.useResponseContext(),{height:H}=l.useDimensionContext(),R=s.useMemo((()=>!!N.data&&!(N.data.messages.length<=1)),[N.data]),z=s.useMemo((()=>!g&&N.isSuccess&&q&&!R),[g,N.isSuccess,q,R]),D=s.useMemo((()=>{var e,s;return!!L.length&&!(null!==(s=null===(e=null==L?void 0:L[L.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[L]);return console.log(H),e.jsx("div",Object.assign({ref:I,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-8",style:{height:`calc(${H}px - 74px)`}},{children:e.jsxs("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px] px-4"},{children:[(z||!S)&&!C.isWhiteLabel&&e.jsx(h.default,{className:p.default("absolute top-4 right-4",!z&&!S&&"top-2"),animateHover:!0}),e.jsx(x.default,{className:p.default("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",z&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxLines:2,onIconClick:()=>P("")}),S&&!N.isLoading&&e.jsx(m.default,{className:p.default("opacity-0 transition-all duration-500 ease-in-out h-0 w-full",!z&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",onIconClick:()=>P("")}),e.jsx("div",Object.assign({className:p.default("flex flex-col mt-6 transition-all duration-300 ease-in-out w-full",S&&!N.isLoading&&!z&&"mt-0")},{children:N.isLoading&&!(null==k?void 0:k.enablechatresponses)?e.jsxs("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[q&&e.jsxs("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e.jsx(d.default,{className:"w-[72px] h-[72px]"}),e.jsx(d.default,{className:"h-[20px] mt-6 w-full"}),e.jsx(d.default,{className:"h-[20px] mt-2 w-full"}),e.jsx(d.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e.jsx(d.default,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e.jsx(d.default,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e.jsx(d.default,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):N.isError?e.jsx("div",Object.assign({className:"flex w-full justify-center"},{children:e.jsxs("p",Object.assign({className:p.default(b.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e.jsx("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):N.data?e.jsxs("div",Object.assign({className:"flex flex-col w-full"},{children:[e.jsxs("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[N.data.messages.map(((s,a)=>e.jsx(j.default,Object.assign({index:a,message:s},0===a&&{isIntroExpand:w}),a))),L.map(((s,a)=>e.jsx(j.default,{index:N.data.messages.length+a,message:s},a))),"fetching"===E||D?e.jsxs("div",Object.assign({className:p.default("flex max-w-[80%] items-center gap-x-3 ",O?"justify-end":"justify-start")},{children:["NONE"!==(null==k?void 0:k.chaticon)&&e.jsx(r.default,{src:null!==(v=null==k?void 0:k.chaticon)&&void 0!==v?v:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==k?void 0:k.formid}.png`,alt:`${null==k?void 0:k.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6",textColor:y.text}),e.jsx("div",Object.assign({className:"flex items-center gap-x-2 rounded px-4 py-4"},{children:Array.from({length:3}).map(((s,a)=>e.jsx("div",{className:p.default("h-1.5 w-1.5 animate-dot rounded-full",1===a&&"animate-dot-down"),style:{backgroundColor:y.secondaryText}},a)))}))]})):M?e.jsx("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e.jsx(f.default,{})})):A?e.jsx("div",Object.assign({className:p.default("flex items-center gap-x-3",O?"justify-end":"justify-start")},{children:e.jsx(c.default,{error:A})})):null]})),e.jsx(u.default,{className:"w-full"})]})):null}))]}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),a=require("react-intersection-observer"),r=require("../../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../../hooks/pickaxe/useHistory.js"),t=require("../../../Icons/spinner-circle.svg.js"),n=require("./Item.js");exports.default=()=>{var l;const{styles:c,colors:o,isShowHistory:u}=r.usePickaxeContext(),x=i.useHistory({enabled:u}),{ref:d}=a.useInView({onChange(e){e&&x.hasNextPage&&x.fetchNextPage()}});return u&&x.isLoading?e.jsx("div",{className:"w-full min-h-[300px] animate-pulse bg-[#E5E7EB] dark:bg-[#1E1E1F]",style:{backgroundColor:"dark"===c.theme?"#1E1E1F":"#E5E7EB"}}):x.isError?e.jsx("div",{}):u?e.jsxs("div",Object.assign({className:"flex flex-col gap-y-8"},{children:[null===(l=x.data)||void 0===l?void 0:l.pages.map(((a,r)=>e.jsx(s.Fragment,{children:a.data.map((a=>e.jsx(s.Fragment,{children:e.jsx(n.default,{item:a})},a.responseId)))},r))),e.jsx("div",Object.assign({className:"flex items-center justify-center"},{children:x.isFetchingNextPage?e.jsx(t.default,{className:"my-10 h-14 w-14 animate-spin animate-spin text-gray-300",style:{fill:o.accent}}):x.hasNextPage?e.jsx("div",{ref:d,className:"invisible h-14 w-14"}):null}))]})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),i=require("react-intersection-observer"),a=require("../../../../hooks/pickaxe/usePickaxeContext.js"),r=require("../../../../hooks/pickaxe/useHistory.js"),t=require("../../../Icons/spinner-circle.svg.js"),n=require("./Item.js");exports.default=()=>{var l,c;const{styles:o,colors:u,misc:x}=a.usePickaxeContext(),d=r.useHistory({enabled:null===(l=x.isHistory)||void 0===l||l}),{ref:m}=i.useInView({onChange(e){e&&d.hasNextPage&&d.fetchNextPage()}});return d.isLoading?e.jsx("div",{className:"w-full min-h-[300px] animate-pulse bg-[#E5E7EB] dark:bg-[#1E1E1F]",style:{backgroundColor:"dark"===o.theme?"#1E1E1F":"#E5E7EB"}}):d.isError?e.jsx("div",{}):e.jsxs("div",Object.assign({className:"flex flex-col gap-y-8"},{children:[null===(c=d.data)||void 0===c?void 0:c.pages.map(((i,a)=>e.jsx(s.Fragment,{children:i.data.map((i=>e.jsx(s.Fragment,{children:e.jsx(n.default,{item:i})},i.responseId)))},a))),e.jsx("div",Object.assign({className:"flex items-center justify-center"},{children:d.isFetchingNextPage?e.jsx(t.default,{className:"my-10 h-14 w-14 animate-spin animate-spin text-gray-300",style:{fill:u.accent}}):d.hasNextPage?e.jsx("div",{ref:m,className:"invisible h-14 w-14"}):null}))]}))};
@@ -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("../../../common/utils.js"),a=require("../common/PickaxeButton.js"),r=require("../common/PickaxeBranding.js"),o=require("../../../common/cn.js");exports.default=()=>{const{misc:n,translations:x,responsiveBy:l,isShowHistory:c,setChatId:u,setIsNewChat:p,setIsShowHistory:d}=s.usePickaxeContext(),{setMessages:m}=t.useResponseContext();return e.jsxs("div",Object.assign({className:o.default("mt-4 flex flex-wrap flex-col justify-between gap-2","viewport"===l?"min-[767px]:flex-row":"@[767px]/pickaxe-root:flex-row")},{children:[e.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[e.jsx(a.default,Object.assign({className:o.default("w-full","viewport"===l?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]"),onClick:()=>{return e=i.generateId(20),m([]),u(e),void p(!0);var e}},{children:(null==x?void 0:x["new-chat"])||"New chat"})),n.isHistory&&!c&&e.jsx(a.default,Object.assign({variant:"transparent-text",className:o.default("w-full","viewport"===l?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]"),onClick:()=>d(!0)},{children:(null==x?void 0:x["see-history"])||"See history"}))]})),!n.isWhiteLabel&&e.jsx("div",Object.assign({className:"flex justify-end pr-3"},{children:e.jsx(r.default,{})}))]}))};
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/pickaxe/useDimensionContext.js"),r=require("../../../common/utils.js"),a=require("../common/PickaxeButton.js"),n=require("../common/PickaxeBranding.js"),o=require("../../../common/cn.js");exports.default=()=>{const{misc:x,translations:c,responsiveBy:l,setChatId:u,setIsNewChat:p}=s.usePickaxeContext(),{setMessages:m}=t.useResponseContext(),{setHeight:d}=i.useDimensionContext();return e.jsxs("div",Object.assign({className:o.default("mt-4 flex flex-wrap flex-col justify-between gap-2","viewport"===l?"min-[767px]:flex-row":"@[767px]/pickaxe-root:flex-row")},{children:[e.jsx("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:e.jsx(a.default,Object.assign({className:o.default("w-full","viewport"===l?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]"),onClick:()=>{return e=r.generateId(20),d(0),m([]),u(e),void p(!0);var e}},{children:(null==c?void 0:c["new-chat"])||"New chat"}))})),!x.isWhiteLabel&&e.jsx("div",Object.assign({className:"flex justify-end pr-3"},{children:e.jsx(n.default,{})}))]}))};
@@ -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"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/pickaxe/useSubmit.js"),r=require("../../Addons/Document/hooks/useDocument.js"),l=require("../../Addons/Scroll/hooks/useScroll.js"),a=require("../../../../common/utils.js"),d=require("@nem035/gpt-3-encoder"),u=require("eventsource-parser"),c=require("../../common/PickaxeBranding.js"),m=require("../../common/PickaxeButton.js"),p=require("../../../../common/error.js"),g=require("../../../../common/cn.js");exports.default=({questions:f})=>{var h;const{formId:x,userId:b,studioUserId:j,embedUserId:v,deploymentId:w,pickaxe:y,misc:k,translations:q,responsiveBy:I,isShowHistory:O,setChatId:S,setIsShowHistory:C,setIsNewChat:P,onGenerateComplete:U}=n.usePickaxeContext(),{status:D,limits:E,isGenerating:R,setResponse:N,setMessages:_,setStatus:A,setLimitData:L,setError:T}=o.useResponseContext(),{documents:B,websiteLink:H,isUploading:M,onWebsiteUpload:W,setDocumentError:G}=r.useDocument(),{scrollStartSession:J,scrollEndSession:F,scrollToTarget:K}=l.useScroll({auto:!(null==y?void 0:y.enablechatresponses)}),X=i.useSubmit(),[Y,z]=t.useState(!1);return s.jsxs("div",Object.assign({className:g.default("mt-4 flex flex-wrap flex-col justify-between gap-2","viewport"===I?"min-[767px]:flex-row":"@[767px]/pickaxe-root:flex-row")},{children:[s.jsxs("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[s.jsx(m.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:M||"idle"!==D||R||Y,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if("idle"!==D||M||Y)return;T(""),L(null),G(""),N(null);const e=["Multiple Choice","Checkbox"];for(const s of f){if(d.encode(s.input).length>s.maxLength&&!e.includes(s.type))throw new Error("One or more of your responses is too long!");if(s.isRequired&&!s.input.trim()&&"userinput:documentupload"!==s.id)throw new Error("You must fill out all required fields.")}const s=B.filter((e=>"finished"===e.status)),t=B.map((e=>e.name)),n="enduserupload"===(null==y?void 0:y.documentuploadtype),o=f.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),i=a.extractUrlsFromText(H).filter((e=>!t.includes(e)));if(i.length){const e=i[i.length-1];z(!0);const t=yield W(e);t&&(s.push(t),yield new Promise((e=>setTimeout(e,5e3)))),z(!1)}else if(o&&n&&!s.length)return void G("Please paste a valid website/video link or drag a file to add to the knowledge base.");const r=s.length?s[s.length-1]:null,l=n&&r&&"finished"===r.status;let c={};f.forEach((e=>c=Object.assign(Object.assign({},c),{[e.id]:"Knowledge Upload"===e.type||e.id.includes("documentupload")?(null==r?void 0:r.name)||"":e.input}))),A("fetching"),J(),K();const m=yield X.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:x,valueObj:c},l&&{documentId:r.documentId}),b&&{userId:b}),j&&{studioUserId:j}),v&&{embedUserId:v}),w&&{deploymentId:w})),p=m.body;if(!p)throw new Error("Streaming error");const g=m.headers.get("X-Pickaxe-Response-Id");if(!g)throw new Error("Response ID not found");const h=new TextDecoder,k=p.getReader();let q="",I=!0,O=!1;const C=u.createParser({onEvent:e=>{if("delta"===e.event){const s=JSON.parse(e.data).token.replace(/\u200B/g,"");q+=s,N({formId:x,responseId:g,documentIds:r&&r.documentId?[r.documentId]:[],questions:f.map((e=>({id:e.id,question:e.main,answer:e.input}))),questionResponse:q,messageCount:0,sentAt:new Date}),(null==y?void 0:y.enablechatresponses)&&_([{id:0,role:"assistant",content:q}])}else if("error"===e.event){const s=JSON.parse(e.data);T(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(I=!1)}});for(;I;){const{value:e,done:s}=yield k.read();if(s){I=!1;break}const t=h.decode(e);t&&(O||(A("streaming"),O=!0,(null==y?void 0:y.enablechatresponses)&&(S(g),P(!1))),C.feed(t))}null==U||U(g)}catch(e){let s=p.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(E).find((([e])=>s.includes(e)));t?L(t[1]):T(s),K()}finally{A("idle"),z(!1),F()}}))},{children:Y?(null==q?void 0:q.processing)||"Processing...":M?(null==q?void 0:q.uploading)||"Uploading...":"fetching"===D||"streaming"===D?(null==q?void 0:q.loading)||"Loading...":null!==(h=null==y?void 0:y.submittext)&&void 0!==h?h:"Submit"})),k.isHistory&&!O&&s.jsx(m.default,Object.assign({variant:"transparent-text",className:"px-4",onClick:()=>C(!0)},{children:(null==q?void 0:q["see-history"])||"See history"}))]})),!k.isWhiteLabel&&s.jsx("div",Object.assign({className:"flex justify-end pr-3"},{children:s.jsx(c.default,{})}))]}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("react"),n=require("../../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../../hooks/pickaxe/useResponseContext.js"),i=require("../../../../hooks/pickaxe/useDimensionContext.js"),r=require("../../../../hooks/pickaxe/useSubmit.js"),l=require("../../Addons/Document/hooks/useDocument.js"),a=require("../../Addons/Scroll/hooks/useScroll.js"),d=require("../../../../common/utils.js"),u=require("@nem035/gpt-3-encoder"),c=require("eventsource-parser"),m=require("../../common/PickaxeBranding.js"),p=require("../../common/PickaxeButton.js"),g=require("../../../../common/error.js"),f=require("../../../../common/cn.js");exports.default=({questions:x})=>{var h;const{formId:b,userId:j,studioUserId:v,embedUserId:w,deploymentId:k,pickaxe:q,misc:I,translations:y,responsiveBy:O,setChatId:S,setIsNewChat:C,onGenerateComplete:D}=n.usePickaxeContext(),{status:P,limits:U,isGenerating:E,setResponse:R,setMessages:N,setStatus:_,setLimitData:A,setError:L}=o.useResponseContext(),{documents:T,websiteLink:B,isUploading:M,onWebsiteUpload:W,setDocumentError:G}=l.useDocument(),{setHeight:J}=i.useDimensionContext(),{scrollStartSession:F,scrollEndSession:H,scrollToTarget:K}=a.useScroll({auto:!(null==q?void 0:q.enablechatresponses)}),X=r.useSubmit(),[Y,z]=t.useState(!1);return s.jsxs("div",Object.assign({className:f.default("mt-4 flex flex-wrap flex-col justify-between gap-2","viewport"===O?"min-[767px]:flex-row":"@[767px]/pickaxe-root:flex-row")},{children:[s.jsx("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:s.jsx(p.default,Object.assign({className:"px-5 min-h-[42px]",isDisabled:M||"idle"!==P||E||Y,onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if("idle"!==P||M||Y)return;L(""),A(null),G(""),R(null);const e=["Multiple Choice","Checkbox"];for(const s of x){if(u.encode(s.input).length>s.maxLength&&!e.includes(s.type))throw new Error("One or more of your responses is too long!");if(s.isRequired&&!s.input.trim()&&"userinput:documentupload"!==s.id)throw new Error("You must fill out all required fields.")}const s=T.filter((e=>"finished"===e.status)),t=T.map((e=>e.name)),n="enduserupload"===(null==q?void 0:q.documentuploadtype),o=x.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),i=d.extractUrlsFromText(B).filter((e=>!t.includes(e)));if(i.length){const e=i[i.length-1];z(!0);const t=yield W(e);t&&(s.push(t),yield new Promise((e=>setTimeout(e,5e3)))),z(!1)}else if(o&&n&&!s.length)return void G("Please paste a valid website/video link or drag a file to add to the knowledge base.");const r=s.length?s[s.length-1]:null,l=n&&r&&"finished"===r.status;let a={};x.forEach((e=>a=Object.assign(Object.assign({},a),{[e.id]:"Knowledge Upload"===e.type||e.id.includes("documentupload")?(null==r?void 0:r.name)||"":e.input}))),_("fetching"),F(),K();const m=yield X.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:b,valueObj:a},l&&{documentId:r.documentId}),j&&{userId:j}),v&&{studioUserId:v}),w&&{embedUserId:w}),k&&{deploymentId:k})),p=m.body;if(!p)throw new Error("Streaming error");const g=m.headers.get("X-Pickaxe-Response-Id");if(!g)throw new Error("Response ID not found");const f=new TextDecoder,h=p.getReader();let I="",y=!0,O=!1;const U=c.createParser({onEvent:e=>{if("delta"===e.event){const s=JSON.parse(e.data).token.replace(/\u200B/g,"");I+=s,R({formId:b,responseId:g,documentIds:r&&r.documentId?[r.documentId]:[],questions:x.map((e=>({id:e.id,question:e.main,answer:e.input}))),questionResponse:I,messageCount:0,sentAt:new Date}),(null==q?void 0:q.enablechatresponses)&&N([{id:0,role:"assistant",content:I}])}else if("error"===e.event){const s=JSON.parse(e.data);L(s.error||"Something went wrong, please try again.")}else"stop"===e.event&&(y=!1)}});for(;y;){const{value:e,done:s}=yield h.read();if(s){y=!1;break}const t=f.decode(e);t&&(O||(_("streaming"),O=!0,(null==q?void 0:q.enablechatresponses)&&(J(0),S(g),C(!1))),U.feed(t))}null==D||D(g)}catch(e){let s=g.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(U).find((([e])=>s.includes(e)));t?A(t[1]):L(s),K()}finally{_("idle"),z(!1),H()}}))},{children:Y?(null==y?void 0:y.processing)||"Processing...":M?(null==y?void 0:y.uploading)||"Uploading...":"fetching"===P||"streaming"===P?(null==y?void 0:y.loading)||"Loading...":null!==(h=null==q?void 0:q.submittext)&&void 0!==h?h:"Submit"}))})),!I.isWhiteLabel&&s.jsx("div",Object.assign({className:"flex justify-end pr-3"},{children:s.jsx(m.default,{})}))]}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("./Addons/Document/Provider.js"),i=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");const o=s.createContext({});exports.PickaxeContext=o,exports.PickaxeProvider=({children:a,isRtl:n=!1,userId:d="",studioUserId:l="",deploymentId:c="",embedUserId:u="",styles:p,colors:h,limits:m={},misc:F={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:b,responsiveBy:x="viewport",isEmbed:I=!1,forceMobile:y=!1,loadFont:f=!0,onGenerateComplete:g})=>{const[S,j]=s.useState(""),[P,v]=s.useState(""),[w,k]=s.useState(null),[C,O]=s.useState(!1),[q,D]=s.useState(!0),[H,R]=s.useState(!0),[U,B]=s.useState(!1);return s.useEffect((()=>{O(!1)}),[null==p?void 0:p.font]),e.jsx(o.Provider,Object.assign({value:Object.assign({formId:S,isRtl:n,chatId:P,userId:d,studioUserId:l,deploymentId:c,embedUserId:u,pickaxe:w,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},p),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},h),misc:F,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website"},b),responsiveBy:x,isFontLoaded:C,isNewChat:q,isShowIceBreaker:H,isShowHistory:U,loadFont:f,forceMobile:y,isEmbed:I,setIsFontLoaded:O,setFormId:j,setChatId:v,setPickaxe:k,setIsNewChat:D,setIsShowIceBreaker:R,setIsShowHistory:B},g&&{onGenerateComplete:g})},{children:e.jsx(i.default,Object.assign({limits:m},{children:e.jsx(r.default,{children:e.jsx(t.default,{children:a})})}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),s=require("react"),t=require("./Addons/Document/Provider.js"),i=require("./ResponseProvider.js"),r=require("./DimensionProvider.js");const o=s.createContext({});exports.PickaxeContext=o,exports.PickaxeProvider=({children:a,userId:n="",studioUserId:d="",deploymentId:l="",embedUserId:c="",styles:u,colors:p,limits:m={},misc:h={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:F,responsiveBy:b="viewport",forceMobile:x=!1,loadFont:I=!0,isEmbed:f=!1,isRtl:y=!1,onGenerateComplete:g})=>{const[j,P]=s.useState(""),[v,S]=s.useState(""),[w,k]=s.useState(null),[C,O]=s.useState(!1),[q,D]=s.useState(!0),[R,U]=s.useState(!0);return s.useEffect((()=>{O(!1)}),[null==u?void 0:u.font]),e.jsx(o.Provider,Object.assign({value:Object.assign({formId:j,chatId:v,userId:n,studioUserId:d,deploymentId:l,embedUserId:c,pickaxe:w,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},u),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},p),misc:h,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website"},F),responsiveBy:b,forceMobile:x,loadFont:I,isFontLoaded:C,isNewChat:q,isShowIceBreaker:R,isEmbed:f,isRtl:y,setIsFontLoaded:O,setFormId:P,setChatId:S,setPickaxe:k,setIsNewChat:D,setIsShowIceBreaker:U},g&&{onGenerateComplete:g})},{children:e.jsx(i.default,Object.assign({limits:m},{children:e.jsx(r.default,{children:e.jsx(t.default,{children:a})})}))}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react");const s=t.createContext({});exports.ResponseContext=s,exports.default=({limits:r,children:a})=>{const[i,n]=t.useState([]),[u,o]=t.useState(null),[l,c]=t.useState("idle"),[d,m]=t.useState(null),[p,x]=t.useState("");return e.jsx(s.Provider,Object.assign({value:{messages:i,response:u,status:l,limits:r,limitData:d,error:p,isGenerating:"fetching"===l||"streaming"===l,setMessages:n,setResponse:o,setStatus:c,setLimitData:m,setError:x}},{children:a}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react/jsx-runtime"),t=require("react"),s=require("../../hooks/pickaxe/usePickaxeContext.js");const r=t.createContext({});exports.ResponseContext=r,exports.default=({limits:a,children:i})=>{const{chatId:u}=s.usePickaxeContext(),[n,l]=t.useState([]),[o,c]=t.useState(null),[x,d]=t.useState("idle"),[p,m]=t.useState(null),[g,S]=t.useState("");return t.useEffect((()=>{l([]),c(null),d("idle"),m(null),S("")}),[u]),e.jsx(r.Provider,Object.assign({value:{messages:n,response:o,status:x,limits:a,limitData:p,error:g,isGenerating:"fetching"===x||"streaming"===x,setMessages:l,setResponse:c,setStatus:d,setLimitData:m,setError:S}},{children:i}))};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../hooks/pickaxe/usePickaxe.js"),r=require("react"),a=require("../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../hooks/pickaxe/useResponseContext.js"),i=require("../../hooks/pickaxe/useDimensionContext.js"),l=require("../../common/utils.js"),n=require("./Addons/Scroll/Provider.js"),c=require("../Core/Skeleton.js"),u=require("./Chat/index.js"),f=require("./Form/index.js"),d=require("../../common/cn.js");function x(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}exports.Pickaxe=({formId:m,className:p})=>{const{chatId:j,styles:h,colors:w,loadFont:k,responsiveBy:b,isFontLoaded:g,setFormId:v,setChatId:q,setPickaxe:O,setIsFontLoaded:P}=a.usePickaxeContext(),{setMessages:y,setResponse:C,setError:N,setLimitData:R}=o.useResponseContext(),{setWidth:_,setHeight:F,setIsMobile:I}=i.useDimensionContext(),[E,D]=r.useState(!1),L=s.usePickaxe(),M=r.useRef(null);return r.useEffect((()=>{v(m)}),[m]),r.useEffect((()=>{if(!L.data)return;const e=L.data.chatflag;q(e?l.generateId(15):""),e?y([]):C(null),N(""),R(null),O(L.data),D(!0)}),[L.data]),r.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){"undefined"!=typeof window&&(g||k&&"Real Head Pro"!==h.font&&((yield Promise.resolve().then((function(){return x(require("webfontloader"))}))).default.load({google:{families:[h.font]}}),P(!0)))}))}),[h.font,k,g]),r.useEffect((()=>{if(!M.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;_(e),F(s),I(e<768)}}));return e.observe(M.current),()=>{e.disconnect()}}),[M.current]),L.data?t.jsx("div",Object.assign({ref:M,className:d.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full",p,"dark"===h.theme&&"dark"),style:Object.assign({backgroundColor:w.primary,color:w.text},h.font&&"Real Head Pro"!==h.font&&{fontFamily:h.font})},{children:L.isLoading||!E?t.jsx("div",Object.assign({className:d.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===b?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:t.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[t.jsx(c.default,{className:"w-[72px] h-[72px]"}),t.jsx(c.default,{className:"h-[20px] mt-6 w-full"}),t.jsx(c.default,{className:"h-[20px] mt-2 w-full"}),t.jsx(c.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),t.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:t.jsx(c.default,{className:d.default("w-full min-h-[48px]","viewport"===b?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):t.jsx(t.Fragment,{children:j?t.jsx(n.default,{children:t.jsx(u.default,{})}):t.jsx(n.default,{children:t.jsx(f.default,{})})})})):null};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("../../hooks/pickaxe/usePickaxe.js"),r=require("react"),a=require("../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../hooks/pickaxe/useResponseContext.js"),i=require("../../hooks/pickaxe/useDimensionContext.js"),n=require("../../common/utils.js"),l=require("./Addons/Scroll/Provider.js"),c=require("../Core/Skeleton.js"),u=require("./Chat/index.js"),f=require("./Form/index.js"),d=require("../../common/cn.js");function x(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(s){if("default"!==s){var r=Object.getOwnPropertyDescriptor(e,s);Object.defineProperty(t,s,r.get?r:{enumerable:!0,get:function(){return e[s]}})}})),t.default=e,Object.freeze(t)}exports.Pickaxe=({formId:p,className:m})=>{const{chatId:j,styles:h,colors:w,loadFont:k,responsiveBy:b,isFontLoaded:g,setFormId:v,setChatId:q,setPickaxe:O,setIsFontLoaded:P}=a.usePickaxeContext(),{setMessages:y,setResponse:C,setError:N,setLimitData:F}=o.useResponseContext(),{setWidth:I,setHeight:R,setIsMobile:_}=i.useDimensionContext(),[E,D]=r.useState(!1),L=s.usePickaxe(),M=r.useRef(null);return r.useEffect((()=>{v(p)}),[p]),r.useEffect((()=>{if(!L.data)return;const e=L.data.chatflag;q(e?n.generateId(15):""),e?y([]):C(null),N(""),F(null),O(L.data),D(!0)}),[L.data]),r.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){"undefined"!=typeof window&&(g||k&&"Real Head Pro"!==h.font&&((yield Promise.resolve().then((function(){return x(require("webfontloader"))}))).default.load({google:{families:[h.font]}}),P(!0)))}))}),[h.font,k,g]),r.useEffect((()=>{if(!M.current)return;const e=new ResizeObserver((e=>{for(const t of e){const{width:e,height:s}=t.contentRect;I(parseInt(e.toFixed(0))),R(parseInt(s.toFixed(0))),_(e<768)}}));return e.observe(M.current),()=>{e.disconnect()}}),[M.current]),L.data?t.jsx("div",Object.assign({ref:M,className:d.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full",m,"dark"===h.theme&&"dark"),style:Object.assign({backgroundColor:w.primary,color:w.text},h.font&&"Real Head Pro"!==h.font&&{fontFamily:h.font})},{children:L.isLoading||!E?t.jsx("div",Object.assign({className:d.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===b?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:t.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[t.jsx(c.default,{className:"w-[72px] h-[72px]"}),t.jsx(c.default,{className:"h-[20px] mt-6 w-full"}),t.jsx(c.default,{className:"h-[20px] mt-2 w-full"}),t.jsx(c.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),t.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:t.jsx(c.default,{className:d.default("w-full min-h-[48px]","viewport"===b?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):t.jsx(t.Fragment,{children:j?t.jsx(l.default,{children:t.jsx(u.default,{})}):t.jsx(l.default,{children:t.jsx(f.default,{})})})})):null};
@@ -1,2 +1,2 @@
1
- declare const Container: () => import("react/jsx-runtime").JSX.Element | null;
1
+ declare const Container: () => import("react/jsx-runtime").JSX.Element;
2
2
  export default Container;
@@ -35,7 +35,6 @@ export type PickaxeMisc = {
35
35
  };
36
36
  type PickaxeContextType = {
37
37
  formId: string;
38
- isRtl?: boolean;
39
38
  chatId: string;
40
39
  userId: string;
41
40
  studioUserId: string;
@@ -47,20 +46,19 @@ type PickaxeContextType = {
47
46
  misc: PickaxeMisc;
48
47
  translations: PickaxeTranslations;
49
48
  responsiveBy: PickaxeResponsiveBy;
49
+ forceMobile: boolean;
50
+ loadFont: boolean;
50
51
  isFontLoaded: boolean;
51
52
  isNewChat: boolean;
52
53
  isShowIceBreaker: boolean;
53
- isShowHistory: boolean;
54
54
  isEmbed: boolean;
55
- forceMobile: boolean;
56
- loadFont: boolean;
55
+ isRtl?: boolean;
57
56
  setFormId: SetState<string>;
58
57
  setChatId: SetState<string>;
59
58
  setPickaxe: SetState<LimitedPickaxe | null>;
60
59
  setIsFontLoaded: SetState<boolean>;
61
60
  setIsNewChat: SetState<boolean>;
62
61
  setIsShowIceBreaker: SetState<boolean>;
63
- setIsShowHistory: SetState<boolean>;
64
62
  onGenerateComplete?: (responseId: string) => void;
65
63
  };
66
64
  export interface IPickaxeProviderProps {
@@ -82,5 +80,5 @@ export interface IPickaxeProviderProps {
82
80
  onGenerateComplete?: (responseId: string) => void;
83
81
  }
84
82
  export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
85
- export declare const PickaxeProvider: ({ children, isRtl, userId, studioUserId, deploymentId, embedUserId, styles, colors, limits, misc, translations, responsiveBy, isEmbed, forceMobile, loadFont, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
83
+ export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, embedUserId, styles, colors, limits, misc, translations, responsiveBy, forceMobile, loadFont, isEmbed, isRtl, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
86
84
  export {};
@@ -1,6 +1,5 @@
1
1
  export declare const usePickaxeContext: () => {
2
2
  formId: string;
3
- isRtl?: boolean | undefined;
4
3
  chatId: string;
5
4
  userId: string;
6
5
  studioUserId: string;
@@ -12,19 +11,18 @@ export declare const usePickaxeContext: () => {
12
11
  misc: import("../../components/Pickaxe/Provider").PickaxeMisc;
13
12
  translations: import("../../components/Pickaxe/Provider").PickaxeTranslations;
14
13
  responsiveBy: import("../../components/Pickaxe/Provider").PickaxeResponsiveBy;
14
+ forceMobile: boolean;
15
+ loadFont: boolean;
15
16
  isFontLoaded: boolean;
16
17
  isNewChat: boolean;
17
18
  isShowIceBreaker: boolean;
18
- isShowHistory: boolean;
19
19
  isEmbed: boolean;
20
- forceMobile: boolean;
21
- loadFont: boolean;
20
+ isRtl?: boolean | undefined;
22
21
  setFormId: import("../../types/common").SetState<string>;
23
22
  setChatId: import("../../types/common").SetState<string>;
24
23
  setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").LimitedPickaxe | null>;
25
24
  setIsFontLoaded: import("../../types/common").SetState<boolean>;
26
25
  setIsNewChat: import("../../types/common").SetState<boolean>;
27
26
  setIsShowIceBreaker: import("../../types/common").SetState<boolean>;
28
- setIsShowHistory: import("../../types/common").SetState<boolean>;
29
27
  onGenerateComplete?: ((responseId: string) => void) | undefined;
30
28
  };
@@ -1 +1 @@
1
- import{useState as e,useRef as r,useMemo as n,useEffect as t}from"react";import{useScrollContext as o}from"./useScrollContext.js";const l=({auto:l})=>{const{scrollContainerRef:s,scrollTargetRef:c,isLocked:u,isScrollSession:i,isScrollIncreasing:d,setIsLocked:v,setIsScrollSession:a,setIsScrolling:g,setIsScrollIncreasing:f}=o(),[m,p]=e(0),w=r(!1),E=n((()=>null!=l&&l&&i),[l,i]),S=n((()=>s&&s.current?s.current:"undefined"==typeof window?null:window),[s]);t((()=>{if(!S)return;const e=e=>{i&&u&&("mousedown"===e.type||"wheel"===e.type||"DOMMouseScroll"===e.type||"mousewheel"===e.type)&&v(!1)};return null==S||S.addEventListener("scroll",e),null==S||S.addEventListener("mousedown",e),null==S||S.addEventListener("wheel",e),null==S||S.addEventListener("DOMMouseScroll",e),null==S||S.addEventListener("mousewheel",e),()=>{null==S||S.removeEventListener("scroll",e),null==S||S.removeEventListener("mousedown",e),null==S||S.removeEventListener("wheel",e),null==S||S.removeEventListener("DOMMouseScroll",e),null==S||S.removeEventListener("mousewheel",e)}}),[S,i,u]),t((()=>{w.current=!u}),[u]),t((()=>{const e=setInterval((()=>{if(!s.current)return;const e=s.current.scrollHeight;if(e===m)return;const r=e>m;f(r),p(e),r&&l&&h()}),100);return()=>clearInterval(e)}),[s,m,l]),t((()=>{const e=setInterval((()=>{if(s.current)return;if(!c.current)return;const e=c.current.getBoundingClientRect().top+c.current.getBoundingClientRect().height+window.scrollY;if(e===m)return;const r=e>m;f(r),p(e),r&&E&&L()}),100);return()=>clearInterval(e)}),[c,m,E]);const h=()=>{try{if(g(!0),!s.current)return void("development"===process.env.NODE_ENV&&console.log("[useScroll] scrollContainerRef not detected"));if(w.current)return;const e=s.current.scrollHeight;s.current.scrollTo({top:e,behavior:"smooth"}),"development"===process.env.NODE_ENV&&console.log("[useScroll] scrolled scrollContainerRef")}finally{g(!1)}},L=()=>{try{if(g(!0),!c.current)return void("development"===process.env.NODE_ENV&&console.log("[useScroll] scrollTargetRef not detected"));if(w.current)return;const e=c.current.getBoundingClientRect().top+c.current.getBoundingClientRect().height+window.scrollY;window.scroll({top:e,behavior:"smooth"}),"development"===process.env.NODE_ENV&&console.log("[useScroll] scrolled scrollTargetRef")}finally{g(!1)}};return{isScrollIncreasing:d,scrollStartSession:()=>{a(!0),v(!0),w.current=!1},scrollEndSession:()=>{a(!1)},scrollToBottom:h,scrollToTarget:L}};export{l as useScroll};
1
+ import{useState as e,useRef as r,useMemo as n,useEffect as t}from"react";import{useScrollContext as o}from"./useScrollContext.js";const l=({auto:l})=>{const{scrollContainerRef:s,scrollTargetRef:c,isLocked:u,isScrollSession:i,isScrollIncreasing:d,setIsLocked:v,setIsScrollSession:a,setIsScrolling:g,setIsScrollIncreasing:f}=o(),[m,p]=e(0),w=r(!1),E=n((()=>null!=l&&l&&i),[l,i]),S=n((()=>s&&s.current?s.current:"undefined"==typeof window?null:window),[s]);t((()=>{if(!S)return;const e=e=>{i&&u&&("mousedown"===e.type||"wheel"===e.type||"DOMMouseScroll"===e.type||"mousewheel"===e.type)&&v(!1)};return null==S||S.addEventListener("scroll",e),null==S||S.addEventListener("mousedown",e),null==S||S.addEventListener("wheel",e),null==S||S.addEventListener("DOMMouseScroll",e),null==S||S.addEventListener("mousewheel",e),()=>{null==S||S.removeEventListener("scroll",e),null==S||S.removeEventListener("mousedown",e),null==S||S.removeEventListener("wheel",e),null==S||S.removeEventListener("DOMMouseScroll",e),null==S||S.removeEventListener("mousewheel",e)}}),[S,i,u]),t((()=>{w.current=!u}),[u]),t((()=>{const e=setInterval((()=>{if(!s.current)return;const e=s.current.scrollHeight;if(e===m)return;const r=e>m;f(r),p(e),r&&l&&h()}),100);return()=>clearInterval(e)}),[s,m,l]),t((()=>{const e=setInterval((()=>{if(s.current)return;if(!c.current)return;const e=c.current.getBoundingClientRect().top+c.current.getBoundingClientRect().height+window.scrollY;if(e===m)return;const r=e>m;f(r),p(e),r&&E&&L()}),100);return()=>clearInterval(e)}),[c,m,E]);const h=()=>{try{if(g(!0),!s.current)return void("development"===process.env.NODE_ENV&&console.log("[useScroll] scrollContainerRef not detected"));if(w.current)return;const e=s.current.scrollHeight;s.current.scrollTo({top:e,behavior:"smooth"}),"development"===process.env.NODE_ENV&&console.log("[useScroll] scrolled scrollContainerRef")}finally{g(!1)}},L=()=>{try{if(g(!0),!c.current)return void("development"===process.env.NODE_ENV&&console.log("[useScroll] scrollTargetRef not detected"));if(w.current)return;const e=c.current.getBoundingClientRect().top+c.current.getBoundingClientRect().height+window.scrollY;window.scrollTo({top:e-500,behavior:"smooth"}),"development"===process.env.NODE_ENV&&console.log("[useScroll] scrolled scrollTargetRef")}finally{g(!1)}};return{isScrollIncreasing:d,scrollStartSession:()=>{a(!0),v(!0),w.current=!1},scrollEndSession:()=>{a(!1)},scrollToBottom:h,scrollToTarget:L}};export{l as useScroll};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as s}from"react/jsx-runtime";import{useMemo as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as t}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as i}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as l}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as r}from"../../../../hooks/pickaxe/useConversation.js";import c from"../../common/PickaxeIcon.js";import m from"../../../Core/ErrorAlert.js";import d from"../../../Core/Skeleton.js";import p from"../../Addons/Scroll/ScrollLockView.js";import f from"../../common/PickaxeHead.js";import x from"../../common/PickaxeCompactHead.js";import u from"../../common/PickaxeUpgradeCard.js";import h from"./Message.js";import g from"../../common/PickaxeBranding.js";import j from"../../../../common/cn.js";const w=({hideInfo:w,isInputFocused:v})=>{var N;const b=r(),k=n(),{pickaxe:y,colors:C,misc:O,isNewChat:S,isRtl:I,isEmbed:P,setChatId:L}=o(),{scrollContainerRef:E}=l(),{messages:A,status:H,limitData:R,error:$}=t(),{height:z}=i(),D=a((()=>!!b.data&&!(b.data.messages.length<=1)),[b.data]),F=a((()=>!w&&b.isSuccess&&S&&!D),[w,b.isSuccess,S,D]),B=a((()=>{var e,s;return!!A.length&&!(null!==(s=null===(e=null==A?void 0:A[A.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[A]);return e("div",Object.assign({ref:E,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-8",style:{height:`calc(${z}px - 74px)`}},{children:s("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px] px-4"},{children:[(F||!P)&&!O.isWhiteLabel&&e(g,{className:j("absolute top-4 right-4",!F&&!P&&"top-2"),animateHover:!0}),e(f,{className:j("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",F&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxLines:2,onIconClick:()=>L("")}),P&&!b.isLoading&&e(x,{className:j("opacity-0 transition-all duration-500 ease-in-out h-0 w-full",!F&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",onIconClick:()=>L("")}),e("div",Object.assign({className:j("flex flex-col mt-6 transition-all duration-300 ease-in-out w-full",P&&!b.isLoading&&!F&&"mt-0")},{children:b.isLoading&&!(null==y?void 0:y.enablechatresponses)?s("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[S&&s("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e(d,{className:"w-[72px] h-[72px]"}),e(d,{className:"h-[20px] mt-6 w-full"}),e(d,{className:"h-[20px] mt-2 w-full"}),e(d,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e(d,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e(d,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e(d,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):b.isError?e("div",Object.assign({className:"flex w-full justify-center"},{children:s("p",Object.assign({className:j(k.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):b.data?s("div",Object.assign({className:"flex flex-col w-full"},{children:[s("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[b.data.messages.map(((s,a)=>e(h,Object.assign({index:a,message:s},0===a&&{isIntroExpand:v}),a))),A.map(((s,a)=>e(h,{index:b.data.messages.length+a,message:s},a))),"fetching"===H||B?s("div",Object.assign({className:j("flex max-w-[80%] items-center gap-x-3 ",I?"justify-end":"justify-start")},{children:["NONE"!==(null==y?void 0:y.chaticon)&&e(c,{src:null!==(N=null==y?void 0:y.chaticon)&&void 0!==N?N:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==y?void 0:y.formid}.png`,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6",textColor:C.text}),e("div",Object.assign({className:"flex items-center gap-x-2 rounded px-4 py-4"},{children:Array.from({length:3}).map(((s,a)=>e("div",{className:j("h-1.5 w-1.5 animate-dot rounded-full",1===a&&"animate-dot-down"),style:{backgroundColor:C.secondaryText}},a)))}))]})):R?e("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e(u,{})})):$?e("div",Object.assign({className:j("flex items-center gap-x-3",I?"justify-end":"justify-start")},{children:e(m,{error:$})})):null]})),e(p,{className:"w-full"})]})):null}))]}))}))};export{w as default};
1
+ import{jsx as e,jsxs as s}from"react/jsx-runtime";import{useMemo as a}from"react";import{usePickaxeContext as o}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as t}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as i}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useScrollContext as l}from"../../Addons/Scroll/hooks/useScrollContext.js";import{useStyleFontSize as n}from"../../../../hooks/studio/useStyleFontSize.js";import{useConversation as r}from"../../../../hooks/pickaxe/useConversation.js";import c from"../../common/PickaxeIcon.js";import m from"../../../Core/ErrorAlert.js";import d from"../../../Core/Skeleton.js";import p from"../../Addons/Scroll/ScrollLockView.js";import f from"../../common/PickaxeHead.js";import x from"../../common/PickaxeCompactHead.js";import u from"../../common/PickaxeUpgradeCard.js";import h from"./Message.js";import g from"../../common/PickaxeBranding.js";import j from"../../../../common/cn.js";const w=({hideInfo:w,isInputFocused:v})=>{var N;const b=r(),k=n(),{pickaxe:y,colors:C,misc:O,isNewChat:S,isRtl:I,isEmbed:P,setChatId:L}=o(),{scrollContainerRef:E}=l(),{messages:A,status:H,limitData:R,error:$}=t(),{height:z}=i(),D=a((()=>!!b.data&&!(b.data.messages.length<=1)),[b.data]),F=a((()=>!w&&b.isSuccess&&S&&!D),[w,b.isSuccess,S,D]),B=a((()=>{var e,s;return!!A.length&&!(null!==(s=null===(e=null==A?void 0:A[A.length-1])||void 0===e?void 0:e.content)&&void 0!==s?s:"").trim()}),[A]);return console.log(z),e("div",Object.assign({ref:E,className:"flex w-full flex-col items-center overflow-y-auto mb-12 pb-8",style:{height:`calc(${z}px - 74px)`}},{children:s("div",Object.assign({className:"relative flex flex-col items-center flex-grow w-full max-w-[800px] px-4"},{children:[(F||!P)&&!O.isWhiteLabel&&e(g,{className:j("absolute top-4 right-4",!F&&!P&&"top-2"),animateHover:!0}),e(f,{className:j("opacity-0 mt-[0%] transition-all duration-500 ease-in-out max-h-0 overflow-hidden max-w-[500px]",F&&"opacity-100 mt-[10%] max-h-[100%]"),iconClassName:"duration-300 hover:opacity-90",maxLines:2,onIconClick:()=>L("")}),P&&!b.isLoading&&e(x,{className:j("opacity-0 transition-all duration-500 ease-in-out h-0 w-full",!F&&"opacity-100 h-[56px]"),iconClassName:"duration-300 hover:opacity-90",onIconClick:()=>L("")}),e("div",Object.assign({className:j("flex flex-col mt-6 transition-all duration-300 ease-in-out w-full",P&&!b.isLoading&&!F&&"mt-0")},{children:b.isLoading&&!(null==y?void 0:y.enablechatresponses)?s("div",Object.assign({className:"grid w-full max-w-[800px] grid-cols-1 gap-y-6 px-6 pt-10"},{children:[S&&s("div",Object.assign({className:"flex flex-col items-center w-full"},{children:[e(d,{className:"w-[72px] h-[72px]"}),e(d,{className:"h-[20px] mt-6 w-full"}),e(d,{className:"h-[20px] mt-2 w-full"}),e(d,{className:"h-[20px] mt-2 w-full max-w-[400px]"})]})),e(d,{className:"h-10 w-[70%] animate-pulse justify-self-end rounded"}),e(d,{className:"h-[150px] w-[70%] animate-pulse rounded"}),e(d,{className:"h-10 w-[50%] animate-pulse justify-self-end rounded"})]})):b.isError?e("div",Object.assign({className:"flex w-full justify-center"},{children:s("p",Object.assign({className:j(k.b2,"text-center font-semibold")},{children:["Something went wrong. Please try again, or"," ",e("a",Object.assign({href:"mailto:info@pickaxeproject.com?subject=Help",target:"_blank",rel:"noreferrer"},{children:"contact us"}))," ","for help."]}))})):b.data?s("div",Object.assign({className:"flex flex-col w-full"},{children:[s("div",Object.assign({className:"grid grid-cols-1 gap-y-6 w-full"},{children:[b.data.messages.map(((s,a)=>e(h,Object.assign({index:a,message:s},0===a&&{isIntroExpand:v}),a))),A.map(((s,a)=>e(h,{index:b.data.messages.length+a,message:s},a))),"fetching"===H||B?s("div",Object.assign({className:j("flex max-w-[80%] items-center gap-x-3 ",I?"justify-end":"justify-start")},{children:["NONE"!==(null==y?void 0:y.chaticon)&&e(c,{src:null!==(N=null==y?void 0:y.chaticon)&&void 0!==N?N:`https://prod-pickaxe-assets.s3.us-west-2.amazonaws.com/chaticons/${null==y?void 0:y.formid}.png`,alt:`${null==y?void 0:y.formtitle}'s Chat Icon`,width:24,height:24,className:"h-6 w-6",textColor:C.text}),e("div",Object.assign({className:"flex items-center gap-x-2 rounded px-4 py-4"},{children:Array.from({length:3}).map(((s,a)=>e("div",{className:j("h-1.5 w-1.5 animate-dot rounded-full",1===a&&"animate-dot-down"),style:{backgroundColor:C.secondaryText}},a)))}))]})):R?e("div",Object.assign({className:"flex max-w-[80%] items-center gap-x-3"},{children:e(u,{})})):$?e("div",Object.assign({className:j("flex items-center gap-x-3",I?"justify-end":"justify-start")},{children:e(m,{error:$})})):null]})),e(p,{className:"w-full"})]})):null}))]}))}))};export{w as default};
@@ -1 +1 @@
1
- import{jsx as e,jsxs as s}from"react/jsx-runtime";import{Fragment as a}from"react";import{useInView as i}from"react-intersection-observer";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useHistory as r}from"../../../../hooks/pickaxe/useHistory.js";import o from"../../../Icons/spinner-circle.svg.js";import n from"./Item.js";const l=()=>{var l;const{styles:c,colors:m,isShowHistory:d}=t(),p=r({enabled:d}),{ref:f}=i({onChange(e){e&&p.hasNextPage&&p.fetchNextPage()}});return d&&p.isLoading?e("div",{className:"w-full min-h-[300px] animate-pulse bg-[#E5E7EB] dark:bg-[#1E1E1F]",style:{backgroundColor:"dark"===c.theme?"#1E1E1F":"#E5E7EB"}}):p.isError?e("div",{}):d?s("div",Object.assign({className:"flex flex-col gap-y-8"},{children:[null===(l=p.data)||void 0===l?void 0:l.pages.map(((s,i)=>e(a,{children:s.data.map((s=>e(a,{children:e(n,{item:s})},s.responseId)))},i))),e("div",Object.assign({className:"flex items-center justify-center"},{children:p.isFetchingNextPage?e(o,{className:"my-10 h-14 w-14 animate-spin animate-spin text-gray-300",style:{fill:m.accent}}):p.hasNextPage?e("div",{ref:f,className:"invisible h-14 w-14"}):null}))]})):null};export{l as default};
1
+ import{jsx as e,jsxs as s}from"react/jsx-runtime";import{Fragment as i}from"react";import{useInView as a}from"react-intersection-observer";import{usePickaxeContext as t}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useHistory as r}from"../../../../hooks/pickaxe/useHistory.js";import o from"../../../Icons/spinner-circle.svg.js";import n from"./Item.js";const c=()=>{var c,l;const{styles:m,colors:d,misc:p}=t(),f=r({enabled:null===(c=p.isHistory)||void 0===c||c}),{ref:g}=a({onChange(e){e&&f.hasNextPage&&f.fetchNextPage()}});return f.isLoading?e("div",{className:"w-full min-h-[300px] animate-pulse bg-[#E5E7EB] dark:bg-[#1E1E1F]",style:{backgroundColor:"dark"===m.theme?"#1E1E1F":"#E5E7EB"}}):f.isError?e("div",{}):s("div",Object.assign({className:"flex flex-col gap-y-8"},{children:[null===(l=f.data)||void 0===l?void 0:l.pages.map(((s,a)=>e(i,{children:s.data.map((s=>e(i,{children:e(n,{item:s})},s.responseId)))},a))),e("div",Object.assign({className:"flex items-center justify-center"},{children:f.isFetchingNextPage?e(o,{className:"my-10 h-14 w-14 animate-spin animate-spin text-gray-300",style:{fill:d.accent}}):f.hasNextPage?e("div",{ref:g,className:"invisible h-14 w-14"}):null}))]}))};export{c 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{generateId as i}from"../../../common/utils.js";import r from"../common/PickaxeButton.js";import a from"../common/PickaxeBranding.js";import n from"../../../common/cn.js";const c=()=>{const{misc:c,translations:m,responsiveBy:x,isShowHistory:l,setChatId:p,setIsNewChat:f,setIsShowHistory:w}=o(),{setMessages:h}=t();return e("div",Object.assign({className:n("mt-4 flex flex-wrap flex-col justify-between gap-2","viewport"===x?"min-[767px]:flex-row":"@[767px]/pickaxe-root:flex-row")},{children:[e("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[s(r,Object.assign({className:n("w-full","viewport"===x?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]"),onClick:()=>{return e=i(20),h([]),p(e),void f(!0);var e}},{children:(null==m?void 0:m["new-chat"])||"New chat"})),c.isHistory&&!l&&s(r,Object.assign({variant:"transparent-text",className:n("w-full","viewport"===x?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]"),onClick:()=>w(!0)},{children:(null==m?void 0:m["see-history"])||"See history"}))]})),!c.isWhiteLabel&&s("div",Object.assign({className:"flex justify-end pr-3"},{children:s(a,{})}))]}))};export{c as default};
1
+ import{jsxs as e,jsx as o}from"react/jsx-runtime";import{usePickaxeContext as s}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as t}from"../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as i}from"../../../hooks/pickaxe/useDimensionContext.js";import{generateId as r}from"../../../common/utils.js";import a from"../common/PickaxeButton.js";import n from"../common/PickaxeBranding.js";import m from"../../../common/cn.js";const c=()=>{const{misc:c,translations:x,responsiveBy:p,setChatId:l,setIsNewChat:f}=s(),{setMessages:j}=t(),{setHeight:w}=i();return e("div",Object.assign({className:m("mt-4 flex flex-wrap flex-col justify-between gap-2","viewport"===p?"min-[767px]:flex-row":"@[767px]/pickaxe-root:flex-row")},{children:[o("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:o(a,Object.assign({className:m("w-full","viewport"===p?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]"),onClick:()=>{return e=r(20),w(0),j([]),l(e),void f(!0);var e}},{children:(null==x?void 0:x["new-chat"])||"New chat"}))})),!c.isWhiteLabel&&o("div",Object.assign({className:"flex justify-end pr-3"},{children:o(n,{})}))]}))};export{c as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as t,jsx as o}from"react/jsx-runtime";import{useState as s}from"react";import{usePickaxeContext as n}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useSubmit as r}from"../../../../hooks/pickaxe/useSubmit.js";import{useDocument as l}from"../../Addons/Document/hooks/useDocument.js";import{useScroll as a}from"../../Addons/Scroll/hooks/useScroll.js";import{extractUrlsFromText as d}from"../../../../common/utils.js";import{encode as c}from"@nem035/gpt-3-encoder";import{createParser as m}from"eventsource-parser";import u from"../../common/PickaxeBranding.js";import p from"../../common/PickaxeButton.js";import f from"../../../../common/error.js";import g from"../../../../common/cn.js";const h=({questions:h})=>{var x;const{formId:b,userId:v,studioUserId:j,embedUserId:w,deploymentId:y,pickaxe:k,misc:I,translations:O,responsiveBy:S,isShowHistory:C,setChatId:E,setIsShowHistory:U,setIsNewChat:D,onGenerateComplete:N}=n(),{status:P,limits:R,isGenerating:q,setResponse:A,setMessages:L,setStatus:B,setLimitData:T,setError:H}=i(),{documents:W,websiteLink:G,isUploading:J,onWebsiteUpload:M,setDocumentError:_}=l(),{scrollStartSession:K,scrollEndSession:X,scrollToTarget:Y}=a({auto:!(null==k?void 0:k.enablechatresponses)}),z=r(),[F,Q]=s(!1);return t("div",Object.assign({className:g("mt-4 flex flex-wrap flex-col justify-between gap-2","viewport"===S?"min-[767px]:flex-row":"@[767px]/pickaxe-root:flex-row")},{children:[t("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:[o(p,Object.assign({className:"px-5 min-h-[42px]",isDisabled:J||"idle"!==P||q||F,onClick:()=>e(void 0,void 0,void 0,(function*(){try{if("idle"!==P||J||F)return;H(""),T(null),_(""),A(null);const e=["Multiple Choice","Checkbox"];for(const t of h){if(c(t.input).length>t.maxLength&&!e.includes(t.type))throw new Error("One or more of your responses is too long!");if(t.isRequired&&!t.input.trim()&&"userinput:documentupload"!==t.id)throw new Error("You must fill out all required fields.")}const t=W.filter((e=>"finished"===e.status)),o=W.map((e=>e.name)),s="enduserupload"===(null==k?void 0:k.documentuploadtype),n=h.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),i=d(G).filter((e=>!o.includes(e)));if(i.length){const e=i[i.length-1];Q(!0);const o=yield M(e);o&&(t.push(o),yield new Promise((e=>setTimeout(e,5e3)))),Q(!1)}else if(n&&s&&!t.length)return void _("Please paste a valid website/video link or drag a file to add to the knowledge base.");const r=t.length?t[t.length-1]:null,l=s&&r&&"finished"===r.status;let a={};h.forEach((e=>a=Object.assign(Object.assign({},a),{[e.id]:"Knowledge Upload"===e.type||e.id.includes("documentupload")?(null==r?void 0:r.name)||"":e.input}))),B("fetching"),K(),Y();const u=yield z.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:b,valueObj:a},l&&{documentId:r.documentId}),v&&{userId:v}),j&&{studioUserId:j}),w&&{embedUserId:w}),y&&{deploymentId:y})),p=u.body;if(!p)throw new Error("Streaming error");const f=u.headers.get("X-Pickaxe-Response-Id");if(!f)throw new Error("Response ID not found");const g=new TextDecoder,x=p.getReader();let I="",O=!0,S=!1;const C=m({onEvent:e=>{if("delta"===e.event){const t=JSON.parse(e.data).token.replace(/\u200B/g,"");I+=t,A({formId:b,responseId:f,documentIds:r&&r.documentId?[r.documentId]:[],questions:h.map((e=>({id:e.id,question:e.main,answer:e.input}))),questionResponse:I,messageCount:0,sentAt:new Date}),(null==k?void 0:k.enablechatresponses)&&L([{id:0,role:"assistant",content:I}])}else if("error"===e.event){const t=JSON.parse(e.data);H(t.error||"Something went wrong, please try again.")}else"stop"===e.event&&(O=!1)}});for(;O;){const{value:e,done:t}=yield x.read();if(t){O=!1;break}const o=g.decode(e);o&&(S||(B("streaming"),S=!0,(null==k?void 0:k.enablechatresponses)&&(E(f),D(!1))),C.feed(o))}null==N||N(f)}catch(e){let t=f(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(R).find((([e])=>t.includes(e)));o?T(o[1]):H(t),Y()}finally{B("idle"),Q(!1),X()}}))},{children:F?(null==O?void 0:O.processing)||"Processing...":J?(null==O?void 0:O.uploading)||"Uploading...":"fetching"===P||"streaming"===P?(null==O?void 0:O.loading)||"Loading...":null!==(x=null==k?void 0:k.submittext)&&void 0!==x?x:"Submit"})),I.isHistory&&!C&&o(p,Object.assign({variant:"transparent-text",className:"px-4",onClick:()=>U(!0)},{children:(null==O?void 0:O["see-history"])||"See history"}))]})),!I.isWhiteLabel&&o("div",Object.assign({className:"flex justify-end pr-3"},{children:o(u,{})}))]}))};export{h as default};
1
+ import{__awaiter as e}from"../../../../_virtual/_tslib.js";import{jsxs as o,jsx as t}from"react/jsx-runtime";import{useState as s}from"react";import{usePickaxeContext as n}from"../../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as i}from"../../../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as r}from"../../../../hooks/pickaxe/useDimensionContext.js";import{useSubmit as l}from"../../../../hooks/pickaxe/useSubmit.js";import{useDocument as a}from"../../Addons/Document/hooks/useDocument.js";import{useScroll as d}from"../../Addons/Scroll/hooks/useScroll.js";import{extractUrlsFromText as c}from"../../../../common/utils.js";import{encode as m}from"@nem035/gpt-3-encoder";import{createParser as u}from"eventsource-parser";import p from"../../common/PickaxeBranding.js";import f from"../../common/PickaxeButton.js";import g from"../../../../common/error.js";import h from"../../../../common/cn.js";const x=({questions:x})=>{var b;const{formId:v,userId:j,studioUserId:w,embedUserId:k,deploymentId:I,pickaxe:y,misc:O,translations:S,responsiveBy:C,setChatId:D,setIsNewChat:E,onGenerateComplete:U}=n(),{status:P,limits:R,isGenerating:q,setResponse:N,setMessages:A,setStatus:L,setLimitData:B,setError:T}=i(),{documents:W,websiteLink:G,isUploading:J,onWebsiteUpload:M,setDocumentError:_}=a(),{setHeight:H}=r(),{scrollStartSession:K,scrollEndSession:X,scrollToTarget:Y}=d({auto:!(null==y?void 0:y.enablechatresponses)}),z=l(),[F,Q]=s(!1);return o("div",Object.assign({className:h("mt-4 flex flex-wrap flex-col justify-between gap-2","viewport"===C?"min-[767px]:flex-row":"@[767px]/pickaxe-root:flex-row")},{children:[t("div",Object.assign({className:"flex items-center flex-grow flex-wrap gap-2"},{children:t(f,Object.assign({className:"px-5 min-h-[42px]",isDisabled:J||"idle"!==P||q||F,onClick:()=>e(void 0,void 0,void 0,(function*(){try{if("idle"!==P||J||F)return;T(""),B(null),_(""),N(null);const e=["Multiple Choice","Checkbox"];for(const o of x){if(m(o.input).length>o.maxLength&&!e.includes(o.type))throw new Error("One or more of your responses is too long!");if(o.isRequired&&!o.input.trim()&&"userinput:documentupload"!==o.id)throw new Error("You must fill out all required fields.")}const o=W.filter((e=>"finished"===e.status)),t=W.map((e=>e.name)),s="enduserupload"===(null==y?void 0:y.documentuploadtype),n=x.some((e=>"userinput:documentupload"===e.id&&e.isRequired)),i=c(G).filter((e=>!t.includes(e)));if(i.length){const e=i[i.length-1];Q(!0);const t=yield M(e);t&&(o.push(t),yield new Promise((e=>setTimeout(e,5e3)))),Q(!1)}else if(n&&s&&!o.length)return void _("Please paste a valid website/video link or drag a file to add to the knowledge base.");const r=o.length?o[o.length-1]:null,l=s&&r&&"finished"===r.status;let a={};x.forEach((e=>a=Object.assign(Object.assign({},a),{[e.id]:"Knowledge Upload"===e.type||e.id.includes("documentupload")?(null==r?void 0:r.name)||"":e.input}))),L("fetching"),K(),Y();const d=yield z.mutateAsync(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({formId:v,valueObj:a},l&&{documentId:r.documentId}),j&&{userId:j}),w&&{studioUserId:w}),k&&{embedUserId:k}),I&&{deploymentId:I})),p=d.body;if(!p)throw new Error("Streaming error");const f=d.headers.get("X-Pickaxe-Response-Id");if(!f)throw new Error("Response ID not found");const g=new TextDecoder,h=p.getReader();let b="",O=!0,S=!1;const C=u({onEvent:e=>{if("delta"===e.event){const o=JSON.parse(e.data).token.replace(/\u200B/g,"");b+=o,N({formId:v,responseId:f,documentIds:r&&r.documentId?[r.documentId]:[],questions:x.map((e=>({id:e.id,question:e.main,answer:e.input}))),questionResponse:b,messageCount:0,sentAt:new Date}),(null==y?void 0:y.enablechatresponses)&&A([{id:0,role:"assistant",content:b}])}else if("error"===e.event){const o=JSON.parse(e.data);T(o.error||"Something went wrong, please try again.")}else"stop"===e.event&&(O=!1)}});for(;O;){const{value:e,done:o}=yield h.read();if(o){O=!1;break}const t=g.decode(e);t&&(S||(L("streaming"),S=!0,(null==y?void 0:y.enablechatresponses)&&(H(0),D(f),E(!1))),C.feed(t))}null==U||U(f)}catch(e){let o=g(e)||"";o&&!o.includes("Unexpected token 'A',")||(o="Oops! We're experiencing high traffic at the moment. Please try again later.");const t=Object.entries(R).find((([e])=>o.includes(e)));t?B(t[1]):T(o),Y()}finally{L("idle"),Q(!1),X()}}))},{children:F?(null==S?void 0:S.processing)||"Processing...":J?(null==S?void 0:S.uploading)||"Uploading...":"fetching"===P||"streaming"===P?(null==S?void 0:S.loading)||"Loading...":null!==(b=null==y?void 0:y.submittext)&&void 0!==b?b:"Submit"}))})),!O.isWhiteLabel&&t("div",Object.assign({className:"flex justify-end pr-3"},{children:t(p,{})}))]}))};export{x as default};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{createContext as s,useState as i,useEffect as o}from"react";import t from"./Addons/Document/Provider.js";import r from"./ResponseProvider.js";import n from"./DimensionProvider.js";const d=s({}),a=({children:s,isRtl:a=!1,userId:l="",studioUserId:c="",deploymentId:m="",embedUserId:p="",styles:h,colors:F,limits:b={},misc:I={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:y,responsiveBy:u="viewport",isEmbed:f=!1,forceMobile:g=!1,loadFont:w=!0,onGenerateComplete:P})=>{const[j,v]=i(""),[x,S]=i(""),[k,C]=i(null),[O,D]=i(!1),[H,R]=i(!0),[U,B]=i(!0),[L,T]=i(!1);return o((()=>{D(!1)}),[null==h?void 0:h.font]),e(d.Provider,Object.assign({value:Object.assign({formId:j,isRtl:a,chatId:x,userId:l,studioUserId:c,deploymentId:m,embedUserId:p,pickaxe:k,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},h),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},F),misc:I,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website"},y),responsiveBy:u,isFontLoaded:O,isNewChat:H,isShowIceBreaker:U,isShowHistory:L,loadFont:w,forceMobile:g,isEmbed:f,setIsFontLoaded:D,setFormId:v,setChatId:S,setPickaxe:C,setIsNewChat:R,setIsShowIceBreaker:B,setIsShowHistory:T},P&&{onGenerateComplete:P})},{children:e(r,Object.assign({limits:b},{children:e(n,{children:e(t,{children:s})})}))}))};export{d as PickaxeContext,a as PickaxeProvider};
1
+ import{jsx as e}from"react/jsx-runtime";import{createContext as i,useState as s,useEffect as o}from"react";import t from"./Addons/Document/Provider.js";import r from"./ResponseProvider.js";import n from"./DimensionProvider.js";const d=i({}),a=({children:i,userId:a="",studioUserId:l="",deploymentId:c="",embedUserId:m="",styles:p,colors:h,limits:F={},misc:b={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:I,responsiveBy:u="viewport",forceMobile:f=!1,loadFont:g=!0,isEmbed:y=!1,isRtl:w=!1,onGenerateComplete:P})=>{const[j,v]=s(""),[x,k]=s(""),[S,C]=s(null),[O,D]=s(!1),[R,U]=s(!0),[B,L]=s(!0);return o((()=>{D(!1)}),[null==p?void 0:p.font]),e(d.Provider,Object.assign({value:Object.assign({formId:j,chatId:x,userId:a,studioUserId:l,deploymentId:c,embedUserId:m,pickaxe:S,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},p),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},h),misc:b,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website"},I),responsiveBy:u,forceMobile:f,loadFont:g,isFontLoaded:O,isNewChat:R,isShowIceBreaker:B,isEmbed:y,isRtl:w,setIsFontLoaded:D,setFormId:v,setChatId:k,setPickaxe:C,setIsNewChat:U,setIsShowIceBreaker:L},P&&{onGenerateComplete:P})},{children:e(r,Object.assign({limits:F},{children:e(n,{children:e(t,{children:i})})}))}))};export{d as PickaxeContext,a as PickaxeProvider};
@@ -1 +1 @@
1
- import{jsx as e}from"react/jsx-runtime";import{createContext as t,useState as s}from"react";const r=t({}),i=({limits:t,children:i})=>{const[a,n]=s([]),[l,o]=s(null),[m,c]=s("idle"),[u,g]=s(null),[d,p]=s("");return e(r.Provider,Object.assign({value:{messages:a,response:l,status:m,limits:t,limitData:u,error:d,isGenerating:"fetching"===m||"streaming"===m,setMessages:n,setResponse:o,setStatus:c,setLimitData:g,setError:p}},{children:i}))};export{r as ResponseContext,i as default};
1
+ import{jsx as e}from"react/jsx-runtime";import{createContext as t,useState as s,useEffect as r}from"react";import{usePickaxeContext as i}from"../../hooks/pickaxe/usePickaxeContext.js";const a=t({}),n=({limits:t,children:n})=>{const{chatId:l}=i(),[o,m]=s([]),[c,u]=s(null),[d,p]=s("idle"),[g,f]=s(null),[h,x]=s("");return r((()=>{m([]),u(null),p("idle"),f(null),x("")}),[l]),e(a.Provider,Object.assign({value:{messages:o,response:c,status:d,limits:t,limitData:g,error:h,isGenerating:"fetching"===d||"streaming"===d,setMessages:m,setResponse:u,setStatus:p,setLimitData:f,setError:x}},{children:n}))};export{a as ResponseContext,n as default};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as o,jsxs as t,Fragment as s}from"react/jsx-runtime";import{usePickaxe as r}from"../../hooks/pickaxe/usePickaxe.js";import{useState as i,useRef as a,useEffect as l}from"react";import{usePickaxeContext as n}from"../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as m}from"../../hooks/pickaxe/useDimensionContext.js";import{generateId as f}from"../../common/utils.js";import d from"./Addons/Scroll/Provider.js";import p from"../Core/Skeleton.js";import x from"./Chat/index.js";import u from"./Form/index.js";import h from"../../common/cn.js";const w=({formId:w,className:k})=>{const{chatId:j,styles:g,colors:v,loadFont:b,responsiveBy:N,isFontLoaded:y,setFormId:C,setChatId:F,setPickaxe:I,setIsFontLoaded:O}=n(),{setMessages:P,setResponse:R,setError:L,setLimitData:H}=c(),{setWidth:D,setHeight:M,setIsMobile:S}=m(),[_,z]=i(!1),A=r(),B=a(null);return l((()=>{C(w)}),[w]),l((()=>{if(!A.data)return;const e=A.data.chatflag;F(e?f(15):""),e?P([]):R(null),L(""),H(null),I(A.data),z(!0)}),[A.data]),l((()=>{e(void 0,void 0,void 0,(function*(){"undefined"!=typeof window&&(y||b&&"Real Head Pro"!==g.font&&((yield import("webfontloader")).default.load({google:{families:[g.font]}}),O(!0)))}))}),[g.font,b,y]),l((()=>{if(!B.current)return;const e=new ResizeObserver((e=>{for(const o of e){const{width:e,height:t}=o.contentRect;D(e),M(t),S(e<768)}}));return e.observe(B.current),()=>{e.disconnect()}}),[B.current]),A.data?o("div",Object.assign({ref:B,className:h("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full",k,"dark"===g.theme&&"dark"),style:Object.assign({backgroundColor:v.primary,color:v.text},g.font&&"Real Head Pro"!==g.font&&{fontFamily:g.font})},{children:A.isLoading||!_?o("div",Object.assign({className:h("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===N?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:t("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[o(p,{className:"w-[72px] h-[72px]"}),o(p,{className:"h-[20px] mt-6 w-full"}),o(p,{className:"h-[20px] mt-2 w-full"}),o(p,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),o("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:o(p,{className:h("w-full min-h-[48px]","viewport"===N?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):o(s,{children:o(d,j?{children:o(x,{})}:{children:o(u,{})})})})):null};export{w as Pickaxe};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as o,jsxs as t,Fragment as s}from"react/jsx-runtime";import{usePickaxe as r}from"../../hooks/pickaxe/usePickaxe.js";import{useState as i,useRef as a,useEffect as l}from"react";import{usePickaxeContext as n}from"../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as c}from"../../hooks/pickaxe/useResponseContext.js";import{useDimensionContext as m}from"../../hooks/pickaxe/useDimensionContext.js";import{generateId as d}from"../../common/utils.js";import f from"./Addons/Scroll/Provider.js";import p from"../Core/Skeleton.js";import x from"./Chat/index.js";import u from"./Form/index.js";import h from"../../common/cn.js";const w=({formId:w,className:k})=>{const{chatId:j,styles:g,colors:v,loadFont:b,responsiveBy:N,isFontLoaded:y,setFormId:F,setChatId:I,setPickaxe:C,setIsFontLoaded:O}=n(),{setMessages:P,setResponse:R,setError:L,setLimitData:H}=c(),{setWidth:D,setHeight:M,setIsMobile:S}=m(),[_,z]=i(!1),A=r(),B=a(null);return l((()=>{F(w)}),[w]),l((()=>{if(!A.data)return;const e=A.data.chatflag;I(e?d(15):""),e?P([]):R(null),L(""),H(null),C(A.data),z(!0)}),[A.data]),l((()=>{e(void 0,void 0,void 0,(function*(){"undefined"!=typeof window&&(y||b&&"Real Head Pro"!==g.font&&((yield import("webfontloader")).default.load({google:{families:[g.font]}}),O(!0)))}))}),[g.font,b,y]),l((()=>{if(!B.current)return;const e=new ResizeObserver((e=>{for(const o of e){const{width:e,height:t}=o.contentRect;D(parseInt(e.toFixed(0))),M(parseInt(t.toFixed(0))),S(e<768)}}));return e.observe(B.current),()=>{e.disconnect()}}),[B.current]),A.data?o("div",Object.assign({ref:B,className:h("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full",k,"dark"===g.theme&&"dark"),style:Object.assign({backgroundColor:v.primary,color:v.text},g.font&&"Real Head Pro"!==g.font&&{fontFamily:g.font})},{children:A.isLoading||!_?o("div",Object.assign({className:h("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===N?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:t("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[o(p,{className:"w-[72px] h-[72px]"}),o(p,{className:"h-[20px] mt-6 w-full"}),o(p,{className:"h-[20px] mt-2 w-full"}),o(p,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),o("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:o(p,{className:h("w-full min-h-[48px]","viewport"===N?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):o(s,{children:o(f,j?{children:o(x,{})}:{children:o(u,{})})})})):null};export{w as Pickaxe};
@@ -1,2 +1,2 @@
1
- declare const Container: () => import("react/jsx-runtime").JSX.Element | null;
1
+ declare const Container: () => import("react/jsx-runtime").JSX.Element;
2
2
  export default Container;
@@ -35,7 +35,6 @@ export type PickaxeMisc = {
35
35
  };
36
36
  type PickaxeContextType = {
37
37
  formId: string;
38
- isRtl?: boolean;
39
38
  chatId: string;
40
39
  userId: string;
41
40
  studioUserId: string;
@@ -47,20 +46,19 @@ type PickaxeContextType = {
47
46
  misc: PickaxeMisc;
48
47
  translations: PickaxeTranslations;
49
48
  responsiveBy: PickaxeResponsiveBy;
49
+ forceMobile: boolean;
50
+ loadFont: boolean;
50
51
  isFontLoaded: boolean;
51
52
  isNewChat: boolean;
52
53
  isShowIceBreaker: boolean;
53
- isShowHistory: boolean;
54
54
  isEmbed: boolean;
55
- forceMobile: boolean;
56
- loadFont: boolean;
55
+ isRtl?: boolean;
57
56
  setFormId: SetState<string>;
58
57
  setChatId: SetState<string>;
59
58
  setPickaxe: SetState<LimitedPickaxe | null>;
60
59
  setIsFontLoaded: SetState<boolean>;
61
60
  setIsNewChat: SetState<boolean>;
62
61
  setIsShowIceBreaker: SetState<boolean>;
63
- setIsShowHistory: SetState<boolean>;
64
62
  onGenerateComplete?: (responseId: string) => void;
65
63
  };
66
64
  export interface IPickaxeProviderProps {
@@ -82,5 +80,5 @@ export interface IPickaxeProviderProps {
82
80
  onGenerateComplete?: (responseId: string) => void;
83
81
  }
84
82
  export declare const PickaxeContext: import("react").Context<PickaxeContextType>;
85
- export declare const PickaxeProvider: ({ children, isRtl, userId, studioUserId, deploymentId, embedUserId, styles, colors, limits, misc, translations, responsiveBy, isEmbed, forceMobile, loadFont, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
83
+ export declare const PickaxeProvider: ({ children, userId, studioUserId, deploymentId, embedUserId, styles, colors, limits, misc, translations, responsiveBy, forceMobile, loadFont, isEmbed, isRtl, onGenerateComplete, }: IPickaxeProviderProps) => import("react/jsx-runtime").JSX.Element;
86
84
  export {};
@@ -1,6 +1,5 @@
1
1
  export declare const usePickaxeContext: () => {
2
2
  formId: string;
3
- isRtl?: boolean | undefined;
4
3
  chatId: string;
5
4
  userId: string;
6
5
  studioUserId: string;
@@ -12,19 +11,18 @@ export declare const usePickaxeContext: () => {
12
11
  misc: import("../../components/Pickaxe/Provider").PickaxeMisc;
13
12
  translations: import("../../components/Pickaxe/Provider").PickaxeTranslations;
14
13
  responsiveBy: import("../../components/Pickaxe/Provider").PickaxeResponsiveBy;
14
+ forceMobile: boolean;
15
+ loadFont: boolean;
15
16
  isFontLoaded: boolean;
16
17
  isNewChat: boolean;
17
18
  isShowIceBreaker: boolean;
18
- isShowHistory: boolean;
19
19
  isEmbed: boolean;
20
- forceMobile: boolean;
21
- loadFont: boolean;
20
+ isRtl?: boolean | undefined;
22
21
  setFormId: import("../../types/common").SetState<string>;
23
22
  setChatId: import("../../types/common").SetState<string>;
24
23
  setPickaxe: import("../../types/common").SetState<import("../../types/pickaxe").LimitedPickaxe | null>;
25
24
  setIsFontLoaded: import("../../types/common").SetState<boolean>;
26
25
  setIsNewChat: import("../../types/common").SetState<boolean>;
27
26
  setIsShowIceBreaker: import("../../types/common").SetState<boolean>;
28
- setIsShowHistory: import("../../types/common").SetState<boolean>;
29
27
  onGenerateComplete?: ((responseId: string) => void) | undefined;
30
28
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "2.1.11",
3
+ "version": "2.2.1",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",