<!-- REQUIRED JS SCRIPTS -->
<!-- Bootstrap & Jquery App -->
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js" integrity="sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==" crossorigin="anonymous"></script>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/lodash.js/4.17.21/lodash.min.js" integrity="sha512-WFN04846sdKMIP5LKNphMaWzU7YpMyCU245etK3g/2ARYbPK9Ub18eG+ljU96qKRCWh+quCY7yefSmlkQw1ANQ==" crossorigin="anonymous"></script>
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/bootstrap@4.6.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-Piv4xVNRyMGpqkS2by6br4gNJ7DXjqk09RmUpJ8jgGtD7zP9yug3goQfGII0yAns" crossorigin="anonymous"></script>
<!-- AdminLTE -->
<script type="text/javascript" src="//cdn.jsdelivr.net/npm/admin-lte@3.1.0/dist/js/adminlte.min.js"></script>

<!-- Additional Utilities -->
<script src="{{ asset('plugin/bootstrap3-typeahead/js/bootstrap3-typeahead.min.js') }}"></script>

<script type="text/javascript">
	// Our CSRF token to each interaction
	$.ajaxSetup({
		headers: {
			'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
		}
	});

	$.AdminLTESidebarTweak = {};
	$.AdminLTESidebarTweak.Open = true;
	$.AdminLTESidebarTweak.ResizeDelay = 1000;

	$.AdminLTESidebarTweak.options = {
		EnableRemember: true,
		//Removes the transition after page reload.
		NoTransitionAfterReload: false
	};

	// Work out our timezone.
	const tz = Intl.DateTimeFormat().resolvedOptions().timeZone;

	/**
	 * Open and close the sidebar
	 * @param state
	 * @param addclass
	 */
	function sidebaropenclose(state,addclass) {
		// Dont do anything if the state hasnt changed.
		if (state == $.AdminLTESidebarTweak.Open) {
			return;
		}

		$.AdminLTESidebarTweak.Open = state;

		if (addclass !== 'undefined')
			$("body")
				.addClass(state ? 'sidebar-open' : 'sidebar-collapse');

		$(this).delay($.AdminLTESidebarTweak.ResizeDelay).queue(function() {
			window.dispatchEvent(new Event('resize'));
			$(this).dequeue();
		});
	}

	$(function () {
		"use strict";

		$("body").on("collapsed.lte.pushmenu", function(){
			if($.AdminLTESidebarTweak.options.EnableRemember) {
				document.cookie = "toggleState=closed;path=/";

				$("body").queue(sidebaropenclose(false));
			}
		});

		$("body").on("shown.lte.pushmenu", function(){
			if($.AdminLTESidebarTweak.options.EnableRemember){
				document.cookie = "toggleState=opened;path=/";

				$("body").queue(sidebaropenclose(true));
			}
		});

		if($.AdminLTESidebarTweak.options.EnableRemember){
			var re = new RegExp('toggleState' + "=([^;]+)");
			var value = re.exec(document.cookie);
			var toggleState = (value != null) ? unescape(value[1]) : null;
			if(toggleState == 'closed'){
				if($.AdminLTESidebarTweak.options.NoTransitionAfterReload){
					$("body").addClass('sidebar-collapse hold-transition').delay(100).queue(function(){
						$(this).removeClass('hold-transition');
					});
				}else{
					$("body").queue(sidebaropenclose(false,true));
				}
			}
		}
	});
</script>

@if(file_exists('js/custom.js'))
	<!-- Any Custom JS -->
	<script src="{{ asset('js/custom.js') }}"></script>
@endif