<commit_before>'use strict'

const { Tool } = require('./tool')
const { Editor } = require('./editor')

class RemoveTool extends Tool {
  activate () {
    super.activate()

    this.tempMask = this.editor.mask.clone({ insert: false })
    this.editor.mask.visible = false

    this.tempMask.selected = true
    this.editor.baseLayer.addChild(this.tempMask)
  }

  deactivate () {
    super.deactivate()

    this.editor.mask.visible = true
    Editor.sanitizePond(this.editor.mask)

    const newPond = this.editor.pond.subtract(this.editor.mask)
    this.editor.pond.replaceWith(newPond)
    this.editor.pond = newPond

    if (this.editor.veg.length) {
      this.editor.mergeVegetation()

      const newVeg = this.editor.veg[0].subtract(this.editor.mask)
      this.editor.veg[0].replaceWith(newVeg)
      this.editor.veg[0] = newVeg
    }

    if (this.editor.inlet && this.editor.inlet.intersects(this.editor.mask)) {
      this.editor.inlet.remove()
      this.editor.inlet = undefined
    }

    if (this.editor.outlet && this.editor.outlet.intersects(this.editor.mask)) {
      this.editor.outlet.remove()
      this.editor.outlet = undefined
    }

    this.editor.mask.remove()
    this.tempMask.remove()

    this.tempMask = undefined
    this.editor.mask = Editor.createMask()
  }

  onMouseDown (ev) {
    this.editor.mask.add(ev.point)
  }

  onMouseMove (ev) {
    const moveMask = this.editor.mask.clone({ insert: false })
<commit_msg>valid inlets must intersect pond fixes #32<commit_after>'use strict'

const { Tool } = require('./tool')
const { Editor } = require('./editor')

class RemoveTool extends Tool {
  activate () {
    super.activate()

    this.tempMask = this.editor.mask.clone({ insert: false })
    this.editor.mask.visible = false

    this.tempMask.selected = true
    this.editor.baseLayer.addChild(this.tempMask)
  }

  deactivate () {
    super.deactivate()

    this.editor.mask.visible = true
    Editor.sanitizePond(this.editor.mask)

    const newPond = this.editor.pond.subtract(this.editor.mask)
    this.editor.pond.replaceWith(newPond)
    this.editor.pond = newPond

    if (this.editor.veg.length) {
      this.editor.mergeVegetation()

      const newVeg = this.editor.veg[0].subtract(this.editor.mask)
      this.editor.veg[0].replaceWith(newVeg)
      this.editor.veg[0] = newVeg
    }

    if (this.editor.inlet) {
      if (this.editor.inlet.intersects(this.editor.mask)) {
        this.editor.inlet.remove()
        this.editor.inlet = undefined
      }

      if (!this.editor.inlet.intersects(this.editor.pond)) {
        this.editor.inlet.remove()
        this.editor.inlet = undefined
      }
    }

    if (this.editor.outlet) {
      if (this.editor.outlet.intersects(this.editor.mask)) {
        this.editor.outlet.remove()
        this.editor.outlet = undefined
      }

      if (!this.editor.outlet.intersects(this.editor.pond)) {
        this.editor.outlet.remove()
        this.editor.outlet = undefined
      }
    }

    this.editor.mask.remove()
    this.tempMask.remove()

    this.tempMask = undefined
    this.editor.mask = Editor.createMask()
  }

  onMouseDown (ev) {
    this.editor.mask.add(ev.point)
  }

  onMouseMove (ev) {
    const moveMask = this.editor.mask.clone({ insert: false })

{'fraction_non_alphanumeric': 0.1386168910648715, 'fraction_numerical': 0.0024479804161566705, 'mean_word_length': 2.736, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6054130', 'n_tokens_mistral': 1125, 'n_tokens_neox': 1094, 'n_words': 160}