"use strict";
var __webpack_require__ = {};
(()=>{
    __webpack_require__.d = (exports1, definition)=>{
        for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
            enumerable: true,
            get: definition[key]
        });
    };
})();
(()=>{
    __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
})();
(()=>{
    __webpack_require__.r = (exports1)=>{
        if ("u" > typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
            value: 'Module'
        });
        Object.defineProperty(exports1, '__esModule', {
            value: true
        });
    };
})();
var __webpack_exports__ = {};
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
    animateViewport: ()=>animateViewport,
    prefersReducedMotion: ()=>prefersReducedMotion,
    TRANSITION_CONFIG: ()=>TRANSITION_CONFIG,
    ANIMATION_CONSTANTS: ()=>ANIMATION_CONSTANTS,
    calculateNodeFocusViewport: ()=>calculateNodeFocusViewport,
    getCanvasSize: ()=>getCanvasSize,
    animateDrillOut: ()=>animateDrillOut,
    animateDrillIn: ()=>animateDrillIn
});
const external_motion_namespaceObject = require("motion");
const ANIMATION_CONSTANTS = {
    MAX_ZOOM: 3,
    NODE_FOCUS_PADDING: 0.1,
    DEFAULT_CANVAS_WIDTH: 800,
    DEFAULT_CANVAS_HEIGHT: 600,
    TRANSITION_TIMEOUT: 5000
};
const TRANSITION_CONFIG = {
    drillDuration: 0.4,
    viewportDuration: 0.3,
    easing: {
        drillIn: [
            0.4,
            0,
            0.2,
            1
        ],
        drillOut: [
            0.4,
            0,
            0.2,
            1
        ],
        viewport: [
            0.25,
            0.1,
            0.25,
            1
        ]
    }
};
function calculateNodeFocusViewport(nodeBounds, canvasSize, padding = 0.1) {
    const paddingX = canvasSize.width * padding;
    const paddingY = canvasSize.height * padding;
    const availableWidth = canvasSize.width - 2 * paddingX;
    const availableHeight = canvasSize.height - 2 * paddingY;
    const scaleX = availableWidth / nodeBounds.width;
    const scaleY = availableHeight / nodeBounds.height;
    const zoom = Math.min(scaleX, scaleY, ANIMATION_CONSTANTS.MAX_ZOOM);
    const centerX = nodeBounds.x + nodeBounds.width / 2;
    const centerY = nodeBounds.y + nodeBounds.height / 2;
    const x = canvasSize.width / 2 - centerX * zoom;
    const y = canvasSize.height / 2 - centerY * zoom;
    return {
        x,
        y,
        zoom
    };
}
async function animateViewport(fromViewport, toViewport, duration = TRANSITION_CONFIG.viewportDuration, onUpdate, onComplete) {
    return new Promise((resolve)=>{
        (0, external_motion_namespaceObject.animate)(fromViewport, toViewport, {
            duration,
            ease: TRANSITION_CONFIG.easing.viewport,
            onUpdate: (latest)=>{
                if (onUpdate) onUpdate(latest);
            },
            onComplete: ()=>{
                if (onComplete) onComplete();
                resolve();
            }
        });
    });
}
async function animateDrillIn(fromViewport, nodeViewport, onUpdate, onComplete) {
    return new Promise((resolve)=>{
        (0, external_motion_namespaceObject.animate)(fromViewport, nodeViewport, {
            duration: TRANSITION_CONFIG.drillDuration,
            ease: TRANSITION_CONFIG.easing.drillIn,
            onUpdate: (latest)=>{
                if (onUpdate) onUpdate(latest);
            },
            onComplete: ()=>{
                if (onComplete) onComplete();
                resolve();
            }
        });
    });
}
async function animateDrillOut(fromViewport, parentViewport, onUpdate, onComplete) {
    return new Promise((resolve)=>{
        (0, external_motion_namespaceObject.animate)(fromViewport, parentViewport, {
            duration: TRANSITION_CONFIG.drillDuration,
            ease: TRANSITION_CONFIG.easing.drillOut,
            onUpdate: (latest)=>{
                if (onUpdate) onUpdate(latest);
            },
            onComplete: ()=>{
                if (onComplete) onComplete();
                resolve();
            }
        });
    });
}
function getCanvasSize(containerElement) {
    if (!containerElement) return {
        width: ANIMATION_CONSTANTS.DEFAULT_CANVAS_WIDTH,
        height: ANIMATION_CONSTANTS.DEFAULT_CANVAS_HEIGHT
    };
    const rect = containerElement.getBoundingClientRect();
    return {
        width: rect.width || ANIMATION_CONSTANTS.DEFAULT_CANVAS_WIDTH,
        height: rect.height || ANIMATION_CONSTANTS.DEFAULT_CANVAS_HEIGHT
    };
}
function prefersReducedMotion() {
    if ("u" < typeof window) return false;
    const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
    return mediaQuery.matches;
}
exports.ANIMATION_CONSTANTS = __webpack_exports__.ANIMATION_CONSTANTS;
exports.TRANSITION_CONFIG = __webpack_exports__.TRANSITION_CONFIG;
exports.animateDrillIn = __webpack_exports__.animateDrillIn;
exports.animateDrillOut = __webpack_exports__.animateDrillOut;
exports.animateViewport = __webpack_exports__.animateViewport;
exports.calculateNodeFocusViewport = __webpack_exports__.calculateNodeFocusViewport;
exports.getCanvasSize = __webpack_exports__.getCanvasSize;
exports.prefersReducedMotion = __webpack_exports__.prefersReducedMotion;
for(var __rspack_i in __webpack_exports__)if (-1 === [
    "ANIMATION_CONSTANTS",
    "TRANSITION_CONFIG",
    "animateDrillIn",
    "animateDrillOut",
    "animateViewport",
    "calculateNodeFocusViewport",
    "getCanvasSize",
    "prefersReducedMotion"
].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
Object.defineProperty(exports, '__esModule', {
    value: true
});
