<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">% Copyright (c) 2006-2011 Philipp Lehman.
%               2012-2017 Philip Kime, Audrey Boruvka, Joseph Wright
%               2018- Philip Kime, Moritz Wemheuer
%
% Permission is granted to copy, distribute and/or modify this
% software under the terms of the LaTeX Project Public License
% (LPPL), version 1.3c.
%
% This software is provided 'as is', without warranty of any kind,
% either expressed or implied, including, but not limited to, the
% implied warranties of merchantability and fitness for a
% particular purpose.

% Set up the version strings here
\def\abx@date{2024/03/21}
\def\abx@version{3.20}
\def\abx@bbxid{\abx@date\space v\abx@version\space biblatex bibliography style (PK/MW)}
\def\abx@cbxid{\abx@date\space v\abx@version\space biblatex citation style (PK/MW)}
\def\abx@lbxid{\abx@date\space v\abx@version\space biblatex localization (PK/MW)}
\def\abx@cptid{\abx@date\space v\abx@version\space biblatex compatibility (PK/MW)}
\def\abx@dmid{\abx@date\space v\abx@version\space biblatex datamodel (PK/MW)}

% This is not updated by build script as the control file version
% does not necessarily change with the package version.
% This is used when writing the .bcf
\def\blx@bcfversion{3.11}

% This is not updated by build script as the bbl version
% does not necessarily change with the package version.
% This is used when checking the .bbl
\def\blx@bblversion{3.3}

\NeedsTeXFormat{LaTeX2e}[2005/12/01]
\ProvidesPackage{biblatex}
[\abx@date\space v\abx@version\space programmable bibliographies (PK/MW)]

%% Dependencies
\RequirePackage{pdftexcmds}[2018/01/30]
\RequirePackage{etoolbox}
\RequirePackage{keyval}
\RequirePackage{kvoptions}
\RequirePackage{logreq}
\RequirePackage{ifthen}
\RequirePackage{url}
%\RequirePackage{trace}

\@ifpackagelater{etoolbox}{2010/11/29}
  {}
  {\PackageError{biblatex}
     {Outdated 'etoolbox' package}
     {Upgrade to etoolbox v2.1 (2010/11/29) or later.\MessageBreak
      I found: '\csuse{ver@etoolbox.sty}'.\MessageBreak
      This is a fatal error. I'm aborting now}%
   \endinput}

% The new hook management system in LaTeX 2020-10-01 and above
% no longer guarantees that \AtBeginDocument/AfterPreamble
% are executed in order of use.
% Instead each use of those commands gets a 'label'
% and code for the same label is chunked together.
% We give our \AfterPreamble invocations a new label and set up a rule to
% have it executed after all normal biblatex \AtBeginDocument stuff.
% Note that begindocument is a one-time hook, so we are guaranteed
% immediate execution when inside \begin{document}...\end{document}.
\providecommand\IfFormatAtLeastTF{\@ifl@t@r\fmtversion}
\IfFormatAtLeastTF{2020/10/01}
  {\def\blx@AfterPreamble{\AddToHook{begindocument}[biblatex/afterpreamble]}%
   \DeclareHookRule{begindocument}{biblatex/afterpreamble}{after}{biblatex}%
   \def\blx@AtEndDocument{\AddToHook{enddocument/afterlastpage}}}
  {\def\blx@AfterPreamble{\AfterPreamble}%
   \def\blx@AtEndDocument{\AtEndDocument}}

% generalised keyval interface
% define a new key (possibly with a default value)
% {&lt;family&gt;}{&lt;key&gt;}[&lt;default&gt;]{&lt;code&gt;}
\providerobustcmd*{\blx@kv@defkey}{\define@key}

% globally define new key (should only be the last resort)
% {&lt;family&gt;}{&lt;key&gt;}[&lt;default&gt;]{&lt;code&gt;}
\providerobustcmd*{\blx@kv@gdefkey}[2]{%
  \@ifnextchar[%
    {\blx@kv@gdefkey@default{#1}{#2}}
    {\blx@kv@gdefkey@nodefault{#1}{#2}}}

\ifundef\blx@kv@gdefkey@nodefault
  {\protected\def\blx@kv@gdefkey@nodefault#1#2{\csgdef{KV@#1@#2}##1}}
  {}
\ifundef\blx@kv@gdefkey@default
  {\protected\def\blx@kv@gdefkey@default#1#2[#3]{%
     \csgdef{KV@#1@#2@default}{\csuse{KV@#1@#2}{#3}}%
     \csgdef{KV@#1@#2}##1}}
  {}

% test if key is undefined
% {&lt;family&gt;}{&lt;key&gt;}{&lt;true&gt;}{&lt;false&gt;}
\providecommand*{\blx@kv@ifkeyundef}[2]{%
  \ifcsundef{KV@#1@#2}}

% undefine key
% {&lt;family&gt;}{&lt;key&gt;}
\providerobustcmd*{\blx@kv@undef}[2]{\csundef{KV@#1@#2}}

% {&lt;family&gt;}{&lt;key-vals&gt;}
\providerobustcmd*{\blx@kv@setkeys}{\setkeys}

%% Category codes

\def\blx@docatcodes{%
  \do\=\do\&lt;\do\&gt;\do\-\do\"\do\'\do\`\do\.%
  \do\,\do\;\do\:\do\!\do\?\do\/}
\def\do#1{\catcode\number`#1=\the\catcode`#1\relax}
\edef\blx@catcodes{\blx@docatcodes\do\^\do\~\do\&amp;\do\|}
\let\do\noexpand

\def\blx@saneccodes{%
  \catcode`\~=\active
  \let\do\@makeother
  \blx@docatcodes
  \let\do\noexpand}

\blx@saneccodes
\catcode`\&amp;=3
\catcode`\|=3
\catcode`\^=7
\def\blx@nl{^^J}

\protected\def\blx@safe@actives{%
  \let\blx@if@safe@actives\if@safe@actives
  \let\if@safe@actives\iftrue}

\protected\def\blx@rest@actives{%
  \let\if@safe@actives\blx@if@safe@actives}

%% Early errors and warnings
\protected\def\blx@error#1#2{%
  \begingroup
  \blx@safe@actives
  \PackageError{biblatex}{#1}{#2.}%
  \endgroup}

\protected\def\blx@warning@noline#1{%
  \begingroup
  \blx@safe@actives
  \PackageWarningNoLine{biblatex}{#1}%
  \endgroup}
\let\blx@warning\blx@warning@noline
\AtEndOfPackage{%
  \protected\def\blx@warning#1{%
    \begingroup
    \blx@safe@actives
    \PackageWarning{biblatex}{#1}%
    \endgroup}}

\def\blx@err@patch#1{%
  \blx@error
    {Patching #1 failed}
    {This is an internal issue typically caused by a
     conflict\MessageBreak between biblatex and some
     other package. Modifying\MessageBreak the package
     loading order may fix the problem}}

%% Compatibility
% this hook is executed once at the beginning of loading the package
% just a few lines down
% and again later in an \AtEndPreamble hook
\def\blx@packageincompatibility{%
  \def\do##1{%
    \@ifpackageloaded{##1}
      {\ifcsundef{blx@pkgloaded@##1}
         {\global\cslet{blx@pkgloaded@##1}\@empty
          \blx@error
            {Incompatible package '##1'}
            {The '##1' package and biblatex are incompatible}}
         {}}
      {}}%
  \docsvlist{%
    amsrefs,apacite,babelbib,backref,bibtopic,bibunits,chapterbib,
    cite,citeref,drftcite,footbib,inlinebib,jurabib,mcite,mciteplus,
    mlbib,multibbl,multibib,natbib,opcit,overcite,splitbib,ucs}%
  % etextools is special, it gets an option to demote the error to a warning
  % remind people to restore \forlistloop
  \ifcsdef{blx@noerroretextools}
    {\@ifpackageloaded{etextools}
       {\ifcsundef{blx@pkgloaded@etextools}
          {\global\cslet{blx@pkgloaded@etextools}\@empty
           \blx@warning@noline{%
             Incompatible package 'etextools' loaded,\MessageBreak
             no error is thrown because you defined\MessageBreak
             '\string\blx@noerroretextools'.\MessageBreak
             'etextools' redefines '\string\forlistloop', you must\MessageBreak
             restore the definition from 'etoolbox'\MessageBreak
             before you load biblatex}}
          {}}
       {}}
    {\@ifpackageloaded{etextools}
       {\ifcsundef{blx@pkgloaded@etextools}
          {\global\cslet{blx@pkgloaded@etextools}\@empty
           \blx@error
             {Incompatible package 'etextools'}
             {The 'etextools' package and biblatex are
              incompatible.\MessageBreak
              If you must load 'etextools' at all costs, define the command%
              \MessageBreak '\string\blx@noerroretextools'}}
          {}}
       {}}}

% Call this right here, almost immediately after loading to give sensible
% errors for incompatibilities that arise at loading-time.
% The macro is called again a second time in \AtEndPreamble when all packages
% should be loaded.
% This still can't catch all cases, \usepackage{biblatex}\usepackage{natbib}
% still gives a weird error.
\blx@packageincompatibility

% this part is only executed now
\@ifpackageloaded{polyglossia}
  {\global\cslet{blx@pkgloaded@polyglossia}\@empty}
  {}

\@ifpackageloaded{inputenc}
  {\global\cslet{blx@pkgloaded@inputenc}\@empty}
  {}

\@ifpackageloaded{inputenx}
  {\global\cslet{blx@pkgloaded@inputenx}\@empty}
  {}

% this part is deferred to \AtEndPreamble
\def\blx@packageincompatibility@endpreambleonly{%
  % people should not be abusing noerroretextools,
  % so warn if it is not needed
  \ifcsdef{blx@noerroretextools}
    {\@ifpackageloaded{etextools}
       {}
       {\blx@warning@noline{%
          You defined '\string\blx@noerroretextools',\MessageBreak
          but 'etextools' is not loaded.\MessageBreak
          Please do not define '\string\blx@noerroretextools'\MessageBreak
          unless you really need it}}}
    {}%
  \@ifpackageloaded{inputenc}
    {\ifcsundef{blx@pkgloaded@inputenc}
       {\blx@warning@noline{Load 'inputenc' before biblatex}}
       {}}
    {}%
  \@ifpackageloaded{inputenx}
    {\ifcsundef{blx@pkgloaded@inputenx}
       {}
       {\blx@warning@noline{Load 'inputenx' before biblatex}}
       {}}
    {}%
  % polyglossia pretends to be babel, so the nested structure helps
  % to make sure that babel really is babel
  \@ifpackageloaded{polyglossia}
    {\ifcsundef{blx@pkgloaded@polyglossia}
       {\blx@error
         {'polyglossia' loaded after biblatex}
         {'polyglossia' must be loaded before biblatex}}
       {}%
     \@ifpackagelater{polyglossia}{2020/04/08}
       {}
       {\blx@warning@noline
          {biblatex works best with 'polyglossia' 1.49\MessageBreak
           or above.\MessageBreak
           Please update 'polyglossia' to v1.49 (2020/04/08)\MessageBreak
           or later.\MessageBreak
           Variant detection will not work properly with\MessageBreak
           older versions}}}
    {\@ifpackageloaded{babel}
       {\@ifpackagelater{babel}{2016/04/23}
          {}
          {\blx@error
             {Outdated 'babel' package}
             {Upgrade to babel 3.9r (2016/04/23) or later.\MessageBreak
              I found: '\csuse{ver@babel.sty}'.\MessageBreak
              This is a fatal error. I'm aborting now}%
            \endinput}}
       {}}}

\begingroup
\catcode`\#=12
\gdef\blx@patchbidifootnotes{%
  \patchcmd\@footnotetext
    {#1}
    {\toggletrue{blx@footnote}#1}
    {\togglefalse{blx@tempa}}
    {}%
  \patchcmd\@LTRfootnotetext
    {#1}
    {\toggletrue{blx@footnote}#1}
    {\togglefalse{blx@tempa}}
    {}%
  \patchcmd\@RTLfootnotetext
    {#1}
    {\toggletrue{blx@footnote}#1}
    {\togglefalse{blx@tempa}}
    {}}
\endgroup

\AtEndPreamble{%
  \blx@packageincompatibility
  \blx@packageincompatibility@endpreambleonly
  \ifnum\blx@hyperref=\thr@@
  \else
    \ifnum\blx@hyperref=\z@
      \blx@mknohyperref
    \else
      \@ifpackageloaded{hyperref}
        {\blx@mkhyperref}
        {\ifnum\blx@hyperref=\@ne
           \blx@warning@noline{%
             Missing 'hyperref' package.\MessageBreak
             Setting 'hyperref=false'}%
         \fi
         \blx@mknohyperref}%
    \fi
    \undef\blx@mkhyperref
    \undef\blx@mknohyperref
  \fi
  \providecommand*{\nolinkurl}{\url}%
  \ifundef\TE@hook
    {\let\TE@hook\@empty
     \toggletrue{blx@tempa}%
     \def\do#1{%
       \patchcmd#1%
         {\let\isundefined\TE@undef}
         {\let\isundefined\TE@undef\TE@hook}
         {\togglefalse{blx@tempa}\listbreak}
         {}}%
     \docsvlist{%
       \ifthenelse,%          ifthen
       \org@ifthenelse,%      babel
       \HyOrg@ifthenelse,%    hyperref
       \NROrg@ifthenelse}%    nameref
     \iftoggle{blx@tempa}
       {\blx@err@patch{'ifthen' package}}
       {}}
    {}%
  \appto\TE@hook{\blx@TE@hook}%
  % we need to patch \addtocontents
  \toggletrue{blx@tempa}%
  % kernel definition
  \patchcmd\addtocontents
    {\let}
    {\blx@contentssafe@citecommands
     \let}
    {}
    {\blx@err@patch{\string\addtocontents}}%
  % patch footnote
  \toggletrue{blx@tempa}%
  \def\do#1{%
    \patchcmd#1%
      {\color@begingroup}
      {\color@begingroup\toggletrue{blx@footnote}}
      {\togglefalse{blx@tempa}\listbreak}
      {}}%
  \docsvlist{%
    \@footnotetext,%          latex
    \H@@footnotetext,%        hyperref
    \V@@footnotetext,%        fancyvrb
    \scr@saved@footnotetext,% koma-script 3.x
    \l@dold@footnotetext,%    ledmac
    \l@doldold@footnotetext,% ledmac
    \predefinedfootnotetext,% linguex
    \@fntORI}%                frenchle
  \iftoggle{blx@tempa}%       ams classes ...
    {\def\do#1{%
       \patchcmd#1
         {\@makefntext}
         {\toggletrue{blx@footnote}\@makefntext}
         {\togglefalse{blx@tempa}}
         {}}%
     \docsvlist{\@footnotetext,%    ams classes standard
                \H@@footnotetext}}% hyperref
    {}%
  \@ifpackageloaded{bidi}%    bidi
    {\blx@patchbidifootnotes}
    {}%
  \@ifclassloaded{memoir}
    {\def\do#1{%
       \patchcmd#1%
         {\color@begingroup}
         {\color@begingroup\toggletrue{blx@footnote}}
         {}
         {}}%
     \docsvlist{%
       \m@mold@footnotetext,%
       \@plainfootnotetext,%
       \@twocolfootnotetext,%
       \@threecolfootnotetext,%
       \@parafootnotetext}%
     \def\do#1{%
       \patchcmd#1%
         {\color@begingroup\@makefntext}
         {\color@begingroup\toggletrue{blx@footnote}\@makefntext}
         {}
         {}}%
     \docsvlist{%
       \@footnotetext,% patch twice
       \H@@footnotetext,% patch twice
       \@plainfootnotetext}}
    {}%
  \@ifclassloaded{beamer}
    {\expandafter\patchcmd\csname beamerx@\string\beamer@framefootnotetext\endcsname
       {\color@begingroup}
       {\color@begingroup\toggletrue{blx@footnote}}
       {\togglefalse{blx@tempa}}
       {}%
     \expandafter\patchcmd\csname beamerx@\string\@mpfootnotetext\endcsname
       {\color@begingroup}
       {\color@begingroup\toggletrue{blx@footnote}}
       {}
       {}}
    {}%
  \iftoggle{blx@tempa}
    {\blx@warning@noline{%
       Patching footnotes failed.\MessageBreak
       Footnote detection will not work}}
    {}%
  \def\do#1{%
    \patchcmd#1%
      {\color@begingroup}
      {\color@begingroup\toggletrue{blx@footnote}}
      {\listbreak}
      {}}%
  \docsvlist{%
    \@mpfootnotetext,%        minipages
    \H@@mpfootnotetext}%      hyperref minipages
  \@ifpackageloaded{endnotes}
    {\patchcmd\theendnotes
       {\enoteformat}
       {\toggletrue{blx@footnote}\enoteformat}
       {}
       {\blx@err@patch{'endnotes' package}}}
    {}%
  \@ifpackageloaded{bigfoot}
    {\apptocmd\@makefnstartbox
       {\toggletrue{blx@footnote}}
       {}
       {\blx@err@patch{'bigfoot' package}}}
    {}%
  \@ifpackageloaded{showkeys}
    {\ifdef\SK@
       {\AtEveryBibitem{\SK@\SK@@label{\thefield{entrykey}}}%
        \AtEveryLositem{\SK@\SK@@label{\thefield{entrykey}}}%
        \ifundef\SK@cite % = 'notcite' disabled
          {\AtEveryCitekey{\SK@\SK@@ref{\thefield{entrykey}}}}
          {}}
       {}}
    {}%
  \iftoggle{blx@trackfloats}
    {}
    {\apptocmd\@floatboxreset
       {\boolfalse{citetracker}%
        \boolfalse{pagetracker}}
       {}
       {\blx@err@patch{floats}}}%
  \iftoggle{blx@backreffloats}
    {}
    {\apptocmd\@floatboxreset
       {\boolfalse{backtracker}}
       {}
       {\blx@err@patch{floats}}}%
  \ifdef\TX@endtabularx % tabularx/memoir
    {\pretocmd\TX@endtabularx
      {\addtocounter{tabx@nest}{1}}% track nested tabularx environments
      {}
      {\blx@err@patch{'tabularx'}}%
      % no need to conditionalise on top-level tabx as the search/replace
      % will only match once anyway
     \patchcmd\TX@endtabularx
      {\edef\TX@ckpt{\cl@@ckpt}}
      {\edef\TX@ckpt{\cl@@ckpt\abx@resttrackers}%
       \abx@savetrackers}
      {}
      {\blx@err@patch{'tabularx'}}%
     \apptocmd\TX@endtabularx
      {\ifnum\value{tabx@nest}=1% only clear trackers for top-level tabularx
         \abx@cleartrackers
       \fi
       \addtocounter{tabx@nest}{-1}}
      {}
      {\blx@err@patch{'tabularx'}}}
    {}%
  \@ifpackageloaded{csquotes}
    {\@ifpackagelater{csquotes}{2009/05/30}
       {}
       {\blx@error
          {Outdated 'csquotes' package}
          {Upgrade to csquotes v4.4 (2009/05/30) or later.\MessageBreak
           I found: '\csuse{ver@csquotes.sty}'}}%
     \BlockquoteDisable{\let\blx@thecheckpunct\@gobble}%
     \@ifpackagelater{csquotes}{2009/08/27}
       {\appto\@blockquote@prehook{\abx@savetrackers}%
        \appto\@blockquote@posthook{\abx@resttrackers\abx@cleartrackers}}
       {}%
     \@ifpackagelater{csquotes}{2010/06/09}
       {}
       {\newcommand*{\@quotereset}{}\newcount\@quotereset}%
     \newcommand*{\blx@initoquote}{\initoquote}%
     \newcommand*{\blx@textooquote}{\textooquote}%
     \newcommand*{\blx@textcoquote}{\textcoquote}%
     \newcommand*{\blx@initiquote}{\initiquote}%
     \newcommand*{\blx@textoiquote}{\textoiquote}%
     \newcommand*{\blx@textciquote}{\textciquote}%
     \newcommand*{\blx@enquote}{\enquote}}
    {\@ifpackageloaded{babel}
       {\blx@warning@noline{%
          'babel/polyglossia' detected but 'csquotes' missing.\MessageBreak
          Loading 'csquotes' recommended}}
       {}%
     \newcommand*{\@quotelevel}{}%
     \newcount\@quotelevel
     \newcommand*{\@quotereset}{}%
     \newcount\@quotereset
     \newcommand*{\@setquotesfcodes}{}%
     \let\@setquotesfcodes\relax
     \newrobustcmd*{\blx@initoquote}{\@quotelevel\@ne}%
     \newrobustcmd*{\blx@initiquote}{\@quotelevel\tw@}%
     \newrobustcmd*{\blx@textooquote}{``}%
     \newrobustcmd*{\blx@textcoquote}{''}%
     \newrobustcmd*{\blx@textoiquote}{`\relax}% block ligs
     \newrobustcmd*{\blx@textciquote}{'\relax}% block ligs
     \newrobustcmd*{\blx@enquote}
       {\@ifstar\blx@enquote@iii\blx@enquote@i}%
     \def\blx@enquote@i{%
       \ifnum\@quotelevel&gt;\z@
         \expandafter\blx@enquote@iii
       \else
         \expandafter\blx@enquote@ii
       \fi}%
     \long\def\blx@enquote@ii#1{%
       \begingroup\blx@initoquote
       \blx@textooquote#1\blx@textcoquote
       \endgroup}%
     \long\def\blx@enquote@iii#1{%
       \begingroup\blx@initiquote
       \blx@textoiquote#1\blx@textciquote
       \endgroup}%
     \appto\blx@setsfcodes{%
       \sfcode`\`=\z@
       \sfcode`\'=\z@}}%
  \let\do\noexpand}

% no longer needed, keep for backwards compatibility
\let\blx@langstrings\relax

\def\blx@ifhyphenationundef#1{\ifcsundef{l@#1}}

% polyglossia makes heavy use of \AtBeginDocument, so we need to use
% it too to get in later than polyglossia's setup.
% This means that load-order is relevant, boo ...
\AtBeginDocument{%
  \@ifpackageloaded{polyglossia}
    {\ifundef\xpg@ifdefined
       {}
       {\def\blx@ifhyphenationundef#1#2#3{\xpg@ifdefined{#1}{#3}{#2}}}%
     % This is required for languages which are never explicitly selected
     % \xpg@bloaded is not defined in polyglossia &lt; v1.45
     \ifundef\xpg@bloaded
       {\ifundef\xpg@loaded
          {\let\xpg@bloaded\@empty}
          {\let\xpg@bloaded\xpg@loaded}}
       {}%
     \global\let\blx@maplang\blx@maplang@polyglossia
     \def\do#1{\blx@langsetup@from@pkglist{#1}}%
     \expandafter\docsvlist\expandafter{\xpg@bloaded}%
     \def\do#1{\blx@langsetup@from@auxlist{#1}}%
     \dolistloop\blx@lbx@auxloadlist
     \ifboolexpr{
      not togl {blx@autolangbib}
      and
      not togl {blx@autolangcite}}
       {\blx@mknoautolang}
       {\blx@mkautolangpoly}%
    }
    {\global\let\blx@maplang\blx@maplang@babel
     \@ifpackageloaded{babel}
       {% This is required for languages which are never explicitly selected
        \def\do#1{\blx@langsetup@from@pkglist{#1}}%
        \expandafter\docsvlist\expandafter{\bbl@loaded}%
        \def\do#1{\blx@langsetup@from@auxlist{#1}}%
        \dolistloop\blx@lbx@auxloadlist
        \ifboolexpr{
          not togl {blx@autolangbib}
          and
          not togl {blx@autolangcite}}
          {\blx@mknoautolang}
          {\blx@mkautolangbabel}}
       {\blx@mknoautolang}}%
  % These already have defaults set to basically do nothing
  % so if the toggles are true, we need to define again since
  % mkautolang* redefines \blx@beglang
  % In turn, \blx@beglang defines \blx@endlang and so \blx@beglangcite and
  % \blx@endlangcite need redefining inside \blx@beglang after \blx@endlang
  % has been defined.
  \iftoggle{blx@autolangbib}
    {\let\blx@beglangbib\blx@beglang}
    {}%
  \iftoggle{blx@autolangcite}
    {\let\blx@beglangcite\blx@beglang}
    {}%
  % babel/polyglossia has loaded the (main document) language already,
  % so we need to explicitly enable our captions (abx@strings@)
  % and extras (abx@extras@) now
  \ifdefstring{\blx@langhook}{captions}
    {\blx@etb@inittoggle{blx@lang@captions@\blx@languagename}%
     \toggletrue{blx@lang@captions@\blx@languagename}}
    {}%
  \csuse{abx@extras@\blx@languagename}%
  \csuse{abx@strings@\blx@languagename}%
  % avoid accidental re-initialization
  \undef\blx@mkautolangbabel
  \undef\blx@mkautolangpoly
  \undef\blx@mknoautolang
  % pick up the main document language as sortlocale if
  % auto-detection is desired
  \ifdefstring\blx@sortlocale{auto}
    {\ifdef\blx@main@language% babel or polyglossia is loaded
       {\edef\blx@sortlocale{\blx@main@language}}
       {\def\blx@sortlocale{english}}}
     {}%
}


\protected\def\blx@providecount#1{%
  \ifcscounter{#1}
    {}
    {\expandafter\newcount\csname #1\endcsname}}

\def\blx@citecmds{}
% \autocite and \autocites are not defined via \DeclareCiteCommand
\listadd\blx@citecmds{autocite}
\listadd\blx@citecmds{autocites}

\newcommand*{\blx@contentssafe@citecommands}{%
  \forlistloop{\blx@mkcitecmd@contentssafe}{\blx@citecmds}}

\def\blx@mkcitecmd@contentssafe#1{%
  \csdef{#1}{%
    \blx@tocontentsinit{\the\c@refsection}%
    \noexpand\csuse{#1}}}

\protected\def\blx@tocontentsinit#1{%
  \boolfalse{citerequest}%
  \boolfalse{citetracker}%
  \boolfalse{pagetracker}%
  \boolfalse{backtracker}%
  \defcounter{refsection}{#1}}

% trick hyperref into believing we're natbib
\let\NAT@parse\@empty
% trick showkeys into believing we're havard
\let\HAR@checkdef\@empty

\providecommand{\@gobblefive}[5]{}
\providecommand{\@gobblethree}[3]{}

% etoolbox helpers

% \ifinlist{&lt;item&gt;}{&lt;list&gt;} is not a good idea
% for printable stuff according to the etoolbox docs
% for \ifinlist (p. 31)
\newrobustcmd{\blx@ifprintableinlist}[2]{%
  \begingroup
    \def\blx@tempa{\endgroup
      \@secondoftwo}%
    \def\do##1{%
      \ifstrequal{##1}{#1}
        {\def\blx@tempa{\endgroup
           \@firstoftwo}%
         \listbreak}
        {}}%
    \dolistloop{#2}%
  \expandafter\blx@tempa}

\newrobustcmd{\blx@ifprintableinlistcs}[2]{%
  \expandafter\blx@ifprintableinlistcs@i\csname #2\endcsname{#1}}
\long\def\blx@ifprintableinlistcs@i#1#2{\blx@ifprintableinlist{#2}{#1}}

\ifundef\pdf@mdfivesum
  {\let\blx@mdfivesum\@firstofone
   \blx@warning@noline{Command '\string\pdf@mdfivesum' undefined.\MessageBreak
     'labelprefix' may not be able to accept all input.\MessageBreak
     The command is available (via 'pdftexcmds')\MessageBreak
     in recent versions of pdfTeX, LuaTeX and XeTeX}}
  {\let\blx@mdfivesum\pdf@mdfivesum}

\newtoggle{blx@bbl@rerun@requested}

\ifundef\pdf@filemdfivesum
  {\blx@warning@noline{Command '\string\pdf@filemdfivesum' undefined.\MessageBreak
     Biber rerun detection may not work as expected.\MessageBreak
     The command is available (via 'pdftexcmds')\MessageBreak
     in recent versions of pdfTeX, LuaTeX and XeTeX}%
   \let\blx@generate@bbl@mdfivesum@found\@gobble
   \let\blx@generate@bbl@mdfivesum@notfound\relax
   \let\abx@aux@read@bblrerun\relax
   \let\abx@aux@read@bbl@mdfivesum\@gobble
   \let\blx@aux@write@bbl@mdfivesum\relax
   \let\blx@check@bbl@rerun@mdfivesum\relax}
  {\let\blx@filemdfivesum\pdf@filemdfivesum

   \def\blx@generate@bbl@mdfivesum@found#1{%
     \xdef\blx@bbl@mdfivesum@new{\blx@filemdfivesum{#1}}}

   % 'nobblfile' can never be equal to any md5 hash
   \def\blx@generate@bbl@mdfivesum@notfound{%
     \gdef\blx@bbl@mdfivesum@new{nobblfile}}

   \def\abx@aux@read@bblrerun{\global\toggletrue{blx@bbl@rerun@requested}}

   \def\abx@aux@read@bbl@mdfivesum{%
     \gdef\blx@bbl@mdfivesum@old}

   % If we need Biber to rerun, save the hash of the current .bbl.
   % That way we can detect if the Biber rerun really happened when
   % we run LaTeX the next time.
   \def\blx@aux@write@bbl@mdfivesum{%
     \blx@auxwrite\@mainaux{}{%
       \string\abx@aux@read@bbl@mdfivesum{%
         \ifundef\blx@bbl@mdfivesum@old
           {nohash}
           {\blx@bbl@mdfivesum@new}}}%
     \iftoggle{blx@runbiber}
       {\blx@auxwrite\@mainaux{}{\string\abx@aux@read@bblrerun}}
       {}}

   % There was a Biber rerun request last time (\blx@bbl@mdfivesum@old),
   % yet the bbl files are the same (as far as md5 hashes are concerned),
   % that means *no* Biber rerun happened.
   % So we need to re-request a rerun.
   \def\blx@check@bbl@rerun@mdfivesum{%
     \iftoggle{blx@bbl@rerun@requested}
       {\ifdefstrequal\blx@bbl@mdfivesum@old\blx@bbl@mdfivesum@new}
       {\@secondoftwo}
     {\blx@logreq@active{}}
     {}}}


% xstring replacements

% reverse a given string
% idea by egreg (https://tex.stackexchange.com/users/4427/egreg)
% from https://tex.stackexchange.com/q/36034/
% relicensed under LPPL according to
% https://tex.meta.stackexchange.com/a/3333/
\def\blx@revstr#1{%
  \ifblank{#1}
    {}
    {\blx@revstr@l #1\blx@revstr@b@i\blx@revstr@b@ii}}

\def\blx@revstr@l#1#2\blx@revstr@b@i#3\blx@revstr@b@ii{%
  \ifblank{#2}
    {#1#3}
    {\blx@revstr@l#2\blx@revstr@b@i#1#3\blx@revstr@b@ii}}

% these tests are inspired by Stephan v. Bechtolsheim's TUGboat article
% https://www.tug.org/TUGboat/tb09-1/tb20bechtolsheim.pdf
% but we need to test for start and end and not for generic substring
% start is easy, delimited arguments help there
\protected\def\blx@ifstrstartswith#1#2{%
  \def\blx@ifstrstartswith@i ##1#2##2&amp;{%
    \ifblank{##1}}%
  \blx@ifstrstartswith@i #1#2&amp;}

% end is harder, so we reverse everything and apply the start test
\protected\def\blx@ifstrendswith#1#2{%
  \begingroup
  \edef\blx@tempa{\endgroup
    \noexpand\blx@ifstrstartswith{\blx@revstr{#1}}{\blx@revstr{#2}}}%
  \blx@tempa}

% not expandable, so write the result to the macro given in #3
% {&lt;string&gt;}{&lt;strip&gt;}{&lt;result&gt;}
% &lt;result&gt; will contain the bit of &lt;string&gt;
% after the first occurrence of &lt;strip&gt;
\protected\def\blx@stripfromstartinto#1#2#3{%
  \def\blx@stripfromstart@i ##1#2##2&amp;{%
    \def#3{##2}}%
  \blx@stripfromstart@i #1&amp;}

% {&lt;string&gt;}{&lt;strip&gt;}{&lt;result&gt;}
% &lt;result&gt; will contain the bit of &lt;string&gt;
% before the last occurence of &lt;strip&gt;
\protected\def\blx@stripfromendinto#1#2#3{%
  \begingroup
  \edef\blx@tempa{\endgroup
    \noexpand\blx@stripfromstartinto{\blx@revstr{#1}}{\blx@revstr{#2}}}%
  \blx@tempa{#3}%
  \edef#3{\noexpand\blx@revstr{#3}}%
  \edef#3{#3}}

%% Allocation

% Counter to track nested tabularx environemnts so we don't
% try to patch the commands more than once below as this undefs some
% macros and an error is thrown
\newcounter{tabx@nest}
\setcounter{tabx@nest}{0}

\newcounter{listtotal}
\def\thelisttotal{\the\c@listtotal}
\newcounter{listcount}
\def\thelistcount{\the\c@listcount}
\newcounter{liststart}
\def\theliststart{\the\c@liststart}
\newcounter{liststop}
\def\theliststop{\the\c@liststop}
\newcounter{citecount}
\def\thecitecount{\the\c@citecount}
\newcounter{citetotal}
\def\thecitetotal{\the\c@citetotal}
\newcounter{multicitecount}
\def\themulticitecount{\the\c@multicitecount}
\newcounter{multicitetotal}
\def\themulticitetotal{\the\c@multicitetotal}
\newcounter{instcount}
\def\theinstcount{\the\c@instcount}
\newcounter{maxnames}
\def\themaxnames{\the\c@maxnames}
\newcounter{minnames}
\def\theminnames{\the\c@minnames}
\newcounter{maxitems}
\def\themaxitems{\the\c@maxitems}
\newcounter{minitems}
\def\theminitems{\the\c@minitems}
\newcounter{citecounter}
\def\thecitecount{\the\c@citecounter}
\newcounter{maxcitecounter}
\def\themaxcitecounter{\the\c@maxcitecounter}
\newcounter{savedcitecounter}
\def\thecitecount{\the\c@savedcitecounter}
\newcounter{uniquelist}
\def\theuniquelist{\the\c@uniquelist}
\newcounter{uniquename}
\def\theuniquename{\the\c@uniquename}
\newcounter{refsection}
\def\therefsection{\the\c@refsection}
\newcounter{refsegment}
\def\therefsegment{\the\c@refsegment}
\newcounter{maxextratitle}
\def\themaxextratitle{\the\c@maxextratitle}
\newcounter{maxextratitleyear}
\def\themaxextratitleyear{\the\c@maxextratitleyear}
\newcounter{maxextraname}
\def\themaxextraname{\the\c@maxextraname}
\newcounter{maxextradate}
\def\themaxextradate{\the\c@maxextradate}
\newcounter{maxextraalpha}
\def\themaxextraalpha{\the\c@maxextraalpha}
\newcounter{abbrvpenalty}
\def\theabbrvpenalty{\the\c@abbrvpenalty}
\newcounter{highnamepenalty}
\def\thehighnamepenalty{\the\c@highnamepenalty}
\newcounter{lownamepenalty}
\def\thelownamepenalty{\the\c@lownamepenalty}
\newcounter{maxparens}
\def\themaxparens{\the\c@maxparens}
\newcounter{parenlevel}
\def\theparenlevel{\the\c@parenlevel}

\newcount\blx@tempcnta
\newcount\blx@tempcntb
\newcount\blx@tempcntc
\newcounter{blx@maxsection}
\def\theblx@maxsection{\the\c@blx@maxsection}
\expandafter\newcount\csname blx@maxsegment@0\endcsname
\newcount\blx@notetype
\newcount\blx@parenlevel@text
\newcount\blx@parenlevel@foot
\expandafter\newcount\csname blx@sectionciteorder@0\endcsname
\expandafter\newcount\csname blx@sectionciteorderinternal@0\endcsname
\newcount\blx@entrysetcounter
\newcount\blx@biblioinstance

\def\blx@uniquename{false}
\def\blx@uniquelist{false}
\def\blx@maxbibnames{0}
\def\blx@minbibnames{0}
\def\blx@maxcitenames{0}
\def\blx@mincitenames{0}
\def\blx@maxsortnames{0}
\def\blx@minsortnames{0}
\def\blx@maxalphanames{0}
\def\blx@minalphanames{0}
\def\blx@maxitems{0}
\def\blx@minitems{0}

\newlength{\labelnumberwidth}
\newlength{\labelalphawidth}
\newlength{\biblabelsep}
\ifdef\bibitemsep % memoir
  {}
  {\newlength{\bibitemsep}}
\newlength{\bibnamesep}
\newlength{\bibinitsep}
\newlength{\bibparsep}
\newlength{\bibhang}

\newbool{sourcemap}
\newbool{citetracker}
\newbool{pagetracker}
\newbool{backtracker}
\newbool{citerequest}
\booltrue{citerequest}
\newbool{sortcites}

\newtoggle{blx@bbldone}
\newtoggle{blx@tempa}
\newtoggle{blx@tempb}
\newtoggle{blx@runltx}
\newtoggle{blx@runbiber}
\newtoggle{blx@block}
\newtoggle{blx@unit}
\newtoggle{blx@skipentry}
\newtoggle{blx@insert}
\newtoggle{blx@lastins}
\newtoggle{blx@keepunit}
\newtoggle{blx@bibtex}
\newtoggle{blx@debug}
\newtoggle{blx@sortcase}
\newtoggle{blx@sortupper}
\newtoggle{blx@autolangbib}
\newtoggle{blx@autolangcite}
\newtoggle{blx@clearlang}
\newtoggle{blx@defernumbers}
\newtoggle{blx@omitnumbers}
\newtoggle{blx@footnote}
\newtoggle{blx@labelalpha}
\newtoggle{blx@labelnumber}
\newtoggle{blx@labeltitle}
\newtoggle{blx@labeltitleyear}
\newtoggle{blx@labeldateparts}
\newtoggle{blx@pluralothers}
\newtoggle{blx@natbib}
\newtoggle{blx@mcite}
\newtoggle{blx@loadfiles}
\newtoggle{blx@sortsets}
\newtoggle{blx@crossrefsource}
\newtoggle{blx@xrefsource}
\newtoggle{blx@terseinits}
\newtoggle{blx@useprefix}
\newtoggle{blx@addset}
\newtoggle{blx@setonly}
\newtoggle{blx@dataonly}
\newtoggle{blx@skipbib}
\newtoggle{blx@skipbiblist}
\newtoggle{blx@skiplab}
\newtoggle{blx@citation}
\newtoggle{blx@volcite}
\newtoggle{blx@bibliography}
\newtoggle{blx@citeindex}
\newtoggle{blx@bibindex}
\newtoggle{blx@localnumber}
\newtoggle{blx@refcontext}
\newtoggle{blx@noroman}
\newtoggle{blx@nohashothers}
\newtoggle{blx@nosortothers}
\newtoggle{blx@singletitle}
\newtoggle{blx@uniquebaretitle}
\newtoggle{blx@uniqueprimaryauthor}
\newtoggle{blx@uniquetitle}
\newtoggle{blx@uniquework}

\newcommand*{\blx@xifstrequal}[2]{%
  \begingroup
  \edef\blx@tempa{%
    \endgroup
    \noexpand\ifstrequal{#1}{#2}}%
  \blx@tempa}

% Special fields which need resolution using the information provided by biber
\listadd\abx@rfields{labeltitle}
\def\abx@dorfields{%
  \dolistloop\abx@rfields%
}
\listadd\abx@rnames{labelname}
\def\abx@dornames{%
  \dolistloop\abx@rnames%
}

% Used to track default refcontexts for citations
\cslet{blx@defaultrefcontexts@0}\@empty
\listadd\blx@allrefsections{0}
\listadd\blx@alllastrefsections{0}

% Used to track defernumbers from .aux
\global\let\blx@localnumbers\@empty

% Used to track sorting name key specifications
\global\let\blx@sortingnamekeytemplates\@empty

% Used to track uniquename templates
\global\let\blx@untemplatespecs\@empty

% Used to track namehash templates
\global\let\blx@nhtemplatespecs\@empty

% Used to track labelalphaname templates
\global\let\blx@lantemplatespecs\@empty

% Used to track transliterations
\global\let\blx@translits\@empty

% Initialise some lists which track changing citations/sortingtemplates
% etc. between runs
\global\let\blx@nocites\@empty
\global\let\blx@directcites\@empty
\global\let\blx@refcontexts\@empty
\global\let\blx@lastrefcontexts\@empty
\global\let\blx@sortingtemplatenames\@empty
\global\let\blx@dlistnames\@empty
\global\let\blx@biblists\@empty
\global\let\blx@lastbiblists\@empty
\global\let\blx@localnumaux\@empty
\global\cslet{blx@cites@0}\@empty

\newread\blx@bcfin
\newwrite\blx@bcfout

\def\blx@onlypreamble#1{%
  \gappto\blx@dopreamblecmds{\do#1}}

\def\blx@dopreamblecmds{%
  \do\blx@dopreamblecmds
  \do\blx@onlypreamble}

% Deprecations
\newrobustcmd*{\DeprecateField}[2]{%
  \csdef{abx@field@#1}{%
    \ifcsundef{abx@legacywarning@field@#1}
      {\blx@warning@noline{Field '#1' is deprecated. #2}}
      {}%
    \global\cslet{abx@legacywarning@field@#1}\@empty}}%
\newrobustcmd*{\DeprecateList}[2]{%
  \csdef{abx@list@#1}{%
    \ifcsundef{abx@legacywarning@list@#1}
      {\blx@warning@noline{List '#1' is deprecated. #2}}
      {}%
    \global\cslet{abx@legacywarning@list@#1}\@empty}}
\newrobustcmd*{\DeprecateName}[2]{%
  \csdef{abx@name@#1}{%
    \ifcsundef{abx@legacywarning@name@#1}
      {\blx@warning@noline{Name '#1' is deprecated. #2}}
      {}%
    \global\cslet{abx@legacywarning@name@#1}\@empty}}

\let\blx@aliasfields\@empty

\newrobustcmd*{\DeprecateFieldWithReplacement}[2]{%
  \appto\blx@aliasfields{%
    \ifcsundef{abx@field@#2}
      {}
      {\csdef{abx@field@#1}{%
         \csuse{abx@field@#2}%
         \ifcsundef{abx@legacywarning@field@#1}
           {\blx@warning@noline{Field '#1' is deprecated.\MessageBreak
              Please use '#2' instead.\MessageBreak
              Using '#2' now}}
           {}%
         \global\cslet{abx@legacywarning@field@#1}\@empty}}}}

\newrobustcmd*{\DeprecateListWithReplacement}[2]{%
  \appto\blx@aliasfields{%
    \ifcsundef{abx@list@#2}
      {}
      {\csdef{abx@list@#1}{%
         \csuse{abx@list@#2}%
         \ifcsundef{abx@legacywarning@list@#1}
           {\blx@warning@noline{List '#1' is deprecated.\MessageBreak
              Please use '#2' instead.\MessageBreak
              Using '#2' now}}
           {}%
         \global\cslet{abx@legacywarning@list@#1}\@empty}}}}

\newrobustcmd*{\DeprecateNameWithReplacement}[2]{%
  \appto\blx@aliasfields{%
    \ifcsundef{abx@name@#2}
      {}
      {\csdef{abx@name@#1}{%
         \csuse{abx@name@#2}%
         \ifcsundef{abx@legacywarning@name@#1}
           {\blx@warning@noline{Name '#1' is deprecated.\MessageBreak
              Please use '#2' instead.\MessageBreak
              Using '#2' now}}
           {}%
         \global\cslet{abx@legacywarning@name@#1}\@empty}}}}

%% Initialisation
\def\blx@blxinit{%
  \let\blx@blxinit\relax
  \blx@initunit}

\def\blx@secinit{%
  \csgdef{blx@sections@\the\c@refsection}{true}% just to say we have a section for tests later
  \ifcsundef{blx@bsee@\the\c@refsection}
    {\global\cslet{blx@bsee@\the\c@refsection}\@empty}
    {}%
  \ifcsundef{blx@fsee@\the\c@refsection}
    {\global\cslet{blx@fsee@\the\c@refsection}\@empty}
    {}%
  \blx@ibidreset@force
  \blx@idemreset@force
  \blx@opcitreset@force
  \blx@loccitreset@force
  % List to track all aliases in a section. We need to output all aliases
  % to the .bcf every time so that they are visible to biber
  % Reset only if undefined
  \ifcsundef{blx@keyaliases@\the\c@refsection}
    {\global\cslet{blx@keyaliases@\the\c@refsection}\@empty}
    {}%
  \ifcsundef{blx@segm@\the\c@refsection @\the\c@refsegment}
    {\global\cslet{blx@segm@\the\c@refsection @\the\c@refsegment}\@empty}
    {}}

%% Auxiliary commands
\protected\def\blx@regimc#1{%
  \xappto\blx@blxinit{%
    \let\noexpand#1\expandafter\noexpand\csname
    blx@imc@\expandafter\@gobble\string#1\endcsname}}

\protected\def\blx@regimcs#1{\blx@regimcs@i#1&amp;}
\def\blx@regimcs@i#1{%
  \ifx#1&amp;\else
    \blx@regimc#1%
    \expandafter\blx@regimcs@i
  \fi}

% {&lt;field&gt;} =&gt; \do{&lt;item1&gt;}\do{&lt;item2&gt;}...
\def\blx@imc@docsvfield#1{%
  \blx@imc@iffieldundef{#1}
    {}
    {\expandafter\expandafter\expandafter\docsvlist
     \expandafter\expandafter\expandafter{%
       \csname abx@field@#1\endcsname}}}

% {&lt;handler&gt;}{&lt;field&gt;} =&gt; &lt;handler&gt;{&lt;item1&gt;}&lt;handler&gt;{&lt;item2&gt;}...
\def\blx@imc@forcsvfield#1#2{%
  \blx@imc@iffieldundef{#2}
    {}
    {\expandafter\expandafter\expandafter\blx@imc@forcsvfield@i
     \expandafter\expandafter\expandafter{%
       \csname abx@field@#2\endcsname}{#1}}}

\def\blx@imc@forcsvfield@i#1#2{\forcsvlist{#2}{#1}}

\blx@regimcs{\docsvfield \forcsvfield}

% {&lt;list&gt;|&lt;listmacro&gt;}
\protected\long\def\blx@listloop#1{%
  \expandafter\blx@listloop@i#1|&amp;}
\long\def\blx@listloop@i#1|{%
  \ifblank{#1}
    {\blx@break}
    {\blx@do{#1}\blx@listloop@i}}

\long\def\blx@break#1&amp;{%
  \blx@done
  \undef\blx@do
  \undef\blx@done}

% {&lt;listmacro&gt;}{&lt;listcsname&gt;} =&gt; elements of &lt;listmacro&gt; that are in &lt;listcsname&gt;
\protected\def\blx@filter#1#2{%
  \def\do##1{%
    \ifinlistcs{##1}{#2}
      {\listadd#1{##1}}
      {}}%
  \blx@runfilter#1}

% {&lt;listmacro&gt;}{&lt;listcsname&gt;} =&gt; matches in &lt;listmacro&gt;
% Slightly odd use of filtering to do citation sorting.
% Same as blx@filter but it keeps \tempcnta in step with the
% resulting number of things in the filtered list. This is
% because \tempcnta is used to set citetotal - this use
% of filtering for cite sorting has the side-effect of stripping
% duplicates like \cite{foo,foo} but we need then to keep citetotal
% in sync.
\protected\def\blx@filtercitesort#1#2{%
 \blx@tempcnta\z@
 \def\do##1{%
   \ifinlistcs{##1}{#2}
     {\listadd#1{##1}%
      \advance\blx@tempcnta\@ne}
     {}}%
 \blx@runfilter#1}

% {&lt;listmacro&gt;}{&lt;listcsname&gt;} =&gt; elements of &lt;listmacro&gt; that are not in &lt;listcsname&gt;
\protected\def\blx@notfilter#1#2{%
  \def\do##1{%
    \ifinlistcs{##1}{#2}
      {}
      {\listadd#1{##1}}}%
  \blx@runfilter#1}

\def\blx@runfilter#1{%
  \begingroup\edef#1{\endgroup
    \unexpanded{\let#1\@empty\dolistloop}{#1}}%
  #1\let\do\noexpand}

% {&lt;code&gt;}{&lt;string&gt;} =&gt; &lt;code&gt;{&lt;string&gt;}
\protected\def\blx@xsanitizeafter#1#2{%
  \begingroup
  \abx@hook@xsanitize
  \def\blx@tempa{\endgroup#1}%
  \edef\blx@tempb{#2}%
  \expandafter\blx@tempa
  \expandafter{\detokenize\expandafter{\blx@tempb}}}

\def\abx@hook@xsanitize{%
  \blx@safe@actives
  \let\protect\string}

% {&lt;code&gt;}{&lt;string&gt;} =&gt; &lt;code&gt;{&lt;string&gt;}
\begingroup
\catcode`\&lt;=\active
\catcode`\&gt;=\active
\catcode`\&amp;=\active
\catcode`\"=\active
\catcode`\'=\active
\protected\gdef\blx@xmlsanitizeafter#1#2{%
  \begingroup
  \abx@hook@xsanitize
  \def\blx@tempa{\endgroup#1}%
  \edef\blx@tempb{#2}%
  \let\do\@makeother
  \dospecials
  \catcode`\&lt;=\active
  \catcode`\&gt;=\active
  \catcode`\&amp;=\active
  \catcode`\"=\active
  \catcode`\'=\active
  \edef&lt;{\string&amp;lt\string;}%
  \edef&gt;{\string&amp;gt\string;}%
  \edef&amp;{\string&amp;amp\string;}%
  \edef"{\string&amp;quot\string;}%
  \edef'{\string&amp;apos\string;}%
  \endlinechar\m@ne
  \everyeof{\noexpand}%
  \edef\blx@tempb{\scantokens\expandafter{\blx@tempb}}%
  \expandafter\blx@tempa
  \expandafter{\detokenize\expandafter{\blx@tempb}}}
\endgroup

% {&lt;file&gt;}{&lt;message&gt;}{&lt;preload&gt;}{&lt;postload&gt;}{&lt;success&gt;}{&lt;failure&gt;}
\protected\long\def\blx@inputonce#1#2#3#4#5#6{%
  \ifcsundef{blx@file@#1}
    {\blx@info@noline{Trying to load #2..}%
     \IfFileExists{#1}
       {\blx@info@noline{... file '#1' found}%
        \csuse{blx@filehook@preload@#1}%
        #3\@@input\@filef@und#4%
        \csuse{blx@filehook@postload@#1}%
        #5%
        \listxadd\blx@list@req@stat{#1}%
        \@addtofilelist{#1}}
       {\blx@info@noline{... file '#1' not found}%
        \csuse{blx@filehook@failure@#1}%
        #6}%
     \global\cslet{blx@file@#1}\@empty}
    {#5}}

% {&lt;write&gt;}{&lt;precode&gt;}{&lt;string&gt;}
\protected\def\blx@auxwrite#1#2#3{%
  \if@filesw
    \begingroup
    \blx@safe@actives
    \let\protect\string
    #2%
    \immediate\write#1{#3}%
    \endgroup
  \fi}

% {&lt;file&gt;}{&lt;signature&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@ifsigned#1#2{%
  \begingroup
  \let\blx@tempa\@firstoftwo
  \edef\blx@tempb{\csuse{blx@sig@#2}}%
  \edef\blx@tempb{\detokenize\expandafter{\blx@tempb}}%
  \openin\blx@bcfin #1.#2\relax
    \ifeof\blx@bcfin
    \else
      \endlinechar\m@ne
      \readline\blx@bcfin to \blx@tempc
      \ifeof\blx@bcfin
      \else
        \ifx\blx@tempb\blx@tempc
          \readline\blx@bcfin to \blx@tempc
          \edef\blx@tempb{\csuse{blx@ver@#2}}%
          \edef\blx@tempb{\detokenize\expandafter{\blx@tempb}}%
          \ifx\blx@tempb\blx@tempc
          \else
            \blx@warning@noline{%
              File '#1.#2' is wrong format version - expected \blx@bblversion}
          \fi
        \else
          \blx@error
            {File '#1.#2' not created by biblatex}
            {This file was apparently not created by biblatex.
             Rename it or\MessageBreak move it to a location were
             TeX will not find it. If this error\MessageBreak
             persists, consider redefining \string\blxauxsuffix.%
             See the biblatex\MessageBreak manual for details}%
          \let\blx@tempa\@secondoftwo
        \fi
      \fi
    \fi
  \closein\blx@bcfin
  \expandafter\endgroup\blx@tempa}

\edef\blx@sig@bbl{\@percentchar\space $ biblatex auxiliary file $}
\edef\blx@ver@bbl{\@percentchar\space $ biblatex bbl format version \blx@bblversion\space $}
\edef\blx@sig@bcf{\detokenize{&lt;?xml version="1.0" encoding="UTF-8"?&gt;}}
\edef\blx@ver@bcf{%
  \detokenize{&lt;bcf:controlfile version="}\blx@bcfversion
  \detokenize{" bltxversion="}\abx@version
  \detokenize{" xmlns:bcf="https://sourceforge.net/projects/biblatex"&gt;}}

% {&lt;true&gt;}{&lt;false&gt;}
\newrobustcmd*{\lbx@ifutfinput}{%
  \ifboolexpr{%
    test {\ifdefstring\inputencodingname{utf8}}
    or
    test {\ifdefstring\inputencodingname{utf8x}}
    or
    test {\ifdefstring\inputencodingname{lutf8}}
    or
    ( test {\ifundef\inputencodingname}
      and
      ( not test {\ifundef\XeTeXrevision}
        or
        not test {\ifundef\luatexversion}
      )
    )
  }%
}

%% More user feedback
\protected\def\blx@warning@entry#1{%
  \ifdef\abx@field@entrykey
    {\blx@warning{#1\MessageBreak at entry '\abx@field@entrykey'}}
    {\blx@warning{#1}}}

\protected\def\blx@info@noline#1{%
  \begingroup
  \blx@safe@actives
  \PackageInfo{biblatex}{#1\@gobble}%
  \endgroup}
\let\blx@info\blx@info@noline
\AtEndOfPackage{%
  \protected\def\blx@info#1{%
    \begingroup
    \blx@safe@actives
    \PackageInfo{biblatex}{#1}%
    \endgroup}}

\let\blx@noline\@gobble
\AtEndOfPackage{\let\blx@noline\@empty}
\def\blx@imc@BibliographyWarning{\blx@warning@entry}
\blx@regimc\BibliographyWarning

\protected\def\abx@missing#1{%
  \mbox{\reset@font\bfseries#1}}


\def\blx@err@nolang#1{%
  \blx@error
    {Language '#1' not found}
    {The localization module for '#1' could not be found}}

\def\blx@err@invarg#1#2{%
  \blx@error
    {Argument '#1' invalid}
    {\ifblank{#2}
       {The argument you have supplied is invalid.\MessageBreak
        See the biblatex manual for details}
       {#2}}}

\def\blx@err@invopt#1#2{%
  \blx@error
    {Option '#1' invalid}
    {\ifblank{#2}
       {The option you have supplied is invalid.\MessageBreak
        See the biblatex manual for valid option keys and
        possible values}
       {#2}}}

\def\blx@err@confopt#1#2{%
  \blx@error
    {Conflicting options\ifblank{#1}{}{ (#1)}}
    {\ifblank{#2}
       {The option you have supplied conflicts with another one.\MessageBreak
        See the biblatex manual for valid option keys and possible values}
       {#2}}}

\def\blx@err@optdef#1#2{%
  \blx@error
    {Option '#1' already defined}
    {The option '#1' is already defined in scope '#2'}}

\def\blx@err@nodocdiv#1{%
  \blx@error
    {\@backslashchar#1 not provided by class}
    {The document class does not seems to support #1s}}

\def\blx@err@nosec#1{%
  \blx@error
    {Section '#1' not found}
    {The reference section '#1' could not be found}}

\def\blx@err@nosort#1{%
  \blx@error
    {Sorting template '#1' not found}
    {The sorting template '#1' does not seem to have been defined anywhere}}

\def\blx@err@secfirst{%
  \blx@error
    {'section' not first filter}
    {When passing multiple filter options,
     the 'section' filter must be given first}}

\protected\def\blx@err@nestcite{%
  \blx@error
    {Nested citation command}
    {Citation commands may not be nested}}

\def\blx@err@nestenv#1{%
  \blx@error
    {Nested '#1' environment}
    {This environment may not be nested}}

\protected\def\blx@err@citecmd#1{%
  \begingroup
  \escapechar\m@ne
  \blx@error
    {Command '\@backslashchar\string#1' undefined}
    {The citation command '\@backslashchar\string#1'
     has not been defined\MessageBreak by the
     selected citation style}%
  \endgroup}

\def\blx@err@endnote#1{%
  \blx@error
    {Missing or incomplete endnote support}
    {There does not seem to be endnote support available\MessageBreak
     or the available support is incomplete.\MessageBreak
     If you continue, I will fall back to '\string#1'}%
  #1}

\def\blx@err@matchparen#1{%
  \blx@error
    {Unbalanced parentheses or brackets}
    {\iftoggle{blx@footnote}{#1 in foot or endnote}{#1}.\MessageBreak
     This error is triggered if \string\bibopenparen\space and
     \string\bibcloseparen\MessageBreak or
     \string\bibopenbracket\space and \string\bibclosebracket\space
     are unbalanced\MessageBreak or mismatched}}

\def\blx@err@nestparen#1{%
  \blx@error
    {Too deeply nested parentheses or brackets}
    {#1 nested too deeply%
     \iftoggle{blx@footnote}{\space in foot or endnote}{}.\MessageBreak
     This error may also be triggered if \string\mkbibparens\MessageBreak
     or \string\mkbibbrackets\space are nested too deeply}}

\def\blx@err@filter{%
  \blx@error
    {Invalid filter expression}
    {The filter expression you have supplied is invalid.\MessageBreak
     See the biblatex manual for details}}

\def\blx@warn@nohyph#1{%
  \blx@warning{No hyphenation patterns for '#1'}}

\protected\def\blx@warn@citecmd#1#2{%
  \blx@warning{%
    '\string#1' not defined by citation style.\MessageBreak
    Falling back to '\string#2'}%
  #2}

\protected\def\blx@warn@nostring#1{%
  \blx@warning@entry{Bibliography string '#1'
                     \blx@kv@ifkeyundef{blx@lbx}{#1}{undefined}{untranslated}}%
  \abx@missing{#1}}

\def\blx@warn@conflopt#1{%
  \blx@warning{Conflicting options.\MessageBreak#1}}

\def\blx@warn@badoptdt#1{%
  \blx@warning{Invalid option datatype '#1'.\MessageBreak
    Defaulting to 'boolean'}}

\def\blx@warn@depropt#1{%
  \blx@warning{Deprecated option.\MessageBreak Ignoring '#1'}}

\def\blx@warn@bibempty{%
  \@latex@warning{Empty bibliography}}

\def\blx@warn@biblistempty#1{%
  \@latex@warning{Empty biblist '#1'}}

\def\blx@inf@refsec{%
  \blx@info{Reference section=\the\c@refsection}}%

\def\blx@inf@delimdeclare#1#2{%
  \blx@info{Delimiter '#1' in context '#2' already defined, overwriting}}

\def\blx@warn@delimuse#1#2{%
  \blx@warning{Delimiter '#1' in context '#2' undefined}}

\def\blx@inf@refseg{%
  \ifnum\c@refsection=\z@
    \blx@info{Reference segment=\the\c@refsegment}%
  \else
    \blx@info{%
      Reference section/segment=%
      \the\c@refsection/\the\c@refsegment}%
  \fi}

\def\blx@inf@creset{%
  \blx@info{Resetting trackers}}%

\def\blx@msg@cundef#1{%
  Citation '#1' undefined}
\def\blx@msg@cundefon#1{%
  Citation '#1' on page \the\c@page\space undefined}

% Dummy as backend is biber by default. Some style may still use this to
% check though.
\newrobustcmd*{\RequireBiber}[1][2]{}

% \blx@list@active                      active aux files (basename)
%                                       [internal list]
% \blx@list@inactive                    inactive aux files (basename)
%                                       [internal list]
% \blx@list@bibfiles@&lt;auxfile&gt;          aux file -&gt; bib file mapping (refsections)
%                                       aux file (basename) -&gt; bib files (full)
%                                       [internal list]

\let\blx@list@active\@empty
\let\blx@list@inactive\@empty
\listeadd\blx@list@inactive{\jobname}

\protected\def\blx@regbibfiles#1#2{%
  \forlistloop{\blx@regbibfile{#1}}{#2}}

\def\blx@regbibfile#1#2{%
  \ifcsundef{blx@res@loca@#2}
    {\blx@regbibfile@i{#1}{#2}}
    {\ifcsstring{blx@res@loca@#2}{local}
       {\blx@regbibfile@i{#1}{#2}}
       {}}}

\def\blx@regbibfile@i#1#2{%
  \ifinlistcs{#2}{blx@list@bibfiles@#1}
    {}
    {\listcsxadd{blx@list@bibfiles@#1}{#2}}}

\def\blx@check@logreq{%
  \begingroup
  \ltxrequest{biblatex}{{\iftoggle{blx@runltx}{1}{0}}}{%
    \provides[type=dynamic]{
      \file{\jobname.bcf}
    }
    \requires[type=dynamic]{
      \file{\jobname.bbl}
    }
    \ifdef\blx@list@req@edit
      {\requires[type=editable]{
         \forlistloop\file\blx@list@req@edit
       }}
      {}
    \ifdef\blx@list@req@stat
      {\requires[type=static]{
         \forlistloop\file\blx@list@req@stat
       }}
      {}
  }%
  \logrequest[package=biblatex,priority=5,active={{\iftoggle{blx@runbiber}{1}{0}}}]{%
    \generic{biber}
    \cmdline{
      \binary{biber}
      \infile{\jobname}
    }
    \input{
      \file{\jobname.bcf}
    }
    \output{
      \file{\jobname.bbl}
    }
    \provides[type=dynamic]{
      \file{\jobname.bbl}
    }
    \requires[type=dynamic]{
      \file{\jobname.bcf}
    }
    \ifcsdef{blx@list@bibfiles@\jobname}
      {\requires[type=editable]{
         \def\do{\file}
         \dolistcsloop{blx@list@bibfiles@\jobname}
       }}
      {}
  }%
  \endgroup}

\def\blx@logreq@active#1{%
  \ifblank{#1}
    {}
    {\@latex@warning{#1}}%
  \blx@rerun@latex
  \blx@rerun@biber}

\def\blx@rerun@latex{%
  \G@refundefinedtrue
  \global\toggletrue{blx@runltx}%
  \global\let\blx@rerun@latex\relax}

\def\blx@rerun@biber{%
  \global\toggletrue{blx@runbiber}%
  \global\let\blx@rerun@biber\relax}


\let\blx@checksum@old\@empty
\let\blx@checksum@new\@empty
\let\blx@pagesum@old\@empty
\let\blx@pagesum@new\@empty

\def\blx@checksum#1#2#3{%
  \begingroup
  \blx@tempcnta\the\numexpr0#2*0#3\relax
  \blx@tempcntb\blx@tempcnta
  \divide\blx@tempcntb10
  \multiply\blx@tempcntb10
  \advance\blx@tempcnta-\blx@tempcntb
  \xdef#1{#1\the\blx@tempcnta}%
  \endgroup}

\def\blx@addchecksum{\blx@checksum\blx@checksum@old}
\def\blx@addpagesum{\blx@checksum\blx@pagesum@old}
\blx@AtEndDocument{%
  \def\blx@addchecksum{\blx@checksum\blx@checksum@new}%
  \def\blx@addpagesum{\blx@checksum\blx@pagesum@new}}

\protected\def\blx@check@rerun{%
  \begingroup
  \blx@tempcnta\z@
  \iftoggle{blx@runltx}
    {\blx@tempcnta\@ne}
    {\ifx\blx@checksum@old\blx@checksum@new
       \ifx\blx@pagesum@old\blx@pagesum@new
       \else
         \blx@tempcnta\@ne
       \fi
     \else
       \blx@tempcnta\@ne
     \fi}%
  \iftoggle{blx@runbiber}
    {\advance\blx@tempcnta\tw@}
    {}%
  \ifcase\blx@tempcnta
  \or
    \blx@rerun@latex
    \blx@warning@noline{%
      Please rerun LaTeX%
      \ifx\blx@pagesum@old\blx@pagesum@new\else
        .\MessageBreak Page breaks have changed%
      \fi}%
  \else
    \blx@rerun@latex
    \blx@warn@auxlist
  \fi
  \endgroup}

\def\blx@warn@auxlist{%
  \blx@warning@noline{%
    Please (re)run Biber on the file:\MessageBreak
    \jobname\MessageBreak
    and rerun LaTeX afterwards}}

\AfterEndDocument{%
  \blx@check@rerun
  \blx@check@logreq}

%% Punctuation and capitalization

% 1001       prefix sep for names (e.g. d'Argent ... \printnames only)
% 1002       abbreviation period (dot)
% 1003/1250  comma
% 1004/1500  semicolon
% 1005/2000  colon
% 1006/3000  period
% 1007/3001  exclamation mark
% 1008/3002  question mark
% 1009       suppress punctuation
% 1010       new paragaph

\mathchardef\blx@sf@prefixchar=1001% e.g. apostrophe or equivalent for prefix handling
\mathchardef\blx@sf@dot=1002
\mathchardef\blx@sf@comma=1003
\mathchardef\blx@sf@semicolon=1004
\mathchardef\blx@sf@colon=1005
\mathchardef\blx@sf@period=1006
\mathchardef\blx@sf@exclam=1007
\mathchardef\blx@sf@question=1008
\mathchardef\blx@sf@nopunct=1009
\mathchardef\blx@sf@par=1010
\mathchardef\blx@sf@threshold@low=1002
\mathchardef\blx@sf@threshold@high=1009

\csdef{blx@sf@1250}{\the\blx@sf@comma}
\csdef{blx@sf@1500}{\the\blx@sf@semicolon}
\csdef{blx@sf@2000}{\the\blx@sf@colon}
\csdef{blx@sf@3000}{\the\blx@sf@period}
\csdef{blx@sf@3001}{\the\blx@sf@exclam}
\csdef{blx@sf@3002}{\the\blx@sf@question}

\csdef{blx@pm@,}{comma}
\csdef{blx@pm@;}{semicolon}
\csdef{blx@pm@:}{colon}
\csdef{blx@pm@.}{period}
\csdef{blx@pm@!}{exclam}
\csdef{blx@pm@?}{question}

\def\blx@setsfcodes{%
  \let\blx@setsfcodes\relax
  \let\frenchspacing\blx@setfrcodes
  \let\nonfrenchspacing\blx@setencodes
  \ifnum\sfcode`\.&gt;2000
    \blx@setencodes
  \else
    \blx@setfrcodes
  \fi
  \@setquotesfcodes
  \sfcode`\(=\z@
  \sfcode`\)=\z@
  \sfcode`\[=\z@
  \sfcode`\]=\z@
  \sfcode`\&lt;=\z@
  \sfcode`\&gt;=\z@}

\def\blx@setfrcodes{%
  \ifnum\sfcode`\A=\@m
  \else
    \blx@setazcodes
  \fi
  \sfcode`\,=\blx@sf@comma
  \sfcode`\;=\blx@sf@semicolon
  \sfcode`\:=\blx@sf@colon
  \sfcode`\.=\blx@sf@period
  \sfcode`\!=\blx@sf@exclam
  \sfcode`\?=\blx@sf@question
}

\def\blx@setencodes{%
  \sfcode`\,=1250
  \sfcode`\;=1500
  \sfcode`\:=2000
  \sfcode`\.=3000
  \sfcode`\!=3001
  \sfcode`\?=3002
}

\def\abx@dosingleaccents{%
  \do\"\do\'\do\`\do\^\do\~\do\=\do\.%
  \do\H\do\b\do\c\do\d\do\r\do\u\do\v}
\def\abx@dodoubleaccents{%
  \do\t}

% Defining characters that count as prefices in names like d'Argent
% Code from moewe
\let\blx@prefchars\@empty

\def\blx@defprefchars@loop#1{%
  \ifx#1\relax
  \else
    \listadd{\blx@prefchars}{#1}%
    \expandafter\blx@defprefchars@loop
  \fi}

\def\blx@defprefchars#1{%
  \expandafter\blx@defprefchars@loop\detokenize{#1}\relax}

\newrobustcmd*{\DeclarePrefChars}{%
  \@ifstar
    {\blx@defprefchars}
    {\global\let\blx@prefchars\@empty
     \blx@defprefchars}}
\DeclarePrefChars{'-}

\protected\def\blx@imc@ifprefchar{%
  \ifhmode
    \begingroup
    \ifnum\spacefactor=\blx@sf@prefixchar
      \endgroup
      \expandafter\expandafter
      \expandafter\@firstoftwo
    \else
      \endgroup
      \expandafter\expandafter
      \expandafter\@secondoftwo
    \fi
  \else
    \expandafter\@secondoftwo
  \fi}

\blx@regimcs{\ifprefchar}

\def\blx@namecodes{%
  \ifnum\sfcode`\A=\@m
  \else
    \blx@setazcodes
  \fi
  \def\do##1{\sfcode`##1=\blx@sf@prefixchar}%
  \dolistloop\blx@prefchars
}

\begingroup
\let\blx@setazcodes\@empty
\def\blx@tempa{%
  \xdef\blx@setazcodes{%
    \blx@setazcodes
    \sfcode\the\blx@tempcnta=\@m}
  \ifnum\blx@tempcnta&lt;\blx@tempcntb
    \advance\blx@tempcnta\@ne
    \expandafter\blx@tempa
  \fi}
\blx@tempcnta`\A
\blx@tempcntb`\Z
\blx@tempa
\ifnum\inputlineno=\m@ne\else
  \blx@tempcnta"80
  \blx@tempcntb"9C
  \blx@tempa
  \blx@tempcnta"C0
  \blx@tempcntb"DF
  \blx@tempa
\fi
\endgroup

\def\blx@spacefactor{%
  \ifhmode
    \ifcsundef{blx@sf@\the\spacefactor}
      {\the\spacefactor}
      {\csname blx@sf@\the\spacefactor\endcsname}%
  \else
    \the\blx@sf@par
  \fi}

\protected\def\blx@leavevmode{%
  \ifhmode
  \else
    \leavevmode\spacefactor\blx@sf@par
  \fi}

\protected\def\blx@leavevmode@cite{%
  \ifhmode
    \ifnum\spacefactor=\blx@sf@par
    \else
      \spacefactor\@m
    \fi
  \else
    \leavevmode
  \fi}

\protected\def\blx@imc@setpunctfont#1{%
  \blx@ifpuncthook
    {\gdef\abx@puncthook{%
       \ifdim\lastkern&gt;\z@\unkern\fi
       \blx@imc@resetpunctfont#1}}
    {}}
\protected\def\blx@imc@resetpunctfont{%
  \blx@ifpuncthook
    {\global\let\abx@puncthook\@firstofone}
    {}}

\protected\def\blx@setpostpunct#1{%
  \blx@ifuspunct
    {\global\let\blx@postpunct\blx@dopostpunct
     \ifdef\blx@thepostpunct
       {\gappto\blx@thepostpunct{#1}}
       {\gdef\blx@thepostpunct{#1}}}
    {}}

\def\blx@dopostpunct{%
  \blx@thepostpunct
  \global\let\blx@postpunct\@empty
  \global\undef\blx@thepostpunct}

\protected\def\blx@postpunct@agroup{%
  \aftergroup\blx@postpunct
  \let\blx@postpunct@agroup\@empty}

% {&lt;characters&gt;}
\newrobustcmd*{\DeclareCapitalPunctuation}[1]{%
  \cslet{blx@cap@\the\blx@sf@par}\@empty
  \csundef{blx@cap@\the\blx@sf@comma}%
  \csundef{blx@cap@\the\blx@sf@semicolon}%
  \csundef{blx@cap@\the\blx@sf@colon}%
  \csundef{blx@cap@\the\blx@sf@period}%
  \csundef{blx@cap@\the\blx@sf@exclam}%
  \csundef{blx@cap@\the\blx@sf@question}%
  \ifblank{#1}
    {}
    {\expandafter\blx@defcapstring\detokenize{#1}\relax}}

\def\blx@defcapstring#1{%
  \ifx#1\relax
  \else
    \begingroup
    \blx@setfrcodes
    \ifcsdef{blx@pm@#1}
      {\expandafter\endgroup
       \expandafter\let
         \csname blx@cap@\the\sfcode`#1\endcsname\@empty}
      {\blx@warning{Ignoring invalid punctuation mark '#1'}%
       \endgroup}%
    \expandafter\blx@defcapstring
  \fi}

% {&lt;characters&gt;}
\newrobustcmd*{\DeclareQuotePunctuation}[1]{%
  \csdef{blx@qp@comma}{\blx@postpunct}%
  \csdef{blx@qp@semicolon}{\blx@postpunct}%
  \csdef{blx@qp@colon}{\blx@postpunct}%
  \csdef{blx@qp@period}{\blx@postpunct}%
  \csdef{blx@qp@exclam}{\blx@postpunct}%
  \csdef{blx@qp@question}{\blx@postpunct}%
  \cslet{blx@pq@comma}\@empty
  \cslet{blx@pq@semicolon}\@empty
  \cslet{blx@pq@colon}\@empty
  \cslet{blx@pq@period}\@empty
  \cslet{blx@pq@exclam}\@empty
  \cslet{blx@pq@question}\@empty
  \let\blx@quotepunct\@empty
  \ifblank{#1}
    {\let\blx@ifuspunct\@secondoftwo}
    {\let\blx@ifuspunct\@firstoftwo
     \expandafter\blx@defquotepunct\detokenize{#1}&amp;}}

\def\blx@defquotepunct#1{%
  \ifx&amp;#1\relax
  \else
    \ifcsdef{blx@pm@#1}
      {\appto\blx@quotepunct{#1}%
       \cslet{blx@qp@\csuse{blx@pm@#1}}\@empty
       \csdef{blx@pq@\csuse{blx@pm@#1}}{\blx@postpunct}}
      {\blx@warning{Ignoring invalid punctuation mark '#1'}}%
    \expandafter\blx@defquotepunct
  \fi}

% {&lt;mark&gt;}{&lt;characters&gt;}
\newrobustcmd*{\DeclarePunctuationPairs}[2]{%
  \ifcsdef{blx@sf@\detokenize{#1}}
    {\ifnum\csname blx@sf@\detokenize{#1}\endcsname&gt;\blx@sf@prefixchar
       \ifnum\csname blx@sf@\detokenize{#1}\endcsname&lt;\blx@sf@nopunct
         \expandafter\blx@defpunctpairs
         \expandafter{\the\csname blx@sf@\detokenize{#1}\endcsname}{#2}%
       \else
         \blx@err@invarg{\detokenize{#1}{}}%
       \fi
     \else
       \blx@err@invarg{\detokenize{#1}{}}%
     \fi}
    {\blx@err@invarg{\detokenize{#1}{}}}}

\def\blx@defpunctpairs#1#2{%
  \blx@undefpair{#1}{\the\blx@sf@dot}%
  \blx@undefpair{#1}{\the\blx@sf@comma}%
  \blx@undefpair{#1}{\the\blx@sf@semicolon}%
  \blx@undefpair{#1}{\the\blx@sf@colon}%
  \blx@undefpair{#1}{\the\blx@sf@period}%
  \blx@undefpair{#1}{\the\blx@sf@exclam}%
  \blx@undefpair{#1}{\the\blx@sf@question}%
  \ifblank{#2}
    {}
    {\begingroup
     \def\blx@tempa{#1}%
     \let\blx@tempb\@empty
     \blx@setfrcodes
     \sfcode`\*=\blx@sf@dot
     \expandafter\blx@defpair\detokenize{#2}&amp;%
     \expandafter\endgroup\blx@tempb}}

\def\blx@defpair#1{%
  \ifx&amp;#1%
  \else
    \ifnum\the\sfcode`#1&gt;\blx@sf@prefixchar
      \ifnum\the\sfcode`#1&lt;\blx@sf@nopunct
        \eappto\blx@tempb{%
          \cslet{blx@pp@\blx@tempa @\the\sfcode`#1}\noexpand\@empty}%
      \else
        \blx@err@invarg{#1}{}%
      \fi
    \else
      \blx@err@invarg{#1}{}%
    \fi
    \expandafter\blx@defpair
  \fi}

\def\blx@undefpair#1#2{%
  \ifcsdef{blx@pp@#1@#2}
    {\csundef{blx@pp@#1@#2}}
    {}}

\protected\def\blx@resetpunct{%
  \DeclareCapitalPunctuation{.!?}%
  \DeclarePunctuationPairs{dot}{}%
  \DeclarePunctuationPairs{comma}{*!?}%
  \DeclarePunctuationPairs{semicolon}{*!?}%
  \DeclarePunctuationPairs{colon}{*!?}%
  \DeclarePunctuationPairs{period}{}%
  \DeclarePunctuationPairs{exclam}{*}%
  \DeclarePunctuationPairs{question}{*}%
  \DeclareQuotePunctuation{}%
  \def\abx@dot{\ifdim\lastkern&gt;\z@\unkern\fi.\spacefactor\blx@sf@dot}%
  \def\abx@comma{\ifdim\lastkern&gt;\z@\unkern\fi\abx@puncthook{,}}%
  \def\abx@semicolon{\abx@puncthook{;}}%
  \def\abx@colon{\abx@puncthook{:}}%
  \def\abx@period{\ifdim\lastkern&gt;\z@\unkern\fi\abx@puncthook{.}}%
  \def\abx@exclam{\abx@puncthook{!}}%
  \def\abx@question{\abx@puncthook{?}}%
  \global\let\abx@puncthook\@firstofone
  \global\let\blx@postpunct\@empty}

\blx@resetpunct

% {&lt;character&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifpunctmark#1{%
  \ifhmode
    \begingroup
    \sfcode`\*=\blx@sf@dot
    \ifnum\sfcode`#1=\spacefactor
      \endgroup
      \expandafter\expandafter
      \expandafter\@firstoftwo
    \else
      \endgroup
      \expandafter\expandafter
      \expandafter\@secondoftwo
    \fi
  \else
    \expandafter\@secondoftwo
  \fi}

% {&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifterm{%
  \ifhmode
    \expandafter\blx@imc@ifcapital
  \else
    \expandafter\@secondoftwo
  \fi}

% {&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifcapital{%
  \ifcsdef{blx@cap@\blx@spacefactor}}

% {&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifpunct{%
  \ifnum\blx@spacefactor&gt;\blx@sf@threshold@low
    \ifnum\blx@spacefactor&lt;\blx@sf@threshold@high
      \expandafter\expandafter
      \expandafter\@firstoftwo
    \else
      \expandafter\expandafter
      \expandafter\@secondoftwo
    \fi
  \else
    \expandafter\@secondoftwo
  \fi}

% {&lt;character&gt;}
\newrobustcmd*{\autocap}[1]{#1}

\protected\def\blx@imc@autocap{%
  \blx@imc@ifcapital\MakeCapital\@firstofone}

\protected\def\blx@imc@nopunct{%
  \leavevmode\spacefactor\blx@sf@nopunct}

\protected\def\blx@imc@isdot{%
  \ifnum\blx@spacefactor=\blx@sf@period
    \spacefactor\blx@sf@dot
  \fi}

\protected\def\blx@imc@adddot{%
  \blx@addpunct{dot}%
  \ifnum\blx@spacefactor=\blx@sf@period
    \spacefactor\blx@sf@dot
  \fi}

\protected\def\blx@imc@addperiod{%
  \blx@addpunct{period}%
  \ifnum\blx@spacefactor=\blx@sf@dot
    \spacefactor\blx@sf@period
  \fi}

\protected\def\blx@imc@addcomma{\blx@addpunct{comma}}
\protected\def\blx@imc@addsemicolon{\blx@addpunct{semicolon}}
\protected\def\blx@imc@addcolon{\blx@addpunct{colon}}
\protected\def\blx@imc@addexclam{\blx@addpunct{exclam}}
\protected\def\blx@imc@addquestion{\blx@addpunct{question}}

\def\blx@addpunct#1{%
  \unspace
  \ifnum\blx@spacefactor&lt;\blx@sf@threshold@low
    \csuse{blx@qp@#1}\csuse{abx@#1}%
  \else
    \ifnum\blx@spacefactor&gt;\blx@sf@threshold@high
      \csuse{blx@qp@#1}\csuse{abx@#1}%
    \else
      \ifcsdef{blx@pp@\the\csname blx@sf@#1\endcsname @\blx@spacefactor}
        {\csuse{blx@qp@#1}\csuse{abx@#1}}
        {\csuse{blx@qp@#1}}%
    \fi
  \fi
  \csuse{blx@pq@#1}}

\providerobustcmd*{\unspace}{%
  \ifbool{hmode}
    {\ifdimgreater\lastskip\z@
       {\unskip\unspace}
       {\ifnumgreater\lastpenalty\z@
          {\unpenalty\unspace}
          {}}}
    {}}

\newrobustcmd*{\bibsentence}{%
  \leavevmode\spacefactor\blx@sf@par
  \ignorespaces}

\newrobustcmd*{\midsentence}{%
  \leavevmode
  \@ifstar
    {\ifnum\spacefactor=\blx@sf@dot
     \else
       \spacefactor\@m
     \fi}
    {\spacefactor\@m}}

\newrobustcmd*{\addslash}{%
  \unspace/\penalty\hyphenpenalty\hskip\z@skip}

\newrobustcmd*{\addspace}{%
  \unspace\blx@postpunct
  \space\blx@imc@resetpunctfont}

\newrobustcmd*{\addnbspace}{%
  \unspace\blx@postpunct
  \nobreak\space\blx@imc@resetpunctfont}

\newrobustcmd*{\addthinspace}{%
  \unspace\blx@postpunct
  \hskip0.16667em\relax
  \blx@imc@resetpunctfont}

\newrobustcmd*{\addnbthinspace}{%
  \unspace\blx@postpunct
  \nobreak\hskip0.16667em\relax
  \blx@imc@resetpunctfont}

\newrobustcmd*{\addlowpenspace}{%
  \unspace\blx@postpunct
  \penalty\value{lownamepenalty}\space
  \blx@imc@resetpunctfont}

\newrobustcmd*{\addhighpenspace}{%
  \unspace\blx@postpunct
  \penalty\value{highnamepenalty}\space
  \blx@imc@resetpunctfont}

\newrobustcmd*{\addlpthinspace}{%
  \unspace\blx@postpunct
  \penalty\value{lownamepenalty}%
  \hskip0.16667em\relax\blx@imc@resetpunctfont}

\newrobustcmd*{\addhpthinspace}{%
  \unspace\blx@postpunct
  \penalty\value{highnamepenalty}%
  \hskip0.16667em\relax\blx@imc@resetpunctfont}

\newrobustcmd*{\addabbrvspace}{%
  \unspace\blx@postpunct
  \penalty\value{abbrvpenalty}%
  \space\blx@imc@resetpunctfont}

\newrobustcmd*{\addabthinspace}{%
  \unspace\blx@postpunct
  \penalty\value{abbrvpenalty}%
  \hskip0.16667em\relax
  \blx@imc@resetpunctfont}

\newrobustcmd*{\adddotspace}{%
  \unspace\adddot\blx@postpunct
  \penalty\value{abbrvpenalty}%
  \space\blx@imc@resetpunctfont}

\providerobustcmd*{\noligature}{%
  \penalty\@M\discretionary{-}{}{\kern0.03em}%
  \nobreak\hskip\z@skip}

\providerobustcmd*{\hyphen}{%
  \nobreak-\nobreak\hskip\z@skip}

\providerobustcmd*{\nbhyphen}{%
  \nobreak\mbox{-}\nobreak\hskip\z@skip}

\providerobustcmd*{\hyphenate}{%
  \nobreak\-\nobreak\hskip\z@skip}

\providerobustcmd*{\allowhyphens}{%
  \nobreak\hskip\z@skip}

% Idea from Peter Wilson's hyphenat package
% https://ctan.org/pkg/hyphenat
% also https://texfaq.org/FAQ-hyphoff
\newlanguage\blx@langwohyphens

\providerobustcmd*{\nohyphenation}{%
  \language\blx@langwohyphens}

% First part of workaround for odd XeTeX/babel-french behaviour
% https://github.com/plk/biblatex/issues/979
% fix by Ulrike Fischer
% https://tex.stackexchange.com/a/544914/.
% The second bit lives in blx-unicode.def.
\ifundef\XeTeXrevision
  {\providerobustcmd*{\textnohyphenation}[1]{%
     \bgroup\nohyphenation#1\egroup}}
  {}

\blx@regimcs{%
  \setpunctfont \resetpunctfont \ifcapital \autocap \ifpunctmark
  \ifpunct \ifterm \nopunct \isdot \adddot \addperiod \addcomma
  \addsemicolon \addcolon \addexclam \addquestion}

\appto\blx@blxinit{%
  \appto\nocorrlist{\isdot\adddot\addperiod\addcomma}}

%% Style definition

% {&lt;bibstyle&gt;}
\newrobustcmd*{\RequireBibliographyStyle}[1]{%
  \blx@inputonce{#1.bbx}{bibliography style '#1'}{}{}{}
    {\blx@error
       {Style '#1' not found}
       {The bibliography style '#1' could not be found}}}
\@onlypreamble\RequireBibliographyStyle

% {&lt;code&gt;}
\newrobustcmd*{\InitializeBibliographyStyle}{\appto\blx@hook@bbxinit}
\@onlypreamble\InitializeBibliographyStyle

% {&lt;entry type&gt;}{&lt;driverdef&gt;}
\newrobustcmd*{\DeclareBibliographyDriver}[1]{%
  \blx@declarebibdriver{#1}}
\@onlypreamble\DeclareBibliographyDriver

\long\def\blx@declarebibdriver#1#2{\long\csdef{blx@bbx@#1}{#2}}



% {&lt;entry type&gt;}
\def\blx@driver#1{%
  \ifcsdef{blx@bbx@#1}
    {\csuse{blx@bbx@#1}}
    {\ifcsdef{blx@bbx@*}
       {\blx@warning{%
          No driver for '#1'.\MessageBreak
          Using fallback driver}%
        \csuse{blx@bbx@*}}
       {\blx@error
          {No driver for '#1' found}
          {I can't find a driver for
           '#1'\MessageBreak
           (entry type '\abx@field@entrytype')\MessageBreak
           and there is no fallback driver either}}}}

% {&lt;type&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@ifdriver#1{\ifcsdef{blx@bbx@#1}}

% {&lt;alias&gt;}{&lt;type&gt;}
\newrobustcmd*{\DeclareBibliographyAlias}[2]{%
  \csedef{blx@bbx@#1}{%
    \expandafter\noexpand\csname blx@bbx@#2\endcsname}}
\@onlypreamble\DeclareBibliographyAlias

%% Auxiliary commands
\newrobustcmd*{\citereset}{%
  \csuse{blx@hook@cbxinit}%
  \@ifstar
    {}
    {\global\cslet{blx@bsee@\the\c@refsection}\@empty
     \global\cslet{blx@fsee@\the\c@refsection}\@empty
     \blx@ibidreset@force
     \blx@idemreset@force
     \blx@opcitreset@force
     \blx@loccitreset@force}}

\def\blx@save#1{%
  \ifcsdef{blx@saved@#1}
    {}
    {\blx@safe@actives
     \csletcs{blx@saved@#1}{#1}%
     \blx@rest@actives}}

\def\blx@restore#1{%
  \ifcsdef{blx@saved@#1}
    {\blx@safe@actives
     \csletcs{#1}{blx@saved@#1}%
     \csundef{blx@saved@#1}%
     \blx@rest@actives}
    {}}

\newrobustcmd*{\savecommand}[1]{%
  \ifcsdef{blx@saved@cmd@\detokenize{#1}}
    {}
    {\cslet{blx@saved@cmd@\detokenize{#1}}{#1}}}

\newrobustcmd*{\restorecommand}[1]{%
  \ifcsdef{blx@saved@cmd@\detokenize{#1}}
    {\letcs{#1}{blx@saved@cmd@\detokenize{#1}}%
     \csundef{blx@saved@cmd@\detokenize{#1}}}
    {}}

% {&lt;name&gt;}
\newrobustcmd*{\savebibmacro}[1]{%
  \blx@save{abx@macro@\detokenize{#1}}}

\newrobustcmd*{\restorebibmacro}[1]{%
  \blx@restore{abx@macro@\detokenize{#1}}}

% {&lt;name&gt;}[&lt;args&gt;][&lt;optarg&gt;]{&lt;definition&gt;}
\newrobustcmd*{\newbibmacro}{%
  \@star@or@long\blx@newbibmacro}

\def\blx@newbibmacro#1{%
  \ifcsundef{abx@macro@\detokenize{#1}}
    {\blx@defbibmacro\new@command{#1}}
    {\blx@warning{%
       Macro '\detokenize{#1}' already defined.\MessageBreak
       Using \string\renewbibmacro}
     \blx@defbibmacro\renew@command{#1}}}

\newrobustcmd*{\renewbibmacro}{%
  \@star@or@long\blx@renewbibmacro}

\def\blx@renewbibmacro#1{%
  \ifcsundef{abx@macro@\detokenize{#1}}
    {\blx@warning{%
       Macro '\detokenize{#1}' undefined.\MessageBreak
       Using \string\newbibmacro}
     \blx@defbibmacro\new@command{#1}}
    {\blx@defbibmacro\renew@command{#1}}}

\newrobustcmd*{\providebibmacro}{%
  \@star@or@long{\blx@defbibmacro\provide@command}}

\def\blx@defbibmacro#1#2{%
  \expandafter#1\csname abx@macro@\detokenize{#2}\endcsname}

% {&lt;alias&gt;}{&lt;name&gt;}
\newrobustcmd*{\letbibmacro}{%
  \@ifstar
    {\blx@letbibmacro@i}
    {\blx@letbibmacro}}

\def\blx@letbibmacro#1#2{%
  \blx@letbibmacro@i{\detokenize{#1}}{\detokenize{#2}}}

\def\blx@letbibmacro@i#1#2{%
  \ifcsundef{abx@macro@#2}
    {\blx@error
       {Bibliography macro '#2' undefined}
       {Use '\string\newbibmacro' to define this macro}}
    {\csletcs{abx@macro@#1}{abx@macro@#2}}}

% {&lt;name&gt;}
\newrobustcmd*{\usebibmacro}{%
  \@ifstar
    {\blx@usebibmacro@i}
    {\blx@usebibmacro}}

\def\blx@usebibmacro#1{%
  \blx@usebibmacro@i{\detokenize{#1}}}

\def\blx@usebibmacro@i#1{%
  \ifcsundef{abx@macro@#1}
    {\blx@error
       {Bibliography macro '#1' undefined}
       {Use '\string\newbibmacro' to define this macro}}
    {\csuse{abx@macro@#1}}}

% {&lt;name&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@ifbibmacroundef#1{%
  \ifcsundef{abx@macro@#1}}

\def\ifbibmacroundef{\blx@imc@ifbibmacroundef}

% {&lt;field&gt;}
\def\blx@imc@thefield#1{\csuse{abx@field@#1}}

\def\blx@imc@strfield#1{%
  \ifcsdef{abx@field@#1}
    {\detokenize\expandafter\expandafter\expandafter
       {\csname abx@field@#1\endcsname}}
    {}}

\def\blx@imc@csfield#1{\usefield{\unexpanded}{#1}}

% {&lt;command&gt;}{&lt;field&gt;}
\def\blx@imc@usefield#1#2{%
  \expandafter\expandafter\expandafter#1%
  \expandafter\expandafter\expandafter{\csname abx@field@#2\endcsname}}

% {&lt;plainlist&gt;}
\def\blx@imc@thelist#1{\csuse{abx@list@#1}}

\def\blx@imc@strlist#1{%
  \ifcsdef{abx@list@#1}
    {\detokenize\expandafter\expandafter\expandafter
       {\csname abx@list@#1\endcsname}}
    {}}

\def\blx@imc@thefirstlistitem#1{%
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \blx@imc@thefirstlistitem@grab
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  {\csuse{abx@list@#1}}}

\def\blx@imc@thefirstlistitem@grab#1{%
  \blx@imc@thefirstlistitem@grab@i
  #1{}{}%
  \blx@imc@thefirstlistitem@grab@i@end}
\def\blx@imc@thefirstlistitem@grab@i#1#2\blx@imc@thefirstlistitem@grab@i@end{#1}

% {&lt;command&gt;}{&lt;field&gt;}
% needs 7 levels of expansion, i.e. 2^7-1=127 '\expandafter's
\def\blx@imc@usefirstlistitem#1#2{%
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter
  #1%
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter\expandafter\expandafter\expandafter
  \expandafter\expandafter
  {\blx@imc@thefirstlistitem{#2}}}

\def\blx@imc@strfirstlistitem#1{%
  \ifcsdef{abx@list@#1}
    {\blx@imc@usefirstlistitem{\detokenize}{#1}}
    {}}

% {&lt;namelist&gt;}
\def\blx@imc@thename#1{\csuse{abx@name@#1}}

\def\blx@imc@strname#1{%
  \ifcsdef{abx@name@#1}
    {\detokenize\expandafter\expandafter\expandafter
       {\csname abx@name@#1\endcsname}}
    {}}


% We have to save cleared fields/lists/names in case a related entry
% needs them for tests
\let\abx@dorelfields\@empty
\let\abx@dorellists\@empty
\let\abx@dorelnames\@empty

% {&lt;field&gt;}
% If there is a related field in the entry, save a special copy in case
% the related entry needs it for tests. See the corresponding tests in
% \blx@save{field,list,name}
\protected\def\blx@imc@clearfield#1{%
  \ifdef\abx@field@related
    {\csletcs{abx@field@relsaved#1}{abx@field@#1}%
     \listadd\abx@dorelfields{#1}}
    {}%
  \csundef{abx@field@#1}}

% {&lt;plainlist&gt;}
% If there is a related field in the entry, save a special copy in case
% the related entry needs it for tests. See the corresponding tests in
% \blx@save{field,list,name}
\protected\def\blx@imc@clearlist#1{%
  \ifcsundef{abx@list@#1}
    {}
    {\ifdef\abx@field@related
       {\csletcs{abx@list@relsaved#1}{abx@list@#1}%
        \csletcs{etb@tgl@abx@bool@morerelsaved#1}{etb@tgl@abx@bool@more#1}%
        \csletcs{c@relsaved#1}{c@#1}%
        \listadd\abx@dorellists{#1}}
       {}%
     \togglefalse{abx@bool@more#1}%
     \csundef{abx@list@#1}%
     \csname c@#1\endcsname\z@}}

% {&lt;namelist&gt;}
% If there is a related field in the entry, save a special copy in case
% the related entry needs it for tests. See the corresponding tests in
% \blx@save{field,list,name}
\protected\def\blx@imc@clearname#1{%
  \ifcsundef{abx@name@#1}
    {}
    {\ifdef\abx@field@related
      {\csletcs{abx@name@relsaved#1}{abx@name@#1}%
       \csletcs{etb@tgl@abx@bool@morerelsaved#1}{etb@tgl@abx@bool@more#1}%
       \csletcs{c@relsaved#1}{c@#1}%
       \listadd\abx@dorelnames{#1}}
      {}%
     \togglefalse{abx@bool@more#1}%
     \csundef{abx@name@#1}%
     \csname c@#1\endcsname\z@}}

% {&lt;field&gt;}{&lt;macro&gt;}
\protected\def\blx@imc@restorefield#1{\cslet{abx@field@#1}}

% {&lt;plainlist&gt;}{&lt;macro&gt;}
\protected\def\blx@imc@restorelist#1{\cslet{abx@list@#1}}

% {&lt;namelist&gt;}{&lt;macro&gt;}
\protected\def\blx@imc@restorename#1{\cslet{abx@name@#1}}

% {&lt;field&gt;}{&lt;macro&gt;}
\protected\def\blx@imc@savefield{%
  \@ifstar{\blx@savedata{field}}{\global\blx@savedata{field}}}
\def\blx@savedata#1#2#3{\letcs#3{abx@#1@#2}}

% {&lt;plainlist&gt;}{&lt;macro&gt;}
\protected\def\blx@imc@savelist{%
  \@ifstar{\blx@savedata{list}}{\global\blx@savedata{list}}}

% {&lt;namelist&gt;}{&lt;macro&gt;}
\protected\def\blx@imc@savename{%
  \@ifstar{\blx@savedata{name}}{\global\blx@savedata{name}}}

% {&lt;field&gt;}{&lt;csname&gt;}
\protected\def\blx@imc@savefieldcs{%
  \@ifstar{\blx@savedatacs{field}}{\global\blx@savedatacs{field}}}
\def\blx@savedatacs#1#2#3{\csletcs{#3}{abx@#1@#2}}

% {&lt;plainlist&gt;}{&lt;csname&gt;}
\protected\def\blx@imc@savelistcs{%
  \@ifstar{\blx@savedatacs{list}}{\global\blx@savedatacs{list}}}

% {&lt;namelist&gt;}{&lt;csname&gt;}
\protected\def\blx@imc@savenamecs{%
  \@ifstar{\blx@savedatacs{name}}{\global\blx@savedatacs{name}}}

% {&lt;field&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@iffieldundef#1{%
  \ifcsundef{abx@field@#1}}

% {&lt;plainlist&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@iflistundef#1{%
  \ifcsundef{abx@list@#1}}

% {&lt;namelist&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@ifnameundef#1{%
  \ifcsundef{abx@name@#1}}

% {&lt;field1&gt;}{&lt;field2&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@iffieldsequal#1#2{%
  \ifcsequal{abx@field@#1}{abx@field@#2}}

% {&lt;plainlist1&gt;}{&lt;plainlist2&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@iflistsequal#1#2{%
  \ifcsequal{abx@list@#1}{abx@list@#2}}

% {&lt;namelist1&gt;}{&lt;namelist2&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@ifnamesequal#1#2{%
  \ifcsundef{abx@name@#1}
    {\@secondoftwo}
    {\ifcsundef{abx@name@#2}
       {\@secondoftwo}
       {\blx@ifnamesequalcscs{abx@name@#1}{abx@name@#2}}}}

\def\blx@ifnamesequalcscs#1#2{%
  \expandafter\expandafter\expandafter\blx@ifnamesequaldefdef
  \expandafter\expandafter\expandafter{%
    \expandafter\csname\expandafter #1\expandafter\endcsname
  \expandafter}%
  \expandafter{\csname #2\endcsname}}

\def\blx@ifnamesequalcsdef#1#2{%
  \expandafter\blx@ifnamesequaldefdef\expandafter{%
    \csname #1\endcsname}{#2}}

\def\blx@ifnamesequaldefdef#1#2{%
  \begingroup
  \let\blx@tempa\@empty
  \expandafter\blx@ifnamesequal@i#2%
  \let\blx@tempb\blx@tempa
  \let\blx@tempa\@empty
  \expandafter\blx@ifnamesequal@i#1%
  \expandafter\endgroup
  \ifx\blx@tempa\blx@tempb
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}

\def\blx@ifnamesequal@i#1#2{%
  \expandafter\blx@ifnamesequal@ii#2{}&amp;}

\def\blx@ifnamesequal@ii#1{%
  \ifblank{#1}
    {\blx@namebreak}
    {\blx@ifnamesequal@iii#1%
     \blx@ifnamesequal@ii}}

% These explicit nameparts are alright as they are for bibtex only
% biber names will always have a hash generated from all nameparts in datamodel
\def\blx@ifnamesequal@iii#1#2{%
  \blx@kv@setkeys{blx@opt@name}{#1}%
  \blx@kv@setkeys{blx@opt@namepart}{#2}%
  \ifdef\abx@field@hash
    {\eappto\blx@tempa{{\abx@field@hash}}}
    {\eappto\blx@tempa{{{\namepartfamily}{\namepartgiven}{\namepartprefix}{\namepartsuffix}}}}}

% {&lt;csname&gt;}{&lt;def&gt;}{&lt;true&gt;}{&lt;false&gt;}
\newcommand*{\blx@ifcsdefequal}[2]{%
  \ifcsundef{#1}
    {\@secondoftwo}
    {\ifundef#2%
       {\@secondoftwo}
       {\expandafter\ifx\csname#1\endcsname#2%
          \expandafter\@firstoftwo
        \else
          \expandafter\@secondoftwo
        \fi}}}

% {&lt;field&gt;}{&lt;macro&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@iffieldequals#1#2{%
  \blx@ifcsdefequal{abx@field@#1}{#2}}

% {&lt;plainlist&gt;}{&lt;macro&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@iflistequals#1#2{%
  \blx@ifcsdefequal{abx@list@#1}{#2}}

% {&lt;namelist&gt;}{&lt;macro&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@ifnameequals#1#2{%
  \blx@imc@ifnameundef{#1}
    {\@secondoftwo}
    {\ifundef#2%
       {\@secondoftwo}
       {\blx@ifnamesequalcsdef{abx@name@#1}{#2}}}}

% {&lt;field&gt;}{&lt;csname&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@iffieldequalcs#1{%
  \ifcsequal{abx@field@#1}}

% {&lt;plainlist&gt;}{&lt;csname&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@iflistequalcs#1{%
  \ifcsequal{abx@list@#1}}

% {&lt;namelist&gt;}{&lt;csname&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@ifnameequalcs#1#2{%
  \blx@imc@ifnameundef{#1}
    {\@secondoftwo}
    {\ifcsundef{#2}
       {\@secondoftwo}
       {\blx@ifnamesequalcscs{abx@name@#1}{#2}}}}

% {&lt;field&gt;}{&lt;string&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\long\def\blx@imc@iffieldequalstr#1#2{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\expandafter\expandafter\expandafter\ifstrequal
     \expandafter\expandafter\expandafter{%
       \csname abx@field@#1\endcsname}{#2}}}

% {&lt;field&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@iffieldxref#1{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\blx@whichxref
       {\blx@iffieldxref{#1}}
       {\@secondoftwo}}}

\def\blx@iffieldxref#1#2{%
  \begingroup
  \letcs\blx@tempa{abx@field@#2}%
  \letcs\blx@tempb{abx@field@#1}%
  \blx@resetdata
  \blx@getdata{\blx@tempa}%
  \blx@imc@iffieldequals{#1}\blx@tempb
    {\aftergroup\@firstoftwo}
    {\aftergroup\@secondoftwo}%
  \endgroup}

\def\blx@whichxref#1#2{%
  \blx@imc@iffieldundef{crossref}
    {\blx@imc@iffieldundef{xref}
       {#2}
       {#1{xref}}}
    {#1{crossref}}}

% {&lt;plainlist&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@iflistxref#1{%
  \blx@imc@iflistundef{#1}
    {\@secondoftwo}
    {\blx@whichxref
       {\blx@iflistxref{#1}}
       {\@secondoftwo}}}

\def\blx@iflistxref#1#2{%
  \begingroup
  \letcs\blx@tempa{abx@field@#2}%
  \letcs\blx@tempb{abx@list@#1}%
  \blx@resetdata
  \blx@getdata{\blx@tempa}%
  \blx@imc@iflistequals{#1}\blx@tempb
    {\aftergroup\@firstoftwo}
    {\aftergroup\@secondoftwo}%
  \endgroup}

% {&lt;namelist&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifnamexref#1{%
  \blx@imc@ifnameundef{#1}
    {\@secondoftwo}
    {\blx@whichxref
       {\blx@ifnamexref{#1}}
       {\@secondoftwo}}}

\def\blx@ifnamexref#1#2{%
  \begingroup
  \letcs\blx@tempa{abx@field@#2}%
  \letcs\blx@tempb{abx@name@#1}%
  \blx@resetdata
  \blx@getdata{\blx@tempa}%
  \blx@imc@ifnameequals{#1}\blx@tempb
    {\aftergroup\@firstoftwo}
    {\aftergroup\@secondoftwo}%
  \endgroup}

% {&lt;string&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifcurrentfield#1{%
  \begingroup
  \def\blx@tempa{#1}%
  \ifx\currentfield\blx@tempa
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup}

% {&lt;string&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifcurrentlist#1{%
  \begingroup
  \def\blx@tempa{#1}%
  \ifx\currentlist\blx@tempa
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup}

% {&lt;string&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifcurrentname#1{%
  \begingroup
  \def\blx@tempa{#1}%
  \ifx\currentname\blx@tempa
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup}

% {&lt;string&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifentrytype#1{%
  \begingroup
  \def\blx@tempa{#1}%
  \ifx\abx@field@entrytype\blx@tempa
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup}

% {&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@ifmorenames{%
  \ifundef\currentname
    {\@secondoftwo}
    {\iftoggle{abx@bool@more\currentname}
       {\@firstoftwo}
       {\ifnum\c@listtotal&gt;\c@liststop
          \expandafter\@firstoftwo
        \else
          \expandafter\@secondoftwo
        \fi}}}

% {&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@ifmoreitems{%
  \ifundef\currentlist
    {\@secondoftwo}
    {\iftoggle{abx@bool@more\currentlist}
       {\@firstoftwo}
       {\ifnum\c@listtotal&gt;\c@liststop
          \expandafter\@firstoftwo
        \else
          \expandafter\@secondoftwo
        \fi}}}


% {&lt;true&gt;}{&lt;false&gt;}
%\def\blx@imc@iffirstcitekey{%
%  \ifboolexpr{ ( test {\ifnumequal\c@multicitetotal\z@}
%                 and test {\ifnumequal\c@citecount\@ne} )
%    or ( test {\ifnumgreater\c@multicitetotal\z@}
%         and test {\ifnumequal\c@multicitecount\@ne}
%         and test {\ifnumequal\c@citecount\@ne} ) }}
\def\blx@imc@iffirstcitekey{%
  \ifnumequal\c@citecount\@ne
    {\ifnumequal\c@multicitetotal\z@
       {\@firstoftwo}
       {\ifnumequal\c@multicitecount\@ne}}
    {\@secondoftwo}}

\def\blx@imc@iflastcitekey{%
  \ifnumequal\c@citecount\c@citetotal
    {\ifnumequal\c@multicitecount\c@multicitetotal}
    {\@secondoftwo}}

% {&lt;category&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifcategory{%
  \ifdef\abx@field@entrykey
    {\blx@imc@ifentrycategory\abx@field@entrykey}
    {\expandafter\@secondoftwo\@gobble}}

% {&lt;entrykey&gt;}{&lt;category&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifentrycategory{%
  \blx@xsanitizeafter\blx@imc@ifentrycategory@i}

\def\blx@imc@ifentrycategory@i#1#2{%
  \ifcsdef{blx@catg@\detokenize{#2}}
    {\ifinlistcs{#1}{blx@catg@\detokenize{#2}}}
    {\@secondoftwo}}

% {&lt;keyword&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifkeyword{%
  \ifdef\abx@field@entrykey
    {\blx@imc@ifentrykeyword\abx@field@entrykey}
    {\expandafter\@secondoftwo\@gobble}}

% {&lt;entrykey&gt;}{&lt;keyword&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifentrykeyword{%
  \blx@xsanitizeafter\blx@imc@ifentrykeyword@i}

\def\blx@imc@ifentrykeyword@i#1#2{%
  \ifcsdef{blx@keyw@\the\c@refsection @\detokenize{#2}}
    {\ifinlistcs{#1}{blx@keyw@\the\c@refsection @\detokenize{#2}}}
    {\@secondoftwo}}

% {&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@ifciteseen@global{%
  \ifbool{citetracker}
    {\ifdef\abx@field@entrykey
       {\expandafter\blx@ifseen@global
        \expandafter{\abx@field@entrykey}}
       {\@secondoftwo}}
    {\@secondoftwo}}

\protected\def\blx@ifciteseen@context{%
  \ifbool{citetracker}
    {\ifdef\abx@field@entrykey
       {\expandafter\blx@ifseen@context
        \expandafter{\abx@field@entrykey}}
       {\@secondoftwo}}
    {\@secondoftwo}}

\protected\def\blx@ifciteseen@context{%
  \ifbool{citetracker}
    {\ifdef\abx@field@entrykey
       {\expandafter\blx@ifseen@context
        \expandafter{\abx@field@entrykey}}
       {\@secondoftwo}}
    {\@secondoftwo}}

% {&lt;entrykey&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@ifentryseen@global{%
  \blx@xsanitizeafter\blx@ifseen@global}

\protected\def\blx@ifentryseen@context{%
  \blx@xsanitizeafter\blx@ifseen@context}

\def\blx@ifseen@global#1{%
  \ifbool{citetracker}
    {\ifinlistcs{#1}{blx@bsee@\the\c@refsection}}
    {\@secondoftwo}}

\def\blx@ifseen@context#1{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\ifinlistcs{#1}{blx@fsee@\the\c@refsection}}
       {\ifinlistcs{#1}{blx@bsee@\the\c@refsection}}}
    {\@secondoftwo}}

% {&lt;true&gt;}{&lt;false&gt;}
\def\blx@ifciteibid@global{%
  \ifbool{citetracker}
    {\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}
    {\@secondoftwo}}

\def\blx@ifciteibid@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\blx@imc@iffieldequals{entrykey}\blx@lastkey@foot}
       {\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}}
    {\@secondoftwo}}

\def\blx@ifciteibid@strict{%
  \ifbool{citetracker}
    {\blx@ifcitesingle
       {\blx@ifciteibid@global}
       {\@secondoftwo}}
    {\@secondoftwo}}

\def\blx@ifciteibid@constrict{%
  \ifbool{citetracker}
    {\blx@ifcitesingle
       {\iftoggle{blx@footnote}
          {\blx@ifmpfncheck
             {\blx@imc@iffieldequals{entrykey}\blx@lastkey@foot}
             {\@secondoftwo}}
          {\blx@imc@iffieldequals{entrykey}\blx@lastkey@text}}
       {\@secondoftwo}}
    {\@secondoftwo}}

% {&lt;true&gt;}{&lt;false&gt;}
\def\blx@ifciteidem@global{%
  \ifbool{citetracker}
    {\blx@imc@iffieldequals{fullhash}\blx@lasthash@text}
    {\@secondoftwo}}

\def\blx@ifciteidem@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\blx@imc@iffieldequals{fullhash}\blx@lasthash@foot}
       {\blx@imc@iffieldequals{fullhash}\blx@lasthash@text}}
    {\@secondoftwo}}

\let\blx@ifciteidem@strict\blx@ifciteidem@global

\def\blx@ifciteidem@constrict{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\blx@ifmpfncheck
          {\blx@imc@iffieldequals{fullhash}\blx@lasthash@foot}
          {\@secondoftwo}}
       {\blx@imc@iffieldequals{fullhash}\blx@lasthash@text}}
    {\@secondoftwo}}

% {&lt;true&gt;}{&lt;false&gt;}
\def\blx@ifopcit@global{%
  \ifbool{citetracker}
    {\blx@imc@iffieldundef{namehash}
       {\@secondoftwo}
       {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@text@\abx@field@namehash}}}
    {\@secondoftwo}}

\def\blx@ifopcit@context{%
  \ifbool{citetracker}
    {\blx@imc@iffieldundef{namehash}
       {\@secondoftwo}
       {\iftoggle{blx@footnote}
          {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@foot@\abx@field@namehash}}
          {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@text@\abx@field@namehash}}}}
    {\@secondoftwo}}

\def\blx@ifopcit@strict{%
  \ifbool{citetracker}
    {\blx@ifcitesingle
       {\blx@ifopcit@global}
       {\@secondoftwo}}
    {\@secondoftwo}}

\def\blx@ifopcit@constrict{%
  \ifbool{citetracker}
    {\blx@ifcitesingle
       {\blx@imc@iffieldundef{namehash}
          {\@secondoftwo}
          {\iftoggle{blx@footnote}
             {\blx@ifmpfncheck
                {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@foot@\abx@field@namehash}}
                {\@secondoftwo}}
             {\blx@imc@iffieldequalcs{entrykey}{blx@lastkey@text@\abx@field@namehash}}}}
       {\@secondoftwo}}
    {\@secondoftwo}}

% {&lt;true&gt;}{&lt;false&gt;}
\def\blx@ifloccit@global{%
  \ifbool{citetracker}
    {\blx@loccit@check{text}}
    {\@secondoftwo}}

\def\blx@ifloccit@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\blx@loccit@check{foot}}
       {\blx@loccit@check{text}}}
    {\@secondoftwo}}

\def\blx@ifloccit@strict{%
  \ifbool{citetracker}
    {\blx@ifcitesingle
       {\blx@loccit@numcheck{text}}
       {\@secondoftwo}}
    {\@secondoftwo}}

\def\blx@ifloccit@constrict{%
  \ifbool{citetracker}
    {\blx@ifcitesingle
       {\iftoggle{blx@footnote}
          {\blx@ifmpfncheck
             {\blx@loccit@numcheck{foot}}
             {\@secondoftwo}}
          {\blx@loccit@numcheck{text}}}
       {\@secondoftwo}}
    {\@secondoftwo}}

\def\blx@loccit@check#1{%
  \blx@imc@iffieldundef{postnote}
    {\@secondoftwo}
    {\blx@imc@iffieldequalcs{postnote}{blx@lastnote@#1@\abx@field@entrykey}}}

\def\blx@loccit@numcheck#1{%
  \blx@imc@iffieldundef{postnote}
    {\@secondoftwo}
    {\expandafter\blx@imc@ifpages
     \expandafter{\abx@field@postnote}
       {\blx@imc@iffieldequalcs{postnote}{blx@lastnote@#1@\abx@field@entrykey}}
       {\@secondoftwo}}}

% {&lt;true&gt;}{&lt;false&gt;}
\def\blx@ifmpfncheck{%
  \ifnum\numexpr\value\@mpfn-\blx@lastmpfn&lt;\tw@
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}

\def\blx@mpfnsave{%
  \xdef\blx@lastmpfn{\the\value\@mpfn}}

\def\blx@mpfnreset{%
  \global\let\blx@lastmpfn\z@}

\blx@mpfnreset

% {&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@iffirstonpage{%
  \ifbool{pagetracker}
    {\iftoggle{blx@footnote}
       {\blx@iffirstonpage{fnpage}}
       {\blx@iffirstonpage{page}}}
    {\@secondoftwo}}

\def\blx@iffirstonpage#1{%
  \ifcsundef{blx@#1@\number\c@instcount}
    {\@secondoftwo}
    {\expandafter\blx@iffirstonpage@i
     \expandafter{\number\numexpr\c@instcount-1}{#1}}}

\def\blx@iffirstonpage@i#1#2{%
  \ifcsundef{blx@#2@#1}
    {\ifnum#1&gt;\@ne
       \expandafter\@firstoftwo
     \else
       \expandafter\@secondoftwo
     \fi
     {\expandafter\blx@iffirstonpage@i
      \expandafter{\number\numexpr#1-1}{#2}}
     {\@firstoftwo}}
    {\ifnum\csuse{blx@#2@\number\c@instcount}=%
           \csuse{blx@#2@#1} %
       \expandafter\@secondoftwo
     \else
       \expandafter\@firstoftwo
     \fi}}

% {&lt;count1&gt;}{&lt;count2&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@ifsamepage#1#2{%
  \ifbool{pagetracker}
    {\ifcsundef{blx@page@\number\numexpr#1}
       {\ifcsundef{blx@fnpage@\number\numexpr#1}
          {\@secondoftwo}
          {\blx@ifsamepage{#1}{#2}{fnpage}}}
       {\blx@ifsamepage{#1}{#2}{page}}}
    {\@secondoftwo}}

\def\blx@ifsamepage#1#2#3{%
  \ifcsundef{blx@page@\number\numexpr#2}
    {\ifcsundef{blx@fnpage@\number\numexpr#2}
       {\@secondoftwo}
       {\blx@ifsamepage@i{#1}{#2}{#3}{fnpage}}}
    {\blx@ifsamepage@i{#1}{#2}{#3}{page}}}

\def\blx@ifsamepage@i#1#2#3#4{%
  \ifnum\csuse{blx@#3@\number\numexpr#1}=%
        \csuse{blx@#4@\number\numexpr#2} %
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}

% {&lt;string&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\long\def\blx@imc@ifinteger#1{%
  \begingroup
  \def\do##1{\uccode`##1=`\%}%
  \do\0\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9%
  \catcode`\@=11
  \catcode`\%=9
  \endlinechar\m@ne
  \uppercase{\scantokens{\def\blx@tempa{#1}}}%
  \ifx\blx@tempa\@empty
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup}

% {\&lt;non-ASCII numeral&gt;}{\&lt;ASCII number&gt;}
\protected\def\blx@defcomputableequivalent#1#2{%
  \appto\blx@dononasciicomputablenumerals{\do#1}%
  \appto\blx@initcomputableequivs{\uccode`#1=`#2}}

% {&lt;string&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\long\def\blx@imc@hascomputableequivalent#1{%
  \begingroup
  \def\do##1{\uccode`##1=`\%}%
  \blx@dononasciicomputablenumerals
  \catcode`\@=11
  \catcode`\%=9
  \endlinechar\m@ne
  \uppercase{\scantokens{\def\blx@tempa{#1}}}%
  \ifx\blx@tempa\@empty
    \aftergroup\@firstoftwo
  \else
    \aftergroup\@secondoftwo
  \fi
  \endgroup}

% {&lt;string&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\long\def\blx@imc@ifiscomputable#1{%
  \blx@imc@ifinteger{#1}
    {\@firstofone}
    {\blx@imc@hascomputableequivalent{#1}}}

% {&lt;string&gt;}{&lt;macro&gt;}
\protected\long\def\blx@imc@getcomputableequivalent#1#2{%
  \blx@imc@hascomputableequivalent{#1}
    {\begingroup
     \blx@initcomputableequivs
     \uppercase{\def\blx@tempa{#1}}%
     \edef\blx@tempb{\endgroup
       \noexpand\def\noexpand#2{\expandonce{\blx@tempa}}}%
      \blx@tempb}
    {\def#2{#1}}}

% {&lt;field&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@iffieldint#1{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\expandafter\expandafter
     \expandafter\blx@imc@ifinteger
     \expandafter\expandafter
     \expandafter{\csname abx@field@#1\endcsname}}}

% {&lt;field&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@fieldhascomputableequivalent#1{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\expandafter\expandafter
     \expandafter\blx@imc@hascomputableequivalent
     \expandafter\expandafter
     \expandafter{\csname abx@field@#1\endcsname}}}

% {&lt;field&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@iffieldiscomputable#1{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\expandafter\expandafter
     \expandafter\blx@imc@ifiscomputable
     \expandafter\expandafter
     \expandafter{\csname abx@field@#1\endcsname}}}

% {&lt;string&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@ifnumeral{%
  \blx@ifnum\blx@hook@ifnum}

\protected\def\blx@imc@ifnumerals{%
  \blx@ifnum\blx@hook@ifnums}

\protected\def\blx@imc@ifpages{%
  \blx@ifnum\blx@hook@ifpages}

\long\def\blx@ifnum#1#2{%
  \begingroup
  \let\protect\@unexpandable@protect
  \uppercase{\edef\blx@tempa{#2}}%
  \ifx\blx@tempa\@empty
    \aftergroup\@secondoftwo
  \else
    \catcode`\@=11
    \catcode`\%=9
    \endlinechar\m@ne
    \everyeof{\noexpand}#1%
    \uppercase{\edef\blx@tempa{\scantokens{#2}}}%
    \ifx\blx@tempa\@empty
      \aftergroup\@firstoftwo
    \else
      \aftergroup\@secondoftwo
    \fi
  \fi
  \endgroup}

% valid numerals set by the lbx file
\let\lbx@dononasciinumerals\relax

\def\blx@hook@ifnum{%
  \def\do##1{\uccode`##1=`\%}%
  \do\ \do\0\do\1\do\2\do\3\do\4\do\5\do\6\do\7\do\8\do\9%
  \do\i\do\v\do\x\do\l\do\c\do\d\do\m
  \do\I\do\V\do\X\do\L\do\C\do\D\do\M
  \lbx@dononasciinumerals
  \blx@donumchars
  \let\RN\@firstofone
  \let\Rn\@firstofone}

\def\blx@hook@ifnums{%
  \blx@hook@ifnum
  \def\do##1{\uccode`##1=`\%}%
  \blx@dorangechars
  \def\do##1{\let##1\@empty}%
  \blx@dorangecmds}

\def\blx@hook@ifpages{%
  \blx@hook@ifnum
  \blx@hook@ifnums
  \def\do##1{\let##1\@empty}%
  \blx@dopagecmds}

% {&lt;field&gt;}{&lt;true&gt;}{&lt;false&gt;}
\protected\def\blx@imc@iffieldnum#1{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\expandafter\expandafter
     \expandafter\blx@imc@ifnumeral
     \expandafter\expandafter
     \expandafter{\csname abx@field@#1\endcsname}}}

\protected\def\blx@imc@iffieldnums#1{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\expandafter\expandafter
     \expandafter\blx@imc@ifnumerals
     \expandafter\expandafter
     \expandafter{\csname abx@field@#1\endcsname}}}

\protected\def\blx@imc@iffieldpages#1{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\expandafter\expandafter
     \expandafter\blx@imc@ifpages
     \expandafter\expandafter
     \expandafter{\csname abx@field@#1\endcsname}}}

% {&lt;chars&gt;}
\newrobustcmd*{\DeclareNumChars}{%
  \@ifstar
    {\blx@defnumchars}
    {\global\let\blx@donumchars\@empty
     \blx@defnumchars}}

\def\blx@defnumchars#1{%
  \ifblank{#1}
    {}
    {\expandafter\blx@defdochars
     \expandafter\blx@donumchars
     \detokenize{#1}\relax}}

% {&lt;chars&gt;}
\newrobustcmd*{\DeclareRangeChars}{%
  \@ifstar
    {\blx@defrangechars}
    {\global\let\blx@dorangechars\@empty
     \blx@defrangechars}}

\def\blx@defrangechars#1{%
  \ifblank{#1}
    {}
    {\expandafter\blx@defdochars
     \expandafter\blx@dorangechars
     \detokenize{#1}\relax}}

\def\blx@defdochars#1#2{%
  \ifx#2\relax
  \else
    \xdef#1{%
      \expandonce#1\noexpand\do
      \expandafter\noexpand\csname#2\endcsname}%
    \expandafter\blx@defdochars
    \expandafter#1%
  \fi}

% {&lt;cstokens&gt;}
\newrobustcmd*{\DeclareRangeCommands}{%
  \@ifstar
    {\blx@defrangecmds}
    {\global\let\blx@dorangecmds\@empty
     \blx@defrangecmds}}

\def\blx@defrangecmds#1{%
  \ifblank{#1}
    {}
    {\blx@defrangecmds@i#1&amp;}}

\def\blx@defrangecmds@i#1{%
  \ifx&amp;#1%
  \else
    \gappto\blx@dorangecmds{\do#1}%
    \expandafter\blx@defrangecmds@i
  \fi}

% {&lt;cstokens&gt;}
\newrobustcmd*{\DeclarePageCommands}{%
  \@ifstar
    {\blx@defpagecmds}
    {\global\let\blx@dopagecmds\@empty
     \blx@defpagecmds}}

\def\blx@defpagecmds#1{%
  \ifblank{#1}
    {}
    {\blx@defpagecmds@i#1&amp;}}

\def\blx@defpagecmds@i#1{%
  \ifx&amp;#1%
  \else
    \gappto\blx@dopagecmds{\do#1}%
    \expandafter\blx@defpagecmds@i
  \fi}

\DeclareNumChars{.}
\DeclareRangeChars{~,;-+/}
\DeclareRangeCommands{%
  \ \,\space\nobreakspace\addspace\addnbspace
  \addthinspace\addnbthinspace\addlowpenspace
  \addhighpenspace\addlpthinspace\addhpthinspace
  \adddotspace\addabbrvspace\&amp;\psq\psqq
  \bibrangedash\bibdaterangesep\bibtimerangesep\textendash\textemdash\bibrangessep}
\DeclarePageCommands{\pno\ppno}

% *{&lt;code&gt;}
\newrobustcmd*{\NumCheckSetup}{\appto\blx@hook@ifnum}
\newcommand*{\NumcheckSetup}{\NumCheckSetup}

\newrobustcmd*{\NumsCheckSetup}{\appto\blx@hook@ifnums}

\newrobustcmd*{\PagesCheckSetup}{\appto\blx@hook@ifpages}

\PagesCheckSetup{\let\pnfmt\@firstofone}

% [&lt;pagination&gt;][&lt;postpro&gt;]{&lt;string&gt;}
\newrobustcmd*{\blx@imc@mkpageprefix}[1][pagination]{%
  \begingroup
  \def\blx@tempa{\blx@mkpageprefix{page}}%
  \iffieldundef{#1}
    {}
    {\iffieldequalstr{#1}{none}
       {\def\blx@tempa{\blx@mkpageprefix@i}}
       {\iffieldbibstring{#1}
          {\edef\blx@tempa{\blx@mkpageprefix{\thefield{#1}}}}
          {\blx@warning@entry{%
             Unknown pagination type '\strfield{#1}'}}}}%
  \@ifnextchar[%]
    {\blx@tempa}
    {\blx@tempa[\@firstofone]}}

\protected\long\def\blx@mkpageprefix#1[#2]#3{%
  \ifnumeral{#3}
    {\bibstring{#1}\ppspace}
    {\ifnumerals{#3}
       {\bibstring{#1s}\ppspace}
       {\def\pno{\bibstring{#1}}%
        \def\ppno{\bibstring{#1s}}}}%
  \blx@mkpageprefix@i[{#2}]{#3}}

\long\def\blx@mkpageprefix@i[#1]#2{#1{#2}\endgroup}

% [&lt;pagination&gt;][&lt;postpro&gt;]{&lt;string&gt;}
\newrobustcmd*{\blx@imc@mkpagetotal}[1][bookpagination]{%
  \begingroup
  \def\blx@tempa{\blx@mkpagetotal{pagetotal}}%
  \iffieldundef{#1}
    {}
    {\iffieldequalstr{#1}{none}
       {\def\blx@tempa{\blx@mkpagetotal@i}}
       {\iffieldplusstringbibstring{#1}{total}
          {\edef\blx@tempa{\blx@mkpagetotal{\thefield{#1}total}}}
          {\blx@warning@entry{%
             Unknown pagination type '\strfield{#1}total'}}}}%
  \@ifnextchar[%]
    {\blx@tempa}
    {\blx@tempa[\@firstofone]}}

\protected\long\def\blx@mkpagetotal#1[#2]#3{%
  \ifnumeral{#3}
    {\setbox\@tempboxa=\hbox{%
       \blx@tempcnta0#3\relax
       \ifnum\blx@tempcnta=\@ne
         \aftergroup\@firstoftwo
       \else
         \aftergroup\@secondoftwo
       \fi}%
     {#2{#3}\ppspace\bibstring{#1}}
     {#2{#3}\ppspace\bibstring{#1s}}}
    {\def\pno{\bibstring{#1}}%
     \def\ppno{\bibstring{#1s}}%
     #2{#3}}%
  \endgroup}

\long\def\blx@mkpagetotal@i[#1]#2{#1{#2}\endgroup}

\newcounter{mincomprange}
\newcounter{maxcomprange}
\newcounter{mincompwidth}
\setcounter{mincomprange}{10}
\setcounter{maxcomprange}{100000}
\setcounter{mincompwidth}{1}
\def\abx@rangeproclimit{100000}

% {&lt;rangefield&gt;}
\newcommand*{\rangelen}[1]{%
  \ifcsdef{abx@range@#1}
    {\csuse{abx@range@#1}}
    {}}

% &lt;*&gt;[&lt;postpro&gt;]{&lt;string&gt;}
\newrobustcmd*{\mknormrange}{%
  \begingroup
  \@ifstar
    {\blx@range@aux\blx@normrange@ii}
    {\blx@range@aux\blx@normrange@i}}

\def\blx@range@aux#1{%
  \@ifnextchar[{\blx@range@aux@i#1}{#1[\@firstofone][\@firstofone]}}

\def\blx@range@aux@i#1[#2]{%
  \@ifnextchar[{#1[{#2}]}{#1[{#2}][\@firstofone]}}

\def\blx@normrange@i[#1][#2]#3{%
  \let\blx@tempa\@empty
  \protected\def\blx@range@out@value{\appto\blx@tempa}%
  \def\blx@range@out@item@process{#2}%
  \let\blx@range@out@delim\blx@range@out@value
  \let\blx@range@split\blx@genrange@split
  \let\blx@range@process\blx@normrange@process
  \blx@range@chunk{#3}%
  \begingroup
  \edef\blx@tempa{\endgroup
    \unexpanded{#1}{\expandonce\blx@tempa}}%
  \blx@tempa
  \endgroup}

\def\blx@normrange@ii[#1][#2]#3{%
  \protected\def\blx@range@out@value{#1}%
  \def\blx@range@out@item@process{#2}%
  \let\blx@range@out@delim\@firstofone
  \let\blx@range@split\blx@genrange@split
  \let\blx@range@process\blx@normrange@process
  \blx@range@chunk{#3}%
  \endgroup}

\def\blx@range@chunk#1{%
  \blx@range@chunk@semcol#1;&amp;}

\def\blx@range@chunk@semcol#1;#2&amp;{%
  \notblank{#1}
    {\blx@range@chunk@comma#1,&amp;}
    {}%
  \notblank{#2}
    {\notblank{#1}{\blx@range@out@delim{\bibrangessep}}{}%
     \blx@range@chunk@semcol#2&amp;}
    {}}

\def\blx@range@chunk@comma#1,#2&amp;{%
  \notblank{#1}
    {\blx@range@chunk@sep#1\bibrangessep&amp;}
    {}%
  \notblank{#2}
    {\notblank{#1}{\blx@range@out@delim{\bibrangessep}}{}%
     \blx@range@chunk@comma#2&amp;}
    {}}

\def\blx@range@chunk@sep#1\bibrangessep#2&amp;{%
  \notblank{#1}
    {\expandafter\blx@range@split
     \expandafter{\@firstofone#1}}
    {}%
  \notblank{#2}
    {\notblank{#1}{\blx@range@out@delim{\bibrangessep}}{}%
     \blx@range@chunk@sep#2&amp;}
    {}}

% Unicode en-dashes are supported in blx-unicode.def
\def\blx@genrange@split#1{%
  \protected@edef\blx@normrange@abort{%
    \blx@range@out@value{%
      \blx@range@out@item@process{\unexpanded{#1}}}}%
  \blx@imc@ifpages{#1}
    {\blx@normrange@range#1\bibrangedash\bibrangedash&amp;}
    {\blx@normrange@abort}}

\def\blx@normrange@range#1\bibrangedash#2\bibrangedash#3&amp;{%
  \ifblank{#3}
    {\blx@normrange@hyphen#1--&amp;}
    {\ifblank{#2}
       {\begingroup
        \protected@edef\blx@tempc{\endgroup
          \blx@range@out@value{%
            \blx@range@out@item@process{\unexpanded{#1}}%
            \noexpand\bibrangedash}}%
        \blx@tempc}
       {\ifblank{#1}
          {\begingroup
           \protected@edef\blx@tempc{\endgroup
             \blx@range@out@value{%
               \noexpand\bibrangedash
               \blx@range@out@item@process{%
                 \unexpanded{#2}}}}%
           \blx@tempc}
          {\blx@range@process{#1}{#2}}}}}

\def\blx@normrange@hyphen#1-#2-#3&amp;{%
  \ifblank{#3}
    {\blx@normrange@abort}
    {\ifblank{#2}
       {\ifblank{#1}
          {\let\blx@tempb\@empty}
          {\def\blx@tempb{#1}}%
        \blx@normrange@hyphen@i#3&amp;}
       {\ifblank{#1}
          {\begingroup
           \protected@edef\blx@tempc{\endgroup
             \blx@range@out@value{%
               \noexpand\bibrangedash
               \blx@range@out@item@process{%
                 \unexpanded{#2}}}}%
           \blx@tempc}
          {\blx@range@process{#1}{#2}}}}}

\def\blx@normrange@hyphen@i#1-#2&amp;{%
  \ifblank{#1#2}
    {\begingroup
     \protected@edef\blx@tempc{\endgroup
       \blx@range@out@value{%
         \blx@range@out@item@process{\expandonce\blx@tempb}%
         \noexpand\bibrangedash}}%
     \blx@tempc}
    {\notblank{#1}
       {\ifdefempty\blx@tempb
          {\begingroup
           \protected@edef\blx@tempc{\endgroup
             \blx@range@out@value{%
               \noexpand\bibrangedash
               \blx@range@out@item@process{%
                 \unexpanded{#1}}}}%
           \blx@tempc}
          {\expandafter\blx@range@process
           \expandafter{\blx@tempb}{#1}}}
       {\blx@normrange@hyphen@i#2&amp;}}}

\def\blx@normrange@process#1#2{%
  \begingroup
  \protected@edef\blx@tempc{\endgroup
    \blx@range@out@value{%
      \blx@range@out@item@process{\unexpanded{#1}}%
      \noexpand\bibrangedash
      \blx@range@out@item@process{\unexpanded{#2}}}}%
  \blx@tempc}

% &lt;*&gt;[&lt;postpro&gt;]{&lt;string&gt;}
\newrobustcmd*{\mkcomprange}{%
  \begingroup
  \@ifstar
    {\blx@range@aux\blx@comprange@ii}
    {\blx@range@aux\blx@comprange@i}}

\def\blx@comprange@i[#1][#2]#3{%
  \let\blx@tempa\@empty
  \protected\def\blx@range@out@value{\appto\blx@tempa}%
  \def\blx@range@out@item@process{#2}%
  \let\blx@range@out@delim\blx@range@out@value
  \let\blx@range@split\blx@genrange@split
  \let\blx@range@process\blx@comprange@check
  \blx@range@chunk{#3}%
  \begingroup
  \edef\blx@tempa{\endgroup
    \unexpanded{#1}{\expandonce\blx@tempa}}%
  \blx@tempa
  \endgroup}

\def\blx@comprange@ii[#1][#2]#3{%
  \protected\def\blx@range@out@value{#1}%
  \def\blx@range@out@item@process{#2}%
  \let\blx@range@out@delim\@firstofone
  \let\blx@range@split\blx@genrange@split
  \let\blx@range@process\blx@comprange@check
  \blx@range@chunk{#3}%
  \endgroup}

\def\blx@comprange@check#1#2{%
  \blx@imc@ifinteger{#1}
    {\blx@imc@ifinteger{#2}
       {\@firstoftwo}
       {\@secondoftwo}}
    {\@secondoftwo}
    {\blx@comprange@comp{#1}{#2}}
    {\begingroup
     \protected@edef\blx@tempc{\endgroup
       \blx@range@out@value{%
         \blx@range@out@item@process{\unexpanded{#1}}%
         \noexpand\bibrangedash
         \blx@range@out@item@process{\unexpanded{#2}}}}%
     \blx@tempc}}

\def\blx@comprange@comp#1#2{%
  \def\blx@tempb{#1}%
  \def\blx@tempc{#2}%
  \let\blx@tempd\blx@tempc
  \ifnum\c@maxcomprange&lt;\abx@rangeproclimit\relax
    \numdef\blx@tempe\abx@rangeproclimit
  \else
    \numdef\blx@tempe\c@maxcomprange
  \fi
  \blx@tempcntc=\blx@tempe\relax
  \ifnum
    \ifnum\c@mincompwidth&lt;1\space1\fi
    \ifnum\c@maxcomprange&lt;10\space1\fi
    \ifnum\c@mincomprange&lt;\blx@tempb\space\else1\fi
    \ifnum\blx@tempb&lt;\numexpr\blx@tempcntc*10\relax\else1\fi
  0=\z@
    \expandafter\blx@comprange@comp@div
  \else
    \expandafter\blx@comprange@end
  \fi}

\def\blx@comprange@end{%
  \numdef\blx@tempb\blx@tempb
  \ifnum\blx@tempe&gt;\c@maxcomprange\relax
    \numdef\blx@tempc\blx@tempc
  \else
    \numdef\blx@tempc\blx@tempd
  \fi
  \begingroup
  \protected@edef\blx@tempb{\endgroup
    \blx@range@out@value{%
      \blx@range@out@item@process{\blx@tempb}%
      \noexpand\bibrangedash
      \blx@range@out@item@process{\blx@tempc}}}%
  \blx@tempb}

\def\blx@comprange@comp@div{%
  \unless\ifnum\blx@tempb&lt;\blx@tempcntc
    \blx@tempcnta\blx@tempb\relax
    \blx@tempcntb\blx@tempc\relax
    \divide\blx@tempcnta\blx@tempcntc
    \divide\blx@tempcntb\blx@tempcntc
    \ifnum\blx@tempcnta=\blx@tempcntb
      \edef\blx@tempd{\expandafter\@gobble\blx@tempd}%
      \numdef\blx@tempe\blx@tempcntc
    \fi
  \fi
  \divide\blx@tempcntc10\relax
  \ifnum
    \ifnum\blx@tempcntc&lt;10 1\fi
    \ifnum\blx@tempcntc&gt;\c@mincompwidth\else 1\fi
  0=\z@
    \expandafter\blx@comprange@comp@div
  \else
    \expandafter\blx@comprange@end
  \fi}

% &lt;*&gt;[&lt;postpro&gt;]{&lt;string&gt;}
\newrobustcmd*{\mkfirstpage}{%
  \begingroup
  \@ifstar
    {\blx@range@aux\blx@firstpage@ii}
    {\blx@range@aux\blx@firstpage@i}}

\def\blx@firstpage@i[#1][#2]#3{%
  \let\blx@tempa\@empty
  \protected\def\blx@range@out@value{\appto\blx@tempa}%
  \def\blx@range@out@item@process{#2}%
  \let\blx@range@out@delim\blx@range@out@value
  \let\blx@range@split\blx@firstpage@split
  \blx@range@chunk{#3}%
  \begingroup
  \edef\blx@tempa{\endgroup
    \unexpanded{#1}{\expandonce\blx@tempa}}%
  \blx@tempa
  \endgroup}

\def\blx@firstpage@ii[#1][#2]#3{%
  \protected\def\blx@range@out@value{#1}%
  \def\blx@range@out@item@process{#2}%
  \let\blx@range@out@delim\@firstofone
  \let\blx@range@split\blx@firstpage@split
  \blx@range@chunk{#3}%
  \endgroup}

% Unicode en-dashes are supported in blx-unicode.def
\def\blx@firstpage@split#1{%
  \protected@edef\blx@firstpage@abort{%
    \blx@range@out@value{%
      \blx@range@out@item@process{\unexpanded{#1}}}}%
  \blx@firstpage@range#1\bibrangedash\bibrangedash&amp;}

\def\blx@firstpage@range#1\bibrangedash#2\bibrangedash#3&amp;{%
  \ifblank{#3}
    {\blx@firstpage@hyphen#1--&amp;}
    {\ifblank{#1}
       {\begingroup
        \protected@edef\blx@tempc{\endgroup
          \blx@range@out@value{%
            \noexpand\bibrangedash
            \blx@range@out@item@process{\unexpanded{#2}}}}%
        \blx@tempc}
       {\begingroup
        \protected@edef\blx@tempc{\endgroup
          \blx@range@out@value{%
            \blx@range@out@item@process{\unexpanded{#1}}}}%
        \blx@tempc}}}

\def\blx@firstpage@hyphen#1-#2-#3&amp;{%
  \ifblank{#3}
    {\blx@firstpage@abort}
    {\ifblank{#1}
       {\ifblank{#2}
          {\blx@firstpage@hyphen@i#3&amp;}
          {\begingroup
           \protected@edef\blx@tempc{\endgroup
             \blx@range@out@value{%
               \noexpand\bibrangedash
               \blx@range@out@item@process{%
                 \unexpanded{#2}}}}%
           \blx@tempc}}
       {\begingroup
        \protected@edef\blx@tempc{\endgroup
          \blx@range@out@value{%
            \blx@range@out@item@process{\unexpanded{#1}}}}%
        \blx@tempc}}}

\def\blx@firstpage@hyphen@i#1-#2&amp;{%
  \ifblank{#1}
    {\ifblank{#2}
       {\blx@firstpage@abort}
       {\blx@firstpage@hyphen@i#2&amp;}}
    {\begingroup
     \protected@edef\blx@tempc{\endgroup
       \blx@range@out@value{%
         \noexpand\bibrangedash
         \blx@range@out@item@process{%
           \unexpanded{#1}}}}%
     \blx@tempc}}

\newcommand*{\ppspace}{\addnbspace}
\newcommand*{\sqspace}{\addnbspace}

\newrobustcmd*{\RN}[1]{%
  \begingroup
  \expandafter\RNfont
  \expandafter{\romannumeral#1}%
  \endgroup}
\newrobustcmd*{\Rn}[1]{%
  \begingroup
  \expandafter\Rnfont
  \expandafter{\romannumeral#1}%
  \endgroup}

\newcommand*{\RNfont}{\uppercase}
\newcommand*{\Rnfont}{}

% Delimiter interface

% [&lt;contextname, ...&gt;]{&lt;name&gt;}{&lt;code&gt;}
\newrobustcmd*{\DeclareDelimFormat}{%
  \@ifstar
    {\blx@declaredelimclear}
    {\blx@declaredelim}}

\def\blx@cleardelim#1{%
  \ifcsvoid{blx@declaredelimcontexts@#1}
    {}
    {\def\do##1{\csundef{blx@printdelim@##1@#1}}%
     \dolistcsloop{blx@declaredelimcontexts@#1}}%
  \cslet{blx@declaredelimcontexts@#1}\@empty}

\newrobustcmd*{\blx@declaredelimclear}[3][]{%
  \blx@cleardelim{#2}%
  \ifblank{#1}
    {\blx@declaredelim{#2}{#3}}
    {\blx@declaredelim[{#1}]{#2}{#3}}}

\newrobustcmd*{\blx@declaredelim}[3][]{%
  \ifblank{#1}
    {\blx@declaredelim@i{}{}{#2}{#3}}
    {\def\do##1{%
       \listcsadd{blx@declaredelimcontexts@#2}{##1}%
       \blx@declaredelim@i{blx@printdelim@##1@}{##1}{#2}{#3}}%
     \docsvlist{#1}}}%

\def\blx@declaredelim@i#1#2#3#4{%
  \ifcsdef{#1#3}
    {\blx@inf@delimdeclare{#3}{#2}}
    {}%
  \csdef{#1#3}{#4}}

% [&lt;alias context, ...&gt;]{&lt;alias&gt;}[&lt;delim context&gt;]{&lt;delim&gt;}
% deprecated: *[&lt;alias context, ...&gt;]{&lt;alias&gt;}[&lt;delim context&gt;]{&lt;delim&gt;}
% the starred version is only implemented for backwards compatibility
% the only difference is that a missing first argument
%  implies the global/empty context
\newrobustcmd*{\DeclareDelimAlias}{%
  \@ifstar
    {\blx@declaredelimalias@s}
    {\blx@declaredelimalias@a}}

\def\blx@declaredelimalias@s{%
  \blx@warning{%
    The starred command '\string\DeclareDelimAlias*' is\MessageBreak
    deprecated.%
    \MessageBreak
    Use the unstarred version '\string\DeclareDelimAlias'\MessageBreak
    instead}%
  \@ifnextchar[%]
    {\blx@declaredelimalias@om}
    {\blx@declaredelimalias@om[]}}

\def\blx@declaredelimalias@a{%
  \@ifnextchar[%]
    {\blx@declaredelimalias@om}
    {\blx@declaredelimalias@m}}

\def\blx@declaredelimalias@m#1{%
  \@ifnextchar[%]
    {\blx@declaredelimalias@mom{#1}}
    {\blx@declaredelimalias@mm{#1}}}

\def\blx@declaredelimalias@mm{%
  \blx@declaredelimalias@auto}

\def\blx@declaredelimalias@mom{%
  \blx@declaredelimalias@omom[]}

\def\blx@declaredelimalias@om[#1]#2{%
  \@ifnextchar[%]
    {\blx@declaredelimalias@omom[{#1}]{#2}}
    {\blx@declaredelimalias@omm[{#1}]{#2}}}

% hrmpf ... remember that \docsvlist doesn't do anthing for empty
% lists/list items
\def\blx@declaredelimalias@omom[#1]#2[#3]#4{%
  \ifstrequal{#1}{*}
    {\ifstrequal{#3}{*}
       {\blx@declaredelimalias@auto{#2}{#4}}
       {\blx@cleardelim{#1}%
        \blx@declaredelimalias@manual{}{#2}{#3}{#4}}}
    {\def\do##1{\blx@declaredelimalias@manual{##1}{#2}{#3}{#4}}%
     \ifblank{#1}
       {\do{}}
       {\docsvlist{#1}}}}

\def\blx@declaredelimalias@omm[#1]#2#3{%
  \ifstrequal{#1}{*}
    {\blx@declaredelimalias@auto{#2}{#3}}
    {\def\do##1{\blx@declaredelimalias@manual{##1}{#2}{##1}{#3}}%
     \ifblank{#1}
       {\do{}}
       {\docsvlist{#1}}}}

% {&lt;alias&gt;}{&lt;source&gt;}
\def\blx@declaredelimalias@auto#1#2{%
  \blx@cleardelim{#1}%
  \blx@declaredelimalias@manual{}{#1}{}{#2}%
  \ifcsvoid{blx@declaredelimcontexts@#2}
    {}
    {\def\do##1{%
       \blx@declaredelimalias@manual{##1}{#1}{##1}{#2}}%
     \dolistcsloop{blx@declaredelimcontexts@#2}}}

% {&lt;alias context&gt;}{&lt;alias&gt;}{&lt;source context&gt;}{&lt;source&gt;}
\def\blx@declaredelimalias@manual#1#2#3#4{%
  \begingroup
  \ifblank{#1}
    {\def\blx@tempa{{}{}}}
    {\def\blx@tempa{{blx@printdelim@#1@}{#1}}}%
  \ifblank{#3}
    {\def\blx@tempb{{}{}}}
    {\def\blx@tempb{{blx@printdelim@#3@}{#3}}}%
  \edef\blx@tempc{\endgroup
    \noexpand\blx@declaredelimalias@def%
    \expandonce\blx@tempa {\unexpanded{#2}}%
    \expandonce\blx@tempb {\unexpanded{#4}}}%
  \blx@tempc}

% {&lt;alias context internal id&gt;}{&lt;alias context name&gt;}{&lt;alias&gt;}
% {&lt;source context internal id&gt;}{&lt;source context name&gt;}{&lt;source&gt;}
\def\blx@declaredelimalias@def#1#2#3#4#5#6{%
  \ifcsdef{#1#3}
    {\blx@inf@delimdeclare{#3}{#2}}
    {}%
  \ifblank{#2}
    {}
    {\ifinlistcs{#2}{blx@declaredelimcontexts@#3}
       {}
       {\listcsadd{blx@declaredelimcontexts@#3}{#2}}}%
  \csdef{#1#3}{\ifcsundef{#4#6}{\csuse{#6}}{\csuse{#4#6}}}}

\def\blx@delimcontext{none}
\newcommand*{\printdelim}[2][]{%
  \ifblank{#1}
    {\ifcsdef{blx@printdelim@\blx@delimcontext @#2}
      {\csuse{blx@printdelim@\blx@delimcontext @#2}}
      {\ifcsdef{#2}% fall back on legacy macros
        {\csuse{#2}}
        {\blx@warn@delimuse{#2}{*}}}}
    {\ifcsdef{blx@printdelim@#1@#2}
      {\csuse{blx@printdelim@#1@#2}}
      {\blx@warn@delimuse{#2}{#1}}}}

\newcommand*{\delimcontext}[1]{%
  \edef\blx@delimcontext{\blx@delimcontextalias{#1}}}

\def\blx@delimcontextalias#1{%
  \ifcsdef{blx@delimcontextalias@#1}
    {\csuse{blx@delimcontextalias@#1}}
    {#1}}

\newcommand*{\DeclareDelimcontextAlias}[2]{%
  \csdef{blx@delimcontextalias@#1}{#2}}

\newcommand*{\UndeclareDelimcontextAlias}[1]{%
  \csundef{blx@delimcontextalias@#1}}

\newrobustcmd*{\AtUsedriver}{%
  \@ifstar
    {\global\undef\blx@hook@usedriver
     \gappto\blx@hook@usedriver}
    {\gappto\blx@hook@usedriver}}
\@onlypreamble\AtUsedriver
\def\blx@imc@UseUsedriverHook{\csuse{blx@hook@usedriver}}
\blx@regimcs{\UseUsedriverHook}

\AtUsedriver{%
  \delimcontext{bib}%
  \let\finentry\blx@finentry@usedrv
  \let\newblock\relax
  \let\abx@macro@bibindex\@empty
  \let\abx@macro@pageref\@empty}

% {&lt;init&gt;}{&lt;entrytype&gt;}
\protected\def\blx@imc@usedriver#1#2{%
  \begingroup
  \csuse{blx@hook@usedriver}%
  \csuse{blx@hook@bbxinit}#1%
  \blx@beglangbib
  \blx@driver{#2}%
  \blx@endlangbib
  \endgroup}

% Punctuation

\protected\def\blx@initunit{%
  \global\togglefalse{blx@block}%
  \global\togglefalse{blx@unit}%
  \global\togglefalse{blx@insert}%
  \global\togglefalse{blx@lastins}%
  \global\togglefalse{blx@keepunit}%
  \global\let\blx@unitpunct\newunitpunct
  \blx@imc@resetpunctfont}

\def\blx@begunit{%
  \toggletrue{blx@tempa}%
  \iftoggle{blx@insert}
    {\iftoggle{blx@unit}
       {\begingroup
          \let\blx@begunit\@empty
          \let\blx@endunit\@empty
          \let\blx@endnounit\@empty
          \blx@unitpunct\blx@postpunct
        \endgroup
        \global\togglefalse{blx@unit}%
        \togglefalse{blx@tempa}}
       {\blx@postpunct}%
     \iftoggle{blx@block}
       {\begingroup
          \let\blx@begunit\@empty
          \let\blx@endunit\@empty
          \let\blx@endnounit\@empty
          \newblockpunct
        \endgroup
        \global\togglefalse{blx@block}%
        \togglefalse{blx@tempa}}
       {}}
    {}%
  \blx@postpunct
  \blx@imc@resetpunctfont
  \iftoggle{blx@tempa}
    {}
    {\global\togglefalse{blx@insert}}%
  \blx@leavevmode
  \begingroup}

\def\blx@endunit{%
  \endgroup
  \global\toggletrue{blx@insert}%
  \global\toggletrue{blx@lastins}}

\def\blx@nounit{%
  \global\togglefalse{blx@lastins}}

\def\blx@endnounit{%
  \endgroup\blx@nounit}

\protected\def\blx@imc@newblock{%
  \global\toggletrue{blx@block}}%

\protected\def\blx@imc@newunit{%
  \iftoggle{blx@keepunit}
    {}
    {\global\let\blx@unitpunct\newunitpunct
     \global\toggletrue{blx@unit}}}

\protected\def\blx@imc@setunit{%
  \@ifstar\blx@setunit@i\blx@setunit}

\long\def\blx@setunit#1{%
  \iftoggle{blx@keepunit}
    {}
    {\long\gdef\blx@unitpunct{#1}%
     \global\toggletrue{blx@unit}}}

\def\blx@setunit@i{%
  \iftoggle{blx@lastins}
    {\blx@setunit}
    {\@gobble}}

\protected\def\blx@imc@printunit{%
  \@ifstar\blx@printunit@i\blx@printunit}

\def\blx@printunit#1{%
  \long\gdef\blx@unitpunct{#1\global\togglefalse{blx@keepunit}}%
  \global\toggletrue{blx@keepunit}%
  \global\toggletrue{blx@unit}}

\def\blx@printunit@i{%
  \iftoggle{blx@lastins}
    {\blx@printunit}
    {\@gobble}}

\protected\def\blx@imc@finentry{%
  \unspace\finentrypunct
  \blx@postpunct
  \blx@initunit}

\protected\def\blx@finentry@usedrv{%
  \blx@setunit\relax}

\protected\def\blx@finentry@inset{%
  \blx@setunit\entrysetpunct
  \global\toggletrue{blx@block}}

\def\ifentryseen{\blx@imc@ifentryseen}
\def\ifentryinbib{\blx@imc@ifentryinbib}
\def\ifentrycategory{\blx@imc@ifentrycategory}
\def\ifentrykeyword{\blx@imc@ifentrykeyword}


\def\blx@imc@iflabeldateisdate{%
  \iftoggle{blx@labeldateparts}
    {\iffieldundef{labeldatesource}
       {\@secondoftwo}
       {\iffieldequalstr{labeldatesource}{}
          {\@firstoftwo}
          {\iffieldequalstr{labeldatesource}{year}}}}
    {\@secondoftwo}}


\def\blx@imc@ifdatehasyearonlyprecision#1{%
  \iffieldundef{#1year}
    {\@secondoftwo}
    {\ifcsstring{blx@dateformat@#1date}{year}
       {\@firstoftwo}
       {\iffieldundef{#1month}
          {\iffieldundef{#1yeardivision}}
          {\@secondoftwo}}}}

\def\blx@imc@ifdatehastime#1{%
  \iftoggle{blx@#1dateusetime}
    {\iffieldundef{#1hour}
       {\@secondoftwo}
       {\@firstoftwo}}
    {\@secondoftwo}}

\def\blx@imc@ifdateshavedifferentprecision#1#2{%
  \ifboolexpr{   (        test {\ifdatehasyearonlyprecision{#1}}
                  and not test {\ifdatehasyearonlyprecision{#2}})
              or (    not test {\ifdatehasyearonlyprecision{#1}}
                  and     test {\ifdatehasyearonlyprecision{#2}})
              or (        test {\ifdatehastime{#1}}
                  and not test {\ifdatehastime{#2}})
              or (    not test {\ifdatehastime{#1}}
                  and     test {\ifdatehastime{#2}})}}

\def\blx@imc@ifdateyearsequal#1#2{%
  \iffieldsequal{#1year}{#2year}
    {\iffieldundef{#1dateera}
       {\iffieldundef{#2dateera}}
       {\iffieldsequal{#1dateera}{#2dateera}}}
    {\@secondoftwo}}

\def\blx@reconstruct@comparabledate#1{%
  \thefield{#1year}-\thefield{#1month}(\thefield{#1yeardivision})-%
    \thefield{#1day}T%
  \thefield{#1hour}:\thefield{#1minute}:\thefield{#1second}Z%
    \thefield{#1timezone}//%
  e\thefield{#1dateera}E%
  c\csuse{if#1datecirca}{T}{F}%
  j\csuse{if#1datejulian}{T}{F}%
  r\csuse{if#1dateuncertain}{T}{F}%
  k\csuse{if#1dateunknown}{T}{F}%
}

\def\blx@imc@ifdatesequal#1#2{%
  \begingroup
    \edef\blx@tempa{\blx@reconstruct@comparabledate{#1}}%
    \edef\blx@tempb{\blx@reconstruct@comparabledate{#2}}%
    \edef\blx@tempc{\endgroup
      \ifstrequal{\blx@tempa}{\blx@tempb}}%
  \blx@tempc
}

\def\blx@imc@ifdaterangesequal#1#2{%
  \blx@imc@ifdatesequal{#1}{#2}
    {\blx@imc@ifdatesequal{#1end}{#2end}}
    {\@secondoftwo}}

\blx@regimcs{%
  \ifdriver \thefield \strfield \csfield \usefield \thelist \strlist
  \thefirstlistitem \usefirstlistitem \strfirstlistitem
  \thename \strname
  \clearfield \clearlist \clearname \restorefield \restorelist \restorename
  \ifcategory \ifkeyword
  \ifciteseen  \ifciteibid \ifciteidem \ifopcit \ifloccit
  \ifcurrentfield \ifcurrentlist \ifcurrentname \ifentrytype
  \iffieldequalcs \iffieldequals \iffieldequalstr \iffieldsequal
  \iffieldundef \iffieldxref \iflistequalcs \iflistequals
  \iflistsequal \iflistundef \iflistxref
  \ifmorenames \ifmoreitems \iffirstcitekey \iflastcitekey
  \ifnameequalcs \ifnameequals \ifnamesequal \ifnameundef \ifnamexref
  \iffirstonpage \ifsamepage \savefield \savefieldcs \savelist
  \savelistcs \savename \savenamecs \usedriver
  \ifinteger \hascomputableequivalent \ifiscomputable \getcomputableequivalent
  \ifnumeral \ifnumerals \ifpages
  \iffieldint \fieldhascomputableequivalent \iffieldiscomputable
  \iffieldnum \iffieldnums \iffieldpages
  \iflabeldateisdate \ifdatehasyearonlyprecision \ifdatehastime
  \ifdateshavedifferentprecision
  \ifdateyearsequal \ifdatesequal \ifdaterangesequal
  \mkpageprefix \mkpagetotal
  \newblock \newunit \setunit \printunit \finentry}

\appto\blx@blxinit{%
  \def\ifnatbibmode{\iftoggle{blx@natbib}}%
  \def\ifcitation{\iftoggle{blx@citation}}%
  \def\ifvolcite{\iftoggle{blx@volcite}}%
  \def\ifbibliography{\iftoggle{blx@bibliography}}%
  \def\ifciteindex{\iftoggle{blx@citeindex}}%
  \def\ifbibindex{\iftoggle{blx@bibindex}}%
  \def\iffootnote{\iftoggle{blx@footnote}}%
  \def\ifuseprefix{\iftoggle{blx@useprefix}}%
  \def\ifterseinits{\iftoggle{blx@terseinits}}%
  \def\ifcrossrefsource{\iftoggle{abx@bool@crossrefsource}}%
  \def\ifxrefsource{\iftoggle{abx@bool@xrefsource}}%
  \def\ifsingletitle{\iftoggle{abx@bool@singletitle}}%
  \def\ifnocite{\iftoggle{abx@bool@nocite}}%
  \def\ifuniquetitle{\iftoggle{abx@bool@uniquetitle}}%
  \def\ifuniquebaretitle{\iftoggle{abx@bool@uniquebaretitle}}%
  \def\ifuniquework{\iftoggle{abx@bool@uniquework}}%
  \def\ifuniqueprimaryauthor{\iftoggle{abx@bool@uniqueprimaryauthor}}%
  \def\ifandothers#1{\iftoggle{abx@bool@more#1}}%
  \protected\def\pnfmt{\printtext[postnote]}%
  \protected\def\pno{\bibstring{page}}%
  \protected\def\ppno{\bibstring{pages}}%
  \let\nopp\relax
  \protected\def\psq{\sqspace\bibstring{sequens}}%
  \protected\def\psqq{\sqspace\bibstring{sequentes}}}

% Make sure that commands which might pop up inside an \edef will be defined
% as something. If they are taken \AtBeginDocument then we assume that all will
% be well. If not, then provide a definition which will give an error outside
% of a citation context.
\AtBeginDocument{%
  \protected\def\do#1{%
    \ifdefined#1%
    \else
      \protected\def#1{\ERROR}%
    \fi
  }%
  \docsvlist{\pnfmt,\pno,\ppno,\nopp,\psq,\psqq}%
}

%% Global formatting hooks

%% Main formatting commands
% They work by creating a \let alias:
% \abx@&lt;class&gt;@&lt;entrytype&gt;@&lt;formatname&gt; -&gt; \blx@defformat@d
% for later use in \print*
% Then, \blx@defformat@d is defined by calling
% \def\blx@defformat@d#1{format body}

% [&lt;entrytype&gt;]{&lt;name&gt;}{&lt;definiton&gt;}
\newrobustcmd*{\DeclareNameFormat}{%
  \@ifstar
    {\blx@defformat\blx@defnameformat{nfd}*}
    {\blx@defformat\blx@defnameformat{nfd}{}}}

\newrobustcmd*{\DeclareIndexNameFormat}{%
  \@ifstar
    {\blx@defformat\blx@defnameformat{nid}*}
    {\blx@defformat\blx@defnameformat{nid}{}}}

\newrobustcmd*{\DeclareListFormat}{%
  \@ifstar
    {\blx@defformat\blx@defplainformat{lfd}*}
    {\blx@defformat\blx@defplainformat{lfd}{}}}
\newrobustcmd*{\DeclareIndexListFormat}{%
  \@ifstar
    {\blx@defformat\blx@defplainformat{lid}*}
    {\blx@defformat\blx@defplainformat{lid}{}}}

\newrobustcmd*{\DeclareFieldFormat}{%
  \@ifstar
    {\blx@defformat\blx@defplainformat{ffd}*}
    {\blx@defformat\blx@defplainformat{ffd}{}}}
\newrobustcmd*{\DeclareIndexFieldFormat}{%
  \@ifstar
    {\blx@defformat\blx@defplainformat{fid}*}
    {\blx@defformat\blx@defplainformat{fid}{}}}

\newrobustcmd*{\DeclareNameWrapperFormat}{%
  \@ifstar
    {\blx@defformat\blx@defnameformat{nwd}*}
    {\blx@defformat\blx@defnameformat{nwd}{}}}

\newrobustcmd*{\DeclareListWrapperFormat}{%
  \@ifstar
    {\blx@defformat\blx@defplainformat{lwd}*}
    {\blx@defformat\blx@defplainformat{lwd}{}}}

% {&lt;macro&gt;}{&lt;class&gt;}{&lt;*&gt;}
\def\blx@defformat#1#2#3{%
  \@ifnextchar[%]
    {\blx@defformat@i{#1}{#2}{#3}}
    {\blx@defformat@i{#1}{#2}{#3}[*]}}

% {&lt;macro&gt;}{&lt;class&gt;}{&lt;*&gt;}[&lt;entrytype&gt;]{&lt;name&gt;}
\def\blx@defformat@i#1#2#3[#4]#5{%
  \notblank{#3}
    {\blx@resetformat{#2}{#5}}
    {}%
  \def\blx@defformat@a{#2}%
  \def\blx@defformat@b{#4}%
  \blx@xsanitizeafter{\def\blx@defformat@c}{#5}%
  \afterassignment\blx@defformat@ii
  #1}

\def\blx@defformat@ii{%
  \expandafter\forcsvlist
  \expandafter\blx@defformat@iii
  \expandafter{\blx@defformat@b}}

\def\blx@defformat@iii#1{%
  \cslet{abx@\blx@defformat@a @#1@\blx@defformat@c}\blx@defformat@d}

% grab the argument explicitly, this avoids issues with spaces making it
% into the argument specification of the macros
% cf. \def\foo#1{&lt;stuff&gt;} vs. \def\foo#1 {&lt;stuff&gt;}
\long\def\blx@defplainformat#1{%
  \long\def\blx@defformat@d##1{#1}}

\long\def\blx@defnameformat#1{%
  \long\def\blx@defformat@d##1{#1}}

\def\blx@resetformat#1#2{%
  \let\blx@saved@do\do
  \def\do##1{\blx@resetformat@i{#1}{#2}{##1}}%
  \blx@safe@actives
  \abx@doentrytypes
  \blx@rest@actives
  \let\do\blx@saved@do}

\def\blx@resetformat@i#1#2#3{%
  \ifcsdef{abx@#1@#3@#2}
    {\csundef{abx@#1@#3@#2}}
    {}}

% {&lt;name&gt;}{&lt;name&gt;}
\def\blx@letformat#1#2{%
  \blx@safe@actives
  \afterassignment\blx@rest@actives
  \csletcs{#1}{#2}}

% [aliastype]{aliasname}[formattype]{formatname}
\def\blx@defalias#1{%
  \@ifnextchar[%]
    {\blx@defalias@i{#1}}
    {\blx@defalias@i{#1}[*]}}
\def\blx@defalias@i#1[#2]#3{%
  \@ifnextchar[%]
    {\blx@defalias@ii{#1}{#2}{#3}}
    {\blx@defalias@ii{#1}{#2}{#3}[*]}}
\def\blx@defalias@ii#1#2#3[#4]#5{%
  \blx@safe@actives
  \afterassignment\blx@rest@actives
  \csedef{abx@#1@#2@#3}{%
    \expandonce{\csname abx@#1@#4@#5\endcsname}}}



% {&lt;macro&gt;}{&lt;class&gt;}{&lt;name&gt;}{&lt;field&gt;}
\def\blx@getformat#1#2#3#4{%
  \blx@safe@actives
  \afterassignment\blx@rest@actives
  \ifcsundef{abx@#2@\blx@imc@thefield{entrytype}@#3}
    {\ifcsundef{abx@#2@*@#3}
       {\ifcsundef{abx@#2@\blx@imc@thefield{entrytype}@#4}
          {\ifcsundef{abx@#2@*@#4}
             {\letcs#1{abx@#2@*@default}}
             {\letcs#1{abx@#2@*@#4}}}
          {\letcs#1{abx@#2@\blx@imc@thefield{entrytype}@#4}}}
       {\letcs#1{abx@#2@*@#3}}}
    {\letcs#1{abx@#2@\blx@imc@thefield{entrytype}@#3}}}

% [&lt;entrytype&gt;]{&lt;name&gt;}
\newrobustcmd*{\savefieldformat}[2][*]{\blx@save{abx@ffd@#1@#2}}
\newrobustcmd*{\savelistformat}[2][*]{\blx@save{abx@lfd@#1@#2}}
\newrobustcmd*{\savenameformat}[2][*]{\blx@save{abx@nfd@#1@#2}}
\newrobustcmd*{\savelistwrapperformat}[2][*]{\blx@save{abx@lwd@#1@#2}}
\newrobustcmd*{\savenamewrapperformat}[2][*]{\blx@save{abx@nwd@#1@#2}}

\newrobustcmd*{\restorefieldformat}[2][*]{\blx@restore{abx@ffd@#1@#2}}
\newrobustcmd*{\restorelistformat}[2][*]{\blx@restore{abx@lfd@#1@#2}}
\newrobustcmd*{\restorenameformat}[2][*]{\blx@restore{abx@nfd@#1@#2}}
\newrobustcmd*{\restorelistwrapperformat}[2][*]{\blx@restore{abx@lwd@#1@#2}}
\newrobustcmd*{\restorenamewrapperformat}[2][*]{\blx@restore{abx@nwd@#1@#2}}

% [&lt;entrytype&gt;]{&lt;name&gt;}{&lt;true&gt;}{&lt;false&gt;}
\newrobustcmd*{\iffieldformatundef}[2][*]{\ifcsundef{abx@ffd@#1@#2}}
\newrobustcmd*{\iflistformatundef}[2][*]{\ifcsundef{abx@lfd@#1@#2}}
\newrobustcmd*{\ifnameformatundef}[2][*]{\ifcsundef{abx@nfd@#1@#2}}
\newrobustcmd*{\iflistwrapperformatundef}[2][*]{\ifcsundef{abx@lwd@#1@#2}}
\newrobustcmd*{\ifnamewrapperformatundef}[2][*]{\ifcsundef{abx@nwd@#1@#2}}

% [&lt;entrytype&gt;]{&lt;alias&gt;}[&lt;entrytype&gt;]{&lt;name&gt;}
\newrobustcmd*{\DeclareNameAlias}{\blx@defalias{nfd}}
\newrobustcmd*{\DeclareIndexNameAlias}{\blx@defalias{nid}}

\newrobustcmd*{\DeclareListAlias}{\blx@defalias{lfd}}
\newrobustcmd*{\DeclareIndexListAlias}{\blx@defalias{lid}}

\newrobustcmd*{\DeclareFieldAlias}{\blx@defalias{ffd}}
\newrobustcmd*{\DeclareIndexFieldAlias}{\blx@defalias{fid}}

\newrobustcmd*{\DeclareNameWrapperAlias}{\blx@defalias{nwd}}

\newrobustcmd*{\DeclareListWrapperAlias}{\blx@defalias{lwd}}

% #1: internal type signature, #2: type text for warning
%      #3         #4         #5          #6
% [aliastype]{aliasname}[formattype]{formatname}
\def\blx@deprecateformat#1#2{%
  \@ifnextchar[%]
    {\blx@deprecateformat@i{#1}{#2}}
    {\blx@deprecateformat@i{#1}{#2}[*]}}
\def\blx@deprecateformat@i#1#2[#3]#4{%
  \@ifnextchar[%]
    {\blx@deprecateformat@ii{#1}{#2}{#3}{#4}}
    {\blx@deprecateformat@ii{#1}{#2}{#3}{#4}[*]}}
\def\blx@deprecateformat@ii#1#2#3#4[#5]#6{%
  \blx@safe@actives
  \afterassignment\blx@rest@actives
  \csdef{abx@#1@#3@#4}{%
    \ifcsundef{abx@legacywarning@#1@#3@#4}
      {\global\cslet{abx@legacywarning@#1@#3@#4}\@empty
       \blx@warning@noline{%
         #2 '#4' deprecated.\MessageBreak
         Please use '#6' instead.\MessageBreak
         Using '#6' now}}
      {}%
    \csname abx@#1@#5@#6\endcsname}}

% [&lt;entrytype&gt;]{&lt;alias&gt;}[&lt;entrytype&gt;]{&lt;name&gt;}
\newrobustcmd*{\DeprecateNameFormatWithReplacement}{%
  \blx@deprecateformat{nfd}{Name format}}
\newrobustcmd*{\DeprecateIndexNameFormatWithReplacement}{%
  \blx@deprecateformat{nid}{Index name format}}

\newrobustcmd*{\DeprecateListFormatWithReplacement}{%
  \blx@deprecateformat{lfd}{List format}}
\newrobustcmd*{\DeprecateIndexListFormatWithReplacement}{%
  \blx@deprecateformat{lid}{Index list format}}

\newrobustcmd*{\DeprecateFieldFormatWithReplacement}{%
  \blx@deprecateformat{ffd}{Field format}}
\newrobustcmd*{\DeprecateIndexFieldFormatWithReplacement}{%
  \blx@deprecateformat{fid}{Index field format}}

\newrobustcmd*{\DeprecateNameWrapperFormatWithReplacement}{%
  \blx@deprecateformat{nwd}{Name wrapper format}}

\newrobustcmd*{\DeprecateListWrapperFormatWithReplacement}{%
  \blx@deprecateformat{lwd}{List wrapper format}}

% [&lt;format&gt;]{&lt;text&gt;}
\newrobustcmd{\blx@imc@printtext}[2][]{%
  \ifblank{#2}
    {\blx@nounit}
    {\ifblank{#1}
       {\let\blx@theformat\@firstofone}
       {\blx@getformat\blx@theformat{ffd}{#1}{}}%
     \ifdefvoid\blx@theformat
       {\blx@nounit}
       {\blx@begunit
        \blx@theformat{#2}%
        \blx@endunit}}}

% [&lt;format&gt;]{&lt;field&gt;}
\newrobustcmd*{\blx@imc@printfield}[2][]{%
  \blx@imc@iffieldundef{#2}
    {\blx@nounit}
    {\blx@getformat\blx@theformat{ffd}{#1}{#2}%
     \ifdefvoid\blx@theformat
       {\blx@nounit}
       {\blx@begunit
        \edef\currentfield{#2}%
        \expandafter\expandafter
        \expandafter\blx@theformat
        \expandafter\expandafter
        \expandafter{\csname abx@field@#2\endcsname}%
        \blx@endunit}}}

% [&lt;format&gt;]{&lt;field&gt;}
\newcommand*{\blx@imc@indexfield}[2][]{%
  \blx@imc@iffieldundef{#2}
    {}
    {\blx@getformat\blx@theformat{fid}{#1}{#2}%
     \ifdefvoid\blx@theformat
       {}
       {\begingroup
        \edef\currentfield{#2}%
        \letcs\blx@tempa{abx@field@#2}%
        \expandafter\blx@theformat\expandafter{\blx@tempa}%
        \endgroup}}}

% [&lt;format&gt;]{&lt;file&gt;}
\newrobustcmd*{\blx@imc@printfile}[2][]{%
  \iftoggle{blx@loadfiles}
    {\IfFileExists{#2}
       {\listxadd\blx@list@req@edit{#2}%
        \blx@imc@printtext[{#1}]{\input{#2}\unspace}}
       {\blx@nounit}}
    {\blx@nounit}}

% {&lt;macro&gt;}[&lt;format&gt;][&lt;start&gt;-&lt;stop&gt;]
% =&gt; &lt;macro&gt;{&lt;format&gt;}{&lt;start&gt;}{&lt;stop&gt;}
\def\blx@listargs#1{%
  \@ifnextchar[%]
    {\blx@listargs@i{#1}}
    {#1{}{}{}}}

\def\blx@listargs@i#1[#2]{%
  \@ifnextchar[%]
    {\blx@listargs@ii{#1}{#2}}
    {#1{#2}{}{}}}

\def\blx@listargs@ii#1#2[#3]{%
  \blx@listargs@iii{#1}{#2}#3&amp;}

\def\blx@listargs@iii#1#2#3-#4&amp;{%
  #1{#2}{#3}{#4}}

% [&lt;format&gt;][&lt;start&gt;-&lt;stop&gt;]{&lt;namelist&gt;}
\protected\def\blx@imc@printnames{%
  \blx@listargs\blx@printnames}

% {&lt;format&gt;}{&lt;start&gt;}{&lt;stop&gt;}{&lt;namelist&gt;}
\def\blx@printnames#1#2#3#4{%
  \blx@imc@ifnameundef{#4}
    {\blx@nounit}
    {\blx@getformat\blx@thewrapperformat{nwd}{#1}{#4}%
     \ifdefvoid\blx@thewrapperformat
       {\blx@nounit}
       {\blx@getformat\blx@theformat{nfd}{#1}{#4}%
        \ifdefvoid\blx@theformat
          {\blx@nounit}
          {\blx@begunit
           \blx@namesetup{#2}{#3}{#4}%
           \blx@thewrapperformat{\expandafter\blx@nameparser\blx@thedata{}&amp;}%
           \blx@endunit}}}}

\def\blx@namesetup#1#2#3{%
  \def\currentname{#3}%
  \c@listcount\@ne
  \c@listtotal\csname c@#3\endcsname
  \blx@namesetup@i{#3}%
  \ifblank{#1}
    {\c@liststart\@ne}
    {\ifnum#1&lt;\@ne
       \c@liststart\@ne
     \else
       \c@liststart#1\relax
     \fi}%
  \ifblank{#2}
    {\c@liststop\c@listtotal
     \ifnum\c@liststop&gt;\c@maxnames
       \c@liststop\c@minnames
       \ifnum\c@uniquelist&gt;\c@liststop
         \c@liststop\c@uniquelist
       \fi
     \fi}
    {\ifnum#2&gt;\c@listtotal
       \c@liststop\c@listtotal
     \else
       \ifnum#2&lt;\@ne
         \c@liststop\@ne
       \else
         \c@liststop#2\relax
       \fi
     \fi}%
  \ifboolexpr{test {\iftoggle{blx@pluralothers}}
              and
              test {\ifnumcomp{\value{listtotal}-\value{liststop}}{=}{1}}}
    {\c@liststop\c@listtotal}
    {}%
  \blx@namecodes}

\def\blx@namesetup@i#1{%
  \expandafter\expandafter
  \expandafter\blx@namesetup@ii\csname abx@name@#1\endcsname}

\def\blx@namesetup@ii#1#2{%
  \c@uniquelist\z@
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@opt@namelist}{#1}}%
  \def\blx@thedata{#2}}

% Biber-calculated info passed back to biblatex as an option in the .bbl
% unlike stuff defined with \DeclareBiblatexOption and
% \blx@DeclareBackendOption these are not 'real' options
\blx@kv@defkey{blx@opt@namelist}{ul}{\c@uniquelist#1\relax}

\blx@kv@defkey{blx@opt@name}{un}{\c@uniquename#1\relax}
\blx@kv@defkey{blx@opt@name}{uniquepart}{\def\abx@field@uniquepart{#1}}
\blx@kv@defkey{blx@opt@name}{hash}{\edef\abx@field@hash{\detokenize{#1}}}


\newrobustcmd*{\bibinitperiod}{\adddot}
\newrobustcmd*{\bibinitdelim}{\addnbspace}
\newrobustcmd*{\bibinithyphendelim}{.\mbox{-}}
\newrobustcmd*{\bibnamedelima}{\addhighpenspace}
\newrobustcmd*{\bibnamedelimb}{\addlowpenspace}
\newrobustcmd*{\bibnamedelimc}{\addhighpenspace}
\newrobustcmd*{\bibnamedelimd}{\addlowpenspace}
\newrobustcmd*{\bibnamedelimi}{\isdot\addnbspace}

% [&lt;format&gt;][&lt;start&gt;-&lt;stop&gt;]{&lt;namelist&gt;}
\protected\def\blx@imc@indexnames{%
  \blx@listargs\blx@indexnames}

% {&lt;format&gt;}{&lt;start&gt;}{&lt;stop&gt;}{&lt;namelist&gt;}
\def\blx@indexnames#1#2#3#4{%
  \blx@imc@ifnameundef{#4}
    {}
    {\blx@getformat\blx@theformat{nid}{#1}{#4}%
     \ifdefvoid\blx@theformat
       {}
       {\begingroup
        \blx@namesetup{#2}{#3}{#4}%
        \blx@indexnamesetup
        \expandafter\blx@nameparser\blx@thedata{}&amp;%
        \endgroup}}}


\def\blx@indexnamesetup{%
  \let\bibinitperiod\bibindexinitperiod
  \let\bibinitdelim\bibindexinitdelim
  \let\bibinithyphendelim\bibindexinithyphendelim
  \let\bibnamedelima\bibindexnamedelima
  \let\bibnamedelimb\bibindexnamedelimb
  \let\bibnamedelimc\bibindexnamedelimc
  \let\bibnamedelimd\bibindexnamedelimd
  \let\bibnamedelimi\bibindexnamedelimi}

% {&lt;name1&gt;}{&lt;name2&gt;}{...}
\long\def\blx@nameparser#1{%
  \ifblank{#1}
    {\blx@namebreak}
    {\ifnum\c@listcount&lt;\c@liststart
     \else
       \blx@nameparser@i#1%
     \fi
     \advance\c@listcount\@ne
     \ifnum\c@listcount&gt;\c@liststop
       \expandafter\blx@namebreak
     \fi
     \blx@nameparser}}

% {name opts}{nameparts}
\long\def\blx@nameparser@i#1#2{%
  \begingroup
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@opt@name}{#1}}%
  % reset all the nameparts to empty between names
  \def\do##1{%
    \cslet{namepart##1}\@empty
    \cslet{namepart##1i}\@empty}%
  \expandafter\docsvlist\expandafter{\blx@datamodel@constant@nameparts}%
  \blx@kv@setkeys{blx@opt@namepart}{#2}% Extract nameparts information
  % Still pass the nameparts forward for backwards compat
  % When \nameparts is finally removed, remove the "{2}" and remove the
  % arg to \blx@defformat@d in def of \blx@defnameformat
  \blx@theformat{#2}%
  \endgroup}

\long\def\blx@namebreak#1&amp;{}

% [&lt;format&gt;][&lt;start&gt;-&lt;stop&gt;]{&lt;plainlist&gt;}
\protected\def\blx@imc@printlist{%
  \blx@listargs\blx@printlist}

% {&lt;format&gt;}{&lt;start&gt;}{&lt;stop&gt;}{&lt;plainlist&gt;}
\def\blx@printlist#1#2#3#4{%
  \blx@imc@iflistundef{#4}
    {\blx@nounit}
    {\blx@getformat\blx@thewrapperformat{lwd}{#1}{#4}%
     \ifdefvoid\blx@thewrapperformat
       {\blx@nounit}
       {\blx@getformat\blx@theformat{lfd}{#1}{#4}%
        \ifdefvoid\blx@theformat
          {\blx@nounit}
          {\blx@begunit
           \blx@listsetup{#2}{#3}{#4}%
           \blx@thewrapperformat{\expandafter\blx@listparser\blx@thedata{}&amp;}%
           \blx@endunit}}}}

\def\blx@listsetup#1#2#3{%
  \def\currentlist{#3}%
  \c@listcount\@ne
  \expandafter\c@listtotal\csname c@#3\endcsname
  \letcs\blx@thedata{abx@list@#3}%
  \ifblank{#1}
    {\c@liststart\@ne}
    {\ifnum#1&lt;\@ne
       \c@liststart\@ne
     \else
       \c@liststart#1\relax
     \fi}%
  \ifblank{#2}
    {\c@liststop\c@listtotal
     \ifnum\c@listtotal&gt;\c@maxitems
       \c@liststop\c@minitems
     \fi}
    {\ifnum#2&gt;\c@listtotal
       \c@liststop\c@listtotal
     \else
       \ifnum#2&lt;\@ne
         \c@liststop\@ne
       \else
         \c@liststop#2\relax
       \fi
     \fi}}

% [&lt;format&gt;][&lt;start&gt;-&lt;stop&gt;]{&lt;plainlist&gt;}
\protected\def\blx@imc@indexlist{%
  \blx@listargs\blx@indexlist}

% {&lt;format&gt;}{&lt;start&gt;}{&lt;stop&gt;}{&lt;plainlist&gt;}
\def\blx@indexlist#1#2#3#4{%
  \blx@imc@iflistundef{#4}
    {}
    {\blx@getformat\blx@theformat{lid}{#1}{#4}%
     \ifdefvoid\blx@theformat
       {}
       {\begingroup
        \blx@listsetup{#2}{#3}{#4}%
        \expandafter\blx@listparser\blx@thedata{}&amp;%
        \endgroup}}}

% {&lt;item1&gt;}{&lt;item2&gt;}{...}
\long\def\blx@listparser#1{%
  \ifblank{#1}
    {\blx@listbreak}
    {\ifnum\c@listcount&lt;\c@liststart
     \else
       \blx@theformat{#1}%
     \fi
     \advance\c@listcount\@ne
     \ifnum\c@listcount&gt;\c@liststop
       \expandafter\blx@listbreak
     \fi
     \blx@listparser}}

\long\def\blx@listbreak#1&amp;{}

% &lt;*&gt;{&lt;key&gt;}{&lt;code&gt;}
\protected\def\blx@imc@entrydata{%
  \@ifstar
    {\blx@xsanitizeafter{\blx@imc@entrydata@i\blx@saveentry}}
    {\blx@xsanitizeafter{\blx@imc@entrydata@i{}}}}

\long\def\blx@imc@entrydata@i#1#2#3{%
  \blx@getrefcontext{#2}%
  \blx@ifdata{#2}
    {\begingroup
     #1%
     \blx@resetdata
     \blx@getdata{#2}%
     \blx@entrysetcount
     \blx@setoptions@type\abx@field@entrytype
     \blx@setoptions@entry
     \addtocounter{instcount}\@ne
     \blx@execute
     \blx@beglangbib#3\blx@endlangbib
     \endgroup}
    {}}

\protected\def\blx@imc@entryset#1#2{%
  \blx@imc@iffieldundef{entrykey}
    {}
    {\begingroup
     \long\def\blx@entryset@precode{#1}%
     \long\def\blx@entryset@postcode{#2}%
     \let\finentry\blx@finentry@inset
     \let\do\blx@entryset
     \blx@imc@docsvfield{entryset}%
     \endgroup}}

\def\blx@entryset#1{%
  \blx@ifdata{#1}
    {\begingroup
     \blx@imc@clearlist{pageref}%
     \blx@getdata{#1}%
     \blx@setoptions@type\abx@field@entrytype
     \blx@setoptions@entry
     \global\blx@entrysetcounter\@ne
     \edef\abx@field@entrysetcount{\the\blx@entrysetcounter}%
     \blx@execute
     \blx@beglangbib
     \blx@begunit
     \blx@anchor
     \blx@entryset@precode
     \blx@driver{\blx@imc@thefield{entrytype}}%
     \blx@entryset@postcode
     \blx@endunit
     \blx@endlangbib
     \endgroup}
    {}%
  \let\do\blx@entryset@i}

\def\blx@entryset@i#1{%
  \blx@ifdata{#1}
    {\begingroup
     \blx@resetdata
     \blx@getdata{#1}%
     \blx@setoptions@type\abx@field@entrytype
     \blx@setoptions@entry
     \global\advance\blx@entrysetcounter\@ne
     \edef\abx@field@entrysetcount{\the\blx@entrysetcounter}%
     \addtocounter{instcount}\@ne
     \blx@execute
     \blx@beglangbib
     \blx@begunit
     \blx@anchor
     \blx@entryset@precode
     \blx@driver{\blx@imc@thefield{entrytype}}%
     \blx@entryset@postcode
     \blx@endunit
     \blx@endlangbib
     \endgroup}
    {\blx@nounit}}

\blx@regimcs{%
  \printtext \printfield \printlist \printnames \printfile
  \indexfield \indexlist \indexnames \entrydata \entryset}

\let\blx@bibstringsets\@empty

% {&lt;set&gt;}{&lt;bibstring_1&gt;,...,&lt;bibstring_n&gt;}
\newrobustcmd*{\DeclareBibstringSet}[1]{%
  \listadd\blx@bibstringsets{#1}%
  \def\do##1{%
    \csdef{blx@bibstringset@string@##1}{#1}%
    \listcsadd{blx@bibstringset@set@#1}{##1}}%
  \docsvlist}

% {&lt;set&gt;}
\newrobustcmd*{\UndeclareBibstringSet}[1]{%
  \def\do##1{\csundef{blx@bibstringset@string@##1}}%
  \dolistcsloop{blx@bibstringset@set@#1}%
  \csundef{blx@bibstringset@set@#1}%
  \UndeclareBibstringSetFormat{#1}}

\newrobustcmd*{\UndeclareBibstringSets}{%
  \forlistloop{\UndeclareBibstringSet}{\blx@bibstringsets}%
  \let\blx@bibstringsets\@empty}

% {&lt;set&gt;}{&lt;code&gt;}
\newrobustcmd*{\DeclareBibstringSetFormat}[1]{%
  \csdef{blx@bibstringsetformat@#1}##1}

% {&lt;set&gt;}
\newrobustcmd*{\UndeclareBibstringSetFormat}[1]{%
  \csundef{blx@bibstringsetformat@#1}}

% {&lt;wrapper&gt;}{&lt;string (name)&gt;}{&lt;text (derived from string)&gt;}
\def\blx@wrapbibstring#1#2#3{%
  \ifcsundef{blx@bibstringset@string@#2}
    {#1{#3}}
    {\ifcsundef{blx@bibstringsetformat@\csuse{blx@bibstringset@string@#2}}
       {#1{#3}}
       {#1{\csuse{blx@bibstringsetformat@\csuse{blx@bibstringset@string@#2}}
             {#3}}}}}

%% Localization

% {&lt;wrapper&gt;}{&lt;long/short&gt;}{&lt;string&gt;}{&lt;print code&gt;}
% &lt;print code&gt; is executed when the bibstring is defined
% it differs between the \bib...string versions
% in &lt;print code&gt; \blx@tempa should be used as &lt;string&gt;
\protected\def\blx@met@bibstring#1#2#3#4{%
  \blx@begunit
  \blx@hyphenreset
  \blx@bibstringsimple
  \lowercase{\edef\blx@tempa{#3}}%
  \ifcsundef{#2@\blx@tempa}
    {\blx@warn@nostring\blx@tempa
     \blx@endnounit}
    {#4}}

% [&lt;wrapper&gt;]{&lt;string&gt;}
\newrobustcmd*{\blx@imc@bibstring}[2][\@firstofone]{%
  \blx@bibstring{#1}{\abx@str}{#2}}

\newrobustcmd*{\blx@imc@biblstring}[2][\@firstofone]{%
  \blx@bibstring{#1}{abx@lstr}{#2}}

\newrobustcmd*{\blx@imc@bibsstring}[2][\@firstofone]{%
  \blx@bibstring{#1}{abx@sstr}{#2}}

\def\blx@bibstringsimple{%
  \let\bibstring\blx@imc@bibxstring
  \let\biblstring\blx@imc@bibxlstring
  \let\bibsstring\blx@imc@bibxsstring}

\def\blx@bibstringnormal{%
  \let\bibstring\blx@imc@bibstring
  \let\biblstring\blx@imc@biblstring
  \let\bibsstring\blx@imc@bibsstring}

\protected\def\blx@bibstring#1#2#3{%
  \blx@met@bibstring{#1}{#2}{#3}
    {\blx@imc@ifcapital
       {\blx@wrapbibstring{#1}{\blx@tempa}{\MakeCapital{\csuse{#2@\blx@tempa}}}}
       {\blx@wrapbibstring{#1}{\blx@tempa}{\csuse{#2@\blx@tempa}}}%
     \blx@endunit}}

% [&lt;wrapper&gt;]{&lt;string&gt;}
\newrobustcmd*{\blx@imc@bibncpstring}[2][\@firstofone]{%
  \blx@bibncpstring{#1}{\abx@str}{#2}}

\newrobustcmd*{\blx@imc@bibncplstring}[2][\@firstofone]{%
  \blx@bibncpstring{#1}{abx@lstr}{#2}}

\newrobustcmd*{\blx@imc@bibncpsstring}[2][\@firstofone]{%
  \blx@bibncpstring{#1}{abx@sstr}{#2}}

\protected\def\blx@bibncpstring#1#2#3{%
  \blx@met@bibstring{#1}{#2}{#3}
    {\blx@wrapbibstring{#1}{\blx@tempa}{\csuse{#2@\blx@tempa}}%
     \blx@endunit}}

% [&lt;wrapper&gt;]{&lt;string&gt;}
\newrobustcmd*{\blx@imc@bibcpstring}[2][\@firstofone]{%
  \blx@bibcpstring{#1}{\abx@str}{#2}}

\newrobustcmd*{\blx@imc@bibcplstring}[2][\@firstofone]{%
  \blx@bibcpstring{#1}{abx@lstr}{#2}}

\newrobustcmd*{\blx@imc@bibcpsstring}[2][\@firstofone]{%
  \blx@bibcpstring{#1}{abx@sstr}{#2}}

\protected\def\blx@bibcpstring#1#2#3{%
  \blx@met@bibstring{#1}{#2}{#3}
    {\blx@wrapbibstring{#1}{\blx@tempa}{\MakeCapital{\csuse{#2@\blx@tempa}}}%
     \blx@endunit}}

% [&lt;wrapper&gt;]{&lt;string&gt;}
\newrobustcmd*{\blx@imc@biblcstring}[2][\@firstofone]{%
  \blx@biblcstring{#1}{\abx@str}{#2}}

\newrobustcmd*{\blx@imc@biblclstring}[2][\@firstofone]{%
  \blx@biblcstring{#1}{abx@lstr}{#2}}

\newrobustcmd*{\blx@imc@biblcsstring}[2][\@firstofone]{%
  \blx@biblcstring{#1}{abx@sstr}{#2}}

\protected\def\blx@biblcstring#1#2#3{%
  \blx@met@bibstring{#1}{#2}{#3}
    {\blx@wrapbibstring{#1}{\blx@tempa}{\blx@maketext@lowercase{\csuse{#2@\blx@tempa}}}%
     \blx@endunit}}

% [&lt;wrapper&gt;]{&lt;string&gt;}
\newrobustcmd*{\blx@imc@bibucstring}[2][\@firstofone]{%
  \blx@bibucstring{#1}{\abx@str}{#2}}

\newrobustcmd*{\blx@imc@bibuclstring}[2][\@firstofone]{%
  \blx@bibucstring{#1}{abx@lstr}{#2}}

\newrobustcmd*{\blx@imc@bibucsstring}[2][\@firstofone]{%
  \blx@bibucstring{#1}{abx@sstr}{#2}}

\protected\def\blx@bibucstring#1#2#3{%
  \blx@met@bibstring{#1}{#2}{#3}
    {\blx@wrapbibstring{#1}{\blx@tempa}{\blx@maketext@uppercase{\csuse{#2@\blx@tempa}}}%
     \blx@endunit}}

% {&lt;string&gt;}
\def\blx@imc@bibxstring#1{%
  \blx@bibxstring{\abx@str}{#1}}

\def\blx@imc@bibxlstring#1{%
  \blx@bibxstring{abx@lstr}{#1}}

\def\blx@imc@bibxsstring#1{%
  \blx@bibxstring{abx@sstr}{#1}}

\def\blx@bibxstring#1#2{%
  \ifcsundef{#1@#2}
    {\protect\blx@warn@nostring{#2}}
    {\csuse{#1@#2}}}

% {&lt;string&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@ifbibstring#1{%
  \ifcsundef{\abx@str @\detokenize{#1}}
    {\@secondoftwo}
    {\@firstoftwo}}

\def\blx@imc@ifbibxstring#1{%
  \blx@xsanitizeafter\ifcsundef{\abx@str @#1}
    {\@secondoftwo}
    {\@firstoftwo}}

% {&lt;field&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@iffieldbibstring#1{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\ifcsundef{\abx@str @\detokenize\expandafter
                          \expandafter\expandafter{%
                \csname abx@field@#1\endcsname}}
       {\@secondoftwo}
       {\@firstoftwo}}}

% {&lt;field&gt;}{&lt;string&gt;}{&lt;true&gt;}{&lt;false&gt;}
\def\blx@imc@iffieldplusstringbibstring#1#2{%
  \blx@imc@iffieldundef{#1}
    {\@secondoftwo}
    {\ifcsundef{\abx@str @\detokenize\expandafter
                          \expandafter\expandafter{%
                \csname abx@field@#1\endcsname}#2}
       {\@secondoftwo}
       {\@firstoftwo}}}

\blx@regimcs{%
  \bibstring   \biblstring   \bibsstring
  \bibxstring  \bibxlstring  \bibxsstring
  \bibncpstring \bibncplstring \bibncpsstring
  \bibcpstring \bibcplstring \bibcpsstring
  \biblcstring \biblclstring \biblcsstring
  \bibucstring \bibuclstring \bibucsstring
  \ifbibstring \ifbibxstring \iffieldbibstring
  \iffieldplusstringbibstring}

% \DeclareCaseChangeEquivalent is available in
% LaTeX 2022-06-01-PL5
% the older code works-ish for LaTeX before 2022-06-01
% it errors with 2022-06-01-PL4
% but we'll not guard against this specific PL
\ifundef\DeclareCaseChangeEquivalent
  {\let\blx@hook@uc\relax
   \let\blx@hook@lc\relax
   %
   \AtEndPreamble{%
     \toggletrue{blx@tempa}%
     \toggletrue{blx@tempb}%
     \expandafter\patchcmd\csname MakeUppercase \endcsname
       {\protected@edef}
       {\blx@hook@uc\protected@edef}
       {\togglefalse{blx@tempa}}
       {}%
     \expandafter\patchcmd\csname MakeLowercase \endcsname
       {\protected@edef}
       {\blx@hook@lc\protected@edef}
       {\togglefalse{blx@tempb}}
       {}%
     \@ifpackageloaded{textcase}
       {\expandafter\patchcmd\csname MakeUppercase \endcsname
          {\def\i}
          {\blx@hook@uc\def\i}
          {\togglefalse{blx@tempa}}
          {}%
        \expandafter\patchcmd\csname MakeLowercase \endcsname
          {\@uclcnotmath{}}
          {\@uclcnotmath{\blx@hook@lc}}
          {\togglefalse{blx@tempb}}
          {}%
        \expandafter\patchcmd\csname MakeTextUppercase \endcsname
          {\def\i}
          {\blx@hook@uc\def\i}
          {}
          {}%
        \expandafter\patchcmd\csname MakeTextLowercase \endcsname
          {\@uclcnotmath{}}
          {\@uclcnotmath{\blx@hook@lc}}
          {}
          {}}
       {}%
     \iftoggle{blx@tempa}{\blx@err@patch{\string\MakeUppercase}}{}%
     \iftoggle{blx@tempb}{\blx@err@patch{\string\MakeLowercase}}{}%
   }
   %
   \appto\blx@blxinit{%
     \def\blx@hook@uc{%
       \def\bibstring{\blx@imc@bibucstring}%
       \def\biblstring{\blx@imc@bibuclstring}%
       \def\bibsstring{\blx@imc@bibucsstring}%
       \def\biblcstring{\blx@imc@bibucstring}%
       \def\biblclstring{\blx@imc@bibuclstring}%
       \def\biblcsstring{\blx@imc@bibucsstring}%
       \def\bibcpstring{\blx@imc@bibucstring}%
       \def\bibcplstring{\blx@imc@bibuclstring}%
       \def\bibcpsstring{\blx@imc@bibucsstring}}%
     \def\blx@hook@lc{%
       \def\bibstring{\blx@imc@biblcstring}%
       \def\biblstring{\blx@imc@biblclstring}%
       \def\bibsstring{\blx@imc@biblcsstring}%
       \def\bibucstring{\blx@imc@biblcstring}%
       \def\bibuclstring{\blx@imc@biblclstring}%
       \def\bibucsstring{\blx@imc@biblcsstring}%
       \def\bibcpstring{\blx@imc@biblcstring}%
       \def\bibcplstring{\blx@imc@biblclstring}%
       \def\bibcpsstring{\blx@imc@biblcsstring}}}}
  {\DeclareCaseChangeEquivalent{\bibstring}{%
     \CaseSwitch
       {\blx@imc@bibstring}
       {\blx@imc@bibucstring}
       {\blx@imc@biblcstring}
       {\blx@imc@bibcpstring}}
   \DeclareCaseChangeEquivalent{\biblstring}{%
     \CaseSwitch
       {\blx@imc@biblstring}
       {\blx@imc@bibuclstring}
       {\blx@imc@biblclstring}
       {\blx@imc@bibcplstring}}
   \DeclareCaseChangeEquivalent{\bibsstring}{%
     \CaseSwitch
       {\blx@imc@bibsstring}
       {\blx@imc@bibucsstring}
       {\blx@imc@biblcsstring}
       {\blx@imc@bibcpsstring}}
   \DeclareCaseChangeEquivalent{\biblcstring}{%
     \CaseSwitch
       {\blx@imc@bibstring}
       {\blx@imc@bibucstring}
       {\blx@imc@biblcstring}
       {\blx@imc@bibcpstring}}
   \DeclareCaseChangeEquivalent{\biblclstring}{%
     \CaseSwitch
       {\blx@imc@biblstring}
       {\blx@imc@bibuclstring}
       {\blx@imc@biblclstring}
       {\blx@imc@bibcplstring}}
   \DeclareCaseChangeEquivalent{\biblcsstring}{%
     \CaseSwitch
       {\blx@imc@bibsstring}
       {\blx@imc@bibucsstring}
       {\blx@imc@biblcsstring}
       {\blx@imc@bibcpsstring}}
   \DeclareCaseChangeEquivalent{\bibucstring}{%
     \CaseSwitch
       {\blx@imc@bibstring}
       {\blx@imc@bibucstring}
       {\blx@imc@biblcstring}
       {\blx@imc@bibcpstring}}
   \DeclareCaseChangeEquivalent{\bibuclstring}{%
     \CaseSwitch
       {\blx@imc@biblstring}
       {\blx@imc@bibuclstring}
       {\blx@imc@biblclstring}
       {\blx@imc@bibcplstring}}
   \DeclareCaseChangeEquivalent{\bibucsstring}{%
     \CaseSwitch
       {\blx@imc@bibsstring}
       {\blx@imc@bibucsstring}
       {\blx@imc@biblcsstring}
       {\blx@imc@bibcpsstring}}
   \DeclareCaseChangeEquivalent{\bibcpstring}{%
     \CaseSwitch
       {\blx@imc@bibstring}
       {\blx@imc@bibucstring}
       {\blx@imc@biblcstring}
       {\blx@imc@bibcpstring}}
   \DeclareCaseChangeEquivalent{\bibcplstring}{%
     \CaseSwitch
       {\blx@imc@biblstring}
       {\blx@imc@bibuclstring}
       {\blx@imc@biblclstring}
       {\blx@imc@bibcplstring}}
   \DeclareCaseChangeEquivalent{\bibcpsstring}{%
     \CaseSwitch
       {\blx@imc@bibsstring}
       {\blx@imc@bibucsstring}
       {\blx@imc@biblcsstring}
       {\blx@imc@bibcpsstring}}}

\def\abx@dostrings{%
  \do{bibliography}%
  \do{references}%
  \do{shorthands}%
  \do{editor}%
  \do{editors}%
  \do{compiler}%
  \do{compilers}%
  \do{redactor}%
  \do{redactors}%
  \do{reviser}%
  \do{revisers}%
  \do{founder}%
  \do{founders}%
  \do{continuator}%
  \do{continuators}%
  \do{collaborator}%
  \do{collaborators}%
  \do{translator}%
  \do{translators}%
  \do{commentator}%
  \do{commentators}%
  \do{annotator}%
  \do{annotators}%
  \do{commentary}%
  \do{annotations}%
  \do{introduction}%
  \do{foreword}%
  \do{afterword}%
  \do{editortr}%
  \do{editorstr}%
  \do{editorco}%
  \do{editorsco}%
  \do{editoran}%
  \do{editorsan}%
  \do{editorin}%
  \do{editorsin}%
  \do{editorfo}%
  \do{editorsfo}%
  \do{editoraf}%
  \do{editorsaf}%
  \do{editortrco}%
  \do{editorstrco}%
  \do{editortran}%
  \do{editorstran}%
  \do{editortrin}%
  \do{editorstrin}%
  \do{editortrfo}%
  \do{editorstrfo}%
  \do{editortraf}%
  \do{editorstraf}%
  \do{editorcoin}%
  \do{editorscoin}%
  \do{editorcofo}%
  \do{editorscofo}%
  \do{editorcoaf}%
  \do{editorscoaf}%
  \do{editoranin}%
  \do{editorsanin}%
  \do{editoranfo}%
  \do{editorsanfo}%
  \do{editoranaf}%
  \do{editorsanaf}%
  \do{editortrcoin}%
  \do{editorstrcoin}%
  \do{editortrcofo}%
  \do{editorstrcofo}%
  \do{editortrcoaf}%
  \do{editorstrcoaf}%
  \do{editortranin}%
  \do{editorstranin}%
  \do{editortranfo}%
  \do{editorstranfo}%
  \do{editortranaf}%
  \do{editorstranaf}%
  \do{translatorco}%
  \do{translatorsco}%
  \do{translatoran}%
  \do{translatorsan}%
  \do{translatorin}%
  \do{translatorsin}%
  \do{translatorfo}%
  \do{translatorsfo}%
  \do{translatoraf}%
  \do{translatorsaf}%
  \do{translatorcoin}%
  \do{translatorscoin}%
  \do{translatorcofo}%
  \do{translatorscofo}%
  \do{translatorcoaf}%
  \do{translatorscoaf}%
  \do{translatoranin}%
  \do{translatorsanin}%
  \do{translatoranfo}%
  \do{translatorsanfo}%
  \do{translatoranaf}%
  \do{translatorsanaf}%
  \do{byauthor}%
  \do{byeditor}%
  \do{bycompiler}%
  \do{byredactor}%
  \do{byreviser}%
  \do{byreviewer}%
  \do{byfounder}%
  \do{bycontinuator}%
  \do{bycollaborator}%
  \do{bytranslator}%
  \do{bycommentator}%
  \do{byannotator}%
  \do{withcommentator}%
  \do{withannotator}%
  \do{withintroduction}%
  \do{withforeword}%
  \do{withafterword}%
  \do{organizer}%
  \do{organizers}%
  \do{byorganizer}%
  \do{byeditortr}%
  \do{byeditorco}%
  \do{byeditoran}%
  \do{byeditorin}%
  \do{byeditorfo}%
  \do{byeditoraf}%
  \do{byeditortrco}%
  \do{byeditortran}%
  \do{byeditortrin}%
  \do{byeditortrfo}%
  \do{byeditortraf}%
  \do{byeditorcoin}%
  \do{byeditorcofo}%
  \do{byeditorcoaf}%
  \do{byeditoranin}%
  \do{byeditoranfo}%
  \do{byeditoranaf}%
  \do{byeditortrcoin}%
  \do{byeditortrcofo}%
  \do{byeditortrcoaf}%
  \do{byeditortranin}%
  \do{byeditortranfo}%
  \do{byeditortranaf}%
  \do{bytranslatorco}%
  \do{bytranslatoran}%
  \do{bytranslatorin}%
  \do{bytranslatorfo}%
  \do{bytranslatoraf}%
  \do{bytranslatorcoin}%
  \do{bytranslatorcofo}%
  \do{bytranslatorcoaf}%
  \do{bytranslatoranin}%
  \do{bytranslatoranfo}%
  \do{bytranslatoranaf}%
  \do{and}%
  \do{andothers}%
  \do{andmore}%
  \do{volume}%
  \do{volumes}%
  \do{involumes}%
  \do{part}%
  \do{jourvol}%
  \do{jourser}%
  \do{newseries}%
  \do{oldseries}%
  \do{edition}%
  \do{reprint}%
  \do{reprintof}%
  \do{reprintas}%
  \do{reprintfrom}%
  \do{reviewof}%
  \do{translationof}%
  \do{translationas}%
  \do{translationfrom}%
  \do{origpubas}%
  \do{origpubin}%
  \do{astitle}%
  \do{bypublisher}%
  \do{nodate}%
  \do{page}%
  \do{pages}%
  \do{column}%
  \do{columns}%
  \do{line}%
  \do{lines}%
  \do{verse}%
  \do{verses}%
  \do{section}%
  \do{sections}%
  \do{paragraph}%
  \do{paragraphs}%
  \do{pagetotal}%
  \do{pagetotals}%
  \do{columntotal}%
  \do{columntotals}%
  \do{linetotal}%
  \do{linetotals}%
  \do{versetotal}%
  \do{versetotals}%
  \do{sectiontotal}%
  \do{sectiontotals}%
  \do{paragraphtotal}%
  \do{paragraphtotals}%
  \do{in}%
  \do{inseries}%
  \do{ofseries}%
  \do{book}%
  \do{issue}%
  \do{number}%
  \do{chapter}%
  \do{bathesis}%
  \do{mathesis}%
  \do{phdthesis}%
  \do{candthesis}%
  \do{resreport}%
  \do{techreport}%
  \do{software}%
  \do{datacd}%
  \do{audiocd}%
  \do{version}%
  \do{url}%
  \do{urlfrom}%
  \do{urlseen}%
  \do{file}%
  \do{inpreparation}%
  \do{submitted}%
  \do{inpress}%
  \do{prepublished}%
  \do{forthcoming}%
  \do{library}%
  \do{abstract}%
  \do{annotation}%
  \do{citedas}%
  \do{seenote}%
  \do{quotedin}%
  \do{opcit}%
  \do{loccit}%
  \do{ibidem}%
  \do{idem}%
  \do{idemsf}%
  \do{idemsm}%
  \do{idemsn}%
  \do{idempf}%
  \do{idempm}%
  \do{idempn}%
  \do{idempp}%
  \do{confer}%
  \do{sequens}%
  \do{sequentes}%
  \do{passim}%
  \do{see}%
  \do{seealso}%
  \do{backrefpage}%
  \do{backrefpages}%
  \do{thiscite}%
  \do{january}%
  \do{february}%
  \do{march}%
  \do{april}%
  \do{may}%
  \do{june}%
  \do{july}%
  \do{august}%
  \do{september}%
  \do{october}%
  \do{november}%
  \do{december}%
  \do{langamerican}%
  \do{langbasque}%
  \do{langbrazilian}%
  \do{langbulgarian}%
  \do{langcatalan}%
  \do{langcroatian}%
  \do{langczech}%
  \do{langdanish}%
  \do{langdutch}%
  \do{langenglish}%
  \do{langestonian}%
  \do{langfinnish}%
  \do{langfrench}%
  \do{langgalician}%
  \do{langgerman}%
  \do{langgreek}%
  \do{langhungarian}%
  \do{langitalian}%
  \do{langjapanese}%
  \do{langlatin}%
  \do{langlatvian}%
  \do{langlithuanian}%
  \do{langmarathi}%
  \do{langnorwegian}%
  \do{langpolish}%
  \do{langportuguese}%
  \do{langserbian}%
  \do{langromanian}%
  \do{langrussian}%
  \do{langslovak}%
  \do{langslovene}%
  \do{langspanish}%
  \do{langswedish}%
  \do{langturkish}%
  \do{langukrainian}%
  \do{fromamerican}%
  \do{frombasque}%
  \do{frombrazilian}%
  \do{frombulgarian}%
  \do{fromcatalan}%
  \do{fromcroatian}%
  \do{fromczech}%
  \do{fromdanish}%
  \do{fromdutch}%
  \do{fromenglish}%
  \do{fromestonian}%
  \do{fromfinnish}%
  \do{fromfrench}%
  \do{fromgalician}%
  \do{fromgerman}%
  \do{fromgreek}%
  \do{fromhungarian}%
  \do{fromitalian}%
  \do{fromjapanese}%
  \do{fromlatin}%
  \do{fromlithuanian}%
  \do{fromlatvian}%
  \do{frommarathi}%
  \do{fromnorwegian}%
  \do{frompolish}%
  \do{fromportuguese}%
  \do{fromromanian}%
  \do{fromrussian}%
  \do{fromserbian}%
  \do{fromslovak}%
  \do{fromslovene}%
  \do{fromspanish}%
  \do{fromswedish}%
  \do{fromturkish}%
  \do{fromukrainian}%
  \do{countryde}%
  \do{countryep}%
  \do{countryeu}%
  \do{countryfr}%
  \do{countryuk}%
  \do{countryus}%
  \do{patent}%
  \do{patentde}%
  \do{patenteu}%
  \do{patentfr}%
  \do{patentuk}%
  \do{patentus}%
  \do{patreq}%
  \do{patreqde}%
  \do{patreqeu}%
  \do{patreqfr}%
  \do{patrequk}%
  \do{patrequs}%
  \do{commonera}%
  \do{beforecommonera}%
  \do{annodomini}%
  \do{beforechrist}%
  \do{circa}%
  \do{spring}%
  \do{summer}%
  \do{autumn}%
  \do{winter}%
  \do{springN}%
  \do{summerN}%
  \do{autumnN}%
  \do{winterN}%
  \do{springS}%
  \do{summerS}%
  \do{autumnS}%
  \do{winterS}%
  \do{Q1}%
  \do{Q2}%
  \do{Q3}%
  \do{Q4}%
  \do{QD1}%
  \do{QD2}%
  \do{QD3}%
  \do{S1}%
  \do{S2}%
  \do{am}%
  \do{pm}%
}

\newrobustcmd*{\NewBibliographyString}[1]{%
  \forcsvlist\blx@newstring{#1}}

\def\blx@newstring#1{%
  \blx@kv@ifkeyundef{blx@lbx}{#1}
    {\gappto\abx@dostrings{\do{#1}}%
     \blx@kv@gdefkey{blx@lbx}{#1}{\blx@defstring{#1}{##1}}}
    {}}

% in *.cbx/bbx/tex: &lt;key&gt; = {&lt;string&gt;},
% in *.lbx:         &lt;key&gt; = {{&lt;longstring&gt;}{&lt;abbrevstring&gt;}},
\def\do#1{\blx@kv@defkey{blx@lbx}{#1}{\blx@defstring{#1}{##1}}}
\abx@dostrings

% in *.cbx/bbx/tex: (implicit)
% in *.lbx:         inherit = {&lt;language&gt;},
\blx@kv@defkey{blx@lbx}{inherit}{%
  \blx@lbxinput@strings{#1}{}{\blx@err@nolang{#1}}%
  \csuse{abx@strings@#1}}

\def\blx@cfg@defstring#1#2{%
  \csdef{abx@lstr@#1}{#2}%
  \csdef{abx@sstr@#1}{#2}}

\def\blx@lbx@defstring#1#2{%
  \blx@lbx@defstring@i{#1}#2}
\def\blx@lbx@defstring@i#1#2#3{%
  \csdef{abx@lstr@#1}{#2}%
  \csdef{abx@sstr@#1}{#3}}

% {&lt;language&gt;}
\def\blx@lbxcheck#1{%
  \ifcsdef{blx@lng@#1}
    {\expandafter\expandafter\expandafter\IfFileExists
     \expandafter\expandafter\expandafter{%
     \csname blx@lng@#1\endcsname.lbx}
       {}
       {\blx@err@nolang{#1}}}
    {\IfFileExists{#1.lbx}
       {}
       {\blx@err@nolang{#1}}}}

% {&lt;language&gt;}{&lt;definitions&gt;}
\newrobustcmd*{\DefineBibliographyExtras}[2]{%
  \blx@lbxcheck{#1}%
  \csgappto{blx@hook@extras@#1}{%
    \blx@defbibextras{#1}{#2}}}
\@onlypreamble\DefineBibliographyExtras

\newrobustcmd*{\UndefineBibliographyExtras}[2]{%
  \blx@lbxcheck{#1}%
  \csgappto{blx@hook@noextras@#1}{%
    \blx@undefbibextras{#1}{#2}}}
\@onlypreamble\UndefineBibliographyExtras

\def\blx@defbibextras#1{\csgappto{abx@extras@#1}}
\def\blx@undefbibextras#1{\csgappto{abx@noextras@#1}}

% {&lt;language&gt;}{&lt;language&gt;}
\def\blx@letbibextras#1#2{%
  \blx@lbxinput@extras{#2}{}{\blx@err@nolang{#2}}%
  \global\csletcs{abx@extras@#1}{abx@extras@#2}
  \global\csletcs{abx@noextras@#1}{abx@noextras@#2}}%

% {&lt;language&gt;}{&lt;strings&gt;}
\newrobustcmd*{\DefineBibliographyStrings}[2]{%
  \blx@lbxcheck{#1}%
  \csgappto{blx@hook@strings@#1}{%
    \begingroup
    \let\blx@defstring\blx@cfg@defstring
    \blx@defbibstrings{#1}{#2}%
    \endgroup}}
\@onlypreamble\DefineBibliographyStrings

\def\blx@defbibstrings#1#2{%
  \def\do##1{\csundef{abx@lstr@##1}\csundef{abx@sstr@##1}}%
  \abx@dostrings
  \csuse{abx@strings@#1}%
  \blx@kv@setkeys{blx@lbx}{#2}%
  \let\do\blx@defbibstrings@i
  \csxdef{abx@strings@#1}{\abx@dostrings}%
  \csgappto{abx@strings@#1}{%
    \ifcsdef{\abx@str @bibliography}
      {\letcs\bibname{\abx@str @bibliography}}
      {\let\bibname\@empty}%
    \ifcsdef{\abx@str @references}
      {\letcs\refname{\abx@str @references}}
      {\let\refname\@empty}%
    \ifcsdef{\abx@str @shorthands}
      {\letcs\biblistname{\abx@str @shorthands}}
      {\let\biblistname\@empty}}}

% this one is special, it's basically ours and probably not defined
% by anyone else, so we had better make sure it exists
\providecommand*{\biblistname}{\blx@warn@nostring{shorthands}}

\def\blx@defbibstrings@i#1{%
  \ifcsdef{abx@lstr@#1}
    {\def\expandafter\noexpand\csname abx@lstr@#1\endcsname{%
       \csexpandonce{abx@lstr@#1}}}
    {\undef\expandafter\noexpand\csname abx@lstr@#1\endcsname}%
  \ifcsdef{abx@sstr@#1}
    {\def\expandafter\noexpand\csname abx@sstr@#1\endcsname{%
       \csexpandonce{abx@sstr@#1}}}
    {\undef\expandafter\noexpand\csname abx@sstr@#1\endcsname}}

% {&lt;language&gt;}{&lt;language&gt;}
\def\blx@letbibstrings#1#2{%
  \blx@lbxinput@strings{#2}{}{\blx@err@nolang{#2}}%
  \global\csletcs{abx@strings@#1}{abx@strings@#2}}%

% {&lt;language&gt;}{&lt;exceptions&gt;}
\newrobustcmd*{\DefineHyphenationExceptions}[2]{%
  \blx@ifhyphenationundef{#1}
    {\blx@warn@nohyph{#1}}
    {}%
  \csgappto{blx@hook@hyph@#1}{\blx@hyphexcept{#1}{#2}}}
\@onlypreamble\DefineHyphenationExceptions

\def\blx@hyphexcept#1#2{%
  \blx@ifhyphenationundef{#1}
    {\blx@warn@nohyph{#1}}
    {\begingroup
     \language\csname l@#1\endcsname\relax
     \hyphenation{#2}%
     \endgroup}}

% {&lt;mapping suffix&gt;}
\newrobustcmd*{\DeclareLanguageMappingSuffix}[1]{%
  \gdef\blx@lng@suff{#1}}
\@onlypreamble\DeclareLanguageMappingSuffix
\let\blx@lng@suff\@empty

% {&lt;language&gt;}{&lt;mapping&gt;}
\newrobustcmd*{\DeclareLanguageMapping}[2]{%
  \csgdef{blx@lng@#1}{#2}%
  \csgdef{blx@lng@explicit@#1}{#2}}
\@onlypreamble\DeclareLanguageMapping

% to avoid copying, these commands simply redefine the input handlers and
% process and postprocess code
% {&lt;language&gt;}{&lt;success&gt;}{&lt;failure&gt;}
\def\blx@lbxinput#1{%
  \csletcs{blx@lbx@input@handler}{blx@lbx@input@handler@once}%
  \csletcs{blx@lbx@input@process}{blx@lbx@input@process@all}%
  \csletcs{blx@lbx@input@postprocess}{blx@lbx@input@postprocess@all}%
  \blx@lbxinput@i{#1}}

\def\blx@lbxinput@strings#1{%
  \csletcs{blx@lbx@input@handler}{blx@lbx@input@handler@simple}%
  \csletcs{blx@lbx@input@process}{blx@lbx@input@process@strings}%
  \csletcs{blx@lbx@input@postprocess}{blx@lbx@input@postprocess@strings}%
  \blx@lbxinput@i{#1}}

\def\blx@lbxinput@extras#1{%
  \csletcs{blx@lbx@input@handler}{blx@lbx@input@handler@simple}%
  \csletcs{blx@lbx@input@process}{blx@lbx@input@process@extras}%
  \csletcs{blx@lbx@input@postprocess}{blx@lbx@input@postprocess@extras}%
  \blx@lbxinput@i{#1}}

\def\blx@lbxinput@i#1{%
  \ifcsundef{blx@nolbxrecurse@#1}
    {\ifcsdef{blx@lng@explicit@#1}
       {\global\csletcs{blx@lng@#1}{blx@lng@explicit@#1}}
       {\ifdefempty\blx@lng@suff
          {}
          {\csgdef{blx@lng@#1}{#1\blx@lng@suff}}}}
    {}%
  \blx@lbxinput@ii{#1}}

\def\blx@lbxinput@ii#1{%
  \ifcsdef{blx@lng@#1}
    {\expandafter\expandafter\expandafter\blx@lbxinput@iii
     \expandafter\expandafter\expandafter{%
       \csname blx@lng@#1\endcsname}{#1}}
    {\blx@lbxinput@iv{#1}{#1}{language '#1'}}}

% {&lt;mapping&gt;}{&lt;language&gt;}
\def\blx@lbxinput@iii#1#2{%
  \global\csundef{blx@lng@#2}%
  \IfFileExists{#1.lbx}
    {\blx@lbxinput@iv{#2}{#1}{language '#2' -&gt; '#1'}}
    {\ifcsdef{blx@suffmaptried@#2}
      {}
      {\blx@warning@noline{%
          File '#1.lbx' not found!\MessageBreak
          Ignoring mapping '#2' -&gt; '#1'}%
       \global\cslet{blx@suffmaptried@#2}\@empty}%
     \blx@lbxinput@iv{#2}{#2}{language '#2'}}}

% .lbx files must be read with one of the two following commands,
% do not use \blx@inputonce. Only the commands here make sure that the file
% is read as many times as necessary.
% blx@file@lbx@simple@#1 only blocks the file being added to the file list
% blx@file@lbx@once@#1 blocks a file from being loaded again by the input-once
% routine
% {&lt;file&gt;}{&lt;message&gt;}{&lt;preload&gt;}{&lt;postload&gt;}{&lt;success&gt;}{&lt;failure&gt;}
\protected\long\def\blx@lbx@input@handler@simple#1#2#3#4#5#6{%
  \blx@info@noline{Trying to load #2..}%
  \IfFileExists{#1}
    {\blx@info@noline{... file '#1' found}%
     \csuse{blx@lbxfilehook@simple@preload@#1}%
     #3%
     \@@input\@filef@und
     #4%
     \csuse{blx@lbxfilehook@simple@postload@#1}%
     #5%
     \ifcsundef{blx@file@lbx@simple@#1}
       {\listxadd\blx@list@req@stat{#1}%
        \@addtofilelist{#1}%
        \global\cslet{blx@file@lbx@simple@#1}\@empty}
       {}}
    {\blx@info@noline{... file '#1' not found}%
     \csuse{blx@lbxfilehook@simple@failure@#1}%
     #6}}

% {&lt;file&gt;}{&lt;message&gt;}{&lt;preload&gt;}{&lt;postload&gt;}{&lt;success&gt;}{&lt;failure&gt;}
\protected\long\def\blx@lbx@input@handler@once#1#2#3#4#5#6{%
  \ifcsundef{blx@file@lbx@once@#1}
    {\blx@info@noline{Trying to load #2..}%
     \IfFileExists{#1}
       {\blx@info@noline{... file '#1' found}%
        \csuse{blx@lbxfilehook@once@preload@#1}%
        #3%
        \@@input\@filef@und
        #4%
        \csuse{blx@lbxfilehook@once@postload@#1}%
        #5%
        \ifcsundef{blx@file@lbx@simple@#1}
          {\listxadd\blx@list@req@stat{#1}%
           \@addtofilelist{#1}}
          {}}
       {\blx@info@noline{... file '#1' not found}%
        \csuse{blx@lbxfilehook@once@failure@#1}%
        #6}%
     \global\cslet{blx@file@lbx@once@#1}\@empty
     \global\cslet{blx@file@lbx@simple@#1}\@empty}
    {#5}}

\def\blx@lbx@input@process@strings#1{%
  \global\cslet{abx@strings@#1}\@empty
  \def\InheritBibliographyStrings{%
    \blx@letbibstrings{#1}}%
  \def\DeclareBibliographyStrings##1{%
    \begingroup
      \let\blx@defstring\blx@lbx@defstring
      \blx@defbibstrings{#1}{##1}%
    \endgroup}}

\def\blx@lbx@input@process@extras#1{%
  \global\cslet{abx@extras@#1}\@empty
  \global\cslet{abx@noextras@#1}\@empty
  \def\InheritBibliographyExtras{\blx@letbibextras{#1}}%
  \def\DeclareBibliographyExtras{\blx@defbibextras{#1}}%
  \def\UndeclareBibliographyExtras{\blx@undefbibextras{#1}}}

\def\blx@lbx@input@process@all#1{%
  \blx@lbx@input@process@strings{#1}%
  \blx@lbx@input@process@extras{#1}%
  \def\DeclareHyphenationExceptions{\blx@hyphexcept{#1}}}

\def\blx@lbx@input@postprocess@strings#1{%
  \csuse{blx@hook@strings@#1}}

\def\blx@lbx@input@postprocess@extras#1{%
  \csuse{blx@hook@extras@#1}%
  \csuse{blx@hook@noextras@#1}}

\def\blx@lbx@input@postprocess@all#1{%
  \blx@lbx@input@postprocess@strings{#1}%
  \blx@lbx@input@postprocess@extras{#1}%
  \csuse{blx@hook@hyph@#1}%
  \blx@maplang{#1}{#1}}

% {&lt;language&gt;}{&lt;lbxfile&gt;}{&lt;message&gt;}
\def\blx@lbxinput@iv#1#2#3{%
  \begingroup
    \blx@lbx@input@handler{#2.lbx}{#3}
      {\let\InheritBibliographyStrings\@gobble
       \let\DeclareBibliographyStrings\@gobble
       \let\InheritBibliographyExtras\@gobble
       \let\DeclareBibliographyExtras\@gobble
       \let\UndeclareBibliographyExtras\@gobble
       \blx@lbx@input@process{#1}%
       \begingroup
       \cslet{blx@nolbxrecurse@#1}\@empty
       \blx@saneccodes
       \makeatletter}
      {\endgroup
       \blx@lbx@input@postprocess{#1}}
      {\aftergroup\@firstoftwo}
      {\aftergroup\@secondoftwo}%
  \endgroup}

% {&lt;language&gt;}
\protected\def\blx@langsetup#1{%
  \blx@lbxinput{#1}
    {\edef\blx@languagename{#1}}
    {\blx@warning
       {Language '#1' not supported.\MessageBreak
        Using dummy definitions}}}

\protected\def\blx@langsetup@from@pkglist#1{%
  \global\cslet{blx@lbx@loaded@from@pkglist@#1}\@empty
  \blx@langsetup{#1}}

\protected\def\blx@langsetup@from@auxlist#1{%
  \global\cslet{blx@lbx@loaded@from@auxlist@#1}\@empty
  \blx@langsetup{#1}}

\newcommand*{\blx@lbx@loadlist}{}

\protected\def\blx@langsetup@indoc#1{%
  \ifcsundef{blx@lbx@loaded@from@pkglist@#1}
    {\xifinlist{#1}\blx@lbx@loadlist
       {}
       {\listxadd\blx@lbx@loadlist{#1}}%
     \ifcsundef{blx@lbx@loaded@from@auxlist@#1}
       {\ifcsundef{blx@lbx@loaded@nolistload@#1}
          {\blx@warning@noline{%
             No localisation for language '#1' loaded.\MessageBreak
             Please rerun LaTeX to ensure languages can\MessageBreak
             be requested properly}%
           \global\cslet{blx@lbx@loaded@nolistload@#1}\@empty}
          {}}
       {\edef\blx@languagename{#1}}}
    {\edef\blx@languagename{#1}}%
}

\newcommand*{\blx@lbx@auxloadlist}{}

\def\abx@aux@lbx@loadrequest{%
  \listgadd\blx@lbx@auxloadlist}

\protected\def\blx@lbx@writeloaderequest#1{%
  \blx@auxwrite\@mainaux{}{%
    \string\abx@aux@lbx@loadrequest{#1}}}

% auxiliary macros

% {&lt;field base name&gt;}
\newrobustcmd*{\mkdaterangeshort}{%
  \mkdaterangefull{short}}

\newrobustcmd*{\mkdaterangelong}{%
  \mkdaterangefull{long}}

\newrobustcmd*{\mkdaterangeterse}{%
  \mkdaterangetrunc{short}}

\newrobustcmd*{\mkdaterangecomp}{%
  \mkdaterangetrunc{long}}

\newrobustcmd*{\mkdaterangeshortextra}{%
  \mkdaterangefullextra{short}}

\newrobustcmd*{\mkdaterangelongextra}{%
  \mkdaterangefullextra{long}}

\newrobustcmd*{\mkdaterangeterseextra}{%
  \mkdaterangetruncextra{short}}

\newrobustcmd*{\mkdaterangecompextra}{%
  \mkdaterangetruncextra{long}}

% calls to \blx@metadateinfo should be grouped to avoid name clashes
\def\blx@metadateinfo#1{%
  \letcs\ifdateera{if#1dateera}%
  \letcs\ifenddateera{if#1enddateera}%
  \letcs\ifdatecirca{if#1datecirca}%
  \letcs\ifenddatecirca{if#1enddatecirca}%
  \letcs\ifdatejulian{if#1datejulian}%
  \letcs\ifenddatejulian{if#1enddatejulian}%
  \letcs\ifdateuncertain{if#1dateuncertain}%
  \letcs\ifenddateuncertain{if#1enddateuncertain}%
  \letcs\ifdateunknown{if#1dateunknown}%
  \letcs\ifenddateunknown{if#1enddateunknown}}

\expandafter\newrobustcmd\expandafter*\csname mktimerange24h\endcsname{%
  \mktimerange{24h}}

\expandafter\newrobustcmd\expandafter*\csname mktimerange12h\endcsname{%
  \mktimerange{12h}}

\expandafter\newrobustcmd\expandafter*\csname mktimerange24hcomp\endcsname[1]{%
  \iffieldundef{#1hour}
    {}
    {\ifboolexpr{test {\iffieldundef{#1endhour}}
                 or
                 test {\iffieldequalstr{#1endhour}{}}}
       {\mktimerange{24h}{#1}}
       {\iffieldsequal{#1hour}{#1endhour}
          % 14:xx:xx 14:xx:xx
          {\iffieldsequal{#1minute}{#1endminute}
             % 14:13:xx 14:13:xx
             {\toggletrue{blx@seconds}%
              \printtext[{#1time}]{%
                \csuse{mkbibtime24h}{#1hour}{#1minute}{#1second}{}%
              \bibtimerangesep
              \csuse{mkbibtime24h}{}{}{#1endsecond}{}}}
             % 14:13:xx 14:14:xx
             {\toggletrue{blx@seconds}%
              \printtext[{#1time}]{\csuse{mkbibtime24h}{#1hour}{#1minute}{}{}%
              \bibtimerangesep
              \csuse{mkbibtime24h}{}{#1endminute}{}{}}}}
          % 14:xx:xx 15:xx:xx
          {\mktimerange{24h}{#1}}}}}

% {&lt;24h|24hcomp|12h&gt;}{&lt;datetype&gt;}
\newrobustcmd*{\mktimerange}[2]{%
  \begingroup
    \iffieldundef{#2hour}
      {\blx@nounit}
      {\blx@timepre{#2}{}%
       \printtext[{#2time}]{%
         \csuse{mkbibtime#1}{#2hour}{#2minute}{#2second}{#2timezone}%
         \iffieldundef{#2endhour}
           {}
           {\blx@timepre{#2}{end}%
            \iffieldequalstr{#2endhour}{}
              {\mbox{\bibtimerangesep}}
              {\bibtimerangesep
               \csuse{mkbibtime#1}{#2endhour}{#2endminute}{#2endsecond}{#2endtimezone}}}}}%
  \endgroup}

% {&lt;datetype&gt;}{''|end}
\newrobustcmd*{\blx@timepre}[2]{%
  \iftoggle{blx@timezones}{}
    {\blx@imc@clearfield{#1#2timezone}}%
  \iftoggle{blx@seconds}{}
    {\blx@imc@clearfield{#1#2second}}}

\newcommand*{\blx@if@printtime}[2]{%
  \iftoggle{blx@#1dateusetime}
    {\iffieldundef{#1#2hour}
       {\@secondoftwo}
       {\@firstoftwo}}
    {\@secondoftwo}}

\newcommand*{\blx@if@printanytimes}[1]{%
  \iftoggle{blx@#1dateusetime}
    {\iffieldundef{#1hour}
       {\iffieldundef{#1endhour}
          {\@secondoftwo}
          {\@firstoftwo}}
       {\@firstoftwo}}
    {\@secondoftwo}}

% {&lt;datetype&gt;}{'' | end}
\newrobustcmd*{\blx@printtime}[2]{%
  \blx@if@printtime{#1}{#2}
    {\blx@timepre{#1}{#2}%
     \bibdatetimesep%
     \printtext[{#1time}]{%
       \csuse{mkbibtime\csuse{blx@timeformat@#1time}}
         {#1#2hour}{#1#2minute}{#1#2second}{#1#2timezone}}}
    {}}

% {&lt;short|long&gt;}{&lt;datetype&gt;}
\newrobustcmd*{\mkdaterangefull}[2]{%
  \begingroup
    \blx@metadateinfo{#2}%
    \iffieldundef{#2year}
      {\blx@nounit}
      {\printtext[{#2date}]{%
         \datecircaprint
         % Such a year division component can only come from an ISO8601 year division which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldundef{#2yeardivision}
           {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
            % Optionally print the time after the date
            \blx@printtime{#2}{}}
           {\csuse{mkbibyeardivisiondate#1}{#2year}{#2yeardivision}}%
         \dateuncertainprint
         \dateeraprint{#2year}%
         \iffieldundef{#2endyear}
           {}
           {\iffieldequalstr{#2endyear}{}
              {\mbox{\bibdaterangesep}}
              {\bibdaterangesep
               \enddatecircaprint
               \iffieldundef{#2endyeardivision}
                 {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}%
                  % Optionally print the time after the date
                  \blx@printtime{#2}{end}}
                 {\csuse{mkbibyeardivisiondate#1}{#2endyear}{#2endyeardivision}}%
               \enddateuncertainprint
               \dateeraprint{#2endyear}}}}}%
  \endgroup}

\newrobustcmd*{\mkdaterangefullextra}[2]{%
  \begingroup
    \blx@metadateinfo{#2}%
    \iffieldundef{#2year}
      {\blx@nounit}
      {\printtext[{#2date}]{%
         \datecircaprint
         % Such a year division component can only come from an ISO8601 year division which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldundef{#2yeardivision}
           {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
            % Optionally print the time after the date
            \blx@printtime{#2}{}}
           {\csuse{mkbibyeardivisiondate#1}{#2year}{#2yeardivision}}%
         \dateuncertainprint
         \dateeraprint{#2year}%
         \iffieldundef{#2endyear}
           {\printfield{extradate}}
           {\iffieldequalstr{#2endyear}{}
              {\printfield{extradate}%
               \mbox{\bibdaterangesep}}
              {\bibdaterangesep
               \enddatecircaprint
               \iffieldundef{#2endyeardivision}
                 {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}%
                  % Optionally print the time after the date
                  \blx@printtime{#2}{end}}
                 {\csuse{mkbibyeardivisiondate#1}{#2endyear}{#2endyeardivision}}}%
               \printfield{extradate}%
               \enddateuncertainprint
               \dateeraprint{#2endyear}}}}%
  \endgroup}

\newrobustcmd*{\mkdaterangetrunc}[2]{%
  \blx@if@printanytimes{#2}
    {\mkdaterangefull{#1}{#2}}
    {\mkdaterangetrunc@i{#1}{#2}}}

\newrobustcmd*{\mkdaterangetrunc@i}[2]{%
  \begingroup
    \blx@metadateinfo{#2}%
    \iffieldundef{#2year}
      {\blx@nounit}
      {\printtext[{#2date}]{%
         \datecircaprint
         % Such a year division component can only come from an ISO8601 year division which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldundef{#2yeardivision}
           {\ifdateyearsequal{#2}{#2end}
              {\iffieldsequal{#2month}{#2endmonth}
                 {\csuse{mkbibdate#1}{}{}{#2day}}
                 {\csuse{mkbibdate#1}{}{#2month}{#2day}}}
              {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
               \iffieldsequal{#2dateera}{#2enddateera}{}
                 {\dateeraprint{#2year}}}}
           {\ifdateyearsequal{#2}{#2end}
             {\csuse{mkbibyeardivisiondate#1}{}{#2yeardivision}}
             {\csuse{mkbibyeardivisiondate#1}{#2year}{#2yeardivision}%
              \iffieldsequal{#2dateera}{#2enddateera}{}
                {\dateeraprint{#2year}}}}%
         \dateuncertainprint
         \iffieldundef{#2endyear}
           {}
           {\iffieldequalstr{#2endyear}{}
              {\mbox{\bibdaterangesep}}
              {\bibdaterangesep
               \enddatecircaprint
               \iffieldundef{#2endyeardivision}
                 {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}}
                 {\csuse{mkbibyeardivisiondate#1}{#2endyear}{#2endyeardivision}}%
               \enddateuncertainprint
               \dateeraprint{#2endyear}}}}}%
  \endgroup}

\newrobustcmd*{\mkdaterangetruncextra}[2]{%
  \blx@if@printanytimes{#2}
    {\mkdaterangefullextra{#1}{#2}}
    {\mkdaterangetruncextra@i{#1}{#2}}}

\newrobustcmd*{\mkdaterangetruncextra@i}[2]{%
  \begingroup
    \blx@metadateinfo{#2}%
    \iffieldundef{#2year}
      {\blx@nounit}
      {\printtext[{#2date}]{%
         \datecircaprint
         % Such a year division component can only come from an ISO8601 year division which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldundef{#2yeardivision}
           {\ifdateyearsequal{#2}{#2end}
              {\iffieldsequal{#2month}{#2endmonth}
                 {\csuse{mkbibdate#1}{}{}{#2day}}
                 {\csuse{mkbibdate#1}{}{#2month}{#2day}}}
              {\csuse{mkbibdate#1}{#2year}{#2month}{#2day}%
               \iffieldsequal{#2dateera}{#2enddateera}{}
                 {\dateeraprint{#2year}}}}
           {\ifdateyearsequal{#2}{#2end}
             {\csuse{mkbibyeardivisiondate#1}{}{#2yeardivision}}
             {\csuse{mkbibyeardivisiondate#1}{#2year}{#2yeardivision}%
              \iffieldsequal{#2dateera}{#2enddateera}{}
                {\dateeraprint{#2year}}}}%
         \dateuncertainprint
         \iffieldundef{#2endyear}
           {\printfield{extradate}}
           {\iffieldequalstr{#2endyear}{}
              {\printfield{extradate}%
               \mbox{\bibdaterangesep}}
              {\bibdaterangesep
               \enddatecircaprint
               \iffieldundef{#2endyeardivision}
                 {\csuse{mkbibdate#1}{#2endyear}{#2endmonth}{#2endday}}
                 {\csuse{mkbibyeardivisiondate#1}{#2endyear}{#2endyeardivision}}}%
               \printfield{extradate}%
               \enddateuncertainprint
               \dateeraprint{#2endyear}}}}%
  \endgroup}

\newrobustcmd*{\mkdaterangeyear}[1]{%
  \begingroup
    \blx@imc@clearfield{#1yeardivision}%
    \blx@imc@clearfield{#1month}%
    \blx@imc@clearfield{#1day}%
    \blx@imc@clearfield{#1hour}%
    \blx@imc@clearfield{#1minute}%
    \blx@imc@clearfield{#1second}%
    \blx@imc@clearfield{#1timezone}%
    \blx@imc@clearfield{#1endyeardivision}%
    \blx@imc@clearfield{#1endmonth}%
    \blx@imc@clearfield{#1endday}%
    \blx@imc@clearfield{#1endhour}%
    \blx@imc@clearfield{#1endminute}%
    \blx@imc@clearfield{#1endsecond}%
    \blx@imc@clearfield{#1endtimezone}%
    \ifdateyearsequal{#1}{#1end}
      {\blx@imc@clearfield{#1endyear}}
      {}%
    \mkdaterangefull{short}{#1}%
  \endgroup}

% {&lt;datetype&gt;}
\newrobustcmd*{\mkdaterangeymd}[1]{%
  \begingroup
    \blx@metadateinfo{#1}%
    \iffieldundef{#1year}
      {\blx@nounit}
      {\printtext[{#1date}]{%
         \datecircaprint
         % Such a year division component can only come from an ISO8601 year division which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldundef{#1yeardivision}
           {\blx@ymddate{#1}{}%
            % Optionally print the time after the date
            \blx@printtime{#1}{}}
           {\csuse{mkbibyeardivisiondateshort}{#1year}{#1yeardivision}}%
         \dateuncertainprint
         \dateeraprint{#1year}%
         \iffieldundef{#1endyear}
           {}
           {\iffieldequalstr{#1endyear}{}
              {\mbox{\bibdaterangesep}}
              {\bibdaterangesep
               \enddatecircaprint
               \iffieldundef{#1yeardivision}
                 {\blx@ymddate{#1}{end}%
                  % Optionally print the time after the date
                  \blx@printtime{#1}{end}}
                 {\csuse{mkbibyeardivisiondateshort}{#1endyear}{#1endyeardivision}}%
               \enddateuncertainprint
               \dateeraprint{#1endyear}}}}}%
  \endgroup}

% {&lt;datetype&gt;}
\newrobustcmd*{\mkdaterangeymdextra}[1]{%
  \begingroup
    \blx@metadateinfo{#1}%
    \iffieldundef{#1year}
      {\blx@nounit}
      {\printtext[{#1date}]{%
         \datecircaprint
         % Such a year division component can only come from an ISO8601 year division which replaces
         % a normal month so if it exists, we know that a normal date print is ruled out
         \iffieldundef{#1yeardivision}
           {\blx@ymddate[extradate]{#1}{}%
            % Optionally print the time after the date
            \blx@printtime{#1}{}}
           {\csuse{mkbibyeardivisiondateshort}{#1year}{#1yeardivision}}%
         \dateuncertainprint
         \dateeraprint{#1year}%
         \iffieldundef{#1endyear}
           {}
           {\iffieldequalstr{#1endyear}{}
              {\mbox{\bibdaterangesep}}
              {\bibdaterangesep
               \enddatecircaprint
               \iffieldundef{#1yeardivision}
                 {\blx@ymddate{#1}{end}%
                  % Optionally print the time after the date
                  \blx@printtime{#1}{end}}
                 {\csuse{mkbibyeardivisiondateshort}{#1endyear}{#1endyeardivision}}}%
               \enddateuncertainprint
               \dateeraprint{#1endyear}}}}%
  \endgroup}

% [extradate]{&lt;datetype&gt;}{''|end}
\newrobustcmd*{\blx@ymddate}[3][]{%
  \dateeraprintpre{#2#3year}%
  \mkyearzeros{\thefield{#2#3year}}\ifblank{#1}{}{\printfield{#1}}%
  \iffieldundef{#2#3month}{}{\bibdatesep\mkmonthzeros{\thefield{#2#3month}}}%
  \iffieldundef{#2#3day}{}{\bibdatesep\mkdayzeros{\thefield{#2#3day}}}}

\newrobustcmd*{\mkdaterangeyearextra}[1]{%
  \begingroup
    \blx@imc@clearfield{#1yeardivision}%
    \blx@imc@clearfield{#1month}%
    \blx@imc@clearfield{#1day}%
    \blx@imc@clearfield{#1hour}%
    \blx@imc@clearfield{#1minute}%
    \blx@imc@clearfield{#1second}%
    \blx@imc@clearfield{#1timezone}%
    \blx@imc@clearfield{#1endyeardivision}%
    \blx@imc@clearfield{#1endmonth}%
    \blx@imc@clearfield{#1endday}%
    \blx@imc@clearfield{#1endhour}%
    \blx@imc@clearfield{#1endminute}%
    \blx@imc@clearfield{#1endsecond}%
    \blx@imc@clearfield{#1endtimezone}%
    \ifdateyearsequal{#1}{#1end}
      {\blx@imc@clearfield{#1endyear}}
      {}%
    \mkdaterangefullextra{short}{#1}%
  \endgroup}

\newrobustcmd*{\mkdaterangeiso}[1]{%
  \begingroup
    \blx@metadateinfo{#1}%
    \def\bibdatetimesep{T}%
    \iffieldundef{#1year}
      {\blx@nounit}
      {\printtext[{#1date}]{%
         \blx@isodate{#1}{}%
         \ifboolexpr{%
           togl {blx@#1dateusetime}
           and
           not test {\iffieldundef{#1hour}}}
           {\bibdatetimesep%
            \blx@isotime{#1}{}}
           {}%
         \dateuncertainprint
         \datecircaprintiso
         \iffieldundef{#1endyear}
           {}
           {\addslash
            \blx@isodate{#1}{end}%
            \ifboolexpr{%
              togl {blx@#1dateusetime}
              and
              not test {\iffieldundef{#1endhour}}}
              {\bibdatetimesep%
               \blx@isotime{#1}{end}}
              {}%
           \enddateuncertainprint
           \enddatecircaprintiso}}}%
  \endgroup}

\newrobustcmd*{\mkdaterangeisoextra}[1]{%
  \begingroup
    \blx@metadateinfo{#1}%
    \def\bibdatetimesep{T}%
    \iffieldundef{#1year}
      {\blx@nounit}
      {\printtext[{#1date}]{%
         \blx@isodate[extradate]{#1}{}%
         \ifboolexpr{%
           togl {blx@#1dateusetime}
           and
           not test {\iffieldundef{#1hour}}}
           {\bibdatetimesep%
            \blx@isotime{#1}{}}
           {}%
         \dateuncertainprint
         \datecircaprintiso
         \iffieldundef{#1endyear}
           {}
           {\addslash
            \blx@isodate{#1}{end}}%
            \ifboolexpr{%
              togl {blx@#1dateusetime}
              and
              not test {\iffieldundef{#1endhour}}}
              {\bibdatetimesep%
               \blx@isotime{#1}{end}}
              {}%
            \enddateuncertainprint
            \enddatecircaprintiso}}%
  \endgroup}

% [extradate]{&lt;datetype&gt;}{''|end}
\newrobustcmd*{\blx@isodate}[3][]{%
  \dateeraprintpre{#2#3year}%
  \blx@imc@forcezerosy{\thefield{#2#3year}}\ifblank{#1}{}{\printfield{#1}}%
  % Such a year division component can only come from an ISO8601 year division which replaces
  % a normal month so if it exists, we know that a normal date print is ruled out
  \iffieldundef{#2#3yeardivision}
    {\iffieldundef{#2#3month}{}{\hyphen\blx@imc@forcezerosmdt{\thefield{#2#3month}}}%
     \iffieldundef{#2#3day}{}{\hyphen\blx@imc@forcezerosmdt{\thefield{#2#3day}}}}
    {\hyphen\blx@yeardivisionmap{\thefield{#2#3yeardivision}}}}

\def\blx@yeardivisionmap#1{%
  \blx@xifstrequal{#1}{spring}{21}
    {\blx@xifstrequal{#1}{summer}{22}
      {\blx@xifstrequal{#1}{autumn}{23}
        {\blx@xifstrequal{#1}{winter}{24}{}}}}}

\newrobustcmd*{\blx@isotime}[2]{%
  \blx@imc@forcezerosmdt{\thefield{#1#2hour}}%
  :\blx@imc@forcezerosmdt{\thefield{#1#2minute}}%
  :\blx@imc@forcezerosmdt{\thefield{#1#2second}}%
  \iftoggle{blx@timezones}
    {\mkbibtimezone{\thefield{#1#2timezone}}}
    {}}

% some sane defaults for bibliography extras
% many of these should be redefined in the .lbx files
% all .lbx files should have date and time handling, so the fallback values
% issue a warning to make people aware of the deficiency in their file
% \mkbibordinal should also only be used if it is defined, so it warns as well
% times
\newrobustcmd*{\bibtimesep}{:}
\newrobustcmd*{\bibtimerangesep}{\textendash}
\newrobustcmd*{\bibutctimezone}{Z}
\newrobustcmd*{\bibtimezonesep}{}
\newrobustcmd*{\bibtzminsep}{\bibtimesep}
% dates
\newrobustcmd*{\bibdateuncertain}{?}
% \textminus is only guaranteed for non-PDFTeX
\newrobustcmd*{\bibdateeraprefix}{\ifdef\textminus\textminus\textendash}
\newrobustcmd*{\bibdateeraendprefix}{\,\bibdateeraprefix}
\newrobustcmd*{\bibdatesep}{\hyphen}
\newrobustcmd*{\bibdatendsep}{\hyphen}
\newrobustcmd*{\bibdaterangesep}{\bibrangedash}
% date+times
\newrobustcmd*{\bibdatetimesep}{\space}
% ranges
\newrobustcmd*{\bibrangedash}{\textendash}
\newrobustcmd*{\bibrangessep}{,\space}
% formatters
\newrobustcmd*{\mkbibtimezone}[1]{\blx@xifstrequal{#1}{Z}{\bibutctimezone}{#1}}
% you should never end up needing the next few definitions
% but it is safer to do something than just swallow the input
\newrobustcmd*{\mkbibdatelong}[3]{%
  \blx@warning@noline{%
    Using fallback definition for \string\mkbibdatelong.\MessageBreak
    The command should be defined in the .lbx file.\MessageBreak
    If you see this message, the .lbx file could not be\MessageBreak
    loaded, is faulty or does not contain a definition\MessageBreak
    for \string\mkbibdatelong
  }%
  \iffieldundef{#3}
    {}
    {\mkbibordinal{\thefield{#3}}%
     \iffieldundef{#2}{}{\nobreakspace}}%
  \iffieldundef{#2}
    {}
    {\mkbibmonth{\thefield{#2}}%
     \iffieldundef{#1}{}{\space}}%
  \iffieldbibstring{#1}
    {\bibstring{\thefield{#1}}}
    {\dateeraprintpre{#1}\stripzeros{\thefield{#1}}}}

\newrobustcmd*{\mkbibdateshort}[3]{%
  \blx@warning@noline{%
    Using fallback definition for \string\mkbibdateshort.\MessageBreak
    The command should be defined in the .lbx file.\MessageBreak
    If you see this message, the .lbx file could not be\MessageBreak
    loaded, is faulty or does not contain a definition\MessageBreak
    for \string\mkbibdateshort
  }%
  \iffieldundef{#3}
    {}
    {\mkdayzeros{\thefield{#3}}%
     \iffieldundef{#2}{}{/}}%
  \iffieldundef{#2}
    {}
    {\mkmonthzeros{\thefield{#2}}%
     \iffieldundef{#1}{}{/}}%
  \iffieldbibstring{#1}
    {\bibstring{\thefield{#1}}}
    {\dateeraprintpre{#1}\mkyearzeros{\thefield{#1}}}}

\expandafter\newrobustcmd\expandafter*\csname mkbibtime24h\endcsname[4]{%
  \blx@warning@noline{%
    Using fallback definition for
    \expandafter\string\csname mkbibtime24h\endcsname.\MessageBreak
    The command should be defined in the .lbx file.\MessageBreak
    If you see this message, the .lbx file could not be\MessageBreak
    loaded, is faulty or does not contain a definition\MessageBreak
    for \expandafter\string\csname mkbibtime24h\endcsname
  }%
    \iffieldundef{#1}
      {}
      {\mktimezeros{\thefield{#1}}%
       \iffieldundef{#2}{}{\bibtimesep}}%
    \iffieldundef{#2}
      {}
      {\mktimezeros{\thefield{#2}}%
       \iffieldundef{#3}{}{\bibtimesep}}%
    \iffieldundef{#3}
      {}
      {\mktimezeros{\thefield{#3}}}%
    \iffieldundef{#4}{}
      {\bibtimezonesep
       \mkbibtimezone{\thefield{#4}}}}

\expandafter\newrobustcmd\expandafter*\csname mkbibtime12h\endcsname[4]{%
  \blx@warning@noline{%
    Using fallback definition for
    \expandafter\string\csname mkbibtime12h\endcsname.\MessageBreak
    The command should be defined in the .lbx file.\MessageBreak
    If you see this message, the .lbx file could not be\MessageBreak
    loaded, is faulty or does not contain a definition\MessageBreak
    for \expandafter\string\csname mkbibtime12h\endcsname
  }%
    \stripzeros{\mktimehh{\thefield{#1}}}%
    \bibtimesep
    \forcezerosmdt{\thefield{#2}}%
    \iffieldundef{#3}{}
      {\bibtimesep
       \forcezeros{\thefield{#3}}}%
     \space
     \ifnumless{\thefield{#1}}{12}
       {\bibstring{am}}
       {\bibstring{pm}}%
    \iffieldundef{#4}{}
     {\space\bibtimezonesep
      \mkbibparens{\mkbibtimezone{\thefield{#4}}}}}

\newrobustcmd*{\mkbibyeardivisiondateshort}[2]{%
  \blx@warning@noline{%
    Using fallback definition for \string\mkbibyeardivisiondateshort.\MessageBreak
    The command should be defined in the .lbx file.\MessageBreak
    If you see this message, the .lbx file could not be\MessageBreak
    loaded, is faulty or does not contain a definition\MessageBreak
    for \string\mkbibyeardivisiondateshort
  }%
  \mkbibyeardivision{\thefield{#2}}%
  \iffieldundef{#1}{}{\space}%
  \dateeraprintpre{#1}\mkyearzeros{\thefield{#1}}}
\def\mkbibseasondateshort{% LEGACY
  \blx@warning@noline{%
    '\string\mkbibseasondateshort' is deprecated in favour of\MessageBreak
    '\string\mkbibyeardivisiondateshort'}%
  \mkbibyeardivisiondateshort}

\newrobustcmd*{\mkbibyeardivisiondatelong}[2]{%
  \blx@warning@noline{%
    Using fallback definition for \string\mkbibyeardivisiondatelong.\MessageBreak
    The command should be defined in the .lbx file.\MessageBreak
    If you see this message, the .lbx file could not be\MessageBreak
    loaded, is faulty or does not contain a definition\MessageBreak
    for \string\mkbibyeardivisiondatelong
  }%
  \mkbibyeardivision{\thefield{#2}}%
  \iffieldundef{#1}{}{\space}%
  \dateeraprintpre{#1}\mkyearzeros{\thefield{#1}}}
\def\mkbibseasondatelong{% LEGACY
  \blx@warning@noline{%
    '\string\mkbibseasondatelong' is deprecated in favour of\MessageBreak
    '\string\mkbibyeardivisiondatelong'}%
  \mkbibyeardivisiondatelong}

\newrobustcmd*{\bibdatedash}{\bibrangedash}
\newrobustcmd*{\finalandcomma}{}
\newrobustcmd*{\finalandsemicolon}{}
\newrobustcmd*{\mkbibordinal}[1]{%
  \blx@warning@noline{%
    Using fallback definition for \string\mkbibordinal.\MessageBreak
    The command should be defined in the .lbx file.\MessageBreak
    If you see this message, the .lbx file could not be\MessageBreak
    loaded, is faulty or does not contain a definition\MessageBreak
    for \string\mkbibordinal
  }%
  #1%
}
\newrobustcmd*{\mkbibmascord}{\mkbibordinal}
\newrobustcmd*{\mkbibfemord}{\mkbibordinal}
\newrobustcmd*{\mkbibneutord}{\mkbibordinal}
% the following is usually not redefined in an .lbx
\newrobustcmd*{\mkbibyeardivision}[1]{\abx@bibyeardivision{#1}}
\newrobustcmd*\mkbibseason{% LEGACY
  \blx@warning@noline{%
    '\string\mkbibseason' is deprecated in favour of\MessageBreak
    '\string\mkbibyeardivision'}%
  \mkbibyeardivision}
\newrobustcmd*{\mkbibmonth}[1]{%
  \ifcase0#1\relax
    \blx@warning@entry{Month out of range or not an integer}%
  \or\abx@bibmonth{january}%
  \or\abx@bibmonth{february}%
  \or\abx@bibmonth{march}%
  \or\abx@bibmonth{april}%
  \or\abx@bibmonth{may}%
  \or\abx@bibmonth{june}%
  \or\abx@bibmonth{july}%
  \or\abx@bibmonth{august}%
  \or\abx@bibmonth{september}%
  \or\abx@bibmonth{october}%
  \or\abx@bibmonth{november}%
  \or\abx@bibmonth{december}%
  \else
    \blx@warning@entry{Month out of range}#1%
  \fi}

% strip leading zeros and prepend zero for month/day/timeparts
% Allow for non numeric labelyear values
\protected\def\blx@imc@forcezerosmdt#1{%
  \protected@edef\blx@tempa{#1}%
  \expandafter\blx@imc@forcezerosmdt@i\expandafter{\blx@tempa}}

\protected\def\blx@imc@forcezerosmdt@i#1{%
  \notblank{#1}
    {\blx@imc@ifinteger{#1}
       {\ifnumless{#1}{10}
         {0\the\numexpr(#1)\relax}
         {#1}}
       {#1}}
    {#1}}

% strip leading zeros and prepend zero(s) for year
% Allow for non numeric labelyear values
\protected\def\blx@imc@forcezerosy#1{%
  \protected@edef\blx@tempa{#1}%
  \expandafter\blx@imc@forcezerosy@i\expandafter{\blx@tempa}}

\protected\def\blx@imc@forcezerosy@i#1{%
  \notblank{#1}
    {\blx@imc@ifinteger{#1}
       {\ifnumless{#1}{10}% 1-digit year
          {000\the\numexpr(#1)\relax}
          {\ifnumless{#1}{100}% 2-digit year
            {00\the\numexpr(#1)\relax}
            {\ifnumless{#1}{1000}% 3-digit year
              {0\the\numexpr(#1)\relax}
              {#1}}}}
       {#1}}
    {#1}}%

\let\blx@imc@mkyearzeros\blx@imc@forcezerosy
\let\blx@imc@mkmonthzeros\blx@imc@forcezerosmdt
\let\blx@imc@mkdayzeros\blx@imc@forcezerosmdt
\protected\def\blx@imc@stripzeros#1{%
  \begingroup
  \setbox\@tempboxa=\hbox\bgroup
  \aftergroup\endgroup
  \abx@hook@xsanitize
  \if0#1\relax
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi
  {\@tempcnta#1\relax
   \expandafter\egroup
   \number\@tempcnta
   \@tempcnta#1\relax}
  {\egroup#1}}

\let\blx@imc@printlabeldate\@empty
\let\blx@imc@printlabeltime\@empty
\let\blx@imc@printlabeldateextra\@empty

\blx@regimcs{\printlabeldate \printlabeltime \printlabeldateextra
  \stripzeros \forcezerosy \forcezerosmdt
  \mkyearzeros \mkmonthzeros \mkdayzeros \mktimezeros}

% User macro for retrieving currrent language
\def\currentlang{\blx@languagename}

% We need to be able to prefix \providetoggle with \global,
% plus we don't need the testing from \providetoggle anway.
% This uses internal implementation details of etoolbox's
% toggles, so is a bit meh, but it's better than rolling our own
% version of toggles just for that.
\newcommand*{\blx@etb@inittoggle}[1]{\cslet{etb@tgl@#1}\@secondoftwo}

% There is no \nocaptions..., so if we send everything to \captions...
% we need to find a way to call our noextras only in situations where
% \noextras... is called to clean up \extras... AND \captions...
% and not just \extras...
% We detect this by setting a toggle in the \captions...

% {&lt;language&gt;}{&lt;strings&gt;}
\def\blx@maplang@babel#1#2{%
  \global\blx@etb@inittoggle{blx@lang@captions@#2}%
  \ifdefstring{\blx@langhook}{captions}
    {\csgappto{captions#1}{%
       \toggletrue{blx@lang@captions@#2}%
       \blx@resetpunct
       \csuse{abx@extras@#2}%
       \csuse{abx@strings@#2}}%
     \csgappto{noextras#1}{%
       \iftoggle{blx@lang@captions@#2}
         {\blx@resetpunct
          \csuse{abx@noextras@#2}}
         {}}}
    {\csgappto{extras#1}{%
       \blx@resetpunct
       \csuse{abx@extras@#2}%
       \csuse{abx@strings@#2}}%
     \csgappto{noextras#1}{%
       \blx@resetpunct
       \csuse{abx@noextras@#2}}}}

\def\blx@maplang@polyglossia#1#2{%
  \global\blx@etb@inittoggle{blx@lang@captions@#2}%
  \ifdefstring{\blx@langhook}{captions}
    {\csgappto{captions@bbl@#1}{%
       \toggletrue{blx@lang@captions@#2}%
       \blx@resetpunct
       \csuse{abx@extras@#2}%
       \csuse{abx@strings@#2}}%
     \csgappto{noextras@bbl@#1}{%
       \iftoggle{blx@lang@captions@#2}
         {\blx@resetpunct
          \csuse{abx@noextras@#2}}
         {}}}
    {\csgappto{blockextras@bbl@#1}{%
       \blx@resetpunct
       \csuse{abx@extras@#2}%
       \csuse{abx@strings@#2}}%
     \csgappto{inlineextras@bbl@#1}{%
       \blx@resetpunct
       \csuse{abx@extras@#2}%
       \csuse{abx@strings@#2}}%
     \csgappto{noextras@bbl@#1}{%
       \blx@resetpunct
       \csuse{abx@noextras@#2}}}}

%% babel/polyglossia interface
\def\blx@beglang{\blx@clearlang\begingroup}
\def\blx@endlang{\endgroup}
\let\blx@beglangbib\blx@beglang
\let\blx@endlangbib\blx@endlang
\let\blx@beglangcite\blx@beglang
\let\blx@endlangcite\blx@endlang
\let\blx@hook@endlang\@empty
\let\blx@hook@initlang\@empty
\let\blx@imc@mainlang\@empty
\let\blx@imc@textmainlang\@firstofone
\let\blx@imc@textouterlang\@firstofone
\def\blx@hyphenreset{%
  \blx@ifhyphenationundef{\blx@languagename}
    {}
    {\language\csname l@\blx@languagename\endcsname\relax}%
  \ifcsundef{\blx@languagename hyphenmins}
    {\blx@sethyphenmins\tw@\thr@@}
    {\expandafter\expandafter\expandafter\blx@sethyphenmins
       \csname\blx@languagename hyphenmins\endcsname}}
\def\blx@sethyphenmins#1#2{%
  \lefthyphenmin#1\relax
  \righthyphenmin#2\relax}



\def\blx@mkautolangbabel{%
  \ifundef\bbl@main@language
    {\blx@error
      {No default 'babel' language defined}
      {You must define a default language for 'babel'}}
    {\let\blx@main@language\bbl@main@language}%
  \let\blx@outer@language\blx@main@language
  % use afterreset to get in a bit earlier
  % we want to be there before \captions... is issued
  % beforeextras is before extras, but captions come before extras
  % afterreset was added in 3.9i (~2014-03-16)
  % way before 3.9r (2016-04-23), which we require
  \AddBabelHook{biblatex@langsetup}{afterreset}{%
    \expandafter\blx@langsetup@indoc\expandafter{\languagename}}%
  \ifdef\blx@thelangenv
    {\def\blx@beglang{%
       \blx@clearlang
       \begingroup
       % track outer language (i.e. language not selected by biblatex)
       \ifundef\blx@outer@language@set
         {\let\blx@outer@language\blx@languagename
          \let\blx@outer@language@set\@empty}
         {}%
         % Need to override all entries, regardless of if there is a
         % langid if language=&lt;language&gt; option is given
         \ifboolexpr { test {\ifdef\abx@field@langid }
                       or
                       test {\ifdef\blx@forcelanguagename} }
           % override local langid if we forced it with
           % language=&lt;language&gt; option
           {\ifdef\blx@forcelanguagename
              {\let\abx@field@langid\blx@forcelanguagename}
              {}%
            \let\blx@languagename\abx@field@langid% track global language
            \blx@ifhyphenationundef{\abx@field@langid}
              {\blx@warn@nohyph{\abx@field@langid}}
              {\blx@hook@initlang
               \def\blx@endlang{%
                 \blx@hook@endlang
                 \expandafter\end\expandafter{\blx@thelangenv}%
                 \endgroup}%
               \iftoggle{blx@autolangbib}
                 {\let\blx@endlangbib\blx@endlang}
                 {}%
               \iftoggle{blx@autolangcite}
                 {\let\blx@endlangcite\blx@endlang}
                 {}%
               \expandafter\expandafter\expandafter\begin
                 \expandafter\expandafter\expandafter{%
                   \expandafter\blx@thelangenv\expandafter}%
                     \expandafter{\abx@field@langid}}}
           {}}}
    {}%
  \def\blx@imc@mainlang{%
    \ifundef\blx@warn@mainlang
      {\blx@warning@noline{%
         '\string\mainlang' is deprecated in favour of\MessageBreak
         '\string\textmainlang'.%
         \MessageBreak
         Please consider using the new command,\MessageBreak
         but note that the syntax is different.\MessageBreak
         Using the old, problematic definition}%
       \global\let\blx@warn@mainlang\@empty}
      {}%
    \expandafter\selectlanguage\expandafter{\blx@main@language}}%
  \def\blx@imc@textmainlang##1{%
    {{\expandafter\selectlanguage\expandafter{\blx@main@language}##1}}}%
  \def\blx@imc@textouterlang##1{%
    {{\expandafter\selectlanguage\expandafter{\blx@outer@language}##1}}}%
  \expandafter\blx@langsetup@from@pkglist\expandafter{\blx@main@language}%
}

\def\blx@beglang@spacefactors{\frenchspacing}

\def\blx@mkautolangpoly{%
  \ifundef\mainbabelname
    {\ifundef\bbl@main@language
       {\blx@error
          {No default 'polyglossia' language defined}
          {You must define a default language for 'polyglossia'}}
       {\let\blx@main@language\bbl@main@language}}
    {\let\blx@main@language\mainbabelname}%
  \let\blx@outer@language\blx@main@language
  \ifundef\polyglossia@language@switched
    {\apptocmd\select@language
       {\expandafter\blx@langsetup@indoc\expandafter{\babelname}}
       {}
       {\blx@err@patch{'polyglossia' package}%
        \blx@mknoautolang}}
    {\appto\polyglossia@language@switched{%
       \expandafter\blx@langsetup@indoc\expandafter{\babelname}}}%
  \ifdef\blx@thelangenv
     {\def\blx@beglang{%
        \blx@clearlang
        \begingroup
        % track outer language (i.e. language not selected by biblatex)
        \ifundef\blx@outer@language@set
          {\let\blx@outer@language\blx@languagename
           \let\blx@outer@language@set\@empty}
          {}%
        % Need to override all entries, regardless of if there is a
        % langid if language=&lt;language&gt; option is given
        \ifboolexpr { test {\ifdef\abx@field@langid }
                      or
                      test {\ifdef\blx@forcelanguagename} }
          % override local langid if we forced it with
          % language=&lt;language&gt; option
          {\ifdef\blx@forcelanguagename
             {\let\abx@field@langid\blx@forcelanguagename}
             {}%
           \let\blx@languagename\abx@field@langid% track global language
           \blx@ifhyphenationundef{\abx@field@langid}
             {\blx@warn@nohyph{\abx@field@langid}}
             {\blx@hook@initlang
              \def\blx@endlang{%
                \blx@hook@endlang
                % Polyglossia language envs are \&lt;lang&gt;[]
                \ifcsstring{blx@thelangenv}{langname}
                  {\expandafter\end\expandafter{\abx@field@langid}}
                  {\expandafter\end\expandafter{\blx@thelangenv}}%
                \endgroup}%
              \iftoggle{blx@autolangbib}
                {\let\blx@endlangbib\blx@endlang}
                {}%
              \iftoggle{blx@autolangcite}
                {\let\blx@endlangcite\blx@endlang}
                {}%
              \ifcsstring{blx@thelangenv}{langname}
                {\ifdef\abx@field@langidopts
                   {\expandafter\expandafter\expandafter\begin
                      \expandafter\expandafter\expandafter{%
                        \expandafter\abx@field@langid\expandafter}%
                          \expandafter[\abx@field@langidopts]}
                   {\expandafter\begin\expandafter{\abx@field@langid}}}
                {\expandafter\expandafter\expandafter\begin
                   \expandafter\expandafter\expandafter{%
                     \expandafter\blx@thelangenv\expandafter}%
                       \expandafter{\abx@field@langid}}%
              \blx@beglang@spacefactors}}
          {}}}
       {}%
  \def\blx@imc@mainlang{%
    \ifundef\blx@warn@mainlang
      {\blx@warning@noline{%
         '\string\mainlang' is deprecated in favour of\MessageBreak
         '\string\textmainlang'.%
         \MessageBreak
         Please consider using the new command,\MessageBreak
         but note that the syntax is different.\MessageBreak
         Using the old, problematic definition}%
       \global\let\blx@warn@mainlang\@empty}
      {}%
    \select@language{\blx@main@language}}%
  \def\blx@imc@textmainlang##1{{{\select@language{\blx@main@language}##1}}}%
  \def\blx@imc@textouterlang##1{{{\select@language{\blx@outer@language}##1}}}%
  \expandafter\blx@langsetup@from@pkglist\expandafter{\blx@main@language}}

\def\blx@mknoautolang{%
  \blx@lbxinput{\blx@languagename}
    {}
    {\blx@err@nolang{\blx@languagename}}}

\blx@regimcs{\mainlang \textmainlang \textouterlang}

\newrobustcmd*{\DeclareRedundantLanguages}[2]{%
  \begingroup
  \ifblank{#2}
    {\def\do##1{%
       \global\csundef{blx@rlm@##1}%
       \global\csundef{blx@rlm@lang##1}}}
    {\def\do##1{%
       \csxdef{blx@rlm@##1}{#2}%
       \csxdef{blx@rlm@lang##1}{#2}}}%
  \docsvlist{#1}%
  \endgroup}

\def\blx@clearlang{%
  \iftoggle{blx@clearlang}
    {\iflistundef{language}
       {}
       {\ifnumgreater{\value{language}}{1}
          {}
          {\expandafter\blx@clearlang@i\abx@list@language}}}
    {}}

\def\blx@clearlang@i#1{%
  \ifcsdef{blx@rlm@#1}
    {\expandafter\expandafter\expandafter\forcsvlist
     \expandafter\expandafter\expandafter\blx@clearlang@ii
     \expandafter\expandafter\expandafter{%
       \csname blx@rlm@#1\endcsname}}
    {}}

\def\blx@clearlang@ii#1{%
  \ifdefstring\languagename{#1}
    {\clearlist{language}}
    {}}

%% Biber equivalents to bibtex data interface

\def\abx@doentrytypes{\dolistloop\blx@datamodel@entrytypes}

% fields which can be used as labels - we auto-create some macros for these
\def\abx@dolabelfields{\dolistloop\blx@datamodel@labelfields}
\def\abx@dolabelwidths{%
  \do{labelnumber}%
  \do{labelalpha}%
  \abx@dolabelfields}

\def\abx@donames{\dolistloop\blx@datamodel@names}
\def\abx@donameparts{\expandafter\docsvlist\expandafter{\blx@datamodel@constant@nameparts}}

\def\abx@dofields{\dolistloop\blx@datamodel@fields}

\def\abx@dolists{%
  \dolistloop\blx@datamodel@lists%
  \do{pageref}}

% Used to pass regexps to .bcf
\def\regexp#1{\expandafter\zap@space\detokenize{#1} \@empty}

% Have to do this otherwise the '~'s in the .bcf strings are not expanded
% This is done for the .bcf later but since we have to do all the
% data model things much earlier, have to set this here and reset on finishing
\let\blx@tsave~
\let~\space
% Data model and supporting macros must be loaded early
\blx@inputonce{blx-dm.def}{biblatex default data model}{}{}{}{}
\let~\blx@tsave

% We need to now load any style data model
% Order of precedence is:
% &lt;datamodel option&gt;.dbx
%   &lt;style option&gt;.dbx
%     &lt;citestyle option&gt;.dbx and &lt;bibstyle option&gt;.dbx
% This has to be done before the real options processing so we need to
% pick out just these four options to look at. You can't do this with keyval,
% you have to use kvoptions. So, pick out these four, pass through all
% others and delete datamodel option as we don't care about it when we come
% to really set options below
\SetupKeyvalOptions{
  family=blx@opt@eldt,
  prefix=blx@opt@eldt@}
\DeclareStringOption{datamodel}
\DeclareStringOption{style}
\DeclareStringOption{citestyle}
\DeclareStringOption{bibstyle}
\DeclareDefaultOption{}
\ProcessLocalKeyvalOptions{blx@opt@eldt}
\ifx\blx@opt@eldt@datamodel\@empty
  \ifx\blx@opt@eldt@style\@empty
    \ifx\blx@opt@eldt@citestyle\@empty
    \else
      \blx@inputonce{\blx@opt@eldt@citestyle.dbx}{biblatex citestyle data model}{}{}{}{}
    \fi
    \ifx\blx@opt@eldt@bibstyle\@empty
    \else
      \blx@inputonce{\blx@opt@eldt@bibstyle.dbx}{biblatex bibstyle data model}{}{}{}{}
    \fi
  \else
    \blx@inputonce{\blx@opt@eldt@style.dbx}{biblatex style data model}{}{}{}{}
  \fi
\else
  \blx@inputonce{\blx@opt@eldt@datamodel.dbx}{biblatex style data model}{}{}{}{}
\fi
\DisableKeyvalOption[action=undef,local]{blx@opt@eldt}{datamodel}

% Override with user-defined data model if there is one
\blx@inputonce{biblatex-dm.cfg}{biblatex custom data model}{}{}{}{}

% Initialise option datatypes lists
\global\let\blx@bcf@options@scope@global\@empty
\global\let\blx@bcf@options@scope@type\@empty
\global\let\blx@bcf@options@scope@entry\@empty
\global\let\blx@bcf@options@scope@namelist\@empty
\global\let\blx@bcf@options@scope@name\@empty
\global\let\blx@globalopts@datatypes\@empty
\global\let\blx@typeopts@datatypes\@empty
\global\let\blx@entryopts@datatypes\@empty
\global\let\blx@namelistopts@datatypes\@empty
\global\let\blx@nameopts@datatypes\@empty
\def\do#1{%
  \global\cslet{blx@globalopts@#1}\@empty
  \global\cslet{blx@typeopts@#1}\@empty
  \global\cslet{blx@entryopts@#1}\@empty
  \global\cslet{blx@namelistopts@#1}\@empty
  \global\cslet{blx@nameopts@#1}\@empty}
\expandafter\expandafter\expandafter
\docsvlist
\expandafter\expandafter\expandafter
{\csname blx@datamodel@constant@optiondatatypes\endcsname}

% Helper for collecting options and datatypes
% {&lt;datatype&gt;}{&lt;scope&gt;}{&lt;name&gt;}
\def\blx@collectopts#1#2#3{%
  \ifinlistcs{#1}{#2@datatypes}
    {}
    {\listcsgadd{#2@datatypes}{#1}}%
  \ifinlistcs{#3}{#2@#1}
    {}
    {\listcsgadd{#2@#1}{#3}}}


% entry, namelist, name scopes are input/handled on the backend side
% if we want to see the info back on the biblatex side, we need the backend
% to pass the info through via the .bbl file
\def\blx@declareblxopt@extrahandler@entry#1{%
  \csgdef{blx@bcf@backendout@entry@#1}{1}}
\def\blx@declareblxopt@extrahandler@namelist#1{%
  \csgdef{blx@bcf@backendout@namelist@#1}{1}}
\def\blx@declareblxopt@extrahandler@name#1{%
  \csgdef{blx@bcf@backendout@name@#1}{1}}

% {&lt;option scope&gt;}[&lt;datatype&gt;]{&lt;key&gt;}[&lt;value&gt;]{&lt;code&gt;}
\protected\def\blx@declareblxopt#1{%
  \@ifnextchar[%]
    {\blx@declareblxopt@i#1}
    {\blx@declareblxopt@i#1[]}}

\def\blx@declareblxopt@i#1[#2]#3{%
  \begingroup
  \ifblank{#2}
    {\def\blx@tempa{boolean}}
    {\ifcsundef{blx@#1opts@#2}
       {\blx@warn@badoptdt{#2}%
        \def\blx@tempa{boolean}}
       {\def\blx@tempa{#2}}}%
  \expandafter\blx@collectopts\expandafter{\blx@tempa}{blx@#1opts}{#3}%
  \ifcsundef{blx@declareblxopt@extrahandler@#1}
    {}
    {\csuse{blx@declareblxopt@extrahandler@#1}{#3}}%
  \endgroup
  \@ifnextchar[%]
    {\csuse{blx@defblxopt@#1opt}{#3}}
    {\csuse{blx@defblxopt@#1opt}{#3}[]}}

\long\def\blx@defblxopt@globalopt#1[#2]#3{%
  \blx@kv@ifkeyundef{blx@opt@ldt}{#1}
    {\blx@kv@ifkeyundef{blx@opt@pre}{#1}
       {\ifblank{#2}
          {\blx@kv@defkey{blx@opt@pre}{#1}{#3}}
          {\blx@kv@defkey{blx@opt@pre}{#1}[{#2}]{#3}}}
       {\blx@err@optdef{#1}{pre/global}}}
    {\blx@err@optdef{#1}{ldt/global}}}

\long\def\blx@defblxopt@typeentryopt#1#2[#3]#4{%
  \blx@kv@ifkeyundef{blx@opt@#1}{#2}
    {\ifblank{#3}
       {\blx@kv@defkey{blx@opt@#1}{#2}{#4}}
       {\blx@kv@defkey{blx@opt@#1}{#2}[{#3}]{#4}}}
    {\blx@err@optdef{#2}{#1}}}

\def\blx@defblxopt@typeopt{\blx@defblxopt@typeentryopt{typ}}
\def\blx@defblxopt@entryopt{\blx@defblxopt@typeentryopt{ent}}
\def\blx@defblxopt@nameopt{\blx@defblxopt@typeentryopt{name}}
\def\blx@defblxopt@namelistopt{\blx@defblxopt@typeentryopt{namelist}}

% The Declare*Option macros are for options which need to be visible
% to biblatex. For options which only biber needs to see, they can be
% passed to the .bcf directly using \blx@collectopts
% [&lt;datatype&gt;]{&lt;key&gt;}[&lt;default value&gt;]{&lt;code&gt;}
\newcommand*{\DeclareBibliographyOption}{\blx@declareblxopt{global}}
\newcommand*{\DeclareTypeOption}{\blx@declareblxopt{type}}
\newcommand*{\DeclareEntryOption}{\blx@declareblxopt{entry}}

% we'll assume that \blx@optscopes is non-empty from now on
\newcommand*{\blx@optscopes}{}
\forcsvlist{\listadd\blx@optscopes}{global,type,entry}

\long\def\blx@defblxopt@loopscopes@i#1[#2]#3#4{%
  \csuse{blx@defblxopt@#4opt}{#1}[{#2}]{#3}}

\long\def\blx@defblxopt@loopscopes#1[#2]#3{%
  \forlistloop{\blx@defblxopt@loopscopes@i{#1}[{#2}]{#3}}{\blx@optscopes}}

% {&lt;option scopes&gt;}[&lt;datatype&gt;]{&lt;key&gt;}[&lt;default value&gt;]{&lt;code&gt;}
\newrobustcmd*{\DeclareBiblatexOption}[1]{%
  \let\blx@optscopes\@empty
  \forcsvlist{\listadd\blx@optscopes}{#1}%
  \blx@DeclareBiblatexOption@i}

\newrobustcmd*{\blx@DeclareBiblatexOption@i}[2][]{%
  \begingroup
  \ifblank{#1}
    {\def\blx@tempa{boolean}}
    {\let\blx@tempb\@secondoftwo
     \def\do##1{%
       \ifcsundef{blx@##1opts@#1}
         {\let\blx@tempb\@firstoftwo\listbreak}
         {}}%
     \dolistloop{\blx@optscopes}%
     \blx@tempb
       {\blx@warn@badoptdt{#1}%
        \def\blx@tempa{boolean}}
       {\def\blx@tempa{#1}}}%
  \def\do##1{%
    \expandafter\blx@collectopts\expandafter{\blx@tempa}{blx@##1opts}{#2}%
    \ifcsundef{blx@declareblxopt@extrahandler@##1}
      {}
      {\csuse{blx@declareblxopt@extrahandler@##1}{#2}}}%
  \dolistloop{\blx@optscopes}%
  \endgroup
  \@ifnextchar[%]
    {\blx@defblxopt@loopscopes{#2}}
    {\blx@defblxopt@loopscopes{#2}[]}}

% this macro is internal for now because options declared with it need
% support on the backend side and are not useful for document or style authors
% {&lt;option scopes&gt;}[&lt;datatype&gt;]{&lt;key&gt;}
\newrobustcmd*{\blx@DeclareBackendOption}[1]{%
  \let\blx@optscopes\@empty
  \forcsvlist{\listadd\blx@optscopes}{#1}%
  \blx@DeclareBackendOption@i}

\newrobustcmd*{\blx@DeclareBackendOption@i}[2][]{%
  \begingroup
  \ifblank{#1}
    {\def\blx@tempa{boolean}}
    {\let\blx@tempb\@secondoftwo
     \def\do##1{%
       \ifcsundef{blx@##1opts@#1}
         {\let\blx@tempb\@firstoftwo\listbreak}
         {}}%
     \dolistloop{\blx@optscopes}%
     \blx@tempb
       {\blx@warn@badoptdt{#1}%
        \def\blx@tempa{boolean}}
       {\def\blx@tempa{#1}}}%
  \def\do##1{%
    \expandafter\blx@collectopts\expandafter{\blx@tempa}{blx@##1opts}{#2}}%
  \dolistloop{\blx@optscopes}%
  \endgroup}

% per-entry inheritance blocking option for biber
\blx@DeclareBackendOption{entry}[string]{noinherit}


% nametemplates meta-option entry/namelist/name scope
% this meta option is resolved by Biber
\blx@DeclareBackendOption{entry,namelist,name}[string]{nametemplates}
\gdef\blx@bcf@backendin@entry@nametemplates{sortingnamekeytemplatename,%
  uniquenametemplatename,labelalphanametemplatename,namehashtemplatename}%
\gdef\blx@bcf@backendin@namelist@nametemplates{sortingnamekeytemplatename,%
  uniquenametemplatename,labelalphanametemplatename,namehashtemplatename}%
\gdef\blx@bcf@backendin@name@nametemplates{sortingnamekeytemplatename,%
  uniquenametemplatename,labelalphanametemplatename,namehashtemplatename}%



% Misc globalopts
\blx@DeclareBackendOption{global}[xml]{datamodel}
\blx@collectopts{string}{blx@globalopts}{controlversion}

\newcommand*{\labelalphaothers}{+}
\newcommand*{\sortalphaothers}{\labelalphaothers}
\blx@DeclareBackendOption{global,type}[string]{alphaothers}
\blx@DeclareBackendOption{global,type}[string]{sortalphaothers}

% date, eventdate, urldate etc.
\def\abx@dodates{\dolistloop\blx@datamodel@dates}
% year, endyear, month, endmonth etc.
\def\abx@dodateparts{\expandafter\docsvlist\expandafter{\blx@dateparts}}

% '', event, url, orig etc.
\def\do#1{%
  \blx@stripfromendinto{#1}{date}\blx@datetype
  \listxadd\blx@datetypes{\blx@datetype}}
\abx@dodates
% main date field has an empty prefix (''date) which can't be added to a list
% and so do it explicity
% This is one of the few (only?) hard-coded datamodel assumptions but it is
% very unlikely that anyone would *remove* the main date field in a custom application ...
\def\abx@dodatetypes{\do{}\dolistloop\blx@datetypes}

% Sanity check on date field names - they *must* end in 'date' to make things easier/possible later
\def\do#1{%
  \blx@ifstrendswith{#1}{date}
    {}
    {\blx@error
       {Invalid date field name '#1'}
       {Date fields in the datamodel must end in the string 'date' but '#1' doesn't}}}
\abx@dodates

% date meta-information option fallbacks
\def\do#1{%
  \cslet{#1datecircaprint}\@empty
  \cslet{#1enddatecircaprint}\@empty
  \cslet{#1datecircaprintiso}\@empty
  \cslet{#1enddatecircaprintiso}\@empty
  \cslet{#1dateuncertainprint}\@empty
  \cslet{#1enddateuncertainprint}\@empty
  \cslet{#1dateeraprint}\@gobble
  \cslet{#1dateeraprintpre}\@gobble
  \csdef{if#1dateera}##1{\@secondoftwo}%
  \csdef{if#1enddateera}##1{\@secondoftwo}%
  \cslet{if#1datecirca}\@secondoftwo
  \cslet{if#1enddatecirca}\@secondoftwo
  \cslet{if#1datejulian}\@secondoftwo
  \cslet{if#1enddatejulian}\@secondoftwo
  \cslet{if#1dateuncertain}\@secondoftwo
  \cslet{if#1enddateuncertain}\@secondoftwo
  \cslet{if#1dateunknown}\@secondoftwo
  \cslet{if#1enddateunknown}\@secondoftwo}
\abx@dodatetypes
\do{labeldate}

% These are internal fields/booleans which are not part of the data model but
% which need to be dealt with along with data model fields in places
\def\do#1{%
  \listxadd\blx@datemetafields{#1dateera}%
  \listxadd\blx@datemetafields{#1enddateera}%
  \listxadd\blx@datemetafields{#1dateunspecified}}
\abx@dodatetypes


\def\do#1{%
  \listxadd\blx@datemetabooleans{#1datecirca}%
  \listxadd\blx@datemetabooleans{#1enddatecirca}%
  \listxadd\blx@datemetabooleans{#1datejulian}%
  \listxadd\blx@datemetabooleans{#1enddatejulian}%
  \listxadd\blx@datemetabooleans{#1dateuncertain}%
  \listxadd\blx@datemetabooleans{#1enddateuncertain}%
  \listxadd\blx@datemetabooleans{#1dateunknown}%
  \listxadd\blx@datemetabooleans{#1enddateunknown}}
\abx@dodatetypes

\def\do#1{%
  \listxadd\blx@namepartmetafields{#1namehash}%
  \listxadd\blx@namepartmetafields{#1fullhash}%
  \listxadd\blx@namepartmetafields{#1fullhashraw}%
  \listxadd\blx@namepartmetafields{#1bibnamehash}}
\abx@donameparts

\def\do#1{%
  \listxadd\blx@labeldatepartfields{label#1}}
\abx@dodateparts

\def\abx@dointernalfields{%
  \do{clonesourcekey}%
  \do{labeldate}%
  \do{labeldatesource}%
  \do{labeldateera}%
  \do{labelenddateera}%
  \do{labelyear}%
  \do{labelendyear}%
  \do{labelmonth}%
  \do{labelendmonth}%
  \do{labelday}%
  \do{labelendday}%
  \do{labelhour}%
  \do{labelendhour}%
  \do{labelminute}%
  \do{labelendminute}%
  \do{labelsecond}%
  \do{labelendsecond}%
  \do{labeltimezone}%
  \do{labelendtimezone}%
  \do{labelyeardivision}%
  \do{labelendyeardivision}%
  \do{entrykey}%
  \do{entryset}%
  \do{entrysetcount}%
  \do{entrytype}%
  \do{extraalpha}%
  \do{extraname}%
  \do{extratitle}%
  \do{extratitleyear}%
  \do{extradate}%
  \do{fullhash}%
  \do{fullhashraw}%
  \do{labelalpha}%
  \do{labelnumber}%
  \do{labelprefix}%
  \do{labeltitleyear}%
  \do{localnumber}%
  \do{namehash}%
  \do{bibnamehash}%
  \do{options}%
  \do{sortinit}%
  \do{sortinithash}%
  \dolistloop\blx@datemetafields
  \dolistloop\blx@namepartmetafields
  \dolistloop\blx@labeldatepartfields}

\def\abx@dobooleans{%
  \do{crossrefsource}%
  \do{xrefsource}%
  \do{singletitle}%
  \do{uniquetitle}%
  \do{uniquebaretitle}%
  \do{uniquework}%
  \do{uniqueprimaryauthor}%
  \do{nocite}%
  \dolistloop\blx@datemetabooleans}

% Date datatype fields
\def\do#1{%
  \protected\csdef{blx@imc@print#1date}{}%
  \protected\csdef{blx@imc@print#1dateextra}{}%
  \protected\csdef{blx@imc@print#1time}{}}
\abx@dodatetypes

% \blx@regimcs doesn't work in do-lists nicely so use internal macro it calls
\def\do#1{%
  \xappto\blx@blxinit{\csletcs{print#1date}{blx@imc@print#1date}}%
  \xappto\blx@blxinit{\csletcs{print#1time}{blx@imc@print#1time}}%
  \xappto\blx@blxinit{\csletcs{print#1dateextra}{blx@imc@print#1dateextra}}}
\abx@dodatetypes

% Set up circa, julian and uncertain date internals
\def\blx@makeifdatemeta@bools@i#1#2{%
  \appto\blx@blxinit{%
    \blx@makeifdatemeta@bools{#1}{#2}}}

\def\blx@makeifdatemeta@bools#1#2{%
  \csdef{if#1date#2}{\iftoggle{abx@bool@#1date#2}}%
  \csdef{if#1enddate#2}{\iftoggle{abx@bool@#1enddate#2}}%
  \appto\blx@TE@hook{%
    \csdef{if#1date#2}{\blx@TE{\iftoggle{abx@bool@#1date#2}}}%
    \csdef{if#1enddate#2}{\blx@TE{\iftoggle{abx@bool@#1enddate#2}}}}}

% Set up date era internals
\def\blx@makeifdatemeta@fields@i#1{%
  \appto\blx@blxinit{%
    \blx@makeifdatemeta@fields{#1}}}

\def\blx@makeifdatemeta@fields#1{%
  \csdef{if#1dateera}##1{\ifcsstring{abx@field@#1dateera}{##1}}%
  \csdef{if#1enddateera}##1{\ifcsstring{abx@field@#1enddateera}{##1}}%
  \appto\blx@TE@hook{%
    \csdef{if#1dateera}##1{\blx@TE{\ifcsstring{abx@field@#1dateera}{##1}}}%
    \csdef{if#1enddateera}##1{\blx@TE{\ifcsstring{abx@field@#1enddateera}{##1}}}}}

% Create date meta information boolean tests
\def\do#1{%
  \blx@makeifdatemeta@bools@i{#1}{circa}%
  \blx@makeifdatemeta@bools@i{#1}{julian}%
  \blx@makeifdatemeta@bools@i{#1}{uncertain}%
  \blx@makeifdatemeta@bools@i{#1}{unknown}}
\abx@dodatetypes

% Create date meta information field tests
\def\do#1{%
  \blx@makeifdatemeta@fields@i{#1}}
\abx@dodatetypes

% Resolve date meta information tests and print routines for labeldate
% We have to test here, in each \def, whether the labeldatesource
% is a real date field or not. If it's not, then we don't want to use
% any of the meta-information and so make the conditionals always return false
% This can't be neater by testing for the \abx@field@labeldatesource value
% earlier because its not available until the tests are in scope.
\appto\blx@blxinit{%
   \ifdefstring\blx@dateera{astronomical}
     {\protected\def\dateeraprintpre#1{%
        \iffieldnum{#1}
          {\begingroup
           \let\blx@tempa\@empty
           \blx@ifstrendswith{#1}{endyear}
             {\blx@stripfromendinto{#1}{endyear}\blx@datetype
              \def\blx@tempa{end}}
             {\blx@stripfromendinto{#1}{year}\blx@datetype}%
           \csuse{if\blx@datetype\blx@tempa dateera}{bce}
             {\ifnumless{0-\thefield{#1}}{0}
               {\csuse{bibdateera\blx@tempa prefix}}
               {}}
             {}%
           \endgroup}
          {}}}
     {\protected\def\dateeraprint#1{%
        \iffieldnum{#1}
          {\begingroup
           \let\blx@tempa\@empty
           \blx@ifstrendswith{#1}{endyear}
             {\blx@stripfromendinto{#1}{endyear}\blx@datetype
              \def\blx@tempa{end}}
             {\blx@stripfromendinto{#1}{year}\blx@datetype}%
           \csuse{if\blx@datetype\blx@tempa dateera}{bce}
             {\ifnum\numexpr0-\thefield{#1}\relax&lt;\blx@dateeraauto
                % \midsentence is to suppress automatic capitalisation
                \printdelim{dateeradelim}\midsentence\bibstring{\blx@dateera@bce}\relax
              \fi}
             {\ifnumless{\thefield{#1}}\blx@dateeraauto
               {\printdelim{dateeradelim}\midsentence\bibstring{\blx@dateera@ce}}
               {}}%
           \endgroup}
          {}}}%
  \iftoggle{blx@labeldateparts}
    {\def\iflabeldateera#1{% start era
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\ifcsstring{abx@field@\abx@field@labeldatesource dateera}{#1}}
         {\@secondoftwo}}%
     \appto\blx@TE@hook{\def\iflabeldateera#1{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\blx@TE{\ifcsstring{abx@field@\abx@field@labeldatesource dateera}{#1}}}
         {\@secondoftwo}}}%
     % end era
     \def\iflabelenddateera#1{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\ifcsstring{abx@field@\abx@field@labeldatesource enddateera}{#1}}
         {\@secondoftwo}}%
     \appto\blx@TE@hook{\def\iflabelenddateera#1{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\blx@TE{\ifcsstring{abx@field@\abx@field@labeldatesource enddateera}{#1}}}
         {\@secondoftwo}}}%
     % start circa
     \def\iflabeldatecirca{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\iftoggle{abx@bool@\abx@field@labeldatesource datecirca}}
         {\@secondoftwo}}%
     \appto\blx@TE@hook{\def\iflabeldatecirca{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\blx@TE{\iftoggle{abx@bool@\abx@field@labeldatesource datecirca}}}
         {\@secondoftwo}}}%
     % end circa
     \def\iflabelenddatecirca{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\iftoggle{abx@bool@\abx@field@labeldatesource enddatecirca}}
         {\@secondoftwo}}%
     \appto\blx@TE@hook{\def\iflabelenddatecirca{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\blx@TE{\iftoggle{abx@bool@\abx@field@labeldatesource enddatecirca}}}
         {\@secondoftwo}}}%
     % start julian
     \def\iflabeldatejulian{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\iftoggle{abx@bool@\abx@field@labeldatesource datejulian}}
         {\@secondoftwo}}%
     \appto\blx@TE@hook{\def\iflabeldatejulian{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\blx@TE{\iftoggle{abx@bool@\abx@field@labeldatesource datejulian}}}
         {\@secondoftwo}}}%
     % end julian
     \def\iflabelenddatejulian{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\iftoggle{abx@bool@\abx@field@labeldatesource enddatejulian}}
         {\@secondoftwo}}%
     \appto\blx@TE@hook{\def\iflabelenddatejulian{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\blx@TE{\iftoggle{abx@bool@\abx@field@labeldatesource enddatejulian}}}
         {\@secondoftwo}}}%
     % start uncertain
     \def\iflabeldateuncertain{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\iftoggle{abx@bool@\abx@field@labeldatesource dateuncertain}}
         {\@secondoftwo}}%
     \appto\blx@TE@hook{\def\iflabeldateuncertain{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\blx@TE{\iftoggle{abx@bool@\abx@field@labeldatesource dateuncertain}}}
         {\@secondoftwo}}}%
     % end uncertain
     \def\iflabelenddateuncertain{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\iftoggle{abx@bool@\abx@field@labeldatesource enddateuncertain}}
         {\@secondoftwo}}%
     \appto\blx@TE@hook{\def\iflabelenddateuncertain{%
       \xifinlist{\abx@field@labeldatesource date}\blx@datamodel@dates
         {\blx@TE{\iftoggle{abx@bool@\abx@field@labeldatesource enddateuncertain}}}
         {\@secondoftwo}}}}%
  {}}

% Name toggles like \ifauthor etc. need to be dynamically created for all
% name datatypes in the data model and we have to do this here after the
% datamodel is available. Need to be careful about expansions here as these
% go into hooks to be executed later

% toggle to say if we have set any &lt;name&gt;inits to true. Used for conflict
% tests with uniquename settings (see \AtEndPreamble below)
\newtoggle{abx@bool@xinits}
% define &lt;name&gt;inits options and tests (terseinits is global for all initials)
\def\do#1{%
  \newtoggle{abx@bool@#1inits}%
  \appto\blx@blxinit{%
    \csdef{if#1inits}{\iftoggle{abx@bool@#1inits}}%
    \appto\blx@TE@hook{%
      \csdef{if#1inits}{\blx@TE{\iftoggle{abx@bool@#1inits}}}}}%
  \DeclareBiblatexOption{global,type,entry,namelist,name}[boolean]{#1inits}[true]{%
    \settoggle{abx@bool@#1inits}{##1}}}
\abx@donameparts

\def\do#1{%
  % Define use&lt;name&gt; options scope for biber
  \blx@DeclareBackendOption{global,type,entry}[boolean]{use#1}%
  % Define name toggles
  \newtoggle{blx@use#1}\toggletrue{blx@use#1}%
  % Define tests
  \appto\blx@blxinit{%
    \csdef{ifuse#1}{\iftoggle{blx@use#1}}%
    \appto\blx@TE@hook{%
      \csdef{ifuse#1}{\blx@TE{\iftoggle{blx@use#1}}}}}}
\abx@donames

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% Since these are bare counters which define \the&lt;string&gt;, save any current values
% (memoir, titling, koma etc. have a \theauthor macro, for example) and restore at
% end of package
\def\do#1{%
  \csletcs{blx@compat@the#1}{the#1}%
  \newcounter{#1}%
  \newcounter{saved#1}%
  \appto\abx@dobooleans{\do{more#1}}}

\abx@donames
\abx@dornames
\abx@dolists
%\abx@dorlists

\AtEndOfPackage{%
  \def\do#1{\csletcs{the#1}{blx@compat@the#1}}%
  \abx@donames
  \abx@dornames
  \abx@dolists}

\def\do#1{\newtoggle{abx@bool@#1}}
\abx@dobooleans

\def\do#1{\expandafter\newlength\expandafter{\csname #1width\endcsname}}
\abx@dolabelfields

\def\do#1{\expandafter\newlength\expandafter{\csname local#1width\endcsname}}
\abx@dolabelwidths

\protected\def\blx@resetdata{%
  \let\blx@saved@do\do
  \let\do\blx@imc@clearname
  \abx@donames
  \let\do\blx@imc@clearlist
  \abx@dolists
  \let\do\blx@imc@clearfield
  \abx@dofields
  \abx@dointernalfields
  \ifundef\abx@annotation@defined
    {}
    {\def\do##1{\csundef{abx@annotation@##1}}%
     \dolistloop\abx@annotation@defined}%
  \let\abx@annotation@defined\@empty
  \def\do##1{\togglefalse{abx@bool@##1}}%
  \abx@dobooleans
  \let\do\blx@saved@do
  \c@citecounter\z@
  \iftoggle{blx@bibliography}
    {\c@maxnames\blx@maxbibnames\relax
     \c@minnames\blx@minbibnames\relax}
    {\c@maxnames\blx@maxcitenames\relax
     \c@minnames\blx@mincitenames\relax}%
  \c@maxitems\blx@maxitems\relax
  \c@minitems\blx@minitems\relax}

\protected\def\blx@saveentry{%
  \let\blx@saved@do\do
  \let\do\blx@savename
  \abx@donames
  \let\do\blx@saverelname
  \dolistloop\abx@dorelnames
  \let\do\blx@savelist
  \abx@dolists
  \let\do\blx@saverellist
  \dolistloop\abx@dorellists
  \let\do\blx@savefield
  \abx@dofields
  \abx@dointernalfields
  \let\do\blx@saverelfield
  \dolistloop\abx@dorelfields
  \ifundef\abx@savedannotation@defined
    {}
    {\def\do##1{\csundef{abx@annotation@\blx@saveannotations@makesaved##1}}%
     \dolistloop\abx@savedannotation@defined}%
  \let\abx@savedannotation@defined\@empty
  \ifundef\abx@annotation@defined
    {}
    {\let\do\blx@saveannotations
     \dolistloop\abx@annotation@defined}%
  \let\abx@savedannotation@defined\abx@annotation@defined
  \let\do\blx@savebool
  \abx@dobooleans
  \let\do\blx@savedatetype
  \abx@dodatetypes
  \do{label}%
  \c@savedcitecounter\c@citecounter
  \let\do\blx@saved@do}

\protected\def\blx@savename#1{%
  \csletcs{etb@tgl@abx@bool@moresaved#1}{etb@tgl@abx@bool@more#1}%
  \csletcs{abx@name@saved#1}{abx@name@#1}%
  \csname c@saved#1\endcsname\csname c@#1\endcsname}

% override with name saved from \clearfield for related processing
\protected\def\blx@saverelname#1{%
  \csletcs{etb@tgl@abx@bool@moresaved#1}{etb@tgl@abx@bool@morerelsaved#1}%
  \csletcs{abx@name@saved#1}{abx@name@relsaved#1}%
  \csname c@saved#1\endcsname\csname c@relsaved#1\endcsname}

\protected\def\blx@savelist#1{%
  \csletcs{etb@tgl@abx@bool@moresaved#1}{etb@tgl@abx@bool@more#1}%
  \csletcs{abx@list@saved#1}{abx@list@#1}%
  \csname c@saved#1\endcsname\csname c@#1\endcsname}

% override with list saved from \clearfield for related processing
\protected\def\blx@saverellist#1{%
  \csletcs{etb@tgl@abx@bool@moresaved#1}{etb@tgl@abx@bool@morerelsaved#1}%
  \csletcs{abx@list@saved#1}{abx@list@relsaved#1}%
  \csname c@saved#1\endcsname\csname c@relsaved#1\endcsname}

\protected\def\blx@savefield#1{%
  \csletcs{abx@field@saved#1}{abx@field@#1}}

% override with field saved from \clearfield for related processing
\protected\def\blx@saverelfield#1{%
  \csletcs{abx@field@saved@#1}{abx@field@relsaved#1}}

\protected\def\blx@savebool#1{%
  \csletcs{etb@tgl@abx@bool@saved#1}{etb@tgl@abx@bool@#1}}

\protected\def\blx@savedatetype#1{%
  \csletcs{blx@dateformat@saved#1date}{blx@dateformat@#1date}%
  \protected\csedef{blx@imc@printsaved#1date}{%
    \noexpand\csuse{mkdaterange\csuse{blx@dateformat@saved#1date}}
      {saved#1}}%
  \protected\csedef{blx@imc@printsaved#1dateextra}{%
    \begingroup
      % extradate is hard-coded in date macros, so reset it temporarily
      \csletcs{abx@field@extradate}{abx@field@savedextradate}%
      \noexpand\csuse{mkdaterange\csuse{blx@dateformat@saved#1date}extra}
        {saved#1}%
    \endgroup}%
  \csletcs{blx@timeformat@saved#1time}{blx@timeformat@#1time}%
  \protected\csedef{blx@imc@printsaved#1time}{%
    \noexpand\csuse{mktimerange\csuse{blx@timeformat@saved#1time}}
      {saved#1}}%
  \csletcs{etb@tgl@blx@saved#1dateusetime}{etb@tgl@blx@#1dateusetime}%
  % the datemetabooleans are here again for labeldate
  \blx@savebool{#1datecirca}%
  \blx@savebool{#1enddatecirca}%
  \blx@savebool{#1datejulian}%
  \blx@savebool{#1enddatejulian}%
  \blx@savebool{#1dateuncertain}%
  \blx@savebool{#1enddateuncertain}%
  \blx@savebool{#1dateunknown}%
  \blx@savebool{#1enddateunknown}%
  \blx@makeifdatemeta@bools{saved#1}{circa}%
  \blx@makeifdatemeta@bools{saved#1}{julian}%
  \blx@makeifdatemeta@bools{saved#1}{uncertain}%
  \blx@makeifdatemeta@bools{saved#1}{unknown}%
  \blx@makeifdatemeta@fields{saved#1}%
  \csletcs{printsaved#1date}{blx@imc@printsaved#1date}%
  \csletcs{printsaved#1time}{blx@imc@printsaved#1time}%
  \csletcs{printsaved#1dateextra}{blx@imc@printsaved#1dateextra}}

\def\blx@saveannotations@makesaved#1@#2{#1@saved#2}
\protected\def\blx@saveannotations#1{%
  \csletcs{abx@annotation@\blx@saveannotations@makesaved#1}{abx@annotation@#1}}

% {&lt;code&gt;}
\protected\long\def\blx@bbl@preamble#1{%
  \gappto\abx@preamble{#1}}

% {&lt;message&gt;}
\protected\def\blx@bbl@warn#1{%
  \begingroup
  \def\item{\MessageBreak-\space}%
  \def\break{\MessageBreak\space\space}%
  \blx@warning@noline{%
    Biber reported the following issues%
    \ifdef\abx@field@entrykey
      {\MessageBreak with '\abx@field@entrykey'}
      {}%
    :#1}%
  \endgroup}

% {&lt;field&gt;}{&lt;code&gt;}
\newrobustcmd{\DeclareFieldInputHandler}[2]{%
  \ifblank{#2}
    {\csundef{blx@fih@#1}}
    {\long\csdef{blx@fih@#1}##1{#2}}}
\@onlypreamble\DeclareFieldInputHandler

% {&lt;list&gt;}{&lt;code&gt;}
\newrobustcmd*{\DeclareListInputHandler}[2]{%
  \ifblank{#2}
    {\csundef{blx@lih@#1}}
    {\csdef{blx@lih@#1}##1{#2}}}
\@onlypreamble\DeclareListInputHandler

% {&lt;name&gt;}{&lt;code&gt;}
\newrobustcmd*{\DeclareNameInputHandler}[2]{%
  \ifblank{#2}
    {\csundef{blx@nih@#1}}
    {\csdef{blx@nih@#1}##1{#2}}}
\@onlypreamble\DeclareNameInputHandler

% {&lt;entrykey&gt;}{&lt;refsection&gt;}{&lt;field&gt;}{&lt;refcontext&gt;}{&lt;value&gt;}
\long\def\blx@bbl@addentryfield#1#2#3#4#5{%
  \csxappto{blx@data@#2@#4@#1}{%
    \def\expandafter\noexpand\csname abx@field@#3\endcsname{#5}}}

% {&lt;rangefield&gt;}{&lt;value&gt;}
\protected\def\blx@bbl@rangedef#1#2{%
  \csxappto\blx@bbl@data{%
    \def\expandafter\noexpand\csname abx@range@#1\endcsname{#2}}}

% {&lt;field&gt;}{&lt;value&gt;}
\long\def\blx@bbl@addfield#1#2{%
  \csxappto\blx@bbl@data{%
    \def\expandafter\noexpand\csname abx@field@#1\endcsname{#2}}}

\protected\long\def\blx@bbl@fielddef#1#2{%
  \def\NewValue{#2}%
  \ifcsdef{blx@fih@#1}
    {\csname blx@fih@#1\endcsname{#2}%
     \ifdefvoid\NewValue}
    {\@secondoftwo}
       {}
       {\blx@bbl@addfield{#1}{\expandonce\NewValue}}}

\protected\long\def\blx@bbl@fieldedef#1#2{%
  \edef\NewValue{#2}%
  \ifcsdef{blx@fih@#1}
    {\csname blx@fih@#1\expandafter
     \endcsname\expandafter{\NewValue}%
     \ifdefvoid\NewValue}
    {\@secondoftwo}
       {}
       {\blx@bbl@addfield{#1}{\NewValue}}}

\protected\long\def\blx@bbl@stringdef#1#2{%
  \begingroup
  \edef\blx@tempa{\endgroup
    \blx@bbl@fielddef{#1}{\detokenize{#2}}}%
  \blx@tempa}

% Verbatim lists
% {&lt;list&gt;}{&lt;listcount&gt;}
\protected\def\blx@bbl@verbldef#1#2{%
  \begingroup
  \let\lverb\blx@bbl@verbladd
  \def\blx@tempa{#1}%
  \def\blx@tempb{#2}%
  \let\blx@tempc\@empty
  \let\NewValue\@empty}

\protected\def\blx@bbl@verblend{%
  \expandafter\blx@bbl@listdef\expandafter{\expandafter\blx@tempa\expandafter}\expandafter{\expandafter\blx@tempb\expandafter}\expandafter{\blx@tempc}%
  \endgroup}

\protected\def\blx@bbl@verbladd{%
  \begingroup
  \let\do\@makeother
  \dospecials
  \catcode\endlinechar=12\relax
  \blx@bbl@verbladd@i}

% Verbatim fields
% {&lt;field&gt;}
\protected\def\blx@bbl@verbdef#1{%
  \begingroup
  \let\verb\blx@bbl@verbadd
  \def\blx@tempa{#1}%
  \let\NewValue\@empty}

\protected\def\blx@bbl@verbend{%
  \ifcsdef{blx@fih@\blx@tempa}
    {\csname blx@fih@\blx@tempa\expandafter
     \endcsname\expandafter{\NewValue}%
     \ifdefvoid\NewValue}
    {\@secondoftwo}
       {}
       {\blx@bbl@addfield{\blx@tempa}{\NewValue}}%
  \endgroup}

\protected\def\blx@bbl@verbadd{%
  \begingroup
  \let\do\@makeother
  \dospecials
  \catcode\endlinechar=12\relax
  \blx@bbl@verbadd@i}

% {&lt;scope&gt;}{&lt;field&gt;}{&lt;name&gt;}{&lt;itemcount&gt;}{&lt;part&gt;}{&lt;isliteral&gt;}{&lt;value&gt;}
\protected\def\blx@bbl@annotationdef#1#2#3#4#5#6#7{%
  \ifstrequal{#1}{field}
     {\csxappto\blx@bbl@data{%
        \listadd\noexpand\abx@annotation@defined{field@#2@#3}}%
      \ifstrequal{#6}{1}
        {\csgappto\blx@bbl@data{%
           \csdef{abx@annotation@literal@field@#2@#3}{#7}}}
        {\csxappto\blx@bbl@data{%
           \def\do####1{\listcsadd{abx@annotation@field@#2@#3}{####1}}%
           \docsvlist{#7}}}}
     {}%
  \ifstrequal{#1}{item}
     {\csxappto\blx@bbl@data{%
        \listadd\noexpand\abx@annotation@defined{item@#2@#3@#4}}%
      \ifstrequal{#6}{1}
        {\csgappto\blx@bbl@data{%
           \csdef{abx@annotation@literal@item@#2@#3@#4}{#7}}}
        {\csxappto\blx@bbl@data{%
           \def\do####1{\listcsadd{abx@annotation@item@#2@#3@#4}{####1}}%
           \docsvlist{#7}}}}
     {}%
  \ifstrequal{#1}{part}
     {\csxappto\blx@bbl@data{%
        \listadd\noexpand\abx@annotation@defined{part@#2@#3@#4@#5}}%
      \ifstrequal{#6}{1}
        {\csgappto\blx@bbl@data{%
           \csdef{abx@annotation@literal@part@#2@#3@#4@#5}{#7}}}
        {\csxappto\blx@bbl@data{%
          \def\do####1{\listcsadd{abx@annotation@part@#2@#3@#4@#5}{####1}}%
          \docsvlist{#7}}}}
     {}}

% [&lt;field&gt;][&lt;annotationname&gt;]
\def\blx@imc@getfieldannotation{%
  \let\blx@tempa\@empty
  \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  \@ifnextchar[%]
   {\blx@imc@getfieldannotation@i}
   {\blx@imc@getfieldannotation@i[\blx@tempa]}}

\def\blx@imc@getfieldannotation@i[#1]{%
 \ifstrempty{#1}
   {\blx@imc@getfieldannotation@i[\blx@tempa]}
   {\@ifnextchar[%]
      {\blx@imc@getfieldannotation@ii{#1}}
      {\blx@imc@getfieldannotation@ii{#1}[default]}}}

\def\blx@imc@getfieldannotation@ii#1[#2]{%
  \def\blx@tempb{#1}%
  \blx@resolve@annotation@label{\blx@tempb}%
  \ifcsdef{abx@annotation@literal@field@\blx@tempb @#2}
    {\csuse{abx@annotation@literal@field@\blx@tempb @#2}}
    {}}

% [&lt;field&gt;][&lt;annotationname&gt;][&lt;item&gt;]
\def\blx@imc@getitemannotation{%
  \let\blx@tempa\@empty
  \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  \@ifnextchar[%]
   {\blx@imc@getitemannotation@i}
   {\blx@imc@getitemannotation@i[\blx@tempa]}}

\def\blx@imc@getitemannotation@i[#1]{%
  \ifstrempty{#1}
    {\blx@imc@getitemannotation@i[\blx@tempa]}
    {\@ifnextchar[%]
      {\blx@imc@getitemannotation@ii{#1}}
      {\blx@imc@getitemannotation@ii{#1}[default]}}}

\def\blx@imc@getitemannotation@ii#1[#2]{%
  \ifstrempty{#2}
    {\def\blx@tempb{default}}
    {\def\blx@tempb{#2}}%
  \@ifnextchar[%]
    {\blx@imc@getitemannotation@iii{#1}{\blx@tempb}}
    {\blx@imc@getitemannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}}

\def\blx@imc@getitemannotation@iii#1#2[#3]{%
  \def\blx@tempc{#1}%
  \blx@resolve@annotation@label{\blx@tempc}%
  \ifcsdef{abx@annotation@literal@item@\blx@tempc @#2@#3}
    {\csuse{abx@annotation@literal@item@\blx@tempc @#2@#3}}
    {}}

% [&lt;field&gt;][&lt;annotationname&gt;][&lt;item&gt;]{&lt;part&gt;}
\def\blx@imc@getpartannotation{%
  \let\blx@tempa\@empty
  \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  \@ifnextchar[%]
    {\blx@imc@getpartannotation@i}
    {\blx@imc@getpartannotation@i[\blx@tempa]}}

\def\blx@imc@getpartannotation@i[#1]{%
  \ifstrempty{#1}
    {\blx@imc@getpartannotation@i[\blx@tempa]}
    {\@ifnextchar[%]
      {\blx@imc@getpartannotation@ii{#1}}
      {\blx@imc@getpartannotation@ii{#1}[default]}}}

\def\blx@imc@getpartannotation@ii#1[#2]{%
 \ifstrempty{#2}
   {\def\blx@tempb{default}}
   {\def\blx@tempb{#2}}%
  \@ifnextchar[%]
    {\blx@imc@getpartannotation@iii{#1}{\blx@tempb}}
    {\blx@imc@getpartannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}}

\def\blx@imc@getpartannotation@iii#1#2[#3]#4{%
  \ifstrempty{#3}
    {\def\blx@tempc{\the\value{listcount}}}
    {\def\blx@tempc{#3}}%
  \def\blx@tempd{#1}%
  \blx@resolve@annotation@label{\blx@tempd}%
  \ifcsdef{abx@annotation@literal@part@\blx@tempd @#2@\blx@tempc @#4}
    {\csuse{abx@annotation@literal@part@\blx@tempd @#2@\blx@tempc @#4}}
    {}}

% [&lt;field&gt;][&lt;annotationname&gt;]{&lt;annotation&gt;}
\def\blx@imc@iffieldannotation{%
  \let\blx@tempa\@empty
  \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
 \@ifnextchar[%]
    {\blx@imc@iffieldannotation@i}
    {\blx@imc@iffieldannotation@i[\blx@tempa]}}

\def\blx@imc@iffieldannotation@i[#1]{%
  \ifstrempty{#1}
    {\blx@imc@iffieldannotation@i[\blx@tempa]}
    {\@ifnextchar[%]
      {\blx@imc@iffieldannotation@ii{#1}}
      {\blx@imc@iffieldannotation@ii{#1}[default]}}}

\def\blx@imc@iffieldannotation@ii#1[#2]#3{%
  \ifstrempty{#2}
    {\def\blx@tempb{default}}
    {\def\blx@tempb{#2}}%
  \def\blx@tempc{#1}%
  \blx@resolve@annotation@label{\blx@tempc}%
  \ifinlistcs{#3}{abx@annotation@field@\blx@tempc @\blx@tempb}}

% [&lt;field&gt;][&lt;annotationname&gt;][&lt;item&gt;]{&lt;annotation&gt;}
\def\blx@imc@ifitemannotation{%
  \let\blx@tempa\@empty
  \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
   \@ifnextchar[%]
    {\blx@imc@ifitemannotation@i}
    {\blx@imc@ifitemannotation@i[\blx@tempa]}}

\def\blx@imc@ifitemannotation@i[#1]{%
  \ifstrempty{#1}
    {\blx@imc@ifitemannotation@i[\blx@tempa]}
    {\@ifnextchar[%]
      {\blx@imc@ifitemannotation@ii{#1}}
      {\blx@imc@ifitemannotation@ii{#1}[default]}}}

\def\blx@imc@ifitemannotation@ii#1[#2]{%
  \ifstrempty{#2}
    {\def\blx@tempb{default}}
    {\def\blx@tempb{#2}}%
  \@ifnextchar[%]
    {\blx@imc@ifitemannotation@iii{#1}{\blx@tempb}}
    {\blx@imc@ifitemannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}}

\def\blx@imc@ifitemannotation@iii#1#2[#3]#4{%
  \def\blx@tempc{#1}%
  \blx@resolve@annotation@label{\blx@tempc}%
  \ifinlistcs{#4}{abx@annotation@item@\blx@tempc @#2@#3}}

% [&lt;field&gt;][&lt;annotationname&gt;][&lt;item&gt;]{&lt;part&gt;}{&lt;annotation&gt;}
\def\blx@imc@ifpartannotation{%
  \let\blx@tempa\@empty
  \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  \@ifnextchar[%]
    {\blx@imc@ifpartannotation@i}
    {\blx@imc@ifpartannotation@i[\blx@tempa]}}

\def\blx@imc@ifpartannotation@i[#1]{%
  \ifstrempty{#1}
    {\blx@imc@ifpartannotation@i[\blx@tempa]}
    {\@ifnextchar[%]
      {\blx@imc@ifpartannotation@ii{#1}}
      {\blx@imc@ifpartannotation@ii{#1}[default]}}}

\def\blx@imc@ifpartannotation@ii#1[#2]{%
 \ifstrempty{#2}
   {\def\blx@tempb{default}}
   {\def\blx@tempb{#2}}%
  \@ifnextchar[%]
    {\blx@imc@ifpartannotation@iii{#1}{\blx@tempb}}
    {\blx@imc@ifpartannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}}

\def\blx@imc@ifpartannotation@iii#1#2[#3]#4#5{%
  \ifstrempty{#3}
    {\def\blx@tempc{\the\value{listcount}}}
    {\def\blx@tempc{#3}}%
  \def\blx@tempd{#1}%
  \blx@resolve@annotation@label{\blx@tempd}%
  \ifinlistcs{#5}{abx@annotation@part@\blx@tempd @#2@\blx@tempc @#4}}

% [&lt;field&gt;][&lt;annotationname&gt;]
\def\blx@imc@hasfieldannotation{%
  \let\blx@tempa\@empty
  \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
 \@ifnextchar[%]
    {\blx@imc@hasfieldannotation@i}
    {\blx@imc@hasfieldannotation@i[\blx@tempa]}}

\def\blx@imc@hasfieldannotation@i[#1]{%
  \ifstrempty{#1}
    {\blx@imc@hasfieldannotation@i[\blx@tempa]}
    {\@ifnextchar[%]
      {\blx@imc@hasfieldannotation@ii{#1}}
      {\blx@imc@hasfieldannotation@ii{#1}[default]}}}

\def\blx@imc@hasfieldannotation@ii#1[#2]{%
  \ifstrempty{#2}
    {\def\blx@tempb{default}}
    {\def\blx@tempb{#2}}%
  \def\blx@tempc{#1}%
  \blx@resolve@annotation@label{\blx@tempc}%
  \ifcsdef{abx@annotation@literal@field@\blx@tempc @\blx@tempb}}

% [&lt;field&gt;][&lt;annotationname&gt;][&lt;item&gt;]
\def\blx@imc@hasitemannotation{%
  \let\blx@tempa\@empty
  \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
   \@ifnextchar[%]
    {\blx@imc@hasitemannotation@i}
    {\blx@imc@hasitemannotation@i[\blx@tempa]}}

\def\blx@imc@hasitemannotation@i[#1]{%
  \ifstrempty{#1}
    {\blx@imc@hasitemannotation@i[\blx@tempa]}
    {\@ifnextchar[%]
      {\blx@imc@hasitemannotation@ii{#1}}
      {\blx@imc@hasitemannotation@ii{#1}[default]}}}

\def\blx@imc@hasitemannotation@ii#1[#2]{%
  \ifstrempty{#2}
    {\def\blx@tempb{default}}
    {\def\blx@tempb{#2}}%
  \@ifnextchar[%]
    {\blx@imc@hasitemannotation@iii{#1}{\blx@tempb}}
    {\blx@imc@hasitemannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}}

\def\blx@imc@hasitemannotation@iii#1#2[#3]{%
  \def\blx@tempc{#1}%
  \blx@resolve@annotation@label{\blx@tempc}%
  \ifcsdef{abx@annotation@literal@item@\blx@tempc @#2@#3}}

% [&lt;field&gt;][&lt;annotationname&gt;][&lt;item&gt;]{&lt;part&gt;}
\def\blx@imc@haspartannotation{%
  \let\blx@tempa\@empty
  \ifdefvoid\currentfield{}{\let\blx@tempa\currentfield}%
  \ifdefvoid\currentlist{}{\let\blx@tempa\currentlist}%
  \ifdefvoid\currentname{}{\let\blx@tempa\currentname}%
  \@ifnextchar[%]
    {\blx@imc@haspartannotation@i}
    {\blx@imc@haspartannotation@i[\blx@tempa]}}

\def\blx@imc@haspartannotation@i[#1]{%
  \ifstrempty{#1}
    {\blx@imc@haspartannotation@i[\blx@tempa]}
    {\@ifnextchar[%]
      {\blx@imc@haspartannotation@ii{#1}}
      {\blx@imc@haspartannotation@ii{#1}[default]}}}

\def\blx@imc@haspartannotation@ii#1[#2]{%
 \ifstrempty{#2}
   {\def\blx@tempb{default}}
   {\def\blx@tempb{#2}}%
  \@ifnextchar[%]
    {\blx@imc@haspartannotation@iii{#1}{\blx@tempb}}
    {\blx@imc@haspartannotation@iii{#1}{\blx@tempb}[\the\value{listcount}]}}

\def\blx@imc@haspartannotation@iii#1#2[#3]#4{%
  \ifstrempty{#3}
    {\def\blx@tempc{\the\value{listcount}}}
    {\def\blx@tempc{#3}}%
  \def\blx@tempd{#1}%
  \blx@resolve@annotation@label{\blx@tempd}%
  \ifcsdef{abx@annotation@literal@part@\blx@tempd @#2@\blx@tempc @#4}}

% labeldatesource has a slightly different format than other &lt;field&gt;sources
% that's one reason for a dedicated command, the other being that this command
% is probably only used in contexts where \currentfield is not defined, so
% the &lt;datetype&gt; argument is always required
% [&lt;annotationname&gt;]{&lt;datetype&gt;}{&lt;annotation&gt;}
\newcommand*{\blx@imc@ifdateannotation}[3][]{%
  \ifblank{#1}
    {\def\blx@tempa{default}}
    {\def\blx@tempa{#1}}%
  \def\blx@tempb{#2}%
  \ifcsundef{abx@field@\blx@tempb source}
    {}%
    {\letcs\blx@tempa{abx@field@\blx@tempb source}%
     \edef\blx@tempb{\blx@tempb date}}%
  \ifinlistcs{#3}{abx@annotation@field@\blx@tempb @\blx@tempa}}

% [&lt;annotationname&gt;]{&lt;datetype&gt;}
\newcommand*{\blx@imc@hasdateannotation}[2][]{%
  \ifblank{#1}
    {\def\blx@tempa{default}}
    {\def\blx@tempa{#1}}%
  \def\blx@tempb{#2}%
  \ifcsundef{abx@field@\blx@tempb source}
    {}%
    {\letcs\blx@tempa{abx@field@\blx@tempb source}%
     \edef\blx@tempb{\blx@tempb date}}%
  \ifboolexpr { test {\ifcsdef{abx@annotation@field@\blx@tempb @\blx@tempa}}
                or
                test {\ifcsdef{abx@annotation@literal@field@\blx@tempb @\blx@tempa}} }}

% [&lt;annotationname&gt;]{&lt;datetype&gt;}
\newcommand*{\blx@imc@getdateannotation}[2][]{%
  \ifblank{#1}
    {\def\blx@tempa{default}}
    {\def\blx@tempa{#1}}%
  \def\blx@tempb{#1}%
  \ifcsundef{abx@field@\blx@tempb source}
    {}%
    {\letcs\blx@tempb{abx@field@\blx@tempb source}%
     \edef\blx@tempb{\blx@tempb date}}%
  \ifcsdef{abx@annotation@literal@field@\blx@tempb @\blx@tempa}
    {\csuse{abx@annotation@literal@field@\blx@tempb @\blx@tempa}}
    {}}

\blx@regimcs{\iffieldannotation \ifitemannotation \ifpartannotation
  \ifdateannotation \getfieldannotation \getitemannotation \getpartannotation
  \getdateannotation \hasfieldannotation \hasitemannotation \haspartannotation
  \hasdateannotation}

% {&lt;fieldname&gt;}
\def\blx@resolve@annotation@label#1{%
  \ifcsundef{abx@field@#1source}
    {}%
    {\letcs\blx@tempa{abx@field@#1source}}}

\begingroup
\catcode`\&lt;=12
\catcode`\&gt;=12
\uccode`\&lt;=`\ %
\uccode`\&gt;=\endlinechar
\uppercase{\gdef\blx@bbl@verbadd@i&lt;#1&gt;}{%
  \endgroup
  \edef\NewValue{\NewValue\detokenize{#1}}}
\uppercase{\gdef\blx@bbl@verbladd@i&lt;#1&gt;}{%
  \endgroup
  \eappto\blx@tempc{{\detokenize{#1}}}}%
\endgroup

% {&lt;counter&gt;}{&lt;value&gt;}
\protected\long\def\blx@bbl@cntdef#1#2{%
  \csxappto\blx@bbl@data{%
    \csname c@#1\endcsname#2\relax}}

% {&lt;boolean&gt;}
\protected\def\blx@bbl@booltrue#1{%
  \csgappto\blx@bbl@data{%
    \toggletrue{abx@bool@#1}}}

\protected\def\blx@bbl@boolfalse#1{%
  \csgappto\blx@bbl@data{%
    \togglefalse{abx@bool@#1}}}

% {&lt;list&gt;}{&lt;itemcount&gt;}{&lt;value&gt;}
\protected\def\blx@bbl@listdef#1#2#3{%
  \def\NewCount{#2}%
  \def\NewValue{#3}%
  \ifcsdef{blx@lih@#1}
    {\csname blx@lih@#1\endcsname{#3}%
     \ifdefvoid\NewValue}
    {\@secondoftwo}
       {}
       {\csxappto\blx@bbl@data{%
          \csname c@#1\endcsname\NewCount\relax
          \def\expandafter\noexpand\csname abx@list@#1\endcsname
          {\expandonce\NewValue}}}}

% {&lt;name&gt;}{&lt;itemcount&gt;}{&lt;nameoptions&gt;}{&lt;value&gt;}
\protected\def\blx@bbl@namedef#1#2#3#4{%
  \def\NewCount{#2}%
  \def\NewOption{#3}%
  \def\NewValue{#4}%
  \ifcsdef{blx@nih@#1}
    {\csname blx@nih@#1\endcsname{#4}%
     \ifdefvoid\NewValue}
    {\@secondoftwo}
       {}
       {\csxappto\blx@bbl@data{%
          \csname c@#1\endcsname\NewCount\relax
          \def\expandafter\noexpand\csname abx@name@#1\endcsname
          {{\expandonce\NewOption}{\expandonce\NewValue}}}}}

% blx@setp@&lt;rs&gt;@&lt;sp&gt; = map of set parent &lt;sp&gt; in a refsection &lt;rs&gt; to csv
%                      of set children
% blx@seti@&lt;rs&gt;@&lt;sc&gt; = position of set child &lt;sc&gt; in entry set in
%                      refsection &lt;rs&gt;
% blx@setc@&lt;rs&gt;@&lt;sc&gt; = map of set child &lt;sc&gt; in refsection &lt;rs&gt; to set parent

% {&lt;entrykey&gt;,...}
\protected\def\blx@bbl@set#1{%
  \blx@bbl@fieldedef{entryset}{\detokenize{#1}}%
  \csxdef{blx@setp@\the\c@refsection @\abx@field@entrykey}{\detokenize{#1}}%
  \begingroup
  \blx@tempcnta\z@
  \expandafter\forcsvlist
  \expandafter\blx@bbl@set@i
  \expandafter{\detokenize{#1}}%
  \endgroup}

\def\blx@bbl@set@i#1{%
  \advance\blx@tempcnta\@ne
  \csxdef{blx@seti@\the\c@refsection @#1}{\the\blx@tempcnta}}

% {&lt;entrykey&gt;}
\protected\def\blx@bbl@inset#1{%
  \toggletrue{blx@setonly}%
  \blx@bbl@fieldedef{entryset}{\detokenize{#1}}%
  \csxdef{blx@setc@\the\c@refsection @\abx@field@entrykey}{\detokenize{#1}}}

% {&lt;entrykey&gt;}
\protected\def\blx@bbl@xref#1{}% No-op to avoid an error with BibTeX .bbl
\protected\def\blx@bbl@fakeset#1{}% No-op to avoid an error with BibTeX .bbl

% {&lt;keyword&gt;,...}
\protected\def\blx@bbl@keyw#1{%
  \forcsvlist{\blx@addkeyword{\abx@field@entrykey}}{#1}%
  \blx@bbl@fielddef{keywords}{#1}}

\def\blx@addkeyword#1#2{%
  \listcsxadd{blx@keyw@\the\c@refsection @\detokenize{#2}}{#1}}

\newcommand*{\blx@ifcatcode@other}[1]{%
  \ifnumequal{\catcode\number`#1}{12}}

% {&lt;options&gt;}
\protected\long\def\blx@bbl@options#1{%
  \ifblank{#1}
    {}
    {\begingroup
     \blx@ifcatcode@other{,}
       {\blx@ifcatcode@other{=}}
       {\@secondoftwo}
     {\blx@bbl@options@check{#1}}
     {\ifundef\blx@bbl@options@warncatcode
        {\blx@warning@noline{%
           Irregular catcode regime detected.\MessageBreak
           Attempting to work around this with \string\scantokens}%
         \global\let\blx@bbl@options@warncatcode\@empty}
        {}%
      \makeatletter
      \@makeother\=
      \@makeother\'
      \endlinechar\m@ne
      \scantokens\expandafter{\blx@bbl@options@check{#1}}}}}

\long\def\blx@bbl@options@check#1{%
  \let\blx@tempa\@empty
  \forcsvlist\blx@bbl@options@checkopt{#1}%
  \edef\blx@tempa{%
    \endgroup % this group was opened in \blx@bbl@options
    \ifx\blx@tempa\@empty
    \else
      \def\noexpand\abx@field@options{\expandonce\blx@tempa}%
    \fi}%
  \blx@tempa}


\long\def\blx@bbl@options@checkopt#1{\blx@bbl@options@checkopt@i#1==&amp;}

\long\def\blx@bbl@options@checkopt@i#1=#2=#3&amp;{%
  \blx@kv@ifkeyundef{blx@opt@ent}{#1}
    {\blx@warning@noline{%
       Ignoring undefined option '#1'\MessageBreak
       at entry '\abx@field@entrykey'}}
    {\eappto\blx@tempa{%
       \ifx\blx@tempa\@empty\else,\fi
       \unexpanded{#1}\ifblank{#2}{}{=\unexpanded{#2}}}}}

\def\blx@ifdata#1{%
  \ifcsdef{blx@data@\the\c@refsection @\blx@refcontext@context @#1}}
\let\blx@imc@ifentryinbib\blx@ifdata

\def\blx@getdata#1{%
  \csuse{blx@data@\the\c@refsection @\blx@refcontext@context @#1}%
  \blx@adjustyears
  \blx@getlabeldata
  \blx@aliasfields
  \blx@setcitecounter}

\def\blx@adjustyears{%
  % All dates by default are output from biber in astronomical era with a year 0
  % So, if we are ouputting BCE/BC era, we need to adjust the years by +1
  \def\do##1{%
    \ifdefstring\blx@dateera{astronomical}
      {}
      {\ifcsdef{abx@field@##1year}
        {\csuse{if##1dateera}{bce}
          {\csedef{abx@field@##1year}{\number\numexpr\csuse{abx@field@##1year}+1}}
          {}}
        {}%
       \ifcsdef{abx@field@##1endyear}
         {\csuse{if##1enddateera}{bce}
           {\csedef{abx@field@##1endyear}{\number\numexpr\csuse{abx@field@##1endyear}+1}}
           {}}
         {}}%
      {}}%
  \abx@dodatetypes}

\def\blx@getlabeldata{%
  % Here we resolve label* bib fields to their real fields. In fact, currently biber resolves
  % the label* fields too, as it needs to do this to generate various internal
  % counters for tracking things like singletitle etc. internally. However, it does not output
  % the resolved values to the .bbl. It is conceptually neater to have just the calculated label*
  % source field in the .bbl and let biblatex resolve the label* field using the label*source
  % fields. However, currently there is no way/need to vary the label* resolution to pick up a
  % different target field in biblatex and so practically, this resolution is being done twice,
  % once by biber, once by biblatex. It is possible in the future that it would be useful to
  % to change the resolution of the label* fields dynamically in a style/document and so this
  % biblatex-side resolution remains.
  %
  % An unanswered question is whether such dynamic resolution causes problems due to the fact
  % that biber uses the label* field to generate counters internally and changing the
  % label* field resolution in biblatex would occur after such counters have been used to
  % generate the .bbl
  % This could all be removed from biblatex if necessary and biber could output all resolved
  % label* fields to the .bbl but then it potentially removes control of such things from
  % macros
  %
  % fields
  \def\do##1{%
    \ifcsundef{abx@field@##1source}
      {}%
      {\csletcs{abx@field@##1}{abx@field@\csuse{abx@field@##1source}}}}%
  \dolistloop\abx@rfields%
  % names
  \def\do##1{%
    \ifcsundef{abx@field@##1source}
     {}
     {\csname c@##1\expandafter\endcsname\expandafter
        \the\csname c@\csuse{abx@field@##1source}\endcsname
      \csletcs{abx@name@##1}{abx@name@\csuse{abx@field@##1source}}%
      \csletcs{etb@tgl@abx@bool@more##1}{%
        etb@tgl@abx@bool@more\csuse{abx@field@##1source}}}}%
  \dolistloop\abx@rnames%
  % Resolve labeldate
  % Note that here we can't refer to labelyear as this is where we create it, hence the
  % complications in constructing test names etc.
  % This also shows why biber shouldn't resolve labeldate fields as we have to add
  % circa/uncertain/era etc. information to them and that has to be done here.
  \ifundef\abx@field@labeldatesource
    {}
    {\ifcsundef{abx@field@\abx@field@labeldatesource year}
       % \DeclareLabeldate resolved to a literal/localisation string or a non-date field
       % in which case we only set labelyear.
       {\ifcsundef{abx@field@\abx@field@labeldatesource}
         % \DeclareLabeldate resolved to a literal/localisation string
         {\let\abx@field@labelyear\abx@field@labeldatesource}
         % \DeclareLabeldate resolved to a non-date field.  Not safe to \edef because
         % such contents could contain arbitrary macros, unlike EDTF sourced labeldatesource values
         {\letcs\abx@field@labelyear{abx@field@\abx@field@labeldatesource}}}
       % \DeclareLabeldate resolved to a date field name prefix like '', 'event', 'url'
       % or 'orig'
       {% labeldateera/labelenddateera
        \letcs\abx@field@labeldateera{abx@field@\abx@field@labeldatesource dateera}%
        \letcs\abx@field@labelenddateera{abx@field@\abx@field@labeldatesource enddateera}%
        \letcs\abx@field@labelyear{abx@field@\abx@field@labeldatesource year}%
        \letcs\abx@field@labelendyear{abx@field@\abx@field@labeldatesource endyear}%
        \letcs\abx@field@labelmonth{abx@field@\abx@field@labeldatesource month}%
        \letcs\abx@field@labelendmonth{abx@field@\abx@field@labeldatesource endmonth}%
        \letcs\abx@field@labelday{abx@field@\abx@field@labeldatesource day}%
        \letcs\abx@field@labelendday{abx@field@\abx@field@labeldatesource endday}%
        \letcs\abx@field@labelhour{abx@field@\abx@field@labeldatesource hour}%
        \letcs\abx@field@labelendhour{abx@field@\abx@field@labeldatesource endhour}%
        \letcs\abx@field@labelminute{abx@field@\abx@field@labeldatesource minute}%
        \letcs\abx@field@labelendminute{abx@field@\abx@field@labeldatesource endminute}%
        \letcs\abx@field@labelsecond{abx@field@\abx@field@labeldatesource second}%
        \letcs\abx@field@labelendsecond{abx@field@\abx@field@labeldatesource endsecond}%
        \letcs\abx@field@labeltimezone{abx@field@\abx@field@labeldatesource timezone}%
        \letcs\abx@field@labelendtimezone{abx@field@\abx@field@labeldatesource endtimezone}%
        \letcs\abx@field@labelyeardivision{abx@field@\abx@field@labeldatesource yeardivision}%
        \letcs\abx@field@labelendyeardivision{abx@field@\abx@field@labeldatesource endyeardivision}%
        \letcs\abx@field@labeldateunspecified{abx@field@\abx@field@labeldatesource dateunspecified}%
        \letcs\etb@tgl@abx@bool@labeldatecirca{etb@tgl@abx@bool@\abx@field@labeldatesource datecirca}%
        \letcs\etb@tgl@abx@bool@labelenddatecirca{etb@tgl@abx@bool@\abx@field@labeldatesource enddatecirca}%
        \letcs\etb@tgl@abx@bool@labeldatejulian{etb@tgl@abx@bool@\abx@field@labeldatesource datejulian}%
        \letcs\etb@tgl@abx@bool@labelenddatejulian{etb@tgl@abx@bool@\abx@field@labeldatesource enddatejulian}%
        \letcs\etb@tgl@abx@bool@labeldateuncertain{etb@tgl@abx@bool@\abx@field@labeldatesource dateuncertain}%
        \letcs\etb@tgl@abx@bool@labelenddateuncertain{etb@tgl@abx@bool@\abx@field@labeldatesource enddateuncertain}%
        \letcs\etb@tgl@abx@bool@labeldateunknown{etb@tgl@abx@bool@\abx@field@labeldatesource dateunknown}%
        \letcs\etb@tgl@abx@bool@labelenddateunknown{etb@tgl@abx@bool@\abx@field@labeldatesource enddateunknown}%
       }%
    }%
}

% This gets the entry data for a citation
\def\blx@getdata@cite#1{%
  \blx@getdata{#1}%
  % Inject the relevant set parent fields like labelnumber/labelprefix into child
  \ifcsdef{blx@setc@\the\c@refsection @#1}
    {\blx@ifdata{#1}
       {\def\abx@field@childentrykey{#1}%LEGACY(&lt;3.8)
        \let\abx@field@childentrytype\abx@field@entrytype %LEGACY(&lt;3.8)
        \begingroup
        \expandafter\expandafter\expandafter\blx@getdata
          \expandafter\expandafter\expandafter{%
            \csname blx@setc@\the\c@refsection @#1\endcsname}%
        \let\blx@tempa\@empty
        % Inject labelnumber if it exists
        \ifdef\abx@field@labelnumber
          {\appto\blx@tempa{%
             \def\noexpand\abx@field@labelnumber{%
               \expandonce\abx@field@labelnumber}}}
          {}%
        % Inject labelprefix if it exists
        \ifdef\abx@field@labelprefix
          {\appto\blx@tempa{%
             \def\noexpand\abx@field@labelprefix{%
               \expandonce\abx@field@labelprefix}}}
          {}%
        % Inject labelalpha if it exists
        \ifdef\abx@field@labelalpha
          {\appto\blx@tempa{%
             \def\noexpand\abx@field@labelalpha{%
               \expandonce\abx@field@labelalpha}}}
          {}%
        % Inject extraalpha if it exists
        \ifdef\abx@field@extraalpha
          {\appto\blx@tempa{%
              \def\noexpand\abx@field@extraalpha{%
                \expandonce\abx@field@extraalpha}}}
          {}%
        % Perform the injection
        \edef\blx@tempb{\endgroup\blx@tempa}%
        \blx@tempb}
       {}}
    {}%
  \ifcsdef{blx@seti@\the\c@refsection @#1}
    {\letcs\abx@field@entrysetcount{blx@seti@\the\c@refsection @#1}}
    {}}

\def\blx@execute{%
  \blx@imc@thefield{execute}}

\def\blx@setoptions@entry{%
  \blx@imc@iffieldundef{options}
    {}
    {\begingroup
     \edef\blx@tempa{\endgroup
       \noexpand\blx@kv@setkeys{blx@opt@ent}{\abx@field@options}}%
     \blx@tempa
     \blx@checkoptions@entry}}

\def\blx@setoptions@type#1{%
  \ifcsdef{blx@opts@type@#1}
    {\begingroup
     \edef\blx@tempa{\endgroup
       \noexpand\blx@kv@setkeys{blx@opt@typ}{\csuse{blx@opts@type@#1}}}%
     \blx@tempa}
    {}}

\def\blx@checkoptions@global{}
\def\blx@checkoptions@type{}
\def\blx@checkoptions@entry{}

\def\blx@entrysetcount{%
  \ifdef\abx@field@entrykey
    {\ifcsdef{blx@seti@\the\c@refsection @\abx@field@entrykey}
       {\letcs\abx@field@entrysetcount{%
          blx@seti@\the\c@refsection @\abx@field@entrykey}}
       {}}
    {}}

% {&lt;section&gt;}
\def\blx@bbl@refsection#1{%
  \begingroup
  \c@refsection#1\relax}

\def\blx@bbl@endrefsection{%
  \iftoggle{blx@addset}
    {\blx@addset
     \global\togglefalse{blx@addset}}
    {}%
  \endgroup}

% {&lt;entrykey&gt;}
\protected\def\blx@bbl@missing#1{%
  \listcsxadd{blx@miss@\the\c@refsection}{\detokenize{#1}}%
  \blx@warning@noline{%
    The following entry could not be found\MessageBreak
    in the database%
    \ifnumgreater\c@refsection\z@
      { (refsection \the\c@refsection)}
      {}:\MessageBreak
    \detokenize{#1}\MessageBreak
    Please verify the spelling and rerun\MessageBreak
    LaTeX afterwards}}

% We create an alias resolving macro and also a list of aliases
% which we need to add to the .bcf. We need to resolve the aliases
% for internal use but we always want the aliases themselves in the .bcf
% so that biber can correctly use and resolve them too.
\protected\def\blx@bbl@keyalias#1#2{%
  \csxdef{blx@keyalias@\the\c@refsection @#1}{\detokenize{#2}}%
  \listcsxadd{blx@keyaliases@\the\c@refsection}{\detokenize{#1}}}

% blx@dlist@list@&lt;section&gt;@&lt;refcontext&gt; - a list of list items in a refcontext in a
%                                         section (for tracking bibliography lists,
%                                         obeys skipbiblist)
% blx@dlist@entry@&lt;section&gt;@&lt;list&gt; - a list of normal entries in a list in a
%                                    section (for tracking bibliographies,
%                                    obeys skipbib)
% blx@dlist@centry@&lt;section&gt;@&lt;list&gt; - a list of normal entries in a list in a
%                                     section (for tracking citations,
%                                     does not obey skipbib).
%                                     Same as @entry@, but includes skipbib'd entries
%                                     and set children

% {&lt;entrykey&gt;}{&lt;entrytype&gt;}{&lt;options&gt;}{&lt;citecount&gt;}
% citecount is just ignored as it's already calculated from actual cites
% It's in the .bbl to force the .bbl to change when only the citecount changes.
\protected\def\blx@bbl@entry#1#2#3#4{%
  \begingroup
  \edef\abx@field@entrykey{\detokenize{#1}}%
  \blx@setoptions@type{#2}%
  \blx@bbl@options{#3}%
  \blx@setoptions@entry
  \edef\blx@bbl@data{blx@data@\the\c@refsection @\blx@dlist@name @\abx@field@entrykey}%
  \blx@bbl@addfield{entrykey}{\abx@field@entrykey}%
  \listcsxadd{blx@entries@\the\c@refsection}{\abx@field@entrykey}%
  \blx@bbl@addfield{entrytype}{#2}%
  \csuse\blx@bbl@data
  \blx@imc@iffieldundef{options}
    {}
    {\blx@bbl@fieldedef{options}{\expandonce\abx@field@options}}}

\protected\def\blx@bbl@endentry{%
  \csuse\blx@bbl@data
  \ifcsundef{blx@pref@\the\c@refsection @\abx@field@entrykey}
    {}
    {\blx@addpageref{\abx@field@entrykey}}%
  \nottoggle{blx@setonly}
    {}
    {\global\toggletrue{blx@addset}%
     \toggletrue{blx@skipbib}%
     \toggletrue{blx@skipbiblist}%
     \toggletrue{blx@skiplab}}%
  \expandafter\ifstrequal\expandafter{\blx@dlist@type}{entry}
    {\listcsxadd{blx@type@\the\c@refsection @\abx@field@entrytype}{\abx@field@entrykey}%
     \ifdef\abx@field@entrysubtype
       {\listcsxadd{blx@subt@\the\c@refsection @\abx@field@entrysubtype}{\abx@field@entrykey}}
       {}%
     \nottoggle{blx@setonly}
       {\listcsxadd{blx@dlist@centry@\the\c@refsection @\blx@dlist@name}{\abx@field@entrykey}}
       {}%
     \nottoggle{blx@skipbib}
       {\listcsxadd{blx@dlist@entry@\the\c@refsection @\blx@dlist@name}{\abx@field@entrykey}}
       {}}%
    {}%
  \nottoggle{blx@skipbiblist}
    {\expandafter\ifstrequal\expandafter{\blx@dlist@type}{list}
      {\blx@bbl@labelfields
        \listcsxadd{blx@dlist@\blx@dlist@type @\the\c@refsection @\blx@dlist@name}{\abx@field@entrykey}}
      {}}%
    {}%
  \nottoggle{blx@skiplab}
    {\iftoggle{blx@labelnumber}
       {\blx@bbl@labelnumber}
       {}%
     \iftoggle{blx@labelalpha}
       {\blx@bbl@labelalpha}
       {}%
     \iftoggle{blx@labeltitle}
       {\blx@bbl@labeltitle}
       {}%
     \iftoggle{blx@labeltitleyear}
       {\blx@bbl@labeltitleyear}
       {}%
     \iftoggle{blx@labeldateparts}
       {\blx@bbl@labeldate}
       {}%
     \blx@bbl@labelname}
    {}%
  \blx@bbl@titles
  \blx@bbl@hooks
  \endgroup}

% This, at the end of the .bbl, puts any set parent children into the
% current context sort list of citations (a separate list *@centry@* to the
% bibliography *@entry@* which doesn't want the children adding if they weren't
% cited) as this is needed for the subentry citing
% when sortcites is enabled as for sortcites, the current context sorting list
% is used and the parent set of a subentry is not necessarily
% available in the current context sortlist.
\def\blx@addset{%
  \begingroup
  \ifcsdef{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}
    {\letcs\blx@tempa{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}%
     \global\cslet{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}\@empty
     \forlistloop\blx@addset@i\blx@tempa}
    {\blx@warning@noline{Sorting template has changed}}%
  \endgroup}

\def\blx@addset@i#1{%
  \listcsgadd{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}{#1}%
  \ifcsdef{blx@setp@\the\c@refsection @#1}
    {\expandafter\expandafter\expandafter\forcsvlist
     \expandafter\expandafter\expandafter\blx@addset@ii
     \expandafter\expandafter\expandafter{%
       \csname blx@setp@\the\c@refsection @#1\endcsname}}
    {}}

\def\blx@addset@ii#1{%
  \listcsgadd{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}{#1}}

% {&lt;csname&gt;}{&lt;field&gt;/&lt;format&gt;}{&lt;field&gt;}
\def\abx@flfw@getfieldformat#1#2#3{%
  \blx@getformat\abx@tmp@theformat{ffd}{#2}{#3}%
  \csletcs{#1}{abx@tmp@theformat}}


% {&lt;instance (int)&gt;}{&lt;field&gt;}{&lt;length&gt;}
\def\abx@aux@locallabelwidth#1#2#3{%
  \csgdef{blx@locallabelwidth@#1@#2}{#3}}

\def\blx@locallabelwidth@write@length#1{%
  \blx@auxwrite\@mainaux{}
    {\string\abx@aux@locallabelwidth
       {\the\blx@biblioinstance}%
       {#1}%
       {\the\csname local#1width\endcsname}}}

\def\blx@locallabelwidth@write{%
  \let\do\blx@locallabelwidth@write@length
  \abx@dolabelwidths}

\let\blx@locallabelwidth@finish\relax

\def\blx@labelwidth@resetlocal{%
  \def\do##1{%
    \csname local##1width\endcsname\z@}%
  \abx@dolabelwidths}

\def\blx@labelwidth@settolocal@length#1{%
  \ifcsundef{blx@locallabelwidth@\the\blx@biblioinstance @#1}
    {}
    {\csname #1width\endcsname
     \csname blx@locallabelwidth@\the\blx@biblioinstance @#1\endcsname
     \space}}

\def\blx@labelwidth@settolocal{%
  \let\do\blx@labelwidth@settolocal@length
  \abx@dolabelwidths}

\def\blx@locallabelwidth@setlengths{%
  \global\advance\blx@biblioinstance\@ne
  \blx@labelwidth@resetlocal
  \blx@labelwidth@settolocal}

\let\blx@locallabelwidth@init\relax


% {&lt;prefix for labelwidth fields&gt;}
\def\blx@bbl@labelnumberwidth@numeric#1{%
  \abx@flfw@getfieldformat{abx@flfw@labelnumberwidth}{labelnumberwidth}{}%
  \abx@flfw@getfieldformat{abx@flfw@labelprefix}{labelprefix}{}%
  \abx@flfw@getfieldformat{abx@flfw@labelnumber}{labelnumber}{}%
  \iftoggle{blx@defernumbers}
    {\ifundef\abx@field@localnumber
      {\numdef\abx@field@localnumber{0}}%
      {}}
    {\ifundef\abx@field@localnumber
      {\edef\abx@field@localnumber{%
          \csuse{blx@labelnumber@\the\c@refsection}}}
      {}}%
  \blx@setlabwidth{\csname #1labelnumberwidth\endcsname}{%
    \csuse{abx@flfw@labelnumberwidth}{%
      \ifdef\abx@field@labelprefix
        {\csuse{abx@flfw@labelprefix}{\abx@field@labelprefix}}
        {}%
      \csuse{abx@flfw@labelnumber}{\abx@field@localnumber}}}}

\def\blx@bbl@labelnumberwidth@shorthand#1{%
  \abx@flfw@getfieldformat{abx@flfw@labelnumberwidth}{labelnumberwidth}{}%
  \abx@flfw@getfieldformat{abx@flfw@labelnumber}{labelnumber}{}%
  \blx@setlabwidth{\csname #1labelnumberwidth\endcsname}{%
    \csuse{abx@flfw@labelnumberwidth}{%
      \csuse{abx@flfw@labelnumber}{\abx@field@shorthand}}}}

\def\blx@bbl@locallabelnumberwidth{%
  \ifdefempty\abx@field@localnumber
    {}
    {\ifundef\abx@field@shorthand
       {\blx@bbl@labelnumberwidth@numeric{local}}
       {\blx@bbl@labelnumberwidth@shorthand{local}}}}

% {&lt;prefix for labelwidth fields&gt;}
\def\blx@bbl@labelalphawidth#1{%
  \abx@flfw@getfieldformat{abx@flfw@labelalphawidth}{labelalphawidth}{}%
  \abx@flfw@getfieldformat{abx@flfw@labelprefix}{labelprefix}{}%
  \abx@flfw@getfieldformat{abx@flfw@labelalpha}{labelalpha}{}%
  \abx@flfw@getfieldformat{abx@flfw@extraalpha}{extraalpha}{}%
  \blx@setlabwidth{\csname #1labelalphawidth\endcsname}{%
    \csuse{abx@flfw@labelalphawidth}{%
      \ifdef\abx@field@labelprefix
        {\csuse{abx@flfw@labelprefix}{\abx@field@labelprefix}}
        {}%
      \csuse{abx@flfw@labelalpha}{\abx@field@labelalpha}%
      \ifundef\abx@field@extraalpha
        {}
        {\csuse{abx@flfw@extraalpha}{\abx@field@extraalpha}}}}}

\def\blx@bbl@locallabelalphawidth{%
  \ifundef\abx@field@labelalpha
    {}
    {\blx@bbl@labelalphawidth{local}}}

\def\blx@bbl@locallabelfields{\blx@bbl@labelfields@i{local}}

\def\blx@bbl@labelfields{\blx@bbl@labelfields@i{}}

% {&lt;prefix for labelwidth fields&gt;}
\def\blx@bbl@labelfields@i#1{%
  \def\do##1{%
    \ifcsundef{abx@field@##1}
      {}
      {\abx@flfw@getfieldformat{abx@flfw@##1width}{##1width}{##1}%
       \blx@setlabwidth{\csname #1##1width\endcsname}{%
         \csuse{abx@flfw@##1width}{\csname abx@field@##1\endcsname}}}}%
  \abx@dolabelfields}

\def\blx@bbl@labelnumber{%
  % Used at endentry, when reading .bbl
  % only do this for the global sorting list otherwise we increment
  % the labelnumbers for each sortlist
  \ifdefempty\abx@field@localnumber
    {}% only if omitnumbers=true
    {\ifundef\abx@field@shorthand
      {\iftoggle{blx@defernumbers}
        % only if defernumbers=true, we have to define localnumber to
        % something to stop labelnumberwidth def complaining on first
        % post-backend run since there will be nothing in the .aux yet
        % for defernums localnumbers. On the second post-backend run,
        % it will have a value correct for generating labelnumberwidth
        % We also have to define a dummy value for labelnumber here for
        % first post-backend runs otherwise references to labelnumber
        % in cite styles like numeric-comp will die.
        {\ifundef\abx@field@localnumber
          {\numdef\abx@field@localnumber{0}%
           \blx@bbl@fielddef{labelnumber}{0}}%
          {}}
        {\csnumgdef{blx@labelnumber@\the\c@refsection}{%
            \csuse{blx@labelnumber@\the\c@refsection}+1}%
          \edef\abx@field@localnumber{%
            \csuse{blx@labelnumber@\the\c@refsection}}%
          \blx@bbl@fieldedef{labelnumber}{\abx@field@localnumber}%
          \blx@bbl@fieldedef{localnumber}{\abx@field@localnumber}}%
        \iftoggle{blx@skipbib}
          {}
          {\blx@bbl@labelnumberwidth@numeric{}}}
      {\csgappto\blx@bbl@data{\let\abx@field@labelnumber\abx@field@shorthand}%
        \iftoggle{blx@skipbib}
          {}
          {\blx@bbl@labelnumberwidth@shorthand{}}}}}

\def\blx@bbl@labelalpha{%
   \ifundef\abx@field@labelalpha
     {}
     {\ifundef\abx@field@extraalpha
        {}
        {\ifnum\abx@field@extraalpha&gt;\c@maxextraalpha
           \global\c@maxextraalpha\abx@field@extraalpha\relax
         \fi}%
      \iftoggle{blx@skipbib}
        {}
        {\blx@bbl@labelalphawidth{}}}}

\def\blx@bbl@labeltitle{%
  \ifundef\abx@field@extratitle
    {}
    {\ifnum\abx@field@extratitle&gt;\c@maxextratitle
       \global\c@maxextratitle\abx@field@extratitle\relax
     \fi}}

\def\blx@bbl@labeltitleyear{%
  \ifundef\abx@field@extratitleyear
    {}
    {\ifnum\abx@field@extratitleyear&gt;\c@maxextratitleyear
       \global\c@maxextratitleyear\abx@field@extratitleyear\relax
     \fi}}

\def\blx@bbl@labelname{%
  \ifundef\abx@field@extraname
    {}
    {\ifnum\abx@field@extraname&gt;\c@maxextraname
       \global\c@maxextraname\abx@field@extraname\relax
     \fi}}

\def\blx@bbl@labeldate{%
  \ifundef\abx@field@extradate
    {}
    {\ifnum\abx@field@extradate&gt;\c@maxextradate
       \global\c@maxextradate\abx@field@extradate\relax
     \fi}}

\def\blx@bbl@titles{%
  \ifundef\abx@field@indextitle
    {\csgappto\blx@bbl@data{%
       \let\abx@field@indextitle\abx@field@title}}
    {}%
  \ifundef\abx@field@indexsorttitle
    {\csgappto\blx@bbl@data{%
       \let\abx@field@indexsorttitle\abx@field@indextitle}}
    {}}

\def\blx@bbl@hooks{%
  \ifcsundef{blx@hook@bblitem@*}
    {\ifcsundef{blx@hook@bblitem@\abx@field@entrytype}
       {}
       {\csuse\blx@bbl@data
        \csuse{blx@hook@bblitem@\abx@field@entrytype}}}
    {\csuse\blx@bbl@data
     \csuse{blx@hook@bblitem@*}%
     \csuse{blx@hook@bblitem@\abx@field@entrytype}}}

\newrobustcmd*{\AtDataInput}[1][*]{\csgappto{blx@hook@bblitem@#1}}
\@onlypreamble\AtDataInput

\def\blx@setlabwidth#1#2{%
  \begingroup
  \settowidth{\@tempdima}{\bibfont#2}%
  \ifnum\@tempdima&gt;#1%
    \global#1\@tempdima
  \fi
  \endgroup}

\def\blx@bblstart{%
  \let\preamble\blx@bbl@preamble
  \let\warn\blx@bbl@thewarn
  \let\refsection\blx@bbl@refsection
  \let\endrefsection\blx@bbl@endrefsection
  \let\entry\blx@bbl@entry
  \let\endentry\blx@bbl@endentry
  \let\missing\blx@bbl@missing
  \let\keyalias\blx@bbl@keyalias
  \let\datalist\blx@bbl@dlist
  \let\enddatalist\blx@bbl@enddlist
  \let\set\blx@bbl@set
  \let\inset\blx@bbl@inset
  \let\fakeset\blx@bbl@fakeset % A No-op for Biber
  \let\xref\blx@bbl@xref % A No-op for Biber
  \let\keyw\blx@bbl@keyw
  \let\name\blx@bbl@namedef
  \let\list\blx@bbl@listdef
  \let\field\blx@bbl@fielddef
  \let\range\blx@bbl@rangedef
  \let\strng\blx@bbl@stringdef
  \let\cnt\blx@bbl@cntdef
  \let\true\blx@bbl@booltrue
  \let\false\blx@bbl@boolfalse
  \let\verb\blx@bbl@verbdef
  \let\endverb\blx@bbl@verbend
  \let\lverb\blx@bbl@verbldef
  \let\endlverb\blx@bbl@verblend
  \let\annotation\blx@bbl@annotationdef}

\def\blx@bblend{%
  \def\blx@do@outer##1{%
    \ifcsundef{blx@prelim@lastcites@##1}
      {}
      {\def\blx@do@inner####1{%
         \ifinlistcs{####1}{blx@keyaliases@##1}
           {\listcsxadd{blx@lastcites@##1}
              {\csuse{blx@keyalias@##1@####1}}}
           {\listcsgadd{blx@lastcites@##1}{####1}}}%
       \forlistcsloop\blx@do@inner{blx@prelim@lastcites@##1}}}%
  \forlistloop\blx@do@outer\blx@alllastrefsections
  % Special warning for defernumbers when a citation cannot be found
  \iftoggle{blx@defernumbers}
    {\def\blx@do@outer##1{%
       \ifcsundef{blx@lastcites@##1}
         {}
         {\def\blx@do@inner####1{%
            \ifinlistcs{####1}{blx@entries@##1}
              {}
              {\blx@warning@noline{%
                 citation '####1'\MessageBreak
                 was not found at all in the .bbl file,\MessageBreak
                 bibliography labels cannot be generated,\MessageBreak
                 please correct the citation}}}%
          \forlistcsloop\blx@do@inner{blx@lastcites@##1}}}%
     \forlistloop\blx@do@outer\blx@alllastrefsections}
    {}}

% {&lt;entrykey&gt;}
% Get the saved information on which citations were mentioned last run
\protected\def\abx@aux@cite#1#2{%
  \xifinlistcs{\detokenize{#2}}{blx@prelim@lastcites@#1}
    {}
    {\listcsxadd{blx@prelim@lastcites@#1}{\detokenize{#2}}}}

% {&lt;refcontext&gt;}
% Get the saved information on which refcontexts were mentioned last run
\protected\def\abx@aux@refcontext#1{%
  \xifinlist{\detokenize{#1}}\blx@lastrefcontexts
    {}
    {\listxadd\blx@lastrefcontexts{\detokenize{#1}}}}

% {&lt;sortingtemplatename&gt;}
% Get the saved information on which shorthand sorting templates were mentioned last run
\protected\def\abx@aux@biblist#1{%
  \ifinlist{#1}\blx@lastbiblists
    {}
    {\listgadd\blx@lastbiblists{#1}}}

% Here we mustn't change the checksum if we used localnumbers from the
% .aux file as this means that deferred numbering is
% complete. Otherwise we get in an endless rerun loop because the
% checksum due to number changes is always different.
\blx@AtEndDocument{%
  \def\abx@aux@number#1#2#3#4#5{%
    \ifblank{#5}
      {}
      {\nottoggle{blx@localnumber}
         {\blx@addchecksum{#1}{#5}}
         {}}}}

\blx@AtEndDocument{%
  % Here we run some tests to decide if we need to issue re-run
  % messages in certain circumstances. In general, if we add/remove
  % any citations or add/remove any sorting templates, we need to re-run
  % biber. Also, if we have to re-run biber, we need to defer writing
  % the defernumbers .aux information because it will not yet be correct.
  \begingroup
  % Test to see if there are any .aux entries with defernums (localnum)
  % information which are no longer in the .bbl. This is to catch
  % when .bib entries are removed when using \nocite{*}. In this case,
  % We need another run to remove the .aux localnumber info
  \def\blx@do@outer#1{%
    \def\blx@do@inner##1{%
      \xifinlistcs{##1}{blx@entries@#1}
        {}
        {\blx@rerun@latex
         \listbreak}}%
    \forlistloop\blx@do@inner\blx@localnumbers}%
  \forlistloop\blx@do@outer\blx@allrefsections
  % Test to see if we *removed* any citations since last run
  % (adding citations is dealt with naturally in \blx@citation@entry)
  % If so, give a rerun biber message. This also sets the
  % rerun biber toggle so defernums doesn't consume the localnumbers
  % in the .aux but instead, re-writes them, which is what we need.
  \def\blx@do@outer#1{%
    \ifcsundef{blx@lastcites@#1}
      {}
      {\def\blx@do@inner##1{%
         \ifinlistcs{##1}{blx@cites@#1}
           {}
           {\blx@logreq@active{}%
            \listbreak}}%
       \forlistcsloop\blx@do@inner{blx@lastcites@#1}}}%
  \forlistloop\blx@do@outer\blx@alllastrefsections
  % Special case - if we are using sortingtemplate with \citeorder anywhere,
  % then changes in citation order matter and we need to re-run biber.
  % So a special test to see if the cites from last run are identical in order.
  % We have already tested for more or less cites between runs by now, we are
  % testing here for exactly the same cites by treating the cite and
  % lastcite lists as strings and comparing them. This doesn't apply
  % to biblist sortingtemplates as nobody wants to sort biblists with
  % "none", since it makes no sense
  \togglefalse{blx@tempa}%
  \def\do#1{%
    \ifcsundef{blx@sortingtemplate@citeorder@relevant@#1}
      {}
      {\toggletrue{blx@tempa}%
       \listbreak}}%
  \dolistloop\blx@sortingtemplatenames
  \iftoggle{blx@tempa}
    {\ifdefstrequal\blx@allrefsections\blx@alllastrefsections
       {\def\do#1{%
          \ifcsundef{blx@cites@#1}
            {\cslet{blx@cites@#1}\@empty}
            {}%
          \ifcsundef{blx@lastcites@#1}
            {\cslet{blx@lastcites@#1}\@empty}
            {}%
          \ifcsstrequal{blx@cites@#1}{blx@lastcites@#1}
            {}
            {\blx@logreq@active{}%
             \listbreak}}%
        \dolistloop\blx@allrefsections}
       {\blx@logreq@active{}}}
    {}%
  % if citecount is enabled we pass the counter on to Biber via the bcf
  % for sorting, we need to rerun if anything here changed
  \ifundef\blx@citecounter
    {}
    {\def\blx@do@outer#1{%
       \ifcsundef{blx@cites@#1}
         {}
         {\def\blx@do@inner##1{%
            \ifnumequal{0\csuse{blx@currcount@#1@\detokenize{##1}}}
                       {0\csuse{blx@count@#1@\detokenize{##1}}}
              {}
              {\blx@logreq@active{}%
               \listbreak}}%
          \forlistcsloop\blx@do@inner{blx@cites@#1}}}%
     \forlistloop\blx@do@outer\blx@allrefsections}%
  % Test if we removed any mention of a reference context since last run
  % If we did, we need to re-run biber
  \def\do#1{\ifinlist{#1}\blx@refcontexts{}{\blx@logreq@active{}}\relax}%
  \dolistloop\blx@lastrefcontexts
  % Test if we added any mention of a reference context since last run
  % If we did, we need to re-run biber
  \def\do#1{\ifinlist{#1}\blx@lastrefcontexts{}{\blx@logreq@active{}}\relax}%
  \dolistloop\blx@refcontexts
  % Test if we removed any mention of a biblist since last run.
  % If we did, we need to re-run biber
  \def\do#1{\ifinlist{#1}\blx@biblists{}{\blx@logreq@active{}}\relax}%
  \dolistloop\blx@lastbiblists
  % Test to see if we added any mention of a biblist since last run.
  % If we did, we need to re-run biber
  \def\do#1{\ifinlist{#1}\blx@lastbiblists{}{\blx@logreq@active{}}\relax}%
  \dolistloop\blx@biblists
  % If we have to run biber or latex again and we are using defernumbers,
  % don't write the localnumber information to the .aux file yet as we will
  % potentially have to regenerate sorting order first in biber
  \iftoggle{blx@defernumbers}
    {\iftoggle{blx@runbiber}
      {}
      {\def\do#1{\blx@auxwrite\@mainaux{}{#1}}
       \dolistloop\blx@localnumaux}}
    {}%
  % Write out missing languages we still need to load
  \forlistloop{\blx@lbx@writeloaderequest}{\blx@lbx@loadlist}%
  % Issue rerun warning if we need to load a language babel/polyglossia
  % hasn't told us about and that we are not loading it already from previous
  % runs.
  \def\do#1{\xifinlist{#1}{\blx@lbx@auxloadlist}{}{\blx@rerun@latex\listbreak}}%
  \dolistloop\blx@lbx@loadlist
  % Write md5 hash of .bbl to .aux if we need a Biber rerun.
  % This needs to happen here and not in \blx@check@rerun together with
  % the other rerun stuff, because \AfterEndDocument would be too
  % late for .aux file writing.
  \blx@aux@write@bbl@mdfivesum
  \endgroup}

% {&lt;instcount&gt;}{&lt;entrykey&gt;}{&lt;refsection&gt;}{&lt;refcontext&gt;}{&lt;labelnumber&gt;}
\protected\def\blx@aux@number#1#2#3#4#5{%
  \blx@bbl@addentryfield{\detokenize{#2}}{#3}{localnumber}{#4}{#5}%
  \blx@bbl@addentryfield{\detokenize{#2}}{#3}{labelnumber}{#4}{#5}%
  \csgdef{blx@localnumber@#3@\detokenize{#2}}{#5}%
  \xifinlistcs{\detokenize{#2}}{blx@localnumbers@#3}
    {}
    {\listcsxadd{blx@localnumbers@#3}{\detokenize{#2}}}%
  \global\toggletrue{blx@localnumber}%
  \ifblank{#5}
    {}
    {\csgdef{blx@labelnumber@#3}{#5}}}

% Called as part of bib output for an entry
% Only used when defernumbers=true
\def\blx@addlabelnumber{%
  \begingroup
  \nottoggle{blx@skiplab}
    {\iftoggle{blx@labelnumber}
       {\ifundef\abx@field@shorthand
         % Need to know if we set any localnumber from .aux file, not
         % just current item. Otherwise, we may just write new
         % localnumbers but not existing ones
         % Also, don't want to regenerate localnumber for any key in a
         % refsection which we've already seen because this has the nasty
         % side-effect of incrementing the localnum counter
         % Also, have to create localnumber again if \nocite{*} as items
         % could have been added to the .bib file without changing the cite
         % information in the .tex
         {\ifboolexpr { (not togl {blx@localnumber}
                         or
                         test {\ifinlist{*}\blx@nocites})
                         and
                         not test {\ifcsdef{blx@defer@\the\c@refsection @\blx@refcontext@context @\abx@field@entrykey}} }
            {\iftoggle{blx@omitnumbers}
               {\let\abx@field@localnumber\@empty}
               {\csnumgdef{blx@labelnumber@\the\c@refsection}{%
                  \csuse{blx@labelnumber@\the\c@refsection}+1}%
                \edef\abx@field@localnumber{%
                  \csuse{blx@labelnumber@\the\c@refsection}}%
                \blx@bbl@addentryfield{\abx@field@entrykey}{\the\c@refsection}%
                {localnumber}{\blx@refcontext@context}{\abx@field@localnumber}}}
            {}%
          % Issue re-run message if there was no localnumber in the .aux and
          % \nocite{*} was used because this means that an entry was added to the .bib
          % and was not yet recorded in the .aux. We will have generated a localnumber
          % for such a case above and now we need to re-run to make sure it's in the .aux
          % for the next run
          \ifboolexpr { test {\ifinlist{*}\blx@nocites}
                        and
                        not test {\ifcsdef{blx@localnumber@\the\c@refsection @\abx@field@entrykey}} }
            {\blx@rerun@latex}
            {}%
          % If localnumbers were already in the .aux, add them
          % again from the .aux. This prevents some cycling
          % problems where pagebreaks change after localnumber
          % settles down and then we need another run which then
          % regenerates localnumber requiring another run but then
          % the pagebreaks change back again ... etc.
          \ifcsundef{blx@defer@\the\c@refsection @\blx@refcontext@context @\abx@field@entrykey}
            {\ifundef\abx@field@localnumber
               {}
               {\listxadd\blx@localnumaux{%
                  \string\abx@aux@number%
                     {\the\c@instcount}%
                     {\abx@field@entrykey}%
                     {\the\c@refsection}%
                     {\blx@refcontext@context}%
                     {\abx@field@localnumber}}%
                   % record that we have already generated and output localnum
                   % for this key in this refsection/refcontext
                   \global\cslet{blx@defer@\the\c@refsection @\blx@refcontext@context @\abx@field@entrykey}\@empty}}
           {}}
         {}}%
       {}}
    {}%
  \endgroup}

% {&lt;datalistname&gt;}
\def\blx@bbl@dlist[#1]#2{%
  \begingroup
  \def\blx@dlist@type{#1}%
  \def\blx@dlist@name{#2}}

\def\blx@bbl@enddlist{%
  \csnumgdef{blx@labelnumber@\the\c@refsection}{0}%
  \endgroup}

\def\blx@addpageref#1{%
  \begingroup
  \blx@tempcnta\z@
  \let\blx@tempa\@empty
  \def\do##1{%
    \appto\blx@tempa{{##1}}%
    \advance\blx@tempcnta\@ne}%
  \dolistcsloop{blx@pref@\the\c@refsection @#1}%
  \edef\blx@tempa{\endgroup
    \noexpand\blx@bbl@listdef{pageref}{\the\blx@tempcnta}{\expandonce{\blx@tempa}}}%
  \blx@tempa}

%% Data input
\def\blx@bblinput{%
  \begingroup
  \blx@info@noline{Trying to load bibliographic data..}%
  \blx@blxinit
  \blx@bblfile
  \endgroup}

\def\blx@bblfile{%
  \blx@secinit
  \begingroup
  \blx@bblstart
  \blx@ifsigned{\jobname}{bbl}
    {\InputIfFileExists{\jobname.bbl}
       {\blx@info@noline{... file '\jobname.bbl' found}%
        \global\toggletrue{blx@bbldone}%
        \blx@generate@bbl@mdfivesum@found{\jobname.bbl}}
       {\blx@info@noline{... file '\jobname.bbl' not found}%
        \typeout{No file \jobname.bbl.}%
        \blx@generate@bbl@mdfivesum@notfound}}
    {\blx@generate@bbl@mdfivesum@notfound}%
  \blx@bblend
  \endgroup
  % Check if Biber rerun was not carried out.
  % If so, ask for it again.
  \blx@check@bbl@rerun@mdfivesum
  % global sorting as this is called at BeginDocument
  \csnumgdef{blx@labelnumber@\the\c@refsection}{0}}

%% Bibliography

% {&lt;name&gt;}{&lt;start code&gt;}[&lt;end code&gt;]{&lt;item code&gt;}
\newrobustcmd*{\defbibenvironment}[4]{%
  \long\csdef{blx@env@#1}{#2}%
  \long\csdef{blx@endenv@#1}{#3}%
  \long\csdef{blx@item@#1}{#4}}

\defbibenvironment{bibliography}
  {\list{}{%
     \leftmargin\bibhang
     \itemindent-\leftmargin
     \itemsep\bibitemsep
     \parsep\bibparsep}}
  {\endlist}
  {\item}

\def\do#1{%
  \defbibenvironment{#1}
   {\list{\thefield{#1}}{%
       \labelwidth\csname #1width\endcsname
       \labelsep\biblabelsep
       \leftmargin\labelwidth
       \advance\leftmargin\labelsep
       \itemsep\bibitemsep
       \parsep\bibparsep
       \def\makelabel####1{####1\hss}}}
    {\endlist}
    {\item}}
\abx@dolabelfields

% {&lt;name&gt;}[&lt;default&gt;]{&lt;code&gt;}
\newrobustcmd*{\defbibheading}[1]{%
  \@ifnextchar[%]
    {\blx@defbibheading{blx@head@#1}}
    {\blx@defbibheading{blx@head@#1}[\bibname]}}

\def\blx@defbibheading#1[#2]{%
  \csundef{#1}%
  \expandafter\newcommand\csname#1\endcsname[1][{#2}]}

% {&lt;name&gt;}{&lt;text&gt;}
\newrobustcmd*{\defbibnote}[1]{%
  \blx@defbibnote{#1}}

\long\def\blx@defbibnote#1#2{%
  \long\csdef{blx@note@#1}{#2}}

% {&lt;name&gt;}{&lt;code&gt;}
\newrobustcmd*{\defbibfilter}[2]{%
  \begingroup
  \def\blx@flt@error{\csname blx@flt@errortrue\endcsname}%
  \let\not\blx@flt@not \let\NOT\not
  \let\and\blx@flt@and \let\AND\and
  \let\or\blx@flt@or   \let\OR\or
  \letcs\({blx@flt@(}  \letcs\){blx@flt@)}%
  \def\section##1{\blx@flt@error}%
  \def\segment##1{segment=##1}%
  \def\type##1{type=##1}%
  \def\subtype##1{subtype=##1}%
  \def\keyword##1{keyword={##1}}%
  \def\category##1{category={##1}}%
  \edef\blx@tempa{\noexpand\blx@defbibfilter{#2}}%
  \ifdef\blx@flt@errortrue
    {\blx@err@filter}
    {\let\the\relax
     \let\blx@flt@item\relax
     \edef\blx@tempa{\blx@tempa}%
     \ifdef\blx@flt@errortrue
       {\blx@err@filter}
       {\csxdef{blx@filter@#1}{\blx@tempa}}}%
  \endgroup}

\def\blx@defbibfilter#1{%
  \blx@defbibfilter@i#1 &amp;}
\def\blx@defbibfilter@i#1 #2&amp;{%
  \blx@defbibfilter@ii#1==&amp;%
  \ifblank{#2}{}{\blx@defbibfilter@i#2 &amp;}}
\def\blx@defbibfilter@ii#1=#2=#3&amp;{%
  \ifblank{#2}
    {\ifblank{#1}
       {}
       {\ifcsdef{blx@flt@#1}
          {\csname blx@flt@#1\endcsname}
          {\blx@flt@error}}}
    {\ifcsdef{blx@flt@#1}
       {\csname blx@flt@#1\endcsname{\detokenize{#2}}}
       {\blx@flt@error}}}

\def\blx@flt@and{ and }
\def\blx@flt@or{ or }
\def\blx@flt@not{ not }
\csdef{blx@flt@(}{ ( }
\csdef{blx@flt@)}{ ) }
\def\blx@flt@segment#1{%
  test {\xifinlistcs\blx@flt@item{blx@segm@\the\c@refsection @#1}}}
\def\blx@flt@type#1{%
  test {\xifinlistcs\blx@flt@item{blx@type@\the\c@refsection @#1}}}
\def\blx@flt@subtype#1{%
  test {\xifinlistcs\blx@flt@item{blx@subt@\the\c@refsection @#1}}}
\def\blx@flt@keyword#1{%
  test {\xifinlistcs\blx@flt@item{blx@keyw@\the\c@refsection @#1}}}
\def\blx@flt@category#1{%
  test {\xifinlistcs\blx@flt@item{blx@catg@#1}}}

% {&lt;name&gt;}{&lt;code&gt;}
\newrobustcmd*{\defbibcheck}[2]{%
  \csdef{blx@bibcheck@#1}{%
    \togglefalse{blx@skipentry}%
    \def\skipentry{\toggletrue{blx@skipentry}}%
    #2\undef\skipentry}}

% options
% We need a 2-pass structure for options in \printbibliography and
% \printbiblist because the section has to be set before any
% other options and this partly determines which list to use for later filtering
\blx@kv@defkey{blx@bib1}{segment}{}
\blx@kv@defkey{blx@bib1}{type}{}
\blx@kv@defkey{blx@bib1}{nottype}{}
\blx@kv@defkey{blx@bib1}{subtype}{}
\blx@kv@defkey{blx@bib1}{notsubtype}{}
\blx@kv@defkey{blx@bib1}{keyword}{}
\blx@kv@defkey{blx@bib1}{notkeyword}{}
\blx@kv@defkey{blx@bib1}{category}{}
\blx@kv@defkey{blx@bib1}{notcategory}{}
\blx@kv@defkey{blx@bib1}{filter}{}
\blx@kv@defkey{blx@bib1}{check}{}
\blx@kv@defkey{blx@bib1}{heading}{}
\blx@kv@defkey{blx@bib1}{env}{}
\blx@kv@defkey{blx@bib1}{title}{}
\blx@kv@defkey{blx@bib1}{label}{}
\blx@kv@defkey{blx@bib1}{prenote}{}
\blx@kv@defkey{blx@bib1}{postnote}{}
\blx@kv@defkey{blx@bib1}{omitnumbers}[]{}
% Here we are using the first pass to see if there is an explicit setting for resetnumbers
% If there isn't we will use the default behaviour where if there is a labelprefix,
% resetnumbers will default to "true"
\blx@kv@defkey{blx@bib1}{resetnumbers}[true]{%
  \toggletrue{blx@resetnumsexplicit}}

\blx@kv@defkey{blx@bib2}{section}{}
\blx@kv@defkey{blx@bib2}{sorting}{}

\blx@kv@defkey{blx@biblist1}{segment}{}
\blx@kv@defkey{blx@biblist1}{type}{}
\blx@kv@defkey{blx@biblist1}{nottype}{}
\blx@kv@defkey{blx@biblist1}{subtype}{}
\blx@kv@defkey{blx@biblist1}{notsubtype}{}
\blx@kv@defkey{blx@biblist1}{keyword}{}
\blx@kv@defkey{blx@biblist1}{notkeyword}{}
\blx@kv@defkey{blx@biblist1}{category}{}
\blx@kv@defkey{blx@biblist1}{notcategory}{}
\blx@kv@defkey{blx@biblist1}{filter}{}
\blx@kv@defkey{blx@biblist1}{check}{}
\blx@kv@defkey{blx@biblist1}{heading}{}
\blx@kv@defkey{blx@biblist1}{env}{}
\blx@kv@defkey{blx@biblist1}{title}{}
\blx@kv@defkey{blx@biblist1}{label}{}
\blx@kv@defkey{blx@biblist1}{prenote}{}
\blx@kv@defkey{blx@biblist1}{postnote}{}

\blx@kv@defkey{blx@biblist2}{section}{}
\blx@kv@defkey{blx@biblist2}{sorting}{}

\blx@kv@defkey{blx@bib1}{section}{%
  \ifcsundef{blx@sections@#1}
    {\blx@err@nosec{#1}}
    {\c@refsection#1\relax
     \def\blx@tempe{#1}}}

\blx@kv@defkey{blx@biblist1}{section}{%
  \ifcsundef{blx@sections@#1}
    {\blx@err@nosec{#1}}
    {\c@refsection#1\relax
     \def\blx@tempe{#1}}}

\blx@kv@defkey{blx@bbg}{section}{%
  \ifcsundef{blx@sections@#1}
    {\blx@err@nosec{#1}}
    {\c@refsection#1\relax}}

\blx@kv@defkey{blx@bbc}{section}{%
  \ifcsundef{blx@sections@#1}
    {\blx@err@nosec{#1}}
    {\c@refsection#1\relax}}

\blx@kv@defkey{blx@bib2}{segment}{\blx@key@segment{#1}}
\blx@kv@defkey{blx@biblist2}{segment}{\blx@key@segment{#1}}

\def\blx@key@segment#1{%
  \ifcsundef{blx@segm@\the\c@refsection @#1}
    {\blx@warning{Segment '#1' not found in section '\the\c@refsection'}}
    {\c@refsegment#1\relax
     \blx@printbibchecks
     \blx@filter\blx@tempa{blx@segm@\the\c@refsection @#1}}}

\blx@kv@defkey{blx@bib2}{type}{\blx@key@type{#1}}
\blx@kv@defkey{blx@biblist2}{type}{\blx@key@type{#1}}

\def\blx@key@type#1{%
  \ifcsundef{blx@type@\the\c@refsection @#1}
    {\blx@warning{Type '#1' not found}%
     \let\blx@tempa\@empty}
    {\blx@printbibchecks
     \iftoggle{blx@tempb}
       {\togglefalse{blx@tempb}%
        \blx@filter\blx@tempa{blx@type@\the\c@refsection @#1}}
       {\let\blx@tempa\@empty
        \blx@error
          {'type' used multiple times}
          {When passing multiple filter options, each entry\MessageBreak
           must satisfy all conditions (AND conjunction),\MessageBreak
           hence some options may not be used twice.\MessageBreak
           Use 'filter' and '\string\defbibfilter' with OR conjunctions}}}}

\blx@kv@defkey{blx@bib2}{nottype}{\blx@key@nottype{#1}}
\blx@kv@defkey{blx@biblist2}{nottype}{\blx@key@nottype{#1}}

\def\blx@key@nottype#1{%
  \ifcsundef{blx@type@\the\c@refsection @#1}
    {}
    {\blx@printbibchecks
     \blx@notfilter\blx@tempa{blx@type@\the\c@refsection @#1}}}

\blx@kv@defkey{blx@bib2}{subtype}{\blx@key@subtype{#1}}
\blx@kv@defkey{blx@biblist2}{subtype}{\blx@key@subtype{#1}}

\def\blx@key@subtype#1{%
  \ifcsundef{blx@subt@\the\c@refsection @#1}
    {\blx@warning{Subtype '#1' not found}%
     \let\blx@tempa\@empty}
    {\blx@printbibchecks
     \iftoggle{blx@tempb}
       {\togglefalse{blx@tempb}%
        \blx@filter\blx@tempa{blx@subt@\the\c@refsection @#1}}
       {\let\blx@tempa\@empty
        \blx@error
          {'subtype' used multiple times}
          {When passing multiple filter options, each entry\MessageBreak
           must satisfy all conditions (AND conjunction),\MessageBreak
           hence some options may not be used twice.\MessageBreak
           Use 'filter' and '\string\defbibfilter' with OR conjunctions}}}}

\blx@kv@defkey{blx@bib2}{notsubtype}{\blx@key@notsubtype{#1}}
\blx@kv@defkey{blx@biblist2}{notsubtype}{\blx@key@notsubtype{#1}}

\def\blx@key@notsubtype#1{%
  \ifcsundef{blx@subt@\the\c@refsection @#1}
    {}
    {\blx@printbibchecks
     \blx@notfilter\blx@tempa{blx@subt@\the\c@refsection @#1}}}

\blx@kv@defkey{blx@bib2}{keyword}{\blx@key@keyword{#1}}
\blx@kv@defkey{blx@biblist2}{keyword}{\blx@key@keyword{#1}}

\def\blx@key@keyword#1{%
  \ifcsundef{blx@keyw@\the\c@refsection @\detokenize{#1}}
    {\blx@warning{Keyword '\detokenize{#1}' not found}%
     \let\blx@tempa\@empty}
    {\blx@printbibchecks
     \blx@filter\blx@tempa{blx@keyw@\the\c@refsection @\detokenize{#1}}}}

\blx@kv@defkey{blx@bib2}{notkeyword}{\blx@key@notkeyword{#1}}
\blx@kv@defkey{blx@biblist2}{notkeyword}{\blx@key@notkeyword{#1}}

\def\blx@key@notkeyword#1{%
  \ifcsundef{blx@keyw@\the\c@refsection @\detokenize{#1}}
    {}
    {\blx@printbibchecks
     \blx@notfilter\blx@tempa{blx@keyw@\the\c@refsection @\detokenize{#1}}}}

\blx@kv@defkey{blx@bib2}{category}{\blx@key@category{#1}}
\blx@kv@defkey{blx@biblist2}{category}{\blx@key@category{#1}}

\def\blx@key@category#1{%
  \ifcsundef{blx@catg@\detokenize{#1}}
    {\blx@warning{Category '\detokenize{#1}' not found}%
     \let\blx@tempa\@empty}
    {\blx@printbibchecks
     \blx@filter\blx@tempa{blx@catg@\detokenize{#1}}}}

\blx@kv@defkey{blx@bib2}{notcategory}{\blx@key@notcategory{#1}}
\blx@kv@defkey{blx@biblist2}{notcategory}{\blx@key@notcategory{#1}}

\def\blx@key@notcategory#1{%
  \ifcsundef{blx@catg@#1}
    {}
    {\blx@printbibchecks
     \blx@notfilter\blx@tempa{blx@catg@#1}}}

\let\blx@default@thefilter\@empty
\blx@kv@defkey{blx@bibdefaults}{filter}{%
  \def\blx@default@thefilter{#1}}
\blx@kv@defkey{blx@bib2}{filter}{\blx@key@filter{#1}}
\blx@kv@defkey{blx@biblist2}{filter}{\blx@key@filter{#1}}

\def\blx@key@filter#1{%
  \ifblank{#1}
    {}
    {\ifcsdef{blx@filter@#1}
      {\blx@printbibchecks
       \blx@bibfilter\blx@tempa{blx@filter@#1}}
      {\let\blx@tempa\@empty
       \blx@error
         {Filter '#1' not found}
         {The filter '#1' could not be found.\MessageBreak
          Use \string\defbibfilter\space to define it}}}}

\blx@kv@defkey{blx@bib2}{check}{\blx@key@bibcheck{#1}}
\blx@kv@defkey{blx@biblist2}{check}{\blx@key@bibcheck{#1}}

% empty bibcheck does nothing
\cslet{blx@bibcheck@}\relax
\def\blx@key@bibcheck#1{%
  \ifcsdef{blx@bibcheck@#1}
    {\letcs\blx@bibcheck{blx@bibcheck@#1}}
    {\let\blx@tempa\@empty
     \blx@error
       {Check '#1' not found}
       {The check '#1' could not be found.\MessageBreak
        Use \string\defbibcheck\space to define it}}}

\def\blx@default@theheading{bibliography}
\blx@kv@defkey{blx@bibdefaults}{heading}{%
  \blx@key@heading{\blx@default@theheading}{#1}}
\blx@kv@defkey{blx@bhd}{heading}{%
  \blx@key@heading{\blx@theheading}{#1}}
\blx@kv@defkey{blx@bib2}{heading}{%
  \blx@key@heading{\blx@theheading}{#1}}
\blx@kv@defkey{blx@biblist2}{heading}{%
  \blx@key@heading{\blx@theheading}{#1}}
\blx@kv@defkey{blx@bbs}{heading}{%
  \blx@key@heading{\blx@theheading}{#1}}
\blx@kv@defkey{blx@bbg}{heading}{%
  \blx@key@heading{\blx@theheading}{#1}}

\def\blx@key@heading#1#2{%
  \ifcsundef{blx@head@#2}
     {\blx@error
        {Heading '#2' not found}
        {The heading '#2' could not be found.\MessageBreak
         Use \string\defbibheading\space to define it}}
     {\def#1{#2}}}

\def\blx@default@theenv{bibliography}
\blx@kv@defkey{blx@bibdefaults}{env}{%
  \blx@key@env{\blx@default@theenv}{#1}}
\blx@kv@defkey{blx@bib2}{env}{\blx@key@env{\blx@theenv}{#1}}
\blx@kv@defkey{blx@biblist2}{env}{\blx@key@env{\blx@theenv}{#1}}
\blx@kv@defkey{blx@bbs}{env}{\blx@key@env{\blx@theenv}{#1}}
\blx@kv@defkey{blx@bbg}{env}{\blx@key@env{\blx@theenv}{#1}}
\blx@kv@defkey{blx@bbc}{env}{\blx@key@env{\blx@theenv}{#1}}

\def\blx@key@env#1#2{%
  \ifcsundef{blx@env@#2}
     {\blx@error
        {Environment '#2' not found}
        {The environment '#2' could not be found.\MessageBreak
         Use \string\defbibenvironment\space to define it}}
     {\def#1{#2}}}

\let\blx@default@thetitle\@empty
\blx@kv@defkey{blx@bibdefaults}{title}{%
  \def\blx@default@thetitle{#1}}
\blx@kv@defkey{blx@bhd}{title}{\def\blx@thetitle{#1}}
\blx@kv@defkey{blx@bib2}{title}{\def\blx@thetitle{#1}}
\blx@kv@defkey{blx@biblist2}{title}{\def\blx@thetitle{#1}}

\blx@kv@defkey{blx@bhd}{label}{\def\blx@thelabel{#1}}
\blx@kv@defkey{blx@bib2}{label}{\def\blx@thelabel{#1}}
\blx@kv@defkey{blx@biblist2}{label}{\def\blx@thelabel{#1}}

\cslet{blx@note@}\@empty
\def\blx@key@bibnote#1#2{%
  \ifcsundef{blx@note@#2}
    {\blx@error
       {Note '#2' not found}
       {The note '#2' could not be found.\MessageBreak
        Use \string\defbibnote\space to define it}}
    {\def#1{#2}}}

\let\blx@default@theprenote\@empty
\blx@kv@defkey{blx@bibdefaults}{prenote}{%
  \blx@key@bibnote{\blx@default@theprenote}{#1}}
\blx@kv@defkey{blx@bib2}{prenote}{%
  \blx@key@bibnote{\blx@theprenote}{#1}}
\blx@kv@defkey{blx@biblist2}{prenote}{%
  \blx@key@bibnote{\blx@theprenote}{#1}}
\blx@kv@defkey{blx@bbs}{prenote}{%
  \blx@key@bibnote{\blx@theprenote}{#1}}
\blx@kv@defkey{blx@bbg}{prenote}{%
  \blx@key@bibnote{\blx@theprenote}{#1}}
\blx@kv@defkey{blx@bbc}{prenote}{%
  \blx@key@bibnote{\blx@theprenote}{#1}}
\blx@kv@defkey{blx@bhd}{prenote}{%
  \blx@key@bibnote{\blx@theprenote}{#1}}

\let\blx@default@thepostnote\@empty
\blx@kv@defkey{blx@bibdefaults}{postnote}{%
  \blx@key@bibnote{\blx@default@thepostnote}{#1}}
\blx@kv@defkey{blx@bib2}{postnote}{%
  \blx@key@bibnote{\blx@thepostnote}{#1}}
\blx@kv@defkey{blx@biblist2}{postnote}{%
  \blx@key@bibnote{\blx@thepostnote}{#1}}
\blx@kv@defkey{blx@bbs}{postnote}{%
  \blx@key@bibnote{\blx@thepostnote}{#1}}
\blx@kv@defkey{blx@bbg}{postnote}{%
  \blx@key@bibnote{\blx@thepostnote}{#1}}
\blx@kv@defkey{blx@bbc}{postnote}{%
  \blx@key@bibnote{\blx@thepostnote}{#1}}
\blx@kv@defkey{blx@bhd}{postnote}{%
  \blx@key@bibnote{\blx@thepostnote}{#1}}

\blx@kv@defkey{blx@bibdefaults}{locallabelwidth}{%
  \blx@key@locallabelwidth{#1}}
\blx@kv@defkey{blx@bib1}{locallabelwidth}[]{}
\blx@kv@defkey{blx@biblist1}{locallabelwidth}[]{}
\blx@kv@defkey{blx@bib2}{locallabelwidth}[true]{%
  \blx@key@locallabelwidth{#1}}
\blx@kv@defkey{blx@biblist2}{locallabelwidth}[true]{%
  \blx@key@locallabelwidth{#1}}

\def\blx@key@locallabelwidth#1{%
  \ifstrequal{#1}{true}
    {\let\blx@locallabelwidth@init\blx@locallabelwidth@setlengths
     \let\blx@locallabelwidth@finish\blx@locallabelwidth@write}
    {\let\blx@locallabelwidth@init\relax
     \let\blx@locallabelwidth@finish\relax}}

\blx@kv@defkey{blx@bib2}{resetnumbers}[true]{%
  \iftoggle{blx@defernumbers}
    {\ifstrequal{#1}{true}
       {\csnumdef{blx@labelnumber@\the\c@refsection}{0}}
       {\ifstrequal{#1}{false}
         {}
         {\csnumdef{blx@labelnumber@\the\c@refsection}{#1-1}}}}
    {\blx@warning{%
       Option 'resetnumbers' requires 'defernumbers=true'.\MessageBreak
       Ignoring 'resetnumbers=true'}}}

\blx@kv@defkey{blx@bib2}{omitnumbers}[true]{%
  \ifstrequal{#1}{true}
    {\iftoggle{blx@defernumbers}
       {\toggletrue{blx@omitnumbers}}
       {\blx@warning{%
          Option 'omitnumbers' requires 'defernumbers=true'.\MessageBreak
          Ignoring 'omitnumbers=true'}}}
    {}}


\newrobustcmd*{\DeclarePrintbibliographyDefaults}{%
  \blx@kv@setkeys{blx@bibdefaults}}

% [&lt;options&gt;]
\newrobustcmd*{\printbibheading}{%
  \begingroup
  \edef\on@line{\on@line}%
  \@ifnextchar[%]
    {\blx@printbibheading}
    {\blx@printbibheading[]}}

\def\blx@printbibheading[#1]{%
  \let\blx@theheading\blx@default@theheading
  \let\blx@thetitle\blx@default@thetitle
  \let\blx@theprenote\blx@default@theprenote
  \let\blx@thepostnote\blx@default@thepostnote
  \undef\blx@thelabel
  \blx@safe@actives
  \blx@kv@setkeys{blx@bhd}{#1}%
  \blx@rest@actives
  \blx@bibheading\blx@theheading\blx@thetitle
  \blx@biblabel\blx@thelabel
  \blx@bibnote\blx@theprenote
  \blx@bibnote\blx@thepostnote
  \endgroup}

% We use this to determine whether an explicit value for resetnumbers is passed to
% \printbibliography, if not, then we use the default behaviour where a labelprefix forces
% a reset. It is useful that we have a 2-pass structure for \printbibliography keys anyway.
\newtoggle{blx@resetnumsexplicit}

% [&lt;options&gt;]
\newrobustcmd*{\printbibliography}{%
  \begingroup
  \delimcontext{bib}%
  \edef\on@line{\on@line}%
  \@ifnextchar[%]
    {\blx@printbibliography}
    {\blx@printbibliography[]}}

\def\blx@printbibliography[#1]{%
  \toggletrue{blx@tempa}%
  \toggletrue{blx@tempb}%
  \let\blx@theheading\blx@default@theheading
  \let\blx@theenv\blx@default@theenv
  \let\blx@theprenote\blx@default@theprenote
  \let\blx@thepostnote\blx@default@thepostnote
  \let\blx@thetitle\blx@default@thetitle
  \let\blx@thefilter\blx@default@thefilter
  \undef\blx@thelabel
  % defaults
  \let\blx@tempa\@empty% before there is a .bbl, this must not be undef
  \edef\blx@tempe{\the\c@refsection}% default refsection is current
  \blx@safe@actives
  \togglefalse{blx@resetnumsexplicit}%
  \blx@kv@setkeys{blx@bib1}{#1}% First pass options keys - section and resetnumbers
  % Is there a user-specified option for resetnumbers? If so, this overrides the default
  % "labelprefix implies resetnumbers" behaviour
  \iftoggle{blx@resetnumsexplicit}
    {}
    {\ifdefempty\blx@refcontext@labelprefix
      {\ifdefempty\blx@refcontext@labelprefix@real}
      {\@secondoftwo}
      {}
      {\blx@kv@setkeys{blx@bib2}{resetnumbers}}}%
  \blx@rest@actives
  \ifcsvoid{blx@dlist@entry@\blx@tempe @\blx@refcontext@context}
    {}
    {\letcs\blx@tempa{blx@dlist@entry@\blx@tempe @\blx@refcontext@context}}%
  \blx@safe@actives
  % Must reset omitnumbers as it's a global macro and if we don't, any
  % \printbibliography following one with this set will inherit any
  % previous "true" value
  \togglefalse{blx@omitnumbers}%
  \expandafter\blx@key@filter\expandafter{\blx@thefilter}% Can only be defaulted once \blx@tempa is set since it filters on this
  \blx@kv@setkeys{blx@bib2}{#1}% ... now we have correct \blx@tempa, set rest of options
  \blx@rest@actives
  % Add datalist to list of seen datalists to prevent duplicates
  \xifinlist{\blx@refcontext@context @\blx@tempe @entry}\blx@dlistnames
    {}
    {\listxadd\blx@dlistnames{\blx@refcontext@context @\blx@tempe @entry}%
     \xappto\blx@dlists{%
       \blx@xml@dlist{\blx@refcontext@context}{entry}{\blx@tempe}{\blx@xml@dlist@refcontext{\blx@refcontext@sortingtemplatename}{\blx@refcontext@sortingnamekeytemplatename}{\blx@refcontext@labelprefix@real}{\blx@refcontext@uniquenametemplatename}{\blx@refcontext@labelalphanametemplatename}{\blx@refcontext@namehashtemplatename}}{}}}%
  \ifdefvoid\blx@tempa
    {\blx@warn@bibempty\endgroup}
    {\blx@bibliography\blx@tempa}}

% [&lt;options&gt;]
\newrobustcmd*{\bibbysection}{%
  \begingroup
  \delimcontext{bib}%
  \ifnum\c@blx@maxsection=\z@
    \blx@warning{No reference sections found}%
  \fi
  \edef\on@line{\on@line}%
  \@ifnextchar[%]
    {\blx@bibbysection}
    {\blx@bibbysection[]}}

\def\blx@bibbysection[#1]{%
  \let\blx@theheading\blx@default@theheading
  \let\blx@theenv\blx@default@theenv
  \let\blx@theprenote\blx@default@theprenote
  \let\blx@thepostnote\blx@default@thepostnote
  \let\blx@thetitle\blx@default@thetitle
  \let\blx@thefilter\blx@default@thefilter
  \undef\blx@thelabel
  \c@refsection\z@
  \blx@safe@actives
  \blx@kv@setkeys{blx@bbs}{#1}%
  \blx@rest@actives
  \togglefalse{blx@tempa}%
  \blx@refsections}

\def\blx@refsections{%
  \ifcsvoid{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}
    {}
    {\toggletrue{blx@tempa}%
     \begingroup
     \expandafter\blx@bibliography\csname blx@dlist@entry@\the\c@refsection @\blx@refcontext@context\endcsname}%
  \ifnum\c@refsection&lt;\c@blx@maxsection
    \advance\c@refsection\@ne
    \expandafter\blx@refsections
  \else
    \iftoggle{blx@tempa}{}{\blx@warn@bibempty}%
    \endgroup
  \fi}

% [&lt;options&gt;]
\newrobustcmd*{\bibbysegment}{%
  \begingroup
  \delimcontext{bib}%
  \edef\on@line{\on@line}%
  \ifnum\csname blx@maxsegment@\the\c@refsection\endcsname=\z@
    \blx@warning{No reference segments found}%
  \fi
  \@ifnextchar[%]
    {\blx@bibbysegment}
    {\blx@bibbysegment[]}}

\def\blx@bibbysegment[#1]{%
  \let\blx@theheading\blx@default@theheading
  \let\blx@theenv\blx@default@theenv
  \let\blx@theprenote\blx@default@theprenote
  \let\blx@thepostnote\blx@default@thepostnote
  \let\blx@thetitle\blx@default@thetitle
  \let\blx@thefilter\blx@default@thefilter
  \undef\blx@thelabel
  \c@refsegment\@ne
  \blx@safe@actives
  \blx@kv@setkeys{blx@bbg}{#1}%
  \blx@rest@actives
  \togglefalse{blx@tempa}%
  \blx@refsegments}

\def\blx@refsegments{%
  \ifcsvoid{blx@segm@\the\c@refsection @\the\c@refsegment}
    {}
    {\toggletrue{blx@tempa}%
     \begingroup
     \let\blx@tempa\@empty
     \ifcsvoid{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}
       {}
       {\letcs\blx@tempa{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}}%
     \blx@filter\blx@tempa{blx@segm@\the\c@refsection @\the\c@refsegment}%
     \blx@bibliography\blx@tempa}%
  \ifnum\c@refsegment&lt;\csname blx@maxsegment@\the\c@refsection\endcsname
    \advance\c@refsegment\@ne
    \expandafter\blx@refsegments
  \else
    \iftoggle{blx@tempa}{}{\blx@warn@bibempty}%
    \endgroup
  \fi}

% [&lt;options&gt;]
\newrobustcmd*{\bibbycategory}{%
  \begingroup
  \delimcontext{bib}%
  \edef\on@line{\on@line}%
  \ifx\blx@categories\@empty
    \blx@warning{No categories found}%
  \fi
  \@ifnextchar[%]
    {\blx@bibbycategory}
    {\blx@bibbycategory[]}}

\def\blx@bibbycategory[#1]{%
  \let\blx@theheading\blx@default@theheading
  \let\blx@theenv\blx@default@theenv
  \let\blx@theprenote\blx@default@theprenote
  \let\blx@thepostnote\blx@default@thepostnote
  \let\blx@thetitle\blx@default@thetitle
  \let\blx@thefilter\blx@default@thefilter
  \undef\blx@thelabel
  \blx@safe@actives
  \blx@kv@setkeys{blx@bbc}{#1}%
  \blx@rest@actives
  \togglefalse{blx@tempa}%
  \forlistloop\blx@bibcategory\blx@categories
  \blx@endbibcategory}

\def\blx@bibcategory#1{%
  \ifcsvoid{blx@catg@#1}
    {}
    {\toggletrue{blx@tempa}%
     \begingroup
     \blx@key@heading{\blx@theheading}{#1}%
     \let\blx@tempa\@empty
     \ifcsvoid{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}
       {}
       {\letcs\blx@tempa{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}}%
     \blx@filter\blx@tempa{blx@catg@#1}%
     \blx@bibliography\blx@tempa}}%

\def\blx@endbibcategory{%
  \iftoggle{blx@tempa}{}{\blx@warn@bibempty}%
  \endgroup}

% {&lt;entrykey&gt;,...}
\def\blx@bibliography{%
  \blx@bibheading\blx@theheading\blx@thetitle
  \blx@biblabel\blx@thelabel
  \blx@bibnote\blx@theprenote
  \begingroup
  \blx@bibinit
  \let\@noitemerr\@empty
  \let\blx@noitem\blx@warn@bibempty
  \ifnum\bibinitsep=\z@
    \let\blx@initsep\relax
  \fi
  \ifnum\bibnamesep=\z@
    \let\blx@namesep\relax
  \fi
  \blx@locallabelwidth@init
  \csuse{blx@env@\blx@theenv}%
  \csuse{blx@hook@bibinit}%
  \csuse{blx@hook@bibinit@next}%
  \let\blx@do\blx@bibitem
  \let\blx@done\blx@endbibliography
  \blx@listloop}

\def\blx@endbibliography{%
  \csuse{blx@endenv@\blx@theenv}%
  \blx@noitem
  \blx@locallabelwidth@finish
  \endgroup
  \blx@bibnote\blx@thepostnote
  \expandafter\endgroup\if@endpe\@doendpe\fi
  \par}

\def\blx@bibheading#1#2{%
  \begingroup
  \edef\blx@tempa{\endgroup
    \noexpand\blx@bibheading@i{\expandonce#1}{\expandonce#2}}%
  \blx@tempa}

\def\blx@bibheading@i#1#2{%
  \let\newrefsection\relax
  \let\newrefsegment\relax
  \ifblank{#2}
    {\csuse{blx@head@#1}}
    {\csuse{blx@head@#1}[{#2}]}%
  \let\newrefsection\blx@newrefsection
  \let\newrefsegment\blx@newrefsegment}

\def\blx@biblabel#1{%
  \ifdefvoid#1
    {}
    {\expandafter\label\expandafter{#1}}}

\def\blx@bibnote#1{%
  \ifdefempty#1
    {}
    {\begingroup
     \let\newrefsection\relax
     \let\newrefsegment\relax
     \noindent
     \csuse{blx@note@#1}\par\nobreak
     \endgroup}}

\def\blx@bibinit{%
  \iftoggle{blx@citation}
    {}
    {\toggletrue{blx@bibliography}}%
  \blx@blxinit
  \blx@resetdata
  \csuse{blx@hook@bbxinit}%
  \bibsetup\bibfont
  \blx@setsfcodes
  \csuse{blx@bibsetup}}

% {&lt;entrykey&gt;}
% output a bib item, this is why \blx@thelabelnumber is here so that
% labelnumber is deferred if defernumbers=true
\def\blx@bibitem#1{%
  \blx@ifdata{#1}
    {\begingroup
     \blx@getdata{#1}%
     \blx@bibcheck
     \iftoggle{blx@skipentry}{}{%
       \blx@setdefaultrefcontext{#1}%
       \global\let\blx@noitem\@empty
       \blx@setoptions@type\abx@field@entrytype
       \blx@setoptions@entry
       \blx@thelabelnumber
       \addtocounter{instcount}\@ne
       \iftoggle{blx@labelnumber}
         {\blx@bbl@locallabelnumberwidth}
         {}%
       \iftoggle{blx@labelalpha}
         {\blx@bbl@locallabelalphawidth}
         {}%
       \nottoggle{blx@skipbiblist}
         {\blx@bbl@locallabelfields}
         {}%
       \csuse{blx@item@\blx@theenv}\relax
       \blx@initsep
       \blx@namesep
       \csuse{blx@hook@bibitem}%
       \blx@execute
       \blx@initunit
       \blx@anchor
       \blx@beglangbib
       \bibsentence
       \blx@pagetracker
       \blx@driver\abx@field@entrytype
       \blx@postpunct
       \blx@endlangbib}%
     \endgroup}
    {}}

\let\blx@bibcheck\relax

\def\blx@edef@refcontext#1{%
  \edef\blx@refcontext@context{#1}%
  \expandafter\edef\expandafter\blx@refcontext@context\expandafter{%
    \expandafter\detokenize\expandafter{\blx@refcontext@context}}}

\def\blx@xdef@refcontext#1{%
  \edef\blx@refcontext@context{#1}%
  \expandafter\xdef\expandafter\blx@refcontext@context\expandafter{%
    \expandafter\detokenize\expandafter{\blx@refcontext@context}}}


% This sets and saves to the .aux the default refcontext for an entry. The
% default refcontext for an entry is the refcontext of the last
% bibliography in the refsection in which it is actually printed. This
% allows citations to default to selecting data from the correct
% bibliography list in standard cases where entries are not listed in
% multiple bibliographies
\def\blx@setdefaultrefcontext#1{%
  \ifinlistcs{#1}{blx@defaultrefcontexts@\the\c@refsection}
    {}
    {\listcsgadd{blx@defaultrefcontexts@\the\c@refsection}{#1}}%
  \global\cslet{blx@assignedrefcontextbib@\the\c@refsection @#1}%
    \blx@refcontext@context}
% &lt;refsection&gt;&lt;key&gt;&lt;refcontext&gt;
\def\abx@aux@defaultrefcontext#1#2#3{%
  \csxdef{blx@assignedrefcontextbib@aux@#1@#2}{\detokenize{#3}}}
% \abx@aux@defaultlabelprefix is a dummy only used by BibTeX to implement a
% simple labelprefix not based on full refcontexts, which BibTeX does not
% support.
\let\abx@aux@defaultlabelprefix\@gobblethree

\blx@AtEndDocument{%
  % always add default refcontext declarations to .aux after biber run
  \iftoggle{blx@bbldone}
    {\def\do#1{%
       \begingroup
       \def\do##1{%
         \blx@auxwrite\@mainaux{}{\string\abx@aux@defaultrefcontext{#1}{##1}{%
           \csuse{blx@assignedrefcontextbib@#1@##1}}}%
         \ifcsequal{blx@assignedrefcontextbib@#1@##1}
                   {blx@assignedrefcontextbib@aux@#1@##1}
           {}
           {\blx@rerun@latex}}%
       \dolistcsloop{blx@defaultrefcontexts@#1}%
       \endgroup}
     \dolistloop\blx@allrefsections}
    {}}

\def\blx@initsep{%
  \blx@imc@iffieldundef{sortinithash}
    {}
    {\ifnum\c@instcount&gt;\@ne
       \blx@imc@iffieldequals{sortinithash}\blx@previnithash
         {}
         {\addvspace{\bibinitsep}}%
     \fi
     \global\let\blx@previnithash\abx@field@sortinithash}}

\def\blx@namesep{%
  \ifnum\c@instcount&gt;\@ne
    \blx@imc@iffieldequals{fullhash}\blx@prevhash
      {}
      {\addvspace{\bibnamesep}}%
  \fi
  \global\let\blx@prevhash\abx@field@fullhash}

\newrobustcmd*{\AtBeginBibliography}{\gappto\blx@hook@bibinit}
\newrobustcmd*{\AtEveryBibitem}{\gappto\blx@hook@bibitem}
\@onlypreamble\AtBeginBibliography
\@onlypreamble\AtEveryBibitem

\def\blx@imc@UseBibitemHook{\csuse{blx@hook@bibitem}}

\blx@regimcs{\UseBibitemHook}

\newrobustcmd*{\AtNextBibliography}{%
  \ifundef\blx@hook@bibinit@next
    {\gdef\blx@hook@bibinit@next{\global\undef\blx@hook@bibinit@next}}
    {}%
  \gappto\blx@hook@bibinit@next}

% page tracker
\def\blx@pagetracker@context{%
  \blx@leavevmode
  \ifbool{@filesw}
    {\ifbool{pagetracker}
       {\protected@write\@mainaux{}{%
          \iftoggle{blx@footnote}
            {\string\abx@aux@fnpage}
            {\string\abx@aux@page}%
          {\the\c@instcount}{\noexpand\the\c@page}}}
       {}}
    {}}

% {&lt;instcount&gt;}{&lt;page&gt;}
\protected\def\blx@aux@page#1#2{%
  \csgdef{blx@page@#1}{#2}%
  \blx@addpagesum{#1}{#2}}
\protected\def\blx@aux@spread#1#2{%
  \ifodd#2\relax
    \csxdef{blx@page@#1}{\number\numexpr#2-1}%
  \else
    \csgdef{blx@page@#1}{#2}%
  \fi
  \blx@addpagesum{#1}{#2}}

\protected\def\blx@aux@fnpage#1#2{%
  \csgdef{blx@fnpage@#1}{#2}%
  \blx@addpagesum{#1}{#2}}
\protected\def\blx@aux@fnspread#1#2{%
  \ifodd#2\relax
    \csxdef{blx@fnpage@#1}{\number\numexpr#2-1}%
  \else
    \csgdef{blx@fnpage@#1}{#2}%
  \fi
  \blx@addpagesum{#1}{#2}}

\blx@AtEndDocument{%
  \def\abx@aux@page#1#2{\blx@addpagesum{#1}{#2}}%
  \def\abx@aux@fnpage#1#2{\blx@addpagesum{#1}{#2}}}

% hyperref interface
\appto\blx@mkhyperref{%
  \let\blx@anchors\@empty
  \ifundef\hyper@natanchorstart
    {\protected\def\blx@anchor{%
       \xifinlist{\the\c@refsection @\abx@field@entrykey}{\blx@anchors}
         {}
         {\listxadd\blx@anchors{\the\c@refsection @\abx@field@entrykey}%
          \hypertarget{cite.\the\c@refsection @\abx@field@entrykey}{}}}}
    {\protected\def\blx@anchor{%
       \xifinlist{\the\c@refsection @\abx@field@entrykey}{\blx@anchors}
         {}
         {\listxadd\blx@anchors{\the\c@refsection @\abx@field@entrykey}%
          \hyper@natanchorstart{\the\c@refsection @\abx@field@entrykey}%
          \hyper@natanchorend}}}}

\appto\blx@mknohyperref{\let\blx@anchor\relax}

\blx@kv@defkey{blx@biblist2}{driver}{\blx@key@driver{#1}}
\blx@kv@defkey{blx@biblist1}{driver}{}

\def\blx@key@driver#1{%
  \def\blx@thebiblistdriver{#1}}

% Custom bibliography list
% [&lt;options&gt;]{biblistname}
\newrobustcmd*{\printbiblist}[2][]{%
  \begingroup
  \delimcontext{biblist}%
  \edef\on@line{\on@line}%
  \toggletrue{blx@tempa}%
  \toggletrue{blx@tempb}%
  \def\blx@theheading{biblist}% default to biblist heading
  \def\blx@theenv{#2}% default to list name
  \def\blx@thebiblist{#2}%
  \def\blx@thebiblistdriver{#2}%
  \def\blx@thebiblistfilter{#2}%
  \let\blx@theprenote\@empty
  \let\blx@thepostnote\@empty
  \let\blx@thetitle\@empty
  \let\blx@thefilter\@empty
  \undef\blx@thelabel
  % defaults
  \let\blx@tempa\@empty% before there is a .bbl, this must not be undef
  % default sorting template and template name for list is same name as list
  % name, then current context if not found
  \edef\blx@tempc{%
    \ifcsdef{blx@sortingtemplate@#2}
      {#2}
      {\blx@refcontext@sortingtemplatename}}%
    % locally define this since we want to fetch data from the datalist
    % name after the list we are printing rather than the data in
    % refcontext list.
    % Note that the name must be unique so we prepend any filter name
    % because the combination of options might not generate a unique name
    % since sortschemename has a fallback to the refcontext scheme if there
    % is no sortscheme named after the list
    \blx@kv@setkeys{blx@biblist1}{#1}% Set section and biblistfilter only, if present ...
    \blx@edef@refcontext{\blx@thebiblistfilter :\blx@tempc/%
      \blx@refcontext@sortingnamekeytemplatename/%
      \blx@refcontext@labelprefix/%
      \blx@refcontext@uniquenametemplatename/%
      \blx@refcontext@labelalphanametemplatename/%
      \blx@refcontext@namehashtemplatename}%
  \xifinlist\blx@tempc\blx@sortingtemplatenames
    {}
    {\listxadd\blx@sortingtemplatenames\blx@tempc}%
  \let\blx@printbibchecks\relax
  \edef\blx@tempe{\the\c@refsection}% default refsection is current
  \blx@safe@actives
  \blx@printbibchecks
  % Add the sortingtemplate to the list of sortingtemplates for this biblist
  % so we can compare on next run
  \xifinlist\blx@tempc\blx@biblists
    {}
    {\listxadd\blx@biblists\blx@tempc}%
  \blx@auxwrite\@mainaux{}{\string\abx@aux@biblist{\blx@tempc}}%
  \blx@rest@actives
  \ifcsvoid{blx@dlist@list@\blx@tempe @\blx@refcontext@context}
    {}
    {\letcs\blx@tempa{blx@dlist@list@\blx@tempe @\blx@refcontext@context}}%
  \blx@safe@actives
  \blx@kv@setkeys{blx@biblist2}{#1}% ... now we have correct \blx@tempa, set rest of options
  \ifundef\blx@bibcheck
    {\ifcsdef{blx@bibcheck@#2}
      {\letcs\blx@bibcheck{blx@bibcheck@#2}}
      {}}
    {}%
  \blx@rest@actives
  % Add datalist to list of seen datalists to prevent duplicates
  \xifinlist{\blx@refcontext@context @\blx@tempe @list}\blx@dlistnames
    {}
    {\listxadd\blx@dlistnames{\blx@refcontext@context @\blx@tempe @list}%
     \xappto\blx@dlists{%
       \blx@xml@dlist{\blx@refcontext@context}{list}{\blx@tempe}{\blx@xml@dlist@refcontext{\blx@tempc}{\blx@refcontext@sortingnamekeytemplatename}{\blx@refcontext@labelprefix@real}{\blx@refcontext@uniquenametemplatename}{\blx@refcontext@labelalphanametemplatename}{\blx@refcontext@namehashtemplatename}}{\csuse{blx@biblistfilters@\blx@thebiblistfilter}}}}%
  \ifdefvoid\blx@tempa
    {\blx@warn@biblistempty{#2}\endgroup}
    {\blx@biblist\blx@tempa}}

\def\blx@printbibchecks{%
  \togglefalse{blx@tempa}%
  \iftoggle{blx@defernumbers}
    {\global\let\blx@printbibchecks\relax}
    {\iftoggle{blx@labelnumber}
       {\ifundef\blx@printbibchecks@suppresswarn
          {\blx@warning@noline{%
             Split bibliography detected.\MessageBreak
             Many simple split bibliography setups with\MessageBreak
             non-overlapping bibliographies benefit from%
             \MessageBreak
             setting 'defernumbers=true'.\MessageBreak
             See the documentation for details.\MessageBreak
             This warning can be suppressed with\MessageBreak
             '\string\BiblatexSplitbibDefernumbersWarningOff'}}
          {}}
       {\global\let\blx@printbibchecks\relax}}}

% {&lt;entrykey&gt;,...}
\def\blx@biblist{%
  \if@twocolumn
    \@restonecoltrue\onecolumn
  \else
    \@restonecolfalse
  \fi
  \blx@bibheading\blx@theheading\blx@thetitle
  \blx@biblabel\blx@thelabel
  \blx@bibnote\blx@theprenote
  \begingroup
  \blx@bibinit
  \let\@noitemerr\@empty
  \def\blx@noitem{\blx@warn@biblistempty{\blx@thebiblist}}%
  \blx@locallabelwidth@init
  \csuse{blx@env@\blx@theenv}%
  \csuse{blx@hook@biblistinit@\blx@thebiblist}%
  \let\blx@do\blx@biblistitem
  \let\blx@done\blx@endbiblist
  \blx@listloop}

\def\blx@endbiblist{%
  \csuse{blx@endenv@\blx@theenv}%
  \blx@noitem
  \blx@locallabelwidth@finish
  \endgroup
  \blx@bibnote\blx@thepostnote
  \expandafter\endgroup\if@endpe\@doendpe\fi
  \if@restonecol\twocolumn\fi
  \par}

% {&lt;biblistname&gt;}
\newrobustcmd*{\AtBeginBiblist}[1]{\csgappto{blx@hook@biblistinit@#1}}
\newrobustcmd*{\AtEveryBiblistitem}[1]{\csgappto{blx@hook@biblistitem@#1}}
\@onlypreamble\AtBeginBiblist
\@onlypreamble\AtEveryBiblistitem

% {&lt;entrykey&gt;}
\def\blx@biblistitem#1{%
  \blx@ifdata{#1}
    {\begingroup
     \blx@getdata{#1}%
     \blx@bibcheck
     \iftoggle{blx@skipentry}{}{%
       \blx@setdefaultrefcontext{#1}%
       \global\let\blx@noitem\@empty
       \blx@setoptions@type\abx@field@entrytype
       \blx@setoptions@entry
       \addtocounter{instcount}\@ne
       \iftoggle{blx@labelnumber}
         {\blx@bbl@locallabelnumberwidth}
         {}%
       \iftoggle{blx@labelalpha}
         {\blx@bbl@locallabelalphawidth}
         {}%
       \nottoggle{blx@skipbiblist}
         {\blx@bbl@locallabelfields}
         {}%
       \csuse{blx@item@\blx@theenv}\relax
       \csuse{blx@hook@biblistitem@\blx@thebiblist}%
       \blx@execute
       \blx@initunit
       \blx@beglangbib
       \bibsentence
       \blx@pagetracker
       \blx@driver{\blx@thebiblistdriver}%
       \blx@postpunct
       \blx@endlangbib}%
     \endgroup}
    {}}

% Just a default in case .bbx doesn't define it. standard.bbx defines
% it to print a complete entry, like the bibliography.
\DeclareBibliographyDriver{shorthand}{%
  \iffieldundef{shorttitle}
    {\printfield{title}}
    {\printfield{shorttitle}}}

% Reference contexts
\newcommand*{\DeclareRefcontext}[2]{%
  \csgdef{blx@refcontext@name@#1}{#2}}
\@onlypreamble\DeclareRefcontext

\def\newrefcontext{%
  \endrefcontext
  \refcontext}

% Backwards compat for older \refcontext[] format
\def\refcontext{%
  \@ifnextchar[%]
    {\refcontext@i}
    {\refcontext@i[]}}

\def\refcontext@i[#1]{%
  \@ifnextchar\bgroup
    {\refcontext@ii[{#1}]}
    {\refcontext@ii[{#1}]{}}}

\newcommand*{\refcontext@ii}[2][]{%
  \iftoggle{blx@refcontext}
    {\blx@err@nestenv{refcontext}%
     \endrefcontext}
    {\toggletrue{blx@refcontext}%
     % Set refcontext from named refcontext, if given
     \ifblank{#2}
       {}
       {\begingroup
        \edef\blx@tempa{\endgroup%
          \noexpand\blx@kv@setkeys{blx@refcontext}{\csuse{blx@refcontext@name@#2}}}%
        \blx@tempa}%
     % Override with explicit refcontext keyvals, if given
     \def\blx@gdef@or@def{\gdef}%
     \def\blx@xdef@or@edef{\xdef}%
     \blx@kv@setkeys{blx@refcontext}{#1}%
     % Add the sortingtemplate to the list of sortingtemplates so we can track
     % special cases like sorting=none which need cite order change detection
     \xifinlist\blx@refcontext@sortingtemplatename\blx@sortingtemplatenames
       {}
       {\listxadd\blx@sortingtemplatenames\blx@refcontext@sortingtemplatename}%
     \blx@xdef@refcontext{%
       \blx@refcontext@sortingtemplatename/%
       \blx@refcontext@sortingnamekeytemplatename/%
       \blx@refcontext@labelprefix/%
       \blx@refcontext@uniquenametemplatename/%
       \blx@refcontext@labelalphanametemplatename/%
       \blx@refcontext@namehashtemplatename}%
     % Add the refcontext to the list of refcontexts so we can compare on next run
     \xifinlist\blx@refcontext@context\blx@refcontexts
       {}
       {\listxadd\blx@refcontexts\blx@refcontext@context}%
     \blx@auxwrite\@mainaux{}{\string\abx@aux@refcontext{\blx@refcontext@context}}%
     \ifcsundef{blx@sortingtemplate@\blx@refcontext@sortingtemplatename}
       {\blx@err@invopt{sorting=\blx@refcontext@sortingtemplatename}{}}
       {}%
     \ifcsundef{blx@sortingnamekeytemplate@\blx@refcontext@sortingnamekeytemplatename}
       {\blx@err@invopt{sortingnamekeytemplate=\blx@refcontext@sortingnamekeytemplatename}{}}
       {}%
     \ifcsundef{blx@uniquenametemplate@\blx@refcontext@uniquenametemplatename}
       {\blx@err@invopt{uniquenametemplate=\blx@refcontext@uniquenametemplatename}{}}
       {}%
     \ifcsundef{blx@labelalphanametemplate@\blx@refcontext@labelalphanametemplatename}
       {\blx@err@invopt{labelalphanametemplate=\blx@refcontext@labelalphanametemplatename}{}}
       {}%
     \ifcsundef{blx@namehashtemplate@\blx@refcontext@namehashtemplatename}
       {\blx@err@invopt{namehashtemplate=\blx@refcontext@namehashtemplatename}{}}
       {}}}

% Reset to global sorting etc. when we leave a ref context (since they can't be nested)
\protected\def\endrefcontext{%
  \togglefalse{blx@refcontext}%
  \global\let\blx@refcontext@labelprefix\@empty
  \global\let\blx@refcontext@labelprefix@real\@empty
  \xdef\blx@refcontext@sortingtemplatename{\blx@sorting}%
  \gdef\blx@refcontext@sortingnamekeytemplatename{global}%
  \gdef\blx@refcontext@uniquenametemplatename{global}%
  \gdef\blx@refcontext@labelalphanametemplatename{global}%
  \gdef\blx@refcontext@namehashtemplatename{global}%
  \blx@xdef@refcontext{%
    \blx@refcontext@sortingtemplatename/%
    \blx@refcontext@sortingnamekeytemplatename/%
    /%
    \blx@refcontext@uniquenametemplatename/%
    \blx@refcontext@labelalphanametemplatename/%
    \blx@refcontext@namehashtemplatename}}

% local version of \newrefcontext
\def\localrefcontext{%
  \@ifnextchar[%]
    {\localrefcontext@i}
    {\localrefcontext@i[]}}

\def\localrefcontext@i[#1]{%
  \@ifnextchar\bgroup
    {\localrefcontext@ii[{#1}]}
    {\localrefcontext@ii[{#1}]{}}}

\newcommand*{\localrefcontext@ii}[2][]{%
  \ifblank{#2}
    {}
    {\begingroup
     \edef\blx@tempa{\endgroup%
       \noexpand\blx@kv@setkeys{blx@refcontext}{\csuse{blx@refcontext@name@#2}}}%
     \blx@tempa}%
  % Override with explicit refcontext keyvals, if given
  \def\blx@gdef@or@def{\def}%
  \def\blx@xdef@or@edef{\edef}%
  \blx@kv@setkeys{blx@refcontext}{#1}%
  % Add the sortingtemplate to the list of sortingtemplates so we can track
  % special cases like sorting=none which need cite order change detection
  \xifinlist\blx@refcontext@sortingtemplatename\blx@sortingtemplatenames
    {}
    {\listxadd\blx@sortingtemplatenames\blx@refcontext@sortingtemplatename}%
  \blx@edef@refcontext{%
    \blx@refcontext@sortingtemplatename/%
    \blx@refcontext@sortingnamekeytemplatename/%
    \blx@refcontext@labelprefix/%
    \blx@refcontext@uniquenametemplatename/%
    \blx@refcontext@labelalphanametemplatename/%
    \blx@refcontext@namehashtemplatename}%
  % Add the refcontext to the list of refcontexts so we can compare on next run
  \xifinlist\blx@refcontext@context\blx@refcontexts
    {}
    {\listxadd\blx@refcontexts\blx@refcontext@context}%
  \blx@auxwrite\@mainaux{}{\string\abx@aux@refcontext{\blx@refcontext@context}}%
  \ifcsundef{blx@sortingtemplate@\blx@refcontext@sortingtemplatename}
    {\blx@err@invopt{sorting=\blx@refcontext@sortingtemplatename}{}}
    {}%
  \ifcsundef{blx@sortingnamekeytemplate@\blx@refcontext@sortingnamekeytemplatename}
    {\blx@err@invopt{sortingnamekeytemplate=\blx@refcontext@sortingnamekeytemplatename}{}}
    {}%
  \ifcsundef{blx@uniquenametemplate@\blx@refcontext@uniquenametemplatename}
    {\blx@err@invopt{uniquenametemplate=\blx@refcontext@uniquenametemplatename}{}}
    {}%
  \ifcsundef{blx@labelalphanametemplate@\blx@refcontext@labelalphanametemplatename}
    {\blx@err@invopt{labelalphanametemplate=\blx@refcontext@labelalphanametemplatename}{}}
    {}%
  \ifcsundef{blx@namehashtemplate@\blx@refcontext@namehashtemplatename}
    {\blx@err@invopt{namehashtemplate=\blx@refcontext@namehashtemplatename}{}}
    {}}

\def\blx@gdef@or@def{\gdef}
\def\blx@xdef@or@edef{\xdef}

% Meta option to set all name template options
\blx@kv@defkey{blx@refcontext}{nametemplates}{%
  \blx@gdef@or@def\blx@refcontext@sortingnamekeytemplatename{#1}%
  \blx@gdef@or@def\blx@refcontext@uniquenametemplatename{#1}%
  \blx@gdef@or@def\blx@refcontext@labelalphanametemplatename{#1}%
  \blx@gdef@or@def\blx@refcontext@namehashtemplatename{#1}}

\blx@kv@defkey{blx@refcontext}{sorting}{\blx@gdef@or@def\blx@refcontext@sortingtemplatename{#1}}
\blx@kv@defkey{blx@refcontext}{sortingnamekeytemplatename}{\blx@gdef@or@def\blx@refcontext@sortingnamekeytemplatename{#1}}
\blx@kv@defkey{blx@refcontext}{uniquenametemplatename}{\blx@gdef@or@def\blx@refcontext@uniquenametemplatename{#1}}
\blx@kv@defkey{blx@refcontext}{labelalphanametemplatename}{\blx@gdef@or@def\blx@refcontext@labelalphanametemplatename{#1}}
\blx@kv@defkey{blx@refcontext}{namehashtemplatename}{\blx@gdef@or@def\blx@refcontext@namehashtemplatename{#1}}

% labelprefix cannot be used as is because it is used to construct the internal
% refcontext name which is referenced/expanded a lot all over the place. So,
% we hash the given input and use the safe hash as internal name.
% But that is not enough since the MD5 hash function expands the argument all
% the way and so unexpandable content like \dag breaks.
% Unexpandable content should be protected with \detokenize.
\blx@kv@defkey{blx@refcontext}{labelprefix}{%
  \blx@xdef@or@edef\blx@refcontext@labelprefix{\blx@mdfivesum{#1}}%
  \blx@gdef@or@def\blx@refcontext@labelprefix@real{#1}%
  \iftoggle{blx@defernumbers}
    {}%
    {\iftoggle{blx@labelnumber}
       {\blx@warning{%
          Option 'labelprefix' requires global\MessageBreak
          'defernumbers=true'}}
       {}}}


% [refcontext keys]{&lt;keyword1&gt;,&lt;keyword2&gt;,...}
\newcommand*{\assignrefcontextkeyws}{%
  \@ifstar
    {\blx@assignrefcontextkeyws[*]}
    {\blx@assignrefcontextkeyws[]}}

\def\blx@assignrefcontextkeyws[#1][#2]#3{%
  \edef\blx@tempa{\blx@sorting}%
  \def\blx@tempb{global}%
  \let\blx@tempc\@empty%
  \def\blx@tempd{global}%
  \def\blx@tempe{global}%
  \def\blx@tempg{global}%
  \blx@kv@setkeys{blx@assignrefcontextmeta}{#2}%
  \blx@kv@setkeys{blx@assignrefcontext}{#2}%
  \def\do##1{%
    \listxadd\blx@assignedrefcontextkeywlist{##1}%
    \csxdef{blx@assignedrefcontextkeyws#1@\the\c@refsection @##1}%
      {\blx@tempa/\blx@tempb/\blx@tempc/\blx@tempd/\blx@tempe/\blx@tempg}}%
  \docsvlist{#3}}

% [refcontext keys]{&lt;category1&gt;,&lt;category2&gt;,...}
\newcommand*{\assignrefcontextcats}{%
  \@ifstar
    {\blx@assignrefcontextcats[*]}
    {\blx@assignrefcontextcats[]}}

\def\blx@assignrefcontextcats[#1][#2]#3{%
  \edef\blx@tempa{\blx@sorting}%
  \def\blx@tempb{global}%
  \let\blx@tempc\@empty%
  \def\blx@tempd{global}%
  \def\blx@tempe{global}%
  \def\blx@tempg{global}%
  \blx@kv@setkeys{blx@assignrefcontextmeta}{#2}%
  \blx@kv@setkeys{blx@assignrefcontext}{#2}%
  \def\do##1{%
    \listxadd\blx@assignedrefcontextcatlist{##1}%
    \csxdef{blx@assignedrefcontextcats#1@\the\c@refsection @##1}%
      {\blx@tempa/\blx@tempb/\blx@tempc/\blx@tempd/\blx@tempe/\blx@tempg}}%
  \docsvlist{#3}}

% [refcontext keys]{&lt;entrykey1&gt;,&lt;entrykey2&gt;,...}
\newcommand*{\assignrefcontextentries}{%
  \@ifstar
    {\blx@assignrefcontextentries[*]}
    {\blx@assignrefcontextentries[]}}

\def\blx@assignrefcontextentries[#1][#2]#3{%
  \edef\blx@tempa{\blx@sorting}%
  \def\blx@tempb{global}%
  \let\blx@tempc\@empty%
  \def\blx@tempd{global}%
  \def\blx@tempe{global}%
  \def\blx@tempg{global}%
  \blx@kv@setkeys{blx@assignrefcontextmeta}{#2}%
  \blx@kv@setkeys{blx@assignrefcontext}{#2}%
  \def\do##1{%
    \csxdef{blx@assignedrefcontextkeys#1@\the\c@refsection @##1}%
      {\blx@tempa/\blx@tempb/\blx@tempc/\blx@tempd/\blx@tempe/\blx@tempg}}%
  \docsvlist{#3}}

% This makes sure that named refcontexts set options first
% Note that the docs say that "name=default" selects the global default
% refcontext and this is because this won't set anything and the defaults
% in the above macros will take effect.
\blx@kv@defkey{blx@assignrefcontextmeta}{name}{%
  \begingroup
  \edef\blx@tempf{\endgroup%
  \noexpand\blx@kv@setkeys{blx@assignrefcontext}{\csuse{blx@refcontext@name@#1}}}%
  \blx@tempf}
\blx@kv@defkey{blx@assignrefcontextmeta}{nametemplates}{}
\blx@kv@defkey{blx@assignrefcontextmeta}{sorting}{}
\blx@kv@defkey{blx@assignrefcontextmeta}{sortingnamekeytemplatename}{}
\blx@kv@defkey{blx@assignrefcontextmeta}{labelprefix}{}
\blx@kv@defkey{blx@assignrefcontextmeta}{uniquenametemplatename}{}
\blx@kv@defkey{blx@assignrefcontextmeta}{labelalphanametemplatename}{}
\blx@kv@defkey{blx@assignrefcontextmeta}{namehashtemplatename}{}

% Meta option to set all name template options
\blx@kv@defkey{blx@assignrefcontext}{name}{}
\blx@kv@defkey{blx@assignrefcontext}{nametemplates}{%
  \def\blx@tempb{#1}%
  \def\blx@tempd{#1}%
  \def\blx@tempe{#1}%
  \def\blx@tempg{#1}}
\blx@kv@defkey{blx@assignrefcontext}{sorting}{\def\blx@tempa{#1}}
\blx@kv@defkey{blx@assignrefcontext}{sortingnamekeytemplatename}{\def\blx@tempb{#1}}
\blx@kv@defkey{blx@assignrefcontext}{labelprefix}{\edef\blx@tempc{\blx@mdfivesum{#1}}}
\blx@kv@defkey{blx@assignrefcontext}{uniquenametemplatename}{\def\blx@tempd{#1}}
\blx@kv@defkey{blx@assignrefcontext}{labelalphanametemplatename}{\def\blx@tempe{#1}}
\blx@kv@defkey{blx@assignrefcontext}{namehashtemplatename}{\def\blx@tempg{#1}}

% Manually force a refcontext datalist in the .bcf
\newcommand*{\GenRefcontextData}[1]{%
  \begingroup
  \edef\blx@tempb{\the\c@refsection}%
  \def\blx@tempc{global}%
  \def\blx@tempd{global}%
  \def\blx@tempe{global}%
  \let\blx@tempf\blx@sorting%
  \let\blx@tempg\@empty%
  \def\blx@temph{global}%
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@refcontextmanual}{#1}}%
  \def\blx@tempa{\blx@tempf/\blx@tempc/\blx@tempg/\blx@tempd/\blx@tempe/\blx@temph}%
  \xifinlist{\blx@tempa @\blx@tempb @entry}\blx@dlistnames
    {}
    {\listxadd\blx@dlistnames{\blx@tempa @\blx@tempb @entry}%
     \xappto\blx@dlists{%
       \blx@xml@dlist{\blx@tempa}{entry}{\blx@tempb}{\blx@xml@dlist@refcontext{\blx@tempf}{\blx@tempc}{\blx@tempg}{\blx@tempd}{\blx@tempe}{\blx@temph}}{}}}%
   \endgroup}

% Meta option to set all name template options
\blx@kv@defkey{blx@refcontextmanual}{nametemplates}{%
  \def\blx@tempc@sortingnamekeytemplatename{#1}%
  \def\blx@tempd@uniquenametemplatename{#1}%
  \def\blx@tempe@labelalphanametemplatename{#1}}
\blx@kv@defkey{blx@refcontextmanual}{sorting}{\def\blx@tempf{#1}}
\blx@kv@defkey{blx@refcontextmanual}{sortingnamekeytemplatename}{\def\blx@tempc{#1}}
\blx@kv@defkey{blx@refcontextmanual}{uniquenametemplatename}{\def\blx@tempd{#1}}
\blx@kv@defkey{blx@refcontextmanual}{labelalphanametemplatename}{\def\blx@tempe{#1}}
\blx@kv@defkey{blx@refcontextmanual}{namehashtemplatename}{\def\blx@temph{#1}}
\blx@kv@defkey{blx@refcontextmanual}{labelprefix}{%
  \def\blx@tempg{#1}%
  \iftoggle{blx@defernumbers}
    {}%
    {\iftoggle{blx@labelnumber}
       {\blx@warning{%
          Option 'labelprefix' requires global\MessageBreak
          'defernumbers=true'}}
       {}}}

% Reference sections
\newrobustcmd*{\AtBeginRefsection}{\gappto\blx@hook@refsectioninit}
\@onlypreamble\AtBeginRefsection

\newrobustcmd*{\AtNextRefsection}{%
  \ifundef\blx@hook@refsection@next
    {\gdef\blx@hook@refsection@next{\global\undef\blx@hook@refsection@next}}
    {}%
  \gappto\blx@hook@refsection@next}

\newrobustcmd*{\AtFollowingRefsections}{\gappto\blx@hook@refsection@following}

\newrobustcmd*{\newrefsection}{%
  \endrefcontext
  \ifnum\c@refsection&gt;\z@
    \endrefsection
  \fi
  \refsection}
\let\blx@newrefsection\newrefsection

\newrobustcmd*{\refsection}{%
  \begingroup
  \edef\on@line{\on@line}%
  \ifnum\c@refsection&gt;\z@
    \blx@err@nestenv{refsection}%
    \blx@endrefsection
  \fi
  \ifnum\c@refsegment&gt;\z@
    \blx@err@nestenv{refsection}%
    \blx@endrefsegment
  \fi
  \@ifnextchar[%]
    {\blx@refsection}
    {\blx@refsection[]}}

\def\blx@refsection{%
  \begingroup
  \blx@hook@fileverb
  \blx@refsection@i}

\def\blx@refsection@i[#1]{%
  \endgroup
  \stepcounter{blx@maxsection}%
  \setcounter{refsection}{\value{blx@maxsection}}%
  \csuse{blx@hook@refsectioninit}%
  \csuse{blx@hook@refsection@following}%
  \csuse{blx@hook@refsection@next}%
  \xifinlist{\the\c@refsection}\blx@allrefsections
    {}
    {\listxadd\blx@allrefsections{\the\c@refsection}}%
  \ifcsdef{blx@defaultrefcontexts@\the\c@refsection}
    {}
    {\global\cslet{blx@defaultrefcontexts@\the\c@refsection}\@empty}%
  \blx@providecount{blx@maxsegment@\the\c@refsection}%
  \blx@providecount{blx@sectionciteorder@\the\c@refsection}%
  \blx@inf@refsec
  \blx@secinit
  \if@filesw
    \blx@auxwrite\@mainaux{}{%
      \string\abx@aux@refsection{\the\c@refsection}{\the\c@page}}%
    \ifblank{#1}
      {}
      {\let\blx@bibfiles\@empty
       % globals should be first as it might contain macros needed for others
       \forlistloop{\listadd\blx@bibfiles}\blx@bibfiles@global}%
       \blx@xsanitizeafter{\forcsvlist\blx@refsection@addfile}{#1}%
    \blx@refsection@ii
  \fi
  \blx@info{Setting label 'refsection:\the\c@refsection'}%
  \label{refsection:\the\c@refsection}%
  \endgroup}

\def\blx@refsection@addfile#1{%
  \ifcsdef{blx@res@labl@#1}
    {\blx@refsection@addfile@i{\csuse{blx@res@labl@#1}}}
    {\blx@refsection@addfile@i{#1}}}

\def\blx@refsection@addfile@i#1{%
  \ifcsdef{blx@res@loca@#1}
    {\listeadd\blx@bibfiles{#1}}
    {\listeadd\blx@bibfiles{\blx@stripbib{#1}\detokenize{.bib}}}}

\def\blx@refsection@ii{%
  \blx@regbibfiles\jobname\blx@bibfiles
  \begingroup
  \let\blx@tempa\@empty
  \blx@bibdata\blx@tempa\blx@bibfiles
  \blx@auxwrite\blx@bcfout
    {\let\do\blx@datasource}
    {\blx@xml@endsection\blx@nl
     \blx@xml@comment{SECTION \the\c@refsection}%
     \blx@xml@bibdata{\the\c@refsection}{\blx@tempa}%
     \blx@xml@section{\the\c@refsection}}%
  \endgroup}

\protected\def\endrefsection{%
  \endrefcontext
  \blx@endrefsection
  \blx@inf@refsec}

\def\blx@endrefsection{%
  \blx@endrefsegment
  \blx@providecount{blx@sectionciteorder@\the\c@refsection}%
  % make sure we always output aliases to the .bcf otherwise after their
  % first resolution by biber, they will be invisible to subsequent biber
  % runs since biblatex will resolve the \keyalias{} macro to the main
  % entry key, biber won't put \keyalias{}in the .bbl on subsequent runs
  % and biblatex will report a missing citekey
  \ifcsempty{blx@keyaliases@\the\c@refsection}
    {}
    {\def\do##1{%
       \blx@xmlsanitizeafter{\def\blx@tempa}{##1}%
       % Make sure this counter exists. Sometimes it might not when using, e.g:
       % refsection=chapter and \includeonly to put in the chapters or when
       % inserting citations into table of contents
       \global\advance\csname blx@sectionciteorder@\the\c@refsection\endcsname\@ne
       \blx@auxwrite\blx@bcfout{}{%
         \blx@xml@citekey{\blx@tempa}{}
         {\expandafter\the\csname blx@sectionciteorder@\the\c@refsection\endcsname}{1}}}%
     \dolistcsloop{blx@keyaliases@\the\c@refsection}}%
  % output key counts (for \citecount sorting) if citecounter option is not false
  \ifcsundef{blx@cites@\the\c@refsection}
    {}
    {\ifundef\blx@citecounter
       {}
       {\def\do##1{%
          \ifcsundef{blx@currcount@\the\c@refsection @##1}
            {\csdef{blx@currcount@\the\c@refsection @##1}{0}}
            {}%
          \blx@auxwrite\blx@bcfout{}
            {\blx@xml@citekeycount{##1}{\csuse{blx@currcount@\the\c@refsection @##1}}}}%
        \dolistcsloop{blx@cites@\the\c@refsection}}}%
  \ifnum\c@refsection&gt;\z@
    \blx@auxwrite\blx@bcfout{}{%
      \blx@xml@endsection\blx@nl
      \blx@xml@comment{SECTION 0 (cont.)}%
      \blx@xml@section{0}}%
  \fi
  \global\c@refsection\z@}

\blx@AtEndDocument{%
  \endrefcontext
  % close non-0 refsection if active
  \ifnum\c@refsection&gt;\z@
    \blx@endrefsection
  \fi
  % close refsection 0
  \blx@endrefsection
  \def\abx@aux@refsection#1#2{\blx@addchecksum{#1}{#2}}}

\protected\def\abx@aux@refsection#1#2{%
  \listgadd\blx@alllastrefsections{#1}%
  \ifnum#1&gt;\c@blx@maxsection
    \setcounter{blx@maxsection}{#1}%
  \fi
  \blx@addchecksum{#1}{#2}}

% Reference segments
\newrobustcmd*{\newrefsegment}{%
  \ifnum\c@refsegment&gt;\z@
    \blx@endrefsegment
  \fi
  \refsegment}
\let\blx@newrefsegment\newrefsegment

\newrobustcmd*{\refsegment}{%
  \ifnum\c@refsegment&gt;\z@
    \blx@err@nestenv{refsegment}%
    \blx@endrefsegment
  \fi
  \global\advance\csname blx@maxsegment@\the\c@refsection\endcsname\@ne
  \setcounter{refsegment}{\csuse{blx@maxsegment@\the\c@refsection}}%
  \blx@inf@refseg
  \blx@info{Setting label 'refsegment:\the\c@refsection\the\c@refsegment'}%
  \label{refsegment:\the\c@refsection\the\c@refsegment}%
  \ifcsundef{blx@segm@\the\c@refsection @\the\c@refsegment}
    {\global\cslet{blx@segm@\the\c@refsection @\the\c@refsegment}\@empty}
    {}}

\protected\def\endrefsegment{%
  \blx@endrefsegment
  \blx@inf@refseg}

\def\blx@endrefsegment{%
  \global\c@refsegment\z@}

% Reference section/segment auto-reset
% we are prepending to the commands so that the resets happen before
% the part title is typeset otherwise \cites in there could be "ibid"
% which makes no sense

% option switch
%{&lt;option level counter&gt;}{&lt;patch&gt;}{&lt;pre&gt;}{&lt;post&gt;}
\def\blx@patchsection@switch#1#2#3#4{%
  \AtEndPreamble{%
    #3%
    \ifcase#1
    \or % 1: part
      \blx@refpatch@part{#2}%
    \or % 2: chapter
      \blx@refpatch@chapter{#2}%
    \or % 3: section
      \blx@refpatch@sect{section}{#2}{1}%
    \or % 4: subsection
      \blx@refpatch@sect{subsection}{#2}{2}%
    \or % 5: chapter+ = part, chapter
      \blx@refpatch@part{#2}%
      \blx@refpatch@chapter{#2}%
    \or % 6: section+ = part, chapter, section
      \blx@refpatch@part{#2}%
      \ifundef\chapter
        {}
        {\blx@refpatch@chapter{#2}}%
      \blx@refpatch@sect{section}{#2}{1}%
    \or % 7: subsection+ = part, chapter, section, subsection
      \blx@refpatch@part{#2}%
      \ifundef\chapter
        {}
        {\blx@refpatch@chapter{#2}}%
      \blx@refpatch@sect{section}{#2}{1}%
      \blx@refpatch@sect{subsection}{#2}{2}%
    \fi
    #4%
  }%
}

%% Patching all the different document classes and their sectioning
%% commands is ... messy at best
%% For now we do the big three: (1) Standard classes, (2) KOMA-Script
%% and (3) memoir.
%%
%% Timing of the patch can be tricky.
%% Ideally we want the code to be executed when all counters have
%% been increased so the labels attach to the right thing, but
%% at the same time we want the code to be executed before the heading
%% is typeset so it already applies to the text in the heading.
%% Bonus points for actually executing the code on the correct page.

%% memoir has hooks for section headings that we can use here
%% see 18.25 'Heading Hooks' of the manual (v3.7h, 2018/12/12)
%% they are in a good position, when the counters have been
%% increased but heading text not yet typeset.
%% The manual suggests this hooks have been around since 2005 or so,
%% so we take them for granted.

%% Newer versions of KOMA-Script (&gt;=3.27) (will) have a hook system
%% that we can use for that purpose as well.
%% This is fairly new, so we need to have a fallback for older versions.

%% The standard classes are tricky.
%% We insert something in \@startsection to get the level number
%% and then patch \@sect and \@ssect so the label attaches to the
%% right thing.

%% Test for correct KOMA patch method
% KOMA 3.27 has \AddtoDoHook
\newcommand*{\blx@ifkoma@AddtoDoHook}{%
  \ifcsundef{KOMAClassName}
    {\@secondoftwo}
    {\ifcsundef{AddtoDoHook}
       {\@secondoftwo}
       {\@firstoftwo}}}

% KOMA 3.26 has \startsection@secnumdepth for some testing
\newcommand*{\blx@ifkoma@startsection}{%
  \ifcsundef{KOMAClassName}
    {\@secondoftwo}
    {\ifcsundef{startsection@secnumdepth}
       {\@secondoftwo}
       {\@firstoftwo}}}

\newcommand*{\blx@ifmemoir}{\@ifclassloaded{memoir}}

% Note that \ExecuteDoHook always feeds an argument to the code, here that is
% going to be an empty group, which we explicitly gobble to avoid trouble.
\def\blx@refpatch@koma@AddtoDoHook#1#2{%
  \AddtoDoHook{heading/begingroup/#1}{#2\@gobble}}

% \part
\def\blx@refpatch@part@memoir#1{%
  \apptocmd\mempartinfo{#1}
    {}{\blx@err@patch{\string\mempartinfo}}%
  \apptocmd\mempartstarinfo{#1}
    {}{\blx@err@patch{\string\mempartstarinfo}}}

\def\blx@refpatch@part@std#1{%
  \toggletrue{blx@tempa}%
  \def\do##1{%
    \pretocmd##1{#1}
      {\togglefalse{blx@tempa}\listbreak}
      {}}%
  \docsvlist{%
    \H@old@part,%    hyperref
    \NR@part,%       nameref
    \@part}%         latex/koma-script/memoir
  \iftoggle{blx@tempa}
    {\blx@err@patch{\string\@part}}
    {}%
  \let\do\noexpand}

\def\blx@refpatch@part#1{%
  \ifundef\part
    {\blx@err@nodocdiv{part}}
    {\blx@ifkoma@AddtoDoHook
       {\blx@refpatch@koma@AddtoDoHook{part}{#1}}
       {\blx@ifmemoir
          {\blx@refpatch@part@memoir{#1}}
          {\blx@refpatch@part@std{#1}}}}}

% \chapter
\def\blx@refpatch@chapter@memoir#1{%
  \apptocmd\memchapinfo{#1}
    {}{\blx@err@patch{\string\memchapinfo}}%
  \apptocmd\memchapstarinfo{#1}
    {}{\blx@err@patch{\string\memchapstarinfo}}%
  \apptocmd\memappchapinfo{#1}
    {}{\blx@err@patch{\string\memappchapinfo}}%
  \apptocmd\memappchapstarinfo{#1}
    {}{\blx@err@patch{\string\memappchapstarinfo}}%
}

\def\blx@refpatch@chapter@std#1{%
  \pretocmd\@makechapterhead{#1}
    {}
    {\blx@err@patch{\string\@makechapterhead}}
  \pretocmd\@makeschapterhead{#1}
    {}
    {\blx@err@patch{\string\@makeschapterhead}}}

\def\blx@refpatch@chapter#1{%
  \ifundef\chapter
    {\blx@err@nodocdiv{chapter}}
    {\blx@ifkoma@AddtoDoHook
       {\blx@refpatch@koma@AddtoDoHook{chapter}{#1}}
       {\blx@ifmemoir
          {\blx@refpatch@chapter@memoir{#1}}
          {\blx@refpatch@chapter@std{#1}}}}}

% \section, \subsection
% {&lt;section csname&gt;}{&lt;patch code&gt;}{&lt;section level number&gt;}
\def\blx@refpatch@sect#1#2#3{%
  \ifcsundef{#1}
    {\blx@err@nodocdiv{#1}\@gobbletwo}
    {\blx@ifkoma@AddtoDoHook
       {\blx@refpatch@koma@AddtoDoHook{#1}{#2}}
       {\blx@ifkoma@startsection
          {\blx@refpatch@sect@koma@startsection{#2}{#3}}
          {\blx@ifmemoir
             {\blx@refpatch@sect@memoir{#1}{#2}}
             {\blx@refpatch@sect@std{#2}{#3}}}}}}

% KOMA &gt;= 3.26 defines \startsection@secnumdepth to check the sectioning level,
% so we can now use \At@startsection.
% Starting from 3.27 we use AddtoDoHook, so this is a short-lived
% intermezzo.
\def\blx@refpatch@sect@koma@startsection#1#2{%
  \At@startsection{\ifnumequal{\startsection@secnumdepth}{#2}{#1}{}}}

% The memoir classes have a nice hook we can use
% {&lt;section csname&gt;}{&lt;patch code&gt;}
\edef\blx@refpatch@sect@memoir#1#2{%
  \apptocmd\noexpand\memsecinfo
    {\noexpand\blx@refpatch@sect@memoir@i{\string#1}{#1}{#2}}
    {}{\noexpand\blx@err@patch{\string\memsecinfo}}%
  \apptocmd\noexpand\memsecstarinfo
    {\noexpand\blx@refpatch@sect@memoir@i{\string#1}{#1}{#2}}
    {}{\noexpand\blx@err@patch{\string\memsecstarinfo}}}

% we have to expand the section csname, because
% memoir saves it in a helper macro
\protected\def\blx@refpatch@sect@memoir@i#1#2#3{%
  \begingroup
  \edef\blx@tempa{\endgroup
    \noexpand\ifstrequal{#1}{#2}}%
  \blx@tempa{#3}{}}

% The standard classes have \@startsection, \@sect and \@ssect.
% \@startsection is used by unstarred and starred sections alike
% but it comes in too early if we set labels.
% The counter is only stepped in \@sect, so we need to patch
% that if we want \labels to attach to the right thing.
% But then we also need to patch \@ssect for starred/un-numbered
% sections. Unfortunately, \@ssect doesn't know the level number
% so we patch \@startsection to remember the level number
% in blx@refpatch@current@sectlevel
% and then patch \@sect and \@ssect with the actual code
% testing against blx@refpatch@current@sectlevel.

% {&lt;do initialization&gt;}{&lt;csv list to do&gt;}{&lt;error&gt;}
\def\blx@refpatch@docsvlist#1#2#3{%
  \toggletrue{blx@tempa}%
  #1%
  \docsvlist{#2}%
  \iftoggle{blx@tempa}
    {#3}
    {}%
  \let\do\noexpand}

\newtoggle{blx@refpatch@sect@std@pre@done}

\def\blx@refpatch@sect@std@pre{%
  \iftoggle{blx@refpatch@sect@std@pre@done}
    {}
    {\blx@refpatch@docsvlist
       {\blx@refpatch@sect@std@pre@defdo}
       {\scr@startsection,
        \@startsection}
       {\blx@err@patch{\string\@startsection}}
     \global\toggletrue{blx@refpatch@sect@std@pre@done}}}

\edef\blx@refpatch@sect@std@pre@defdo{%
  \def\noexpand\do##1{%
    \pretocmd##1
      {\csnumdef{blx@refpatch@current@sectlevel}{\string#2}}
      {\togglefalse{blx@tempa}\noexpand\listbreak}
      {}}}

\edef\blx@refpatch@sect@std@defdo@sect#1#2{%
  \def\noexpand\do##1{%
    \patchcmd##1%
      {\noexpand\@tempskipa \string#5\noexpand\relax}
      {\noexpand\blx@refpatch@sect@std@testandruncode{#1}{#2}%
       \noexpand\@tempskipa \string#5\noexpand\relax}
      {\togglefalse{blx@tempa}\noexpand\listbreak}
      {}}}

\edef\blx@refpatch@sect@std@defdo@ssect#1#2{%
  \def\noexpand\do##1{%
    \patchcmd##1%
      {\noexpand\@tempskipa \string#3\noexpand\relax}
      {\noexpand\blx@refpatch@sect@std@testandruncode{#1}{#2}%
       \noexpand\@tempskipa \string#3\noexpand\relax}
      {\togglefalse{blx@tempa}\noexpand\listbreak}
      {}}}

% {&lt;patch code&gt;}{&lt;section level number&gt;}
\def\blx@refpatch@sect@std#1#2{%
  \blx@refpatch@sect@std@pre
  % \@sect for numbered (unstarred) sections
  \blx@refpatch@docsvlist
    {\blx@refpatch@sect@std@defdo@sect{#1}{#2}}
    {\H@old@sectm@m,% memoir+hyperref (what a mess...)
     \M@sect,%        memoir
     \H@old@sect,%    hyperref
     \NR@sect,%       nameref
     \scr@sect,%      koma-script 3.x
     \scr@startsection,%  bad hack for koma 3.15 &lt;= v &lt;= 3.25
     \@sect}
    {\blx@err@patch{\string\@sect}}
  % \@ssect for un-numbered (starred) sections
  \blx@refpatch@docsvlist
    {\blx@refpatch@sect@std@defdo@ssect{#1}{#2}}
    {\H@old@ssectm@m,% memoir+hyperref (what a mess...)
     \M@ssect,%        memoir
     \H@old@ssect,%    hyperref
     \NR@ssect,%       nameref
     \scr@ssect,%      koma-script 3.x
     \@ssect}
    {\blx@err@patch{\string\@ssect}}}

\def\blx@refpatch@sect@std@testandruncode#1#2{%
  \ifnumequal{#2}{0\csuse{blx@refpatch@current@sectlevel}}
    {#1}
    {}}

% Bibliography categories

\let\blx@categories\@empty

% {&lt;category&gt;}
\newrobustcmd*{\DeclareBibliographyCategory}[1]{%
  \ifcsundef{blx@catg@#1}
    {\global\cslet{blx@catg@#1}\@empty
     \listgadd\blx@categories{#1}}
    {\blx@error
       {Category '#1' already declared}
       {The bibliography category '#1'\MessageBreak
        has already been declared}}}
\@onlypreamble\DeclareBibliographyCategory

% {&lt;category&gt;}{&lt;entrykey&gt;,...}
\newrobustcmd*{\addtocategory}[2]{%
  \ifcsundef{blx@catg@#1}
    {\blx@error
       {Category '#1' not declared}
       {Use \string\DeclareBibliographyCategory\space to declare}}
    {\blx@AfterPreamble{%
       \blx@xsanitizeafter{\forcsvlist{\blx@addtocategory{#1}}}{#2}}}}

% {&lt;category&gt;}{&lt;entrykey&gt;,...}
\def\blx@addtocategory#1#2{%
  % If we are adding a set member to a category, make sure we also add the
  % set parent if it is cited. If it is cited, we should be using the set
  % parent in the category, not the set child member. blx@setc@... will
  % only exist if the set parent is also cited as it is only defined when a
  % member contains \inset which only happens when the set parent is cited.
  \ifcsdef{blx@setc@\the\c@refsection @#2}
    {\blx@auxwrite\@mainaux{}{\string\abx@aux@category{#1}{\csuse{blx@setc@\the\c@refsection @#2}}}%
     \abx@aux@category{#1}{\csuse{blx@setc@\the\c@refsection @#2}}}
    {}%
  \blx@auxwrite\@mainaux{}{\string\abx@aux@category{#1}{#2}}%
  \abx@aux@category{#1}{#2}}

% {&lt;category&gt;}{&lt;entrykey&gt;,...}
\protected\def\abx@aux@category#1#2{%
  \xifinlistcs{\detokenize{#2}}{blx@catg@#1}
    {}
    {\listcsxadd{blx@catg@#1}{\detokenize{#2}}}}

\blx@AtEndDocument{\let\abx@aux@category\@gobbletwo}

% [&lt;options&gt;]{&lt;resource&gt;,...}
\renewrobustcmd*{\bibliography}[1]{%
  \begingroup
  \def\blx@tempa{file}%
  \def\blx@tempb{bibtex}%
  \def\blx@tempc{local}%
  \undef\blx@tempd
  \let\blx@tempe\@empty
  \blx@xsanitizeafter{\forcsvlist\blx@addbib@legacy}{#1}%
  \endgroup}
\@onlypreamble\bibliography

\def\blx@addbib@legacy#1{%
  \begingroup
  \edef\blx@tempa{\endgroup
    \noexpand\blx@addbib@resource{\blx@stripbib{#1}\detokenize{.bib}}}%
  \blx@tempa}

\def\blx@stripbib#1{%
  \expandafter\blx@stripbib@i\detokenize{#1.bib}&amp;}
\edef\blx@stripbib@i{%
  \def\noexpand\blx@stripbib@i##1\detokenize{.bib}##2&amp;}
\blx@stripbib@i{#1}

% [&lt;options&gt;]{&lt;resource&gt;,...}
\newrobustcmd*{\addbibresource}{%
  \blx@addbib\blx@addbib@resource}
\@onlypreamble\addbibresource

\newrobustcmd*{\addglobalbib}{%
  \blx@addbib\blx@addbib@global}
\@onlypreamble\addglobalbib

\newrobustcmd*{\addsectionbib}{%
  \blx@addbib\blx@addbib@register}
\@onlypreamble\addsectionbib

\def\blx@addbib#1{%
  \@ifnextchar[%]
    {\blx@addbib@i{#1}}
    {\blx@addbib@i{#1}[]}}

% kill all spaces and %
% see https://github.com/plk/biblatex/issues/1026
\def\blx@addbib@i#1[#2]{%
  \begingroup
  \@ifnextchar\bgroup
    {\blx@hook@fileverb\blx@addbib@ii{#1}{#2}}%
    {\blx@hook@fileverb\blx@addbib@ii{#1}{#2}}}

\def\blx@addbib@ii#1#2#3{%
  \endgroup
  \begingroup
  \def\blx@tempa{file}%
  \def\blx@tempb{bibtex}%
  \def\blx@tempc{local}%
  \undef\blx@tempd
  \let\blx@tempe\@empty
  \def\blx@tempf{false}%
  \blx@kv@setkeys{blx@addbib}{#2}%
  \blx@xsanitizeafter{#1}{#3}%
  \endgroup}

\def\blx@hook@fileverb{%
  \let\do\@makeother
  \dospecials
  \catcode`\\=\z@
  \catcode`\{=\@ne
  \catcode`\}=\tw@}

\blx@kv@defkey{blx@addbib}{type}{\def\blx@tempa{#1}}
\blx@kv@defkey{blx@addbib}{datatype}{\def\blx@tempb{#1}}
\blx@kv@defkey{blx@addbib}{location}{\def\blx@tempc{#1}}
\blx@kv@defkey{blx@addbib}{label}{\edef\blx@tempd{\detokenize{#1}}}
\blx@kv@defkey{blx@addbib}{bibencoding}{\def\blx@tempe{#1}}
\blx@kv@defkey{blx@addbib}{glob}[true]{\def\blx@tempf{#1}}

% \blx@res@type@&lt;resource&gt;      resource -&gt; type
% \blx@res@data@&lt;resource&gt;      resource -&gt; datatype
% \blx@res@loca@&lt;resource&gt;      resource -&gt; datatype
% \blx@res@labl@&lt;resource&gt;      label    -&gt; resource
% \blx@res@glob@&lt;resource&gt;      glob     -&gt; true|false

\def\blx@addbib@register#1{%
  \csxdef{blx@res@type@#1}{\blx@tempa}%
  \csxdef{blx@res@data@#1}{\blx@tempb}%
  \csxdef{blx@res@loca@#1}{\blx@tempc}%
  \csxdef{blx@res@bibencoding@#1}{\blx@tempe}%
  \ifdef\blx@tempf
    {\csxdef{blx@res@glob@#1}{\blx@tempf}}
    {}%
  \ifdef\blx@tempd
    {\csxdef{blx@res@labl@\blx@tempd}{#1}}
    {}}

\def\blx@addbib@resource#1{%
  \blx@addbib@register{#1}%
  \listgadd\blx@bibfiles{#1}%
  \blx@regbibfile\jobname{#1}}

\def\blx@addbib@global#1{%
  \blx@addbib@resource{#1}%
  \listgadd\blx@bibfiles@global{#1}}

\let\blx@bibfiles\@empty
\let\blx@bibfiles@global\@empty

\def\blx@bibdata#1#2{%
  \forlistloop{\blx@bibdata@i{#1}}#2}
\def\blx@bibdata@i#1#2{%
  \blx@xmlsanitizeafter{\blx@bibdata@ii{#1}{#2}}{#2}}
\def\blx@bibdata@ii#1#2#3{%
  \eappto#1{%
    \blx@xml@datasource
      {\ifcsdef{blx@res@type@#2}
         {\csuse{blx@res@type@#2}}
         {file}}
      {\ifcsdef{blx@res@data@#2}
        {\csuse{blx@res@data@#2}}
        {bibtex}}
      {\ifcsvoid{blx@res@bibencoding@#2}
        {}
        { encoding="\csuse{blx@res@bibencoding@#2}"}}
      {\ifcsvoid{blx@res@glob@#2}
        {}
        { glob="\csuse{blx@res@glob@#2}"}}
      {#3}}}

%% Citations

\newrobustcmd*{\AtEveryCite}{\gappto\blx@hook@cite}
\newrobustcmd*{\AtEveryCitekey}{\gappto\blx@hook@citekey}
\newrobustcmd*{\AtEveryMultiCite}{\gappto\blx@hook@mcite}
\@onlypreamble\AtEveryCite
\@onlypreamble\AtEveryCitekey
\@onlypreamble\AtEveryMultiCite

\newrobustcmd*{\AtEachCitekey}{%
  \iftoggle{blx@citation}{\appto\blx@hook@citekey}{\@gobble}}

\let\blx@hook@entrykey\@gobble
\newrobustcmd*{\AtEveryEntrykey}{%
  \apptocmd{\blx@hook@entrykey}}
\@onlypreamble\AtEveryEntrykey

\def\blx@imc@UseEveryCiteHook{\csuse{blx@hook@cite}}
\def\blx@imc@UseEveryCitekeyHook{\csuse{blx@hook@citekey}}
\def\blx@imc@UseEveryMultiCiteHook{\csuse{blx@hook@mcite}}

\newrobustcmd*{\AtNextCite}{%
  \ifundef\blx@hook@cite@next
    {\gdef\blx@hook@cite@next{\global\undef\blx@hook@cite@next}}
    {}%
  \gappto\blx@hook@cite@next}

\newrobustcmd*{\AtNextCitekey}{%
  \ifundef\blx@hook@citekey@next
    {\gdef\blx@hook@citekey@next{\global\undef\blx@hook@citekey@next}}
    {}%
  \gappto\blx@hook@citekey@next}

\newrobustcmd*{\AtNextMultiCite}{%
  \ifundef\blx@hook@mcite@next
    {\gdef\blx@hook@mcite@next{\global\undef\blx@hook@mcite@next}}
    {}%
  \gappto\blx@hook@mcite@next}

\def\blx@imc@UseNextCiteHook{\csuse{blx@hook@cite@next}}
\def\blx@imc@UseNextCitekeyHook{\csuse{blx@hook@citekey@next}}
\def\blx@imc@UseNextMultiCiteHook{\csuse{blx@hook@mcite@next}}

\def\blx@imc@DeferNextCitekeyHook{\undef\blx@hook@citekey@next}

\blx@regimcs{%
  \UseEveryCiteHook \UseEveryCitekeyHook \UseEveryMultiCiteHook
  \UseNextCiteHook \UseNextCitekeyHook \UseNextMultiCiteHook
  \DeferNextCitekeyHook}

% {&lt;style&gt;}

\newrobustcmd*{\RequireCitationStyle}[1]{%
  \blx@inputonce{#1.cbx}{citation style '#1'}{}{}{}
    {\blx@error
       {Style '#1' not found}
       {The citation style '#1' could not be found}}}
\@onlypreamble\RequireCitationStyle

% {&lt;code&gt;}

\newrobustcmd*{\InitializeCitationStyle}{\appto\blx@hook@cbxinit}
\@onlypreamble\InitializeCitationStyle

% {&lt;code&gt;}

\newrobustcmd*{\OnManualCitation}{\appto\blx@hook@mancite}
\@onlypreamble\OnManualCitation

\newrobustcmd*{\mancite}{%
  \csuse{blx@hook@mancite}%
  \blx@ibidreset
  \blx@idemreset
  \blx@opcitreset
  \blx@loccitreset}

% {&lt;entrykey&gt;}{&lt;message&gt;}
% Wrapper to track cite keys which are \nocited
\def\blx@nocitation#1#2{%
  \ifinlist{#1}\blx@nocites
    {}
    {\listgadd\blx@nocites{#1}}%
  \blx@citation@i{#1}{#2}}

% {&lt;entrykey&gt;}{&lt;message&gt;}
% Just a wrapper to suppress citation tracking in toc/lof etc.
\def\blx@citation#1#2{%
  \ifinlist{#1}\blx@directcites
    {}
    {\listgadd\blx@directcites{#1}}%
  \blx@citation@i{#1}{#2}}

\def\blx@citation@i#1#2{%
  \ifbool{citerequest}
    {\blx@citation@entry{#1}{#2}}
    {}}

\def\blx@citation@entry#1#2{%
  \blx@bibreq{#1}%
  \ifinlistcs{#1}{blx@cites@\the\c@refsection}
    {}
    {\listcsgadd{blx@cites@\the\c@refsection}{#1}}%
  \blx@auxwrite\@mainaux{}{\string\abx@aux@cite{\the\c@refsection}{#1}}%
  \ifinlistcs{#1}{blx@segm@\the\c@refsection @\the\c@refsegment}
    {}
    {\listcsgadd{blx@segm@\the\c@refsection @\the\c@refsegment}{#1}}%
  \blx@auxwrite\@mainaux{}{\string\abx@aux@segm{\the\c@refsection}%
                                               {\the\c@refsegment}%
                                               {\detokenize{#1}}}%
  \blx@ifdata{#1}
    {}
    {\ifcsdef{blx@miss@\the\c@refsection}
       {\ifinlistcs{#1}{blx@miss@\the\c@refsection}
          {\@latex@warning{#2{#1}}}
          {\blx@logreq@active{#2{#1}}}}
       {\blx@logreq@active{#2{#1}}}}%
  \blx@hook@entrykey{#1}}

\protected\def\abx@aux@segm#1#2#3{%
  \xifinlistcs{\detokenize{#3}}{blx@segm@#1@#2}
    {}
    {\listcsxadd{blx@segm@#1@#2}{\detokenize{#3}}}}

\def\blx@nocitation@all{%
  \ifinlist{*}\blx@nocites
    {}
    {\listgadd\blx@nocites{*}}%
  \blx@citation@all}

\def\blx@citation@all{%
  \blx@auxwrite\@mainaux{}{\string\abx@aux@nociteall}%
  \ifbool{citerequest}
    {\global\advance\csname blx@sectionciteorder@\the\c@refsection\endcsname\@ne
     \blx@bibreq{*}%
     \global\csletcs
       {blx@segm@\the\c@refsection @\the\c@refsegment}
       {blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}%
      \ifcsvoid{blx@dlist@entry@\the\c@refsection @\blx@refcontext@context}
       {\blx@logreq@active{}}
       {}}
    {}}

\def\abx@aux@nociteall{%
  \listgadd\blx@nocites{*}}

\protected\def\blx@bibreq#1{%
  \advance\blx@tempcntc\@ne% holds internal \cite{} citation order
  \begingroup
  \blx@xmlsanitizeafter{\def\blx@tempa}{#1}%
  \let\blx@tempb\@empty
  % Only output as \nocited if a key wasn't also directly \cite'd
  % Since citekey output is sequential as cites are read, the .bcf might contain
  % duplicate keys with differring nocite attributes if \nocite{X} and \cite{X} both occur
  % but biber deals with this and priorities \cites
  \ifboolexpr{test {\ifinlist{#1}\blx@nocites}
              and
              not test {\ifinlist{#1}\blx@directcites}}
    {\def\blx@tempb{ nocite="1"}}
    {}%
  \blx@auxwrite\blx@bcfout{}{\blx@xml@citekey{\blx@tempa}{\blx@tempb}%
      {\expandafter\the\csname blx@sectionciteorder@\the\c@refsection\endcsname}%
      {\expandafter\the\csname blx@tempcntc\endcsname}}%
  % citeall is always order "0" - this makes no real difference as biber
  % ignores all other citekeys in the section if citeall is present
  % \ifstrequal{*}{#1}
  %   {\blx@auxwrite\blx@bcfout{}{\blx@xml@citekey{\blx@tempa}{\blx@tempb}{0}}}
  %   {\blx@auxwrite\blx@bcfout{}{\blx@xml@citekey{\blx@tempa}{\blx@tempb}{%
  %      \expandafter\the\csname blx@sectionciteorder@\the\c@refsection\endcsname}}}%
  \endgroup}

% {&lt;set&gt;}{&lt;key1,key2,key3&gt;}
\newrobustcmd*{\defbibentryset}[2]{%
  \@bsphack
  \begingroup
  \blx@xsanitizeafter{\def\blx@tempa}{#1}%
  \let\blx@tempb\@empty
  \let\blx@tempc\@empty
  \blx@xsanitizeafter{\forcsvlist\blx@defentryset@add}{#2}%
  \ifcsdef{blx@set@\the\c@refsection @\blx@tempa}
    {\expandafter\ifdefequal
       \csname blx@set@\the\c@refsection @\blx@tempa\endcsname
       \blx@tempb
       {}
       {\blx@error
          {Conflicting definitions of '\blx@tempa'}
          {The entry set '\blx@tempa' has been defined before.%
           \MessageBreak
           old: \blx@tempa\space = %
           \csuse{blx@set@\the\c@refsection @\blx@tempa}\MessageBreak
           new: \blx@tempa\space = \blx@tempb\MessageBreak
           I'm ignoring the new definition}}}
    {\global\cslet{blx@set@\the\c@refsection @\blx@tempa}\blx@tempb
     \edef\blx@tempa{%
       \blx@AfterPreamble{\blx@setreq{\blx@tempa}{\blx@tempb}}}%
     \blx@tempa}%
  \endgroup
  \@esphack}

\def\blx@defentryset@add#1{%
  \edef\blx@tempb{\blx@tempb\blx@tempc#1}%
  \def\blx@tempc{,}}

\protected\def\blx@setreq#1#2{%
  \begingroup
  \blx@xmlsanitizeafter{\def\blx@tempa}{#1}%
  \blx@xmlsanitizeafter{\def\blx@tempb}{#2}%
  \blx@auxwrite\blx@bcfout{}{\blx@xml@citeset{\blx@tempa}{\blx@tempb}}%
  \endgroup}


\def\abx@warn@emptycite{%
  \abx@warn@emptycite@print
  \abx@warn@emptycite@log}

\def\abx@warn@emptycite@print@text{%
  \textless empty citation\textgreater}

\def\abx@warn@emptycite@print{%
  \abx@missing@entry{\abx@warn@emptycite@print@text}}

\def\abx@warn@emptycite@log{%
  \@latex@warning{\blx@msg@cundefon{}}}


% {&lt;entrykey&gt;,...}
% a crude way to check for a do-nothing argument:
% loop over it to see what happens
\protected\def\blx@citeloop#1{%
  \togglefalse{blx@tempa}%
  \def\do{\toggletrue{blx@tempa}\listbreak}%
  \expandafter\docsvlist\expandafter{\detokenize{#1}}%
  \iftoggle{blx@tempa}
    {\expandafter\blx@citeloop@i\expandafter{\detokenize{#1}}}
    {\abx@warn@emptycite}}
\protected\def\blx@citeloop@i#1{%
  \begingroup
  % This must be here and not after \blx@citeadd as this changes the refcontext
  \letcs\blx@tempb{blx@dlist@centry@\the\c@refsection @\blx@refcontext@context}%
  \ifundef\blx@tempb
    {\let\blx@tempb\@empty}
    {}%
  % Make sure this counter exists. Sometimes it might not when using, e.g:
  % refsection=chapter and \includeonly to put in the chapters or when
  % inserting citations into table of contents
  \blx@providecount{blx@sectionciteorder@\the\c@refsection}%
  \global\advance\csname blx@sectionciteorder@\the\c@refsection\endcsname\@ne
  \blx@tempcnta\z@
  \blx@tempcntb\z@
  \blx@tempcntc\z@
  \let\blx@tempa\@empty
  \forcsvlist\blx@citeadd{#1}% adds to \blx@tempa
  \blx@thenotecheck
  \ifnum\blx@tempcnta&gt;\z@
    \ifnum\blx@tempcntb&gt;\z@
      \multicitedelim
    \fi
  \else
    \blx@postpunct@saved
  \fi
  % \blx@tempb is a sorted list of all cites, \blx@tempa is the list of cites to
  % sort using this list
  \blx@thecitesort
  \edef\blx@tempa{\endgroup
    \c@citecount\z@
    \c@citetotal\the\blx@tempcnta\relax
    \unexpanded{\forlistloop\blx@citeprint}{\blx@tempb}}%
  \blx@tempa}

\def\blx@notecheck{%
  \ifnum\blx@tempcnta&gt;\@ne
    \blx@warning{%
      Package option 'sortcites' enabled.\MessageBreak
      Verify postnote placement}%
  \fi}

\def\blx@citesort{%
  \ifnum\blx@tempcnta&gt;\@ne
    \blx@filtercitesort\blx@tempb{blx@tempa}%
  \else
    \blx@citenosort
  \fi}

\def\blx@citenosort{%
  \let\blx@tempb\blx@tempa}

\def\abx@missing@entry#1{%
  \abx@missing{#1}}

% {&lt;entrykey&gt;}
\def\blx@citeadd#1{%
  \ifcsdef{blx@keyalias@\the\c@refsection @#1}
    {\letcs\blx@realkey{blx@keyalias@\the\c@refsection @#1}}
    {\def\blx@realkey{#1}}%
  \expandafter\blx@getrefcontext\expandafter{\blx@realkey}% needed for \ifdata
  \expandafter\blx@citation\expandafter{\blx@realkey}\blx@msg@cundefon
  \expandafter\blx@ifdata\expandafter{\blx@realkey}
    {\advance\blx@tempcnta\@ne
     \listeadd\blx@tempa{\blx@realkey}}
    {\ifnum\blx@tempcntb&gt;\z@\multicitedelim\fi
     \expandafter\abx@missing@entry\expandafter{\blx@realkey}%
     \advance\blx@tempcntb\@ne}}

% set default refcontext for one citation key
% and then override with data from auto-assign \assignrefcontext* macros, if any
% &lt;entrykey&gt;
\def\blx@getrefcontext#1{%
  % Save refcontext for restoration at end of \citeprint
  \let\blx@refcontext@context@saved\blx@refcontext@context
  % Get the default refcontext
  % If there was one due to appearance in a bib/biblist, use it
  % otherwise fall back on global refcontext. This can happen for cites
  % made (a bit strangely but some styles do this) inside a biblist
  % which never appear in any printed bib/biblist and therefore have no default
  % refcontext defined
  \ifcsdef{blx@assignedrefcontextbib@aux@\the\c@refsection @#1}
    {\letcs\blx@refcontext@context{blx@assignedrefcontextbib@aux@\the\c@refsection @#1}}
    {\blx@edef@refcontext{\blx@sorting/global//global/global/global}}%
  % assignment via keyword list
  \ifdef\blx@assignedrefcontextkeywlist
    {\def\do##1{%
       \blx@imc@ifentrykeyword{#1}{##1}
         {% weak version
          \ifboolexpr{test {\ifcsdef{blx@assignedrefcontextkeyws*@\the\c@refsection @##1}}
                      and
                      not togl {blx@refcontext}}% inside explicit non-global refcontext
            {\letcs\blx@refcontext@context{blx@assignedrefcontextkeyws*@\the\c@refsection @##1}}
            {}%
          % strong version
          \ifcsdef{blx@assignedrefcontextkeyws@\the\c@refsection @##1}
            {\letcs\blx@refcontext@context{blx@assignedrefcontextkeyws@\the\c@refsection @##1}}
            {}}
         {}}%
     \dolistloop\blx@assignedrefcontextkeywlist}
    {}%
  % assignment via category
  \ifdef\blx@assignedrefcontextcatlist
    {\def\do##1{%
       \blx@imc@ifentrycategory{#1}{##1}
         {% weak version
          \ifboolexpr{test {\ifcsdef{blx@assignedrefcontextcats*@\the\c@refsection @##1}}
                      and
                      not togl {blx@refcontext}}% inside explicit non-global refcontext
            {\letcs\blx@refcontext@context{blx@assignedrefcontextcats*@\the\c@refsection @##1}}
            {}%
          % strong version
          \ifcsdef{blx@assignedrefcontextcats@\the\c@refsection @##1}
            {\letcs\blx@refcontext@context{blx@assignedrefcontextcats@\the\c@refsection @##1}}
            {}}
         {}}%
     \dolistloop\blx@assignedrefcontextcatlist}
    {}%
  % assignment via entrykeys
  % weak version
  \nottoggle{blx@refcontext}
    {\ifcsdef{blx@assignedrefcontextkeys*@\the\c@refsection @*}
       {\letcs\blx@refcontext@context{blx@assignedrefcontextkeys*@\the\c@refsection @*}}
       {\ifcsdef{blx@assignedrefcontextkeys*@\the\c@refsection @#1}
         {\letcs\blx@refcontext@context{blx@assignedrefcontextkeys*@\the\c@refsection @#1}}
         {}}}
    {}%
  % strong version
  \ifcsdef{blx@assignedrefcontextkeys@\the\c@refsection @*}
    {\letcs\blx@refcontext@context{blx@assignedrefcontextkeys@\the\c@refsection @*}}
    {\ifcsdef{blx@assignedrefcontextkeys@\the\c@refsection @#1}
      {\letcs\blx@refcontext@context{blx@assignedrefcontextkeys@\the\c@refsection @#1}}
      {}}}

% {&lt;entrykey&gt;}
\protected\def\blx@citeprint#1{%
  \blx@getrefcontext{#1}%
  \advance\c@citecount\@ne
  \addtocounter{instcount}\@ne
  \ifnum\c@citecount=\@ne
    \blx@getdata@cite{#1}%
    \blx@precode
    \ifnum\c@citetotal&gt;\@ne
      \blx@resetdata
    \fi
  \else
    \blx@dlimcode
  \fi
  \begingroup
  \ifnum\c@citetotal&gt;\@ne
    \blx@getdata@cite{#1}%
  \fi
  \blx@entrysetcount
  \blx@setoptions@type\abx@field@entrytype
  \blx@setoptions@entry
  \blx@backref{#1}%
  \blx@pagetracker
  \csuse{blx@hook@citekey}%
  \csuse{blx@hook@citekey@next}%
  \blx@beglangcite
  \blx@execute
  \blx@loopcode
  \blx@citecounter
  \blx@citetracker
  \blx@ibidtracker
  \blx@idemtracker
  \blx@opcittracker
  \blx@loccittracker
  \ifnum\c@citecount=\c@citetotal
    \def\blx@thecheckpunct{\blx@err@nestcite\@gobble}%
    \blx@postcode
    \blx@postpunct@saved
  \fi
  \blx@endlangcite
  \endgroup
  \let\blx@refcontext@context\blx@refcontext@context@saved}

% cite counter
\def\blx@citecounter@global{%
  \ifbool{@filesw}
    {\ifbool{citetracker}
       {\abx@curr@count{\the\c@refsection}{\abx@field@entrykey}%
        \immediate\write\@mainaux{%
          \string\abx@aux@count
          {\the\c@refsection}{\abx@field@entrykey}}}
       {}}
    {}}

\def\blx@citecounter@context{%
  \ifbool{@filesw}
    {\ifbool{citetracker}
       {\iftoggle{blx@footnote}
          {\abx@curr@fncount}
          {\abx@curr@count}
          {\the\c@refsection}{\abx@field@entrykey}%
        \immediate\write\@mainaux{%
          \iftoggle{blx@footnote}
            {\string\abx@aux@fncount}
            {\string\abx@aux@count}%
          {\the\c@refsection}{\abx@field@entrykey}}}
       {}}
    {}}

% {&lt;refsection&gt;}{&lt;entrykey&gt;}
% set maxcitecounter as well, note that we also define a maxcitecounter across
% all refsections, but that does not have a high-level interface
\protected\def\blx@aux@count#1#2{%
  \csnumgdef{blx@count@#1@\detokenize{#2}}{%
    \csuse{blx@count@#1@\detokenize{#2}}+1}%
  \ifnumgreater{\csuse{blx@count@#1@\detokenize{#2}}}{%
      0\csuse{blx@maxcitecounter@#1}}
    {\csnumgdef{blx@maxcitecounter@#1}{%
       \csuse{blx@count@#1@\detokenize{#2}}}}
    {}%
  \ifnumgreater{\csuse{blx@count@#1@\detokenize{#2}}}{%
      0\csuse{blx@maxcitecounter}}
    {\csnumgdef{blx@maxcitecounter}{%
       \csuse{blx@count@#1@\detokenize{#2}}}}
    {}}

\protected\def\blx@aux@fncount#1#2{%
  \csnumgdef{blx@fncount@#1@\detokenize{#2}}{%
    \csuse{blx@fncount@#1@\detokenize{#2}}+1}%
  \ifnumgreater{\csuse{blx@fncount@#1@\detokenize{#2}}}{%
      0\csuse{blx@maxfncitecounter@#1}}
    {\csnumgdef{blx@maxfncitecounter@#1}{%
       \csuse{blx@fncount@#1@\detokenize{#2}}}}
    {}%
  \ifnumgreater{\csuse{blx@fncount@#1@\detokenize{#2}}}{%
      0\csuse{blx@maxfncitecounter}}
    {\csnumgdef{blx@maxfncitecounter}{%
       \csuse{blx@fncount@#1@\detokenize{#2}}}}
    {}}

\let\abx@aux@count\@gobbletwo
\let\abx@aux@fncount\@gobbletwo

\protected\def\blx@curr@count#1#2{%
  \csnumgdef{blx@currcount@#1@#2}{%
    \csuse{blx@currcount@#1@#2}+1}}

\protected\def\blx@curr@fncount#1#2{%
  \csnumgdef{blx@currfncount@#1@#2}{%
    \csuse{blx@currfncount@#1@#2}+1}}

\let\abx@curr@count\@gobbletwo
\let\abx@curr@fncount\@gobbletwo

\blx@AtEndDocument{%
  \let\abx@aux@count\@gobbletwo
  \let\abx@aux@fncount\@gobbletwo
  \let\abx@curr@count\@gobbletwo
  \let\abx@curr@fncount\@gobbletwo}

\protected\def\blx@setcitecounter@global{%
  \c@citecounter0%
    \csuse{blx@count@\the\c@refsection @\abx@field@entrykey}%
  \relax
  \c@maxcitecounter0%
    \csuse{blx@maxcitecounter@\the\c@refsection}%
  \relax}

\protected\def\blx@setcitecounter@context{%
  \c@citecounter0%
    \iftoggle{blx@footnote}
      {\csuse{blx@fncount@\the\c@refsection @\abx@field@entrykey}}
      {\csuse{blx@count@\the\c@refsection @\abx@field@entrykey}}%
  \relax
  \c@maxcitecounter0%
    \iftoggle{blx@footnote}
      {\csuse{blx@maxfncitecounter@\the\c@refsection}}
      {\csuse{blx@maxcitecounter@\the\c@refsection}}%
  \relax}

% cite tracker
\def\blx@citetracker@global{%
  \ifbool{citetracker}
    {\xifinlistcs\abx@field@entrykey{blx@bsee@\the\c@refsection}
       {}
       {\listcsxadd{blx@bsee@\the\c@refsection}\abx@field@entrykey}}
    {}}

\def\blx@citetracker@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\xifinlistcs\abx@field@entrykey{blx@fsee@\the\c@refsection}
          {}
          {\listcsxadd{blx@fsee@\the\c@refsection}\abx@field@entrykey}}
       {\xifinlistcs\abx@field@entrykey{blx@bsee@\the\c@refsection}
          {}
          {\listcsxadd{blx@bsee@\the\c@refsection}\abx@field@entrykey}}}
    {}}

\protected\appto\abx@savetrackers{%
  \global\csletcs{blx@saved@bsee@\the\c@refsection}{blx@bsee@\the\c@refsection}%
  \global\csletcs{blx@saved@fsee@\the\c@refsection}{blx@fsee@\the\c@refsection}}

\protected\appto\abx@resttrackers{%
  \global\csletcs{blx@bsee@\the\c@refsection}{blx@saved@bsee@\the\c@refsection}%
  \global\csletcs{blx@fsee@\the\c@refsection}{blx@saved@fsee@\the\c@refsection}}

\protected\appto\abx@cleartrackers{%
  \global\cslet{blx@saved@bsee@\the\c@refsection}\@empty
  \global\cslet{blx@saved@fsee@\the\c@refsection}\@empty}

% ibidem tracker
\def\blx@ibidtracker@global{%
  \ifbool{citetracker}
    {\global\let\blx@lastkey@text\abx@field@entrykey}
    {}}

\def\blx@ibidtracker@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\global\let\blx@lastkey@foot\abx@field@entrykey}
       {\global\let\blx@lastkey@text\abx@field@entrykey}}
    {}}

\def\blx@ibidtracker@strict{%
  \blx@ifcitesingle
    {\blx@ibidtracker@global}
    {\blx@ibidreset@global}}%

\def\blx@ibidtracker@constrict{%
  \blx@ifcitesingle
    {\iftoggle{blx@footnote}
       {\blx@mpfnsave}
       {}%
     \blx@ibidtracker@context}
    {\blx@ibidreset@context}}%

\def\blx@ibidreset@force{%
  \global\undef\blx@lastkey@text
  \global\undef\blx@lastkey@foot
  \blx@mpfnreset}

\def\blx@ibidreset@global{%
  \global\undef\blx@lastkey@text}

\def\blx@ibidreset@context{%
  \iftoggle{blx@footnote}
    {\blx@mpfnreset
     \global\undef\blx@lastkey@foot}
    {\global\undef\blx@lastkey@text}}

\protected\appto\abx@savetrackers{%
  \global\let\blx@saved@lastkey@text\blx@lastkey@text
  \global\let\blx@saved@lastkey@foot\blx@lastkey@foot}

\protected\appto\abx@resttrackers{%
  \global\let\blx@lastkey@text\blx@saved@lastkey@text
  \global\let\blx@lastkey@foot\blx@saved@lastkey@foot}

\protected\appto\abx@cleartrackers{%
  \global\undef\blx@saved@lastkey@text
  \global\undef\blx@saved@lastkey@foot}

% idem tracker
\def\blx@idemtracker@global{%
  \ifbool{citetracker}
    {\global\let\blx@lasthash@text\abx@field@fullhash}
    {}}

\def\blx@idemtracker@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\global\let\blx@lasthash@foot\abx@field@fullhash}
       {\global\let\blx@lasthash@text\abx@field@fullhash}}
    {}}

\let\blx@idemtracker@strict\blx@idemtracker@global

\def\blx@idemtracker@constrict{%
  \iftoggle{blx@footnote}
    {\blx@mpfnsave}
    {}%
  \blx@idemtracker@context}

\def\blx@idemreset@force{%
  \global\undef\blx@lasthash@text
  \global\undef\blx@lasthash@foot
  \blx@mpfnreset}

\def\blx@idemreset@global{%
  \global\undef\blx@lasthash@text}

\def\blx@idemreset@context{%
  \iftoggle{blx@footnote}
    {\blx@mpfnreset
     \global\undef\blx@lasthash@foot}
    {\global\undef\blx@lasthash@text}}

\protected\appto\abx@savetrackers{%
  \global\let\blx@saved@lasthash@text\blx@lasthash@text
  \global\let\blx@saved@lasthash@text\blx@lasthash@text}

\protected\appto\abx@resttrackers{%
  \global\let\blx@lasthash@text\blx@saved@lasthash@text
  \global\let\blx@lasthash@text\blx@saved@lasthash@text}

\protected\appto\abx@cleartrackers{%
  \global\undef\blx@saved@lasthash@text
  \global\undef\blx@saved@lasthash@foot}

% opcit tracker
\def\blx@opcittracker@global{%
  \ifbool{citetracker}
    {\blx@opcit@tracker{text}}
    {}}

\def\blx@opcittracker@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\blx@opcit@tracker{foot}}
       {\blx@opcit@tracker{text}}}
    {}}

\def\blx@opcittracker@strict{%
  \blx@ifcitesingle
    {\blx@opcittracker@global}
    {\blx@opcitreset@global}}%

\def\blx@opcittracker@constrict{%
  \blx@ifcitesingle
    {\iftoggle{blx@footnote}
       {\blx@mpfnsave}
       {}%
     \blx@opcittracker@context}
    {\blx@opcitreset@context}}%

\def\blx@opcit@tracker#1{%
  \blx@imc@iffieldundef{namehash}
    {}
    {\global\cslet{blx@lastkey@#1@\abx@field@namehash}\abx@field@entrykey
     \xifinlistcs\abx@field@namehash{blx@trackhash@#1}
       {}
       {\listcsxadd{blx@trackhash@#1}\abx@field@namehash}}}

\def\blx@opcit@reset#1{%
  \begingroup
  \def\do##1{\global\csundef{blx@lastkey@#1@##1}}%
  \dolistcsloop{blx@trackhash@#1}%
  \global\cslet{blx@trackhash@#1}\@empty
  \endgroup}

\def\blx@opcitreset@force{%
  \blx@opcit@reset{text}%
  \blx@opcit@reset{foot}%
  \blx@mpfnreset}

\def\blx@opcitreset@global{%
  \blx@opcit@reset{text}}

\def\blx@opcitreset@context{%
  \iftoggle{blx@footnote}
    {\blx@opcit@reset{foot}%
     \blx@mpfnreset}
    {\blx@opcit@reset{text}}}

\let\blx@trackhash@text\@empty
\let\blx@trackhash@foot\@empty

\protected\appto\abx@savetrackers{%
  \begingroup
  \def\do#1{\global\csletcs{blx@saved@lastkey@text@#1}{blx@lastkey@text@#1}}%
  \dolistloop\blx@trackhash@text
  \global\let\blx@saved@trackhash@text\blx@trackhash@text
  \def\do#1{\global\csletcs{blx@saved@lastkey@foot@#1}{blx@lastkey@foot@#1}}%
  \dolistloop\blx@trackhash@foot
  \global\let\blx@saved@trackhash@foot\blx@trackhash@foot
  \endgroup}

\protected\appto\abx@resttrackers{%
  \begingroup
  \blx@opcit@reset{text}%
  \global\let\blx@trackhash@text\blx@saved@trackhash@text
  \def\do#1{\global\csletcs{blx@lastkey@text@#1}{blx@saved@lastkey@text@#1}}%
  \dolistloop\blx@trackhash@text
  \blx@opcit@reset{foot}%
  \global\let\blx@trackhash@foot\blx@saved@trackhash@foot
  \def\do#1{\global\csletcs{blx@lastkey@foot@#1}{blx@saved@lastkey@foot@#1}}%
  \dolistloop\blx@trackhash@foot
  \endgroup}

\protected\appto\abx@cleartrackers{%
  \begingroup
  \def\do#1{\global\csundef{blx@saved@lastkey@text@#1}}%
  \dolistloop\blx@saved@trackhash@text
  \global\undef\blx@saved@trackhash@text
  \def\do#1{\global\csundef{blx@saved@lastkey@foot@#1}}%
  \dolistloop\blx@saved@trackhash@foot
  \global\undef\blx@saved@trackhash@foot
  \endgroup}

% loccit tracker
\def\blx@loccittracker@global{%
  \ifbool{citetracker}
    {\blx@loccit@tracker{text}}
    {}}

\def\blx@loccittracker@context{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\blx@loccit@tracker{foot}}
       {\blx@loccit@tracker{text}}}
    {}}

\def\blx@loccittracker@strict{%
  \ifbool{citetracker}
    {\blx@loccit@stricttracker{text}}
    {}}

\def\blx@loccittracker@constrict{%
  \ifbool{citetracker}
    {\iftoggle{blx@footnote}
       {\blx@mpfnsave
        \blx@loccit@stricttracker{foot}}
       {\blx@loccit@stricttracker{text}}}
    {}}

\def\blx@loccit@tracker#1{%
  \global\csundef{blx@lastnote@#1@\abx@field@entrykey}%
  \blx@imc@iffieldundef{postnote}
    {}
    {\global\cslet{blx@lastnote@#1@\abx@field@entrykey}\abx@field@postnote
     \xifinlistcs\abx@field@entrykey{blx@trackkeys@#1}
       {}
       {\listcsxadd{blx@trackkeys@#1}\abx@field@entrykey}}}

\def\blx@loccit@stricttracker#1{%
  \global\csundef{blx@lastnote@#1@\abx@field@entrykey}%
  \blx@imc@iffieldundef{postnote}
    {}
    {\blx@ifcitesingle
       {\expandafter\blx@imc@ifpages
        \expandafter{\abx@field@postnote}
          {\global\cslet{blx@lastnote@#1@\abx@field@entrykey}\abx@field@postnote
           \xifinlistcs\abx@field@entrykey{blx@trackkeys@#1}
             {}
             {\listcsxadd{blx@trackkeys@#1}\abx@field@entrykey}}
          {}}
       {}}}

\def\blx@loccit@reset#1{%
  \begingroup
  \def\do##1{\global\csundef{blx@lastnote@#1@##1}}%
  \dolistcsloop{blx@trackkeys@#1}%
  \global\cslet{blx@trackkeys@#1}\@empty
  \endgroup}

\def\blx@loccitreset@force{%
  \blx@loccit@reset{text}%
  \blx@loccit@reset{foot}%
  \blx@mpfnreset}

\def\blx@loccitreset@global{%
  \blx@loccit@reset{text}}

\def\blx@loccitreset@context{%
  \iftoggle{blx@footnote}
    {\blx@loccit@reset{foot}%
     \blx@mpfnreset}
    {\blx@loccit@reset{text}}}

\let\blx@trackkeys@text\@empty
\let\blx@trackkeys@foot\@empty

\protected\appto\abx@savetrackers{%
  \begingroup
  \def\do#1{\global\csletcs{blx@saved@lastnote@text@#1}{blx@lastnote@text@#1}}%
  \dolistloop\blx@trackkeys@text
  \global\let\blx@saved@trackkeys@text\blx@trackkeys@text
  \def\do#1{\global\csletcs{blx@saved@lastnote@foot@#1}{blx@lastnote@foot@#1}}%
  \dolistloop\blx@trackkeys@foot
  \global\let\blx@saved@trackkeys@foot\blx@trackkeys@foot
  \endgroup}

\protected\appto\abx@resttrackers{%
  \begingroup
  \blx@loccit@reset{text}%
  \global\let\blx@trackkeys@text\blx@saved@trackkeys@text
  \def\do#1{\global\csletcs{blx@lastnote@text@#1}{blx@saved@lastnote@text@#1}}%
  \dolistloop\blx@trackkeys@text
  \blx@loccit@reset{foot}%
  \global\let\blx@trackkeys@foot\blx@saved@trackkeys@foot
  \def\do#1{\global\csletcs{blx@lastnote@foot@#1}{blx@saved@lastnote@foot@#1}}%
  \dolistloop\blx@trackkeys@foot
  \endgroup}

\protected\appto\abx@cleartrackers{%
  \begingroup
  \def\do#1{\global\csundef{blx@saved@lastnote@text@#1}}%
  \dolistloop\blx@saved@trackkeys@text
  \global\undef\blx@saved@trackkeys@text
  \def\do#1{\global\csundef{blx@saved@lastnote@foot@#1}}%
  \dolistloop\blx@saved@trackkeys@foot
  \global\undef\blx@saved@trackkeys@foot
  \endgroup}

\def\blx@addbackref#1{%
  \ifcsdef{blx@setp@\the\c@refsection @#1}
    {\ifcase\blx@backrefsetstyle
       \blx@addbackref@i{#1}%
     \or
       \blx@addbackref@ii{setp}{#1}%
     \or
       \blx@addbackref@i{#1}%
     \or
       \blx@addbackref@i{#1}%
     \or
       \blx@addbackref@i{#1}%
       \blx@addbackref@ii{setp}{#1}%
     \or
       \blx@addbackref@i{#1}%
       \blx@addbackref@ii{setp}{#1}%
     \fi}
    {\ifcsdef{blx@setc@\the\c@refsection @#1}
       {\ifcase\blx@backrefsetstyle
          \blx@addbackref@ii{setc}{#1}%
        \or
          \blx@addbackref@i{#1}%
        \or
          \blx@addbackref@i{#1}%
        \or
          \blx@addbackref@i{#1}%
          \blx@addbackref@ii{setc}{#1}%
        \or
          \blx@addbackref@i{#1}%
        \or
          \blx@addbackref@i{#1}%
          \blx@addbackref@ii{setc}{#1}%
        \fi}
       {\blx@addbackref@i{#1}}}}

\def\blx@addbackref@i#1{%
  \ifbacktracker
    \blx@leavevmode
    \if@filesw
      \protected@write\@mainaux{}{\string\abx@aux@backref
        {\the\c@instcount}{#1}{\the\c@refsection}%
        {\thepage}{\noexpand\the\c@page}}%
    \fi
  \fi}

\def\blx@addbackref@ii#1#2{%
  \expandafter\expandafter\expandafter\forcsvlist
  \expandafter\expandafter\expandafter\blx@addbackref@i
  \expandafter\expandafter\expandafter{%
    \csname blx@#1@\the\c@refsection @#2\endcsname}}

% {&lt;instcount&gt;}{&lt;entrykey&gt;}{&lt;refsection&gt;}{&lt;page&gt;}{&lt;page int&gt;}
\protected\def\blx@aux@backref#1#2#3#4#5{%
  \ifcsundef{blx@pref@#3@\detokenize{#2}}
    {\global\cslet{blx@pref@#3@\detokenize{#2}}\@empty
     \expandafter\blx@onlypreamble\csname blx@pref@#3@\detokenize{#2}\endcsname}
    {}%
  \blx@ifprintableinlistcs{#4}{blx@pref@#3@\detokenize{#2}}
    {}
    {\listcsgadd{blx@pref@#3@\detokenize{#2}}{#4}}%
  \blx@addpagesum{#1}{#5}}

\blx@AtEndDocument{%
  \def\abx@aux@backref#1#2#3#4#5{\blx@addpagesum{#1}{#5}}}

% {&lt;true&gt;}{&lt;false&gt;}
\def\blx@ifcitesingle{%
  \ifnum\c@citetotal=\@ne
    \expandafter\@firstoftwo
  \else
    \expandafter\@secondoftwo
  \fi}

%  hyperref interface
\appto\blx@mkhyperref{%
  \protected\def\blx@imc@bibhyperref{%
    \@ifnextchar[%]
      {\blx@bibhyperref}
      {\blx@bibhyperref[\abx@field@entrykey]}}%
  \ifundef\hyper@natanchorstart
    {\long\def\blx@bibhyperref[#1]#2{%
       \blx@sfsave\hyperlink{cite.\the\c@refsection @#1}{\blx@sfrest
         #2%
       \blx@sfsave}\blx@sfrest}%
     \protected\long\def\blx@imc@bibhyperlink#1#2{%
       \blx@sfsave\hyperlink{cite.\the\c@refsection:#1}{\blx@sfrest
         #2%
       \blx@sfsave}\blx@sfrest}%
     \protected\long\def\blx@imc@bibhypertarget#1#2{%
       \blx@sfsave\hypertarget{cite.\the\c@refsection:#1}{\blx@sfrest
         #2%
       \blx@sfsave}\blx@sfrest}}%
    {\long\def\blx@bibhyperref[#1]#2{%
       \blx@sfsave\hyper@natlinkstart{\the\c@refsection @#1}\blx@sfrest
       #2%
       \blx@sfsave\hyper@natlinkend\blx@sfrest}%
     \protected\long\def\blx@imc@bibhyperlink#1#2{%
       \blx@sfsave\hyper@natlinkstart{\the\c@refsection:#1}\blx@sfrest
       #2%
       \blx@sfsave\hyper@natlinkend\blx@sfrest}%
     \protected\long\def\blx@imc@bibhypertarget#1#2{%
       \blx@sfsave\hyper@natanchorstart{\the\c@refsection:#1}\blx@sfrest
       #2%
       \blx@sfsave\hyper@natanchorend\blx@sfrest}}
  \let\blx@imc@ifhyperref\@firstoftwo
  \def\blx@sf{\spacefactor}%
  \def\blx@sfsave{%
    \blx@leavevmode
    \numgdef\blx@sf{\spacefactor}}%
  \def\blx@sfrest{%
    \ifhmode\spacefactor\blx@sf\relax\fi
    \gdef\blx@sf{\spacefactor}}}

\appto\blx@mknohyperref{%
  \protected\def\blx@imc@bibhyperref{\@ifnextchar[\blx@nohyperref\@firstofone}%
  \def\blx@nohyperref[#1]#2{#2}%
  \let\blx@imc@bibhyperlink\@secondoftwo
  \let\blx@imc@bibhypertarget\@secondoftwo
  \let\blx@imc@ifhyperref\@secondoftwo}

\blx@regimcs{%
  \bibhyperref \bibhyperlink \bibhypertarget \ifhyperref}

% {&lt;entrykey&gt;,...}
\protected\def\nocite#{\blx@nocite}

\def\blx@nocite#1{%
  \@bsphack
  \blx@AfterPreamble{%
    \ifstrequal{*}{#1}
      {\blx@nocitation@all}
      {\blx@xsanitizeafter{\forcsvlist\blx@nocite@do}{#1}}}%
  \@esphack}

\def\blx@nocite@do#1{%
    % Make sure this counter exists. Sometimes it might not when using, e.g:
    % refsection=chapter and \includeonly to put in the chapters or when
    % inserting citations into table of contents
  \blx@providecount{blx@sectionciteorder@\the\c@refsection}%
  \global\advance\csname blx@sectionciteorder@\the\c@refsection\endcsname\@ne
  \blx@nocitation{#1}\blx@msg@cundef}

% {&lt;macro&gt;}[&lt;arg1&gt;][&lt;arg2&gt;]{&lt;arg3&gt;}
% =&gt; &lt;macro&gt;{&lt;arg1&gt;}{&lt;arg2&gt;}{&lt;arg3&gt;}
\protected\def\blx@citeargs#1{%
  \@ifnextchar[%]
    {\blx@citeargs@i{#1}}
    {\blx@citeargs@iii{#1{}{}}}}
\long\def\blx@citeargs@i#1[#2]{%
  \@ifnextchar[%]
    {\blx@citeargs@ii{#1{#2}}}
    {\blx@citeargs@iii{#1{}{#2}}}}
\long\def\blx@citeargs@ii#1[#2]{%
  \blx@citeargs@iii{#1{#2}}}
\long\def\blx@citeargs@iii#1#2{%
  \blx@xsanitizeafter{#1}{#2}}

% {&lt;macro&gt;}(&lt;arg1&gt;)(&lt;arg2&gt;)
% =&gt; &lt;macro&gt;{&lt;arg1&gt;}{&lt;arg2&gt;}
\protected\def\blx@multiargs#1{%
  \@ifnextchar(%)
    {\blx@multiargs@i{#1}}
    {#1{}{}}}
\long\def\blx@multiargs@i#1(#2){%
  \@ifnextchar(%)
    {\blx@multiargs@ii{#1{#2}}}
    {#1{}{#2}}}
\long\def\blx@multiargs@ii#1(#2){#1{#2}}

% {&lt;macro&gt;}[&lt;arg1&gt;][&lt;arg2&gt;]{&lt;arg3&gt;}&lt;punct&gt;
% =&gt; &lt;macro&gt;{&lt;arg1&gt;}{&lt;arg2&gt;}{&lt;arg3&gt;}{&lt;punctcmd&gt;}
\protected\def\blx@citepunct#1{%
  \blx@citeargs{\blx@citepunct@i{#1}}}
\long\def\blx@citepunct@i#1#2#3#4{%
  \blx@thecheckpunct{#1{#2}{#3}{#4}}}

% {&lt;csname&gt;}[&lt;arg1&gt;][&lt;arg2&gt;]{arg3}[arg4]{arg5}&lt;punct&gt;
% =&gt; &lt;macro&gt;{&lt;arg1&gt;}{&lt;arg2&gt;}{&lt;arg3&gt;}{&lt;arg4&gt;}{arg5}{&lt;punctcmd&gt;}
\protected\def\blx@citexpunct#1{%
  \blx@citeargs{\blx@citexpunct@i{#1}}}
\long\def\blx@citexpunct@i#1#2#3#4{%
  \@ifnextchar[%]
    {\blx@citexpunct@ii{#1}{{#2}{#3}{#4}}}
    {\blx@citexpunct@ii{#1}{{#2}{#3}{#4}}[{#1}]}}
\long\def\blx@citexpunct@ii#1#2[#3]#4{%
  \blx@thecheckpunct{\blxcitecmd{#1}#2{#3}{#4}}}

% {&lt;code&gt;}&lt;punct&gt; =&gt; &lt;code&gt;{&lt;punctcmd&gt;}
\long\def\blx@checkpunct#1{%
  \begingroup
  \def\blx@tempa{\endgroup#1}%
  \futurelet\blx@tempb\blx@checkpunct@i}
\def\blx@checkpunct@i{%
  \expandafter\blx@checkpunct@ii\blx@autopunct&amp;}
\def\blx@checkpunct@ii#1{%
  \ifx#1&amp;%
    \expandafter\blx@checkpunct@iii
  \fi
  \ifx#1\blx@tempb
    \expandafter\blx@checkpunct@iv
  \fi
  \blx@checkpunct@ii}
\def\blx@checkpunct@iii#1\blx@checkpunct@ii{%
  \global\undef\abx@field@postpunct
  \blx@tempa{\blx@postpunct}}
\def\blx@checkpunct@iv#1\blx@checkpunct@ii#2&amp;#3{%
  \gdef\abx@field@postpunct{#3}%
  \edef\blx@tempa{%
    \expandonce\blx@tempa{%
    \ifcsdef{blx@pm@\detokenize{#3}}
      {\csname blx@imc@add\csname blx@pm@\detokenize{#3}\endcsname
       \endcsname}
      {\noexpand#3}}}%
  \blx@tempa}

\long\def\blx@nocheckpunct#1{#1{}}

\protected\def\blx@citeinit{%
  \iftoggle{blx@bibliography}
    {}
    {\toggletrue{blx@citation}}%
  \blx@blxinit
  \citesetup
  \blx@setsfcodes
  \blx@postpunct@agroup
  \blx@resetdata
  \blx@leavevmode
  \csuse{blx@hook@cite}%
  \csuse{blx@hook@cite@next}%
  \let\blx@citeinit\blx@resetdata}

\protected\def\blx@citecmdinit{%
  \blx@leavevmode@cite
  \iftoggle{blx@bibliography}
    {}
    {\blx@initunit}}

% *{&lt;command&gt;}[&lt;wrapper&gt;]{&lt;precode&gt;}{&lt;loopcode&gt;}{&lt;delimcode&gt;}{&lt;postcode&gt;}
\newrobustcmd*{\DeclareCiteCommand}{%
  \@ifstar{\blx@defcitecmd*}{\blx@defcitecmd{}}}

\def\blx@defcitecmd#1#2{%
  \begingroup
  \escapechar\m@ne
  \edef\blx@tempa{\endgroup
    \noexpand\blx@defcitecmd@i{#1}{\string#2}}%
  \blx@tempa}

\def\blx@defcitecmd@i#1#2{%
  \listadd\blx@citecmds{#2}%
  \blx@checkcitecmd{#2}{#1}%
  \protected\csdef{#2}{%
    \blx@citecmdinit
    \@ifstar
      {\blx@citepunct{\blxcitecmd{#2*}}}
      {\blx@citepunct{\blxcitecmd{#2}}}}%
  \@ifnextchar[%]
    {\blx@defcitecmd@iii{#2#1}}
    {\blx@defcitecmd@ii{#2#1}}}

\long\def\blx@defcitecmd@ii#1{%
  \csundef{blx@defcite@wrapper@#1}%
  \blx@defcitecmd@iv{#1}%
  \blx@defcitecmd@v{#1}}

\long\def\blx@defcitecmd@iii#1[#2]{%
  \csdef{blx@defcite@wrapper@#1}{#2}%
  \blx@defcitecmd@iv{#1}%
  \blx@defcitecmd@v{#1}}

\long\def\blx@defcitecmd@iv#1{%
  \protected\long\csedef{blx@cite@#1}##1##2##3##4{%
    \ifboolexpe{test {\ifcsundef{blx@defcite@wrapper@#1}}
                and
                (test {\ifcsundef{blx@citepunct@#1}}
                 or
                 test {\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}})}
      {}
      {\begingroup
       \blx@citeinit}%
    \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@l}
      {\noexpand\unspace##4}
      {}%
    \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@f}
      {\noexpand\iftoggle{blx@footnote}{}{\unspace##4}}
      {}%
    \ifcsundef{blx@defcite@wrapper@#1}
      {\blxciteicmd{#1}{##1}{##2}{##3}{%
         \ifcsundef{blx@citepunct@#1}{##4}{}%
         \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}{##4}{}}}
      {\csexpandonce{blx@defcite@wrapper@#1}{%
         \blxciteicmd{#1}{##1}{##2}{##3}{%
           \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}{##4}{}}}%
       \ifcsundef{blx@citepunct@#1}{##4}{}}%
    \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@r}{##4}{}%
    \ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@f}
      {\noexpand\iftoggle{blx@footnote}{##4}{}}
      {}%
    \ifboolexpe{test {\ifcsundef{blx@defcite@wrapper@#1}}
                and
                (test {\ifcsundef{blx@citepunct@#1}}
                 or
                 test {\ifcsequal{blx@citepunct@#1}{blx@citepunctid@pos@c}})}
      {}
      {\endgroup}}}

\long\def\blx@defcitecmd@v#1#2#3#4#5{%
  \protected\long\csdef{blx@citei@#1}##1##2##3##4{%
    \ifblank{##1}
      {}
      {\def\abx@field@prenote{##1}}%
    \ifblank{##2}
      {\let\blx@thenotecheck\relax}
      {\def\abx@field@postnote{##2}%
       \iftoggle{blx@volcite}
         {\blx@defvolcitepostnote##2}
         {}}%
    \def\blx@precode{\delimcontext{#1}#2}%
    \def\blx@loopcode{#3}%
    \def\blx@dlimcode{#4}%
    \def\blx@postcode{#5}%
    \def\blx@postpunct@saved{##4}%
    \blx@citeloop{##3}%
    \endgroup}}

% {&lt;type&gt;}{&lt;name&gt;}{*}
\def\blx@checkcitecmd#1#2{%
  \ifblank{#2}
    {\ifcsdef{blx@cite@#1}
       {\blx@info{Redefining '\@backslashchar#1'}}
       {\ifcsundef{#1}
          {}
          {\blx@warning@noline{Redefining '\@backslashchar#1'}}}%
     \ifcsdef{blx@cite@#1*}
       {}
       {\csedef{blx@cite@#1*}{%
          \expandafter\noexpand\csname blx@cite@#1\endcsname}%
        \csedef{blx@citei@#1*}{%
          \expandafter\noexpand\csname blx@citei@#1\endcsname}}}
    {\ifcsdef{blx@cite@#1}
       {}
       {\csdef{blx@cite@#1}{\blx@err@citecmd{#1}}%
        \csdef{blx@citei@#1}{\blx@err@citecmd{#1}}}}}

% {&lt;name&gt;}{prenote}{postnote}{citekey}{punct}
\newrobustcmd*{\blxcitecmd}[1]{%
  \ifcsundef{blx@cite@#1}
    {\blx@err@citecmd{#1}}
    {\csuse{blx@cite@#1}}}

\newrobustcmd*{\blxciteicmd}[1]{%
  \begingroup
  \blx@citeinit
  \ifcsundef{blx@citei@#1}
    {\blx@err@citecmd{#1}}
    {\csuse{blx@citei@#1}}}

% {&lt;multicitecount&gt;}{&lt;name&gt;}{prenote}{postnote}{citekey}{punct}
\protected\def\blxmciteicmd#1{%
  \c@multicitecount#1\relax
  \blxciteicmd}

% {&lt;multicitetotal&gt;}{&lt;multiprenote&gt;}{&lt;multipostnote&gt;}
\protected\def\blxmcites#1#2#3{%
  \begingroup
  \blx@citeinit
  \c@multicitecount\z@
  \c@multicitetotal#1\relax
  \ifnum\c@multicitetotal&gt;\@ne
    \let\blx@ifcitesingle\@secondoftwo
  \fi
  \csuse{blx@hook@mcite}%
  \csuse{blx@hook@mcite@next}%
  \ifblank{#2}%
    {}
    {\def\abx@field@multiprenote{#2}}%
  \ifblank{#3}%
    {}
    {\def\abx@field@multipostnote{#3}}%
  \usebibmacro{multiprenote}}

\protected\def\blxendmcites{%
  \usebibmacro{multipostnote}%
  \endgroup}

% {&lt;command&gt;}[&lt;wrapper&gt;]{&lt;cite&gt;}{&lt;delimiter&gt;}
\newrobustcmd{\DeclareMultiCiteCommand}[1]{%
  \ifundef#1%
    {}
    {\blx@info{Redefining '\string#1'}}%
  \@ifnextchar[%]
    {\blx@defmcitecmd{#1}}
    {\blx@defmcitecmd{#1}[\@firstofone]}}

\def\blx@defmcitecmd#1[#2]#3#4{%
  \begingroup
  \escapechar\m@ne
  \edef\blx@tempa{\endgroup
    \listadd\noexpand\blx@citecmds{\string#1}%
    \protected\def\noexpand#1{%
      \blx@citecmdinit
      \noexpand\@ifstar
        {\expandafter\noexpand
         \csname blx@mcite@\string#1\endcsname*%
         \expandafter\noexpand
         \csname blx@mcitei@\string#1\endcsname}
        {\expandafter\noexpand
         \csname blx@mcite@\string#1\endcsname{}%
         \expandafter\noexpand
         \csname blx@mcitei@\string#1\endcsname}}%
    \protected\csdef{blx@mcite@\string#1}####1####2{%
      \begingroup
      \blx@citeinit
      \noexpand\blx@multicite
        ####2%
        {\unexpanded{#2}}%
        {\string#3####1}%
        {\unexpanded{#4}}}%
    \protected\long\csdef{blx@mcitei@\string#1}%
  }%
  \blx@tempa##1##2##3{##1{##2}##3\endgroup}}

% {&lt;command&gt;}{&lt;wrapper&gt;}{&lt;citecmd&gt;}{&lt;delimiter&gt;} =&gt;
%  &lt;init&gt;&lt;command&gt;{&lt;wrapper&gt;}{&lt;cites&gt;}{&lt;punct&gt;}
\def\blx@multicite#1#2#3#4{%
  \begingroup
  \csuse{blx@hook@mcite@before}%
  \def\blx@tempa{#1}%
  \def\blx@tempb{#2}%
  \def\blx@tempc{#3}%
  \def\blx@tempd{#4}%
  \c@multicitetotal\z@
  \blx@multiargs\blx@multicite@i}

\def\blx@multicite@i#1#2{%
  \ifblank{#1}%
    {\let\abx@field@multiprenote\@empty}%
    {\def\abx@field@multiprenote{#1}}%
  \ifblank{#2}%
    {\let\abx@field@multipostnote\@empty}%
    {\def\abx@field@multipostnote{#2}}%
  \let\blx@tempe\@empty
  \let\blx@tempf\@empty
  \togglefalse{blx@tempa}%
  \blx@multiparse}

\def\blx@multicite@add#1#2#3{%
  \togglefalse{blx@tempa}%
  \advance\c@multicitetotal\@ne
  \eappto\blx@tempe{%
    \expandonce\blx@tempf
    \blxmciteicmd{\the\c@multicitetotal}%
    {\expandonce\blx@tempc}\unexpanded{{#1}{#2}{#3}}{}}%
  \let\blx@tempf\blx@tempd
  \blx@multiparse}

\def\blx@multicite@end#1{%
  \edef\blx@tempa{\endgroup
    \expandonce\blx@tempa
      {\expandonce\blx@tempb}%
      {\blxmcites
         {\the\c@multicitetotal}%
         {\expandonce\abx@field@multiprenote}%
         {\expandonce\abx@field@multipostnote}%
       \expandonce\blx@tempe
       \blxendmcites}%
      {#1}%
    \iftoggle{blx@tempa}{\relax\space}{}}%
  \blx@tempa}

\def\blx@multiparse{%
  \futurelet\@let@token\blx@multiparse@i}

\def\blx@multiparse@i{%
  \ifx\@let@token\relax
    \blx@multiparse@ii{\blx@multicite@end{}}%
  \fi
  \ifx\@let@token[%]
    \blx@multiparse@ii{\blx@citeargs\blx@multicite@add}%
  \fi
  \ifx\@let@token\bgroup
    \blx@multiparse@ii{\blx@citeargs\blx@multicite@add}%
  \fi
  \ifx\@let@token\@sptoken
    \blx@multiparse@ii\blx@multiparse@iii
  \fi
  \iftrue
    \iftoggle{blx@tempa}
      {\blx@multiparse@ii{\blx@multicite@end{}}}
      {\blx@multiparse@ii{\blx@thecheckpunct\blx@multicite@end}}%
  \fi
  &amp;}

\def\blx@multiparse@ii#1#2&amp;{\fi#1}
\csdef{blx@multiparse@iii} {\toggletrue{blx@tempa}\blx@multiparse}

% {&lt;name&gt;}[l|i|r]{&lt;cite&gt;}{&lt;multicite&gt;}
\newrobustcmd*{\DeclareAutoCiteCommand}[1]{%
  \ifcsundef{blx@acite@#1}
    {}
    {\blx@info{Redefining autocite command '#1'}}%
  \@ifnextchar[%]
    {\blx@defautocmd@i{#1}}
    {\blx@defautocmd@i{#1}[r]}}

\def\blx@defautocmd@i#1[#2]#3#4{%
  \begingroup
  \escapechar\m@ne
  \edef\blx@tempa{\endgroup
    \noexpand\blx@defautocmd@ii{#1}{#2}%
      {\string#3}{\string#4}}%
  \blx@tempa}

\def\blx@defautocmd@ii#1#2#3#4{%
  \protected\csedef{blx@acite@#1}{%
    \blx@citecmdinit
    \noexpand\@ifstar
      {\blx@citepunct{\expandafter\noexpand
       \csname blx@acitei@#1\endcsname*}}
      {\blx@citepunct{\expandafter\noexpand
       \csname blx@acitei@#1\endcsname{}}}}%
  \protected\csedef{blx@acitei@#1}##1##2##3##4##5{%
    \begingroup
    \blx@citeinit
    \if l#2\noexpand\unspace##5\fi
    \if f#2\noexpand\iftoggle{blx@footnote}{}{\unspace##5}\fi
    \blxcitecmd{#3##1}{##2}{##3}{##4}{}%
    \if r#2##5\fi
    \if f#2\noexpand\iftoggle{blx@footnote}{##5}{}\fi
    \endgroup}%
  \protected\csedef{blx@macite@#1}{%
    \blx@citecmdinit
    \noexpand\@ifstar
      {\expandafter\noexpand
       \csname blx@macitei@#1\endcsname*%
       \expandafter\noexpand
       \csname blx@maciteii@#1\endcsname}
      {\expandafter\noexpand
       \csname blx@macitei@#1\endcsname{}%
       \expandafter\noexpand
       \csname blx@maciteii@#1\endcsname}}%
  \csedef{blx@macitei@#1}{\csname blx@mcite@#4\endcsname}%
  \protected\csedef{blx@maciteii@#1}##1##2##3{%
    \if l#2\noexpand\unspace##3\fi
    \if f#2\noexpand\iftoggle{blx@footnote}{}{\unspace##3}\fi
    ##1{##2}%
    \if r#2##3\fi
    \if f#2\noexpand\iftoggle{blx@footnote}{##3}{}\fi
    \endgroup}}

% {&lt;characters&gt;}
\newrobustcmd*{\DeclareAutoPunctuation}[1]{%
  \ifblank{#1}
    {\let\blx@thecheckpunct\blx@nocheckpunct}
    {\let\blx@thecheckpunct\blx@checkpunct
     \def\blx@autopunct{#1}}}

% {&lt;command&gt;}{&lt;pos marker&gt;}
% pos markers are:
%   l: move punctuation before the command (i.e. left of it)
%   r: leave punctuation after the command (i.e. to the right)
%   f: like l in normal text, like r in footnotes
%   c: pass on to the cite command,
%      the punctuation will eventually end up as field 'postpunct'
%   d: discard the punctuation
%   o (or any other value): restores the old standard behaviour
%      r for wrapped citation commands,
%      c for unwrapped ones
\newrobustcmd*{\DeclareCitePunctuationPosition}[2]{%
  \begingroup
  \escapechar\m@ne
  \edef\blx@tempa{\endgroup
    \noexpand\blx@defcitepunctpos@i{\string#1}{#2}}%
  \blx@tempa}

\def\blx@citepunctid@pos@l{l}
\def\blx@citepunctid@pos@r{r}
\def\blx@citepunctid@pos@f{f}
\def\blx@citepunctid@pos@c{c}
\def\blx@citepunctid@pos@d{d}

\def\blx@defcitepunctpos@i#1#2{%
  \ifcsundef{blx@citepunctid@pos@#2}
    {\csundef{blx@citepunct@#1}}
    {\csletcs{blx@citepunct@#1}{blx@citepunctid@pos@#2}}%
  \blx@defcitecmd@iv{#1}}

\AfterEndPreamble{% babel
  \begingroup
  \makeatletter
  \endlinechar\m@ne
  \scantokens\expandafter{%
    \expandafter\gdef
    \expandafter\blx@autopunct
    \expandafter{\blx@autopunct}}%
  \endgroup}

\listadd\blx@citecmds{citename}
% [&lt;prenote&gt;][&lt;postnote&gt;]{&lt;entrykey&gt;,...}[&lt;format&gt;]{&lt;namelist&gt;}&lt;punct&gt;
\newrobustcmd*{\citename}{\blx@citexpunct{citename}}
\long\csdef{blx@cite@citename}#1#2#3#4#5#6{%
  \begingroup
  \blx@citecmdinit
  \blx@citeinit
  \ifblank{#1}
    {}
    {\def\abx@field@prenote{#1}}%
  \ifblank{#2}
    {\let\blx@thenotecheck\relax}
    {\def\abx@field@postnote{#2}}%
  \def\blx@precode{\usebibmacro{prenote}}%
  \def\blx@loopcode{%
    \ifnameundef{#5}
      {\blx@warning@entry{'#5' undefined or not a name list}%
       \abx@missing{#5}}
      {\printnames[{#4}]{#5}}}%
  \def\blx@dlimcode{\multicitedelim}%
  \def\blx@postpunct@saved{#6}%
  \ifblank{#2}
    {\let\blx@postcode\@empty}
    {\def\blx@postcode{\usebibmacro{postnote}}}%
  \boolfalse{citetracker}%
  \boolfalse{pagetracker}%
  \blx@citeloop{#3}%
  \endgroup}


\listadd\blx@citecmds{citelist}
% [&lt;prenote&gt;][&lt;postnote&gt;]{&lt;entrykey&gt;,...}[&lt;format&gt;]{&lt;list&gt;}&lt;punct&gt;
\newrobustcmd*{\citelist}{\blx@citexpunct{citelist}}
\long\csdef{blx@cite@citelist}#1#2#3#4#5#6{%
  \begingroup
  \blx@citecmdinit
  \blx@citeinit
  \ifblank{#1}
    {}
    {\def\abx@field@prenote{#1}}%
  \ifblank{#2}
    {\let\blx@thenotecheck\relax}
    {\def\abx@field@postnote{#2}}%
  \def\blx@precode{\usebibmacro{prenote}}%
  \def\blx@loopcode{%
    \iflistundef{#5}
      {\blx@warning@entry{'#5' undefined or not a literal list}%
       \abx@missing{#5}}
      {\printlist[{#4}]{#5}}}%
  \def\blx@dlimcode{\multicitedelim}%
  \def\blx@postpunct@saved{#6}%
  \ifblank{#2}
    {\let\blx@postcode\@empty}
    {\def\blx@postcode{\usebibmacro{postnote}}}%
  \boolfalse{citetracker}%
  \boolfalse{pagetracker}%
  \blx@citeloop{#3}%
  \endgroup}

\listadd\blx@citecmds{citefield}
% [&lt;prenote&gt;][&lt;postnote&gt;]{&lt;entrykey&gt;,...}[&lt;format&gt;]{&lt;field&gt;}&lt;punct&gt;

\newrobustcmd*{\citefield}{\blx@citexpunct{citefield}}
\long\csdef{blx@cite@citefield}#1#2#3#4#5#6{%
  \begingroup
  \blx@citecmdinit
  \blx@citeinit
  \ifblank{#1}
    {}
    {\def\abx@field@prenote{#1}}%
  \ifblank{#2}
    {\let\blx@thenotecheck\relax}
    {\def\abx@field@postnote{#2}}%
  \def\blx@precode{\usebibmacro{prenote}}%
  \def\blx@loopcode{%
    \iffieldundef{#5}
      {\blx@warning@entry{'#5' undefined or not a field}%
       \abx@missing{#5}}
      {\printfield[{#4}]{#5}}}%
  \def\blx@dlimcode{\multicitedelim}%
  \def\blx@postpunct@saved{#6}%
  \ifblank{#2}
    {\let\blx@postcode\@empty}
    {\def\blx@postcode{\usebibmacro{postnote}}}%
  \boolfalse{citetracker}%
  \boolfalse{pagetracker}%
  \blx@citeloop{#3}%
  \endgroup}

\renewrobustcmd*{\cite}{\blx@err@citecmd\cite}
\let\blx@cite@cite\relax
\newrobustcmd*{\parencite}{\blx@warn@citecmd\parencite\cite}
\let\blx@cite@parencite\relax
\newrobustcmd*{\footcite}{\blx@warn@citecmd\footcite\cite}
\let\blx@cite@footcite\relax
\newrobustcmd*{\footcitetext}{\blx@warn@citecmd\footcitetext\cite}
\let\blx@cite@footcitetext\relax
\newrobustcmd*{\smartcite}{\blx@warn@citecmd\smartcite\cite}
\let\blx@cite@smartcite\relax
\newrobustcmd*{\textcite}{\blx@warn@citecmd\textcite\cite}
\let\blx@cite@textcite\relax
\newrobustcmd*{\supercite}{\blx@warn@citecmd\supercite\cite}
\let\blx@cite@supercite\relax

%% ifthen interface

\def\blx@TE#1#2{%
  \TE@throw
  \unexpanded{%
    \iftrue\@nameuse{fi}%
    #1{\@nameuse{iftrue}}{\@nameuse{iffalse}}}#2}

\def\blx@xTE#1#2{%
  \TE@throw
  \unexpanded{\iftrue\@nameuse{fi}}%
  #1\unexpanded{{\@nameuse{iftrue}}{\@nameuse{iffalse}}}#2}

\let\blx@TE@hook\@empty

\appto\blx@blxinit{%
  \appto\blx@TE@hook{%
    \def\ifhyperref{\blx@TE\blx@imc@ifhyperref}%
    \def\ifmorenames{\blx@TE\blx@imc@ifmorenames}%
    \def\ifmoreitems{\blx@TE\blx@imc@ifmoreitems}%
    \def\iffirstcitekey{\blx@TE\blx@imc@iffirstcitekey}%
    \def\iflastcitekey{\blx@TE\blx@imc@iflastcitekey}%
    \def\ifciteseen{\blx@TE\blx@imc@ifciteseen}%
    \def\ifentryseen{\blx@TE\blx@imc@ifentryseen}%
    \def\ifentryinbib{\blx@TE\blx@imc@ifentryinbib}%
    \def\ifciteibid{\blx@TE\blx@imc@ifciteibid}%
    \def\ifciteidem{\blx@TE\blx@imc@ifciteidem}%
    \def\ifopcit{\blx@TE\blx@imc@ifopcit}%
    \def\ifloccit{\blx@TE\blx@imc@ifloccit}%
    \def\ifsamepage{\blx@TE\blx@imc@ifsamepage}%
    \def\iffirstonpage{\blx@TE\blx@imc@iffirstonpage}%
    \def\ifcurrentfield#1{\blx@TE{\blx@imc@ifcurrentfield{#1}}}%
    \def\ifcurrentlist#1{\blx@TE{\blx@imc@ifcurrentlist{#1}}}%
    \def\ifcurrentname#1{\blx@TE{\blx@imc@ifcurrentname{#1}}}%
    \def\ifentrytype#1{\blx@TE{\blx@imc@ifentrytype{#1}}}%
    \def\iffieldequalcs#1#2{\blx@TE{\blx@imc@iffieldequalcs{#1}{#2}}}%
    \def\iffieldequals#1#2{\blx@TE{\blx@imc@iffieldequals{#1}{#2}}}%
    \def\iffieldequalstr#1#2{\blx@TE{\blx@imc@iffieldequalstr{#1}{#2}}}%
    \def\iffieldsequal#1#2{\blx@TE{\blx@imc@iffieldsequal{#1}{#2}}}%
    \def\iflistequalcs#1#2{\blx@TE{\blx@imc@iflistequalcs{#1}{#2}}}%
    \def\iflistequals#1#2{\blx@TE{\blx@imc@iflistequals{#1}{#2}}}%
    \def\iflistsequal#1#2{\blx@TE{\blx@imc@iflistsequal{#1}{#2}}}%
    \def\ifbibmacroundef#1{\blx@TE{\blx@imc@ifbibmacroundef{#1}}}%
    \def\iffieldundef#1{\blx@TE{\blx@imc@iffieldundef{#1}}}%
    \def\ifnameequalcs#1#2{\blx@TE{\blx@imc@ifnameequalcs{#1}{#2}}}%
    \def\ifnameequals#1#2{\blx@TE{\blx@imc@ifnameequals{#1}{#2}}}%
    \def\ifnamesequal#1#2{\blx@TE{\blx@imc@ifnamesequal{#1}{#2}}}%
    \def\ifnameundef#1{\blx@TE{\blx@imc@ifnameundef{#1}}}%
    \def\ifcategory#1{\blx@TE{\blx@imc@ifcategory{#1}}}%
    \def\ifkeyword#1{\blx@TE{\blx@imc@ifkeyword{#1}}}%
    \def\ifentrycategory#1#2{\blx@TE{\blx@imc@ifentrycategory{#1}{#2}}}%
    \def\ifentrykeyword#1#2{\blx@TE{\blx@imc@ifentrykeyword{#1}{#2}}}%
    \def\ifcapital{\blx@TE\blx@imc@ifcapital}%
    \def\ifinteger#1{\blx@TE{\blx@imc@ifinteger{#1}}}%
    \def\iffieldint#1{\blx@TE{\blx@imc@iffieldint{#1}}}%
    \def\ifnumeral#1{\blx@TE{\blx@imc@ifnumeral{#1}}}%
    \def\ifnumerals#1{\blx@TE{\blx@imc@ifnumerals{#1}}}%
    \def\ifpages#1{\blx@TE{\blx@imc@ifpages{#1}}}%
    \def\iffieldnum#1{\blx@TE{\blx@imc@iffieldnum{#1}}}%
    \def\iffieldnums#1{\blx@TE{\blx@imc@iffieldnums{#1}}}%
    \def\iffieldpages#1{\blx@TE{\blx@imc@iffieldpages{#1}}}%
    \def\ifbibstring#1{\blx@TE{\blx@imc@ifbibstring{#1}}}%
    \def\iffieldbibstring#1{\blx@TE{\blx@imc@iffieldbibstring{#1}}}%
    \def\ifnatbibmode{\blx@TE{\iftoggle{blx@natbib}}}%
    \def\ifcitation{\blx@TE{\iftoggle{blx@citation}}}%
    \def\ifvolcite{\blx@TE{\iftoggle{blx@volcite}}}%
    \def\ifbibliography{\blx@TE{\iftoggle{blx@bibliography}}}%
    \def\ifciteindex{\blx@TE{\iftoggle{blx@citeindex}}}%
    \def\ifbibindex{\blx@TE{\iftoggle{blx@bibindex}}}%
    \def\iffootnote{\blx@TE{\iftoggle{blx@footnote}}}%
    \def\ifuseprefix{\blx@TE{\iftoggle{blx@useprefix}}}%
    \def\ifterseinits{\blx@TE{\iftoggle{blx@terseinits}}}%
    \def\ifsingletitle{\blx@TE{\iftoggle{abx@bool@singletitle}}}%
    \def\ifnocite{\blx@TE{\iftoggle{abx@bool@nocite}}}%
    \def\ifuniquetitle{\blx@TE{\iftoggle{abx@bool@uniquetitle}}}%
    \def\ifuniquebaretitle{\blx@TE{\iftoggle{abx@bool@uniquebaretitle}}}%
    \def\ifuniquework{\blx@TE{\iftoggle{abx@bool@uniquework}}}%
    \def\ifuniqueprimaryauthor{\blx@TE{\iftoggle{abx@bool@uniqueprimaryauthor}}}%
    \def\ifandothers#1{\blx@TE{\iftoggle{abx@bool@more#1}}}%
    \def\iflabeldateisdate{\blx@TE\blx@imc@iflabeldateisdate}%
    \def\ifdatehasyearonlyprecision#1{%
      \blx@TE{\blx@imc@ifdatehasyearonlyprecision{#1}}}%
    \def\ifdatehastime#1{\blx@TE{\blx@imc@ifdatehastime{#1}}}%
    \def\ifdateshavedifferentprecision#1#2{%
      \blx@TE{\blx@imc@ifdateshavedifferentprecision{#1}{#2}}}%
    \def\ifdateyearsequal#1#2{%
      \blx@TE{\blx@imc@ifdateyearsequal{#1}{#2}}}}}

% {&lt;listmacro&gt;}{&lt;filtercsname&gt;} =&gt; matches in &lt;listmacro&gt;
\protected\def\blx@bibfilter#1#2{%
  \begingroup
  \edef\blx@do##1{%
    \def\noexpand\blx@flt@item{##1}%
    \ifboolexpr{\csexpandonce{#2}}%
      {\listadd\noexpand\blx@tempa{##1}}%
      {}}%
  \let\blx@done\relax
  \edef\blx@tempa{%
    \let\noexpand\blx@tempa\noexpand\@empty
    \blx@listloop{#1}}%
  \blx@tempa
  \edef\blx@tempa{\endgroup
    \def\noexpand#1{\blx@tempa}}%
  \blx@tempa}

%% Auxiliary macros
\newrobustcmd*{\mkbibquote}{\blx@enquote}
\protected\def\blx@imc@mkbibquote{%
  \blx@ifuspunct\blx@usquote\blx@enquote}

\def\blx@usquote{%
  \ifnum\@quotelevel&gt;\z@
    \expandafter\blx@usiquote
  \else
    \expandafter\blx@usoquote
  \fi}

\long\def\blx@usoquote#1{%
  \begingroup
  \blx@initoquote
  \blx@textooquote#1%
  \futurelet\@let@token\blx@usoquote@i}

\def\blx@usoquote@i{%
  \blx@usqcheck
    {\ifx\blx@postpunct\@empty\else\blx@dopostpunct\fi
     \blx@textcoquote\endgroup}
    {\blx@setpostpunct\blx@textcoquote\endgroup}}

\long\def\blx@usiquote#1{%
  \begingroup
  \blx@initiquote
  \blx@textoiquote#1%
  \futurelet\@let@token\blx@usiquote@i}

\def\blx@usiquote@i{%
  \blx@usqcheck
    {\blx@textciquote\endgroup}
    {\blx@setpostpunct\blx@textciquote\endgroup}}

\long\def\blx@usqcheck#1#2{%
  \def\blx@tempa{#1}%
  \def\blx@tempb{#2}%
  \ifx\@let@token\space
    \blx@usqcheck@i\blx@tempa
  \fi
  \ifx\@let@token\@sptoken
    \blx@usqcheck@i\blx@tempa
  \fi
  \if\noexpand\@let@token\relax
    \expandafter\blx@usqcheck@iv
  \fi
  \expandafter\blx@usqcheck@ii\blx@quotepunct\relax&amp;}

\long\def\blx@usqcheck@i#1#2&amp;{\fi#1}

\long\def\blx@usqcheck@ii#1{%
  \if\noexpand#1\relax
    \blx@usqcheck@i\blx@tempa
  \fi
  \if\noexpand#1\noexpand\@let@token
    \blx@usqcheck@i{\blx@usqcheck@iii\blx@tempa}%
  \fi
  \blx@usqcheck@ii
}

\long\def\blx@usqcheck@iii#1#2{#2#1}

\long\def\blx@usqcheck@iv#1&amp;#2{%
  \begingroup
    \escapechar=-1 %
    \edef\blx@tempa{\expandafter\@gobble\string#2}%
    \expandafter\endgroup
    \ifx\blx@tempa\@empty
    \else
      \blx@usqcheck@i\blx@tempb
    \fi
    #1&amp;#2%
}

\newrobustcmd*{\mkbibemph}{\emph}
\protected\long\def\blx@imc@mkbibemph#1{%
  \emph{#1}\blx@imc@setpunctfont\emph}

\newrobustcmd*{\mkbibbold}{\textbf}
\protected\long\def\blx@imc@mkbibbold#1{%
  \textbf{#1}\blx@imc@setpunctfont\textbf}

\newrobustcmd*{\mkbibitalic}{\textit}
\protected\long\def\blx@imc@mkbibitalic#1{%
  \textit{#1}\blx@imc@setpunctfont\textit}

\blx@regimcs{\mkbibquote \mkbibemph \mkbibbold \mkbibitalic}

\newcommand*{\bibleftparen}{\blx@postpunct(}
\newcommand*{\bibrightparen}{\blx@postpunct)\midsentence}
\newcommand*{\bibleftbracket}{\blx@postpunct[}
\newcommand*{\bibrightbracket}{\blx@postpunct]\midsentence}

\def\blx@parenlevel{%
  \iftoggle{blx@footnote}
    {\blx@parenlevel@foot}
    {\blx@parenlevel@text}}

\newrobustcmd*{\blx@bibopenparen}{%
  \blx@opencheck\bibopenparen
  \blx@postpunct
  \ifnum\blx@parenlevel=\z@
    \global\blx@parenlevel\@ne
    \global\c@parenlevel\@ne
    \expandafter\bibleftparen
  \else
    \expandafter\blx@openparen
  \fi}

\newrobustcmd*{\blx@bibopenbracket}{%
  \blx@opencheck\bibopenbracket
  \blx@postpunct
  \ifnum\blx@parenlevel=\z@
    \global\blx@parenlevel1002
    \global\c@parenlevel\@ne
    \expandafter\bibleftbracket
  \else
    \expandafter\blx@openparen
  \fi}

\newrobustcmd*{\blx@bibcloseparen}{%
  \blx@closecheck\bibcloseparen
  \blx@postpunct\blx@closeparen}

\newrobustcmd*{\blx@bibclosebracket}{%
  \blx@closecheck\bibclosebracket
  \blx@postpunct\blx@closeparen}

\def\blx@openparen{%
  \ifodd\blx@parenlevel
    \global\advance\blx@parenlevel\@ne
    \global\advance\c@parenlevel\@ne
    \expandafter\bibleftbracket
  \else
    \global\advance\blx@parenlevel\@ne
    \global\advance\c@parenlevel\@ne
    \expandafter\bibleftparen
  \fi}

\def\blx@closeparen{%
  \ifodd\blx@parenlevel
    \blx@closeparen@i
    \expandafter\bibrightparen
  \else
    \blx@closeparen@i
    \expandafter\bibrightbracket
  \fi}

\def\blx@closeparen@i{%
  \ifnum\blx@parenlevel=1002
    \global\blx@parenlevel\z@
    \global\c@parenlevel\z@
  \else
    \global\advance\blx@parenlevel\m@ne
    \global\advance\c@parenlevel\m@ne
  \fi}

\def\blx@opencheck#1{%
  \ifnum\numexpr\blx@parenlevel+\@ne
    \ifnum\blx@parenlevel&gt;\@m -1001\fi
  &gt;\c@maxparens
    \blx@err@nestparen{\string#1}%
    \blx@errormark
  \fi}

\def\blx@closecheck#1{%
  \ifnum\numexpr\blx@parenlevel
    \ifnum\blx@parenlevel&gt;\@m -1001\fi
  &gt;\c@maxparens
    \blx@err@nestparen{\string#1}%
    \blx@errormark
  \fi
  \ifnum\blx@parenlevel&lt;\@ne
    \blx@err@matchparen{Unmatched \string#1}%
    \blx@errormark
  \fi}

\protected\def\blx@errormark{%
  \rule[0.25ex]{1.25ex}{1.25ex}}

\blx@AtEndDocument{%
  \unless\ifnum\blx@parenlevel@text=\z@
    \blx@err@matchparen{%
      Unbalanced parentheses or brackets in the document body}%
  \fi
  \unless\ifnum\blx@parenlevel@foot=\z@
    \blx@err@matchparen{%
      Unbalanced parentheses or brackets in a foot or endnote}%
  \fi}

\newrobustcmd{\mkbibparens}[1]{%
  \begingroup
  \blx@blxinit
  \blx@setsfcodes
  \bibopenparen#1\bibcloseparen
  \endgroup}

\newrobustcmd{\mkbibbrackets}[1]{%
  \begingroup
  \blx@blxinit
  \blx@setsfcodes
  \bibopenbracket#1\bibclosebracket
  \endgroup}

\newrobustcmd*{\parentext}{\mkbibparens}
\newrobustcmd*{\brackettext}{\mkbibbrackets}

\newrobustcmd{\mkbibsuperscript}[1]{%
  \unspace\allowhyphens\textsuperscript{%
    \begingroup
    \protected\long\def\mkbibsuperscript##1{%
      \blx@warning{Nested superscript}%
      \mkbibbrackets{##1}}%
    #1\endgroup}}

\newrobustcmd{\mkbibfootnote}{\blx@mkbibfootnote{}}
\newrobustcmd{\mkbibfootnotetext}{\blx@mkbibfootnote{text}}
\newrobustcmd{\blx@mkbibfootnote}[2]{%
  \iftoggle{blx@footnote}
    {\blx@warning{Nested notes}%
     \addspace\mkbibparens{#2}}
    {\unspace
     \ifnum\blx@notetype=\tw@
       \expandafter\@firstoftwo
     \else
       \expandafter\@secondoftwo
     \fi
       {\csuse{blx@theendnote#1}{\protecting{\blxmkbibnote{end}{#2}}}}
       {\csuse{footnote#1}{\protecting{\blxmkbibnote{foot}{#2}}}}}}

\newrobustcmd{\mkbibendnote}{\blx@mkbibendnote{}}
\newrobustcmd{\mkbibendnotetext}{\blx@mkbibendnote{text}}
\newrobustcmd{\blx@mkbibendnote}[2]{%
  \iftoggle{blx@footnote}
    {\blx@warning{Nested notes}%
     \addspace\mkbibparens{#2}}
    {\unspace
     \ifnum\blx@notetype=\@ne
       \expandafter\@firstoftwo
     \else
       \expandafter\@secondoftwo
     \fi
       {\csuse{footnote#1}{\protecting{\blxmkbibnote{foot}{#2}}}}
       {\csuse{blx@theendnote#1}{\protecting{\blxmkbibnote{end}{#2}}}}}}

\newrobustcmd{\blxmkbibnote}[2]{%
  \begingroup
  \blx@blxinit
  \blx@setsfcodes
  \blx@postpunct@agroup
  \toggletrue{blx@footnote}%
  \csuse{bib#1notewrapper}{#2}%
  \endgroup}

\newcommand{\bibfootnotewrapper}[1]{%
  \bibsentence#1\addperiod}

\newcommand{\bibendnotewrapper}[1]{%
  \bibsentence#1\addperiod}

\AtEndPreamble{%
  \def\blx@theendnote{\blx@err@endnote\footnote}%
  \def\blx@theendnotetext{\blx@err@endnote\footnotetext}%
  \ifdef\endnote
    {\def\blx@theendnote{\endnote}%
     \ifdef\endnotetext
       {\def\blx@theendnotetext{\endnotetext}}
       {}}
    {\ifdef\pagenote
       {\def\blx@theendnote{\pagenote}%
        \ifdef\pagenotetext
          {\def\blx@theendnotetext{\pagenotetext}}
          {}}
       {}}}

\newrobustcmd*{\mknumalph}[1]{%
  \begingroup
  \blx@tempcnta=#1\relax
  \ifnum\blx@tempcnta&gt;702 %
  \else
    \ifnum\blx@tempcnta&gt;26 %
      \advance\blx@tempcnta\m@ne
      \divide\blx@tempcnta26\relax
      \blx@numalph\blx@tempcnta
      \multiply\blx@tempcnta26\relax
      \blx@tempcnta=\numexpr#1-\blx@tempcnta\relax
    \fi
  \fi
  \blx@numalph\blx@tempcnta
  \endgroup}
\def\blx@numalph#1{%
  \ifcase#1\relax\blx@warning@entry{Value out of range}\number#1\or
  a\or b\or c\or d\or e\or f\or g\or h\or i\or j\or k\or l\or m\or
  n\or o\or p\or q\or r\or s\or t\or u\or v\or w\or x\or y\or z\else
  \blx@warning@entry{Value out of range}\number#1\fi}

% {&lt;macro&gt;}[&lt;pre&gt;]{&lt;vol&gt;}[&lt;post&gt;] =&gt; &lt;macro&gt;{&lt;pre&gt;}{{&lt;vol&gt;}{&lt;post&gt;}}

\newrobustcmd*{\volcitecmd}{%
  \AtNextCite{%
    \toggletrue{blx@volcite}%
    \csuse{blx@hook@volcite}}%
  \begingroup\let\blx@citeargs\blx@volciteargs}

\protected\def\blx@volciteargs#1{%
  \endgroup
  \@ifnextchar[%]
    {\blx@volciteargs@i{#1}}
    {\blx@volciteargs@i{#1}[]}}

\long\def\blx@volciteargs@i#1[#2]#3{%
  \@ifnextchar[%]
    {\blx@volciteargs@ii{#1}{#2}{#3}}
    {\blx@citeargs@iii{#1{#2}{{#3}{}}}}}

\long\def\blx@volciteargs@ii#1#2#3[#4]{%
  \blx@citeargs@iii{#1{#2}{{#3}{#4}}}}

\newrobustcmd*{\multivolcitecmd}{%
  \AtNextCite{%
    \toggletrue{blx@volcite}%
    \csuse{blx@hook@volcite}}%
  \def\blx@hook@mcite@before{%
    \global\undef\blx@hook@mcite@before
    \let\blx@citeargs\blx@volmciteargs}}

\protected\def\blx@volmciteargs#1{%
  \@ifnextchar[%]
    {\blx@volciteargs@i{#1}}
    {\blx@volciteargs@i{#1}[]}}

\long\def\blx@defvolcitepostnote#1#2{%
  \def\abx@field@volcitevolume{#1}%
  \ifblank{#2}
    {}
    {\def\abx@field@volcitepages{#2}}}

\newrobustcmd*{\AtVolcite}{%
  \@ifstar
    {\global\undef\blx@hook@volcite
     \gappto\blx@hook@volcite}
    {\gappto\blx@hook@volcite}}
\@onlypreamble\AtVolcite
\def\blx@imc@UseVolciteHook{\csuse{blx@hook@volcite}}
\blx@regimcs{\UseVolciteHook}

\AtVolcite{%
  \DeclareFieldAlias{postnote}{volcitenote}}

%% Control file

\begingroup
\let~\space
\@makeother\&lt;
\@makeother\&gt;
\@makeother\.
\@makeother\:
\@makeother\?
\@makeother\"
\@makeother\-
\@makeother\=
\@makeother\/
\xdef\blx@xml@file{%
  \blx@sig@bcf\blx@nl
  \blx@ver@bcf\blx@nl}
\xdef\blx@xml@endfile{%
  &lt;/bcf:controlfile&gt;}
\xdef\blx@xml@comment#1{%
  ~~&lt;!-- #1 --&gt;\blx@nl}
\xdef\blx@xml@options#1#2#3{%
  ~~&lt;bcf:options%
    \noexpand\ifblank{#1}{}{ component="#1"}%
    \noexpand\ifblank{#2}{}{ type="#2"}%
  &gt;\blx@nl
  #3%
  ~~&lt;/bcf:options&gt;\blx@nl}
\xdef\blx@xml@option#1#2{%
  ~~~~&lt;bcf:option type="#1"&gt;\blx@nl
  #2%
  ~~~~&lt;/bcf:option&gt;\blx@nl}
\xdef\blx@xml@ordered#1#2#3{%
  ~~~~~~&lt;bcf:value order="#1"#2%
  &gt;#3&lt;/bcf:value&gt;\blx@nl}

\xdef\blx@xml@datafieldset#1#2{%
  ~~&lt;bcf:datafieldset name="#1"&gt;\blx@nl
  #2%
  ~~&lt;/bcf:datafieldset&gt;\blx@nl}

\xdef\blx@xml@datafieldsets@member#1{%
  ~~~~&lt;bcf:member#1/&gt;\blx@nl}

\xdef\blx@xml@transliteration#1#2{%
  ~~&lt;bcf:transliteration entrytype="#1"&gt;\blx@nl
  #2%
  ~~&lt;/bcf:transliteration&gt;\blx@nl}
\xdef\blx@xml@translit#1#2#3#4{%
  ~~~~&lt;bcf:translit #1target="#2" from="#3" to="#4"/&gt;\blx@nl}

\xdef\blx@xml@sourcemap#1{%
  ~~&lt;bcf:sourcemap&gt;\blx@nl
  #1%
  ~~&lt;/bcf:sourcemap&gt;\blx@nl}
\xdef\blx@xml@sourcemap@maps#1#2{%
  ~~~~&lt;bcf:maps#1&gt;\blx@nl
  #2%
  ~~~~&lt;/bcf:maps&gt;\blx@nl}
\xdef\blx@xml@sourcemap@map#1#2{%
  ~~~~~~&lt;bcf:map#1&gt;\blx@nl
  #2%
  ~~~~~~&lt;/bcf:map&gt;\blx@nl}
\xdef\blx@xml@sourcemap@perdatasource#1{%
  ~~~~~~~~&lt;bcf:per\string_datasource&gt;#1&lt;/bcf:per\string_datasource&gt;\blx@nl}
\xdef\blx@xml@sourcemap@pertype#1{%
  ~~~~~~~~&lt;bcf:per\string_type&gt;#1&lt;/bcf:per\string_type&gt;\blx@nl}
\xdef\blx@xml@sourcemap@pernottype#1{%
  ~~~~~~~~&lt;bcf:per\string_nottype&gt;#1&lt;/bcf:per\string_nottype&gt;\blx@nl}
\xdef\blx@xml@sourcemap@step#1{%
  ~~~~~~~~&lt;bcf:map\string_step#1/&gt;\blx@nl}

\xdef\blx@xml@labelalphanametemplate#1#2{%
  ~~&lt;bcf:labelalphanametemplate name="#1"&gt;\blx@nl
  #2%
  ~~&lt;/bcf:labelalphanametemplate&gt;\blx@nl}
\xdef\blx@xml@labelalphanametemplatenamepart#1#2#3{%
  ~~~~&lt;bcf:namepart #1#2&gt;#3&lt;/bcf:namepart&gt;\blx@nl}

\xdef\blx@xml@labelalphatemplate#1#2{%
  ~~&lt;bcf:labelalphatemplate type="#1"&gt;\blx@nl
  #2%
  ~~&lt;/bcf:labelalphatemplate&gt;\blx@nl}
\xdef\blx@xml@labelalpha@element#1#2{%
  ~~~~&lt;bcf:labelelement order="#1"&gt;\blx@nl
  #2%
  ~~~~&lt;/bcf:labelelement&gt;\blx@nl}
\xdef\blx@xml@labelalpha@part#1#2{%
  ~~~~~~&lt;bcf:labelpart#1&gt;#2&lt;/bcf:labelpart&gt;\blx@nl}

\xdef\blx@xml@extradate#1{%
  ~~&lt;bcf:extradatespec&gt;\blx@nl
  #1%
  ~~&lt;/bcf:extradatespec&gt;\blx@nl}
\xdef\blx@xml@extradatescope#1{%
  ~~~~&lt;bcf:scope&gt;\blx@nl
  #1%
  ~~~~&lt;/bcf:scope&gt;\blx@nl}
\xdef\blx@xml@edordered#1#2{%
  ~~~~~~&lt;bcf:field order="#1"&gt;#2&lt;/bcf:field&gt;\blx@nl}

\xdef\blx@xml@inheritance#1{%
  ~~&lt;bcf:inheritance&gt;\blx@nl
  #1%
  ~~&lt;/bcf:inheritance&gt;\blx@nl}
\xdef\blx@xml@inherit@defaults#1#2{%
  ~~~~&lt;bcf:defaults#1&gt;\blx@nl
  #2%
  ~~~~&lt;/bcf:defaults&gt;\blx@nl}
\xdef\blx@xml@inherit@data#1#2{%
  ~~~~&lt;bcf:inherit#1&gt;\blx@nl
  #2%
  ~~~~&lt;/bcf:inherit&gt;\blx@nl}
\xdef\blx@xml@inherit@type#1#2#3{%
  ~~~~~~&lt;bcf:type\string_pair source="#1" target="#2"#3/&gt;\blx@nl}
\xdef\blx@xml@inherit@field#1#2#3{%
  ~~~~~~&lt;bcf:field source="#1" target="#2"#3/&gt;\blx@nl}
\xdef\blx@xml@inherit@block#1{%
  ~~~~~~&lt;bcf:field source="#1" skip="true"/&gt;\blx@nl}

\xdef\blx@xml@nosorts#1{%
  ~~&lt;bcf:nosorts&gt;\blx@nl
  #1%
  ~~&lt;/bcf:nosorts&gt;\blx@nl}
\xdef\blx@xml@nosort#1#2{%
  ~~~~&lt;bcf:nosort field="#1" value="#2"/&gt;\blx@nl}

\xdef\blx@xml@nonamestrings#1{%
  ~~&lt;bcf:nonamestrings&gt;\blx@nl
  #1%
  ~~&lt;/bcf:nonamestrings&gt;\blx@nl}
\xdef\blx@xml@nonamestring#1#2{%
  ~~~~&lt;bcf:nonamestring field="#1" value="#2"/&gt;\blx@nl}

\xdef\blx@xml@noinits#1{%
  ~~&lt;bcf:noinits&gt;\blx@nl
  #1%
  ~~&lt;/bcf:noinits&gt;\blx@nl}
\xdef\blx@xml@noinit#1{%
  ~~~~&lt;bcf:noinit value="#1"/&gt;\blx@nl}

\xdef\blx@xml@nolabels#1{%
  ~~&lt;bcf:nolabels&gt;\blx@nl
  #1%
  ~~&lt;/bcf:nolabels&gt;\blx@nl}
\xdef\blx@xml@nolabel#1{%
  ~~~~&lt;bcf:nolabel value="#1"/&gt;\blx@nl}

\xdef\blx@xml@nolabelwidthcounts#1{%
  ~~&lt;bcf:nolabelwidthcounts&gt;\blx@nl
  #1%
  ~~&lt;/bcf:nolabelwidthcounts&gt;\blx@nl}
\xdef\blx@xml@nolabelwidthcount#1{%
  ~~~~&lt;bcf:nolabelwidthcount value="#1"/&gt;\blx@nl}

\xdef\blx@xml@uniquenametemplate#1#2{%
  ~~&lt;bcf:uniquenametemplate name="#1"&gt;\blx@nl%
  #2%
  ~~&lt;/bcf:uniquenametemplate&gt;\blx@nl}

\xdef\blx@xml@uniquenametemplatenamepart#1#2#3{%
  ~~~~&lt;bcf:namepart #1#2&gt;#3&lt;/bcf:namepart&gt;\blx@nl}

\xdef\blx@xml@namehashtemplate#1#2{%
  ~~&lt;bcf:namehashtemplate name="#1"&gt;\blx@nl%
  #2%
  ~~&lt;/bcf:namehashtemplate&gt;\blx@nl}

\xdef\blx@xml@namehashtemplatenamepart#1#2#3{%
  ~~~~&lt;bcf:namepart #1#2&gt;#3&lt;/bcf:namepart&gt;\blx@nl}

\xdef\blx@xml@sortingnamekeytemplate#1#2#3{%
  ~~&lt;bcf:sortingnamekeytemplate name="#1" visibility="#2"&gt;\blx@nl%
  #3%
  ~~&lt;/bcf:sortingnamekeytemplate&gt;\blx@nl}

\xdef\blx@xml@sortingnamekeykeypart#1#2{%
  ~~~~&lt;bcf:keypart#1&gt;\blx@nl
  #2%
  ~~~~&lt;/bcf:keypart&gt;\blx@nl}

\xdef\blx@xml@sortingnamekeynamepart#1#2#3{%
  ~~~~~~&lt;bcf:part type="namepart"#1#2&gt;#3&lt;/bcf:part&gt;\blx@nl}

\xdef\blx@xml@sortingnamekeyliteral#1#2{%
  ~~~~~~&lt;bcf:part type="literal"#1&gt;#2&lt;/bcf:part&gt;\blx@nl}

\xdef\blx@xml@sortingtemplate#1#2#3{%
  ~~&lt;bcf:sortingtemplate name="#1"#2&gt;\blx@nl%
  #3%
  ~~&lt;/bcf:sortingtemplate&gt;\blx@nl}
\xdef\blx@xml@presort#1#2{%
  ~~&lt;bcf:presort\noexpand\ifblank{#1}{}{ type="#1"}&gt;%
  #2&lt;/bcf:presort&gt;\blx@nl}

\xdef\blx@xml@sortexclude#1#2{%
  ~~&lt;bcf:sortexclusion\noexpand\ifblank{#1}{}{ type="#1"}&gt;\blx@nl
  #2%
  ~~&lt;/bcf:sortexclusion&gt;\blx@nl}
\xdef\blx@xml@exclude#1{%
  ~~~~&lt;bcf:exclusion&gt;#1&lt;/bcf:exclusion&gt;\blx@nl}
\xdef\blx@xml@sortinclude#1#2{%
  ~~&lt;bcf:sortinclusion\noexpand\ifblank{#1}{}{ type="#1"}&gt;\blx@nl
  #2%
  ~~&lt;/bcf:sortinclusion&gt;\blx@nl}
\xdef\blx@xml@include#1{%
  ~~~~&lt;bcf:inclusion&gt;#1&lt;/bcf:inclusion&gt;\blx@nl}
\xdef\blx@xml@sort#1#2{%
  ~~~~&lt;bcf:sort #1&gt;\blx@nl
  #2%
  ~~~~&lt;/bcf:sort&gt;\blx@nl}
\xdef\blx@xml@sortitem#1#2{%
  ~~~~~~&lt;bcf:sortitem #1&gt;#2&lt;/bcf:sortitem&gt;\blx@nl}
\xdef\blx@xml@section#1{%
  ~~&lt;bcf:section number="#1"&gt;}
\xdef\blx@xml@endsection{%
  ~~&lt;/bcf:section&gt;}

\xdef\blx@xml@dlist@refcontext#1#2#3#4#5#6{%
  ~~~~~~~~~~~~~~~~sortingtemplatename="#1"\blx@nl
  ~~~~~~~~~~~~~~~~sortingnamekeytemplatename="#2"\blx@nl
  ~~~~~~~~~~~~~~~~labelprefix="#3"\blx@nl
  ~~~~~~~~~~~~~~~~uniquenametemplatename="#4"\blx@nl
  ~~~~~~~~~~~~~~~~labelalphanametemplatename="#5"\blx@nl
  ~~~~~~~~~~~~~~~~namehashtemplatename="#6"}
\xdef\blx@xml@dlist#1#2#3#4#5{%
  ~~&lt;bcf:datalist section="#3"\blx@nl
  ~~~~~~~~~~~~~~~~name="#1"\blx@nl
  ~~~~~~~~~~~~~~~~type="#2"\blx@nl
  #4&gt;\blx@nl
  #5%
  ~~&lt;/bcf:datalist&gt;\blx@nl}
\xdef\blx@xml@dlistfilterorbegin{%
  ~~~~&lt;bcf:filteror&gt;\blx@nl}
\xdef\blx@xml@dlistfilterorend{%
  ~~~~&lt;/bcf:filteror&gt;\blx@nl}
\xdef\blx@xml@dlistfilter#1#2{%
  ~~~~&lt;bcf:filter type="#1"&gt;#2&lt;/bcf:filter&gt;\blx@nl}

\xdef\blx@xml@bibdata#1#2{%
  ~~&lt;bcf:bibdata section="#1"&gt;\blx@nl
  #2%
  ~~&lt;/bcf:bibdata&gt;\blx@nl}
\xdef\blx@xml@datasource#1#2#3#4#5{%
  ~~~~&lt;bcf:datasource type="#1" datatype="#2"#3#4&gt;#5&lt;/bcf:datasource&gt;\blx@nl}
\xdef\blx@xml@citekey#1#2#3#4{%
  ~~~~&lt;bcf:citekey order="#3" intorder="#4"#2&gt;#1&lt;/bcf:citekey&gt;}
\xdef\blx@xml@citeset#1#2{%
  ~~~~&lt;bcf:citekey type="set" members="#2"&gt;#1&lt;/bcf:citekey&gt;}
\xdef\blx@xml@citekeycount#1#2{%
  ~~~~&lt;bcf:citekeycount count="#2"&gt;#1&lt;/bcf:citekeycount&gt;}
\xdef\blx@xml@svalue#1#2{%
  \blx@xml@option{singlevalued}{%
  ~~~~~~&lt;bcf:key&gt;#1&lt;/bcf:key&gt;\blx@nl
  ~~~~~~&lt;bcf:value&gt;#2&lt;/bcf:value&gt;\blx@nl}}
\xdef\blx@xml@mvalue#1#2{%
  \blx@xml@option{multivalued}{%
  ~~~~~~&lt;bcf:key&gt;#1&lt;/bcf:key&gt;\blx@nl
  #2}}
\xdef\blx@xml@toggle#1{%
  \blx@xml@svalue{#1}{\noexpand\iftoggle{blx@#1}{1}{0}}}
\xdef\blx@xml@options@scope#1#2{%
  ~~&lt;bcf:optionscope type="#1"&gt;\blx@nl
  #2%
  ~~&lt;/bcf:optionscope&gt;\blx@nl}
\xdef\blx@xml@option@scope#1#2{% GLOBAL/TYPE scope
  ~~~~&lt;bcf:option datatype="#1"&gt;#2&lt;/bcf:option&gt;\blx@nl}
\xdef\blx@xml@option@entryscope#1#2{% ENTRY scope
  ~~~~&lt;bcf:option datatype="#1"\noexpand\ifcsdef{blx@bcf@backendout@entry@#2}{ backendout="1"}{}\noexpand\ifcsdef{blx@bcf@backendin@entry@#2}{ backendin="\noexpand\csuse{blx@bcf@backendin@entry@#2}"}{}&gt;#2&lt;/bcf:option&gt;\blx@nl}
\xdef\blx@xml@option@namelistscope#1#2{% NAMELIST scope
  ~~~~&lt;bcf:option datatype="#1"\noexpand\ifcsdef{blx@bcf@backendout@namelist@#2}{ backendout="1"}{}\noexpand\ifcsdef{blx@bcf@backendin@namelist@#2}{ backendin="\noexpand\csuse{blx@bcf@backendin@namelist@#2}"}{}&gt;#2&lt;/bcf:option&gt;\blx@nl}
\xdef\blx@xml@option@namescope#1#2{% NAME scope
  ~~~~&lt;bcf:option datatype="#1"\noexpand\ifcsdef{blx@bcf@backendout@name@#2}{ backendout="1"}{}\noexpand\ifcsdef{blx@bcf@backendin@name@#2}{ backendin="\noexpand\csuse{blx@bcf@backendin@name@#2}"}{}&gt;#2&lt;/bcf:option&gt;\blx@nl}
\endgroup

\def\blx@bcf@options@global{%
  \blx@xml@comment{GLOBAL}%
  \blx@xml@options{biblatex}{global}{%
    \blx@xml@svalue{alphaothers}{\labelalphaothers}%
    \blx@xml@mvalue{extradatecontext}{\blx@bcf@extradatecontext}%
    \blx@xml@toggle{labelalpha}%
    \blx@xml@mvalue{labelnamespec}{\blx@bcf@labelnamespec}%
    \blx@xml@toggle{labeltitle}%
    \blx@xml@mvalue{labeltitlespec}{\blx@bcf@labeltitlespec}%
    \blx@xml@toggle{labeltitleyear}%
    \blx@xml@toggle{labeldateparts}%
    \blx@xml@mvalue{labeldatespec}{\blx@bcf@labeldatespec}%
    \blx@xml@toggle{julian}%
    \blx@xml@svalue{gregorianstart}{\blx@gregorianstart}%
    \blx@xml@svalue{maxalphanames}{\blx@maxalphanames}%
    \blx@xml@svalue{maxbibnames}{\blx@maxbibnames}%
    \blx@xml@svalue{maxcitenames}{\blx@maxcitenames}%
    \blx@xml@svalue{maxsortnames}{\blx@maxsortnames}%
    \blx@xml@svalue{maxitems}{\blx@maxitems}%
    \blx@xml@svalue{minalphanames}{\blx@minalphanames}%
    \blx@xml@svalue{minbibnames}{\blx@minbibnames}%
    \blx@xml@svalue{mincitenames}{\blx@mincitenames}%
    \blx@xml@svalue{minsortnames}{\blx@minsortnames}%
    \blx@xml@svalue{minitems}{\blx@minitems}%
    \blx@xml@toggle{nohashothers}%
    \blx@xml@toggle{noroman}%
    \blx@xml@toggle{nosortothers}%
    \blx@xml@toggle{pluralothers}%
    \blx@xml@toggle{singletitle}%
    \blx@xml@toggle{skipbib}%
    \blx@xml@toggle{skipbiblist}%
    \blx@xml@toggle{skiplab}%
    \blx@xml@svalue{sortalphaothers}{\sortalphaothers}%
    \blx@xml@svalue{sortlocale}{\blx@sortlocale}%
    \blx@xml@svalue{sortingtemplatename}{\blx@sorting}%
    \blx@xml@toggle{sortsets}%
    \blx@xml@svalue{uniquelist}{\blx@uniquelist}%
    \blx@xml@svalue{uniquename}{\blx@uniquename}%
    \blx@xml@toggle{uniqueprimaryauthor}%
    \blx@xml@toggle{uniquetitle}%
    \blx@xml@toggle{uniquebaretitle}%
    \blx@xml@toggle{uniquework}%
    \blx@xml@toggle{useprefix}%
    \blx@xml@nametoggles
  }%
}

\def\blx@bcf@options@type#1{%
  \blx@xml@comment{#1}%
  \blx@xml@options{biblatex}{#1}{%
    \blx@xml@mvalue{extradatecontext}{%
      \ifcsdef{blx@bcf@extradatecontext@#1}
        {\csuse{blx@bcf@extradatecontext@#1}}
        {\blx@bcf@extradatecontext}}%
    \blx@xml@toggle{labelalpha}%
    \blx@xml@mvalue{labelnamespec}{%
      \ifcsdef{blx@bcf@labelnamespec@#1}
        {\csuse{blx@bcf@labelnamespec@#1}}
        {\blx@bcf@labelnamespec}}%
    \blx@xml@toggle{labeltitle}%
    \blx@xml@mvalue{labeltitlespec}{%
      \ifcsdef{blx@bcf@labeltitlespec@#1}
        {\csuse{blx@bcf@labeltitlespec@#1}}
        {\blx@bcf@labeltitlespec}}%
    \blx@xml@toggle{labeltitleyear}%
    \blx@xml@toggle{labeldateparts}%
    \blx@xml@mvalue{labeldatespec}{%
      \ifcsdef{blx@bcf@labeldatespec@#1}
        {\csuse{blx@bcf@labeldatespec@#1}}
        {\blx@bcf@labeldatespec}}%
    \blx@xml@svalue{maxalphanames}{\blx@maxalphanames}%
    \blx@xml@svalue{maxbibnames}{\blx@maxbibnames}%
    \blx@xml@svalue{maxcitenames}{\blx@maxcitenames}%
    \blx@xml@svalue{maxsortnames}{\blx@maxsortnames}%
    \blx@xml@svalue{maxitems}{\blx@maxitems}%
    \blx@xml@svalue{minalphanames}{\blx@minalphanames}%
    \blx@xml@svalue{minbibnames}{\blx@minbibnames}%
    \blx@xml@svalue{mincitenames}{\blx@mincitenames}%
    \blx@xml@svalue{minsortnames}{\blx@minsortnames}%
    \blx@xml@svalue{minitems}{\blx@minitems}%
    \blx@xml@toggle{nohashothers}%
    \blx@xml@toggle{noroman}%
    \blx@xml@toggle{nosortothers}%
    \blx@xml@toggle{singletitle}%
    \blx@xml@toggle{skipbib}%
    \blx@xml@toggle{skipbiblist}%
    \blx@xml@toggle{skiplab}%
    \blx@xml@svalue{uniquelist}{\blx@uniquelist}%
    \blx@xml@svalue{uniquename}{\blx@uniquename}%
    \blx@xml@toggle{uniqueprimaryauthor}%
    \blx@xml@toggle{uniquetitle}%
    \blx@xml@toggle{uniquebaretitle}%
    \blx@xml@toggle{uniquework}%
    \blx@xml@toggle{useprefix}%
    \blx@xml@nametoggles
  }%
}

\def\blx@ctrlwrite{%
  \begingroup
  \blx@safe@actives
  \let\protect\string
  % options
  \protected@edef\labelalphaothers{\labelalphaothers}%
  \protected@edef\sortalphaothers{\sortalphaothers}%
  \blx@xmlsanitizeafter{\def\labelalphaothers}{\labelalphaothers}%
  \blx@xmlsanitizeafter{\def\sortalphaothers}{\sortalphaothers}%
  % Expand the global use* name toggles
  \let\blx@xml@nametoggles\@empty
  \def\do##1{\eappto\blx@xml@nametoggles{\blx@xml@toggle{use##1}}}%
  \abx@donames
  \edef\blx@tempa{%
    \blx@xml@file
    \blx@xml@comment{BIBER OPTIONS}%
    \blx@xml@options{biber}{global}{%
      \blx@xml@svalue{output_encoding}{\blx@texencoding}%
      \blx@xml@svalue{input_encoding}{\blx@bibencoding}%
      \blx@xml@toggle{debug}%
      \blx@xml@svalue{mincrossrefs}{\blx@mincrossrefs}%
      \blx@xml@svalue{minxrefs}{\blx@minxrefs}%
      \blx@xml@toggle{sortcase}%
      \blx@xml@toggle{sortupper}%
    }%
    \blx@xml@comment{BIBLATEX OPTIONS}%
    \blx@bcf@options@global
  }%
  \ifdef\blx@opts@type
    {\def\do##1{%
       \begingroup
       \let\protect\relax
       \blx@setoptions@type{##1}%
       % Expand the type use* name toggles
       \let\blx@xml@nametoggles\@empty
       \def\do####1{\eappto\blx@xml@nametoggles{\blx@xml@toggle{use####1}}}%
       \abx@donames
       \blx@checkoptions@type
       \xappto\blx@tempa{\blx@bcf@options@type{##1}}%
       \endgroup}%
     \dolistloop\blx@opts@type}
    {}%
  % options scope
  % GLOBAL
  \def\do##1{%
    \begingroup
    \def\do####1{\xappto\blx@bcf@options@scope@global{\blx@xml@option@scope{##1}{####1}}}%
    \dolistcsloop{blx@globalopts@##1}%
    \endgroup}%
  \dolistloop\blx@globalopts@datatypes
  % ENTRYTYPE
  \def\do##1{%
    \begingroup
    \def\do####1{\xappto\blx@bcf@options@scope@type{\blx@xml@option@scope{##1}{####1}}}%
    \dolistcsloop{blx@typeopts@##1}%
    \endgroup}%
  \dolistloop\blx@typeopts@datatypes
  % ENTRY
  \def\do##1{%
    \begingroup
    \def\do####1{\xappto\blx@bcf@options@scope@entry{\blx@xml@option@entryscope{##1}{####1}}}%
    \dolistcsloop{blx@entryopts@##1}%
    \endgroup}%
  \dolistloop\blx@entryopts@datatypes
  % NAMELIST
  \def\do##1{%
    \begingroup
    \def\do####1{\xappto\blx@bcf@options@scope@namelist{\blx@xml@option@namelistscope{##1}{####1}}}%
    \dolistcsloop{blx@namelistopts@##1}%
    \endgroup}%
  \dolistloop\blx@entryopts@datatypes
  % NAME
  \def\do##1{%
    \begingroup
    \def\do####1{\xappto\blx@bcf@options@scope@name{\blx@xml@option@namescope{##1}{####1}}}%
    \dolistcsloop{blx@nameopts@##1}%
    \endgroup}%
  \dolistloop\blx@entryopts@datatypes

  \eappto\blx@tempa{%
    \blx@xml@comment{BIBLATEX OPTION SCOPE}%
    \blx@xml@options@scope{GLOBAL}{\blx@bcf@options@scope@global}%
    \blx@xml@options@scope{ENTRYTYPE}{\blx@bcf@options@scope@type}%
    \blx@xml@options@scope{ENTRY}{\blx@bcf@options@scope@entry}%
    \blx@xml@options@scope{NAMELIST}{\blx@bcf@options@scope@namelist}%
    \blx@xml@options@scope{NAME}{\blx@bcf@options@scope@name}}
  % datafieldsets
  \def\do##1{%
    \xappto\blx@bcf@datafieldsets{\blx@xml@datafieldset{##1}{\csuse{blx@datafieldsetmembers@##1}}}}
  \dolistloop\blx@datafieldsets

  \eappto\blx@tempa{%
    \blx@xml@comment{DATAFIELDSETS}%
    \blx@bcf@datafieldsets}%
  % sourcemap
  \ifbool{sourcemap}
  {\eappto\blx@tempa{%
     \blx@xml@comment{SOURCEMAP}%
     \blx@xml@sourcemap{%
       \ifdef\blx@sourcemap@user
         {\blx@sourcemap@user}
         {}%
       \ifdef\blx@sourcemap@style
         {\blx@sourcemap@style}
         {}%
       \ifdef\blx@sourcemap@defaults@bibtex
         {\blx@sourcemap@defaults@bibtex}
         {}%
       \ifdef\blx@sourcemap@defaults@biblatexml
         {\blx@sourcemap@defaults@biblatexml}
         {}}}}
  {}%
  % labelalpha name template
  \eappto\blx@tempa{\blx@xml@comment{LABELALPHA NAME TEMPLATE}}%
  \def\do##1{%
    \eappto\blx@tempa{%
      \blx@xml@labelalphanametemplate{##1}{\csuse{blx@labelalphanametemplate@##1}}}}%
  \dolistloop\blx@lantemplatespecs
  % labelalpha template
  \eappto\blx@tempa{%
    \blx@xml@comment{LABELALPHA TEMPLATE}}%
  \def\do##1{%
    \eappto\blx@tempa{%
      \blx@xml@labelalphatemplate{##1}{%
      \csuse{blx@labelalphatemplate@##1}}}}%
  \dolistloop\blx@latem@type
  % extradate specification
  \eappto\blx@tempa{%
    \blx@xml@comment{EXTRADATE}%
    \blx@xml@extradate{\csuse{blx@bcf@extradatespec}}}%
  % data inheritance
  \eappto\blx@tempa{%
    \blx@xml@comment{INHERITANCE}%
    \blx@xml@inheritance{%
      \csuse{blx@inherit@default}%
      \csuse{blx@inherit@data}}}%
  % noinit
  \ifcsdef{blx@noinit}
    {\eappto\blx@tempa{%
      \blx@xml@comment{NOINIT}%
      \blx@xml@noinits{%
        \csuse{blx@noinit}}}}%
    {}%
  % nolabel
  \ifcsdef{blx@nolabel}
    {\eappto\blx@tempa{%
      \blx@xml@comment{NOLABEL}%
      \blx@xml@nolabels{%
        \csuse{blx@nolabel}}}}%
    {}%
  % nolabel
  \ifcsdef{blx@nolabelwidthcount}
    {\eappto\blx@tempa{%
      \blx@xml@comment{NOLABELWIDTHCOUNT}%
      \blx@xml@nolabelwidthcounts{%
        \csuse{blx@nolabelwidthcount}}}}%
    {}%
  % nosort
  \ifcsdef{blx@nosort}
    {\eappto\blx@tempa{%
      \blx@xml@comment{NOSORT}%
      \blx@xml@nosorts{%
        \csuse{blx@nosort}}}}%
    {}%
  % nonamestrings
  \ifcsdef{blx@nonamestring}
    {\eappto\blx@tempa{%
      \blx@xml@comment{NONAMESTRING}%
      \blx@xml@nonamestrings{%
        \csuse{blx@nonamestring}}}}%
    {}%
  % transliteration
  \ifdefempty\blx@translits
    {}
    {\eappto\blx@tempa{\blx@xml@comment{TRANSLITERATION}}%
     \def\do##1{%
       \eappto\blx@tempa{\blx@xml@transliteration{##1}{\csuse{blx@translit@##1}}}}%
     \dolistloop\blx@translits}%
  % uniquenametemplate
  \eappto\blx@tempa{\blx@xml@comment{UNIQUENAME TEMPLATES}}%
  \def\do##1{%
    \eappto\blx@tempa{%
      \blx@xml@uniquenametemplate{##1}{\csuse{blx@uniquenametemplate@##1}}}}%
  \dolistloop\blx@untemplatespecs
  % namehashtemplate
  \eappto\blx@tempa{\blx@xml@comment{NAME HASH TEMPLATES}}%
  \def\do##1{%
    \eappto\blx@tempa{%
      \blx@xml@namehashtemplate{##1}{\csuse{blx@namehashtemplate@##1}}}}%
  \dolistloop\blx@nhtemplatespecs
  % sortingnamekeytemplate
  \eappto\blx@tempa{\blx@xml@comment{SORTING NAME KEY TEMPLATES}}%
  \def\do##1{%
    \eappto\blx@tempa{%
      \blx@xml@sortingnamekeytemplate{##1}{\csuse{blx@sortingnamekeytemplatesvisibility@##1}}{\csuse{blx@sortingnamekeytemplate@##1}}}}%
  \dolistloop\blx@sortingnamekeytemplates
  % presort/sorting excludes/sorting includes
  \def\do##1{%
    \eappto\blx@bcf@presort{\csuse{blx@bcf@presort@##1}}%
    \eappto\blx@bcf@exclude{\csuse{blx@bcf@exclude@##1}}%
    \eappto\blx@bcf@include{\csuse{blx@bcf@include@##1}}}%
  \abx@doentrytypes
  \do{*}% entrytype wildcard
  \eappto\blx@tempa{%
    \blx@bcf@presort
    \blx@bcf@exclude
    \blx@bcf@include}%
  % datamodel
  \eappto\blx@tempa{%
    \blx@xml@comment{DATA MODEL}%
    \blx@xml@datamodel{%
      \blx@xml@datamodel@constants{%
        \blx@bcf@datamodel@constants
      }%
      \blx@xml@datamodel@entrytypes{%
        \blx@bcf@datamodel@entrytypes
      }%
      \blx@xml@datamodel@fields{%
        \blx@bcf@datamodel@fields
      }%
      \blx@bcf@datamodel@entryfields
      \blx@bcf@datamodel@multiscript@entryfields
      \blx@bcf@datamodel@constraints
    }%
  }%
  % files
  \let\blx@tempb\@empty
  \blx@bibdata\blx@tempb\blx@bibfiles
  \eappto\blx@tempa{%
    \blx@xml@comment{CITATION DATA}%
    \blx@xml@comment{SECTION 0}%
    \blx@xml@bibdata{0}{\blx@tempb}%
    \blx@xml@section{0}%
  }%
  \immediate\openout\blx@bcfout\jobname.bcf\relax
  \blx@auxwrite\blx@bcfout{}{\blx@tempa}%
  \global\undef\blx@tempa
  \endgroup
  \AfterEndDocument{%
    \def\do##1{%
      \csxappto{blx@sortingtemplates}{%
        \blx@xml@sortingtemplate{##1}
                        {\ifcsdef{blx@sortdef@locale@##1}{ locale="\csuse{blx@sortdef@locale@##1}"}{}}
                        {\csuse{blx@sortingtemplate@##1}}}}%
      \dolistloop\blx@sortingtemplatenames
    \blx@auxwrite\blx@bcfout{}{%
      \blx@xml@endsection\blx@nl
      \blx@xml@comment{SORTING TEMPLATES}%
      \csuse{blx@sortingtemplates}%
      \blx@xml@comment{DATALISTS}%
      \csuse{blx@dlists}%
      \blx@xml@endfile}%
    \immediate\closeout\blx@bcfout}}

%% Customisation

% nolabel
\newrobustcmd*{\DeclareNolabel}[1]{%
  \begingroup
  \let\nolabel\blx@nolabel@setup
  \let\blx@tempa\@empty
  #1%
  \global\let\blx@nolabel\blx@tempa
  \endgroup}
\@onlypreamble\DeclareNolabel

\newcommand*{\blx@nolabel@setup}[1]{%
  \eappto\blx@tempa{%
    \blx@xml@nolabel{#1}}}

% nolabelwidthcount
\newrobustcmd*{\DeclareNolabelwidthcount}[1]{%
  \begingroup
  \let\nolabel\blx@nolabelwidthcount@setup
  \let\blx@tempa\@empty
  #1%
  \global\let\blx@nolabelwidthcount\blx@tempa
  \endgroup}
\@onlypreamble\DeclareNolabelwidthcount

\newcommand*{\blx@nolabelwidthcount@setup}[1]{%
  \eappto\blx@tempa{%
    \blx@xml@nolabelwidthcount{#1}}}

% nosort
\newrobustcmd*{\DeclareNosort}[1]{%
  \begingroup
  \let\nosort\blx@nosort@setup
  \let\blx@tempa\@empty
  #1%
  \global\let\blx@nosort\blx@tempa
  \endgroup}
\@onlypreamble\DeclareNosort

\newcommand*{\blx@nosort@setup}[2]{%
  \eappto\blx@tempa{%
    \blx@xml@nosort{#1}{#2}}}

% nonamestring
\newrobustcmd*{\DeclareNonamestring}[1]{%
  \begingroup
  \let\nonamestring\blx@nonamestring@setup
  \let\blx@tempa\@empty
  #1%
  \global\let\blx@nonamestring\blx@tempa
  \endgroup}
\@onlypreamble\DeclareNonamestring

\newcommand*{\blx@nonamestring@setup}[2]{%
  \eappto\blx@tempa{%
    \blx@xml@nonamestring{#1}{#2}}}

% noinit
\newrobustcmd*{\DeclareNoinit}[1]{%
  \begingroup
  \let\noinit\blx@noinit@setup
  \let\blx@tempa\@empty
  #1%
  \global\let\blx@noinit\blx@tempa
  \endgroup}
\@onlypreamble\DeclareNoinit

\newcommand*{\blx@noinit@setup}[1]{%
  \eappto\blx@tempa{%
    \blx@xml@noinit{#1}}}

% datafieldsets
\newrobustcmd*{\DeclareDatafieldSet}[2]{%
  \begingroup
  \let\member\blx@datafieldset@member
  \let\blx@tempa\@empty
  \def\blx@setname{#1}
  \cslet{blx@datafieldset@#1}\@empty
  #2%
  \csxdef{blx@datafieldsetmembers@#1}{\blx@tempa}%
  \listgadd\blx@datafieldsets{#1}%
  \global\csletcs{datafieldset#1}{blx@datafieldset@#1}% expose user-facing macro
  \endgroup}
\@onlypreamble\DeclareDatafieldSet

\newcommand*{\blx@datafieldset@member}[1][2]{%
  \let\blx@dm@fieldtype\@empty
  \let\blx@dm@datatype\@empty
  \let\blx@member@field\@empty
  \let\blx@tempb\@empty
  \blx@kv@setkeys{blx@datafieldsets@member}{#1}%
  \eappto\blx@tempa{%
    \blx@xml@datafieldsets@member{\blx@tempb}}%
  \ifdefempty\blx@member@field
    {}
    {\listcsxadd{blx@datafieldset@\blx@setname}{\blx@member@field}}%
  % Set some internal macros in case biblatex needs to use the set
  \ifboolexpr{%
    not test {\ifdefempty{\blx@dm@fieldtype}}
    and
    not test {\ifdefempty{\blx@dm@datatype}}}
      {\def\do##1{%
         \listcsxadd{blx@datafieldset@\blx@setname}{##1}}
       \dolistcsloop{blx@datamodelfields@types@\blx@dm@fieldtype @\blx@dm@datatype}}
      {\ifdefempty{\blx@dm@fieldtype}
         {}
         {\def\do##1{%
           \listcsxadd{blx@datafieldset@\blx@setname}{##1}}
          \dolistcsloop{blx@datamodelfields@fieldtypes@\blx@dm@fieldtype}}%
       \ifdefempty{\blx@dm@datatype}
         {}
         {\def\do##1{%
           \listcsxadd{blx@datafieldset@\blx@setname}{##1}}
          \dolistcsloop{blx@datamodelfields@datatypes@\blx@dm@datatype}}}}

\blx@kv@defkey{blx@datafieldsets@member}{datatype}{% characters
  \appto\blx@tempb{ datatype="#1"}%
  \def\blx@dm@datatype{#1}}
\blx@kv@defkey{blx@datafieldsets@member}{fieldtype}{% characters
  \appto\blx@tempb{ fieldtype="#1"}%
  \def\blx@dm@fieldtype{#1}}
\blx@kv@defkey{blx@datafieldsets@member}{field}{% characters
  \appto\blx@tempb{ field="#1"}%
  \def\blx@member@field{#1}}

% sourcemap
\newrobustcmd*{\DeclareSourcemap}[1]{%
  \booltrue{sourcemap}%
  \begingroup
  \let\maps\blx@usersourcemap@maps
  \let\blx@tempa\@empty
  #1%
  \xappto\blx@sourcemap@user\blx@tempa%
  \endgroup}
\@onlypreamble\DeclareSourcemap

\newrobustcmd*{\DeclareStyleSourcemap}[1]{%
  \booltrue{sourcemap}%
  \begingroup
  \let\maps\blx@stylesourcemap@maps
  \let\blx@tempa\@empty
  #1%
  \xappto\blx@sourcemap@style\blx@tempa%
  \endgroup}

\@onlypreamble\DeclareStyleSourcemap

\newrobustcmd*{\DeclareDriverSourcemap}[2][]{%
  \booltrue{sourcemap}%
  \begingroup
  \let\blx@tempa\@empty
  \let\blx@tempb\@empty
  \let\blx@tempc\@empty
  \let\blx@tempd\@empty
  \let\map\blx@sourcemap@map
  #2%
  \ifblank{#1}
    {\blx@kv@setkeys{blx@sourcemap@maps}{datatype=bibtex, level=driver}}
    {\blx@kv@setkeys{blx@sourcemap@maps}{#1, level=driver}}%
  \eappto\blx@tempa{%
    \blx@xml@sourcemap@maps{\blx@tempb}{\blx@tempc}}%
  \csxdef{blx@sourcemap@defaults@\blx@tempd}{\blx@tempa}%
  \endgroup}
\@onlypreamble\DeclareDriverSourcemap

\newcommand*{\blx@usersourcemap@maps}[2][]{%
  \let\blx@tempb\@empty
  \let\blx@tempc\@empty
  \let\map\blx@sourcemap@map
  \ifblank{#1}
    {\blx@kv@setkeys{blx@sourcemap@maps}{datatype=bibtex, level=user}}
    {\blx@kv@setkeys{blx@sourcemap@maps}{#1, level=user}}%
  #2%
  \eappto\blx@tempa{%
    \blx@xml@sourcemap@maps{\blx@tempb}{\blx@tempc}}}

\newcommand*{\blx@stylesourcemap@maps}[2][]{%
  \let\blx@tempb\@empty
  \let\blx@tempc\@empty
  \let\map\blx@sourcemap@map
  \ifblank{#1}
    {\blx@kv@setkeys{blx@sourcemap@maps}{datatype=bibtex, level=style}}
    {\blx@kv@setkeys{blx@sourcemap@maps}{#1, level=style}}%
  #2%
  \eappto\blx@tempa{%
    \blx@xml@sourcemap@maps{\blx@tempb}{\blx@tempc}}}

\blx@kv@defkey{blx@sourcemap@maps}{datatype}{% characters
  \eappto\blx@tempb{ datatype="#1"}%
  \eappto\blx@tempd{#1}}
\blx@kv@defkey{blx@sourcemap@maps}{overwrite}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempb{ map\string_overwrite="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@maps}{level}{% user|style|driver
    \appto\blx@tempb{ level="#1"}}

\newcommand*{\blx@sourcemap@map}[2][]{%
  \let\blx@tempm\@empty
  \let\blx@tempe\@empty
  \let\perdatasource\blx@sourcemap@perdatasource
  \let\pertype\blx@sourcemap@pertype
  \let\pernottype\blx@sourcemap@pernottype
  \let\step\blx@sourcemap@step
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@sourcemap@map}{#1}}%
  #2%
  \eappto\blx@tempc{%
    \blx@xml@sourcemap@map{\blx@tempm}{\blx@tempe}}}

\blx@kv@defkey{blx@sourcemap@map}{overwrite}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempm{ map\string_overwrite="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@map}{foreach}{% characters
  \eappto\blx@tempm{ map\string_foreach="#1"}}
\blx@kv@defkey{blx@sourcemap@map}{refsection}{% integer
  \eappto\blx@tempm{ refsection="#1"}}

\newcommand*{\blx@sourcemap@perdatasource}[1]{%
  \eappto\blx@tempe{%
    \blx@xml@sourcemap@perdatasource{#1}}}

\newcommand*{\blx@sourcemap@pertype}[1]{%
  \eappto\blx@tempe{%
    \blx@xml@sourcemap@pertype{#1}}}

\newcommand*{\blx@sourcemap@pernottype}[1]{%
  \eappto\blx@tempe{%
    \blx@xml@sourcemap@pernottype{#1}}}

\newcommand*{\blx@sourcemap@step}[1][2]{%
  \let\blx@tempf\@empty
  \blx@kv@setkeys{blx@sourcemap@step}{#1}%
  \eappto\blx@tempe{%
    \blx@xml@sourcemap@step{\blx@tempf}}}

\blx@kv@defkey{blx@sourcemap@step}{typesource}{% characters
  \eappto\blx@tempf{ map\string_type\string_source="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{typetarget}{% characters
  \eappto\blx@tempf{ map\string_type\string_target="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{final}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_final="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{cited}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_entrykey\string_cited="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{nocited}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_entrykey\string_nocited="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{citedornocited}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_entrykey\string_citedornocited="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{allnocited}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_entrykey\string_allnocited="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{starnocited}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_entrykey\string_starnocited="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{fieldsource}{% characters
  \eappto\blx@tempf{ map\string_field\string_source="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{notfield}{% characters
  \eappto\blx@tempf{ map\string_notfield="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{fieldtarget}{% characters
  \eappto\blx@tempf{ map\string_field\string_target="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{fieldset}{% characters
  \eappto\blx@tempf{ map\string_field\string_set="#1"}}
% We are sanitising the XML here as it's the value of an attribute which
% might contain quotes or ampersands (URLs, for example)
\blx@kv@defkey{blx@sourcemap@step}{fieldvalue}{% characters
  \blx@xmlsanitizeafter{\def\blx@temps}{#1}%
  \eappto\blx@tempf{ map\string_field\string_value="\blx@temps"}}
\blx@kv@defkey{blx@sourcemap@step}{append}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_append="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{appendstrict}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_appendstrict="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{null}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_null="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{entrynull}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_entry\string_null="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{entrynocite}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_entry\string_nocite="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{entrynew}{% characters
  \appto\blx@tempf{ map\string_entry\string_new="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{entrynewtype}{% characters
  \appto\blx@tempf{ map\string_entry\string_newtype="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{entrytarget}{% characters
  \appto\blx@tempf{ map\string_entrytarget="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{entryclone}{% characters
  \appto\blx@tempf{ map\string_entry\string_clone="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{origfield}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_origfield="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{origfieldval}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_origfieldval="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{origentrytype}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempf{ map\string_origentrytype="1"}}
    {}}
\blx@kv@defkey{blx@sourcemap@step}{match}{% characters
  \appto\blx@tempf{ map\string_match="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{matchi}{% characters
  \appto\blx@tempf{ map\string_matchi="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{matches}{% characters
  \appto\blx@tempf{ map\string_matches="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{matchesi}{% characters
  \appto\blx@tempf{ map\string_matchesi="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{notmatch}{% characters
  \appto\blx@tempf{ map\string_notmatch="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{notmatchi}{% characters
  \appto\blx@tempf{ map\string_notmatchi="#1"}}
\blx@kv@defkey{blx@sourcemap@step}{replace}{% characters
  \eappto\blx@tempf{ map\string_replace="#1"}}

% [&lt;specname&gt;]{&lt;spec&gt;}
\newrobustcmd*{\DeclareLabelalphaNameTemplate}[2][]{%
  \begingroup
  \ifblank{#1}
    {\def\blx@lantname{global}}% default
    {\def\blx@lantname{#1}}%
  \let\namepart\blx@lantem@namepart
  \let\blx@tempa\@empty
  \blx@tempcnta\z@
  #2%
  \global\cslet{blx@labelalphanametemplate@\blx@lantname}\blx@tempa
  \xifinlist\blx@lantname\blx@lantemplatespecs
    {}
    {\listxadd\blx@lantemplatespecs\blx@lantname}%
  \endgroup}
\@onlypreamble\DeclareLabelalphaNameTemplate
\blx@DeclareBackendOption{global}[xml]{labelalphanametemplate}
\DeclareBiblatexOption{entry,namelist,name}[string]{labelalphanametemplatename}{%
  \def\blx@refcontext@labelalphanametemplatename{#1}}

\newcommand*{\blx@lantem@namepart}[2][]{%
  \ifinlist{#2}\blx@datamodel@constants@nameparts@l
    {}
    {\blx@error
      {Invalid namepart '#2'}
      {Namepart '#2' in labelalphaname template declaration '\blx@lantname' is not defined in the data model}}%
  \advance\blx@tempcntb\@ne
  \edef\blx@tempe{order="\the\blx@tempcntb"}%
  \let\blx@tempc\@empty
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@lantem@namepart}{#1}}%
  \eappto\blx@tempa{%
    \blx@xml@labelalphanametemplatenamepart{\blx@tempe}{\blx@tempc}{#2}}}

\blx@kv@defkey{blx@lantem@namepart}{use}[true]{% use* option for namepart true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ use="1"}}
    {}}

\blx@kv@defkey{blx@lantem@namepart}{pre}[true]{% pre option for namepart true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ pre="1"}}
    {}}

\blx@kv@defkey{blx@lantem@namepart}{compound}[true]{% base option for namepart true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ substring\string_compound="1"}}
    {}}

\blx@kv@defkey{blx@lantem@namepart}{strwidth}{% integer
  \eappto\blx@tempc{ substring\string_width="#1"}}

\blx@kv@defkey{blx@lantem@field}{strside}{% left|right
  \ifstrequal{#1}{right}
    {\eappto\blx@tempc{ substring\string_side="right"}}
    {\eappto\blx@tempc{ substring\string_side="left"}}}

% [&lt;entrytype&gt;]{&lt;spec&gt;}
\newrobustcmd*{\DeclareLabelalphaTemplate}[2][]{%
   \ifblank{#1}
     {\blx@latem{#2}{global}}
     {\forcsvlist{\blx@latem{#2}}{#1}}}
\@onlypreamble\DeclareLabelalphaTemplate
\blx@DeclareBackendOption{global,type}[xml]{labelalphatemplate}

\def\blx@latem#1#2{%
  \begingroup
  \let\labelelement\blx@latem@element
  \let\field\blx@latem@field
  \let\literal\blx@latem@literal
  \blx@tempcnta\z@
  \let\blx@tempa\@empty
  #1%
  \ifdef\blx@latem@type
    {\ifinlist{#2}\blx@latem@type
      {\global\cslet{blx@labelalphatemplate@#2}\blx@tempa}
      {\listgadd\blx@latem@type{#2}%
       \global\cslet{blx@labelalphatemplate@#2}\blx@tempa}}
    {\listgadd\blx@latem@type{#2}%
     \global\cslet{blx@labelalphatemplate@#2}\blx@tempa}%
  \endgroup}

\newcommand*{\blx@latem@element}[1]{%
  \advance\blx@tempcnta\@ne
  \let\blx@tempb\@empty
  #1%
  \eappto\blx@tempa{%
    \blx@xml@labelalpha@element{\the\blx@tempcnta}{\blx@tempb}}}

\newcommand*{\blx@latem@literal}[1]{%
  \blx@xmlsanitizeafter{\def\blx@temps}{#1}%
  \eappto\blx@tempb{%
    \blx@xml@labelalpha@part{}{\expandafter\regexp\expandafter{\blx@temps}}}}

\newcommand*{\blx@latem@field}[2][]{%
  \let\blx@tempc\@empty
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@latem@field}{#1}}%
  \eappto\blx@tempb{%
    \blx@xml@labelalpha@part{\blx@tempc}{#2}}}

\blx@kv@defkey{blx@latem@field}{uppercase}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ uppercase="1"}}
    {}}
\blx@kv@defkey{blx@latem@field}{lowercase}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ lowercase="1"}}
    {}}
\blx@kv@defkey{blx@latem@field}{final}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ final="1"}}
    {}}
\blx@kv@defkey{blx@latem@field}{strwidth}{% integer
    \eappto\blx@tempc{ substring\string_width="#1"}}
\blx@kv@defkey{blx@latem@field}{varwidth}[true]{% "v"
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ substring\string_width="v"}}
    {}}
\blx@kv@defkey{blx@latem@field}{varwidthnorm}[true]{% "vf"
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ substring\string_width="vf"}}
    {}}
\blx@kv@defkey{blx@latem@field}{varwidthlist}[true]{% "l"
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ substring\string_width="l"}}
    {}}
\blx@kv@defkey{blx@latem@field}{strfixedcount}{%
    \eappto\blx@tempc{ substring\string_fixed\string_threshold="#1"}}
\blx@kv@defkey{blx@latem@field}{strwidthmax}{%
    \eappto\blx@tempc{ substring\string_width\string_max="#1"}}
\blx@kv@defkey{blx@latem@field}{strside}{% left|right
  \ifstrequal{#1}{right}
    {\eappto\blx@tempc{ substring\string_side="right"}}
    {\eappto\blx@tempc{ substring\string_side="left"}}}
\blx@kv@defkey{blx@latem@field}{namessep}{%
    \eappto\blx@tempc{ namessep="#1"}}
\blx@kv@defkey{blx@latem@field}{ifnames}{%
    \eappto\blx@tempc{ ifnames="#1"}}
\blx@kv@defkey{blx@latem@field}{names}{%
    \eappto\blx@tempc{ names="#1"}}
\blx@kv@defkey{blx@latem@field}{noalphaothers}[true]{%
    \eappto\blx@tempc{ noalphaothers="1"}}
\blx@kv@defkey{blx@latem@field}{padchar}{%
  \blx@xmlsanitizeafter{\def\blx@temps}{#1}%
  \eappto\blx@tempc{ pad\string_char="\expandafter\regexp\expandafter{\blx@temps}"}}
\blx@kv@defkey{blx@latem@field}{padside}{% left|right
  \ifstrequal{#1}{left}
    {\eappto\blx@tempc{ pad\string_side="left"}}
    {\eappto\blx@tempc{ pad\string_side="right"}}}

% [&lt;exceptions&gt;]{&lt;options&gt;}
\newrobustcmd*{\DefaultInheritance}[2][]{%
  \begingroup
  \let\blx@tempf\@empty
  \ifblank{#2}
    {}
    {\blx@kv@setkeys{blx@inherit@default}{#2}}%
  \edef\blx@tempa{\space
    inherit\string_all="\iftoggle{blx@inherit@all}{true}{false}"\space
    override\string_target="\iftoggle{blx@inherit@override}{true}{false}"%
    \blx@tempf}%
  \let\blx@tempb\@empty
  \let\except\blx@inherit@except
  #1%
  \xdef\blx@inherit@default{%
    \blx@xml@inherit@defaults{\blx@tempa}{\blx@tempb}}%
  \endgroup}
\@onlypreamble\DefaultInheritance

\newtoggle{blx@inherit@all}
\newtoggle{blx@inherit@override}

\blx@kv@defkey{blx@inherit@default}{all}[true]{% true|false
  \settoggle{blx@inherit@all}{#1}}
\blx@kv@defkey{blx@inherit@default}{override}[true]{% true|false
  \settoggle{blx@inherit@override}{#1}}
\blx@kv@defkey{blx@inherit@default}{ignore}{% csv list
  \edef\blx@tempf{ ignore="#1"}}

% {&lt;source&gt;}{&lt;target&gt;}{&lt;options&gt;}
\newcommand*{\blx@inherit@except}[3]{%
  \let\blx@tempc\@empty
  \ifblank{#3}
    {}
    {\blx@kv@setkeys{blx@inherit@except}{#3}}%
  \eappto\blx@tempb{%
    \blx@xml@inherit@type{#1}{#2}{\blx@tempc}}}

\blx@kv@defkey{blx@inherit@except}{all}[true]{% true|false
  \eappto\blx@tempc{ inherit\string_all="#1"}}
\blx@kv@defkey{blx@inherit@except}{override}[true]{% true|false
  \eappto\blx@tempc{ override\string_target="#1"}}
\blx@kv@defkey{blx@inherit@except}{ignore}{% csv list
  \eappto\blx@tempc{ ignore="#1"}}

% {&lt;type,type,...&gt;}{&lt;type,type,...&gt;}{&lt;spec&gt;}
\newrobustcmd*{\DeclareDataInheritance}[4][]{%
  \begingroup
  \let\blx@tempa\@empty
  \let\blx@tempf\@empty
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@inherit}{#1}}%
  \forcsvlist{\blx@inherit@i{#3}}{#2}%
  \let\blx@tempb\@empty
  \let\inherit\blx@inherit@field
  \let\noinherit\blx@inherit@block
  #4%
  \xappto\blx@inherit@data{%
    \blx@xml@inherit@data{\blx@tempf}{%
      \blx@tempa
      \blx@tempb}}%
  \endgroup}
\@onlypreamble\DeclareDataInheritance

\def\blx@inherit@i#1#2{%
  \forcsvlist{\blx@inherit@ii{#2}}{#1}}

\def\blx@inherit@ii#1#2{%
  \eappto\blx@tempa{\blx@xml@inherit@type{#1}{#2}{}}}

\blx@DeclareBackendOption{global}[xml]{inheritance}

% [&lt;options&gt;]{&lt;source&gt;}{&lt;target&gt;}
\newcommand*{\blx@inherit@field}[3][]{%
  \let\blx@tempc\@empty
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@inherit@field}{#1}}%
  \eappto\blx@tempb{%
    \blx@xml@inherit@field{#2}{#3}{\blx@tempc}}}

\newcommand*{\blx@inherit@block}[1]{%
  \eappto\blx@tempb{\blx@xml@inherit@block{#1}}}

\blx@kv@defkey{blx@inherit}{ignore}{% csv list
  \edef\blx@tempf{ ignore="#1"}}

\blx@kv@defkey{blx@inherit@field}{override}[true]{% true|false
  \ifstrequal{#1}{true}
    {\edef\blx@tempc{ override\string_target="true"}}
    {\edef\blx@tempc{ override\string_target="false"}}}

\newrobustcmd*{\ResetDataInheritance}{%
  \global\csundef{blx@inherit@data}}
\@onlypreamble\ResetDataInheritance

% {&lt;name&gt;}{&lt;spec&gt;}
\newrobustcmd*{\DeclareBiblistFilter}[2]{%
  \begingroup
  \let\filteror\blx@biblistfilteror
  \let\filter\blx@biblistfilter
  \let\blx@tempa\@empty
  #2%
  \global\cslet{blx@biblistfilters@#1}\blx@tempa
  \endgroup}
\@onlypreamble\DeclareBiblistFilter

\newcommand*{\blx@biblistfilteror}[1]{%
  \eappto\blx@tempa{\blx@xml@dlistfilterorbegin}%
  #1%
  \eappto\blx@tempa{\blx@xml@dlistfilterorend}}

\newcommand*{\blx@biblistfilter}[1][2]{%
  \let\blx@tempc\@empty
  \let\blx@tempd\@empty
  \blx@kv@setkeys{blx@biblistfilter@filter}{#1}%
  \eappto\blx@tempa{%
    \blx@xml@dlistfilter{\blx@tempc}{\blx@tempd}}}

\blx@kv@defkey{blx@biblistfilter@filter}{type}{%
  \def\blx@tempc{#1}}
\blx@kv@defkey{blx@biblistfilter@filter}{filter}{%
  \def\blx@tempd{#1}}

% Predefine filters for label fields
\def\do#1{\DeclareBiblistFilter{#1}{\filter[type=field,filter=#1]}}
\abx@dolabelfields

\blx@kv@defkey{blx@biblist1}{biblistfilter}{\blx@key@biblistfilter{#1}}
\blx@kv@defkey{blx@biblist2}{biblistfilter}{}

\def\blx@key@biblistfilter#1{%
  \ifcsundef{blx@biblistfilters@#1}
    {\blx@error
        {BiblistFilter '#1' not found}
        {The BiblistFilter '#1' could not be found.\MessageBreak
         Use '\string\DeclareBiblistFilter' to define it}}
    {\def\blx@thebiblistfilter{#1}}}

% [&lt;entrytype&gt;]{specification}
\newrobustcmd*{\DeclareSortTranslit}[2][]{%
  \begingroup
  \ifblank{#1}
    {\def\blx@tempa{*}}
    {\def\blx@tempa{#1}}%
  \let\translit\blx@translit@setup
  \let\blx@tempb\@empty
  #2%
  \global\cslet{blx@translit@\blx@tempa}\blx@tempb
  \xifinlist\blx@tempa\blx@translits
    {}
    {\listxadd\blx@translits\blx@tempa}%
  \endgroup}
\@onlypreamble\DeclareSortTranslit
\blx@DeclareBackendOption{global,type}[xml]{translit}

% [&lt;langids&gt;]{&lt;field or set&gt;}{translitsource}{translittarget}
\newcommand*{\blx@translit@setup}[4][]{%
  \eappto\blx@tempb{%
    \ifblank{#1}
     {\blx@xml@translit{}{#2}{#3}{#4}}
     {\blx@xml@translit{langids="#1" }{#2}{#3}{#4}}}}

% [&lt;specname&gt;]{&lt;spec&gt;}
\newrobustcmd*{\DeclareUniquenameTemplate}[2][]{%
  \begingroup
  \ifblank{#1}
    {\def\blx@untname{global}}% default
    {\def\blx@untname{#1}}%
  \let\namepart\blx@untemp@namepart
  \let\blx@tempa\@empty
  \blx@tempcnta\z@
  #2%
  \global\cslet{blx@uniquenametemplate@\blx@untname}\blx@tempa
  \xifinlist\blx@untname\blx@untemplatespecs
    {}
    {\listxadd\blx@untemplatespecs\blx@untname}%
  \endgroup}
\@onlypreamble\DeclareUniquenameTemplate
\blx@DeclareBackendOption{global}[xml]{uniquenametemplate}
\DeclareBiblatexOption{entry,namelist,name}[string]{uniquenametemplatename}{%
  \def\blx@refcontext@uniquenametemplatename{#1}}

\newcommand*{\blx@untemp@namepart}[2][]{%
  \ifinlist{#2}\blx@datamodel@constants@nameparts@l
    {}
    {\blx@error
      {Invalid namepart '#2'}
      {Namepart '#2' in uniquename template declaration '\blx@untname' is not defined in the data model}}%
  \advance\blx@tempcntb\@ne
  \edef\blx@tempe{order="\the\blx@tempcntb"}%
  \let\blx@tempc\@empty
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@untemp@namepart}{#1}}%
  \eappto\blx@tempa{%
    \blx@xml@uniquenametemplatenamepart{\blx@tempe}{\blx@tempc}{#2}}}

\blx@kv@defkey{blx@untemp@namepart}{use}[true]{% use* option for namepart true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ use="1"}}
    {}}

\blx@kv@defkey{blx@untemp@namepart}{base}[true]{% base option for namepart true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ base="1"}}
    {}}

\blx@kv@defkey{blx@untemp@namepart}{disambiguation}{% disambiguation option for namepart none|inits|full|fullonly
  \appto\blx@tempc{ disambiguation="#1"}}

% [&lt;specname&gt;]{&lt;spec&gt;}
\newrobustcmd*{\DeclareNamehashTemplate}[2][]{%
  \begingroup
  \ifblank{#1}
    {\def\blx@nhtname{global}}% default
    {\def\blx@nhtname{#1}}%
  \let\namepart\blx@nhtemp@namepart
  \let\blx@tempa\@empty
  \blx@tempcnta\z@
  #2%
  \global\cslet{blx@namehashtemplate@\blx@nhtname}\blx@tempa
  \xifinlist\blx@nhtname\blx@nhtemplatespecs
    {}
    {\listxadd\blx@nhtemplatespecs\blx@nhtname}%
  \endgroup}
\@onlypreamble\DeclareNamehashTemplate
\blx@DeclareBackendOption{global}[xml]{namehashtemplate}
\DeclareBiblatexOption{entry,namelist,name}[string]{namehashtemplatename}{%
  \def\blx@refcontext@namehashtemplatename{#1}}

\newcommand*{\blx@nhtemp@namepart}[2][]{%
  \ifinlist{#2}\blx@datamodel@constants@nameparts@l
    {}
    {\blx@error
      {Invalid namepart '#2'}
      {Namepart '#2' in name hash template declaration '\blx@nhtname' is not defined in the data model}}%
  \advance\blx@tempcntb\@ne
  \edef\blx@tempe{order="\the\blx@tempcntb"}%
  \let\blx@tempc\@empty
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@nhtemp@namepart}{#1}}%
  \eappto\blx@tempa{%
    \blx@xml@namehashtemplatenamepart{\blx@tempe}{\blx@tempc}{#2}}}

\blx@kv@defkey{blx@nhtemp@namepart}{hashscope}{\def\blx@tempc{ hashscope="#1"}}

% [&lt;templatename&gt;]{&lt;template&gt;}
\newrobustcmd*{\DeclareSortingNamekeyTemplate}[2][]{%
  \begingroup
  \ifblank{#1}
    {\def\blx@snkname{global}}% default
    {\def\blx@snkname{#1}}%
  \let\namepart\blx@sortnk@namepart
  \let\keypart\blx@sortnk@keypart
  \let\literal\blx@sortnk@literal
  \let\visibility\blx@sortnk@visibility
  \csgdef{blx@sortingnamekeytemplatesvisibility@\blx@snkname}{sort}% default
  \let\blx@tempa\@empty
  \blx@tempcnta\z@
  #2%
  \global\cslet{blx@sortingnamekeytemplate@\blx@snkname}\blx@tempa
  \xifinlist\blx@snkname\blx@sortingnamekeytemplates
    {}
    {\listxadd\blx@sortingnamekeytemplates\blx@snkname}%
  \endgroup}
\@onlypreamble\DeclareSortingNamekeyTemplate
\blx@DeclareBackendOption{global}[xml]{sortingnamekeytemplate}
\DeclareBiblatexOption{entry,namelist,name}[string]{sortingnamekeytemplatename}{%
  \def\blx@refcontext@sortingnamekeytemplatename{#1}}

% User-mode macro for checking sorting name template options
\def\ifuniquenametemplatename#1{%
  \expandafter\ifstrequal\expandafter{\blx@refcontext@uniquenametemplatename}{#1}}
\def\iflabelalphanametemplatename#1{%
  \expandafter\ifstrequal\expandafter{\blx@refcontext@labelalphanametemplatename}{#1}}
\def\ifnamehashtemplatename#1{%
  \expandafter\ifstrequal\expandafter{\blx@refcontext@namehashtemplatename}{#1}}
\def\ifsortingnamekeytemplatename#1{%
  \expandafter\ifstrequal\expandafter{\blx@refcontext@sortingnamekeytemplatename}{#1}}

\newcommand*{\blx@sortnk@keypart}[1]{%
  \advance\blx@tempcnta\@ne
  \blx@tempcntb\z@
  \edef\blx@tempd{ order="\the\blx@tempcnta"}%
  \let\blx@tempb\@empty
  #1%
  \eappto\blx@tempa{%
    \blx@xml@sortingnamekeykeypart{\blx@tempd}{\blx@tempb}}}

\newcommand*{\blx@sortnk@literal}[1]{%
  \advance\blx@tempcntb\@ne
  \edef\blx@tempe{ order="\the\blx@tempcntb"}%
  \let\blx@tempc\@empty
  \eappto\blx@tempb{%
    \blx@xml@sortingnamekeyliteral{\blx@tempe}{#1}}}

\newcommand*{\blx@sortnk@visibility}[1]{%
  \csgdef{blx@sortingnamekeytemplatesvisibility@\blx@snkname}{#1}}

\newcommand*{\blx@sortnk@namepart}[2][]{%
  \advance\blx@tempcntb\@ne
  \edef\blx@tempe{ order="\the\blx@tempcntb"}%
  \let\blx@tempc\@empty
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@sortnk@namepart}{#1}}%
  \eappto\blx@tempb{%
    \blx@xml@sortingnamekeynamepart{\blx@tempe}{\blx@tempc}{#2}}}

\blx@kv@defkey{blx@sortnk@namepart}{use}[true]{% use* option for namepart true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ use="1"}}
    {\appto\blx@tempc{ use="0"}}}

\blx@kv@defkey{blx@sortnk@namepart}{inits}[true]{% initials only option for namepart true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ inits="1"}}
    {\appto\blx@tempc{ inits="0"}}}

% [options]{&lt;templatename&gt;}{&lt;template&gt;}
\newrobustcmd*{\DeclareSortingTemplate}[3][]{%
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@sortdef@sorting}{#1}%
     \csxdef{blx@sortdef@locale@#2}{\blx@templ}}%
  \begingroup
  \def\name{%LEGACY(&lt;2.0)
    \blx@warning@noline{%
      '\string\name' is deprecated in sorting specifications, please use '\string\field'}%
    \blx@sortdef@field}%
  \def\list{%LEGACY(&lt;2.0)
    \blx@warning@noline{%
      '\string\list' is deprecated in sorting specifications, please use '\string\field'}%
    \blx@sortdef@field}%
  \let\sort\blx@sortdef@sort
  \let\field\blx@sortdef@field
  \let\literal\blx@sortdef@literal
  \global\csundef{blx@sortingtemplate@citeorder@relevant@#2}%
  \def\citeorder{%
    \global\cslet{blx@sortingtemplate@citeorder@relevant@#2}\@empty
    \blx@sortdef@field{citeorder}}%
  \def\intciteorder{%
    \blx@sortdef@field{intciteorder}}%
  \def\citecount{%
    \blx@sortdef@field{citecount}}%
  \blx@tempcnta\z@
  \let\blx@tempa\@empty
  #3%
  \global\cslet{blx@sortingtemplate@#2}\blx@tempa
  \endgroup}
\@onlypreamble\DeclareSortingTemplate
\blx@DeclareBackendOption{global}[xml]{sortingtemplate}

\blx@kv@defkey{blx@sortdef@sorting}{locale}{% locale name
  \def\blx@templ{#1}}

\newcommand*{\blx@sortdef@sort}[2][]{%
  \advance\blx@tempcnta\@ne
  \blx@tempcntb\z@
  \let\blx@tempb\@empty
  \edef\blx@tempc{order="\the\blx@tempcnta"}%
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@sortdef@sort}{#1}}%
  \let\do\@firstofone
  #2%
  \eappto\blx@tempa{%
    \blx@xml@sort{\blx@tempc}{\blx@tempb}}}

\blx@kv@defkey{blx@sortdef@sort}{locale}{% locale name
  \eappto\blx@tempc{ locale="#1"}}
\blx@kv@defkey{blx@sortdef@sort}{direction}{% ascending|descending
  \ifstrequal{#1}{ascending}
    {\eappto\blx@tempc{ sort\string_direction="ascending"}}
    {\eappto\blx@tempc{ sort\string_direction="descending"}}}
\blx@kv@defkey{blx@sortdef@sort}{final}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ final="1"}}
    {}}
\blx@kv@defkey{blx@sortdef@sort}{sortcase}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ sortcase="1"}}
    {\appto\blx@tempc{ sortcase="0"}}}
\blx@kv@defkey{blx@sortdef@sort}{sortupper}[true]{% true|false
  \ifstrequal{#1}{true}
    {\appto\blx@tempc{ sortupper="1"}}
    {\appto\blx@tempc{ sortupper="0"}}}

\newcommand*{\blx@sortdef@field}[2][]{%
  \advance\blx@tempcntb\@ne
  \edef\blx@tempd{order="\the\blx@tempcntb"}%
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@sortdef@field}{#1}}%
  \eappto\blx@tempb{%
    \blx@xml@sortitem{\blx@tempd}{#2}}}

\blx@kv@defkey{blx@sortdef@field}{padside}{% left|right
  \ifstrequal{#1}{right}
    {\eappto\blx@tempd{ pad\string_side="right"}}
    {\eappto\blx@tempd{ pad\string_side="left"}}}
\blx@kv@defkey{blx@sortdef@field}{padwidth}{% integer
  \eappto\blx@tempd{ pad\string_width="#1"}}
\blx@kv@defkey{blx@sortdef@field}{padchar}{% character
  \blx@xmlsanitizeafter{\def\blx@tempe}{#1}%
  \eappto\blx@tempd{ pad\string_char="\blx@tempe"}}
\blx@kv@defkey{blx@sortdef@field}{strside}{% left|right
  \ifstrequal{#1}{right}
    {\eappto\blx@tempd{ substring\string_side="right"}}
    {\eappto\blx@tempd{ substring\string_side="left"}}}
\blx@kv@defkey{blx@sortdef@field}{strwidth}{% integer
  \eappto\blx@tempd{ substring\string_width="#1"}}

\def\blx@sortdef@literal#1{%
  \advance\blx@tempcntb\@ne
  \blx@xmlsanitizeafter{\def\blx@tempe}{#1}%
  \eappto\blx@tempb{%
    \blx@xml@sortitem{literal="1" order="\the\blx@tempcntb"}{\blx@tempe}}}

% [&lt;type,type,...&gt;]{&lt;string&gt;}
\newrobustcmd*{\DeclarePresort}[2][]{%
  \begingroup
  \blx@xmlsanitizeafter{\def\blx@tempa}{#2}%
  \ifblank{#1}
    {\xdef\blx@bcf@presort{\blx@xml@presort{}{\blx@tempa}}}
    {\notblank{#2}
       {\forcsvlist{\blx@defpresort\blx@tempa}{#1}}
       {\forcsvlist\blx@undefpresort{#1}}}%
  \endgroup}
\@onlypreamble\DeclarePresort
\blx@DeclareBackendOption{global,type,entry}[string]{presort}

\def\blx@defpresort#1#2{%
  \csxdef{blx@bcf@presort@#2}{\blx@xml@presort{#2}{#1}}}
\def\blx@undefpresort#1{%
  \global\csundef{blx@bcf@presort@#1}}

% {&lt;entrytype,...&gt;}{&lt;field,...&gt;}
\newrobustcmd*{\DeclareSortExclusion}[2]{%
  \forcsvlist{\blx@sortexclude{#2}}{#1}}
\blx@DeclareBackendOption{type}[xml]{sortexclusion}

% {&lt;field&gt;}{&lt;entrytype&gt;}
\def\blx@sortexclude#1#2{%
  \begingroup
  \ifblank{#1}
    {\global\csundef{blx@bcf@exclude@#2}}
    {\let\blx@tempa\@empty
     \forcsvlist\blx@sortexclude@i{#1}%
     \csxdef{blx@bcf@exclude@#2}{%
       \blx@xml@sortexclude{#2}{\blx@tempa}}}
  \endgroup}

\def\blx@sortexclude@i#1{%
  \appto\blx@tempa{\blx@xml@exclude{#1}}}

% {&lt;entrytype,...&gt;}{&lt;field,...&gt;}
\newrobustcmd*{\DeclareSortInclusion}[2]{%
  \forcsvlist{\blx@sortinclude{#2}}{#1}}
\blx@DeclareBackendOption{type}[xml]{sortinclusion}

% {&lt;field&gt;}{&lt;entrytype&gt;}
\def\blx@sortinclude#1#2{%
  \begingroup
  \ifblank{#1}
    {\global\csundef{blx@bcf@include@#2}}
    {\let\blx@tempa\@empty
     \forcsvlist\blx@sortinclude@i{#1}%
     \csxdef{blx@bcf@include@#2}{%
       \blx@xml@sortinclude{#2}{\blx@tempa}}}
  \endgroup}

\def\blx@sortinclude@i#1{%
  \appto\blx@tempa{\blx@xml@include{#1}}}

% {&lt;field,field,...&gt;}
\newrobustcmd*{\DeclareExtradate}[1]{%
  \begingroup
  \let\blx@tempa\@empty
  \let\scope\blx@extradate@scope
  #1%
  \global\let\blx@bcf@extradatespec\blx@tempa
  \endgroup}
\@onlypreamble\DeclareExtradate
\blx@DeclareBackendOption{global}[xml]{extradatespec}

\newrobustcmd*{\blx@extradate@scope}[1]{%
  \let\blx@tempb\@empty
  \let\field\blx@ordereded@field
  #1%
  \csxappto{blx@tempa}{%
    \noexpand\blx@xml@extradatescope{\blx@tempb}}}

\newcommand*{\blx@ordereded@field}[1]{%
  \advance\blx@tempcnta\@ne
    \csxappto{blx@tempb}{%
      \noexpand\blx@xml@edordered{\the\blx@tempcnta}{#1}}}

% [&lt;type,type,...&gt;]{&lt;field,field,...&gt;}
\newrobustcmd*{\DeclareExtradateContext}[2][]{%
  \begingroup
  \let\blx@tempa\@empty
  \def\blx@tempb{extradatecontext}%
  \let\field\blx@ordered@field
  \ifblank{#1}
    {\global\cslet{blx@bcf@extradatecontext}\@empty}
    {\def\blx@tempa{#1}%
     \def\do##1{\global\cslet{blx@bcf@extradatecontext@##1}\@empty}%
     \expandafter\docsvlist\expandafter{#1}}%
  #2%
  \endgroup}
\@onlypreamble\DeclareExtradateContext
\blx@DeclareBackendOption{global,type}[xml]{extradatecontext}
  
\newrobustcmd*{\DeclareLabelname}[2][]{%
  \begingroup
  \let\blx@tempa\@empty
  \def\blx@tempb{labelnamespec}%
  \let\field\blx@ordered@field
  \ifblank{#1}
    {\global\cslet{blx@bcf@labelnamespec}\@empty}
    {\def\blx@tempa{#1}%
     \def\do##1{\global\cslet{blx@bcf@labelnamespec@##1}\@empty}%
     \expandafter\docsvlist\expandafter{#1}}%
  #2%
  \endgroup}
\@onlypreamble\DeclareLabelname
\blx@DeclareBackendOption{global,type}[xml]{labelnamespec}

\newrobustcmd*{\DeclareLabeltitle}[2][]{%
  \begingroup
  \let\blx@tempa\@empty
  \def\blx@tempb{labeltitlespec}%
  \let\field\blx@ordered@field
  \ifblank{#1}
    {\global\cslet{blx@bcf@labeltitlespec}\@empty}
    {\def\blx@tempa{#1}%
     \def\do##1{\global\cslet{blx@bcf@labeltitlespec@##1}\@empty}%
     \expandafter\docsvlist\expandafter{#1}}%
  #2%
  \endgroup}
\@onlypreamble\DeclareLabeltitle
\blx@DeclareBackendOption{global,type}[xml]{labeltitlespec}

\newrobustcmd*{\DeclareLabeldate}[2][]{%
  \begingroup
  \let\blx@tempa\@empty
  \def\blx@tempb{labeldatespec}%
  \let\field\blx@orderedld@field
  \let\literal\blx@orderedld@literal
  \ifblank{#1}
    {\global\cslet{blx@bcf@labeldatespec}\@empty}
    {\def\blx@tempa{#1}%
     \def\do##1{\global\cslet{blx@bcf@labeldatespec@##1}\@empty}%
     \expandafter\docsvlist\expandafter{#1}}%
  #2%
  \endgroup}
\@onlypreamble\DeclareLabeldate
\blx@DeclareBackendOption{global,type}[xml]{labeldatespec}

\newcommand*{\blx@ordered@field}[2][]{%
  \let\blx@tempc\@empty
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@ordered@field}{#1}}%
  \advance\blx@tempcnta\@ne
  \ifdefempty{\blx@tempa}
    {\csxappto{blx@bcf@\blx@tempb}{%
       \noexpand\blx@xml@ordered{\the\blx@tempcnta}{\blx@tempc}{#2}}}
    {\def\do##1{%
       \blx@addtypeopt{##1}%
       \csxappto{blx@bcf@\blx@tempb @##1}{%
         \noexpand\blx@xml@ordered{\the\blx@tempcnta}{\blx@tempc}{#2}}}%
     \expandafter\docsvlist\expandafter{\blx@tempa}}}

\newcommand*{\blx@orderedld@field}[2][]{%
  \let\blx@tempc\@empty
  \ifblank{#1}
    {}
    {\blx@kv@setkeys{blx@ordered@field}{#1}}%
  \advance\blx@tempcnta\@ne
  \ifdefempty{\blx@tempa}
    {\csxappto{blx@bcf@\blx@tempb}{%
       \noexpand\blx@xml@ordered{\the\blx@tempcnta}{ type="field"\blx@tempc}{#2}}}
    {\def\do##1{%
       \blx@addtypeopt{##1}%
       \csxappto{blx@bcf@\blx@tempb @##1}{%
         \noexpand\blx@xml@ordered{\the\blx@tempcnta}{ type="field"\blx@tempc}{#2}}}%
     \expandafter\docsvlist\expandafter{\blx@tempa}}}

\newcommand*{\blx@orderedld@literal}[1]{%
  \advance\blx@tempcnta\@ne
  \ifdefempty{\blx@tempa}
    {\csxappto{blx@bcf@\blx@tempb}{%
       \noexpand\blx@xml@ordered{\the\blx@tempcnta}{ type="string"}{#1}}}
    {\def\do##1{%
       \blx@addtypeopt{##1}%
       \csxappto{blx@bcf@\blx@tempb @##1}{%
         \noexpand\blx@xml@ordered{\the\blx@tempcnta}{ type="string"}{#1}}}%
     \expandafter\docsvlist\expandafter{\blx@tempa}}}

%% Package options

% [&lt;entrytype,entrytype,...&gt;]{&lt;options&gt;}
\newrobustcmd*{\ExecuteBibliographyOptions}[2][]{%
  \ifblank{#1}
    {\blx@kv@setkeys{blx@opt@pre}{#2}}
    {\forcsvlist{\blx@typeoptions{#2}}{#1}}}
\@onlypreamble\ExecuteBibliographyOptions

\def\blx@typeoptions#1#2{%
  \blx@addtypeopt{#2}%
  \csappto{blx@opts@type@#2}{#1,}}

\def\blx@addtypeopt#1{%
  \notblank{#1}
    {\ifdef\blx@opts@type
       {\ifinlist{#1}\blx@opts@type
          {}
          {\listgadd\blx@opts@type{#1}}}
       {\listgadd\blx@opts@type{#1}}}
    {}}

% load-time only

% Have to have a dummy for this as it's set much earlier but is passed
% through to here where we just ignore it
\blx@kv@defkey{blx@opt@ldt}{datamodel}{}

\blx@kv@defkey{blx@opt@ldt}{backend}{%
  \ifstrequal{#1}{biber}
    {}
    {\ifboolexpr{
       test {\ifstrequal{#1}{bibtex}}
       or
       test {\ifstrequal{#1}{bibtex8}}}
       {\settoggle{blx@bibtex}{true}%
        \newtoggle{blx@bibtex8}%
        \ifstrequal{#1}{bibtex8}
          {\settoggle{blx@bibtex8}{true}}
          {}}%
       {\blx@err@invopt{backend=#1}{}}}}

\blx@kv@defkey{blx@opt@ldt}{style}{%
  \def\blx@cbxfile{#1}%
  \def\blx@bbxfile{#1}}

\blx@kv@defkey{blx@opt@ldt}{bibstyle}{%
  \def\blx@bbxfile{#1}}

\blx@kv@defkey{blx@opt@ldt}{citestyle}{%
  \def\blx@cbxfile{#1}}

\blx@kv@defkey{blx@opt@ldt}{natbib}[true]{%
  \settoggle{blx@natbib}{#1}}

\blx@kv@defkey{blx@opt@ldt}{mcite}[true]{%
  \settoggle{blx@mcite}{#1}}

\blx@kv@defkey{blx@opt@ldt}{noerroretextools}[true]{%
  \blx@warning@noline{%
    The option 'noerroretextools' is deprecated.\MessageBreak
    Define the control sequence '\string\blx@noerroretextools'\MessageBreak
    before loading biblatex instead}%
  \ifstrequal{#1}{true}
    {\global\cslet{blx@noerroretextools}\@empty}
    {\global\csundef{blx@noerroretextools}}}

% load-time and preamble

\DeclareBibliographyOption[boolean]{debug}[true]{%
  \settoggle{blx@debug}{#1}}

\DeclareBibliographyOption[boolean]{loadfiles}[true]{%
  \settoggle{blx@loadfiles}{#1}}

\DeclareBibliographyOption[integer]{mincrossrefs}{%
  \ifnum#1&lt;\z@
    \def\blx@mincrossrefs{1}%
  \else
    \def\blx@mincrossrefs{#1}%
  \fi}

\DeclareBibliographyOption[integer]{minxrefs}{%
  \ifnum#1&lt;\z@
    \def\blx@minxrefs{1}%
  \else
    \def\blx@minxrefs{#1}%
  \fi}
\def\blx@minxrefs{2}

\DeclareBibliographyOption[string]{texencoding}{%
  \ifstrequal{#1}{auto}
    {\undef\blx@texencoding@fromoption}
    {\def\blx@texencoding@fromoption{#1}}}

\DeclareBibliographyOption[string]{bibencoding}{%
  \ifcsdef{blx@bibenc@#1}
    {\letcs\blx@bibencoding{blx@bibenc@#1}}
    {\def\blx@bibencoding{#1}}}

\def\abx@mapbibenc#1#2{\csdef{blx@bibenc@#1}{#2}}
\abx@mapbibenc{inputenc}{auto}
\abx@mapbibenc{x-ascii}{ascii}

\def\abx@mapinpenc#1#2{\csdef{blx@inpenc@#1}{#2}}
\abx@mapinpenc{utf8x}{utf8}
\abx@mapinpenc{lutf8}{utf8}
\abx@mapinpenc{x-ascii}{ascii}

\DeclareBibliographyOption[boolean]{safeinputenc}[true]{%
  \settoggle{blx@safeinputenc}{#1}}
\newtoggle{blx@safeinputenc}

% global "sorting" option becomes "sortingtemplatename" in the .bcf and so
% don't use \DeclareBibliographyOption. This is a legacy naming issue
% unlikely to be corrected as "sorting" is an obvious name for biblatex users
% "sorting" is used in the .bcf for the actual sorting template definitions and is
% an XML format option
\blx@kv@defkey{blx@opt@pre}{sorting}{%
  \def\blx@sorting{#1}%
  \def\blx@refcontext@sortingtemplatename{#1}}
\blx@DeclareBackendOption{global}[string]{sortingtemplatename}

\AtEndPreamble{%
  \ifcsdef{blx@sortingtemplate@\blx@sorting}
    {}
    {\blx@err@invopt{sorting=\blx@sorting}{}%
     \def\blx@sorting{nty}%
     \def\blx@refcontext@sortingtemplatename{nty}}%
  \listxadd\blx@sortingtemplatenames\blx@sorting
  \def\blx@refcontext@sortingnamekeytemplatename{global}%
  \let\blx@refcontext@labelprefix\@empty
  \let\blx@refcontext@labelprefix@real\@empty
  \def\blx@refcontext@uniquenametemplatename{global}%
  \def\blx@refcontext@labelalphanametemplatename{global}%
  \def\blx@refcontext@namehashtemplatename{global}%
  \blx@xdef@refcontext{%
    \blx@refcontext@sortingtemplatename/%
    \blx@refcontext@sortingnamekeytemplatename/%
    \blx@refcontext@labelprefix/%
    \blx@refcontext@uniquenametemplatename/%
    \blx@refcontext@labelalphanametemplatename/%
    \blx@refcontext@namehashtemplatename}%
  \listxadd\blx@refcontexts\blx@refcontext@context}

\DeclareBibliographyOption[boolean]{sortcase}[true]{%
  \settoggle{blx@sortcase}{#1}}

\DeclareBibliographyOption[boolean]{sortupper}[true]{%
  \settoggle{blx@sortupper}{#1}}

\DeclareBiblatexOption{global,type}[integer]{maxnames}{%
  \numdef\blx@maxcitenames{#1}%
  \numdef\blx@maxbibnames{#1}%
  \numdef\blx@maxsortnames{#1}%
  \c@maxnames#1\relax}
\DeclareBiblatexOption{global,type}[integer]{minnames}{%
  \numdef\blx@mincitenames{#1}%
  \numdef\blx@minbibnames{#1}%
  \numdef\blx@minsortnames{#1}%
  \c@minnames#1\relax}
% the per-entry option is resolved by Biber directly
\blx@DeclareBackendOption{entry}[integer]{maxnames}
\blx@DeclareBackendOption{entry}[integer]{minnames}
\gdef\blx@bcf@backendin@entry@maxnames{maxcitenames,maxbibnames,maxsortnames}%
\gdef\blx@bcf@backendin@entry@minnames{mincitenames,minbibnames,minsortnames}%


\DeclareBiblatexOption{global,type,entry}[integer]{maxbibnames}{%
  \numdef\blx@maxbibnames{#1}%
  \numdef\blx@maxsortnames{#1}%
  \iftoggle{blx@bibliography}
    {\c@maxnames#1\relax}
    {}}
\DeclareBiblatexOption{global,type,entry}[integer]{minbibnames}{%
  \numdef\blx@minbibnames{#1}%
  \numdef\blx@minsortnames{#1}%
  \iftoggle{blx@bibliography}
    {\c@minnames#1\relax}
    {}}

\DeclareBiblatexOption{global,type,entry}[integer]{maxcitenames}{%
  \numdef\blx@maxcitenames{#1}%
  \iftoggle{blx@bibliography}
    {}
    {\c@maxnames#1\relax}}
\DeclareBiblatexOption{global,type,entry}[integer]{mincitenames}{%
  \numdef\blx@mincitenames{#1}%
  \iftoggle{blx@bibliography}
    {}
    {\c@minnames#1\relax}}

\DeclareBiblatexOption{global,type,entry}[integer]{maxsortnames}{%
  \numdef\blx@maxsortnames{#1}}
\DeclareBiblatexOption{global,type,entry}[integer]{minsortnames}{%
  \numdef\blx@minsortnames{#1}}

\appto\blx@checkoptions@global{%
  \blx@maxmin@num{maxbibnames}{minbibnames}\blx@maxbibnames\blx@minbibnames
  \blx@maxmin@num{maxcitenames}{mincitenames}\blx@maxcitenames\blx@mincitenames
  \blx@maxmin@num{maxsortnames}{minsortnames}\blx@maxsortnames\blx@minsortnames}
\appto\blx@checkoptions@type{%
  \blx@maxmin@num{maxbibnames}{minbibnames}\blx@maxbibnames\blx@minbibnames
  \blx@maxmin@num{maxcitenames}{mincitenames}\blx@maxcitenames\blx@mincitenames
  \blx@maxmin@num{maxsortnames}{minsortnames}\blx@maxsortnames\blx@minsortnames}
\appto\blx@checkoptions@entry{%
  \blx@maxmin@cnt{maxnames}{minnames}\c@maxnames\c@minnames}

\DeclareBiblatexOption{global,type,entry}[integer]{maxitems}{%
  \numdef\blx@maxitems{#1}%
  \c@maxitems#1\relax}
\DeclareBiblatexOption{global,type,entry}[integer]{minitems}{%
  \numdef\blx@minitems{#1}%
  \c@minitems#1\relax}

\appto\blx@checkoptions@global{%
  \blx@maxmin@num{maxitems}{minitems}\blx@maxitems\blx@minitems}
\appto\blx@checkoptions@type{%
  \blx@maxmin@num{maxitems}{minitems}\blx@maxitems\blx@minitems}
\appto\blx@checkoptions@entry{%
  \blx@maxmin@cnt{maxitems}{minitems}\c@maxitems\blx@minitems}

\DeclareBiblatexOption{global,type,entry}[integer]{maxalphanames}{%
  \numdef\blx@maxalphanames{#1}}
\DeclareBiblatexOption{global,type,entry}[integer]{minalphanames}{%
  \numdef\blx@minalphanames{#1}}

\appto\blx@checkoptions@global{%
  \blx@maxmin@num{maxalphanames}{minalphanames}\blx@maxalphanames\blx@minalphanames}
\appto\blx@checkoptions@type{%
  \blx@maxmin@num{maxalphanames}{minalphanames}\blx@maxalphanames\blx@minalphanames}

\def\blx@maxmin@num#1#2#3#4{%
  \ifnumless#3\@ne
    {\blx@err@invopt{#1=#3}{'#1' must be greater than zero}%
     \let#3\@ne}
    {}%
  \ifnumless#4\@ne
    {\blx@err@invopt{#2=#4}{'#2' must be greater than zero}%
     \let#4\@ne}
    {}%
  \ifnumless#3#4
    {\blx@err@confopt{#1/#2}{'#1' must be greater than or equal to '#2'}%
     \let#3#4}
    {}}

\def\blx@maxmin@cnt#1#2#3#4{%
  \ifnumless#3\@ne
    {\blx@err@invopt{#1=\number#3}{'#1' must be greater than zero}%
     #3\@ne}
    {}%
  \ifnumless#4\@ne
    {\blx@err@invopt{#2=\number#4}{'#2' must be greater than zero}%
     #4\@ne}
    {}%
  \ifnumless#3#4
    {\blx@err@confopt{#1/#2}{'#1' must be greater than or equal to '#2'}%
     #3=#4}
    {}}

\DeclareBiblatexOption{global,type,entry,namelist,name}[boolean]{terseinits}[true]{%
  \ifstrequal{#1}{true}
    {\toggletrue{blx@terseinits}
     \renewrobustcmd*{\bibinitperiod}{}
     \renewrobustcmd*{\bibinitdelim}{}
     \renewrobustcmd*{\bibinithyphendelim}{}}
    {\togglefalse{blx@terseinits}
     \renewrobustcmd*{\bibinitperiod}{\adddot}
     \renewrobustcmd*{\bibinitdelim}{\addnbspace}
     \renewrobustcmd*{\bibinithyphendelim}{\adddot\mbox{-}}}}

\DeclareBiblatexOption{global,type,entry}[boolean]{abbreviate}[true]{%
  \ifstrequal{#1}{true}
    {\def\abx@str{abx@sstr}}
    {\def\abx@str{abx@lstr}}}

\DeclareBiblatexOption{global,type,entry}[boolean]{dateabbrev}[true]{%
  \ifstrequal{#1}{true}
    {\let\abx@bibmonth\blx@imc@bibsstring
     \let\abx@bibyeardivision\blx@imc@bibsstring}
    {\let\abx@bibmonth\blx@imc@biblstring
     \let\abx@bibyeardivision\blx@imc@biblstring}}

\DeclareBibliographyOption[string]{sortlocale}{%
  \edef\blx@sortlocale{\detokenize{#1}}}

\DeclareBibliographyOption[string]{language}{%
  \togglefalse{blx@autolangbib}%
  \togglefalse{blx@autolangcite}%
  \undef\blx@languagename
  \undef\blx@forcelanguagename
  \ifboolexpr{
    test {\ifstrequal{#1}{auto}}
    or
    test {\ifstrequal{#1}{autobib}}
    or
    test {\ifstrequal{#1}{autocite}}
  }
  {\def\blx@languagename{english}%
   \ifstrequal{#1}{auto}
    {\toggletrue{blx@autolangbib}%
     \toggletrue{blx@autolangcite}}
    {}%
   \ifstrequal{#1}{autobib}
    {\toggletrue{blx@autolangbib}}
    {}%
   \ifstrequal{#1}{autocite}
    {\toggletrue{blx@autolangcite}}
    {}}
  % If language is explicit, we do want to auto-switch but only to the
  % selected language
  {\IfFileExists{#1.lbx}
    {\toggletrue{blx@autolangbib}%
     \toggletrue{blx@autolangcite}%
     \edef\blx@languagename{#1}%
     \edef\blx@forcelanguagename{#1}}
    {\blx@error
      {Language '#1' not supported}
      {Failed to find a matching '#1.lbx' file}}}}

\DeclareBiblatexOption{global,type,entry}[boolean]{clearlang}[true]{%
  \settoggle{blx@clearlang}{#1}}

\DeclareBibliographyOption[string]{autolang}{%
  \blx@autolang@i{#1}}

\def\blx@autolang@i#1{%
  \ifcsdef{blx@opt@autolang@#1}
    {\csuse{blx@opt@autolang@#1}}
    {\blx@err@invopt{autolang=#1}{}}}

\def\blx@opt@autolang@none{%
  \undef\blx@thelangenv
  \let\blx@hook@initlang\@empty
  \let\blx@hook@endlang\@empty}
\def\blx@opt@autolang@hyphen{%
  \def\blx@thelangenv{hyphenrules}%
  \let\blx@hook@initlang\@empty
  \let\blx@hook@endlang\@empty}
\csdef{blx@opt@autolang@other*}{%
  \def\blx@thelangenv{otherlanguage*}%
  \def\blx@hook@initlang{\@quotereset\@ne}%
  \def\blx@hook@endlang{\blx@postpunct}}
\def\blx@opt@autolang@other{%
  \def\blx@thelangenv{otherlanguage}%
  \def\blx@hook@initlang{\@quotereset\@ne}%
  \def\blx@hook@endlang{\blx@postpunct}}
\def\blx@opt@autolang@langname{%
  \@ifpackageloaded{polyglossia}
    {\def\blx@thelangenv{langname}}
    {\def\blx@thelangenv{otherlanguage}}%
  \def\blx@hook@initlang{\@quotereset\@ne}%
  \def\blx@hook@endlang{\blx@postpunct}}

\DeclareBibliographyOption[string]{langhook}{%
  \ifstrequal{#1}{captions}
    {\@firstoftwo}
    {\ifstrequal{#1}{extras}}
    {\def\blx@langhook{#1}}
    {\blx@err@invopt{langhook=#1}{}}}


\DeclareBiblatexOption{global,type,entry}[string]{indexing}[true]{%
  \blx@opt@index{#1}}
\def\blx@opt@index#1{%
  \ifcsdef{blx@opt@index@#1}
    {\csuse{blx@opt@index@#1}}
    {\blx@err@invopt{indexing=#1}{}}}
\def\blx@opt@index@true{%
  \toggletrue{blx@citeindex}%
  \toggletrue{blx@bibindex}}
\def\blx@opt@index@false{%
  \togglefalse{blx@citeindex}%
  \togglefalse{blx@bibindex}}
\def\blx@opt@index@cite{%
  \toggletrue{blx@citeindex}%
  \togglefalse{blx@bibindex}}
\def\blx@opt@index@bib{%
  \togglefalse{blx@citeindex}%
  \toggletrue{blx@bibindex}}

\DeclareBibliographyOption[boolean]{sortcites}[true]{%
  \ifstrequal{#1}{true}
    {\let\blx@thecitesort\blx@citesort
     \let\blx@thenotecheck\blx@notecheck
     \booltrue{sortcites}}
    {\let\blx@thecitesort\blx@citenosort
     \let\blx@thenotecheck\relax}}

\DeclareBibliographyOption[boolean]{sortsets}[true]{%
  \settoggle{blx@sortsets}{#1}}

\DeclareBibliographyOption[string]{hyperref}[true]{%
  \ifcsdef{blx@opt@hyperref@#1}
    {\letcs\blx@hyperref{blx@opt@hyperref@#1}}
    {\blx@err@invopt{hyperref=#1}{}}}
\def\blx@opt@hyperref@false{0}
\def\blx@opt@hyperref@true{1}
\def\blx@opt@hyperref@auto{2}
\def\blx@opt@hyperref@manual{3}

\def\blx@warn@usedmanualhyperrefs#1{%
  \blx@warning@noline{The command '\string#1' can\MessageBreak
    only be used with 'hyperref=manual'}}
\def\blx@warn@multiplemanualhyperrefs{%
  \blx@warning@noline{You must call either '\string\BiblatexManualHyperrefOn'\MessageBreak
    or '\string\BiblatexManualHyperrefOff' exactly once.\MessageBreak
    Subsequent calls to either command will be ignored}}
\def\BiblatexManualHyperrefOn{%
  \ifnum\blx@hyperref=\thr@@
    \blx@mkhyperref
    \global\undef\blx@mkhyperref
    \global\undef\blx@mknohyperref
    \global\let\BiblatexManualHyperrefOn\blx@warn@multiplemanualhyperrefs
    \global\let\BiblatexManualHyperrefOff\blx@warn@multiplemanualhyperrefs
  \else
    \blx@warn@usedmanualhyperrefs{\BiblatexManualHyperrefOn}%
  \fi}
\def\BiblatexManualHyperrefOff{%
  \ifnum\blx@hyperref=\thr@@
    \blx@mknohyperref
    \global\undef\blx@mkhyperref
    \global\undef\blx@mknohyperref
    \global\let\BiblatexManualHyperrefOn\blx@warn@multiplemanualhyperrefs
    \global\let\BiblatexManualHyperrefOff\blx@warn@multiplemanualhyperrefs
  \else
    \blx@warn@usedmanualhyperrefs{\BiblatexManualHyperrefOff}%
  \fi}

\DeclareBibliographyOption[boolean]{backref}[true]{%
  \ifstrequal{#1}{true}
    {\let\blx@backref\blx@addbackref
     \let\abx@aux@backref\blx@aux@backref
     \booltrue{backtracker}}
    {\let\blx@backref\@gobble
     \let\abx@aux@backref\@gobblefive
     \boolfalse{backtracker}}}

\DeclareBibliographyOption[string]{backrefsetstyle}{%
  \ifcsdef{blx@opt@backrefsetstyle@#1}
    {\letcs\blx@backrefsetstyle{blx@opt@backrefsetstyle@#1}}
    {\blx@err@invopt{backrefsetstyle=#1}{}}}
\def\blx@opt@backrefsetstyle@setonly{0}
\def\blx@opt@backrefsetstyle@memonly{1}
\def\blx@opt@backrefsetstyle@setormem{2}
\def\blx@opt@backrefsetstyle@setandmem{3}
\def\blx@opt@backrefsetstyle@memandset{4}
\def\blx@opt@backrefsetstyle@setplusmem{5}

\newtoggle{blx@backreffloats}
\DeclareBibliographyOption[boolean]{backreffloats}[true]{%
  \settoggle{blx@backreffloats}{#1}}

\appto\blx@mkhyperref{%
  \ifHy@plainpages
    \blx@warning@noline{%
      hyperref package option 'plainpages' enabled.\MessageBreak
      This may cause problems with hyperlinked back\MessageBreak
      references. 'plainpages=false' is recommended}%
  \fi
  \ifHy@pageanchor\else
    \blx@warning@noline{%
      hyperref package option 'pageanchor' disabled.\MessageBreak
      This will cause problems with hyperlinked back\MessageBreak
      references. 'pageanchor=true' is required}%
  \fi}

\def\blx@optprocess@block#1{%
  \ifcsdef{blx@opt@block@#1}
    {\csuse{blx@opt@block@#1}}
    {\blx@err@invopt{block=#1}{}}}

\DeclareBibliographyOption[string]{block}{%
  \blx@optprocess@block{#1}}

\blx@kv@defkey{blx@bib1}{block}{}
\blx@kv@defkey{blx@bib2}{block}{\blx@optprocess@block{#1}}
\blx@kv@defkey{blx@biblist1}{block}{}
\blx@kv@defkey{blx@biblist2}{block}{\blx@optprocess@block{#1}}

\blx@kv@defkey{blx@bbs}{block}{\blx@optprocess@block{#1}}
\blx@kv@defkey{blx@bbg}{block}{\blx@optprocess@block{#1}}

\def\blx@opt@block@none{%
  \let\blx@bibsetup\@empty
  \let\newblockpunct\@empty}
\def\blx@opt@block@par{%
  \let\blx@bibsetup\@empty
  \def\newblockpunct{\par}}
\def\blx@opt@block@nbpar{%
  \def\blx@bibsetup{\interlinepenalty\@M}%
  \def\newblockpunct{\par\nobreak}}
\def\blx@opt@block@space{%
  \let\blx@bibsetup\@empty
  \def\newblockpunct{%
    \unspace\space
    \hskip  0.11em
    \@plus  0.33em
    \@minus 0.07em}}
\def\blx@opt@block@ragged{%
  \let\blx@bibsetup\raggedright
  \def\newblockpunct{%
    \unspace\penalty-9\relax\space}}

\DeclareBibliographyOption[string]{pagetracker}[true]{%
  \ifcsdef{blx@opt@pagetracker@#1}
    {\csuse{blx@opt@pagetracker@#1}}
    {\blx@err@invopt{pagetracker=#1}{}}}
\def\blx@opt@pagetracker@true{%
  \if@twoside
    \blx@opt@pagetracker@spread
  \else
    \blx@opt@pagetracker@page
  \fi}
\def\blx@opt@pagetracker@false{%
  \let\blx@pagetracker\relax
  \let\abx@aux@page\@gobbletwo
  \let\abx@aux@fnpage\@gobbletwo
  \boolfalse{pagetracker}}
\def\blx@opt@pagetracker@page{%
  \let\blx@pagetracker\blx@pagetracker@context
  \let\abx@aux@page\blx@aux@page
  \let\abx@aux@fnpage\blx@aux@fnpage
  \booltrue{pagetracker}}
\def\blx@opt@pagetracker@spread{%
  \if@twoside
    \let\blx@pagetracker\blx@pagetracker@context
    \let\abx@aux@page\blx@aux@spread
    \let\abx@aux@fnpage\blx@aux@fnspread
    \booltrue{pagetracker}%
  \else
    \blx@warning@noline{%
      LaTeX not in twoside mode\MessageBreak
      Falling back to 'pagetracker=page'}%
    \blx@opt@pagetracker@page
  \fi}

\DeclareBibliographyOption[string]{citecounter}[true]{%
  \ifcsdef{blx@opt@citecounter@#1}
    {\csuse{blx@opt@citecounter@#1}}
    {\blx@err@invopt{citecounter=#1}{}}}
\def\blx@opt@citecounter@true{%
  \let\blx@setcitecounter\blx@setcitecounter@global
  \let\blx@citecounter\blx@citecounter@global
  \let\abx@aux@count\blx@aux@count
  \let\abx@aux@fncount\blx@aux@fncount
  \let\abx@curr@count\blx@curr@count
  \let\abx@curr@fncount\blx@curr@fncount
  \booltrue{citetracker}}
\def\blx@opt@citecounter@context{%
  \let\blx@setcitecounter\blx@setcitecounter@context
  \let\blx@citecounter\blx@citecounter@context
  \let\abx@aux@count\blx@aux@count
  \let\abx@aux@fncount\blx@aux@fncount
  \let\abx@curr@count\blx@curr@count
  \let\abx@curr@fncount\blx@curr@fncount
  \booltrue{citetracker}}
\def\blx@opt@citecounter@false{%
  \let\blx@setcitecounter\relax
  \let\blx@citecounter\relax
  \let\abx@aux@count\@gobbletwo
  \let\abx@aux@fncount\@gobbletwo
  \let\abx@curr@count\@gobbletwo
  \let\abx@curr@fncount\@gobbletwo
  \boolfalse{citetracker}}

\DeclareBiblatexOption{global,type,entry}[string]{citetracker}[true]{%
  \ifcsdef{blx@opt@citetracker@#1}
    {\csuse{blx@opt@citetracker@#1}}
    {\blx@err@invopt{citetracker=#1}{}}}
\def\blx@opt@citetracker@true{%
  \let\blx@imc@ifciteseen\blx@ifciteseen@global
  \let\blx@imc@ifentryseen\blx@ifentryseen@global
  \let\blx@citetracker\blx@citetracker@global
  \booltrue{citetracker}}
\def\blx@opt@citetracker@false{%
  \let\blx@imc@ifciteseen\@secondoftwo
  \protected\long\def\blx@imc@ifentryseen##1##2##3{##3}%
  \let\blx@citetracker\relax}
\def\blx@opt@citetracker@context{%
  \let\blx@imc@ifciteseen\blx@ifciteseen@context
  \let\blx@imc@ifentryseen\blx@ifentryseen@context
  \let\blx@citetracker\blx@citetracker@context
  \booltrue{citetracker}}
\def\blx@opt@citetracker@strict{%
  \let\blx@imc@ifciteseen\blx@ifciteseen@global
  \let\blx@imc@ifentryseen\blx@ifentryseen@global
  \def\blx@citetracker{%
    \blx@ifcitesingle{\blx@citetracker@global}{}}%
  \booltrue{citetracker}}
\def\blx@opt@citetracker@constrict{%
  \let\blx@imc@ifciteseen\blx@ifciteseen@context
  \let\blx@imc@ifentryseen\blx@ifentryseen@context
  \def\blx@citetracker{%
    \blx@ifcitesingle{\blx@citetracker@context}{}}%
  \booltrue{citetracker}}

\DeclareBiblatexOption{global,type,entry}[string]{ibidtracker}[true]{%
  \ifcsdef{blx@opt@ibidtracker@#1}
    {\csuse{blx@opt@ibidtracker@#1}}
    {\blx@err@invopt{ibidtracker=#1}{}}}
\def\blx@opt@ibidtracker@true{%
  \let\blx@imc@ifciteibid\blx@ifciteibid@global
  \let\blx@ibidtracker\blx@ibidtracker@global
  \let\blx@ibidreset\blx@ibidreset@global
  \booltrue{citetracker}}
\def\blx@opt@ibidtracker@false{%
  \let\blx@imc@ifciteibid\@secondoftwo
  \let\blx@ibidtracker\relax
  \let\blx@ibidreset\relax}
\def\blx@opt@ibidtracker@context{%
  \let\blx@imc@ifciteibid\blx@ifciteibid@context
  \let\blx@ibidtracker\blx@ibidtracker@context
  \let\blx@ibidreset\blx@ibidreset@context
  \booltrue{citetracker}}
\def\blx@opt@ibidtracker@strict{%
  \let\blx@imc@ifciteibid\blx@ifciteibid@strict
  \let\blx@ibidtracker\blx@ibidtracker@strict
  \let\blx@ibidreset\blx@ibidreset@global
  \booltrue{citetracker}}
\def\blx@opt@ibidtracker@constrict{%
  \let\blx@imc@ifciteibid\blx@ifciteibid@constrict
  \let\blx@ibidtracker\blx@ibidtracker@constrict
  \let\blx@ibidreset\blx@ibidreset@context
  \booltrue{citetracker}}

\DeclareBiblatexOption{global,type,entry}[string]{idemtracker}[true]{%
  \ifcsdef{blx@opt@idemtracker@#1}
    {\csuse{blx@opt@idemtracker@#1}}
    {\blx@err@invopt{idemtracker=#1}{}}}
\def\blx@opt@idemtracker@true{%
  \let\blx@imc@ifciteidem\blx@ifciteidem@global
  \let\blx@idemtracker\blx@idemtracker@global
  \let\blx@idemreset\blx@idemreset@global
  \booltrue{citetracker}}
\def\blx@opt@idemtracker@false{%
  \let\blx@imc@ifciteidem\@secondoftwo
  \let\blx@idemtracker\relax
  \let\blx@idemreset\relax}
\def\blx@opt@idemtracker@context{%
  \let\blx@imc@ifciteidem\blx@ifciteidem@context
  \let\blx@idemtracker\blx@idemtracker@context
  \let\blx@idemreset\blx@idemreset@context
  \booltrue{citetracker}}
\def\blx@opt@idemtracker@strict{%
  \let\blx@imc@ifciteidem\blx@ifciteidem@strict
  \let\blx@idemtracker\blx@idemtracker@strict
  \let\blx@idemreset\blx@idemreset@global
  \booltrue{citetracker}}
\def\blx@opt@idemtracker@constrict{%
  \let\blx@imc@ifciteidem\blx@ifciteidem@constrict
  \let\blx@idemtracker\blx@idemtracker@constrict
  \let\blx@idemreset\blx@idemreset@context
  \booltrue{citetracker}}

\DeclareBiblatexOption{global,type,entry}[string]{opcittracker}[true]{%
  \ifcsdef{blx@opt@opcittracker@#1}
    {\csuse{blx@opt@opcittracker@#1}}
    {\blx@err@invopt{opcittracker=#1}{}}}
\def\blx@opt@opcittracker@true{%
  \let\blx@imc@ifopcit\blx@ifopcit@global
  \let\blx@opcittracker\blx@opcittracker@global
  \let\blx@opcitreset\blx@opcitreset@global
  \booltrue{citetracker}}
\def\blx@opt@opcittracker@false{%
  \let\blx@imc@ifopcit\@secondoftwo
  \let\blx@opcittracker\relax
  \let\blx@opcitreset\relax}
\def\blx@opt@opcittracker@context{%
  \let\blx@imc@ifopcit\blx@ifopcit@context
  \let\blx@opcittracker\blx@opcittracker@context
  \let\blx@opcitreset\blx@opcitreset@context
  \booltrue{citetracker}}
\def\blx@opt@opcittracker@strict{%
  \let\blx@imc@ifopcit\blx@ifopcit@strict
  \let\blx@opcittracker\blx@opcittracker@strict
  \let\blx@opcitreset\blx@opcitreset@global
  \booltrue{citetracker}}
\def\blx@opt@opcittracker@constrict{%
  \let\blx@imc@ifopcit\blx@ifopcit@constrict
  \let\blx@opcittracker\blx@opcittracker@constrict
  \let\blx@opcitreset\blx@opcitreset@context
  \booltrue{citetracker}}

\DeclareBiblatexOption{global,type,entry}[string]{loccittracker}[true]{%
  \ifcsdef{blx@opt@loccittracker@#1}
    {\csuse{blx@opt@loccittracker@#1}}
    {\blx@err@invopt{loccittracker=#1}{}}}
\def\blx@opt@loccittracker@true{%
  \let\blx@imc@ifloccit\blx@ifloccit@global
  \let\blx@loccittracker\blx@loccittracker@global
  \let\blx@loccitreset\blx@loccitreset@global
  \booltrue{citetracker}}
\def\blx@opt@loccittracker@false{%
  \let\blx@imc@ifloccit\@secondoftwo
  \let\blx@loccittracker\relax
  \let\blx@loccitreset\relax}
\def\blx@opt@loccittracker@context{%
  \let\blx@imc@ifloccit\blx@ifloccit@context
  \let\blx@loccittracker\blx@loccittracker@context
  \let\blx@loccitreset\blx@loccitreset@context
  \booltrue{citetracker}}
\def\blx@opt@loccittracker@strict{%
  \let\blx@imc@ifloccit\blx@ifloccit@strict
  \let\blx@loccittracker\blx@loccittracker@strict
  \let\blx@loccitreset\blx@loccitreset@global
  \booltrue{citetracker}}
\def\blx@opt@loccittracker@constrict{%
  \let\blx@imc@ifloccit\blx@ifloccit@constrict
  \let\blx@loccittracker\blx@loccittracker@constrict
  \let\blx@loccitreset\blx@loccitreset@context
  \booltrue{citetracker}}

\newtoggle{blx@trackfloats}
\DeclareBibliographyOption[boolean]{trackfloats}[true]{%
  \settoggle{blx@trackfloats}{#1}}


\DeclareBibliographyOption[boolean]{parentracker}[true]{%
  \ifstrequal{#1}{true}
    {\let\bibopenparen\blx@bibopenparen
     \let\bibcloseparen\blx@bibcloseparen
     \let\bibopenbracket\blx@bibopenbracket
     \let\bibclosebracket\blx@bibclosebracket}
    {\protected\def\bibopenparen{\bibleftparen}%
     \protected\def\bibcloseparen{\bibrightparen}%
     \protected\def\bibopenbracket{\bibleftbracket}%
     \protected\def\bibclosebracket{\bibrightbracket}}}

\DeclareBibliographyOption[integer]{maxparens}{%
  \ifnumless{#1}{1}
    {\blx@err@invopt{maxparens=#1}{}}
    {\setcounter{maxparens}{#1}}}

\newtoggle{blx@labeldateusetime}
\DeclareBibliographyOption[boolean]{labeldateusetime}[true]{%
  \ifstrequal{#1}{true}
    {\toggletrue{blx@labeldateusetime}}
    {\togglefalse{blx@labeldateusetime}}}

\DeclareBibliographyOption[string]{labeldate}{%
   % 'true' or 'false' means that the user thinks that this is the old 'labeldate'
   % option which is now 'labeldateparts' (which is a boolean).
   \ifboolexpr{%
     test {\ifstrequal{#1}{true}}
     or
     test {\ifstrequal{#1}{false}}}
     {\blx@warning@noline{%
       'labeldate' option used to determine whether to provide label date fields and\MessageBreak
       extradate field is renamed to 'labeldateparts', setting this instead. This option is
       now used to set the format of the labeldate}%
      \settoggle{blx@labeldateparts}{#1}}
     {\ifstrequal{#1}{iso8601}
       {\blx@warning@noline{%
          'iso8601' date format specifier is deprecated.\MessageBreak
          Use 'iso' instead}%
        \def\blx@dateformat@labeldate{iso}%
        \renewrobustcmd*{\bibdateeraendprefix}{\bibdateeraprefix}}
       {\ifstrequal{#1}{edtf}
          {\blx@warning@noline{%
             'edtf' date format specifier is deprecated.\MessageBreak
             Use 'iso' instead}%
           \def\blx@dateformat@labeldate{iso}%
           \renewrobustcmd*{\bibdateeraendprefix}{\bibdateeraprefix}}
          {\def\blx@dateformat@labeldate{#1}}}%
      \ifstrequal{#1}{ymd}
         {\renewrobustcmd*{\bibdaterangesep}{\slash}%
          \renewrobustcmd*{\bibtimerangesep}{\slash}%
          \renewrobustcmd*{\bibdateeraendprefix}{\bibdateeraprefix}}
         {}%
      \ifstrequal{#1}{iso}% bibdaterangesep hard-coded to slash, no extra space before prefices
        {\renewrobustcmd*{\bibdateeraendprefix}{\bibdateeraprefix}}
        {}%
      \ifcsdef{mkdaterange#1}
       {\protected\def\blx@imc@printlabeldate{\csuse{mkdaterange#1}{label}}
        \protected\def\blx@imc@printlabeldateextra{\csuse{mkdaterange#1extra}{label}}}
       {\ifcsdef{mkbibrange#1}%LEGACY(&lt;3.5)
         {\protected\def\blx@imc@printlabeldate{\csuse{mkbibrange#1}{label}}
          \protected\def\blx@imc@printlabeldateextra{\csuse{mkbibrange#1extra}{label}}}
         {\blx@err@invopt{labeldate=#1}{}}}}}

\DeclareBibliographyOption[string]{labeltime}{%
  \ifcsdef{mktimerange#1}
    {\def\blx@timeformat@labeltime{#1}%
     \protected\def\blx@imc@printlabeltime{\csuse{mktimerange#1}{label}}}
    {\blx@err@invopt{labeltime=#1}{}}}

% Date meta-information
\DeclareBibliographyOption[string]{dateera}{%
  \ifboolexpr{%
              test {\ifstrequal{#1}{astronomical}}
              or
              test {\ifstrequal{#1}{secular}}
              or
              test {\ifstrequal{#1}{christian}}}
  {\def\blx@dateera{#1}%
   \ifstrequal{#1}{secular}
     {\def\blx@dateera@bce{beforecommonera}%
      \def\blx@dateera@ce{commonera}}
     {}%
   \ifstrequal{#1}{christian}
     {\def\blx@dateera@bce{beforechrist}%
      \def\blx@dateera@ce{annodomini}}
     {}}
  {\blx@err@invopt{dateera=#1}{}}}

% Effectively turns off dateeraauto since it's only used on ce dates which
% are never less than zero (as that would be a bce date)
\numdef\blx@dateeraauto{0}
\DeclareBibliographyOption[integer]{dateeraauto}{%
  \numdef\blx@dateeraauto{#1}}

\newtoggle{blx@datecirca}
\DeclareBibliographyOption[boolean]{datecirca}[true]{%
  \ifstrequal{#1}{true}
    {\toggletrue{blx@datecirca}%
     \protected\def\datecircaprint{%
       \ifdatecirca{\bibstring{circa}\printdelim{datecircadelim}}{}}%
     \protected\def\enddatecircaprint{%
       \ifenddatecirca{\bibstring{circa}\printdelim{datecircadelim}}{}}%
     \protected\def\datecircaprintedtf{%LEGACY(&lt;3.9)
       \blx@warning@noline{%
         '\string\datecircaprintedtf' is deprecated.
         Please use '\string\datecircaprintiso'}%
       \datecircaprintiso}%
     \protected\def\enddatecircaprintedtf{%LEGACY(&lt;3.9)
       \blx@warning@noline{%
         '\string\enddatecircaprintedtf' is deprecated.
         Please use '\string\enddatecircaprintiso'}%
       \enddatecircaprintiso}%
     \protected\def\datecircaprintiso{%
       \ifdatecirca{\textasciitilde}{}}%
     \protected\def\enddatecircaprintiso{%
       \ifenddatecirca{\textasciitilde}{}}}
    {\togglefalse{blx@datecirca}}}

\newtoggle{blx@dateuncertain}
\DeclareBibliographyOption[boolean]{dateuncertain}[true]{%
  \ifstrequal{#1}{true}
    {\toggletrue{blx@dateuncertain}%
     \protected\def\dateuncertainprint{%
       \ifdateuncertain{\bibdateuncertain}{}}%
     \protected\def\enddateuncertainprint{%
       \ifenddateuncertain{\bibdateuncertain}{}}}
    {\togglefalse{blx@dateuncertain}}}

% *time format options - auto-created for all datamodel date fields
% *date format options - auto-created for all datamodel date fields
% *dateusetime options - auto-created for all datamodel date fields
% Date metadata toggles are defined in one of the \abx@dobooleans calls
\def\do#1{%
  \DeclareBibliographyOption[string]{#1date}{%
    \ifstrequal{##1}{iso8601}
      {\blx@warning@noline{'iso8601' date format specifier is deprecated.\MessageBreak
         Use 'iso' instead}%
       \csdef{blx@dateformat@#1date}{iso}}
      {\ifstrequal{##1}{edtf}
         {\blx@warning@noline{'edtf' date format specifier is deprecated.\MessageBreak
            Use 'iso' instead}%
          \csdef{blx@dateformat@#1date}{iso}}
         {\csdef{blx@dateformat@#1date}{##1}}}%
    \ifstrequal{##1}{ymd}
      {\renewrobustcmd*{\bibdaterangesep}{\slash}%
       \renewrobustcmd*{\bibtimerangesep}{\slash}%
       \renewrobustcmd*{\bibdateeraendprefix}{\bibdateeraprefix}}
      {}%
    \ifcsdef{mkdaterange##1}
      {\protected\csedef{blx@imc@print#1date}{\noexpand\csuse{mkdaterange##1}{#1}}%
       \protected\csedef{blx@imc@print#1dateextra}{\noexpand\csuse{mkdaterange##1extra}{#1}}}
      {\ifcsdef{mkbibrange##1}%LEGACY(&lt;3.5)
        {\blx@warning@noline{%
           '\string\mkbibrange##1(extra)' date range macro in style is deprecated,\MessageBreak
           please define '\string\mkdaterange##1(extra)' instead}%
         \protected\csedef{blx@imc@print#1date}{\noexpand\csuse{mkbibrange##1}{#1}}%
         \protected\csedef{blx@imc@print#1dateextra}{\noexpand\csuse{mkbibrange##1extra}{#1}}}
        {\blx@err@invopt{#1date=##1}{}}}}%
    % Default for new date fields is "comp" but this is overridden below by
    % biblatex defaults
    \blx@kv@setkeys{blx@opt@pre}{#1date=comp}%
    % Time format options
    \DeclareBibliographyOption[string]{#1time}{%
      \csdef{blx@timeformat@#1time}{##1}%
      \ifcsdef{mktimerange##1}
        {\protected\csedef{blx@imc@print#1time}{\csuse{mktimerange##1}{#1}}}
        {\blx@err@invopt{#1time=##1}{}}}%
    % Default for new time fields is "24h"
    \blx@kv@setkeys{blx@opt@pre}{#1time=24h}%
    % Boolean to determine if times are printed with dates
    \newtoggle{blx@#1dateusetime}%
    \DeclareBibliographyOption[boolean]{#1dateusetime}[true]{%
      \settoggle{blx@#1dateusetime}{##1}}}
\abx@dodatetypes

\DeclareBibliographyOption[string]{alldatesusetime}{%
  \def\do##1{\ExecuteBibliographyOptions{##1usetime=#1}}%
  \abx@dodates
  \do{labeldate}}

\DeclareBibliographyOption[string]{alldates}{%
  \def\do##1{\ExecuteBibliographyOptions{##1=#1}}%
  \abx@dodates
  \do{labeldate}}

\DeclareBibliographyOption[string]{alltimes}{%
  \def\do##1{%
    \ExecuteBibliographyOptions{##1time=#1}}%
  \abx@dodatetypes
  \do{label}}

\newtoggle{blx@julian}
\def\blx@gregorianstart{1582-10-15}
\DeclareBibliographyOption[boolean]{julian}[true]{%
  \ifstrequal{#1}{true}
    {\toggletrue{blx@julian}}
    {\togglefalse{blx@julian}}}

\DeclareBibliographyOption[string]{gregorianstart}{%
  \def\blx@gregorianstart{#1}}

\newtoggle{blx@datezeros}\toggletrue{blx@datezeros}
\DeclareBibliographyOption[boolean]{datezeros}[true]{%
  \ifstrequal{#1}{true}
    {\toggletrue{blx@datezeros}%
     \let\blx@imc@mkyearzeros\blx@imc@forcezerosy
     \let\blx@imc@mkmonthzeros\blx@imc@forcezerosmdt
     \let\blx@imc@mkdayzeros\blx@imc@forcezerosmdt}
    {\togglefalse{blx@datezeros}%
     \let\blx@imc@mkyearzeros\blx@imc@stripzeros
     \let\blx@imc@mkmonthzeros\blx@imc@stripzeros
     \let\blx@imc@mkdayzeros\blx@imc@stripzeros}}

\newtoggle{blx@timezeros}\toggletrue{blx@timezeros}
\DeclareBibliographyOption[boolean]{timezeros}[true]{%
  \ifstrequal{#1}{true}
    {\toggletrue{blx@timezeros}%
     \let\blx@imc@mktimezeros\blx@imc@forcezerosmdt}
    {\togglefalse{blx@timezeros}%
     \let\blx@imc@mktimezeros\blx@imc@stripzeros}}

\newtoggle{blx@timezones}
\DeclareBibliographyOption[boolean]{timezones}[true]{%
  \ifstrequal{#1}{true}
    {\toggletrue{blx@timezones}}
    {\togglefalse{blx@timezones}}}

\newtoggle{blx@seconds}
\DeclareBibliographyOption[boolean]{seconds}[true]{%
  \ifstrequal{#1}{true}
    {\toggletrue{blx@seconds}}
    {\togglefalse{blx@seconds}}}

\DeclareBibliographyOption[string]{autocite}{%
  \ifcsundef{blx@acite@#1}
    {\blx@error
       {Autocite command '#1' undefined}
       {The autocite command '#1' has not been defined by
        the\MessageBreak selected citation style}}
    {\letcs\autocite{blx@acite@#1}%
     \letcs\autocites{blx@macite@#1}}}

\DeclareBibliographyOption[string]{notetype}{%
  \ifcsdef{blx@opt@notetype@#1}
    {\blx@notetype\csuse{blx@opt@notetype@#1}}
    {\blx@err@invopt{notetype=#1}{}}}
\cslet{blx@opt@notetype@foot+end}\z@
\let\blx@opt@notetype@footonly\@ne
\let\blx@opt@notetype@endonly\tw@

\DeclareBibliographyOption[boolean]{autopunct}[true]{%
  \ifstrequal{#1}{true}
    {\DeclareAutoPunctuation{.,;:!?}}
    {\DeclareAutoPunctuation{}}}

\DeclareBibliographyOption[boolean]{punctfont}[true]{%
  \ifstrequal{#1}{true}
    {\let\blx@ifpuncthook\@firstoftwo}
    {\let\blx@ifpuncthook\@secondoftwo}}

\DeclareBibliographyOption[boolean]{labelnumber}[true]{%
  \settoggle{blx@labelnumber}{#1}%
  \iftoggle{blx@labelnumber}
    {}
    {\blx@kv@setkeys{blx@opt@pre}{defernumbers=false}}}
\DeclareBiblatexOption{type,entry}[boolean]{labelnumber}[true]{%
  \settoggle{blx@labelnumber}{#1}}

\DeclareBiblatexOption{global,type,entry}[boolean]{labelalpha}[true]{%
  \settoggle{blx@labelalpha}{#1}}

\DeclareBiblatexOption{global,type,entry}[boolean]{labeltitle}[true]{%
  \settoggle{blx@labeltitle}{#1}}

\DeclareBiblatexOption{global,type,entry}[boolean]{labeltitleyear}[true]{%
  \settoggle{blx@labeltitleyear}{#1}}

\DeclareBiblatexOption{global,type,entry}[boolean]{labeldateparts}[true]{%
  \settoggle{blx@labeldateparts}{#1}}

\DeclareBiblatexOption{global,type}[string]{uniquelist}[true]{%
  \ifcsdef{blx@opt@uniquelist@#1}
    {\letcs\blx@uniquelist{blx@opt@uniquelist@#1}}
    {\blx@err@invopt{uniquelist=#1}{}}}
\def\blx@opt@uniquelist@false{false}
\def\blx@opt@uniquelist@true{true}
\def\blx@opt@uniquelist@minyear{minyear}

\DeclareBiblatexOption{global}[boolean]{pluralothers}[true]{%
  \settoggle{blx@pluralothers}{#1}}
  
\blx@DeclareBackendOption{entry,namelist}[string]{uniquelist}

\DeclareBiblatexOption{global,type}[boolean]{nohashothers}[true]{%
  \settoggle{blx@nohashothers}{#1}}
\blx@DeclareBackendOption{entry,namelist}[boolean]{nohashothers}

\DeclareBiblatexOption{global,type}[boolean]{nosortothers}[true]{%
  \settoggle{blx@nosortothers}{#1}}
\blx@DeclareBackendOption{entry,namelist}[boolean]{nosortothers}

\DeclareBiblatexOption{global,type}[string]{uniquename}[true]{%
  \ifcsdef{blx@opt@uniquename@#1}
    {\letcs\blx@uniquename{blx@opt@uniquename@#1}}
    {\blx@err@invopt{uniquename=#1}{}}}
\def\blx@opt@uniquename@false{false}
\def\blx@opt@uniquename@init{init}
\def\blx@opt@uniquename@true{full}
\def\blx@opt@uniquename@full{full}
\def\blx@opt@uniquename@allinit{allinit}
\def\blx@opt@uniquename@allfull{allfull}
\def\blx@opt@uniquename@mininit{mininit}
\def\blx@opt@uniquename@minfull{minfull}
\def\blx@opt@uniquename@minyearinit{minyearinit}
\def\blx@opt@uniquename@minyearfull{minyearfull}

\blx@DeclareBackendOption{entry,namelist,name}[string]{uniquename}

\DeclareBiblatexOption{global,type}[boolean]{noroman}[true]{%
  \settoggle{blx@noroman}{#1}}
\blx@DeclareBackendOption{entry}[boolean]{noroman}

\DeclareBiblatexOption{global,type}[boolean]{singletitle}[true]{%
  \settoggle{blx@singletitle}{#1}}
\blx@DeclareBackendOption{entry}[boolean]{singletitle}

\DeclareBiblatexOption{global,type}[boolean]{uniquetitle}[true]{%
  \settoggle{blx@uniquetitle}{#1}}
\blx@DeclareBackendOption{entry}[boolean]{uniquetitle}

\DeclareBiblatexOption{global,type}[boolean]{uniquebaretitle}[true]{%
  \settoggle{blx@uniquebaretitle}{#1}}
\blx@DeclareBackendOption{entry}[boolean]{uniquebaretitle}

\DeclareBiblatexOption{global,type}[boolean]{uniquework}[true]{%
  \settoggle{blx@uniquework}{#1}}
\blx@DeclareBackendOption{entry}[boolean]{uniquework}

\DeclareBiblatexOption{global,type}[boolean]{uniqueprimaryauthor}[true]{%
  \settoggle{blx@uniqueprimaryauthor}{#1}}
\blx@DeclareBackendOption{entry}[boolean]{uniqueprimaryauthor}


\DeclareBibliographyOption[boolean]{defernumbers}[true]{%
  \settoggle{blx@defernumbers}{#1}%
  \iftoggle{blx@defernumbers}
    {\blx@kv@setkeys{blx@opt@pre}{labelnumber}%
     \let\blx@thelabelnumber\blx@addlabelnumber
     \let\abx@aux@number\blx@aux@number}
    {\let\blx@thelabelnumber\relax
     \let\abx@aux@number\@gobblefive}}

\DeclareBibliographyOption[boolean]{locallabelwidth}[true]{%
  \blx@key@locallabelwidth{#1}}


\DeclareBibliographyOption[string]{refsection}{%
  \ifcsdef{blx@opt@refsection@#1}
    {\letcs\blx@refsecreset@level{blx@opt@refsection@#1}}
    {\blx@err@invopt{refsection=#1}{}}}
\csdef{blx@opt@refsection@none}{0}
\csdef{blx@opt@refsection@part}{1}
\csdef{blx@opt@refsection@chapter}{2}
\csdef{blx@opt@refsection@section}{3}
\csdef{blx@opt@refsection@subsection}{4}
\csdef{blx@opt@refsection@chapter+}{5}
\csdef{blx@opt@refsection@section+}{6}
\csdef{blx@opt@refsection@subsection+}{7}

\blx@patchsection@switch{\blx@refsecreset@level}{\newrefsection}{}{}

\DeclareBibliographyOption[string]{refsegment}{%
  \ifcsdef{blx@opt@refsegment@#1}
    {\letcs\blx@refsegreset@level{blx@opt@refsegment@#1}}
    {\blx@err@invopt{refsegment=#1}{}}}
\csdef{blx@opt@refsegment@none}{0}
\csdef{blx@opt@refsegment@part}{1}
\csdef{blx@opt@refsegment@chapter}{2}
\csdef{blx@opt@refsegment@section}{3}
\csdef{blx@opt@refsegment@subsection}{4}
\csdef{blx@opt@refsegment@chapter+}{5}
\csdef{blx@opt@refsegment@section+}{6}
\csdef{blx@opt@refsegment@subsection+}{7}

\blx@patchsection@switch{\blx@refsegreset@level}
  {\newrefsegment}
  {\ifnumgreater\blx@refsegreset@level\z@
     {\ifnumgreater\blx@refsegreset@level\blx@refsecreset@level
        {}
        {\blx@err@confopt
           {refsegment/refsection}
           {The 'refsegment' option must point to a
            lower-level\MessageBreak document division
            than 'refsection'}%
         \def\blx@refsegreset@level{0}}}
     {}}
  {}

\DeclareBibliographyOption[string]{citereset}{%
  \ifcsdef{blx@opt@citereset@#1}
    {\letcs\blx@citereset@level{blx@opt@citereset@#1}}
    {\blx@err@invopt{citereset=#1}{}}}
\csdef{blx@opt@citereset@none}{0}
\csdef{blx@opt@citereset@part}{1}
\csdef{blx@opt@citereset@chapter}{2}
\csdef{blx@opt@citereset@section}{3}
\csdef{blx@opt@citereset@subsection}{4}
\csdef{blx@opt@citereset@chapter+}{5}
\csdef{blx@opt@citereset@section+}{6}
\csdef{blx@opt@citereset@subsection+}{7}

\blx@patchsection@switch{\blx@citereset@level}{\citereset\blx@inf@creset}{}{}

\DeclareBibliographyOption[boolean]{bibwarn}[true]{%
  \ifstrequal{#1}{true}
    {\def\blx@bbl@thewarn{\blx@bbl@warn}}
    {\let\blx@bbl@thewarn\@gobble}}

% Name field options
\def\do#1{%
  \DeclareBiblatexOption{global,type,entry}[boolean]{use#1}[true]{%
    \settoggle{blx@use#1}{##1}}}
\abx@donames

% Entry options
\DeclareBiblatexOption{global,type,entry,namelist,name}[boolean]{useprefix}[true]{%
  \settoggle{blx@useprefix}{#1}}

\DeclareBiblatexOption{global,type,entry}[boolean]{skipbib}[true]{%
  \settoggle{blx@skipbib}{#1}}

\DeclareBiblatexOption{global,type,entry}[boolean]{skipbiblist}[true]{%
  \settoggle{blx@skipbiblist}{#1}}

\DeclareBiblatexOption{global,type,entry}[boolean]{skiplab}[true]{%
  \settoggle{blx@skiplab}{#1}}

\DeclareBiblatexOption{global,type}[boolean]{dataonly}[true]{%
  \settoggle{blx@skipbib}{#1}%
  \settoggle{blx@skipbiblist}{#1}%
  \settoggle{blx@skiplab}{#1}}
% the entry option is resolved by Biber
\blx@DeclareBackendOption{entry}[boolean]{dataonly}
% This is handled in a special way by by biber. It indicates what to set for various options
% if the dataonly option is "true". If biber finds dataonly=false
% in an entry, the booleans here will be reversed (skip*) and the unique* options (which are not
% booleans) will be ignored, defaulting to higher scope values. biber assumes
% that \blx@bcf@backendin@entry@* options are boolean options as otherwise, negating them
% per-entry makes little sense and it is not clear what to do with such lower-scope overrides.
\gdef\blx@bcf@backendin@entry@dataonly{uniquename=false,uniquelist=false,%
  skipbib=true,skipbiblist=true,skiplab=true}

% Option processor/scheduler
\DeclareOption*{%
  \begingroup
  \def\blx@tempa#1=#2&amp;{#1}%
  \edef\blx@tempa{%
    \expandafter\blx@tempa\CurrentOption=&amp;}%
  \blx@kv@ifkeyundef{blx@opt@ldt}{\blx@tempa}
    {% now it becomes messy,
     % we need to intercept the bibtexcaseprotection option
     % because it is only defined by the case changing code
     % which is loaded after load-time options are processed
     \ifdefstring\blx@tempa{bibtexcaseprotection}
       {\endgroup
        \edef\blx@deferoption@bibtexcaseprotection{\CurrentOption}}
       {\endgroup
        \eappto\blx@theoptions{\CurrentOption,}}}
    {\edef\blx@tempa{\endgroup
       \noexpand\blx@kv@setkeys{blx@opt@ldt}{\CurrentOption}}%
     \blx@tempa}}

\def\blx@processoptions{%
  \ifundef\blx@theoptions
    {}
    {\begingroup
     \edef\blx@tempa{\endgroup
       \noexpand\blx@kv@setkeys{blx@opt@pre}{\blx@theoptions}}%
     \blx@tempa}}

%% Initial setup

\define@key{blx@opt@ldt}{casechanger}[auto]{%
  \ifcsundef{blx@opt@casechanger@#1}
    {\blx@err@invopt
       {casechanger=#1}
       {Valid options for 'casechanger' are 'auto', 'expl3' and
        'latex2e'}}
    {\csletcs{blx@deferoption@casechanger}{blx@opt@casechanger@#1}}}


\csdef{blx@opt@casechanger@auto}{%
  \ifdefstring{\blx@texencoding}{utf8}
    {\blx@info@noline{Document encoding is UTF8 ...}%
     \RequirePackage{expl3}[2020/04/06]%
     \@ifpackagelater{expl3}{2020/04/06}
       {\blx@info@noline{... and expl3\MessageBreak\csuse{ver@expl3.sty}\MessageBreak
          is new enough (at least 2020/04/06),\MessageBreak
          setting 'casechanger=expl3'}%
        \csuse{blx@opt@casechanger@expl3}}
       {\blx@info@noline{... but expl3\MessageBreak\csuse{ver@expl3.sty}\MessageBreak
          is too old (older than 2020/04/06),\MessageBreak
          setting 'casechanger=latex2e'}%
        \csuse{blx@opt@casechanger@latex2e}}}
    {\blx@info@noline{%
       Document encoding not detected as UTF8.\MessageBreak
       Setting 'casechanger=latex2e'}%
     \csuse{blx@opt@casechanger@latex2e}}}

\csdef{blx@opt@casechanger@latex2e}{%
  \RequirePackage{blx-case-latex2e}}
\csletcs{blx@opt@casechanger@2e}{blx@opt@casechanger@latex2e}

\csdef{blx@opt@casechanger@expl3}{%
  \ifdefstring{\blx@texencoding}{utf8}
    {}
    {\blx@warning@noline{%
       The expl3 case changer code should only be used\MessageBreak
       with UTF-8 encoding.\MessageBreak
       But the document encoding was detected as
       '\blx@texencoding'.\MessageBreak
       Case changing macros may break\MessageBreak
       if used with non-ASCII characters}}%
  \RequirePackage{blx-case-expl3}}
\csletcs{blx@opt@casechanger@3}{blx@opt@casechanger@expl3}

% default to auto
\csletcs{blx@deferoption@casechanger}{blx@opt@casechanger@auto}

% This is a bit unfortunate, but we need some more definitions after
% loading the case changing code.
\def\blx@casechange@postload{%
  % Language fallback, in order:
  % * explicit option language=&lt;lang&gt;, which overrides everything
  % * langid field of entry
  % * babel/polyglossia lang
  % * main document lang (we should never reach this)
  % * &lt;empty&gt; (we should *definitely* never reach this)
  % Everything here is expandable so that
  % \blx@mksc@lang expands to the language name.
  \def\blx@mksc@lang{%
    \ifundef\blx@forcelanguagename
      {\ifundef\abx@field@langid
        {\ifundef\blx@languagename
          {\ifundef\blx@main@language
             {}
             {\blx@main@language}}
          {\blx@languagename}}
        {\abx@field@langid}}
      {\blx@forcelanguagename}}%
  %
  \DeclareCaseLangs{%
    american,british,canadian,
    english,USenglish,UKenglish,
    australian,newzealand}%
  % Textcase defines \NoCaseChange as \let\NoCaseChange\@firstofone
  \ifundef\NoCaseChange
    {\let\NoCaseChange\@firstofone}
    {}%
  % we also need to defer the bibtexcaseprotection option until after we load
  % the case changing code
  \ifundef\blx@deferoption@bibtexcaseprotection
    {}
    {\begingroup
     \edef\blx@tempa{\endgroup
       \noexpand\blx@kv@setkeys{blx@opt@pre}{%
         \blx@deferoption@bibtexcaseprotection}}%
     \blx@tempa}}
% That's it for the case change code

% Set defaults
\blx@kv@setkeys{blx@opt@ldt}{style=numeric}
\blx@kv@setkeys{blx@opt@pre}{%
  sorting=nty,sortlocale=auto,sortcase,sortupper,sortcites=false,pluralothers=false,
  maxnames=3,minnames=1,maxalphanames=3,minalphanames=1,
  maxitems=3,minitems=1,mincrossrefs=2,minxrefs=2,
  useauthor=true,useeditor=true,usetranslator=false,
  indexing=false,abbreviate=true,dateabbrev=true,dateera=astronomical,
  backref=false,backrefsetstyle=setonly,backreffloats=true,
  pagetracker=false,
  ibidtracker=false,idemtracker=false,opcittracker=false,loccittracker=false,
  citetracker=false,trackfloats=false,
  citecounter=false,
  block=none,
  language=autobib,clearlang=true,autolang=none,langhook=captions,
  date=comp,labeldate=year,origdate=comp,eventdate=comp,urldate=short,
  autopunct=true,punctfont=false,defernumbers=false,timezeros=true,
  refsection=none,refsegment=none,citereset=none,hyperref=auto,
  parentracker,maxparens=3,bibencoding=auto,bibwarn,timezones=false,
  seconds=false,julian=false,labeltime=24h,locallabelwidth=false}

% Load Unicode enhancements (only for LuaTeX and XeTeX)
\ifboolexpr{
    not test {\ifundef\XeTeXrevision}
    or
    not test {\ifundef\luatexversion}}
  {\blx@inputonce{blx-unicode.def}{enhanced support for Unicode engines}{}{}{}{}}
  {}

% Load compatibility code
\blx@inputonce{blx-compat.def}{compatibility code}{}{}{}{}


% Restore catcodes
\blx@catcodes
\undef\blx@catcodes

% Process load-time options
\ProcessOptions*

% Switch to BibTeX support if requested
\iftoggle{blx@bibtex}
  {\blx@inputonce{blx-bibtex.def}{BibTeX backend compatibility}{}{}{}{}}
  {}

% Load citation and bibliography styles, configuration file
\blx@inputonce{biblatex.def}{generic definitions}{}{}{}{}
\iftoggle{blx@natbib}
  {\blx@inputonce{blx-natbib.def}{natbib compatibility}{}{}{}{}}
  {}
\iftoggle{blx@mcite}
  {\blx@inputonce{blx-mcite.def}{mcite-like commands}{}{}{}{}}
  {}
\RequireBibliographyStyle{\blx@bbxfile}
\RequireCitationStyle{\blx@cbxfile}
\blx@secinit
\citereset
\blx@inputonce{biblatex.cfg}{configuration file}{}{}{}{}

% Process preamble options
\blx@processoptions

% first stab at guessing the file encoding
\def\blx@guesstexencoding{%
  \ifdef\blx@texencoding@fromoption
    {\let\blx@texencoding\blx@texencoding@fromoption
     \blx@info@noline{%
       Input encoding '\blx@texencoding' specified}}
    {\ifundef\inputencodingname
       {\ifundef\XeTeXrevision
          {\ifundef\luatexversion
             {\def\blx@texencoding{ascii}%
              \blx@info@noline{%
                No input encoding detected.\MessageBreak
                Assuming '\blx@texencoding'}}
             {\def\blx@texencoding{utf8}%
              \blx@info@noline{%
                LuaTeX detected.\MessageBreak
                Assuming input encoding '\blx@texencoding'}}}
          {\def\blx@texencoding{utf8}%
           \blx@info@noline{%
             XeTeX detected.\MessageBreak
             Assuming input encoding '\blx@texencoding'}}}
       {\ifcsdef{blx@inpenc@\inputencodingname}
          {\letcs\blx@texencoding{blx@inpenc@\inputencodingname}}
          {\let\blx@texencoding\inputencodingname}%
        \blx@info@noline{%
          Input encoding '\blx@texencoding' detected}}}}

\blx@guesstexencoding
\let\blx@texencoding@firstguess\blx@texencoding

% this ultimately loads either
% blx-case-expl3.def or blx-case-latex2e.def
\blx@deferoption@casechanger
\blx@casechange@postload


% Deferred setup at end of preamble
\AtEndPreamble{%
  \blx@checkoptions@global
  \c@maxnames\blx@maxcitenames\relax
  \c@minnames\blx@mincitenames\relax
  \c@maxitems\blx@maxitems\relax
  \c@minitems\blx@minitems\relax
  \togglefalse{abx@bool@xinits}
  \def\do#1{\iftoggle{abx@bool@#1inits}{\toggletrue{abx@bool@xinits}}{}}
  \abx@donameparts
  \iftoggle{abx@bool@xinits}
    {\ifdefstrequal\blx@uniquename\blx@opt@uniquename@full
       {\blx@warn@conflopt{%
          '&lt;namepart&gt;inits' conflicts with 'uniquename=full'.\MessageBreak
          Setting 'uniquename=init'}%
        \blx@kv@setkeys{blx@opt@pre}{uniquename=init}}
       {}%
     \ifdefstrequal\blx@uniquename\blx@opt@uniquename@allfull
       {\blx@warn@conflopt{%
          '&lt;namepart&gt;inits' conflicts with 'uniquename=allfull'.\MessageBreak
          Setting 'uniquename=allinit}%
        \blx@kv@setkeys{blx@opt@pre}{uniquename=allinit}}
       {}%
     \ifdefstrequal\blx@uniquename\blx@opt@uniquename@minyearfull
       {\blx@warn@conflopt{%
          '&lt;namepart&gt;inits' conflicts with 'uniquename=minyearfull'.\MessageBreak
          Setting 'uniquename=minyearinit}%
        \blx@kv@setkeys{blx@opt@pre}{uniquename=minyearinit}}
       {}
     \ifdefstrequal\blx@uniquename\blx@opt@uniquename@minfull
       {\blx@warn@conflopt{%
          '&lt;namepart&gt;inits' conflicts with 'uniquename=minfull'.\MessageBreak
          Setting 'uniquename=mininit}%
        \blx@kv@setkeys{blx@opt@pre}{uniquename=mininit}}
       {}}
    {}%
  \nottoggle{blx@labeldateparts}
    {\ifdefstrequal\blx@uniquelist\blx@opt@uniquelist@minyear
       {\blx@warn@conflopt{%
          'uniquelist=minyear' requires 'labeldateparts'.\MessageBreak
          Setting 'uniquelist=true'}%
        \blx@kv@setkeys{blx@opt@pre}{uniquelist}}
       {}}
    {}%
    \def\do#1{%
      \ifcsstring{blx@dateformat@#1}{iso}
        {\blx@stripfromendinto{#1}{date}\blx@datetype
         \ifdefstring\blx@dateera{astronomical}{}
           {\blx@warn@conflopt{%
              '#1=iso' requires 'dateera=astronomical'.\MessageBreak
              Setting 'dateera=astronomical'}%
            \blx@kv@setkeys{blx@opt@pre}{dateera=astronomical}}%
          \ifcsstring{blx@timeformat@\blx@datetype time}{24h}%
           {}
           {\blx@warn@conflopt{%
              '#1=iso' requires '\blx@datetype time=24h'.\MessageBreak
              Setting '\blx@datetype time=24h'}%
            \blx@kv@setkeys{blx@opt@pre}{\blx@datetype time=24h}}%
         \iftoggle{blx@julian}
           {\blx@warn@conflopt{%
              '#1=iso' requires 'julian=false'.\MessageBreak
              Setting 'julian=false'}%
            \blx@kv@setkeys{blx@opt@pre}{julian=false}}
           {}%
         \nottoggle{blx@datezeros}
           {\blx@warn@conflopt{%
              '#1=iso' requires 'datezeros=true'.\MessageBreak
              Setting 'datezeros=true'}%
            \blx@kv@setkeys{blx@opt@pre}{datezeros=true}}
           {}%
         \nottoggle{blx@timezeros}
           {\blx@warn@conflopt{%
              '#1=iso' requires 'timezeros=true'.\MessageBreak
              Setting 'timezeros=true'}%
            \blx@kv@setkeys{blx@opt@pre}{timezeros=true}}
           {}%
         \nottoggle{blx@seconds}
           {\blx@warn@conflopt{%
              '#1=iso' requires 'seconds=true'.\MessageBreak
              Setting 'seconds=true'}%
            \blx@kv@setkeys{blx@opt@pre}{seconds=true}}
           {}}
        {}}%
    \abx@dodates
    \do{labeldate}}



\def\blx@checkencoding{%
  \blx@guesstexencoding
  \ifdefstrequal\blx@texencoding@firstguess\blx@texencoding
    {}
    {\blx@warning@noline{%
      Initial guess for file encoding (\blx@texencoding@firstguess)\MessageBreak
      and new guess (\blx@texencoding) do not match.\MessageBreak
      Please set up your document encoding *before*\MessageBreak
      loading biblatex.\MessageBreak
      The case changing code might not work as expected}}%
  \ifdef\blx@bibencoding
    {\ifdefstring\blx@bibencoding{ascii}
       {\blx@info@noline{%
          Data encoding '\blx@bibencoding' specified.\MessageBreak
          No need to reencode data}}
       {\ifdefstring\blx@bibencoding{auto}
          {\let\blx@bibencoding\blx@texencoding
           \blx@info@noline{%
             Automatic encoding selection.\MessageBreak
             Assuming data encoding '\blx@bibencoding'}}
          {\ifdefstrequal\blx@bibencoding\blx@texencoding
             {\blx@info@noline{%
                Data encoding '\blx@bibencoding' specified.\MessageBreak
                No need to reencode data}}
             {\blx@info@noline{%
                   Data encoding '\blx@bibencoding' specified.\MessageBreak
                   Backend will reencode on the fly}}}}}
    {\def\blx@bibencoding{ascii}%
     \blx@info@noline{%
        Data encoding not specified.\MessageBreak
        Assuming '\blx@bibencoding'}}%
  \ifboolexpr{%
    togl {blx@safeinputenc}
    and ( test {\@ifpackageloaded{inputenc}}
          or
          test {\@ifpackageloaded{inputenx}} )
  }
    {\def\blx@texencoding{ascii}%
     \blx@info@noline{%
        Input encoding '\blx@texencoding' forced by\MessageBreak
        'safeinputenc' option}}
    {}%
}

% Deferred last minute setup
\AtBeginDocument{%
  \blx@auxwrite\@mainaux{}{\string\abx@aux@refcontext{\blx@refcontext@context}}
  \blx@checkencoding
  \if@filesw
    \blx@ctrlwrite
  \fi
  \blx@bblinput
  \setcounter{blx@maxsection}{0}%
  \csuse{blx@hook@refsectioninit}%
  \csuse{blx@hook@refsection@following}%
  \csuse{blx@hook@refsection@next}%
  \csuse{abx@preamble}%
  \blx@inf@refsec
  \blx@inf@refseg}

\AtEndOfPackage{%
  % Data model macros are forbidden after package load is finished
  \def\blx@warn@dm#1{\blx@warning@noline{Data model macro '#1' cannot be used in preamble}}
  \def\ResetDatamodelEntrytypes{\blx@warn@dm{ResetDatamodelEntrytypes}}
  \def\ResetDatamodelFields{\blx@warn@dm{ResetDatamodelFields}}
  \def\ResetDatamodelEntryfields{\blx@warn@dm{ResetDatamodelEntryfields}}
  \def\ResetDatamodelConstraints{\blx@warn@dm{ResetDatamodelConstraints}}
  \renewcommand*{\DeclareDatamodelMultiscriptEntryfields}[1]{\blx@warn@dm{DeclareDatamodelMultiscriptEntryfields}}
  \renewcommand*{\DeclareDatamodelEntrytypes}[2][]{\blx@warn@dm{DeclareDatamodelEntrytypes}}
  \renewcommand*{\DeclareDatamodelFields}[2][]{\blx@warn@dm{DeclareDatamodelFields}}
  \renewcommand*{\DeclareDatamodelEntryfields}[2][]{\blx@warn@dm{DeclareDatamodelEntryfields}}
  \renewcommand*{\DeclareDatamodelConstraints}[2][]{\blx@warn@dm{DeclareDatamodelConstraints}}
  \renewcommand*{\DeclareDatamodelConstant}[3][]{\blx@warn@dm{DeclareDatamodelConstant}}
  \AtBeginDocument{%
    \let\do\undef
    \blx@dopreamblecmds
    \let\do\noexpand}}

\def\BiblatexHungarianWarningOff{\global\let\lbx@hu@loadinfo\@empty}
\def\BiblatexLatvianWarningOff{\global\let\lbx@lv@loadinfo\@empty}
\def\BiblatexSplitbibDefernumbersWarningOff{%
  \global\let\blx@printbibchecks@suppresswarn\@empty}

\endinput
</pre></body></html>