<?php

namespace Breakdance\Interactions;

add_filter('breakdance_element_dependencies', '\Breakdance\Interactions\addDependencies', 100, 1);

/**
 * @param ElementDependenciesAndConditions[] $deps
 * @return ElementDependenciesAndConditions[]
 */
function addDependencies($deps)
{
    $condition = ['propertyPath' => 'settings.interactions.interactions'];
    $runInBuilder = defined('BREAKDANCE_RUN_INTERACTIONS_IN_BUILDER') && BREAKDANCE_RUN_INTERACTIONS_IN_BUILDER;
    $builderCondition = $runInBuilder ? $condition : 'return false;';

    $deps[] = [
        "frontendCondition" => $condition,
        "builderCondition"  => $builderCondition,
        "scripts" => [
            "%%BREAKDANCE_ELEMENTS_PLUGIN_URL%%dependencies-files/breakdance-interactions@1/dist/interactions.umd.js",
        ]
    ];

    return $deps;
}
