@siberiacancode/reactuse 0.0.114 → 0.0.115

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,94 +1,99 @@
1
- import { useState as h, useEffect as k } from "react";
2
- import { useDeviceOrientation as R } from "../useDeviceOrientation/useDeviceOrientation.mjs";
3
- import { useMouse as T } from "../useMouse/useMouse.mjs";
4
- import { useRefState as x } from "../useRefState/useRefState.mjs";
5
- import { useScreenOrientation as j } from "../useScreenOrientation/useScreenOrientation.mjs";
6
- import { isTarget as w } from "../../utils/helpers/isTarget.mjs";
7
- const E = (...r) => {
8
- const u = w(r[0]) ? r[0] : void 0, v = r[1] ? r[1] : r[0], c = x(), a = T(u ?? c), i = j(), t = R(), {
9
- deviceOrientationRollAdjust: d = (n) => n,
10
- deviceOrientationTiltAdjust: p = (n) => n,
11
- mouseRollAdjust: f = (n) => n,
12
- mouseTiltAdjust: g = (n) => n
13
- } = v ?? {}, [m, b] = h({
1
+ import { useState as x, useEffect as B } from "react";
2
+ import { useDeviceOrientation as C } from "../useDeviceOrientation/useDeviceOrientation.mjs";
3
+ import { useRefState as D } from "../useRefState/useRefState.mjs";
4
+ import { useScreenOrientation as P } from "../useScreenOrientation/useScreenOrientation.mjs";
5
+ import { isTarget as X } from "../../utils/helpers/isTarget.mjs";
6
+ import { getElement as Y } from "../../utils/helpers/getElement.mjs";
7
+ const G = (...a) => {
8
+ const n = X(a[0]) ? a[0] : void 0, p = a[1] ? a[1] : a[0], i = D(), s = P(), e = C(), {
9
+ deviceOrientationRollAdjust: g = (o) => o,
10
+ deviceOrientationTiltAdjust: f = (o) => o,
11
+ mouseRollAdjust: b = (o) => o,
12
+ mouseTiltAdjust: y = (o) => o
13
+ } = p ?? {}, [u, O] = x({
14
14
  roll: 0,
15
15
  tilt: 0,
16
16
  source: "mouse"
17
- }), s = () => t.supported && (t.value.alpha || t.value.gamma) ? "deviceOrientation" : "mouse", y = () => {
18
- if (s() === "deviceOrientation") {
19
- let e;
20
- switch (i.value.orientationType) {
21
- case "landscape-primary":
22
- e = t.value.gamma / 90;
23
- break;
24
- case "landscape-secondary":
25
- e = -t.value.gamma / 90;
26
- break;
27
- case "portrait-primary":
28
- e = -t.value.beta / 90;
29
- break;
30
- case "portrait-secondary":
31
- e = t.value.beta / 90;
32
- break;
33
- default:
34
- e = -t.value.beta / 90;
35
- }
36
- return d(e);
37
- } else {
38
- if (!a.element) return 0;
39
- const e = a.y - a.elementPositionY, o = a.element.getBoundingClientRect().height, l = -(e - o / 2) / o;
40
- return f(l);
41
- }
42
- }, O = () => {
43
- if (s() === "deviceOrientation") {
44
- let e;
45
- switch (i.value.orientationType) {
46
- case "landscape-primary":
47
- e = t.value.beta / 90;
48
- break;
49
- case "landscape-secondary":
50
- e = -t.value.beta / 90;
51
- break;
52
- case "portrait-primary":
53
- e = t.value.gamma / 90;
54
- break;
55
- case "portrait-secondary":
56
- e = -t.value.gamma / 90;
57
- break;
58
- default:
59
- e = t.value.gamma / 90;
60
- }
61
- return p(e);
62
- } else {
63
- if (!a.element) return 0;
64
- const e = a.x - a.elementPositionX, o = a.element.getBoundingClientRect().width, l = (e - o / 2) / o;
65
- return g(l);
66
- }
67
- };
68
- return k(() => {
69
- if (!a.element) return;
70
- const n = s(), e = y(), o = O();
71
- b({
72
- roll: e,
73
- source: n,
74
- tilt: o
75
- });
17
+ });
18
+ return B(() => {
19
+ if (!n && !i.state) return;
20
+ const o = n ? Y(n) : i.current;
21
+ if (!o) return;
22
+ console.log("element", o);
23
+ const m = (v) => {
24
+ const { left: h, top: k } = o.getBoundingClientRect(), w = h + window.scrollX, R = k + window.scrollY, c = () => e.supported && (e.value.alpha || e.value.gamma) ? "deviceOrientation" : "mouse", T = () => {
25
+ if (c() === "deviceOrientation") {
26
+ let t;
27
+ switch (s.value.orientationType) {
28
+ case "landscape-primary":
29
+ t = e.value.gamma / 90;
30
+ break;
31
+ case "landscape-secondary":
32
+ t = -e.value.gamma / 90;
33
+ break;
34
+ case "portrait-primary":
35
+ t = -e.value.beta / 90;
36
+ break;
37
+ case "portrait-secondary":
38
+ t = e.value.beta / 90;
39
+ break;
40
+ default:
41
+ t = -e.value.beta / 90;
42
+ }
43
+ return g(t);
44
+ } else {
45
+ const t = v.pageY - R, r = o.getBoundingClientRect().height, l = -(t - r / 2) / r;
46
+ return b(l);
47
+ }
48
+ }, j = () => {
49
+ if (c() === "deviceOrientation") {
50
+ let t;
51
+ switch (s.value.orientationType) {
52
+ case "landscape-primary":
53
+ t = e.value.beta / 90;
54
+ break;
55
+ case "landscape-secondary":
56
+ t = -e.value.beta / 90;
57
+ break;
58
+ case "portrait-primary":
59
+ t = e.value.gamma / 90;
60
+ break;
61
+ case "portrait-secondary":
62
+ t = -e.value.gamma / 90;
63
+ break;
64
+ default:
65
+ t = e.value.gamma / 90;
66
+ }
67
+ return f(t);
68
+ } else {
69
+ const t = v.pageX - w, r = o.getBoundingClientRect().width, l = (t - r / 2) / r;
70
+ return y(l);
71
+ }
72
+ }, A = c(), E = T(), S = j();
73
+ O({
74
+ roll: E,
75
+ source: A,
76
+ tilt: S
77
+ });
78
+ };
79
+ return document.addEventListener("mousemove", m), () => {
80
+ document.removeEventListener("mousemove", m);
81
+ };
76
82
  }, [
77
- i.value.angle,
78
- i.value.orientationType,
79
- t.value.gamma,
80
- t.value.beta,
81
- t.value.alpha,
82
- t.value.absolute,
83
- a.x,
84
- a.y,
85
- a.element
86
- ]), u ? { value: m } : {
87
- ref: c,
88
- value: m
83
+ n,
84
+ i.state,
85
+ s.value.angle,
86
+ s.value.orientationType,
87
+ e.value.gamma,
88
+ e.value.beta,
89
+ e.value.alpha,
90
+ e.value.absolute
91
+ ]), n ? { value: u } : {
92
+ ref: i,
93
+ value: u
89
94
  };
90
95
  };
91
96
  export {
92
- E as useParallax
97
+ G as useParallax
93
98
  };
94
99
  //# sourceMappingURL=useParallax.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"useParallax.mjs","sources":["../../../../src/hooks/useParallax/useParallax.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useDeviceOrientation } from '../useDeviceOrientation/useDeviceOrientation';\nimport { useMouse } from '../useMouse/useMouse';\nimport { useRefState } from '../useRefState/useRefState';\nimport { useScreenOrientation } from '../useScreenOrientation/useScreenOrientation';\n\n/** The use parallax value type */\nexport interface UseParallaxValue {\n /** Roll value. Scaled to `-0.5 ~ 0.5` */\n roll: number;\n /** Sensor source, can be `mouse` or `deviceOrientation` */\n source: 'deviceOrientation' | 'mouse';\n /** Tilt value. Scaled to `-0.5 ~ 0.5` */\n tilt: number;\n}\n\n/** The use parallax options type */\nexport interface UseParallaxOptions {\n /** Device orientation roll adjust function */\n deviceOrientationRollAdjust?: (value: number) => number;\n /** Device orientation tilt adjust function */\n deviceOrientationTiltAdjust?: (value: number) => number;\n /** Mouse roll adjust function */\n mouseRollAdjust?: (value: number) => number;\n /** Mouse tilt adjust function */\n mouseTiltAdjust?: (value: number) => number;\n}\n\ninterface UseParallaxReturn {\n value: UseParallaxValue;\n}\n\nexport interface UseParallax {\n (target: HookTarget, options?: UseParallaxOptions): UseParallaxReturn;\n\n <Target extends Element>(\n options?: UseParallaxOptions,\n target?: never\n ): UseParallaxReturn & {\n ref: StateRef<Target>;\n };\n}\n\n/**\n * @name useParallax\n * @description - Hook to help create parallax effect\n * @category Sensors\n *\n * @overload\n * @param {HookTarget} target The target element for the parallax effect\n * @param {UseParallaxOptions} options The options for the parallax effect\n * @returns {UseParallaxReturn} An object of parallax values\n *\n * @example\n * const { value } = useParallax(ref);\n *\n * @overload\n * @template Target The target element for the parallax effect\n * @param {UseParallaxOptions} options The options for the parallax effect\n * @returns {UseParallaxReturn & { ref: StateRef<Target> }} An object of parallax values\n *\n * @example\n * const { ref, value } = useParallax();\n */\nexport const useParallax = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const options = (params[1] ? params[1] : params[0]) as UseParallaxOptions | undefined;\n\n const internalRef = useRefState<Element>();\n\n const mouse = useMouse(target ?? internalRef);\n const screenOrientation = useScreenOrientation();\n const deviceOrientation = useDeviceOrientation();\n\n const {\n deviceOrientationRollAdjust = (value) => value,\n deviceOrientationTiltAdjust = (value) => value,\n mouseRollAdjust = (value) => value,\n mouseTiltAdjust = (value) => value\n } = (options ?? {}) as UseParallaxOptions;\n\n const [value, setValue] = useState({\n roll: 0,\n tilt: 0,\n source: 'mouse'\n });\n\n const getSource = () => {\n const isDeviceOrientation =\n deviceOrientation.supported &&\n (deviceOrientation.value.alpha || deviceOrientation.value.gamma);\n\n if (isDeviceOrientation) return 'deviceOrientation';\n return 'mouse';\n };\n\n const getRoll = () => {\n const source = getSource();\n if (source === 'deviceOrientation') {\n let value: number;\n switch (screenOrientation.value.orientationType) {\n case 'landscape-primary':\n value = deviceOrientation.value.gamma! / 90;\n break;\n case 'landscape-secondary':\n value = -deviceOrientation.value.gamma! / 90;\n break;\n case 'portrait-primary':\n value = -deviceOrientation.value.beta! / 90;\n break;\n case 'portrait-secondary':\n value = deviceOrientation.value.beta! / 90;\n break;\n default:\n value = -deviceOrientation.value.beta! / 90;\n }\n return deviceOrientationRollAdjust(value);\n } else {\n if (!mouse.element) return 0;\n const y = mouse.y - mouse.elementPositionY;\n const height = mouse.element.getBoundingClientRect().height;\n const value = -(y - height / 2) / height;\n return mouseRollAdjust(value);\n }\n };\n\n const getTilt = () => {\n const source = getSource();\n if (source === 'deviceOrientation') {\n let value: number;\n switch (screenOrientation.value.orientationType) {\n case 'landscape-primary':\n value = deviceOrientation.value.beta! / 90;\n break;\n case 'landscape-secondary':\n value = -deviceOrientation.value.beta! / 90;\n break;\n case 'portrait-primary':\n value = deviceOrientation.value.gamma! / 90;\n break;\n case 'portrait-secondary':\n value = -deviceOrientation.value.gamma! / 90;\n break;\n default:\n value = deviceOrientation.value.gamma! / 90;\n }\n return deviceOrientationTiltAdjust(value);\n } else {\n if (!mouse.element) return 0;\n const x = mouse.x - mouse.elementPositionX;\n const width = mouse.element.getBoundingClientRect().width;\n const value = (x - width / 2) / width;\n return mouseTiltAdjust(value);\n }\n };\n\n useEffect(() => {\n if (!mouse.element) return;\n\n const source = getSource();\n const roll = getRoll();\n const tilt = getTilt();\n\n setValue({\n roll,\n source,\n tilt\n });\n }, [\n screenOrientation.value.angle,\n screenOrientation.value.orientationType,\n deviceOrientation.value.gamma,\n deviceOrientation.value.beta,\n deviceOrientation.value.alpha,\n deviceOrientation.value.absolute,\n mouse.x,\n mouse.y,\n mouse.element\n ]);\n\n if (target) return { value };\n\n return {\n ref: internalRef,\n value\n };\n}) as UseParallax;\n"],"names":["useParallax","params","target","isTarget","options","internalRef","useRefState","mouse","useMouse","screenOrientation","useScreenOrientation","deviceOrientation","useDeviceOrientation","deviceOrientationRollAdjust","value","deviceOrientationTiltAdjust","mouseRollAdjust","mouseTiltAdjust","setValue","useState","getSource","getRoll","y","height","getTilt","x","width","useEffect","source","roll","tilt"],"mappings":";;;;;;AAuEa,MAAAA,IAAe,IAAIC,MAAkB;AAC1C,QAAAC,IAAUC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAC5CG,IAAWH,EAAO,CAAC,IAAIA,EAAO,CAAC,IAAIA,EAAO,CAAC,GAE3CI,IAAcC,EAAqB,GAEnCC,IAAQC,EAASN,KAAUG,CAAW,GACtCI,IAAoBC,EAAqB,GACzCC,IAAoBC,EAAqB,GAEzC;AAAA,IACJ,6BAAAC,IAA8B,CAACC,MAAUA;AAAAA,IACzC,6BAAAC,IAA8B,CAACD,MAAUA;AAAAA,IACzC,iBAAAE,IAAkB,CAACF,MAAUA;AAAAA,IAC7B,iBAAAG,IAAkB,CAACH,MAAUA;AAAAA,EAC/B,IAAKV,KAAW,CAAC,GAEX,CAACU,GAAOI,CAAQ,IAAIC,EAAS;AAAA,IACjC,MAAM;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IAAQH,EAAkB,MAAM,QAAS;AAAA,MAAA;AAE7C,aAAOI,EAA4BD,CAAK;AAAA,IAAA,OACnC;AACD,UAAA,CAACP,EAAM,QAAgB,QAAA;AACrB,YAAAkB,IAAIlB,EAAM,IAAIA,EAAM,kBACpBmB,IAAQnB,EAAM,QAAQ,sBAAwB,EAAA,OAC9CO,KAASW,IAAIC,IAAQ,KAAKA;AAChC,aAAOT,EAAgBH,CAAK;AAAA,IAAA;AAAA,EAEhC;AA0BI,SAxBJa,EAAU,MAAM;AACV,QAAA,CAACpB,EAAM,QAAS;AAEpB,UAAMqB,IAASR,EAAU,GACnBS,IAAOR,EAAQ,GACfS,IAAON,EAAQ;AAEZ,IAAAN,EAAA;AAAA,MACP,MAAAW;AAAA,MACA,QAAAD;AAAA,MACA,MAAAE;AAAA,IAAA,CACD;AAAA,EAAA,GACA;AAAA,IACDrB,EAAkB,MAAM;AAAA,IACxBA,EAAkB,MAAM;AAAA,IACxBE,EAAkB,MAAM;AAAA,IACxBA,EAAkB,MAAM;AAAA,IACxBA,EAAkB,MAAM;AAAA,IACxBA,EAAkB,MAAM;AAAA,IACxBJ,EAAM;AAAA,IACNA,EAAM;AAAA,IACNA,EAAM;AAAA,EAAA,CACP,GAEGL,IAAe,EAAE,OAAAY,EAAM,IAEpB;AAAA,IACL,KAAKT;AAAA,IACL,OAAAS;AAAA,EACF;AACF;"}
1
+ {"version":3,"file":"useParallax.mjs","sources":["../../../../src/hooks/useParallax/useParallax.ts"],"sourcesContent":["import { useEffect, useState } from 'react';\n\nimport type { HookTarget } from '@/utils/helpers';\n\nimport { getElement, isTarget } from '@/utils/helpers';\n\nimport type { StateRef } from '../useRefState/useRefState';\n\nimport { useDeviceOrientation } from '../useDeviceOrientation/useDeviceOrientation';\nimport { useRefState } from '../useRefState/useRefState';\nimport { useScreenOrientation } from '../useScreenOrientation/useScreenOrientation';\n\n/** The use parallax value type */\nexport interface UseParallaxValue {\n /** Roll value. Scaled to `-0.5 ~ 0.5` */\n roll: number;\n /** Sensor source, can be `mouse` or `deviceOrientation` */\n source: 'deviceOrientation' | 'mouse';\n /** Tilt value. Scaled to `-0.5 ~ 0.5` */\n tilt: number;\n}\n\n/** The use parallax options type */\nexport interface UseParallaxOptions {\n /** Device orientation roll adjust function */\n deviceOrientationRollAdjust?: (value: number) => number;\n /** Device orientation tilt adjust function */\n deviceOrientationTiltAdjust?: (value: number) => number;\n /** Mouse roll adjust function */\n mouseRollAdjust?: (value: number) => number;\n /** Mouse tilt adjust function */\n mouseTiltAdjust?: (value: number) => number;\n}\n\ninterface UseParallaxReturn {\n value: UseParallaxValue;\n}\n\nexport interface UseParallax {\n (target: HookTarget, options?: UseParallaxOptions): UseParallaxReturn;\n\n <Target extends Element>(\n options?: UseParallaxOptions,\n target?: never\n ): UseParallaxReturn & {\n ref: StateRef<Target>;\n };\n}\n\n/**\n * @name useParallax\n * @description - Hook to help create parallax effect\n * @category Sensors\n *\n * @overload\n * @param {HookTarget} target The target element for the parallax effect\n * @param {UseParallaxOptions} options The options for the parallax effect\n * @returns {UseParallaxReturn} An object of parallax values\n *\n * @example\n * const { value } = useParallax(ref);\n *\n * @overload\n * @template Target The target element for the parallax effect\n * @param {UseParallaxOptions} options The options for the parallax effect\n * @returns {UseParallaxReturn & { ref: StateRef<Target> }} An object of parallax values\n *\n * @example\n * const { ref, value } = useParallax();\n */\nexport const useParallax = ((...params: any[]) => {\n const target = (isTarget(params[0]) ? params[0] : undefined) as HookTarget | undefined;\n const options = (params[1] ? params[1] : params[0]) as UseParallaxOptions | undefined;\n\n const internalRef = useRefState<Element>();\n\n const screenOrientation = useScreenOrientation();\n const deviceOrientation = useDeviceOrientation();\n\n const {\n deviceOrientationRollAdjust = (value) => value,\n deviceOrientationTiltAdjust = (value) => value,\n mouseRollAdjust = (value) => value,\n mouseTiltAdjust = (value) => value\n } = (options ?? {}) as UseParallaxOptions;\n\n const [value, setValue] = useState({\n roll: 0,\n tilt: 0,\n source: 'mouse'\n });\n\n useEffect(() => {\n if (!target && !internalRef.state) return;\n\n const element = (target ? getElement(target) : internalRef.current) as Element;\n if (!element) return;\n\n console.log('element', element);\n const onMouseMove = (event: MouseEvent) => {\n const { left, top } = element.getBoundingClientRect();\n const elementPositionX = left + window.scrollX;\n const elementPositionY = top + window.scrollY;\n\n const getSource = () => {\n const isDeviceOrientation =\n deviceOrientation.supported &&\n (deviceOrientation.value.alpha || deviceOrientation.value.gamma);\n\n if (isDeviceOrientation) return 'deviceOrientation';\n return 'mouse';\n };\n\n const getRoll = () => {\n const source = getSource();\n if (source === 'deviceOrientation') {\n let value: number;\n switch (screenOrientation.value.orientationType) {\n case 'landscape-primary':\n value = deviceOrientation.value.gamma! / 90;\n break;\n case 'landscape-secondary':\n value = -deviceOrientation.value.gamma! / 90;\n break;\n case 'portrait-primary':\n value = -deviceOrientation.value.beta! / 90;\n break;\n case 'portrait-secondary':\n value = deviceOrientation.value.beta! / 90;\n break;\n default:\n value = -deviceOrientation.value.beta! / 90;\n }\n return deviceOrientationRollAdjust(value);\n } else {\n const y = event.pageY - elementPositionY;\n const height = element.getBoundingClientRect().height;\n const value = -(y - height / 2) / height;\n return mouseRollAdjust(value);\n }\n };\n\n const getTilt = () => {\n const source = getSource();\n if (source === 'deviceOrientation') {\n let value: number;\n switch (screenOrientation.value.orientationType) {\n case 'landscape-primary':\n value = deviceOrientation.value.beta! / 90;\n break;\n case 'landscape-secondary':\n value = -deviceOrientation.value.beta! / 90;\n break;\n case 'portrait-primary':\n value = deviceOrientation.value.gamma! / 90;\n break;\n case 'portrait-secondary':\n value = -deviceOrientation.value.gamma! / 90;\n break;\n default:\n value = deviceOrientation.value.gamma! / 90;\n }\n return deviceOrientationTiltAdjust(value);\n } else {\n const x = event.pageX - elementPositionX;\n const width = element.getBoundingClientRect().width;\n const value = (x - width / 2) / width;\n return mouseTiltAdjust(value);\n }\n };\n\n const source = getSource();\n const roll = getRoll();\n const tilt = getTilt();\n\n setValue({\n roll,\n source,\n tilt\n });\n };\n\n document.addEventListener('mousemove', onMouseMove);\n return () => {\n document.removeEventListener('mousemove', onMouseMove);\n };\n }, [\n target,\n internalRef.state,\n screenOrientation.value.angle,\n screenOrientation.value.orientationType,\n deviceOrientation.value.gamma,\n deviceOrientation.value.beta,\n deviceOrientation.value.alpha,\n deviceOrientation.value.absolute\n ]);\n\n if (target) return { value };\n\n return {\n ref: internalRef,\n value\n };\n}) as UseParallax;\n"],"names":["useParallax","params","target","isTarget","options","internalRef","useRefState","screenOrientation","useScreenOrientation","deviceOrientation","useDeviceOrientation","deviceOrientationRollAdjust","value","deviceOrientationTiltAdjust","mouseRollAdjust","mouseTiltAdjust","setValue","useState","useEffect","element","getElement","onMouseMove","event","left","top","elementPositionX","elementPositionY","getSource","getRoll","y","height","getTilt","x","width","source","roll","tilt"],"mappings":";;;;;;AAsEa,MAAAA,IAAe,IAAIC,MAAkB;AAC1C,QAAAC,IAAUC,EAASF,EAAO,CAAC,CAAC,IAAIA,EAAO,CAAC,IAAI,QAC5CG,IAAWH,EAAO,CAAC,IAAIA,EAAO,CAAC,IAAIA,EAAO,CAAC,GAE3CI,IAAcC,EAAqB,GAEnCC,IAAoBC,EAAqB,GACzCC,IAAoBC,EAAqB,GAEzC;AAAA,IACJ,6BAAAC,IAA8B,CAACC,MAAUA;AAAAA,IACzC,6BAAAC,IAA8B,CAACD,MAAUA;AAAAA,IACzC,iBAAAE,IAAkB,CAACF,MAAUA;AAAAA,IAC7B,iBAAAG,IAAkB,CAACH,MAAUA;AAAAA,EAC/B,IAAKR,KAAW,CAAC,GAEX,CAACQ,GAAOI,CAAQ,IAAIC,EAAS;AAAA,IACjC,MAAM;AAAA,IACN,MAAM;AAAA,IACN,QAAQ;AAAA,EAAA,CACT;AA2GG,SAzGJC,EAAU,MAAM;AACd,QAAI,CAAChB,KAAU,CAACG,EAAY,MAAO;AAEnC,UAAMc,IAAWjB,IAASkB,EAAWlB,CAAM,IAAIG,EAAY;AAC3D,QAAI,CAACc,EAAS;AAEN,YAAA,I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