@pickaxeproject/react 5.6.1-beta.1 → 5.6.1-beta.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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>{try{const t=document.cookie.split("; ");for(const r of t){const[t,o]=r.split("=");if(t===e)return o}return null}catch(e){return console.error("[pxe] failed to get cookie",e),null}};exports.deleteAuthToken=e=>{try{if("undefined"==typeof window)return;localStorage.removeItem(e)}catch(e){console.error("[pxe] failed to delete auth token",e)}},exports.deleteCookie=e=>{document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"},exports.extractUrlsFromText=e=>{const t=e.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(t))},exports.formatBytes=(e,t=2)=>{if(!+e)return"0 Bytes";const r=t<0?0:t,o=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,o)).toFixed(r))} ${["Bytes","KB","MB","PB","EB"][o]}`},exports.generateId=(e,t="",r="")=>{let o="";for(let t=0;t<e;t++){o+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return t+o+r},exports.getAuthToken=t=>{try{if("undefined"==typeof window)return null;let r=null;return r=new URLSearchParams(window.location.search).get("pxtoken"),r||(r=localStorage.getItem(`PXE-token-${t}`)),r||(r=e(`PXE-token-${t}`)),r?decodeURIComponent(r):null}catch(e){return null}},exports.getCookie=e,exports.isInIframe=()=>{if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch(e){return!0}},exports.mergeRefs=function(...e){return t=>{for(const r of e)r&&("function"==typeof r?r(t):r.current=t)}},exports.randomStr=(e,t=!1)=>{let r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";t&&(r=r.replace(/[0-9]/g,""));let o="";for(let t=0;t<e;t++)o+=r.charAt(Math.floor(Math.random()*r.length));return o},exports.safeJSONParse=e=>{try{return JSON.parse(e)}catch(e){return null}},exports.setAuthToken=(e,t)=>{try{if("undefined"==typeof window)return;localStorage.setItem(e,t)}catch(e){console.error("[pxe] failed to set auth token",e)}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e=e=>{try{const t=document.cookie.split("; ");for(const o of t){const[t,r]=o.split("=");if(t===e)return r}return null}catch(e){return console.error("[pxe] failed to get cookie",e),null}};exports.deleteAuthToken=e=>{try{if("undefined"==typeof window)return;localStorage.removeItem(e)}catch(e){console.error("[pxe] failed to delete auth token",e)}},exports.deleteCookie=e=>{document.cookie=e+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"},exports.extractUrlsFromText=e=>{const t=e.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(t))},exports.formatBytes=(e,t=2)=>{if(!+e)return"0 Bytes";const o=t<0?0:t,r=Math.floor(Math.log(e)/Math.log(1024));return`${parseFloat((e/Math.pow(1024,r)).toFixed(o))} ${["Bytes","KB","MB","PB","EB"][r]}`},exports.generateId=(e,t="",o="")=>{let r="";for(let t=0;t<e;t++){r+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return t+r+o},exports.getAuthToken=t=>{try{if("undefined"==typeof window)return null;let o=null;return o=new URLSearchParams(window.location.search).get("pxtoken"),o||(o=localStorage.getItem(`PXE-token-${t}`)),o||(o=e(`PXE-token-${t}`)),o||(o=e(`__Secure-PS-${t}.session-token`)),o?decodeURIComponent(o):null}catch(e){return null}},exports.getCookie=e,exports.isInIframe=()=>{if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch(e){return!0}},exports.mergeRefs=function(...e){return t=>{for(const o of e)o&&("function"==typeof o?o(t):o.current=t)}},exports.randomStr=(e,t=!1)=>{let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";t&&(o=o.replace(/[0-9]/g,""));let r="";for(let t=0;t<e;t++)r+=o.charAt(Math.floor(Math.random()*o.length));return r},exports.safeJSONParse=e=>{try{return JSON.parse(e)}catch(e){return null}},exports.setAuthToken=(e,t)=>{try{if("undefined"==typeof window)return;localStorage.setItem(e,t)}catch(e){console.error("[pxe] failed to set auth token",e)}};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),i=require("../../hooks/pickaxe/usePickaxeContext.js"),l=require("./Addons/Auth/hooks/useAuthContext.js"),r=require("../../hooks/pickaxe/useResponseContext.js"),c=require("./Addons/Document/hooks/useDocumentContext.js"),o=require("./Addons/Artifact/hooks/useArtifactContext.js"),n=require("uuid"),d=require("./Addons/Scroll/Provider.js"),u=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),f=require("./Addons/Auth/index.js"),p=require("../../common/cn.js"),j=require("../../common/api/pickaxe.js"),h=require("./common/AccessGroupCardPreview.js");exports.Pickaxe=({pickaxeId:g,className:b})=>{const{sessionId:v,styles:w,colors:y,responsiveBy:k,deploymentType:q,isNewChat:N,isEmailLogin:O,isEmbed:C,opacity:A,deploymentId:_,sender:P,portalId:S,setContextId:I,setPickaxeId:E,setSessionId:D,setPickaxe:L}=i.usePickaxeContext(),{isLoggedOut:R,isSent:M,token:T}=l.useAuthContext(),{setMessages:U,setResponse:F,setError:G,setLimitData:$,setIsSwitchedToChat:B}=r.useResponseContext(),{setDocumentError:H}=c.useDocumentContext(),{setCurrentArtifact:W}=o.useArtifactContext(),[z,J]=a.useState(!1),[K,Q]=a.useState("loading"),[V,X]=a.useState([]),[Y,Z]=a.useState(null),ee=t.usePickaxe(),se="chat-input"===q&&N&&!M,te="chat-input"!==q||!M;a.useEffect((()=>{E(g)}),[g]),a.useEffect((()=>{if(!_||!ee.data)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;Q("loading");try{const s=yield j.default.post("/validate_studio_deployment",{data:{deploymentId:_,sender:P||void 0,studioSessionToken:T,portalId:S,studioId:null===(e=ee.data)||void 0===e?void 0:e.studioid}});s.data.success?Q("success"):"Login required."===s.data.message?(Q("login_required"),J(!0)):"Access denied."===s.data.message?(Q("access_denied"),J(!0)):"Upgrade required."===s.data.message?(Q("upgrade_required"),X(s.data.upgradeGroups||[]),Z(s.data.upgradeUrl),J(!0)):Q("login_required")}catch(e){console.error("Failed to validate deployment:",e),Q("success")}}))}),[_,P,T,S,ee.data]),a.useEffect((()=>{if(!ee.data)return;const e=ee.data.chatflag;D(e?n.v4():""),I(n.v4()),e?U([]):F(null),G(""),H(""),$(null),W(null),B(!1),L(ee.data),J(!0)}),[ee.data]),a.useEffect((()=>{G(""),H(""),$(null),U([]),F(null),W(null)}),[v]);const ae=a.useMemo((()=>{const e=null!=A?A:1;if(!y.primary||!y.primary.startsWith("#")||e<0||e>1)return y.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${y.primary}${s}`}),[y.primary,A]);if(!ee.data)return null;return s.jsx("div",Object.assign({className:p.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===w.theme&&"dark",b),style:Object.assign({backgroundColor:se?"transparent":ae,color:y.text},w.font&&"Real Head Pro"!==w.font&&{fontFamily:w.font})},{children:ee.isLoading||!z||"loading"===K?s.jsx("div",Object.assign({className:p.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===k?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s.jsx(u.default,{className:"w-[72px] h-[72px]"}),s.jsx(u.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s.jsx(u.default,{className:p.default("w-full min-h-[48px]","viewport"===k?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===K?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:V&&V.length>0?s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[s.jsxs("div",Object.assign({className:"text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),s.jsx("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:V.map(((e,t)=>s.jsx(h.default,{data:e,upgradeUrl:Y},e.id||t)))}))]})):s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===K&&C||O&&R&&te?s.jsx(f.default,{}):"login_required"!==K||C?"access_denied"===K?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Contact tool owner to request access."}))]}))})):v?s.jsx(d.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(d.ScrollProvider,{children:s.jsx(m.default,{})}):s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}))};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),a=require("react"),i=require("../../hooks/pickaxe/usePickaxeContext.js"),l=require("./Addons/Auth/hooks/useAuthContext.js"),r=require("../../hooks/pickaxe/useResponseContext.js"),c=require("./Addons/Document/hooks/useDocumentContext.js"),o=require("./Addons/Artifact/hooks/useArtifactContext.js"),n=require("uuid"),d=require("./Addons/Scroll/Provider.js"),u=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),f=require("./Addons/Auth/index.js"),p=require("../../common/cn.js"),j=require("../../common/api/pickaxe.js"),h=require("./common/AccessGroupCardPreview.js");exports.Pickaxe=({pickaxeId:g,className:b})=>{const{sessionId:v,styles:w,colors:y,responsiveBy:k,deploymentType:q,isNewChat:N,isEmailLogin:O,isEmbed:C,opacity:A,deploymentId:_,sender:P,portalId:S,setContextId:I,setPickaxeId:E,setSessionId:D,setPickaxe:L}=i.usePickaxeContext(),{isLoggedOut:R,isSent:M,token:T}=l.useAuthContext(),{setMessages:U,setResponse:F,setError:G,setLimitData:$,setIsSwitchedToChat:B}=r.useResponseContext(),{setDocumentError:H}=c.useDocumentContext(),{setCurrentArtifact:W}=o.useArtifactContext(),[z,J]=a.useState(!1),[K,Q]=a.useState("loading"),[V,X]=a.useState([]),[Y,Z]=a.useState(null),ee=t.usePickaxe(),se="chat-input"===q&&N&&!M,te="chat-input"!==q||!M;a.useEffect((()=>{E(g)}),[g]),a.useEffect((()=>{if(!_&&!S||!ee.data)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;Q("loading");try{const s=yield j.default.post("/validate_studio_deployment",{data:{deploymentId:_,sender:P||void 0,studioSessionToken:T,portalId:S,studioId:null===(e=ee.data)||void 0===e?void 0:e.studioid}});s.data.success?Q("success"):"Login required."===s.data.message?(Q("login_required"),J(!0)):"Access denied."===s.data.message?(Q("access_denied"),J(!0)):"Upgrade required."===s.data.message?(Q("upgrade_required"),X(s.data.upgradeGroups||[]),Z(s.data.upgradeUrl),J(!0)):Q("login_required")}catch(e){console.error("Failed to validate deployment:",e),Q("success")}}))}),[_,P,T,S,ee.data]),a.useEffect((()=>{if(!ee.data)return;const e=ee.data.chatflag;D(e?n.v4():""),I(n.v4()),e?U([]):F(null),G(""),H(""),$(null),W(null),B(!1),L(ee.data),J(!0)}),[ee.data]),a.useEffect((()=>{G(""),H(""),$(null),U([]),F(null),W(null)}),[v]);const ae=a.useMemo((()=>{const e=null!=A?A:1;if(!y.primary||!y.primary.startsWith("#")||e<0||e>1)return y.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${y.primary}${s}`}),[y.primary,A]);if(!ee.data)return null;return s.jsx("div",Object.assign({className:p.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===w.theme&&"dark",b),style:Object.assign({backgroundColor:se?"transparent":ae,color:y.text},w.font&&"Real Head Pro"!==w.font&&{fontFamily:w.font})},{children:ee.isLoading||!z||"loading"===K?s.jsx("div",Object.assign({className:p.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===k?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s.jsxs("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s.jsx(u.default,{className:"w-[72px] h-[72px]"}),s.jsx(u.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(u.default,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s.jsx("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s.jsx(u.default,{className:p.default("w-full min-h-[48px]","viewport"===k?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===K?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:V&&V.length>0?s.jsxs("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[s.jsxs("div",Object.assign({className:"text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),s.jsx("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:V.map(((e,t)=>s.jsx(h.default,{data:e,upgradeUrl:Y},e.id||t)))}))]})):s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===K&&C||O&&R&&te?s.jsx(f.default,{}):"login_required"!==K||C?"access_denied"===K?s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Contact tool owner to request access."}))]}))})):v?s.jsx(d.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(d.ScrollProvider,{children:s.jsx(m.default,{})}):s.jsx("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s.jsxs("div",Object.assign({className:"text-center mb-8"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}))};
@@ -1 +1 @@
1
- const t=(t,e="",o="")=>{let r="";for(let e=0;e<t;e++){r+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return e+r+o},e=(t,e=!1)=>{let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";e&&(o=o.replace(/[0-9]/g,""));let r="";for(let e=0;e<t;e++)r+=o.charAt(Math.floor(Math.random()*o.length));return r},o=t=>{const e=t.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(e))},r=(t,e=2)=>{if(!+t)return"0 Bytes";const o=e<0?0:e,r=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/Math.pow(1024,r)).toFixed(o))} ${["Bytes","KB","MB","PB","EB"][r]}`},n=t=>{try{const e=document.cookie.split("; ");for(const o of e){const[e,r]=o.split("=");if(e===t)return r}return null}catch(t){return console.error("[pxe] failed to get cookie",t),null}},l=t=>{document.cookie=t+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"},a=t=>{try{if("undefined"==typeof window)return null;let e=null;return e=new URLSearchParams(window.location.search).get("pxtoken"),e||(e=localStorage.getItem(`PXE-token-${t}`)),e||(e=n(`PXE-token-${t}`)),e?decodeURIComponent(e):null}catch(t){return null}},c=(t,e)=>{try{if("undefined"==typeof window)return;localStorage.setItem(t,e)}catch(t){console.error("[pxe] failed to set auth token",t)}},u=t=>{try{if("undefined"==typeof window)return;localStorage.removeItem(t)}catch(t){console.error("[pxe] failed to delete auth token",t)}};function f(...t){return e=>{for(const o of t)o&&("function"==typeof o?o(e):o.current=e)}}const i=()=>{if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch(t){return!0}},d=t=>{try{return JSON.parse(t)}catch(t){return null}};export{u as deleteAuthToken,l as deleteCookie,o as extractUrlsFromText,r as formatBytes,t as generateId,a as getAuthToken,n as getCookie,i as isInIframe,f as mergeRefs,e as randomStr,d as safeJSONParse,c as setAuthToken};
1
+ const t=(t,e="",o="")=>{let r="";for(let e=0;e<t;e++){r+="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"[Math.floor(36*Math.random())]}return e+r+o},e=(t,e=!1)=>{let o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890";e&&(o=o.replace(/[0-9]/g,""));let r="";for(let e=0;e<t;e++)r+=o.charAt(Math.floor(Math.random()*o.length));return r},o=t=>{const e=t.match(/(https?:\/\/[^\s]+)/g)||[];return Array.from(new Set(e))},r=(t,e=2)=>{if(!+t)return"0 Bytes";const o=e<0?0:e,r=Math.floor(Math.log(t)/Math.log(1024));return`${parseFloat((t/Math.pow(1024,r)).toFixed(o))} ${["Bytes","KB","MB","PB","EB"][r]}`},n=t=>{try{const e=document.cookie.split("; ");for(const o of e){const[e,r]=o.split("=");if(e===t)return r}return null}catch(t){return console.error("[pxe] failed to get cookie",t),null}},l=t=>{document.cookie=t+"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;"},c=t=>{try{if("undefined"==typeof window)return null;let e=null;return e=new URLSearchParams(window.location.search).get("pxtoken"),e||(e=localStorage.getItem(`PXE-token-${t}`)),e||(e=n(`PXE-token-${t}`)),e||(e=n(`__Secure-PS-${t}.session-token`)),e?decodeURIComponent(e):null}catch(t){return null}},a=(t,e)=>{try{if("undefined"==typeof window)return;localStorage.setItem(t,e)}catch(t){console.error("[pxe] failed to set auth token",t)}},u=t=>{try{if("undefined"==typeof window)return;localStorage.removeItem(t)}catch(t){console.error("[pxe] failed to delete auth token",t)}};function f(...t){return e=>{for(const o of t)o&&("function"==typeof o?o(e):o.current=e)}}const i=()=>{if("undefined"==typeof window)return!1;try{return window.self!==window.top}catch(t){return!0}},s=t=>{try{return JSON.parse(t)}catch(t){return null}};export{u as deleteAuthToken,l as deleteCookie,o as extractUrlsFromText,r as formatBytes,t as generateId,c as getAuthToken,n as getCookie,i as isInIframe,f as mergeRefs,e as randomStr,s as safeJSONParse,a as setAuthToken};
@@ -1 +1 @@
1
- import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as t,jsxs as s}from"react/jsx-runtime";import{usePickaxe as a}from"../../hooks/pickaxe/usePickaxe.js";import{useState as o,useEffect as i,useMemo as r}from"react";import{usePickaxeContext as l}from"../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as c}from"./Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as n}from"../../hooks/pickaxe/useResponseContext.js";import{useDocumentContext as d}from"./Addons/Document/hooks/useDocumentContext.js";import{useArtifactContext as m}from"./Addons/Artifact/hooks/useArtifactContext.js";import{v4 as p}from"uuid";import{ScrollProvider as u}from"./Addons/Scroll/Provider.js";import f from"./common/PickaxeSkeleton.js";import x from"./Chat/index.js";import h from"./Form/index.js";import g from"./Addons/Auth/index.js";import j from"../../common/cn.js";import b from"../../common/api/pickaxe.js";import v from"./common/AccessGroupCardPreview.js";const w=({pickaxeId:w,className:y})=>{const{sessionId:N,styles:k,colors:O,responsiveBy:A,deploymentType:C,isNewChat:_,isEmailLogin:q,isEmbed:I,opacity:P,deploymentId:S,sender:L,portalId:D,setContextId:E,setPickaxeId:R,setSessionId:T,setPickaxe:U}=l(),{isLoggedOut:F,isSent:G,token:M}=c(),{setMessages:$,setResponse:B,setError:H,setLimitData:W,setIsSwitchedToChat:z}=n(),{setDocumentError:J}=d(),{setCurrentArtifact:K}=m(),[Q,V]=o(!1),[X,Y]=o("loading"),[Z,ee]=o([]),[te,se]=o(null),ae=a(),oe="chat-input"===C&&_&&!G,ie="chat-input"!==C||!G;i((()=>{R(w)}),[w]),i((()=>{if(!S||!ae.data)return;e(void 0,void 0,void 0,(function*(){var e;Y("loading");try{const t=yield b.post("/validate_studio_deployment",{data:{deploymentId:S,sender:L||void 0,studioSessionToken:M,portalId:D,studioId:null===(e=ae.data)||void 0===e?void 0:e.studioid}});t.data.success?Y("success"):"Login required."===t.data.message?(Y("login_required"),V(!0)):"Access denied."===t.data.message?(Y("access_denied"),V(!0)):"Upgrade required."===t.data.message?(Y("upgrade_required"),ee(t.data.upgradeGroups||[]),se(t.data.upgradeUrl),V(!0)):Y("login_required")}catch(e){console.error("Failed to validate deployment:",e),Y("success")}}))}),[S,L,M,D,ae.data]),i((()=>{if(!ae.data)return;const e=ae.data.chatflag;T(e?p():""),E(p()),e?$([]):B(null),H(""),J(""),W(null),K(null),z(!1),U(ae.data),V(!0)}),[ae.data]),i((()=>{H(""),J(""),W(null),$([]),B(null),K(null)}),[N]);const re=r((()=>{const e=null!=P?P:1;if(!O.primary||!O.primary.startsWith("#")||e<0||e>1)return O.primary;const t=Math.round(255*e).toString(16).padStart(2,"0");return`${O.primary}${t}`}),[O.primary,P]);if(!ae.data)return null;return t("div",Object.assign({className:j("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===k.theme&&"dark",y),style:Object.assign({backgroundColor:oe?"transparent":re,color:O.text},k.font&&"Real Head Pro"!==k.font&&{fontFamily:k.font})},{children:ae.isLoading||!Q||"loading"===X?t("div",Object.assign({className:j("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===A?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[t(f,{className:"w-[72px] h-[72px]"}),t(f,{className:"h-[20px] mt-6 w-full"}),t(f,{className:"h-[20px] mt-2 w-full"}),t(f,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),t("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:t(f,{className:j("w-full min-h-[48px]","viewport"===A?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===X?t("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:Z&&Z.length>0?s("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[s("div",Object.assign({className:"text-center"},{children:[t("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),t("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),t("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:Z.map(((e,s)=>t(v,{data:e,upgradeUrl:te},e.id||s)))}))]})):s("div",Object.assign({className:"text-center mb-8"},{children:[t("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),t("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===X&&I||q&&F&&ie?t(g,{}):"login_required"!==X||I?"access_denied"===X?t("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s("div",Object.assign({className:"text-center mb-8"},{children:[t("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),t("p",Object.assign({className:"opacity-80"},{children:"Contact tool owner to request access."}))]}))})):t(u,N?{children:t(x,{})}:{children:t(h,{})}):t("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s("div",Object.assign({className:"text-center mb-8"},{children:[t("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),t("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}))};export{w as Pickaxe};
1
+ import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as t,jsxs as s}from"react/jsx-runtime";import{usePickaxe as a}from"../../hooks/pickaxe/usePickaxe.js";import{useState as o,useEffect as i,useMemo as r}from"react";import{usePickaxeContext as l}from"../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as c}from"./Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as n}from"../../hooks/pickaxe/useResponseContext.js";import{useDocumentContext as d}from"./Addons/Document/hooks/useDocumentContext.js";import{useArtifactContext as m}from"./Addons/Artifact/hooks/useArtifactContext.js";import{v4 as p}from"uuid";import{ScrollProvider as u}from"./Addons/Scroll/Provider.js";import f from"./common/PickaxeSkeleton.js";import x from"./Chat/index.js";import h from"./Form/index.js";import g from"./Addons/Auth/index.js";import j from"../../common/cn.js";import b from"../../common/api/pickaxe.js";import v from"./common/AccessGroupCardPreview.js";const w=({pickaxeId:w,className:y})=>{const{sessionId:N,styles:k,colors:O,responsiveBy:A,deploymentType:C,isNewChat:_,isEmailLogin:q,isEmbed:I,opacity:P,deploymentId:S,sender:L,portalId:D,setContextId:E,setPickaxeId:R,setSessionId:T,setPickaxe:U}=l(),{isLoggedOut:F,isSent:G,token:M}=c(),{setMessages:$,setResponse:B,setError:H,setLimitData:W,setIsSwitchedToChat:z}=n(),{setDocumentError:J}=d(),{setCurrentArtifact:K}=m(),[Q,V]=o(!1),[X,Y]=o("loading"),[Z,ee]=o([]),[te,se]=o(null),ae=a(),oe="chat-input"===C&&_&&!G,ie="chat-input"!==C||!G;i((()=>{R(w)}),[w]),i((()=>{if(!S&&!D||!ae.data)return;e(void 0,void 0,void 0,(function*(){var e;Y("loading");try{const t=yield b.post("/validate_studio_deployment",{data:{deploymentId:S,sender:L||void 0,studioSessionToken:M,portalId:D,studioId:null===(e=ae.data)||void 0===e?void 0:e.studioid}});t.data.success?Y("success"):"Login required."===t.data.message?(Y("login_required"),V(!0)):"Access denied."===t.data.message?(Y("access_denied"),V(!0)):"Upgrade required."===t.data.message?(Y("upgrade_required"),ee(t.data.upgradeGroups||[]),se(t.data.upgradeUrl),V(!0)):Y("login_required")}catch(e){console.error("Failed to validate deployment:",e),Y("success")}}))}),[S,L,M,D,ae.data]),i((()=>{if(!ae.data)return;const e=ae.data.chatflag;T(e?p():""),E(p()),e?$([]):B(null),H(""),J(""),W(null),K(null),z(!1),U(ae.data),V(!0)}),[ae.data]),i((()=>{H(""),J(""),W(null),$([]),B(null),K(null)}),[N]);const re=r((()=>{const e=null!=P?P:1;if(!O.primary||!O.primary.startsWith("#")||e<0||e>1)return O.primary;const t=Math.round(255*e).toString(16).padStart(2,"0");return`${O.primary}${t}`}),[O.primary,P]);if(!ae.data)return null;return t("div",Object.assign({className:j("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===k.theme&&"dark",y),style:Object.assign({backgroundColor:oe?"transparent":re,color:O.text},k.font&&"Real Head Pro"!==k.font&&{fontFamily:k.font})},{children:ae.isLoading||!Q||"loading"===X?t("div",Object.assign({className:j("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===A?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:s("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[t(f,{className:"w-[72px] h-[72px]"}),t(f,{className:"h-[20px] mt-6 w-full"}),t(f,{className:"h-[20px] mt-2 w-full"}),t(f,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),t("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:t(f,{className:j("w-full min-h-[48px]","viewport"===A?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===X?t("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:Z&&Z.length>0?s("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[s("div",Object.assign({className:"text-center"},{children:[t("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),t("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),t("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:Z.map(((e,s)=>t(v,{data:e,upgradeUrl:te},e.id||s)))}))]})):s("div",Object.assign({className:"text-center mb-8"},{children:[t("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),t("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===X&&I||q&&F&&ie?t(g,{}):"login_required"!==X||I?"access_denied"===X?t("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s("div",Object.assign({className:"text-center mb-8"},{children:[t("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),t("p",Object.assign({className:"opacity-80"},{children:"Contact tool owner to request access."}))]}))})):t(u,N?{children:t(x,{})}:{children:t(h,{})}):t("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:s("div",Object.assign({className:"text-center mb-8"},{children:[t("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),t("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}))};export{w as Pickaxe};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pickaxeproject/react",
3
- "version": "5.6.1-beta.1",
3
+ "version": "5.6.1-beta.3",
4
4
  "description": "Client utility library for Pickaxe",
5
5
  "repository": {
6
6
  "type": "git",