@pickaxeproject/react 6.0.1-12 → 6.0.1-14
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/_virtual/index3.js +1 -0
- package/dist/cjs/_virtual/index4.js +1 -0
- package/dist/cjs/_virtual/react-is.development.js +1 -0
- package/dist/cjs/_virtual/react-is.production.min.js +1 -0
- package/dist/cjs/components/Pickaxe/Addons/Auth/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/cjs/components/Pickaxe/Provider.js +1 -1
- package/dist/cjs/components/Pickaxe/common/AccessGroupCardPreview.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/@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 +1 -0
- package/dist/cjs/node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js +1 -0
- 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/node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js +7 -0
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js +1 -0
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js +1 -0
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js +1 -0
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -0
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js +1 -0
- package/dist/cjs/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js +1 -0
- package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +9 -0
- package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +9 -0
- package/dist/cjs/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +1 -0
- package/dist/cjs/src/components/Pickaxe/Addons/Auth/Provider.d.ts +2 -0
- package/dist/cjs/src/components/Pickaxe/Addons/Auth/hooks/useAuth.d.ts +0 -1
- package/dist/cjs/src/components/Pickaxe/Provider.d.ts +7 -0
- package/dist/cjs/src/components/Pickaxe/ResponseProvider.d.ts +1 -0
- package/dist/esm/_virtual/index3.js +1 -0
- package/dist/esm/_virtual/index4.js +1 -0
- package/dist/esm/_virtual/react-is.development.js +1 -0
- package/dist/esm/_virtual/react-is.production.min.js +1 -0
- package/dist/esm/components/Pickaxe/Addons/Auth/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/Addons/Auth/hooks/useAuth.js +1 -1
- package/dist/esm/components/Pickaxe/Provider.js +1 -1
- package/dist/esm/components/Pickaxe/common/AccessGroupCardPreview.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/@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 +1 -0
- package/dist/esm/node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js +1 -0
- 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/node_modules/.pnpm/object-assign@4.1.1/node_modules/object-assign/index.js +6 -0
- package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/checkPropTypes.js +1 -0
- package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithThrowingShims.js +1 -0
- package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/factoryWithTypeCheckers.js +1 -0
- package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/index.js +1 -0
- package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/ReactPropTypesSecret.js +1 -0
- package/dist/esm/node_modules/.pnpm/prop-types@15.8.1/node_modules/prop-types/lib/has.js +1 -0
- package/dist/esm/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.development.js +9 -0
- package/dist/esm/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/cjs/react-is.production.min.js +9 -0
- package/dist/esm/node_modules/.pnpm/react-is@16.13.1/node_modules/react-is/index.js +1 -0
- package/dist/esm/src/components/Pickaxe/Addons/Auth/Provider.d.ts +2 -0
- package/dist/esm/src/components/Pickaxe/Addons/Auth/hooks/useAuth.d.ts +0 -1
- package/dist/esm/src/components/Pickaxe/Provider.d.ts +7 -0
- package/dist/esm/src/components/Pickaxe/ResponseProvider.d.ts +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,_;Object.defineProperty(exports,"__esModule",{value:!0}),exports.__require=function(){return _?e:(_=1,e="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var e,r;Object.defineProperty(exports,"__esModule",{value:!0}),exports.__require=function(){return r?e:(r=1,e=Function.call.bind(Object.prototype.hasOwnProperty))};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("../../../../../../_virtual/react-is.development.js");
|
|
2
|
+
/** @license React v16.13.1
|
|
3
|
+
* react-is.development.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/exports.__require=function(){return e||(e=1,"production"!==process.env.NODE_ENV&&function(){var e="function"==typeof Symbol&&Symbol.for,t=e?Symbol.for("react.element"):60103,o=e?Symbol.for("react.portal"):60106,n=e?Symbol.for("react.fragment"):60107,s=e?Symbol.for("react.strict_mode"):60108,c=e?Symbol.for("react.profiler"):60114,a=e?Symbol.for("react.provider"):60109,f=e?Symbol.for("react.context"):60110,_=e?Symbol.for("react.async_mode"):60111,p=e?Symbol.for("react.concurrent_mode"):60111,u=e?Symbol.for("react.forward_ref"):60112,i=e?Symbol.for("react.suspense"):60113,l=e?Symbol.for("react.suspense_list"):60120,y=e?Symbol.for("react.memo"):60115,m=e?Symbol.for("react.lazy"):60116,x=e?Symbol.for("react.block"):60121,d=e?Symbol.for("react.fundamental"):60117,b=e?Symbol.for("react.responder"):60118,S=e?Symbol.for("react.scope"):60119;function $(e){if("object"==typeof e&&null!==e){var r=e.$$typeof;switch(r){case t:var l=e.type;switch(l){case _:case p:case n:case c:case s:case i:return l;default:var x=l&&l.$$typeof;switch(x){case f:case u:case m:case y:case a:return x;default:return r}}case o:return r}}}var v=_,M=p,C=f,w=a,P=t,h=u,j=n,E=m,R=y,g=o,A=c,F=s,I=i,z=!1;function O(e){return $(e)===p}r.__exports.AsyncMode=v,r.__exports.ConcurrentMode=M,r.__exports.ContextConsumer=C,r.__exports.ContextProvider=w,r.__exports.Element=P,r.__exports.ForwardRef=h,r.__exports.Fragment=j,r.__exports.Lazy=E,r.__exports.Memo=R,r.__exports.Portal=g,r.__exports.Profiler=A,r.__exports.StrictMode=F,r.__exports.Suspense=I,r.__exports.isAsyncMode=function(e){return z||(z=!0,console.warn("The ReactIs.isAsyncMode() alias has been deprecated, and will be removed in React 17+. Update your code to use ReactIs.isConcurrentMode() instead. It has the exact same API.")),O(e)||$(e)===_},r.__exports.isConcurrentMode=O,r.__exports.isContextConsumer=function(e){return $(e)===f},r.__exports.isContextProvider=function(e){return $(e)===a},r.__exports.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===t},r.__exports.isForwardRef=function(e){return $(e)===u},r.__exports.isFragment=function(e){return $(e)===n},r.__exports.isLazy=function(e){return $(e)===m},r.__exports.isMemo=function(e){return $(e)===y},r.__exports.isPortal=function(e){return $(e)===o},r.__exports.isProfiler=function(e){return $(e)===c},r.__exports.isStrictMode=function(e){return $(e)===s},r.__exports.isSuspense=function(e){return $(e)===i},r.__exports.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===n||e===p||e===c||e===s||e===i||e===l||"object"==typeof e&&null!==e&&(e.$$typeof===m||e.$$typeof===y||e.$$typeof===a||e.$$typeof===f||e.$$typeof===u||e.$$typeof===d||e.$$typeof===b||e.$$typeof===S||e.$$typeof===x)},r.__exports.typeOf=$}()),r.__exports};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("../../../../../../_virtual/react-is.production.min.js");
|
|
2
|
+
/** @license React v16.13.1
|
|
3
|
+
* react-is.production.min.js
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
6
|
+
*
|
|
7
|
+
* This source code is licensed under the MIT license found in the
|
|
8
|
+
* LICENSE file in the root directory of this source tree.
|
|
9
|
+
*/exports.__require=function(){if(e)return r.__exports;e=1;var t="function"==typeof Symbol&&Symbol.for,o=t?Symbol.for("react.element"):60103,n=t?Symbol.for("react.portal"):60106,s=t?Symbol.for("react.fragment"):60107,c=t?Symbol.for("react.strict_mode"):60108,f=t?Symbol.for("react.profiler"):60114,_=t?Symbol.for("react.provider"):60109,p=t?Symbol.for("react.context"):60110,u=t?Symbol.for("react.async_mode"):60111,i=t?Symbol.for("react.concurrent_mode"):60111,a=t?Symbol.for("react.forward_ref"):60112,y=t?Symbol.for("react.suspense"):60113,l=t?Symbol.for("react.suspense_list"):60120,m=t?Symbol.for("react.memo"):60115,x=t?Symbol.for("react.lazy"):60116,b=t?Symbol.for("react.block"):60121,S=t?Symbol.for("react.fundamental"):60117,$=t?Symbol.for("react.responder"):60118,d=t?Symbol.for("react.scope"):60119;function M(e){if("object"==typeof e&&null!==e){var r=e.$$typeof;switch(r){case o:switch(e=e.type){case u:case i:case s:case f:case c:case y:return e;default:switch(e=e&&e.$$typeof){case p:case a:case x:case m:case _:return e;default:return r}}case n:return r}}}function v(e){return M(e)===i}return r.__exports.AsyncMode=u,r.__exports.ConcurrentMode=i,r.__exports.ContextConsumer=p,r.__exports.ContextProvider=_,r.__exports.Element=o,r.__exports.ForwardRef=a,r.__exports.Fragment=s,r.__exports.Lazy=x,r.__exports.Memo=m,r.__exports.Portal=n,r.__exports.Profiler=f,r.__exports.StrictMode=c,r.__exports.Suspense=y,r.__exports.isAsyncMode=function(e){return v(e)||M(e)===u},r.__exports.isConcurrentMode=v,r.__exports.isContextConsumer=function(e){return M(e)===p},r.__exports.isContextProvider=function(e){return M(e)===_},r.__exports.isElement=function(e){return"object"==typeof e&&null!==e&&e.$$typeof===o},r.__exports.isForwardRef=function(e){return M(e)===a},r.__exports.isFragment=function(e){return M(e)===s},r.__exports.isLazy=function(e){return M(e)===x},r.__exports.isMemo=function(e){return M(e)===m},r.__exports.isPortal=function(e){return M(e)===n},r.__exports.isProfiler=function(e){return M(e)===f},r.__exports.isStrictMode=function(e){return M(e)===c},r.__exports.isSuspense=function(e){return M(e)===y},r.__exports.isValidElementType=function(e){return"string"==typeof e||"function"==typeof e||e===s||e===i||e===f||e===c||e===y||e===l||"object"==typeof e&&null!==e&&(e.$$typeof===x||e.$$typeof===m||e.$$typeof===_||e.$$typeof===p||e.$$typeof===a||e.$$typeof===S||e.$$typeof===$||e.$$typeof===d||e.$$typeof===b)},r.__exports.typeOf=M,r.__exports};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,r=require("../../../../../_virtual/index4.js"),o=require("./cjs/react-is.production.min.js"),s=require("./cjs/react-is.development.js");exports.__require=function(){return e||(e=1,"production"===process.env.NODE_ENV?r.__module.exports=o.__require():r.__module.exports=s.__require()),r.__module.exports};
|
|
@@ -2,6 +2,7 @@ import type { SetState } from "../../../../types/common";
|
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
type AuthContextType = {
|
|
4
4
|
emailInput: string;
|
|
5
|
+
redirectUrl: string | null;
|
|
5
6
|
token: string | null;
|
|
6
7
|
isLoggedIn: boolean;
|
|
7
8
|
isLoggedOut: boolean;
|
|
@@ -17,6 +18,7 @@ type AuthContextType = {
|
|
|
17
18
|
setIsResendDisabled: SetState<boolean>;
|
|
18
19
|
setIsSent: SetState<boolean>;
|
|
19
20
|
setIsPricingAuth: SetState<boolean>;
|
|
21
|
+
setRedirectUrl: SetState<string | null>;
|
|
20
22
|
};
|
|
21
23
|
export interface IAuthProviderProps {
|
|
22
24
|
children: ReactNode;
|
|
@@ -36,6 +36,7 @@ export type PickaxeMisc = {
|
|
|
36
36
|
isDescription: boolean;
|
|
37
37
|
isHistory?: boolean;
|
|
38
38
|
};
|
|
39
|
+
type ValidationStatus = "loading" | "success" | "login_required" | "upgrade_required" | "access_denied" | "stripe_checkout";
|
|
39
40
|
export type PickaxeDeploymentEmbedType = "inline" | "fab" | "popup" | "chat-input" | "direct-link";
|
|
40
41
|
export type PickaxeDeploymentDimensions = {
|
|
41
42
|
width: {
|
|
@@ -64,6 +65,7 @@ type PickaxeContextType = {
|
|
|
64
65
|
senderType: PickaxeHistorySenderType;
|
|
65
66
|
deploymentId?: string;
|
|
66
67
|
deploymentType?: PickaxeDeploymentEmbedType;
|
|
68
|
+
validationStatus: ValidationStatus;
|
|
67
69
|
deploymentDimensions?: PickaxeDeploymentDimensions;
|
|
68
70
|
deploymentMisc?: PickaxeDeploymentMisc;
|
|
69
71
|
portalId?: string;
|
|
@@ -89,10 +91,13 @@ type PickaxeContextType = {
|
|
|
89
91
|
isEmbed: boolean;
|
|
90
92
|
isDropShadow: boolean;
|
|
91
93
|
allowGuestUsage: boolean;
|
|
94
|
+
stripeAccountId: string | null;
|
|
95
|
+
clientSecret: string | null;
|
|
92
96
|
setContextId: SetState<string>;
|
|
93
97
|
setPickaxeId: SetState<string>;
|
|
94
98
|
setSessionId: SetState<string>;
|
|
95
99
|
setLastSessionId: SetState<string>;
|
|
100
|
+
setValidationStatus: SetState<ValidationStatus>;
|
|
96
101
|
setSender: SetState<string | undefined>;
|
|
97
102
|
setSenderType: SetState<PickaxeHistorySenderType>;
|
|
98
103
|
setPickaxe: SetState<LimitedPickaxe | null>;
|
|
@@ -100,6 +105,8 @@ type PickaxeContextType = {
|
|
|
100
105
|
setIsNewChat: SetState<boolean>;
|
|
101
106
|
setIsShowIceBreaker: SetState<boolean>;
|
|
102
107
|
setIsShowFeedbackMessage: SetState<boolean>;
|
|
108
|
+
setStripeAccountId: SetState<string | null>;
|
|
109
|
+
setClientSecret: SetState<string | null>;
|
|
103
110
|
onGenerateComplete?: (responseId: string) => void;
|
|
104
111
|
};
|
|
105
112
|
export interface IPickaxeProviderProps {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={exports:{}};export{e as __module};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e={exports:{}};export{e as __module};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r={};export{r as __exports};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var r={};export{r as __exports};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsx as e}from"react/jsx-runtime";import{useState as s,createContext as
|
|
1
|
+
import{jsx as e}from"react/jsx-runtime";import{useState as s,createContext as t}from"react";const i=t({}),n=({children:t})=>{const[n,r]=s(""),[g,d]=s(null),[l,o]=s(null),[c,u]=s(!1),[a,I]=s(!1),[m,p]=s(!1),[h,L]=s(!1),[S,b]=s(!1);return e(i.Provider,Object.assign({value:{emailInput:n,redirectUrl:l,token:g,isLoggedIn:!!g,isLoggedOut:!g,isLoggingIn:c,isSending:m,isResendDisabled:h,isSent:S,isPricingAuth:a,setIsPricingAuth:I,setRedirectUrl:o,setEmailInput:r,setToken:d,setIsLoggingIn:u,setIsSending:p,setIsResendDisabled:L,setIsSent:b}},{children:t}))};export{i as AuthContext,n as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as
|
|
1
|
+
import{__awaiter as e}from"../../../../../_virtual/_tslib.js";import{useEffect as t}from"react";import{usePickaxeContext as i}from"../../../../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as o}from"./useAuthContext.js";import{useAuthVerify as r}from"./useAuthVerify.js";import{getAuthToken as s,deleteAuthToken as n,setAuthToken as d}from"../../../../../common/utils.js";import a from"../../../../../common/api/pickaxe.js";import m from"../../../../../common/error.js";import{useResponseContext as u}from"../../../../../hooks/pickaxe/useResponseContext.js";const c=()=>{const{deploymentId:c,pickaxe:l,setSender:f,setSenderType:p}=i(),{emailInput:g,redirectUrl:k,isSending:I,isLoggedOut:h,isPricingAuth:w,setToken:j,setIsLoggingIn:v,setIsSending:x,setIsSent:y,setIsResendDisabled:S,setIsPricingAuth:E}=o(),P=r({token:s((null==l?void 0:l.studioid)||"")||"",enabled:h,setIsLoggingIn:v}),{setLimitData:b}=u();t((()=>{if("undefined"==typeof window)return;if(!P.data)return;const{success:e,token:t,error:i}=P.data;if(!e||i)return n(`PXE-token-${null==l?void 0:l.studioid}`),void E(!1);e&&t&&(j(t),f(void 0),p("STUDIO_USER"),w&&(E(!1),b(null)))}),[P.data,null==l?void 0:l.studioid]);return{onSend:t=>e(void 0,void 0,void 0,(function*(){try{if(!l)return;if(I)return;const e=g.trim().toLowerCase();if(!e)throw new Error("Email address cannot be empty.");if(!e.includes("@")||!e.includes("."))throw new Error("Please enter a valid email address.");if(!l.studioid)throw new Error(`Studio ID is missing for ${l.formid}. Please contact support.`);x(!0),t&&S(!0);const i=(yield a.post("/auth/email",Object.assign(Object.assign({pickaxeId:l.formid,studioId:l.studioid,email:e},c&&{deploymentId:c}),{redirectUrl:k}))).data;if(!i.success)throw new Error(i.error||"Failed to send sign-in link.");x(!1),y(!0),t&&(yield new Promise((e=>setTimeout(e,3e4))),S(!1)),d(`PXE-token-${l.studioid}`,i.token),E(!0)}catch(e){const t=m(e);alert(t)}finally{x(!1)}}))}};export{c as useAuth};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as o}from"react/jsx-runtime";import{createContext as
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as o}from"react/jsx-runtime";import{createContext as t,useState as i,useEffect as s}from"react";import{ArtifactProvider as n}from"./Addons/Artifact/Provider.js";import r from"./DimensionProvider.js";import a from"./ResponseProvider.js";import l from"./Addons/Document/Provider.js";import d from"./Addons/Auth/Provider.js";const c=t({}),p=({children:t,origin:p,sender:m,senderType:y,portalId:u,deploymentId:h,deploymentType:f,deploymentDimensions:b,deploymentMisc:g,styles:v,colors:S,limits:F={},misc:I={isWhiteLabel:!0,isProfileImage:!0,isChatImage:!0,isTitle:!0,isDescription:!0,isHistory:!0},translations:w,artifact:x={popupType:"auto"},responsiveBy:k="viewport",locale:P="en",opacity:j=1,forceMobile:C=!1,disableHtml:T=!1,disableJs:D=!1,disableCss:A=!1,loadFont:H=!0,isRtl:O=!1,isEmbed:R=!1,isDropShadow:L=!1,allowGuestUsage:M=!0,onGenerateComplete:E})=>{const[B,G]=i(""),[N,U]=i(""),[W,J]=i(""),[_,z]=i(""),[V,Y]=i(m),[q,K]=i(y),[Q,X]=i("loading"),[Z,$]=i(null),[ee,oe]=i(null),[te,ie]=i(null),[se,ne]=i(!1),[re,ae]=i(!0),[le,de]=i(!0),[ce,pe]=i(!1);return s((()=>{ne(!1)}),[null==v?void 0:v.font]),s((()=>{e(void 0,void 0,void 0,(function*(){if("undefined"!=typeof window&&H&&!se&&(null==v?void 0:v.font)&&"Real Head Pro"!==v.font)try{(yield import("webfontloader")).default.load({google:{families:[v.font]},active:()=>{ne(!0)},inactive:()=>{console.error("[pxe] failed to load font {styles.font}"),ne(!0)}})}catch(e){console.error("[pxe] failed to load font:",e),ne(!0)}}))}),[H,se,null==v?void 0:v.font]),s((()=>{Y(m)}),[m]),o(c.Provider,Object.assign({value:Object.assign({origin:p,contextId:B,pickaxeId:N,sessionId:W,lastSessionId:_,sender:V,senderType:q,portalId:u,deploymentId:h,deploymentType:f,validationStatus:Q,deploymentDimensions:b,deploymentMisc:g,pickaxe:te,styles:Object.assign({theme:"light",font:"Real Head Pro",fontSize:"md",formFieldStyle:"box",btnStyle:"filled",outlineThickness:1,cornerRadius:4},v),colors:Object.assign({primary:"#F6F8FA",text:"#000000",secondary:"#FFFFFF",secondaryText:"#000000",accent:"#228DD7",accentText:"#FFFFFF",error:"#EF4444"},S),misc:I,translations:Object.assign({"new-chat":"New chat","see-history":"See history","see-input":"See input","hide-input":"Hide input",processing:"Processing...",uploading:"Uploading...",loading:"Loading...","powered-by-pickaxe":"Powered by Pickaxe","form-doc-placeholder":"Paste a website/video link or drag a file",website:"Website",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"},w),artifact:x,responsiveBy:k,locale:P,opacity:j,forceMobile:C,loadFont:H,disableHtml:T,disableJs:D,disableCss:A,isFontLoaded:se,isNewChat:re,isShowIceBreaker:le,isShowFeedbackMessage:ce,isRtl:O,isEmbed:R,isDropShadow:L,allowGuestUsage:M,clientSecret:ee,stripeAccountId:Z,setClientSecret:oe,setStripeAccountId:$,setContextId:G,setValidationStatus:X,setPickaxeId:U,setSessionId:J,setLastSessionId:z,setSender:Y,setSenderType:K,setPickaxe:ie,setIsFontLoaded:ne,setIsNewChat:ae,setIsShowIceBreaker:de,setIsShowFeedbackMessage:pe},E&&{onGenerateComplete:E})},{children:o(d,{children:o(r,{children:o(a,Object.assign({limits:F},{children:o(l,{children:o(n,Object.assign({},x,{children:t}))})}))})})}))};export{c as PickaxeContext,p as PickaxeProvider};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsxs as t,jsx as i}from"react/jsx-runtime";import{useMemo as s}from"react";import{usePickaxeContext as o}from"../../../hooks/pickaxe/usePickaxeContext.js";import r from"./PickaxeButton.js";import{STUDIO_INFINITY_VALUE as n,intervalToSuffix as c}from"./PickaxeCommon.js";import{currencyOptions as a}from"./PickaxeCurrency.js";import{Avatar as l,AvatarImage as d,AvatarFallback as m}from"./PickaxeAvatar.js";import{useAuthContext as p}from"../Addons/Auth/hooks/useAuthContext.js";import u from"../../../common/api/pickaxe.js";import{isInIframe as f}from"../../../common/utils.js";import{useResponseContext as x}from"../../../hooks/pickaxe/useResponseContext.js";const h=({data:h,children:b,upgradeUrl:v})=>{var j;const{limitData:g}=x(),{colors:k,sender:y,pickaxe:N,setValidationStatus:O,setStripeAccountId:w,setClientSecret:C}=o(),{token:S,setRedirectUrl:U}=p(),I=s((()=>{var e;return null!==(e=h.displayName)&&void 0!==e?e:h.name}),[h]),_=s((()=>{var e;return null!==(e=h.displayDescription)&&void 0!==e?e:h.description}),[h]),A=s((()=>{var e;const{price:t,priceInterval:i,currency:s}=h;if(!t)return{price:"Free",suffix:""};const o=c(i,!0);return{price:`${(null!==(e=a.find((e=>e.id===s)))&&void 0!==e?e:a[0]).symbol}${t.toLocaleString()}`,suffix:o}}),[h]),L=s((()=>{const{limit:e,limitInterval:t}=h;if(e===n)return{limit:"Unlimited",suffix:""};const i=c(t,!0);return{limit:e.toLocaleString(),suffix:i}}),[h]);return t("div",Object.assign({className:"relative flex min-h-[260px] w-[220px] shrink-0 snap-center flex-col justify-between rounded-xl border p-4 shadow-sm",style:{backgroundColor:k.secondary,color:k.secondaryText}},{children:[b,t("div",Object.assign({className:"flex flex-col"},{children:[t("div",Object.assign({className:"flex flex-col"},{children:[t(l,Object.assign({className:"h-8 w-8"},{children:[i(d,{src:null!==(j=h.image)&&void 0!==j?j:"",alt:I}),i(m,{})]})),i("p",Object.assign({className:"mt-2 text-sm font-semibold line-clamp-1",title:I},{children:I})),Boolean(_)&&i("p",Object.assign({className:"mt-1 text-[10px] opacity-70 line-clamp-2 leading-tight"},{children:_})),t("p",Object.assign({className:"mt-2 text-base font-semibold"},{children:[A.price,i("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:A.suffix}))]}))]})),t("div",Object.assign({className:"mt-3 flex flex-col border-t py-2",style:{borderTopColor:k.secondaryText}},{children:[i("span",Object.assign({className:"text-[10px] font-bold opacity-50"},{children:"USES"})),t("p",Object.assign({className:"text-base font-semibold"},{children:[L.limit,i("span",Object.assign({className:"text-xs font-normal opacity-70"},{children:L.suffix}))]}))]}))]})),i(r,Object.assign({variant:"primary",className:"w-full mt-2 min-h-[32px] text-xs",onClick:()=>e(void 0,void 0,void 0,(function*(){if(S)e(void 0,void 0,void 0,(function*(){try{const e=yield u.post("/access_group_checkout",{data:{studioUserId:y||void 0,studioId:null==N?void 0:N.studioid,accessGroupId:h.accessGroupId,successUrl:document.URL,isEmbed:f(),studioSessionToken:S}}),{success:t,url:i,clientSecret:s,stripeAccountId:o,error:r}=e.data;t?f()?s&&o?(w(o),C(s),O("stripe_checkout")):i&&window.open(i,"_blank"):i&&(window.location.href=i):alert(r)}catch(e){alert(e)}}));else if(f()){const e=v||(null==g?void 0:g.limitLink);U(e||null),O("login_required")}else window.location.href=v||`${null==g?void 0:g.limitLink}?redirectUrl=${document.URL}`}))},{children:h.ctaButtonText}))]}))};export{h as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as o}from"react/jsx-runtime";import{useState as t,useEffect as r}from"react";import{AnimatePresence as
|
|
1
|
+
import{__awaiter as e}from"../../../_virtual/_tslib.js";import{jsx as s,jsxs as o}from"react/jsx-runtime";import{useState as t,useEffect as r}from"react";import{AnimatePresence as i}from"framer-motion";import{usePickaxeContext as a}from"../../../hooks/pickaxe/usePickaxeContext.js";import{useResponseContext as l}from"../../../hooks/pickaxe/useResponseContext.js";import{useStyleFontSize as c}from"../../../hooks/studio/useStyleFontSize.js";import{isInIframe as n}from"../../../common/utils.js";import d from"../../Icons/circle-exclamation.svg.js";import m from"../../Core/SpringTransition.js";import p from"../../Core/HtmlRenderer.js";import u from"./PickaxeButton.js";import f from"../../../common/cn.js";import x from"../../../common/api/pickaxe.js";import{useAuthContext as b}from"../Addons/Auth/hooks/useAuthContext.js";import g from"./AccessGroupCardPreview.js";const h=({price:e,uses:s,isSelected:t,onClick:r,colors:i})=>o("button",Object.assign({onClick:r,className:f("flex items-center gap-2 rounded-xl border px-4 py-3 shadow-sm transition-all duration-200 shrink-0",t?"border-2":"border opacity-80 hover:opacity-100"),style:{backgroundColor:i.secondary,color:i.secondaryText,borderColor:t?i.secondaryText:"rgba(0,0,0,0.1)"}},{children:[o("span",Object.assign({className:"text-xl font-bold"},{children:["$",e]})),o("span",Object.assign({className:"text-sm opacity-70"},{children:["/ ",s.toLocaleString()," uses"]}))]})),y=({className:y,iconClassName:v,htmlClassName:j})=>{var w,k;const{colors:C,pickaxe:N,sender:U,setValidationStatus:A,setClientSecret:O,setStripeAccountId:S}=a(),{token:_,setRedirectUrl:L}=b(),{limitData:R}=l(),$=c(),[G,I]=t(0);if(r((()=>{var e;(null===(e=null==R?void 0:R.buyUses)||void 0===e?void 0:e.length)&&I(0)}),[R]),!R)return null;const T=R.customLink,P=R.limitCTA,B=Array.isArray(R.upgradeGroups)&&R.upgradeGroups.length>0,q=Array.isArray(R.buyUses)&&R.buyUses.length>0,z=q&&Array.isArray(R.buyUses)&&R.buyUses[G];return s(i,{children:o(m,Object.assign({className:f("flex flex-col gap-5 w-full",y)},{children:[o("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:C.secondary}},{children:[o("div",Object.assign({className:"flex gap-3 items-start"},{children:[s(d,{className:f("h-5 w-5 shrink-0 mt-0.5",v),style:{color:C.accent}}),s(p,{className:f($.b2,"font-semibold leading-relaxed text-sm",j),style:{color:C.text},html:R.limitMessage||""})]})),T&&s(u,Object.assign({variant:"primary",className:"whitespace-nowrap min-h-[32px] w-full sm:w-auto text-sm",onClick:()=>e(void 0,void 0,void 0,(function*(){if(n()){if(!_)return L(T||null),void A("login_required");window.open(T)}else window.location.href=`${T}?redirectUrl=${document.URL}`}))},{children:P}))]})),B&&o("div",Object.assign({className:"flex flex-col gap-2"},{children:[s("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:C.text}},{children:"Available Plans"})),s("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-4 pt-1 snap-x scrollbar-thin"},{children:null===(w=R.upgradeGroups)||void 0===w?void 0:w.map(((e,o)=>s(g,{data:e},e.accessGroupId||o)))}))]})),q&&z&&o("div",Object.assign({className:"flex flex-col gap-3"},{children:[s("h3",Object.assign({className:"text-xs font-bold opacity-70 uppercase px-1",style:{color:C.text}},{children:"Buy Credits"})),s("div",Object.assign({className:"flex flex-row gap-3 overflow-x-auto pb-2 pt-1 snap-x scrollbar-thin"},{children:null===(k=R.buyUses)||void 0===k?void 0:k.map(((e,o)=>s(h,{price:e.price,uses:e.uses,isSelected:o===G,onClick:()=>I(o),colors:C},o)))})),o(u,Object.assign({variant:"primary",className:"w-full py-3 text-sm font-bold shadow-md",onClick:()=>e(void 0,void 0,void 0,(function*(){var s,o;_?(s=z.uses,o=z.price,e(void 0,void 0,void 0,(function*(){try{const e=yield x.post("/get_extra_usage_payment_link",{data:{sender:U||void 0,studioSessionToken:_,studioId:null==N?void 0:N.studioid,cost:o,isEmbed:n(),extraUses:s,successUrl:document.URL}}),{success:t,url:r,clientSecret:i,stripeAccountId:a,error:l}=e.data;t?n()?i&&a?(S(a),O(i),A("stripe_checkout")):r&&window.open(r,"_blank"):r&&(window.location.href=r):alert(l)}catch(e){alert(e)}}))):n()?(L(T||null),A("login_required")):window.location.href=`${T}?redirectUrl=${document.URL}`}))},{children:["Buy ",z.uses.toLocaleString()," Uses for $",z.price]}))]}))]}))})};export{y as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as s,jsxs as t}from"react/jsx-runtime";import{usePickaxe as
|
|
1
|
+
import{__awaiter as e}from"../../_virtual/_tslib.js";import{jsx as s,jsxs as t}from"react/jsx-runtime";import{usePickaxe as o}from"../../hooks/pickaxe/usePickaxe.js";import{useState as i,useMemo as a,useEffect as r}from"react";import{usePickaxeContext as c}from"../../hooks/pickaxe/usePickaxeContext.js";import{useAuthContext as l}from"./Addons/Auth/hooks/useAuthContext.js";import{useResponseContext as n}from"../../hooks/pickaxe/useResponseContext.js";import{useDocumentContext as d}from"./Addons/Document/hooks/useDocumentContext.js";import{useArtifactContext as m}from"./Addons/Artifact/hooks/useArtifactContext.js";import{v4 as u}from"uuid";import{ScrollProvider as p}from"./Addons/Scroll/Provider.js";import f from"./common/PickaxeSkeleton.js";import x from"./Chat/index.js";import h from"./Form/index.js";import g from"./Addons/Auth/index.js";import j from"../../common/cn.js";import v from"../../common/api/pickaxe.js";import b from"./common/AccessGroupCardPreview.js";import{Avatar as y,AvatarImage as k,AvatarFallback as w}from"./common/PickaxeAvatar.js";import N from"../Icons/lock.svg.js";import{EmbeddedCheckoutProvider as O,EmbeddedCheckout as _}from"../../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";import{loadStripe as I}from"../../node_modules/.pnpm/@stripe_stripe-js@7.9.0/node_modules/@stripe/stripe-js/dist/index.mjs.js";const A=({className:e})=>s("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("polyline",{points:"15 18 9 12 15 6"})})),C=({pickaxeId:C,className:S})=>{const{sessionId:q,styles:P,colors:L,responsiveBy:T,deploymentType:R,isNewChat:E,isEmbed:D,opacity:G,deploymentId:U,sender:B,portalId:$,validationStatus:F,stripeAccountId:M,clientSecret:W,setClientSecret:z,setStripeAccountId:H,setValidationStatus:J,setContextId:K,setPickaxeId:V,setSessionId:X,setPickaxe:Y}=c(),{isSent:Q,token:Z}=l(),{setMessages:ee,setResponse:se,setError:te,setLimitData:oe,setIsSwitchedToChat:ie}=n(),{setDocumentError:ae}=d(),{setCurrentArtifact:re}=m(),[ce,le]=i(!1),[ne,de]=i([]),[me,ue]=i(null),pe=o(),fe="chat-input"===R&&E&&!Q,xe=a((()=>M?I(process.env.NEXT_PUBLIC_STRIPE_KEY,{stripeAccount:M}):null),[M]);r((()=>{V(C)}),[C]);r((()=>{if(!U&&!$||!pe.data)return;if("stripe_checkout"===F)return;e(void 0,void 0,void 0,(function*(){var e;J("loading");try{const s=yield v.post("/validate_studio_deployment",{data:{deploymentId:U,sender:B||void 0,studioSessionToken:Z,portalId:$,studioId:null===(e=pe.data)||void 0===e?void 0:e.studioid}});s.data.success?J("success"):"Login required."===s.data.message?(J("login_required"),le(!0)):"Access denied."===s.data.message?(J("access_denied"),de(s.data.upgradeGroups||[]),le(!0)):"Upgrade required."===s.data.message?(J("upgrade_required"),de(s.data.upgradeGroups||[]),ue(s.data.upgradeUrl),le(!0)):J("login_required")}catch(e){console.error("Failed to validate deployment:",e),J("success")}}))}),[U,B,Z,$,pe.data]),r((()=>{if(!pe.data)return;const e=pe.data.chatflag;X(e?u():""),K(u()),e?ee([]):se(null),te(""),ae(""),oe(null),re(null),ie(!1),Y(pe.data),le(!0)}),[pe.data]),r((()=>{te(""),ae(""),oe(null),ee([]),se(null),re(null)}),[q]);const he=a((()=>{const e=null!=G?G:1;if(!L.primary||!L.primary.startsWith("#")||e<0||e>1)return L.primary;const s=Math.round(255*e).toString(16).padStart(2,"0");return`${L.primary}${s}`}),[L.primary,G]);if(!pe.data)return null;return s("div",Object.assign({className:j("relative @container/pickaxe-root flex flex-col flex-grow w-full h-full","dark"===P.theme&&"dark",S),style:Object.assign({backgroundColor:fe?"transparent":he,color:L.text},P.font&&"Real Head Pro"!==P.font&&{fontFamily:P.font})},{children:"stripe_checkout"===F&&W&&xe?t("div",Object.assign({className:"absolute inset-0 z-[999] flex flex-col w-full h-full overflow-hidden",style:{backgroundColor:L.secondary||"#ffffff",color:L.secondaryText||"#000000"}},{children:[s("div",Object.assign({className:"flex items-center p-4 border-b border-gray-100 shrink-0"},{children:t("button",Object.assign({onClick:()=>{z&&z(null),H&&H(null),J("success")},className:"flex items-center gap-2 text-sm font-semibold opacity-70 hover:opacity-100 transition-opacity",style:{color:L.text}},{children:[s(A,{className:"w-5 h-5"}),s("span",{children:"Back"})]}))})),s("div",Object.assign({className:"flex-1 w-full h-full overflow-y-auto [&>div]:h-full"},{children:s(O,Object.assign({stripe:xe,options:{clientSecret:W}},{children:s(_,{})}))}))]})):pe.isLoading||!ce||"loading"===F?s("div",Object.assign({className:j("flex items-center flex-col w-full pt-12 px-4 pb-10","viewport"===T?"min-[767px]:pb-40":"@[767px]/pickaxe-root:pb-40")},{children:t("div",Object.assign({className:"flex w-full items-center max-w-[700px] flex-col"},{children:[s(f,{className:"w-[72px] h-[72px]"}),s(f,{className:"h-[20px] mt-6 w-full"}),s(f,{className:"h-[20px] mt-2 w-full"}),s(f,{className:"h-[20px] mt-2 w-full max-w-[400px]"}),s("div",Object.assign({className:"flex flex-col gap-y-8 w-full mt-6"},{children:s(f,{className:j("w-full min-h-[48px]","viewport"===T?"min-[767px]:max-w-[176px]":"@[767px]/pickaxe-root:max-w-[176px]")})}))]}))})):"upgrade_required"===F?s("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:ne&&ne.length>0?t("div",Object.assign({className:"flex flex-col items-center gap-6 w-full max-w-4xl"},{children:[t("div",Object.assign({className:"text-center"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Upgrade Required"})),s("p",Object.assign({className:"opacity-80"},{children:"Please upgrade to continue using this tool."}))]})),s("div",Object.assign({className:"flex flex-wrap justify-center gap-4 w-full"},{children:ne.map(((e,t)=>s(b,{data:e,upgradeUrl:me},e.id||t)))}))]})):t("div",Object.assign({className:"text-center mb-8"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Locked"})),s("p",Object.assign({className:"opacity-80"},{children:"This tool is locked to use. Contact owner for more information."}))]}))})):"login_required"===F&&D?s(g,{}):"login_required"!==F||D?"access_denied"===F?t("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:[t(y,Object.assign({className:"h-[68px] w-[68px] mb-4"},{children:[s(k,{src:null===(ge=pe.data)||void 0===ge?void 0:ge.coverphoto,alt:`${null===(je=pe.data)||void 0===je?void 0:je.formtitle} Logo`}),s(w,{})]})),t("div",Object.assign({className:"text-center mb-6"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),t("div",Object.assign({className:"w-[400px] text-xl flex justify-center items-start"},{children:[s(N,{className:"h-6 w-6 mr-[-20px] shrink-0"}),s("p",Object.assign({className:"ml-1"},{children:"It looks like you don't have access to these resources. Please request access to continue."}))]}))]})),s("button",Object.assign({className:"px-6 py-2 font-medium rounded-md transition-colors",style:{backgroundColor:L.accent,color:L.accentText,borderRadius:P.cornerRadius},onClick:()=>{e(void 0,void 0,void 0,(function*(){var e,s;const t=ne.map((e=>e.accessGroupId));try{const o=yield v.post("/request_access",{data:{sender:B||void 0,studioSessionToken:Z,studioId:null===(e=pe.data)||void 0===e?void 0:e.studioid,message:JSON.stringify({toolId:null===(s=pe.data)||void 0===s?void 0:s.formid,deploymentId:U,accessGroupIds:t})}});o.data.success?alert("Successfully requested access!"):alert(o.data.error)}catch(e){alert(`Couldn't request access. Error: ${e}`)}}))}},{children:"Request Access"})),s("span",Object.assign({className:"mt-4 mb-2"},{children:"or"})),s("span",Object.assign({className:"font-medium text-lg"},{children:"Sign in with a different account"}))]})):s(p,q?{children:s(x,{})}:{children:s(h,{})}):s("div",Object.assign({className:"flex flex-col items-center justify-center w-full h-full p-4 overflow-y-auto"},{children:t("div",Object.assign({className:"text-center mb-8"},{children:[s("h2",Object.assign({className:"text-2xl font-bold mb-2"},{children:"Access Denied"})),s("p",Object.assign({className:"opacity-80"},{children:"Login is required."}))]}))}))}));var ge,je};export{C as Pickaxe};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e from"react";import t from"../../../../../prop-types@15.8.1/node_modules/prop-types/index.js";function n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function r(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?n(Object(r),!0).forEach((function(t){c(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function c(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function u(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},c=Object.keys(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(r=0;r<c.length;r++)n=c[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var r,o,c=[],u=!0,i=!1;try{for(n=n.call(e);!(u=(r=n.next()).done)&&(c.push(r.value),!t||c.length!==t);u=!0);}catch(e){i=!0,o=e}finally{try{u||null==n.return||n.return()}finally{if(i)throw o}}return c}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return a(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var s=function(t,n,r){var o=!!r,c=e.useRef(r);e.useEffect((function(){c.current=r}),[r]),e.useEffect((function(){if(!o||!t)return function(){};var e=function(){c.current&&c.current.apply(c,arguments)};return t.on(n,e),function(){t.off(n,e)}}),[o,n,t,c])},l=function(t){var n=e.useRef(t);return e.useEffect((function(){n.current=t}),[t]),n.current},p=function(e){return null!==e&&"object"===o(e)},d="[object Object]",f=function e(t,n){if(!p(t)||!p(n))return t===n;var r=Array.isArray(t);if(r!==Array.isArray(n))return!1;var o=Object.prototype.toString.call(t)===d;if(o!==(Object.prototype.toString.call(n)===d))return!1;if(!o&&!r)return t===n;var c=Object.keys(t),u=Object.keys(n);if(c.length!==u.length)return!1;for(var i={},a=0;a<c.length;a+=1)i[c[a]]=!0;for(var s=0;s<u.length;s+=1)i[u[s]]=!0;var l=Object.keys(i);if(l.length!==c.length)return!1;var f=t,m=n;return l.every((function(t){return e(f[t],m[t])}))},m=function(e,t,n){return p(e)?Object.keys(e).reduce((function(o,u){var i=!p(t)||!f(e[u],t[u]);return n.includes(u)?(i&&console.warn("Unsupported prop change: options.".concat(u," is not a mutable property.")),o):i?r(r({},o||{}),{},c({},u,e[u])):o}),null):null},h="Invalid prop `stripe` supplied to `Elements`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.",y=function(e){var t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h;if(null===e||p(t=e)&&"function"==typeof t.elements&&"function"==typeof t.createToken&&"function"==typeof t.createPaymentMethod&&"function"==typeof t.confirmCardPayment)return e;throw new Error(n)},g=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h;if(function(e){return p(e)&&"function"==typeof e.then}(e))return{tag:"async",stripePromise:Promise.resolve(e).then((function(e){return y(e,t)}))};var n=y(e,t);return null===n?{tag:"empty"}:{tag:"sync",stripe:n}},v=e.createContext(null);v.displayName="ElementsContext";t.any,t.object,t.func.isRequired;var b=e.createContext(null);b.displayName="CheckoutContext",t.any,t.shape({fetchClientSecret:t.func.isRequired,elementsOptions:t.object}).isRequired;var C=function(t){var n=e.useContext(b),r=e.useContext(v);if(n){if(r)throw new Error("You cannot wrap the part of your app that ".concat(t," in both <CheckoutProvider> and <Elements> providers."));return n}return function(e,t){if(!e)throw new Error("Could not find Elements context; You need to wrap the part of your app that ".concat(t," in an <Elements> provider."));return e}(r,t)},E=["mode"],k=function(n,r){var o,c="".concat((o=n).charAt(0).toUpperCase()+o.slice(1),"Element"),a=r?function(t){C("mounts <".concat(c,">"));var n=t.id,r=t.className;return e.createElement("div",{id:n,className:r})}:function(t){var r,o=t.id,a=t.className,p=t.options,d=void 0===p?{}:p,f=t.onBlur,h=t.onFocus,y=t.onReady,g=t.onChange,v=t.onEscape,b=t.onClick,k=t.onLoadError,S=t.onLoaderStart,w=t.onNetworksChange,j=t.onConfirm,P=t.onCancel,O=t.onShippingAddressChange,x=t.onShippingRateChange,A=t.onSavedPaymentMethodRemove,R=t.onSavedPaymentMethodUpdate,I=C("mounts <".concat(c,">")),N="elements"in I?I.elements:null,U="checkoutState"in I?I.checkoutState:null,Y="success"===(null==U?void 0:U.type)?U.checkout:null,L=i(e.useState(null),2),M=L[0],B=L[1],D=e.useRef(null),q=e.useRef(null);s(M,"blur",f),s(M,"focus",h),s(M,"escape",v),s(M,"click",b),s(M,"loaderror",k),s(M,"loaderstart",S),s(M,"networkschange",w),s(M,"confirm",j),s(M,"cancel",P),s(M,"shippingaddresschange",O),s(M,"shippingratechange",x),s(M,"savedpaymentmethodremove",A),s(M,"savedpaymentmethodupdate",R),s(M,"change",g),y&&(r="expressCheckout"===n?y:function(){y(M)}),s(M,"ready",r),e.useLayoutEffect((function(){if(null===D.current&&null!==q.current&&(N||Y)){var e=null;if(Y)switch(n){case"payment":e=Y.createPaymentElement(d);break;case"address":if(!("mode"in d))throw new Error("You must supply options.mode. mode must be 'billing' or 'shipping'.");var t=d.mode,r=u(d,E);if("shipping"===t)e=Y.createShippingAddressElement(r);else{if("billing"!==t)throw new Error("Invalid options.mode. mode must be 'billing' or 'shipping'.");e=Y.createBillingAddressElement(r)}break;case"expressCheckout":e=Y.createExpressCheckoutElement(d);break;case"currencySelector":e=Y.createCurrencySelectorElement();break;case"taxId":e=Y.createTaxIdElement(d);break;default:throw new Error("Invalid Element type ".concat(c,". You must use either the <PaymentElement />, <AddressElement options={{mode: 'shipping'}} />, <AddressElement options={{mode: 'billing'}} />, or <ExpressCheckoutElement />."))}else N&&(e=N.create(n,d));D.current=e,B(e),e&&e.mount(q.current)}}),[N,Y,d]);var T=l(d);return e.useEffect((function(){if(D.current){var e=m(d,T,["paymentRequest"]);e&&"update"in D.current&&D.current.update(e)}}),[d,T]),e.useLayoutEffect((function(){return function(){if(D.current&&"function"==typeof D.current.destroy)try{D.current.destroy(),D.current=null}catch(e){}}}),[]),e.createElement("div",{id:o,className:a,ref:q})};return a.propTypes={id:t.string,className:t.string,onChange:t.func,onBlur:t.func,onFocus:t.func,onReady:t.func,onEscape:t.func,onClick:t.func,onLoadError:t.func,onLoaderStart:t.func,onNetworksChange:t.func,onConfirm:t.func,onCancel:t.func,onShippingAddressChange:t.func,onShippingRateChange:t.func,onSavedPaymentMethodRemove:t.func,onSavedPaymentMethodUpdate:t.func,options:t.object},a.displayName=c,a.__elementType=n,a},S="undefined"==typeof window,w=e.createContext(null);w.displayName="EmbeddedCheckoutProviderContext";var j=function(){var t=e.useContext(w);if(!t)throw new Error("<EmbeddedCheckout> must be used within <EmbeddedCheckoutProvider>");return t},P=function(t){var n=t.stripe,r=t.options,o=t.children,c=e.useMemo((function(){return g(n,"Invalid prop `stripe` supplied to `EmbeddedCheckoutProvider`. We recommend using the `loadStripe` utility from `@stripe/stripe-js`. See https://stripe.com/docs/stripe-js/react#elements-props-stripe for details.")}),[n]),u=e.useRef(null),a=e.useRef(null),s=i(e.useState({embeddedCheckout:null}),2),p=s[0],d=s[1];e.useEffect((function(){if(!a.current&&!u.current){var e=function(e){a.current||u.current||(a.current=e,u.current=a.current.initEmbeddedCheckout(r).then((function(e){d({embeddedCheckout:e})})))};"async"!==c.tag||a.current||!r.clientSecret&&!r.fetchClientSecret?"sync"!==c.tag||a.current||!r.clientSecret&&!r.fetchClientSecret||e(c.stripe):c.stripePromise.then((function(t){t&&e(t)}))}}),[c,r,p,a]),e.useEffect((function(){return function(){p.embeddedCheckout?(u.current=null,p.embeddedCheckout.destroy()):u.current&&u.current.then((function(){u.current=null,p.embeddedCheckout&&p.embeddedCheckout.destroy()}))}}),[p.embeddedCheckout]),e.useEffect((function(){var e;(e=a)&&e._registerWrapper&&e.registerAppInfo&&(e._registerWrapper({name:"react-stripe-js",version:"4.0.2"}),e.registerAppInfo({name:"react-stripe-js",version:"4.0.2",url:"https://stripe.com/docs/stripe-js/react"}))}),[a]);var f=l(n);e.useEffect((function(){null!==f&&f!==n&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the `stripe` prop after setting it.")}),[f,n]);var m=l(r);return e.useEffect((function(){null!=m&&(null!=r?(void 0===r.clientSecret&&void 0===r.fetchClientSecret&&console.warn("Invalid props passed to EmbeddedCheckoutProvider: You must provide one of either `options.fetchClientSecret` or `options.clientSecret`."),null!=m.clientSecret&&r.clientSecret!==m.clientSecret&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the client secret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead."),null!=m.fetchClientSecret&&r.fetchClientSecret!==m.fetchClientSecret&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change fetchClientSecret after setting it. Unmount and create a new instance of EmbeddedCheckoutProvider instead."),null!=m.onComplete&&r.onComplete!==m.onComplete&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onComplete option after setting it."),null!=m.onShippingDetailsChange&&r.onShippingDetailsChange!==m.onShippingDetailsChange&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onShippingDetailsChange option after setting it."),null!=m.onLineItemsChange&&r.onLineItemsChange!==m.onLineItemsChange&&console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot change the onLineItemsChange option after setting it.")):console.warn("Unsupported prop change on EmbeddedCheckoutProvider: You cannot unset options after setting them."))}),[m,r]),e.createElement(w.Provider,{value:p},o)},O=S?function(t){var n=t.id,r=t.className;return j(),e.createElement("div",{id:n,className:r})}:function(t){var n=t.id,r=t.className,o=j().embeddedCheckout,c=e.useRef(!1),u=e.useRef(null);return e.useLayoutEffect((function(){return!c.current&&o&&null!==u.current&&(o.mount(u.current),c.current=!0),function(){if(c.current&&o)try{o.unmount(),c.current=!1}catch(e){}}}),[o]),e.createElement("div",{ref:u,id:n,className:r})};k("auBankAccount",S),k("card",S),k("cardNumber",S),k("cardExpiry",S),k("cardCvc",S),k("fpxBank",S),k("iban",S),k("idealBank",S),k("p24Bank",S),k("epsBank",S),k("payment",S),k("expressCheckout",S),k("paymentRequestButton",S),k("linkAuthentication",S),k("address",S),k("shippingAddress",S),k("paymentMethodMessaging",S),k("affirmMessage",S),k("afterpayClearpayMessage",S),k("taxId",S);export{O as EmbeddedCheckout,P as EmbeddedCheckoutProvider};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e,r="basil",n="https://js.stripe.com",t="".concat(n,"/").concat(r,"/stripe.js"),o=/^https:\/\/js\.stripe\.com\/v3\/?(\?.*)?$/,i=/^https:\/\/js\.stripe\.com\/(v3|[a-z]+)\/stripe\.js(\?.*)?$/,s="loadStripe.setLoadParameters was called but an existing Stripe.js script already exists in the document; existing script parameters will be used",a=function(e){var r=e&&!e.advancedFraudSignals?"?advancedFraudSignals=false":"",n=document.createElement("script");n.src="".concat(t).concat(r);var o=document.head||document.body;if(!o)throw new Error("Expected document.body not to be null. Stripe.js requires a <body> element.");return o.appendChild(n),n},c=null,u=null,l=null,d=function(e){return null!==c?c:(c=new Promise((function(r,t){if("undefined"!=typeof window&&"undefined"!=typeof document)if(window.Stripe&&e&&console.warn(s),window.Stripe)r(window.Stripe);else try{var c=function(){for(var e,r=document.querySelectorAll('script[src^="'.concat(n,'"]')),t=0;t<r.length;t++){var s=r[t];if(e=s.src,o.test(e)||i.test(e))return s}return null}();if(c&&e)console.warn(s);else if(c){if(c&&null!==l&&null!==u){var d;c.removeEventListener("load",l),c.removeEventListener("error",u),null===(d=c.parentNode)||void 0===d||d.removeChild(c),c=a(e)}}else c=a(e);l=function(e,r){return function(){window.Stripe?e(window.Stripe):r(new Error("Stripe.js not available"))}}(r,t),u=function(e){return function(r){e(new Error("Failed to load Stripe.js",{cause:r}))}}(t),c.addEventListener("load",l),c.addEventListener("error",u)}catch(e){return void t(e)}else r(null)}))).catch((function(e){return c=null,Promise.reject(e)}))},p=!1,f=function(){return e||(e=d(null).catch((function(r){return e=null,Promise.reject(r)})))};Promise.resolve().then((function(){return f()})).catch((function(e){p||console.warn(e)}));var v=function(){for(var e=arguments.length,n=new Array(e),t=0;t<e;t++)n[t]=arguments[t];p=!0;var o=Date.now();return f().then((function(e){return function(e,n,t){if(null===e)return null;var o=n[0].match(/^pk_test/),i=function(e){return 3===e?"v3":e}(e.version),s=r;o&&i!==s&&console.warn("Stripe.js@".concat(i," was loaded on the page, but @stripe/stripe-js@").concat("7.9.0"," expected Stripe.js@").concat(s,". This may result in unexpected behavior. For more information, see https://docs.stripe.com/sdks/stripejs-versioning"));var a=e.apply(void 0,n);return function(e,r){e&&e._registerWrapper&&e._registerWrapper({name:"stripe-js",version:"7.9.0",startTime:r})}(a,t),a}(e,n,o)}))};export{v as loadStripe};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{commonjsGlobal as t}from"../../../../../_virtual/_commonjsHelpers.js";import{__module as e}from"../../../../../_virtual/cose-base2.js";import{__require as r}from"../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js";var i;function o(){return i||(i=1,t=e,e.exports,o=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}])},t.exports=o(r())),e.exports;var t,o}e.exports;export{o as __require};
|
|
1
|
+
import{commonjsGlobal as t}from"../../../../../_virtual/_commonjsHelpers.js";import{__module as e}from"../../../../../_virtual/cose-base.js";import{__require as r}from"../../../layout-base@1.0.2/node_modules/layout-base/layout-base.js";var i;function o(){return i||(i=1,t=e,e.exports,o=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}])},t.exports=o(r())),e.exports;var t,o}e.exports;export{o as __require};
|