%% The LaTeX package tcolorbox - version 6.7.1 (2025/07/08)
%% tcbskinsjigsaw.code.tex: Code for colorboxes with different skins
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2006-2025 by Prof. Dr. Dr. Thomas F. Sturm <thomas dot sturm at unibw dot de>
%% -------------------------------------------------------------------------------------------
%%
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3
%% of this license or (at your option) any later version.
%% The latest version of this license is in
%%   http://www.latex-project.org/lppl.txt
%% and version 1.3 or later is part of all distributions of LaTeX
%% version 2005/12/01 or later.
%%
%% This work has the LPPL maintenance status `author-maintained'.
%%
%% This work consists of all files listed in README
%%
\tcb@set@library@version{6.7.1}

\newcounter{tcbrastercolumn}
\newcounter{tcbrasterrow}
\newcounter{tcbrasternum}
\newcounter{tcbraster}
\def\tcb@raster@number{\@arabic\c@tcbraster}%
\def\theHtcbrasternum{\tcb@raster@number.\@arabic\c@tcbrasternum}

\setcounter{tcbrasternum}{1}
\setcounter{tcbrastercolumn}{1}
\setcounter{tcbrasterrow}{1}

\def\tcb@raster@ehg@all{%
  \tcbset{equal height group={\kvtcb@raster@ehgid}}%
}

\def\tcb@raster@ehg@row{%
  \tcbset{equal height group={\kvtcb@raster@ehgid @\number\c@tcbrasterrow}}%
}


\tcbset{%
  raster columns/.store in=\kvtcb@raster@columns,
  raster rows/.store in=\kvtcb@raster@rows,
  raster width/.store in=\kvtcb@raster@width,
  raster height/.store in=\kvtcb@raster@height,
  %
  raster before skip/.store in=\kvtcb@raster@skip@before,
  raster after skip/.store in=\kvtcb@raster@skip@after,
  raster left skip/.store in=\kvtcb@raster@skip@left,
  raster right skip/.store in=\kvtcb@raster@skip@right,
  %
  raster column skip/.store in=\kvtcb@raster@xskip,
  raster row skip/.store in=\kvtcb@raster@yskip,
  %
  raster equal skip/.style={raster before skip=#1,raster after skip=#1,
    raster column skip=#1,raster row skip=#1},
  %
  raster@halign/.store in=\kvtcb@raster@halign,
  raster halign/.is choice,
  raster halign/center/.style={raster@halign=\centering},
  raster halign/left/.style={raster@halign=\raggedright},
  raster halign/right/.style={raster@halign=\raggedleft},
  %
  raster valign/.store in=\kvtcb@raster@valign,
  %
  raster equal height group/.store in=\kvtcb@raster@ehgid,%
  raster equal height/.is choice,
  raster equal height/.default=all,
  raster equal height/none/.code={\let\tcb@raster@ehg@set\@empty},%
  raster equal height/rows/.code={\let\tcb@raster@ehg@set\tcb@raster@ehg@row},%
  raster equal height/all/.code={\let\tcb@raster@ehg@set\tcb@raster@ehg@all},%
  %
  raster force size/.is choice,%
  raster force size/.default=true,%
  raster force size/true/.code={\let\tcb@raster@set@size\tcbset@late@options},%
  raster force size/false/.code={\let\tcb@raster@set@size\tcbset},%
  raster multicolumn/.code={%
    \ifnum\numexpr\c@tcbrastercolumn+#1>\numexpr\kvtcb@raster@columns+1\relax
      \tcb@warning{'raster multicolumn' combined too much columns}%
    \else%
      \tcbset@late@options{%
        code={\preto\kvtcb@afterbox{\addtocounter{tcbrastercolumn}{\numexpr#1-1}\addtocounter{tcbrasternum}{\numexpr#1-1}}},
        width=(\tcb@raster@box@width+\tcb@raster@xskip)*#1-\tcb@raster@xskip}%
    \fi%
  },
  raster multirow/.code={%
    \ifdefined\tcb@raster@box@height%
      \tcbset@late@options{%
        height=(\tcb@raster@box@height+\tcb@raster@yskip)*#1-\tcb@raster@yskip}%
    \else%
      \tcb@warning{'raster multirow' needs a fixed 'raster height'}%
    \fi%
  },
  raster width center/.style={raster width=\linewidth,raster left skip=(\linewidth-(#1))/2,raster right skip=(\linewidth-(#1))/2},
  raster width flush left/.style={raster width=\linewidth,raster left skip=0pt,raster right skip=\linewidth-(#1)},
  raster width flush right/.style={raster width=\linewidth,raster left skip=\linewidth-(#1),raster right skip=0pt},
}

\tcbset{
  raster reset/.style={
    raster width=\linewidth,raster height=0pt,
    raster equal skip=2mm,
    raster columns=2,raster rows=2,
    raster left skip=0pt,raster right skip=0pt,
    raster halign=left,raster valign=center,
    raster equal height=none,
    raster equal height group={REG@\tcb@raster@number},
    raster force size,},
  raster reset
}

\setcounter{tcbraster}{0}

\let\tcb@raster@change@minipage\@empty
\let\tcb@raster@change@fitbox\@empty
\def\tcb@raster@change@hbox{\tcbset{capture=minipage}}

\def\tcb@height@fill@unbroken@raster#1{%
  \ifnum\c@tcblayer<2\relax%
    \kvtcb@beforebox%
    \def\kvtcb@beforebox{}%
    \tcb@breakat@init%
    \tcbset{compress page=#1}%
    \tcb@comp@h@page%
    \ifdim\tcb@h@page<0pt\relax\unkern\pagebreak\tcb@comp@h@page\kern\tcb@raster@skip@left\fi%
    \tcbset{height=\tcb@h@page-\kvtcb@bbtop@stand-\kvtcb@bbbottom@stand}%
  \fi%
}

\newenvironment{tcbraster}[1][]{%
  \tcb@layer@pushup%
  \stepcounter{tcbraster}%
  \edef\tcb@raster@number{\number\c@tcbraster}%
  \edef\tcb@raster@save@num{\number\c@tcbrasternum}%
  \edef\tcb@raster@save@column{\number\c@tcbrastercolumn}%
  \edef\tcb@raster@save@row{\number\c@tcbrasterrow}%
  \let\tcb@raster@change@fitbox\@empty%
  \setcounter{tcbrasternum}{1}%
  \setcounter{tcbrastercolumn}{1}%
  \setcounter{tcbrasterrow}{1}%
  \let\tcb@height@fill@unbroken\tcb@height@fill@unbroken@raster%
  \tcbset{every box on layer \the\numexpr\number\c@tcblayer+1\relax/.append code={%
    \tcb@raster@ehg@set%
    \tcbset{raster every box/.try}%
    \ifodd\c@tcbrastercolumn\relax%
      \tcbset{raster odd column/.try}%
    \else%
      \tcbset{raster even column/.try}%
    \fi%
    \tcbset{raster column \number\c@tcbrastercolumn/.try}%
    \ifodd\c@tcbrasterrow\relax%
      \tcbset{raster odd row/.try}%
    \else%
      \tcbset{raster even row/.try}%
    \fi%
    \tcbset{raster row \number\c@tcbrasterrow/.try}%
    \ifodd\c@tcbrasternum\relax%
      \tcbset{raster odd number/.try}%
    \else%
      \tcbset{raster even number/.try}%
    \fi%
    \tcbset{raster row \number\c@tcbrasterrow\space column \number\c@tcbrastercolumn/.try}%
    \tcbset{raster number \number\c@tcbrasternum/.try}%
  }}%
  \tcbset{#1}%
  % sanitize
  \tcbdimto\tcb@raster@width{\kvtcb@raster@width}%
  \tcbdimto\tcb@raster@height{\kvtcb@raster@height}%
  \tcbglueto\tcb@raster@skip@before{\kvtcb@raster@skip@before}%
  \tcbglueto\tcb@raster@skip@after{\kvtcb@raster@skip@after}%
  \tcbdimto\tcb@raster@skip@left{\kvtcb@raster@skip@left}%
  \tcbdimto\tcb@raster@skip@right{\kvtcb@raster@skip@right}%
  \tcbdimto\tcb@raster@xskip{\kvtcb@raster@xskip}%
  \tcbdimto\tcb@raster@yskip{\kvtcb@raster@yskip}%
  \tcbset@late@options{%
    before={\ifhmode\unskip\fi\ifnum\c@tcbrastercolumn>1 \kern\tcb@raster@xskip\else%
      \ifnum\c@tcbrasterrow>1 \parindent\z@\parskip\z@\par\nointerlineskip\addvspace{\the\dimexpr\tcb@raster@yskip\relax}\noindent\fi%
      \kern\tcb@raster@skip@left\fi},
    after={%
      \stepcounter{tcbrasternum}%
      \ifnum\c@tcbrastercolumn=\kvtcb@raster@columns\relax%
        \kern\tcb@raster@skip@right%
        \setcounter{tcbrastercolumn}{1}\stepcounter{tcbrasterrow}%
      \else%
        \stepcounter{tcbrastercolumn}%
      \fi},%
    box align=\kvtcb@raster@valign,%
    code={\preto\kvtcb@phantom{\addtocounter{tcbrasternum}{-1}\refstepcounter{tcbrasternum}}},%
  }%
  \tcbdimto\tcb@raster@box@width{(\tcb@raster@width+\tcb@raster@xskip-\tcb@raster@skip@left-\tcb@raster@skip@right)/\kvtcb@raster@columns-\tcb@raster@xskip}%
  \tcb@raster@set@size{%
    code={\csuse{tcb@raster@change@\kvtcb@capture}},
    width=\tcb@raster@box@width,
  }%
  \ifdim\dimexpr\tcb@raster@height>0pt\relax%
    \tcbdimto\tcb@raster@box@height{(\tcb@raster@height+\tcb@raster@yskip-0.001pt)/\kvtcb@raster@rows-\tcb@raster@yskip}%
    \tcb@raster@set@size{height=\tcb@raster@box@height}%
  \fi%
  \let\tcb@end@raster\@empty%
  \ifinner\ifhmode%
    \color@vbox%
    \hsize=\tcb@raster@width%
    \let\tcb@end@raster\color@endbox%
  \fi\fi%
  \if@nobreak%
    \iftcb@ignorenobreak%
      {\par\nointerlineskip%
      \addvspace{\glueexpr\tcb@raster@skip@before-\parskip}}%
    \fi%
  \else%
    {\par\nointerlineskip%
    \addvspace{\glueexpr\tcb@raster@skip@before-\parskip}}%
  \fi%
  \tcb@parfillskip@check\kvtcb@raster@halign\noindent%
}{%
  \ifhmode\unskip\fi%
  \ifnum\c@tcbrastercolumn>1\relax%
    \kern\tcb@raster@skip@right%
  \fi%
  \begingroup%
  \par\nointerlineskip%
  \addvspace{\glueexpr\tcb@raster@skip@after-\parskip}%
  \endgroup%
  \tcb@end@raster%
  \setcounter{tcbrasternum}{\tcb@raster@save@num}%
  \setcounter{tcbrastercolumn}{\tcb@raster@save@column}%
  \setcounter{tcbrasterrow}{\tcb@raster@save@row}%
}

\newcommand{\tcbitem@following}[1][]{%
  \end{tcolorbox}\begin{tcolorbox}[{#1}]%
}

\newcommand{\tcbitem@first}[1][]{%
  \let\tcbitem=\tcbitem@following%
  \begin{tcolorbox}[{#1}]%
}

\newenvironment{tcbitemize}[1][]{%
  \begin{tcbraster}[{#1}]%
  \let\tcb@raster@change@fitbox=\tcb@raster@change@hbox%
  \let\tcbitem=\tcbitem@first%
}{\end{tcolorbox}\end{tcbraster}}

\newenvironment{tcboxedraster}[2][]{%
  \tcolorbox[{#2}]\begin{tcbraster}[{#1}]}%
  {\end{tcbraster}\endtcolorbox}

\newenvironment{tcboxeditemize}[2][]{%
  \tcolorbox[{#2}]\tcbitemize[{#1}]}%
  {\endtcbitemize\endtcolorbox}
