@kazuhi-ra/turnbox-core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 NOHT CO.,LTD.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # @kazuhi-ra/turnbox-core
2
+
3
+ Pure geometry and navigation functions for TURNBOX.js. No DOM dependency.
4
+
5
+ For most use cases, prefer `@kazuhi-ra/turnbox-dom`, `@kazuhi-ra/turnbox-react`, or `@kazuhi-ra/turnbox-vue`.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @kazuhi-ra/turnbox-core
11
+ ```
12
+
13
+ ## API
14
+
15
+ ### normalizeOptions(options)
16
+
17
+ Fills in defaults and returns a `NormalizedOptions` object.
18
+
19
+ ```ts
20
+ import { normalizeOptions } from "@kazuhi-ra/turnbox-core";
21
+
22
+ const opts = normalizeOptions({ faces: 4, duration: 400 });
23
+ ```
24
+
25
+ ### calcFaceTransform(currentFace, faceNum, opts)
26
+
27
+ Returns the CSS transform values for `faceNum` relative to `currentFace`.
28
+
29
+ ```ts
30
+ import { normalizeOptions, calcFaceTransform } from "@kazuhi-ra/turnbox-core";
31
+
32
+ const opts = normalizeOptions({ faces: 4 });
33
+ const t = calcFaceTransform(1, 2, opts);
34
+ // { axis: "X", deg: 90, x: 0, y: -25, z: 25, zIndex: 10, transformOrigin: "50% 50%" }
35
+
36
+ const css = `rotate${t.axis}(${t.deg}deg) translate3d(${t.x}px, ${t.y}px, ${t.z}px)`;
37
+ ```
38
+
39
+ ### DEFAULT_SIZE / DEFAULT_HEIGHT
40
+
41
+ ```ts
42
+ import { DEFAULT_SIZE, DEFAULT_HEIGHT } from "@kazuhi-ra/turnbox-core";
43
+ // DEFAULT_SIZE = 200
44
+ // DEFAULT_HEIGHT = 50
45
+ ```
46
+
47
+ ## Internal API
48
+
49
+ `@kazuhi-ra/turnbox-core/internal` is used across the `@kazuhi-ra/turnbox-*` packages and may have breaking changes in minor releases. Direct use from outside the monorepo is not recommended.
50
+
51
+ ## License
52
+
53
+ MIT
@@ -0,0 +1,167 @@
1
+ // src/normalize.ts
2
+ var MAX_FACE_PCS = 4;
3
+ var DEFAULT_DURATION = 200;
4
+ var DEFAULT_DELAY = 0;
5
+ var DEFAULT_EASING = "linear";
6
+ var DEFAULT_PERSPECTIVE = 800;
7
+ var DEFAULT_SIZE = 200;
8
+ var DEFAULT_HEIGHT = 50;
9
+ var normalizeOptions = (options) => {
10
+ const faces = Math.min(options.faces, MAX_FACE_PCS);
11
+ const axis = options.axis ?? "X";
12
+ const direction = options.direction ?? "positive";
13
+ const duration = options.duration ?? DEFAULT_DURATION;
14
+ const delay = options.delay ?? DEFAULT_DELAY;
15
+ const easing = options.easing ?? DEFAULT_EASING;
16
+ const perspective = options.perspective ?? DEFAULT_PERSPECTIVE;
17
+ const width = options.width ?? DEFAULT_SIZE;
18
+ const height = options.height ?? DEFAULT_HEIGHT;
19
+ const even = options.even ?? (axis === "Y" ? width : height);
20
+ const length = axis === "Y" ? width : height;
21
+ const fixed = even === length;
22
+ const rawType = options.type ?? "real";
23
+ const type = !fixed && rawType === "skip" ? "real" : rawType;
24
+ const geometry = fixed ? { kind: "fixed", axis, length } : { kind: "variable", axis, length, even };
25
+ return { faces, direction, type, duration, delay, easing, perspective, geometry };
26
+ };
27
+
28
+ // src/transform.ts
29
+ var TRANSFORM_ORIGIN_CENTER = "50% 50%";
30
+ var TRANSFORM_ORIGIN_TOP_EDGE = "50% 0px";
31
+ var TRANSFORM_ORIGIN_LEFT_EDGE = "0px 50%";
32
+ var getFaceParity = (faceNum) => faceNum % 2 !== 0 ? "odd" : "even";
33
+ var calcBaseDeg = (currentFace, faceNum) => (currentFace - faceNum) * -90;
34
+ var isSkipWrapEdge = (currentFace, faceNum) => currentFace === MAX_FACE_PCS && faceNum === 1 || currentFace === 1 && faceNum === MAX_FACE_PCS;
35
+ var applyAnimationType = (deg, currentFace, faceNum, type) => {
36
+ if (type === "skip") {
37
+ const clamped = Math.sign(deg) * 90;
38
+ return isSkipWrapEdge(currentFace, faceNum) ? clamped * -1 : clamped;
39
+ }
40
+ if (type === "repeat") {
41
+ if (getFaceParity(currentFace) === "odd" && getFaceParity(faceNum) === "even") return 90;
42
+ if (getFaceParity(currentFace) === "even" && getFaceParity(faceNum) === "odd") return -90;
43
+ }
44
+ return deg;
45
+ };
46
+ var applyDirection = (deg, direction) => {
47
+ if (direction !== "negative") return deg;
48
+ const flipped = deg * -1;
49
+ return Object.is(flipped, -0) ? 0 : flipped;
50
+ };
51
+ var calcDeg = (currentFace, faceNum, options) => {
52
+ const base = calcBaseDeg(currentFace, faceNum);
53
+ const typed = applyAnimationType(base, currentFace, faceNum, options.type);
54
+ return applyDirection(typed, options.direction);
55
+ };
56
+ var faceVisibility = (deg) => {
57
+ const abs = Math.abs(deg);
58
+ if (abs === 0 || abs === 360) return "front";
59
+ if (abs === 90 || abs === 270) return "side";
60
+ return "hidden";
61
+ };
62
+ var Z_INDEX = { front: 20, side: 10, hidden: 0 };
63
+ var calcZIndex = (deg) => Z_INDEX[faceVisibility(deg)];
64
+ var classifyDeg = (deg) => {
65
+ if (deg === 0 || Math.abs(deg) === 360) return "zero";
66
+ if (deg === 90 || deg === -270) return "pos90";
67
+ if (Math.abs(deg) === 180) return "half";
68
+ return "neg90";
69
+ };
70
+ var calcFixedTranslate = (deg, axis, length) => {
71
+ const abs = Math.abs(deg);
72
+ if (abs === 0 || abs === 360) return [0, 0, 0];
73
+ if (abs === 180) return [0, 0, length];
74
+ const changeHalf = (deg < 0 ? -length : length) / 2;
75
+ const half = length / 2;
76
+ if (axis === "Y") return [changeHalf, 0, half];
77
+ return abs === 90 ? [0, -changeHalf, half] : [0, changeHalf, half];
78
+ };
79
+ var variableTranslateTable = {
80
+ Y: {
81
+ odd: {
82
+ zero: () => [0, 0, 0],
83
+ pos90: (_l, e) => [e, 0, 0],
84
+ half: (l, e) => [e * 2 - l, 0, e],
85
+ neg90: (l, e) => [e - l, 0, e]
86
+ },
87
+ even: {
88
+ zero: () => [0, 0, 0],
89
+ pos90: (l, e) => [e, 0, -(e - l)],
90
+ half: (l, e) => [e, 0, l],
91
+ neg90: (_l, e) => [0, 0, e]
92
+ }
93
+ },
94
+ X: {
95
+ odd: {
96
+ zero: () => [0, 0, 0],
97
+ pos90: (l, e) => [0, e - l, e],
98
+ half: (l, e) => [0, e * 2 - l, e],
99
+ neg90: (_l, e) => [0, e, 0]
100
+ },
101
+ even: {
102
+ zero: () => [0, 0, 0],
103
+ pos90: (_l, e) => [0, 0, e],
104
+ half: (l, e) => [0, e, l],
105
+ neg90: (l, e) => [0, e, -(e - l)]
106
+ }
107
+ }
108
+ };
109
+ var adjustTranslateTable = {
110
+ Y: {
111
+ odd: {
112
+ zero: () => [0, 0, 0],
113
+ pos90: (_l, e) => [0, 0, e],
114
+ half: (l, e) => [-l, 0, e],
115
+ neg90: (l, _e) => [-l, 0, 0]
116
+ },
117
+ even: {
118
+ zero: () => [0, 0, 0],
119
+ pos90: (l, _e) => [0, 0, l],
120
+ half: (l, e) => [-e, 0, l],
121
+ neg90: (_l, e) => [-e, 0, 0]
122
+ }
123
+ },
124
+ X: {
125
+ odd: {
126
+ zero: () => [0, 0, 0],
127
+ pos90: (l, _e) => [0, -l, 0],
128
+ half: (l, e) => [0, -l, e],
129
+ neg90: (_l, e) => [0, 0, e]
130
+ },
131
+ even: {
132
+ zero: () => [0, 0, 0],
133
+ pos90: (_l, e) => [0, -e, 0],
134
+ half: (l, e) => [0, -e, l],
135
+ neg90: (l, _e) => [0, 0, l]
136
+ }
137
+ }
138
+ };
139
+ var lookupTranslate = (table, deg, faceNum, geometry) => table[geometry.axis][getFaceParity(faceNum)][classifyDeg(deg)](geometry.length, geometry.even);
140
+ var calcFaceTransform = (currentFace, faceNum, options) => {
141
+ const { geometry } = options;
142
+ const deg = calcDeg(currentFace, faceNum, options);
143
+ const [x, y, z] = geometry.kind === "fixed" ? calcFixedTranslate(deg, geometry.axis, geometry.length) : lookupTranslate(variableTranslateTable, deg, faceNum, geometry);
144
+ const transformOrigin = geometry.kind === "fixed" ? TRANSFORM_ORIGIN_CENTER : geometry.axis === "X" ? `50% ${geometry.even}px` : `${geometry.even}px 50%`;
145
+ return { axis: geometry.axis, deg, x, y, z, zIndex: calcZIndex(deg), transformOrigin };
146
+ };
147
+ var calcAdjustFaceTransform = (currentFace, faceNum, options) => {
148
+ const { geometry } = options;
149
+ const deg = calcDeg(currentFace, faceNum, options);
150
+ const [x, y, z] = geometry.kind === "variable" ? lookupTranslate(adjustTranslateTable, deg, faceNum, geometry) : [0, 0, 0];
151
+ const transformOrigin = geometry.axis === "X" ? TRANSFORM_ORIGIN_TOP_EDGE : TRANSFORM_ORIGIN_LEFT_EDGE;
152
+ return { axis: geometry.axis, deg, x, y, z, zIndex: calcZIndex(deg), transformOrigin };
153
+ };
154
+
155
+ export {
156
+ MAX_FACE_PCS,
157
+ DEFAULT_DURATION,
158
+ DEFAULT_DELAY,
159
+ DEFAULT_EASING,
160
+ DEFAULT_PERSPECTIVE,
161
+ DEFAULT_SIZE,
162
+ DEFAULT_HEIGHT,
163
+ normalizeOptions,
164
+ getFaceParity,
165
+ calcFaceTransform,
166
+ calcAdjustFaceTransform
167
+ };
@@ -0,0 +1,183 @@
1
+ // src/normalize.ts
2
+ var MAX_FACE_PCS = 4;
3
+ var DEFAULT_DURATION = 200;
4
+ var DEFAULT_DELAY = 0;
5
+ var DEFAULT_EASING = "linear";
6
+ var DEFAULT_PERSPECTIVE = 800;
7
+ var DEFAULT_SIZE = 200;
8
+ var DEFAULT_HEIGHT = 50;
9
+ var normalizeOptions = (options) => {
10
+ const faces = Math.min(options.faces, MAX_FACE_PCS);
11
+ const axis = options.axis ?? "X";
12
+ const direction = options.direction ?? "positive";
13
+ const duration = options.duration ?? DEFAULT_DURATION;
14
+ const delay = options.delay ?? DEFAULT_DELAY;
15
+ const easing = options.easing ?? DEFAULT_EASING;
16
+ const perspective = options.perspective ?? DEFAULT_PERSPECTIVE;
17
+ const width = options.width ?? DEFAULT_SIZE;
18
+ const height = options.height ?? DEFAULT_HEIGHT;
19
+ const even = options.even ?? (axis === "Y" ? width : height);
20
+ const length = axis === "Y" ? width : height;
21
+ const fixed = even === length;
22
+ const rawType = options.type ?? "real";
23
+ const type = !fixed && rawType === "skip" ? "real" : rawType;
24
+ const geometry = fixed ? { kind: "fixed", axis, length } : { kind: "variable", axis, length, even };
25
+ return { faces, direction, type, duration, delay, easing, perspective, geometry };
26
+ };
27
+
28
+ // src/types.ts
29
+ var VIRTUAL_PREV_WRAP = 0;
30
+ var VIRTUAL_NEXT_WRAP = 5;
31
+
32
+ // src/transform.ts
33
+ var TRANSFORM_ORIGIN_CENTER = "50% 50%";
34
+ var TRANSFORM_ORIGIN_TOP_EDGE = "50% 0px";
35
+ var TRANSFORM_ORIGIN_LEFT_EDGE = "0px 50%";
36
+ var getFaceParity = (faceNum) => faceNum % 2 !== 0 ? "odd" : "even";
37
+ var calcBaseDeg = (currentFace, faceNum) => (currentFace - faceNum) * -90;
38
+ var isSkipWrapEdge = (currentFace, faceNum) => currentFace === MAX_FACE_PCS && faceNum === 1 || currentFace === 1 && faceNum === MAX_FACE_PCS;
39
+ var applyAnimationType = (deg, currentFace, faceNum, type) => {
40
+ if (type === "skip") {
41
+ const clamped = Math.sign(deg) * 90;
42
+ return isSkipWrapEdge(currentFace, faceNum) ? clamped * -1 : clamped;
43
+ }
44
+ if (type === "repeat") {
45
+ if (getFaceParity(currentFace) === "odd" && getFaceParity(faceNum) === "even") return 90;
46
+ if (getFaceParity(currentFace) === "even" && getFaceParity(faceNum) === "odd") return -90;
47
+ }
48
+ return deg;
49
+ };
50
+ var applyDirection = (deg, direction) => {
51
+ if (direction !== "negative") return deg;
52
+ const flipped = deg * -1;
53
+ return Object.is(flipped, -0) ? 0 : flipped;
54
+ };
55
+ var calcDeg = (currentFace, faceNum, options) => {
56
+ const base = calcBaseDeg(currentFace, faceNum);
57
+ const typed = applyAnimationType(base, currentFace, faceNum, options.type);
58
+ return applyDirection(typed, options.direction);
59
+ };
60
+ var faceVisibility = (deg) => {
61
+ const abs = Math.abs(deg);
62
+ if (abs === 0 || abs === 360) return "front";
63
+ if (abs === 90 || abs === 270) return "side";
64
+ return "hidden";
65
+ };
66
+ var Z_INDEX = { front: 20, side: 10, hidden: 0 };
67
+ var calcZIndex = (deg) => Z_INDEX[faceVisibility(deg)];
68
+ var classifyDeg = (deg) => {
69
+ if (deg === 0 || Math.abs(deg) === 360) return "zero";
70
+ if (deg === 90 || deg === -270) return "pos90";
71
+ if (Math.abs(deg) === 180) return "half";
72
+ return "neg90";
73
+ };
74
+ var calcFixedTranslate = (deg, axis, length) => {
75
+ const abs = Math.abs(deg);
76
+ if (abs === 0 || abs === 360) return [0, 0, 0];
77
+ if (abs === 180) return [0, 0, length];
78
+ const changeHalf = (deg < 0 ? -length : length) / 2;
79
+ const half = length / 2;
80
+ if (axis === "Y") return [changeHalf, 0, half];
81
+ return abs === 90 ? [0, -changeHalf, half] : [0, changeHalf, half];
82
+ };
83
+ var variableTranslateTable = {
84
+ Y: {
85
+ odd: {
86
+ zero: () => [0, 0, 0],
87
+ pos90: (_l, e) => [e, 0, 0],
88
+ half: (l, e) => [e * 2 - l, 0, e],
89
+ neg90: (l, e) => [e - l, 0, e]
90
+ },
91
+ even: {
92
+ zero: () => [0, 0, 0],
93
+ pos90: (l, e) => [e, 0, -(e - l)],
94
+ half: (l, e) => [e, 0, l],
95
+ neg90: (_l, e) => [0, 0, e]
96
+ }
97
+ },
98
+ X: {
99
+ odd: {
100
+ zero: () => [0, 0, 0],
101
+ pos90: (l, e) => [0, e - l, e],
102
+ half: (l, e) => [0, e * 2 - l, e],
103
+ neg90: (_l, e) => [0, e, 0]
104
+ },
105
+ even: {
106
+ zero: () => [0, 0, 0],
107
+ pos90: (_l, e) => [0, 0, e],
108
+ half: (l, e) => [0, e, l],
109
+ neg90: (l, e) => [0, e, -(e - l)]
110
+ }
111
+ }
112
+ };
113
+ var adjustTranslateTable = {
114
+ Y: {
115
+ odd: {
116
+ zero: () => [0, 0, 0],
117
+ pos90: (_l, e) => [0, 0, e],
118
+ half: (l, e) => [-l, 0, e],
119
+ neg90: (l, _e) => [-l, 0, 0]
120
+ },
121
+ even: {
122
+ zero: () => [0, 0, 0],
123
+ pos90: (l, _e) => [0, 0, l],
124
+ half: (l, e) => [-e, 0, l],
125
+ neg90: (_l, e) => [-e, 0, 0]
126
+ }
127
+ },
128
+ X: {
129
+ odd: {
130
+ zero: () => [0, 0, 0],
131
+ pos90: (l, _e) => [0, -l, 0],
132
+ half: (l, e) => [0, -l, e],
133
+ neg90: (_l, e) => [0, 0, e]
134
+ },
135
+ even: {
136
+ zero: () => [0, 0, 0],
137
+ pos90: (_l, e) => [0, -e, 0],
138
+ half: (l, e) => [0, -e, l],
139
+ neg90: (l, _e) => [0, 0, l]
140
+ }
141
+ }
142
+ };
143
+ var lookupTranslate = (table, deg, faceNum, geometry) => table[geometry.axis][getFaceParity(faceNum)][classifyDeg(deg)](geometry.length, geometry.even);
144
+ var calcFaceTransform = (currentFace, faceNum, options) => {
145
+ const { geometry } = options;
146
+ const deg = calcDeg(currentFace, faceNum, options);
147
+ const [x, y, z] = geometry.kind === "fixed" ? calcFixedTranslate(deg, geometry.axis, geometry.length) : lookupTranslate(variableTranslateTable, deg, faceNum, geometry);
148
+ const transformOrigin = geometry.kind === "fixed" ? TRANSFORM_ORIGIN_CENTER : geometry.axis === "X" ? `50% ${geometry.even}px` : `${geometry.even}px 50%`;
149
+ return { axis: geometry.axis, deg, x, y, z, zIndex: calcZIndex(deg), transformOrigin };
150
+ };
151
+ var calcAdjustFaceTransform = (currentFace, faceNum, options) => {
152
+ const { geometry } = options;
153
+ const deg = calcDeg(currentFace, faceNum, options);
154
+ const [x, y, z] = geometry.kind === "variable" ? lookupTranslate(adjustTranslateTable, deg, faceNum, geometry) : [0, 0, 0];
155
+ const transformOrigin = geometry.axis === "X" ? TRANSFORM_ORIGIN_TOP_EDGE : TRANSFORM_ORIGIN_LEFT_EDGE;
156
+ return { axis: geometry.axis, deg, x, y, z, zIndex: calcZIndex(deg), transformOrigin };
157
+ };
158
+ var calcPrePositionTransform = (via, opts) => {
159
+ const { geometry, direction } = opts;
160
+ const dirSign = direction === "negative" ? -1 : 1;
161
+ const shortDeg = (via === VIRTUAL_NEXT_WRAP ? 90 : -90) * dirSign;
162
+ const half = geometry.length / 2;
163
+ const changeHalf = shortDeg < 0 ? -half : half;
164
+ const [x, y, z] = geometry.axis === "Y" ? [changeHalf, 0, half] : [0, -changeHalf, half];
165
+ return `rotate${geometry.axis}(${shortDeg}deg) translate3d(${x}px, ${y}px, ${z}px)`;
166
+ };
167
+
168
+ export {
169
+ MAX_FACE_PCS,
170
+ DEFAULT_DURATION,
171
+ DEFAULT_DELAY,
172
+ DEFAULT_EASING,
173
+ DEFAULT_PERSPECTIVE,
174
+ DEFAULT_SIZE,
175
+ DEFAULT_HEIGHT,
176
+ normalizeOptions,
177
+ VIRTUAL_PREV_WRAP,
178
+ VIRTUAL_NEXT_WRAP,
179
+ getFaceParity,
180
+ calcFaceTransform,
181
+ calcAdjustFaceTransform,
182
+ calcPrePositionTransform
183
+ };
@@ -0,0 +1,159 @@
1
+ // src/normalize.ts
2
+ var MAX_FACE_PCS = 4;
3
+ var DEFAULT_DURATION = 800;
4
+ var DEFAULT_DELAY = 50;
5
+ var DEFAULT_SIZE = 200;
6
+ var normalizeOptions = (options) => {
7
+ const faces = Math.min(options.faces, MAX_FACE_PCS);
8
+ const axis = options.axis ?? "X";
9
+ const direction = options.direction ?? "positive";
10
+ const duration = options.duration ?? DEFAULT_DURATION;
11
+ const delay = options.delay ?? DEFAULT_DELAY;
12
+ const width = options.width ?? DEFAULT_SIZE;
13
+ const height = options.height ?? DEFAULT_SIZE;
14
+ const even = options.even ?? (axis === "Y" ? width : height);
15
+ const length = axis === "Y" ? width : height;
16
+ const fixed = even === length;
17
+ const rawType = options.type ?? "real";
18
+ const type = !fixed && rawType === "skip" ? "real" : rawType;
19
+ const geometry = fixed ? { kind: "fixed", axis, length } : { kind: "variable", axis, length, even };
20
+ return { faces, direction, type, duration, delay, geometry };
21
+ };
22
+
23
+ // src/transform.ts
24
+ var TRANSFORM_ORIGIN_CENTER = "50% 50%";
25
+ var TRANSFORM_ORIGIN_TOP_EDGE = "50% 0px";
26
+ var TRANSFORM_ORIGIN_LEFT_EDGE = "0px 50%";
27
+ var getFaceParity = (faceNum) => faceNum % 2 !== 0 ? "odd" : "even";
28
+ var calcBaseDeg = (currentFace, faceNum) => (currentFace - faceNum) * -90;
29
+ var isSkipWrapEdge = (currentFace, faceNum) => currentFace === MAX_FACE_PCS && faceNum === 1 || currentFace === 1 && faceNum === MAX_FACE_PCS;
30
+ var applyAnimationType = (deg, currentFace, faceNum, type) => {
31
+ if (type === "skip") {
32
+ const clamped = Math.sign(deg) * 90;
33
+ return isSkipWrapEdge(currentFace, faceNum) ? clamped * -1 : clamped;
34
+ }
35
+ if (type === "repeat") {
36
+ if (getFaceParity(currentFace) === "odd" && getFaceParity(faceNum) === "even") return 90;
37
+ if (getFaceParity(currentFace) === "even" && getFaceParity(faceNum) === "odd") return -90;
38
+ }
39
+ return deg;
40
+ };
41
+ var applyDirection = (deg, direction) => {
42
+ if (direction !== "negative") return deg;
43
+ const flipped = deg * -1;
44
+ return Object.is(flipped, -0) ? 0 : flipped;
45
+ };
46
+ var calcDeg = (currentFace, faceNum, options) => {
47
+ const base = calcBaseDeg(currentFace, faceNum);
48
+ const typed = applyAnimationType(base, currentFace, faceNum, options.type);
49
+ return applyDirection(typed, options.direction);
50
+ };
51
+ var faceVisibility = (deg) => {
52
+ const abs = Math.abs(deg);
53
+ if (abs === 0 || abs === 360) return "front";
54
+ if (abs === 90 || abs === 270) return "side";
55
+ return "hidden";
56
+ };
57
+ var Z_INDEX = { front: 20, side: 10, hidden: 0 };
58
+ var calcZIndex = (deg) => Z_INDEX[faceVisibility(deg)];
59
+ var classifyDeg = (deg) => {
60
+ if (deg === 0 || Math.abs(deg) === 360) return "zero";
61
+ if (deg === 90 || deg === -270) return "pos90";
62
+ if (Math.abs(deg) === 180) return "half";
63
+ return "neg90";
64
+ };
65
+ var calcFixedTranslate = (deg, axis, length) => {
66
+ const abs = Math.abs(deg);
67
+ if (abs === 0 || abs === 360) return [0, 0, 0];
68
+ if (abs === 180) return [0, 0, length];
69
+ const changeHalf = (deg < 0 ? -length : length) / 2;
70
+ const half = length / 2;
71
+ if (axis === "Y") return [changeHalf, 0, half];
72
+ return abs === 90 ? [0, -changeHalf, half] : [0, changeHalf, half];
73
+ };
74
+ var variableTranslateTable = {
75
+ Y: {
76
+ odd: {
77
+ zero: () => [0, 0, 0],
78
+ pos90: (_l, e) => [e, 0, 0],
79
+ half: (l, e) => [e * 2 - l, 0, e],
80
+ neg90: (l, e) => [e - l, 0, e]
81
+ },
82
+ even: {
83
+ zero: () => [0, 0, 0],
84
+ pos90: (l, e) => [e, 0, -(e - l)],
85
+ half: (l, e) => [e, 0, l],
86
+ neg90: (_l, e) => [0, 0, e]
87
+ }
88
+ },
89
+ X: {
90
+ odd: {
91
+ zero: () => [0, 0, 0],
92
+ pos90: (l, e) => [0, e - l, e],
93
+ half: (l, e) => [0, e * 2 - l, e],
94
+ neg90: (_l, e) => [0, e, 0]
95
+ },
96
+ even: {
97
+ zero: () => [0, 0, 0],
98
+ pos90: (_l, e) => [0, 0, e],
99
+ half: (l, e) => [0, e, l],
100
+ neg90: (l, e) => [0, e, -(e - l)]
101
+ }
102
+ }
103
+ };
104
+ var adjustTranslateTable = {
105
+ Y: {
106
+ odd: {
107
+ zero: () => [0, 0, 0],
108
+ pos90: (_l, e) => [0, 0, e],
109
+ half: (l, e) => [-l, 0, e],
110
+ neg90: (l, _e) => [-l, 0, 0]
111
+ },
112
+ even: {
113
+ zero: () => [0, 0, 0],
114
+ pos90: (l, _e) => [0, 0, l],
115
+ half: (l, e) => [-e, 0, l],
116
+ neg90: (_l, e) => [-e, 0, 0]
117
+ }
118
+ },
119
+ X: {
120
+ odd: {
121
+ zero: () => [0, 0, 0],
122
+ pos90: (l, _e) => [0, -l, 0],
123
+ half: (l, e) => [0, -l, e],
124
+ neg90: (_l, e) => [0, 0, e]
125
+ },
126
+ even: {
127
+ zero: () => [0, 0, 0],
128
+ pos90: (_l, e) => [0, -e, 0],
129
+ half: (l, e) => [0, -e, l],
130
+ neg90: (l, _e) => [0, 0, l]
131
+ }
132
+ }
133
+ };
134
+ var lookupTranslate = (table, deg, faceNum, geometry) => table[geometry.axis][getFaceParity(faceNum)][classifyDeg(deg)](geometry.length, geometry.even);
135
+ var calcFaceTransform = (currentFace, faceNum, options) => {
136
+ const { geometry } = options;
137
+ const deg = calcDeg(currentFace, faceNum, options);
138
+ const [x, y, z] = geometry.kind === "fixed" ? calcFixedTranslate(deg, geometry.axis, geometry.length) : lookupTranslate(variableTranslateTable, deg, faceNum, geometry);
139
+ const transformOrigin = geometry.kind === "fixed" ? TRANSFORM_ORIGIN_CENTER : geometry.axis === "X" ? `50% ${geometry.even}px` : `${geometry.even}px 50%`;
140
+ return { axis: geometry.axis, deg, x, y, z, zIndex: calcZIndex(deg), transformOrigin };
141
+ };
142
+ var calcAdjustFaceTransform = (currentFace, faceNum, options) => {
143
+ const { geometry } = options;
144
+ const deg = calcDeg(currentFace, faceNum, options);
145
+ const [x, y, z] = geometry.kind === "variable" ? lookupTranslate(adjustTranslateTable, deg, faceNum, geometry) : [0, 0, 0];
146
+ const transformOrigin = geometry.axis === "X" ? TRANSFORM_ORIGIN_TOP_EDGE : TRANSFORM_ORIGIN_LEFT_EDGE;
147
+ return { axis: geometry.axis, deg, x, y, z, zIndex: calcZIndex(deg), transformOrigin };
148
+ };
149
+
150
+ export {
151
+ MAX_FACE_PCS,
152
+ DEFAULT_DURATION,
153
+ DEFAULT_DELAY,
154
+ DEFAULT_SIZE,
155
+ normalizeOptions,
156
+ getFaceParity,
157
+ calcFaceTransform,
158
+ calcAdjustFaceTransform
159
+ };