\usepackage{hyperref}

\usepackage{fontspec}

\usepackage{chngcntr}

\usepackage{scrextend}

\usepackage{listings}

\usepackage{contour}

\usepackage[normalem]{ulem}

\usepackage{underscore}

\lstdefinestyle{animateblocks}{
	basicstyle=\color{black!20},
	moredelim=**[is][\only<+>{\color{black}}]{@}{@},
}

\lstset{
	escapeinside={<!}{!>},
}

\usepackage{tikz}
\tikzstyle{every picture}+=[remember picture]
\usetikzlibrary{shapes.geometric, arrows, arrows.meta, shapes, automata, positioning, positioning, fit, calc, overlay-beamer-styles}
\tikzstyle{squarednode} = [rectangle, draw=black, minimum size=5mm]
\tikzstyle{arrow} = [thick,->,>=stealth]
\tikzstyle{textarrow} = [awesomegray,thick,->,-{Kite[open]}]
\tikzset{
	node distance = 5mm,
	invisible/.style={opacity=0},
	visible on/.style={alt={#1{}{invisible}}},
	alt/.code args={<#1>#2#3}{%
		\alt<#1>{\pgfkeysalso{#2}}{\pgfkeysalso{#3}}
	},
}

\usepackage[ngerman]{babel}
\usepackage[
	backend=biber,
	style=alphabetic,
	sorting=ynt
]{biblatex}
\usepackage{csquotes}

\nocite{*}

\AtEndPreamble{
	\hypersetup{
		pdftitle = {\mytitle},
		pdfauthor = {\student},
		pdfsubject = {\mytitle}
	}
}

\renewcommand{\maketitle}{
	\begin{frame}[noframenumbering, plain]
		\titlepage
	\end{frame}
}

\renewcommand{\ULdepth}{1.8pt}
\contourlength{0.8pt}
\newcommand{\gul}[1]{%
	\uline{\phantom{#1}}%
	\llap{\contour{white}{#1}}%
}

\makeatletter
\def\beamer@calltheme#1#2#3{
	\def\beamer@themelist{#2}
	\@for\beamer@themename:=\beamer@themelist\do
		{\usepackage[{#1}]{\beamer@themelocation/#3\beamer@themename}}}
	\def\usefolder#1{
	\def\beamer@themelocation{#1}
}

\def\beamer@themelocation{}

\usefolder{styles}
\usetheme{Awesome}

\newcounter{framesinsection}
\newcounter{framesinsubsection}
\counterwithin*{framesinsection}{section}
\counterwithin*{framesinsubsection}{subsection}

\newcommand{\stepframe}{
	\ifbeamer@isfragile
		\stepcounter{framesinsection}
		\stepcounter{framesinsubsection}
	\else%
		\ifbeamer@noframenumbering\else%
			\stepcounter{framesinsection}
			\stepcounter{framesinsubsection}
		\fi%
	\fi%
	\ifnum\theframesinsection=0
		\setcounter{framesinsection}{1}
	\fi%
	\ifnum\theframesinsubsection=0
		\setcounter{framesinsubsection}{1}
	\fi%
}

\BeforeBeginEnvironment{frame}{
	\stepframe
}
\pretocmd{\againframe}{
	\stepframe
}{}{}

\newcommand{\refreshcountsinaux}{
	\immediate\write\@auxout{\global\noexpand\@namedef{s@totalsubsectionframes-\arabic{section}-\arabic{subsection}}{\theframesinsubsection}}
	\immediate\write\@auxout{\global\noexpand\@namedef{s@totalsectionframes-\arabic{section}}{\theframesinsection}}
}

\pretocmd{\section}{
	\refreshcountsinaux
}{}{}
\pretocmd{\subsection}{
	\refreshcountsinaux
}{}{}
\AtEndDocument{
	\refreshcountsinaux
}
\newcommand{\framespersection}{
	\ifcsdef{s@totalsectionframes-\arabic{section}}{
		\csname s@totalsectionframes-\arabic{section}\endcsname
	}{
		0
	}
}
\newcommand{\framespersubsection}{
	\ifcsdef{s@totalsubsectionframes-\arabic{section}-\arabic{subsection}}{
		\csname s@totalsubsectionframes-\arabic{section}-\arabic{subsection}\endcsname
	}{
		0
	}
}
\makeatother