This commit is contained in:
2025-09-19 14:25:20 +08:00
parent 269893a435
commit fbf3f77229
24949 changed files with 2839404 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
export * from './use-content';
export * from './use-content-dom';
export * from './use-focus-trap';

View File

@@ -0,0 +1,14 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var useContent = require('./use-content.js');
var useContentDom = require('./use-content-dom.js');
var useFocusTrap = require('./use-focus-trap.js');
exports.usePopperContent = useContent.usePopperContent;
exports.usePopperContentDOM = useContentDom.usePopperContentDOM;
exports.usePopperContentFocusTrap = useFocusTrap.usePopperContentFocusTrap;
//# sourceMappingURL=index.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;"}

View File

@@ -0,0 +1,40 @@
import type { CSSProperties, StyleValue } from 'vue';
import type { UsePopperReturn } from 'element-plus/es/hooks';
import type { UsePopperContentReturn } from './use-content';
import type { PopperContentProps } from '../content';
export declare const usePopperContentDOM: (props: PopperContentProps, { attributes, styles, role, }: Pick<UsePopperReturn, "attributes" | "styles"> & Pick<UsePopperContentReturn, "role">) => {
ariaModal: import("vue").ComputedRef<string | undefined>;
arrowStyle: import("vue").ComputedRef<CSSProperties>;
contentAttrs: import("vue").ComputedRef<{
[key: string]: string | boolean;
}>;
contentClass: import("vue").ComputedRef<((string | {
[x: string]: boolean;
} | (string | {
[x: string]: boolean;
} | (string | {
[x: string]: boolean;
} | (string | {
[x: string]: boolean;
} | (string | {
[x: string]: boolean;
} | (string | {
[x: string]: boolean;
} | (string | {
[x: string]: boolean;
} | (string | {
[x: string]: boolean;
} | (string | {
[x: string]: boolean;
} | (string | {
[x: string]: boolean;
} | (string | {
[x: string]: boolean;
} | (string | {
[x: string]: boolean;
} | any)[])[])[])[])[])[])[])[])[])[])[]) | undefined)[]>;
contentStyle: import("vue").ComputedRef<StyleValue[]>;
contentZIndex: import("vue").Ref<number>;
updateZIndex: () => void;
};
export type UsePopperContentDOMReturn = ReturnType<typeof usePopperContentDOM>;

View File

@@ -0,0 +1,49 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var index = require('../../../../hooks/use-z-index/index.js');
var index$1 = require('../../../../hooks/use-namespace/index.js');
var types = require('../../../../utils/types.js');
const usePopperContentDOM = (props, {
attributes,
styles,
role
}) => {
const { nextZIndex } = index.useZIndex();
const ns = index$1.useNamespace("popper");
const contentAttrs = vue.computed(() => vue.unref(attributes).popper);
const contentZIndex = vue.ref(types.isNumber(props.zIndex) ? props.zIndex : nextZIndex());
const contentClass = vue.computed(() => [
ns.b(),
ns.is("pure", props.pure),
ns.is(props.effect),
props.popperClass
]);
const contentStyle = vue.computed(() => {
return [
{ zIndex: vue.unref(contentZIndex) },
vue.unref(styles).popper,
props.popperStyle || {}
];
});
const ariaModal = vue.computed(() => role.value === "dialog" ? "false" : void 0);
const arrowStyle = vue.computed(() => vue.unref(styles).arrow || {});
const updateZIndex = () => {
contentZIndex.value = types.isNumber(props.zIndex) ? props.zIndex : nextZIndex();
};
return {
ariaModal,
arrowStyle,
contentAttrs,
contentClass,
contentStyle,
contentZIndex,
updateZIndex
};
};
exports.usePopperContentDOM = usePopperContentDOM;
//# sourceMappingURL=use-content-dom.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"use-content-dom.js","sources":["../../../../../../../packages/components/popper/src/composables/use-content-dom.ts"],"sourcesContent":["import { computed, ref, unref } from 'vue'\nimport { useNamespace, useZIndex } from '@element-plus/hooks'\nimport { isNumber } from '@element-plus/utils'\n\nimport type { CSSProperties, StyleValue } from 'vue'\nimport type { UsePopperReturn } from '@element-plus/hooks'\nimport type { UsePopperContentReturn } from './use-content'\nimport type { PopperContentProps } from '../content'\n\nexport const usePopperContentDOM = (\n props: PopperContentProps,\n {\n attributes,\n styles,\n role,\n }: Pick<UsePopperReturn, 'attributes' | 'styles'> &\n Pick<UsePopperContentReturn, 'role'>\n) => {\n const { nextZIndex } = useZIndex()\n const ns = useNamespace('popper')\n\n const contentAttrs = computed(() => unref(attributes).popper)\n const contentZIndex = ref<number>(\n isNumber(props.zIndex) ? props.zIndex : nextZIndex()\n )\n const contentClass = computed(() => [\n ns.b(),\n ns.is('pure', props.pure),\n ns.is(props.effect),\n props.popperClass,\n ])\n const contentStyle = computed<StyleValue[]>(() => {\n return [\n { zIndex: unref(contentZIndex) } as CSSProperties,\n unref(styles).popper as CSSProperties,\n props.popperStyle || {},\n ]\n })\n const ariaModal = computed<string | undefined>(() =>\n role.value === 'dialog' ? 'false' : undefined\n )\n const arrowStyle = computed(\n () => (unref(styles).arrow || {}) as CSSProperties\n )\n\n const updateZIndex = () => {\n contentZIndex.value = isNumber(props.zIndex) ? props.zIndex : nextZIndex()\n }\n\n return {\n ariaModal,\n arrowStyle,\n contentAttrs,\n contentClass,\n contentStyle,\n contentZIndex,\n\n updateZIndex,\n }\n}\n\nexport type UsePopperContentDOMReturn = ReturnType<typeof usePopperContentDOM>\n"],"names":["useZIndex","useNamespace","computed","unref","ref","isNumber"],"mappings":";;;;;;;;;AAGY,MAAC,mBAAmB,GAAG,CAAC,KAAK,EAAE;AAC3C,EAAE,UAAU;AACZ,EAAE,MAAM;AACR,EAAE,IAAI;AACN,CAAC,KAAK;AACN,EAAE,MAAM,EAAE,UAAU,EAAE,GAAGA,eAAS,EAAE,CAAC;AACrC,EAAE,MAAM,EAAE,GAAGC,oBAAY,CAAC,QAAQ,CAAC,CAAC;AACpC,EAAE,MAAM,YAAY,GAAGC,YAAQ,CAAC,MAAMC,SAAK,CAAC,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC;AAChE,EAAE,MAAM,aAAa,GAAGC,OAAG,CAACC,cAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC,CAAC;AAClF,EAAE,MAAM,YAAY,GAAGH,YAAQ,CAAC,MAAM;AACtC,IAAI,EAAE,CAAC,CAAC,EAAE;AACV,IAAI,EAAE,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC,IAAI,CAAC;AAC7B,IAAI,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;AACvB,IAAI,KAAK,CAAC,WAAW;AACrB,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,YAAY,GAAGA,YAAQ,CAAC,MAAM;AACtC,IAAI,OAAO;AACX,MAAM,EAAE,MAAM,EAAEC,SAAK,CAAC,aAAa,CAAC,EAAE;AACtC,MAAMA,SAAK,CAAC,MAAM,CAAC,CAAC,MAAM;AAC1B,MAAM,KAAK,CAAC,WAAW,IAAI,EAAE;AAC7B,KAAK,CAAC;AACN,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,SAAS,GAAGD,YAAQ,CAAC,MAAM,IAAI,CAAC,KAAK,KAAK,QAAQ,GAAG,OAAO,GAAG,KAAK,CAAC,CAAC,CAAC;AAC/E,EAAE,MAAM,UAAU,GAAGA,YAAQ,CAAC,MAAMC,SAAK,CAAC,MAAM,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;AAC/D,EAAE,MAAM,YAAY,GAAG,MAAM;AAC7B,IAAI,aAAa,CAAC,KAAK,GAAGE,cAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;AAC/E,GAAG,CAAC;AACJ,EAAE,OAAO;AACT,IAAI,SAAS;AACb,IAAI,UAAU;AACd,IAAI,YAAY;AAChB,IAAI,YAAY;AAChB,IAAI,YAAY;AAChB,IAAI,aAAa;AACjB,IAAI,YAAY;AAChB,GAAG,CAAC;AACJ;;;;"}

View File

@@ -0,0 +1,77 @@
import type { Modifier } from '@popperjs/core';
import type { PopperContentProps } from '../content';
export declare const usePopperContent: (props: PopperContentProps) => {
attributes: import("vue").ComputedRef<{
[key: string]: {
[key: string]: string | boolean;
};
}>;
arrowRef: import("vue").Ref<HTMLElement | undefined>;
contentRef: import("vue").Ref<HTMLElement | undefined>;
instanceRef: import("vue").ComputedRef<import("@popperjs/core").Instance | undefined>;
state: import("vue").ComputedRef<{
elements?: {
reference: Element | import("@popperjs/core").VirtualElement;
popper: HTMLElement;
arrow?: HTMLElement;
} | undefined;
options?: import("@popperjs/core").OptionsGeneric<any> | undefined;
placement?: import("@popperjs/core").Placement | undefined;
strategy?: import("@popperjs/core").PositioningStrategy | undefined;
orderedModifiers?: Modifier<any, any>[] | undefined;
rects?: import("@popperjs/core").StateRects | undefined;
scrollParents?: {
reference: Array<Element | import("@popperjs/core").Window | import("@popperjs/core").VisualViewport>;
popper: Array<Element | import("@popperjs/core").Window | import("@popperjs/core").VisualViewport>;
} | undefined;
styles?: {
[key: string]: Partial<CSSStyleDeclaration>;
} | undefined;
attributes?: {
[key: string]: {
[key: string]: string | boolean;
};
} | undefined;
modifiersData?: {
[key: string]: any;
arrow?: {
x?: number;
y?: number;
centerOffset: number;
};
hide?: {
isReferenceHidden: boolean;
hasPopperEscaped: boolean;
referenceClippingOffsets: import("@popperjs/core").SideObject;
popperEscapeOffsets: import("@popperjs/core").SideObject;
};
offset?: {
top?: import("@popperjs/core").Offsets | undefined;
bottom?: import("@popperjs/core").Offsets | undefined;
left?: import("@popperjs/core").Offsets | undefined;
right?: import("@popperjs/core").Offsets | undefined;
auto?: import("@popperjs/core").Offsets | undefined;
"auto-start"?: import("@popperjs/core").Offsets | undefined;
"auto-end"?: import("@popperjs/core").Offsets | undefined;
"top-start"?: import("@popperjs/core").Offsets | undefined;
"top-end"?: import("@popperjs/core").Offsets | undefined;
"bottom-start"?: import("@popperjs/core").Offsets | undefined;
"bottom-end"?: import("@popperjs/core").Offsets | undefined;
"right-start"?: import("@popperjs/core").Offsets | undefined;
"right-end"?: import("@popperjs/core").Offsets | undefined;
"left-start"?: import("@popperjs/core").Offsets | undefined;
"left-end"?: import("@popperjs/core").Offsets | undefined;
};
preventOverflow?: import("@popperjs/core").Offsets;
popperOffsets?: import("@popperjs/core").Offsets;
} | undefined;
reset?: boolean | undefined;
}>;
styles: import("vue").ComputedRef<{
[key: string]: Partial<CSSStyleDeclaration>;
}>;
role: import("vue").ComputedRef<string>;
forceUpdate: () => void | undefined;
update: () => Promise<Partial<import("@popperjs/core").State>> | undefined;
};
export type UsePopperContentReturn = ReturnType<typeof usePopperContent>;

View File

@@ -0,0 +1,73 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
var lodashUnified = require('lodash-unified');
var constants = require('../constants.js');
var utils = require('../utils.js');
var index = require('../../../../hooks/use-popper/index.js');
const DEFAULT_ARROW_OFFSET = 0;
const usePopperContent = (props) => {
const { popperInstanceRef, contentRef, triggerRef, role } = vue.inject(constants.POPPER_INJECTION_KEY, void 0);
const arrowRef = vue.ref();
const arrowOffset = vue.computed(() => props.arrowOffset);
const eventListenerModifier = vue.computed(() => {
return {
name: "eventListeners",
enabled: !!props.visible
};
});
const arrowModifier = vue.computed(() => {
var _a;
const arrowEl = vue.unref(arrowRef);
const offset = (_a = vue.unref(arrowOffset)) != null ? _a : DEFAULT_ARROW_OFFSET;
return {
name: "arrow",
enabled: !lodashUnified.isUndefined(arrowEl),
options: {
element: arrowEl,
padding: offset
}
};
});
const options = vue.computed(() => {
return {
onFirstUpdate: () => {
update();
},
...utils.buildPopperOptions(props, [
vue.unref(arrowModifier),
vue.unref(eventListenerModifier)
])
};
});
const computedReference = vue.computed(() => utils.unwrapMeasurableEl(props.referenceEl) || vue.unref(triggerRef));
const { attributes, state, styles, update, forceUpdate, instanceRef } = index.usePopper(computedReference, contentRef, options);
vue.watch(instanceRef, (instance) => popperInstanceRef.value = instance, {
flush: "sync"
});
vue.onMounted(() => {
vue.watch(() => {
var _a, _b;
return (_b = (_a = vue.unref(computedReference)) == null ? void 0 : _a.getBoundingClientRect) == null ? void 0 : _b.call(_a);
}, () => {
update();
});
});
return {
attributes,
arrowRef,
contentRef,
instanceRef,
state,
styles,
role,
forceUpdate,
update
};
};
exports.usePopperContent = usePopperContent;
//# sourceMappingURL=use-content.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"use-content.js","sources":["../../../../../../../packages/components/popper/src/composables/use-content.ts"],"sourcesContent":["import { computed, inject, onMounted, ref, unref, watch } from 'vue'\nimport { isUndefined } from 'lodash-unified'\nimport { usePopper } from '@element-plus/hooks'\nimport { POPPER_INJECTION_KEY } from '../constants'\nimport { buildPopperOptions, unwrapMeasurableEl } from '../utils'\n\nimport type { Modifier } from '@popperjs/core'\nimport type { PartialOptions } from '@element-plus/hooks'\nimport type { PopperContentProps } from '../content'\n\nconst DEFAULT_ARROW_OFFSET = 0\n\nexport const usePopperContent = (props: PopperContentProps) => {\n const { popperInstanceRef, contentRef, triggerRef, role } = inject(\n POPPER_INJECTION_KEY,\n undefined\n )!\n\n const arrowRef = ref<HTMLElement>()\n const arrowOffset = computed(() => props.arrowOffset)\n\n const eventListenerModifier = computed(() => {\n return {\n name: 'eventListeners',\n enabled: !!props.visible,\n } as Modifier<'eventListeners', any>\n })\n\n const arrowModifier = computed(() => {\n const arrowEl = unref(arrowRef)\n const offset = unref(arrowOffset) ?? DEFAULT_ARROW_OFFSET\n // Seems like the `phase` and `fn` is required by Modifier type\n // But on its documentation they didn't specify that.\n // Refer to https://popper.js.org/docs/v2/modifiers/arrow/\n return {\n name: 'arrow',\n enabled: !isUndefined(arrowEl),\n options: {\n element: arrowEl,\n padding: offset,\n },\n } as any\n })\n\n const options = computed<PartialOptions>(() => {\n return {\n onFirstUpdate: () => {\n update()\n },\n ...buildPopperOptions(props, [\n unref(arrowModifier),\n unref(eventListenerModifier),\n ]),\n }\n })\n\n const computedReference = computed(\n () => unwrapMeasurableEl(props.referenceEl) || unref(triggerRef)\n )\n\n const { attributes, state, styles, update, forceUpdate, instanceRef } =\n usePopper(computedReference, contentRef, options)\n\n watch(instanceRef, (instance) => (popperInstanceRef.value = instance), {\n flush: 'sync',\n })\n\n onMounted(() => {\n watch(\n () => unref(computedReference)?.getBoundingClientRect?.(),\n () => {\n update()\n }\n )\n })\n\n return {\n attributes,\n arrowRef,\n contentRef,\n instanceRef,\n state,\n styles,\n role,\n\n forceUpdate,\n update,\n }\n}\n\nexport type UsePopperContentReturn = ReturnType<typeof usePopperContent>\n"],"names":["inject","POPPER_INJECTION_KEY","ref","computed","unref","isUndefined","buildPopperOptions","unwrapMeasurableEl","usePopper","watch","onMounted"],"mappings":";;;;;;;;;;AAKA,MAAM,oBAAoB,GAAG,CAAC,CAAC;AACnB,MAAC,gBAAgB,GAAG,CAAC,KAAK,KAAK;AAC3C,EAAE,MAAM,EAAE,iBAAiB,EAAE,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,GAAGA,UAAM,CAACC,8BAAoB,EAAE,KAAK,CAAC,CAAC,CAAC;AACnG,EAAE,MAAM,QAAQ,GAAGC,OAAG,EAAE,CAAC;AACzB,EAAE,MAAM,WAAW,GAAGC,YAAQ,CAAC,MAAM,KAAK,CAAC,WAAW,CAAC,CAAC;AACxD,EAAE,MAAM,qBAAqB,GAAGA,YAAQ,CAAC,MAAM;AAC/C,IAAI,OAAO;AACX,MAAM,IAAI,EAAE,gBAAgB;AAC5B,MAAM,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO;AAC9B,KAAK,CAAC;AACN,GAAG,CAAC,CAAC;AACL,EAAE,MAAM,aAAa,GAAGA,YAAQ,CAAC,MAAM;AACvC,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,MAAM,OAAO,GAAGC,SAAK,CAAC,QAAQ,CAAC,CAAC;AACpC,IAAI,MAAM,MAAM,GAAG,CAAC,EAAE,GAAGA,SAAK,CAAC,WAAW,CAAC,KAAK,IAAI,GAAG,EAAE,GAAG,oBAAoB,CAAC;AACjF,IAAI,OAAO;AACX,MAAM,IAAI,EAAE,OAAO;AACnB,MAAM,OAAO,EAAE,CAACC,yBAAW,CAAC,OAAO,CAAC;AACpC,MAAM,OAAO,EAAE;AACf,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,OAAO,EAAE,MA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AC,CAAC;AACL,EAAE,OAAO;AACT,IAAI,UAAU;AACd,IAAI,QAAQ;AACZ,IAAI,UAAU;AACd,IAAI,WAAW;AACf,IAAI,KAAK;AACT,IAAI,MAAM;AACV,IAAI,IAAI;AACR,IAAI,WAAW;AACf,IAAI,MAAM;AACV,GAAG,CAAC;AACJ;;;;"}

View File

@@ -0,0 +1,12 @@
import type { SetupContext } from 'vue';
import type { PopperContentEmits, PopperContentProps } from '../content';
export declare const usePopperContentFocusTrap: (props: PopperContentProps, emit: SetupContext<PopperContentEmits>["emit"]) => {
focusStartRef: import("vue").Ref<HTMLElement | "first" | "container" | undefined>;
trapped: import("vue").Ref<boolean>;
onFocusAfterReleased: (event: CustomEvent) => void;
onFocusAfterTrapped: () => void;
onFocusInTrap: (event: FocusEvent) => void;
onFocusoutPrevented: (event: CustomEvent) => void;
onReleaseRequested: () => void;
};
export type UsePopperContentFocusTrapReturn = ReturnType<typeof usePopperContentFocusTrap>;

View File

@@ -0,0 +1,52 @@
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var vue = require('vue');
const usePopperContentFocusTrap = (props, emit) => {
const trapped = vue.ref(false);
const focusStartRef = vue.ref();
const onFocusAfterTrapped = () => {
emit("focus");
};
const onFocusAfterReleased = (event) => {
var _a;
if (((_a = event.detail) == null ? void 0 : _a.focusReason) !== "pointer") {
focusStartRef.value = "first";
emit("blur");
}
};
const onFocusInTrap = (event) => {
if (props.visible && !trapped.value) {
if (event.target) {
focusStartRef.value = event.target;
}
trapped.value = true;
}
};
const onFocusoutPrevented = (event) => {
if (!props.trapping) {
if (event.detail.focusReason === "pointer") {
event.preventDefault();
}
trapped.value = false;
}
};
const onReleaseRequested = () => {
trapped.value = false;
emit("close");
};
return {
focusStartRef,
trapped,
onFocusAfterReleased,
onFocusAfterTrapped,
onFocusInTrap,
onFocusoutPrevented,
onReleaseRequested
};
};
exports.usePopperContentFocusTrap = usePopperContentFocusTrap;
//# sourceMappingURL=use-focus-trap.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"use-focus-trap.js","sources":["../../../../../../../packages/components/popper/src/composables/use-focus-trap.ts"],"sourcesContent":["import { ref } from 'vue'\n\nimport type { SetupContext } from 'vue'\nimport type { PopperContentEmits, PopperContentProps } from '../content'\n\nexport const usePopperContentFocusTrap = (\n props: PopperContentProps,\n emit: SetupContext<PopperContentEmits>['emit']\n) => {\n const trapped = ref(false)\n const focusStartRef = ref<'container' | 'first' | HTMLElement>()\n\n const onFocusAfterTrapped = () => {\n emit('focus')\n }\n\n const onFocusAfterReleased = (event: CustomEvent) => {\n if (event.detail?.focusReason !== 'pointer') {\n focusStartRef.value = 'first'\n emit('blur')\n }\n }\n\n const onFocusInTrap = (event: FocusEvent) => {\n if (props.visible && !trapped.value) {\n if (event.target) {\n focusStartRef.value = event.target as typeof focusStartRef.value\n }\n trapped.value = true\n }\n }\n\n const onFocusoutPrevented = (event: CustomEvent) => {\n if (!props.trapping) {\n if (event.detail.focusReason === 'pointer') {\n event.preventDefault()\n }\n trapped.value = false\n }\n }\n\n const onReleaseRequested = () => {\n trapped.value = false\n emit('close')\n }\n\n return {\n focusStartRef,\n trapped,\n\n onFocusAfterReleased,\n onFocusAfterTrapped,\n onFocusInTrap,\n onFocusoutPrevented,\n onReleaseRequested,\n }\n}\n\nexport type UsePopperContentFocusTrapReturn = ReturnType<\n typeof usePopperContentFocusTrap\n>\n"],"names":["ref"],"mappings":";;;;;;AACY,MAAC,yBAAyB,GAAG,CAAC,KAAK,EAAE,IAAI,KAAK;AAC1D,EAAE,MAAM,OAAO,GAAGA,OAAG,CAAC,KAAK,CAAC,CAAC;AAC7B,EAAE,MAAM,aAAa,GAAGA,OAAG,EAAE,CAAC;AAC9B,EAAE,MAAM,mBAAmB,GAAG,MAAM;AACpC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;AAClB,GAAG,CAAC;AACJ,EAAE,MAAM,oBAAoB,GAAG,CAAC,KAAK,KAAK;AAC1C,IAAI,IAAI,EAAE,CAA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