/*
 * Copyright (c) 2018, 2026, Oracle and/or its affiliates.
 * Licensed under The Universal Permissive License (UPL), Version 1.0
 * as shown at https://oss.oracle.com/licenses/upl/
 */
const AVAIL_TITLE="---- Available in AMD mode ----";const UNAVAIL_TITLE="---- Unavailable in AMD mode ----";function show(nd,arg,appCtx){var packs;if(packs=nd.builtinpacks.getPackMetadata(nd,appCtx)){let prefixes=nd.builtinpacks.getPrefixes();arg=arg?arg.toLowerCase():arg;for(let pack of prefixes){if(!arg||arg===pack)_display(packs[pack],appCtx.colors)}}};function _display(pack,clr){var rules,rule,opts;let sorted=[],avail=[],unavail=[],max=0;console.log(`\n\n${clr.BRIGHTRED("\u25CF")}  ${clr.CYAN("Pack")} ${clr.BRIGHTRED(`${pack.prefix}`)} ${clr.CYAN(" - Rules Available/Unavailable in AMD mode by default")}\n`);rules=pack.rules;_getSortedRulesByName(rules,sorted);for(rule of sorted){let ar;opts=rules[rule];ar=opts.hasOwnProperty("amd")&&!opts.amd?unavail:avail;ar.push(rule);ar.push(opts.hasOwnProperty("inservice")?opts.inservice:true);ar.push(opts.hasOwnProperty("enabled")?opts.enabled:true);max=rule.length>max?rule.length:max}console.log(clr.BRIGHTYELLOW(`●  Available  in AMD mode - ${avail.length/3}`));console.log(clr.BRIGHTYELLOW(`●  Unavailable in AMD mode - ${unavail.length/3}\n`));if(!avail.length){return}_displayRules(unavail,false,max,clr);_displayRules(avail,true,max,clr);console.log("")};function _displayRules(list,avail,max,clr){if(!list.length){return}let rule,inserv,enabled,inserv_s,enabled_s,i;console.log("  "+clr.BRIGHTCYAN(avail?AVAIL_TITLE:UNAVAIL_TITLE));for(i=0;i<list.length;i++){rule=list[i++];inserv=list[i++];enabled=list[i];inserv_s=inserv?clr.BRIGHTGREEN(`${inserv}`):clr.RED(`${inserv}`);enabled_s=enabled?clr.BRIGHTGREEN(`${enabled}`):clr.RED(`${enabled}`);console.log(clr.BRIGHTYELLOW(`●  ${rule}`)+_spacer(rule,max)+"   "+clr.BRIGHTCYAN("In service:")+" "+inserv_s+"  "+(inserv?" ":"")+clr.BRIGHTCYAN("Enabled:")+enabled_s)}};function _getSortedRulesByName(rules,sorted){var rule;for(rule in rules){sorted.push(rule)}sorted.sort()};function _spacer(s,max){return" ".repeat(max-s.length+2)};module.exports.show=show;