\RequireCitationStyle{verbose-ibid}

\blx@inputonce{biblatex-sbl.def}{biblatex-sbl definitions and macros}{}{}{}{}

\ProvidesFile{sbl.cbx}[\sbl@abx@cbxid]

% Provide a hypertarget for entries using a crossref so short citations can
% link to it
\DeclareFieldFormat{bibhypertarget}{%
  \ifboolexpr{
    not test {\iffieldundef{crossref}}
    and
    not test {\ifcrossrefseen}
  }
    {\bibhypertarget{\iffootnote{f}{t}:\cbx@resetcount:\thefield{crossref}}{}}
    {}%
  \bibhypertarget{\iffootnote{f}{t}:\cbx@resetcount:\thefield{entrykey}}{#1}}

% toggle to put details (translator, edition, text collection) in parentheses
% after the title and source division. By default this is true except when all
% of the following conditions are satisfied:
%   - a text collection or edition is included in the bib entry (using the
%     xref field)
%   - a postnote is specified for the text collection or edition in the
%     citation (without this, the text collection is not printed)
%   - the citation is a \parencite or some derivative
\newtoggle{sbl@blx@ancienttext@useparens}
\toggletrue{sbl@blx@ancienttext@useparens}

% test if currently in brackets or parentheses
\newrobustcmd*{\ifinparens}[2]{%
  \ifnum\blx@parenlevel>\z@
    #1%
  \else
    #2%
  \fi}

\def\cbx@opt@citepages@omit{%
  \renewbibmacro*{cite:citepages}{}%
  \renewbibmacro*{cite:full:citepages}{%
    \ifboolexpr{
      test {\ifnumequal{\value{citecount}}{\value{citetotal}}}
      and
      (
        test {\iffieldbegpages{postnote}}
        or
        test {\iffieldbegpages{volcitepages}}
      )
    }
      {\clearfield{pages}%
       \clearfield{pagetotal}}
      {}}%
  \renewbibmacro*{cite:postnote}{%
    \usebibmacro{cite:postnote:ibidpage}}}

\def\cbx@opt@citepages@separate{%
  \providetoggle{cbx:fullcite}%
  \renewbibmacro*{cite:citepages}{%
    \global\togglefalse{cbx:fullcite}}%
  \renewbibmacro*{cite:full:citepages}{%
    \global\toggletrue{cbx:fullcite}}%
  \renewbibmacro*{cite:postnote}{%
    \ifboolexpr{
      togl {cbx:fullcite}
      and
      (
        test {\iffieldbegpages{postnote}}
        or
        test {\iffieldbegpages{volcitepages}}
      )
      and
      test {\ifnumequal{\value{citecount}}{\value{citetotal}}}
      and
      (
       not test {\iffieldundef{pages}}
       or
       not test {\iffieldundef{pagetotal}}
       or
       test {\iffieldequalstr{relatedtype}{multivolarticle}}
      )
    }
      {\usebibmacro{cite:postnote:pages}}
      {\usebibmacro{cite:postnote:ibidpage}}}
  \providebibmacro*{cite:postnote:pages}{%
    \setunit{\printdelim{postnotedelim}}%
    \bibstring{thiscite}%
    \setunit{\addspace}%
    \printfield{postnote}}}

\ExecuteBibliographyOptions{
  citepages=omit,
  citetracker=context,
  dateabbrev=false,
  ibidtracker=false,
  idemtracker=citation,
  isbn=false,
  language=american,
  maxbibnames=99,
  mincrossrefs=2,
  minxrefs=1,
  nametracker=context,
  pagetracker=true,
  sorting=nwty,
  uniquework=true,
}

\ExecuteBibliographyOptions[ancienttext]{%
  skipbib
}

\ExecuteBibliographyOptions[book,collection,commentary,reference]{%
  usetitle
}

% SBL needs useprefix=true for citations, but not in sorting or bibliography
\AtEveryCite{\toggletrue{blx@useprefix}}

\RequirePackage[after=title]{biblatex-source-division}

\renewbibmacro{getsourcedivision}{%
  \ifboolexpr{
    test {\iffieldundef{postnote}}
    or
    (
      not test {\iffieldundef{volcitevolume}}
      and
      test {\iffieldundef{volcitepages}}
    )
  }
    {}
    {\iffieldundef{volcitevolume}
       {\usefield{\getsourcedivision@}{postnote}}
       {\usefield{\getsourcedivision@}{volcitepages}}%
     \ifdefempty{\blxsd@titleaddon}
       {}
       {\ifboolexpr{
          test {\iffieldundef{maintitle}}
          or
          test {\ifdefstring{\biblatexsourcedivision@after}{title}}
        }
          {\restorefield{titleaddon}{\blxsd@titleaddon}}
          {\restorefield{maintitleaddon}{\blxsd@titleaddon}}}%
     \iffieldundef{volcitevolume}
       {\ifdefempty{\blxsd@postnote}
          {\clearfield{postnote}}
          {\restorefield{postnote}{\blxsd@postnote}}}
       {\ifdefempty{\blxsd@postnote}
          {\clearfield{volcitepages}%
           \edef\abx@field@postnote{{\abx@field@volcitevolume}{}}}
          {\restorefield{volcitepages}{\blxsd@postnote}%
           \edef\abx@field@postnote{%
             {\unexpanded\expandafter{\abx@field@volcitevolume}}%
             {\unexpanded\expandafter{\abx@field@volcitepages}}}}}}}

\def\getsourcedivision@ii(#1)#2++{%
  \gdef\blxsd@titleaddon{#1}%
  \gdef\blxsd@postnote{#2}}

% Thanks to @moewe (https://tex.stackexchange.com/a/497548/87678)
\ExplSyntaxOn
\cs_new_protected:Nn \__sblblx_declare_nestable_cite_command:nnn
  {
    \cs_set_nopar:cpn { __sblblx_cite_temp:n } ##1
      {
        \blx@xsanitizeafter \blx@nocite@do {##1}
        \blx@ifdata {##1}
          {
            \begingroup
            \blx@blxinit
            \entrydata {##1} {#3}
            \endgroup
          }
          { \abx@missing@entry {##1} }
      }
    \bool_if:nTF {#1}
      {
        \cs_set_eq:cc { __sblblx_cite_star_#2:n } { __sblblx_cite_temp:n }
      }
      {
        \cs_set_eq:cc { __sblblx_cite_#2:n } { __sblblx_cite_temp:n }
      }
    \cs_set_protected_nopar:cpn {#2}
      {
        \peek_meaning_remove:NTF *
          {
            \cs_if_exist:cTF { __sblblx_cite_star_#2:n }
              { \use:c { __sblblx_cite_star_#2:n } }
              { \use:c { __sblblx_cite_#2:n } }
          }
          { \use:c { __sblblx_cite_#2:n } }
      }
  }
\NewDocumentCommand \DeclareNestableCiteCommand { s m m }
  {
    \__sblblx_declare_nestable_cite_command:nnn {#1} {#2} {#3}
  }
\ExplSyntaxOff

\DeclareNestableCiteCommand{citejournal}
  {\usebibmacro{abbrev:shortfield}{shortjournal}{journaltitle}}

\DeclareNestableCiteCommand*{citejournal}
  {\printfield{journaltitle}}

\DeclareNestableCiteCommand{citeseries}
  {\usebibmacro{abbrev:shortfield}{shortseries}{series}}

\DeclareNestableCiteCommand*{citeseries}
  {\printfield{series}}

\DeclareNestableCiteCommand{citeshorthand}
  {\usebibmacro{cite:shorthand}}

\DeclareNestableCiteCommand{abbrev}
  {\usebibmacro{cite:shorthand}}

% Note: biblatex-sbl does not use the postcode declared with
% \DeclareCiteCommand so it is left blank to avoid confusion. Where
% appropriate it is included in the loopcode in the declarations below,
% otherwise the printing is taken care of in the cite bibmacro. This is
% because the postnote generally does not fall at the end of the citation.
\DeclareCiteCommand*{\cite}
  {\usebibmacro{prenote}}
  {\usebibmacro{cite:star}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {}

\DeclareCiteCommand{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \ifnameseen
     {\printnames{labelname}}
     {\printnames[given-family]{labelname}%
      \nametracker}%
   \usebibmacro{postnote}}
  {\multicitedelim}
  {}

\DeclareCiteCommand*{\citeauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \ifnameseen
     {\printnames[][1-1]{labelname}}
     {\printnames[given-family][1-1]{labelname}%
      \nametracker}%
   \usebibmacro{postnote}}
  {\multicitedelim}
  {}

\DeclareCiteCommand{\citeshortauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames{labelname}%
   \usebibmacro{postnote}}
  {\multicitedelim}
  {}

\DeclareCiteCommand*{\citeshortauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames[][1-1]{labelname}%
   \usebibmacro{postnote}}
  {\multicitedelim}
  {}

\providecommand{\citefullauthor}{}
\undef\citefullauthor
\DeclareCiteCommand{\citefullauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames[given-family]{labelname}%
   \usebibmacro{postnote}}
  {\multicitedelim}
  {}

\DeclareCiteCommand*{\citefullauthor}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\ifciteindex
     {\indexnames{labelname}}
     {}%
   \printnames[given-family][1-1]{labelname}%
   \usebibmacro{postnote}}
  {\multicitedelim}
  {}

\providecommand\Citefullauthor{}
\renewrobustcmd*{\Citefullauthor}{%
  \@ifstar{\bibsentence\citefullauthor*}{\bibsentence\citefullauthor}}
\newrobustcmd*{\Citeshortauthor}{%
  \@ifstar{\bibsentence\citeshortauthor*}{\bibsentence\citeshortauthor}}

\DeclareCiteCommand{\citetitle}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\DeclareFieldAlias{bibhyperlink}{default}%
   \usebibmacro{cite:title}%
   \usebibmacro{postnote}}
  {\multicitedelim}
  {}

\DeclareCiteCommand*{\citetitle}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\usebibmacro{title}%
   \usebibmacro{postnote}}
  {\multicitedelim}
  {}

\DeclareCiteCommand{\citecollection}
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\usebibmacro{cite:collection}}
  {\multicitedelim}
  {}

\DeclareCiteCommand{\parencitecollection}[\mkbibparens]
  {\boolfalse{citetracker}%
   \boolfalse{pagetracker}%
   \usebibmacro{prenote}}
  {\usebibmacro{cite:collection}}
  {\multicitedelim}
  {}

\DeclareCiteCommand*{\footcite}[\mkbibfootnote]
  {\usebibmacro{prenote}}
  {\usebibmacro{cite:star}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {}

\DeclareCiteCommand*{\footcitetext}[\mkbibfootnotetext]
  {\usebibmacro{prenote}}
  {\usebibmacro{cite:star}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {}

\DeclareCiteCommand*{\parencite}[\mkbibparens]
  {\usebibmacro{prenote}}
  {\usebibmacro{cite:star}%
   \usebibmacro{cite}}
  {\multicitedelim}
  {}

% \sblfootquotepunct is inserted at the end of a quotation immediately before
% a citation to ensure punctuation is placed inside quotation if using us
% style punctuation
\newbool{sbl@blx@footquotesuppressperiod}
\NewDocumentCommand\sblfootquotepunct{om}{%
  \ifentryseen{#2}
    {\IfNoValueF{#1}{#1}%
     \global\boolfalse{sbl@blx@footquotesuppressperiod}}
    {\blx@ifuspunct
       {\IfNoValueTF{#1}{.}{#1}%
        \global\booltrue{sbl@blx@footquotesuppressperiod}}
       {\IfNoValueF{#1}
          {#1\global\booltrue{sbl@blx@footquotesuppressperiod}}}}}

% set a boolean flag to indicate we are inside a footnote from \smartcite
\newbool{sbl@blx@footnote}
\newrobustcmd\mksblsmartfootcite[1]{%
  \begingroup
  \blx@blxinit
  \blx@setsfcodes
  \booltrue{sbl@blx@footnote}%
  #1%
  \endgroup}

% set a boolean flag to indicate we are inside parentheses
\newbool{sbl@blx@footinparens}
% format the start of a smart citation
%   - normal behaviour for \smartcite in running text and \smartcites
%   - if in footnote
%       - add `\addperiod\space` and set `prenote` to
%         `\bibstring{see}` for first citation
%       - add opening parenthesis for subsequent citation
\newbibmacro{smartcitestart}{%
  \ifboolexpr{
    test {\ifnumequal\c@citetotal\@ne}
    and
    test {\ifnumequal\c@multicitetotal\z@}
    and
    bool {sbl@blx@footnote}
  }
    {\ifciteseen
       {\bibopenparen
        \booltrue{sbl@blx@footinparens}}
       {\ifbool{sbl@blx@footquotesuppressperiod}
          {}
          {\addperiod\space}%
        \bibsentence
        \setfield{prenote}{\bibstring{see}}}}
    {}}

% format the end of a smart citation
%   - normal behaviour for \smartcite in running text and \smartcites
%   - if in footnote
%       - add closing parenthesis if opened by smartcitestart
\newbibmacro{smartciteend}{%
  \ifbool{sbl@blx@footinparens}
    {\bibcloseparen}
    {}}

% integrate \ifciteseen logic into \smartcite and \smartcite* in footnotes
\DeclareCiteCommand{\smartcite}[\iffootnote\mksblsmartfootcite\mkbibfootnote]
  {\usebibmacro{smartcitestart}%
   \usebibmacro{prenote}}
  {\usebibmacro{citeindex}%
   \usebibmacro{cite}%
   \usebibmacro{smartciteend}}
  {\multicitedelim}
  {}

\DeclareCiteCommand*{\smartcite}[\iffootnote\mksblsmartfootcite\mkbibfootnote]
  {\usebibmacro{smartcitestart}%
   \usebibmacro{prenote}}
  {\usebibmacro{cite:star}%
   \usebibmacro{cite}%
   \usebibmacro{smartciteend}}
  {\multicitedelim}
  {}

% define \fullcite commands which always produce a full citation

\newtoggle{sbl@blx@usefullcite}
\newrobustcmd*{\fullcitecmd}{\AtNextCite{\toggletrue{sbl@blx@usefullcite}}}

\renewrobustcmd*{\fullcite}{\fullcitecmd\cite}
\newrobustcmd*{\pfullcite}{\fullcitecmd\parencite}
\newrobustcmd*{\ffullcite}{\fullcitecmd\footcite}
\newrobustcmd*{\ftfullcite}{\fullcitecmd\footcitetext}
\newrobustcmd*{\sfullcite}{\fullcitecmd\smartcite}
\newrobustcmd*{\afullcite}{\fullcitecmd\autocite}

\newrobustcmd*{\fullcites}{\fullcitecmd\cites}
\newrobustcmd*{\pfullcites}{\fullcitecmd\parencites}
\newrobustcmd*{\ffullcites}{\fullcitecmd\footcites}
\newrobustcmd*{\ftfullcites}{\fullcitecmd\footcitetext}
\newrobustcmd*{\sfullcites}{\fullcitecmd\smartcites}
\newrobustcmd*{\afullcites}{\fullcitecmd\autocites}

\newrobustcmd*{\volfullcite}{\volcitecmd\fullcite}
\newrobustcmd*{\pvolfullcite}{\volcitecmd\pfullcite}
\newrobustcmd*{\fvolfullcite}{\volcitecmd\ffullcite}
\newrobustcmd*{\ftvolfullcite}{\volcitecmd\ftfullcite}
\newrobustcmd*{\svolfullcite}{\volcitecmd\sfullcite}
\newrobustcmd*{\avolfullcite}{\volcitecmd\afullcite}

\newrobustcmd*{\volfullcites}{\multivolcitecmd\fullcites}
\newrobustcmd*{\pvolfullcites}{\multivolcitecmd\pfullcites}
\newrobustcmd*{\fvolfullcites}{\multivolcitecmd\ffullcites}
\newrobustcmd*{\ftvolfullcites}{\multivolcitecmd\ftfullcites}
\newrobustcmd*{\svolfullcites}{\multivolcitecmd\sfullcites}
\newrobustcmd*{\avolfullcites}{\multivolcitecmd\afullcites}

\newrobustcmd*{\Fullcite}{\fullcitecmd\Cite}
\newrobustcmd*{\Pfullcite}{\fullcitecmd\Parencite}
\newrobustcmd*{\Ffullcite}{\fullcitecmd\Footcite}
\newrobustcmd*{\Ftfullcite}{\fullcitecmd\Footcitetext}
\newrobustcmd*{\Sfullcite}{\fullcitecmd\Smartcite}
\newrobustcmd*{\Afullcite}{\fullcitecmd\Autocite}

\newrobustcmd*{\Fullcites}{\fullcitecmd\Cites}
\newrobustcmd*{\Pfullcites}{\fullcitecmd\Parencites}
\newrobustcmd*{\Ffullcites}{\fullcitecmd\Footcites}
\newrobustcmd*{\Ftfullcites}{\fullcitecmd\Footcitetext}
\newrobustcmd*{\Sfullcites}{\fullcitecmd\Smartcites}
\newrobustcmd*{\Afullcites}{\fullcitecmd\Autocites}

\newrobustcmd*{\Volfullcite}{\volcitecmd\Fullcite}
\newrobustcmd*{\Pvolfullcite}{\volcitecmd\Pfullcite}
\newrobustcmd*{\Fvolfullcite}{\volcitecmd\Ffullcite}
\newrobustcmd*{\Ftvolfullcite}{\volcitecmd\Ftfullcite}
\newrobustcmd*{\Svolfullcite}{\volcitecmd\Sfullcite}
\newrobustcmd*{\Avolfullcite}{\volcitecmd\Afullcite}

\newrobustcmd*{\Volfullcites}{\multivolcitecmd\Fullcites}
\newrobustcmd*{\Pvolfullcites}{\multivolcitecmd\Pfullcites}
\newrobustcmd*{\Fvolfullcites}{\multivolcitecmd\Ffullcites}
\newrobustcmd*{\Ftvolfullcites}{\multivolcitecmd\Ftfullcites}
\newrobustcmd*{\Svolfullcites}{\multivolcitecmd\Sfullcites}
\newrobustcmd*{\Avolfullcites}{\multivolcitecmd\Afullcites}

% Define transcite commands to cite @ancienttext entry types with a translator

\newtoggle{sbl@blx@transcite}
\newrobustcmd*{\transcitecmd}{\AtNextCite{\toggletrue{sbl@blx@transcite}}}

% transcite variants
\newrobustcmd*{\transcite}{\transcitecmd\cite}
\newrobustcmd*{\ptranscite}{\transcitecmd\parencite}
\newrobustcmd*{\ftranscite}{\transcitecmd\footcite}
\newrobustcmd*{\fttranscite}{\transcitecmd\footcitetext}
\newrobustcmd*{\stranscite}{\transcitecmd\smartcite}
\newrobustcmd*{\atranscite}{\transcitecmd\autocite}

\newrobustcmd*{\transcites}{\transcitecmd\cites}
\newrobustcmd*{\ptranscites}{\transcitecmd\parencites}
\newrobustcmd*{\ftranscites}{\transcitecmd\footcites}
\newrobustcmd*{\fttranscites}{\transcitecmd\footcitetexts}
\newrobustcmd*{\stranscites}{\transcitecmd\smartcites}
\newrobustcmd*{\atranscites}{\transcitecmd\autocites}

\newrobustcmd*{\voltranscite}{\volcitecmd\transcite}
\newrobustcmd*{\pvoltranscite}{\volcitecmd\ptranscite}
\newrobustcmd*{\fvoltranscite}{\volcitecmd\ftranscite}
\newrobustcmd*{\ftvoltranscite}{\volcitecmd\fttranscite}
\newrobustcmd*{\svoltranscite}{\volcitecmd\stranscite}
\newrobustcmd*{\avoltranscite}{\volcitecmd\atranscite}

\newrobustcmd*{\voltranscites}{\multivolcitecmd\transcites}
\newrobustcmd*{\pvoltranscites}{\multivolcitecmd\ptranscites}
\newrobustcmd*{\fvoltranscites}{\multivolcitecmd\ftranscites}
\newrobustcmd*{\ftvoltranscites}{\multivolcitecmd\fttranscites}
\newrobustcmd*{\svoltranscites}{\multivolcitecmd\stranscites}
\newrobustcmd*{\avoltranscites}{\multivolcitecmd\atranscites}

\newrobustcmd*{\transcitecollection}{\transcitecmd\citecollection}
\newrobustcmd*{\ptranscitecollection}{\transcitecmd\parencitecollection}

\newrobustcmd*{\Transcite}{\transcitecmd\Cite}
\newrobustcmd*{\Ptranscite}{\transcitecmd\Parencite}
\newrobustcmd*{\Ftranscite}{\transcitecmd\Footcite}
\newrobustcmd*{\Fttranscite}{\transcitecmd\Footcitetext}
\newrobustcmd*{\Stranscite}{\transcitecmd\Smartcite}
\newrobustcmd*{\Atranscite}{\transcitecmd\Autocite}

\newrobustcmd*{\Transcites}{\transcitecmd\Cites}
\newrobustcmd*{\Ptranscites}{\transcitecmd\Parencites}
\newrobustcmd*{\Ftranscites}{\transcitecmd\Footcites}
\newrobustcmd*{\Fttranscites}{\transcitecmd\Footcitetexts}
\newrobustcmd*{\Stranscites}{\transcitecmd\Smartcites}
\newrobustcmd*{\Atranscites}{\transcitecmd\Autocites}

\newrobustcmd*{\Voltranscite}{\volcitecmd\Transcite}
\newrobustcmd*{\Pvoltranscite}{\volcitecmd\Ptranscite}
\newrobustcmd*{\Fvoltranscite}{\volcitecmd\Ftranscite}
\newrobustcmd*{\Ftvoltranscite}{\volcitecmd\Fttranscite}
\newrobustcmd*{\Svoltranscite}{\volcitecmd\Stranscite}
\newrobustcmd*{\Avoltranscite}{\volcitecmd\Atranscite}

\newrobustcmd*{\Voltranscites}{\multivolcitecmd\Transcites}
\newrobustcmd*{\Pvoltranscites}{\multivolcitecmd\Ptranscites}
\newrobustcmd*{\Fvoltranscites}{\multivolcitecmd\Ftranscites}
\newrobustcmd*{\Ftvoltranscites}{\multivolcitecmd\Fttranscites}
\newrobustcmd*{\Svoltranscites}{\multivolcitecmd\Stranscites}
\newrobustcmd*{\Avoltranscites}{\multivolcitecmd\Atranscites}

% transcite and fullcite variants
\newrobustcmd*{\transfullcite}{\transcitecmd\fullcite}
\newrobustcmd*{\ptransfullcite}{\transcitecmd\pfullcite}
\newrobustcmd*{\ftransfullcite}{\transcitecmd\ffullcite}
\newrobustcmd*{\fttransfullcite}{\transcitecmd\ftfullcite}
\newrobustcmd*{\stransfullcite}{\transcitecmd\sfullcite}
\newrobustcmd*{\atransfullcite}{\transcitecmd\afullcite}

\newrobustcmd*{\transfullcites}{\transcitecmd\fullcites}
\newrobustcmd*{\ptransfullcites}{\transcitecmd\pfullcites}
\newrobustcmd*{\ftransfullcites}{\transcitecmd\ffullcites}
\newrobustcmd*{\fttransfullcites}{\transcitecmd\ftfullcites}
\newrobustcmd*{\stransfullcites}{\transcitecmd\sfullcites}
\newrobustcmd*{\atransfullcites}{\transcitecmd\afullcites}

\newrobustcmd*{\voltransfullcite}{\volcitecmd\transfullcite}
\newrobustcmd*{\pvoltransfullcite}{\volcitecmd\ptransfullcite}
\newrobustcmd*{\fvoltransfullcite}{\volcitecmd\ftransfullcite}
\newrobustcmd*{\ftvoltransfullcite}{\volcitecmd\fttransfullcite}
\newrobustcmd*{\svoltransfullcite}{\volcitecmd\stransfullcite}
\newrobustcmd*{\avoltransfullcite}{\volcitecmd\atransfullcite}

\newrobustcmd*{\voltransfullcites}{\multivolcitecmd\transfullcites}
\newrobustcmd*{\pvoltransfullcites}{\multivolcitecmd\ptransfullcites}
\newrobustcmd*{\fvoltransfullcites}{\multivolcitecmd\ftransfullcites}
\newrobustcmd*{\ftvoltransfullcites}{\multivolcitecmd\fttransfullcites}
\newrobustcmd*{\svoltransfullcites}{\multivolcitecmd\stransfullcites}
\newrobustcmd*{\avoltransfullcites}{\multivolcitecmd\atransfullcites}

\newrobustcmd*{\Transfullcite}{\transcitecmd\Fullcite}
\newrobustcmd*{\Ptransfullcite}{\transcitecmd\Pfullcite}
\newrobustcmd*{\Ftransfullcite}{\transcitecmd\Ffullcite}
\newrobustcmd*{\Fttransfullcite}{\transcitecmd\Ftfullcite}
\newrobustcmd*{\Stransfullcite}{\transcitecmd\Sfullcite}
\newrobustcmd*{\Atransfullcite}{\transcitecmd\Afullcite}

\newrobustcmd*{\Transfullcites}{\transcitecmd\Fullcites}
\newrobustcmd*{\Ptransfullcites}{\transcitecmd\Pfullcites}
\newrobustcmd*{\Ftransfullcites}{\transcitecmd\Ffullcites}
\newrobustcmd*{\Fttransfullcites}{\transcitecmd\Ftfullcites}
\newrobustcmd*{\Stransfullcites}{\transcitecmd\Sfullcites}
\newrobustcmd*{\Atransfullcites}{\transcitecmd\Afullcites}

\newrobustcmd*{\Voltransfullcite}{\volcitecmd\Transfullcite}
\newrobustcmd*{\Pvoltransfullcite}{\volcitecmd\Ptransfullcite}
\newrobustcmd*{\Fvoltransfullcite}{\volcitecmd\Ftransfullcite}
\newrobustcmd*{\Ftvoltransfullcite}{\volcitecmd\Fttransfullcite}
\newrobustcmd*{\Svoltransfullcite}{\volcitecmd\Stransfullcite}
\newrobustcmd*{\Avoltransfullcite}{\volcitecmd\Atransfullcite}

\newrobustcmd*{\Voltransfullcites}{\multivolcitecmd\Transfullcites}
\newrobustcmd*{\Pvoltransfullcites}{\multivolcitecmd\Ptransfullcites}
\newrobustcmd*{\Fvoltransfullcites}{\multivolcitecmd\Ftransfullcites}
\newrobustcmd*{\Ftvoltransfullcites}{\multivolcitecmd\Fttransfullcites}
\newrobustcmd*{\Svoltransfullcites}{\multivolcitecmd\Stransfullcites}
\newrobustcmd*{\Avoltransfullcites}{\multivolcitecmd\Atransfullcites}


% main citation macros

\renewbibmacro*{cite}{%
  \usebibmacro{cite:usefull}%
  \ifboolexpr{
    test {\ifentrytype{ancienttext}}
    and
    togl {sbl@blx@transcite}
  }
    {\usebibmacro{cite:trans:ancienttext}}
    {\iffieldequalstr{relatedtype}{multivolarticle}
       {\cbx@opt@citepages@separate}
       {}%
     \usebibmacro{cite:citepages}%
     \global\togglefalse{cbx:loccit}%
     \ifboolexpr{
       test {\ifciteseen}
       or
       not test {\iffieldundef{shorthand}}
       or
       test {\ifentrytype{series}}
     }
       {\ifboolexpr{
          test {\ifentrytype{series}}
          and
          test {\iffieldundef{shorthand}}
        }
          {\delimcontext{series}%
           \usebibmacro{abbrev:shortfield}{shortseries}{series}%
           \usebibmacro*{cite:postnote}}
          {\iffieldundef{shorthand}
             {\ifboolexpr{
                test {\ifciteibid}
                and
                not test {\iffirstonpage}
              }
                {\usebibmacro{cite:ibid}%
                 \usebibmacro{cite:postnote}}
                {\ifdefbibmacro{cite:short:\thefield{entrytype}}
                   {\usebibmacro*{cite:short:\thefield{entrytype}}}
                   {\usebibmacro{cite:short}}}%
                 \AtNextCitekey{\blx@idemreset}}
             {\usebibmacro{cite:shorthand}%
              \usebibmacro{cite:postnote}}}}
       {\ifciteidem
          {\DeclareNameAlias{default}{labelname}}
          {}%
        \ifboolexpr{
          test {\ifcrossrefseen}
          and
          test {\ifdefbibmacro{cite:full:\thefield{entrytype}:seen}}
        }
         {\usebibmacro{cite:full:citepages}%
          \printtext[bibhypertarget]{\usebibmacro*{cite:full:\thefield{entrytype}:seen}}}
         {\ifentrytype{ancienttext}
            {\usebibmacro{cite:short:ancienttext}}
            {\usebibmacro{cite:full}}}}}}

\newbibmacro*{cite:usefull}{%
  \iftoggle{sbl@blx@usefullcite}
    {\let\ifciteseen\@secondoftwo
     \let\ifcrossrefseen\@secondoftwo
     \boolfalse{citetracker}%
     \boolfalse{pagetracker}%
     \DeclareFieldAlias{bibhypertarget}{default}%
     \restorefield{labeltitle}{\abx@field@title}%
     \clearfield{shorttitle}%
     \clearfield{shortmaintitle}}
    {}}

\newbibmacro*{cite:star}{%
  \let\ifciteibid\@secondoftwo%
  \renewbibmacro*{author}{}%
  \renewbibmacro*{editor+others}{}%
  \renewbibmacro*{translator+others}{}}

\renewbibmacro*{cite:short}{%
  \printnames{labelname}%
  \clearname{\thefield{labelnamesource}}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{cite:title}%
  \ifuniquework
    {}
    {\usebibmacro{cite:label:editor}}%
  \usebibmacro{cite:postnote}}

\renewbibmacro*{cite:shorthand}{%
  \printtext[shorthandlink]{\printfield{shorthand}}}

\newbibmacro*{cite:title}{%
  \ifentrytype{ancienttext}
    {\usebibmacro{cite:shorttitle:ancienttext}}
    {\printtext[citetitle]{\printfield[bibhyperlink]{labeltitle}}}}

\newbibmacro*{cite:label:editor}{%
  \setunit{\addspace}%
  \ifnameundef{editor}
    {\ifnameundef{bookeditor}
       {\ifnameundef{maineditor}
          {}
          {\printtext[parens]{\printnames[labelname]{maineditor}}}}
       {\printtext[parens]{\printnames[labelname]{bookeditor}}}}
    {\printtext[parens]{\printnames[labelname]{editor}}}}

\newbibmacro*{cite:collection}{%
  \ifentrytype{ancienttext}
    {\usebibmacro{cite:setformat:ancienttext}%
     \iftoggle{sbl@blx@transcite}
       {\usebibmacro{cite:translator:ancienttext}%
        \newunit}
       {}%
     \usebibmacro{cite:collection:ancienttext}}
    {\renewbibmacro*{author/translator+others}{}%
     \renewbibmacro*{title}{}%
     \usebibmacro{cite:full}}}

\newbibmacro*{cite:short:inreference}{%
  \iffieldundef{postnote}
    {}
    {\clearfield{pages}}%
  \printnames{labelname}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{cite:title}%
  \setunit{\bibpagespunct}%
  \usebibmacro{volume+part+pages}}

\newbibmacro*{cite:short:online}{%
  \printnames{labelname}%
  \setunit{\printdelim{nametitledelim}}%
  \begingroup
  \iffieldundef{title}
    {}
    {\usebibmacro{cite:title}%
     \DeclareFieldAlias{shorttitlelink}{default}}%
  \ifboolexpr{
    not test {\ifnameundef{labelname}}
    and
    not test {\iffieldundef{title}}
  }
    {}
    {\newunit
     \iffieldundef{type}
       {\printtext[shorttitlelink]{\printfield{website}}}
       {\printtext[shorttitlelink]{\printfield{type}}}}%
  \endgroup
  \usebibmacro{cite:postnote}}

\newbibmacro*{cite:short:periodical}{%
  \printnames{labelname}%
  \clearname{\thefield{labelnamesource}}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \iffieldundef{title}
    {\usebibmacro{abbrev:shortfield}{shortjournal}{journaltitle}}
    {\usebibmacro{cite:title}%
     \ifuniquework
       {}
       {\usebibmacro{cite:label:editor}}}%
  \usebibmacro{cite:postnote}}

\newbibmacro*{cite:short:review}{%
  \iffieldundef{title}
    {\printnames{labelname}%
     \setunit{\printdelim{nametitledelim}}\newblock
     \printtext[bibhyperlink]{%
      \biblstring{reviewof}%
       \setunit{\addspace}%
       \usebibmacro{revdlabeltitle}}%
     \usebibmacro{revdlabelname}%
     \usebibmacro{cite:postnote}}
    {\usebibmacro{cite:short}}}

\newbibmacro*{cite:full:book:seen}{%
  \usebibmacro{author/editor+others/translator+others}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{volume+part+of:}%
  \entrydata*{\thefield{crossref}}{%
    \renewbibmacro{cite:postnote}{}%
    \usebibmacro{cite:short}}%
  \usebibmacro{chapter+pages}}

\newbibmacro*{cite:full:inbook:seen}{%
  \usebibmacro{author/translator+others}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \newunit\newblock
  \usebibmacro{pages+in:}%
  \entrydata*{\thefield{crossref}}{%
    \renewbibmacro{cite:postnote}{}%
    \usebibmacro{cite:short}}%
  \usebibmacro{volume+part+pages}}

\newbibmacro*{cite:full:suppbook:seen}{%
  \usebibmacro{author/translator+others}%
  \setunit{\printdelim{nametitledelim}}\newblock
  \usebibmacro{title}%
  \newunit
  \printlist{language}%
  \newunit\newblock
  \usebibmacro{byauthor}%
  \setunit{\addspace}%
  \usebibmacro{to:}%
  \entrydata*{\thefield{crossref}}{%
    \renewbibmacro{cite:postnote}{}%
    \usebibmacro{cite:short}}%
  \usebibmacro{volume+part+pages}}

\newbibmacro*{cite:full:commentary:seen}{%
  \usebibmacro{cite:full:book:seen}}

\newbibmacro*{cite:full:incommentary:seen}{%
  \usebibmacro{cite:full:inbook:seen}}

\newbibmacro*{cite:full:collection:seen}{%
  \usebibmacro{cite:full:book:seen}}

\newbibmacro*{cite:full:incollection:seen}{%
  \usebibmacro{cite:full:inbook:seen}}

\newbibmacro*{cite:full:proceedings:seen}{%
  \usebibmacro{cite:full:book:seen}}

\newbibmacro*{cite:full:inproceedings:seen}{%
  \iffieldundef{booktitle}
    {\usebibmacro{cite:full}}
    {\usebibmacro{cite:full:incollection:seen}}}

\newbibmacro*{cite:full:reference:seen}{%
  \usebibmacro{cite:full:book:seen}}

\newbibmacro*{cite:full:inreference:seen}{%
  \iffieldundef{booktitle}
    {\usebibmacro{cite:full}}
    {\usebibmacro{cite:full:inbook:seen}}}

% ancienttext citation macros

\newbibmacro*{cite:setformat:ancienttext}{%
  % no pages if postnote is set
  \iffieldundef{postnote}
    {}
    {\clearfield{pages}}%
  % no pages if no source division and no postnote
  \ifboolexpr{
    (
      not test {\iffieldundef{titleaddon}}
      or
      not test {\iffieldundef{maintitleaddon}}
    )
    and
    test {\iffieldundef{postnote}}
  }
    {\clearfield{pages}}
    {}%
  % don't print xref if no reference attached to it
  \ifboolexpr{
    test {\iffieldundef{pages}}
    and
    (
      test {\iffieldundef{postnote}}
      or
      not test {\iffieldundef{volcitevolume}}
      and
      test {\iffieldundef{volcitepages}}
    )
  }
    {\togglefalse{sbl@blx@usexref}}
    {}%
  % smuggle translator from xref to main entry if needed
  \iffieldundef{xref}
    {\togglefalse{sbl@blx@usexref}}
    {\ifnameundef{translator}
       {\entrydata*{\thefield{xref}}{%
          \savename{translator}{\sbl@saved@translator}%
          \setcounter{sbl@savedtranslator}{\value{translator}}}%
        \restorename{translator}{\sbl@saved@translator}%
        \setcounter{translator}{\value{sbl@savedtranslator}}}
       {}}%
  % clear translator if not needed
  \iftoggle{sbl@blx@transcite}
    {}
    {\clearname{translator}}%
  % disable printing of parentheses if no translator and no xref
  % or if xref and in parentheses already or in the presence of xrefstring
  \ifboolexpr{
    not test {\iffieldundef{xrefstring}}
    or
    (
      not togl {sbl@blx@usexref}
      and
      test {\ifnameundef{translator}}
    )
    or
    (
      togl {sbl@blx@usexref}
      and
      test {\ifinparens}
    )
  }
    {\togglefalse{sbl@blx@ancienttext@useparens}}
    {}}

% cite ancienttext without translator
\newbibmacro*{cite:short:ancienttext}{%
  \usebibmacro{cite:setformat:ancienttext}%
  \usebibmacro{cite:title:ancienttext}%
  \newunit
  \iftoggle{sbl@blx@ancienttext@useparens}
    {\setunit{\addspace}%
     \printtext{\bibopenparen}}
    {}%
  \usebibmacro{cite:collection:ancienttext}%
  \iftoggle{sbl@blx@ancienttext@useparens}
    {\printtext{\bibcloseparen}}
    {}}

% cite ancienttext with translator
\newbibmacro*{cite:trans:ancienttext}{%
  \usebibmacro{cite:citepages}%
  \ifciteseen
    {\iffieldundef{postnote}
       {}
       {\clearfield{pages}}}
    {\usebibmacro{cite:full:citepages}}%
  \usebibmacro{cite:setformat:ancienttext}%
  \usebibmacro{cite:title:ancienttext}%
  \newunit
  \iftoggle{sbl@blx@ancienttext@useparens}
    {\setunit{\addspace}%
     \printtext{\bibopenparen}}
    {}%
  \usebibmacro{cite:translator:ancienttext}%
  \setunit*{\newunitpunct}%
  \usebibmacro{cite:collection:ancienttext}%
  \iftoggle{sbl@blx@ancienttext@useparens}
    {\setunit{\nopunct}%
     \printtext{\bibcloseparen}}
    {}}

% ancienttext title macros
\newbibmacro*{cite:title:ancienttext}{%
  \ifnameundef{author}
    {}
    {\usebibmacro{author}%
     \setunit{\printdelim{nametitledelim}}}%
  \ifboolexpr{
    test {\iffieldundef{xref}}
    and
    test {\iffieldundef{postnote}}
    and
    test {\iffieldundef{titleaddon}}
  }
    {\clearfield{shortmaintitle}%
     \clearfield{shorttitle}%
     \restorefield{labeltitle}{\abx@field@title}}
    {}%
  \usebibmacro{cite:maintitle:ancienttext}%
  \newblock
  \ifboolexpr{
    not test {\ifciteseen}
    and
    not test {\iffieldundef{entrysubtype}}
  }
    {\usebibmacro{title}}
    {\usebibmacro{cite:title}}%
  \iftoggle{sbl@blx@usexref}
    {}
    {\setunit{\bibpagespunct}%
     \usebibmacro{cite:postnote}}}

\newbibmacro*{cite:shorttitle:ancienttext}{%
  \printtext[citetitle]{%
    \iffieldundef{shorttitle}
      {\printfield{labeltitle}}
      {\printtext[shorttitlelink]{\printfield{labeltitle}}}}%
  \setunit{\titleaddonpunct}%
  \printfield{titleaddon}}

\newbibmacro*{cite:maintitle:ancienttext}{%
  \iffieldundef{shortmaintitle}
    {\printfield[citetitle]{maintitle}}
    {\printtext[citetitle]{\printfield[shortmaintitlelink]{shortmaintitle}}}%
  \setunit*{\newunitpunct}}

% ancienttext translator macro
\newbibmacro*{cite:translator:ancienttext}{%
  \iftoggle{sbl@blx@usexref}
    {\ifnameundef{translator}
       {}
       {\usebibmacro{bytranslator}}}
    {\ifnameundef{translator}
       {}
       {\printnames[labelname]{translator}}}}

% ancienttext collection macro
\newbibmacro*{cite:collection:ancienttext}{%
  \savefield*{volume}{\sbl@saved@volume}%
  \savefield*{text}{\sbl@saved@text}%
  \savefield*{pages}{\sbl@saved@pages}%
  \savefield*{postnote}{\sbl@saved@postnote}%
  \iftoggle{sbl@blx@usexref}
    {\iffieldundef{xrefstring}
       {}
       {\newunit
        \printfield{xrefstring}%
        \setunit{\addspace}}%
     \entrydata*{\thefield{xref}}{%
       \begingroup
       \renewbibmacro*{cite:postnote}{}%
       \usebibmacro{cite}%
       \endgroup
       \iffieldundef{volcitevolume}
         {\restorefield{volume}{\sbl@saved@volume}%
          \restorefield{text}{\sbl@saved@text}}
         {}%
       \restorefield{pages}{\sbl@saved@pages}%
       \restorefield{postnote}{\sbl@saved@postnote}%
       \ifboolexpr{
         (
           not test {\iffieldundef{shorthand}}
           or
           test {\ifentrytype{series}}
         )
         and
         (
           not test {\iffieldundef{volume}}
           or
           not test {\iffieldundef{volcitevolume}}
           or
           test {\ifpaginationequalstr{section}}
         )
       }
         {\setunit{\addspace}}
         {\newunit}%
       \usebibmacro{volume+text+pages}%
       \blx@citetracker}}
    {}}
