<commit_before>@mixin init-media-alt($out: true) {

  //////////
  // base //
  //////////

  // backup $base as spec'd;
  // merge spec'd $base against defaults, and normalize
  $base-orig: $base !global;
  $base: normalize-medium(map-merge($medium-default, $base)) !global;

  ///////////
  // media //
  ///////////

  // TODO: use a sassdash sortBy with a function, to determine proper sorting
  $media: if(length($media)>0, $media, (
    c4: ( grid-columns: 4 ),
    c6: ( grid-columns: 6 ),
    c8: ( grid-columns: 8 ),
    c10: ( grid-columns: 10 ),
    c12: ( grid-columns: 12 ),
  )) !global;

  // backup $media;
  // make temp for recursive merging
  $media-orig: $media !global;
  $reference: $base;

  @each $m, $medium in $media {

    // merge current medium against ref-medium, normalize primitive values
    $reference: normalize-medium(map-merge($reference, $medium));

    // get and merge sub-maps
    $sizes: map-merge(map-get($reference, 'sizes'), map-get($medium, 'sizes') or ());
    $lines: map-merge(map-get($reference, 'lines'), map-get($medium, 'lines') or ());
    $mults-x: map-merge(map-get($reference, 'mults-x'), map-get($medium, 'mults-x') or ());
    $mults-y: map-merge(map-get($reference, 'mults-y'), map-get($medium, 'mults-y') or ());

    // calc and merge additional props
    $font-size: map-get($reference, 'font-size');
    $margin-x: map-get($reference, 'margin-x');
    $outer-x: map-get($reference, 'outer-right') + map-get($reference, 'outer-left');

    $type-width: map-get($reference, 'type-width');
    $type-columns: map-get($reference, 'type-columns');
    $grid-columns: map-get($reference, 'grid-columns');
    $type-vs-grid: $type-columns/$grid-columns;

    $content-width: ($type-width + $margin-x) / $type-vs-grid - $margin-x;
    $outer-width: $content-width + $outer-x;
    $breakpoint: unit-assert($outer-width * map-get($reference, 'html-scale'), em);

    $reference: map-merge($reference, (
      'content-width': $content-width,
      'breakpoint': $breakpoint,
      'sizes': $sizes,
      'lines': $lines,
      'mults-x': $mults-x,
      'mults-y': $mults-y,
    ));

    // merge reference back to master
    $media: map-merge($media, ($m: $reference)) !global;
  }

  @if $out {
    $globals: if(variable-exists('globals'), $globals, ());
    @include json-content(map-merge($globals, (media: $media)));
    @include media-for(font-size line-height) {
      html { font-size: unit-assert(medium-value('html-scale'), em); }
      body { line-height: medium-value('line-height'); }
    }
  }
}
<commit_msg>note re non-sorting in init-media-alt<commit_after>@mixin init-media-alt($out: true) {

  //////////
  // base //
  //////////

  // backup $base as spec'd;
  // merge spec'd $base against defaults, and normalize
  $base-orig: $base !global;
  $base: normalize-medium(map-merge($medium-default, $base)) !global;

  ///////////
  // media //
  ///////////

  // NB: must be provided in order !
  // (sorting these would require recursive pre-calc and check of resulting breakpoints, FTS)
  $media: if(length($media)>0, $media, (
    c4: ( grid-columns: 4 ),
    c6: ( grid-columns: 6 ),
    c8: ( grid-columns: 8 ),
    c10: ( grid-columns: 10 ),
    c12: ( grid-columns: 12 ),
  )) !global;

  // backup $media;
  // make temp for recursive merging
  $media-orig: $media !global;
  $reference: $base;

  @each $m, $medium in $media {

    // merge current medium against ref-medium, normalize primitive values
    $reference: normalize-medium(map-merge($reference, $medium));

    // get and merge sub-maps
    $sizes: map-merge(map-get($reference, 'sizes'), map-get($medium, 'sizes') or ());
    $lines: map-merge(map-get($reference, 'lines'), map-get($medium, 'lines') or ());
    $mults-x: map-merge(map-get($reference, 'mults-x'), map-get($medium, 'mults-x') or ());
    $mults-y: map-merge(map-get($reference, 'mults-y'), map-get($medium, 'mults-y') or ());

    // calc and merge additional props
    $font-size: map-get($reference, 'font-size');
    $margin-x: map-get($reference, 'margin-x');
    $outer-x: map-get($reference, 'outer-right') + map-get($reference, 'outer-left');

    $type-width: map-get($reference, 'type-width');
    $type-columns: map-get($reference, 'type-columns');
    $grid-columns: map-get($reference, 'grid-columns');
    $type-vs-grid: $type-columns/$grid-columns;

    $content-width: ($type-width + $margin-x) / $type-vs-grid - $margin-x;
    $outer-width: $content-width + $outer-x;
    $breakpoint: unit-assert($outer-width * map-get($reference, 'html-scale'), em);

    $reference: map-merge($reference, (
      'content-width': $content-width,
      'breakpoint': $breakpoint,
      'sizes': $sizes,
      'lines': $lines,
      'mults-x': $mults-x,
      'mults-y': $mults-y,
    ));

    // merge reference back to master
    $media: map-merge($media, ($m: $reference)) !global;
  }

  @if $out {
    $globals: if(variable-exists('globals'), $globals, ());
    @include json-content(map-merge($globals, (media: $media)));
    @include media-for(font-size line-height) {
      html { font-size: unit-assert(medium-value('html-scale'), em); }
      body { line-height: medium-value('line-height'); }
    }
  }
}

{'fraction_non_alphanumeric': 0.21132147638171733, 'fraction_numerical': 0.005737234652897304, 'mean_word_length': 3.0323824209714725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5362206', 'n_tokens_mistral': 1855, 'n_tokens_neox': 1785, 'n_words': 396}