%%
%% This is file `latex-lab-testphase-table.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% latex-lab-table.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright 2021-2023 LaTeX Project
%% 
%% This file was generated from file(s) of the  `LaTeX-lab Bundle'.
%% ------------------------------------------------------------------------------------
%% 
%% It may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version 1.3c
%% 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.3c or later is part of all distributions of LaTeX
%% version 2008 or later.
%% 
%% This file may only be distributed together with a copy of the LaTeX
%% `LaTeX-lab Bundle'. You may however distribute the `LaTeX-lab Bundle'
%% without such generated files.
%% 
%% The newest sources can be found below
%% 
%%    https://github.com/latex3/latex2e/required/latex-lab
%% 
%% where one can also log issues in case there are any.
%% 
%% 
%% File: latex-lab-table.dtx (C) Copyright 2023-2024 LaTeX Project
\def\ltlabtbldate{2024-08-10}
\def\ltlabtblversion{0.85m}
\ProvidesExplPackage {latex-lab-testphase-table} {\ltlabtbldate} {\ltlabtblversion}
  {Code related to the tagging of tables}
\RequirePackage{array}
\tl_new:N  \l__tbl_celltag_tl
\tl_set:Nn \l__tbl_celltag_tl {TD}
\tl_new:N  \l__tbl_pcelltag_tl
\tl_set:Nn \l__tbl_pcelltag_tl {TD}
\tl_new:N  \l__tbl_rowtag_tl
\tl_set:Nn \l__tbl_rowtag_tl {TR}
\tl_new:N  \l__tbl_tabletag_tl
\tl_set:Nn \l__tbl_tabletag_tl {Table}
\tl_new:N  \l__tbl_cellattribute_tl
\tl_set:Nn \l__tbl_cellattribute_tl {}
\tl_new:N  \l__tbl_rowattribute_tl
\tl_set:Nn \l__tbl_rowattribute_tl {}
\prop_new:N\g__tbl_untagged_cells_prop
\prop_new:N\l__tbl_saved_untagged_cells_prop
\clist_new:N \l__tbl_tmpa_clist
\tl_new:N \l__tbl_tmpa_tl
\str_new:N \l__tbl_tmpa_str
\str_if_exist:cF { l__socket_tagsupport/tbl/init/celldata_plug_str }
 {
   \NewSocket{tagsupport/tbl/init/celldata}{0}
   \NewSocket{tagsupport/tbl/restore/celldata}{0}
 }
\NewSocketPlug{tagsupport/tbl/init/celldata}{default}
  {
    \prop_set_eq:NN\l__tbl_saved_untagged_cells_prop \g__tbl_untagged_cells_prop
    \prop_gclear:N \g__tbl_untagged_cells_prop
  }
\AssignSocketPlug{tagsupport/tbl/init/celldata}{default}

\NewSocketPlug{tagsupport/tbl/restore/celldata}{default}
  {
    \prop_gset_eq:NN\g__tbl_untagged_cells_prop \l__tbl_saved_untagged_cells_prop
  }
\AssignSocketPlug{tagsupport/tbl/restore/celldata}{default}
\NewSocketPlug{tagsupport/tbl/cell/begin}{TD}
  {
    \__tbl_show_curr_cell_data:
    \__tbl_if_tag_cell:nnT {\g__tbl_row_int } { \g__tbl_col_int }
      {
        \clist_if_in:NVT \l__tbl_header_columns_clist\g__tbl_col_int
          {
            \tl_set:Nn \l__tbl_celltag_tl {TH}
            \tl_set:Ne \l__tbl_cellattribute_tl {\l__tbl_cellattribute_tl,TH-row}
          }
        \tl_set:Ne \l__tbl_tmpa_tl {\int_eval:n { \g__tbl_col_int - 1 - \g__tbl_table_cols_tl }}
        \clist_if_in:NoT \l__tbl_header_columns_clist { \l__tbl_tmpa_tl }
          {
            \tl_set:Nn \l__tbl_celltag_tl {TH}
            \tl_set:Ne \l__tbl_cellattribute_tl {\l__tbl_cellattribute_tl,TH-row}
          }
        \tag_struct_begin:n
          {
            tag             =\l__tbl_celltag_tl,
            attribute-class ={\l__tbl_cellattribute_tl}
          }
        \seq_gput_right:Ne \g__tbl_struct_cur_seq { \tag_get:n {struct_num} }
        \int_step_inline:nn { \g__tbl_span_tl - 1 }
          {
            \seq_gput_right:Ne \g__tbl_struct_cur_seq { -\tag_get:n {struct_num} }
          }
        \tag_mc_begin:n{}
      }
  }
\NewSocketPlug{tagsupport/tbl/cell/end}{TD}
  {
    \__tbl_if_tag_cell:nnT {\g__tbl_row_int } { \g__tbl_col_int }
      {
        \tag_mc_end:
        \tag_struct_end:
      }
  }
\NewSocketPlug{tagsupport/tbl/pcell/begin}{TDpbox}
  {
    \__tbl_show_curr_cell_data:
    \__tbl_if_tag_cell:nnT {\g__tbl_row_int } { \g__tbl_col_int }
      {
        \clist_if_in:NVT \l__tbl_header_columns_clist\g__tbl_col_int
          {
            \tl_set:Nn \l__tbl_celltag_tl {TH}
            \tl_set:Ne \l__tbl_cellattribute_tl {\l__tbl_cellattribute_tl,TH-row}
          }
        \tag_struct_begin:n
          {
            tag             =\l__tbl_pcelltag_tl,
            attribute-class ={\l__tbl_cellattribute_tl}
          }
        \seq_gput_right:Ne \g__tbl_struct_cur_seq { \tag_get:n {struct_num} }
        \int_step_inline:nn { \g__tbl_span_tl - 1 }
          {
            \seq_gput_right:Ne \g__tbl_struct_cur_seq { -\tag_get:n {struct_num} }
          }
        \tagpdfparaOn
        \tl_set:Nn \l__tag_para_main_tag_tl {Div}
     }
  }
\NewSocketPlug{tagsupport/tbl/pcell/end}{TDpbox}
  {
    \__tbl_if_tag_cell:nnT {\g__tbl_row_int } { \g__tbl_col_int }
      {
        \tag_struct_end:
        \legacy_if:nT {@endpe}{\par}
        \mode_if_vertical:T{ \tagpdfparaOff }
      }
  }
\NewSocketPlug{tagsupport/tbl/row/begin}{TR}
  {
    \seq_gclear:N \g__tbl_struct_cur_seq
    \tag_struct_begin:n
     {
       tag            =\l__tbl_rowtag_tl,
       attribute-class=\l__tbl_rowattribute_tl
     }
   \seq_gput_right:Ne \g__tbl_struct_rows_seq { \tag_get:n {struct_num} }
  }
\NewSocketPlug{tagsupport/tbl/row/end}{TR}
  {
    \tag_if_active:T
      {
    \__tbl_add_missing_cells:
    \seq_gput_right:Ne \g__tbl_struct_cells_seq
      {
        \seq_use:Nn \g__tbl_struct_cur_seq {,}
      }
    \int_compare:nNnTF { \g__tbl_row_int } =
                       { \seq_count:N \g__tbl_struct_cells_seq }
      {
        \__tbl_trace:n
          {==>~
            structure~stored~for~row~\int_use:N\g__tbl_row_int :~
            \seq_use:Nn \g__tbl_struct_cur_seq {,}
          }
      }
      { \ERRORtbl/row } % should not happen ...
    \tag_struct_end:
  }
  }
\int_if_exist:NF \l__tag_block_flattened_level_int
  {
    \int_new:N \l__tag_block_flattened_level_int
  }
\NewSocketPlug{tagsupport/para/restore}{Table}
  {
    \tl_set:Nn    \l__tag_para_main_tag_tl {Div}
    \tl_set_eq:NN \l__tag_para_tag_tl\l__tag_para_tag_default_tl
    \bool_set_true:N \l__tag_para_bool
    \bool_set_false:N \l__tag_para_flattened_bool
    \int_zero:N \l__tag_block_flattened_level_int
  }
\NewSocketPlug{tagsupport/tbl/init}{Table}
  {
     \bool_set_false:N \l__tag_para_bool
     \AssignSocketPlug{tagsupport/para/restore}{Table}
     \__tbl_init_struct_data:
  }
\NewSocketPlug{tagsupport/tbl/finalize}{Table}
  {
    \__tbl_set_header_rows:
    \__tbl_restore_struct_data:
  }
\NewSocketPlug{tagsupport/tbl/longtable/init}{Table}
 {
   \seq_gclear:N\g__tbl_struct_rows_seq
   \seq_gclear:N\g__tbl_struct_cells_seq
   \seq_gclear:N\g__tbl_struct_cur_seq
   \seq_gclear:N\g__tbl_LT@firsthead_rows_seq
   \seq_gclear:N\g__tbl_LT@head_rows_seq
   \seq_gclear:N\g__tbl_LT@lastfoot_rows_seq
   \seq_gclear:N\g__tbl_LT@foot_rows_seq
 }

\NewSocketPlug{tagsupport/tbl/longtable/finalize}{Table}
  {
     \bool_lazy_and:nnTF
       { \seq_if_empty_p:N \g__tbl_LT@head_rows_seq  }
       { \seq_if_empty_p:N \g__tbl_LT@firsthead_rows_seq }
       { \__tbl_set_header_rows: }
       {
         \seq_if_empty:NTF \g__tbl_LT@firsthead_rows_seq
           {
             \clist_set:Ne \l__tbl_header_rows_clist
               {\seq_use:Nn \g__tbl_LT@head_rows_seq {,}}
             \__tbl_set_header_rows:
           }
           {
             \clist_set:Ne \l__tbl_header_rows_clist
               { \seq_use:Nn \g__tbl_LT@firsthead_rows_seq {,} }
             \__tbl_set_header_rows:
             \pdf_version_compare:NnTF < {2.0}
              {
                \seq_map_inline:Nn \g__tbl_LT@head_rows_seq
                  {
                    \seq_gset_item:cnn
                      {g__tag_struct_kids_ \g__tbl_struct_table_tl _seq}
                      { ##1 }
                      {}
                    \tl_set:Ne \l__tbl_tmpa_tl
                      { \seq_item:Nn\g__tbl_struct_rows_seq {##1} }
                    \prop_if_exist:cT
                      { g__tag_struct_ \l__tbl_tmpa_tl _prop }
                      {
                        %\prop_gremove:cn {g__tag_struct_ \l__tbl_tmpa_tl _prop} {P}
                      }
                  }
              }
              {
                \seq_map_inline:Nn \g__tbl_LT@head_rows_seq
                  {
                    \tl_set:Ne \l__tbl_tmpa_tl
                      { \seq_item:Nn\g__tbl_struct_rows_seq {##1} }
                    \prop_if_exist:cT
                      { g__tag_struct_ \l__tbl_tmpa_tl _prop }
                      {
                        \__tag_struct_prop_gput:onn { \l__tbl_tmpa_tl } {S}{/Artifact}
                      }
                   }
               }
            }
       }
     \bool_lazy_and:nnF
       { \seq_if_empty_p:N \g__tbl_LT@foot_rows_seq  }
       { \seq_if_empty_p:N \g__tbl_LT@lastfoot_rows_seq }
       {
         \seq_if_empty:NTF \g__tbl_LT@lastfoot_rows_seq
           {
             \seq_map_inline:Nn \g__tbl_LT@foot_rows_seq
               {
                 \tl_set:Ne \l__tbl_tmpa_tl
                   {
                     \seq_item:cn
                       {g__tag_struct_kids_ \g__tbl_struct_table_tl _seq}
                       {##1}
                   }
                 \seq_gset_item:cnn
                   {g__tag_struct_kids_ \g__tbl_struct_table_tl _seq}
                   { ##1 }
                   {}
                 \seq_gput_right:cV
                   {g__tag_struct_kids_ \g__tbl_struct_table_tl _seq}
                   \l__tbl_tmpa_tl
               }
           }
           {
             \seq_map_inline:Nn \g__tbl_LT@lastfoot_rows_seq
               {
                 \tl_set:Ne \l__tbl_tmpa_tl
                   {
                     \seq_item:cn
                       {g__tag_struct_kids_ \g__tbl_struct_table_tl _seq}
                       {##1}
                   }
                 \seq_gset_item:cnn
                   {g__tag_struct_kids_ \g__tbl_struct_table_tl _seq}
                   { ##1 }
                   {}
                 \seq_gput_right:cV
                   {g__tag_struct_kids_ \g__tbl_struct_table_tl _seq}
                   \l__tbl_tmpa_tl
               }
            \pdf_version_compare:NnTF < {2.0}
              {
                \seq_map_inline:Nn \g__tbl_LT@foot_rows_seq
                  {
                    \seq_gset_item:cnn
                      {g__tag_struct_kids_ \g__tbl_struct_table_tl _seq}
                      { ##1 }
                      {}
                    \tl_set:Ne \l__tbl_tmpa_tl
                      { \seq_item:Nn\g__tbl_struct_rows_seq {##1} }
                    \prop_if_exist:cT
                      { g__tag_struct_ \l__tbl_tmpa_tl _prop }
                      {
                        %\prop_gremove:cn {g__tag_struct_ \l__tbl_tmpa_tl _prop} {P}
                      }
                  }
              }
              {
                \seq_map_inline:Nn \g__tbl_LT@foot_rows_seq
                  {
                    \tl_set:Ne \l__tbl_tmpa_tl
                      { \seq_item:Nn\g__tbl_struct_rows_seq {##1} }
                    \prop_if_exist:cT
                      { g__tag_struct_ \l__tbl_tmpa_tl _prop }
                      {
                        \__tag_struct_prop_gput:onn {\l__tbl_tmpa_tl} {S}{/Artifact}
                      }
                   }
               }
           }
       }
  }
\NewSocketPlug{tagsupport/tbl/longtable/head}{Table}
 {
  \tagmcbegin{artifact}
   \tag_mc_reset_box:N\LT@head
  \tagmcend
 }
\NewSocketPlug{tagsupport/tbl/longtable/foot}{Table}
 {
   \tagmcbegin{artifact}
   \tag_mc_reset_box:N \LT@foot
   \tagmcend
 }
\NewSocketPlug{tagsupport/tbl/hmode/begin}{Table}
  {
    \tag_mc_end_push:
     \bool_lazy_and:nnT
      { \bool_if_exist_p:N \l__tag_para_bool } { \l__tag_para_bool }
      { \tag_struct_end:n { text } }
    \tag_struct_begin:n {tag=\l__tbl_tabletag_tl}
    \tl_gset:Ne \g__tbl_struct_table_tl { \tag_get:n {struct_num} }
  }
\NewSocketPlug{tagsupport/tbl/hmode/end}{Table}
  {
    \tag_struct_end:
    \bool_lazy_and:nnT
      { \bool_if_exist_p:N \l__tag_para_bool } { \l__tag_para_bool }
      { \tag_struct_begin:n { tag=\l__tag_para_tag_tl } }
    \tag_mc_begin_pop:n{}
  }
\NewSocketPlug{tagsupport/tbl/vmode/begin}{Table}
  {
    \tag_struct_begin:n {tag=\l__tbl_tabletag_tl}
    \tl_gset:Ne \g__tbl_struct_table_tl { \tag_get:n {struct_num} }
  }
\NewSocketPlug{tagsupport/tbl/vmode/end}{Table}
  {
    \tag_struct_end:
    \par
  }
\NewSocketPlug{tagsupport/tbl/colspan}{code}
  {
    \int_compare:nNnT {#1}>{1}
     {
       \prop_get:NeNF \g__tag_attr_entries_prop
          {colspan-\int_eval:n{#1}}
          \l__tbl_tmpa_tl
          {
            \__tag_attr_new_entry:ee
              {colspan-\int_eval:n{#1}}
              {/O /Table /ColSpan~\int_eval:n{#1}}
          }
       \tl_set:Ne \l__tbl_cellattribute_tl
          {\l__tbl_cellattribute_tl,colspan-\int_eval:n{#1}}
     }
  }
\str_if_exist:cF { l__socket_tagsupport/tbl/leaders/end_plug_str }
    {
      \NewSocket{tagsupport/tbl/leaders/begin}{0}
      \NewSocket{tagsupport/tbl/leaders/end}{0}
    }
\NewSocketPlug{tagsupport/tbl/leaders/begin}{code}
  { \tag_mc_begin:n{artifact} }
\NewSocketPlug{tagsupport/tbl/leaders/end}{code}
  { \tag_mc_end: }
\AddToHook{cmd/array/before}{\__tag_tbl_disable:}


\cs_new_protected:Npn \__tag_tbl_disable:
 {
   \AssignSocketPlug{tagsupport/tbl/cell/begin}{noop}
   \AssignSocketPlug{tagsupport/tbl/cell/end}{noop}
   \AssignSocketPlug{tagsupport/tbl/pcell/begin}{noop}
   \AssignSocketPlug{tagsupport/tbl/pcell/end}{noop}
   \AssignSocketPlug{tagsupport/tbl/row/begin}{noop}
   \AssignSocketPlug{tagsupport/tbl/row/end}{noop}
   \AssignSocketPlug{tagsupport/tbl/init}{noop}
   \AssignSocketPlug{tagsupport/tbl/finalize}{noop}
   \AssignSocketPlug{tagsupport/tbl/longtable/init}{noop}
   \AssignSocketPlug{tagsupport/tbl/longtable/head}{noop}
   \AssignSocketPlug{tagsupport/tbl/longtable/foot}{noop}
   \AssignSocketPlug{tagsupport/tbl/longtable/finalize}{noop}
   \AssignSocketPlug{tagsupport/tbl/hmode/begin}{noop}
   \AssignSocketPlug{tagsupport/tbl/hmode/end}{noop}
   \AssignSocketPlug{tagsupport/tbl/vmode/begin}{noop}
   \AssignSocketPlug{tagsupport/tbl/vmode/end}{noop}
   \AssignSocketPlug{tagsupport/tbl/colspan}{noop}
   \AssignSocketPlug{tagsupport/tbl/leaders/begin}{noop}
   \AssignSocketPlug{tagsupport/tbl/leaders/end}{noop}
 }

\cs_new_protected:Npn \__tag_tbl_enable:
 {
   \AssignSocketPlug{tagsupport/tbl/cell/begin}{TD}
   \AssignSocketPlug{tagsupport/tbl/cell/end}{TD}
   \AssignSocketPlug{tagsupport/tbl/pcell/begin}{TDpbox}
   \AssignSocketPlug{tagsupport/tbl/pcell/end}{TDpbox}
   \AssignSocketPlug{tagsupport/tbl/row/begin}{TR}
   \AssignSocketPlug{tagsupport/tbl/row/end}{TR}
   \AssignSocketPlug{tagsupport/tbl/init}{Table}
   \AssignSocketPlug{tagsupport/tbl/finalize}{Table}
   \AssignSocketPlug{tagsupport/tbl/longtable/head}{Table}
   \AssignSocketPlug{tagsupport/tbl/longtable/foot}{Table}
   \AssignSocketPlug{tagsupport/tbl/longtable/init}{Table}
   \AssignSocketPlug{tagsupport/tbl/longtable/finalize}{Table}
   \AssignSocketPlug{tagsupport/tbl/hmode/begin}{Table}
   \AssignSocketPlug{tagsupport/tbl/hmode/end}{Table}
   \AssignSocketPlug{tagsupport/tbl/vmode/begin}{Table}
   \AssignSocketPlug{tagsupport/tbl/vmode/end}{Table}
   \AssignSocketPlug{tagsupport/tbl/colspan}{code}
   \AssignSocketPlug{tagsupport/tbl/leaders/begin}{code}
   \AssignSocketPlug{tagsupport/tbl/leaders/end}{code}
 }

\keys_define:nn { __tag / setup }
  {
    table/tagging .choices:nn = { true, on }
      { \__tag_tbl_enable: },
    table/tagging .choices:nn = { false, off }
      { \__tag_tbl_disable: },
    table/tagging .choice:,
    table/tagging / presentation .code:n =
     {
       \__tag_tbl_enable:
       \tl_set:Nn\l__tbl_rowtag_tl   {NonStruct}
       \tl_set:Nn\l__tbl_pcelltag_tl {NonStruct}
       \tl_set:Nn\l__tbl_celltag_tl  {text}
       \tl_set:Nn\l__tbl_tabletag_tl {Div}
       \clist_clear:N \l__tbl_header_rows_clist
       \clist_clear:N \l__tbl_header_columns_clist
     },
    table/tagging .default:n = true,
    table/tagging .initial:n = true
  }
\keys_define:nn { __tag / setup }
  {
    table-tagging .meta:n = {table/tagging={#1}}
  }
\AddToHook{begindocument}
  {
   \tag_if_active:T
     {
       \tagpdfsetup
         {
           role/new-attribute =
            {TH-col}{/O /Table /Scope /Column},
           role/new-attribute =
             {TH-row}{/O /Table /Scope /Row},
           role/new-attribute =
             {TH-both}{/O /Table /Scope /Both},
         }
         \seq_gput_left:Ne\g__tag_attr_class_used_seq
           {\pdf_name_from_unicode_e:n{TH-col}}
         \seq_gput_left:Ne\g__tag_attr_class_used_seq
           {\pdf_name_from_unicode_e:n{TH-row}}
         \seq_gput_left:Ne\g__tag_attr_class_used_seq
           {\pdf_name_from_unicode_e:n{TH-both}}
     }
  }

\clist_new:N  \l__tbl_header_rows_clist
\clist_new:N  \l__tbl_header_columns_clist
\cs_new_protected:Npn \__tbl_set_header_rows:
  {
    \clist_map_inline:Nn \l__tbl_header_rows_clist
      {
        \clist_set:Ne\l__tbl_tmpa_clist
          {
            \seq_item:Nn \g__tbl_struct_cells_seq {##1}
          }
        \clist_map_inline:Nn \l__tbl_tmpa_clist
          {
            \prop_if_exist:cT { g__tag_struct_####1_prop }
              {
                \__tag_struct_prop_gput:nnn{ ####1 }{S}{/TH}
                \prop_get:cnNTF
                  { g__tag_struct_####1_prop }
                  { C }
                  \l__tbl_tmpa_tl
                  {
                    \str_set:Ne \l__tbl_tmpa_str {\l__tbl_tmpa_tl}
                    \str_remove_once:Nn \l__tbl_tmpa_str {[}
                    \str_remove_once:Nn \l__tbl_tmpa_str {]}
                    \str_if_in:NnTF\l__tbl_tmpa_str{/TH-row}
                     {
                       \str_replace_once:Nnn \l__tbl_tmpa_str {/TH-row}{/TH-both}
                       \__tag_struct_prop_gput:nne{ ####1 }{C}{[\l__tbl_tmpa_str]}
                     }
                     {
                       \__tag_struct_prop_gput:nne{ ####1 }{C}{[/TH-col~\l__tbl_tmpa_str]}
                     }
                  }
                  {\__tag_struct_prop_gput:nnn{ ####1 }{C}{/TH-col}}
             }
          }
      }
  }
\keys_define:nn { __tag / setup }
  {
    table/header-rows .clist_set:N = \l__tbl_header_rows_clist,
    table/header-columns .clist_set:N = \l__tbl_header_columns_clist,
    table-header-rows .meta:n = {table/header-rows={#1}}
  }
\cs_if_exist:NT \__tag_struct_prop_gput:nnn
 {
   \cs_generate_variant:Nn \__tag_struct_prop_gput:nnn {one}
 }
\cs_new_protected:Npn \__tbl_multirow:n #1
 {
   \prop_get:NeNF \g__tag_attr_entries_prop
      {rowspan-\int_eval:n{#1}}
      \l__tbl_tmpa_tl
      {
        \__tag_attr_new_entry:ee
          {rowspan-\int_eval:n{#1}}
          {/O /Table /RowSpan~\int_eval:n{#1}}
      }
   \seq_gput_left:Ne\g__tag_attr_class_used_seq
     {\pdf_name_from_unicode_e:n{rowspan-\int_eval:n{#1}}}
   \seq_get_right:NN\g__tbl_struct_cur_seq \l__tbl_tmpb_tl
   \tl_set:Ne \l__tbl_tmpb_tl { \int_abs:n{\l__tbl_tmpb_tl} }
   \prop_get:cnNTF
      { g__tag_struct_\l__tbl_tmpb_tl _prop }
      { C }
      \l__tbl_tmpa_tl
      {
        \tl_remove_once:Nn \l__tbl_tmpa_tl {[}
        \tl_remove_once:Nn \l__tbl_tmpa_tl {]}
        \__tag_struct_prop_gput:one{ \l__tbl_tmpb_tl }
          {C}
          {[/rowspan-\int_eval:n{#1}~\l__tbl_tmpa_tl]}
      }
      {
        \__tag_struct_prop_gput:one{ \l__tbl_tmpb_tl }
          {C}
          {[/rowspan-\int_eval:n{#1}]}
      }
    \__tbl_gset_untagged_row_cells:nn {#1-1}{\g__tbl_span_tl}
 }
\keys_define:nn{ __tag / setup }
 { table/multirow .code:n = {\__tbl_multirow:n {#1} }
  ,table/multirow .default:n = 1
 }
\cs_new_protected:Npn \__tbl_gset_untagged_row_cells:nn #1 #2 % #1 number of rows, #2 number of columns
  {
    \int_step_inline:nn {#1}
     {
       \int_step_inline:nn {#2}
        {
          \prop_gput:Nee \g__tbl_untagged_cells_prop
           { \int_eval:n {\g__tbl_row_int + ##1},\int_eval:n{\g__tbl_col_int + ####1 -1 } }{}
        }
     }
  }
\prg_new_protected_conditional:Npnn\__tbl_if_tag_cell:nn #1 #2 %#1 row, #2 col
  { T,TF }
  {
    \prop_get:NeNTF \g__tbl_untagged_cells_prop
      {\int_eval:n{#1},\int_eval:n{#2}}\l__tbl_tmpa_tl
      { \prg_return_false:}
      { \prg_return_true: }
  }
\cs_new_protected:Npn \__tbl_show_curr_cell_data: {
   \__tbl_trace:n { ==>~ current~cell~data:~
                 \int_use:N \g__tbl_row_int ,
                 \int_use:N \g__tbl_col_int ,
                 \g__tbl_span_tl
               }
}
\cs_new:Npn \__tbl_add_missing_cells:
  {
    \int_compare:nNnT \g__tbl_missing_cells_int > 0
      {
       \__tbl_trace:n {==>~
         ~Inserting~\int_use:N \g__tbl_missing_cells_int \space
          additional~cell(s)~into~previous~row:}
       \int_step_inline:nn { \g__tbl_missing_cells_int }
           {
             \int_gincr:N\g__tbl_col_int
             \UseTaggingSocket{tbl/cell/begin}
             \UseTaggingSocket{tbl/cell/end}
           }
      }
  }
\tl_new:N  \g__tbl_struct_table_tl
\tl_new:N  \l__tbl_saved_struct_table_tl
\seq_new:N \g__tbl_struct_rows_seq
\seq_new:N \l__tbl_saved_struct_rows_seq
\seq_new:N \g__tbl_struct_cells_seq
\seq_new:N \l__tbl_saved_struct_cells_seq
\seq_new:N \g__tbl_struct_cur_seq
\seq_new:N \l__tbl_saved_struct_cur_seq

\cs_new_protected:Npn \__tbl_init_struct_data: {
  \tl_set_eq:NN  \l__tbl_saved_struct_table_tl \g__tbl_struct_table_tl
  \seq_set_eq:NN \l__tbl_saved_struct_rows_seq \g__tbl_struct_rows_seq
  \seq_set_eq:NN \l__tbl_saved_struct_cells_seq \g__tbl_struct_cells_seq
  \seq_set_eq:NN \l__tbl_saved_struct_cur_seq \g__tbl_struct_cur_seq
  \seq_gclear:N\g__tbl_struct_rows_seq
  \seq_gclear:N\g__tbl_struct_cells_seq
  \seq_gclear:N\g__tbl_struct_cur_seq
}

\cs_new_protected:Npn \__tbl_restore_struct_data: {
  \tl_gset_eq:NN  \g__tbl_struct_table_tl \l__tbl_saved_struct_table_tl
  \seq_gset_eq:NN \g__tbl_struct_rows_seq \l__tbl_saved_struct_rows_seq
  \seq_gset_eq:NN \g__tbl_struct_cells_seq\l__tbl_saved_struct_cells_seq
  \seq_gset_eq:NN \g__tbl_struct_cur_seq  \l__tbl_saved_struct_cur_seq
}

\def\__tbl_patch_LT@makecaption#1#2#3{%
  \LT@mcol\LT@cols c{%
  % test can go after merge
    \str_if_exist:cT { l__socket_tagsupport/parbox/before_plug_str }
      {
        \AssignSocketPlug{tagsupport/parbox/before}{noop}
        \AssignSocketPlug{tagsupport/parbox/after}{noop}
      }
    \hbox to\z@{\hss\parbox[t]\LTcapwidth{%
    \reset@font
    \tag_stop:n{caption}
    \sbox\@tempboxa{#1{#2:~}#3}%
    \tag_start:n{caption}
    \ifdim\wd\@tempboxa>\hsize
      #1{#2:~}#3%
    \else
      \hbox to\hsize{\hfil#1{#2:~}#3\hfil}%
    \fi
    \endgraf\vskip\baselineskip}%
  \hss}}}
\AddToHook{package/longtable/after}
  {
   \cs_set_eq:NN \LT@makecaption\__tbl_patch_LT@makecaption
  }


\endinput
%%
%% End of file `latex-lab-testphase-table.sty'.
