"use strict";class ManageBrew{static initialise(){BrewUtil.pAddBrewData().then(()=>BrewUtil.pAddLocalBrewData()).catch(BrewUtil.pPurgeBrew).then(()=>{ManageBrew.pRender()})}static async pRender(){const a=$(`#brewmanager`).empty(),b=$(`<div style="position: relative;"/>`);if(await BrewUtil._pRenderBrewScreen(a,$(`<div/>`),b,!1,async()=>ManageBrew.pRender()),BrewUtil.homebrewMeta){const a=$(`#metamanager`).empty(),b=Object.keys(BrewUtil.homebrewMeta).filter(a=>"sources"!==a);if(b.length){a.append(`
					<hr>
					<h4>Metadata</h4>
					<p><i>Warning: deleting metadata may invalidate or otherwise corrupt homebrew that depends on it. Use with caution.</i></p>
				`);const c=c=>{c<b.length-1&&a.append(`<br>`)};b.sort(SortUtil.ascSort).forEach((b,d)=>{const e=(c,d)=>{const e=$(`<div/>`).appendTo(a),f=()=>{const a=Object.keys(BrewUtil.homebrewMeta[b]||{});if(e.empty(),a.length){e.append(`<div class="bold">${c}:</div>`);const g=$(`<ul class="list-display-only" style="padding-top: 0"/>`).appendTo(e);a.forEach(a=>{const c=d?d(BrewUtil.homebrewMeta,b,a):a.toTitleCase(),e=$(`<li class="row manbrew__row">
										<span class="action col-10 manbrew__col--tall">${c}</span>
									</li>`).appendTo(g),h=$(`<span class="col-2 text-right"/>`).appendTo(e);$(`<button class="btn btn-danger btn-sm"><span class="glyphicon glyphicon-trash"></span></button>`).appendTo(h).click(()=>{delete BrewUtil.homebrewMeta[b][a],Object.keys(BrewUtil.homebrewMeta[b]).length||delete BrewUtil.homebrewMeta[b],StorageUtil.syncSet(HOMEBREW_META_STORAGE,BrewUtil.homebrewMeta),f()})})}};f()};switch(b){case"actions":{e("Actions");break}case"spellDistanceUnits":{e("Spell Distance Units");break}case"spellSchools":e("Spell Schools",(a,b,c)=>a[b][c].full||c);}c(d)})}}}}window.addEventListener("load",()=>{ExcludeUtil.pInitialise(),ManageBrew.initialise()});