<commit_before>var ajax = require('../ajax')
var htmlEncode = require('htmlencode')
var adminUrls = require('../admin-urls')
var cookies = require('../cookies')
var browser = require('../browser')
var getUrlParameter = require('../get-url-parameter')
var Address = require('./Address')
var Service = require('./Service')
var Need = require('./Need')
var ko = require('knockout')
var BaseViewModel = require('./BaseViewModel')

function ServiceProvider (data) {
  var self = this

  self.key = ko.observable(data.key)
  self.name = ko.observable(data.name)
  self.shortDescription = ko.observable(htmlEncode.htmlDecode(data.shortDescription))
  self.description = ko.observable(htmlEncode.htmlDecode(data.description))
  self.telephone = ko.observable(data.telephone)
  self.email = ko.observable(data.email)
  self.website = ko.observable(data.website)
  self.facebook = ko.observable(data.facebook)
  self.twitter = ko.observable(data.twitter)
  data.addresses.forEach((a) => a.serviceProviderId = data.key)
  self.addresses = ko.observableArray(data.addresses.map((a) => new Address(a)))
  self.addresses().forEach((a) => a.addListener(self))

  data.providedServices.forEach((s) => s.serviceProviderId = data.key)
  self.services = ko.observableArray(data.providedServices.map((s) => new Service(s)))
  self.services().forEach((s) => s.addListener(self))

  var buildNeeds = function (needs) {
    return needs !== undefined && needs !== null
    ? needs.map((n) => new Need(n))
    : []
  }

  self.needs = ko.observableArray(buildNeeds(data.needs))
  self.needs().forEach((s) => s.addListener(self))

  self.addAddressUrl = adminUrls.serviceProviderAddressesAdd + '?providerId=' + data.key
  self.amendAddressesUrl = adminUrls.serviceProviderAddresses + '?key=' + data.key

  self.addServiceUrl = adminUrls.serviceProviderServicesAdd + '?providerId=' + data.key
  self.amendServicesUrl = adminUrls.serviceProviderServices + '?providerId=' + data.key

  self.addNeedUrl = adminUrls.serviceProviderNeedsAdd + '?providerId=' + data.key

  self.deleteAddress = function (deletedAddress) {
    var notDeleted = function (address) {<commit_msg>lintin<commit_after>var ajax = require('../ajax')
var htmlEncode = require('htmlencode')
var adminUrls = require('../admin-urls')
var cookies = require('../cookies')
var browser = require('../browser')
var getUrlParameter = require('../get-url-parameter')
var Address = require('./Address')
var Service = require('./Service')
var Need = require('./Need')
var ko = require('knockout')
var BaseViewModel = require('./BaseViewModel')

function ServiceProvider (data) {
  var self = this

  self.key = ko.observable(data.key)
  self.name = ko.observable(data.name)
  self.shortDescription = ko.observable(htmlEncode.htmlDecode(data.shortDescription))
  self.description = ko.observable(htmlEncode.htmlDecode(data.description))
  self.telephone = ko.observable(data.telephone)
  self.email = ko.observable(data.email)
  self.website = ko.observable(data.website)
  self.facebook = ko.observable(data.facebook)
  self.twitter = ko.observable(data.twitter)
  data.addresses.forEach((a) => { a.serviceProviderId = data.key })
  self.addresses = ko.observableArray(data.addresses.map((a) => new Address(a)))
  self.addresses().forEach((a) => a.addListener(self))

  data.providedServices.forEach((s) => { s.serviceProviderId = data.key })
  self.services = ko.observableArray(data.providedServices.map((s) => new Service(s)))
  self.services().forEach((s) => s.addListener(self))

  var buildNeeds = function (needs) {
    return needs !== undefined && needs !== null
    ? needs.map((n) => new Need(n))
    : []
  }

  self.needs = ko.observableArray(buildNeeds(data.needs))
  self.needs().forEach((s) => s.addListener(self))

  self.addAddressUrl = adminUrls.serviceProviderAddressesAdd + '?providerId=' + data.key
  self.amendAddressesUrl = adminUrls.serviceProviderAddresses + '?key=' + data.key

  self.addServiceUrl = adminUrls.serviceProviderServicesAdd + '?providerId=' + data.key
  self.amendServicesUrl = adminUrls.serviceProviderServices + '?providerId=' + data.key

  self.addNeedUrl = adminUrls.serviceProviderNeedsAdd + '?providerId=' + data.key

  self.deleteAddress = function (deletedAddress) {
    var notDeleted = function (address) {
{'fraction_non_alphanumeric': 0.15581992069045952, 'fraction_numerical': 0.0, 'mean_word_length': 4.963838664812239, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, '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': '5503954', 'n_tokens_mistral': 1358, 'n_tokens_neox': 1323, 'n_words': 236}