@visulima/cerebro 3.1.2 → 3.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,11 @@
1
+ ## @visulima/cerebro [3.1.3](https://github.com/visulima/visulima/compare/@visulima/cerebro@3.1.2...@visulima/cerebro@3.1.3) (2026-10-13)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/colorize:** upgraded to 2.2.0
7
+ * **@visulima/pail:** upgraded to 5.0.1
8
+
1
9
  ## @visulima/cerebro [3.1.2](https://github.com/visulima/visulima/compare/@visulima/cerebro@3.1.1...@visulima/cerebro@3.1.2) (2026-09-21)
2
10
 
3
11
  ### Bug Fixes
package/LICENSE.md CHANGED
@@ -559,36 +559,6 @@ Repository: git+https://github.com/visulima/visulima.git
559
559
  > MIT
560
560
  >
561
561
  > # Bundled dependencies:
562
- > ## codsen-format-diagnostic-value
563
- > License: MIT
564
- > By: Roy Revelt
565
- > Repository: git+https://github.com/codsen/codsen.git
566
- >
567
- > > MIT License
568
- > >
569
- > > Copyright © 2010-2026 Roy Revelt and other contributors
570
- > >
571
- > > Permission is hereby granted, free of charge, to any person obtaining
572
- > > a copy of this software and associated documentation files (the
573
- > > "Software"), to deal in the Software without restriction, including
574
- > > without limitation the rights to use, copy, modify, merge, publish,
575
- > > distribute, sublicense, and/or sell copies of the Software, and to
576
- > > permit persons to whom the Software is furnished to do so, subject to
577
- > > the following conditions:
578
- > >
579
- > > The above copyright notice and this permission notice shall be
580
- > > included in all copies or substantial portions of the Software.
581
- > >
582
- > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
583
- > > EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
584
- > > MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
585
- > > NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
586
- > > LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
587
- > > OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
588
- > > WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
589
- >
590
- > ---------------------------------------
591
- >
592
562
  > ## codsen-utils
593
563
  > License: MIT
594
564
  > By: Roy Revelt
@@ -596,7 +566,7 @@ Repository: git+https://github.com/visulima/visulima.git
596
566
  >
597
567
  > > MIT License
598
568
  > >
599
- > > Copyright © 2010-2026 Roy Revelt and other contributors
569
+ > > Copyright © 2010-2025 Roy Revelt and other contributors
600
570
  > >
601
571
  > > Permission is hereby granted, free of charge, to any person obtaining
602
572
  > > a copy of this software and associated documentation files (the
@@ -694,14 +664,68 @@ Repository: git+https://github.com/visulima/visulima.git
694
664
  >
695
665
  > ---------------------------------------
696
666
  >
697
- > ## html-entity-codec
667
+ > ## html-entities
698
668
  > License: MIT
699
- > By: Roy Revelt
700
- > Repository: git+https://github.com/codsen/codsen.git
669
+ > By: Marat Dulin
670
+ > Repository: https://github.com/mdevils/html-entities.git
671
+ >
672
+ > > Copyright (c) 2021 Dulin Marat
673
+ > >
674
+ > > Permission is hereby granted, free of charge, to any person obtaining a copy
675
+ > > of this software and associated documentation files (the "Software"), to deal
676
+ > > in the Software without restriction, including without limitation the rights
677
+ > > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
678
+ > > copies of the Software, and to permit persons to whom the Software is
679
+ > > furnished to do so, subject to the following conditions:
680
+ > >
681
+ > > The above copyright notice and this permission notice shall be included in
682
+ > > all copies or substantial portions of the Software.
683
+ > >
684
+ > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
685
+ > > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
686
+ > > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
687
+ > > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
688
+ > > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
689
+ > > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
690
+ > > THE SOFTWARE.
691
+ >
692
+ > ---------------------------------------
693
+ >
694
+ > ## indent-string
695
+ > License: MIT
696
+ > By: Sindre Sorhus
697
+ > Repository: sindresorhus/indent-string
701
698
  >
702
699
  > > MIT License
703
700
  > >
704
- > > Copyright © 2010-2026 Roy Revelt and other contributors
701
+ > > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
702
+ > >
703
+ > > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
704
+ > >
705
+ > > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
706
+ > >
707
+ > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
708
+ >
709
+ > ---------------------------------------
710
+ >
711
+ > ## lodash-es
712
+ > License: MIT
713
+ > By: John-David Dalton, Mathias Bynens
714
+ > Repository: lodash/lodash
715
+ >
716
+ > > Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
717
+ > >
718
+ > > Based on Underscore.js, copyright Jeremy Ashkenas,
719
+ > > DocumentCloud and Investigative Reporters & Editors <http://underscorejs.org/>
720
+ > >
721
+ > > This software consists of voluntary contributions made by many
722
+ > > individuals. For exact contribution history, see the revision history
723
+ > > available at https://github.com/lodash/lodash
724
+ > >
725
+ > > The following license applies to all parts of this software except as
726
+ > > documented below:
727
+ > >
728
+ > > ====
705
729
  > >
706
730
  > > Permission is hereby granted, free of charge, to any person obtaining
707
731
  > > a copy of this software and associated documentation files (the
@@ -721,23 +745,21 @@ Repository: git+https://github.com/visulima/visulima.git
721
745
  > > LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
722
746
  > > OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
723
747
  > > WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
724
- >
725
- > ---------------------------------------
726
- >
727
- > ## indent-string
728
- > License: MIT
729
- > By: Sindre Sorhus
730
- > Repository: sindresorhus/indent-string
731
- >
732
- > > MIT License
733
748
  > >
734
- > > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
749
+ > > ====
735
750
  > >
736
- > > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
751
+ > > Copyright and related rights for sample code are waived via CC0. Sample
752
+ > > code is defined as all source code displayed within the prose of the
753
+ > > documentation.
737
754
  > >
738
- > > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
755
+ > > CC0: http://creativecommons.org/publicdomain/zero/1.0/
739
756
  > >
740
- > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
757
+ > > ====
758
+ > >
759
+ > > Files located in the node_modules and vendor directories are externally
760
+ > > maintained libraries used by this software which have their own
761
+ > > licenses; we recommend you read them, as their terms may differ from the
762
+ > > terms above.
741
763
  >
742
764
  > ---------------------------------------
743
765
  >
@@ -748,7 +770,7 @@ Repository: git+https://github.com/visulima/visulima.git
748
770
  >
749
771
  > > MIT License
750
772
  > >
751
- > > Copyright © 2010-2026 Roy Revelt and other contributors
773
+ > > Copyright © 2010-2025 Roy Revelt and other contributors
752
774
  > >
753
775
  > > Permission is hereby granted, free of charge, to any person obtaining
754
776
  > > a copy of this software and associated documentation files (the
@@ -778,7 +800,7 @@ Repository: git+https://github.com/visulima/visulima.git
778
800
  >
779
801
  > > MIT License
780
802
  > >
781
- > > Copyright © 2010-2026 Roy Revelt and other contributors
803
+ > > Copyright © 2010-2025 Roy Revelt and other contributors
782
804
  > >
783
805
  > > Permission is hereby granted, free of charge, to any person obtaining
784
806
  > > a copy of this software and associated documentation files (the
@@ -808,7 +830,7 @@ Repository: git+https://github.com/visulima/visulima.git
808
830
  >
809
831
  > > MIT License
810
832
  > >
811
- > > Copyright © 2010-2026 Roy Revelt and other contributors
833
+ > > Copyright © 2010-2025 Roy Revelt and other contributors
812
834
  > >
813
835
  > > Permission is hereby granted, free of charge, to any person obtaining
814
836
  > > a copy of this software and associated documentation files (the
@@ -838,7 +860,7 @@ Repository: git+https://github.com/visulima/visulima.git
838
860
  >
839
861
  > > MIT License
840
862
  > >
841
- > > Copyright © 2010-2026 Roy Revelt and other contributors
863
+ > > Copyright © 2010-2025 Roy Revelt and other contributors
842
864
  > >
843
865
  > > Permission is hereby granted, free of charge, to any person obtaining
844
866
  > > a copy of this software and associated documentation files (the
@@ -878,6 +900,29 @@ Repository: git+https://github.com/visulima/visulima.git
878
900
  >
879
901
  > ---------------------------------------
880
902
  >
903
+ > ## rfdc
904
+ > License: MIT
905
+ > By: David Mark Clements
906
+ > Repository: git+https://github.com/davidmarkclements/rfdc.git
907
+ >
908
+ > > Copyright 2019 "David Mark Clements <david.mark.clements@gmail.com>"
909
+ > >
910
+ > > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
911
+ > > documentation files (the "Software"), to deal in the Software without restriction, including without limitation
912
+ > > the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and
913
+ > > to permit persons to whom the Software is furnished to do so, subject to the following conditions:
914
+ > >
915
+ > > The above copyright notice and this permission notice shall be included in all copies or substantial portions
916
+ > > of the Software.
917
+ > >
918
+ > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
919
+ > > TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
920
+ > > THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
921
+ > > CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
922
+ > > IN THE SOFTWARE.
923
+ >
924
+ > ---------------------------------------
925
+ >
881
926
  > ## string-collapse-leading-whitespace
882
927
  > License: MIT
883
928
  > By: Roy Revelt
@@ -885,7 +930,7 @@ Repository: git+https://github.com/visulima/visulima.git
885
930
  >
886
931
  > > MIT License
887
932
  > >
888
- > > Copyright © 2010-2026 Roy Revelt and other contributors
933
+ > > Copyright © 2010-2025 Roy Revelt and other contributors
889
934
  > >
890
935
  > > Permission is hereby granted, free of charge, to any person obtaining
891
936
  > > a copy of this software and associated documentation files (the
@@ -915,7 +960,7 @@ Repository: git+https://github.com/visulima/visulima.git
915
960
  >
916
961
  > > MIT License
917
962
  > >
918
- > > Copyright © 2010-2026 Roy Revelt and other contributors
963
+ > > Copyright © 2010-2025 Roy Revelt and other contributors
919
964
  > >
920
965
  > > Permission is hereby granted, free of charge, to any person obtaining
921
966
  > > a copy of this software and associated documentation files (the
@@ -945,7 +990,7 @@ Repository: git+https://github.com/visulima/visulima.git
945
990
  >
946
991
  > > MIT License
947
992
  > >
948
- > > Copyright © 2010-2026 Roy Revelt and other contributors
993
+ > > Copyright © 2010-2025 Roy Revelt and other contributors
949
994
  > >
950
995
  > > Permission is hereby granted, free of charge, to any person obtaining
951
996
  > > a copy of this software and associated documentation files (the
@@ -983,6 +1028,35 @@ Repository: git+https://github.com/visulima/visulima.git
983
1028
  > >
984
1029
  > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
985
1030
  >
1031
+ > ---------------------------------------
1032
+ >
1033
+ > ## tiny-invariant
1034
+ > License: MIT
1035
+ > By: Alex Reardon
1036
+ > Repository: https://github.com/alexreardon/tiny-invariant.git
1037
+ >
1038
+ > > MIT License
1039
+ > >
1040
+ > > Copyright (c) 2019 Alexander Reardon
1041
+ > >
1042
+ > > Permission is hereby granted, free of charge, to any person obtaining a copy
1043
+ > > of this software and associated documentation files (the "Software"), to deal
1044
+ > > in the Software without restriction, including without limitation the rights
1045
+ > > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1046
+ > > copies of the Software, and to permit persons to whom the Software is
1047
+ > > furnished to do so, subject to the following conditions:
1048
+ > >
1049
+ > > The above copyright notice and this permission notice shall be included in all
1050
+ > > copies or substantial portions of the Software.
1051
+ > >
1052
+ > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1053
+ > > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1054
+ > > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1055
+ > > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1056
+ > > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1057
+ > > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1058
+ > > SOFTWARE.
1059
+ >
986
1060
  >
987
1061
  >
988
1062
  >
@@ -1 +1 @@
1
- import{inverse as d,cyan as f,green as h,yellow as y}from"@visulima/colorize";import{t as v,c as b,f as E}from"../packem_shared/format-positional-usage-DWL9qN10.js";const N=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],$="__Other",C=r=>r.charAt(0).toUpperCase()+r.slice(1),w=(r,s,l,o)=>{r.debug("no command given, printing general help...");let m=[...new Set(l.values())].filter(t=>!t.hidden);o&&(m=m.filter(t=>t.group===o));const e=m.reduce((t,i)=>{const p=i.group??$;return t[p]??=[],t[p].push(i),t},{}),a=t=>t.map(i=>{let p="";typeof i.alias=="string"?p=i.alias:Array.isArray(i.alias)&&(p=i.alias.join(", ")),p!==""&&(p=` [${p}]`);let u=i.name;return i.commandPath&&i.commandPath.length>0&&(u=`${i.commandPath.join(" ")} ${i.name}`),[`${h(u)}${p}`,i.description??""]});(r.raw??r.log)(b([{content:`${f(s.getCliName())} ${h("<command>")} [positional arguments] ${y("[options]")}`,header:d.cyan(" Usage ")},...Object.keys(e).map(t=>{const i=o?` ${C(o)}`:"";return{content:a(e[t]),header:t===$||o?d.green(` Available${i} Commands `):` ${d.green(` ${C(t)} `)}`}}),l.has("help")?{header:d.yellow(" Command Options "),optionList:l.get("help").options?.filter(t=>!t.hidden)}:void 0,{header:d.yellow(" Global Options "),optionList:s.getGlobalOptions()},{content:N.filter(t=>!t.hidden).map(t=>[t.name,t.description??""]),header:d.magenta(" Environment Variables ")},{content:`Run "${f(s.getCliName())} ${h("help <command>")}" or "${f(s.getCliName())} ${h("<command>")} ${y("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},P=(r,s)=>{const l=[];for(const o of r.values()){if(o.hidden)continue;const m=o.commandPath??[];if(m.length<s.length)continue;let e=!0;for(const[a,t]of s.entries())if(m[a]!==t){e=!1;break}e&&l.push(o)}return l},O=(r,s,l,o)=>{const m=l.join(" "),e=[{content:`${f(s.getCliName())} ${h(m)} ${h("<subcommand>")} [positional arguments] ${y("[options]")}`,header:d.cyan(" Usage ")},{content:o.map(a=>{const t=[...a.commandPath??[],a.name].join(" ");return[h(t),a.description??""]}),header:d.green(" Subcommands ")},{header:d.yellow(" Global Options "),optionList:s.getGlobalOptions()},{content:`Run "${f(s.getCliName())} ${h(`${m} <subcommand>`)} ${y("--help")}" for help with a specific subcommand.`,raw:!0}];(r.raw??r.log)(b(e))},A=(r,s,l,o,m)=>{let e=m??l.get(o);if(!e)for(const n of l.values()){const c=n.commandPath?[...n.commandPath,n.name]:[n.name];if(c.at(-1)===o||c.join(" ")===o){e=n;break}}if(!e){const n=o.split(" ").filter(Boolean),c=n.length>0?P(l,n):[];if(c.length>0){O(r,s,n,c);return}r.error(`Command "${o}" not found`);return}const a=[],i=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");a.push({content:`${f(s.getCliName())} ${h(i)}${E(e)}${e.options?" [options]":""}`,header:d.cyan(" Usage ")}),e.description&&a.push({content:e.description,header:d.green(" Description ")});const p=(e.argument?[e.argument]:e.arguments??[]).filter(n=>!n.hidden);if(p.length>0&&a.push({header:"Command Positional Arguments",isArgument:!0,optionList:p}),Array.isArray(e.options)&&e.options.length>0&&a.push({header:d.yellow(" Command Options "),optionList:e.options.filter(n=>!n.hidden)}),a.push({header:d.yellow(" Global Options "),optionList:s.getGlobalOptions()}),Array.isArray(e.env)&&e.env.length>0){const n=e.env.filter(c=>!c.hidden);n.length>0&&a.push({content:n.map(c=>[c.name,c.description??""]),header:d.magenta(" Environment Variables ")})}if(e.alias!==void 0&&e.alias.length>0){let n=e.alias;typeof e.alias=="string"&&(n=[e.alias]),a.splice(1,0,{content:n,header:"Alias(es)"})}Array.isArray(e.examples)&&e.examples.length>0&&a.push({content:e.examples,header:"Examples"});const u=[...e.commandPath??[],e.name],g=P(l,u);g.length>0&&a.push({content:g.map(n=>{const c=[...n.commandPath??[],n.name].join(" ");return[h(c),n.description??""]}),header:d.green(" Subcommands ")}),(r.raw??r.log)(b(a))};class S{argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(s){this.commands=s}execute(s){const{argument:l,command:o,commandName:m,logger:e,options:a,runtime:t}=s,{footer:i,header:p}=t.getCommandSection();p&&(e.raw??e.log)(v(p));const u=m==="help"&&Array.isArray(l)&&l.length>0?l.join(" "):void 0;if(m==="help"&&u===void 0)w(e,t,this.commands,typeof a?.group=="string"?a.group:void 0);else{const g=u!==void 0||o===void 0||o.name==="help"?void 0:o;A(e,t,this.commands,u??m,g)}i&&(e.raw??e.log)(v(i))}}export{S as default};
1
+ import{inverse as d,cyan as f,green as h,yellow as y}from"@visulima/colorize";import{t as v,c as b,f as E}from"../packem_shared/format-positional-usage-O92DKKjW.js";const N=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],$="__Other",C=r=>r.charAt(0).toUpperCase()+r.slice(1),w=(r,s,l,o)=>{r.debug("no command given, printing general help...");let m=[...new Set(l.values())].filter(t=>!t.hidden);o&&(m=m.filter(t=>t.group===o));const e=m.reduce((t,i)=>{const p=i.group??$;return t[p]??=[],t[p].push(i),t},{}),a=t=>t.map(i=>{let p="";typeof i.alias=="string"?p=i.alias:Array.isArray(i.alias)&&(p=i.alias.join(", ")),p!==""&&(p=` [${p}]`);let u=i.name;return i.commandPath&&i.commandPath.length>0&&(u=`${i.commandPath.join(" ")} ${i.name}`),[`${h(u)}${p}`,i.description??""]});(r.raw??r.log)(b([{content:`${f(s.getCliName())} ${h("<command>")} [positional arguments] ${y("[options]")}`,header:d.cyan(" Usage ")},...Object.keys(e).map(t=>{const i=o?` ${C(o)}`:"";return{content:a(e[t]),header:t===$||o?d.green(` Available${i} Commands `):` ${d.green(` ${C(t)} `)}`}}),l.has("help")?{header:d.yellow(" Command Options "),optionList:l.get("help").options?.filter(t=>!t.hidden)}:void 0,{header:d.yellow(" Global Options "),optionList:s.getGlobalOptions()},{content:N.filter(t=>!t.hidden).map(t=>[t.name,t.description??""]),header:d.magenta(" Environment Variables ")},{content:`Run "${f(s.getCliName())} ${h("help <command>")}" or "${f(s.getCliName())} ${h("<command>")} ${y("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},P=(r,s)=>{const l=[];for(const o of r.values()){if(o.hidden)continue;const m=o.commandPath??[];if(m.length<s.length)continue;let e=!0;for(const[a,t]of s.entries())if(m[a]!==t){e=!1;break}e&&l.push(o)}return l},O=(r,s,l,o)=>{const m=l.join(" "),e=[{content:`${f(s.getCliName())} ${h(m)} ${h("<subcommand>")} [positional arguments] ${y("[options]")}`,header:d.cyan(" Usage ")},{content:o.map(a=>{const t=[...a.commandPath??[],a.name].join(" ");return[h(t),a.description??""]}),header:d.green(" Subcommands ")},{header:d.yellow(" Global Options "),optionList:s.getGlobalOptions()},{content:`Run "${f(s.getCliName())} ${h(`${m} <subcommand>`)} ${y("--help")}" for help with a specific subcommand.`,raw:!0}];(r.raw??r.log)(b(e))},A=(r,s,l,o,m)=>{let e=m??l.get(o);if(!e)for(const n of l.values()){const c=n.commandPath?[...n.commandPath,n.name]:[n.name];if(c.at(-1)===o||c.join(" ")===o){e=n;break}}if(!e){const n=o.split(" ").filter(Boolean),c=n.length>0?P(l,n):[];if(c.length>0){O(r,s,n,c);return}r.error(`Command "${o}" not found`);return}const a=[],i=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");a.push({content:`${f(s.getCliName())} ${h(i)}${E(e)}${e.options?" [options]":""}`,header:d.cyan(" Usage ")}),e.description&&a.push({content:e.description,header:d.green(" Description ")});const p=(e.argument?[e.argument]:e.arguments??[]).filter(n=>!n.hidden);if(p.length>0&&a.push({header:"Command Positional Arguments",isArgument:!0,optionList:p}),Array.isArray(e.options)&&e.options.length>0&&a.push({header:d.yellow(" Command Options "),optionList:e.options.filter(n=>!n.hidden)}),a.push({header:d.yellow(" Global Options "),optionList:s.getGlobalOptions()}),Array.isArray(e.env)&&e.env.length>0){const n=e.env.filter(c=>!c.hidden);n.length>0&&a.push({content:n.map(c=>[c.name,c.description??""]),header:d.magenta(" Environment Variables ")})}if(e.alias!==void 0&&e.alias.length>0){let n=e.alias;typeof e.alias=="string"&&(n=[e.alias]),a.splice(1,0,{content:n,header:"Alias(es)"})}Array.isArray(e.examples)&&e.examples.length>0&&a.push({content:e.examples,header:"Examples"});const u=[...e.commandPath??[],e.name],g=P(l,u);g.length>0&&a.push({content:g.map(n=>{const c=[...n.commandPath??[],n.name].join(" ");return[h(c),n.description??""]}),header:d.green(" Subcommands ")}),(r.raw??r.log)(b(a))};class S{argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(s){this.commands=s}execute(s){const{argument:l,command:o,commandName:m,logger:e,options:a,runtime:t}=s,{footer:i,header:p}=t.getCommandSection();p&&(e.raw??e.log)(v(p));const u=m==="help"&&Array.isArray(l)&&l.length>0?l.join(" "):void 0;if(m==="help"&&u===void 0)w(e,t,this.commands,typeof a?.group=="string"?a.group:void 0);else{const g=u!==void 0||o===void 0||o.name==="help"?void 0:o;A(e,t,this.commands,u??m,g)}i&&(e.raw??e.log)(v(i))}}export{S as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as L}from"node:module";import{f as R,c as F}from"../packem_shared/format-positional-usage-DWL9qN10.js";import{g as q,a as G,b as U}from"../packem_shared/runtime-process-BN-eTlwy.js";let k;const O=e=>(k??=L(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[n,t]=$.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return $.getBuiltinModule(e)}return O(e)},{resolve:v,join:V,dirname:B}=T("node:path"),C=async(e,n)=>{try{return await e.access(n),!0}catch{return!1}},z=async()=>{const{default:e}=await import("github-slugger"),n=new e;return t=>n.slug(t)},I=e=>e.filter(Boolean),W=(e,n)=>{const t=new Set,o=[];for(const s of e){const r=n(s);t.has(r)||(t.add(r),o.push(s))}return o},D=(e,n)=>{const o=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");return`${n} ${o}${R(e,"readme")}`},H=(e,n)=>{if(!Array.isArray(e.env)||e.env.length===0)return;const t=e.env.filter(o=>!o.hidden);t.length>0&&n.push({content:t.map(o=>[o.name,o.description??""]),header:" Environment Variables "})},N=(e,n)=>{const t=[],s=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),r=!!e.options;t.push({content:`${n} ${s}${R(e)}${r?" [options]":""}`,header:" Usage "}),e.description&&t.push({content:e.description,header:" Description "});const c=(e.argument?[e.argument]:e.arguments??[]).filter(a=>!a.hidden);if(c.length>0&&t.push({header:"Command Positional Arguments",isArgument:!0,optionList:c}),Array.isArray(e.options)&&e.options.length>0&&t.push({header:" Command Options ",optionList:e.options.filter(a=>!a.hidden)}),H(e,t),e.alias!==void 0&&e.alias.length>0){const a=Array.isArray(e.alias)?e.alias:[e.alias];t.splice(1,0,{content:a,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&t.push({content:e.examples,header:"Examples"}),F(t)},J=(e,n)=>{const t=e.description?.trim().split(`
1
+ import{createRequire as L}from"node:module";import{f as R,c as F}from"../packem_shared/format-positional-usage-O92DKKjW.js";import{g as q,a as G,b as U}from"../packem_shared/runtime-process-BN-eTlwy.js";let k;const O=e=>(k??=L(import.meta.url))(e),$=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,T=e=>{if(typeof $<"u"&&$.versions&&$.versions.node){const[n,t]=$.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return $.getBuiltinModule(e)}return O(e)},{resolve:v,join:V,dirname:B}=T("node:path"),C=async(e,n)=>{try{return await e.access(n),!0}catch{return!1}},z=async()=>{const{default:e}=await import("github-slugger"),n=new e;return t=>n.slug(t)},I=e=>e.filter(Boolean),W=(e,n)=>{const t=new Set,o=[];for(const s of e){const r=n(s);t.has(r)||(t.add(r),o.push(s))}return o},D=(e,n)=>{const o=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");return`${n} ${o}${R(e,"readme")}`},H=(e,n)=>{if(!Array.isArray(e.env)||e.env.length===0)return;const t=e.env.filter(o=>!o.hidden);t.length>0&&n.push({content:t.map(o=>[o.name,o.description??""]),header:" Environment Variables "})},N=(e,n)=>{const t=[],s=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),r=!!e.options;t.push({content:`${n} ${s}${R(e)}${r?" [options]":""}`,header:" Usage "}),e.description&&t.push({content:e.description,header:" Description "});const c=(e.argument?[e.argument]:e.arguments??[]).filter(a=>!a.hidden);if(c.length>0&&t.push({header:"Command Positional Arguments",isArgument:!0,optionList:c}),Array.isArray(e.options)&&e.options.length>0&&t.push({header:" Command Options ",optionList:e.options.filter(a=>!a.hidden)}),H(e,t),e.alias!==void 0&&e.alias.length>0){const a=Array.isArray(e.alias)?e.alias:[e.alias];t.splice(1,0,{content:a,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&t.push({content:e.examples,header:"Examples"}),F(t)},J=(e,n)=>{const t=e.description?.trim().split(`
2
2
  `)[0]??"",o=D(e,n),s=N(e,n);return I([`## \`${o}\``,t,`\`\`\`
3
3
  ${s.trim()}
4
4
  \`\`\``]).join(`
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Cli as o}from"./packem_shared/Cerebro-B02RU3RC.js";import{VERBOSITY_DEBUG as E,VERBOSITY_NORMAL as s,VERBOSITY_QUIET as p,VERBOSITY_VERBOSE as u}from"./packem_shared/VERBOSITY_DEBUG-D7HfSD5l.js";import{default as l}from"./packem_shared/defineCommand-C_isHeEs.js";import{default as d}from"./packem_shared/InvalidArgumentChoiceError-BpovuqrZ.js";import{default as B}from"./packem_shared/MissingArgumentError-D78kza2a.js";import{default as O}from"./packem_shared/SurplusArgumentError-BLwT9lo0.js";import{lazyNamed as S}from"./packem_shared/lazyNamed-BKSCmVsV.js";import{c as C}from"./packem_shared/VisulimaError-BDqtOVL5-Db_MJ_p7.js";const a=(r,e)=>new o(r,e);export{o as Cerebro,d as InvalidArgumentChoiceError,B as MissingArgumentError,O as SurplusArgumentError,E as VERBOSITY_DEBUG,s as VERBOSITY_NORMAL,p as VERBOSITY_QUIET,u as VERBOSITY_VERBOSE,C as VisulimaError,a as createCerebro,l as defineCommand,S as lazyNamed};
1
+ import{Cli as o}from"./packem_shared/Cerebro-CENsjWZ1.js";import{VERBOSITY_DEBUG as E,VERBOSITY_NORMAL as s,VERBOSITY_QUIET as p,VERBOSITY_VERBOSE as u}from"./packem_shared/VERBOSITY_DEBUG-D7HfSD5l.js";import{default as l}from"./packem_shared/defineCommand-C_isHeEs.js";import{default as d}from"./packem_shared/InvalidArgumentChoiceError-BpovuqrZ.js";import{default as B}from"./packem_shared/MissingArgumentError-D78kza2a.js";import{default as O}from"./packem_shared/SurplusArgumentError-BLwT9lo0.js";import{lazyNamed as S}from"./packem_shared/lazyNamed-BKSCmVsV.js";import{c as C}from"./packem_shared/VisulimaError-BDqtOVL5-Db_MJ_p7.js";const a=(r,e)=>new o(r,e);export{o as Cerebro,d as InvalidArgumentChoiceError,B as MissingArgumentError,O as SurplusArgumentError,E as VERBOSITY_DEBUG,s as VERBOSITY_NORMAL,p as VERBOSITY_QUIET,u as VERBOSITY_VERBOSE,C as VisulimaError,a as createCerebro,l as defineCommand,S as lazyNamed};
@@ -0,0 +1,4 @@
1
+ import{createRequire as ct}from"node:module";import{VERBOSITY_DEBUG as V,POSITIONALS_KEY as oe,VERBOSITY_NORMAL as le,VERBOSITY_QUIET as vt,VERBOSITY_VERBOSE as At}from"./VERBOSITY_DEBUG-D7HfSD5l.js";import{C as b}from"./cerebro-error-Dv3FuXO8.js";import{c as re,d as we,o as Ne,e as F,a as Ct,b as Nt,f as bt,h as Ot,i as _t}from"./runtime-process-BN-eTlwy.js";import{c as ee}from"./VisulimaError-BDqtOVL5-Db_MJ_p7.js";import Et from"./InvalidArgumentChoiceError-BpovuqrZ.js";import xt from"./MissingArgumentError-D78kza2a.js";import kt from"./SurplusArgumentError-BLwT9lo0.js";import{X as It,H as Pt,C as ie,A as q,D as X,b as $,P as ce,m as be,Q as Oe,Y as $t,U as _e,$ as Lt,W as Ee,d as xe,G as ke,K as Mt,M as Ut,l as St,o as Tt,y as Dt,z as Vt,Z as jt,j as Rt,f as Bt,q as zt,k as Ft,v as Wt,J as qt,F as Gt,h as Kt,V as Ht}from"./constants-aPzGW29R-Cuf0YlDT.js";import{E as Xt,f as Yt}from"./format-user-facing-error-Cb7ySnUi.js";import{distance as Jt}from"fastest-levenshtein";let ht;const ut=t=>(ht??=ct(import.meta.url))(t),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pt=t=>{if(typeof Z<"u"&&Z.versions&&Z.versions.node){const[e,n]=Z.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return Z.getBuiltinModule(t)}return ut(t)},{writeFile:ft,stat:dt,rm:gt,readFile:Ce,readdir:mt,mkdir:wt,access:yt}=pt("node:fs/promises"),te=[{alias:"v",description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];class B extends b{commandName;constructor(e,n=[]){const s=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(s,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}}class Ge extends b{option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}}class Zt extends b{unknownOptions;constructor(e,n){const s=e.join(", "),i=`Found unknown ${e.length===1?"option":"options"}: ${s}`;super(i,"UNKNOWN_OPTION",{suggestions:n,unknownOptions:e}),this.name="UnknownOptionError",this.unknownOptions=e,n&&n.length>0&&(this.hint=`Did you mean: ${n.join(", ")}?`)}}class Qt extends b{pluginName;constructor(e,n,s){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:s,pluginName:e}),this.name="PluginError",this.pluginName=e,s&&(this.cause=s)}}class en{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);re().CEREBRO_OUTPUT_LEVEL===String(V)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const n=this.getDependencyOrder();this.logger.debug(`initializing ${String(n.length)} plugin(s)...`);for(const s of n)if(typeof s.init=="function"){this.logger.debug(`initializing plugin: ${s.name}`);try{await s.init(e)}catch(i){const o=new Qt(s.name,`Failed to initialize: ${i instanceof Error?i.message:String(i)}`,i instanceof Error?i:void 0);throw this.logger.error(o.message),o}}this.initialized=!0}async executeLifecycle(e,n,s){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const i=this.getDependencyOrder();for(const o of i){const l=o[e];if(typeof l=="function"){this.logger.debug(`executing ${e} hook for plugin: ${o.name}`);try{await(e==="afterCommand"?l(n,s):l(n))}catch(a){throw this.logger.error(`Error in ${e} hook for plugin "${o.name}":`,a),a}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const s=this.getDependencyOrder();for(const i of s)if(typeof i.onError=="function"){this.logger.debug(`executing error handler for plugin: ${i.name}`);try{await i.onError(e,n)}catch(o){this.logger.error(`Error in error handler for plugin "${i.name}":`,o)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,s=new Set,i=o=>{if(n.has(o))return;if(s.has(o))throw new Error(`Circular dependency detected involving plugin "${o}"`);const l=this.plugins.get(o);if(!l)throw new Error(`Plugin "${o}" not found`);if(s.add(o),l.dependencies)for(const a of l.dependencies)i(a);s.delete(o),n.add(o),e.push(l)};for(const o of this.plugins.keys())i(o);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}}const Q=t=>t.type?.name==="Boolean",tn=t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},Ie=t=>(Q(t)||(t.typeLabel=t.typeLabel??tn(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),nn=new RegExp(/^-([^\d-])$/),sn=new RegExp(/^--(\S+)/),on=new RegExp(/^-([^\d-]{2,})$/),rn=t=>nn.test(t)||sn.test(t)||on.test(t),an=(t,e)=>{const n=e[0]&&rn(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const s=new Error(`Command not recognised: ${String(n)}`);throw s.command=n,s.name="INVALID_COMMAND",s}return{argv:e,command:n}};let ln=class Ke extends ee{optionName;value;constructor(e,n,s){super({hint:`Pass a valid ${s} value for '${e}'.`,message:`Invalid ${s} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,Ke.prototype)}},cn=class He extends ee{optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,He.prototype)}},Pe=class Xe extends ee{optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,Xe.prototype)}};class Ae extends ee{value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,Ae.prototype)}}let L=class Ye extends ee{constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,Ye.prototype)}};const G=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",ye=t=>t===Number||typeof t=="function"&&t.name==="Number",$e=t=>t===String||typeof t=="function"&&t.name==="String",Le=(t,e,n)=>{const s=Number(t);if(e&&Number.isNaN(s)&&String(t).trim().toLowerCase()!=="nan")throw new ln(n??"",String(t),"Number");return s},hn=(t,e,n={})=>{const{optionName:s,strictTypes:i}=n;return Array.isArray(t)?G(e)?t.map(Boolean):ye(e)?t.map(o=>Le(o,i,s)):$e(e)?t.map(String):t.map(o=>e(String(o))):t===null?null:G(e)?!!t:ye(e)?Le(t,i,s):$e(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},x=(t,e,n,...s)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...s)},un=/-([a-z])/g,pn=/^\d+$/,fn=t=>t.codePointAt(0)===95,Me=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],Ue=t=>t==="__proto__"||t==="constructor"||t==="prototype",he=(t,e,n,s=!1)=>{t[e]===void 0?t[e]=s?[n]:n:s&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},Se=(t,e,n,s,i)=>{let o=e.get(t)??n.get(t);if(!o&&s){const l=t.toLowerCase();o=s.get(l)??i?.get(l)}return o},dn=(t,e,n,s)=>{const i=n.debug??!1;x(i,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),x(i,"Starting argument resolution","resolver"),x(i,"Tokens:","resolver",t),x(i,"Definitions:","resolver",e),x(i,"Processing tokens...","resolver");const o=new Map,l=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,c=n.camelCase?new Map:void 0;for(const f of e)if(o.set(f.name,f),f.alias&&l.set(f.alias,f),n.caseInsensitive&&a&&(a.set(f.name.toLowerCase(),f),f.alias&&u&&u.set(f.alias.toLowerCase(),f)),n.camelCase&&r&&c){const w=f.name.replaceAll(un,(v,I)=>I.toUpperCase());r.set(f.name,w),c.set(w,f.name)}const p=Object.create(null),h=Object.create(null),m=[],g=[],y=new Set;let A=!1;const d=e.find(f=>f.defaultOption),C=e.some(f=>f.group),O=e.find(f=>ye(f.type));for(let f=0;f<t.length;f++){const w=t[f];if(w.kind==="option-terminator"){p._unknown=s.slice(w.index),A=!0;break}if(w.kind==="option"&&w.name){let v=Se(w.name,o,l,a,u);!v&&w.value===void 0&&O&&pn.test(w.name)&&(v=O,w.value=w.name,w.name=O.name);let I=!1;if(!v&&n.negation&&w.value===void 0&&w.name.startsWith("no-")){const _=w.name.slice(3),U=Se(_,o,l,a,u);U?.type&&G(U.type)&&(v=U,I=!0)}const N=v?v.name:w.name,P=v?.multiple,M=v?.lazyMultiple;if(Object.hasOwn(h,N)&&h[N]!==void 0&&!P&&!M&&!n.partial)throw new cn(N);if(!v&&n.partial){const _=w.rawName??`--${w.name}${w.value!==void 0&&w.inlineValue?`=${w.value}`:""}`;m.push({index:w.index,value:_});continue}if(!v&&n.stopAtFirstUnknown){p._unknown=s.slice(w.index);break}if(!v&&!n.partial)throw new Pe(w.name);if(w.value===void 0){const _=t[f+1],U=_?.kind==="option"&&!("name"in _)&&_.value!==void 0,T=_&&v&&!(v.type&&G(v.type))&&(_.kind==="positional"||U),lt=v&&v.defaultOption&&!v.multiple&&!v.lazyMultiple;if(T&&(!v?.defaultOption||lt))if(P){let D=f+1;const ae=[];for(;D<t.length&&(t[D].kind==="positional"||t[D].kind==="option"&&!("name"in t[D])&&t[D].value!==void 0);)ae.push(t[D].value),y.add(t[D].index),D++;h[N]=h[N]===void 0?ae:Me(h[N],ae),f=D-1}else M?(he(h,N,_.value,!0),y.add(_.index),f++):(h[N]=_.value,y.add(_.index),f++);else v?.type&&G(v.type)?he(h,N,!I,P):(P||M)&&h[N]!==void 0?he(h,N,null,!0):h[N]=P?[]:null}else{let{value:_}=w;if(v?.type&&G(v.type))switch(_){case"":{if(n.partial){const T=`${w.rawName??`--${w.name}`}${w.value?`=${w.value}`:""}`;g.push({index:w.index,value:T}),_=!0}else throw new Pe(w.name);break}case"false":{_=!1;break}case"true":{_=!0;break}default:_=!0}const U=[_];if(P){let T=f+1;for(;T<t.length&&t[T].kind==="positional";)U.push(t[T].value),y.add(t[T].index),T++;f=T-1}h[N]===void 0?h[N]=P||M?U:_:P||M?h[N]=Me(h[N],U):h[N]=_}}else if(w.kind==="positional"&&n.stopAtFirstUnknown&&!y.has(w.index)&&!d){x(i,`Found unconsumed positional token at index ${String(w.index)}, stopping processing`,"resolver"),p._unknown=s.slice(w.index);break}}for(const[f,w]of Object.entries(h)){const v=o.get(f);v&&(v.multiple||v.lazyMultiple)&&!Array.isArray(w)&&(h[f]=[w])}const k=f=>f.kind==="option"&&!o.has(f.name??"")&&!l.has(f.name??"")&&(!n.caseInsensitive||!a?.has(f.name?.toLowerCase()??"")&&!u?.has(f.name?.toLowerCase()??""));let E=-1,H=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!A&&(E=t.findIndex(f=>k(f)),E!==-1&&(H=t[E].index)),d){const f=[],w=[];for(const v of t)v.kind==="positional"&&!y.has(v.index)&&v.index<H&&(f.push(v.value),w.push(v));if(f.length>0){const v=h[d.name],I=d.multiple??d.lazyMultiple;v===void 0?I?(w.forEach(N=>y.add(N.index)),h[d.name]=f):(y.add(w[0].index),h[d.name]=f[0]):I&&(w.forEach(N=>y.add(N.index)),h[d.name]=Array.isArray(v)?[...f,...v]:[...f,v])}}if(!n.partial){for(const f of t)if(f.kind==="positional"&&!y.has(f.index))throw new Ae(s[f.index])}if(n.partial&&!n.stopAtFirstUnknown){const f=[...m];for(const w of g)f.push({index:w.index,value:w.value});for(const w of t)w.kind==="positional"&&!y.has(w.index)&&f.push({index:w.index,value:s[w.index]});f.length>0&&(f.sort((w,v)=>w.index-v.index),p._unknown=f.map(w=>w.value))}if(n.stopAtFirstUnknown&&!A){const f=t.findIndex(v=>v.kind==="positional"&&!y.has(v.index));let w=-1;if(E!==-1&&f!==-1?w=Math.min(E,f):E!==-1?w=E:f!==-1&&(w=f),w>=0){const v=t[w].index;p._unknown=s.slice(v)}}for(const[f,w]of Object.entries(h)){const v=n.camelCase?r?.get(f)??f:f,I=o.get(f);I?.type?p[v]=hn(w,I.type,{optionName:I.name,strictTypes:n.strictTypes}):p[v]=w===void 0?null:w}for(const f of e){const w=n.camelCase?r?.get(f.name)??f.name:f.name;!(w in p)&&f.defaultValue!==void 0&&(f.multiple??f.lazyMultiple?p[w]=Array.isArray(f.defaultValue)?[...f.defaultValue]:[f.defaultValue]:p[w]=f.defaultValue)}if(C){const f={},w={},v={};for(const N of e)if(N.group){const P=Array.isArray(N.group)?N.group:[N.group];for(const M of P)Ue(M)||(f[M]??={})}for(const N of Object.keys(p))if(!fn(N)){w[N]=p[N];let P=N;n.camelCase&&(P=c?.get(N)??N);const M=o.get(P);if(M?.group){const _=Array.isArray(M.group)?M.group:[M.group];for(const U of _)Ue(U)||f[U]&&(f[U][N]=p[N])}else v[N]=p[N]}const I={_all:w};for(const[N,P]of Object.entries(f))I[N]=P;Object.keys(v).length>0&&(I._none=v),p._unknown&&(I._unknown=p._unknown),Object.keys(p).forEach(N=>delete p[N]),Object.assign(p,I)}const S=Object.defineProperties({},Object.getOwnPropertyDescriptors(p));return x(i,"Final parsed result:","resolver",S),S},Je="-",J=Je.codePointAt(0),K="=",gn=K.codePointAt(0),mn="--",wn=Je,yn="--",Ze=t=>t.length>2&&t.startsWith(yn),vn=t=>Ze(t)&&!t.includes(K,3),An=t=>Ze(t)&&t.includes(K,3),Cn=t=>{if(t.length!==2||t.codePointAt(0)!==J||t.codePointAt(1)===J)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},Nn=t=>{if(t.length<=2||t.codePointAt(0)!==J||t.codePointAt(1)===J)return!1;const e=t.codePointAt(1);return!(e!==void 0&&e>=48&&e<=57)},bn=t=>{const e=[];let n=0,s=[],i=0,o=-1,l=0;for(;i<s.length||n<t.length;){let a;if(i<s.length?(a=s[i],i++):(a=t[n],n++),l>0?l--:o++,a===mn){e.push({index:o,kind:"option-terminator"});const u=[...s.slice(i),...t.slice(n)],r=u.map((c,p)=>({index:o+p+1,kind:"positional",value:c}));e.push(...r),o+=u.length;break}if(Cn(a)){const u=a.charAt(1);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(Nn(a)&&!a.includes(K)){const u=[];let r="",c=!1;for(let p=1;p<a.length;p++){const h=a.charAt(p);c?r+=h:h.codePointAt(0)===gn?c=!0:u.push(`${wn}${h}`)}if(c)if(u.length>0){const p=u.pop();u.push(`${p}=${r}`)}else u.push(r);s=i<s.length?[...u,...s.slice(i)]:u,i=0,l=u.length;continue}if(vn(a)){const u=a.slice(2);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(An(a)){const u=a.indexOf(K),r=a.slice(2,u),c=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:c});continue}if(a.length>2&&a.codePointAt(0)===J&&a.codePointAt(1)!==J&&a.includes(K)){const u=a.indexOf(K),r=a.charAt(1),c=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:c});continue}e.push({index:o,kind:"positional",value:a})}return e},On=/\d/,_n=t=>typeof t=="function",En=(t,e,n)=>{const s=n?.debug??!1;x(s,"Validating definitions:","validation",t,"caseInsensitive:",e);const i=new Set,o=new Set,l=new Set,a=new Set;let u=0;for(const r of t){if(x(s,"Checking definition:","validation",r),!r.name)throw x(s,"Validation failed: name is required","validation"),new L("Invalid option definition: name is required");if(typeof r.name!="string")throw new L("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new L("Invalid option definition: name cannot be empty");const c=e?r.name.toLowerCase():"";if(i.has(r.name)||e&&l.has(c))throw new L(`Invalid option definition: duplicate name '${r.name}'`);if(o.has(r.name)||e&&a.has(c))throw new L(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(i.add(r.name),e&&l.add(c),r.alias!==void 0){if(typeof r.alias!="string")throw new L("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new L("Invalid option definition: alias must be a single character");if(On.test(r.alias))throw new L("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new L('Invalid option definition: alias cannot be "-"');const p=e?r.alias.toLowerCase():"";if(o.has(r.alias)||e&&a.has(p))throw new L(`Invalid option definition: duplicate alias '${r.alias}'`);if(i.has(r.alias)||e&&l.has(p))throw new L(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);o.add(r.alias),e&&a.add(p)}if(r.defaultOption&&(u++,r.type!==void 0&&G(r.type)))throw new L("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&_n(r.type)))throw new L("Invalid option definition: invalid type")}if(u>1)throw x(s,"Validation failed: multiple defaultOptions not allowed","validation"),new L("Invalid option definition: multiple defaultOptions not allowed");x(s,"Validation completed successfully","validation")};function xn(t,e={}){const n=e.debug??!1;x(n,"Starting command-line-args parsing","index"),x(n,"Options:","index",e);const s={...e};s.stopAtFirstUnknown&&(s.partial=!0);const i=Array.isArray(t)?t:[t];x(n,"Normalized definitions:","index",i),En(i,s.caseInsensitive,n?s:void 0);let{argv:o}=s;o??=process.argv.slice(2),x(n,"Using argv:","index",o);let l=o;s.caseInsensitive&&(l=o.map(r=>{if(r.startsWith("--")){const c=r.indexOf("="),p=(c===-1?r.slice(2):r.slice(2,c)).toLowerCase();return c===-1?`--${p}`:`--${p}${r.slice(c)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const c=r.indexOf("="),p=c===-1?r.slice(1):r.slice(1,c);if(!p)return r;const h=p.toLowerCase();return c===-1?`-${h}`:`-${h}${r.slice(c)}`}return r}));const a=bn(l.map(String));x(n,"Tokenized arguments:","index",a);const u=dn(a,i,s,o);return x(n,"Command-line-args parsing completed","index"),u}class kn{result;argv;options;argument;args;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;rawArgv;constructor(e,n){this.commandName=e,this.command=n}}class ue extends b{commandName;constructor(e,n,s){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",s!==void 0&&(this.cause=s)}}const In=/^-{1,2}(\w+)(=(.+))?$/,Qe=(t,e,n,s)=>{const i=In.exec(t);if(i===null)return{};const o=i[1];if(!o)return{};const l=n&&s?n.get(o)??s.get(o):e.find(a=>a.name===o||a.alias===o);return l!==void 0?{argName:l.name,argValue:i[3],option:l}:{}},Te=(t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},Pn=new Set(["0","1","false","true"]),$n=(t,e,n,s)=>{if(e.length===0||t.length===0)return{};const i=(o,l)=>{const{argName:a,argValue:u,option:r}=Qe(l,e,n,s),{lastOption:c}=o;return r&&Q(r)&&u&&a?o.partial[a]=Te(u,r):o.lastName&&c&&Q(c)&&Pn.has(l)&&(o.partial[o.lastName]=Te(l,c)),{lastName:a,lastOption:r,partial:o.partial}};return t.reduce(i,{partial:{}}).partial},Ln=new Set(["0","1","false","true"]),Mn=(t,e,n,s)=>{if(e.length===0||t.length===0)return t;const i=(o,l)=>{const{argValue:a,option:u}=Qe(l,e,n,s),{lastOption:r}=o;if(r&&Q(r)&&Ln.has(l)){const{args:p}=o;return{args:p.slice(0,-1)}}return u&&Q(u)&&a?{args:o.args}:{args:[...o.args,l],lastOption:u}};return t.reduce(i,{args:[]}).args},De=t=>{const e=new Map;for(const n of t){const s=e.get(n.name);s?e.set(n.name,{...s,...n}):e.set(n.name,n)}return[...e.values()]},Un=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},Sn=(t,e)=>{if(!t.type)return e;if(e===void 0)return;if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return Un(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const o=Number.parseFloat(e);return Number.isNaN(o)?void 0:o}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)},Tn=/_./g,Dn=/^[A-Z]/,Vn=t=>t.toLowerCase().replaceAll(Tn,e=>e[1]?.toUpperCase()??e).replace(Dn,e=>e.toLowerCase()),jn=(t,e=re())=>{if(!t||t.length===0)return{};const n={};for(const s of t){const i=e[s.name],o=Sn(s,i),l=o===void 0?s.defaultValue:o,a=Vn(s.name);n[a]=l}return n},Rn=/-([a-z])/g,et=t=>t.replaceAll(Rn,(e,n)=>n.toUpperCase()),Ve=(t,e)=>t.type===void 0?e:t.type(e),Bn=(t,e)=>{const{choices:n}=t;if(!n||n.length===0)return[];const s=[];for(const i of e)n.includes(i)||s.push({choices:n,name:t.name,value:i});return s},zn=(t,e)=>e&&t.defaultValue!==void 0&&!Array.isArray(t.defaultValue)?[t.defaultValue]:t.defaultValue,Fn=(t,e)=>{const n={},s=[],i=[],o=t.length-1;let l=0;for(const[a,u]of t.entries()){const r=et(u.name),c=a===o&&u.multiple===!0,p=c?e.slice(a):e.slice(a,a+1);if(p.length===0){u.required===!0&&s.push(u.name),n[r]=zn(u,c);continue}i.push(...Bn(u,p)),l=a+p.length,n[r]=c?p.map(h=>Ve(u,h)):Ve(u,p[0])}return{invalid:i,missing:s,resolved:n,surplus:e.slice(l)}},Wn=t=>{const e=new Map,n=new Map;for(const s of t)if(e.set(s.name,s),s.alias){const i=Array.isArray(s.alias)?s.alias:[s.alias];for(const o of i)n.set(o,s)}return{optionMapByAlias:n,optionMapByName:e}},tt=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new ue(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(s){throw new ue(t.name,s instanceof Error?s.message:String(s),s)}const n=e.default;if(typeof n!="function")throw new ue(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},qn=(t,e,n,s,i,o=[])=>{const l=new kn(t.name,t),{_all:a,_unknown:u,positionals:r}=e,p=Object.keys(n).length>0?{...a,...n}:a;oe in p&&delete p[oe],l.argument=r?.[oe]??[],l.args={},l.rawUnknown=[...u??[]],l.rawArgv=[...o];const h=Object.keys(s).length>0;return l.options=h?{...p,...s}:p,l.env=jn(t.env,i),l},Gn=(t,e,n)=>{const s=t.options??[],i=s.length>0;let o=De(i?[...s,...n]:n);if(o.length>0){for(const c of o)if(c.multiple&&c.lazyMultiple)throw new Error(`Argument "${c.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}const l=t.arguments!==void 0&&t.arguments.length>0;(t.argument||l)&&(o=[{defaultOption:!0,description:t.argument?.description,group:"positionals",multiple:!0,name:oe,type:t.argument?.type??String,typeLabel:t.argument?.typeLabel},...o]);let a,u;if(i){const{optionMapByAlias:c,optionMapByName:p}=Wn(s);a=Mn(e,s,p,c),u=$n(e,s,p,c)}else a=e,u={};const r=xn(o,{argv:a,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:o,booleanValues:u,parsedArgs:r}},pe=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await tt(t))(e),Kn=(t,e)=>{if(!t.arguments||t.arguments.length===0)return;const n=e.rawUnknown.indexOf("--"),s=n===-1?[]:e.rawUnknown.slice(n+1),i=s.length===0?e.argument:e.argument.slice(0,Math.max(0,e.argument.length-s.length)),o=Fn(t.arguments,i);if(e.args=o.resolved,o.missing.length>0)throw new xt(t.name,o.missing);const[l]=o.invalid;if(l)throw new Et(l.name,l.value,l.choices);if(o.surplus.length>0)throw new kt(t.name,o.surplus,t.arguments.length)};class Hn{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const s=this.cache.keys().next().value;s!==void 0&&this.cache.delete(s)}this.cache.set(e,n)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}}const Xn=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),Yn=new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))","g"),Jn=t=>{if(typeof t!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof t}`);return t.replaceAll(Yn,"")},fe=new Hn(1e3),Zn=/[.*+?^${}()|[\]\\]/g,Qn=t=>{const e=t.join("");if(fe.has(e)){const i=fe.get(e);return i.lastIndex=0,i}const n=t.map(i=>i.replaceAll(Zn,String.raw`\$&`)).join("|"),s=new RegExp(n,"g");return fe.set(e,s),s},es=t=>{const e=[];let n=0,s;for(q.lastIndex=0;(s=q.exec(t))!==null;)s.index>n&&e.push(t.slice(n,s.index)),e.push(s[0]),n=q.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},ts=/[ČŠŽĐ]/i,nt=new Uint8Array(128),st=new Uint8Array(128),ot=new Uint8Array(128);for(let t=0;t<128;t++)nt[t]=t>=65&&t<=90?1:0,st[t]=t>=97&&t<=122?1:0,ot[t]=t>=48&&t<=57?1:0;const de=t=>nt[t],je=t=>st[t],ge=t=>ot[t],j=(t,e,n,s,i)=>{if(t.length===0)return[];let o=!1;const l=Object.values(e);for(const m of l)if(m(t[0])){o=!0;break}if(!o&&!n)return[t];const a=[...t],u=[];let r=a[0],c="other";const p=Object.entries(e);for(const m of p){const[g,y]=m;if(y(a[0])){c=g;break}}let h=n&&s?a[0]===a[0].toLocaleUpperCase(s):!1;for(let m=1;m<a.length;m++){const g=a[m];let y="other";for(const C of p){const[O,k]=C;if(k(g)){y=O;break}}const A=n&&s?g===g.toLocaleUpperCase(s):!1;let d=!1;i?d=i(c,y,h,A,g,m,a):(c!==y&&c!=="other"&&y!=="other"&&(d=!0),n&&y!=="other"&&!h&&A&&(d=!0)),d?(u.push(r),r=g):r+=g,c=y,n&&(h=A)}return r&&r.length>0&&u.push(r),u.length>0?u:[t]},ns=(t,e,n,s)=>{if(n.size===0)return e;for(const i of n)if(t.startsWith(i,e))return s.push(i),e+i.length;return e},it=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const s=[],i=t.length;for(let o=1;o<i;o++){const l=ns(t,n,e,s);if(l!==n){n=l,o=n-1;continue}const a=t.codePointAt(o-1),u=t.codePointAt(o),r=a&&a<128&&de(a),c=u&&u<128&&de(u),p=a&&a<128&&je(a),h=a&&a<128&&ge(a),m=u&&u<128&&ge(u);if(p&&c){s.push(t.slice(n,o)),n=o;continue}if(h&&!m||!h&&m){s.push(t.slice(n,o)),n=o;continue}if(m&&!h){let g=!1,y=!1;if(o+1<i){const A=t.codePointAt(o+1);g=A&&A<128&&de(A),y=A&&A<128&&ge(A)}if(!y&&g){s.push(t.slice(n,o),t.slice(o,o+1)),n=o+1;continue}}if(o+1<i){const g=t.codePointAt(o+1),y=g&&g<128&&je(g);if(r&&c&&y){const A=t.slice(n,o+1);e.has(A)||(s.push(t.slice(n,o)),n=o)}}}return n<i&&s.push(t.slice(n)),s.filter(o=>o!=="")},rt=(t,e,n)=>{if(t.length===0)return[];const s=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!s&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const r=[...t],c=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e),g=m,y=m?0:-1;for(let A=1;A<c;A++){const d=r[A],C=d===d.toLocaleUpperCase(e);if(C===m)h+=d;else if(C)h&&h.length>0&&(p.push(h),h=d),g=!0,y=A;else{if(g&&A-y>1){const O=r[A-1],k=h.slice(0,-1);k&&k.length>0&&p.push(k),h=O+d}else h+=d;g=!1,y=-1}m=C}return h&&h.length>0&&p.push(h),p}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!X.test(t)&&!$.test(t))return[t];const r=[...t],c=r.length,p=[];let h=r[0];const m=r[0];let g;X.test(m)?g=1:$.test(m)?g=2:g=0;let y=m===m.toLocaleUpperCase(e);for(let d=1;d<c;d++){const C=r[d];let O;X.test(C)?O=1:$.test(C)?O=2:O=0;const k=C===C.toLocaleUpperCase(e);g!==O&&(g===1||g===2)&&(O===1||O===2)||O===g&&!y&&k?(p.push(h),h=C):h+=C,g=O,y=k}h&&h.length>0&&p.push(h);const A=[];for(let d=0;d<p.length;d++)d<p.length-1&&p[d].length===1&&$.test(p[d])&&X.test(p[d+1][0])?(A.push(p[d]+p[d+1]),d+=1):A.push(p[d]);return A}if(e.startsWith("el")){if(!ce.test(t)&&!$.test(t))return[t];const r=[];be.lastIndex=0;let c;for(;(c=be.exec(t))!==null;)r.push(c[0]);r.length===0&&r.push(t);const p=[];if(r.length===1){const h=r[0];if(!h||!ce.test(h[0])||h.length===1)return[h??t]}for(const h of r){if(!h)continue;if(!ce.test(h[0])||h.length===1){p.push(h);continue}const m=h.length;let g=h[0],y=h[0]===h[0].toLocaleUpperCase(e);for(let A=1;A<m;A++){const d=h[A],C=d===d.toLocaleUpperCase(e);!y&&C?(p.push(g),g=d):g+=d,y=C}g&&p.push(g)}return p}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),c=r?{hiragana:h=>Lt.test(h),kanji:h=>_e.test(h),katakana:h=>$t.test(h),latin:h=>$.test(h)}:{hangul:h=>Ee.test(h),latin:h=>$.test(h)},p=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const h=j(t,c,!1,e,(g,y)=>g==="hiragana"&&y==="katakana"||g==="katakana"&&y==="hiragana"||g==="hiragana"&&y==="latin"||g==="katakana"&&y==="latin"||g==="kanji"&&y==="latin"||g==="latin"&&(y==="hiragana"||y==="katakana"||y==="kanji")),m=[];for(const g of h){const y=g;y.length===1&&p.has(y)&&m.length>0?m[m.length-1]=m.at(-1)+y:m.push(y)}return m.length>0?m:[t]}return j(t,c,!1,e,(h,m)=>h==="hangul"&&m==="latin"||h==="latin"&&m==="hangul")}if(e.startsWith("sl")){const r=[...t],c=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e);for(let g=1;g<c;g++){const y=r[g],A=y===y.toLocaleUpperCase(e),d=ts.test(y),C=g<c-1&&r[g+1]===r[g+1].toLocaleUpperCase(e);!m&&A||d&&C?(p.push(h),h=y,d&&C&&(p.push(h),h="")):h+=y,m=A}return h&&h.length>0&&p.push(h),p}if(e.startsWith("zh"))return j(t,{han:r=>_e.test(r),latin:r=>$.test(r)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=c=>xe.test(c)||ke.test(c);return j(t,{latin:c=>$.test(c),rtl:c=>r(c)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const r=c=>Mt.test(c)||Ut.test(c)||St.test(c)||Tt.test(c)||Dt.test(c)||Vt.test(c)||jt.test(c)||Rt.test(c)||Bt.test(c)||zt.test(c)||Ft.test(c)||Wt.test(c)||qt.test(c)||Gt.test(c)||Kt.test(c)||Ht.test(c);return j(t,{indic:c=>r(c),latin:c=>$.test(c)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return j(t,{cyrillic:r=>X.test(r),latin:r=>$.test(r)},!0,e);if(["ar","fa","he"].includes(e))return j(t,{latin:r=>$.test(r),rtl:r=>xe.test(r)||ke.test(r)},!1,e);if(e.startsWith("ko"))return j(t,{hangul:r=>Ee.test(r),latin:r=>$.test(r)},!1,e);if(e.startsWith("uz")){if(!X.test(t)&&!$.test(t))return[t];const r=[...t],c=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e);for(let g=1;g<c;g++){const y=r[g],A=y===y.toLocaleUpperCase(e);if(Oe.test(y)||Oe.test(r[g-1])){h+=y;continue}!m&&A?(p.push(h),h=y):h+=y,m=A}return h&&h.length>0&&p.push(h),p}const i=[...t],o=i.length,l=[];let a=i[0],u=i[0]===i[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){l.push(r),a=i[r.length],u=a===a.toLocaleUpperCase(e);break}for(let r=1;r<o;r++){const c=i[r],p=c===c.toLocaleUpperCase(e);let h=0;for(const m of n)if(t.startsWith(m,r)){l.push(a,m),h=m.length,a="";const g=m.at(-1);g&&(u=g===g.toLocaleUpperCase(e));break}if(h>0){r+=h-1;continue}!u&&p?(l.push(a),a=c):a+=c,u=p}return a&&l.push(a),l},ss=(t,e,n)=>{const s=[],i=ie.test(t)?t.split(ie).filter(Boolean):[t];for(const o of i){const l=o;if(ie.test(l))s.push(l);else{q.lastIndex=0;const a=q.test(l)?es(l).filter(Boolean):[l];for(const u of a)if(q.lastIndex=0,q.test(u))s.push(u);else if(e){const r=e.toLowerCase().split("-")[0];s.push(...rt(u,r,n))}else s.push(...it(u,n))}}return s},os=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:s=!1,knownAcronyms:i=[],locale:o,normalize:l=!1,separators:a,stripAnsi:u=!1,stripEmoji:r=!1}=e,c=new Set([...i].toSorted((d,C)=>C.length-d.length));let p=t;u&&(p=Jn(p)),r&&(p=It(p));let h;Array.isArray(a)?h=Qn(a):a instanceof RegExp?h=a:h=Pt;const m=[];let g=p;const y=h.flags.includes("g")?h:new RegExp(h.source,`${h.flags}g`);for(;g.length>0;){const d=y.exec(g);if(!d){g===".."?m.push(".."):g==="."?m.push("."):g.length>0&&m.push(g);break}const C=d.index,O=d[0],k=O.length,E=g.slice(0,C),H=g.slice(C+k);if(O.startsWith("../"))m.push(".."),g=g.slice(C+3);else if(O.startsWith("./"))m.push("."),g=g.slice(C+2);else if(C===0&&O==="..")m.push(".."),g=g.slice(2);else if(C===0&&O===".")m.push("."),g=g.slice(1);else{E.length>0&&m.push(E);let S=0;for(;(S=O.indexOf("../",S))!==-1;)m.push(".."),S+=3;for(S=0;(S=O.indexOf("./",S))!==-1;)(S===0||O[S-1]!==".")&&m.push("."),S+=2;let f=H;for(;f.startsWith("../");)m.push(".."),f=f.slice(3);for(;f.startsWith("./");)m.push("."),f=f.slice(2);if(f===".."){m.push("..");break}else if(f==="."){m.push(".");break}else g=f}y.lastIndex=0}if(m.length===0){const d=p.split(h).filter(Boolean);m.push(...d)}let A=[];for(const d of m)n||s?A.push(...ss(d,o,c)):o?A.push(...rt(d,o,c)):A.push(...it(d,c));return l&&(A=A.map(d=>c.has(d)?d:o&&d===d.toLocaleUpperCase(o)?d[0]+d.slice(1).toLocaleLowerCase(o):d.toUpperCase()===d&&!c.has(d)?d.slice(0,1)+d.slice(1).toLowerCase():d)),A},is=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),rs=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const s=[];let i="",o="";for(let l=0;l<n;l++){const a=t[l];if(ie.test(a)){i?(s.push(i+o+a),i="",o=""):(s.length>0&&s.push(e),i=a);continue}i?(o&&(o+=e),o+=a):(s.length>0&&s.push(e),s.push(a))}return s.join("")},Y=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return rs(os(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(i=>{const o=i,l=o.toLowerCase();return n?(n=!1,Xn(l)):is(l)}),"")};class as extends b{commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}}class ls extends b{choices;option;value;constructor(e,n,s){super(`Invalid value "${n}" for option "${e}". Allowed values: ${s.join(", ")}`,"INVALID_CHOICE",{choices:s,option:e,value:n}),this.name="InvalidChoiceError",this.option=e,this.value=n,this.choices=s,this.hint=`Use one of: ${s.map(i=>`--${e} ${i}`).join(", ")}`}}const Re=(t,e,n=!1)=>{const s=[],i=e._all??e;for(const o of t){if(!n&&!o.required)continue;const l=o.__camelCaseName__??o.name;if(i[l]===void 0){if(o.type?.name==="Boolean"){e[l]=!1;continue}s.push(o)}}return s},cs=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Jt(t,e)<=t.length/3,R=(t,e)=>{const n=t.toLowerCase();return e.filter(s=>cs(s.toLowerCase(),n))},hs=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(s=>{const i=s.startsWith("--");let o=`Found unknown ${i?"option":"argument"} "${s}"`;if(i){const l=R(s.replace("--",""),(e.options??[]).map(a=>a.name));if(l.length>0){const[a,...u]=l.map(r=>`--${r}`);o+=u.length>0?`, did you mean ${a??""} or ${u.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(o)}),n.length>0)throw new b(n.join(`
2
+ `),Xt.UNKNOWN_OPTION,{unknownOptions:[...t._unknown??[]]})},W=(t,e)=>new b(`Command "${t}" ${e}`,"INVALID_COMMAND",{commandName:t}),us=(t,e)=>{const n=new Set;for(const[s,i]of t.entries()){if(typeof i!="object"||i===null)throw W(e,`has a positional argument at index ${String(s)} that is not an object`);const{name:o}=i;if(typeof o!="string"||o.length===0)throw W(e,`has a positional argument at index ${String(s)} without a name`);const l=et(o);if(n.has(l))throw W(e,`declares duplicate positional argument "${o}"`);n.add(l);const a=s===0?void 0:t[s-1];if(i.required===!0&&a!==void 0&&a.required!==!0)throw W(e,`declares required positional "${o}" after an optional one, which can never be satisfied`);if(i.multiple===!0&&s!==t.length-1)throw W(e,`declares a variadic positional "${o}" that is not the last one`)}},ps=(t,e,n)=>{const s=n.__requiredOptions__,i=s?Re(s,e,!0):Re(t,e,!1);if(i.length>0)throw new as(n.name,i.map(o=>o.name));e._unknown&&e._unknown.length>0&&!n.argument&&!n.arguments?.length&&hs(e,n)},fs=(t,e,n)=>{const s=n.__conflictingOptions__??t.filter(i=>i.conflicts!==void 0);if(s.length>0){const i=s.find(o=>{const l=o.__camelCaseName__??Y(o.name);return Array.isArray(o.conflicts)?o.conflicts.some(a=>e[Y(a)]!==void 0)&&e[l]!==void 0:e[Y(o.conflicts)]!==void 0&&e[l]!==void 0});if(i)throw new Ge(i.name,typeof i.conflicts=="string"?i.conflicts:i.conflicts?.[0]??"unknown")}},ds=(t,e)=>{const n=e.options;if(n)for(const s of n){if(!s.choices||s.choices.length===0)continue;const i=s.__camelCaseName__??Y(s.name),o=t[i];if(o==null)continue;const l=Array.isArray(o)?o:[o];for(const a of l){const u=String(a);if(!s.choices.includes(u))throw new ls(s.name,u,s.choices)}}},gs=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const i of t.options){if(i.name){const o=e.get(i.name)??[];o.push(i),e.set(i.name,o)}if(typeof i.alias=="string"&&i.alias.length>0){const o=n.get(i.alias)??[];o.push(i),n.set(i.alias,o)}else if(Array.isArray(i.alias)){for(const o of i.alias)if(o.length>0){const l=n.get(o)??[];l.push(i),n.set(o,l)}}}const s=[];for(const[i,o]of e)o.length>1&&s.push(`Duplicate option name "${i}" in command "${t.name}": ${JSON.stringify(o)}`);for(const[i,o]of n)o.length>1&&s.push(`Duplicate option alias "-${i}" used by options ${o.map(l=>`"${l.name}"`).join(", ")} in command "${t.name}"`);if(s.length>0)throw new Error(s.join(`
3
+ `))},ms=t=>{const{arguments:e}=t;if(e!==void 0){if(!Array.isArray(e))throw W(t.name,'must declare "arguments" as an array — slot order is significant, so a record cannot express it');if(t.argument!==void 0)throw W(t.name,'cannot define both "argument" and "arguments" — choose one');us(e,t.name)}},ws=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let s;for(let i=1;i<=e.length;i+=1){const o=e[i-1];if(o===void 0||o.startsWith("-"))break;n.push(o);const l=n.join(" ");t.has(l)&&(s={commandPath:[...n],depth:i})}return s?{argv:e.slice(s.depth),commandPath:s.commandPath}:{argv:e,commandPath:void 0}},z=t=>t.join(" "),Be=(t,e)=>e&&e.length>0?[...e,t]:[t],ze=t=>t===void 0||Array.isArray(t)?t:Object.entries(t).map(([e,n])=>({...n,name:e})),ys=t=>{const e=ze(t.options),n=ze(t.env);return e===t.options&&n===t.env?t:Object.assign(Object.create(Object.getPrototypeOf(t)),t,{env:n,options:e})},vs=/^no-/,As=t=>{t.options?.forEach(e=>{e.__camelCaseName__=Y(e.name)})},Cs=t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const s of t.options)e.add(s.name);const n=[];for(const s of t.options)if(s.name.startsWith("no-")){const i=s.name.replace(vs,"");if(!e.has(i)){if(s.type!==Boolean)throw new Error(`Cannot add negated option "${s.name}" to command "${t.name}" because it is not a boolean.`);const o={...s,alias:void 0,defaultValue:s.defaultValue===void 0?!0:!s.defaultValue,description:`Inverse of --${s.name}.`,name:i};n.push(o),e.add(i)}}n.length>0&&t.options.push(...n)},Ns=(t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,s=new Map;for(const o of e.options)if(o.name.startsWith("no-")){const l=Y(o.name);s.set(l,o)}const i=Object.keys(n).filter(o=>s.has(o));if(i.length!==0)for(const o of i){const l=o.charAt(2);if(!l)continue;const a=l.toLowerCase()+o.slice(3),u=s.get(o);u&&(u.__negated__=!0),n[a]=!n[o],Reflect.deleteProperty(n,o)}},bs=(t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const i of e.options)i.__camelCaseName__&&i.__negated__===void 0&&i.implies!==void 0&&n.set(i.__camelCaseName__,i);if(n.size===0)return;const{options:s}=t;for(const i of Object.keys(s)){const o=n.get(i);if(o?.implies){const{implies:l}=o;for(const[a,u]of Object.entries(l))s[a]===void 0&&(s[a]=u)}}},Os=()=>!!process.versions.electron,_s=()=>Os()&&!process.defaultApp,Es=()=>_s()?0:1,xs=t=>t.slice(Es()+1),ks=" ",Is=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,s)=>n===e[s]),Ps=t=>{if(typeof t=="string")return t.split(ks);const e=we();return Is(t,e)?xs(t):t},$s=t=>{const e=o=>{t.error(`Uncaught exception: ${o.message||o}`),o.stack&&t.error(o.stack),F(1)},n=(o,l)=>{if(o instanceof Error)t.error(`Promise rejection: ${o.message||o}`),o.stack&&t.error(o.stack);else{let a;if(typeof o=="string")a=o;else try{a=JSON.stringify(o)}catch{a=String(o)}t.error(`Promise rejection: ${a}`)}F(1)},s=Ne("uncaughtException",e),i=Ne("unhandledRejection",n);return()=>{s(),i()}},Fe=100,Ls=/^[a-z][\w-]*$/i,ve=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new b(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},We=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new b(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},ne=(t,e)=>{if(typeof t!="object"||t===null)throw new b(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},se=t=>{const e=ve(t,"Command name");if(e.length>Fe)throw new b(`Command name is too long (maximum ${String(Fe)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new b(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Ls.test(e))throw new b(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},Ms=1e6,Us=1e5,Ss=new Set([`
4
+ `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Ts=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,s=n.maxArgumentLength??Ms;if(Number.isFinite(s)&&s>0&&t.length>s)throw new Error(`Argument is too long (maximum ${String(s)} characters)`);if(n.checkDangerousChars){for(const i of t)if(Ss.has(i))throw new Error(`Argument contains dangerous character: ${i}`)}return n.trim?t.trim():t},qe=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,s=n.maxArguments??Us;if(Number.isFinite(s)&&s>0&&t.length>s)throw new Error(`Too many arguments (maximum ${String(s)})`);return t.map(i=>Ts(i,n))},Ds=/^-([^\d-])$/,Vs=/^--(\S+)/,js=/^-([^\d-]{2,})$/,me=t=>Ds.test(t)||Vs.test(t)||js.test(t),Rs={access:(t,e)=>yt(t,e),mkdir:(t,e)=>wt(t,e),readdir:t=>mt(t),readFile:(async(t,e)=>e===void 0?Ce(t):Ce(t,e)),rm:(t,e)=>gt(t,e),stat:t=>dt(t),writeFile:(t,e,n)=>ft(t,e,n)},Bs=(t,e,n)=>{const s=e.indexOf("--"),i=s===-1?new Set:new Set(e.slice(s+1)),o=n.filter(u=>u.startsWith("--")&&u!=="--"&&!i.has(u));if(o.length===0)return;const l=(t.options??[]).map(u=>u.name),a=o.flatMap(u=>R(u.slice(2),l).map(r=>`--${r}`));throw new Zt(o,a)};class at{#t;#e;#h;#p;#f;#d;#O;#_;#E;#A;#x;#C;#k;#N=le;#u;#n;#s;#o;#i;#r;#I=!1;#P;#$=!1;#g;#m;#w;#l=[];#D(){return this.#g===void 0&&(this.#g=[...this.#s.keys()]),this.#g}#L(){return this.#m===void 0&&(this.#m=[...this.#n.keys()]),this.#m}#a(){return this.#w===void 0&&(this.#w=[...this.#D(),...this.#L()]),this.#w}#M(){return this.#l.length===0?te:[...te,...this.#l]}#U(){this.#g=void 0,this.#m=void 0,this.#w=void 0}#b(){if(this.#h===void 0){const e=Ps(this.#e.argv);this.#h=qe(e,{maxArguments:this.#C}),this.#V()}return this.#h}#y(){return this.#A??re()}#v(e){this.#N=e,this.#y().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){return this.#N}#V(){if(!this.#h)return;let e=!1;for(const n of this.#h){if(n==="--quiet"||n==="-q"){this.#v(vt),e=!0;break}if(n==="--verbose"||n==="-v"){this.#v(At),e=!0;break}if(n==="--debug"){this.#v(V),e=!0;break}}e||this.#v(Object.hasOwn(this.#y(),"DEBUG")?V:le)}#j(){this.#$||(this.#P=$s(this.#t),this.#$=!0)}#R(){return{arch:Nt(),argv:this.#b(),cwd:this.#p,env:this.#A??re(),exit:this.#E??(e=>F(e??0)),platform:Ct(),stdin:this.#x}}#S(e,n,s,i){this.#c()===V&&this.#t.debug(`command '${i}' found, parsing command args: ${n.join(", ")}`);const{arguments_:o,booleanValues:l,parsedArgs:a}=Gn(e,n,this.#M()),u=Object.keys(l).length>0;let r=a;u&&(r={...a,_all:{...a._all,...l}}),ps(o,r,e);const c=qn(e,a,l,s,this.#y(),n);c.runtime=this,c.argv=this.#b(),c.fs=this.#_??Rs,c.process=this.#R(),c.console=this.#t,Kn(e,c);const p=e.options&&e.options.length>0;if(p&&e.options){const h=e.options.filter(m=>m.name.startsWith("no-"));for(const m of h){const g=m.name.slice(3),y=`--${m.name}`,A=`--${g}`,d=n.includes(y),C=n.includes(A);if(d&&C)throw new Ge(g,m.name)}}return p&&(Ns(c,e),bs(c,e)),fs(o,c.options,e),ds(c.options,e),this.#k&&Bs(e,n,c.rawUnknown),this.#c()===V&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(c.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(c.argument,null,2))),{arguments_:o,booleanValues:l,commandArgs:r,parsedArgs:a,toolbox:c}}async#T(e,n,s){const i=this.getPluginManager();try{!this.#I&&i.hasPlugins()&&(await i.init({cli:this,cwd:this.#p,logger:this.#t}),this.#I=!0),await i.executeLifecycle("execute",n),await i.executeLifecycle("beforeCommand",n);let o;const l=s.global;if(l?.help){const a=this.#n.get("help");if(!a)throw new b("Help command not found","COMMAND_NOT_FOUND");o=await pe(a,n,s)}else if(l?.version??l?.V){const a=this.#n.get("version");if(!a)throw new b("Version command not found","COMMAND_NOT_FOUND");o=await pe(a,n,s)}else o=await pe(e,n,s);return await i.executeLifecycle("afterCommand",n,o),o}catch(o){throw await i.executeErrorHandlers(o,n),o}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new b("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const s=n.argv??we(),i=n.cwd??bt();if(this.#e={...n,argv:s,cwd:i},this.#e.argv&&!Array.isArray(this.#e.argv))throw new b("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new b("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new b("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new b("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const p=["debug","error","info","log","warn"],h=[],m=this.#e.logger;for(const g of p)typeof m[g]!="function"&&h.push(g);if(h.length>0)throw new b(`Logger object is missing required methods: ${h.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:h});this.#t=this.#e.logger}else this.#t={...console,debug:(...p)=>{this.#c()===V&&console.debug(...p)}};this.#d=this.#e.packageVersion,this.#O=this.#e.packageName,this.#p=this.#e.cwd,this.#i="help",this.#r={};const o=n.fs;if(o!==void 0&&(typeof o!="object"||o===null))throw new b("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const l=n.exit;if(l!==void 0&&typeof l!="function")throw new b("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new b("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const u=n.stdin;if(u!==void 0&&typeof u!="string")throw new b("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#_=n.fs,this.#E=n.exit,this.#A=n.env,this.#x=n.stdin??"",this.#C=n.maxArguments,this.#k=n.strictOptions??!1;const r=this.#y().CEREBRO_OUTPUT_LEVEL,c=r===void 0?Number.NaN:Number(r);this.#N=Number.isNaN(c)?le:c,this.#n=new Map,this.#s=new Map,this.#o=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#f}${this.#d?` v${this.#d}`:""}`),this.#r}setDefaultCommand(e){return this.#i=e,this}get defaultCommand(){return this.#i}addCommand(e){ne(e,"Command"),se(e.name),e.options!==void 0&&ne(e.options,"Command options"),e.env!==void 0&&ne(e.env,"Command env"),ms(e);const n=ys(e),s=typeof n.execute=="function",i=typeof n.loader=="function";if(s&&i)throw new b(`Command "${n.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:n.name});if(!s&&!i)throw new b(`Command "${n.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:n.name});n.alias&&(typeof n.alias=="string"?se(n.alias):We(n.alias,"Command alias").forEach(c=>se(c))),n.argument&&ne(n.argument,"Command argument"),n.commandPath&&(We(n.commandPath,"Command commandPath"),n.commandPath.forEach(c=>{se(c)}));const o=Be(n.name,n.commandPath),l=z(o);if(this.#s.has(l))throw new b(`Command with path "${l}" already exists`,"DUPLICATE_COMMAND",{commandName:n.name,commandPath:n.commandPath});const a=Array.isArray(n.commandPath)&&n.commandPath.length>0,u=this.#n.get(n.name),r=u!==void 0&&(u.commandPath===void 0||u.commandPath.length===0);if(!a&&r)throw new b(`Command with name "${n.name}" already exists`,"DUPLICATE_COMMAND",{commandName:n.name});if(n.options)for(const c of n.options)Ie(c);if(gs(n),Cs(n),As(n),n.options&&(n.__conflictingOptions__=n.options.filter(c=>c.conflicts!==void 0),n.__requiredOptions__=n.options.filter(c=>c.required===!0)),a&&u!==void 0)this.#n.set(l,n);else{if(!a&&u!==void 0&&!r){const c=Be(u.name,u.commandPath);this.#n.set(z(c),u)}this.#n.set(n.name,n)}if(this.#s.set(l,o),this.#o.set(l,n),this.#U(),n.alias!==void 0){const c=typeof n.alias=="string"?[n.alias]:n.alias;for(const p of c){if(this.#c()===V&&this.#t.debug("adding alias",p),this.#n.has(p))throw new b(`Command alias "${p}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:p,commandName:n.name});this.#n.set(p,n)}}return this}addGlobalOption(e){const n=e,s=new Set(te.map(l=>l.name)),i=new Set(te.map(l=>l.alias).filter(Boolean));if(s.has(n.name))throw new b(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&i.has(n.alias))throw new b(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(l=>l.name)).has(n.name))throw new b(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",Ie(n),this.#l.push(n),this}getGlobalOptions(){return this.#M()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#u?this.#u:(this.#u=new en(this.#t),this.#u.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#u)}getCliName(){return this.#f}getPackageVersion(){return this.#d}getPackageName(){return this.#O}getCommands(){return this.#n}getCwd(){return this.#p}dispose(){this.#P?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:s=!0,...i}=e;if(!this.#n.has("help")){const{default:d}=await import("../commands/help-command.js");this.addCommand(new d(this.#n))}const o=this.#L(),l=this.#s;this.#j();const a=this.#b();let u,r=[...a];this.#c()===V&&(this.#t.debug(`process.execPath: ${Ot()}`),this.#t.debug(`process.execArgv: ${_t().join(" ")}`),this.#t.debug(`process.argv: ${we().join(" ")}`));const c=ws(l,[...a]);if(c.commandPath)u=c.commandPath,r=c.argv;else{if(a.length>1&&a[0]&&a[1]&&!me(a[0])&&!me(a[1])){const C=[];let O=0;for(;O<a.length;){const E=a[O];if(!E||me(E))break;C.push(E),O+=1}const k=z(C);if(C[0]&&!o.includes(C[0])){const E=this.#a(),H=R(k,E);throw new B(k,H)}}let d;try{d=an([null,...o],[...a])}catch(C){if(C instanceof Error&&C.name==="INVALID_COMMAND"&&"command"in C){const O=C.command,k=this.#a(),E=R(O,k);throw new B(O,E)}throw C}d.command&&(u=[d.command],r=d.argv)}if(!u)if(this.#i)u=[this.#i];else{const d=this.#a();throw new B("",d)}const p=z(u),h=this.#s.get(p);let m;if(h){if(m=this.#o.get(p),!m||z(h)!==p){const d=this.#a(),C=R(p,d);throw new B(p,C)}}else{const d=u.at(-1);if(m=d?this.#n.get(d):void 0,!m){const C=this.#a(),O=R(p,C);throw new B(p,O)}}if(typeof m.execute!="function"&&typeof m.loader!="function")return this.#t.error(`Command "${m.name}" has no function to execute.`),s?F(1):void 0;const g=r;let y,A;try{({commandArgs:y,toolbox:A}=this.#S(m,g,i,p))}catch(d){const C=Yt(d);if(this.#t.error(C??d),s)return F(1);throw d}try{return await this.#T(m,A,y),s?F(0):void 0}catch(d){if(s)return this.#t.error(d),F(1);throw d}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:s=[],...i}=n;ve(e,"Command name");const o=e.split(" ").filter(Boolean),l=z(o),u=this.#s.get(l)?this.#o.get(l):this.#n.get(e);if(!u){const m=this.#a(),g=R(l||e,m);throw new B(e,g)}if(typeof u.execute!="function"&&typeof u.loader!="function")throw new b(`Command "${u.name}" has no function to execute`,"INVALID_COMMAND",{commandName:u.name});const c=[...qe(s,{maxArguments:this.#C})];this.#c()===V&&this.#t.debug(`running command '${e}' programmatically with args: ${c.join(", ")}`);const{commandArgs:p,toolbox:h}=this.#S(u,c,i,l||e);return this.#T(u,h,p)}clone(e){const n={...this.#e,...e},s=new at(this.#f,n);for(const[i,o]of this.#n)s.#n.set(i,o);for(const[i,o]of this.#s)s.#s.set(i,[...o]);for(const[i,o]of this.#o)s.#o.set(i,o);for(const i of this.#l)s.#l.push(i);return s.#i=this.#i,s.#r={...this.#r},s.#U(),s}async getAction(e){ve(e,"Command name");const n=e.split(" ").filter(Boolean),s=z(n),o=this.#s.get(s)?this.#o.get(s):this.#n.get(e);if(!o){const l=this.#a(),a=R(s||e,l);throw new B(e,a)}if(typeof o.execute=="function")return o.execute;if(typeof o.loader=="function")return tt(o);throw new b(`Command "${o.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:o.name})}}export{at as Cli};
@@ -1 +1 @@
1
- const n=String.raw,p=n`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,e=()=>new RegExp(n`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${p}(?:\u200D${p})*`,"gu");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const u=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,i=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,c=e(),r=/[-_./\s]+/g,o=/(\u001B\[[0-9;]*[a-z])/i,a=new RegExp("\\p{Script=Arabic}","u"),E=new RegExp("\\p{Script=Bengali}","u"),g=new RegExp("\\p{Script=Cyrillic}","u"),s=new RegExp("\\p{Script=Devanagari}","u"),S=new RegExp("\\p{Script=Ethiopic}","u"),w=new RegExp("\\p{Script=Greek}","u"),R=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),x=new RegExp("\\p{Script=Gujarati}","u"),l=new RegExp("\\p{Script=Gurmukhi}","u"),B=new RegExp("\\p{Script=Hangul}","u"),F=new RegExp("\\p{Script=Hebrew}","u"),m=new RegExp("\\p{Script=Hiragana}","u"),y=new RegExp("\\p{Script=Han}","u"),d=new RegExp("\\p{Script=Kannada}","u"),h=new RegExp("\\p{Script=Katakana}","u"),k=new RegExp("\\p{Script=Khmer}","u"),G=new RegExp("\\p{Script=Lao}","u"),b=new RegExp("\\p{Script=Latin}","u"),H=new RegExp("\\p{Script=Malayalam}","u"),L=new RegExp("\\p{Script=Myanmar}","u"),M=new RegExp("\\p{Script=Oriya}","u"),j=new RegExp("\\p{Script=Sinhala}","u"),K=new RegExp("\\p{Script=Tamil}","u"),O=new RegExp("\\p{Script=Telugu}","u"),T=new RegExp("\\p{Script=Thai}","u"),f=new RegExp("\\p{Script=Tibetan}","u"),z=/[\u02BB\u02BC\u0027]/u,C=t=>t.replace(c,"");export{m as $,i as B,a as C,s as D,w as F,E as G,o as H,L as J,S as K,u as L,g as M,r as O,x as P,z as Q,y as U,M as V,B as W,C as X,h as Y,O as Z,H as b,c,F as d,j as f,k as h,G as j,b as k,l,R as m,T as q,f as v,d as y,K as z};
1
+ const n=String.raw,p=n`\p{Emoji}(?:\p{EMod}|[\u{E0020}-\u{E007E}]+\u{E007F}|\uFE0F?\u20E3?)`,t=()=>new RegExp(n`\p{RI}{2}|(?![#*\d](?!\uFE0F?\u20E3))${p}(?:\u200D${p})*`,"gu");Object.freeze(new Map([[0,0],[1,22],[2,22],[3,23],[4,24],[7,27],[8,28],[9,29],[30,39],[31,39],[32,39],[33,39],[34,39],[35,39],[36,39],[37,39],[40,49],[41,49],[42,49],[43,49],[44,49],[45,49],[46,49],[47,49],[90,39]]));const u=/[\u001B\u009B](?:[[()#;?]{0,10}(?:\d{1,4}(?:;\d{0,4})*)?[0-9A-ORZcf-nqry=><]|\]8;;[^\u0007\u001B]{0,100}(?:\u0007|\u001B\\))/g,i=/[\u0000-\u0008\n-\u001F\u007F-\u009F]{1,1000}/y,c=t(),r=/[-_./\s]+/g,o=/(\u001B\[[0-9;]*[a-z])/i,a=new RegExp("\\p{Script=Arabic}","u"),E=new RegExp("\\p{Script=Bengali}","u"),g=new RegExp("\\p{Script=Cyrillic}","u"),s=new RegExp("\\p{Script=Devanagari}","u"),w=new RegExp("\\p{Script=Ethiopic}","u"),S=new RegExp("\\p{Script=Greek}","u"),R=new RegExp("\\p{Script=Greek}+|\\p{Script=Latin}+|[^\\p{Script=Greek}\\p{Script=Latin}]+","gu"),x=new RegExp("\\p{Script=Gujarati}","u"),l=new RegExp("\\p{Script=Gurmukhi}","u"),B=new RegExp("\\p{Script=Hangul}","u"),F=new RegExp("\\p{Script=Hebrew}","u"),m=new RegExp("\\p{Script=Hiragana}","u"),y=new RegExp("\\p{Script=Han}","u"),d=new RegExp("\\p{Script=Kannada}","u"),h=new RegExp("\\p{Script=Katakana}","u"),k=new RegExp("\\p{Script=Khmer}","u"),G=new RegExp("\\p{Script=Lao}","u"),b=new RegExp("\\p{Script=Latin}","u"),H=new RegExp("\\p{Script=Malayalam}","u"),M=new RegExp("\\p{Script=Myanmar}","u"),j=new RegExp("\\p{Script=Oriya}","u"),K=new RegExp("\\p{Script=Sinhala}","u"),L=new RegExp("\\p{Script=Tamil}","u"),O=new RegExp("\\p{Script=Telugu}","u"),T=new RegExp("\\p{Script=Thai}","u"),f=new RegExp("\\p{Script=Tibetan}","u"),z=/[\u02BB\u02BC\u0027]/u,A=e=>e.replace(c,"");export{m as $,c as A,o as C,g as D,w as F,a as G,r as H,M as J,s as K,E as M,i as O,S as P,z as Q,y as U,j as V,B as W,A as X,h as Y,O as Z,b,F as d,K as f,k as h,H as j,G as k,x as l,R as m,l as o,T as q,f as v,u as w,d as y,L as z};
@@ -0,0 +1,6 @@
1
+ import{createRequire as et}from"node:module";import{w as U,O as v,A as st}from"./constants-aPzGW29R-Cuf0YlDT.js";import{createTable as A}from"@visulima/tabular";import{NO_BORDER as $}from"@visulima/tabular/style";import at from"@visulima/colorize/template";import{c as lt}from"./runtime-process-BN-eTlwy.js";import{bold as M,underline as ut}from"@visulima/colorize";let rt;const nt=t=>(rt??=et(import.meta.url))(t),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:w,S=t=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[e,r]=b.versions.node.split(".").map(Number);if(e>22||e===22&&r>=3||e===20&&r>=16)return b.getBuiltinModule(t)}return nt(t)},w=b,{execFileSync:ot}=S("node:child_process"),W=S("node:fs"),it=S("node:tty"),ct=S("node:os"),dt=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],ft=12288,ht=65510,pt=[12288,12288,65281,65376,65504,65510],mt=8361,wt=65518,gt=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],bt=32,yt=10630,Nt=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],It=4352,Wt=262141,G=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],O=(t,e)=>{let r=0,s=Math.floor(t.length/2)-1;for(;r<=s;){const i=Math.floor((r+s)/2),c=i*2;if(e<t[c])s=i-1;else if(e>t[c+1])r=i+1;else return!0}return!1},z=19968,[Ot,vt]=xt(G);function xt(t){let e=t[0],r=t[1];for(let s=0;s<t.length;s+=2){const i=t[s],c=t[s+1];if(z>=i&&z<=c)return[i,c];c-i>r-e&&(e=i,r=c)}return[e,r]}const Et=t=>t<161||t>1114109?!1:O(dt,t),At=t=>t<ft||t>ht?!1:O(pt,t),$t=t=>t<mt||t>wt?!1:O(gt,t),Mt=t=>t<bt||t>yt?!1:O(Nt,t),Ct=t=>t>=Ot&&t<=vt?!0:t<It||t>Wt?!1:O(G,t);function Rt(t){return Et(t)?"ambiguous":At(t)?"fullwidth":$t(t)?"halfwidth":Mt(t)?"narrow":Ct(t)?"wide":"neutral"}function St(t){if(!Number.isSafeInteger(t))throw new TypeError(`Expected a code point, got \`${typeof t}\`.`)}function V(t){return St(t),Rt(t)}const D=new Map,Tt=t=>[t.ambiguousIsNarrow?1:0,t.control,t.fullWidth,t.regular,t.wide].join("|"),kt=t=>{const e=Tt(t.width);let r=D.get(e);return r||(r=new Map,D.set(e,r)),r},x=new RegExp(U.source,"y"),_=new RegExp(st.source,"uy"),E=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,Y=t=>t>=32&&t<=126?"latin":t===8203||t===8204||t===8205||t===8288?"zero":t<=31||t>=127&&t<=159?"control":t>=160&&t<=255||t>=9472&&t<=9599?"latin":t>=4352&&t<=4607||t>=11904&&t<=40959||t>=44032&&t<=55215||t>=63744&&t<=64255||t>=65280&&t<=65519&&!(t>=65377&&t<=65439)||t>=12352&&t<=12543?"wide":t===8230?"latin":"other",Lt=(t,e)=>{const r=kt(e),s=Math.floor(t/65536),i=t%65536;let c=r.get(s);if(c||(c=new Map,r.set(s,c)),c.has(i))return c.get(i);let n;switch(Y(t)){case"control":{n=e.width.control;break}case"latin":{n=e.width.regular;break}case"wide":{n=e.width.wide;break}case"zero":{n=0;break}default:switch(V(t)){case"ambiguous":{n=e.width.ambiguousIsNarrow?e.width.regular:e.width.wide;break}case"fullwidth":{n=e.width.fullWidth;break}case"wide":{n=e.width.wide;break}default:n=e.width.regular}}return c.set(i,n),n},_t=t=>t>=768&&t<=879||t>=6832&&t<=6911||t>=7616&&t<=7679||t>=8400&&t<=8447||t>=65056&&t<=65071||t>=917760&&t<=917999||t>=65024&&t<=65039||t>=3633&&t<=3642||t>=3655&&t<=3662||t>=3761&&t<=3769||t>=3771&&t<=3772||t>=3784&&t<=3789||t>=2304&&t<=2307||t>=2362&&t<=2383||t>=2385&&t<=2391||t>=2402&&t<=2403||t>=2433&&t<=2435||t>=2492&&t<=2500||t>=2509&&t<=2509||t>=2561&&t<=2563||t>=2620&&t<=2637||t>=1611&&t<=1631||t>=1648&&t<=1648||t>=1750&&t<=1773||t>=2276&&t<=2302||t>=1425&&t<=1469||t>=1471&&t<=1471||t>=1473&&t<=1474||t>=1476&&t<=1477||t>=1479&&t<=1479||t>=3893&&t<=3893||t>=3895&&t<=3895||t>=3897&&t<=3897||t>=3953&&t<=3966||t>=3968&&t<=3972||t>=3974&&t<=3975?!0:t>=768&&t<=777||t>=803&&t<=803,F=(t,e={})=>{if(!t||t.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const r={truncation:{countAnsiEscapeCodes:e.countAnsiEscapeCodes??!1,ellipsis:e.ellipsis??"",ellipsisWidth:e.ellipsisWidth??(e.ellipsis?F(e.ellipsis,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:e.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:e.ambiguousIsNarrow??!1,ansi:e.ansiWidth??0,control:e.controlWidth??0,emoji:e.emojiWidth??2,fullWidth:e.fullWidth??2,halfWidth:e.halfWidth??1,regular:e.regularWidth??1,tab:e.tabWidth??8,wide:e.wideWidth??2}},s=Math.max(0,r.truncation.limit-r.truncation.ellipsisWidth),{length:i}=t,c=i>1e4;let n=0,o=0,l=i,a=!1;const u=t.includes("\x1B")||t.includes("›");for(;n<i;){if(u&&(t[n]==="\x1B"||t[n]==="›")){if(t.startsWith("\x1B]8;;",n)){const f="\x1B]8;;\x07",p=f.length,T=t.indexOf("\x07",n+5);if(T!==-1){const k=t.indexOf(f,T+1);if(k!==-1){const Q=k+p,tt=t.slice(T+1,k).replace(U,""),B=F(tt,{ambiguousIsNarrow:r.width.ambiguousIsNarrow,ansiWidth:r.width.ansi,controlWidth:r.width.control,countAnsiEscapeCodes:!1,ellipsis:r.truncation.ellipsis,ellipsisWidth:r.truncation.ellipsisWidth,emojiWidth:r.width.emoji,fullWidth:r.width.fullWidth,halfWidth:r.width.halfWidth,limit:Math.max(0,s-o),regularWidth:r.width.regular,tabWidth:r.width.tab,wideWidth:r.width.wide}),L=B.width;if(B.truncated)a=!0,l=Math.min(l,n);else if(o+L>s&&(l=Math.min(l,n),a=!0,o+L>r.truncation.limit))break;if(o+=L,n=Q,a&&o>=r.truncation.limit)break;continue}}}if(x.lastIndex=n,x.test(t)){const f=x.lastIndex-n,p=r.truncation.countAnsiEscapeCodes?f:r.width.ansi;if(o+p>s&&(l=Math.min(l,n),o+p>r.truncation.limit)){a=!0;break}o+=p,n=x.lastIndex;continue}}const m=t.codePointAt(n);if(m===8203||m===65279||m>=8288&&m<=8292){n+=1;continue}if(m===9){if(o+r.width.tab>s&&(l=Math.min(l,n),o+r.width.tab>r.truncation.limit)){a=!0;break}o+=r.width.tab,n+=1;continue}if(E.lastIndex=n,E.test(t)){const f=(E.lastIndex-n)*r.width.regular;if(o+f>s){const p=r.width.regular>0?Math.floor((s-o)/r.width.regular):0;if(l=Math.min(l,n+p),o+f>r.truncation.limit){a=!0;break}}o+=f,n=E.lastIndex;continue}if((m<=31||m>=127&&m<=159)&&(v.lastIndex=n,v.test(t))){const f=(v.lastIndex-n)*r.width.control;if(o+f>s){const p=r.width.control>0?Math.floor((s-o)/r.width.control):0;if(l=Math.min(l,n+p),o+f>r.truncation.limit){a=!0;break}}o+=f,n=v.lastIndex;continue}if(_.lastIndex=n,_.test(t)){if(o+r.width.emoji>s&&(l=Math.min(l,n),o+r.width.emoji>r.truncation.limit)){a=!0;break}o+=r.width.emoji,n=_.lastIndex;continue}const g=t.codePointAt(n)??0;if(_t(g)){n+=g>65535?2:1;continue}let d;if(c)d=Lt(g,r);else switch(Y(g)){case"control":{d=r.width.control;break}case"latin":{d=r.width.regular;break}case"wide":{d=r.width.wide;break}case"zero":{d=0;break}default:switch(V(g)){case"ambiguous":{d=r.width.ambiguousIsNarrow?r.width.regular:r.width.wide;break}case"fullwidth":{d=r.width.fullWidth;break}case"wide":{d=r.width.wide;break}default:d=r.width.regular}}if(o+d>s&&(l=Math.min(l,n),o+d>r.truncation.limit)){a=!0;break}o+=d,n+=g>65535?2:1}let y=o,N=!1;return a&&r.truncation.limit>=r.truncation.ellipsisWidth&&(y=r.truncation.limit,N=!0),{ellipsed:N,index:a?l:i,truncated:a,width:y}},jt=(t,e={})=>F(t,{...e,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,K=80,J=24,P=(t,e,{shell:r,env:s}={})=>ot(t,e,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:r,env:s}).trim(),C=(t,e)=>({columns:Number.parseInt(t,10),rows:Number.parseInt(e,10)}),X=(t,e)=>{const{columns:r,rows:s}=C(t,e);if(!(Number.isNaN(r)||Number.isNaN(s))&&!(r===K&&s===J))return{columns:r,rows:s}},Ft=()=>{if(w.platform!=="linux")return!0;try{const t=W.readFileSync("/proc/self/stat","utf8"),e=t.lastIndexOf(") ");if(e===-1)return!1;const r=t.slice(e+2).trim().split(/\s+/),s=Number.parseInt(r[2],10),i=Number.parseInt(r[5],10);return Number.isNaN(s)||Number.isNaN(i)||i<=0?!1:s===i}catch{return!1}};function Pt(){const{env:t,stdout:e,stderr:r}=w;if(e?.columns&&e?.rows)return C(e.columns,e.rows);if(r?.columns&&r?.rows)return C(r.columns,r.rows);if(t.COLUMNS&&t.LINES)return C(t.COLUMNS,t.LINES);const s={columns:K,rows:J};return w.platform==="win32"?j()??s:w.platform==="darwin"?q()??j()??s:q()??j()??Bt()??s}const q=()=>{try{const t=w.platform==="darwin"?W.constants.O_EVTONLY|W.constants.O_NONBLOCK:W.constants.O_NONBLOCK,{columns:e,rows:r}=it.WriteStream(W.openSync("/dev/tty",t));return{columns:e,rows:r}}catch{}},j=()=>{try{const t=P("tput",["cols"],{env:{TERM:"dumb",...w.env}}),e=P("tput",["lines"],{env:{TERM:"dumb",...w.env}});if(t&&e)return X(t,e)}catch{}},Bt=()=>{try{if(!Ft())return;const t=P("resize",["-u"]).match(/\d+/g);if(t.length===2)return X(t[0],t[1])}catch{}},I=new Map,zt=500,h=t=>{if(!t||t==="")return"";const e=I.get(t);if(e!==void 0)return e;let r;try{r=at(Object.assign([],{raw:[t]}))}catch{r=t}if(I.size>=zt){const s=I.keys().next().value;s!==void 0&&I.delete(s)}return I.set(t,r),r},R=()=>{const e=lt().CEREBRO_TERMINAL_WIDTH;if(e===void 0)return;const r=Number.parseInt(e,10);if(!(Number.isNaN(r)||r<=0))return r};class Z{lines;constructor(){this.lines=[]}add(e){this.lines.push(e)}toString(){return this.lines.join(ct.EOL)}header(e){this.add(M(e)),this.lines.push("")}}const Dt=t=>t!==void 0&&t>0?t:Pt().columns,qt=(t,e,r,s)=>{if(t.length===0||t.some(u=>u.length!==2))return;let i=0;for(const u of t){const y=u[0];if(y===void 0)continue;const N=jt(y);N>i&&(i=N)}if(i===0)return;const c=r+s,n=i+c,l=20+c;if(n+l>e)return;const a=e-n;return[n,a]};class Ht extends Z{constructor(e){if(super(),e.header&&this.header(h(e.header)),e.content){if(e.raw)if(Array.isArray(e.content)&&e.content.every(r=>typeof r=="string"))e.content.forEach(r=>{Array.isArray(r)?r.forEach(s=>{this.add(h(s))}):this.add(h(r))});else if(typeof e.content=="string")this.add(h(e.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(e.content));this.add("")}}getContentLines(e){if(typeof e=="string"){const r=A({showHeader:!1,style:{border:$,paddingLeft:4,paddingRight:1},terminalWidth:R(),truncateOverflow:!1,wordWrap:!0});return r.addRow([h(e)]),r.toString()}if(Array.isArray(e)&&e.every(r=>typeof r=="string"||Array.isArray(r)&&r.every(s=>typeof s=="string"))){const i=Dt(R()),c=a=>Array.isArray(a)?a.map(u=>h(u)):[h(a)],n=e.map(a=>c(a)),o=qt(n,i,4,1),l=A({columnWidths:o,showHeader:!1,style:{border:$,paddingLeft:4,paddingRight:1},terminalWidth:i,truncateOverflow:!1,wordWrap:!0});return n.forEach(a=>{o!==void 0&&a.length===2?l.addRow([{content:a[0],wordWrap:!1},a[1]]):l.addRow(a)}),l.toString()}if(typeof e=="object"){const r=e;if(!r.options||!r.data)throw new Error(`Must have an "options" or "data" property
2
+ ${JSON.stringify(e)}`);const s=A({showHeader:!1,style:{border:$,paddingLeft:4,paddingRight:1},terminalWidth:R(),truncateOverflow:!1,wordWrap:!0});return r.data.forEach(i=>{Array.isArray(i)?s.addRow(i.map(c=>h(c))):s.addRow([h(i)])}),s.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
3
+
4
+ ${JSON.stringify(e)}`)}}class Ut extends Z{constructor(e){super();let r=e.optionList??[];const s=Array.isArray(e.hide)?e.hide:[e.hide].filter(n=>typeof n=="string"),i=Array.isArray(e.group)?e.group:[e.group].filter(n=>typeof n=="string");s.length>0&&(r=r.filter(n=>!s.includes(n.name))),e.header&&this.header(h(e.header)),i.length>0&&(r=r.filter(n=>{const o=n,l=i.includes("_none")&&!o.group,a=o.group,u=this.intersect(Array.isArray(a)?a:[a],i);return l||u?n:void 0}));const c=A({showHeader:!1,style:{border:$,paddingLeft:2,paddingRight:1,...e.tableOptions?.style},terminalWidth:R()??e.tableOptions?.terminalWidth,truncateOverflow:!1,wordWrap:e.tableOptions?.wordWrap??!0,...e.tableOptions});r.forEach(n=>{const o=n;c.addRow([this.getOptionNames(o,e.reverseNameOrder??!1,e.isArgument??!1),h(o.description)])}),this.add(c.toString()),this.lines.push("")}getOptionNames(e,r,s){if(!e.name)throw new TypeError("Invalid option definition, name is required.");const i=e.type?e.type.name.toLowerCase():"string",{lazyMultiple:c}=e,n=e.multiple||c?"[]":"",o=e.typeLabel===void 0?ut(`${i}${n}`):h(e.typeLabel),l=s?M(e.name):M.yellow(`--${e.name}`),a=e.alias;if(a){const u=M(`-${a}`);return r?`${l}, ${u} ${o}`:`${u}, ${l} ${o}`}return`${l} ${o}`}intersect(e,r){return e.some(s=>r.includes(s))}}const Qt=t=>(Array.isArray(t)?t:[t]).length===0?"":`
5
+ ${t.map(r=>r.optionList?new Ut(r).toString():new Ht(r).toString()).join(`
6
+ `)}`,H=(t,e)=>{const s=`${e==="readme"?t.name.toUpperCase():t.name}${t.multiple===!0?"...":""}`;return t.required===!0?e==="readme"?s:`<${s}>`:`[${s}]`},te=(t,e="help")=>t.argument?t.argument.hidden?"":e==="readme"?` ${H(t.argument,e)}`:" [positional arguments]":!t.arguments||t.arguments.length===0?"":t.arguments.filter(r=>!r.hidden).map(r=>` ${H(r,e)}`).join("");export{Qt as c,te as f,h as t};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visulima/cerebro",
3
- "version": "3.1.2",
3
+ "version": "3.1.3",
4
4
  "description": "A delightful toolkit for building cross-runtime CLIs for Node.js, Deno, and Bun.",
5
5
  "keywords": [
6
6
  "ansi",
@@ -119,7 +119,7 @@
119
119
  "provenance": true
120
120
  },
121
121
  "dependencies": {
122
- "@visulima/colorize": "2.1.1",
122
+ "@visulima/colorize": "2.2.0",
123
123
  "@visulima/tabular": "4.1.0",
124
124
  "fastest-levenshtein": "^1.0.16"
125
125
  },
@@ -127,7 +127,7 @@
127
127
  "@bomb.sh/tab": ">=0.0.22",
128
128
  "@visulima/boxen": "5.0.0",
129
129
  "@visulima/find-cache-dir": "3.0.1",
130
- "@visulima/pail": "5.0.0",
130
+ "@visulima/pail": "5.0.1",
131
131
  "github-slugger": ">=2.0.0"
132
132
  },
133
133
  "peerDependenciesMeta": {
@@ -1,4 +0,0 @@
1
- import{createRequire as ct}from"node:module";import{VERBOSITY_DEBUG as V,POSITIONALS_KEY as oe,VERBOSITY_NORMAL as le,VERBOSITY_QUIET as vt,VERBOSITY_VERBOSE as At}from"./VERBOSITY_DEBUG-D7HfSD5l.js";import{C as b}from"./cerebro-error-Dv3FuXO8.js";import{c as re,d as we,o as be,e as F,a as Ct,b as Nt,f as bt,h as Ot,i as _t}from"./runtime-process-BN-eTlwy.js";import{c as ee}from"./VisulimaError-BDqtOVL5-Db_MJ_p7.js";import Et from"./InvalidArgumentChoiceError-BpovuqrZ.js";import xt from"./MissingArgumentError-D78kza2a.js";import kt from"./SurplusArgumentError-BLwT9lo0.js";import{X as It,O as $t,H as ie,c as q,M as X,k as P,F as ce,m as Oe,Q as _e,Y as Pt,U as Ee,$ as Lt,W as xe,d as ke,C as Ie,D as Ut,G as Mt,P as Tt,l as St,y as Dt,z as Vt,Z as jt,b as Rt,f as Bt,q as zt,j as Ft,v as Wt,J as qt,K as Kt,h as Gt,V as Ht}from"./constants-BKuEbBw1-BRv49X2l.js";import{E as Xt,f as Yt}from"./format-user-facing-error-Cb7ySnUi.js";import{distance as Jt}from"fastest-levenshtein";let ht;const ut=t=>(ht??=ct(import.meta.url))(t),Z=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,pt=t=>{if(typeof Z<"u"&&Z.versions&&Z.versions.node){const[e,n]=Z.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return Z.getBuiltinModule(t)}return ut(t)},{writeFile:ft,stat:dt,rm:gt,readFile:Ne,readdir:mt,mkdir:wt,access:yt}=pt("node:fs/promises"),te=[{alias:"v",description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];class B extends b{commandName;constructor(e,n=[]){const s=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(s,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}}class Ge extends b{option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}}class Zt extends b{unknownOptions;constructor(e,n){const s=e.join(", "),i=`Found unknown ${e.length===1?"option":"options"}: ${s}`;super(i,"UNKNOWN_OPTION",{suggestions:n,unknownOptions:e}),this.name="UnknownOptionError",this.unknownOptions=e,n&&n.length>0&&(this.hint=`Did you mean: ${n.join(", ")}?`)}}class Qt extends b{pluginName;constructor(e,n,s){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:s,pluginName:e}),this.name="PluginError",this.pluginName=e,s&&(this.cause=s)}}class en{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);re().CEREBRO_OUTPUT_LEVEL===String(V)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const n=this.getDependencyOrder();this.logger.debug(`initializing ${String(n.length)} plugin(s)...`);for(const s of n)if(typeof s.init=="function"){this.logger.debug(`initializing plugin: ${s.name}`);try{await s.init(e)}catch(i){const o=new Qt(s.name,`Failed to initialize: ${i instanceof Error?i.message:String(i)}`,i instanceof Error?i:void 0);throw this.logger.error(o.message),o}}this.initialized=!0}async executeLifecycle(e,n,s){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const i=this.getDependencyOrder();for(const o of i){const l=o[e];if(typeof l=="function"){this.logger.debug(`executing ${e} hook for plugin: ${o.name}`);try{await(e==="afterCommand"?l(n,s):l(n))}catch(a){throw this.logger.error(`Error in ${e} hook for plugin "${o.name}":`,a),a}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const s=this.getDependencyOrder();for(const i of s)if(typeof i.onError=="function"){this.logger.debug(`executing error handler for plugin: ${i.name}`);try{await i.onError(e,n)}catch(o){this.logger.error(`Error in error handler for plugin "${i.name}":`,o)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,s=new Set,i=o=>{if(n.has(o))return;if(s.has(o))throw new Error(`Circular dependency detected involving plugin "${o}"`);const l=this.plugins.get(o);if(!l)throw new Error(`Plugin "${o}" not found`);if(s.add(o),l.dependencies)for(const a of l.dependencies)i(a);s.delete(o),n.add(o),e.push(l)};for(const o of this.plugins.keys())i(o);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}}const Q=t=>t.type?.name==="Boolean",tn=t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},$e=t=>(Q(t)||(t.typeLabel=t.typeLabel??tn(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),nn=new RegExp(/^-([^\d-])$/),sn=new RegExp(/^--(\S+)/),on=new RegExp(/^-([^\d-]{2,})$/),rn=t=>nn.test(t)||sn.test(t)||on.test(t),an=(t,e)=>{const n=e[0]&&rn(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const s=new Error(`Command not recognised: ${String(n)}`);throw s.command=n,s.name="INVALID_COMMAND",s}return{argv:e,command:n}};class Ae extends ee{optionName;value;constructor(e,n,s){super({hint:`Pass a valid ${s} value for '${e}'.`,message:`Invalid ${s} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,Ae.prototype)}}let ln=class He extends ee{optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,He.prototype)}},Pe=class Xe extends ee{optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,Xe.prototype)}};class Ce extends ee{value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,Ce.prototype)}}let L=class Ye extends ee{constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,Ye.prototype)}};const K=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",ye=t=>t===Number||typeof t=="function"&&t.name==="Number",Le=t=>t===String||typeof t=="function"&&t.name==="String",Ue=(t,e,n)=>{const s=Number(t);if(e&&Number.isNaN(s)&&String(t).trim().toLowerCase()!=="nan")throw new Ae(n??"",String(t),"Number");return s},cn=(t,e,n={})=>{const{optionName:s,strictTypes:i}=n;return Array.isArray(t)?K(e)?t.map(Boolean):ye(e)?t.map(o=>Ue(o,i,s)):Le(e)?t.map(String):t.map(o=>e(String(o))):t===null?null:K(e)?!!t:ye(e)?Ue(t,i,s):Le(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},x=(t,e,n,...s)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...s)},hn=/-([a-z])/g,un=/^\d+$/,pn=t=>t.codePointAt(0)===95,Me=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],Te=t=>t==="__proto__"||t==="constructor"||t==="prototype",he=(t,e,n,s=!1)=>{t[e]===void 0?t[e]=s?[n]:n:s&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},Se=(t,e,n,s,i)=>{let o=e.get(t)??n.get(t);if(!o&&s){const l=t.toLowerCase();o=s.get(l)??i?.get(l)}return o},fn=(t,e,n,s)=>{const i=n.debug??!1;x(i,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),x(i,"Starting argument resolution","resolver"),x(i,"Tokens:","resolver",t),x(i,"Definitions:","resolver",e),x(i,"Processing tokens...","resolver");const o=new Map,l=new Map,a=n.caseInsensitive?new Map:void 0,u=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,c=n.camelCase?new Map:void 0;for(const f of e)if(o.set(f.name,f),f.alias&&l.set(f.alias,f),n.caseInsensitive&&a&&(a.set(f.name.toLowerCase(),f),f.alias&&u&&u.set(f.alias.toLowerCase(),f)),n.camelCase&&r&&c){const w=f.name.replaceAll(hn,(v,I)=>I.toUpperCase());r.set(f.name,w),c.set(w,f.name)}const p=Object.create(null),h=Object.create(null),m=[],g=[],y=new Set;let A=!1;const d=e.find(f=>f.defaultOption),C=e.some(f=>f.group),O=e.find(f=>ye(f.type));for(let f=0;f<t.length;f++){const w=t[f];if(w.kind==="option-terminator"){p._unknown=s.slice(w.index),A=!0;break}if(w.kind==="option"&&w.name){let v=Se(w.name,o,l,a,u);!v&&w.value===void 0&&O&&un.test(w.name)&&(v=O,w.value=w.name,w.name=O.name);let I=!1;if(!v&&n.negation&&w.value===void 0&&w.name.startsWith("no-")){const _=w.name.slice(3),M=Se(_,o,l,a,u);M?.type&&K(M.type)&&(v=M,I=!0)}const N=v?v.name:w.name,$=v?.multiple,U=v?.lazyMultiple;if(Object.hasOwn(h,N)&&h[N]!==void 0&&!$&&!U&&!n.partial)throw new ln(N);if(!v&&n.partial){const _=w.rawName??`--${w.name}${w.value!==void 0&&w.inlineValue?`=${w.value}`:""}`;m.push({index:w.index,value:_});continue}if(!v&&n.stopAtFirstUnknown){p._unknown=s.slice(w.index);break}if(!v&&!n.partial)throw new Pe(w.name);if(w.value===void 0){const _=t[f+1],M=_?.kind==="option"&&!("name"in _)&&_.value!==void 0,S=_&&v&&!(v.type&&K(v.type))&&(_.kind==="positional"||M),lt=v&&v.defaultOption&&!v.multiple&&!v.lazyMultiple;if(S&&(!v?.defaultOption||lt))if($){let D=f+1;const ae=[];for(;D<t.length&&(t[D].kind==="positional"||t[D].kind==="option"&&!("name"in t[D])&&t[D].value!==void 0);)ae.push(t[D].value),y.add(t[D].index),D++;h[N]=h[N]===void 0?ae:Me(h[N],ae),f=D-1}else U?(he(h,N,_.value,!0),y.add(_.index),f++):(h[N]=_.value,y.add(_.index),f++);else v?.type&&K(v.type)?he(h,N,!I,$):($||U)&&h[N]!==void 0?he(h,N,null,!0):h[N]=$?[]:null}else{let{value:_}=w;if(v?.type&&K(v.type))switch(_){case"":{if(n.partial){const S=`${w.rawName??`--${w.name}`}${w.value?`=${w.value}`:""}`;g.push({index:w.index,value:S}),_=!0}else throw new Pe(w.name);break}case"false":{_=!1;break}case"true":{_=!0;break}default:_=!0}const M=[_];if($){let S=f+1;for(;S<t.length&&t[S].kind==="positional";)M.push(t[S].value),y.add(t[S].index),S++;f=S-1}h[N]===void 0?h[N]=$||U?M:_:$||U?h[N]=Me(h[N],M):h[N]=_}}else if(w.kind==="positional"&&n.stopAtFirstUnknown&&!y.has(w.index)&&!d){x(i,`Found unconsumed positional token at index ${String(w.index)}, stopping processing`,"resolver"),p._unknown=s.slice(w.index);break}}for(const[f,w]of Object.entries(h)){const v=o.get(f);v&&(v.multiple||v.lazyMultiple)&&!Array.isArray(w)&&(h[f]=[w])}const k=f=>f.kind==="option"&&!o.has(f.name??"")&&!l.has(f.name??"")&&(!n.caseInsensitive||!a?.has(f.name?.toLowerCase()??"")&&!u?.has(f.name?.toLowerCase()??""));let E=-1,H=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!A&&(E=t.findIndex(f=>k(f)),E!==-1&&(H=t[E].index)),d){const f=[],w=[];for(const v of t)v.kind==="positional"&&!y.has(v.index)&&v.index<H&&(f.push(v.value),w.push(v));if(f.length>0){const v=h[d.name],I=d.multiple??d.lazyMultiple;v===void 0?I?(w.forEach(N=>y.add(N.index)),h[d.name]=f):(y.add(w[0].index),h[d.name]=f[0]):I&&(w.forEach(N=>y.add(N.index)),h[d.name]=Array.isArray(v)?[...f,...v]:[...f,v])}}if(!n.partial){for(const f of t)if(f.kind==="positional"&&!y.has(f.index))throw new Ce(s[f.index])}if(n.partial&&!n.stopAtFirstUnknown){const f=[...m];for(const w of g)f.push({index:w.index,value:w.value});for(const w of t)w.kind==="positional"&&!y.has(w.index)&&f.push({index:w.index,value:s[w.index]});f.length>0&&(f.sort((w,v)=>w.index-v.index),p._unknown=f.map(w=>w.value))}if(n.stopAtFirstUnknown&&!A){const f=t.findIndex(v=>v.kind==="positional"&&!y.has(v.index));let w=-1;if(E!==-1&&f!==-1?w=Math.min(E,f):E!==-1?w=E:f!==-1&&(w=f),w>=0){const v=t[w].index;p._unknown=s.slice(v)}}for(const[f,w]of Object.entries(h)){const v=n.camelCase?r?.get(f)??f:f,I=o.get(f);I?.type?p[v]=cn(w,I.type,{optionName:I.name,strictTypes:n.strictTypes}):p[v]=w===void 0?null:w}for(const f of e){const w=n.camelCase?r?.get(f.name)??f.name:f.name;!(w in p)&&f.defaultValue!==void 0&&(f.multiple??f.lazyMultiple?p[w]=Array.isArray(f.defaultValue)?[...f.defaultValue]:[f.defaultValue]:p[w]=f.defaultValue)}if(C){const f={},w={},v={};for(const N of e)if(N.group){const $=Array.isArray(N.group)?N.group:[N.group];for(const U of $)Te(U)||(f[U]??={})}for(const N of Object.keys(p))if(!pn(N)){w[N]=p[N];let $=N;n.camelCase&&($=c?.get(N)??N);const U=o.get($);if(U?.group){const _=Array.isArray(U.group)?U.group:[U.group];for(const M of _)Te(M)||f[M]&&(f[M][N]=p[N])}else v[N]=p[N]}const I={_all:w};for(const[N,$]of Object.entries(f))I[N]=$;Object.keys(v).length>0&&(I._none=v),p._unknown&&(I._unknown=p._unknown),Object.keys(p).forEach(N=>delete p[N]),Object.assign(p,I)}const T=Object.defineProperties({},Object.getOwnPropertyDescriptors(p));return x(i,"Final parsed result:","resolver",T),T},Je="-",J=Je.codePointAt(0),G="=",dn=G.codePointAt(0),gn="--",mn=Je,wn="--",Ze=t=>t.length>2&&t.startsWith(wn),yn=t=>Ze(t)&&!t.includes(G,3),vn=t=>Ze(t)&&t.includes(G,3),An=t=>{if(t.length!==2||t.codePointAt(0)!==J||t.codePointAt(1)===J)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},Cn=t=>{if(t.length<=2||t.codePointAt(0)!==J||t.codePointAt(1)===J)return!1;const e=t.codePointAt(1);return!(e!==void 0&&e>=48&&e<=57)},Nn=t=>{const e=[];let n=0,s=[],i=0,o=-1,l=0;for(;i<s.length||n<t.length;){let a;if(i<s.length?(a=s[i],i++):(a=t[n],n++),l>0?l--:o++,a===gn){e.push({index:o,kind:"option-terminator"});const u=[...s.slice(i),...t.slice(n)],r=u.map((c,p)=>({index:o+p+1,kind:"positional",value:c}));e.push(...r),o+=u.length;break}if(An(a)){const u=a.charAt(1);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(Cn(a)&&!a.includes(G)){const u=[];let r="",c=!1;for(let p=1;p<a.length;p++){const h=a.charAt(p);c?r+=h:h.codePointAt(0)===dn?c=!0:u.push(`${mn}${h}`)}if(c)if(u.length>0){const p=u.pop();u.push(`${p}=${r}`)}else u.push(r);s=i<s.length?[...u,...s.slice(i)]:u,i=0,l=u.length;continue}if(yn(a)){const u=a.slice(2);e.push({index:o,kind:"option",name:u,rawName:a});continue}if(vn(a)){const u=a.indexOf(G),r=a.slice(2,u),c=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:c});continue}if(a.length>2&&a.codePointAt(0)===J&&a.codePointAt(1)!==J&&a.includes(G)){const u=a.indexOf(G),r=a.charAt(1),c=a.slice(u+1);e.push({index:o,inlineValue:!0,kind:"option",name:r,rawName:a,value:c});continue}e.push({index:o,kind:"positional",value:a})}return e},bn=/\d/,On=t=>typeof t=="function",_n=(t,e,n)=>{const s=n?.debug??!1;x(s,"Validating definitions:","validation",t,"caseInsensitive:",e);const i=new Set,o=new Set,l=new Set,a=new Set;let u=0;for(const r of t){if(x(s,"Checking definition:","validation",r),!r.name)throw x(s,"Validation failed: name is required","validation"),new L("Invalid option definition: name is required");if(typeof r.name!="string")throw new L("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new L("Invalid option definition: name cannot be empty");const c=e?r.name.toLowerCase():"";if(i.has(r.name)||e&&l.has(c))throw new L(`Invalid option definition: duplicate name '${r.name}'`);if(o.has(r.name)||e&&a.has(c))throw new L(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(i.add(r.name),e&&l.add(c),r.alias!==void 0){if(typeof r.alias!="string")throw new L("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new L("Invalid option definition: alias must be a single character");if(bn.test(r.alias))throw new L("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new L('Invalid option definition: alias cannot be "-"');const p=e?r.alias.toLowerCase():"";if(o.has(r.alias)||e&&a.has(p))throw new L(`Invalid option definition: duplicate alias '${r.alias}'`);if(i.has(r.alias)||e&&l.has(p))throw new L(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);o.add(r.alias),e&&a.add(p)}if(r.defaultOption&&(u++,r.type!==void 0&&K(r.type)))throw new L("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&On(r.type)))throw new L("Invalid option definition: invalid type")}if(u>1)throw x(s,"Validation failed: multiple defaultOptions not allowed","validation"),new L("Invalid option definition: multiple defaultOptions not allowed");x(s,"Validation completed successfully","validation")};function En(t,e={}){const n=e.debug??!1;x(n,"Starting command-line-args parsing","index"),x(n,"Options:","index",e);const s={...e};s.stopAtFirstUnknown&&(s.partial=!0);const i=Array.isArray(t)?t:[t];x(n,"Normalized definitions:","index",i),_n(i,s.caseInsensitive,n?s:void 0);let{argv:o}=s;o??=process.argv.slice(2),x(n,"Using argv:","index",o);let l=o;s.caseInsensitive&&(l=o.map(r=>{if(r.startsWith("--")){const c=r.indexOf("="),p=(c===-1?r.slice(2):r.slice(2,c)).toLowerCase();return c===-1?`--${p}`:`--${p}${r.slice(c)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const c=r.indexOf("="),p=c===-1?r.slice(1):r.slice(1,c);if(!p)return r;const h=p.toLowerCase();return c===-1?`-${h}`:`-${h}${r.slice(c)}`}return r}));const a=Nn(l.map(String));x(n,"Tokenized arguments:","index",a);const u=fn(a,i,s,o);return x(n,"Command-line-args parsing completed","index"),u}class xn{result;argv;options;argument;args;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;rawArgv;constructor(e,n){this.commandName=e,this.command=n}}class ue extends b{commandName;constructor(e,n,s){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",s!==void 0&&(this.cause=s)}}const kn=/^-{1,2}(\w+)(=(.+))?$/,Qe=(t,e,n,s)=>{const i=kn.exec(t);if(i===null)return{};const o=i[1];if(!o)return{};const l=n&&s?n.get(o)??s.get(o):e.find(a=>a.name===o||a.alias===o);return l!==void 0?{argName:l.name,argValue:i[3],option:l}:{}},De=(t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},In=new Set(["0","1","false","true"]),$n=(t,e,n,s)=>{if(e.length===0||t.length===0)return{};const i=(o,l)=>{const{argName:a,argValue:u,option:r}=Qe(l,e,n,s),{lastOption:c}=o;return r&&Q(r)&&u&&a?o.partial[a]=De(u,r):o.lastName&&c&&Q(c)&&In.has(l)&&(o.partial[o.lastName]=De(l,c)),{lastName:a,lastOption:r,partial:o.partial}};return t.reduce(i,{partial:{}}).partial},Pn=new Set(["0","1","false","true"]),Ln=(t,e,n,s)=>{if(e.length===0||t.length===0)return t;const i=(o,l)=>{const{argValue:a,option:u}=Qe(l,e,n,s),{lastOption:r}=o;if(r&&Q(r)&&Pn.has(l)){const{args:p}=o;return{args:p.slice(0,-1)}}return u&&Q(u)&&a?{args:o.args}:{args:[...o.args,l],lastOption:u}};return t.reduce(i,{args:[]}).args},Ve=t=>{const e=new Map;for(const n of t){const s=e.get(n.name);s?e.set(n.name,{...s,...n}):e.set(n.name,n)}return[...e.values()]},Un=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},Mn=(t,e)=>{if(!t.type)return e;if(e===void 0)return;if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return Un(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const o=Number.parseFloat(e);return Number.isNaN(o)?void 0:o}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)},Tn=/_./g,Sn=/^[A-Z]/,Dn=t=>t.toLowerCase().replaceAll(Tn,e=>e[1]?.toUpperCase()??e).replace(Sn,e=>e.toLowerCase()),Vn=(t,e=re())=>{if(!t||t.length===0)return{};const n={};for(const s of t){const i=e[s.name],o=Mn(s,i),l=o===void 0?s.defaultValue:o,a=Dn(s.name);n[a]=l}return n},jn=/-([a-z])/g,et=t=>t.replaceAll(jn,(e,n)=>n.toUpperCase()),je=(t,e)=>t.type===void 0?e:t.type(e),Rn=(t,e)=>{const{choices:n}=t;if(!n||n.length===0)return[];const s=[];for(const i of e)n.includes(i)||s.push({choices:n,name:t.name,value:i});return s},Bn=(t,e)=>e&&t.defaultValue!==void 0&&!Array.isArray(t.defaultValue)?[t.defaultValue]:t.defaultValue,zn=(t,e)=>{const n={},s=[],i=[],o=t.length-1;let l=0;for(const[a,u]of t.entries()){const r=et(u.name),c=a===o&&u.multiple===!0,p=c?e.slice(a):e.slice(a,a+1);if(p.length===0){u.required===!0&&s.push(u.name),n[r]=Bn(u,c);continue}i.push(...Rn(u,p)),l=a+p.length,n[r]=c?p.map(h=>je(u,h)):je(u,p[0])}return{invalid:i,missing:s,resolved:n,surplus:e.slice(l)}},Fn=t=>{const e=new Map,n=new Map;for(const s of t)if(e.set(s.name,s),s.alias){const i=Array.isArray(s.alias)?s.alias:[s.alias];for(const o of i)n.set(o,s)}return{optionMapByAlias:n,optionMapByName:e}},tt=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new ue(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(s){throw new ue(t.name,s instanceof Error?s.message:String(s),s)}const n=e.default;if(typeof n!="function")throw new ue(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},Wn=(t,e,n,s,i,o=[])=>{const l=new xn(t.name,t),{_all:a,_unknown:u,positionals:r}=e,p=Object.keys(n).length>0?{...a,...n}:a;oe in p&&delete p[oe],l.argument=r?.[oe]??[],l.args={},l.rawUnknown=[...u??[]],l.rawArgv=[...o];const h=Object.keys(s).length>0;return l.options=h?{...p,...s}:p,l.env=Vn(t.env,i),l},qn=(t,e,n)=>{const s=t.options??[],i=s.length>0;let o=Ve(i?[...s,...n]:n);if(o.length>0){for(const c of o)if(c.multiple&&c.lazyMultiple)throw new Error(`Argument "${c.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}const l=t.arguments!==void 0&&t.arguments.length>0;(t.argument||l)&&(o=[{defaultOption:!0,description:t.argument?.description,group:"positionals",multiple:!0,name:oe,type:t.argument?.type??String,typeLabel:t.argument?.typeLabel},...o]);let a,u;if(i){const{optionMapByAlias:c,optionMapByName:p}=Fn(s);a=Ln(e,s,p,c),u=$n(e,s,p,c)}else a=e,u={};const r=En(o,{argv:a,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:o,booleanValues:u,parsedArgs:r}},pe=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await tt(t))(e),Kn=(t,e)=>{if(!t.arguments||t.arguments.length===0)return;const n=e.rawUnknown.indexOf("--"),s=n===-1?[]:e.rawUnknown.slice(n+1),i=s.length===0?e.argument:e.argument.slice(0,Math.max(0,e.argument.length-s.length)),o=zn(t.arguments,i);if(e.args=o.resolved,o.missing.length>0)throw new xt(t.name,o.missing);const[l]=o.invalid;if(l)throw new Et(l.name,l.value,l.choices);if(o.surplus.length>0)throw new kt(t.name,o.surplus,t.arguments.length)};let Gn=class{capacity;cache;constructor(e){this.capacity=e,this.cache=new Map}get(e){if(!this.cache.has(e))return;const n=this.cache.get(e);return this.cache.delete(e),this.cache.set(e,n),n}has(e){return this.cache.has(e)}set(e,n){if(this.cache.has(e))this.cache.delete(e);else if(this.cache.size>=this.capacity){const s=this.cache.keys().next().value;s!==void 0&&this.cache.delete(s)}this.cache.set(e,n)}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}size(){return this.cache.size}};const Hn=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),Xn=new RegExp("[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d/#&.:=?%@~_]*)*)?(?:\\u0007|\\u001B\\u005C|\\u009C))|(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))","g"),Yn=t=>{if(typeof t!="string")throw new TypeError(`The "value" argument must be of type string. Received ${typeof t}`);return t.replaceAll(Xn,"")},fe=new Gn(1e3),Jn=/[.*+?^${}()|[\]\\]/g,Zn=t=>{const e=t.join("");if(fe.has(e)){const i=fe.get(e);return i.lastIndex=0,i}const n=t.map(i=>i.replaceAll(Jn,String.raw`\$&`)).join("|"),s=new RegExp(n,"g");return fe.set(e,s),s},Qn=t=>{const e=[];let n=0,s;for(q.lastIndex=0;(s=q.exec(t))!==null;)s.index>n&&e.push(t.slice(n,s.index)),e.push(s[0]),n=q.lastIndex;return n<t.length&&e.push(t.slice(n)),e.filter(Boolean)},es=/[ČŠŽĐ]/i,nt=new Uint8Array(128),st=new Uint8Array(128),ot=new Uint8Array(128);for(let t=0;t<128;t++)nt[t]=t>=65&&t<=90?1:0,st[t]=t>=97&&t<=122?1:0,ot[t]=t>=48&&t<=57?1:0;const de=t=>nt[t],Re=t=>st[t],ge=t=>ot[t],j=(t,e,n,s,i)=>{if(t.length===0)return[];let o=!1;const l=Object.values(e);for(const m of l)if(m(t[0])){o=!0;break}if(!o&&!n)return[t];const a=[...t],u=[];let r=a[0],c="other";const p=Object.entries(e);for(const m of p){const[g,y]=m;if(y(a[0])){c=g;break}}let h=n&&s?a[0]===a[0].toLocaleUpperCase(s):!1;for(let m=1;m<a.length;m++){const g=a[m];let y="other";for(const C of p){const[O,k]=C;if(k(g)){y=O;break}}const A=n&&s?g===g.toLocaleUpperCase(s):!1;let d=!1;i?d=i(c,y,h,A,g,m,a):(c!==y&&c!=="other"&&y!=="other"&&(d=!0),n&&y!=="other"&&!h&&A&&(d=!0)),d?(u.push(r),r=g):r+=g,c=y,n&&(h=A)}return r&&r.length>0&&u.push(r),u.length>0?u:[t]},ts=(t,e,n,s)=>{if(n.size===0)return e;for(const i of n)if(t.startsWith(i,e))return s.push(i),e+i.length;return e},it=(t,e=new Set)=>{if(t.length===0)return[];if(t.toUpperCase()===t)return[t];let n=0;const s=[],i=t.length;for(let o=1;o<i;o++){const l=ts(t,n,e,s);if(l!==n){n=l,o=n-1;continue}const a=t.codePointAt(o-1),u=t.codePointAt(o),r=a&&a<128&&de(a),c=u&&u<128&&de(u),p=a&&a<128&&Re(a),h=a&&a<128&&ge(a),m=u&&u<128&&ge(u);if(p&&c){s.push(t.slice(n,o)),n=o;continue}if(h&&!m||!h&&m){s.push(t.slice(n,o)),n=o;continue}if(m&&!h){let g=!1,y=!1;if(o+1<i){const A=t.codePointAt(o+1);g=A&&A<128&&de(A),y=A&&A<128&&ge(A)}if(!y&&g){s.push(t.slice(n,o),t.slice(o,o+1)),n=o+1;continue}}if(o+1<i){const g=t.codePointAt(o+1),y=g&&g<128&&Re(g);if(r&&c&&y){const A=t.slice(n,o+1);e.has(A)||(s.push(t.slice(n,o)),n=o)}}}return n<i&&s.push(t.slice(n)),s.filter(o=>o!=="")},rt=(t,e,n)=>{if(t.length===0)return[];const s=t===t.toLocaleUpperCase(e);if(e.startsWith("de")){if(!s&&t.replaceAll("ß","SS")===t.toLocaleUpperCase(e))return[t];const r=[...t],c=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e),g=m,y=m?0:-1;for(let A=1;A<c;A++){const d=r[A],C=d===d.toLocaleUpperCase(e);if(C===m)h+=d;else if(C)h&&h.length>0&&(p.push(h),h=d),g=!0,y=A;else{if(g&&A-y>1){const O=r[A-1],k=h.slice(0,-1);k&&k.length>0&&p.push(k),h=O+d}else h+=d;g=!1,y=-1}m=C}return h&&h.length>0&&p.push(h),p}if(e.startsWith("uk")||e.startsWith("ru")||e.startsWith("bg")||e.startsWith("sr")||e.startsWith("mk")||e.startsWith("be")){if(!X.test(t)&&!P.test(t))return[t];const r=[...t],c=r.length,p=[];let h=r[0];const m=r[0];let g;X.test(m)?g=1:P.test(m)?g=2:g=0;let y=m===m.toLocaleUpperCase(e);for(let d=1;d<c;d++){const C=r[d];let O;X.test(C)?O=1:P.test(C)?O=2:O=0;const k=C===C.toLocaleUpperCase(e);g!==O&&(g===1||g===2)&&(O===1||O===2)||O===g&&!y&&k?(p.push(h),h=C):h+=C,g=O,y=k}h&&h.length>0&&p.push(h);const A=[];for(let d=0;d<p.length;d++)d<p.length-1&&p[d].length===1&&P.test(p[d])&&X.test(p[d+1][0])?(A.push(p[d]+p[d+1]),d+=1):A.push(p[d]);return A}if(e.startsWith("el")){if(!ce.test(t)&&!P.test(t))return[t];const r=[];Oe.lastIndex=0;let c;for(;(c=Oe.exec(t))!==null;)r.push(c[0]);r.length===0&&r.push(t);const p=[];if(r.length===1){const h=r[0];if(!h||!ce.test(h[0])||h.length===1)return[h??t]}for(const h of r){if(!h)continue;if(!ce.test(h[0])||h.length===1){p.push(h);continue}const m=h.length;let g=h[0],y=h[0]===h[0].toLocaleUpperCase(e);for(let A=1;A<m;A++){const d=h[A],C=d===d.toLocaleUpperCase(e);!y&&C?(p.push(g),g=d):g+=d,y=C}g&&p.push(g)}return p}if(e.startsWith("ja")||e.startsWith("ko")){const r=e.startsWith("ja"),c=r?{hiragana:h=>Lt.test(h),kanji:h=>Ee.test(h),katakana:h=>Pt.test(h),latin:h=>P.test(h)}:{hangul:h=>xe.test(h),latin:h=>P.test(h)},p=new Set(["が","で","と","に","の","は","へ","も","や","を"]);if(r){const h=j(t,c,!1,e,(g,y)=>g==="hiragana"&&y==="katakana"||g==="katakana"&&y==="hiragana"||g==="hiragana"&&y==="latin"||g==="katakana"&&y==="latin"||g==="kanji"&&y==="latin"||g==="latin"&&(y==="hiragana"||y==="katakana"||y==="kanji")),m=[];for(const g of h){const y=g;y.length===1&&p.has(y)&&m.length>0?m[m.length-1]=m.at(-1)+y:m.push(y)}return m.length>0?m:[t]}return j(t,c,!1,e,(h,m)=>h==="hangul"&&m==="latin"||h==="latin"&&m==="hangul")}if(e.startsWith("sl")){const r=[...t],c=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e);for(let g=1;g<c;g++){const y=r[g],A=y===y.toLocaleUpperCase(e),d=es.test(y),C=g<c-1&&r[g+1]===r[g+1].toLocaleUpperCase(e);!m&&A||d&&C?(p.push(h),h=y,d&&C&&(p.push(h),h="")):h+=y,m=A}return h&&h.length>0&&p.push(h),p}if(e.startsWith("zh"))return j(t,{han:r=>Ee.test(r),latin:r=>P.test(r)},!1,e);if(["ar","fa","he","ur"].includes(e.split("-")[0])){const r=c=>ke.test(c)||Ie.test(c);return j(t,{latin:c=>P.test(c),rtl:c=>r(c)},!1,e)}if(["am","bn","gu","hi","km","kn","lo","ml","mr","ne","or","pa","si","ta","te","th"].includes(e.split("-")[0])){const r=c=>Ut.test(c)||Mt.test(c)||Tt.test(c)||St.test(c)||Dt.test(c)||Vt.test(c)||jt.test(c)||Rt.test(c)||Bt.test(c)||zt.test(c)||Ft.test(c)||Wt.test(c)||qt.test(c)||Kt.test(c)||Gt.test(c)||Ht.test(c);return j(t,{indic:c=>r(c),latin:c=>P.test(c)},!1,e)}if(["be","bg","ru","sr","uk"].includes(e))return j(t,{cyrillic:r=>X.test(r),latin:r=>P.test(r)},!0,e);if(["ar","fa","he"].includes(e))return j(t,{latin:r=>P.test(r),rtl:r=>ke.test(r)||Ie.test(r)},!1,e);if(e.startsWith("ko"))return j(t,{hangul:r=>xe.test(r),latin:r=>P.test(r)},!1,e);if(e.startsWith("uz")){if(!X.test(t)&&!P.test(t))return[t];const r=[...t],c=r.length,p=[];let h=r[0],m=r[0]===r[0].toLocaleUpperCase(e);for(let g=1;g<c;g++){const y=r[g],A=y===y.toLocaleUpperCase(e);if(_e.test(y)||_e.test(r[g-1])){h+=y;continue}!m&&A?(p.push(h),h=y):h+=y,m=A}return h&&h.length>0&&p.push(h),p}const i=[...t],o=i.length,l=[];let a=i[0],u=i[0]===i[0].toLocaleUpperCase(e);for(const r of n)if(t.startsWith(r)){l.push(r),a=i[r.length],u=a===a.toLocaleUpperCase(e);break}for(let r=1;r<o;r++){const c=i[r],p=c===c.toLocaleUpperCase(e);let h=0;for(const m of n)if(t.startsWith(m,r)){l.push(a,m),h=m.length,a="";const g=m.at(-1);g&&(u=g===g.toLocaleUpperCase(e));break}if(h>0){r+=h-1;continue}!u&&p?(l.push(a),a=c):a+=c,u=p}return a&&l.push(a),l},ns=(t,e,n)=>{const s=[],i=ie.test(t)?t.split(ie).filter(Boolean):[t];for(const o of i){const l=o;if(ie.test(l))s.push(l);else{q.lastIndex=0;const a=q.test(l)?Qn(l).filter(Boolean):[l];for(const u of a)if(q.lastIndex=0,q.test(u))s.push(u);else if(e){const r=e.toLowerCase().split("-")[0];s.push(...rt(u,r,n))}else s.push(...it(u,n))}}return s},ss=(t,e={})=>{if(!t||typeof t!="string")return[];const{handleAnsi:n=!1,handleEmoji:s=!1,knownAcronyms:i=[],locale:o,normalize:l=!1,separators:a,stripAnsi:u=!1,stripEmoji:r=!1}=e,c=new Set([...i].toSorted((d,C)=>C.length-d.length));let p=t;u&&(p=Yn(p)),r&&(p=It(p));let h;Array.isArray(a)?h=Zn(a):a instanceof RegExp?h=a:h=$t;const m=[];let g=p;const y=h.flags.includes("g")?h:new RegExp(h.source,`${h.flags}g`);for(;g.length>0;){const d=y.exec(g);if(!d){g===".."?m.push(".."):g==="."?m.push("."):g.length>0&&m.push(g);break}const C=d.index,O=d[0],k=O.length,E=g.slice(0,C),H=g.slice(C+k);if(O.startsWith("../"))m.push(".."),g=g.slice(C+3);else if(O.startsWith("./"))m.push("."),g=g.slice(C+2);else if(C===0&&O==="..")m.push(".."),g=g.slice(2);else if(C===0&&O===".")m.push("."),g=g.slice(1);else{E.length>0&&m.push(E);let T=0;for(;(T=O.indexOf("../",T))!==-1;)m.push(".."),T+=3;for(T=0;(T=O.indexOf("./",T))!==-1;)(T===0||O[T-1]!==".")&&m.push("."),T+=2;let f=H;for(;f.startsWith("../");)m.push(".."),f=f.slice(3);for(;f.startsWith("./");)m.push("."),f=f.slice(2);if(f===".."){m.push("..");break}else if(f==="."){m.push(".");break}else g=f}y.lastIndex=0}if(m.length===0){const d=p.split(h).filter(Boolean);m.push(...d)}let A=[];for(const d of m)n||s?A.push(...ns(d,o,c)):o?A.push(...rt(d,o,c)):A.push(...it(d,c));return l&&(A=A.map(d=>c.has(d)?d:o&&d===d.toLocaleUpperCase(o)?d[0]+d.slice(1).toLocaleLowerCase(o):d.toUpperCase()===d&&!c.has(d)?d.slice(0,1)+d.slice(1).toLowerCase():d)),A},os=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),is=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const s=[];let i="",o="";for(let l=0;l<n;l++){const a=t[l];if(ie.test(a)){i?(s.push(i+o+a),i="",o=""):(s.length>0&&s.push(e),i=a);continue}i?(o&&(o+=e),o+=a):(s.length>0&&s.push(e),s.push(a))}return s.join("")},Y=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return is(ss(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(i=>{const o=i,l=o.toLowerCase();return n?(n=!1,Hn(l)):os(l)}),"")};class rs extends b{commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}}class as extends b{choices;option;value;constructor(e,n,s){super(`Invalid value "${n}" for option "${e}". Allowed values: ${s.join(", ")}`,"INVALID_CHOICE",{choices:s,option:e,value:n}),this.name="InvalidChoiceError",this.option=e,this.value=n,this.choices=s,this.hint=`Use one of: ${s.map(i=>`--${e} ${i}`).join(", ")}`}}const Be=(t,e,n=!1)=>{const s=[],i=e._all??e;for(const o of t){if(!n&&!o.required)continue;const l=o.__camelCaseName__??o.name;if(i[l]===void 0){if(o.type?.name==="Boolean"){e[l]=!1;continue}s.push(o)}}return s},ls=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:Jt(t,e)<=t.length/3,R=(t,e)=>{const n=t.toLowerCase();return e.filter(s=>ls(s.toLowerCase(),n))},cs=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(s=>{const i=s.startsWith("--");let o=`Found unknown ${i?"option":"argument"} "${s}"`;if(i){const l=R(s.replace("--",""),(e.options??[]).map(a=>a.name));if(l.length>0){const[a,...u]=l.map(r=>`--${r}`);o+=u.length>0?`, did you mean ${a??""} or ${u.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(o)}),n.length>0)throw new b(n.join(`
2
- `),Xt.UNKNOWN_OPTION,{unknownOptions:[...t._unknown??[]]})},W=(t,e)=>new b(`Command "${t}" ${e}`,"INVALID_COMMAND",{commandName:t}),hs=(t,e)=>{const n=new Set;for(const[s,i]of t.entries()){if(typeof i!="object"||i===null)throw W(e,`has a positional argument at index ${String(s)} that is not an object`);const{name:o}=i;if(typeof o!="string"||o.length===0)throw W(e,`has a positional argument at index ${String(s)} without a name`);const l=et(o);if(n.has(l))throw W(e,`declares duplicate positional argument "${o}"`);n.add(l);const a=s===0?void 0:t[s-1];if(i.required===!0&&a!==void 0&&a.required!==!0)throw W(e,`declares required positional "${o}" after an optional one, which can never be satisfied`);if(i.multiple===!0&&s!==t.length-1)throw W(e,`declares a variadic positional "${o}" that is not the last one`)}},us=(t,e,n)=>{const s=n.__requiredOptions__,i=s?Be(s,e,!0):Be(t,e,!1);if(i.length>0)throw new rs(n.name,i.map(o=>o.name));e._unknown&&e._unknown.length>0&&!n.argument&&!n.arguments?.length&&cs(e,n)},ps=(t,e,n)=>{const s=n.__conflictingOptions__??t.filter(i=>i.conflicts!==void 0);if(s.length>0){const i=s.find(o=>{const l=o.__camelCaseName__??Y(o.name);return Array.isArray(o.conflicts)?o.conflicts.some(a=>e[Y(a)]!==void 0)&&e[l]!==void 0:e[Y(o.conflicts)]!==void 0&&e[l]!==void 0});if(i)throw new Ge(i.name,typeof i.conflicts=="string"?i.conflicts:i.conflicts?.[0]??"unknown")}},fs=(t,e)=>{const n=e.options;if(n)for(const s of n){if(!s.choices||s.choices.length===0)continue;const i=s.__camelCaseName__??Y(s.name),o=t[i];if(o==null)continue;const l=Array.isArray(o)?o:[o];for(const a of l){const u=String(a);if(!s.choices.includes(u))throw new as(s.name,u,s.choices)}}},ds=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const i of t.options){if(i.name){const o=e.get(i.name)??[];o.push(i),e.set(i.name,o)}if(typeof i.alias=="string"&&i.alias.length>0){const o=n.get(i.alias)??[];o.push(i),n.set(i.alias,o)}else if(Array.isArray(i.alias)){for(const o of i.alias)if(o.length>0){const l=n.get(o)??[];l.push(i),n.set(o,l)}}}const s=[];for(const[i,o]of e)o.length>1&&s.push(`Duplicate option name "${i}" in command "${t.name}": ${JSON.stringify(o)}`);for(const[i,o]of n)o.length>1&&s.push(`Duplicate option alias "-${i}" used by options ${o.map(l=>`"${l.name}"`).join(", ")} in command "${t.name}"`);if(s.length>0)throw new Error(s.join(`
3
- `))},gs=t=>{const{arguments:e}=t;if(e!==void 0){if(!Array.isArray(e))throw W(t.name,'must declare "arguments" as an array — slot order is significant, so a record cannot express it');if(t.argument!==void 0)throw W(t.name,'cannot define both "argument" and "arguments" — choose one');hs(e,t.name)}},ms=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let s;for(let i=1;i<=e.length;i+=1){const o=e[i-1];if(o===void 0||o.startsWith("-"))break;n.push(o);const l=n.join(" ");t.has(l)&&(s={commandPath:[...n],depth:i})}return s?{argv:e.slice(s.depth),commandPath:s.commandPath}:{argv:e,commandPath:void 0}},z=t=>t.join(" "),ze=(t,e)=>e&&e.length>0?[...e,t]:[t],Fe=t=>t===void 0||Array.isArray(t)?t:Object.entries(t).map(([e,n])=>({...n,name:e})),ws=t=>{const e=Fe(t.options),n=Fe(t.env);return e===t.options&&n===t.env?t:Object.assign(Object.create(Object.getPrototypeOf(t)),t,{env:n,options:e})},ys=/^no-/,vs=t=>{t.options?.forEach(e=>{e.__camelCaseName__=Y(e.name)})},As=t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const s of t.options)e.add(s.name);const n=[];for(const s of t.options)if(s.name.startsWith("no-")){const i=s.name.replace(ys,"");if(!e.has(i)){if(s.type!==Boolean)throw new Error(`Cannot add negated option "${s.name}" to command "${t.name}" because it is not a boolean.`);const o={...s,alias:void 0,defaultValue:s.defaultValue===void 0?!0:!s.defaultValue,description:`Inverse of --${s.name}.`,name:i};n.push(o),e.add(i)}}n.length>0&&t.options.push(...n)},Cs=(t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,s=new Map;for(const o of e.options)if(o.name.startsWith("no-")){const l=Y(o.name);s.set(l,o)}const i=Object.keys(n).filter(o=>s.has(o));if(i.length!==0)for(const o of i){const l=o.charAt(2);if(!l)continue;const a=l.toLowerCase()+o.slice(3),u=s.get(o);u&&(u.__negated__=!0),n[a]=!n[o],Reflect.deleteProperty(n,o)}},Ns=(t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const i of e.options)i.__camelCaseName__&&i.__negated__===void 0&&i.implies!==void 0&&n.set(i.__camelCaseName__,i);if(n.size===0)return;const{options:s}=t;for(const i of Object.keys(s)){const o=n.get(i);if(o?.implies){const{implies:l}=o;for(const[a,u]of Object.entries(l))s[a]===void 0&&(s[a]=u)}}},bs=()=>!!process.versions.electron,Os=()=>bs()&&!process.defaultApp,_s=()=>Os()?0:1,Es=t=>t.slice(_s()+1),xs=" ",ks=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,s)=>n===e[s]),Is=t=>{if(typeof t=="string")return t.split(xs);const e=we();return ks(t,e)?Es(t):t},$s=t=>{const e=o=>{t.error(`Uncaught exception: ${o.message||o}`),o.stack&&t.error(o.stack),F(1)},n=(o,l)=>{if(o instanceof Error)t.error(`Promise rejection: ${o.message||o}`),o.stack&&t.error(o.stack);else{let a;if(typeof o=="string")a=o;else try{a=JSON.stringify(o)}catch{a=String(o)}t.error(`Promise rejection: ${a}`)}F(1)},s=be("uncaughtException",e),i=be("unhandledRejection",n);return()=>{s(),i()}},We=100,Ps=/^[a-z][\w-]*$/i,ve=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new b(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},qe=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new b(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},ne=(t,e)=>{if(typeof t!="object"||t===null)throw new b(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},se=t=>{const e=ve(t,"Command name");if(e.length>We)throw new b(`Command name is too long (maximum ${String(We)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new b(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!Ps.test(e))throw new b(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},Ls=1e6,Us=1e5,Ms=new Set([`
4
- `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),Ts=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,s=n.maxArgumentLength??Ls;if(Number.isFinite(s)&&s>0&&t.length>s)throw new Error(`Argument is too long (maximum ${String(s)} characters)`);if(n.checkDangerousChars){for(const i of t)if(Ms.has(i))throw new Error(`Argument contains dangerous character: ${i}`)}return n.trim?t.trim():t},Ke=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,s=n.maxArguments??Us;if(Number.isFinite(s)&&s>0&&t.length>s)throw new Error(`Too many arguments (maximum ${String(s)})`);return t.map(i=>Ts(i,n))},Ss=/^-([^\d-])$/,Ds=/^--(\S+)/,Vs=/^-([^\d-]{2,})$/,me=t=>Ss.test(t)||Ds.test(t)||Vs.test(t),js={access:(t,e)=>yt(t,e),mkdir:(t,e)=>wt(t,e),readdir:t=>mt(t),readFile:(async(t,e)=>e===void 0?Ne(t):Ne(t,e)),rm:(t,e)=>gt(t,e),stat:t=>dt(t),writeFile:(t,e,n)=>ft(t,e,n)},Rs=(t,e,n)=>{const s=e.indexOf("--"),i=s===-1?new Set:new Set(e.slice(s+1)),o=n.filter(u=>u.startsWith("--")&&u!=="--"&&!i.has(u));if(o.length===0)return;const l=(t.options??[]).map(u=>u.name),a=o.flatMap(u=>R(u.slice(2),l).map(r=>`--${r}`));throw new Zt(o,a)};class at{#t;#e;#h;#p;#f;#d;#O;#_;#E;#A;#x;#C;#k;#N=le;#u;#n;#s;#o;#i;#r;#I=!1;#$;#P=!1;#g;#m;#w;#l=[];#D(){return this.#g===void 0&&(this.#g=[...this.#s.keys()]),this.#g}#L(){return this.#m===void 0&&(this.#m=[...this.#n.keys()]),this.#m}#a(){return this.#w===void 0&&(this.#w=[...this.#D(),...this.#L()]),this.#w}#U(){return this.#l.length===0?te:[...te,...this.#l]}#M(){this.#g=void 0,this.#m=void 0,this.#w=void 0}#b(){if(this.#h===void 0){const e=Is(this.#e.argv);this.#h=Ke(e,{maxArguments:this.#C}),this.#V()}return this.#h}#y(){return this.#A??re()}#v(e){this.#N=e,this.#y().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){return this.#N}#V(){if(!this.#h)return;let e=!1;for(const n of this.#h){if(n==="--quiet"||n==="-q"){this.#v(vt),e=!0;break}if(n==="--verbose"||n==="-v"){this.#v(At),e=!0;break}if(n==="--debug"){this.#v(V),e=!0;break}}e||this.#v(Object.hasOwn(this.#y(),"DEBUG")?V:le)}#j(){this.#P||(this.#$=$s(this.#t),this.#P=!0)}#R(){return{arch:Nt(),argv:this.#b(),cwd:this.#p,env:this.#A??re(),exit:this.#E??(e=>F(e??0)),platform:Ct(),stdin:this.#x}}#T(e,n,s,i){this.#c()===V&&this.#t.debug(`command '${i}' found, parsing command args: ${n.join(", ")}`);const{arguments_:o,booleanValues:l,parsedArgs:a}=qn(e,n,this.#U()),u=Object.keys(l).length>0;let r=a;u&&(r={...a,_all:{...a._all,...l}}),us(o,r,e);const c=Wn(e,a,l,s,this.#y(),n);c.runtime=this,c.argv=this.#b(),c.fs=this.#_??js,c.process=this.#R(),c.console=this.#t,Kn(e,c);const p=e.options&&e.options.length>0;if(p&&e.options){const h=e.options.filter(m=>m.name.startsWith("no-"));for(const m of h){const g=m.name.slice(3),y=`--${m.name}`,A=`--${g}`,d=n.includes(y),C=n.includes(A);if(d&&C)throw new Ge(g,m.name)}}return p&&(Cs(c,e),Ns(c,e)),ps(o,c.options,e),fs(c.options,e),this.#k&&Rs(e,n,c.rawUnknown),this.#c()===V&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(c.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(c.argument,null,2))),{arguments_:o,booleanValues:l,commandArgs:r,parsedArgs:a,toolbox:c}}async#S(e,n,s){const i=this.getPluginManager();try{!this.#I&&i.hasPlugins()&&(await i.init({cli:this,cwd:this.#p,logger:this.#t}),this.#I=!0),await i.executeLifecycle("execute",n),await i.executeLifecycle("beforeCommand",n);let o;const l=s.global;if(l?.help){const a=this.#n.get("help");if(!a)throw new b("Help command not found","COMMAND_NOT_FOUND");o=await pe(a,n,s)}else if(l?.version??l?.V){const a=this.#n.get("version");if(!a)throw new b("Version command not found","COMMAND_NOT_FOUND");o=await pe(a,n,s)}else o=await pe(e,n,s);return await i.executeLifecycle("afterCommand",n,o),o}catch(o){throw await i.executeErrorHandlers(o,n),o}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new b("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#f=e.trim();const s=n.argv??we(),i=n.cwd??bt();if(this.#e={...n,argv:s,cwd:i},this.#e.argv&&!Array.isArray(this.#e.argv))throw new b("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new b("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new b("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new b("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const p=["debug","error","info","log","warn"],h=[],m=this.#e.logger;for(const g of p)typeof m[g]!="function"&&h.push(g);if(h.length>0)throw new b(`Logger object is missing required methods: ${h.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:h});this.#t=this.#e.logger}else this.#t={...console,debug:(...p)=>{this.#c()===V&&console.debug(...p)}};this.#d=this.#e.packageVersion,this.#O=this.#e.packageName,this.#p=this.#e.cwd,this.#i="help",this.#r={};const o=n.fs;if(o!==void 0&&(typeof o!="object"||o===null))throw new b("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const l=n.exit;if(l!==void 0&&typeof l!="function")throw new b("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new b("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const u=n.stdin;if(u!==void 0&&typeof u!="string")throw new b("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#_=n.fs,this.#E=n.exit,this.#A=n.env,this.#x=n.stdin??"",this.#C=n.maxArguments,this.#k=n.strictOptions??!1;const r=this.#y().CEREBRO_OUTPUT_LEVEL,c=r===void 0?Number.NaN:Number(r);this.#N=Number.isNaN(c)?le:c,this.#n=new Map,this.#s=new Map,this.#o=new Map}setCommandSection(e){return this.#r=e,this}getCommandSection(){return this.#r.header||(this.#r.header=`${this.#f}${this.#d?` v${this.#d}`:""}`),this.#r}setDefaultCommand(e){return this.#i=e,this}get defaultCommand(){return this.#i}addCommand(e){ne(e,"Command"),se(e.name),e.options!==void 0&&ne(e.options,"Command options"),e.env!==void 0&&ne(e.env,"Command env"),gs(e);const n=ws(e),s=typeof n.execute=="function",i=typeof n.loader=="function";if(s&&i)throw new b(`Command "${n.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:n.name});if(!s&&!i)throw new b(`Command "${n.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:n.name});n.alias&&(typeof n.alias=="string"?se(n.alias):qe(n.alias,"Command alias").forEach(c=>se(c))),n.argument&&ne(n.argument,"Command argument"),n.commandPath&&(qe(n.commandPath,"Command commandPath"),n.commandPath.forEach(c=>{se(c)}));const o=ze(n.name,n.commandPath),l=z(o);if(this.#s.has(l))throw new b(`Command with path "${l}" already exists`,"DUPLICATE_COMMAND",{commandName:n.name,commandPath:n.commandPath});const a=Array.isArray(n.commandPath)&&n.commandPath.length>0,u=this.#n.get(n.name),r=u!==void 0&&(u.commandPath===void 0||u.commandPath.length===0);if(!a&&r)throw new b(`Command with name "${n.name}" already exists`,"DUPLICATE_COMMAND",{commandName:n.name});if(n.options)for(const c of n.options)$e(c);if(ds(n),As(n),vs(n),n.options&&(n.__conflictingOptions__=n.options.filter(c=>c.conflicts!==void 0),n.__requiredOptions__=n.options.filter(c=>c.required===!0)),a&&u!==void 0)this.#n.set(l,n);else{if(!a&&u!==void 0&&!r){const c=ze(u.name,u.commandPath);this.#n.set(z(c),u)}this.#n.set(n.name,n)}if(this.#s.set(l,o),this.#o.set(l,n),this.#M(),n.alias!==void 0){const c=typeof n.alias=="string"?[n.alias]:n.alias;for(const p of c){if(this.#c()===V&&this.#t.debug("adding alias",p),this.#n.has(p))throw new b(`Command alias "${p}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:p,commandName:n.name});this.#n.set(p,n)}}return this}addGlobalOption(e){const n=e,s=new Set(te.map(l=>l.name)),i=new Set(te.map(l=>l.alias).filter(Boolean));if(s.has(n.name))throw new b(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&i.has(n.alias))throw new b(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(l=>l.name)).has(n.name))throw new b(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",$e(n),this.#l.push(n),this}getGlobalOptions(){return this.#U()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#u?this.#u:(this.#u=new en(this.#t),this.#u.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#u)}getCliName(){return this.#f}getPackageVersion(){return this.#d}getPackageName(){return this.#O}getCommands(){return this.#n}getCwd(){return this.#p}dispose(){this.#$?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:s=!0,...i}=e;if(!this.#n.has("help")){const{default:d}=await import("../commands/help-command.js");this.addCommand(new d(this.#n))}const o=this.#L(),l=this.#s;this.#j();const a=this.#b();let u,r=[...a];this.#c()===V&&(this.#t.debug(`process.execPath: ${Ot()}`),this.#t.debug(`process.execArgv: ${_t().join(" ")}`),this.#t.debug(`process.argv: ${we().join(" ")}`));const c=ms(l,[...a]);if(c.commandPath)u=c.commandPath,r=c.argv;else{if(a.length>1&&a[0]&&a[1]&&!me(a[0])&&!me(a[1])){const C=[];let O=0;for(;O<a.length;){const E=a[O];if(!E||me(E))break;C.push(E),O+=1}const k=z(C);if(C[0]&&!o.includes(C[0])){const E=this.#a(),H=R(k,E);throw new B(k,H)}}let d;try{d=an([null,...o],[...a])}catch(C){if(C instanceof Error&&C.name==="INVALID_COMMAND"&&"command"in C){const O=C.command,k=this.#a(),E=R(O,k);throw new B(O,E)}throw C}d.command&&(u=[d.command],r=d.argv)}if(!u)if(this.#i)u=[this.#i];else{const d=this.#a();throw new B("",d)}const p=z(u),h=this.#s.get(p);let m;if(h){if(m=this.#o.get(p),!m||z(h)!==p){const d=this.#a(),C=R(p,d);throw new B(p,C)}}else{const d=u.at(-1);if(m=d?this.#n.get(d):void 0,!m){const C=this.#a(),O=R(p,C);throw new B(p,O)}}if(typeof m.execute!="function"&&typeof m.loader!="function")return this.#t.error(`Command "${m.name}" has no function to execute.`),s?F(1):void 0;const g=r;let y,A;try{({commandArgs:y,toolbox:A}=this.#T(m,g,i,p))}catch(d){const C=Yt(d);if(this.#t.error(C??d),s)return F(1);throw d}try{return await this.#S(m,A,y),s?F(0):void 0}catch(d){if(s)return this.#t.error(d),F(1);throw d}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:s=[],...i}=n;ve(e,"Command name");const o=e.split(" ").filter(Boolean),l=z(o),u=this.#s.get(l)?this.#o.get(l):this.#n.get(e);if(!u){const m=this.#a(),g=R(l||e,m);throw new B(e,g)}if(typeof u.execute!="function"&&typeof u.loader!="function")throw new b(`Command "${u.name}" has no function to execute`,"INVALID_COMMAND",{commandName:u.name});const c=[...Ke(s,{maxArguments:this.#C})];this.#c()===V&&this.#t.debug(`running command '${e}' programmatically with args: ${c.join(", ")}`);const{commandArgs:p,toolbox:h}=this.#T(u,c,i,l||e);return this.#S(u,h,p)}clone(e){const n={...this.#e,...e},s=new at(this.#f,n);for(const[i,o]of this.#n)s.#n.set(i,o);for(const[i,o]of this.#s)s.#s.set(i,[...o]);for(const[i,o]of this.#o)s.#o.set(i,o);for(const i of this.#l)s.#l.push(i);return s.#i=this.#i,s.#r={...this.#r},s.#M(),s}async getAction(e){ve(e,"Command name");const n=e.split(" ").filter(Boolean),s=z(n),o=this.#s.get(s)?this.#o.get(s):this.#n.get(e);if(!o){const l=this.#a(),a=R(s||e,l);throw new B(e,a)}if(typeof o.execute=="function")return o.execute;if(typeof o.loader=="function")return tt(o);throw new b(`Command "${o.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:o.name})}}export{at as Cli};
@@ -1,6 +0,0 @@
1
- import{createRequire as te}from"node:module";import{L as U,B as v,c as ie}from"./constants-BKuEbBw1-BRv49X2l.js";import{createTable as A}from"@visulima/tabular";import{NO_BORDER as M}from"@visulima/tabular/style";import ae from"@visulima/colorize/template";import{c as le}from"./runtime-process-BN-eTlwy.js";import{bold as $,underline as ue}from"@visulima/colorize";let re;const ne=e=>(re??=te(import.meta.url))(e),b=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:w,T=e=>{if(typeof b<"u"&&b.versions&&b.versions.node){const[t,r]=b.versions.node.split(".").map(Number);if(t>22||t===22&&r>=3||t===20&&r>=16)return b.getBuiltinModule(e)}return ne(e)},w=b,{execFileSync:se}=T("node:child_process"),W=T("node:fs"),oe=T("node:tty"),ce=T("node:os"),de=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],fe=12288,he=65510,pe=[12288,12288,65281,65376,65504,65510],me=8361,we=65518,ge=[8361,8361,65377,65470,65474,65479,65482,65487,65490,65495,65498,65500,65512,65518],be=32,ye=10630,Ne=[32,126,162,163,165,166,172,172,175,175,10214,10221,10629,10630],Ie=4352,We=262141,Y=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141],O=(e,t)=>{let r=0,i=Math.floor(e.length/2)-1;for(;r<=i;){const o=Math.floor((r+i)/2),c=o*2;if(t<e[c])i=o-1;else if(t>e[c+1])r=o+1;else return!0}return!1},P=19968,[Oe,ve]=xe(Y);function xe(e){let t=e[0],r=e[1];for(let i=0;i<e.length;i+=2){const o=e[i],c=e[i+1];if(P>=o&&P<=c)return[o,c];c-o>r-t&&(t=o,r=c)}return[t,r]}const Ee=e=>e<161||e>1114109?!1:O(de,e),Ae=e=>e<fe||e>he?!1:O(pe,e),Me=e=>e<me||e>we?!1:O(ge,e),$e=e=>e<be||e>ye?!1:O(Ne,e),Se=e=>e>=Oe&&e<=ve?!0:e<Ie||e>We?!1:O(Y,e);function Ce(e){return Ee(e)?"ambiguous":Ae(e)?"fullwidth":Me(e)?"halfwidth":$e(e)?"narrow":Se(e)?"wide":"neutral"}function Te(e){if(!Number.isSafeInteger(e))throw new TypeError(`Expected a code point, got \`${typeof e}\`.`)}function G(e){return Te(e),Ce(e)}const D=new Map,ke=e=>[e.ambiguousIsNarrow?1:0,e.control,e.fullWidth,e.regular,e.wide].join("|"),Le=e=>{const t=ke(e.width);let r=D.get(t);return r||(r=new Map,D.set(t,r)),r},x=new RegExp(U.source,"y"),_=new RegExp(ie.source,"uy"),E=/(?:[\u0020-\u007E\u00A0-\u00FF](?!\uFE0F)){1,1000}/y,V=e=>e>=32&&e<=126?"latin":e===8203||e===8204||e===8205||e===8288?"zero":e<=31||e>=127&&e<=159?"control":e>=160&&e<=255||e>=9472&&e<=9599?"latin":e>=4352&&e<=4607||e>=11904&&e<=40959||e>=44032&&e<=55215||e>=63744&&e<=64255||e>=65280&&e<=65519&&!(e>=65377&&e<=65439)||e>=12352&&e<=12543?"wide":e===8230?"latin":"other",Re=(e,t)=>{const r=Le(t),i=Math.floor(e/65536),o=e%65536;let c=r.get(i);if(c||(c=new Map,r.set(i,c)),c.has(o))return c.get(o);let n;switch(V(e)){case"control":{n=t.width.control;break}case"latin":{n=t.width.regular;break}case"wide":{n=t.width.wide;break}case"zero":{n=0;break}default:switch(G(e)){case"ambiguous":{n=t.width.ambiguousIsNarrow?t.width.regular:t.width.wide;break}case"fullwidth":{n=t.width.fullWidth;break}case"wide":{n=t.width.wide;break}default:n=t.width.regular}}return c.set(o,n),n},_e=e=>e>=768&&e<=879||e>=6832&&e<=6911||e>=7616&&e<=7679||e>=8400&&e<=8447||e>=65056&&e<=65071||e>=917760&&e<=917999||e>=65024&&e<=65039||e>=3633&&e<=3642||e>=3655&&e<=3662||e>=3761&&e<=3769||e>=3771&&e<=3772||e>=3784&&e<=3789||e>=2304&&e<=2307||e>=2362&&e<=2383||e>=2385&&e<=2391||e>=2402&&e<=2403||e>=2433&&e<=2435||e>=2492&&e<=2500||e>=2509&&e<=2509||e>=2561&&e<=2563||e>=2620&&e<=2637||e>=1611&&e<=1631||e>=1648&&e<=1648||e>=1750&&e<=1773||e>=2276&&e<=2302||e>=1425&&e<=1469||e>=1471&&e<=1471||e>=1473&&e<=1474||e>=1476&&e<=1477||e>=1479&&e<=1479||e>=3893&&e<=3893||e>=3895&&e<=3895||e>=3897&&e<=3897||e>=3953&&e<=3966||e>=3968&&e<=3972||e>=3974&&e<=3975?!0:e>=768&&e<=777||e>=803&&e<=803,F=(e,t={})=>{if(!e||e.length===0)return{ellipsed:!1,index:0,truncated:!1,width:0};const r={truncation:{countAnsiEscapeCodes:t.countAnsiEscapeCodes??!1,ellipsis:t.ellipsis??"",ellipsisWidth:t.ellipsisWidth??(t.ellipsis?F(t.ellipsis,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width:0),limit:t.limit??Number.POSITIVE_INFINITY},width:{ambiguousIsNarrow:t.ambiguousIsNarrow??!1,ansi:t.ansiWidth??0,control:t.controlWidth??0,emoji:t.emojiWidth??2,fullWidth:t.fullWidth??2,halfWidth:t.halfWidth??1,regular:t.regularWidth??1,tab:t.tabWidth??8,wide:t.wideWidth??2}},i=Math.max(0,r.truncation.limit-r.truncation.ellipsisWidth),{length:o}=e,c=o>1e4;let n=0,s=0,l=o,a=!1;const u=e.includes("\x1B")||e.includes("›");for(;n<o;){if(u&&(e[n]==="\x1B"||e[n]==="›")){if(e.startsWith("\x1B]8;;",n)){const f="\x1B]8;;\x07",p=f.length,k=e.indexOf("\x07",n+5);if(k!==-1){const L=e.indexOf(f,k+1);if(L!==-1){const Q=L+p,ee=e.slice(k+1,L).replace(U,""),z=F(ee,{ambiguousIsNarrow:r.width.ambiguousIsNarrow,ansiWidth:r.width.ansi,controlWidth:r.width.control,countAnsiEscapeCodes:!1,ellipsis:r.truncation.ellipsis,ellipsisWidth:r.truncation.ellipsisWidth,emojiWidth:r.width.emoji,fullWidth:r.width.fullWidth,halfWidth:r.width.halfWidth,limit:Math.max(0,i-s),regularWidth:r.width.regular,tabWidth:r.width.tab,wideWidth:r.width.wide}),R=z.width;if(z.truncated)a=!0,l=Math.min(l,n);else if(s+R>i&&(l=Math.min(l,n),a=!0,s+R>r.truncation.limit))break;if(s+=R,n=Q,a&&s>=r.truncation.limit)break;continue}}}if(x.lastIndex=n,x.test(e)){const f=x.lastIndex-n,p=r.truncation.countAnsiEscapeCodes?f:r.width.ansi;if(s+p>i&&(l=Math.min(l,n),s+p>r.truncation.limit)){a=!0;break}s+=p,n=x.lastIndex;continue}}const m=e.codePointAt(n);if(m===8203||m===65279||m>=8288&&m<=8292){n+=1;continue}if(m===9){if(s+r.width.tab>i&&(l=Math.min(l,n),s+r.width.tab>r.truncation.limit)){a=!0;break}s+=r.width.tab,n+=1;continue}if(E.lastIndex=n,E.test(e)){const f=(E.lastIndex-n)*r.width.regular;if(s+f>i){const p=r.width.regular>0?Math.floor((i-s)/r.width.regular):0;if(l=Math.min(l,n+p),s+f>r.truncation.limit){a=!0;break}}s+=f,n=E.lastIndex;continue}if((m<=31||m>=127&&m<=159)&&(v.lastIndex=n,v.test(e))){const f=(v.lastIndex-n)*r.width.control;if(s+f>i){const p=r.width.control>0?Math.floor((i-s)/r.width.control):0;if(l=Math.min(l,n+p),s+f>r.truncation.limit){a=!0;break}}s+=f,n=v.lastIndex;continue}if(_.lastIndex=n,_.test(e)){if(s+r.width.emoji>i&&(l=Math.min(l,n),s+r.width.emoji>r.truncation.limit)){a=!0;break}s+=r.width.emoji,n=_.lastIndex;continue}const g=e.codePointAt(n)??0;if(_e(g)){n+=g>65535?2:1;continue}let d;if(c)d=Re(g,r);else switch(V(g)){case"control":{d=r.width.control;break}case"latin":{d=r.width.regular;break}case"wide":{d=r.width.wide;break}case"zero":{d=0;break}default:switch(G(g)){case"ambiguous":{d=r.width.ambiguousIsNarrow?r.width.regular:r.width.wide;break}case"fullwidth":{d=r.width.fullWidth;break}case"wide":{d=r.width.wide;break}default:d=r.width.regular}}if(s+d>i&&(l=Math.min(l,n),s+d>r.truncation.limit)){a=!0;break}s+=d,n+=g>65535?2:1}let y=s,N=!1;return a&&r.truncation.limit>=r.truncation.ellipsisWidth&&(y=r.truncation.limit,N=!0),{ellipsed:N,index:a?l:o,truncated:a,width:y}},je=(e,t={})=>F(e,{...t,ellipsis:"",ellipsisWidth:0,limit:Number.POSITIVE_INFINITY}).width,K=80,J=24,B=(e,t,{shell:r,env:i}={})=>se(e,t,{encoding:"utf8",stdio:["ignore","pipe","ignore"],timeout:500,shell:r,env:i}).trim(),S=(e,t)=>({columns:Number.parseInt(e,10),rows:Number.parseInt(t,10)}),X=(e,t)=>{const{columns:r,rows:i}=S(e,t);if(!(Number.isNaN(r)||Number.isNaN(i))&&!(r===K&&i===J))return{columns:r,rows:i}},Fe=()=>{if(w.platform!=="linux")return!0;try{const e=W.readFileSync("/proc/self/stat","utf8"),t=e.lastIndexOf(") ");if(t===-1)return!1;const r=e.slice(t+2).trim().split(/\s+/),i=Number.parseInt(r[2],10),o=Number.parseInt(r[5],10);return Number.isNaN(i)||Number.isNaN(o)||o<=0?!1:i===o}catch{return!1}};function Be(){const{env:e,stdout:t,stderr:r}=w;if(t?.columns&&t?.rows)return S(t.columns,t.rows);if(r?.columns&&r?.rows)return S(r.columns,r.rows);if(e.COLUMNS&&e.LINES)return S(e.COLUMNS,e.LINES);const i={columns:K,rows:J};return w.platform==="win32"?j()??i:w.platform==="darwin"?q()??j()??i:q()??j()??ze()??i}const q=()=>{try{const e=w.platform==="darwin"?W.constants.O_EVTONLY|W.constants.O_NONBLOCK:W.constants.O_NONBLOCK,{columns:t,rows:r}=oe.WriteStream(W.openSync("/dev/tty",e));return{columns:t,rows:r}}catch{}},j=()=>{try{const e=B("tput",["cols"],{env:{TERM:"dumb",...w.env}}),t=B("tput",["lines"],{env:{TERM:"dumb",...w.env}});if(e&&t)return X(e,t)}catch{}},ze=()=>{try{if(!Fe())return;const e=B("resize",["-u"]).match(/\d+/g);if(e.length===2)return X(e[0],e[1])}catch{}},I=new Map,Pe=500,h=e=>{if(!e||e==="")return"";const t=I.get(e);if(t!==void 0)return t;let r;try{r=ae(Object.assign([],{raw:[e]}))}catch{r=e}if(I.size>=Pe){const i=I.keys().next().value;i!==void 0&&I.delete(i)}return I.set(e,r),r},C=()=>{const t=le().CEREBRO_TERMINAL_WIDTH;if(t===void 0)return;const r=Number.parseInt(t,10);if(!(Number.isNaN(r)||r<=0))return r};class Z{lines;constructor(){this.lines=[]}add(t){this.lines.push(t)}toString(){return this.lines.join(ce.EOL)}header(t){this.add($(t)),this.lines.push("")}}const De=e=>e!==void 0&&e>0?e:Be().columns,qe=(e,t,r,i)=>{if(e.length===0||e.some(u=>u.length!==2))return;let o=0;for(const u of e){const y=u[0];if(y===void 0)continue;const N=je(y);N>o&&(o=N)}if(o===0)return;const c=r+i,n=o+c,l=20+c;if(n+l>t)return;const a=t-n;return[n,a]};class He extends Z{constructor(t){if(super(),t.header&&this.header(h(t.header)),t.content){if(t.raw)if(Array.isArray(t.content)&&t.content.every(r=>typeof r=="string"))t.content.forEach(r=>{Array.isArray(r)?r.forEach(i=>{this.add(h(i))}):this.add(h(r))});else if(typeof t.content=="string")this.add(h(t.content));else throw new TypeError("Invalid raw content, must be a string or array of strings.");else this.add(this.getContentLines(t.content));this.add("")}}getContentLines(t){if(typeof t=="string"){const r=A({showHeader:!1,style:{border:M,paddingLeft:4,paddingRight:1},terminalWidth:C(),truncateOverflow:!1,wordWrap:!0});return r.addRow([h(t)]),r.toString()}if(Array.isArray(t)&&t.every(r=>typeof r=="string"||Array.isArray(r)&&r.every(i=>typeof i=="string"))){const o=De(C()),c=a=>Array.isArray(a)?a.map(u=>h(u)):[h(a)],n=t.map(a=>c(a)),s=qe(n,o,4,1),l=A({columnWidths:s,showHeader:!1,style:{border:M,paddingLeft:4,paddingRight:1},terminalWidth:o,truncateOverflow:!1,wordWrap:!0});return n.forEach(a=>{s!==void 0&&a.length===2?l.addRow([{content:a[0],wordWrap:!1},a[1]]):l.addRow(a)}),l.toString()}if(typeof t=="object"){const r=t;if(!r.options||!r.data)throw new Error(`Must have an "options" or "data" property
2
- ${JSON.stringify(t)}`);const i=A({showHeader:!1,style:{border:M,paddingLeft:4,paddingRight:1},terminalWidth:C(),truncateOverflow:!1,wordWrap:!0});return r.data.forEach(o=>{Array.isArray(o)?i.addRow(o.map(c=>h(c))):i.addRow([h(o)])}),i.toString()}throw new Error(`invalid input - 'content' must be a string, array of strings or a object:
3
-
4
- ${JSON.stringify(t)}`)}}class Ue extends Z{constructor(t){super();let r=t.optionList??[];const i=Array.isArray(t.hide)?t.hide:[t.hide].filter(n=>typeof n=="string"),o=Array.isArray(t.group)?t.group:[t.group].filter(n=>typeof n=="string");i.length>0&&(r=r.filter(n=>!i.includes(n.name))),t.header&&this.header(h(t.header)),o.length>0&&(r=r.filter(n=>{const s=n,l=o.includes("_none")&&!s.group,a=s.group,u=this.intersect(Array.isArray(a)?a:[a],o);return l||u?n:void 0}));const c=A({showHeader:!1,style:{border:M,paddingLeft:2,paddingRight:1,...t.tableOptions?.style},terminalWidth:C()??t.tableOptions?.terminalWidth,truncateOverflow:!1,wordWrap:t.tableOptions?.wordWrap??!0,...t.tableOptions});r.forEach(n=>{const s=n;c.addRow([this.getOptionNames(s,t.reverseNameOrder??!1,t.isArgument??!1),h(s.description)])}),this.add(c.toString()),this.lines.push("")}getOptionNames(t,r,i){if(!t.name)throw new TypeError("Invalid option definition, name is required.");const o=t.type?t.type.name.toLowerCase():"string",{lazyMultiple:c}=t,n=t.multiple||c?"[]":"",s=t.typeLabel===void 0?ue(`${o}${n}`):h(t.typeLabel),l=i?$(t.name):$.yellow(`--${t.name}`),a=t.alias;if(a){const u=$(`-${a}`);return r?`${l}, ${u} ${s}`:`${u}, ${l} ${s}`}return`${l} ${s}`}intersect(t,r){return t.some(i=>r.includes(i))}}const Qe=e=>(Array.isArray(e)?e:[e]).length===0?"":`
5
- ${e.map(r=>r.optionList?new Ue(r).toString():new He(r).toString()).join(`
6
- `)}`,H=(e,t)=>{const i=`${t==="readme"?e.name.toUpperCase():e.name}${e.multiple===!0?"...":""}`;return e.required===!0?t==="readme"?i:`<${i}>`:`[${i}]`},et=(e,t="help")=>e.argument?e.argument.hidden?"":t==="readme"?` ${H(e.argument,t)}`:" [positional arguments]":!e.arguments||e.arguments.length===0?"":e.arguments.filter(r=>!r.hidden).map(r=>` ${H(r,t)}`).join("");export{Qe as c,et as f,h as t};