"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useFileItem = void 0;
const sdk_1 = require("@cntrl-site/sdk");
const useKeyframeValue_1 = require("../../common/useKeyframeValue");
const useLayoutContext_1 = require("../useLayoutContext");
const DEFAULT_COLOR = 'rgba(0, 0, 0, 1)';
const useFileItem = (item, sectionId) => {
    const layoutId = (0, useLayoutContext_1.useLayoutContext)();
    const radius = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderRadius, (item, layoutId) => {
        if (!layoutId)
            return;
        const layoutParams = item.layoutParams[layoutId];
        return 'radius' in layoutParams ? layoutParams.radius : 0;
    }, (animator, scroll, value) => value !== undefined ? animator.getRadius({ radius: value }, scroll).radius : undefined, sectionId, [layoutId]);
    const strokeWidth = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderWidth, (item, layoutId) => {
        if (!layoutId)
            return;
        const layoutParams = item.layoutParams[layoutId];
        return 'strokeWidth' in layoutParams ? layoutParams.strokeWidth : 0;
    }, (animator, scroll, value) => value !== undefined ? animator.getBorderWidth({ borderWidth: value }, scroll).borderWidth : undefined, sectionId, [layoutId]);
    const opacity = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Opacity, (item, layoutId) => {
        if (!layoutId)
            return;
        const layoutParams = item.layoutParams[layoutId];
        return 'opacity' in layoutParams ? layoutParams.opacity : 1;
    }, (animator, scroll, value) => value !== undefined ? animator.getOpacity({ opacity: value }, scroll).opacity : undefined, sectionId, [layoutId]);
    const strokeColor = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.BorderColor, (item, layoutId) => {
        if (!layoutId)
            return;
        const layoutParams = item.layoutParams[layoutId];
        return 'strokeColor' in layoutParams ? layoutParams.strokeColor : DEFAULT_COLOR;
    }, (animator, scroll, value) => value ? animator.getBorderColor({ color: value }, scroll).color : undefined, sectionId, [layoutId]);
    const blur = (0, useKeyframeValue_1.useKeyframeValue)(item, sdk_1.KeyframeType.Blur, (item, layoutId) => {
        if (!layoutId)
            return;
        const layoutParams = item.layoutParams[layoutId];
        return 'blur' in layoutParams ? layoutParams.blur : 0;
    }, (animator, scroll, value) => value !== undefined ? animator.getBlur({ blur: value }, scroll).blur : undefined, sectionId, [layoutId]);
    return { radius, strokeWidth, opacity, strokeColor, blur };
};
exports.useFileItem = useFileItem;
