<commit_before>/**
 * @license
 * Copyright 2014 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

function factorial(n) {
  if ( n > 170 ) return 1/0;
  var r = 1;
  while ( n > 0 ) r *= n--;
  return r;
};
function permutation(n, r) { return factorial(n) / factorial(n-r); };
function combination(n, r) { return permutation(n, r) / factorial(r); };

function trigFn(f) {
  return function(a) {
    return f(this.degreesMode ? a * Math.PI / 180 : a);
  };
}

function invTrigFn(f) {
  return function(a) {
    return this.degreesMode ? f(a) / Math.PI * 180 : f(a);
  };
}

/** Make a Binary Action. **/
function binaryOp(name, keys, f, sym) {
  f.toString = function() { return sym; };
  return {
    name: name,
    label: sym,
    keyboardShortcuts: keys,
    action: function() {
      if ( this.op != DEFAULT_OP ) this.equals();
      this.push('', f);
      this.editable = true;
    }
  };
}

function unaryOp(name, keys, f, opt_sym) {
  var sym = opt_sym || name;
  f.toString = function() { return sym; };

  return {
    name: name,
    label: sym,
    keyboardShortcuts: keys,
    action: function() {
      this.op = f;
      this.push(f.call(this, this.a2));
      this.editable = false;
    }
  };
}

/** Make a 0-9 Number Action. **/
function num(n) {
  return {
    name: n.toString(),
    keyboardShortcuts: [48+n /* 0 */ , 96+n /* keypad-0 */],
    action: function() {
      if ( ! this.editable ) {
        this.push(n);
        this.editable = true;
      } else {
        if ( this.a2 == '0' && ! n ) return;
        this.a2 = this.a2 == '0' ? n : this.a2.toString() + n;
      }
    }
  };
}


var DEFAULT_OP = function(a1, a2) { return a2; };
DEFAULT_OP.toString = function() { return ''; };


/** A subclass of FloatFieldView which doesn't display 0 values. **/
CLASS({
  name:  'CalcFloatFieldView',
  extendsModel: 'FloatFieldView',
  methods: { valueToText: function(v) { return v == 0 ? '' : v.toString(); } }
});


CLASS({ name: 'History', properties: [ 'op', 'a2' ] });


CLASS({
  name: 'Calc',

  requires: [ 'CalcView' ],

  templates: [ function CSS() {/*
    body {
      font-family: Roboto, 'Helvetica Neue', Helvetica, Arial;
      font-size: 28px;
      margin: 0;
    }

    * {
      box-sizing: border-box;
    }

    html {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
    }

    body {
      margin: 0px;
      padding: 0px;
      width: 100%;
      height: 100%;
      font-weight: 300;
    }

    ::-webkit-scrollbar {
      display: none;
    }

    ::-webkit-scrollbar-thumb {
      display: none;
    }

    .calc {
      background-color: #eee;
      border: 0;
      margin: 0;
      padding: 0px;
      display: flex;
      flex-direction: column;
      height: 100%;
    }

    .calc-display, .calc-display:focus {
      border: none;
      letter-spacing: 1px;
      line-height: 36px;
      margin: 0;
      min-width: 204px;
      overflow: scroll;
      padding: 0 25pt 2pt 25pt;
      text-align: right;
    }

    .edge {
      background: linear-gradient(to bottom, rgba(240,240,240,1) 0%,
                                             rgba(240,240,240,0) 100%);
      height: 20px;
      position: absolute;
      top: 5px;
      width: 100%;
      z-index: 99;
    }

    .edge2 {
      background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%,
                                             rgba(0,0,0,0) 100%);<commit_msg>ACalc: Fix position of top edge.<commit_after>/**
 * @license
 * Copyright 2014 Google Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

function factorial(n) {
  if ( n > 170 ) return 1/0;
  var r = 1;
  while ( n > 0 ) r *= n--;
  return r;
};
function permutation(n, r) { return factorial(n) / factorial(n-r); };
function combination(n, r) { return permutation(n, r) / factorial(r); };

function trigFn(f) {
  return function(a) {
    return f(this.degreesMode ? a * Math.PI / 180 : a);
  };
}

function invTrigFn(f) {
  return function(a) {
    return this.degreesMode ? f(a) / Math.PI * 180 : f(a);
  };
}

/** Make a Binary Action. **/
function binaryOp(name, keys, f, sym) {
  f.toString = function() { return sym; };
  return {
    name: name,
    label: sym,
    keyboardShortcuts: keys,
    action: function() {
      if ( this.op != DEFAULT_OP ) this.equals();
      this.push('', f);
      this.editable = true;
    }
  };
}

function unaryOp(name, keys, f, opt_sym) {
  var sym = opt_sym || name;
  f.toString = function() { return sym; };

  return {
    name: name,
    label: sym,
    keyboardShortcuts: keys,
    action: function() {
      this.op = f;
      this.push(f.call(this, this.a2));
      this.editable = false;
    }
  };
}

/** Make a 0-9 Number Action. **/
function num(n) {
  return {
    name: n.toString(),
    keyboardShortcuts: [48+n /* 0 */ , 96+n /* keypad-0 */],
    action: function() {
      if ( ! this.editable ) {
        this.push(n);
        this.editable = true;
      } else {
        if ( this.a2 == '0' && ! n ) return;
        this.a2 = this.a2 == '0' ? n : this.a2.toString() + n;
      }
    }
  };
}


var DEFAULT_OP = function(a1, a2) { return a2; };
DEFAULT_OP.toString = function() { return ''; };


/** A subclass of FloatFieldView which doesn't display 0 values. **/
CLASS({
  name:  'CalcFloatFieldView',
  extendsModel: 'FloatFieldView',
  methods: { valueToText: function(v) { return v == 0 ? '' : v.toString(); } }
});


CLASS({ name: 'History', properties: [ 'op', 'a2' ] });


CLASS({
  name: 'Calc',

  requires: [ 'CalcView' ],

  templates: [ function CSS() {/*
    body {
      font-family: Roboto, 'Helvetica Neue', Helvetica, Arial;
      font-size: 28px;
      margin: 0;
    }

    * {
      box-sizing: border-box;
    }

    html {
      margin: 0;
      padding: 0;
      width: 100%;
      height: 100%;
      overflow: hidden;
    }

    body {
      margin: 0px;
      padding: 0px;
      width: 100%;
      height: 100%;
      font-weight: 300;
    }

    ::-webkit-scrollbar {
      display: none;
    }

    ::-webkit-scrollbar-thumb {
      display: none;
    }

    .calc {
      background-color: #eee;
      border: 0;
      margin: 0;
      padding: 0px;
      display: flex;
      flex-direction: column;
      height: 100%;
    }

    .calc-display, .calc-display:focus {
      border: none;
      letter-spacing: 1px;
      line-height: 36px;
      margin: 0;
      min-width: 204px;
      overflow: scroll;
      padding: 0 25pt 2pt 25pt;
      text-align: right;
    }

    .edge {
      background: linear-gradient(to bottom, rgba(240,240,240,1) 0%,
                                             rgba(240,240,240,0) 100%);
      height: 20px;
      position: absolute;
      top: 0;
      width: 100%;
      z-index: 99;
    }

    .edge2 {
      background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%,
                                             rgba(0,0,0,0) 100%);
{'fraction_non_alphanumeric': 0.14677520350657483, 'fraction_numerical': 0.03231058234189105, 'mean_word_length': 2.172824791418355, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1310065', 'n_tokens_mistral': 2922, 'n_tokens_neox': 2654, 'n_words': 756}