%% The LaTeX package tcolorbox - version 6.4.1 (2024/10/22)
%% tcbprocessing.code.tex: Code for conditional processing
%%
%% -------------------------------------------------------------------------------------------
%% 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
%%
\tcb@set@library@version{6.4.1}

\ExplSyntaxOn

\bool_new:N \l__tcobox_proc_hash_equal_bool

\cs_new_protected:Npn \__tcobox_proc_compute_hash:nn #1#2
  {
    \tl_set:Ne \l__tcobox_tmpa_tl { \file_mdfive_hash:n { #1 } }
    \file_get:nnN { #2 } { } \l__tcobox_tmpb_tl
    \str_if_eq:eeTF { \l__tcobox_tmpa_tl } { \tl_trim_spaces:o { \l__tcobox_tmpb_tl } }
      {
        \bool_set_true:N \l__tcobox_proc_hash_equal_bool
      }
      {
        \bool_set_false:N \l__tcobox_proc_hash_equal_bool
        \iow_open:Nn \g__tcobox_out_iow { #2 }
        \iow_now:NV \g__tcobox_out_iow \l__tcobox_tmpa_tl
        \iow_close:N \g__tcobox_out_iow
      }
  }

\prg_new_protected_conditional:Npnn \__tcobox_if_file_process:nnnn #1#2#3#4 { TF }
  {
    \__tcobox_proc_compute_hash:nn {#2} {#3}
    \int_case:nn {#1}
      {
        {0} { \prg_return_true: }
        {1}
          {
            \bool_if:NTF \l__tcobox_proc_hash_equal_bool
              {
                \file_if_exist:nTF {#4}
                  {
                    \file_compare_timestamp:nNnTF {#4} < {#3}
                      { \prg_return_true: }
                      { \prg_return_false: }
                  }
                  { \prg_return_true: }
              }
              {
                \prg_return_true:
              }
          }
        {2} { \prg_return_false: }
      }
  }

\cs_gset_eq:NN \tcbiffileprocess \__tcobox_if_file_process:nnnnTF

\ExplSyntaxOff
