(()=>{"use strict";var e={d:(o,t)=>{for(var a in t)e.o(t,a)&&!e.o(o,a)&&Object.defineProperty(o,a,{enumerable:!0,get:t[a]})},o:(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},o={};e.r(o),e.d(o,{BegingroupStack:()=>R,begingroupStack:()=>O});var t={};e.r(t),e.d(t,{BegingroupMethods:()=>T});var a={};e.r(a),e.d(a,{BegingroupConfiguration:()=>C});const n=("undefined"!=typeof window?window:global).MathJax._.components.global,i=(n.GLOBAL,n.isObject,n.combineConfig,n.combineDefaults,n.combineWithMathJax),r=(n.MathJax,MathJax._.input.tex.HandlerTypes),s=r.ConfigurationType,g=r.HandlerType,l=MathJax._.input.tex.Configuration,p=l.Configuration,u=(l.ConfigurationHandler,l.ParserConfiguration,MathJax._.input.tex.TokenMap),d=(u.parseResult,u.AbstractTokenMap,u.RegExpMap,u.AbstractParseMap,u.CharacterMap,u.DelimiterMap),b=(u.MacroMap,u.CommandMap),h=u.EnvironmentMap,M=MathJax._.input.tex.MapHandler,E=M.MapHandler,c=(M.SubHandler,M.SubHandlers,MathJax._.input.tex.TexError.default),N=MathJax._.input.tex.newcommand.NewcommandUtil,f=N.NewcommandTables,x=N.NewcommandPriority,m=(N.NewcommandUtil,MathJax._.input.tex.ParseMethods.default);class R{constructor(e){this.i=x,this.top=x,this.base=x,this.MARKER=Symbol("marker"),this.handlers=e.handlers,this.getGlobal()}getGlobal(){this.global={[f.NEW_DELIMITER]:E.getMap(f.NEW_DELIMITER),[f.NEW_ENVIRONMENT]:E.getMap(f.NEW_ENVIRONMENT),[f.NEW_COMMAND]:E.getMap(f.NEW_COMMAND)}}checkGlobal(e,o){for(const t of o){const o=e.shift(),a=this.handlers.get(R.handlerMap[t]);let n;this.global[t].add(o,this.MARKER);do{const e=a.applicable(o);n=e.lookup(o),e.remove(o)}while(n&&n!==this.MARKER)}return o.map((e=>this.global[e]))}push(){new d(f.NEW_DELIMITER,m.delimiter,{}),new b(f.NEW_COMMAND,{}),new h(f.NEW_ENVIRONMENT,m.environment,{}),this.handlers.add(R.handlerConfig,{},--this.i)}pop(){if(this.i===this.base)throw new c("MissingBegingroup","Missing \\begingroup or extra \\endgroup");this.handlers.remove(R.handlerConfig,{});for(const e of[f.NEW_COMMAND,f.NEW_ENVIRONMENT,f.NEW_DELIMITER])E.register(this.handlers.retrieve(e));this.i++}finish(){this.top=this.i}remove(){for(;this.i<this.top;)this.pop()}reset(){this.top=this.base,this.remove()}sandbox(){this.base=x,this.reset(),this.push(),this.getGlobal(),this.base=x-1}}function O(e){return e.packageData.get("begingroup").stack}R.handlerConfig={[g.DELIMITER]:[f.NEW_DELIMITER],[g.ENVIRONMENT]:[f.NEW_ENVIRONMENT],[g.MACRO]:[f.NEW_DELIMITER,f.NEW_COMMAND]},R.handlerMap={[f.NEW_DELIMITER]:g.DELIMITER,[f.NEW_ENVIRONMENT]:g.ENVIRONMENT,[f.NEW_COMMAND]:g.MACRO};const _=MathJax._.input.tex.base.BaseMethods,I=(_.splitAlignArray,_.default),T={begingroup(e,o){O(e.configuration).push()},endgroup(e,o){O(e.configuration).pop()},reset(e,o){O(e.configuration).reset()},sandbox(e,o){O(e.configuration).sandbox(),e.stack.global.isSandbox=!0},global(e,o){const t=e.i,a="\\"===e.GetNext()?(e.i++,e.GetCS()):"";if(e.i=t,!e.options.begingroup.allowGlobal.includes(a))throw new c("IllegalGlobal","Invalid use of %1",e.currentCS);e.stack.env.isGlobal=!0},macro:I.Macro};new b("begingroup",{begingroup:T.begingroup,endgroup:T.endgroup,global:T.global,gdef:[T.macro,"\\global\\def"],begingroupReset:T.reset,begingroupSandbox:T.sandbox}),new b("begingroup",{begingroup:T.begingroup,endgroup:T.endgroup,global:T.global,gdef:[T.macro,"\\global\\def"],begingroupReset:T.reset,begingroupSandbox:T.sandbox});const C=p.create("begingroup",{[s.HANDLER]:{[g.MACRO]:["begingroup"]},[s.CONFIG]:(e,o)=>{o.parseOptions.packageData.set("begingroup",{stack:new R(o.parseOptions)})},[s.OPTIONS]:{begingroup:{allowGlobal:["let","def","newcommand","DeclareMathOperator","Newextarrow"]}},[s.PREPROCESSORS]:[({data:e})=>O(e).remove()],[s.POSTPROCESSORS]:[({data:e})=>O(e).finish()]});MathJax.loader&&MathJax.loader.checkVersion("[tex]/begingroup","4.0.0","tex-extension"),i({_:{input:{tex:{begingroup:{BegingroupConfiguration:a,BegingroupMethods:t,BegingroupStack:o}}}}})})();