/******/ (() => { // webpackBootstrap
;
(function ($) {
  var app = {
    init: function init() {
      $(window).on('elementor/frontend/init', function () {
        elementorFrontend.hooks.addAction('frontend/element_ready/soft_multimedia_player.default', app.handlePlayerSelection);
      });
    },
    handlePlayerSelection: function handlePlayerSelection($scope) {
      var $select = $scope.find('.player_id');
      if (!$select.length) return;
      $select.select2({
        width: '100%',
        placeholder: wp.i18n.__('Select a player', 'soft-multimedia-player'),
        allowClear: true,
        minimumInputLength: 0,
        minimumResultsForSearch: 0,
        templateResult: app.formatOption,
        templateSelection: app.formatOption
      });
      $select.on('change', function () {
        var selectedId = parseInt(this.value);
        var $parentSelect = window.parent.jQuery('[data-setting="player_id"]');
        $parentSelect.val(selectedId)[0].dispatchEvent(new Event('change', {
          bubbles: true,
          cancelable: true
        }));
      });
    },
    formatOption: function formatOption(data) {
      if (!data.id) return data.text;
      var image = $(data.element).data('image');
      var label = data.text || '';
      if (image) {
        return $("<span class=\"smp-select2-option\"><img src=\"".concat(image, "\" /> ").concat(label, "</span>"));
      }
      return $('<span>').text(label);
    }
  };
  app.init();
})(jQuery);
/******/ })()
;