markdown-flow-ui 0.2.2 → 0.2.3-dev.2
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/components/Slide/Slide.cjs.js +1 -1
- package/dist/components/Slide/Slide.cjs.js.map +1 -1
- package/dist/components/Slide/Slide.es.js +631 -590
- package/dist/components/Slide/Slide.es.js.map +1 -1
- package/dist/components/Slide/utils/interactionPlayback.cjs.js +1 -1
- package/dist/components/Slide/utils/interactionPlayback.cjs.js.map +1 -1
- package/dist/components/Slide/utils/interactionPlayback.d.ts +9 -0
- package/dist/components/Slide/utils/interactionPlayback.es.js +10 -2
- package/dist/components/Slide/utils/interactionPlayback.es.js.map +1 -1
- package/dist/components/Slide/utils/interactionResolution.cjs.js +2 -0
- package/dist/components/Slide/utils/interactionResolution.cjs.js.map +1 -0
- package/dist/components/Slide/utils/interactionResolution.d.ts +13 -0
- package/dist/components/Slide/utils/interactionResolution.es.js +33 -0
- package/dist/components/Slide/utils/interactionResolution.es.js.map +1 -0
- package/dist/components/Slide/utils/interactionResolution.test.d.ts +1 -0
- package/dist/components/Slide/utils/streamingNavigation.cjs.js +1 -1
- package/dist/components/Slide/utils/streamingNavigation.cjs.js.map +1 -1
- package/dist/components/Slide/utils/streamingNavigation.es.js +15 -9
- package/dist/components/Slide/utils/streamingNavigation.es.js.map +1 -1
- package/dist/node_modules/cose-base/cose-base.cjs.js +1 -1
- package/dist/node_modules/cose-base/cose-base.cjs.js.map +1 -1
- package/dist/node_modules/cose-base/cose-base.es.js +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/cose-base/cose-base.cjs.js +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/cose-base/cose-base.cjs.js.map +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/cose-base/cose-base.es.js +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/layout-base/layout-base.cjs.js +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/layout-base/layout-base.cjs.js.map +1 -1
- package/dist/node_modules/cytoscape-fcose/node_modules/layout-base/layout-base.es.js +1 -1
- package/dist/node_modules/layout-base/layout-base.cjs.js +1 -1
- package/dist/node_modules/layout-base/layout-base.cjs.js.map +1 -1
- package/dist/node_modules/layout-base/layout-base.es.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactionResolution.cjs.js","sources":["../../../../src/components/Slide/utils/interactionResolution.ts"],"sourcesContent":["import {\n getInteractionDefaultSelectedValues,\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../../lib/interaction-defaults\";\nimport type { Element } from \"../types\";\n\ninterface ResolveSlideInteractionStateOptions {\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n}\n\nexport const resolveSlideInteractionState = (\n activeInteractionElement?: Element,\n options: ResolveSlideInteractionStateOptions = {}\n) => {\n const { interactionDefaultValueOptions } = options;\n if (!activeInteractionElement) {\n return {\n interactionDefaults: {},\n interactionDefaultSelectedValues: undefined,\n hasResolvedInteractionInput: false,\n isInteractionReadonly: false,\n shouldAutoContinueInteraction: false,\n };\n }\n\n const interactionContent =\n typeof activeInteractionElement.content === \"string\"\n ? activeInteractionElement.content\n : undefined;\n const hasResolvedInteractionInput = Boolean(\n activeInteractionElement.user_input?.trim()\n );\n const effectiveDefaultValueOptions = hasResolvedInteractionInput\n ? undefined\n : interactionDefaultValueOptions;\n\n return {\n interactionDefaults: getInteractionDefaultValues(\n interactionContent,\n activeInteractionElement.user_input,\n effectiveDefaultValueOptions\n ),\n interactionDefaultSelectedValues: getInteractionDefaultSelectedValues(\n interactionContent,\n activeInteractionElement.user_input,\n effectiveDefaultValueOptions\n ),\n hasResolvedInteractionInput,\n isInteractionReadonly: Boolean(activeInteractionElement.readonly),\n // Keep auto-continue only for passive markers that are explicitly readonly.\n shouldAutoContinueInteraction: Boolean(activeInteractionElement.readonly),\n };\n};\n"],"names":["resolveSlideInteractionState","activeInteractionElement","options","interactionDefaultValueOptions","interactionContent","hasResolvedInteractionInput","effectiveDefaultValueOptions","getInteractionDefaultValues","getInteractionDefaultSelectedValues"],"mappings":"4IAWaA,EAA+B,CAC1CC,EACAC,EAA+C,KAC5C,CACH,KAAM,CAAE,+BAAAC,GAAmCD,EAC3C,GAAI,CAACD,EACH,MAAO,CACL,oBAAqB,CAAA,EACrB,iCAAkC,OAClC,4BAA6B,GAC7B,sBAAuB,GACvB,8BAA+B,EAAA,EAInC,MAAMG,EACJ,OAAOH,EAAyB,SAAY,SACxCA,EAAyB,QACzB,OACAI,EAA8B,EAClCJ,EAAyB,YAAY,KAAA,EAEjCK,EAA+BD,EACjC,OACAF,EAEJ,MAAO,CACL,oBAAqBI,EAAAA,4BACnBH,EACAH,EAAyB,WACzBK,CAAA,EAEF,iCAAkCE,EAAAA,oCAChCJ,EACAH,EAAyB,WACzBK,CAAA,EAEF,4BAAAD,EACA,sBAAuB,EAAQJ,EAAyB,SAExD,8BAA+B,EAAQA,EAAyB,QAAQ,CAE5E"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InteractionDefaultValueOptions } from '../../../lib/interaction-defaults';
|
|
2
|
+
import { Element } from '../types';
|
|
3
|
+
interface ResolveSlideInteractionStateOptions {
|
|
4
|
+
interactionDefaultValueOptions?: InteractionDefaultValueOptions;
|
|
5
|
+
}
|
|
6
|
+
export declare const resolveSlideInteractionState: (activeInteractionElement?: Element, options?: ResolveSlideInteractionStateOptions) => {
|
|
7
|
+
interactionDefaults: import('..').InteractionDefaultValues;
|
|
8
|
+
interactionDefaultSelectedValues: string[] | undefined;
|
|
9
|
+
hasResolvedInteractionInput: boolean;
|
|
10
|
+
isInteractionReadonly: boolean;
|
|
11
|
+
shouldAutoContinueInteraction: boolean;
|
|
12
|
+
};
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getInteractionDefaultSelectedValues as a, getInteractionDefaultValues as l } from "../../../lib/interaction-defaults.es.js";
|
|
2
|
+
const r = (t, u = {}) => {
|
|
3
|
+
const { interactionDefaultValueOptions: s } = u;
|
|
4
|
+
if (!t)
|
|
5
|
+
return {
|
|
6
|
+
interactionDefaults: {},
|
|
7
|
+
interactionDefaultSelectedValues: void 0,
|
|
8
|
+
hasResolvedInteractionInput: !1,
|
|
9
|
+
isInteractionReadonly: !1,
|
|
10
|
+
shouldAutoContinueInteraction: !1
|
|
11
|
+
};
|
|
12
|
+
const e = typeof t.content == "string" ? t.content : void 0, o = !!t.user_input?.trim(), n = o ? void 0 : s;
|
|
13
|
+
return {
|
|
14
|
+
interactionDefaults: l(
|
|
15
|
+
e,
|
|
16
|
+
t.user_input,
|
|
17
|
+
n
|
|
18
|
+
),
|
|
19
|
+
interactionDefaultSelectedValues: a(
|
|
20
|
+
e,
|
|
21
|
+
t.user_input,
|
|
22
|
+
n
|
|
23
|
+
),
|
|
24
|
+
hasResolvedInteractionInput: o,
|
|
25
|
+
isInteractionReadonly: !!t.readonly,
|
|
26
|
+
// Keep auto-continue only for passive markers that are explicitly readonly.
|
|
27
|
+
shouldAutoContinueInteraction: !!t.readonly
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
r as resolveSlideInteractionState
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=interactionResolution.es.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactionResolution.es.js","sources":["../../../../src/components/Slide/utils/interactionResolution.ts"],"sourcesContent":["import {\n getInteractionDefaultSelectedValues,\n getInteractionDefaultValues,\n type InteractionDefaultValueOptions,\n} from \"../../../lib/interaction-defaults\";\nimport type { Element } from \"../types\";\n\ninterface ResolveSlideInteractionStateOptions {\n interactionDefaultValueOptions?: InteractionDefaultValueOptions;\n}\n\nexport const resolveSlideInteractionState = (\n activeInteractionElement?: Element,\n options: ResolveSlideInteractionStateOptions = {}\n) => {\n const { interactionDefaultValueOptions } = options;\n if (!activeInteractionElement) {\n return {\n interactionDefaults: {},\n interactionDefaultSelectedValues: undefined,\n hasResolvedInteractionInput: false,\n isInteractionReadonly: false,\n shouldAutoContinueInteraction: false,\n };\n }\n\n const interactionContent =\n typeof activeInteractionElement.content === \"string\"\n ? activeInteractionElement.content\n : undefined;\n const hasResolvedInteractionInput = Boolean(\n activeInteractionElement.user_input?.trim()\n );\n const effectiveDefaultValueOptions = hasResolvedInteractionInput\n ? undefined\n : interactionDefaultValueOptions;\n\n return {\n interactionDefaults: getInteractionDefaultValues(\n interactionContent,\n activeInteractionElement.user_input,\n effectiveDefaultValueOptions\n ),\n interactionDefaultSelectedValues: getInteractionDefaultSelectedValues(\n interactionContent,\n activeInteractionElement.user_input,\n effectiveDefaultValueOptions\n ),\n hasResolvedInteractionInput,\n isInteractionReadonly: Boolean(activeInteractionElement.readonly),\n // Keep auto-continue only for passive markers that are explicitly readonly.\n shouldAutoContinueInteraction: Boolean(activeInteractionElement.readonly),\n };\n};\n"],"names":["resolveSlideInteractionState","activeInteractionElement","options","interactionDefaultValueOptions","interactionContent","hasResolvedInteractionInput","effectiveDefaultValueOptions","getInteractionDefaultValues","getInteractionDefaultSelectedValues"],"mappings":";AAWO,MAAMA,IAA+B,CAC1CC,GACAC,IAA+C,OAC5C;AACH,QAAM,EAAE,gCAAAC,MAAmCD;AAC3C,MAAI,CAACD;AACH,WAAO;AAAA,MACL,qBAAqB,CAAA;AAAA,MACrB,kCAAkC;AAAA,MAClC,6BAA6B;AAAA,MAC7B,uBAAuB;AAAA,MACvB,+BAA+B;AAAA,IAAA;AAInC,QAAMG,IACJ,OAAOH,EAAyB,WAAY,WACxCA,EAAyB,UACzB,QACAI,IAA8B,EAClCJ,EAAyB,YAAY,KAAA,GAEjCK,IAA+BD,IACjC,SACAF;AAEJ,SAAO;AAAA,IACL,qBAAqBI;AAAA,MACnBH;AAAA,MACAH,EAAyB;AAAA,MACzBK;AAAA,IAAA;AAAA,IAEF,kCAAkCE;AAAA,MAChCJ;AAAA,MACAH,EAAyB;AAAA,MACzBK;AAAA,IAAA;AAAA,IAEF,6BAAAD;AAAA,IACA,uBAAuB,EAAQJ,EAAyB;AAAA;AAAA,IAExD,+BAA+B,EAAQA,EAAyB;AAAA,EAAQ;AAE5E;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=r=>!!(r?.type==="interaction"&&(r.readonly||r.user_input?.trim())),M=(r,n)=>r.length<=n.length&&r.every((a,c)=>a===n[c]),f=(r,n)=>n.length<=r.length&&n.every((a,c)=>{const h=r[c];return a.type===h?.type&&a.sequence_number===h?.sequence_number&&a.content===h?.content}),k=({previousIndex:r,previousSlideElementList:n,nextSlideElementList:a})=>{if(a.length===0)return-1;const c=a.length>n.length&&M(n,a),h=n.length-1,t=r===h,g=r>=0?n[r]:void 0;return c&&t&&o(g)?n.length:a.length<n.length&&f(n,a)&&a.length>0?Math.min(r,a.length-1):r>=0&&r<a.length?r:-1};exports.resolveNextSlideIndexAfterMarkerAppend=k;
|
|
2
2
|
//# sourceMappingURL=streamingNavigation.cjs.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamingNavigation.cjs.js","sources":["../../../../src/components/Slide/utils/streamingNavigation.ts"],"sourcesContent":["import type { Element } from \"../types\";\n\ninterface ResolveNextSlideIndexParams {\n previousIndex: number;\n previousSlideElementList: Element[];\n nextSlideElementList: Element[];\n}\n\nconst isResolvedInteractionElement = (element?: Element) =>\n Boolean(\n element?.type === \"interaction\" &&\n (element.readonly || element.user_input?.trim())\n );\n\nconst hasStableMarkerPrefix = (\n previousSlideElementList: Element[],\n nextSlideElementList: Element[]\n) =>\n previousSlideElementList.length <= nextSlideElementList.length &&\n previousSlideElementList.every(\n (element, index) => element === nextSlideElementList[index]\n );\n\nexport const resolveNextSlideIndexAfterMarkerAppend = ({\n previousIndex,\n previousSlideElementList,\n nextSlideElementList,\n}: ResolveNextSlideIndexParams) => {\n if (nextSlideElementList.length === 0) {\n return -1;\n }\n\n const hasAppendedMarkers =\n nextSlideElementList.length > previousSlideElementList.length &&\n hasStableMarkerPrefix(previousSlideElementList, nextSlideElementList);\n const previousLastMarkerIndex = previousSlideElementList.length - 1;\n const wasFocusedOnPreviousLastMarker =\n previousIndex === previousLastMarkerIndex;\n const previousCurrentElement =\n previousIndex >= 0 ? previousSlideElementList[previousIndex] : undefined;\n\n // When a resolved interaction is already the terminal step and SSE appends\n // the first follow-up marker, jump into that new marker immediately instead\n // of waiting for the interaction auto-close and silent-step delay.\n if (\n hasAppendedMarkers &&\n wasFocusedOnPreviousLastMarker &&\n isResolvedInteractionElement(previousCurrentElement)\n ) {\n return previousSlideElementList.length;\n }\n\n if (previousIndex >= 0 && previousIndex < nextSlideElementList.length) {\n return previousIndex;\n }\n\n return -1;\n};\n"],"names":["isResolvedInteractionElement","element","hasStableMarkerPrefix","previousSlideElementList","nextSlideElementList","index","resolveNextSlideIndexAfterMarkerAppend","previousIndex","hasAppendedMarkers","previousLastMarkerIndex","wasFocusedOnPreviousLastMarker","previousCurrentElement"],"mappings":"gFAQA,MAAMA,EAAgCC,GACpC,GACEA,GAAS,OAAS,gBACfA,EAAQ,UAAYA,EAAQ,YAAY,KAAA,IAGzCC,EAAwB,CAC5BC,EACAC,IAEAD,EAAyB,QAAUC,EAAqB,QACxDD,EAAyB,MACvB,CAACF,EAASI,IAAUJ,IAAYG,EAAqBC,CAAK,CAC5D,
|
|
1
|
+
{"version":3,"file":"streamingNavigation.cjs.js","sources":["../../../../src/components/Slide/utils/streamingNavigation.ts"],"sourcesContent":["import type { Element } from \"../types\";\n\ninterface ResolveNextSlideIndexParams {\n previousIndex: number;\n previousSlideElementList: Element[];\n nextSlideElementList: Element[];\n}\n\nconst isResolvedInteractionElement = (element?: Element) =>\n Boolean(\n element?.type === \"interaction\" &&\n (element.readonly || element.user_input?.trim())\n );\n\nconst hasStableMarkerPrefix = (\n previousSlideElementList: Element[],\n nextSlideElementList: Element[]\n) =>\n previousSlideElementList.length <= nextSlideElementList.length &&\n previousSlideElementList.every(\n (element, index) => element === nextSlideElementList[index]\n );\n\nconst hasStableMarkerIdentityPrefix = (\n previousSlideElementList: Element[],\n nextSlideElementList: Element[]\n) =>\n nextSlideElementList.length <= previousSlideElementList.length &&\n nextSlideElementList.every((element, index) => {\n const previousElement = previousSlideElementList[index];\n\n return (\n element.type === previousElement?.type &&\n element.sequence_number === previousElement?.sequence_number &&\n element.content === previousElement?.content\n );\n });\n\nexport const resolveNextSlideIndexAfterMarkerAppend = ({\n previousIndex,\n previousSlideElementList,\n nextSlideElementList,\n}: ResolveNextSlideIndexParams) => {\n if (nextSlideElementList.length === 0) {\n return -1;\n }\n\n const hasAppendedMarkers =\n nextSlideElementList.length > previousSlideElementList.length &&\n hasStableMarkerPrefix(previousSlideElementList, nextSlideElementList);\n const previousLastMarkerIndex = previousSlideElementList.length - 1;\n const wasFocusedOnPreviousLastMarker =\n previousIndex === previousLastMarkerIndex;\n const previousCurrentElement =\n previousIndex >= 0 ? previousSlideElementList[previousIndex] : undefined;\n\n // When a resolved interaction is already the terminal step and SSE appends\n // the first follow-up marker, jump into that new marker immediately instead\n // of waiting for the interaction auto-close and silent-step delay.\n if (\n hasAppendedMarkers &&\n wasFocusedOnPreviousLastMarker &&\n isResolvedInteractionElement(previousCurrentElement)\n ) {\n return previousSlideElementList.length;\n }\n\n const hasTruncatedMarkers =\n nextSlideElementList.length < previousSlideElementList.length &&\n hasStableMarkerIdentityPrefix(\n previousSlideElementList,\n nextSlideElementList\n );\n\n if (hasTruncatedMarkers && nextSlideElementList.length > 0) {\n return Math.min(previousIndex, nextSlideElementList.length - 1);\n }\n\n if (previousIndex >= 0 && previousIndex < nextSlideElementList.length) {\n return previousIndex;\n }\n\n return -1;\n};\n"],"names":["isResolvedInteractionElement","element","hasStableMarkerPrefix","previousSlideElementList","nextSlideElementList","index","hasStableMarkerIdentityPrefix","previousElement","resolveNextSlideIndexAfterMarkerAppend","previousIndex","hasAppendedMarkers","previousLastMarkerIndex","wasFocusedOnPreviousLastMarker","previousCurrentElement"],"mappings":"gFAQA,MAAMA,EAAgCC,GACpC,GACEA,GAAS,OAAS,gBACfA,EAAQ,UAAYA,EAAQ,YAAY,KAAA,IAGzCC,EAAwB,CAC5BC,EACAC,IAEAD,EAAyB,QAAUC,EAAqB,QACxDD,EAAyB,MACvB,CAACF,EAASI,IAAUJ,IAAYG,EAAqBC,CAAK,CAC5D,EAEIC,EAAgC,CACpCH,EACAC,IAEAA,EAAqB,QAAUD,EAAyB,QACxDC,EAAqB,MAAM,CAACH,EAASI,IAAU,CAC7C,MAAME,EAAkBJ,EAAyBE,CAAK,EAEtD,OACEJ,EAAQ,OAASM,GAAiB,MAClCN,EAAQ,kBAAoBM,GAAiB,iBAC7CN,EAAQ,UAAYM,GAAiB,OAEzC,CAAC,EAEUC,EAAyC,CAAC,CACrD,cAAAC,EACA,yBAAAN,EACA,qBAAAC,CACF,IAAmC,CACjC,GAAIA,EAAqB,SAAW,EAClC,MAAO,GAGT,MAAMM,EACJN,EAAqB,OAASD,EAAyB,QACvDD,EAAsBC,EAA0BC,CAAoB,EAChEO,EAA0BR,EAAyB,OAAS,EAC5DS,EACJH,IAAkBE,EACdE,EACJJ,GAAiB,EAAIN,EAAyBM,CAAa,EAAI,OAKjE,OACEC,GACAE,GACAZ,EAA6Ba,CAAsB,EAE5CV,EAAyB,OAIhCC,EAAqB,OAASD,EAAyB,QACvDG,EACEH,EACAC,CAAA,GAGuBA,EAAqB,OAAS,EAChD,KAAK,IAAIK,EAAeL,EAAqB,OAAS,CAAC,EAG5DK,GAAiB,GAAKA,EAAgBL,EAAqB,OACtDK,EAGF,EACT"}
|
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
const
|
|
2
|
-
(
|
|
3
|
-
), k = ({
|
|
1
|
+
const t = (r) => !!(r?.type === "interaction" && (r.readonly || r.user_input?.trim())), M = (r, n) => r.length <= n.length && r.every(
|
|
2
|
+
(a, h) => a === n[h]
|
|
3
|
+
), k = (r, n) => n.length <= r.length && n.every((a, h) => {
|
|
4
|
+
const c = r[h];
|
|
5
|
+
return a.type === c?.type && a.sequence_number === c?.sequence_number && a.content === c?.content;
|
|
6
|
+
}), y = ({
|
|
4
7
|
previousIndex: r,
|
|
5
|
-
previousSlideElementList:
|
|
6
|
-
nextSlideElementList:
|
|
8
|
+
previousSlideElementList: n,
|
|
9
|
+
nextSlideElementList: a
|
|
7
10
|
}) => {
|
|
8
|
-
if (
|
|
11
|
+
if (a.length === 0)
|
|
9
12
|
return -1;
|
|
10
|
-
const
|
|
11
|
-
return
|
|
13
|
+
const h = a.length > n.length && M(n, a), c = n.length - 1, g = r === c, o = r >= 0 ? n[r] : void 0;
|
|
14
|
+
return h && g && t(o) ? n.length : a.length < n.length && k(
|
|
15
|
+
n,
|
|
16
|
+
a
|
|
17
|
+
) && a.length > 0 ? Math.min(r, a.length - 1) : r >= 0 && r < a.length ? r : -1;
|
|
12
18
|
};
|
|
13
19
|
export {
|
|
14
|
-
|
|
20
|
+
y as resolveNextSlideIndexAfterMarkerAppend
|
|
15
21
|
};
|
|
16
22
|
//# sourceMappingURL=streamingNavigation.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamingNavigation.es.js","sources":["../../../../src/components/Slide/utils/streamingNavigation.ts"],"sourcesContent":["import type { Element } from \"../types\";\n\ninterface ResolveNextSlideIndexParams {\n previousIndex: number;\n previousSlideElementList: Element[];\n nextSlideElementList: Element[];\n}\n\nconst isResolvedInteractionElement = (element?: Element) =>\n Boolean(\n element?.type === \"interaction\" &&\n (element.readonly || element.user_input?.trim())\n );\n\nconst hasStableMarkerPrefix = (\n previousSlideElementList: Element[],\n nextSlideElementList: Element[]\n) =>\n previousSlideElementList.length <= nextSlideElementList.length &&\n previousSlideElementList.every(\n (element, index) => element === nextSlideElementList[index]\n );\n\nexport const resolveNextSlideIndexAfterMarkerAppend = ({\n previousIndex,\n previousSlideElementList,\n nextSlideElementList,\n}: ResolveNextSlideIndexParams) => {\n if (nextSlideElementList.length === 0) {\n return -1;\n }\n\n const hasAppendedMarkers =\n nextSlideElementList.length > previousSlideElementList.length &&\n hasStableMarkerPrefix(previousSlideElementList, nextSlideElementList);\n const previousLastMarkerIndex = previousSlideElementList.length - 1;\n const wasFocusedOnPreviousLastMarker =\n previousIndex === previousLastMarkerIndex;\n const previousCurrentElement =\n previousIndex >= 0 ? previousSlideElementList[previousIndex] : undefined;\n\n // When a resolved interaction is already the terminal step and SSE appends\n // the first follow-up marker, jump into that new marker immediately instead\n // of waiting for the interaction auto-close and silent-step delay.\n if (\n hasAppendedMarkers &&\n wasFocusedOnPreviousLastMarker &&\n isResolvedInteractionElement(previousCurrentElement)\n ) {\n return previousSlideElementList.length;\n }\n\n if (previousIndex >= 0 && previousIndex < nextSlideElementList.length) {\n return previousIndex;\n }\n\n return -1;\n};\n"],"names":["isResolvedInteractionElement","element","hasStableMarkerPrefix","previousSlideElementList","nextSlideElementList","index","resolveNextSlideIndexAfterMarkerAppend","previousIndex","hasAppendedMarkers","previousLastMarkerIndex","wasFocusedOnPreviousLastMarker","previousCurrentElement"],"mappings":"AAQA,MAAMA,IAA+B,CAACC,MACpC,GACEA,GAAS,SAAS,kBACfA,EAAQ,YAAYA,EAAQ,YAAY,KAAA,KAGzCC,IAAwB,CAC5BC,GACAC,MAEAD,EAAyB,UAAUC,EAAqB,UACxDD,EAAyB;AAAA,EACvB,CAACF,GAASI,MAAUJ,MAAYG,EAAqBC,CAAK;AAC5D,
|
|
1
|
+
{"version":3,"file":"streamingNavigation.es.js","sources":["../../../../src/components/Slide/utils/streamingNavigation.ts"],"sourcesContent":["import type { Element } from \"../types\";\n\ninterface ResolveNextSlideIndexParams {\n previousIndex: number;\n previousSlideElementList: Element[];\n nextSlideElementList: Element[];\n}\n\nconst isResolvedInteractionElement = (element?: Element) =>\n Boolean(\n element?.type === \"interaction\" &&\n (element.readonly || element.user_input?.trim())\n );\n\nconst hasStableMarkerPrefix = (\n previousSlideElementList: Element[],\n nextSlideElementList: Element[]\n) =>\n previousSlideElementList.length <= nextSlideElementList.length &&\n previousSlideElementList.every(\n (element, index) => element === nextSlideElementList[index]\n );\n\nconst hasStableMarkerIdentityPrefix = (\n previousSlideElementList: Element[],\n nextSlideElementList: Element[]\n) =>\n nextSlideElementList.length <= previousSlideElementList.length &&\n nextSlideElementList.every((element, index) => {\n const previousElement = previousSlideElementList[index];\n\n return (\n element.type === previousElement?.type &&\n element.sequence_number === previousElement?.sequence_number &&\n element.content === previousElement?.content\n );\n });\n\nexport const resolveNextSlideIndexAfterMarkerAppend = ({\n previousIndex,\n previousSlideElementList,\n nextSlideElementList,\n}: ResolveNextSlideIndexParams) => {\n if (nextSlideElementList.length === 0) {\n return -1;\n }\n\n const hasAppendedMarkers =\n nextSlideElementList.length > previousSlideElementList.length &&\n hasStableMarkerPrefix(previousSlideElementList, nextSlideElementList);\n const previousLastMarkerIndex = previousSlideElementList.length - 1;\n const wasFocusedOnPreviousLastMarker =\n previousIndex === previousLastMarkerIndex;\n const previousCurrentElement =\n previousIndex >= 0 ? previousSlideElementList[previousIndex] : undefined;\n\n // When a resolved interaction is already the terminal step and SSE appends\n // the first follow-up marker, jump into that new marker immediately instead\n // of waiting for the interaction auto-close and silent-step delay.\n if (\n hasAppendedMarkers &&\n wasFocusedOnPreviousLastMarker &&\n isResolvedInteractionElement(previousCurrentElement)\n ) {\n return previousSlideElementList.length;\n }\n\n const hasTruncatedMarkers =\n nextSlideElementList.length < previousSlideElementList.length &&\n hasStableMarkerIdentityPrefix(\n previousSlideElementList,\n nextSlideElementList\n );\n\n if (hasTruncatedMarkers && nextSlideElementList.length > 0) {\n return Math.min(previousIndex, nextSlideElementList.length - 1);\n }\n\n if (previousIndex >= 0 && previousIndex < nextSlideElementList.length) {\n return previousIndex;\n }\n\n return -1;\n};\n"],"names":["isResolvedInteractionElement","element","hasStableMarkerPrefix","previousSlideElementList","nextSlideElementList","index","hasStableMarkerIdentityPrefix","previousElement","resolveNextSlideIndexAfterMarkerAppend","previousIndex","hasAppendedMarkers","previousLastMarkerIndex","wasFocusedOnPreviousLastMarker","previousCurrentElement"],"mappings":"AAQA,MAAMA,IAA+B,CAACC,MACpC,GACEA,GAAS,SAAS,kBACfA,EAAQ,YAAYA,EAAQ,YAAY,KAAA,KAGzCC,IAAwB,CAC5BC,GACAC,MAEAD,EAAyB,UAAUC,EAAqB,UACxDD,EAAyB;AAAA,EACvB,CAACF,GAASI,MAAUJ,MAAYG,EAAqBC,CAAK;AAC5D,GAEIC,IAAgC,CACpCH,GACAC,MAEAA,EAAqB,UAAUD,EAAyB,UACxDC,EAAqB,MAAM,CAACH,GAASI,MAAU;AAC7C,QAAME,IAAkBJ,EAAyBE,CAAK;AAEtD,SACEJ,EAAQ,SAASM,GAAiB,QAClCN,EAAQ,oBAAoBM,GAAiB,mBAC7CN,EAAQ,YAAYM,GAAiB;AAEzC,CAAC,GAEUC,IAAyC,CAAC;AAAA,EACrD,eAAAC;AAAA,EACA,0BAAAN;AAAA,EACA,sBAAAC;AACF,MAAmC;AACjC,MAAIA,EAAqB,WAAW;AAClC,WAAO;AAGT,QAAMM,IACJN,EAAqB,SAASD,EAAyB,UACvDD,EAAsBC,GAA0BC,CAAoB,GAChEO,IAA0BR,EAAyB,SAAS,GAC5DS,IACJH,MAAkBE,GACdE,IACJJ,KAAiB,IAAIN,EAAyBM,CAAa,IAAI;AAKjE,SACEC,KACAE,KACAZ,EAA6Ba,CAAsB,IAE5CV,EAAyB,SAIhCC,EAAqB,SAASD,EAAyB,UACvDG;AAAA,IACEH;AAAA,IACAC;AAAA,EAAA,KAGuBA,EAAqB,SAAS,IAChD,KAAK,IAAIK,GAAeL,EAAqB,SAAS,CAAC,IAG5DK,KAAiB,KAAKA,IAAgBL,EAAqB,SACtDK,IAGF;AACT;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("../../_virtual/cose-base.cjs2.js"),Q=require("../layout-base/layout-base.cjs.js");var $=I.__module.exports,X;function J(){return X||(X=1,(function(W,k){(function(y,w){W.exports=w(Q.__require())})($,function(x){return(function(y){var w={};function l(n){if(w[n])return w[n].exports;var g=w[n]={i:n,l:!1,exports:{}};return y[n].call(g.exports,g,g.exports,l),g.l=!0,g.exports}return l.m=y,l.c=w,l.i=function(n){return n},l.d=function(n,g,p){l.o(n,g)||Object.defineProperty(n,g,{configurable:!1,enumerable:!0,get:p})},l.n=function(n){var g=n&&n.__esModule?function(){return n.default}:function(){return n};return l.d(g,"a",g),g},l.o=function(n,g){return Object.prototype.hasOwnProperty.call(n,g)},l.p="",l(l.s=7)})([(function(y,w){y.exports=x}),(function(y,w,l){var n=l(0).FDLayoutConstants;function g(){}for(var p in n)g[p]=n[p];g.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,g.DEFAULT_RADIAL_SEPARATION=n.DEFAULT_EDGE_LENGTH,g.DEFAULT_COMPONENT_SEPERATION=60,g.TILE=!0,g.TILING_PADDING_VERTICAL=10,g.TILING_PADDING_HORIZONTAL=10,g.TREE_REDUCTION_ON_INCREMENTAL=!1,y.exports=g}),(function(y,w,l){var n=l(0).FDLayoutEdge;function g(G,u,E){n.call(this,G,u,E)}g.prototype=Object.create(n.prototype);for(var p in n)g[p]=n[p];y.exports=g}),(function(y,w,l){var n=l(0).LGraph;function g(G,u,E){n.call(this,G,u,E)}g.prototype=Object.create(n.prototype);for(var p in n)g[p]=n[p];y.exports=g}),(function(y,w,l){var n=l(0).LGraphManager;function g(G){n.call(this,G)}g.prototype=Object.create(n.prototype);for(var p in n)g[p]=n[p];y.exports=g}),(function(y,w,l){var n=l(0).FDLayoutNode,g=l(0).IMath;function p(u,E,T,L){n.call(this,u,E,T,L)}p.prototype=Object.create(n.prototype);for(var G in n)p[G]=n[G];p.prototype.move=function(){var u=this.graphManager.getLayout();this.displacementX=u.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=u.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>u.coolingFactor*u.maxNodeDisplacement&&(this.displacementX=u.coolingFactor*u.maxNodeDisplacement*g.sign(this.displacementX)),Math.abs(this.displacementY)>u.coolingFactor*u.maxNodeDisplacement&&(this.displacementY=u.coolingFactor*u.maxNodeDisplacement*g.sign(this.displacementY)),this.child==null?this.moveBy(this.displacementX,this.displacementY):this.child.getNodes().length==0?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),u.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},p.prototype.propogateDisplacementToChildren=function(u,E){for(var T=this.getChild().getNodes(),L,P=0;P<T.length;P++)L=T[P],L.getChild()==null?(L.moveBy(u,E),L.displacementX+=u,L.displacementY+=E):L.propogateDisplacementToChildren(u,E)},p.prototype.setPred1=function(u){this.pred1=u},p.prototype.getPred1=function(){return pred1},p.prototype.getPred2=function(){return pred2},p.prototype.setNext=function(u){this.next=u},p.prototype.getNext=function(){return next},p.prototype.setProcessed=function(u){this.processed=u},p.prototype.isProcessed=function(){return processed},y.exports=p}),(function(y,w,l){var n=l(0).FDLayout,g=l(4),p=l(3),G=l(5),u=l(2),E=l(1),T=l(0).FDLayoutConstants,L=l(0).LayoutConstants,P=l(0).Point,R=l(0).PointD,V=l(0).Layout,B=l(0).Integer,Z=l(0).IGeometry,j=l(0).LGraph,_=l(0).Transform;function d(){n.call(this),this.toBeTiled={}}d.prototype=Object.create(n.prototype);for(var U in n)d[U]=n[U];d.prototype.newGraphManager=function(){var t=new g(this);return this.graphManager=t,t},d.prototype.newGraph=function(t){return new p(null,this.graphManager,t)},d.prototype.newNode=function(t){return new G(this.graphManager,t)},d.prototype.newEdge=function(t){return new u(null,null,t)},d.prototype.initParameters=function(){n.prototype.initParameters.call(this,arguments),this.isSubLayout||(E.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=E.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=E.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=T.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=T.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=T.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=T.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=T.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=T.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/T.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=T.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},d.prototype.layout=function(){var t=L.DEFAULT_CREATE_BENDS_AS_NEEDED;return t&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},d.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){if(E.TREE_REDUCTION_ON_INCREMENTAL){this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter(function(a){return e.has(a)});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(i){return e.has(i)});this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},d.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished)if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;if(this.totalIterations%T.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged())if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;this.coolingCycle++,this.layoutQuality==0?this.coolingAdjuster=this.coolingCycle:this.layoutQuality==1&&(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(o){return t.has(o)});this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=T.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=T.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},d.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},d.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if(T.ANIMATE==="during")this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},d.prototype.calculateNodesToApplyGravitationTo=function(){var t=[],e,r=this.graphManager.getGraphs(),i=r.length,o;for(o=0;o<i;o++)e=r[o],e.updateConnected(),e.isConnected||(t=t.concat(e.getNodes()));return t},d.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e=new Set,r;for(r=0;r<t.length;r++){var i=t[r];if(!e.has(i)){var o=i.getSource(),a=i.getTarget();if(o==a)i.getBendpoints().push(new R),i.getBendpoints().push(new R),this.createDummyNodesForBendpoints(i),e.add(i);else{var s=[];if(s=s.concat(o.getEdgeListToNode(a)),s=s.concat(a.getEdgeListToNode(o)),!e.has(s[0])){if(s.length>1){var h;for(h=0;h<s.length;h++){var f=s[h];f.getBendpoints().push(new R),this.createDummyNodesForBendpoints(f)}}s.forEach(function(C){e.add(C)})}}}if(e.size==t.length)break}},d.prototype.positionNodesRadially=function(t){for(var e=new P(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,a=0,s=new R(0,0),h=0;h<t.length;h++){h%r==0&&(a=0,o=i,h!=0&&(o+=E.DEFAULT_COMPONENT_SEPERATION),i=0);var f=t[h],C=V.findCenterOfTree(f);e.x=a,e.y=o,s=d.radialLayout(f,C,e),s.y>i&&(i=Math.floor(s.y)),a=Math.floor(s.x+E.DEFAULT_COMPONENT_SEPERATION)}this.transform(new R(L.WORLD_CENTER_X-s.x/2,L.WORLD_CENTER_Y-s.y/2))},d.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),E.DEFAULT_RADIAL_SEPARATION);d.branchRadialLayout(e,null,0,359,0,i);var o=j.calculateBounds(t),a=new _;a.setDeviceOrgX(o.getMinX()),a.setDeviceOrgY(o.getMinY()),a.setWorldOrgX(r.x),a.setWorldOrgY(r.y);for(var s=0;s<t.length;s++){var h=t[s];h.transform(a)}var f=new R(o.getMaxX(),o.getMaxY());return a.inverseTransformPoint(f)},d.branchRadialLayout=function(t,e,r,i,o,a){var s=(i-r+1)/2;s<0&&(s+=180);var h=(s+r)%360,f=h*Z.TWO_PI/360,C=o*Math.cos(f),m=o*Math.sin(f);t.setCenter(C,m);var N=[];N=N.concat(t.getEdges());var c=N.length;e!=null&&c--;for(var v=0,A=N.length,D,O=t.getEdgesBetween(e);O.length>1;){var F=O[0];O.splice(0,1);var M=N.indexOf(F);M>=0&&N.splice(M,1),A--,c--}e!=null?D=(N.indexOf(O[0])+1)%A:D=0;for(var b=Math.abs(i-r)/c,S=D;v!=c;S=++S%A){var Y=N[S].getOtherEnd(t);if(Y!=e){var H=(r+v*b)%360,K=(H+b)%360;d.branchRadialLayout(Y,t,H,K,o+a,a),v++}}},d.maxDiagonalInTree=function(t){for(var e=B.MIN_VALUE,r=0;r<t.length;r++){var i=t[r],o=i.getDiagonal();o>e&&(e=o)}return e},d.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},d.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 a=i[o],s=a.getParent();this.getNodeDegreeWithChildren(a)===0&&(s.id==null||!this.getToBeTiled(s))&&r.push(a)}for(var o=0;o<r.length;o++){var a=r[o],h=a.getParent().id;typeof e[h]>"u"&&(e[h]=[]),e[h]=e[h].concat(a)}Object.keys(e).forEach(function(f){if(e[f].length>1){var C="DummyCompound_"+f;t.memberGroups[C]=e[f];var m=e[f][0].getParent(),N=new G(t.graphManager);N.id=C,N.paddingLeft=m.paddingLeft||0,N.paddingRight=m.paddingRight||0,N.paddingBottom=m.paddingBottom||0,N.paddingTop=m.paddingTop||0,t.idToDummyNode[C]=N;var c=t.getGraphManager().add(t.newGraph(),N),v=m.getChild();v.add(N);for(var A=0;A<e[f].length;A++){var D=e[f][A];v.remove(D),c.add(D)}}})},d.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)},d.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})},d.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)}},d.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach(function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,a=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,a)})},d.prototype.getToBeTiled=function(t){var e=t.id;if(this.toBeTiled[e]!=null)return this.toBeTiled[e];var r=t.getChild();if(r==null)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var a=i[o];if(this.getNodeDegree(a)>0)return this.toBeTiled[e]=!1,!1;if(a.getChild()==null){this.toBeTiled[a.id]=!1;continue}if(!this.getToBeTiled(a))return this.toBeTiled[e]=!1,!1}return this.toBeTiled[e]=!0,!0},d.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=r+1)}return r},d.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(t.getChild()==null)return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},d.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},d.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];r.getChild()!=null&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},d.prototype.adjustLocations=function(t,e,r,i,o){e+=i,r+=o;for(var a=e,s=0;s<t.rows.length;s++){var h=t.rows[s];e=a;for(var f=0,C=0;C<h.length;C++){var m=h[C];m.rect.x=e,m.rect.y=r,e+=m.rect.width+t.horizontalPadding,m.rect.height>f&&(f=m.rect.height)}r+=f+t.verticalPadding}},d.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})},d.prototype.tileNodes=function(t,e){var r=E.TILING_PADDING_VERTICAL,i=E.TILING_PADDING_HORIZONTAL,o={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:r,horizontalPadding:i};t.sort(function(h,f){return h.rect.width*h.rect.height>f.rect.width*f.rect.height?-1:h.rect.width*h.rect.height<f.rect.width*f.rect.height?1:0});for(var a=0;a<t.length;a++){var s=t[a];o.rows.length==0?this.insertNodeToRow(o,s,0,e):this.canAddHorizontal(o,s.rect.width,s.rect.height)?this.insertNodeToRow(o,s,this.getShortestRowIndex(o),e):this.insertNodeToRow(o,s,o.rows.length,e),this.shiftToLastRow(o)}return o},d.prototype.insertNodeToRow=function(t,e,r,i){var o=i;if(r==t.rows.length){var a=[];t.rows.push(a),t.rowWidth.push(o),t.rowHeight.push(0)}var s=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(s+=t.horizontalPadding),t.rowWidth[r]=s,t.width<s&&(t.width=s);var h=e.rect.height;r>0&&(h+=t.verticalPadding);var f=0;h>t.rowHeight[r]&&(f=t.rowHeight[r],t.rowHeight[r]=h,f=t.rowHeight[r]-f),t.height+=f,t.rows[r].push(e)},d.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},d.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},d.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 a=0;t.rowHeight[i]<r&&i>0&&(a=r+t.verticalPadding-t.rowHeight[i]);var s;t.width-o>=e+t.horizontalPadding?s=(t.height+a)/(o+e+t.horizontalPadding):s=(t.height+a)/t.width,a=r+t.verticalPadding;var h;return t.width<e?h=(t.height+a)/e:h=(t.height+a)/t.width,h<1&&(h=1/h),s<1&&(s=1/s),s<h},d.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],a=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>a&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-a,t.rowWidth[r]=t.rowWidth[r]+a,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var s=Number.MIN_VALUE,h=0;h<i.length;h++)i[h].height>s&&(s=i[h].height);e>0&&(s+=t.verticalPadding);var f=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=s,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var C=t.rowHeight[e]+t.rowHeight[r];t.height+=C-f,this.shiftToLastRow(t)}},d.prototype.tilingPreLayout=function(){E.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},d.prototype.tilingPostLayout=function(){E.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},d.prototype.reduceTrees=function(){for(var t=[],e=!0,r;e;){var i=this.graphManager.getAllNodes(),o=[];e=!1;for(var a=0;a<i.length;a++)r=i[a],r.getEdges().length==1&&!r.getEdges()[0].isInterGraph&&r.getChild()==null&&(o.push([r,r.getEdges()[0],r.getOwner()]),e=!0);if(e==!0){for(var s=[],h=0;h<o.length;h++)o[h][0].getEdges().length==1&&(s.push(o[h]),o[h][0].getOwner().remove(o[h][0]));t.push(s),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=t},d.prototype.growTree=function(t){for(var e=t.length,r=t[e-1],i,o=0;o<r.length;o++)i=r[o],this.findPlaceforPrunedNode(i),i[2].add(i[0]),i[2].add(i[1],i[1].source,i[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},d.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0];i==t[1].source?r=t[1].target:r=t[1].source;var o=r.startX,a=r.finishX,s=r.startY,h=r.finishY,f=0,C=0,m=0,N=0,c=[f,m,C,N];if(s>0)for(var v=o;v<=a;v++)c[0]+=this.grid[v][s-1].length+this.grid[v][s].length-1;if(a<this.grid.length-1)for(var v=s;v<=h;v++)c[1]+=this.grid[a+1][v].length+this.grid[a][v].length-1;if(h<this.grid[0].length-1)for(var v=o;v<=a;v++)c[2]+=this.grid[v][h+1].length+this.grid[v][h].length-1;if(o>0)for(var v=s;v<=h;v++)c[3]+=this.grid[o-1][v].length+this.grid[o][v].length-1;for(var A=B.MAX_VALUE,D,O,F=0;F<c.length;F++)c[F]<A?(A=c[F],D=1,O=F):c[F]==A&&D++;if(D==3&&A==0)c[0]==0&&c[1]==0&&c[2]==0?e=1:c[0]==0&&c[1]==0&&c[3]==0?e=0:c[0]==0&&c[2]==0&&c[3]==0?e=3:c[1]==0&&c[2]==0&&c[3]==0&&(e=2);else if(D==2&&A==0){var M=Math.floor(Math.random()*2);c[0]==0&&c[1]==0?M==0?e=0:e=1:c[0]==0&&c[2]==0?M==0?e=0:e=2:c[0]==0&&c[3]==0?M==0?e=0:e=3:c[1]==0&&c[2]==0?M==0?e=1:e=2:c[1]==0&&c[3]==0?M==0?e=1:e=3:M==0?e=2:e=3}else if(D==4&&A==0){var M=Math.floor(Math.random()*4);e=M}else e=O;e==0?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-T.DEFAULT_EDGE_LENGTH-i.getHeight()/2):e==1?i.setCenter(r.getCenterX()+r.getWidth()/2+T.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):e==2?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+T.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-T.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},y.exports=d}),(function(y,w,l){var n={};n.layoutBase=l(0),n.CoSEConstants=l(1),n.CoSEEdge=l(2),n.CoSEGraph=l(3),n.CoSEGraphManager=l(4),n.CoSELayout=l(6),n.CoSENode=l(5),y.exports=n})])})})(I.__module)),I.__module.exports}exports.__require=J;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("../../_virtual/cose-base.cjs.js"),Q=require("../layout-base/layout-base.cjs.js");var $=I.__module.exports,X;function J(){return X||(X=1,(function(W,k){(function(y,w){W.exports=w(Q.__require())})($,function(x){return(function(y){var w={};function l(n){if(w[n])return w[n].exports;var g=w[n]={i:n,l:!1,exports:{}};return y[n].call(g.exports,g,g.exports,l),g.l=!0,g.exports}return l.m=y,l.c=w,l.i=function(n){return n},l.d=function(n,g,p){l.o(n,g)||Object.defineProperty(n,g,{configurable:!1,enumerable:!0,get:p})},l.n=function(n){var g=n&&n.__esModule?function(){return n.default}:function(){return n};return l.d(g,"a",g),g},l.o=function(n,g){return Object.prototype.hasOwnProperty.call(n,g)},l.p="",l(l.s=7)})([(function(y,w){y.exports=x}),(function(y,w,l){var n=l(0).FDLayoutConstants;function g(){}for(var p in n)g[p]=n[p];g.DEFAULT_USE_MULTI_LEVEL_SCALING=!1,g.DEFAULT_RADIAL_SEPARATION=n.DEFAULT_EDGE_LENGTH,g.DEFAULT_COMPONENT_SEPERATION=60,g.TILE=!0,g.TILING_PADDING_VERTICAL=10,g.TILING_PADDING_HORIZONTAL=10,g.TREE_REDUCTION_ON_INCREMENTAL=!1,y.exports=g}),(function(y,w,l){var n=l(0).FDLayoutEdge;function g(G,u,E){n.call(this,G,u,E)}g.prototype=Object.create(n.prototype);for(var p in n)g[p]=n[p];y.exports=g}),(function(y,w,l){var n=l(0).LGraph;function g(G,u,E){n.call(this,G,u,E)}g.prototype=Object.create(n.prototype);for(var p in n)g[p]=n[p];y.exports=g}),(function(y,w,l){var n=l(0).LGraphManager;function g(G){n.call(this,G)}g.prototype=Object.create(n.prototype);for(var p in n)g[p]=n[p];y.exports=g}),(function(y,w,l){var n=l(0).FDLayoutNode,g=l(0).IMath;function p(u,E,T,L){n.call(this,u,E,T,L)}p.prototype=Object.create(n.prototype);for(var G in n)p[G]=n[G];p.prototype.move=function(){var u=this.graphManager.getLayout();this.displacementX=u.coolingFactor*(this.springForceX+this.repulsionForceX+this.gravitationForceX)/this.noOfChildren,this.displacementY=u.coolingFactor*(this.springForceY+this.repulsionForceY+this.gravitationForceY)/this.noOfChildren,Math.abs(this.displacementX)>u.coolingFactor*u.maxNodeDisplacement&&(this.displacementX=u.coolingFactor*u.maxNodeDisplacement*g.sign(this.displacementX)),Math.abs(this.displacementY)>u.coolingFactor*u.maxNodeDisplacement&&(this.displacementY=u.coolingFactor*u.maxNodeDisplacement*g.sign(this.displacementY)),this.child==null?this.moveBy(this.displacementX,this.displacementY):this.child.getNodes().length==0?this.moveBy(this.displacementX,this.displacementY):this.propogateDisplacementToChildren(this.displacementX,this.displacementY),u.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},p.prototype.propogateDisplacementToChildren=function(u,E){for(var T=this.getChild().getNodes(),L,P=0;P<T.length;P++)L=T[P],L.getChild()==null?(L.moveBy(u,E),L.displacementX+=u,L.displacementY+=E):L.propogateDisplacementToChildren(u,E)},p.prototype.setPred1=function(u){this.pred1=u},p.prototype.getPred1=function(){return pred1},p.prototype.getPred2=function(){return pred2},p.prototype.setNext=function(u){this.next=u},p.prototype.getNext=function(){return next},p.prototype.setProcessed=function(u){this.processed=u},p.prototype.isProcessed=function(){return processed},y.exports=p}),(function(y,w,l){var n=l(0).FDLayout,g=l(4),p=l(3),G=l(5),u=l(2),E=l(1),T=l(0).FDLayoutConstants,L=l(0).LayoutConstants,P=l(0).Point,R=l(0).PointD,V=l(0).Layout,B=l(0).Integer,Z=l(0).IGeometry,j=l(0).LGraph,_=l(0).Transform;function d(){n.call(this),this.toBeTiled={}}d.prototype=Object.create(n.prototype);for(var U in n)d[U]=n[U];d.prototype.newGraphManager=function(){var t=new g(this);return this.graphManager=t,t},d.prototype.newGraph=function(t){return new p(null,this.graphManager,t)},d.prototype.newNode=function(t){return new G(this.graphManager,t)},d.prototype.newEdge=function(t){return new u(null,null,t)},d.prototype.initParameters=function(){n.prototype.initParameters.call(this,arguments),this.isSubLayout||(E.DEFAULT_EDGE_LENGTH<10?this.idealEdgeLength=10:this.idealEdgeLength=E.DEFAULT_EDGE_LENGTH,this.useSmartIdealEdgeLengthCalculation=E.DEFAULT_USE_SMART_IDEAL_EDGE_LENGTH_CALCULATION,this.springConstant=T.DEFAULT_SPRING_STRENGTH,this.repulsionConstant=T.DEFAULT_REPULSION_STRENGTH,this.gravityConstant=T.DEFAULT_GRAVITY_STRENGTH,this.compoundGravityConstant=T.DEFAULT_COMPOUND_GRAVITY_STRENGTH,this.gravityRangeFactor=T.DEFAULT_GRAVITY_RANGE_FACTOR,this.compoundGravityRangeFactor=T.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/T.CONVERGENCE_CHECK_PERIOD,this.finalTemperature=T.CONVERGENCE_CHECK_PERIOD/this.maxIterations,this.coolingAdjuster=1)},d.prototype.layout=function(){var t=L.DEFAULT_CREATE_BENDS_AS_NEEDED;return t&&(this.createBendpoints(),this.graphManager.resetAllEdges()),this.level=0,this.classicLayout()},d.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){if(E.TREE_REDUCTION_ON_INCREMENTAL){this.reduceTrees(),this.graphManager.resetAllNodesToApplyGravitation();var e=new Set(this.getAllNodes()),r=this.nodesWithGravity.filter(function(a){return e.has(a)});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(i){return e.has(i)});this.graphManager.setAllNodesToApplyGravitation(r),this.positionNodesRandomly()}}return this.initSpringEmbedder(),this.runSpringEmbedder(),!0},d.prototype.tick=function(){if(this.totalIterations++,this.totalIterations===this.maxIterations&&!this.isTreeGrowing&&!this.isGrowthFinished)if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;if(this.totalIterations%T.CONVERGENCE_CHECK_PERIOD==0&&!this.isTreeGrowing&&!this.isGrowthFinished){if(this.isConverged())if(this.prunedNodesAll.length>0)this.isTreeGrowing=!0;else return!0;this.coolingCycle++,this.layoutQuality==0?this.coolingAdjuster=this.coolingCycle:this.layoutQuality==1&&(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(o){return t.has(o)});this.graphManager.setAllNodesToApplyGravitation(e),this.graphManager.updateBounds(),this.updateGrid(),this.coolingFactor=T.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=T.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},d.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},d.prototype.runSpringEmbedder=function(){this.initialAnimationPeriod=25,this.animationPeriod=this.initialAnimationPeriod;var t=!1;if(T.ANIMATE==="during")this.emit("layoutstarted");else{for(;!t;)t=this.tick();this.graphManager.updateBounds()}},d.prototype.calculateNodesToApplyGravitationTo=function(){var t=[],e,r=this.graphManager.getGraphs(),i=r.length,o;for(o=0;o<i;o++)e=r[o],e.updateConnected(),e.isConnected||(t=t.concat(e.getNodes()));return t},d.prototype.createBendpoints=function(){var t=[];t=t.concat(this.graphManager.getAllEdges());var e=new Set,r;for(r=0;r<t.length;r++){var i=t[r];if(!e.has(i)){var o=i.getSource(),a=i.getTarget();if(o==a)i.getBendpoints().push(new R),i.getBendpoints().push(new R),this.createDummyNodesForBendpoints(i),e.add(i);else{var s=[];if(s=s.concat(o.getEdgeListToNode(a)),s=s.concat(a.getEdgeListToNode(o)),!e.has(s[0])){if(s.length>1){var h;for(h=0;h<s.length;h++){var f=s[h];f.getBendpoints().push(new R),this.createDummyNodesForBendpoints(f)}}s.forEach(function(C){e.add(C)})}}}if(e.size==t.length)break}},d.prototype.positionNodesRadially=function(t){for(var e=new P(0,0),r=Math.ceil(Math.sqrt(t.length)),i=0,o=0,a=0,s=new R(0,0),h=0;h<t.length;h++){h%r==0&&(a=0,o=i,h!=0&&(o+=E.DEFAULT_COMPONENT_SEPERATION),i=0);var f=t[h],C=V.findCenterOfTree(f);e.x=a,e.y=o,s=d.radialLayout(f,C,e),s.y>i&&(i=Math.floor(s.y)),a=Math.floor(s.x+E.DEFAULT_COMPONENT_SEPERATION)}this.transform(new R(L.WORLD_CENTER_X-s.x/2,L.WORLD_CENTER_Y-s.y/2))},d.radialLayout=function(t,e,r){var i=Math.max(this.maxDiagonalInTree(t),E.DEFAULT_RADIAL_SEPARATION);d.branchRadialLayout(e,null,0,359,0,i);var o=j.calculateBounds(t),a=new _;a.setDeviceOrgX(o.getMinX()),a.setDeviceOrgY(o.getMinY()),a.setWorldOrgX(r.x),a.setWorldOrgY(r.y);for(var s=0;s<t.length;s++){var h=t[s];h.transform(a)}var f=new R(o.getMaxX(),o.getMaxY());return a.inverseTransformPoint(f)},d.branchRadialLayout=function(t,e,r,i,o,a){var s=(i-r+1)/2;s<0&&(s+=180);var h=(s+r)%360,f=h*Z.TWO_PI/360,C=o*Math.cos(f),m=o*Math.sin(f);t.setCenter(C,m);var N=[];N=N.concat(t.getEdges());var c=N.length;e!=null&&c--;for(var v=0,A=N.length,D,O=t.getEdgesBetween(e);O.length>1;){var F=O[0];O.splice(0,1);var M=N.indexOf(F);M>=0&&N.splice(M,1),A--,c--}e!=null?D=(N.indexOf(O[0])+1)%A:D=0;for(var b=Math.abs(i-r)/c,S=D;v!=c;S=++S%A){var Y=N[S].getOtherEnd(t);if(Y!=e){var H=(r+v*b)%360,K=(H+b)%360;d.branchRadialLayout(Y,t,H,K,o+a,a),v++}}},d.maxDiagonalInTree=function(t){for(var e=B.MIN_VALUE,r=0;r<t.length;r++){var i=t[r],o=i.getDiagonal();o>e&&(e=o)}return e},d.prototype.calcRepulsionRange=function(){return 2*(this.level+1)*this.idealEdgeLength},d.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 a=i[o],s=a.getParent();this.getNodeDegreeWithChildren(a)===0&&(s.id==null||!this.getToBeTiled(s))&&r.push(a)}for(var o=0;o<r.length;o++){var a=r[o],h=a.getParent().id;typeof e[h]>"u"&&(e[h]=[]),e[h]=e[h].concat(a)}Object.keys(e).forEach(function(f){if(e[f].length>1){var C="DummyCompound_"+f;t.memberGroups[C]=e[f];var m=e[f][0].getParent(),N=new G(t.graphManager);N.id=C,N.paddingLeft=m.paddingLeft||0,N.paddingRight=m.paddingRight||0,N.paddingBottom=m.paddingBottom||0,N.paddingTop=m.paddingTop||0,t.idToDummyNode[C]=N;var c=t.getGraphManager().add(t.newGraph(),N),v=m.getChild();v.add(N);for(var A=0;A<e[f].length;A++){var D=e[f][A];v.remove(D),c.add(D)}}})},d.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)},d.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})},d.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)}},d.prototype.repopulateZeroDegreeMembers=function(){var t=this,e=this.tiledZeroDegreePack;Object.keys(e).forEach(function(r){var i=t.idToDummyNode[r],o=i.paddingLeft,a=i.paddingTop;t.adjustLocations(e[r],i.rect.x,i.rect.y,o,a)})},d.prototype.getToBeTiled=function(t){var e=t.id;if(this.toBeTiled[e]!=null)return this.toBeTiled[e];var r=t.getChild();if(r==null)return this.toBeTiled[e]=!1,!1;for(var i=r.getNodes(),o=0;o<i.length;o++){var a=i[o];if(this.getNodeDegree(a)>0)return this.toBeTiled[e]=!1,!1;if(a.getChild()==null){this.toBeTiled[a.id]=!1;continue}if(!this.getToBeTiled(a))return this.toBeTiled[e]=!1,!1}return this.toBeTiled[e]=!0,!0},d.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=r+1)}return r},d.prototype.getNodeDegreeWithChildren=function(t){var e=this.getNodeDegree(t);if(t.getChild()==null)return e;for(var r=t.getChild().getNodes(),i=0;i<r.length;i++){var o=r[i];e+=this.getNodeDegreeWithChildren(o)}return e},d.prototype.performDFSOnCompounds=function(){this.compoundOrder=[],this.fillCompexOrderByDFS(this.graphManager.getRoot().getNodes())},d.prototype.fillCompexOrderByDFS=function(t){for(var e=0;e<t.length;e++){var r=t[e];r.getChild()!=null&&this.fillCompexOrderByDFS(r.getChild().getNodes()),this.getToBeTiled(r)&&this.compoundOrder.push(r)}},d.prototype.adjustLocations=function(t,e,r,i,o){e+=i,r+=o;for(var a=e,s=0;s<t.rows.length;s++){var h=t.rows[s];e=a;for(var f=0,C=0;C<h.length;C++){var m=h[C];m.rect.x=e,m.rect.y=r,e+=m.rect.width+t.horizontalPadding,m.rect.height>f&&(f=m.rect.height)}r+=f+t.verticalPadding}},d.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})},d.prototype.tileNodes=function(t,e){var r=E.TILING_PADDING_VERTICAL,i=E.TILING_PADDING_HORIZONTAL,o={rows:[],rowWidth:[],rowHeight:[],width:0,height:e,verticalPadding:r,horizontalPadding:i};t.sort(function(h,f){return h.rect.width*h.rect.height>f.rect.width*f.rect.height?-1:h.rect.width*h.rect.height<f.rect.width*f.rect.height?1:0});for(var a=0;a<t.length;a++){var s=t[a];o.rows.length==0?this.insertNodeToRow(o,s,0,e):this.canAddHorizontal(o,s.rect.width,s.rect.height)?this.insertNodeToRow(o,s,this.getShortestRowIndex(o),e):this.insertNodeToRow(o,s,o.rows.length,e),this.shiftToLastRow(o)}return o},d.prototype.insertNodeToRow=function(t,e,r,i){var o=i;if(r==t.rows.length){var a=[];t.rows.push(a),t.rowWidth.push(o),t.rowHeight.push(0)}var s=t.rowWidth[r]+e.rect.width;t.rows[r].length>0&&(s+=t.horizontalPadding),t.rowWidth[r]=s,t.width<s&&(t.width=s);var h=e.rect.height;r>0&&(h+=t.verticalPadding);var f=0;h>t.rowHeight[r]&&(f=t.rowHeight[r],t.rowHeight[r]=h,f=t.rowHeight[r]-f),t.height+=f,t.rows[r].push(e)},d.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},d.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},d.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 a=0;t.rowHeight[i]<r&&i>0&&(a=r+t.verticalPadding-t.rowHeight[i]);var s;t.width-o>=e+t.horizontalPadding?s=(t.height+a)/(o+e+t.horizontalPadding):s=(t.height+a)/t.width,a=r+t.verticalPadding;var h;return t.width<e?h=(t.height+a)/e:h=(t.height+a)/t.width,h<1&&(h=1/h),s<1&&(s=1/s),s<h},d.prototype.shiftToLastRow=function(t){var e=this.getLongestRowIndex(t),r=t.rowWidth.length-1,i=t.rows[e],o=i[i.length-1],a=o.width+t.horizontalPadding;if(t.width-t.rowWidth[r]>a&&e!=r){i.splice(-1,1),t.rows[r].push(o),t.rowWidth[e]=t.rowWidth[e]-a,t.rowWidth[r]=t.rowWidth[r]+a,t.width=t.rowWidth[instance.getLongestRowIndex(t)];for(var s=Number.MIN_VALUE,h=0;h<i.length;h++)i[h].height>s&&(s=i[h].height);e>0&&(s+=t.verticalPadding);var f=t.rowHeight[e]+t.rowHeight[r];t.rowHeight[e]=s,t.rowHeight[r]<o.height+t.verticalPadding&&(t.rowHeight[r]=o.height+t.verticalPadding);var C=t.rowHeight[e]+t.rowHeight[r];t.height+=C-f,this.shiftToLastRow(t)}},d.prototype.tilingPreLayout=function(){E.TILE&&(this.groupZeroDegreeMembers(),this.clearCompounds(),this.clearZeroDegreeMembers())},d.prototype.tilingPostLayout=function(){E.TILE&&(this.repopulateZeroDegreeMembers(),this.repopulateCompounds())},d.prototype.reduceTrees=function(){for(var t=[],e=!0,r;e;){var i=this.graphManager.getAllNodes(),o=[];e=!1;for(var a=0;a<i.length;a++)r=i[a],r.getEdges().length==1&&!r.getEdges()[0].isInterGraph&&r.getChild()==null&&(o.push([r,r.getEdges()[0],r.getOwner()]),e=!0);if(e==!0){for(var s=[],h=0;h<o.length;h++)o[h][0].getEdges().length==1&&(s.push(o[h]),o[h][0].getOwner().remove(o[h][0]));t.push(s),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()}}this.prunedNodesAll=t},d.prototype.growTree=function(t){for(var e=t.length,r=t[e-1],i,o=0;o<r.length;o++)i=r[o],this.findPlaceforPrunedNode(i),i[2].add(i[0]),i[2].add(i[1],i[1].source,i[1].target);t.splice(t.length-1,1),this.graphManager.resetAllNodes(),this.graphManager.resetAllEdges()},d.prototype.findPlaceforPrunedNode=function(t){var e,r,i=t[0];i==t[1].source?r=t[1].target:r=t[1].source;var o=r.startX,a=r.finishX,s=r.startY,h=r.finishY,f=0,C=0,m=0,N=0,c=[f,m,C,N];if(s>0)for(var v=o;v<=a;v++)c[0]+=this.grid[v][s-1].length+this.grid[v][s].length-1;if(a<this.grid.length-1)for(var v=s;v<=h;v++)c[1]+=this.grid[a+1][v].length+this.grid[a][v].length-1;if(h<this.grid[0].length-1)for(var v=o;v<=a;v++)c[2]+=this.grid[v][h+1].length+this.grid[v][h].length-1;if(o>0)for(var v=s;v<=h;v++)c[3]+=this.grid[o-1][v].length+this.grid[o][v].length-1;for(var A=B.MAX_VALUE,D,O,F=0;F<c.length;F++)c[F]<A?(A=c[F],D=1,O=F):c[F]==A&&D++;if(D==3&&A==0)c[0]==0&&c[1]==0&&c[2]==0?e=1:c[0]==0&&c[1]==0&&c[3]==0?e=0:c[0]==0&&c[2]==0&&c[3]==0?e=3:c[1]==0&&c[2]==0&&c[3]==0&&(e=2);else if(D==2&&A==0){var M=Math.floor(Math.random()*2);c[0]==0&&c[1]==0?M==0?e=0:e=1:c[0]==0&&c[2]==0?M==0?e=0:e=2:c[0]==0&&c[3]==0?M==0?e=0:e=3:c[1]==0&&c[2]==0?M==0?e=1:e=2:c[1]==0&&c[3]==0?M==0?e=1:e=3:M==0?e=2:e=3}else if(D==4&&A==0){var M=Math.floor(Math.random()*4);e=M}else e=O;e==0?i.setCenter(r.getCenterX(),r.getCenterY()-r.getHeight()/2-T.DEFAULT_EDGE_LENGTH-i.getHeight()/2):e==1?i.setCenter(r.getCenterX()+r.getWidth()/2+T.DEFAULT_EDGE_LENGTH+i.getWidth()/2,r.getCenterY()):e==2?i.setCenter(r.getCenterX(),r.getCenterY()+r.getHeight()/2+T.DEFAULT_EDGE_LENGTH+i.getHeight()/2):i.setCenter(r.getCenterX()-r.getWidth()/2-T.DEFAULT_EDGE_LENGTH-i.getWidth()/2,r.getCenterY())},y.exports=d}),(function(y,w,l){var n={};n.layoutBase=l(0),n.CoSEConstants=l(1),n.CoSEEdge=l(2),n.CoSEGraph=l(3),n.CoSEGraphManager=l(4),n.CoSELayout=l(6),n.CoSENode=l(5),y.exports=n})])})})(I.__module)),I.__module.exports}exports.__require=J;
|
|
2
2
|
//# sourceMappingURL=cose-base.cjs.js.map
|