%% The LaTeX package tcolorbox - version 6.3.0 (2024/07/10)
%% tcbminted.code.tex: Code for colorboxes with listings
%%
%% -------------------------------------------------------------------------------------------
%% Copyright (c) 2006-2024 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
%%
%\makeatletter
\tcb@set@library@version{6.3.0}

\RequirePackage{minted}[2021/12/24]

% to be removed, if integrated into the minted package (#281)
\minted@def@optcl{envname}{-P envname}{#1}

\tcbuselibrary{listings@core}

\ExplSyntaxOn

\cs_new_nopar:Npn \__tcobox_minted_input_listing:nnnn #1#2#3#4
  {
    \tl_if_empty:nF { #4 }
      {
        \usemintedstyle { #4 }
      }
    \tl_set:Nn \l__tcobox_tmpa_tl { \inputminted[#1 }
    \cs_if_exist:NT \tcb@listing@capture
      {
        \str_if_eq:VnT \tcb@listing@capture { hbox }
          {
            \tl_put_right:Nn \l__tcobox_tmpa_tl { ,envname=BVerbatim }
          }
      }
    \tl_put_right:Nn \l__tcobox_tmpa_tl { ] }
    \file_if_exist:nTF { \minted@outputdir #3 }
      {
        \l__tcobox_tmpa_tl { #2 }{ \minted@outputdir #3 }
      }
      {
        \l__tcobox_tmpa_tl { #2 }{ #3 }
      }
  }

\cs_generate_variant:Nn \__tcobox_minted_input_listing:nnnn {VVVV}


\cs_new_nopar:Npn \__tcbbox_minted_uselistinglisting:
  {
    \__tcobox_minted_input_listing:VVVV
      \kvtcb@minted@options
      \kvtcb@minted@language
      \kvtcb@listingfile
      \kvtcb@minted@style
  }


\cs_new_nopar:Npn \__tcbbox_minted_usetemplisting:
  {
    \__tcobox_minted_input_listing:VVVV
      \kvtcb@minted@options
      \kvtcb@minted@language
      \kvtcb@tempfile
      \kvtcb@minted@style
  }


\cs_new_nopar:Npn \__tcbbox_minted_doc_usetemplisting:
  {
    \__tcobox_minted_input_listing:VVVV
      \kvtcb@docmintoptions
      \kvtcb@docminted@language
      \kvtcb@tempfile
      \kvtcb@docmintstyle
  }


\tcbset
  {
    listing~engine/minted/.code=
      {
        \cs_set_eq:NN \tcbuselistinglisting   \__tcbbox_minted_uselistinglisting:
        \cs_set_eq:NN \tcbusetemplisting      \__tcbbox_minted_usetemplisting:
        \cs_set_eq:NN \tcb@doc@usetemplisting \__tcbbox_minted_doc_usetemplisting:
      },
  }

\ExplSyntaxOff


\tcbset{%
  minted language/.store in=\kvtcb@minted@language,
  minted options/.store in=\kvtcb@minted@options,
  default@minted@options/.store in=\kvtcb@default@minted@options,
  default minted options/.style={default@minted@options={#1},minted options={#1}},
  minted style/.store in=\kvtcb@minted@style,
}


\tcbset{%
  default@minted@options={tabsize=2,fontsize=\small,breaklines,autogobble},
  reset@minted/.style={%
    minted language=latex,
    code={\let\kvtcb@minted@options\kvtcb@default@minted@options},
    minted style=,
    listing engine=minted,
  },
  initialize@reset=reset@minted,
}

