@pickaxeproject/react 6.8.10 → 6.9.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/documents.js +1 -1
- package/dist/cjs/common/error.js +1 -1
- package/dist/cjs/common/validation.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
- package/dist/cjs/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/cjs/components/Pickaxe/index.js +1 -1
- package/dist/cjs/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
- package/dist/cjs/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
- package/dist/cjs/src/components/Pickaxe/Provider.d.ts +1 -0
- package/dist/cjs/src/components/Pickaxe/ResponseProvider.d.ts +1 -0
- package/dist/cjs/src/types/response.d.ts +1 -0
- package/dist/esm/common/documents.js +1 -1
- package/dist/esm/common/error.js +1 -1
- package/dist/esm/common/validation.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Document/hooks/useDocument.js +1 -1
- package/dist/esm/components/Pickaxe/Chat/Input.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/common/PickaxeUpgradeCard.js +1 -1
- package/dist/esm/components/Pickaxe/index.js +1 -1
- package/dist/esm/node_modules/.pnpm/cose-base@1.0.3/node_modules/cose-base/cose-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/cose-base@2.2.0/node_modules/cose-base/cose-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/layout-base@1.0.2/node_modules/layout-base/layout-base.js +1 -1
- package/dist/esm/node_modules/.pnpm/layout-base@2.0.1/node_modules/layout-base/layout-base.js +1 -1
- package/dist/esm/src/components/Pickaxe/Provider.d.ts +1 -0
- package/dist/esm/src/components/Pickaxe/ResponseProvider.d.ts +1 -0
- package/dist/esm/src/types/response.d.ts +1 -0
- package/package.json +213 -211
- /package/dist/cjs/node_modules/.pnpm/{@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1 → @stripe_react-stripe-js@4.0_36b9ff7edcdb64a55c314003f3454117}/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js +0 -0
- /package/dist/esm/node_modules/.pnpm/{@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1 → @stripe_react-stripe-js@4.0_36b9ff7edcdb64a55c314003f3454117}/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.additionalAllowedFileExtensions=[".md"],exports.allowedFileMimeTypes=["application/pdf","text/plain","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/markdown","application/xml","text/xml","audio/mpeg","video/mp4","video/quicktime","video/x-quicktime","video/avi","video/x-msvideo","video/x-matroska"],exports.allowedImageMimeTypes=["image/png","image/jpeg","image/webp","image/gif"];
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.additionalAllowedFileExtensions=[".md",".html",".htm"],exports.allowedFileMimeTypes=["application/pdf","text/plain","application/vnd.openxmlformats-officedocument.wordprocessingml.document","text/csv","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/json","application/vnd.openxmlformats-officedocument.presentationml.presentation","text/markdown","text/html","application/xml","text/xml","audio/mpeg","video/mp4","video/quicktime","video/x-quicktime","video/avi","video/x-msvideo","video/x-matroska"],exports.allowedImageMimeTypes=["image/png","image/jpeg","image/webp","image/gif"];
|
package/dist/cjs/common/error.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.default=(e,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});exports.default=(e,s=!1)=>{var r,o,t;if(!e)return e;s||console.error(e);let a="[ERROR] Something wrong occured";if(e.response){if(a=null===(r=e.response.data)||void 0===r?void 0:r.message,!a){const s=null===(o=e.response.data)||void 0===o?void 0:o.error;a="string"==typeof s?s:null==s?void 0:s.message}}else a=e.request?null===(t=e.request.data)||void 0===t?void 0:t.message:e.raw?e.raw.message:e.message;return a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const e={"login required":"login_required","upgrade required":"upgrade_required","access denied":"access_denied"},r=r=>{var u;if("string"!=typeof r)return null;const s=r.trim().toLowerCase().replace(/[.!]+$/g,"");return null!==(u=e[s])&&void 0!==u?u:null},u=(e,r)=>{const u=(s=e)&&"object"==typeof s?s:null;var s;return u&&r?Object.assign(Object.assign({},u),{hideUpgradeOptions:!0}):u};exports.getValidationFailure=e=>{var s;if("string"==typeof e){const u=r(e);return u?{status:u,accessGroup:null,upgradeGroups:[],upgradeUrl:null}:null}if(!e||"object"!=typeof e)return null;const t=e,n=null!==(s=r(t.message))&&void 0!==s?s:r(t.error);return n?{status:n,accessGroup:u(t.accessGroup,t.hideUpgradeOptions),upgradeGroups:Array.isArray(t.upgradeGroups)?t.upgradeGroups:[],upgradeUrl:"string"==typeof t.upgradeUrl?t.upgradeUrl:null}:null};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("./useAuthContext.js"),s=require("../../../../../common/utils.js"),r=require("../../../../../common/api/pickaxe.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),i=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),t=require("./useAuthContext.js"),s=require("../../../../../common/utils.js"),r=require("../../../../../common/api/pickaxe.js"),o=require("../../../../../common/error.js");exports.useAuth=()=>{const{deploymentId:n,isEmbed:d,pickaxe:a,translations:u,setValidationStatus:l}=i.usePickaxeContext(),{emailInput:c,redirectUrl:m,isSending:p,setIsSending:f,setIsSent:h,setIsResendDisabled:k,setIsPricingAuth:v}=t.useAuthContext();return{onSend:i=>e.__awaiter(void 0,void 0,void 0,(function*(){try{if(!a)return;if(p)return;const e=c.trim().toLowerCase();if(!e)throw new Error((null==u?void 0:u["email-address-cannot-be-empty"])||"Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error((null==u?void 0:u["please-enter-valid-email-address"])||"Please enter a valid email address.");if(!a.studioid)throw new Error(`Studio ID is missing for ${a.formid}. Please contact support.`);f(!0),i&&k(!0);const t=(yield r.pickaxeApi2.post("/auth/email",Object.assign(Object.assign({pickaxeId:a.formid,studioId:a.studioid,email:e},n&&{deploymentId:n}),{redirectUrl:m}))).data;if(!t.success)throw new Error(t.error||(null==u?void 0:u["failed-to-send-sign-in-link"])||"Failed to send sign-in link.");f(!1),h(!0),i&&(yield new Promise((e=>setTimeout(e,3e4))),k(!1)),s.setAuthToken(`PXE-token-${a.studioid}`,t.token),v(!0)}catch(e){const i=o.default(e);if(d&&"You must be invited to use this tool"===i)return void l("access_denied");alert(i)}finally{f(!1)}}))}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../Auth/hooks/useAuthContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),o=require("./useDocumentContext.js"),n=require("../../../../../common/documents.js"),r=require("uuid"),d=require("../../../../../common/error.js");exports.useDocument=({onQuestionChange:u}={})=>{var a,l;const{contextId:c,pickaxeId:p,sessionId:m,sender:f,senderType:w,pickaxe:v,translations:b}=t.usePickaxeContext(),{token:I}=s.useAuthContext(),h=o.useDocumentContext(),g=i.useSubmitDocument(),y=null!==(l=null===(a=null==v?void 0:v.documentuploadtype)||void 0===a?void 0:a.startsWith("enduserupload"))&&void 0!==l&&l,k=(null==b?void 0:b["file-upload-disabled"])||"File uploads are disabled for this Pickaxe.",D=e=>{const t=[...n.allowedFileMimeTypes,...n.allowedImageMimeTypes],s=e.some((e=>{var s;if(t.includes(e.type))return!1;if(""===e.type){const t=null===(s=e.name.split(".").pop())||void 0===s?void 0:s.toLowerCase();if(t&&n.additionalAllowedFileExtensions.includes(`.${t}`))return!1}return!0}));if(s){const e=(null==b?void 0:b["invalid-upload-file-types"])||"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, XML, PNG, JPEG, WEBP, or GIF files. Please try again.",t=new Error(e),s=d.default(t);return h.setDocumentError(s),!0}return!1};return Object.assign(Object.assign({},h),{onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(h.setDocumentError(""),!t.length)return null;if(!y)return h.setDocumentError(k),null;if(D(t))return null;h.setIsUploading(!0),h.setIsShowList(!0);const s=t.map((e=>({file:e,id:r.v4()})));s.forEach((({file:e,id:t})=>{h.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,folder:o,error:r}=yield g.document(Object.assign(Object.assign(Object.assign({contextId:c,pickaxeId:p,sessionId:m,file:t},(null==v?void 0:v.workspaceid)&&{workspaceId:v.workspaceid}),"STUDIO_USER"===w&&{studioUserId:f}),I&&{studioSessionToken:I}));if(!e)throw new Error(r||(null==b?void 0:b["document-processing-failed"])||"Document processing failed");null==u||u({input:t.name,documentId:i});const d=i.startsWith("IMAGE-")||n.allowedImageMimeTypes.includes(t.type);return h.editDocument(Object.assign({id:s,type:d?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i},d&&o&&{folder:o})),{name:t.name,documentId:i}}catch(e){const i=d.default(e);return h.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}}))));yield Promise.allSettled(i),h.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){h.setDocumentError("");let e=t.trim();if(!e)return null;if(!y)return h.setDocumentError(k),null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error((null==b?void 0:b["invalid-website-or-youtube-link"])||"Please paste a valid website URL or Youtube video link to add to the knowledge base.");h.setIsUploading(!0),h.setIsShowList(!0),h.setWebsiteLink(""),h.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield g.website(Object.assign(Object.assign(Object.assign({pickaxeId:p,sessionId:m,website:e},(null==v?void 0:v.workspaceid)&&{workspaceId:v.workspaceid}),"STUDIO_USER"===w&&{studioUserId:f}),I&&{studioSessionToken:I})),{success:s,documentId:i}=t;if(!s)throw new Error((null==b?void 0:b["website-processing-failed"])||"Website processing failed, please try again.");h.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=d.default(t);if(s.includes((null==b?void 0:b["invalid-website-url"])||"Please paste a valid website URL"))return h.setDocumentError(s),null;h.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{h.setIsUploading(!1)}}))})};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../../../_virtual/_tslib.js"),t=require("../../../../../hooks/pickaxe/usePickaxeContext.js"),s=require("../../Auth/hooks/useAuthContext.js"),i=require("../../../../../hooks/pickaxe/useSubmitDocument.js"),o=require("./useDocumentContext.js"),n=require("../../../../../common/documents.js"),r=require("uuid"),d=require("../../../../../common/error.js");exports.useDocument=({onQuestionChange:u}={})=>{var a,l;const{contextId:c,pickaxeId:p,sessionId:m,sender:f,senderType:w,pickaxe:v,translations:b}=t.usePickaxeContext(),{token:I}=s.useAuthContext(),h=o.useDocumentContext(),g=i.useSubmitDocument(),y=null!==(l=null===(a=null==v?void 0:v.documentuploadtype)||void 0===a?void 0:a.startsWith("enduserupload"))&&void 0!==l&&l,k=(null==b?void 0:b["file-upload-disabled"])||"File uploads are disabled for this Pickaxe.",D=e=>{const t=[...n.allowedFileMimeTypes,...n.allowedImageMimeTypes],s=e.some((e=>{var s;if(t.includes(e.type))return!1;if(""===e.type){const t=null===(s=e.name.split(".").pop())||void 0===s?void 0:s.toLowerCase();if(t&&n.additionalAllowedFileExtensions.includes(`.${t}`))return!1}return!0}));if(s){const e=(null==b?void 0:b["invalid-upload-file-types"])||"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, or GIF files. Please try again.",t=new Error(e),s=d.default(t);return h.setDocumentError(s),!0}return!1};return Object.assign(Object.assign({},h),{onFileUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){if(h.setDocumentError(""),!t.length)return null;if(!y)return h.setDocumentError(k),null;if(D(t))return null;h.setIsUploading(!0),h.setIsShowList(!0);const s=t.map((e=>({file:e,id:r.v4()})));s.forEach((({file:e,id:t})=>{h.addDocument({type:"document",id:t,size:e.size,name:e.name,status:"uploading"})}));const i=s.map((({file:t,id:s})=>e.__awaiter(void 0,void 0,void 0,(function*(){try{const{success:e,documentId:i,folder:o,error:r}=yield g.document(Object.assign(Object.assign(Object.assign({contextId:c,pickaxeId:p,sessionId:m,file:t},(null==v?void 0:v.workspaceid)&&{workspaceId:v.workspaceid}),"STUDIO_USER"===w&&{studioUserId:f}),I&&{studioSessionToken:I}));if(!e)throw new Error(r||(null==b?void 0:b["document-processing-failed"])||"Document processing failed");null==u||u({input:t.name,documentId:i});const d=i.startsWith("IMAGE-")||n.allowedImageMimeTypes.includes(t.type);return h.editDocument(Object.assign({id:s,type:d?"image":"document",name:t.name,size:t.size,status:"finished",documentId:i},d&&o&&{folder:o})),{name:t.name,documentId:i}}catch(e){const i=d.default(e);return h.editDocument({id:s,name:t.name,size:t.size,status:"failed",error:i}),{error:i}}}))));yield Promise.allSettled(i),h.setIsUploading(!1)})),onWebsiteUpload:t=>e.__awaiter(void 0,void 0,void 0,(function*(){h.setDocumentError("");let e=t.trim();if(!e)return null;if(!y)return h.setDocumentError(k),null;e.startsWith("http://")&&(e=e.replace("http://","https://")),e.startsWith("https://")||(e=`https://${e}`);try{if(!e.includes("."))throw new Error((null==b?void 0:b["invalid-website-or-youtube-link"])||"Please paste a valid website URL or Youtube video link to add to the knowledge base.");h.setIsUploading(!0),h.setIsShowList(!0),h.setWebsiteLink(""),h.setDocuments([{type:"website",id:e,size:0,name:e,status:"uploading"}]);const t=yield g.website(Object.assign(Object.assign(Object.assign({pickaxeId:p,sessionId:m,website:e},(null==v?void 0:v.workspaceid)&&{workspaceId:v.workspaceid}),"STUDIO_USER"===w&&{studioUserId:f}),I&&{studioSessionToken:I})),{success:s,documentId:i}=t;if(!s)throw new Error((null==b?void 0:b["website-processing-failed"])||"Website processing failed, please try again.");h.setDocuments([{type:"website",id:e,size:0,name:e,status:"finished",documentId:i}]);return{type:"website",id:e,name:e,size:0,status:"finished",documentId:i}}catch(t){const s=d.default(t);if(s.includes((null==b?void 0:b["invalid-website-url"])||"Please paste a valid website URL"))return h.setDocumentError(s),null;h.editDocument({type:"website",id:e,size:0,name:e,status:"failed",error:s});return{type:"website",id:e,size:0,name:e,status:"failed",error:s}}finally{h.setIsUploading(!1)}}))})};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../hooks/studio/useStyleInput.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),c=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),f=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),h=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),I=require("../../Icons/microphone.svg.js"),y=require("../../Icons/stop.svg.js"),x=require("../Addons/Document/List.js"),j=require("../../Core/Textarea.js"),S=require("../../Core/ErrorAlert.js"),O=require("../../../common/error.js"),w=require("../../../common/api/pickaxe.js"),N=require("../../../common/validation.js"),_=require("../../../common/cn.js"),k=require("../../../common/utils.js"),E=require("../../../common/pickaxeConfig.js"),C=require("../../../common/deploymentWebhooks.js"),U=require("../../../hooks/studio/useStudio.js"),T=require("../../../hooks/pickaxe/useSpeech.js"),A=require("../common/PickaxeCommon.js");const D=e=>"string"==typeof e&&e.trim().length>0,P=e=>e.map((e=>Object.assign({},e))),L=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),R=(e,t)=>{if(e&&"object"==typeof e)return e[t]},M=(e,t)=>{const s=R(e,t);return D(s)?s:null},q=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},F=({studioUser:e,deploymentId:t,portalId:s})=>{var n,i;const r=Array.isArray(R(e,"uses"))?R(e,"uses"):[],o=(({deploymentId:e,portalId:t})=>D(e)?{type:"deployment",id:e}:D(t)?{type:"portal",id:t}:null)({deploymentId:t,portalId:s});if(!o)return{scope:o,record:null};const a=null!==(i=null!==(n=r.find((e=>e.id===o.id&&e.type===o.type)))&&void 0!==n?n:r.find((e=>e.id===o.id)))&&void 0!==i?i:null;return{scope:o,record:a}},V=s.forwardRef((({resubmitPrompt:R,onFocus:V,onBlur:$,onInputHeightChange:B,initSmitheryAuthData:X},H)=>{var K,W,Y,z,G,J,Q,Z,ee,te,se,ne;const{origin:ie,pickaxeId:re,sessionId:oe,sender:ae,senderType:le,portalId:de,deploymentId:ce,deploymentType:ue,pickaxe:pe,styles:me,colors:fe,translations:ge,locale:ve,forceMobile:he,isNewChat:be,isRtl:Ie,isShowFeedbackMessage:ye,accessGroup:xe,setIsNewChat:je,setIsShowIceBreaker:Se,setValidationStatus:Oe,setValidationUpgradeGroups:we,setValidationUpgradeUrl:Ne,setAccessGroup:_e,onGenerateComplete:ke}=n.usePickaxeContext(),{token:Ee,isLoggedOut:Ce,isSent:Ue,isPricingAuth:Te}=d.useAuthContext(),{messages:Ae,isGenerating:De,setMessages:Pe,setStatus:Le,setLimitData:Re,setError:Me}=i.useResponseContext(),{documents:qe,isUploading:Fe,documentError:Ve,onFileUpload:$e,setDocuments:Be,setDocumentError:Xe}=c.useDocument(),{studio:He}=U.useStudio(),{scrollStartSession:Ke,scrollEndSession:We,scrollToBottom:Ye}=u.useScroll({auto:!0}),{artifacts:ze,currentPopupType:Ge,setArtifacts:Je,setCurrentArtifact:Qe}=p.useArtifactContext(),{height:Ze}=l.useDimensionContext(),et=a.useConversation(),[tt,st]=s.useState(""),[nt,it]=s.useState(!1),[rt,ot]=s.useState(!1),[at,lt]=s.useState(null),[dt,ct]=s.useState(null),[ut,pt]=s.useState(!1),[mt,ft]=s.useState(!1),[gt,vt]=s.useState(0),ht=s.useRef(null),bt=s.useRef(""),It=s.useRef(null),yt=s.useRef(null),xt=s.useRef(null),jt=s.useRef([]),St=s.useRef(null),Ot=s.useRef(null),wt=s.useRef(null),Nt=s.useRef(null),_t=s.useRef(new Set),kt=s.useRef(null),Et=Math.max(.4*Ze,100),{speechTranscript:Ct,isSpeechListening:Ut,isSpeechProcessing:Tt,isSpeechSupported:At,onStartListening:Dt,onStopListening:Pt}=T.useSpeech(),[Lt]=f.useMediaQuery("(max-width: 480px)"),Rt=m.useHover(),{isHover:Mt}=Rt,qt=e.__rest(Rt,["isHover"]),Ft=m.useHover(),{isHover:Vt}=Ft,$t=e.__rest(Ft,["isHover"]),Bt=m.useHover(),{isHover:Xt}=Bt,Ht=e.__rest(Bt,["isHover"]),Kt=o.useStyleFontSize(),Wt=r.useStyleInput(),Yt="undefined"!=typeof window?window.location.hostname:"",zt="undefined"!=typeof window?window.location.href:"",Gt="undefined"!=typeof window&&window.self!==window.top,Jt=Yt.includes("pickaxe.co")&&!zt.includes("https://studio.pickaxe.co/_embed")&&!Gt,Qt=null!==(W=null===(K=null==pe?void 0:pe.documentuploadtype)||void 0===K?void 0:K.startsWith("enduserupload"))&&void 0!==W&&W,Zt=At&&(null==pe?void 0:pe.enablevoicetotext),es=D(ce),ts="chat-input"===ue&&be&&!Ue,ss="chat-input"===ue&&Te&&Ce&&Ue,ns=s.useCallback((e=>{const t=N.getValidationFailure(e);return!!t&&(Me(""),Re(null),Oe(t.status),_e(t.accessGroup),we(t.upgradeGroups),Ne(t.upgradeUrl),!0)}),[Me,Re,Oe,we,Ne,_e]),is=null!==(Y=null==pe?void 0:pe.placeholdertext)&&void 0!==Y?Y:Ie?"بماذا تريد أن تتحدث؟":(null==ge?void 0:ge["what-do-you-want-to-talk-about"])||"What do you want to talk about?",rs=nt||rt,os=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){pt(!1);try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({studioId:null==pe?void 0:pe.studioid},Ee?{studioSessionToken:Ee}:ae?{sender:ae}:{sender:k.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),Jt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(lt(t.studioUser),ct(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{pt(!0)}}))),[Jt,null==pe?void 0:pe.studioid,ae,Ee]);s.useEffect((()=>{os()}),[os]);const as=Number(null!==(z=null==xe?void 0:xe.limit)&&void 0!==z?z:0),ls="string"==typeof(null==xe?void 0:xe.limitInterval)?xe.limitInterval:null,ds=!!(null==He?void 0:He.data.usage)&&He.data.usage.isCredits,cs=s.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=de?de:M(at,"portalId"))&&void 0!==e?e:M(at,"portalid"))&&void 0!==t?t:M(xe,"portalId"))&&void 0!==s?s:M(xe,"portalid"))&&void 0!==n?n:M(pe,"portalId"))&&void 0!==i?i:M(pe,"portalid")}),[xe,de,pe,at]),us=s.useMemo((()=>F({studioUser:at,deploymentId:ce,portalId:cs})),[ce,cs,at]);s.useEffect((()=>{es&&be&&oe&&_t.current.add(oe)}),[be,oe,es]);const ps=s.useCallback((()=>{var e,t,s;return{studioId:null==pe?void 0:pe.studioid,userEmail:M(at,"email"),userId:null!==(e=M(at,"userId"))&&void 0!==e?e:M(at,"userid"),sessionId:oe,deploymentId:ce,deploymentType:ue,portalId:cs,accessGroupId:null!==(t=null==xe?void 0:xe.accessGroupId)&&void 0!==t?t:null,pickaxeId:re,sender:ae,senderType:le,origin:ie,metadata:null!==(s=E.getPickaxeConfigMetadata(ce))&&void 0!==s?s:null}}),[null==xe?void 0:xe.accessGroupId,ce,ue,ie,null==pe?void 0:pe.studioid,re,cs,ae,le,oe,at]),ms=s.useCallback((()=>!!(es&&ut&&oe)&&(!!_t.current.has(oe)&&(C.fireDeploymentSessionInitializedWebhook(ps()),_t.current.delete(oe),!0))),[ps,ut,oe,es]);s.useEffect((()=>{if(!ut||!oe)return;ms();const e=kt.current;(null==e?void 0:e.sessionId)===oe&&(C.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),ps()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),kt.current=null)}),[ms,ps,ut,oe]);const fs={currentUses:q(null==at?void 0:at.currentUses),extraUses:q(null==at?void 0:at.extraUses)},gs=us.scope?{currentUses:null!==(J=q(null===(G=us.record)||void 0===G?void 0:G.currentUses))&&void 0!==J?J:0,extraUses:null!==(Z=q(null===(Q=us.record)||void 0===Q?void 0:Q.extraUses))&&void 0!==Z?Z:0}:{currentUses:0,extraUses:0},vs=M(at,"type"),hs="guest"===vs||!vs&&Ce?gs:fs;s.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(ds&&(null===(e=null==He?void 0:He.data)||void 0===e?void 0:e.workspaceId))try{const e=yield w.pickaxeApi2.get(`/cost_per_run?workspaceId=${He.data.workspaceId}`,{withCredentials:!1});t&&vt(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&vt(0)}else t&&vt(0)})),()=>{t=!1}}),[ds,null===(ee=null==He?void 0:He.data)||void 0===ee?void 0:ee.workspaceId]);const bs=(({currentUses:e,extraUses:t,limit:s,limitInterval:n})=>{const i=Number(null!=e?e:0),r=Number(null!=t?t:0);return s===A.STUDIO_INFINITY_VALUE||r===A.STUDIO_INFINITY_VALUE?A.STUDIO_INFINITY_VALUE:"one_time"===n?Math.max(0,r-i):Math.max(0,s-i)+r})({currentUses:hs.currentUses,extraUses:hs.extraUses,limit:as,limitInterval:ls}),Is=bs===A.STUDIO_INFINITY_VALUE?A.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(bs)),ys=(({extraUses:e,limit:t,limitInterval:s})=>{const n=Number(null!=e?e:0);return t===A.STUDIO_INFINITY_VALUE||n===A.STUDIO_INFINITY_VALUE?A.STUDIO_INFINITY_VALUE:"one_time"===s?Math.max(0,n):Math.max(0,t)+Math.max(0,n)})({extraUses:hs.extraUses,limit:as,limitInterval:ls}),xs=ys===A.STUDIO_INFINITY_VALUE?A.STUDIO_INFINITY_VALUE:Math.ceil(.05*ys),js=ds?Math.ceil(5*gt):5,Ss=xs===A.STUDIO_INFINITY_VALUE?A.STUDIO_INFINITY_VALUE:Math.max(xs,js),Os=s.useMemo((()=>!!at&&(!mt&&(Is!==A.STUDIO_INFINITY_VALUE&&(!(Is<=0)&&Is<=Ss)))),[mt,Ss,Is,at]),ws=(null===(te=null==xe?void 0:xe.upgrade)||void 0===te?void 0:te.isLinkToCustomURL)&&"string"==typeof xe.upgrade.limitLink&&xe.upgrade.limitLink.trim().length>0?xe.upgrade.limitLink.trim():null,Ns=ws&&"string"==typeof(null===(se=null==xe?void 0:xe.upgrade)||void 0===se?void 0:se.limitCTA)&&xe.upgrade.limitCTA.trim().length>0?xe.upgrade.limitCTA:(null==ge?void 0:ge["pricing.upgrade"])||(null==ge?void 0:ge.upgrade)||"Upgrade",_s=s.useMemo((()=>{var e,t,s;return!!be&&(!!pe&&(!et.isLoading&&(!((null!==(t=null===(e=et.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=pe.icebreakers)||void 0===s?void 0:s.length)&&(!ye&&!ts)))))}),[pe,be,ye,ts,et.data,et.isLoading]),ks=s.useMemo((()=>{if(De||Fe)return!1;const e=Qt&&qe.length>0&&qe.every((e=>"finished"===e.status));return!(!tt.trim()&&!e)&&qe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Qt,De,Fe,tt,qe]);s.useImperativeHandle(H,(()=>({onSubmit:Es}))),s.useEffect((()=>{Se(_s)}),[_s]),s.useEffect((()=>{var e;if(R){const t=Array.from(Ae),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Es(s,!0)}}),[R]),s.useEffect((()=>{if(!wt.current||!B)return;const e=new ResizeObserver((e=>{for(const t of e)B(t.contentRect.height)}));return e.observe(wt.current),()=>{e.disconnect()}}),[B]),s.useEffect((()=>{if(!Ut)return;const e=bt.current?`${bt.current} `:"";st(`${e}${Ct}`)}),[Ct,Ut]),s.useEffect((()=>{if(!St.current)return;(()=>{if(!St.current)return;let e=St.current.scrollHeight>52;tt.includes("\n")||qe.length?e=!0:tt.trim()||(e=!1),it(e)})()}),[tt,qe]),s.useEffect((()=>{const e=St.current,t=Ot.current;if(!e||!t||nt||tt.includes("\n"))return void ot(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=tt||is,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;ot(r>l)}),[tt,nt,is]);const Es=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i,r;let o=null;try{if(De||Fe)return;const a=qe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),l=a.map((e=>e.documentId)).filter(Boolean),d=a.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),c=null!=t?t:tt,u=null!==(n=null===(e=null==pe?void 0:pe.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&l.length>0;if(!c&&!u)return;Me(""),Xe(""),Re(null),st(""),je(!1),Le("fetching"),Ke(),Ye();const p=[...s?Array.from(Ae.slice(0,Ae.length-1)):Array.from(Ae),...s?[]:[{id:Ae.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:u?l:[]}],{id:Ae.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];Pe(p),Ye(),u&&Be([]);const m=E.getPickaxeConfigMetadata(ce),f="undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`;o=f,yt.current=f,xt.current=null,jt.current=[];const g=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:ie,pickaxeId:re,sessionId:oe,submissionId:f,senderType:le,value:c},u&&{documentIds:l}),ae&&{sender:ae}),Ee&&{studioSessionToken:Ee}),!Ee&&!ae&&{sender:k.initializeEmbedUserId()}),cs&&{portalId:cs}),ce&&{deploymentId:ce}),m&&{metadata:m}),u&&d.length>0?{uploadedModelImages:d}:{})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},Jt&&{credentials:"include"})),h=yield g.json();if(!h.success){if(h.limitData){const e=new Error(h.error||h.message||(null==ge?void 0:ge["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=h.limitData,e}if(ns(h))return;throw new Error(h.error||h.message||(null==ge?void 0:ge["failed-to-start-generation"])||"Failed to start generation")}const b=null!==(i=h.submissionId)&&void 0!==i?i:f;o=b,yt.current=b;const I=()=>xt.current===b;if(I())return;es&&be&&oe&&_t.current.add(oe);const y=Object.assign(Object.assign({},ps()),{message:c,documentIds:u?l:[],uploadedModelImages:u?d:[],hasUploadedDocuments:u,isHidden:s,metadata:null!=m?m:null});ut?(ms(),C.fireDeploymentFirstMessageSubmittedWebhook(y)):kt.current=y,Le("streaming"),Nt.current=new AbortController;const x=p.length-1,j=[];let S=[...null!=ze?ze:[]],O=0,w=!1,N="";for(;!w;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${b}?index=${O}`,{signal:null===(r=Nt.current)||void 0===r?void 0:r.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();It.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(I())w=!0;else if(e.event&&"ping"!==e.event&&O++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Re(t.limitData),Me(""),void(w=!0);const s=t.error||t.message||(null==ge?void 0:ge["something-went-wrong"])||"Something went wrong.";return ns(t)||Me(s),void(w=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&X){const e=n.data.error;if("string"==typeof e){const t=/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e),s=/['"]type['"]\s*:\s*['"]unauthorized_composio['"]/.test(e);if(t){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw w=!0,X({provider:"smithery",smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}else if(s){const t=e.match(/['"]toolkitSlug['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw w=!0,X({provider:"composio",toolkitSlug:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw w=!0,X({provider:"smithery",smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM");if("unauthorized_composio"===t.type&&t.toolkitSlug&&t.serverId&&t.name)throw w=!0,X({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)N="",j.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)N+=n.delta,j[j.length-1].content=N;else if("text-end"===n.type)N="";else if("reasoning-start"===n.type)N="",j.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)N+=n.delta,j[j.length-1].content=N;else if("reasoning-end"===n.type)N="";else if(n.type.startsWith("data-")){const e=n;j.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}jt.current=P(j),Pe([...p.slice(0,x),Object.assign(Object.assign({},p[p.length-1]),{id:Ae.length+1,role:"assistant",parts:j})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);S=S.filter((e=>!(e.id===t.id&&e.version===t.version))),S.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Je([...S]),Ge.startsWith("inline")||Qe({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);S=S.filter((e=>!(e.id===t.id&&e.version===t.version))),S.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Je(S),Ge.startsWith("inline")||Qe({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);S=S.filter((e=>!(e.id===t.id&&e.version===t.version))),S.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Je(S),Ge.startsWith("inline")||Qe({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");S=S.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Je(S)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Je(S.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Re(t.limitData),Me(""),void(w=!0);const s=t.error||t.message||(null==ge?void 0:ge["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(ns(t))return void(w=!0);Me(s)}else"stop"===e.event&&(w=!0)}else w=!0}});for(;;){if(I()){w=!0,t.cancel().catch((()=>{}));break}const{value:e,done:i}=yield t.read();if(I()){w=!0,t.cancel().catch((()=>{}));break}if(i)break;n.feed(s.decode(e))}w||I()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||L(e)||I())return void(w=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==ke||ke(oe)}catch(e){if(L(e))return;if(e.limitData)Re(e.limitData),Me("");else{let t=O.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==ge?void 0:ge["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),ns(t)||Me(t)}}finally{const e=!o||yt.current===o;Ye(),e&&(Le("idle"),We(),It.current=null),o&&e&&(yt.current=null,jt.current=[]),yield os()}}));return ss?null:t.jsx("div",Object.assign({className:_.default("flex w-full flex-shrink-0 flex-col items-center",!ts&&"px-4 pb-8"),dir:Ie?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:wt,className:_.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===me.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Wt),{maxHeight:`${Et}px`,overflowY:"auto"})},{children:[Os&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:Wt.backgroundColor?`${Wt.backgroundColor}E6`:void 0,borderColor:fe.text+"20",color:fe.text,borderTopRightRadius:me.cornerRadius+"px",borderTopLeftRadius:me.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[Is.toLocaleString()," ",ds?(null==ge?void 0:ge.credits)||"Credits":(null==ge?void 0:ge.uses)||"Uses"," ",(null==ge?void 0:ge.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:fe.accent,color:fe.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),ws)return void window.open(ws,"_blank","noopener,noreferrer");const t=k.buildUpgradeUrl({baseUrl:dt,accessGroupId:null==xe?void 0:xe.accessGroupId,redirectUrl:document.URL});t&&(k.isInIframe()?window.open(t):location.href=t)}},{children:Ns})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>ft(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!De&&qe.length>0&&t.jsx(x.default,{className:"p-4 pb-0",isDisabled:De}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Ut&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(ne=fe.accent)&&void 0!==ne?ne:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:fe.text+"90"}},{children:(null==ge?void 0:ge.listening)||"Listening..."}))]})),t.jsx(j.default,Object.assign({ref:St,className:_.default(Kt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!tt.trim()&&!tt.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Ie?"text-right":"text-left",rs&&"mb-12",Ut&&"text-transparent"),value:tt,placeholder:is,onChange:e=>{st(e)},onKeyDown:e=>{he||Lt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Fe||De||Es()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!Qt)return;t.preventDefault(),je(!1),yield $e(e)}}))},V&&{onFocus:V},$&&{onBlur:$},{dir:Ie?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Ot,className:_.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",rs?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!rs&&Wt.backgroundColor&&{backgroundColor:Wt.backgroundColor}),{borderTopRightRadius:me.cornerRadius+"px",borderBottomRightRadius:me.cornerRadius+"px"})},{children:De?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{const t=yt.current;t&&(xt.current=t,(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:yt.current))return;const e=P(jt.current);try{yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/cancel/${t}`,Object.assign({method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()}),body:JSON.stringify({outputMessageParts:e})},Jt&&{credentials:"include"}))}catch(e){console.warn("Failed to cancel submission",e)}}))})(t)),Nt.current&&(Nt.current.abort(),Nt.current=null),It.current&&(It.current.cancel().catch((()=>{})),It.current=null),Le("idle")},style:{backgroundColor:fe.accent,color:fe.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):Ut?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:Pt,style:{backgroundColor:fe.accent,color:fe.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Qt&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Vt?fe.accent+"10":void 0,color:Vt?fe.accent:fe.accent+"80"},disabled:Fe||De,onClick:()=>{var e;return null===(e=ht.current)||void 0===e?void 0:e.click()}},$t,{children:[t.jsx("input",{id:"file-upload",ref:ht,type:"file",accept:[...g.allowedFileMimeTypes,...g.allowedImageMimeTypes,...g.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){je(!1),yield $e(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(h.default,{className:"h-6 w-6 shrink-0"})]})),Zt&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Ut?fe.accent:Xt?fe.accent+"10":void 0,color:Ut?fe.accentText:Xt?fe.accent:fe.accent+"80"},disabled:Fe||De||Tt,onClick:()=>{Ut?Pt():(bt.current=tt,Dt(ve||"en-US"))}},Ht,{children:t.jsx(I.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Mt||ks?fe.accent:fe.accent+"10",color:Mt||ks?fe.accentText:fe.accent+"80"},disabled:!ks,onClick:()=>Es()},qt,{children:t.jsx(b.default,{className:_.default("h-6 w-6 shrink-0",Ie&&"scale-x-[-1] transform")})}))]})}))]}))]})),Ve&&t.jsx(S.default,{error:Ve,className:"mt-3"})]}))}))}));V.displayName="Input",exports.default=V;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),s=require("react"),n=require("../../../hooks/pickaxe/usePickaxeContext.js"),i=require("../../../hooks/pickaxe/useResponseContext.js"),r=require("../../../hooks/studio/useStyleInput.js"),o=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../hooks/pickaxe/useConversation.js"),l=require("../../../hooks/pickaxe/useDimensionContext.js"),d=require("../Addons/Auth/hooks/useAuthContext.js"),c=require("../Addons/Document/hooks/useDocument.js"),u=require("../Addons/Scroll/hooks/useScroll.js"),p=require("../Addons/Artifact/hooks/useArtifactContext.js"),m=require("../../../hooks/core/useHover.js"),f=require("../../../hooks/core/useMediaQuery.js"),g=require("../../../common/documents.js"),v=require("eventsource-parser"),h=require("../../Icons/attach-vertical.svg.js"),b=require("../../Icons/arrow-right.svg.js"),I=require("../../Icons/microphone.svg.js"),y=require("../../Icons/stop.svg.js"),x=require("../Addons/Document/List.js"),j=require("../../Core/Textarea.js"),S=require("../../Core/ErrorAlert.js"),O=require("../../../common/error.js"),w=require("../../../common/api/pickaxe.js"),N=require("../../../common/validation.js"),_=require("../../../common/cn.js"),k=require("../../../common/utils.js"),E=require("../../../common/pickaxeConfig.js"),U=require("../../../common/deploymentWebhooks.js"),C=require("../../../hooks/studio/useStudio.js"),T=require("../../../hooks/pickaxe/useSpeech.js"),A=require("../common/PickaxeCommon.js");const D=e=>"string"==typeof e&&e.trim().length>0,P=e=>e.map((e=>Object.assign({},e))),L=e=>e instanceof Error&&("AbortError"===e.name||"BodyStreamBuffer was aborted"===e.message),R=(e,t)=>{if(e&&"object"==typeof e)return e[t]},M=(e,t)=>{const s=R(e,t);return D(s)?s:null},q=e=>{const t=Number(e);return Number.isFinite(t)?t:void 0},F=({studioUser:e,deploymentId:t,portalId:s})=>{var n,i;const r=Array.isArray(R(e,"uses"))?R(e,"uses"):[],o=(({deploymentId:e,portalId:t})=>D(e)?{type:"deployment",id:e}:D(t)?{type:"portal",id:t}:null)({deploymentId:t,portalId:s});if(!o)return{scope:o,record:null};const a=null!==(i=null!==(n=r.find((e=>e.id===o.id&&e.type===o.type)))&&void 0!==n?n:r.find((e=>e.id===o.id)))&&void 0!==i?i:null;return{scope:o,record:a}},V=s.forwardRef((({resubmitPrompt:R,onFocus:V,onBlur:B,onInputHeightChange:$,initSmitheryAuthData:X},H)=>{var K,W,Y,z,G,J,Q,Z,ee,te,se,ne;const{origin:ie,pickaxeId:re,sessionId:oe,sender:ae,senderType:le,portalId:de,deploymentId:ce,deploymentType:ue,pickaxe:pe,styles:me,colors:fe,translations:ge,locale:ve,forceMobile:he,isNewChat:be,isRtl:Ie,isShowFeedbackMessage:ye,accessGroup:xe,setIsNewChat:je,setIsShowIceBreaker:Se,setValidationStatus:Oe,setValidationUpgradeGroups:we,setValidationUpgradeUrl:Ne,setAccessGroup:_e,onGenerateComplete:ke}=n.usePickaxeContext(),{token:Ee,isLoggedOut:Ue,isSent:Ce,isPricingAuth:Te}=d.useAuthContext(),{messages:Ae,isGenerating:De,setMessages:Pe,setStatus:Le,setLimitData:Re,setError:Me}=i.useResponseContext(),{documents:qe,isUploading:Fe,documentError:Ve,onFileUpload:Be,setDocuments:$e,setDocumentError:Xe}=c.useDocument(),{studio:He}=C.useStudio(),{scrollStartSession:Ke,scrollEndSession:We,scrollToBottom:Ye}=u.useScroll({auto:!0}),{artifacts:ze,currentPopupType:Ge,setArtifacts:Je,setCurrentArtifact:Qe}=p.useArtifactContext(),{height:Ze}=l.useDimensionContext(),et=a.useConversation(),[tt,st]=s.useState(""),[nt,it]=s.useState(!1),[rt,ot]=s.useState(!1),[at,lt]=s.useState(null),[dt,ct]=s.useState(null),[ut,pt]=s.useState(!1),[mt,ft]=s.useState(!1),[gt,vt]=s.useState(0),ht=s.useRef(null),bt=s.useRef(""),It=s.useRef(null),yt=s.useRef(null),xt=s.useRef(null),jt=s.useRef([]),St=s.useRef(null),Ot=s.useRef(null),wt=s.useRef(null),Nt=s.useRef(null),_t=s.useRef(new Set),kt=s.useRef(null),Et=Math.max(.4*Ze,100),{speechTranscript:Ut,isSpeechListening:Ct,isSpeechProcessing:Tt,isSpeechSupported:At,onStartListening:Dt,onStopListening:Pt}=T.useSpeech(),[Lt]=f.useMediaQuery("(max-width: 480px)"),Rt=m.useHover(),{isHover:Mt}=Rt,qt=e.__rest(Rt,["isHover"]),Ft=m.useHover(),{isHover:Vt}=Ft,Bt=e.__rest(Ft,["isHover"]),$t=m.useHover(),{isHover:Xt}=$t,Ht=e.__rest($t,["isHover"]),Kt=o.useStyleFontSize(),Wt=r.useStyleInput(),Yt="undefined"!=typeof window?window.location.hostname:"",zt="undefined"!=typeof window?window.location.href:"",Gt="undefined"!=typeof window&&window.self!==window.top,Jt=Yt.includes("pickaxe.co")&&!zt.includes("https://studio.pickaxe.co/_embed")&&!Gt,Qt=null!==(W=null===(K=null==pe?void 0:pe.documentuploadtype)||void 0===K?void 0:K.startsWith("enduserupload"))&&void 0!==W&&W,Zt=At&&(null==pe?void 0:pe.enablevoicetotext),es=D(ce),ts="chat-input"===ue&&be&&!Ce,ss="chat-input"===ue&&Te&&Ue&&Ce,ns=s.useCallback((e=>{const t=N.getValidationFailure(e);return!!t&&(Me(""),Re(null),Oe(t.status),_e(t.accessGroup),we(t.upgradeGroups),Ne(t.upgradeUrl),!0)}),[Me,Re,Oe,we,Ne,_e]),is=null!==(Y=null==pe?void 0:pe.placeholdertext)&&void 0!==Y?Y:Ie?"بماذا تريد أن تتحدث؟":(null==ge?void 0:ge["what-do-you-want-to-talk-about"])||"What do you want to talk about?",rs=nt||rt,os=s.useCallback((()=>e.__awaiter(void 0,void 0,void 0,(function*(){pt(!1);try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/user`,Object.assign(Object.assign({method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Object.assign({studioId:null==pe?void 0:pe.studioid},Ee?{studioSessionToken:Ee}:ae?{sender:ae}:{sender:k.initializeEmbedUserId()}))},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{headers:{"Content-Type":"application/json","x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN}})),Jt&&{credentials:"include"})),t=yield e.json();(null==t?void 0:t.studioUser)&&(lt(t.studioUser),ct(t.url))}catch(e){console.error("Failed to fetch studio user:",e)}finally{pt(!0)}}))),[Jt,null==pe?void 0:pe.studioid,ae,Ee]);s.useEffect((()=>{os()}),[os]);const as=Number(null!==(z=null==xe?void 0:xe.limit)&&void 0!==z?z:0),ls="string"==typeof(null==xe?void 0:xe.limitInterval)?xe.limitInterval:null,ds=!!(null==He?void 0:He.data.usage)&&He.data.usage.isCredits,cs=s.useMemo((()=>{var e,t,s,n,i;return null!==(i=null!==(n=null!==(s=null!==(t=null!==(e=null!=de?de:M(at,"portalId"))&&void 0!==e?e:M(at,"portalid"))&&void 0!==t?t:M(xe,"portalId"))&&void 0!==s?s:M(xe,"portalid"))&&void 0!==n?n:M(pe,"portalId"))&&void 0!==i?i:M(pe,"portalid")}),[xe,de,pe,at]),us=s.useMemo((()=>F({studioUser:at,deploymentId:ce,portalId:cs})),[ce,cs,at]);s.useEffect((()=>{es&&be&&oe&&_t.current.add(oe)}),[be,oe,es]);const ps=s.useCallback((()=>{var e,t,s;return{studioId:null==pe?void 0:pe.studioid,userEmail:M(at,"email"),userId:null!==(e=M(at,"userId"))&&void 0!==e?e:M(at,"userid"),sessionId:oe,deploymentId:ce,deploymentType:ue,portalId:cs,accessGroupId:null!==(t=null==xe?void 0:xe.accessGroupId)&&void 0!==t?t:null,pickaxeId:re,sender:ae,senderType:le,origin:ie,metadata:null!==(s=E.getPickaxeConfigMetadata(ce))&&void 0!==s?s:null}}),[null==xe?void 0:xe.accessGroupId,ce,ue,ie,null==pe?void 0:pe.studioid,re,cs,ae,le,oe,at]),ms=s.useCallback((()=>!!(es&&ut&&oe)&&(!!_t.current.has(oe)&&(U.fireDeploymentSessionInitializedWebhook(ps()),_t.current.delete(oe),!0))),[ps,ut,oe,es]);s.useEffect((()=>{if(!ut||!oe)return;ms();const e=kt.current;(null==e?void 0:e.sessionId)===oe&&(U.fireDeploymentFirstMessageSubmittedWebhook(Object.assign(Object.assign(Object.assign({},e),ps()),{message:e.message,documentIds:e.documentIds,uploadedModelImages:e.uploadedModelImages,hasUploadedDocuments:e.hasUploadedDocuments,isHidden:e.isHidden})),kt.current=null)}),[ms,ps,ut,oe]);const fs={currentUses:q(null==at?void 0:at.currentUses),extraUses:q(null==at?void 0:at.extraUses)},gs=us.scope?{currentUses:null!==(J=q(null===(G=us.record)||void 0===G?void 0:G.currentUses))&&void 0!==J?J:0,extraUses:null!==(Z=q(null===(Q=us.record)||void 0===Q?void 0:Q.extraUses))&&void 0!==Z?Z:0}:{currentUses:0,extraUses:0},vs=M(at,"type"),hs="guest"===vs||!vs&&Ue?gs:fs;s.useEffect((()=>{let t=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){var e;if(ds&&(null===(e=null==He?void 0:He.data)||void 0===e?void 0:e.workspaceId))try{const e=yield w.pickaxeApi2.get(`/cost_per_run?workspaceId=${He.data.workspaceId}`,{withCredentials:!1});t&&vt(1e4*(Number(e.data.costPerRun)||0))}catch(e){console.error("Failed to fetch average cost per run:",e),t&&vt(0)}else t&&vt(0)})),()=>{t=!1}}),[ds,null===(ee=null==He?void 0:He.data)||void 0===ee?void 0:ee.workspaceId]);const bs=(({currentUses:e,extraUses:t,limit:s,limitInterval:n})=>{const i=Number(null!=e?e:0),r=Number(null!=t?t:0);return s===A.STUDIO_INFINITY_VALUE||r===A.STUDIO_INFINITY_VALUE?A.STUDIO_INFINITY_VALUE:"one_time"===n?Math.max(0,r-i):Math.max(0,s-i)+r})({currentUses:hs.currentUses,extraUses:hs.extraUses,limit:as,limitInterval:ls}),Is=bs===A.STUDIO_INFINITY_VALUE?A.STUDIO_INFINITY_VALUE:Math.max(0,Math.ceil(bs)),ys=(({extraUses:e,limit:t,limitInterval:s})=>{const n=Number(null!=e?e:0);return t===A.STUDIO_INFINITY_VALUE||n===A.STUDIO_INFINITY_VALUE?A.STUDIO_INFINITY_VALUE:"one_time"===s?Math.max(0,n):Math.max(0,t)+Math.max(0,n)})({extraUses:hs.extraUses,limit:as,limitInterval:ls}),xs=ys===A.STUDIO_INFINITY_VALUE?A.STUDIO_INFINITY_VALUE:Math.ceil(.05*ys),js=ds?Math.ceil(5*gt):5,Ss=xs===A.STUDIO_INFINITY_VALUE?A.STUDIO_INFINITY_VALUE:Math.max(xs,js),Os=s.useMemo((()=>!!at&&(!mt&&(Is!==A.STUDIO_INFINITY_VALUE&&(!(Is<=0)&&Is<=Ss)))),[mt,Ss,Is,at]),ws=Boolean(null==xe?void 0:xe.hideUpgradeOptions),Ns=!ws&&(null===(te=null==xe?void 0:xe.upgrade)||void 0===te?void 0:te.isLinkToCustomURL)&&"string"==typeof xe.upgrade.limitLink&&xe.upgrade.limitLink.trim().length>0?xe.upgrade.limitLink.trim():null,_s=Ns&&"string"==typeof(null===(se=null==xe?void 0:xe.upgrade)||void 0===se?void 0:se.limitCTA)&&xe.upgrade.limitCTA.trim().length>0?xe.upgrade.limitCTA:(null==ge?void 0:ge["pricing.upgrade"])||(null==ge?void 0:ge.upgrade)||"Upgrade",ks=s.useMemo((()=>{var e,t,s;return!!be&&(!!pe&&(!et.isLoading&&(!((null!==(t=null===(e=et.data)||void 0===e?void 0:e.messages.length)&&void 0!==t?t:0)>1)&&(!!(null===(s=pe.icebreakers)||void 0===s?void 0:s.length)&&(!ye&&!ts)))))}),[pe,be,ye,ts,et.data,et.isLoading]),Es=s.useMemo((()=>{if(De||Fe)return!1;const e=Qt&&qe.length>0&&qe.every((e=>"finished"===e.status));return!(!tt.trim()&&!e)&&qe.every((e=>"finished"===e.status||e.isInsertedAsRaw))}),[Qt,De,Fe,tt,qe]);s.useImperativeHandle(H,(()=>({onSubmit:Us}))),s.useEffect((()=>{Se(ks)}),[ks]),s.useEffect((()=>{var e;if(R){const t=Array.from(Ae),s=null===(e=t[t.length-2].parts.find((e=>"text"===e.type)))||void 0===e?void 0:e.content;Us(s,!0)}}),[R]),s.useEffect((()=>{if(!wt.current||!$)return;const e=new ResizeObserver((e=>{for(const t of e)$(t.contentRect.height)}));return e.observe(wt.current),()=>{e.disconnect()}}),[$]),s.useEffect((()=>{if(!Ct)return;const e=bt.current?`${bt.current} `:"";st(`${e}${Ut}`)}),[Ut,Ct]),s.useEffect((()=>{if(!St.current)return;(()=>{if(!St.current)return;let e=St.current.scrollHeight>52;tt.includes("\n")||qe.length?e=!0:tt.trim()||(e=!1),it(e)})()}),[tt,qe]),s.useEffect((()=>{const e=St.current,t=Ot.current;if(!e||!t||nt||tt.includes("\n"))return void ot(!1);const s=window.getComputedStyle(e),n=`${s.fontStyle} ${s.fontVariant} ${s.fontWeight} ${s.fontSize} / ${s.lineHeight} ${s.fontFamily}`,i=document.createElement("span");Object.assign(i.style,{font:n,letterSpacing:s.letterSpacing,position:"absolute",visibility:"hidden",whiteSpace:"nowrap",top:"0",left:"0"}),i.textContent=tt||is,document.body.appendChild(i);const r=i.offsetWidth;i.remove();const o=parseFloat(s.paddingLeft)||0,a=parseFloat(s.paddingRight)||0,l=e.clientWidth-o-a-t.offsetWidth;ot(r>l)}),[tt,nt,is]);const Us=(t,s=!1)=>e.__awaiter(void 0,void 0,void 0,(function*(){var e,n,i,r;let o=null;try{if(De||Fe)return;const a=qe.filter((e=>"finished"===e.status&&!e.isInsertedAsRaw)),l=a.map((e=>e.documentId)).filter(Boolean),d=a.filter((e=>"image"===e.type)).map((e=>{const t=e.name.split(".").pop()||"";return{documentId:e.documentId,extension:t}})),c=null!=t?t:tt,u=null!==(n=null===(e=null==pe?void 0:pe.documentuploadtype)||void 0===e?void 0:e.startsWith("enduserupload"))&&void 0!==n&&n&&l.length>0;if(!c&&!u)return;Me(""),Xe(""),Re(null),st(""),je(!1),Le("fetching"),Ke(),Ye();const p=[...s?Array.from(Ae.slice(0,Ae.length-1)):Array.from(Ae),...s?[]:[{id:Ae.length+1,role:"user",parts:[{type:"text",content:c,isVisible:!0}],documentIds:u?l:[]}],{id:Ae.length+(s?0:2),role:"assistant",parts:[],documentIds:[]}];Pe(p),Ye(),u&&$e([]);const m=E.getPickaxeConfigMetadata(ce),f="undefined"!=typeof crypto&&"randomUUID"in crypto?crypto.randomUUID():`submission-${Date.now()}-${Math.random().toString(36).slice(2)}`;o=f,yt.current=f,xt.current=null,jt.current=[];const g=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/submit`,Object.assign({method:"POST",body:JSON.stringify(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({origin:ie,pickaxeId:re,sessionId:oe,submissionId:f,senderType:le,value:c},u&&{documentIds:l}),ae&&{sender:ae}),Ee&&{studioSessionToken:Ee}),!Ee&&!ae&&{sender:k.initializeEmbedUserId()}),cs&&{portalId:cs}),ce&&{deploymentId:ce}),m&&{metadata:m}),u&&d.length>0?{uploadedModelImages:d}:{})),headers:Object.assign(Object.assign({},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()})},Jt&&{credentials:"include"})),h=yield g.json();if(!h.success){if(h.limitData){const e=new Error(h.error||h.message||(null==ge?void 0:ge["failed-to-start-generation"])||"Failed to start generation");throw e.limitData=h.limitData,e}if(ns(h))return;throw new Error(h.error||h.message||(null==ge?void 0:ge["failed-to-start-generation"])||"Failed to start generation")}const b=null!==(i=h.submissionId)&&void 0!==i?i:f;o=b,yt.current=b;const I=()=>xt.current===b;if(I())return;es&&be&&oe&&_t.current.add(oe);const y=Object.assign(Object.assign({},ps()),{message:c,documentIds:u?l:[],uploadedModelImages:u?d:[],hasUploadedDocuments:u,isHidden:s,metadata:null!=m?m:null});ut?(ms(),U.fireDeploymentFirstMessageSubmittedWebhook(y)):kt.current=y,Le("streaming"),Nt.current=new AbortController;const x=p.length-1,j=[];let S=[...null!=ze?ze:[]],O=0,w=!1,N="";for(;!w;)try{const e=yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/stream/${b}?index=${O}`,{signal:null===(r=Nt.current)||void 0===r?void 0:r.signal,headers:{"Cache-Control":"no-cache",Connection:"keep-alive"}});if(!e.body)throw new Error("No response body");const t=e.body.getReader();It.current=t;const s=new TextDecoder,n=v.createParser({onEvent:e=>{var t,s;if(I())w=!0;else if(e.event&&"ping"!==e.event&&O++,"stop"!==e.event){if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Re(t.limitData),Me(""),void(w=!0);const s=t.error||t.message||(null==ge?void 0:ge["something-went-wrong"])||"Something went wrong.";return ns(t)||Me(s),void(w=!0)}if("delta"===e.event){const n=JSON.parse(e.data);if("data-error"===n.type&&X){const e=n.data.error;if("string"==typeof e){const t=/['"]type['"]\s*:\s*['"]unauthorized_smithery['"]/.test(e),s=/['"]type['"]\s*:\s*['"]unauthorized_composio['"]/.test(e);if(t){const t=e.match(/['"]qualifiedName['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw w=!0,X({provider:"smithery",smitheryId:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}else if(s){const t=e.match(/['"]toolkitSlug['"]\s*:\s*['"]([^'"]+)['"]/),s=e.match(/['"]serverId['"]\s*:\s*['"]([^'"]+)['"]/),n=e.match(/['"]name['"]\s*:\s*['"]([^'"]+)['"]/);if(t&&t[1]&&s&&s[1]&&n&&n[1])throw w=!0,X({provider:"composio",toolkitSlug:t[1],serverId:s[1],name:n[1]}),new Error("STOP_STREAM")}}else if("object"==typeof e&&null!==e){const t=e;if("unauthorized_smithery"===t.type&&t.qualifiedName&&t.serverId&&t.name)throw w=!0,X({provider:"smithery",smitheryId:t.qualifiedName,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM");if("unauthorized_composio"===t.type&&t.toolkitSlug&&t.serverId&&t.name)throw w=!0,X({provider:"composio",toolkitSlug:t.toolkitSlug,serverId:t.serverId,name:t.name}),new Error("STOP_STREAM")}}else if("text-start"===n.type)N="",j.push({type:"text",content:"",isVisible:null===(t=n.isVisible)||void 0===t||t});else if("text-delta"===n.type)N+=n.delta,j[j.length-1].content=N;else if("text-end"===n.type)N="";else if("reasoning-start"===n.type)N="",j.push({type:"reasoning",content:"",isVisible:null===(s=n.isVisible)||void 0===s||s});else if("reasoning-delta"===n.type)N+=n.delta,j[j.length-1].content=N;else if("reasoning-end"===n.type)N="";else if(n.type.startsWith("data-")){const e=n;j.push({type:e.type,content:JSON.stringify(e.data),isVisible:!0})}jt.current=P(j),Pe([...p.slice(0,x),Object.assign(Object.assign({},p[p.length-1]),{id:Ae.length+1,role:"assistant",parts:j})])}else if("artifact_created"===e.event){const t=JSON.parse(e.data);S=S.filter((e=>!(e.id===t.id&&e.version===t.version))),S.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Je([...S]),Ge.startsWith("inline")||Qe({id:t.id,version:t.version})}else if("artifact_updated"===e.event){const t=JSON.parse(e.data);S=S.filter((e=>!(e.id===t.id&&e.version===t.version))),S.push(Object.assign(Object.assign({},t),{content:"",status:"updating"})),Je(S),Ge.startsWith("inline")||Qe({id:t.id,version:t.version})}else if("artifact_rewrite"===e.event){const t=JSON.parse(e.data);S=S.filter((e=>!(e.id===t.id&&e.version===t.version))),S.push(Object.assign(Object.assign({},t),{content:"",status:"streaming"})),Je(S),Ge.startsWith("inline")||Qe({id:t.id,version:t.version})}else if("artifact_content"===e.event){const t=JSON.parse(e.data),s=t.token.replace(/\u200B/g,"");S=S.map((e=>e.id===t.id&&e.version===t.version?Object.assign(Object.assign({},e),{content:e.content+s,status:"streaming"}):e)),Je(S)}else if("artifact_finished"===e.event){const t=JSON.parse(e.data);Je(S.map((e=>e.id===t.id?Object.assign(Object.assign({},e),{status:"finished"}):e)))}else if("error"===e.event){const t=JSON.parse(e.data);if(t.limitData)return Re(t.limitData),Me(""),void(w=!0);const s=t.error||t.message||(null==ge?void 0:ge["something-went-wrong-try-again"])||"Something went wrong, please try again.";if(ns(t))return void(w=!0);Me(s)}else"stop"===e.event&&(w=!0)}else w=!0}});for(;;){if(I()){w=!0,t.cancel().catch((()=>{}));break}const{value:e,done:i}=yield t.read();if(I()){w=!0,t.cancel().catch((()=>{}));break}if(i)break;n.feed(s.decode(e))}w||I()||(yield new Promise((e=>setTimeout(e,1e3))))}catch(e){if("STOP_STREAM"===e.message||L(e)||I())return void(w=!0);console.warn("Stream connection lost, retrying...",e),yield new Promise((e=>setTimeout(e,1e3)))}null==ke||ke(oe)}catch(e){if(L(e))return;if(e.limitData)Re(e.limitData),Me("");else{let t=O.default(e)||"";t&&!t.includes("Unexpected token 'A',")||(t=(null==ge?void 0:ge["high-traffic-try-again-later"])||"Oops! We're experiencing high traffic at the moment. Please try again later."),ns(t)||Me(t)}}finally{const e=!o||yt.current===o;Ye(),e&&(Le("idle"),We(),It.current=null),o&&e&&(yt.current=null,jt.current=[]),yield os()}}));return ss?null:t.jsx("div",Object.assign({className:_.default("flex w-full flex-shrink-0 flex-col items-center",!ts&&"px-4 pb-8"),dir:Ie?"rtl":"ltr"},{children:t.jsxs("div",Object.assign({className:"flex w-full max-w-[800px] flex-col"},{children:[t.jsxs("div",Object.assign({ref:wt,className:_.default("relative flex flex-col w-full justify-end gap-y-3 py-[3px]","block"===me.formFieldStyle&&"shadow"),style:Object.assign(Object.assign({},Wt),{maxHeight:`${Et}px`,overflowY:"auto"})},{children:[Os&&t.jsxs("div",Object.assign({className:"sticky top-0 z-10 flex w-full items-center justify-between border-b px-4 py-2.5 shadow-sm backdrop-blur-md",style:{backgroundColor:Wt.backgroundColor?`${Wt.backgroundColor}E6`:void 0,borderColor:fe.text+"20",color:fe.text,borderTopRightRadius:me.cornerRadius+"px",borderTopLeftRadius:me.cornerRadius+"px"}},{children:[t.jsx("div",Object.assign({className:"flex items-center gap-2 text-sm font-medium"},{children:t.jsxs("span",{children:[Is.toLocaleString()," ",ds?(null==ge?void 0:ge.credits)||"Credits":(null==ge?void 0:ge.uses)||"Uses"," ",(null==ge?void 0:ge.remaining)||"remaining"]})})),t.jsxs("div",Object.assign({className:"flex items-center gap-3"},{children:[!ws&&t.jsx("button",Object.assign({className:"rounded-md px-3 py-1.5 text-xs font-semibold transition-opacity hover:opacity-90",style:{backgroundColor:fe.accent,color:fe.accentText},onClick:e=>{if(e.preventDefault(),e.stopPropagation(),Ns)return void window.open(Ns,"_blank","noopener,noreferrer");const t=k.buildUpgradeUrl({baseUrl:dt,accessGroupId:null==xe?void 0:xe.accessGroupId,redirectUrl:document.URL});t&&(k.isInIframe()?window.open(t):location.href=t)}},{children:_s})),t.jsx("button",Object.assign({className:"flex h-6 w-6 items-center justify-center rounded-full opacity-60 transition-opacity hover:opacity-100",onClick:()=>ft(!0)},{children:t.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:2,stroke:"currentColor",className:"h-4 w-4"},{children:t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M6 18L18 6M6 6l12 12"})}))}))]}))]})),!De&&qe.length>0&&t.jsx(x.default,{className:"p-4 pb-0",isDisabled:De}),t.jsxs("div",Object.assign({className:"relative flex w-full flex-col"},{children:[Ct&&t.jsxs("div",Object.assign({className:"absolute left-4 top-1/2 flex -translate-y-1/2 select-none items-center gap-x-2"},{children:[t.jsx("span",{className:"h-2 w-2 animate-pulse rounded-full bg-c-secondary",style:{backgroundColor:null!==(ne=fe.accent)&&void 0!==ne?ne:"#ff0000"}}),t.jsx("span",Object.assign({className:"text-sm text-c-secondary font-semilight",style:{color:fe.text+"90"}},{children:(null==ge?void 0:ge.listening)||"Listening..."}))]})),t.jsx(j.default,Object.assign({ref:St,className:_.default(Kt.i1,"py-3.5 max-h-60 px-4 w-full border-transparent bg-transparent",!tt.trim()&&!tt.includes("\n")&&"overflow-hidden text-ellipsis whitespace-nowrap placeholder:whitespace-normal placeholder:overflow-visible",Ie?"text-right":"text-left",rs&&"mb-12",Ct&&"text-transparent"),value:tt,placeholder:is,onChange:e=>{st(e)},onKeyDown:e=>{he||Lt||"Enter"===e.key&&(e.shiftKey||(e.preventDefault(),Fe||De||Us()))},onPaste:t=>e.__awaiter(void 0,void 0,void 0,(function*(){const e=Array.from(t.clipboardData.files||[]);if(e.length>0){if(!Qt)return;t.preventDefault(),je(!1),yield Be(e)}}))},V&&{onFocus:V},B&&{onBlur:B},{dir:Ie?"rtl":"ltr"})),t.jsx("div",Object.assign({ref:Ot,className:_.default("flex items-center gap-2 absolute right-0 z-2 transition-all duration-200 ease-in-out",rs?"bottom-0 mb-2.5":"top-1/2 -translate-y-1/2"),style:Object.assign(Object.assign({},!rs&&Wt.backgroundColor&&{backgroundColor:Wt.backgroundColor}),{borderTopRightRadius:me.cornerRadius+"px",borderBottomRightRadius:me.cornerRadius+"px"})},{children:De?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:()=>{const t=yt.current;t&&(xt.current=t,(t=>{e.__awaiter(void 0,void 0,void 0,(function*(){if(!(t=null!=t?t:yt.current))return;const e=P(jt.current);try{yield fetch(`${process.env.NEXT_PUBLIC_PICKAXE_API2_URL}/response/cancel/${t}`,Object.assign({method:"POST",headers:Object.assign(Object.assign({"Content-Type":"application/json"},(!process.env.NODE_ENV||"development"===process.env.NODE_ENV)&&Object.assign({},process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN&&{"x-pickaxe-session-token":process.env.NEXT_PUBLIC_PICKAXE_SESSION_TOKEN})),{"x-request-sent-at":(new Date).toISOString()}),body:JSON.stringify({outputMessageParts:e})},Jt&&{credentials:"include"}))}catch(e){console.warn("Failed to cancel submission",e)}}))})(t)),Nt.current&&(Nt.current.abort(),Nt.current=null),It.current&&(It.current.cancel().catch((()=>{})),It.current=null),Le("idle")},style:{backgroundColor:fe.accent,color:fe.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):Ct?t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",onClick:Pt,style:{backgroundColor:fe.accent,color:fe.accentText}},{children:t.jsx(y.default,{className:"h-4 w-4 shrink-0"})})):t.jsxs(t.Fragment,{children:[Qt&&t.jsxs("button",Object.assign({className:"flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Vt?fe.accent+"10":void 0,color:Vt?fe.accent:fe.accent+"80"},disabled:Fe||De,onClick:()=>{var e;return null===(e=ht.current)||void 0===e?void 0:e.click()}},Bt,{children:[t.jsx("input",{id:"file-upload",ref:ht,type:"file",accept:[...g.allowedFileMimeTypes,...g.allowedImageMimeTypes,...g.additionalAllowedFileExtensions].join(", "),multiple:!0,hidden:!0,className:"hidden",onChange:t=>e.__awaiter(void 0,void 0,void 0,(function*(){je(!1),yield Be(Array.from(t.target.files||[])),t.target.value=""}))}),t.jsx(h.default,{className:"h-6 w-6 shrink-0"})]})),Zt&&t.jsx("button",Object.assign({className:"disabled:cursor-default flex h-8 w-8 items-center justify-center rounded-full outline-none transition-colors duration-200 ease-in-out",style:{backgroundColor:Ct?fe.accent:Xt?fe.accent+"10":void 0,color:Ct?fe.accentText:Xt?fe.accent:fe.accent+"80"},disabled:Fe||De||Tt,onClick:()=>{Ct?Pt():(bt.current=tt,Dt(ve||"en-US"))}},Ht,{children:t.jsx(I.default,{className:"h-5 w-5 shrink-0"})})),t.jsx("button",Object.assign({className:"flex h-8 w-8 items-center mr-2 justify-center rounded-full outline-none transition-colors duration-200 ease-in-out disabled:cursor-default",style:{backgroundColor:Mt||Es?fe.accent:fe.accent+"10",color:Mt||Es?fe.accentText:fe.accent+"80"},disabled:!Es,onClick:()=>Us()},qt,{children:t.jsx(b.default,{className:_.default("h-6 w-6 shrink-0",Ie&&"scale-x-[-1] transform")})}))]})}))]}))]})),Ve&&t.jsx(S.default,{error:Ve,className:"mt-3"})]}))}))}));V.displayName="Input",exports.default=V;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),o=require("./Addons/Artifact/Provider.js"),a=require("./DimensionProvider.js"),s=require("./ResponseProvider.js"),n=require("./Addons/Document/Provider.js"),r=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:p,senderType:f,deploymentId:h,portalId:g,deploymentType:m,deploymentDimensions:y,deploymentMisc:b,styles:w,colors:v,limits:S={},misc:k={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:x={popupType:"auto"},responsiveBy:C="viewport",locale:F="en",opacity:I=1,forceMobile:j=!1,disableHtml:q=!1,disableJs:T=!1,disableCss:D=!1,loadFont:O=!0,isRtl:A=!1,isEmbed:U=!1,isDropShadow:E=!1,allowGuestUsage:R=!0,preventInitialSessionId:L=!1,onGenerateComplete:M,onSessionIdChange:G})=>{const[H,W]=i.useState(""),[_,B]=i.useState(""),[N,X]=i.useState(""),[V,Y]=i.useState(""),[z,J]=i.useState(p),[K,Q]=i.useState(null),[Z,$]=i.useState(f),[ee,te]=i.useState("loading"),[ie,oe]=i.useState([]),[ae,se]=i.useState(null),[ne,re]=i.useState(null),[le,de]=i.useState(null),[ce,ue]=i.useState(null),[pe,fe]=i.useState(!1),[he,ge]=i.useState(!0),[me,ye]=i.useState(!0),[be,we]=i.useState(!1);return i.useEffect((()=>{fe(!1)}),[null==w?void 0:w.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&O&&!pe&&(null==w?void 0:w.font)&&"Real Head Pro"!==w.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[w.font]},active:()=>{fe(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),fe(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),fe(!0)}}))}),[O,pe,null==w?void 0:w.font]),i.useEffect((()=>{J(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign({origin:u,contextId:H,pickaxeId:_,sessionId:N,lastSessionId:V,sender:z,senderType:Z,portalId:g,deploymentId:h,deploymentType:m,validationStatus:ee,validationUpgradeGroups:ie,validationUpgradeUrl:ae,deploymentDimensions:y,deploymentMisc:b,accessGroup:K,pickaxe:ce,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},w),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},v),misc:k,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",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, XML, PNG, JPEG, WEBP, or GIF files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},P),artifact:x,responsiveBy:C,locale:F,opacity:I,forceMobile:j,loadFont:O,disableHtml:q,disableJs:T,disableCss:D,isFontLoaded:pe,isNewChat:he,isShowIceBreaker:me,isShowFeedbackMessage:be,isRtl:A,isEmbed:U,isDropShadow:E,allowGuestUsage:R,clientSecret:le,stripeAccountId:ne,preventInitialSessionId:L,setClientSecret:de,setStripeAccountId:re,setContextId:W,setValidationStatus:te,setValidationUpgradeGroups:oe,setValidationUpgradeUrl:se,setPickaxeId:B,setSessionId:e=>{X((t=>{const i="function"==typeof e?e(t):e;return null==G||G(i),i}))},setLastSessionId:Y,setSender:J,setSenderType:$,setAccessGroup:Q,setPickaxe:ue,setIsFontLoaded:fe,setIsNewChat:ge,setIsShowIceBreaker:ye,setIsShowFeedbackMessage:we},M&&{onGenerateComplete:M})},{children:t.jsx(r.default,{children:t.jsx(a.default,{children:t.jsx(s.default,Object.assign({limits:S},{children:t.jsx(n.default,{children:t.jsx(o.ArtifactProvider,Object.assign({},x,{children:c}))})}))})})}))};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),t=require("react/jsx-runtime"),i=require("react"),o=require("./Addons/Artifact/Provider.js"),a=require("./DimensionProvider.js"),s=require("./ResponseProvider.js"),n=require("./Addons/Document/Provider.js"),r=require("./Addons/Auth/Provider.js");function l(e){if(e&&e.__esModule)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(i){if("default"!==i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}})),t.default=e,Object.freeze(t)}const d=i.createContext({});exports.PickaxeContext=d,exports.PickaxeProvider=({children:c,origin:u,sender:p,senderType:f,deploymentId:h,portalId:g,deploymentType:m,deploymentDimensions:y,deploymentMisc:b,styles:w,colors:v,limits:S={},misc:k={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:P,artifact:x={popupType:"auto"},responsiveBy:C="viewport",locale:F="en",opacity:I=1,forceMobile:j=!1,disableHtml:q=!1,disableJs:T=!1,disableCss:D=!1,loadFont:O=!0,isRtl:A=!1,isEmbed:U=!1,isDropShadow:E=!1,allowGuestUsage:R=!0,preventInitialSessionId:L=!1,onGenerateComplete:M,onSessionIdChange:G})=>{const[H,W]=i.useState(""),[_,B]=i.useState(""),[N,X]=i.useState(""),[V,Y]=i.useState(""),[z,J]=i.useState(p),[K,Q]=i.useState(null),[Z,$]=i.useState(f),[ee,te]=i.useState("loading"),[ie,oe]=i.useState([]),[ae,se]=i.useState(null),[ne,re]=i.useState(null),[le,de]=i.useState(null),[ce,ue]=i.useState(null),[pe,fe]=i.useState(!1),[he,ge]=i.useState(!0),[me,ye]=i.useState(!0),[be,we]=i.useState(!1);return i.useEffect((()=>{fe(!1)}),[null==w?void 0:w.font]),i.useEffect((()=>{e.__awaiter(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&O&&!pe&&(null==w?void 0:w.font)&&"Real Head Pro"!==w.font)try{(yield Promise.resolve().then((function(){return l(require("webfontloader"))}))).default.load({google:{families:[w.font]},active:()=>{fe(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),fe(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),fe(!0)}}))}),[O,pe,null==w?void 0:w.font]),i.useEffect((()=>{J(p)}),[p]),t.jsx(d.Provider,Object.assign({value:Object.assign({origin:u,contextId:H,pickaxeId:_,sessionId:N,lastSessionId:V,sender:z,senderType:Z,portalId:g,deploymentId:h,deploymentType:m,validationStatus:ee,validationUpgradeGroups:ie,validationUpgradeUrl:ae,deploymentDimensions:y,deploymentMisc:b,accessGroup:K,pickaxe:ce,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},w),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},v),misc:k,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",copy:"Copy","file-limit-reached":"You have reached the file limit.",save:"Save","save-as":"Save as","please-enter-email-to-continue":"Please enter your email to continue:","enter-email-to-continue":"Enter here your email to continue",submit:"Submit",sending:"Sending...","check-your-inbox":"Check your inbox","we-sent-your-an-activation-link":"We sent you an activation link. Please be sure to check your spam folder too.",resend:"Resend",resending:"Resending...","chat-history":"Chat History","exit-chat-history":"Exit Chat History","no-history":"No history yet.","log-out":"Log Out","clear-form":"Clear form","form.clear-form":"Clear form",expand:"Expand","expand-artifact":"Expand artifact",collapse:"Collapse","collapse-artifact":"Collapse artifact",close:"Close","close-artifact":"Close artifact",download:"Download","copy-artifact-content":"Copy artifact content","download-artifact-content":"Download artifact content","delete-confirm":"Are you sure you want to delete this conversation?",other:"Other","select-options":"Select option(s)","select-an-option":"Select an option","type-your-answer":"Type your answer...",cancel:"Cancel","rename-chat":"Rename chat","delete-chat":"Delete chat","conversation-name":"Conversation name","not-available":"n/a","open-chat":"Open Chat",copied:"Copied!","copy-assistant-message":"Copy assistant message","failed-delete-conversation":"Failed to delete conversation.","failed-update-name":"Failed to update name.","failed-rename-chat":"Failed to rename chat.","failed-delete-chat":"Failed to delete chat.","drop-files-to-upload":"Drop files to upload","add-anything-to-the-conversation":"Add anything to the conversation","something-went-wrong-please-try-again":"Something went wrong. Please try again, or","contact-us":"contact us","for-help":"for help.",back:"Back","upgrade-required":"Upgrade Required","please-upgrade-to-continue-using-this-tool":"Please upgrade to continue using this tool.","access-locked":"Access Locked","this-tool-is-locked-contact-owner":"This tool is locked to use. Contact owner for more information.","access-denied":"Access Denied","login-is-required":"Login is required.","no-access-request-access":"It looks like you don't have access to these resources. Please request access to continue.","request-access":"Request Access",or:"or","sign-in-with-different-account":"Sign in with a different account","access-requested-successfully":"Successfully requested access!","open-tool":"Open Tool","fab-icon":"FAB Icon","iframe-artifact-fallback":"Iframe is not supported, please view this artifact in a browser that supports it.","html-preview":"HTML preview","image-link-is-broken":"[Image link is broken]","download-video":"Download Video","available-plans":"Available Plans",buy:"Buy",credits:"Credits",uses:"Uses",credits_upper:"CREDITS",uses_upper:"USES",free:"Free","pricing.free":"Free",unlimited:"Unlimited","pricing.unlimited":"Unlimited","authentication-required":"Authentication Required","smithery-auth-description-prefix":"The tool you are trying to use requires authentication with",dismiss:"Dismiss",connect:"Connect",connecting:"Connecting...","auth-failed":"Auth failed","failed-to-finalize-authentication":"Failed to finalize authentication.","must-be-logged-in-to-connect-smithery":"You must be logged in to connect Smithery MCPs.","feedback-dislike-input-placeholder":"Write here...","feedback-submit":"Submit","feedback-thanks":"Thanks for the feedback!","feedback-like-title":"What went right?","feedback-dislike-title":"What went wrong?","feedback-dislike-message":"Help us improve our answers","what-do-you-want-to-talk-about":"What do you want to talk about?","failed-to-start-generation":"Failed to start generation","response-too-long":"One or more of your responses is too long!","required-fields-missing":"You must fill out all required fields.","something-went-wrong":"Something went wrong.","something-went-wrong-try-again":"Something went wrong, please try again.","high-traffic-try-again-later":"Oops! We're experiencing high traffic at the moment. Please try again later.",listening:"Listening...",remaining:"remaining",upgrade:"Upgrade","pricing.upgrade":"Upgrade","email-address-cannot-be-empty":"Email address cannot be empty.","please-enter-valid-email-address":"Please enter a valid email address.","failed-to-send-sign-in-link":"Failed to send sign-in link.",tool:"Tool","document-processing-failed":"Document processing failed","invalid-upload-file-types":"You can only upload PDF, TXT, DOCX, CSV, XLSX, JSON, PPTX, MD, HTML, XML, PNG, JPEG, WEBP, or GIF files. Please try again.","invalid-website-or-youtube-link":"Please paste a valid website URL or Youtube video link to add to the knowledge base.","website-processing-failed":"Website processing failed, please try again.","invalid-website-url":"Please paste a valid website URL","document-upload-required":"Please paste a valid website/video link or drag a file to add to the knowledge base.",thinking:"Thinking...",thought:"Thought","thought-for":"Thought for",seconds:"seconds","untitled-artifact":"Untitled Artifact",created:"Created",updated:"Updated",rewrote:"Rewrote",artifact:"Artifact","iframe-not-supported-use-different-browser":"Iframe not supported, use a different browser."},P),artifact:x,responsiveBy:C,locale:F,opacity:I,forceMobile:j,loadFont:O,disableHtml:q,disableJs:T,disableCss:D,isFontLoaded:pe,isNewChat:he,isShowIceBreaker:me,isShowFeedbackMessage:be,isRtl:A,isEmbed:U,isDropShadow:E,allowGuestUsage:R,clientSecret:le,stripeAccountId:ne,preventInitialSessionId:L,setClientSecret:de,setStripeAccountId:re,setContextId:W,setValidationStatus:te,setValidationUpgradeGroups:oe,setValidationUpgradeUrl:se,setPickaxeId:B,setSessionId:e=>{X((t=>{const i="function"==typeof e?e(t):e;return null==G||G(i),i}))},setLastSessionId:Y,setSender:J,setSenderType:$,setAccessGroup:Q,setPickaxe:ue,setIsFontLoaded:fe,setIsNewChat:ge,setIsShowIceBreaker:ye,setIsShowFeedbackMessage:we},M&&{onGenerateComplete:M})},{children:t.jsx(r.default,{children:t.jsx(a.default,{children:t.jsx(s.default,Object.assign({limits:S},{children:t.jsx(n.default,{children:t.jsx(o.ArtifactProvider,Object.assign({},x,{children:c}))})}))})})}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),i=require("react"),t=require("framer-motion"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../common/utils.js"),n=require("../../Icons/circle-exclamation.svg.js"),c=require("../../Core/SpringTransition.js"),d=require("../../Core/HtmlRenderer.js"),u=require("./PickaxeButton.js"),p=require("../../../common/cn.js"),x=require("../../../common/api/pickaxe.js"),m=require("../Addons/Auth/hooks/useAuthContext.js"),v=require("./AccessGroupCardPreview.js"),f=require("./HorizontalScrollCue.js"),b=require("../../../hooks/studio/useStudio.js"),g=require("./PickaxeCurrency.js");const j=({price:e,uses:i,isCredits:t,isSelected:r,costPerRun:o,onClick:l,colors:a,currencySymbol:n})=>{const c=`${n}${e}`,d={backgroundColor:a.secondary,color:a.secondaryText,borderColor:r?a.secondaryText:"rgba(0,0,0,0.1)"},u=t&&o?Math.ceil(i/o):0;return t?s.jsxs("button",Object.assign({onClick:l,className:p.default("flex min-w-[200px] shrink-0 cursor-pointer flex-col rounded-[16px] px-6 py-5 text-left transition-all duration-200",r?"border-2 shadow-sm":"border opacity-80 hover:opacity-100"),style:d},{children:[s.jsxs("div",Object.assign({className:"mb-4 flex items-center gap-2"},{children:[s.jsx("span",Object.assign({className:"text-[24px] font-semibold tracking-tight"},{children:c})),s.jsxs("span",Object.assign({className:"text-[14px] font-light opacity-80"},{children:["/",i.toLocaleString()," credits"]}))]})),s.jsx("div",{className:"mb-4 h-[1px] w-full",style:{backgroundColor:a.secondaryText,opacity:.15}}),s.jsxs("span",Object.assign({className:"text-[14px] italic opacity-70"},{children:["~ ",void 0!==u&&u>0?u.toLocaleString():"..."," ","runs"]}))]})):s.jsxs("button",Object.assign({onClick:l,className:p.default("flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-[16px] px-5 py-3 transition-all duration-200",r?"border-2 shadow-sm":"border opacity-80 hover:opacity-100"),style:d},{children:[s.jsx("span",Object.assign({className:"text-[24px] font-semibold tracking-tight"},{children:c})),s.jsxs("span",Object.assign({className:"text-[14px] font-light opacity-80"},{children:["/",i.toLocaleString()," uses"]}))]}))},y=(e,s)=>{var i,t;const r=Number(s?null!==(i=e.credits)&&void 0!==i?i:e.uses:null!==(t=e.uses)&&void 0!==t?t:e.credits);return Number.isFinite(r)?r:0},h=e=>{const s=Number(e.price);return Number.isFinite(s)?s:0};exports.default=({className:k,iconClassName:C,htmlClassName:w})=>{var N,S,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),i=require("react"),t=require("framer-motion"),r=require("../../../hooks/pickaxe/usePickaxeContext.js"),o=require("../../../hooks/pickaxe/useResponseContext.js"),l=require("../../../hooks/studio/useStyleFontSize.js"),a=require("../../../common/utils.js"),n=require("../../Icons/circle-exclamation.svg.js"),c=require("../../Core/SpringTransition.js"),d=require("../../Core/HtmlRenderer.js"),u=require("./PickaxeButton.js"),p=require("../../../common/cn.js"),x=require("../../../common/api/pickaxe.js"),m=require("../Addons/Auth/hooks/useAuthContext.js"),v=require("./AccessGroupCardPreview.js"),f=require("./HorizontalScrollCue.js"),b=require("../../../hooks/studio/useStudio.js"),g=require("./PickaxeCurrency.js");const j=({price:e,uses:i,isCredits:t,isSelected:r,costPerRun:o,onClick:l,colors:a,currencySymbol:n})=>{const c=`${n}${e}`,d={backgroundColor:a.secondary,color:a.secondaryText,borderColor:r?a.secondaryText:"rgba(0,0,0,0.1)"},u=t&&o?Math.ceil(i/o):0;return t?s.jsxs("button",Object.assign({onClick:l,className:p.default("flex min-w-[200px] shrink-0 cursor-pointer flex-col rounded-[16px] px-6 py-5 text-left transition-all duration-200",r?"border-2 shadow-sm":"border opacity-80 hover:opacity-100"),style:d},{children:[s.jsxs("div",Object.assign({className:"mb-4 flex items-center gap-2"},{children:[s.jsx("span",Object.assign({className:"text-[24px] font-semibold tracking-tight"},{children:c})),s.jsxs("span",Object.assign({className:"text-[14px] font-light opacity-80"},{children:["/",i.toLocaleString()," credits"]}))]})),s.jsx("div",{className:"mb-4 h-[1px] w-full",style:{backgroundColor:a.secondaryText,opacity:.15}}),s.jsxs("span",Object.assign({className:"text-[14px] italic opacity-70"},{children:["~ ",void 0!==u&&u>0?u.toLocaleString():"..."," ","runs"]}))]})):s.jsxs("button",Object.assign({onClick:l,className:p.default("flex shrink-0 cursor-pointer items-center justify-center gap-2 rounded-[16px] px-5 py-3 transition-all duration-200",r?"border-2 shadow-sm":"border opacity-80 hover:opacity-100"),style:d},{children:[s.jsx("span",Object.assign({className:"text-[24px] font-semibold tracking-tight"},{children:c})),s.jsxs("span",Object.assign({className:"text-[14px] font-light opacity-80"},{children:["/",i.toLocaleString()," uses"]}))]}))},y=(e,s)=>{var i,t;const r=Number(s?null!==(i=e.credits)&&void 0!==i?i:e.uses:null!==(t=e.uses)&&void 0!==t?t:e.credits);return Number.isFinite(r)?r:0},h=e=>{const s=Number(e.price);return Number.isFinite(s)?s:0};exports.default=({className:k,iconClassName:C,htmlClassName:w})=>{var N,O,S,_;const{colors:q,pickaxe:A,sender:U,translations:I,setValidationStatus:P,setClientSecret:L,setStripeAccountId:R}=r.usePickaxeContext(),{token:G,setRedirectUrl:T}=m.useAuthContext(),{limitData:B}=o.useResponseContext(),{studio:F}=b.useStudio(),M=l.useStyleFontSize(),[z,E]=i.useState(0),[$,H]=i.useState(null),D=Boolean(null==B?void 0:B.hideUpgradeOptions),V=null==F?void 0:F.data,J=null==V?void 0:V.usage,K=Boolean(null==J?void 0:J.isCredits),Q=null!==(O=null===(N=g.currencyOptions.find((e=>e.id===(null==V?void 0:V.currency))))||void 0===N?void 0:N.symbol)&&void 0!==O?O:g.currencyOptions[0].symbol,W=D||"string"!=typeof(null==B?void 0:B.customLink)?"":B.customLink.trim(),X=i.useMemo((()=>{if(D)return[];if(W)return[];const e=K?null==J?void 0:J.availableCredits:null==J?void 0:J.availableUses;if(Array.isArray(e)&&e.length>0)return e;const s=null==B?void 0:B.buyUses;return Array.isArray(s)?s:[]}),[W,K,null==B?void 0:B.buyUses,D,null==J?void 0:J.availableCredits,null==J?void 0:J.availableUses]);i.useEffect((()=>{E(0)}),[X]);const Y=X.length>0,Z=Y?X[z]:void 0,ee=Z?y(Z,K):0,se=Z?h(Z):0;i.useEffect((()=>{let s=!0;return e.__awaiter(void 0,void 0,void 0,(function*(){if(W)H(null);else if(null==V?void 0:V.workspaceId)try{const e=yield x.pickaxeApi2.get(`/cost_per_run?workspaceId=${V.workspaceId}`,{withCredentials:!1});if(s){const s=1e4*e.data.costPerRun||0;H(s)}}catch(e){console.error("Failed to fetch cost per run:",e),s&&H(0)}else H(0)})),()=>{s=!1}}),[W,null==V?void 0:V.workspaceId,H]);const ie=W,te=(null===(S=null==B?void 0:B.limitCTA)||void 0===S?void 0:S.trim())||(null==I?void 0:I["pricing.upgrade"])||(null==I?void 0:I.upgrade)||"Upgrade",re=!D&&!W&&Array.isArray(null==B?void 0:B.upgradeGroups)&&(null==B?void 0:B.upgradeGroups)&&(null==B?void 0:B.upgradeGroups.length)>0;return B?s.jsx(t.AnimatePresence,{children:s.jsxs(c.default,Object.assign({className:p.default("flex flex-col gap-5 w-full",k)},{children:[s.jsxs("div",Object.assign({className:"flex flex-col sm:flex-row gap-4 items-start sm:items-center justify-between rounded-lg p-3 bg-opacity-5",style:{backgroundColor:q.secondary}},{children:[s.jsxs("div",Object.assign({className:"flex gap-3 items-start"},{children:[s.jsx(n.default,{className:p.default("h-5 w-5 shrink-0 mt-0.5",C),style:{color:q.accent}}),s.jsx(d.default,{className:p.default(M.b2,"font-semibold leading-relaxed text-sm",w),style:{color:q.text},html:B.limitMessage||""})]})),ie&&s.jsx(u.default,Object.assign({variant:"primary",className:"whitespace-nowrap min-h-[32px] w-full sm:w-auto text-sm",onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){window.open(ie,"_blank","noopener,noreferrer")}))},{children:te}))]})),re&&s.jsxs("div",Object.assign({className:"flex flex-col gap-2"},{children:[s.jsx("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:q.text}},{children:(null==I?void 0:I["available-plans"])||"Available Plans"})),s.jsx(f.default,Object.assign({contentClassName:"gap-3 pb-4 pt-1",edgeColor:q.primary},{children:null===(_=B.upgradeGroups)||void 0===_?void 0:_.map(((e,i)=>s.jsx(v.default,{data:e},e.accessGroupId||i)))}))]})),Y&&Z&&s.jsxs("div",Object.assign({className:"flex flex-col gap-3"},{children:[s.jsxs("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:q.text}},{children:[(null==I?void 0:I.buy)||"Buy"," ",K?(null==I?void 0:I.credits)||"Credits":(null==I?void 0:I.uses)||"Uses"]})),s.jsx("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-2 pt-1 snap-x scrollbar-thin"},{children:X.map(((e,i)=>s.jsx(j,{price:h(e),uses:y(e,K),isCredits:K,costPerRun:$||void 0,isSelected:i===z,onClick:()=>E(i),colors:q,currencySymbol:Q},i)))})),s.jsxs(u.default,Object.assign({variant:"primary",className:"w-full py-3 text-sm font-bold shadow-md",onClick:()=>e.__awaiter(void 0,void 0,void 0,(function*(){if(G){var s,i;s=ee,i=se,e.__awaiter(void 0,void 0,void 0,(function*(){try{const e=yield x.pickaxeApi2.post("/billing/extra_usage_payment_link",{data:{sender:U||void 0,studioSessionToken:G,studioId:null==A?void 0:A.studioid,cost:i,isEmbed:a.isInIframe(),extraUses:s,successUrl:document.URL}}),{success:t,url:r,clientSecret:o,stripeAccountId:l,error:n}=e.data;t?a.isInIframe()?o&&l?(R(l),L(o),P("stripe_checkout")):r&&window.open(r,"_blank"):r&&(window.location.href=r):alert(n)}catch(e){alert(e)}}))}else{const e=B.limitLink||ie;if(a.isInIframe())T(e||null),P("login_required");else{const s=a.buildUpgradeUrl({baseUrl:e,redirectUrl:document.URL});s&&(window.location.href=s)}}}))},{children:[(null==I?void 0:I.buy)||"Buy"," ",ee.toLocaleString()," ",K?(null==I?void 0:I.credits)||"Credits":(null==I?void 0:I.uses)||"Uses"," ","for ",Q,se]}))]}))]}))}):null};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("../../_virtual/_tslib.js"),s=require("react/jsx-runtime"),t=require("../../hooks/pickaxe/usePickaxe.js"),i=require("react"),a=require("../../hooks/pickaxe/usePickaxeContext.js"),r=require("./Addons/Auth/hooks/useAuthContext.js"),l=require("./Addons/Auth/hooks/useAuthBootstrap.js"),o=require("../../hooks/pickaxe/useResponseContext.js"),n=require("./Addons/Document/hooks/useDocumentContext.js"),c=require("./Addons/Artifact/hooks/useArtifactContext.js"),d=require("uuid"),u=require("./Addons/Scroll/Provider.js"),p=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),f=require("./Addons/Auth/index.js"),j=require("../../common/cn.js"),g=require("../../common/api/pickaxe.js"),h=require("../../common/validation.js"),v=require("./common/AccessGroupCardPreview.js"),b=require("./common/HorizontalScrollCue.js"),k=require("./common/PickaxeButton.js"),y=require("./common/PickaxeAvatar.js"),w=require("../Icons/lock.svg.js"),N=require("../../node_modules/.pnpm/@stripe_react-stripe-js@4.0.2_@stripe_stripe-js@7.9.0_react-dom@18.3.1_react@18.3.1__react@18.3.1/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js"),q=require("../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js");const O=({className:e})=>s.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e},{children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}));exports.Pickaxe=({pickaxeId:A,className:C})=>{const{sessionId:_,styles:I,colors:S,responsiveBy:P,deploymentType:E,isNewChat:L,isEmbed:T,opacity:U,deploymentId:G,sender:R,portalId:B,validationStatus:M,validationUpgradeGroups:D,validationUpgradeUrl:F,accessGroup:V,stripeAccountId:$,clientSecret:z,translations:H,preventInitialSessionId:W,setClientSecret:J,setStripeAccountId:K,setValidationStatus:X,setValidationUpgradeGroups:Y,setValidationUpgradeUrl:Q,setContextId:Z,setPickaxeId:ee,setSessionId:se,setPickaxe:te,setAccessGroup:ie}=a.usePickaxeContext(),{isSent:ae,token:re,isAuthBootstrapComplete:le}=r.useAuthContext(),{setMessages:oe,setResponse:ne,setError:ce,setLimitData:de,setIsSwitchedToChat:ue}=o.useResponseContext(),{setDocumentError:pe}=n.useDocumentContext(),{setCurrentArtifact:xe}=c.useArtifactContext(),[me,fe]=i.useState(!1),je=t.usePickaxe();l.useAuthBootstrap();const ge="chat-input"===E&&L&&!ae,he=i.useMemo((()=>$?q.loadStripe(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:$}):null),[$]);i.useEffect((()=>{ee(A)}),[A]);i.useEffect((()=>{if(!G&&!B||!je.data)return;if(!le)return;if("stripe_checkout"===M)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;X("loading");try{const s=yield g.pickaxeApi2.post("/access/validate",{data:{deploymentId:G,sender:R||void 0,studioSessionToken:re,portalId:B,studioId:null===(e=je.data)||void 0===e?void 0:e.studioid}});if(s.data.success)X("success"),Y([]),Q(null),ie(s.data.accessGroup);else{const e=h.getValidationFailure(s.data);if(!e)return X("login_required"),Y([]),void Q(null);X(e.status),ie(e.accessGroup),Y(e.upgradeGroups),Q(e.upgradeUrl),fe(!0)}}catch(e){console.error("Failed to validate deployment:",e),X("success")}}))}),[G,le,R,re,B,je.data]),i.useEffect((()=>{if(!je.data)return;const e=je.data.chatflag;W||se(e?d.v4():""),Z(d.v4()),e?oe([]):ne(null),ce(""),pe(""),de(null),xe(null),ue(!1),te(je.data),fe(!0)}),[je.data]),i.useEffect((()=>{ce(""),pe(""),de(null),oe([]),ne(null),xe(null)}),[_]);const ve=i.useMemo((()=>{const e=null!=U?U:1;if(!S.primary||!S.primary.startsWith("#")||e<0||e>1)return S.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${S.primary}${s}`}),[S.primary,U]);if(!je.data)return null;return s.jsx("div",Object.assign({className:j.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===I.theme&&"dark",C),style:Object.assign({backgroundColor:ge?"transparent":ve,color:S.text},I.font&&"Real Head Pro"!==I.font&&{fontFamily:I.font})},{children:(()=>{var t,i,a,r,l;if("stripe_checkout"===M&&z&&he)return s.jsxs("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:S.secondary||"#ffffff",color:S.secondaryText||"#000000"}},{children:[s.jsx("div",Object.assign({className:"flex items-center p-4 border-b border-gray-100 shrink-0"},{children:s.jsxs("button",Object.assign({onClick:()=>{J&&J(null),K&&K(null),X("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:S.text}},{children:[s.jsx(O,{className:"w-5 h-5"}),s.jsx("span",{children:(null==H?void 0:H.back)||"Back"})]}))})),s.jsx("div",Object.assign({className:"flex-1 w-full h-full overflow-y-auto [&>div]:h-full"},{children:s.jsx(N.EmbeddedCheckoutProvider,Object.assign({stripe:he,options:{clientSecret:z}},{children:s.jsx(N.EmbeddedCheckout,{})}))}))]}));if(je.isLoading||!me||"loading"===M)return s.jsx("div",Object.assign({className:j.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===P?"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(p.default,{className:"w-[72px] h-[72px]"}),s.jsx(p.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(p.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(p.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(p.default,{className:j.default("w-full min-h-[48px]","viewport"===P?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))}));if("upgrade_required"===M){const e=D.length>0,r=(null===(t=null==V?void 0:V.upgrade)||void 0===t?void 0:t.isLinkToCustomURL)&&"string"==typeof V.upgrade.limitLink&&V.upgrade.limitLink.trim().length>0?V.upgrade.limitLink.trim():null,l="string"==typeof(null===(i=null==V?void 0:V.upgrade)||void 0===i?void 0:i.limitMessage)&&V.upgrade.limitMessage.trim().length>0?V.upgrade.limitMessage:(null==H?void 0:H["please-upgrade-to-continue-using-this-tool"])||"Please upgrade to continue using this tool.",o="string"==typeof(null===(a=null==V?void 0:V.upgrade)||void 0===a?void 0:a.limitCTA)&&V.upgrade.limitCTA.trim().length>0?V.upgrade.limitCTA:(null==H?void 0:H["pricing.upgrade"])||(null==H?void 0:H.upgrade)||"Upgrade";return s.jsx("div",Object.assign({className:"flex h-full min-h-0 w-full items-start justify-center overflow-y-auto p-4"},{children:r?s.jsxs("div",Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==H?void 0:H["upgrade-required"])||"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:l})),s.jsx(k.default,Object.assign({variant:"primary",className:"min-h-[40px] px-5 text-sm",onClick:()=>{window.open(r,"_blank","noopener,noreferrer")}},{children:o}))]})):e?s.jsxs("div",Object.assign({className:"flex w-full max-w-4xl flex-col items-center gap-6 py-6"},{children:[s.jsxs("div",Object.assign({className:"max-w-[640px] text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2 break-words"},{children:(null==H?void 0:H["upgrade-required"])||"Upgrade Required"})),s.jsx("p",Object.assign({className:"break-words opacity-80"},{children:(null==H?void 0:H["please-upgrade-to-continue-using-this-tool"])||"Please upgrade to continue using this tool."}))]})),s.jsx(b.default,Object.assign({className:"w-full",contentClassName:j.default("gap-4 pb-4",D.length<=3&&("viewport"===P?"min-[767px]:justify-center":"@[767px]/pickaxe-root:justify-center"))},{children:D.map(((e,t)=>s.jsx(v.default,{data:e,upgradeUrl:F},e.accessGroupId||e.id||t)))}))]})):s.jsxs("div",Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==H?void 0:H["access-locked"])||"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:(null==H?void 0:H["this-tool-is-locked-contact-owner"])||"This tool is locked to use. Contact owner for more information."}))]}))}))}return"login_required"===M&&T?s.jsx(f.default,{}):"login_required"!==M||T?"access_denied"===M?s.jsxs("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[s.jsxs(y.Avatar,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s.jsx(y.AvatarImage,{src:null===(r=je.data)||void 0===r?void 0:r.coverphoto,alt:`${null===(l=je.data)||void 0===l?void 0:l.formtitle} Logo`}),s.jsx(y.AvatarFallback,{})]})),s.jsxs("div",Object.assign({className:"text-center mb-6"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==H?void 0:H["access-denied"])||"Access Denied"})),s.jsxs("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s.jsx(w.default,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s.jsx("p",Object.assign({className:"ml-1"},{children:(null==H?void 0:H["no-access-request-access"])||"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s.jsx("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:S.accent,color:S.accentText,borderRadius:I.cornerRadius},onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;const t=D.map((e=>e.accessGroupId));try{const i=yield g.pickaxeApi2.post("/access/request",{data:{sender:R||void 0,studioSessionToken:re,studioId:null===(e=je.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=je.data)||void 0===s?void 0:s.formid,deploymentId:G,accessGroupIds:t})}});i.data.success?alert((null==H?void 0:H["access-requested-successfully"])||"Successfully requested access!"):alert(i.data.error)}catch(e){alert(`Couldn't request access. Error: ${e}`)}}))}},{children:(null==H?void 0:H["request-access"])||"Request Access"})),s.jsx("span",Object.assign({className:"mt-4 mb-2"},{children:(null==H?void 0:H.or)||"or"})),s.jsx("span",Object.assign({className:"font-medium text-lg"},{children:(null==H?void 0:H["sign-in-with-different-account"])||"Sign in with a different account"}))]})):_?s.jsx(u.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(u.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:(null==H?void 0:H["access-denied"])||"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:(null==H?void 0:H["login-is-required"])||"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"),i=require("react"),a=require("../../hooks/pickaxe/usePickaxeContext.js"),r=require("./Addons/Auth/hooks/useAuthContext.js"),l=require("./Addons/Auth/hooks/useAuthBootstrap.js"),o=require("../../hooks/pickaxe/useResponseContext.js"),n=require("./Addons/Document/hooks/useDocumentContext.js"),c=require("./Addons/Artifact/hooks/useArtifactContext.js"),d=require("uuid"),u=require("./Addons/Scroll/Provider.js"),p=require("./common/PickaxeSkeleton.js"),x=require("./Chat/index.js"),m=require("./Form/index.js"),f=require("./Addons/Auth/index.js"),j=require("../../common/cn.js"),g=require("../../common/api/pickaxe.js"),h=require("../../common/error.js"),v=require("../../common/validation.js"),b=require("./common/AccessGroupCardPreview.js"),k=require("./common/HorizontalScrollCue.js"),y=require("./common/PickaxeButton.js"),w=require("./common/PickaxeAvatar.js"),N=require("../Icons/lock.svg.js"),q=require("../../node_modules/.pnpm/@stripe_react-stripe-js@4.0_36b9ff7edcdb64a55c314003f3454117/node_modules/@stripe/react-stripe-js/dist/react-stripe.esm.mjs.js"),O=require("../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js");const C=({className:e})=>s.jsx("svg",Object.assign({xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:e},{children:s.jsx("polyline",{points:"15 18 9 12 15 6"})}));exports.Pickaxe=({pickaxeId:A,className:I})=>{const{sessionId:_,styles:S,colors:P,responsiveBy:U,deploymentType:E,isNewChat:L,isEmbed:G,opacity:R,deploymentId:T,sender:B,portalId:M,validationStatus:D,validationUpgradeGroups:F,validationUpgradeUrl:V,accessGroup:$,stripeAccountId:z,clientSecret:H,translations:W,preventInitialSessionId:J,setClientSecret:K,setStripeAccountId:X,setValidationStatus:Y,setValidationUpgradeGroups:Q,setValidationUpgradeUrl:Z,setContextId:ee,setPickaxeId:se,setSessionId:te,setPickaxe:ie,setAccessGroup:ae}=a.usePickaxeContext(),{emailInput:re,isSent:le,token:oe,isAuthBootstrapComplete:ne}=r.useAuthContext(),{setMessages:ce,setResponse:de,setError:ue,setLimitData:pe,setIsSwitchedToChat:xe}=o.useResponseContext(),{setDocumentError:me}=n.useDocumentContext(),{setCurrentArtifact:fe}=c.useArtifactContext(),[je,ge]=i.useState(!1),he=t.usePickaxe();l.useAuthBootstrap();const ve="chat-input"===E&&L&&!le,be=i.useMemo((()=>z?O.loadStripe(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:z}):null),[z]);i.useEffect((()=>{se(A)}),[A]);i.useEffect((()=>{if(!T&&!M||!he.data)return;if(!ne)return;if("stripe_checkout"===D)return;e.__awaiter(void 0,void 0,void 0,(function*(){var e;Y("loading");try{const s=yield g.pickaxeApi2.post("/access/validate",{data:{deploymentId:T,sender:B||void 0,studioSessionToken:oe,portalId:M,studioId:null===(e=he.data)||void 0===e?void 0:e.studioid}});if(s.data.success)Y("success"),Q([]),Z(null),ae(((e,s)=>e&&s?Object.assign(Object.assign({},e),{hideUpgradeOptions:!0}):e)(s.data.accessGroup,s.data.hideUpgradeOptions));else{const e=v.getValidationFailure(s.data);if(!e)return Y("login_required"),Q([]),void Z(null);Y(e.status),ae(e.accessGroup),Q(e.upgradeGroups),Z(e.upgradeUrl),ge(!0)}}catch(e){console.error("Failed to validate deployment:",e),Y("success")}}))}),[T,ne,B,oe,M,he.data]),i.useEffect((()=>{if(!he.data)return;const e=he.data.chatflag;J||te(e?d.v4():""),ee(d.v4()),e?ce([]):de(null),ue(""),me(""),pe(null),fe(null),xe(!1),ie(he.data),ge(!0)}),[he.data]),i.useEffect((()=>{ue(""),me(""),pe(null),ce([]),de(null),fe(null)}),[_]);const ke=i.useMemo((()=>{const e=null!=R?R:1;if(!P.primary||!P.primary.startsWith("#")||e<0||e>1)return P.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${P.primary}${s}`}),[P.primary,R]);if(!he.data)return null;return s.jsx("div",Object.assign({className:j.default("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===S.theme&&"dark",I),style:Object.assign({backgroundColor:ve?"transparent":ke,color:P.text},S.font&&"Real Head Pro"!==S.font&&{fontFamily:S.font})},{children:(()=>{var t,i,a,r,l;if("stripe_checkout"===D&&H&&be)return s.jsxs("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:P.secondary||"#ffffff",color:P.secondaryText||"#000000"}},{children:[s.jsx("div",Object.assign({className:"flex items-center p-4 border-b border-gray-100 shrink-0"},{children:s.jsxs("button",Object.assign({onClick:()=>{K&&K(null),X&&X(null),Y("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:P.text}},{children:[s.jsx(C,{className:"w-5 h-5"}),s.jsx("span",{children:(null==W?void 0:W.back)||"Back"})]}))})),s.jsx("div",Object.assign({className:"flex-1 w-full h-full overflow-y-auto [&>div]:h-full"},{children:s.jsx(q.EmbeddedCheckoutProvider,Object.assign({stripe:be,options:{clientSecret:H}},{children:s.jsx(q.EmbeddedCheckout,{})}))}))]}));if(he.isLoading||!je||"loading"===D)return s.jsx("div",Object.assign({className:j.default("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===U?"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(p.default,{className:"w-[72px] h-[72px]"}),s.jsx(p.default,{className:"h-[20px] mt-6 w-full"}),s.jsx(p.default,{className:"h-[20px] mt-2 w-full"}),s.jsx(p.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(p.default,{className:j.default("w-full min-h-[48px]","viewport"===U?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))}));if("upgrade_required"===D){const e=null==$?void 0:$.hideUpgradeOptions,r=!e&&F.length>0,l=!e&&(null===(t=null==$?void 0:$.upgrade)||void 0===t?void 0:t.isLinkToCustomURL)&&"string"==typeof $.upgrade.limitLink&&$.upgrade.limitLink.trim().length>0?$.upgrade.limitLink.trim():null,o="string"==typeof(null===(i=null==$?void 0:$.upgrade)||void 0===i?void 0:i.limitMessage)&&$.upgrade.limitMessage.trim().length>0?$.upgrade.limitMessage:(null==W?void 0:W["please-upgrade-to-continue-using-this-tool"])||"Please upgrade to continue using this tool.",n="string"==typeof(null===(a=null==$?void 0:$.upgrade)||void 0===a?void 0:a.limitCTA)&&$.upgrade.limitCTA.trim().length>0?$.upgrade.limitCTA:(null==W?void 0:W["pricing.upgrade"])||(null==W?void 0:W.upgrade)||"Upgrade";return s.jsx("div",Object.assign({className:"flex h-full min-h-0 w-full items-start justify-center overflow-y-auto p-4"},{children:l?s.jsxs("div",Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==W?void 0:W["upgrade-required"])||"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:o})),s.jsx(y.default,Object.assign({variant:"primary",className:"min-h-[40px] px-5 text-sm",onClick:()=>{window.open(l,"_blank","noopener,noreferrer")}},{children:n}))]})):r?s.jsxs("div",Object.assign({className:"flex w-full max-w-4xl flex-col items-center gap-6 py-6"},{children:[s.jsxs("div",Object.assign({className:"max-w-[640px] text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2 break-words"},{children:(null==W?void 0:W["upgrade-required"])||"Upgrade Required"})),s.jsx("p",Object.assign({className:"break-words opacity-80"},{children:(null==W?void 0:W["please-upgrade-to-continue-using-this-tool"])||"Please upgrade to continue using this tool."}))]})),s.jsx(k.default,Object.assign({className:"w-full",contentClassName:j.default("gap-4 pb-4",F.length<=3&&("viewport"===U?"min-[767px]:justify-center":"@[767px]/pickaxe-root:justify-center"))},{children:F.map(((e,t)=>s.jsx(b.default,{data:e,upgradeUrl:V},e.accessGroupId||e.id||t)))}))]})):e?s.jsxs("div",Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==W?void 0:W["upgrade-required"])||"Upgrade Required"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:o}))]})):s.jsxs("div",Object.assign({className:"m-auto flex max-w-[640px] flex-col items-center gap-4 text-center"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==W?void 0:W["access-locked"])||"Access Locked"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:(null==W?void 0:W["this-tool-is-locked-contact-owner"])||"This tool is locked to use. Contact owner for more information."}))]}))}))}return"login_required"===D&&G?s.jsx(f.default,{}):"login_required"!==D||G?"access_denied"===D?s.jsxs("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[s.jsxs(w.Avatar,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s.jsx(w.AvatarImage,{src:null===(r=he.data)||void 0===r?void 0:r.coverphoto,alt:`${null===(l=he.data)||void 0===l?void 0:l.formtitle} Logo`}),s.jsx(w.AvatarFallback,{})]})),s.jsxs("div",Object.assign({className:"text-center mb-6"},{children:[s.jsx("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:(null==W?void 0:W["access-denied"])||"Access Denied"})),s.jsxs("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s.jsx(N.default,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s.jsx("p",Object.assign({className:"ml-1"},{children:(null==W?void 0:W["no-access-request-access"])||"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s.jsx("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:P.accent,color:P.accentText,borderRadius:S.cornerRadius},onClick:()=>{e.__awaiter(void 0,void 0,void 0,(function*(){var e,s;const t=(null==$?void 0:$.accessGroupId)?[$.accessGroupId]:[],i=re.trim().toLowerCase();if(i)try{const a=yield g.pickaxeApi2.post("/access/request",{data:{email:i,studioId:null===(e=he.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=he.data)||void 0===s?void 0:s.formid,deploymentId:T,accessGroupIds:t})}});a.data.success?alert((null==W?void 0:W["access-requested-successfully"])||"Successfully requested access!"):alert(a.data.error)}catch(e){const s=h.default(e);alert(((null==W?void 0:W["request-access-error"])||"Couldn't request access. Error: {error}").replace("{error}",s||String(e)))}else alert((null==W?void 0:W["email-address-cannot-be-empty"])||"Email address cannot be empty.")}))}},{children:(null==W?void 0:W["request-access"])||"Request Access"})),s.jsx("span",Object.assign({className:"mt-4 mb-2"},{children:(null==W?void 0:W.or)||"or"})),s.jsx("span",Object.assign({className:"font-medium text-lg"},{children:(null==W?void 0:W["sign-in-with-different-account"])||"Sign in with a different account"}))]})):_?s.jsx(u.ScrollProvider,{children:s.jsx(x.default,{})}):s.jsx(u.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:(null==W?void 0:W["access-denied"])||"Access Denied"})),s.jsx("p",Object.assign({className:"opacity-80"},{children:(null==W?void 0:W["login-is-required"])||"Login is required."}))]}))}))})()}))};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("../../../../../_virtual/_commonjsHelpers.js"),r=require("../../../../../_virtual/cose-base2.js"),i=require("../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js");r.__module.exports,exports.__require=function(){return t||(t=1,o=r.__module,r.__module.exports,e.commonjsGlobal,n=function(t){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(e,r){e.exports=t},function(t,e,r){var i=r(0).FDLayoutConstants;function o(){}for(var n in i)o[n]=i[n];o.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,o.DEFAULT_RADIAL_SEPARATION=i.DEFAULT_EDGE_LENGTH,o.DEFAULT_COMPONENT_SEPERATION=60,o.TILE=!0,o.TILING_PADDING_VERTICAL=10,o.TILING_PADDING_HORIZONTAL=10,o.TREE_REDUCTION_ON_INCREMENTAL=!1,t.exports=o},function(t,e,r){var i=r(0).FDLayoutEdge;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraph;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraphManager;function o(t){i.call(this,t)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).FDLayoutNode,o=r(0).IMath;function n(t,e,r,o){i.call(this,t,e,r,o)}for(var a in n.prototype=Object.create(i.prototype),i)n[a]=i[a];n.prototype.move=function(){var t=this.graphManager.getLayout();this.displacementX=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementX=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementX)),Math.abs(this.displacementY)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementY=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementY)),null==this.child||0==this.child.getNodes().length?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),t.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},n.prototype.propogateDisplacementToChildren=function(t,e){for(var r,i=this.getChild().getNodes(),o=0;o<i.length;o++)null==(r=i[o]).getChild()?(r.moveBy(t,e),r.displacementX+=t,r.displacementY+=e):r.propogateDisplacementToChildren(t,e)},n.prototype.setPred1=function(t){this.pred1=t},n.prototype.getPred1=function(){return pred1},n.prototype.getPred2=function(){return pred2},n.prototype.setNext=function(t){this.next=t},n.prototype.getNext=function(){return next},n.prototype.setProcessed=function(t){this.processed=t},n.prototype.isProcessed=function(){return processed},t.exports=n},function(t,e,r){var i=r(0).FDLayout,o=r(4),n=r(3),a=r(5),s=r(2),h=r(1),d=r(0).FDLayoutConstants,g=r(0).LayoutConstants,l=r(0).Point,p=r(0).PointD,c=r(0).Layout,u=r(0).Integer,f=r(0).IGeometry,v=r(0).LGraph,T=r(0).Transform;function E(){i.call(this),this.toBeTiled={}}for(var m in E.prototype=Object.create(i.prototype),i)E[m]=i[m];E.prototype.newGraphManager=function(){var t=new o(this);return this.graphManager=t,t},E.prototype.newGraph=function(t){return new n(null,this.graphManager,t)},E.prototype.newNode=function(t){return new a(this.graphManager,t)},E.prototype.newEdge=function(t){return new s(null,null,t)},E.prototype.initParameters=function(){i.prototype.initParameters.call(this,arguments),this.isSubLayout||(h.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=h.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=h.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=d.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=d.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=d.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},E.prototype.layout=function(){return g.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},E.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)h.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)})),this.graphManager.setAllNodesToApplyGravitation(r));else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)}));this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},E.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter((function(e){return t.has(e)}));this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var r=!this.isTreeGrowing&&!this.isGrowthFinished,i=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(r,i),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},E.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},r=0;r<t.length;r++){var i=t[r].rect,o=t[r].id;e[o]={id:o,x:i.getCenterX(),y:i.getCenterY(),w:i.width,h:i.height}}return e},E.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if("during"===d.ANIMATE)this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},E.prototype.calculateNodesToApplyGravitationTo=function(){var t,e,r=[],i=this.graphManager.getGraphs(),o=i.length;for(e=0;e<o;e++)(t=i[e]).updateConnected(),t.isConnected||(r=r.concat(t.getNodes()));return r},E.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e,r=new Set;for(e=0;e<t.length;e++){var i=t[e];if(!r.has(i)){var o=i.getSource(),n=i.getTarget();if(o==n)i.getBendpoints().push(new p),i.getBendpoints().push(new p),this.createDummyNodesForBendpoints(i),r.add(i);else{var a=[];if(a=(a=a.concat(o.getEdgeListToNode(n))).concat(n.getEdgeListToNode(o)),!r.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var h=a[s];h.getBendpoints().push(new p),this.createDummyNodesForBendpoints(h)}a.forEach((function(t){r.add(t)}))}}}if(r.size==t.length)break}},E.prototype.positionNodesRadially=function(t){for(var e=new l(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,n=0,a=new p(0,0),s=0;s<t.length;s++){s%r==0&&(n=0,o=i,0!=s&&(o+=h.DEFAULT_COMPONENT_SEPERATION),i=0);var d=t[s],u=c.findCenterOfTree(d);e.x=n,e.y=o,(a=E.radialLayout(d,u,e)).y>i&&(i=Math.floor(a.y)),n=Math.floor(a.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(g.WORLD_CENTER_X-a.x/2,g.WORLD_CENTER_Y-a.y/2))},E.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),h.DEFAULT_RADIAL_SEPARATION);E.branchRadialLayout(e,null,0,359,0,i);var o=v.calculateBounds(t),n=new T;n.setDeviceOrgX(o.getMinX()),n.setDeviceOrgY(o.getMinY()),n.setWorldOrgX(r.x),n.setWorldOrgY(r.y);for(var a=0;a<t.length;a++)t[a].transform(n);var s=new p(o.getMaxX(),o.getMaxY());return n.inverseTransformPoint(s)},E.branchRadialLayout=function(t,e,r,i,o,n){var a=(i-r+1)/2;a<0&&(a+=180);var s=(a+r)%360*f.TWO_PI/360,h=o*Math.cos(s),d=o*Math.sin(s);t.setCenter(h,d);var g=[],l=(g=g.concat(t.getEdges())).length;null!=e&&l--;for(var p,c=0,u=g.length,v=t.getEdgesBetween(e);v.length>1;){var T=v[0];v.splice(0,1);var m=g.indexOf(T);m>=0&&g.splice(m,1),u--,l--}p=null!=e?(g.indexOf(v[0])+1)%u:0;for(var y=Math.abs(i-r)/l,N=p;c!=l;N=++N%u){var w=g[N].getOtherEnd(t);if(w!=e){var A=(r+c*y)%360,C=(A+y)%360;E.branchRadialLayout(w,t,A,C,o+n,n),c++}}},E.maxDiagonalInTree=function(t){for(var e=u.MIN_VALUE,r=0;r<t.length;r++){var i=t[r].getDiagonal();i>e&&(e=i)}return e},E.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},E.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var r=[],i=this.graphManager.getAllNodes(),o=0;o<i.length;o++){var n=(s=i[o]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=n.id&&this.getToBeTiled(n)||r.push(s)}for(o=0;o<r.length;o++){var s,h=(s=r[o]).getParent().id;void 0===e[h]&&(e[h]=[]),e[h]=e[h].concat(s)}Object.keys(e).forEach((function(r){if(e[r].length>1){var i="DummyCompound_"+r;t.memberGroups[i]=e[r];var o=e[r][0].getParent(),n=new a(t.graphManager);n.id=i,n.paddingLeft=o.paddingLeft||0,n.paddingRight=o.paddingRight||0,n.paddingBottom=o.paddingBottom||0,n.paddingTop=o.paddingTop||0,t.idToDummyNode[i]=n;var s=t.getGraphManager().add(t.newGraph(),n),h=o.getChild();h.add(n);for(var d=0;d<e[r].length;d++){var g=e[r][d];h.remove(g),s.add(g)}}}))},E.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var r=0;r<this.compoundOrder.length;r++)e[this.compoundOrder[r].id]=this.compoundOrder[r],t[this.compoundOrder[r].id]=[].concat(this.compoundOrder[r].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[r].getChild()),this.compoundOrder[r].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},E.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach((function(r){var i=t.idToDummyNode[r];e[r]=t.tileNodes(t.memberGroups[r],i.paddingLeft+i.paddingRight),i.rect.width=e[r].width,i.rect.height=e[r].height}))},E.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],r=e.id,i=e.paddingLeft,o=e.paddingTop;this.adjustLocations(this.tiledMemberPack[r],e.rect.x,e.rect.y,i,o)}},E.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach((function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,n=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,n)}))},E.prototype.getToBeTiled=function(t){var e=t.id;if(null!=this.toBeTiled[e])return this.toBeTiled[e];var r=t.getChild();if(null==r)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var n=i[o];if(this.getNodeDegree(n)>0)return this.toBeTiled[e]=!1,!1;if(null!=n.getChild()){if(!this.getToBeTiled(n))return this.toBeTiled[e]=!1,!1}else this.toBeTiled[n.id]=!1}return this.toBeTiled[e]=!0,!0},E.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),r=0,i=0;i<e.length;i++){var o=e[i];o.getSource().id!==o.getTarget().id&&(r+=1)}return r},E.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(null==t.getChild())return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},E.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},E.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];null!=r.getChild()&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},E.prototype.adjustLocations=function(t,e,r,i,o){r+=o;for(var n=e+=i,a=0;a<t.rows.length;a++){var s=t.rows[a];e=n;for(var h=0,d=0;d<s.length;d++){var g=s[d];g.rect.x=e,g.rect.y=r,e+=g.rect.width+t.horizontalPadding,g.rect.height>h&&(h=g.rect.height)}r+=h+t.verticalPadding}},E.prototype.tileCompoundMembers=function(t,e){var r=this;this.tiledMemberPack=[],Object.keys(t).forEach((function(i){var o=e[i];r.tiledMemberPack[i]=r.tileNodes(t[i],o.paddingLeft+o.paddingRight),o.rect.width=r.tiledMemberPack[i].width,o.rect.height=r.tiledMemberPack[i].height}))},E.prototype.tileNodes=function(t,e){var r={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:h.TILING_PADDING_VERTICAL,horizontalPadding:h.TILING_PADDING_HORIZONTAL};t.sort((function(t,e){return t.rect.width*t.rect.height>e.rect.width*e.rect.height?-1:t.rect.width*t.rect.height<e.rect.width*e.rect.height?1:0}));for(var i=0;i<t.length;i++){var o=t[i];0==r.rows.length?this.insertNodeToRow(r,o,0,e):this.canAddHorizontal(r,o.rect.width,o.rect.height)?this.insertNodeToRow(r,o,this.getShortestRowIndex(r),e):this.insertNodeToRow(r,o,r.rows.length,e),this.shiftToLastRow(r)}return r},E.prototype.insertNodeToRow=function(t,e,r,i){var o=i;r==t.rows.length&&(t.rows.push([]),t.rowWidth.push(o),t.rowHeight.push(0));var n=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(n+=t.horizontalPadding),t.rowWidth[r]=n,t.width<n&&(t.width=n);var a=e.rect.height;r>0&&(a+=t.verticalPadding);var s=0;a>t.rowHeight[r]&&(s=t.rowHeight[r],t.rowHeight[r]=a,s=t.rowHeight[r]-s),t.height+=s,t.rows[r].push(e)},E.prototype.getShortestRowIndex=function(t){for(var e=-1,r=Number.MAX_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]<r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.getLongestRowIndex=function(t){for(var e=-1,r=Number.MIN_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]>r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.canAddHorizontal=function(t,e,r){var i=this.getShortestRowIndex(t);if(i<0)return!0;var o=t.rowWidth[i];if(o+t.horizontalPadding+e<=t.width)return!0;var n,a,s=0;return t.rowHeight[i]<r&&i>0&&(s=r+t.verticalPadding-t.rowHeight[i]),n=t.width-o>=e+t.horizontalPadding?(t.height+s)/(o+e+t.horizontalPadding):(t.height+s)/t.width,s=r+t.verticalPadding,(a=t.width<e?(t.height+s)/e:(t.height+s)/t.width)<1&&(a=1/a),n<1&&(n=1/n),n<a},E.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],n=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>n&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-n,t.rowWidth[r]=t.rowWidth[r]+n,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var a=Number.MIN_VALUE,s=0;s<i.length;s++)i[s].height>a&&(a=i[s].height);e>0&&(a+=t.verticalPadding);var h=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=a,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var d=t.rowHeight[e]+t.rowHeight[r];t.height+=d-h,this.shiftToLastRow(t)}},E.prototype.tilingPreLayout=function(){h.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},E.prototype.tilingPostLayout=function(){h.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},E.prototype.reduceTrees=function(){for(var t,e=[],r=!0;r;){var i=this.graphManager.getAllNodes(),o=[];r=!1;for(var n=0;n<i.length;n++)1!=(t=i[n]).getEdges().length||t.getEdges()[0].isInterGraph||null!=t.getChild()||(o.push([t,t.getEdges()[0],t.getOwner()]),r=!0);if(1==r){for(var a=[],s=0;s<o.length;s++)1==o[s][0].getEdges().length&&(a.push(o[s]),o[s][0].getOwner().remove(o[s][0]));e.push(a),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=e},E.prototype.growTree=function(t){for(var e,r=t[t.length-1],i=0;i<r.length;i++)e=r[i],this.findPlaceforPrunedNode(e),e[2].add(e[0]),e[2].add(e[1],e[1].source,e[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},E.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0],o=(r=i==t[1].source?t[1].target:t[1].source).startX,n=r.finishX,a=r.startY,s=r.finishY,h=[0,0,0,0];if(a>0)for(var g=o;g<=n;g++)h[0]+=this.grid[g][a-1].length+this.grid[g][a].length-1;if(n<this.grid.length-1)for(g=a;g<=s;g++)h[1]+=this.grid[n+1][g].length+this.grid[n][g].length-1;if(s<this.grid[0].length-1)for(g=o;g<=n;g++)h[2]+=this.grid[g][s+1].length+this.grid[g][s].length-1;if(o>0)for(g=a;g<=s;g++)h[3]+=this.grid[o-1][g].length+this.grid[o][g].length-1;for(var l,p,c=u.MAX_VALUE,f=0;f<h.length;f++)h[f]<c?(c=h[f],l=1,p=f):h[f]==c&&l++;if(3==l&&0==c)0==h[0]&&0==h[1]&&0==h[2]?e=1:0==h[0]&&0==h[1]&&0==h[3]?e=0:0==h[0]&&0==h[2]&&0==h[3]?e=3:0==h[1]&&0==h[2]&&0==h[3]&&(e=2);else if(2==l&&0==c){var v=Math.floor(2*Math.random());e=0==h[0]&&0==h[1]?0==v?0:1:0==h[0]&&0==h[2]?0==v?0:2:0==h[0]&&0==h[3]?0==v?0:3:0==h[1]&&0==h[2]?0==v?1:2:0==h[1]&&0==h[3]?0==v?1:3:0==v?2:3}else e=4==l&&0==c?v=Math.floor(4*Math.random()):p;0==e?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-d.DEFAULT_EDGE_LENGTH-i.getHeight()/2):1==e?i.setCenter(r.getCenterX()+r.getWidth()/2+d.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):2==e?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+d.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-d.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},t.exports=E},function(t,e,r){var i={};i.layoutBase=r(0),i.CoSEConstants=r(1),i.CoSEEdge=r(2),i.CoSEGraph=r(3),i.CoSEGraphManager=r(4),i.CoSELayout=r(6),i.CoSENode=r(5),t.exports=i}])},o.exports=n(i.__require())),r.__module.exports;var o,n};
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,e=require("../../../../../_virtual/_commonjsHelpers.js"),r=require("../../../../../_virtual/cose-base.js"),i=require("../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js");r.__module.exports,exports.__require=function(){return t||(t=1,o=r.__module,r.__module.exports,e.commonjsGlobal,n=function(t){return function(t){var e={};function r(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return t[i].call(o.exports,o,o.exports,r),o.l=!0,o.exports}return r.m=t,r.c=e,r.i=function(t){return t},r.d=function(t,e,i){r.o(t,e)||Object.defineProperty(t,e,{configurable:!1,enumerable:!0,get:i})},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=7)}([function(e,r){e.exports=t},function(t,e,r){var i=r(0).FDLayoutConstants;function o(){}for(var n in i)o[n]=i[n];o.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,o.DEFAULT_RADIAL_SEPARATION=i.DEFAULT_EDGE_LENGTH,o.DEFAULT_COMPONENT_SEPERATION=60,o.TILE=!0,o.TILING_PADDING_VERTICAL=10,o.TILING_PADDING_HORIZONTAL=10,o.TREE_REDUCTION_ON_INCREMENTAL=!1,t.exports=o},function(t,e,r){var i=r(0).FDLayoutEdge;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraph;function o(t,e,r){i.call(this,t,e,r)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).LGraphManager;function o(t){i.call(this,t)}for(var n in o.prototype=Object.create(i.prototype),i)o[n]=i[n];t.exports=o},function(t,e,r){var i=r(0).FDLayoutNode,o=r(0).IMath;function n(t,e,r,o){i.call(this,t,e,r,o)}for(var a in n.prototype=Object.create(i.prototype),i)n[a]=i[a];n.prototype.move=function(){var t=this.graphManager.getLayout();this.displacementX=t.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=t.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementX=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementX)),Math.abs(this.displacementY)>t.coolingFactor*t.maxNodeDisplacement&&(this.displacementY=t.coolingFactor*t.maxNodeDisplacement*o.sign(this.displacementY)),null==this.child||0==this.child.getNodes().length?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),t.totalDisplacement+=Math.abs(this.displacementX)+Math.abs(this.displacementY),this.springForceX=0,this.springForceY=0,this.repulsionForceX=0,this.repulsionForceY=0,this.gravitationForceX=0,this.gravitationForceY=0,this.displacementX=0,this.displacementY=0},n.prototype.propogateDisplacementToChildren=function(t,e){for(var r,i=this.getChild().getNodes(),o=0;o<i.length;o++)null==(r=i[o]).getChild()?(r.moveBy(t,e),r.displacementX+=t,r.displacementY+=e):r.propogateDisplacementToChildren(t,e)},n.prototype.setPred1=function(t){this.pred1=t},n.prototype.getPred1=function(){return pred1},n.prototype.getPred2=function(){return pred2},n.prototype.setNext=function(t){this.next=t},n.prototype.getNext=function(){return next},n.prototype.setProcessed=function(t){this.processed=t},n.prototype.isProcessed=function(){return processed},t.exports=n},function(t,e,r){var i=r(0).FDLayout,o=r(4),n=r(3),a=r(5),s=r(2),h=r(1),d=r(0).FDLayoutConstants,g=r(0).LayoutConstants,l=r(0).Point,p=r(0).PointD,c=r(0).Layout,u=r(0).Integer,f=r(0).IGeometry,v=r(0).LGraph,T=r(0).Transform;function E(){i.call(this),this.toBeTiled={}}for(var m in E.prototype=Object.create(i.prototype),i)E[m]=i[m];E.prototype.newGraphManager=function(){var t=new o(this);return this.graphManager=t,t},E.prototype.newGraph=function(t){return new n(null,this.graphManager,t)},E.prototype.newNode=function(t){return new a(this.graphManager,t)},E.prototype.newEdge=function(t){return new s(null,null,t)},E.prototype.initParameters=function(){i.prototype.initParameters.call(this,arguments),this.isSubLayout||(h.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=h.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=h.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=d.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=d.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=d.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=d.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=d.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=d.DEFAULT_COMPOUND_GRAVITY_RANGE_FACTOR,this.prunedNodesAll=[],this.growTreeIterations=0,this.afterGrowthIterations=0,this.isTreeGrowing=!1,this.isGrowthFinished=!1,this.coolingCycle=0,this.maxCoolingCycle=this.maxIterations/d.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=d.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},E.prototype.layout=function(){return g.DEFAULT_CREATE_BENDS_AS_NEEDED&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},E.prototype.classicLayout=function(){if(this.nodesWithGravity=this.calculateNodesToApplyGravitationTo(),this.graphManager.setAllNodesToApplyGravitation(this.nodesWithGravity),this.calcNoOfChildrenForAllNodes(),this.graphManager.calcLowestCommonAncestors(),this.graphManager.calcInclusionTreeDepths(),this.graphManager.getRoot().calcEstimatedSize(),this.calcIdealEdgeLengths(),this.incremental)h.TREE_REDUCTION_ON_INCREMENTAL&&(this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation(),e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)})),this.graphManager.setAllNodesToApplyGravitation(r));else{var t=this.getFlatForest();if(t.length>0)this.positionNodesRadially(t);else{this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter((function(t){return e.has(t)}));this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},E.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}if(this.totalIterations%d.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged()){if(!(this.prunedNodesAll.length>0))return!0;this.isTreeGrowing=!0}this.coolingCycle++,0==this.layoutQuality?this.coolingAdjuster=this.coolingCycle:1==this.layoutQuality&&(this.coolingAdjuster=this.coolingCycle/3),this.coolingFactor=Math.max(this.initialCoolingFactor-Math.pow(this.coolingCycle,Math.log(100*(this.initialCoolingFactor-this.finalTemperature))/Math.log(this.maxCoolingCycle))/100*this.coolingAdjuster,this.finalTemperature),this.animationPeriod=Math.ceil(this.initialAnimationPeriod*Math.sqrt(this.coolingFactor))}if(this.isTreeGrowing){if(this.growTreeIterations%10==0)if(this.prunedNodesAll.length>0){this.graphManager.updateBounds(),this.updateGrid(),this.growTree(this.prunedNodesAll),this.graphManager.resetAllNodesToApplyGravitation();var t=new Set(this.getAllNodes()),e=this.nodesWithGravity.filter((function(e){return t.has(e)}));this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL}else this.isTreeGrowing=!1,this.isGrowthFinished=!0;this.growTreeIterations++}if(this.isGrowthFinished){if(this.isConverged())return!0;this.afterGrowthIterations%10==0&&(this.graphManager.updateBounds(),this.updateGrid()),this.coolingFactor=d.DEFAULT_COOLING_FACTOR_INCREMENTAL*((100-this.afterGrowthIterations)/100),this.afterGrowthIterations++}var r=!this.isTreeGrowing&&!this.isGrowthFinished,i=this.growTreeIterations%10==1&&this.isTreeGrowing||this.afterGrowthIterations%10==1&&this.isGrowthFinished;return this.totalDisplacement=0,this.graphManager.updateBounds(),this.calcSpringForces(),this.calcRepulsionForces(r,i),this.calcGravitationalForces(),this.moveNodes(),this.animate(),!1},E.prototype.getPositionsData=function(){for(var t=this.graphManager.getAllNodes(),e={},r=0;r<t.length;r++){var i=t[r].rect,o=t[r].id;e[o]={id:o,x:i.getCenterX(),y:i.getCenterY(),w:i.width,h:i.height}}return e},E.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if("during"===d.ANIMATE)this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},E.prototype.calculateNodesToApplyGravitationTo=function(){var t,e,r=[],i=this.graphManager.getGraphs(),o=i.length;for(e=0;e<o;e++)(t=i[e]).updateConnected(),t.isConnected||(r=r.concat(t.getNodes()));return r},E.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e,r=new Set;for(e=0;e<t.length;e++){var i=t[e];if(!r.has(i)){var o=i.getSource(),n=i.getTarget();if(o==n)i.getBendpoints().push(new p),i.getBendpoints().push(new p),this.createDummyNodesForBendpoints(i),r.add(i);else{var a=[];if(a=(a=a.concat(o.getEdgeListToNode(n))).concat(n.getEdgeListToNode(o)),!r.has(a[0])){var s;if(a.length>1)for(s=0;s<a.length;s++){var h=a[s];h.getBendpoints().push(new p),this.createDummyNodesForBendpoints(h)}a.forEach((function(t){r.add(t)}))}}}if(r.size==t.length)break}},E.prototype.positionNodesRadially=function(t){for(var e=new l(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,n=0,a=new p(0,0),s=0;s<t.length;s++){s%r==0&&(n=0,o=i,0!=s&&(o+=h.DEFAULT_COMPONENT_SEPERATION),i=0);var d=t[s],u=c.findCenterOfTree(d);e.x=n,e.y=o,(a=E.radialLayout(d,u,e)).y>i&&(i=Math.floor(a.y)),n=Math.floor(a.x+h.DEFAULT_COMPONENT_SEPERATION)}this.transform(new p(g.WORLD_CENTER_X-a.x/2,g.WORLD_CENTER_Y-a.y/2))},E.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),h.DEFAULT_RADIAL_SEPARATION);E.branchRadialLayout(e,null,0,359,0,i);var o=v.calculateBounds(t),n=new T;n.setDeviceOrgX(o.getMinX()),n.setDeviceOrgY(o.getMinY()),n.setWorldOrgX(r.x),n.setWorldOrgY(r.y);for(var a=0;a<t.length;a++)t[a].transform(n);var s=new p(o.getMaxX(),o.getMaxY());return n.inverseTransformPoint(s)},E.branchRadialLayout=function(t,e,r,i,o,n){var a=(i-r+1)/2;a<0&&(a+=180);var s=(a+r)%360*f.TWO_PI/360,h=o*Math.cos(s),d=o*Math.sin(s);t.setCenter(h,d);var g=[],l=(g=g.concat(t.getEdges())).length;null!=e&&l--;for(var p,c=0,u=g.length,v=t.getEdgesBetween(e);v.length>1;){var T=v[0];v.splice(0,1);var m=g.indexOf(T);m>=0&&g.splice(m,1),u--,l--}p=null!=e?(g.indexOf(v[0])+1)%u:0;for(var y=Math.abs(i-r)/l,N=p;c!=l;N=++N%u){var w=g[N].getOtherEnd(t);if(w!=e){var A=(r+c*y)%360,C=(A+y)%360;E.branchRadialLayout(w,t,A,C,o+n,n),c++}}},E.maxDiagonalInTree=function(t){for(var e=u.MIN_VALUE,r=0;r<t.length;r++){var i=t[r].getDiagonal();i>e&&(e=i)}return e},E.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},E.prototype.groupZeroDegreeMembers=function(){var t=this,e={};this.memberGroups={},this.idToDummyNode={};for(var r=[],i=this.graphManager.getAllNodes(),o=0;o<i.length;o++){var n=(s=i[o]).getParent();0!==this.getNodeDegreeWithChildren(s)||null!=n.id&&this.getToBeTiled(n)||r.push(s)}for(o=0;o<r.length;o++){var s,h=(s=r[o]).getParent().id;void 0===e[h]&&(e[h]=[]),e[h]=e[h].concat(s)}Object.keys(e).forEach((function(r){if(e[r].length>1){var i="DummyCompound_"+r;t.memberGroups[i]=e[r];var o=e[r][0].getParent(),n=new a(t.graphManager);n.id=i,n.paddingLeft=o.paddingLeft||0,n.paddingRight=o.paddingRight||0,n.paddingBottom=o.paddingBottom||0,n.paddingTop=o.paddingTop||0,t.idToDummyNode[i]=n;var s=t.getGraphManager().add(t.newGraph(),n),h=o.getChild();h.add(n);for(var d=0;d<e[r].length;d++){var g=e[r][d];h.remove(g),s.add(g)}}}))},E.prototype.clearCompounds=function(){var t={},e={};this.performDFSOnCompounds();for(var r=0;r<this.compoundOrder.length;r++)e[this.compoundOrder[r].id]=this.compoundOrder[r],t[this.compoundOrder[r].id]=[].concat(this.compoundOrder[r].getChild().getNodes()),this.graphManager.remove(this.compoundOrder[r].getChild()),this.compoundOrder[r].child=null;this.graphManager.resetAllNodes(),this.tileCompoundMembers(t,e)},E.prototype.clearZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack=[];Object.keys(this.memberGroups).forEach((function(r){var i=t.idToDummyNode[r];e[r]=t.tileNodes(t.memberGroups[r],i.paddingLeft+i.paddingRight),i.rect.width=e[r].width,i.rect.height=e[r].height}))},E.prototype.repopulateCompounds=function(){for(var t=this.compoundOrder.length-1;t>=0;t--){var e=this.compoundOrder[t],r=e.id,i=e.paddingLeft,o=e.paddingTop;this.adjustLocations(this.tiledMemberPack[r],e.rect.x,e.rect.y,i,o)}},E.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach((function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,n=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,n)}))},E.prototype.getToBeTiled=function(t){var e=t.id;if(null!=this.toBeTiled[e])return this.toBeTiled[e];var r=t.getChild();if(null==r)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var n=i[o];if(this.getNodeDegree(n)>0)return this.toBeTiled[e]=!1,!1;if(null!=n.getChild()){if(!this.getToBeTiled(n))return this.toBeTiled[e]=!1,!1}else this.toBeTiled[n.id]=!1}return this.toBeTiled[e]=!0,!0},E.prototype.getNodeDegree=function(t){t.id;for(var e=t.getEdges(),r=0,i=0;i<e.length;i++){var o=e[i];o.getSource().id!==o.getTarget().id&&(r+=1)}return r},E.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(null==t.getChild())return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},E.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},E.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];null!=r.getChild()&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},E.prototype.adjustLocations=function(t,e,r,i,o){r+=o;for(var n=e+=i,a=0;a<t.rows.length;a++){var s=t.rows[a];e=n;for(var h=0,d=0;d<s.length;d++){var g=s[d];g.rect.x=e,g.rect.y=r,e+=g.rect.width+t.horizontalPadding,g.rect.height>h&&(h=g.rect.height)}r+=h+t.verticalPadding}},E.prototype.tileCompoundMembers=function(t,e){var r=this;this.tiledMemberPack=[],Object.keys(t).forEach((function(i){var o=e[i];r.tiledMemberPack[i]=r.tileNodes(t[i],o.paddingLeft+o.paddingRight),o.rect.width=r.tiledMemberPack[i].width,o.rect.height=r.tiledMemberPack[i].height}))},E.prototype.tileNodes=function(t,e){var r={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:h.TILING_PADDING_VERTICAL,horizontalPadding:h.TILING_PADDING_HORIZONTAL};t.sort((function(t,e){return t.rect.width*t.rect.height>e.rect.width*e.rect.height?-1:t.rect.width*t.rect.height<e.rect.width*e.rect.height?1:0}));for(var i=0;i<t.length;i++){var o=t[i];0==r.rows.length?this.insertNodeToRow(r,o,0,e):this.canAddHorizontal(r,o.rect.width,o.rect.height)?this.insertNodeToRow(r,o,this.getShortestRowIndex(r),e):this.insertNodeToRow(r,o,r.rows.length,e),this.shiftToLastRow(r)}return r},E.prototype.insertNodeToRow=function(t,e,r,i){var o=i;r==t.rows.length&&(t.rows.push([]),t.rowWidth.push(o),t.rowHeight.push(0));var n=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(n+=t.horizontalPadding),t.rowWidth[r]=n,t.width<n&&(t.width=n);var a=e.rect.height;r>0&&(a+=t.verticalPadding);var s=0;a>t.rowHeight[r]&&(s=t.rowHeight[r],t.rowHeight[r]=a,s=t.rowHeight[r]-s),t.height+=s,t.rows[r].push(e)},E.prototype.getShortestRowIndex=function(t){for(var e=-1,r=Number.MAX_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]<r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.getLongestRowIndex=function(t){for(var e=-1,r=Number.MIN_VALUE,i=0;i<t.rows.length;i++)t.rowWidth[i]>r&&(e=i,r=t.rowWidth[i]);return e},E.prototype.canAddHorizontal=function(t,e,r){var i=this.getShortestRowIndex(t);if(i<0)return!0;var o=t.rowWidth[i];if(o+t.horizontalPadding+e<=t.width)return!0;var n,a,s=0;return t.rowHeight[i]<r&&i>0&&(s=r+t.verticalPadding-t.rowHeight[i]),n=t.width-o>=e+t.horizontalPadding?(t.height+s)/(o+e+t.horizontalPadding):(t.height+s)/t.width,s=r+t.verticalPadding,(a=t.width<e?(t.height+s)/e:(t.height+s)/t.width)<1&&(a=1/a),n<1&&(n=1/n),n<a},E.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],n=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>n&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-n,t.rowWidth[r]=t.rowWidth[r]+n,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var a=Number.MIN_VALUE,s=0;s<i.length;s++)i[s].height>a&&(a=i[s].height);e>0&&(a+=t.verticalPadding);var h=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=a,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var d=t.rowHeight[e]+t.rowHeight[r];t.height+=d-h,this.shiftToLastRow(t)}},E.prototype.tilingPreLayout=function(){h.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},E.prototype.tilingPostLayout=function(){h.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},E.prototype.reduceTrees=function(){for(var t,e=[],r=!0;r;){var i=this.graphManager.getAllNodes(),o=[];r=!1;for(var n=0;n<i.length;n++)1!=(t=i[n]).getEdges().length||t.getEdges()[0].isInterGraph||null!=t.getChild()||(o.push([t,t.getEdges()[0],t.getOwner()]),r=!0);if(1==r){for(var a=[],s=0;s<o.length;s++)1==o[s][0].getEdges().length&&(a.push(o[s]),o[s][0].getOwner().remove(o[s][0]));e.push(a),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=e},E.prototype.growTree=function(t){for(var e,r=t[t.length-1],i=0;i<r.length;i++)e=r[i],this.findPlaceforPrunedNode(e),e[2].add(e[0]),e[2].add(e[1],e[1].source,e[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},E.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0],o=(r=i==t[1].source?t[1].target:t[1].source).startX,n=r.finishX,a=r.startY,s=r.finishY,h=[0,0,0,0];if(a>0)for(var g=o;g<=n;g++)h[0]+=this.grid[g][a-1].length+this.grid[g][a].length-1;if(n<this.grid.length-1)for(g=a;g<=s;g++)h[1]+=this.grid[n+1][g].length+this.grid[n][g].length-1;if(s<this.grid[0].length-1)for(g=o;g<=n;g++)h[2]+=this.grid[g][s+1].length+this.grid[g][s].length-1;if(o>0)for(g=a;g<=s;g++)h[3]+=this.grid[o-1][g].length+this.grid[o][g].length-1;for(var l,p,c=u.MAX_VALUE,f=0;f<h.length;f++)h[f]<c?(c=h[f],l=1,p=f):h[f]==c&&l++;if(3==l&&0==c)0==h[0]&&0==h[1]&&0==h[2]?e=1:0==h[0]&&0==h[1]&&0==h[3]?e=0:0==h[0]&&0==h[2]&&0==h[3]?e=3:0==h[1]&&0==h[2]&&0==h[3]&&(e=2);else if(2==l&&0==c){var v=Math.floor(2*Math.random());e=0==h[0]&&0==h[1]?0==v?0:1:0==h[0]&&0==h[2]?0==v?0:2:0==h[0]&&0==h[3]?0==v?0:3:0==h[1]&&0==h[2]?0==v?1:2:0==h[1]&&0==h[3]?0==v?1:3:0==v?2:3}else e=4==l&&0==c?v=Math.floor(4*Math.random()):p;0==e?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-d.DEFAULT_EDGE_LENGTH-i.getHeight()/2):1==e?i.setCenter(r.getCenterX()+r.getWidth()/2+d.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):2==e?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+d.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-d.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},t.exports=E},function(t,e,r){var i={};i.layoutBase=r(0),i.CoSEConstants=r(1),i.CoSEEdge=r(2),i.CoSEGraph=r(3),i.CoSEGraphManager=r(4),i.CoSELayout=r(6),i.CoSENode=r(5),t.exports=i}])},o.exports=n(i.__require())),r.__module.exports;var o,n};
|