(function ($) {
        "use strict";
            var WidgetScrollSequenceHandler = function($scope, $) { 
                let is_editable = elementorFrontend?.isEditMode();
                let advanceTogglePricing = $scope[0].querySelector('.wkit-advanced-pricing-with-toggle');
let advanceTogglePricingId = advanceTogglePricing.getAttribute("data-connection-id");

let toggleWget = '';
if(advanceTogglePricingId){
    toggleWget = document.querySelector('.table-'+advanceTogglePricingId);
}

let advancePricing = advanceTogglePricing.querySelector('.wkit-advance-pricing-inner');

let Button = advancePricing.querySelectorAll('.wkit-button');
let priCnt = advanceTogglePricing.querySelectorAll('.wkit-pricing-content');

Button.forEach((el,index)=>{
    if(index==0){
      el.classList.add('active');  
      priCnt[index].classList.add('active');
      
    }
    el.addEventListener("click",(e, ind)=>{
        let tglindex;
        let aButton = advancePricing.querySelector('.wkit-button.active');
        if(aButton){
            aButton.classList.remove('active');
        }
        let apriCnt = advanceTogglePricing.querySelector('.wkit-pricing-content.active');
        if(apriCnt){
            apriCnt.classList.remove('active');
        }
        e.currentTarget.classList.add('active');
        
        Button.forEach((btn,indd)=>{
            if(btn.classList.contains('active')){
                tglindex = indd;
                priCnt[indd].classList.add('active');
            }
        })
        
    // Toggle Table widget Connection
    if(toggleWget){
       let  togglePricing = toggleWget.querySelector('.pricing-number'),
            toggleDiscount = toggleWget.querySelector('.pricing-discount'),
            toggleLink = toggleWget.querySelector('.toggle-pricing-button-link'),
            toggleProductStart = toggleWget.querySelector('.toggle-products-top-start'),
            toggleProductEnd =  toggleWget.querySelector('.toggle-products-top-end'),
            toggleTooltip = toggleWget.querySelector('.toggle-tooltip-text');
    
    
        let togglePricingOn = Number(togglePricing.getAttribute("data-pricing-on")),
            togglePricingOff = Number(togglePricing.getAttribute("data-pricing-off")),
            toggleDiscountOn = Number(toggleDiscount.getAttribute("data-discount-on")),
            toggleDiscountOff = Number(toggleDiscount.getAttribute("data-discount-off")),
            toggleLinkOn = toggleLink.getAttribute("data-link-on"),
            toggleLinkOff = toggleLink.getAttribute("data-link-off"),
            toggleTooltipOn = toggleTooltip.getAttribute("data-tooltip-on"),
            toggleTooltipOff = toggleTooltip.getAttribute("data-tooltip-off");
        
    let toggleSwitch = toggleWget.querySelector('.toggle-checkbtn');
        
        if(tglindex == 1){
            toggleSwitch.checked = true;
            togglePricing.textContent = togglePricingOn;
            toggleDiscount.textContent = toggleDiscountOn;
            toggleLink.href = toggleLinkOn;
            toggleProductEnd.classList.add('active');
            toggleProductStart.classList.remove('active');
            toggleTooltip.textContent = toggleTooltipOn;
       }else{
            toggleSwitch.checked = false;
            togglePricing.textContent = togglePricingOff;
            toggleDiscount.textContent = toggleDiscountOff;
            toggleLink.href = toggleLinkOff;
            toggleProductStart.classList.add('active');
            toggleProductEnd.classList.remove('active');
            toggleTooltip.textContent = toggleTooltipOff;
       }
    }
        
    }); 
});
  
  
            };	
        $(window).on('elementor/frontend/init', function () {
          elementorFrontend.hooks.addAction('frontend/element_ready/wb-i09ulu24.default', WidgetScrollSequenceHandler);
        });
    })(jQuery);