<commit_before>export default {
  props: [ 'value', 'config' ],
  data() {
    return {
      // boolean internal value cause the real value could be a string when using checkedvalue and uncheckedvalue
      checked: undefined
    }
  },
  mounted() {
    if (this.value === undefined) {
      // if no value, we initialize to false, the the param will be correctly set 
      // i.e. myparam="false" or myparam="0" if uncheckvalue is defined
      let defaultValue = this.config.default || "false"
      let checkedvalue = this.config.checkedvalue || "true"
      this.checked = `${defaultValue}` == `${checkedvalue}`
    }
    else {
      // Cast values to string before compare, because in yaml we might use boolean or number, but
      // wikicode will always use strings
      let checkedvalue = this.config.checkedvalue || "true"
      this.checked = `${this.value}` == `${checkedvalue}`
    }
  },
  watch: {
    checked() {
      let result
      if (this.config.checkedvalue) result = this.checked ? this.config.checkedvalue : this.config.uncheckedvalue
      else result = this.checked
      this.$emit('input', result)
    },
    value() {
      // watch value because it can be affected after mounted
      let checkedvalue = this.config.checkedvalue || "true"
      this.checked = `${this.value}` == `${checkedvalue}`
    }
  },
  template: `
    <div class="form-group input-group checkbox" :title="config.hint" ><commit_msg>fix(InputCheckBox): use the same function to set checked from value<commit_after>export default {
  props: [ 'value', 'config' ],
  data() {
    return {
      // boolean internal value cause the real value could be a string when using checkedvalue and uncheckedvalue
      checked: undefined
    }
  },
  methods: {
    setCheckedFromValue(value){
      if (value === undefined) {
        // if no value, we initialize to false, the the param will be correctly set 
        // i.e. myparam="false" or myparam="0" if uncheckvalue is defined
        let defaultValue = this.config.default || "false"
        let checkedvalue = this.config.checkedvalue || "true"
        this.checked = `${defaultValue}` == `${checkedvalue}`
      }
      else {
        // Cast values to string before compare, because in yaml we might use boolean or number, but
        // wikicode will always use strings
        let checkedvalue = this.config.checkedvalue || "true"
        this.checked = `${value}` == `${checkedvalue}`
      }
    }
  },
  mounted() {
    this.setCheckedFromValue(this.value);
  },
  watch: {
    checked() {
      let result
      if (this.config.checkedvalue) result = this.checked ? this.config.checkedvalue : this.config.uncheckedvalue
      else result = this.checked
      this.$emit('input', result)
    },
    value() {
      // watch value because it can be affected after mounted
      this.setCheckedFromValue(this.value);
    }
  },
  template: `
    <div class="form-group input-group checkbox" :title="config.hint" >
{'fraction_non_alphanumeric': 0.12004034969737727, 'fraction_numerical': 0.0006724949562878278, 'mean_word_length': 2.6910669975186106, 'pattern_counts': {'":': 0, '<': 5, '<?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': '982271', 'n_tokens_mistral': 819, 'n_tokens_neox': 832, 'n_words': 264}