$(document).ready(function(){let key='tx_saasfeetourplanner';let state={step:1,mainCategory:'',subCategory:'',tour:'',duration:''};try{let parse=JSON.parse(window.sessionStorage.getItem(key));state={step:parse.step,mainCategory:parse.mainCategory,subCategory:parse.subCategory,tour:parse.tour,duration:parse.duration}}catch(err){}
$('.interestsMain .next').on('click',function(event){let maincategory=$(this).data('maincategory');state.mainCategory=maincategory;$("input[name='tx_saasfeetourplanner_tourplanner[maincategory]']").val(maincategory);incrementCounter()});$('.interestsSub .next').on('click',function(event){let subcategory=$(this).data('subcategory');$("input[name='tx_saasfeetourplanner_tourplanner[subcategory]']").val(subcategory);state.subCategory=subcategory;incrementCounter()})
$('.interestsTours .next').on('click',function(event){let tour=$(this).data('tour');state.tour=tour;$('[class*="tour-cat-"]').addClass('d-none');$('.searchTourLoading').removeClass('d-none');$("input[name='tx_saasfeetourplanner_tourplanner[tour]']").val(tour);saveState();$('.questionsCategoryWrapper').remove();$(this).closest('form').submit()})
$("input[name='tx_saasfeetourplanner_tourplanner[duration]']").on('change',function(){state.duration=$(this).val()});const saveState=()=>{window.sessionStorage.setItem(key,JSON.stringify(state))}
const showMainCategory=()=>{}
const showSubCategory=()=>{console.log('.parent-cat-'+state.subCategory);$('.parent-cat-'+state.mainCategory).removeClass('d-none')}
const showTours=()=>{console.log('.tour-cat-'+state.subCategory);$('.tour-cat-'+state.subCategory).removeClass('d-none')}
const updateView=(bool)=>{if(state.step===1){$('.back').hide()}else{$('.back').show()}
$('.step').addClass('d-none');$('.step.step-'+state.step).removeClass('d-none');$('[class*="parent-cat-"]').addClass('d-none');$('[class*="tour-cat-"]').addClass('d-none');switch(state.step){case 1:showMainCategory();break;case 2:showSubCategory();break;case 3:showTours();break;default:}
if(bool){$('html,body').animate({scrollTop:$('.tx-saasfee-tourplanner').offset().top-200},500)}}
const incrementCounter=()=>{state.step=state.step+1;updateView(!0);saveState()}
const decrementCounter=()=>{if(state.step>1){state.step=state.step-1}
updateView(!0);saveState()}
$('.back').on('click',function(){decrementCounter()});updateView()})